All of lore.kernel.org
 help / color / mirror / Atom feed
From: Timofey Titovets <nefelim4ag@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Timofey Titovets <nefelim4ag@gmail.com>
Subject: [PATCH 7/7] Btrfs: end_workqueue_bio use switch case instead of else if
Date: Wed,  7 Jun 2017 03:58:44 +0300	[thread overview]
Message-ID: <20170607005844.2078-8-nefelim4ag@gmail.com> (raw)
In-Reply-To: <20170607005844.2078-1-nefelim4ag@gmail.com>

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@gmail.com>
---
 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

  parent reply	other threads:[~2017-06-07  1:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-07  0:58 [PATCH 0/7] Btrfs: if else cleanups Timofey Titovets
2017-06-07  0:58 ` [PATCH 1/7] Btrfs: __compare_inode_defrag decrease max compare count Timofey Titovets
2017-06-07  0:58 ` [PATCH 2/7] Btrfs: backref_comp " Timofey Titovets
2017-06-07  0:58 ` [PATCH 3/7] Btrfs: ref_node_cmp " Timofey Titovets
2017-06-07  0:58 ` [PATCH 4/7] Btrfs: ref_tree_add remove useless compare Timofey Titovets
2017-06-07  0:58 ` [PATCH 5/7] Btrfs: add_all_parents skip compare Timofey Titovets
2017-06-07  0:58 ` [PATCH 6/7] Btrfs: __tree_mod_log_insert decrease max compare count Timofey Titovets
2017-06-07  9:45   ` Filipe Manana
2017-06-07 11:01     ` Timofey Titovets
2017-06-13 14:24       ` David Sterba
2017-06-07  0:58 ` Timofey Titovets [this message]
2017-06-07 22:48   ` [PATCH 7/7] Btrfs: end_workqueue_bio use switch case instead of else if kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170607005844.2078-8-nefelim4ag@gmail.com \
    --to=nefelim4ag@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.