]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: do not move f->pos untill success write 25684/head
authorTang Junhui <tangjunhui@sangfor.com>
Thu, 15 Nov 2018 07:07:24 +0000 (15:07 +0800)
committerJos Collin <jcollin@redhat.com>
Sat, 22 Dec 2018 04:41:02 +0000 (10:11 +0530)
writes maybe failed in Client::_write, so do not move f->pos when write
successfully.

Signed-off-by: Junhui Tang <tangjunhui@sangfor.com.cn>
Fixes: https://tracker.ceph.com/issues/37546
(cherry picked from commit 0fdfc0c5bcda7bd64511365011163f8c74e18d9b)

src/client/Client.cc

index fc99ad53bef945acddac43cc971a78a4e17319bf..e0097777de6dbb1e58c0e34dc3ebad6cadce1b04 100644 (file)
@@ -9196,6 +9196,8 @@ int Client::_preadv_pwritev(int fd, const struct iovec *iov, unsigned iovcnt, in
 int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
                   const struct iovec *iov, int iovcnt)
 {
+  uint64_t fpos = 0;
+
   if ((uint64_t)(offset+size) > mdsmap->get_max_filesize()) //too large!
     return -EFBIG;
 
@@ -9235,7 +9237,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
       }
     }
     offset = f->pos;
-    f->pos = offset+size;
+    fpos = offset+size;
     unlock_fh_pos(f);
   }
 
@@ -9385,6 +9387,11 @@ success:
   lat -= start;
   logger->tinc(l_c_wrlat, lat);
 
+  if (fpos) {
+    lock_fh_pos(f);
+    f->pos = fpos;
+    unlock_fh_pos(f);
+  }
   totalwritten = size;
   r = (int)totalwritten;