]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: keep track of which cap is authoritative
authorSage Weil <sage@newdream.net>
Mon, 30 Mar 2009 17:10:05 +0000 (10:10 -0700)
committerSage Weil <sage@newdream.net>
Mon, 30 Mar 2009 17:10:05 +0000 (10:10 -0700)
src/include/ceph_fs.h
src/kernel/caps.c
src/kernel/inode.c
src/kernel/super.h
src/mds/CInode.cc

index 8d28bbc661d0db0c0c98737d39bdb8452cca74d3..ee5ac7a73e8e82bef95d14550c1d555b600cab3b 100644 (file)
@@ -871,8 +871,11 @@ struct ceph_mds_reply_cap {
        __le32 seq, mseq;
        __le64 realm;
        __le32 ttl_ms;  /* ttl, in ms.  if readonly and unwanted. */
+       __u8 flags;
 } __attribute__ ((packed));
 
+#define CEPH_CAP_FLAG_AUTH  1
+
 struct ceph_mds_reply_inode {
        __le64 ino;
        __le64 snapid;
index c2ddd2dad129edf68a417a8f333b0d75e22ee9ac..90e411bdbbce8f08b3cfe5132f1f0d28bec9b5cd 100644 (file)
@@ -254,7 +254,7 @@ int ceph_add_cap(struct inode *inode,
                 struct ceph_mds_session *session, u64 cap_id,
                 int fmode, unsigned issued, unsigned wanted,
                 unsigned seq, unsigned mseq, u64 realmino,
-                unsigned ttl_ms, unsigned long ttl_from,
+                unsigned ttl_ms, unsigned long ttl_from, int flags,
                 struct ceph_cap *new_cap)
 {
        struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc;
@@ -340,6 +340,11 @@ retry:
                ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
        }
 
+       if (flags & CEPH_CAP_FLAG_AUTH)
+               ci->i_auth_cap = cap;
+       else if (ci->i_auth_cap == cap)
+               ci->i_auth_cap = NULL;
+
        /*
         * Ensure our rdcaps status is correct
         */
@@ -536,6 +541,8 @@ static int __ceph_remove_cap(struct ceph_cap *cap)
        /* remove from inode list */
        rb_erase(&cap->ci_node, &ci->i_caps);
        cap->session = NULL;
+       if (ci->i_auth_cap == cap)
+               ci->i_auth_cap = NULL;
 
        kfree(cap);
 
@@ -1774,7 +1781,7 @@ static void handle_cap_import(struct ceph_mds_client *mdsc,
        downgrade_write(&mdsc->snap_rwsem);
        ceph_add_cap(inode, session, cap_id, -1,
                     issued, wanted, seq, mseq, realmino,
-                    ttl_ms, jiffies - ttl_ms/2, NULL);
+                    ttl_ms, jiffies - ttl_ms/2, CEPH_CAP_FLAG_AUTH, NULL);
        up_read(&mdsc->snap_rwsem);
 }
 
index 6ab193327655a0e7ca8acd05b2272aa87a6df788..ebdb20bea50c5d9b75228818eadac7b678cf86a3 100644 (file)
@@ -258,6 +258,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
        ci->i_xattr_data = NULL;
 
        ci->i_caps = RB_ROOT;
+       ci->i_auth_cap = NULL;
        ci->i_dirty_caps = 0;
        init_waitqueue_head(&ci->i_cap_wq);
        ci->i_hold_caps_until = 0;
@@ -571,6 +572,7 @@ no_change:
                                     le64_to_cpu(info->cap.realm),
                                     le32_to_cpu(info->cap.ttl_ms),
                                     ttl_from,
+                                    info->cap.flags,
                                     NULL);
                } else {
                        spin_lock(&inode->i_lock);
index 3df1e85dce43d027f4e225abfc4487ec51f21e88..79e779d3abef6f1ffd0b9723a3ff525787dc00ce 100644 (file)
@@ -257,6 +257,7 @@ struct ceph_inode_info {
        /* capabilities.  protected _both_ by i_lock and cap->session's
         * s_mutex. */
        struct rb_root i_caps;           /* cap list */
+       struct ceph_cap *i_auth_cap;     /* authoritative cap, if any */
        unsigned i_dirty_caps;           /* mask of dirtied fields */
        wait_queue_head_t i_cap_wq;      /* threads waiting on a capability */
        unsigned long i_hold_caps_until; /* jiffies */
@@ -732,7 +733,7 @@ extern int ceph_add_cap(struct inode *inode,
                        struct ceph_mds_session *session, u64 cap_id,
                        int fmode, unsigned issued, unsigned wanted,
                        unsigned cap, unsigned seq, u64 realmino,
-                       unsigned ttl_ms, unsigned long ttl_from,
+                       unsigned ttl_ms, unsigned long ttl_from, int flags,
                        struct ceph_cap *new_cap);
 extern void ceph_remove_cap(struct ceph_cap *cap);
 extern int ceph_get_cap_mds(struct inode *inode);
index fdf1142c381fa80ba8802c850bccd66a10e4b63c..9dce70c7f45def779425159fafd48e22df8d13bf 100644 (file)
@@ -1492,6 +1492,7 @@ bool CInode::encode_inodestat(bufferlist& bl, Session *session,
       e.cap.ttl_ms = 0;
     }
   }
+  e.cap.flags = is_auth() ? CEPH_CAP_FLAG_AUTH:0;
   dout(10) << "encode_inodestat caps " << ccap_string(e.cap.caps)
           << " seq " << e.cap.seq
           << " mseq " << e.cap.mseq << dendl;