cregit-Linux how code gets into the kernel

Release 4.11 block/blk-mq-debugfs.c

Directory: block
/*
 * Copyright (C) 2017 Facebook
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License v2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/debugfs.h>

#include <linux/blk-mq.h>
#include "blk.h"
#include "blk-mq.h"
#include "blk-mq-tag.h"


struct blk_mq_debugfs_attr {
	
const char *name;
	
umode_t mode;
	
const struct file_operations *fops;
};


static int blk_mq_debugfs_seq_open(struct inode *inode, struct file *file, const struct seq_operations *ops) { struct seq_file *m; int ret; ret = seq_open(file, ops); if (!ret) { m = file->private_data; m->private = inode->i_private; } return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval63100.00%1100.00%
Total63100.00%1100.00%


static int hctx_state_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; seq_printf(m, "0x%lx\n", hctx->state); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval38100.00%1100.00%
Total38100.00%1100.00%


static int hctx_state_open(struct inode *inode, struct file *file) { return single_open(file, hctx_state_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%

static const struct file_operations hctx_state_fops = { .open = hctx_state_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static int hctx_flags_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; seq_printf(m, "0x%lx\n", hctx->flags); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval38100.00%1100.00%
Total38100.00%1100.00%


static int hctx_flags_open(struct inode *inode, struct file *file) { return single_open(file, hctx_flags_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%

static const struct file_operations hctx_flags_fops = { .open = hctx_flags_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v) { struct request *rq = list_entry_rq(v); seq_printf(m, "%p {.cmd_flags=0x%x, .rq_flags=0x%x, .tag=%d, .internal_tag=%d}\n", rq, rq->cmd_flags, (__force unsigned int)rq->rq_flags, rq->tag, rq->internal_tag); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval5696.55%250.00%
Christoph Hellwig11.72%125.00%
Bart Van Assche11.72%125.00%
Total58100.00%4100.00%


static void *hctx_dispatch_start(struct seq_file *m, loff_t *pos) __acquires(&hctx->lock

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval1482.35%150.00%
Bart Van Assche317.65%150.00%
Total17100.00%2100.00%

) { struct blk_mq_hw_ctx *hctx = m->private; spin_lock(&hctx->lock); return seq_list_start(&hctx->dispatch, *pos); }
static void *hctx_dispatch_next(struct seq_file *m, void *v, loff_t *pos) { struct blk_mq_hw_ctx *hctx = m->private; return seq_list_next(v, &hctx->dispatch, pos); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval42100.00%1100.00%
Total42100.00%1100.00%


static void hctx_dispatch_stop(struct seq_file *m, void *v) __releases(&hctx->lock

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval1381.25%150.00%
Bart Van Assche318.75%150.00%
Total16100.00%2100.00%

) { struct blk_mq_hw_ctx *hctx = m->private; spin_unlock(&hctx->lock); } static const struct seq_operations hctx_dispatch_seq_ops = { .start = hctx_dispatch_start, .next = hctx_dispatch_next, .stop = hctx_dispatch_stop, .show = blk_mq_debugfs_rq_show, };
static int hctx_dispatch_open(struct inode *inode, struct file *file) { return blk_mq_debugfs_seq_open(inode, file, &hctx_dispatch_seq_ops); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval27100.00%1100.00%
Total27100.00%1100.00%

static const struct file_operations hctx_dispatch_fops = { .open = hctx_dispatch_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, };
static int hctx_ctx_map_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; sbitmap_bitmap_show(&hctx->ctx_map, m); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval37100.00%1100.00%
Total37100.00%1100.00%


static int hctx_ctx_map_open(struct inode *inode, struct file *file) { return single_open(file, hctx_ctx_map_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%

static const struct file_operations hctx_ctx_map_fops = { .open = hctx_ctx_map_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static void blk_mq_debugfs_tags_show(struct seq_file *m, struct blk_mq_tags *tags) { seq_printf(m, "nr_tags=%u\n", tags->nr_tags); seq_printf(m, "nr_reserved_tags=%u\n", tags->nr_reserved_tags); seq_printf(m, "active_queues=%d\n", atomic_read(&tags->active_queues)); seq_puts(m, "\nbitmap_tags:\n"); sbitmap_queue_show(&tags->bitmap_tags, m); if (tags->nr_reserved_tags) { seq_puts(m, "\nbreserved_tags:\n"); sbitmap_queue_show(&tags->breserved_tags, m); } }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval95100.00%1100.00%
Total95100.00%1100.00%


static int hctx_tags_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; struct request_queue *q = hctx->queue; int res; res = mutex_lock_interruptible(&q->sysfs_lock); if (res) goto out; if (hctx->tags) blk_mq_debugfs_tags_show(m, hctx->tags); mutex_unlock(&q->sysfs_lock); out: return res; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval6580.25%150.00%
Bart Van Assche1619.75%150.00%
Total81100.00%2100.00%


static int hctx_tags_open(struct inode *inode, struct file *file) { return single_open(file, hctx_tags_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%

static const struct file_operations hctx_tags_fops = { .open = hctx_tags_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static int hctx_tags_bitmap_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; struct request_queue *q = hctx->queue; int res; res = mutex_lock_interruptible(&q->sysfs_lock); if (res) goto out; if (hctx->tags) sbitmap_bitmap_show(&hctx->tags->bitmap_tags.sb, m); mutex_unlock(&q->sysfs_lock); out: return res; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval7081.40%150.00%
Bart Van Assche1618.60%150.00%
Total86100.00%2100.00%


static int hctx_tags_bitmap_open(struct inode *inode, struct file *file) { return single_open(file, hctx_tags_bitmap_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%

static const struct file_operations hctx_tags_bitmap_fops = { .open = hctx_tags_bitmap_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static int hctx_sched_tags_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; struct request_queue *q = hctx->queue; int res; res = mutex_lock_interruptible(&q->sysfs_lock); if (res) goto out; if (hctx->sched_tags) blk_mq_debugfs_tags_show(m, hctx->sched_tags); mutex_unlock(&q->sysfs_lock); out: return res; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval6580.25%150.00%
Bart Van Assche1619.75%150.00%
Total81100.00%2100.00%


static int hctx_sched_tags_open(struct inode *inode, struct file *file) { return single_open(file, hctx_sched_tags_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%

static const struct file_operations hctx_sched_tags_fops = { .open = hctx_sched_tags_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static int hctx_sched_tags_bitmap_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; struct request_queue *q = hctx->queue; int res; res = mutex_lock_interruptible(&q->sysfs_lock); if (res) goto out; if (hctx->sched_tags) sbitmap_bitmap_show(&hctx->sched_tags->bitmap_tags.sb, m); mutex_unlock(&q->sysfs_lock); out: return res; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval7081.40%150.00%
Bart Van Assche1618.60%150.00%
Total86100.00%2100.00%


static int hctx_sched_tags_bitmap_open(struct inode *inode, struct file *file) { return single_open(file, hctx_sched_tags_bitmap_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%

static const struct file_operations hctx_sched_tags_bitmap_fops = { .open = hctx_sched_tags_bitmap_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static int hctx_io_poll_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; seq_printf(m, "considered=%lu\n", hctx->poll_considered); seq_printf(m, "invoked=%lu\n", hctx->poll_invoked); seq_printf(m, "success=%lu\n", hctx->poll_success); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval60100.00%1100.00%
Total60100.00%1100.00%


static int hctx_io_poll_open(struct inode *inode, struct file *file) { return single_open(file, hctx_io_poll_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%


static ssize_t hctx_io_poll_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct seq_file *m = file->private_data; struct blk_mq_hw_ctx *hctx = m->private; hctx->poll_considered = hctx->poll_invoked = hctx->poll_success = 0; return count; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval59100.00%1100.00%
Total59100.00%1100.00%

static const struct file_operations hctx_io_poll_fops = { .open = hctx_io_poll_open, .read = seq_read, .write = hctx_io_poll_write, .llseek = seq_lseek, .release = single_release, };
static void print_stat(struct seq_file *m, struct blk_rq_stat *stat) { seq_printf(m, "samples=%d, mean=%lld, min=%llu, max=%llu", stat->nr_samples, stat->mean, stat->min, stat->max); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval39100.00%1100.00%
Total39100.00%1100.00%


static int hctx_stats_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; struct blk_rq_stat stat[2]; blk_stat_init(&stat[BLK_STAT_READ]); blk_stat_init(&stat[BLK_STAT_WRITE]); blk_hctx_stat_get(hctx, stat); seq_puts(m, "read: "); print_stat(m, &stat[BLK_STAT_READ]); seq_puts(m, "\n"); seq_puts(m, "write: "); print_stat(m, &stat[BLK_STAT_WRITE]); seq_puts(m, "\n"); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval109100.00%1100.00%
Total109100.00%1100.00%


static int hctx_stats_open(struct inode *inode, struct file *file) { return single_open(file, hctx_stats_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%


static ssize_t hctx_stats_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct seq_file *m = file->private_data; struct blk_mq_hw_ctx *hctx = m->private; struct blk_mq_ctx *ctx; int i; hctx_for_each_ctx(hctx, ctx, i) { blk_stat_init(&ctx->stat[BLK_STAT_READ]); blk_stat_init(&ctx->stat[BLK_STAT_WRITE]); } return count; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval85100.00%1100.00%
Total85100.00%1100.00%

static const struct file_operations hctx_stats_fops = { .open = hctx_stats_open, .read = seq_read, .write = hctx_stats_write, .llseek = seq_lseek, .release = single_release, };
static int hctx_dispatched_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; int i; seq_printf(m, "%8u\t%lu\n", 0U, hctx->dispatched[0]); for (i = 1; i < BLK_MQ_MAX_DISPATCH_ORDER - 1; i++) { unsigned int d = 1U << (i - 1); seq_printf(m, "%8u\t%lu\n", d, hctx->dispatched[i]); } seq_printf(m, "%8u+\t%lu\n", 1U << (i - 1), hctx->dispatched[i]); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval113100.00%1100.00%
Total113100.00%1100.00%


static int hctx_dispatched_open(struct inode *inode, struct file *file) { return single_open(file, hctx_dispatched_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%


static ssize_t hctx_dispatched_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct seq_file *m = file->private_data; struct blk_mq_hw_ctx *hctx = m->private; int i; for (i = 0; i < BLK_MQ_MAX_DISPATCH_ORDER; i++) hctx->dispatched[i] = 0; return count; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval70100.00%1100.00%
Total70100.00%1100.00%

static const struct file_operations hctx_dispatched_fops = { .open = hctx_dispatched_open, .read = seq_read, .write = hctx_dispatched_write, .llseek = seq_lseek, .release = single_release, };
static int hctx_queued_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; seq_printf(m, "%lu\n", hctx->queued); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval38100.00%1100.00%
Total38100.00%1100.00%


static int hctx_queued_open(struct inode *inode, struct file *file) { return single_open(file, hctx_queued_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%


static ssize_t hctx_queued_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct seq_file *m = file->private_data; struct blk_mq_hw_ctx *hctx = m->private; hctx->queued = 0; return count; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval51100.00%1100.00%
Total51100.00%1100.00%

static const struct file_operations hctx_queued_fops = { .open = hctx_queued_open, .read = seq_read, .write = hctx_queued_write, .llseek = seq_lseek, .release = single_release, };
static int hctx_run_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; seq_printf(m, "%lu\n", hctx->run); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval38100.00%1100.00%
Total38100.00%1100.00%


static int hctx_run_open(struct inode *inode, struct file *file) { return single_open(file, hctx_run_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%


static ssize_t hctx_run_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct seq_file *m = file->private_data; struct blk_mq_hw_ctx *hctx = m->private; hctx->run = 0; return count; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval51100.00%1100.00%
Total51100.00%1100.00%

static const struct file_operations hctx_run_fops = { .open = hctx_run_open, .read = seq_read, .write = hctx_run_write, .llseek = seq_lseek, .release = single_release, };
static int hctx_active_show(struct seq_file *m, void *v) { struct blk_mq_hw_ctx *hctx = m->private; seq_printf(m, "%d\n", atomic_read(&hctx->nr_active)); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval42100.00%1100.00%
Total42100.00%1100.00%


static int hctx_active_open(struct inode *inode, struct file *file) { return single_open(file, hctx_active_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%1100.00%
Total28100.00%1100.00%

static const struct file_operations hctx_active_fops = { .open = hctx_active_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static void *ctx_rq_list_start(struct seq_file *m, loff_t *pos) __acquires(&ctx->lock

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval1482.35%266.67%
Bart Van Assche317.65%133.33%
Total17100.00%3100.00%

) { struct blk_mq_ctx *ctx = m->private; spin_lock(&ctx->lock); return seq_list_start(&ctx->rq_list, *pos); }
static void *ctx_rq_list_next(struct seq_file *m, void *v, loff_t *pos) { struct blk_mq_ctx *ctx = m->private; return seq_list_next(v, &ctx->rq_list, pos); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval42100.00%1100.00%
Total42100.00%1100.00%


static void ctx_rq_list_stop(struct seq_file *m, void *v) __releases(&ctx->lock

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval1381.25%150.00%
Bart Van Assche318.75%150.00%
Total16100.00%2100.00%

) { struct blk_mq_ctx *ctx = m->private; spin_unlock(&ctx->lock); } static const struct seq_operations ctx_rq_list_seq_ops = { .start = ctx_rq_list_start, .next = ctx_rq_list_next, .stop = ctx_rq_list_stop, .show = blk_mq_debugfs_rq_show, };
static int ctx_rq_list_open(struct inode *inode, struct file *file) { return blk_mq_debugfs_seq_open(inode, file, &ctx_rq_list_seq_ops); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval27100.00%1100.00%
Total27100.00%1100.00%

static const struct file_operations ctx_rq_list_fops = { .open = ctx_rq_list_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, };
static int ctx_dispatched_show(struct seq_file *m, void *v) { struct blk_mq_ctx *ctx = m->private; seq_printf(m, "%lu %lu\n", ctx->rq_dispatched[1], ctx->rq_dispatched[0]); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval48100.00%2100.00%
Total48100.00%2100.00%


static int ctx_dispatched_open(struct inode *inode, struct file *file) { return single_open(file, ctx_dispatched_show, inode->i_private); }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval28100.00%2100.00%
Total28100.00%2100.00%


static ssize_t ctx_dispatched_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct seq_file *m = file->private_data; struct blk_mq_ctx *ctx = m->private; ctx->rq_dispatched[0] = ctx->rq_dispatched[1] = 0; return count; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval61100.00%2100.00%
Total61100.00%2100.00%

static const struct file_operations ctx_dispatched_fops = { .open = ctx_dispatched_open, .read = seq_read, .write = ctx_dispatched_write, .llseek = seq_lseek, .release = single_release, };
static int ctx_merged_show(struct seq_file *m, void *v) { struct blk_mq_ctx *ctx = m->private; seq_printf(m, "%lu\n", ctx->rq_merged); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Omar Sandoval38100.00%2100.00%
Total38100.00%2100.00%


static int ctx_merged_open(struct inode *inode, struct file *file) {