From: Bart Van Assche Date: Wed, 1 Feb 2017 18:20:58 +0000 (-0800) Subject: blk-mq-debug: Make show() operations interruptible X-Git-Tag: v4.14-rc1~1481^2^2~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c0f14eab8f138689e68b3498c0c5fd6ff20a948;p=platform%2Fkernel%2Flinux-rpi.git blk-mq-debug: Make show() operations interruptible Allow users to interrupt show operations instead of making a user space process unkillable if ownership of q->sysfs_lock cannot be obtained. Signed-off-by: Bart Van Assche Reviewed-by: Omar Sandoval Signed-off-by: Jens Axboe --- diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 0119ec5..54b2f48 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -178,13 +178,17 @@ 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; - mutex_lock(&q->sysfs_lock); + 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); - return 0; +out: + return res; } static int hctx_tags_open(struct inode *inode, struct file *file) @@ -203,12 +207,17 @@ 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; - mutex_lock(&q->sysfs_lock); + 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); - return 0; + +out: + return res; } static int hctx_tags_bitmap_open(struct inode *inode, struct file *file) @@ -227,13 +236,17 @@ 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; - mutex_lock(&q->sysfs_lock); + 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); - return 0; +out: + return res; } static int hctx_sched_tags_open(struct inode *inode, struct file *file) @@ -252,12 +265,17 @@ 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; - mutex_lock(&q->sysfs_lock); + 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); - return 0; + +out: + return res; } static int hctx_sched_tags_bitmap_open(struct inode *inode, struct file *file)