Commit f5e17aed authored by Jeff Layton's avatar Jeff Layton Committed by Ilya Dryomov

ceph: track primary dentry link

Newer versions of the MDS will flag a dentry as "primary". In later
patches, we'll need to consult this info, so track it in di->flags.
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Reviewed-by: default avatar"Yan, Zheng" <zyan@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 3bb48b41
...@@ -1411,6 +1411,7 @@ void ceph_invalidate_dentry_lease(struct dentry *dentry) ...@@ -1411,6 +1411,7 @@ void ceph_invalidate_dentry_lease(struct dentry *dentry)
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
di->time = jiffies; di->time = jiffies;
di->lease_shared_gen = 0; di->lease_shared_gen = 0;
di->flags &= ~CEPH_DENTRY_PRIMARY_LINK;
__dentry_lease_unlist(di); __dentry_lease_unlist(di);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
} }
......
...@@ -1051,6 +1051,7 @@ static void __update_dentry_lease(struct inode *dir, struct dentry *dentry, ...@@ -1051,6 +1051,7 @@ static void __update_dentry_lease(struct inode *dir, struct dentry *dentry,
struct ceph_mds_session **old_lease_session) struct ceph_mds_session **old_lease_session)
{ {
struct ceph_dentry_info *di = ceph_dentry(dentry); struct ceph_dentry_info *di = ceph_dentry(dentry);
unsigned mask = le16_to_cpu(lease->mask);
long unsigned duration = le32_to_cpu(lease->duration_ms); long unsigned duration = le32_to_cpu(lease->duration_ms);
long unsigned ttl = from_time + (duration * HZ) / 1000; long unsigned ttl = from_time + (duration * HZ) / 1000;
long unsigned half_ttl = from_time + (duration * HZ / 2) / 1000; long unsigned half_ttl = from_time + (duration * HZ / 2) / 1000;
...@@ -1062,8 +1063,13 @@ static void __update_dentry_lease(struct inode *dir, struct dentry *dentry, ...@@ -1062,8 +1063,13 @@ static void __update_dentry_lease(struct inode *dir, struct dentry *dentry,
if (ceph_snap(dir) != CEPH_NOSNAP) if (ceph_snap(dir) != CEPH_NOSNAP)
return; return;
if (mask & CEPH_LEASE_PRIMARY_LINK)
di->flags |= CEPH_DENTRY_PRIMARY_LINK;
else
di->flags &= ~CEPH_DENTRY_PRIMARY_LINK;
di->lease_shared_gen = atomic_read(&ceph_inode(dir)->i_shared_gen); di->lease_shared_gen = atomic_read(&ceph_inode(dir)->i_shared_gen);
if (duration == 0) { if (!(mask & CEPH_LEASE_VALID)) {
__ceph_dentry_dir_lease_touch(di); __ceph_dentry_dir_lease_touch(di);
return; return;
} }
......
...@@ -284,6 +284,7 @@ struct ceph_dentry_info { ...@@ -284,6 +284,7 @@ struct ceph_dentry_info {
#define CEPH_DENTRY_REFERENCED 1 #define CEPH_DENTRY_REFERENCED 1
#define CEPH_DENTRY_LEASE_LIST 2 #define CEPH_DENTRY_LEASE_LIST 2
#define CEPH_DENTRY_SHRINK_LIST 4 #define CEPH_DENTRY_SHRINK_LIST 4
#define CEPH_DENTRY_PRIMARY_LINK 8
struct ceph_inode_xattrs_info { struct ceph_inode_xattrs_info {
/* /*
......
...@@ -531,6 +531,9 @@ struct ceph_mds_reply_lease { ...@@ -531,6 +531,9 @@ struct ceph_mds_reply_lease {
__le32 seq; __le32 seq;
} __attribute__ ((packed)); } __attribute__ ((packed));
#define CEPH_LEASE_VALID (1 | 2) /* old and new bit values */
#define CEPH_LEASE_PRIMARY_LINK 4 /* primary linkage */
struct ceph_mds_reply_dirfrag { struct ceph_mds_reply_dirfrag {
__le32 frag; /* fragment */ __le32 frag; /* fragment */
__le32 auth; /* auth mds, if this is a delegation point */ __le32 auth; /* auth mds, if this is a delegation point */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment