ceph: don't include used caps in cap_wanted
authorYan, Zheng <zyan@redhat.com>
Mon, 25 May 2015 09:36:42 +0000 (17:36 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 25 Jun 2015 08:49:30 +0000 (11:49 +0300)
when copying files to cephfs, file data may stay in page cache after
corresponding file is closed. Cached data use Fc capability. If we
include Fc capability in cap_wanted, MDS will treat files with cached
data as open files, and journal them in an EOpen event when trimming
log segment.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
fs/ceph/caps.c

index 245ca381a6dc2b1d2573433ae6ad239b4ba48470..a80a899e5c41db40ca0bfdb0feedc90d24bdc696 100644 (file)
@@ -1525,13 +1525,13 @@ retry:
 retry_locked:
        file_wanted = __ceph_caps_file_wanted(ci);
        used = __ceph_caps_used(ci);
-       want = file_wanted | used;
        issued = __ceph_caps_issued(ci, &implemented);
        revoking = implemented & ~issued;
 
-       retain = want | CEPH_CAP_PIN;
+       want = file_wanted;
+       retain = file_wanted | used | CEPH_CAP_PIN;
        if (!mdsc->stopping && inode->i_nlink > 0) {
-               if (want) {
+               if (file_wanted) {
                        retain |= CEPH_CAP_ANY;       /* be greedy */
                } else if (S_ISDIR(inode->i_mode) &&
                           (issued & CEPH_CAP_FILE_SHARED) &&