^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #define pr_fmt(fmt) "drbd debugfs: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "drbd_int.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "drbd_req.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "drbd_debugfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /**********************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Whenever you change the file format, remember to bump the version. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) **********************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static struct dentry *drbd_debugfs_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static struct dentry *drbd_debugfs_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static struct dentry *drbd_debugfs_resources;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static struct dentry *drbd_debugfs_minors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static void seq_print_age_or_dash(struct seq_file *m, bool valid, unsigned long dt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) seq_printf(m, "\t%d", jiffies_to_msecs(dt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) seq_printf(m, "\t-");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static void __seq_print_rq_state_bit(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) bool is_set, char *sep, const char *set_name, const char *unset_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (is_set && set_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) seq_putc(m, *sep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) seq_puts(m, set_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) *sep = '|';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) } else if (!is_set && unset_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) seq_putc(m, *sep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) seq_puts(m, unset_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *sep = '|';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static void seq_print_rq_state_bit(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) bool is_set, char *sep, const char *set_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) __seq_print_rq_state_bit(m, is_set, sep, set_name, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* pretty print enum drbd_req_state_bits req->rq_state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static void seq_print_request_state(struct seq_file *m, struct drbd_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) unsigned int s = req->rq_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) char sep = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) seq_printf(m, "\t0x%08x", s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) seq_printf(m, "\tmaster: %s", req->master_bio ? "pending" : "completed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* RQ_WRITE ignored, already reported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) seq_puts(m, "\tlocal:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) seq_print_rq_state_bit(m, s & RQ_IN_ACT_LOG, &sep, "in-AL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) seq_print_rq_state_bit(m, s & RQ_POSTPONED, &sep, "postponed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) seq_print_rq_state_bit(m, s & RQ_COMPLETION_SUSP, &sep, "suspended");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) sep = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) seq_print_rq_state_bit(m, s & RQ_LOCAL_PENDING, &sep, "pending");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) seq_print_rq_state_bit(m, s & RQ_LOCAL_COMPLETED, &sep, "completed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) seq_print_rq_state_bit(m, s & RQ_LOCAL_ABORTED, &sep, "aborted");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) seq_print_rq_state_bit(m, s & RQ_LOCAL_OK, &sep, "ok");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (sep == ' ')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) seq_puts(m, " -");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* for_each_connection ... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) seq_printf(m, "\tnet:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) sep = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) seq_print_rq_state_bit(m, s & RQ_NET_PENDING, &sep, "pending");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) seq_print_rq_state_bit(m, s & RQ_NET_QUEUED, &sep, "queued");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) seq_print_rq_state_bit(m, s & RQ_NET_SENT, &sep, "sent");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) seq_print_rq_state_bit(m, s & RQ_NET_DONE, &sep, "done");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) seq_print_rq_state_bit(m, s & RQ_NET_SIS, &sep, "sis");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) seq_print_rq_state_bit(m, s & RQ_NET_OK, &sep, "ok");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (sep == ' ')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) seq_puts(m, " -");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) seq_printf(m, " :");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) sep = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) seq_print_rq_state_bit(m, s & RQ_EXP_RECEIVE_ACK, &sep, "B");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) seq_print_rq_state_bit(m, s & RQ_EXP_WRITE_ACK, &sep, "C");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) seq_print_rq_state_bit(m, s & RQ_EXP_BARR_ACK, &sep, "barr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (sep == ' ')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) seq_puts(m, " -");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) seq_printf(m, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) static void seq_print_one_request(struct seq_file *m, struct drbd_request *req, unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /* change anything here, fixup header below! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) unsigned int s = req->rq_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define RQ_HDR_1 "epoch\tsector\tsize\trw"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) seq_printf(m, "0x%x\t%llu\t%u\t%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) req->epoch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) (unsigned long long)req->i.sector, req->i.size >> 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) (s & RQ_WRITE) ? "W" : "R");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define RQ_HDR_2 "\tstart\tin AL\tsubmit"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) seq_printf(m, "\t%d", jiffies_to_msecs(now - req->start_jif));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) seq_print_age_or_dash(m, s & RQ_IN_ACT_LOG, now - req->in_actlog_jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) seq_print_age_or_dash(m, s & RQ_LOCAL_PENDING, now - req->pre_submit_jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define RQ_HDR_3 "\tsent\tacked\tdone"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) seq_print_age_or_dash(m, s & RQ_NET_SENT, now - req->pre_send_jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) seq_print_age_or_dash(m, (s & RQ_NET_SENT) && !(s & RQ_NET_PENDING), now - req->acked_jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) seq_print_age_or_dash(m, s & RQ_NET_DONE, now - req->net_done_jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define RQ_HDR_4 "\tstate\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) seq_print_request_state(m, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define RQ_HDR RQ_HDR_1 RQ_HDR_2 RQ_HDR_3 RQ_HDR_4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static void seq_print_minor_vnr_req(struct seq_file *m, struct drbd_request *req, unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) seq_printf(m, "%u\t%u\t", req->device->minor, req->device->vnr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) seq_print_one_request(m, req, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static void seq_print_resource_pending_meta_io(struct seq_file *m, struct drbd_resource *resource, unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct drbd_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) seq_puts(m, "minor\tvnr\tstart\tsubmit\tintent\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) idr_for_each_entry(&resource->devices, device, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct drbd_md_io tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* In theory this is racy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * in the sense that there could have been a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * drbd_md_put_buffer(); drbd_md_get_buffer();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * between accessing these members here. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) tmp = device->md_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (atomic_read(&tmp.in_use)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) seq_printf(m, "%u\t%u\t%d\t",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) device->minor, device->vnr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) jiffies_to_msecs(now - tmp.start_jif));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (time_before(tmp.submit_jif, tmp.start_jif))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) seq_puts(m, "-\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) seq_printf(m, "%d\t", jiffies_to_msecs(now - tmp.submit_jif));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) seq_printf(m, "%s\n", tmp.current_use);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) static void seq_print_waiting_for_AL(struct seq_file *m, struct drbd_resource *resource, unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct drbd_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) seq_puts(m, "minor\tvnr\tage\t#waiting\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) idr_for_each_entry(&resource->devices, device, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) unsigned long jif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct drbd_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int n = atomic_read(&device->ap_actlog_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) spin_lock_irq(&device->resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) req = list_first_entry_or_null(&device->pending_master_completion[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) struct drbd_request, req_pending_master_completion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /* if the oldest request does not wait for the activity log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * it is not interesting for us here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (req && !(req->rq_state & RQ_IN_ACT_LOG))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) jif = req->start_jif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) spin_unlock_irq(&device->resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) seq_printf(m, "%u\t%u\t", device->minor, device->vnr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) if (req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) seq_printf(m, "%u\t", jiffies_to_msecs(now - jif));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) seq_puts(m, "-\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) seq_printf(m, "%u\n", n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static void seq_print_device_bitmap_io(struct seq_file *m, struct drbd_device *device, unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct drbd_bm_aio_ctx *ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) unsigned long start_jif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) unsigned int in_flight;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) unsigned int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) spin_lock_irq(&device->resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) ctx = list_first_entry_or_null(&device->pending_bitmap_io, struct drbd_bm_aio_ctx, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (ctx && ctx->done)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ctx = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (ctx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) start_jif = ctx->start_jif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) in_flight = atomic_read(&ctx->in_flight);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) flags = ctx->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) spin_unlock_irq(&device->resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (ctx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) seq_printf(m, "%u\t%u\t%c\t%u\t%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) device->minor, device->vnr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) (flags & BM_AIO_READ) ? 'R' : 'W',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) jiffies_to_msecs(now - start_jif),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) in_flight);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static void seq_print_resource_pending_bitmap_io(struct seq_file *m, struct drbd_resource *resource, unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct drbd_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) seq_puts(m, "minor\tvnr\trw\tage\t#in-flight\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) idr_for_each_entry(&resource->devices, device, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) seq_print_device_bitmap_io(m, device, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) /* pretty print enum peer_req->flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static void seq_print_peer_request_flags(struct seq_file *m, struct drbd_peer_request *peer_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) unsigned long f = peer_req->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) char sep = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) __seq_print_rq_state_bit(m, f & EE_SUBMITTED, &sep, "submitted", "preparing");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) __seq_print_rq_state_bit(m, f & EE_APPLICATION, &sep, "application", "internal");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) seq_print_rq_state_bit(m, f & EE_CALL_AL_COMPLETE_IO, &sep, "in-AL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) seq_print_rq_state_bit(m, f & EE_SEND_WRITE_ACK, &sep, "C");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) seq_print_rq_state_bit(m, f & EE_MAY_SET_IN_SYNC, &sep, "set-in-sync");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) seq_print_rq_state_bit(m, f & EE_TRIM, &sep, "trim");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) seq_print_rq_state_bit(m, f & EE_ZEROOUT, &sep, "zero-out");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) seq_print_rq_state_bit(m, f & EE_WRITE_SAME, &sep, "write-same");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static void seq_print_peer_request(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct drbd_device *device, struct list_head *lh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) bool reported_preparing = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) struct drbd_peer_request *peer_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) list_for_each_entry(peer_req, lh, w.list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if (reported_preparing && !(peer_req->flags & EE_SUBMITTED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) if (device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) seq_printf(m, "%u\t%u\t", device->minor, device->vnr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) seq_printf(m, "%llu\t%u\t%c\t%u\t",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) (unsigned long long)peer_req->i.sector, peer_req->i.size >> 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) (peer_req->flags & EE_WRITE) ? 'W' : 'R',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) jiffies_to_msecs(now - peer_req->submit_jif));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) seq_print_peer_request_flags(m, peer_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (peer_req->flags & EE_SUBMITTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) reported_preparing = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) static void seq_print_device_peer_requests(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) struct drbd_device *device, unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) seq_puts(m, "minor\tvnr\tsector\tsize\trw\tage\tflags\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) spin_lock_irq(&device->resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) seq_print_peer_request(m, device, &device->active_ee, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) seq_print_peer_request(m, device, &device->read_ee, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) seq_print_peer_request(m, device, &device->sync_ee, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) spin_unlock_irq(&device->resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (test_bit(FLUSH_PENDING, &device->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) seq_printf(m, "%u\t%u\t-\t-\tF\t%u\tflush\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) device->minor, device->vnr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) jiffies_to_msecs(now - device->flush_jif));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static void seq_print_resource_pending_peer_requests(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct drbd_resource *resource, unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct drbd_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) idr_for_each_entry(&resource->devices, device, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) seq_print_device_peer_requests(m, device, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) static void seq_print_resource_transfer_log_summary(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) struct drbd_resource *resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) struct drbd_connection *connection,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) struct drbd_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) unsigned int count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) unsigned int show_state = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) seq_puts(m, "n\tdevice\tvnr\t" RQ_HDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) spin_lock_irq(&resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) list_for_each_entry(req, &connection->transfer_log, tl_requests) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) unsigned int tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) unsigned int s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) ++count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) /* don't disable irq "forever" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) if (!(count & 0x1ff)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) struct drbd_request *req_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) kref_get(&req->kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) spin_unlock_irq(&resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) cond_resched();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) spin_lock_irq(&resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) req_next = list_next_entry(req, tl_requests);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) if (kref_put(&req->kref, drbd_req_destroy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) req = req_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (&req->tl_requests == &connection->transfer_log)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) s = req->rq_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) /* This is meant to summarize timing issues, to be able to tell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * local disk problems from network problems.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) * Skip requests, if we have shown an even older request with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * similar aspects already. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) if (req->master_bio == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) tmp |= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) if ((s & RQ_LOCAL_MASK) && (s & RQ_LOCAL_PENDING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) tmp |= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) if (s & RQ_NET_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) if (!(s & RQ_NET_SENT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) tmp |= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) if (s & RQ_NET_PENDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) tmp |= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) if (!(s & RQ_NET_DONE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) tmp |= 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) if ((tmp & show_state) == tmp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) show_state |= tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) seq_printf(m, "%u\t", count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) seq_print_minor_vnr_req(m, req, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) if (show_state == 0x1f)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) spin_unlock_irq(&resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) /* TODO: transfer_log and friends should be moved to resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) static int in_flight_summary_show(struct seq_file *m, void *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) struct drbd_resource *resource = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) struct drbd_connection *connection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) unsigned long jif = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) connection = first_connection(resource);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) /* This does not happen, actually.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) * But be robust and prepare for future code changes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) if (!connection || !kref_get_unless_zero(&connection->kref))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) return -ESTALE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) /* BUMP me if you change the file format/content/presentation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) seq_printf(m, "v: %u\n\n", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) seq_puts(m, "oldest bitmap IO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) seq_print_resource_pending_bitmap_io(m, resource, jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) seq_puts(m, "meta data IO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) seq_print_resource_pending_meta_io(m, resource, jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) seq_puts(m, "socket buffer stats\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) /* for each connection ... once we have more than one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) if (connection->data.socket) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) /* open coded SIOCINQ, the "relevant" part */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) struct tcp_sock *tp = tcp_sk(connection->data.socket->sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) int answ = tp->rcv_nxt - tp->copied_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) seq_printf(m, "unread receive buffer: %u Byte\n", answ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /* open coded SIOCOUTQ, the "relevant" part */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) answ = tp->write_seq - tp->snd_una;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) seq_printf(m, "unacked send buffer: %u Byte\n", answ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) seq_puts(m, "oldest peer requests\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) seq_print_resource_pending_peer_requests(m, resource, jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) seq_puts(m, "application requests waiting for activity log\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) seq_print_waiting_for_AL(m, resource, jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) seq_puts(m, "oldest application requests\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) seq_print_resource_transfer_log_summary(m, resource, connection, jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) jif = jiffies - jif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) if (jif)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) seq_printf(m, "generated in %d ms\n", jiffies_to_msecs(jif));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) kref_put(&connection->kref, drbd_destroy_connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /* make sure at *open* time that the respective object won't go away. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) void *data, struct kref *kref,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) void (*release)(struct kref *))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) struct dentry *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) int ret = -ESTALE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) /* Are we still linked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * or has debugfs_remove() already been called? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) parent = file->f_path.dentry->d_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) /* serialize with d_delete() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) inode_lock(d_inode(parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) /* Make sure the object is still alive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) if (simple_positive(file->f_path.dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) && kref_get_unless_zero(kref))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) inode_unlock(d_inode(parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) ret = single_open(file, show, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) kref_put(kref, release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) static int in_flight_summary_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) struct drbd_resource *resource = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) return drbd_single_open(file, in_flight_summary_show, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) &resource->kref, drbd_destroy_resource);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) static int in_flight_summary_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) struct drbd_resource *resource = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) kref_put(&resource->kref, drbd_destroy_resource);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) return single_release(inode, file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) static const struct file_operations in_flight_summary_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) .open = in_flight_summary_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) .release = in_flight_summary_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) void drbd_debugfs_resource_add(struct drbd_resource *resource)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) dentry = debugfs_create_dir(resource->name, drbd_debugfs_resources);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) resource->debugfs_res = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) dentry = debugfs_create_dir("volumes", resource->debugfs_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) resource->debugfs_res_volumes = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) dentry = debugfs_create_dir("connections", resource->debugfs_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) resource->debugfs_res_connections = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) dentry = debugfs_create_file("in_flight_summary", 0440,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) resource->debugfs_res, resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) &in_flight_summary_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) resource->debugfs_res_in_flight_summary = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) static void drbd_debugfs_remove(struct dentry **dp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) debugfs_remove(*dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) *dp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) void drbd_debugfs_resource_cleanup(struct drbd_resource *resource)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) /* it is ok to call debugfs_remove(NULL) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) drbd_debugfs_remove(&resource->debugfs_res_in_flight_summary);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) drbd_debugfs_remove(&resource->debugfs_res_connections);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) drbd_debugfs_remove(&resource->debugfs_res_volumes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) drbd_debugfs_remove(&resource->debugfs_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) static void seq_print_one_timing_detail(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) const struct drbd_thread_timing_details *tdp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) struct drbd_thread_timing_details td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) /* No locking...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) * use temporary assignment to get at consistent data. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) td = *tdp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) } while (td.cb_nr != tdp->cb_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) if (!td.cb_addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) seq_printf(m, "%u\t%d\t%s:%u\t%ps\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) td.cb_nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) jiffies_to_msecs(now - td.start_jif),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) td.caller_fn, td.line,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) td.cb_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) static void seq_print_timing_details(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) const char *title,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) unsigned int cb_nr, struct drbd_thread_timing_details *tdp, unsigned long now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) unsigned int start_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) seq_printf(m, "%s\n", title);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) /* If not much is going on, this will result in natural ordering.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) * If it is very busy, we will possibly skip events, or even see wrap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) * arounds, which could only be avoided with locking.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) start_idx = cb_nr % DRBD_THREAD_DETAILS_HIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) for (i = start_idx; i < DRBD_THREAD_DETAILS_HIST; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) seq_print_one_timing_detail(m, tdp+i, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) for (i = 0; i < start_idx; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) seq_print_one_timing_detail(m, tdp+i, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) static int callback_history_show(struct seq_file *m, void *ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) struct drbd_connection *connection = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) unsigned long jif = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) /* BUMP me if you change the file format/content/presentation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) seq_printf(m, "v: %u\n\n", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) seq_puts(m, "n\tage\tcallsite\tfn\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) seq_print_timing_details(m, "worker", connection->w_cb_nr, connection->w_timing_details, jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) seq_print_timing_details(m, "receiver", connection->r_cb_nr, connection->r_timing_details, jif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) static int callback_history_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) struct drbd_connection *connection = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) return drbd_single_open(file, callback_history_show, connection,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) &connection->kref, drbd_destroy_connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) static int callback_history_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) struct drbd_connection *connection = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) kref_put(&connection->kref, drbd_destroy_connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) return single_release(inode, file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) static const struct file_operations connection_callback_history_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) .open = callback_history_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) .release = callback_history_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) static int connection_oldest_requests_show(struct seq_file *m, void *ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) struct drbd_connection *connection = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) unsigned long now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) struct drbd_request *r1, *r2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) /* BUMP me if you change the file format/content/presentation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) seq_printf(m, "v: %u\n\n", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) spin_lock_irq(&connection->resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) r1 = connection->req_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) if (r1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) seq_print_minor_vnr_req(m, r1, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) r2 = connection->req_ack_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) if (r2 && r2 != r1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) r1 = r2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) seq_print_minor_vnr_req(m, r1, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) r2 = connection->req_not_net_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) if (r2 && r2 != r1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) seq_print_minor_vnr_req(m, r2, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) spin_unlock_irq(&connection->resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) static int connection_oldest_requests_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) struct drbd_connection *connection = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) return drbd_single_open(file, connection_oldest_requests_show, connection,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) &connection->kref, drbd_destroy_connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) static int connection_oldest_requests_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) struct drbd_connection *connection = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) kref_put(&connection->kref, drbd_destroy_connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) return single_release(inode, file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) static const struct file_operations connection_oldest_requests_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) .open = connection_oldest_requests_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) .release = connection_oldest_requests_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) void drbd_debugfs_connection_add(struct drbd_connection *connection)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) struct dentry *conns_dir = connection->resource->debugfs_res_connections;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) /* Once we enable mutliple peers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) * these connections will have descriptive names.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) * For now, it is just the one connection to the (only) "peer". */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) dentry = debugfs_create_dir("peer", conns_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) connection->debugfs_conn = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) dentry = debugfs_create_file("callback_history", 0440,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) connection->debugfs_conn, connection,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) &connection_callback_history_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) connection->debugfs_conn_callback_history = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) dentry = debugfs_create_file("oldest_requests", 0440,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) connection->debugfs_conn, connection,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) &connection_oldest_requests_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) connection->debugfs_conn_oldest_requests = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) void drbd_debugfs_connection_cleanup(struct drbd_connection *connection)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) drbd_debugfs_remove(&connection->debugfs_conn_callback_history);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) drbd_debugfs_remove(&connection->debugfs_conn_oldest_requests);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) drbd_debugfs_remove(&connection->debugfs_conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) static void resync_dump_detail(struct seq_file *m, struct lc_element *e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) struct bm_extent *bme = lc_entry(e, struct bm_extent, lce);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) seq_printf(m, "%5d %s %s %s", bme->rs_left,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) test_bit(BME_NO_WRITES, &bme->flags) ? "NO_WRITES" : "---------",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) test_bit(BME_LOCKED, &bme->flags) ? "LOCKED" : "------",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) test_bit(BME_PRIORITY, &bme->flags) ? "PRIORITY" : "--------"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) static int device_resync_extents_show(struct seq_file *m, void *ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) struct drbd_device *device = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) /* BUMP me if you change the file format/content/presentation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) seq_printf(m, "v: %u\n\n", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) if (get_ldev_if_state(device, D_FAILED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) lc_seq_printf_stats(m, device->resync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) lc_seq_dump_details(m, device->resync, "rs_left flags", resync_dump_detail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) put_ldev(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) static int device_act_log_extents_show(struct seq_file *m, void *ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) struct drbd_device *device = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) /* BUMP me if you change the file format/content/presentation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) seq_printf(m, "v: %u\n\n", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) if (get_ldev_if_state(device, D_FAILED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) lc_seq_printf_stats(m, device->act_log);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) lc_seq_dump_details(m, device->act_log, "", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) put_ldev(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) static int device_oldest_requests_show(struct seq_file *m, void *ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) struct drbd_device *device = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) struct drbd_resource *resource = device->resource;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) unsigned long now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) struct drbd_request *r1, *r2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) /* BUMP me if you change the file format/content/presentation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) seq_printf(m, "v: %u\n\n", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) seq_puts(m, RQ_HDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) spin_lock_irq(&resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) /* WRITE, then READ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) for (i = 1; i >= 0; --i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) r1 = list_first_entry_or_null(&device->pending_master_completion[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) struct drbd_request, req_pending_master_completion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) r2 = list_first_entry_or_null(&device->pending_completion[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) struct drbd_request, req_pending_local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) if (r1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) seq_print_one_request(m, r1, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) if (r2 && r2 != r1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) seq_print_one_request(m, r2, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) spin_unlock_irq(&resource->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) static int device_data_gen_id_show(struct seq_file *m, void *ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) struct drbd_device *device = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) struct drbd_md *md;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) enum drbd_uuid_index idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) if (!get_ldev_if_state(device, D_FAILED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) md = &device->ldev->md;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) spin_lock_irq(&md->uuid_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) for (idx = UI_CURRENT; idx <= UI_HISTORY_END; idx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) seq_printf(m, "0x%016llX\n", md->uuid[idx]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) spin_unlock_irq(&md->uuid_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) put_ldev(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) static int device_ed_gen_id_show(struct seq_file *m, void *ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) struct drbd_device *device = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) seq_printf(m, "0x%016llX\n", (unsigned long long)device->ed_uuid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) #define drbd_debugfs_device_attr(name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) static int device_ ## name ## _open(struct inode *inode, struct file *file) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) struct drbd_device *device = inode->i_private; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) return drbd_single_open(file, device_ ## name ## _show, device, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) &device->kref, drbd_destroy_device); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) static int device_ ## name ## _release(struct inode *inode, struct file *file) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) struct drbd_device *device = inode->i_private; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) kref_put(&device->kref, drbd_destroy_device); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) return single_release(inode, file); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) static const struct file_operations device_ ## name ## _fops = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) .owner = THIS_MODULE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) .open = device_ ## name ## _open, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) .read = seq_read, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) .llseek = seq_lseek, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) .release = device_ ## name ## _release, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) drbd_debugfs_device_attr(oldest_requests)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) drbd_debugfs_device_attr(act_log_extents)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) drbd_debugfs_device_attr(resync_extents)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) drbd_debugfs_device_attr(data_gen_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) drbd_debugfs_device_attr(ed_gen_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) void drbd_debugfs_device_add(struct drbd_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) struct dentry *vols_dir = device->resource->debugfs_res_volumes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) char minor_buf[8]; /* MINORMASK, MINORBITS == 20; */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) char vnr_buf[8]; /* volume number vnr is even 16 bit only; */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) char *slink_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) if (!vols_dir || !drbd_debugfs_minors)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) snprintf(vnr_buf, sizeof(vnr_buf), "%u", device->vnr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) dentry = debugfs_create_dir(vnr_buf, vols_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) device->debugfs_vol = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) snprintf(minor_buf, sizeof(minor_buf), "%u", device->minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) slink_name = kasprintf(GFP_KERNEL, "../resources/%s/volumes/%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) device->resource->name, device->vnr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) if (!slink_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) dentry = debugfs_create_symlink(minor_buf, drbd_debugfs_minors, slink_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) device->debugfs_minor = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) kfree(slink_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) slink_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) #define DCF(name) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) dentry = debugfs_create_file(#name, 0440, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) device->debugfs_vol, device, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) &device_ ## name ## _fops); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) device->debugfs_vol_ ## name = dentry; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) DCF(oldest_requests);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) DCF(act_log_extents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) DCF(resync_extents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) DCF(data_gen_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) DCF(ed_gen_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) #undef DCF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) drbd_debugfs_device_cleanup(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) drbd_err(device, "failed to create debugfs entries\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) void drbd_debugfs_device_cleanup(struct drbd_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) drbd_debugfs_remove(&device->debugfs_minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) drbd_debugfs_remove(&device->debugfs_vol_oldest_requests);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) drbd_debugfs_remove(&device->debugfs_vol_act_log_extents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) drbd_debugfs_remove(&device->debugfs_vol_resync_extents);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) drbd_debugfs_remove(&device->debugfs_vol_data_gen_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) drbd_debugfs_remove(&device->debugfs_vol_ed_gen_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) drbd_debugfs_remove(&device->debugfs_vol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) void drbd_debugfs_peer_device_add(struct drbd_peer_device *peer_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) struct dentry *conn_dir = peer_device->connection->debugfs_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) char vnr_buf[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) snprintf(vnr_buf, sizeof(vnr_buf), "%u", peer_device->device->vnr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) dentry = debugfs_create_dir(vnr_buf, conn_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) peer_device->debugfs_peer_dev = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) void drbd_debugfs_peer_device_cleanup(struct drbd_peer_device *peer_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) drbd_debugfs_remove(&peer_device->debugfs_peer_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) static int drbd_version_show(struct seq_file *m, void *ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) seq_printf(m, "# %s\n", drbd_buildtag());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) seq_printf(m, "VERSION=%s\n", REL_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) seq_printf(m, "API_VERSION=%u\n", API_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) seq_printf(m, "PRO_VERSION_MIN=%u\n", PRO_VERSION_MIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) seq_printf(m, "PRO_VERSION_MAX=%u\n", PRO_VERSION_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) static int drbd_version_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) return single_open(file, drbd_version_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) static const struct file_operations drbd_version_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) .open = drbd_version_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) /* not __exit, may be indirectly called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) * from the module-load-failure path as well. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) void drbd_debugfs_cleanup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) drbd_debugfs_remove(&drbd_debugfs_resources);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) drbd_debugfs_remove(&drbd_debugfs_minors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) drbd_debugfs_remove(&drbd_debugfs_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) drbd_debugfs_remove(&drbd_debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) void __init drbd_debugfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) dentry = debugfs_create_dir("drbd", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) drbd_debugfs_root = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) dentry = debugfs_create_file("version", 0444, drbd_debugfs_root, NULL, &drbd_version_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) drbd_debugfs_version = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) dentry = debugfs_create_dir("resources", drbd_debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) drbd_debugfs_resources = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) dentry = debugfs_create_dir("minors", drbd_debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) drbd_debugfs_minors = dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) }