From e0442508e7f78fb5d36851a4503af43e4e640bd6 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 18 Mar 2009 10:44:25 -0700 Subject: [PATCH] kclient: handle cap renew message --- src/kernel/caps.c | 32 ++++++++++++++++++++++++++++++++ src/kernel/super.h | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/kernel/caps.c b/src/kernel/caps.c index 7a6680ff69fa5..36e52bf8d604a 100644 --- a/src/kernel/caps.c +++ b/src/kernel/caps.c @@ -1036,6 +1036,7 @@ int __ceph_check_cap_maybe_renew(struct ceph_inode_info *ci, int mask) " (%lu <= %lu)\n", inode, cap, cap->renew_after, jiffies); cap->renew_after = 0; + cap->renew_from = jiffies; __send_cap(&ceph_client(inode->i_sb)->mdsc, cap, CEPH_CAP_OP_RENEW, 0, 0, cap->issued); goto out; @@ -1501,6 +1502,33 @@ start: return reply; } +/* + * Handle a cap renewal from the MDS. This is only useful on + * rdcap (readonly, expireable) caps. + */ +static void handle_cap_renew(struct inode *inode, + struct ceph_mds_caps *m, + struct ceph_mds_session *session, + struct ceph_cap *cap) + __releases(inode->i_lock) +{ + struct ceph_inode_info *ci = ceph_inode(inode); + + if (cap->renew_from && cap->renew_after == 0) { + unsigned duration = le32_to_cpu(m->ttl_ms) * HZ / 1000; + + cap->expires = cap->renew_from + duration; + cap->renew_after = cap->renew_from + (duration >> 1); + cap->renew_from = 0; + dout(20, "cap_renew %p %p duration %u\n", inode, cap, duration); + __adjust_cap_rdcaps_listing(ci, cap, __ceph_caps_wanted(ci)); + } else { + dout(20, "cap_renew %p %p not renewing (after=%lu from=%lu)\n", + inode, cap, cap->renew_after, cap->renew_from); + } + spin_unlock(&inode->i_lock); +} + /* * Handle FLUSH_ACK from MDS, indicating that metadata we sent to the * MDS has been safely recorded. @@ -1822,6 +1850,10 @@ void ceph_handle_caps(struct ceph_mds_client *mdsc, } break; + case CEPH_CAP_OP_RENEW: + handle_cap_renew(inode, h, session, cap); + break; + case CEPH_CAP_OP_FLUSH_ACK: handle_cap_flush_ack(inode, h, session, cap); if (list_empty(&session->s_caps)) diff --git a/src/kernel/super.h b/src/kernel/super.h index d4c9f2a15560f..28e50e6d9c219 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -149,7 +149,7 @@ struct ceph_cap { int mds_wanted; u32 seq, mseq, gen; unsigned long expires; /* if readonly and unwanted (jiffies) */ - unsigned long renew_after; /* if readonly and unwanted (jiffies) */ + unsigned long renew_after, renew_from; /* for _rdcap_ renewal */ }; /* -- 2.39.5