If arg to "switch case" is determined and it's a consecutive numbers
(This is enum btrfs_wq_endio_type)
Compiler can create jump table to optimize logic
Signed-off-by: Timofey Titovets <nefelim4ag@xxxxxxxxx>
---
fs/btrfs/disk-io.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 8685d6718..72208826d 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -802,18 +802,27 @@ static void end_workqueue_bio(struct bio *bio)
end_io_wq->error = bio->bi_error;
if (bio_op(bio) == REQ_OP_WRITE) {
- if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) {
+ switch (end_io_wq->metadata) {
+ case BTRFS_WQ_ENDIO_DATA:
+ wq = fs_info->endio_write_workers;
+ func = btrfs_endio_write_helper;
+ break;
+ case BTRFS_WQ_ENDIO_METADATA:
wq = fs_info->endio_meta_write_workers;
func = btrfs_endio_meta_write_helper;
- } else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_FREE_SPACE) {
+ break;
+ case BTRFS_WQ_ENDIO_FREE_SPACE:
wq = fs_info->endio_freespace_worker;
func = btrfs_freespace_write_helper;
- } else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) {
+ break;
+ case BTRFS_WQ_ENDIO_RAID56:
wq = fs_info->endio_raid56_workers;
func = btrfs_endio_raid56_helper;
- } else {
+ break;
+ case BTRFS_WQ_ENDIO_DIO_REPAIR:
wq = fs_info->endio_write_workers;
func = btrfs_endio_write_helper;
+ break;
}
} else {
if (unlikely(end_io_wq->metadata ==
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html