From patchwork Wed Jun 7 00:58:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9770389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3FBD860353 for ; Wed, 7 Jun 2017 01:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 218B428533 for ; Wed, 7 Jun 2017 01:00:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 116AF28539; Wed, 7 Jun 2017 01:00:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B426D28543 for ; Wed, 7 Jun 2017 01:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751504AbdFGBAL (ORCPT ); Tue, 6 Jun 2017 21:00:11 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:33315 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751453AbdFGBAJ (ORCPT ); Tue, 6 Jun 2017 21:00:09 -0400 Received: by mail-wr0-f193.google.com with SMTP id v104so11594230wrb.0 for ; Tue, 06 Jun 2017 18:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q+RZ0wZfmcSkSTTG79stzKmYskzZ8+PU8PZ7sKaG1Y4=; b=ARVRQnzgUKawEPWGiRanRTjioxP/oacRMZxoe9Svrh/MGji7/Ry7TYWkleGzRr+DEb 4JZHzAYV9cP1Aqg6RemQIcJtCRkzovPuHFeWKVAQSKocm+WT/vR5Wa5RQyyXHNQ8RJzz 27IHZaw03vwFy2Ax6yuhzwjsaTF8/Hih1ED777elv7rhq4HjU2Wb4nJTj++L1PFgYOYd neAsh4kHNtKO43/NKng5TIavgM3DqdETuHPD2uCPfbP48xuHtFc+JS9Y0wYoGBZf6cvC ZroqQdzwuvDVtog7W+ADdKFnadpKbD1E/VshVB+VzX3OOLsFhZcQzAmmTHi5Nku30nJc Y4cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q+RZ0wZfmcSkSTTG79stzKmYskzZ8+PU8PZ7sKaG1Y4=; b=RWS9TJCRUFh1wOsD3sm6x2ijGinQJ+3vLY1ud8IgLKKdbQGbuIcF19vw5h56Nb7j4Z n+rlyGgbwYnpXbio8eXnSTYtbmNkT6gN4RHdfkpIsAO6XD9ND1DDB4HtUWjTe5eWooCv uZXpQEXfZfOoquBwVAjdCZeYwfumaqncRB5AHcubS39/l9wby6DWGN/ofH7ckS+5aY4H wTt9ZcxwK+MFLn6+JNlY0PfFlYHgbiiJBsT4sWwDD6xQGQRAirMSM/lLYYJ8faPFNDUz YB5hD68k6a4dlWZ8M7bcQE0kR3/18EVs7wbpFTOD1/abfRXOdqlltV3bv8zwhYTMtgnH xstw== X-Gm-Message-State: AODbwcCKiltzWCGQQDLHYHf7O1ymeCwTO3iz3yQlVIW472/oefeLXmw5 nQB2R8KfZOHIEQuB X-Received: by 10.223.150.13 with SMTP id b13mr19597728wra.67.1496797208129; Tue, 06 Jun 2017 18:00:08 -0700 (PDT) Received: from localhost.localdomain ([91.215.176.151]) by smtp.gmail.com with ESMTPSA id q16sm338101wmg.2.2017.06.06.18.00.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 18:00:07 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [PATCH 7/7] Btrfs: end_workqueue_bio use switch case instead of else if Date: Wed, 7 Jun 2017 03:58:44 +0300 Message-Id: <20170607005844.2078-8-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170607005844.2078-1-nefelim4ag@gmail.com> References: <20170607005844.2078-1-nefelim4ag@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- fs/btrfs/disk-io.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) -- 2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 ==