r = fd;
goto out;
}
- ::ftruncate(fd, f.length); // in case there is trailing crap
+ r = _clean_fid_tail_fd(f, fd); // in case there is trailing crap
+ if (r < 0) {
+ goto out;
+ }
f.length = (offset + length) - f.offset;
x_offset = offset - f.offset;
dout(20) << __func__ << " append " << f.fid << " writing "
return r;
}
-int NewStore::_clean_fid_tail(TransContext *txc, const fragment_t& f)
+int NewStore::_clean_fid_tail_fd(const fragment_t& f, int fd)
{
- int fd = _open_fid(f.fid, O_RDWR);
- if (fd < 0) {
- return fd;
- }
struct stat st;
int r = ::fstat(fd, &st);
if (r < 0) {
<< cpp_strerror(r) << dendl;
return r;
}
+ return 1;
+ }
+ return 0;
+}
+
+int NewStore::_clean_fid_tail(TransContext *txc, const fragment_t& f)
+{
+ int fd = _open_fid(f.fid, O_RDWR);
+ if (fd < 0) {
+ return fd;
+ }
+ int r = _clean_fid_tail_fd(f, fd);
+ if (r < 0) {
+ return r;
+ }
+ if (r > 0) {
txc->sync_fd(fd);
} else {
// all good!
int _recover_next_nid();
void _assign_nid(TransContext *txc, OnodeRef o);
+ int _clean_fid_tail_fd(const fragment_t& f, int fd);
int _clean_fid_tail(TransContext *txc, const fragment_t& f);
TransContext *_txc_create(OpSequencer *osr);