From 844186f8ac655d56be969bdac56ac350c5a669d6 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 11 Jul 2011 11:35:15 -0700 Subject: [PATCH] mds: only issue xlocker_caps if we are also the loner We cannot issue caps to a client purely because they have something xlocked, because we do not revoke caps when we drop the xlock. However, if they are a loner AND have the object xlocked, we can; this is why the xlock release code either moves to LOCK or EXCL state. Remember, the goal here is to issue caps when we do operations on objects that xlock them (e.g. setattr, mknod) and move directly to the EXCL state afterward. That only works (or makes sense) when we are the lone client with caps. Fix the get_caps_allowed_by_type() helper to do this properly. Signed-off-by: Sage Weil --- src/mds/CInode.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mds/CInode.h b/src/mds/CInode.h index efd4514d7476e..6622a69fd87b9 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -972,8 +972,15 @@ public: (linklock.gcaps_xlocker_mask(client) << linklock.get_cap_shift()); } int get_caps_allowed_for_client(client_t client) { - int allowed = get_caps_allowed_by_type(client == get_loner() ? CAP_LONER : CAP_ANY); - allowed |= get_caps_allowed_by_type(CAP_XLOCKER) & get_xlocker_mask(client); + int allowed; + if (client == get_loner()) { + // as the loner, we get the loner_caps AND any xlocker_caps for things we have xlocked + allowed = + get_caps_allowed_by_type(CAP_LONER) | + (get_caps_allowed_by_type(CAP_XLOCKER) & get_xlocker_mask(client)); + } else { + allowed = get_caps_allowed_by_type(CAP_ANY); + } return allowed; } -- 2.39.5