]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: add unlock_fh_pos when abort
authorhuanwen ren <rhwlyw@163.com>
Tue, 27 Jun 2017 09:18:53 +0000 (17:18 +0800)
committerGitHub <noreply@github.com>
Tue, 27 Jun 2017 09:18:53 +0000 (17:18 +0800)
add unlock_fh_pos when abort

Signed-off-by: huanwen ren <ren.huanwen@zte.com.cn>
src/client/Client.cc

index cbb216aa76822c2540782295ef1913dd9149786a..b8d902b61d8a7e78972106b6f03080092a15e0f8 100644 (file)
@@ -8444,17 +8444,22 @@ int Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl)
 
   if (in->inline_version == 0) {
     int r = _getattr(in, CEPH_STAT_CAP_INLINE_DATA, f->actor_perms, true);
-    if (r < 0)
+    if (r < 0) {
+      if (movepos)
+        unlock_fh_pos(f);
       return r;
+    }
     assert(in->inline_version > 0);
   }
 
 retry:
   int have;
   int r = get_caps(in, CEPH_CAP_FILE_RD, CEPH_CAP_FILE_CACHE, &have, -1);
-  if (r < 0)
+  if (r < 0) {
+    if (movepos)
+        unlock_fh_pos(f);
     return r;
-
+  }
   if (f->flags & O_DIRECT)
     have &= ~CEPH_CAP_FILE_CACHE;
 
@@ -8556,7 +8561,12 @@ done:
 
   if (have)
     put_cap_ref(in, CEPH_CAP_FILE_RD);
-  return r < 0 ? r : bl->length();
+  if (r < 0) {
+    if (movepos)
+        unlock_fh_pos(f);
+    return r;
+  } else
+    return bl->length();
 }
 
 Client::C_Readahead::C_Readahead(Client *c, Fh *f) :