Skip to content

Commit 78800f5

Browse files
shroffniaxboe
authored andcommitted
block: remove unnecessary goto labels in debugfs attribute read methods
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent a3996d1 commit 78800f5

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

block/blk-mq-debugfs.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,12 @@ static int hctx_tags_show(void *data, struct seq_file *m)
402402

403403
res = mutex_lock_interruptible(&q->elevator_lock);
404404
if (res)
405-
goto out;
405+
return res;
406406
if (hctx->tags)
407407
blk_mq_debugfs_tags_show(m, hctx->tags);
408408
mutex_unlock(&q->elevator_lock);
409409

410-
out:
411-
return res;
410+
return 0;
412411
}
413412

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

420419
res = mutex_lock_interruptible(&q->elevator_lock);
421420
if (res)
422-
goto out;
421+
return res;
423422
if (hctx->tags)
424423
sbitmap_bitmap_show(&hctx->tags->bitmap_tags.sb, m);
425424
mutex_unlock(&q->elevator_lock);
426425

427-
out:
428-
return res;
426+
return 0;
429427
}
430428

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

437435
res = mutex_lock_interruptible(&q->elevator_lock);
438436
if (res)
439-
goto out;
437+
return res;
440438
if (hctx->sched_tags)
441439
blk_mq_debugfs_tags_show(m, hctx->sched_tags);
442440
mutex_unlock(&q->elevator_lock);
443441

444-
out:
445-
return res;
442+
return 0;
446443
}
447444

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

454451
res = mutex_lock_interruptible(&q->elevator_lock);
455452
if (res)
456-
goto out;
453+
return res;
457454
if (hctx->sched_tags)
458455
sbitmap_bitmap_show(&hctx->sched_tags->bitmap_tags.sb, m);
459456
mutex_unlock(&q->elevator_lock);
460457

461-
out:
462-
return res;
458+
return 0;
463459
}
464460

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

0 commit comments

Comments
 (0)