Skip to content

Commit 3a3430a

Browse files
jtlaytonidryomov
authored andcommitted
ceph: show tasks waiting on caps in debugfs caps file
Add some visibility of tasks that are waiting for caps to the "caps" debugfs file. Display the tgid of the waiting task, inode number, and the caps the task needs and wants. Signed-off-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent ad8c28a commit 3a3430a

4 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎fs/ceph/caps.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,7 +2764,19 @@ int ceph_get_caps(struct file *filp, int need, int want,
27642764
if (ret == -EAGAIN)
27652765
continue;
27662766
if (!ret) {
2767+
struct ceph_mds_client *mdsc = fsc->mdsc;
2768+
struct cap_wait cw;
27672769
DEFINE_WAIT_FUNC(wait, woken_wake_function);
2770+
2771+
cw.ino = inode->i_ino;
2772+
cw.tgid = current->tgid;
2773+
cw.need = need;
2774+
cw.want = want;
2775+
2776+
spin_lock(&mdsc->caps_list_lock);
2777+
list_add(&cw.list, &mdsc->cap_wait_list);
2778+
spin_unlock(&mdsc->caps_list_lock);
2779+
27682780
add_wait_queue(&ci->i_cap_wq, &wait);
27692781

27702782
flags |= NON_BLOCKING;
@@ -2778,6 +2790,11 @@ int ceph_get_caps(struct file *filp, int need, int want,
27782790
}
27792791

27802792
remove_wait_queue(&ci->i_cap_wq, &wait);
2793+
2794+
spin_lock(&mdsc->caps_list_lock);
2795+
list_del(&cw.list);
2796+
spin_unlock(&mdsc->caps_list_lock);
2797+
27812798
if (ret == -EAGAIN)
27822799
continue;
27832800
}

‎fs/ceph/debugfs.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ static int caps_show(struct seq_file *s, void *p)
139139
struct ceph_fs_client *fsc = s->private;
140140
struct ceph_mds_client *mdsc = fsc->mdsc;
141141
int total, avail, used, reserved, min, i;
142+
struct cap_wait *cw;
142143

143144
ceph_reservation_status(fsc, &total, &avail, &used, &reserved, &min);
144145
seq_printf(s, "total\t\t%d\n"
@@ -166,6 +167,18 @@ static int caps_show(struct seq_file *s, void *p)
166167
}
167168
mutex_unlock(&mdsc->mutex);
168169

170+
seq_printf(s, "\n\nWaiters:\n--------\n");
171+
seq_printf(s, "tgid ino need want\n");
172+
seq_printf(s, "-----------------------------------------------------\n");
173+
174+
spin_lock(&mdsc->caps_list_lock);
175+
list_for_each_entry(cw, &mdsc->cap_wait_list, list) {
176+
seq_printf(s, "%-13d0x%-17lx%-17s%-17s\n", cw->tgid, cw->ino,
177+
ceph_cap_string(cw->need),
178+
ceph_cap_string(cw->want));
179+
}
180+
spin_unlock(&mdsc->caps_list_lock);
181+
169182
return 0;
170183
}
171184

‎fs/ceph/mds_client.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,6 +4169,7 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
41694169
INIT_DELAYED_WORK(&mdsc->delayed_work, delayed_work);
41704170
mdsc->last_renew_caps = jiffies;
41714171
INIT_LIST_HEAD(&mdsc->cap_delay_list);
4172+
INIT_LIST_HEAD(&mdsc->cap_wait_list);
41724173
spin_lock_init(&mdsc->cap_delay_lock);
41734174
INIT_LIST_HEAD(&mdsc->snap_flush_list);
41744175
spin_lock_init(&mdsc->snap_flush_lock);

‎fs/ceph/mds_client.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ struct ceph_quotarealm_inode {
340340
struct inode *inode;
341341
};
342342

343+
struct cap_wait {
344+
struct list_head list;
345+
unsigned long ino;
346+
pid_t tgid;
347+
int need;
348+
int want;
349+
};
350+
343351
/*
344352
* mds client state
345353
*/
@@ -416,6 +424,7 @@ struct ceph_mds_client {
416424
spinlock_t caps_list_lock;
417425
struct list_head caps_list; /* unused (reserved or
418426
unreserved) */
427+
struct list_head cap_wait_list;
419428
int caps_total_count; /* total caps allocated */
420429
int caps_use_count; /* in use */
421430
int caps_use_max; /* max used caps */

0 commit comments

Comments
 (0)