Skip to content

Commit

Permalink
block: remove unnecessary goto labels in debugfs attribute read methods
Browse files Browse the repository at this point in the history
In some debugfs attribute read methods, failure to acquire the mutex
lock results in jumping to a label before returning an error code.
However this is unnecessary, as we can return the failure code directly,
improving code readability and reducing complexity.

This commit removes the goto labels and ensures that the method returns
immediately upon failing to acquire the mutex lock.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20250313115235.3707600-3-nilay@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Nilay Shroff authored and Jens Axboe committed Mar 13, 2025
1 parent a3996d1 commit 78800f5
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions block/blk-mq-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,12 @@ static int hctx_tags_show(void *data, struct seq_file *m)

res = mutex_lock_interruptible(&q->elevator_lock);
if (res)
goto out;
return res;
if (hctx->tags)
blk_mq_debugfs_tags_show(m, hctx->tags);
mutex_unlock(&q->elevator_lock);

out:
return res;
return 0;
}

static int hctx_tags_bitmap_show(void *data, struct seq_file *m)
Expand All @@ -419,13 +418,12 @@ static int hctx_tags_bitmap_show(void *data, struct seq_file *m)

res = mutex_lock_interruptible(&q->elevator_lock);
if (res)
goto out;
return res;
if (hctx->tags)
sbitmap_bitmap_show(&hctx->tags->bitmap_tags.sb, m);
mutex_unlock(&q->elevator_lock);

out:
return res;
return 0;
}

static int hctx_sched_tags_show(void *data, struct seq_file *m)
Expand All @@ -436,13 +434,12 @@ static int hctx_sched_tags_show(void *data, struct seq_file *m)

res = mutex_lock_interruptible(&q->elevator_lock);
if (res)
goto out;
return res;
if (hctx->sched_tags)
blk_mq_debugfs_tags_show(m, hctx->sched_tags);
mutex_unlock(&q->elevator_lock);

out:
return res;
return 0;
}

static int hctx_sched_tags_bitmap_show(void *data, struct seq_file *m)
Expand All @@ -453,13 +450,12 @@ static int hctx_sched_tags_bitmap_show(void *data, struct seq_file *m)

res = mutex_lock_interruptible(&q->elevator_lock);
if (res)
goto out;
return res;
if (hctx->sched_tags)
sbitmap_bitmap_show(&hctx->sched_tags->bitmap_tags.sb, m);
mutex_unlock(&q->elevator_lock);

out:
return res;
return 0;
}

static int hctx_active_show(void *data, struct seq_file *m)
Expand Down

0 comments on commit 78800f5

Please sign in to comment.