Skip to content

Commit 65d284a

Browse files
MaxKellermannidryomov
authored andcommitted
ceph: use cap_wait_list only if debugfs is enabled
Only debugfs uses this list. By omitting it, we save some memory and reduce lock contention on `caps_list_lock`. Signed-off-by: Max Kellermann <[email protected]> Reviewed-by: Xiubo Li <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 0c38364 commit 65d284a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

fs/ceph/caps.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,10 +3067,13 @@ int __ceph_get_caps(struct inode *inode, struct ceph_file_info *fi, int need,
30673067
flags, &_got);
30683068
WARN_ON_ONCE(ret == -EAGAIN);
30693069
if (!ret) {
3070+
#ifdef CONFIG_DEBUG_FS
30703071
struct ceph_mds_client *mdsc = fsc->mdsc;
30713072
struct cap_wait cw;
3073+
#endif
30723074
DEFINE_WAIT_FUNC(wait, woken_wake_function);
30733075

3076+
#ifdef CONFIG_DEBUG_FS
30743077
cw.ino = ceph_ino(inode);
30753078
cw.tgid = current->tgid;
30763079
cw.need = need;
@@ -3079,6 +3082,7 @@ int __ceph_get_caps(struct inode *inode, struct ceph_file_info *fi, int need,
30793082
spin_lock(&mdsc->caps_list_lock);
30803083
list_add(&cw.list, &mdsc->cap_wait_list);
30813084
spin_unlock(&mdsc->caps_list_lock);
3085+
#endif
30823086

30833087
/* make sure used fmode not timeout */
30843088
ceph_get_fmode(ci, flags, FMODE_WAIT_BIAS);
@@ -3097,9 +3101,11 @@ int __ceph_get_caps(struct inode *inode, struct ceph_file_info *fi, int need,
30973101
remove_wait_queue(&ci->i_cap_wq, &wait);
30983102
ceph_put_fmode(ci, flags, FMODE_WAIT_BIAS);
30993103

3104+
#ifdef CONFIG_DEBUG_FS
31003105
spin_lock(&mdsc->caps_list_lock);
31013106
list_del(&cw.list);
31023107
spin_unlock(&mdsc->caps_list_lock);
3108+
#endif
31033109

31043110
if (ret == -EAGAIN)
31053111
continue;

fs/ceph/mds_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5505,7 +5505,9 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
55055505
INIT_DELAYED_WORK(&mdsc->delayed_work, delayed_work);
55065506
mdsc->last_renew_caps = jiffies;
55075507
INIT_LIST_HEAD(&mdsc->cap_delay_list);
5508+
#ifdef CONFIG_DEBUG_FS
55085509
INIT_LIST_HEAD(&mdsc->cap_wait_list);
5510+
#endif
55095511
spin_lock_init(&mdsc->cap_delay_lock);
55105512
INIT_LIST_HEAD(&mdsc->cap_unlink_delay_list);
55115513
INIT_LIST_HEAD(&mdsc->snap_flush_list);

fs/ceph/mds_client.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ struct ceph_quotarealm_inode {
416416
struct inode *inode;
417417
};
418418

419+
#ifdef CONFIG_DEBUG_FS
420+
419421
struct cap_wait {
420422
struct list_head list;
421423
u64 ino;
@@ -424,6 +426,8 @@ struct cap_wait {
424426
int want;
425427
};
426428

429+
#endif
430+
427431
enum {
428432
CEPH_MDSC_STOPPING_BEGIN = 1,
429433
CEPH_MDSC_STOPPING_FLUSHING = 2,
@@ -512,7 +516,9 @@ struct ceph_mds_client {
512516
spinlock_t caps_list_lock;
513517
struct list_head caps_list; /* unused (reserved or
514518
unreserved) */
519+
#ifdef CONFIG_DEBUG_FS
515520
struct list_head cap_wait_list;
521+
#endif
516522
int caps_total_count; /* total caps allocated */
517523
int caps_use_count; /* in use */
518524
int caps_use_max; /* max used caps */

0 commit comments

Comments
 (0)