]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: hold Fcr caps during readahead
authorYan, Zheng <zheng.z.yan@intel.com>
Thu, 3 Apr 2014 22:49:49 +0000 (06:49 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Fri, 4 Apr 2014 16:47:51 +0000 (00:47 +0800)
Fcr caps prevent the file from being truncated.

Fixes: #7958
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/client/Client.cc
src/client/Client.h

index 14271499ec0101145d0a670021c0bfc0212d4817..137d0b31b11d6ed54ee2a9b9d33177859e99cc76 100644 (file)
@@ -6206,7 +6206,7 @@ int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl)
                                        NULL, 0, onfinish);
        if (r == 0) {
          ldout(cct, 20) << "readahead initiated, c " << onfinish << dendl;
-         in->get();
+         get_cap_ref(in, CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE);
        } else {
          ldout(cct, 20) << "readahead was no-op, already cached" << dendl;
          delete onfinish;
@@ -6224,12 +6224,14 @@ int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl)
   r = objectcacher->file_read(&in->oset, &in->layout, in->snapid,
                              off, len, bl, 0, onfinish);
   if (r == 0) {
+    get_cap_ref(in, CEPH_CAP_FILE_CACHE);
     client_lock.Unlock();
     flock.Lock();
     while (!done)
       cond.Wait(flock);
     flock.Unlock();
     client_lock.Lock();
+    put_cap_ref(in, CEPH_CAP_FILE_CACHE);
     r = rvalue;
   } else {
     // it was cached.
index 80b12d9837d6f31397c81bf4236f54703333164d..df13b6febfc5b2c0790c64f010ff4250f895f6a7 100644 (file)
@@ -566,7 +566,7 @@ private:
        inode(i) { }
     void finish(int r) {
       lsubdout(client->cct, client, 20) << "C_Readahead on " << inode << dendl;
-      client->put_inode(inode, 1);
+      client->put_cap_ref(inode, CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE);
     }
   };