Skip to content

Commit 5eed80f

Browse files
lxbszidryomov
authored andcommitted
ceph: try to choose the auth MDS if possible for getattr
If any 'x' caps is issued we can just choose the auth MDS instead of the random replica MDSes. Because only when the Locker is in LOCK_EXEC state will the loner client could get the 'x' caps. And if we send the getattr requests to any replica MDS it must auth pin and tries to rdlock from the auth MDS, and then the auth MDS need to do the Locker state transition to LOCK_SYNC. And after that the lock state will change back. This cost much when doing the Locker state transition and usually will need to revoke caps from clients. URL: https://tracker.ceph.com/issues/55240 Signed-off-by: Xiubo Li <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent f7a2d06 commit 5eed80f

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

fs/ceph/addr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ static bool ceph_netfs_issue_op_inline(struct netfs_io_subrequest *subreq)
256256
struct iov_iter iter;
257257
ssize_t err = 0;
258258
size_t len;
259+
int mode;
259260

260261
__set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags);
261262
__clear_bit(NETFS_SREQ_COPY_TO_CACHE, &subreq->flags);
@@ -264,7 +265,8 @@ static bool ceph_netfs_issue_op_inline(struct netfs_io_subrequest *subreq)
264265
goto out;
265266

266267
/* We need to fetch the inline data. */
267-
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, USE_ANY_MDS);
268+
mode = ceph_try_to_choose_auth_mds(inode, CEPH_STAT_CAP_INLINE_DATA);
269+
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, mode);
268270
if (IS_ERR(req)) {
269271
err = PTR_ERR(req);
270272
goto out;

fs/ceph/inode.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2259,6 +2259,30 @@ int ceph_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
22592259
return err;
22602260
}
22612261

2262+
int ceph_try_to_choose_auth_mds(struct inode *inode, int mask)
2263+
{
2264+
int issued = ceph_caps_issued(ceph_inode(inode));
2265+
2266+
/*
2267+
* If any 'x' caps is issued we can just choose the auth MDS
2268+
* instead of the random replica MDSes. Because only when the
2269+
* Locker is in LOCK_EXEC state will the loner client could
2270+
* get the 'x' caps. And if we send the getattr requests to
2271+
* any replica MDS it must auth pin and tries to rdlock from
2272+
* the auth MDS, and then the auth MDS need to do the Locker
2273+
* state transition to LOCK_SYNC. And after that the lock state
2274+
* will change back.
2275+
*
2276+
* This cost much when doing the Locker state transition and
2277+
* usually will need to revoke caps from clients.
2278+
*/
2279+
if (((mask & CEPH_CAP_ANY_SHARED) && (issued & CEPH_CAP_ANY_EXCL))
2280+
|| (mask & CEPH_STAT_RSTAT))
2281+
return USE_AUTH_MDS;
2282+
else
2283+
return USE_ANY_MDS;
2284+
}
2285+
22622286
/*
22632287
* Verify that we have a lease on the given mask. If not,
22642288
* do a getattr against an mds.
@@ -2282,7 +2306,7 @@ int __ceph_do_getattr(struct inode *inode, struct page *locked_page,
22822306
if (!force && ceph_caps_issued_mask_metric(ceph_inode(inode), mask, 1))
22832307
return 0;
22842308

2285-
mode = (mask & CEPH_STAT_RSTAT) ? USE_AUTH_MDS : USE_ANY_MDS;
2309+
mode = ceph_try_to_choose_auth_mds(inode, mask);
22862310
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, mode);
22872311
if (IS_ERR(req))
22882312
return PTR_ERR(req);

fs/ceph/super.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,7 @@ static inline void ceph_queue_flush_snaps(struct inode *inode)
10221022
ceph_queue_inode_work(inode, CEPH_I_WORK_FLUSH_SNAPS);
10231023
}
10241024

1025+
extern int ceph_try_to_choose_auth_mds(struct inode *inode, int mask);
10251026
extern int __ceph_do_getattr(struct inode *inode, struct page *locked_page,
10261027
int mask, bool force);
10271028
static inline int ceph_do_getattr(struct inode *inode, int mask, bool force)

0 commit comments

Comments
 (0)