From: "Yan, Zheng" <[email protected]>

When checking if inode's SnapRealm is different from readdir
SnapRealm, we should use find_snaprealm() to get inode's SnapRealm.
Without this fix, I got lots of "ceph_add_cap: couldn't find snap
realm 100" from kernel client.

Signed-off-by: Yan, Zheng <[email protected]>
---
 src/mds/CInode.cc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc
index 8566e55..c129308 100644
--- a/src/mds/CInode.cc
+++ b/src/mds/CInode.cc
@@ -2554,7 +2554,7 @@ void CInode::replicate_relax_locks()
 // =============================================
 
 int CInode::encode_inodestat(bufferlist& bl, Session *session,
-                             SnapRealm *realm,
+                             SnapRealm *dir_realm,
                              snapid_t snapid, unsigned max_bytes)
 {
   int client = session->inst.name.num();
@@ -2565,7 +2565,8 @@ int CInode::encode_inodestat(bufferlist& bl, Session 
*session,
   bool valid = true;
 
   // do not issue caps if inode differs from readdir snaprealm
-  bool no_caps = (realm && snaprealm && realm != snaprealm);
+  SnapRealm *realm = find_snaprealm();
+  bool no_caps = (realm && dir_realm && realm != dir_realm);
   if (no_caps)
     dout(20) << "encode_inodestat realm=" << realm << " snaprealm " << 
snaprealm
             << " no_caps=" << no_caps << dendl;
@@ -2724,7 +2725,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session 
*session,
   } else {
     if (!no_caps && valid && !cap) {
       // add a new cap
-      cap = add_client_cap(client, session, find_snaprealm());
+      cap = add_client_cap(client, session, realm);
       if (is_auth()) {
        if (choose_ideal_loner() >= 0)
          try_set_loner();
@@ -2747,7 +2748,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session 
*session,
       e.cap.seq = cap->get_last_seq();
       dout(10) << "encode_inodestat issueing " << ccap_string(issue) << " seq 
" << cap->get_last_seq() << dendl;
       e.cap.mseq = cap->get_mseq();
-      e.cap.realm = find_snaprealm()->inode->ino();
+      e.cap.realm = realm->inode->ino();
     } else {
       e.cap.cap_id = 0;
       e.cap.caps = 0;
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to