]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: do async wanted adjustment on open if we hold any caps
authorSage Weil <sage@newdream.net>
Mon, 30 Mar 2009 20:09:30 +0000 (13:09 -0700)
committerSage Weil <sage@newdream.net>
Mon, 30 Mar 2009 20:12:42 +0000 (13:12 -0700)
src/kernel/caps.c
src/kernel/file.c
src/kernel/super.h

index 15585b158d036f1d0b2ec50ccd1540d7705c02f0..17c7ebab3b3326c0a13812d15959472d0cf242a4 100644 (file)
@@ -965,6 +965,10 @@ retry_locked:
                if (!revoking && mdsc->stopping && (used == 0))
                        goto ack;
 
+               /* want more caps from mds? */
+               if (want & ~cap->mds_wanted)
+                       goto ack;
+
                if ((cap->issued & ~retain) == 0 &&
                    cap->mds_wanted == want)
                        continue;     /* nothing extra, wanted is correct */
index a91d6b93e11e390e1b8619efd2a8dd21fc23d0d5..d719233ae1e3e8339ba3ca9885407c3f07662936 100644 (file)
@@ -96,7 +96,7 @@ int ceph_open(struct inode *inode, struct file *file)
        struct ceph_file_info *cf = file->private_data;
        struct inode *parent_inode = file->f_dentry->d_parent->d_inode;
        int err;
-       int flags, fmode, mds_wanted, new_want;
+       int flags, fmode, new_want;
 
        if (ceph_snap(inode) != CEPH_NOSNAP && (file->f_mode & FMODE_WRITE))
                return -EROFS;
@@ -122,19 +122,26 @@ int ceph_open(struct inode *inode, struct file *file)
         * registered with the MDS.
         */
        spin_lock(&inode->i_lock);
-       mds_wanted = __ceph_caps_mds_wanted(ci);
-       if ((mds_wanted & new_want) == new_want ||
-           ceph_snap(inode) == CEPH_SNAPDIR) {
+       if (__ceph_is_any_real_caps(ci)) {
+               int mds_wanted = __ceph_caps_mds_wanted(ci);
+               int issued = __ceph_caps_issued(ci, NULL);
+
                dout(10, "open fmode %d caps %d using existing on %p\n",
                     fmode, new_want, inode);
                __ceph_get_fmode(ci, fmode);
                spin_unlock(&inode->i_lock);
+               
+               /* adjust wanted? */
+               if ((issued & new_want) != new_want &&
+                   (mds_wanted & new_want) != new_want &&
+                   ceph_snap(inode) != CEPH_SNAPDIR)
+                       ceph_check_caps(ci, 0, 0, NULL);
+
                return ceph_init_file(inode, file, fmode);
        }
        spin_unlock(&inode->i_lock);
 
-       dout(10, "open fmode %d wants %s, we only already want %s\n",
-            fmode, ceph_cap_string(new_want), ceph_cap_string(mds_wanted));
+       dout(10, "open fmode %d wants %s\n", fmode, ceph_cap_string(new_want));
        if (!ceph_caps_issued_mask(ceph_inode(inode), CEPH_CAP_FILE_EXCL))
                ceph_release_caps(inode, CEPH_CAP_FILE_RDCACHE);
        req = prepare_open_request(inode->i_sb, flags, 0);
index d22743cc3fdd6f7040be679dee544015b8f5f4a5..59fcd1dacdd043b4fade8d69f940cc765cbdcf76 100644 (file)
@@ -442,6 +442,11 @@ static inline struct inode *ceph_find_inode(struct super_block *sb,
 /*
  * caps helpers
  */
+static inline bool __ceph_is_any_real_caps(struct ceph_inode_info *ci)
+{
+       return !RB_EMPTY_ROOT(&ci->i_caps);
+}
+
 extern int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented);
 
 static inline int ceph_caps_issued(struct ceph_inode_info *ci)
@@ -745,7 +750,6 @@ extern void __ceph_flush_snaps(struct ceph_inode_info *ci,
 extern void ceph_check_caps(struct ceph_inode_info *ci, int delayed, int drop,
                            struct ceph_mds_session *session);
 extern void ceph_check_delayed_caps(struct ceph_mds_client *mdsc);
-extern int __ceph_check_cap_maybe_renew(struct ceph_inode_info *ci, int mask);
 
 void ceph_trim_session_clean_caps(struct ceph_mds_session *session);