From patchwork Tue Feb 2 05:35:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1788CC433DB for ; Tue, 2 Feb 2021 05:37:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD73864EAC for ; Tue, 2 Feb 2021 05:37:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231670AbhBBFhG (ORCPT ); Tue, 2 Feb 2021 00:37:06 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:14105 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbhBBFhG (ORCPT ); Tue, 2 Feb 2021 00:37:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244225; x=1643780225; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Snae7ix+uzrLf3Y+uWSKt6eqc4WPqjkdGb7X5QbFnEE=; b=cXyIIFeJ0sJ16qY4h+RpeDjtzn/iGIY1TvNASOm/GFjBnGIRBLHnEmnd Y2A0Y+EJh4dqidBj7GIsyhLhK4DhFZs+aVHusbihv0DNJ3oGLpnaukQA2 tm8B20kONxRoW9egBCu+izY/F2iNn6WDg7F+FYLvzFLPfOPHe/ux3dUYQ PCOYChReLe+FUi6gk/AGf71BE7pBfVkj7mhV6kYgaJLVGex/Q/G/YIp6J w2dx3QfO/FJGDKL6QQYJe3AFGGKhbRm0W/npRfTZJkHk0nKw/0LGYMu6Q MUs9Tt56p3Q7VwgAameoJVIIjxyBlsPNEWKPoeZk0UL9qwMzHBy91c6k/ g==; IronPort-SDR: OgZfBaWhuX9DY76MiKxZup668EoRDLvp7l1BmVBglWQMXEJTztDGNvO3uACOz2yaVlkPM3OJME OPBoeS0VT3Qf2JpqK+LggzIBP6ttBzkZeVMnoKfOzIzuVO0t2JO4CbCYJBs6PpgVBjSI8LoZvP X0X/MlO+8gPUllnN77cl1XK7YXXTh+7VoiE4SAf2XYyYyZekNFo+O4Puav1JmVEMrM7O+W06Ea vJDzulRxBxqVvKqI1sTo/LdCtfLzxnni4o4pmIxnyJKIvZpqd2K/cmVXBpBFeuG4sOAhkqq91x xDY= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="158885664" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:36:00 +0800 IronPort-SDR: O+W3x+Pvvq4BdE5HkCNU/GFqGNATP3n+WBDdvmC6cg9LLxs7pja4gSirXzJfsgiZ/JPCs3iX56 XwcTu7txHl0Ac09Xki4RFoNiLrv+aXYccN37TGSy7hMbhslUm0TkaoItQpNaq2hrdfaCsRi+gF asGuomb27yARET9VTFdLjrtGsOHodSRWHyyTFZZLZ2sgXQdlnvJnKoIC70rB69m7euf7yLGRqn 7WI/ZrBy4jkJTrrfO/dvCDob8CyfLUE/7UNivipzCTQ43/0/dF3KdcYibvcuJZyP3jZbsmN7t3 Z+auPc+evxKjHa2St0Muu2cU Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:18:09 -0800 IronPort-SDR: UXOC/+Yg2zlkLt5Ld/CujylCc6turbPIk18PhvMRCDWNZW5s9hj/AiZaAnFY6kyPT+kuUKDY0g OmmayHp8luIzWmqYhA9coOfVFZuUbaAJdMqB4Q8PDQTB4WMu/pO51wIhBgVY2OIobp6cO6vAwI HxzpHC6SZF2DA35kBN1I5jlDB1pcyeqsAxqDmvOmUrE8KccSmVzGgdtisVv7LOmAq+oLbhshCk +T7u+NGz1sLSKDcV42x+HO1MlbWNC8iLWN+R8Q0v0NObHcS+3IkBgkULuU2X4NHF17bgFF22L1 9b8= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:36:00 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 01/20] loop: use uniform alignment for struct members Date: Mon, 1 Feb 2021 21:35:33 -0800 Message-Id: <20210202053552.4844-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use uniform alignment and tab spaceing for the struct members. Also, add bdev identifire name for function pointer to turnoff checkpatch warning. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/block/loop.h b/drivers/block/loop.h index a3c04f310672..638642bfc76d 100644 --- a/drivers/block/loop.h +++ b/drivers/block/loop.h @@ -41,16 +41,16 @@ struct loop_device { char lo_encrypt_key[LO_KEY_SIZE]; int lo_encrypt_key_size; struct loop_func_table *lo_encryption; - __u32 lo_init[2]; + __u32 lo_init[2]; kuid_t lo_key_owner; /* Who set the key */ - int (*ioctl)(struct loop_device *, int cmd, + int (*ioctl)(struct loop_device *bdev, int cmd, unsigned long arg); - struct file * lo_backing_file; - struct block_device *lo_device; - void *key_data; + struct file *lo_backing_file; + struct block_device *lo_device; + void *key_data; - gfp_t old_gfp_mask; + gfp_t old_gfp_mask; spinlock_t lo_lock; int lo_state; @@ -66,13 +66,13 @@ struct loop_device { }; struct loop_cmd { - struct kthread_work work; - bool use_aio; /* use AIO interface to handle I/O */ - atomic_t ref; /* only for aio */ - long ret; - struct kiocb iocb; - struct bio_vec *bvec; - struct cgroup_subsys_state *css; + struct kthread_work work; + bool use_aio; /* use asynchronous I/O */ + atomic_t ref; /* only for aio */ + long ret; + struct kiocb iocb; + struct bio_vec *bvec; + struct cgroup_subsys_state *css; }; /* Support for loadable transfer modules */ From patchwork Tue Feb 2 05:35:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47100C433DB for ; Tue, 2 Feb 2021 05:37:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1468E64EAC for ; Tue, 2 Feb 2021 05:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231734AbhBBFhO (ORCPT ); Tue, 2 Feb 2021 00:37:14 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:43351 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231710AbhBBFhN (ORCPT ); Tue, 2 Feb 2021 00:37:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244233; x=1643780233; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f6uNsj2Bymx/trVcIbMskT9AETzSX5KyNZzqdu9PdFA=; b=mTUlaKeY/SZk57U51WvqeB2CsxG6EAY7frPMPfyVCBrVycbHibqbA/M+ 3nYzUUo6asqtqUdc2LJaHo772UkQHlErgeeTBsMW+zKxWTpugMHoRrONh iNGWBr+mwX2Dcxq/9L8WkyogUiu0YxOqfrrwN9ul4DODAHEqe4BjYx/0w c0+IyImmfd9iUYmBqJHfSTJN8OhvmPZVn4BbDIE01Zt39i3OZONKZP68A CmHJlJA67Bjb9ZkO4uifotIIXiN1Tafw9MNZflbj0bZRWcYmk721zFYEm kwfsmNUP0ur9INI1tSIacCguVHzh6qpDzWl1Iyo2dub6mfDDjRiHVk9k3 g==; IronPort-SDR: m0fgVR8Y3cLhkO1FTuMg+XRqAKVEzw659k8Mn/EIEPzAhbeHhY6o97H3GdNJeIO5yFpIxsVe/H VZ/EPyQtQHAJrf10NSumR9me1tAA35Uostk9Uqi82jkyxt6W/B7L6sVlB/icTuTIm+sJxLrwtA 8vsRi6Xc7qAAalGIpJYNhIsnQoEYXZbB1k6LPoc8BWEunjPB4Hbl0YF9MD/YVG5CN0pslEHV5m C33nzCY3Ma6eA//T3SnUzCThnU7ylQGnSxCcYmuhRQlllIEFl0bpK/i1VTaShU32sNrunjVfYf 1ds= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="163334270" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:36:08 +0800 IronPort-SDR: NMBTylOjT8NZONU3U3INNuaozT/TlY6Ad+QyYdivz3qwogQKvDM9WlH4TCRudb6lfQ2hgNgD8R RAiDQX0dNGltyrsexZngHe+7T5SJeN9OUSDfIETVJSCRE6Ja82xEExpNbvMcedW4rhhrOii5w6 eBBqEPcXsCZxtgRGcqMeh+7jWBBTu98hUlYgXoAeETA4in50p57jbW/9yErTX/IXchIwkCO0eW KLI6mKUUVnhod49M+Ae4WgWs+OSB3xXOYn7EREuNRdJsCwEHQ4iuPa1srd7Kw1Omtt2vh8E5qr kMUAHJLEtZepjwtQA3Y7vJ2x Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:18:17 -0800 IronPort-SDR: xDqGMD1zwtXMkchJQ/C+BcfM2aFI8vBsrhB28qwB/fvEm9NyzEhyRp0MyYZ9BW2osbF20URBSP jr46qPW0rjrg/nPZuKVBrdIbKzJxFOp6tVsXqone5QzMaHnYE87lXgF5kkLSNevlmvAD52mo3Z kBQ6iMSfs8irxZ7/XiRT1H52CLpYwPpnydF8JdRxGvmVxf2h57mjKRGZF6dHQHsQLW4F8IwnBU Z0b+uxVhRSDDyTIcNdz+7IFnXmV1w57vyL3donVHCazOP8wMfV0UgjAxzVjf5ZUq6C96v85i99 J30= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:36:08 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 02/20] loop: add lockdep assert in loop_add() Date: Mon, 1 Feb 2021 21:35:34 -0800 Message-Id: <20210202053552.4844-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In current code loop_add() is called from loop_probe(), loop_control_ioctl(), and loop_init(). Each of these functions hold global mutex lock loop_ctrl_mutex with two variants mutex_lock() and mutex_lock_killable(). Add lockdep_asset_lock_held() in loop_add() to make sure it will generate an appropriate error message in case of misuse.   Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 578fc034db3f..3bfdcabaf6b1 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2081,6 +2081,8 @@ static int loop_add(struct loop_device **l, int i) struct gendisk *disk; int err; + lockdep_assert_held(&loop_ctl_mutex); + err = -ENOMEM; lo = kzalloc(sizeof(*lo), GFP_KERNEL); if (!lo) From patchwork Tue Feb 2 05:35:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 048A9C433E0 for ; Tue, 2 Feb 2021 05:37:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B693364EDC for ; Tue, 2 Feb 2021 05:37:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231605AbhBBFh0 (ORCPT ); Tue, 2 Feb 2021 00:37:26 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:3355 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbhBBFhW (ORCPT ); Tue, 2 Feb 2021 00:37:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244242; x=1643780242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iayCvKe5PGe1IxVpKjmhNT1nCQLl7vpaxlMfc9BxqY8=; b=F5laaNBFqZZ87jzl1Tf+BCn+xqKwFw34uuTTAy0nUvVcAaNU8zLMqY1q cTCKV3j/AB82nnaPr+0bvLidmfLHdvbY1I80rdA3ntvwsa4zI0JnO+gJd H24M9lz7qeFONmo9ZlQ+6tQpTz8MtDjAShXuMWBgM17vuYxjNl/lSIetU uDsNxJ3ORBN4gPspAhas3+f0d7moN+SrnNUB+nmTq8aJmLWn4HbiY42Yz AVO20LQWhEj0gwbI0BCatMpLze6O39FeKjNcsRrLSI1l7gDTdHNa/sE3F QqiDiuT2ZfgAw8i9wDrXTkHqNhbrvn02PpuXuP3r3wI8fZ9YzhlLjiHwb w==; IronPort-SDR: HkDL2k266RmX87pGsGHCK6JBAaTMHHWk1gUKOCD6OtSJLEwXx4k1iikaEMmih3gAkgt93xsOcK ZiqNBb3zNbhSVCAU8bu5YlQpO60Rf5Za1eE3+GcfkYp1LabIRJSpZZdNC8RQz41fRe4lnc+GqL KP6T5GZ1zmZkqEbKAw3q1J98LSBxCUi3DAWftaW5bzpbTTjn85FnOoPcTKfuTCTVOzH5/ytRJE jGw1w3Mod74Tut8hQ/g3s65BoY/L3YwWkwWG9ADqvrt0p/1ri/1eqwh3h7pBDJBoyigDzloaIY E4w= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="163334285" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:36:16 +0800 IronPort-SDR: UFxUWSBNwPa2ewJzoqbNOyREVjimpsPQrkbNkqUFTBlZ2oJdTCW1xEwRNezGwwUPbZ6Nh7fFrZ tpgse/bv7arKNuLaCNmZOMDWVVox6C+fLWcLKYFcSa5nQ7zRI7wzF/UVN5RmiadzPZ/lb704Dz BOVuXcba/EjR4+MGLWAmOn6Fo7oJM9x41dnxPaZ41GfDnwqKpsdepYh9SDEQLmVFNlLi0gB2CM XfwE2G4dxxuU9NTxUdbp1MeXHwmsR/x5U4XwuuDL5lRTNeRhdiyBwi4AoFxqDbNQh0kU04xKIp fCnLPNswosIB7IGvDTbyqenS Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:18:25 -0800 IronPort-SDR: cO4/ITRpEmcncXAoSh12qq+T6kurAguvd5gN2Zs2TDT1tZhQSXB7CU6hu4H5EDA6gHwXc2aWam ccUzAoqtxlyH0PRCAhr3S9EADxbowp5JhUqnaEs7zAlsJx5lTIddOS9J6gDSTzDRZUWjcRNZf5 Lkjl2PBXl4yFj+QUA4E5Hw7EPHQYFkr+IhXaBi5AbbFiB7OFsJgLQntctFts21bbR89BjoLHgh IQg8ZJyITzt+bhZ24lq3x9WFpgja0BF4X+3hNiYAo6Pt0rCO0FtVOOsGvRNqmdQqp4ObTWtSlZ W6k= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:36:16 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 03/20] loop: add lockdep assert in loop_lookup() Date: Mon, 1 Feb 2021 21:35:35 -0800 Message-Id: <20210202053552.4844-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In current code loop_lookup() is called from loop_probe(), and loop_control_ioctl(). Each of these functions hold global mutex lock loop_ctrl_mutex with two variants mutex_lock() and mutex_lock_killable(). Add lockdep_asset_lock_held() in loop_lookup() to make sure it will generate an appropriate error message in case of misuse.   Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 3bfdcabaf6b1..0a8cee66c622 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2211,6 +2211,8 @@ static int loop_lookup(struct loop_device **l, int i) struct loop_device *lo; int ret = -ENODEV; + lockdep_assert_held(&loop_ctl_mutex); + if (i < 0) { int err; From patchwork Tue Feb 2 05:35:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE1D6C433E0 for ; Tue, 2 Feb 2021 05:37:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE58164EDE for ; Tue, 2 Feb 2021 05:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231710AbhBBFha (ORCPT ); Tue, 2 Feb 2021 00:37:30 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:3359 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbhBBFh3 (ORCPT ); Tue, 2 Feb 2021 00:37:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244249; x=1643780249; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mElkmngegMi7x0cjwruW8ZgJ8rQ6y2vMMid76m7J9mI=; b=XsITsZ73pZpzLkalMTuaNay4k6K0v7bJuicasARjqGpbexMD/xsdoRAK MT4vFd9QckVBp906em+hr1QJ2RIfSG2IemKm6g9L0MZIh8crctkxTTHHw Ot0/lBSJI38h57LDMT2qDBIgC024rqGpYEcsqIFTJArKbmFwjimc8ZcmT blKUWHub+bnmJXoRd8IemxQW1BEpuk/Cccr3MO/lulzxZrVj18trO1Uij amKDdp7LjFGogBGyG+Z3ByFTSLqFNlHRMeEo3kF0fQ14Z4cn2Erw70j5V m5PhUxc0BcGOtpbAEvtdZI8fdv7YdS1ElrUoxgoE9MLsUEcJ7Ww0ZdPSo g==; IronPort-SDR: 5WuDhogF/jhO8+/2FUfDNpoAp1gVTaq45p0rt19DRl6ERS6rwk29cN7PQOpwjo1DXcbU+YNIg1 cdq1W0rV4D7AVBdojoFuXjdwa5q2aLDywfNZkvkzjloIHbL/192cv1aZKVZV4xwCgJQAg7NhRv HNc+eAxFkogsXdLXIy4e7CIK8u9Lr1ranrM8tCgE0rqzFYYOvRwJLaa9dKrCoHq+YzWM0D+Wat ZAZ3exE0oH9hKPc19BCSU4IsIOER19flfXqRWrsN41QqU7AxaMTR+h5lFI+rh5IBKTyMssim2y Qbg= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="163334289" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:36:24 +0800 IronPort-SDR: n29JRKr6uoakkEvjqv4Xh6HXLKjFw14BRYP2iZP2CTakumoRxJPyy1RwDchx2MpQNib4LxPcym LfQfN/Y/9OlDb1ivchs9gx8go78kDAgDs9jkB5oIItJeyQgUxQ0pv5SpLuzNJ4L2wHSy+JQb+J xBdwsKjch773gzJDvDUV4G1KEyeotGRnwAXDEFf7Po/NUeGg4ImdiFHZJliG3IFpsWcHkdAHyT vgxlyxgXLDcQouiGpQzlFralhiWggTMoNFSlSVKp7O8tkOTA7UgN+HU7Qmh+qcSzZwt5IF/jLz zHmIpOKE6Mjl4Fw6yZiAMcdZ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:18:33 -0800 IronPort-SDR: 2ZHU+MYSo5eyKOSDcOIKc9KIQu2H0arolIj44ZQUsU+61WJ5Jdts1bIcDXwNt08ZiAQRYArdBU HVJwLLQ9uJKN0eHUQjDsin+Fd5/5+f6JtJmrPpMxOPs1mANqi/Tpe+zVhmO1i2APmTHTOF7MDF RyZODTy3eRqkt0hM1R9eblI1q8tluCprzcNeu2FsHZFwxVB8zuDHeb//aLC1jIYkdXVHhsvRUn l/NBQ4nDd7MbHQ3Jkaxbjpn3eG1C14XDnnK9o+rJW1B911/KfeGG7bhiUmUcGrpuELyeLKdwIP Mpo= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:36:24 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 04/20] loop: allow user to set the queue depth Date: Mon, 1 Feb 2021 21:35:36 -0800 Message-Id: <20210202053552.4844-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead of hardcoding queue depth allow user to set the hw queue depth using module parameter. Set default value to 128 to retain the existing behavior. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 0a8cee66c622..cf2789f7e6ba 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1950,6 +1950,9 @@ module_param(max_loop, int, 0444); MODULE_PARM_DESC(max_loop, "Maximum number of loop devices"); module_param(max_part, int, 0444); MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device"); +static int hw_queue_depth = 128; +module_param_named(hw_queue_depth, hw_queue_depth, int, 0444); +MODULE_PARM_DESC(hw_queue_depth, "Queue depth for each hardware queue. Default: 128"); MODULE_LICENSE("GPL"); MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR); @@ -2105,7 +2108,7 @@ static int loop_add(struct loop_device **l, int i) err = -ENOMEM; lo->tag_set.ops = &loop_mq_ops; lo->tag_set.nr_hw_queues = 1; - lo->tag_set.queue_depth = 128; + lo->tag_set.queue_depth = hw_queue_depth; lo->tag_set.numa_node = NUMA_NO_NODE; lo->tag_set.cmd_size = sizeof(struct loop_cmd); lo->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_STACKING; From patchwork Tue Feb 2 05:35:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 018DCC433DB for ; Tue, 2 Feb 2021 05:37:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4B9A64E9A for ; Tue, 2 Feb 2021 05:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbhBBFhj (ORCPT ); Tue, 2 Feb 2021 00:37:39 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:34101 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbhBBFhj (ORCPT ); Tue, 2 Feb 2021 00:37:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244258; x=1643780258; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iB/yJ9Lgv7J9LvlB+DckFJp9mu+dsQ1oIN/8MI2+2So=; b=BcZkFzpldMD5xlnLtPXzBQrLeFDx8Q1Xa+P5u9SWe6E2a0OVuzKQ1eAT cOeAxqipkZE9rxJ6VnKTAx25GITDd6xNo5CwLMub7mYXy9Rslboxq29aZ UQ9EhXbnGwaLutL2FFIN91GOj38+ig7nHCcB3TyBbIHyusLbQzvJ+8F8k qdybq7yPGCQE9kOHVJHwUHFFmZOmRiz8Qt+pbWGfnFcbHgDEJ4wkJR9yY O8E+911u+oKgs3Ttv2aZGkea5BCM1H6BERSVJfAfCOU+5BBhfs1wfqDTV 5KFxObyF0TgeVW1N0HeAP7lo+6w8JXtfbURU28KO4gxNW15eBzoJyyy2u A==; IronPort-SDR: d4ODxpObyHpAI+nJ3HPpIhJd8CARiKGFx756czylIyKoImweDmgRkmIL5DHpJtoSF/4TiJcXD3 FVAEpHvB3d8eYKy8JOBJjAOxnzQmKKslKqDj7n4wL9XnW/rxW77afg/NOTQCPiUbTPVgN6RDFM W9ti0SHWzw/FH/uz5CcNf1duFLkkcRxU6U6Fx7/a2+BQ5KbZqoGjdhQjlsoeXbKN6ZtpRANJjt JV+rpAabE9zyMSJ9+RDj785fM7SAl8OFiOacZzt1myDk5JXwUjn4FSmzNV4U1t3lWGoxFk2pup 5+0= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="269301769" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:36:32 +0800 IronPort-SDR: fh4Lnswaaq4zngPDsRlbXuAvGn2zTGS8MKCP0oQdm8xZL4gVbC7pKjFbbkjr1ayvpfe9LadAyd tzcJUfTWzXK23LBdoYqN5BFxxIpOSiT+ahZyTCOOsoTWkH0NIda8G/8/brIfpMJF/nATWSXYPB l+r2PSum6UDWy6sSN1K5gGqpIwfVr4OW1MXWbkH7Oi3NJzbjc7MAfcVHR+Ar+CWkiNGT3XE/ek FUo1seW4hPA3fsyD9N8YK6yv9LjVmXy5A5pB6W4MMSDCvkr2C79ye4rXWcXZUq7fvkz49yAkUP OMSERmvYTUWFFmbJehDJkoJC Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:18:42 -0800 IronPort-SDR: GEPPIz8EZzMsuZwtJ+UEA/QeJmUIPYjG4hzy6QCEYBScfy+GYPk6pRad2uTLjxL17sAKbIeFFW rDbn40V9XciOxmmniyR7oGKtyCDpBkIET9y34lP4LSJnFkVNHbGSjfT3Dvt1qKDSb4txeujRZI f+GcXFVvpuRF4e6vgsUjPAsVI3mNon9muZnDBX2swZ1VkEMp2Ml7N4P1ovozL1e3twk+CSbGno E33k2xbTtgxsAdYBtmKt+z1SCsSa3gkae2hyrQqM5nslZxRDzsxNrYJJwy3VlUCTWZtTeJL4Yj n5w= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:36:33 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 05/20] loop: use snprintf for XXX_show() Date: Mon, 1 Feb 2021 21:35:37 -0800 Message-Id: <20210202053552.4844-6-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use snprintf() over sprintf() which allows us to limit the target buffer size. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index cf2789f7e6ba..3f8d9bdfc16e 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -806,33 +806,35 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf) static ssize_t loop_attr_offset_show(struct loop_device *lo, char *buf) { - return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_offset); + return snprintf(buf, PAGE_SIZE, + "%llu\n", (unsigned long long)lo->lo_offset); } static ssize_t loop_attr_sizelimit_show(struct loop_device *lo, char *buf) { - return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit); + return snprintf(buf, PAGE_SIZE, + "%llu\n", (unsigned long long)lo->lo_sizelimit); } static ssize_t loop_attr_autoclear_show(struct loop_device *lo, char *buf) { int autoclear = (lo->lo_flags & LO_FLAGS_AUTOCLEAR); - return sprintf(buf, "%s\n", autoclear ? "1" : "0"); + return snprintf(buf, PAGE_SIZE, "%s\n", autoclear ? "1" : "0"); } static ssize_t loop_attr_partscan_show(struct loop_device *lo, char *buf) { int partscan = (lo->lo_flags & LO_FLAGS_PARTSCAN); - return sprintf(buf, "%s\n", partscan ? "1" : "0"); + return snprintf(buf, PAGE_SIZE, "%s\n", partscan ? "1" : "0"); } static ssize_t loop_attr_dio_show(struct loop_device *lo, char *buf) { int dio = (lo->lo_flags & LO_FLAGS_DIRECT_IO); - return sprintf(buf, "%s\n", dio ? "1" : "0"); + return snprintf(buf, PAGE_SIZE, "%s\n", dio ? "1" : "0"); } LOOP_ATTR_RO(backing_file); From patchwork Tue Feb 2 05:35:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B355AC433E0 for ; Tue, 2 Feb 2021 05:37:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EAD464EDC for ; Tue, 2 Feb 2021 05:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231596AbhBBFhz (ORCPT ); Tue, 2 Feb 2021 00:37:55 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:43351 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbhBBFhy (ORCPT ); Tue, 2 Feb 2021 00:37:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244273; x=1643780273; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bkIkuiAG01FhQkjjNsCxwfUCtamHqgx5K9UDoQu2S9c=; b=L/MYMXI8wjOyI7sD5+F52Yhmg3RscYawqbKSj/RXdoeQDR7JxT7/ftlX NO7MAqHMHEBlyA+brpA0R3CLCQ8ls30uhr/gbaYa+gf22qowKCrF3kKo2 IPPh4uGyxbUCw+45iTfnjQBLCoxYIq1V41lMqRrRQ2TBj430zUeOfk44l H2vq8mWY2Yt/8Ln1xxwRvyVhc0Q/gKUkply5b1mBw9bHMN/QukXRRxPv5 /PQX3M3H/8g36ihlr4nScV/LTX/i0MAAxOskcWUpVadmM4v++qm3b8pfu 3/0NBbFEe7qZz8gP7PtEG9SVnG87hznBuA3wKT/W+pn0nqZCUNZxeJP93 g==; IronPort-SDR: HydpIzew74hTs0EQdX6VrYv5caYbbeBHi13bvD0+UVTbooTPkhZZ03AiKqIWb477XFcehtJOZh IxzYCTPMFSx2WbX19vgClN+WvI9+AfvVIPss+whHJXroEoCUUxMsxfm3jMJmcJl8huz6AXpDly qnpfcmPXC02Y2w2U5TSrKW0QEaJRK95AsW5C3uEFYnByC7D1bMMdtIzJJpcQqpID90nv1Z58jp iOS+WieblqQJ2Po9idTQ7/vqKLZBQjR6sZAVIvhCJAtinsG8VqGJbdzVmUvLU/cmueVs+3Ngwp ZMU= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="163334305" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:36:40 +0800 IronPort-SDR: sRl8UN3jn7PLP1HQU/ERNT5+FR6HFiUalAGsIxL34FTwFTHvaCsQXwRi1xyI1t7BoWiiffEOJZ Wp4W/a1i1F3/CbLmd1P740KoBbpC7y6B2FnG/4iFIzmtoNsPU+wUUZFTOLg6cPWG32Ebdu1Zao V5R5hcYJcNJ7RoORxw2Vrid9wECF8IBXb7uXic6Kxfw1bJlOQPL3Hd2+w4G1TJ8IQA6TbvNInq iWBq+s6gunSPsvgN91GXKplC9OcR+XyXGvOc4qfIwkZ3HlbgbY9IgVqKn0oIFOiq1PG+1ji2NW Spoa+AahvLF9ZhJjzqwnwrZa Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:20:49 -0800 IronPort-SDR: oxPdTtIskpPSdb1F5rYWHN+L9w1GEDC8E31WYZ5SYqfb3jOpdAkKkojoUuY6shFskBZ1lzta0t EisgYWJdRiD3vvyZ2YQyMZXdLIeXlTT7K/ELlQwuos+vtW1qXokC7nShOW94ooV4wlreuwIKjr PgeZLl1NBpL1UVrx0MQ7CfZwPahoWZknvnLUcR+wif62kaS1CF9gqEqu0JNBGQQecZSiSbGGo/ xVgcppkkgbuEnKIvAexfT2gDX6XUi0FyMYnJ8VkSJgnADNFbhuHSORSxO4Xj7GBMY/0iluQxmX zNA= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:36:40 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 06/20] loop: add newline after variable declaration Date: Mon, 1 Feb 2021 21:35:38 -0800 Message-Id: <20210202053552.4844-7-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add a new line after variable declaration at the start of the function just like we have in the block layer code. No functional change in this patch. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 3f8d9bdfc16e..9e59adfd11ff 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -457,6 +457,7 @@ static int lo_req_flush(struct loop_device *lo, struct request *rq) { struct file *file = lo->lo_backing_file; int ret = vfs_fsync(file, 0); + if (unlikely(ret && ret != -EINVAL)) ret = -EIO; @@ -1584,6 +1585,7 @@ static int loop_set_capacity(struct loop_device *lo) static int loop_set_dio(struct loop_device *lo, unsigned long arg) { int error = -ENXIO; + if (lo->lo_state != Lo_bound) goto out; From patchwork Tue Feb 2 05:35:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79CECC433DB for ; Tue, 2 Feb 2021 05:37:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4376264EDC for ; Tue, 2 Feb 2021 05:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231733AbhBBFhr (ORCPT ); Tue, 2 Feb 2021 00:37:47 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:14105 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231638AbhBBFhr (ORCPT ); Tue, 2 Feb 2021 00:37:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244266; x=1643780266; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1JgN/d1M6nHcg9iqAe9HY4ryEam4iSXfnWjESknWn20=; b=SRFNh6E/tB1pkX4Wjq0bWbkyaPI+AEVELy+lscmaPmW8lBfuWj4DQxZ5 VJ+TfIDrvM0VS00sQha0q8MT90v6CNS26dYMnNH5Pj5nddhtSvGywRBCV og+3e4UWfHSrv8dSUE8WyqedsulMzlwo/zsa3bQ3Rk8EpB/2uVapCo0YF /lkszMvXoeEeon/vz/AlmpFyYlw0QdoLeMJMZUCoFcLZe/r/PzHshknGS o3QxvPr34BZ/OAApeBBCqm67no2rHiPHPlCGmettiApy9OxJ/VjSnhgyD 5MH4fZ6jZXiTP1bXlf0cX5j3VXPmL8OUNX6iHhPARXo1QlXADSIW/Srpg A==; IronPort-SDR: 01sqTRMDd+13s9BoX+quS/rxKqDiXQqgu4usdntQPwh5cENSpqv+ul38WFOgfDtRKVeLnM27HV UWFDV62oBfQM8Pj73BlYP4V04F1Ldg1OUJ5OcjdxAzn7FBGT7LcLv+KNd8v+JcVjrGoNcbjfLD BytIxUdmRRzUWR/CfdOydZgfQsbPaU3iwM06EKAvLz56m0OcOEPjFtvJRZh1eK8R4CdxituexQ wGUaVfpXTMWyfI+M7KQ3jDnroPx4DWJ3orffFygSOMrbPwXM9wswtrnD24qmckqsc219OKOuR5 ecs= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="158885717" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:36:48 +0800 IronPort-SDR: weYrxflmWXRPdmPKcF+agFJO5qdCWe8UFVA668LOgU51u3Y35GTOIbnlik9s6CanqPPI73sO7T HiQFWle85KGVTbTkLN7kW7zOWQZgZr09ITwUApLXmfQpQO3LKd3itKa8OeBae/YLg0rASGlZNd 9vJ1FeqIRXwPoDvlDFqQJnegXR1/IVn/ayi+PtjBVDG5SPOj4y/6JhqlgH5+tmtXDaVwX/rzNE eQ8a2Im7uFfOGdrMxq5Nd903gZBIOiwJKkLtuXa2rfIzor22+53EkgnswyogaR0saqwKSzC1a1 9+5FAr4pdBBZNrDtYfDMhU0f Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:20:57 -0800 IronPort-SDR: YCCvhJVoTC5tvKSCZAipI9AL3Z1GCxEWARz269+mc54Ul566BYpLNxVq1AWptF/ZtUJRcaYsxk R19Daxlf1Fu8z5Gy0bBWXnLuXnzZV/ko83iaRQu2wN6ilsBD7iKeEQf1nPDsqW6IA5BHDv1qZs 1c8EDSKxWNkR4svRo6JtjWP/lCfcIhAjfhKVGibHGi4DHxaU6yCaeIeBWB5MyTnUpk/BKeU+iG +9nI3E5aYTueY0w24rEQzr+fP79nsrI6bCtLkKLBdCFWHnzii9nwhOTIbyn3ADaHUGlycE1bLy +0k= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:36:48 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 07/20] loop: use uniform variable declaration style Date: Mon, 1 Feb 2021 21:35:39 -0800 Message-Id: <20210202053552.4844-8-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The mixing of two different styles of variable declaration cretes confusion for the new developer when adding the code. since this is a block driver use standard variable declaration present in the block layer. No functional change in this patch. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 9e59adfd11ff..c4458b3f1dab 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -669,8 +669,8 @@ static inline int is_loop_device(struct file *file) static int loop_validate_file(struct file *file, struct block_device *bdev) { - struct inode *inode = file->f_mapping->host; - struct file *f = file; + struct inode *inode = file->f_mapping->host; + struct file *f = file; /* Avoid recursion */ while (is_loop_device(f)) { @@ -701,9 +701,9 @@ static int loop_validate_file(struct file *file, struct block_device *bdev) static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, unsigned int arg) { - struct file *file = NULL, *old_file; - int error; - bool partscan; + struct file *file = NULL, *old_file; + bool partscan; + int error; error = mutex_lock_killable(&lo->lo_mutex); if (error) @@ -1069,13 +1069,13 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, struct block_device *bdev, const struct loop_config *config) { - struct file *file; - struct inode *inode; + struct file *file; + struct inode *inode; struct address_space *mapping; - int error; - loff_t size; - bool partscan; - unsigned short bsize; + int error; + loff_t size; + bool partscan; + unsigned short bsize; /* This is safe, since we have a reference from open(). */ __module_get(THIS_MODULE); From patchwork Tue Feb 2 05:35:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12EB3C433DB for ; Tue, 2 Feb 2021 05:38:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B245D64EDC for ; Tue, 2 Feb 2021 05:38:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbhBBFiF (ORCPT ); Tue, 2 Feb 2021 00:38:05 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:60410 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbhBBFiC (ORCPT ); Tue, 2 Feb 2021 00:38:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244281; x=1643780281; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/sbuZDoO/tuTi4agpwhNzOmQchNsnt7PWfWjd/zx47k=; b=W8XXCBIjCzx8GXrARbvC/itSlXs8EOdnkEpRdrrZsuzDMBSe5To4PB0j fEqpJlJ77rHEGMlFYnCYMtNu2dDmmrKG5U0yvrPiG5419bmJv+pm5iFOP +6A1VmGNHDfz8TQjXLU0/dQuA791yf20kbaxjQdlY+WGKOODrVFnUQ26Y PY+1kSGpt7X1TzGHfXYjH7Q0OjK/W6EMfrq9XdvAL1OuWdTZevhN7BAH+ 1MJGxFb3HXG0qI6MSV75a38FXhjMU8ZiovtfxA0HET+0u6bfMm/K6LnZ0 +T9+VpNZ4BlYqnH5o65a8nKeXi7pHOG78LOC0rR8Ady/3bmGCy9JhCylQ g==; IronPort-SDR: QJqvRF5uzVJAwsiY2wz/RO2HNIT+0JD+Jas0RNXwJANapdWXtFnRtha7iRxknRGflwHyL517kJ 7jh949NLod7ODSyYZEw1UufKK+HEWGLrlcv5sMe5FY2FL9xsQKZ4WCmgI16gMNTmfCFhuauSkX UUlglB65urpsRUFqdjFlNxoX2mKU/PSQsD/JbQJlv3w4yk1hUGMHXF9jJmfZ/3cXxe9LPhPVut 5N/fMdKCPhwON0FFd8LQ/52Ng/cXKnRJhz+jDqMwtA9bawt9cZpI6ireH87yb6dCmxlflQJNPr mAg= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="269301781" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:36:55 +0800 IronPort-SDR: cPD+KEjeJKpSggkrF2sbVQ30fDxAdvbrldONkh8gpTyCOYYsV7qMR+gfcJs8GsvVSE/VBqWDqM ezvL7brM5s1qB0x8REPTuGEIYDlGKWhdmCAKlPAlYazwwXeJVyp/PLjS7RXUjVrzgx9v4rE2Jv 2xSQdv+Wy9zxKTp+VVXVa0ZUFjujVO5D2AkEB+bO3DrqdUKOobDUJT57IRmf1cN34flNEvGGfh lIUqCZxh+GDzHpE7lOsoq0rmeWNTb9VP/nraxKm+0LXpQM++VKYEhkSXRnMuM/k8Q7MYm6x4CK 9gnN6F7Sgq59/vOjt+4BFP6p Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:21:05 -0800 IronPort-SDR: sDKPYjxpVz5VeXWvNW7FXoN/DGgx4jxfWwKDH4RGOD82jRua5eq4QzPFx9tvxWy7wWxXU6fVn6 YVV+XCuXe1x5npLwOnwFkacKiZ7QuB4vjm6G2jBpwWD6QAykL7VYd4cxyyM0M8IowoJw/sy6Vy inVlhZYgNIFzN/CJJ4FifglfmurTY4nBZyaq/7FRt4KQPYSwF6f2FBv1TLuRi3LoAcoRGyilnA REsrVeE/yvorU/M0rY9mJ4Olzfw32OMcwQxJAsD4/BWa2Xji8cVXT2hWCFWIS0qPrtAdwrfnWz q6E= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:36:56 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 08/20] loop: use uniform function header style Date: Mon, 1 Feb 2021 21:35:40 -0800 Message-Id: <20210202053552.4844-9-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org There are two different styles present in the code right now, that creates a confusion for a new developer on which style to follow. Since this is a block driver follow common coding style for the function header than having return type on the separate line and align the function parameters to the end of the function name. No functional change in this patch. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 85 +++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index c4458b3f1dab..b0a8d5b0641f 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -232,8 +232,7 @@ static void __loop_update_dio(struct loop_device *lo, bool dio) * loop_validate_block_size() - validates the passed in block size * @bsize: size to validate */ -static int -loop_validate_block_size(unsigned short bsize) +static int loop_validate_block_size(unsigned short bsize) { if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize)) return -EINVAL; @@ -255,11 +254,10 @@ static void loop_set_size(struct loop_device *lo, loff_t size) kobject_uevent(&disk_to_dev(lo->lo_disk)->kobj, KOBJ_CHANGE); } -static inline int -lo_do_transfer(struct loop_device *lo, int cmd, - struct page *rpage, unsigned roffs, - struct page *lpage, unsigned loffs, - int size, sector_t rblock) +static inline int lo_do_transfer(struct loop_device *lo, int cmd, + struct page *rpage, unsigned roffs, + struct page *lpage, unsigned loffs, + int size, sector_t rblock) { int ret; @@ -296,7 +294,7 @@ static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos) } static int lo_write_simple(struct loop_device *lo, struct request *rq, - loff_t pos) + loff_t pos) { struct bio_vec bvec; struct req_iterator iter; @@ -318,7 +316,7 @@ static int lo_write_simple(struct loop_device *lo, struct request *rq, * access to the destination pages of the backing file. */ static int lo_write_transfer(struct loop_device *lo, struct request *rq, - loff_t pos) + loff_t pos) { struct bio_vec bvec, b; struct req_iterator iter; @@ -348,7 +346,7 @@ static int lo_write_transfer(struct loop_device *lo, struct request *rq, } static int lo_read_simple(struct loop_device *lo, struct request *rq, - loff_t pos) + loff_t pos) { struct bio_vec bvec; struct req_iterator iter; @@ -377,7 +375,7 @@ static int lo_read_simple(struct loop_device *lo, struct request *rq, } static int lo_read_transfer(struct loop_device *lo, struct request *rq, - loff_t pos) + loff_t pos) { struct bio_vec bvec, b; struct req_iterator iter; @@ -964,8 +962,7 @@ static void loop_update_rotational(struct loop_device *lo) blk_queue_flag_clear(QUEUE_FLAG_NONROT, q); } -static int -loop_release_xfer(struct loop_device *lo) +static int loop_release_xfer(struct loop_device *lo) { int err = 0; struct loop_func_table *xfer = lo->lo_encryption; @@ -980,9 +977,8 @@ loop_release_xfer(struct loop_device *lo) return err; } -static int -loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer, - const struct loop_info64 *i) +static int loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer, + const struct loop_info64 *i) { int err = 0; @@ -1009,9 +1005,8 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer, * Configures the loop device parameters according to the passed * in loop_info64 configuration. */ -static int -loop_set_status_from_info(struct loop_device *lo, - const struct loop_info64 *info) +static int loop_set_status_from_info(struct loop_device *lo, + const struct loop_info64 *info) { int err; struct loop_func_table *xfer; @@ -1336,8 +1331,8 @@ static int loop_clr_fd(struct loop_device *lo) return __loop_clr_fd(lo, false); } -static int -loop_set_status(struct loop_device *lo, const struct loop_info64 *info) +static int loop_set_status(struct loop_device *lo, + const struct loop_info64 *info) { int err; struct block_device *bdev; @@ -1420,8 +1415,8 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) return err; } -static int -loop_get_status(struct loop_device *lo, struct loop_info64 *info) +static int loop_get_status(struct loop_device *lo, + struct loop_info64 *info) { struct path path; struct kstat stat; @@ -1464,8 +1459,8 @@ loop_get_status(struct loop_device *lo, struct loop_info64 *info) return ret; } -static void -loop_info64_from_old(const struct loop_info *info, struct loop_info64 *info64) +static void loop_info64_from_old(const struct loop_info *info, + struct loop_info64 *info64) { memset(info64, 0, sizeof(*info64)); info64->lo_number = info->lo_number; @@ -1486,8 +1481,8 @@ loop_info64_from_old(const struct loop_info *info, struct loop_info64 *info64) memcpy(info64->lo_encrypt_key, info->lo_encrypt_key, LO_KEY_SIZE); } -static int -loop_info64_to_old(const struct loop_info64 *info64, struct loop_info *info) +static int loop_info64_to_old(const struct loop_info64 *info64, + struct loop_info *info) { memset(info, 0, sizeof(*info)); info->lo_number = info64->lo_number; @@ -1516,8 +1511,8 @@ loop_info64_to_old(const struct loop_info64 *info64, struct loop_info *info) return 0; } -static int -loop_set_status_old(struct loop_device *lo, const struct loop_info __user *arg) +static int loop_set_status_old(struct loop_device *lo, + const struct loop_info __user *arg) { struct loop_info info; struct loop_info64 info64; @@ -1528,8 +1523,8 @@ loop_set_status_old(struct loop_device *lo, const struct loop_info __user *arg) return loop_set_status(lo, &info64); } -static int -loop_set_status64(struct loop_device *lo, const struct loop_info64 __user *arg) +static int loop_set_status64(struct loop_device *lo, + const struct loop_info64 __user *arg) { struct loop_info64 info64; @@ -1538,8 +1533,9 @@ loop_set_status64(struct loop_device *lo, const struct loop_info64 __user *arg) return loop_set_status(lo, &info64); } -static int -loop_get_status_old(struct loop_device *lo, struct loop_info __user *arg) { +static int loop_get_status_old(struct loop_device *lo, + struct loop_info __user *arg) +{ struct loop_info info; struct loop_info64 info64; int err; @@ -1555,8 +1551,9 @@ loop_get_status_old(struct loop_device *lo, struct loop_info __user *arg) { return err; } -static int -loop_get_status64(struct loop_device *lo, struct loop_info64 __user *arg) { +static int loop_get_status64(struct loop_device *lo, + struct loop_info64 __user *arg) +{ struct loop_info64 info64; int err; @@ -1660,8 +1657,8 @@ static int lo_simple_ioctl(struct loop_device *lo, unsigned int cmd, return err; } -static int lo_ioctl(struct block_device *bdev, fmode_t mode, - unsigned int cmd, unsigned long arg) +static int lo_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, + unsigned long arg) { struct loop_device *lo = bdev->bd_disk->private_data; void __user *argp = (void __user *) arg; @@ -1813,9 +1810,8 @@ loop_info64_to_compat(const struct loop_info64 *info64, return 0; } -static int -loop_set_status_compat(struct loop_device *lo, - const struct compat_loop_info __user *arg) +static int loop_set_status_compat(struct loop_device *lo, + const struct compat_loop_info __user *arg) { struct loop_info64 info64; int ret; @@ -1826,9 +1822,8 @@ loop_set_status_compat(struct loop_device *lo, return loop_set_status(lo, &info64); } -static int -loop_get_status_compat(struct loop_device *lo, - struct compat_loop_info __user *arg) +static int loop_get_status_compat(struct loop_device *lo, + struct compat_loop_info __user *arg) { struct loop_info64 info64; int err; @@ -1999,7 +1994,7 @@ EXPORT_SYMBOL(loop_register_transfer); EXPORT_SYMBOL(loop_unregister_transfer); static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx, - const struct blk_mq_queue_data *bd) + const struct blk_mq_queue_data *bd) { struct request *rq = bd->rq; struct loop_cmd *cmd = blk_mq_rq_to_pdu(rq); @@ -2068,7 +2063,7 @@ static void loop_queue_work(struct kthread_work *work) } static int loop_init_request(struct blk_mq_tag_set *set, struct request *rq, - unsigned int hctx_idx, unsigned int numa_node) + unsigned int hctx_idx, unsigned int numa_node) { struct loop_cmd *cmd = blk_mq_rq_to_pdu(rq); From patchwork Tue Feb 2 05:35:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72C59C433DB for ; Tue, 2 Feb 2021 05:38:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41F2064EDC for ; Tue, 2 Feb 2021 05:38:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231418AbhBBFiK (ORCPT ); Tue, 2 Feb 2021 00:38:10 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:8090 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbhBBFiK (ORCPT ); Tue, 2 Feb 2021 00:38:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244290; x=1643780290; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J3l4UcK4KfI5R3RyjBTsVpzeqWQLuT2XH/48XL/4l/s=; b=ckYGFa8HFJ6CNvL8k2IQgp2H+8M4STGb17Sac8rkcOXxIYMKogTJBlft yeGb73V+3sSYGN+2UHdYHzXFX0PgvfplUeAHu17ilcHM6sObngPyh1cuT U7zdMZAG21MTj/up6QQPy++mNh/JNDa3RLHPwl9pzyHhigDIEVJtLkLSv iE9wJvXCjOBG8dKFImv1+UTwHGgJhhw7vFRRDaRrrLQtycg1b6wdju6WM wE+Ed+NGM1EY4sCFMm9Mw+UIu5EVXCQLPeZBeGwwtGPYGEJep6cc0nBBx GoYDh2+9Z+JEE6Sv/a14XfWe8PZ07JJZR8udcR06WD4M1U1/e8sQfhElp g==; IronPort-SDR: xQIOLm8heO2AyoMiiJ5a4ZsmcrUVGQ5idxrFfcA7si2HArAxGTmCKeovQp2ygg2yFc/G9Cah0l jY2vOw4PUq7KNuf51Bl4pkg32Ge09Q6GUYed9CJBSEFrei6jBSeM7WRFmMg32mkoYvJjh4zPuX mChiNzoMFP/kRuxZ9oSvtYNvhRPLjOBE3R3suTxylj3zn4LMwlRkZ8xZxFctEBDUEWj4O7Grmf Y9rf1/2SvhXi/ImGrB1ostFQE+weKsZz90/oXk3nVLME9qYLXlYqgxtXzH2HfhpZBJs3INIrDb e0s= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="160067153" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:37:05 +0800 IronPort-SDR: t+XFUycY1WtLI2BSkqDPi7Jk8t6GV52Gnb0qTqvGRoeSUdIg7KinohQjzAmEuTtOLztBelbzR2 wSKy5tf/aHlD8OHJVklHymRRkh1HiPWxYREn22npVs5qEiqwBiCJiV4YOHziQuIuO0MvvKksd2 b2jA7pHkouEDalPp3dlkOp8uGfANAkRSbpDeaL1JqwdfDfJBMI8WRADqfoaZLkQss5YVstlcOH SmNUU91ZYnuz01b5Jn5c6SIU8GpeZLhf2N/eW0Gx5+vZwhtC3ZHCccNesHZCd+Hj6u9C1DSECJ UX5C8x01EUC/W7rnDCnL5Q1k Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:19:13 -0800 IronPort-SDR: pRwzTFY4tW2qX7Z1LUpQzPDTTeYjkv/ZYrcCchQi3N7g0HB30Z8ec6xV1PrVpD8AeKfa1LWIYC HeVL+afdYGjBTWizeliGYZMPFMBYtK22CQbfNGw0yAsYk9Ug3tbwrehQngXYJEVYNCy1VCI0Ed eycz5E91lPOq7Wsy9xURA7f2O5WKD2fzsZd/PR0jAat4xkOQe5jMMy4ZFpFvgY4iduq/liMx4B 7q/vFDiRadLYk/Yj2vVG/Jg+KfHe42YRaqtKtTNJ/9Mx8p9b1FKK5GxyvcJX+qletjdpwLnHla P/Y= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:37:04 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 09/20] loop: remove extra variable in lo_fallocate() Date: Mon, 1 Feb 2021 21:35:41 -0800 Message-Id: <20210202053552.4844-10-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The local variable q is used to pass it to the blk_queue_discard(). We can get away with using lo->lo_queue instead of storing in a local variable which is not used anywhere else. No functional change in this patch. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- drivers/block/loop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index b0a8d5b0641f..f9f352c7a56f 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -434,12 +434,11 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos, * information. */ struct file *file = lo->lo_backing_file; - struct request_queue *q = lo->lo_queue; int ret; mode |= FALLOC_FL_KEEP_SIZE; - if (!blk_queue_discard(q)) { + if (!blk_queue_discard(lo->lo_queue)) { ret = -EOPNOTSUPP; goto out; } From patchwork Tue Feb 2 05:35:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3956BC433DB for ; Tue, 2 Feb 2021 05:38:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6BCB64E9A for ; Tue, 2 Feb 2021 05:38:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbhBBFiU (ORCPT ); Tue, 2 Feb 2021 00:38:20 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:60445 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbhBBFiT (ORCPT ); Tue, 2 Feb 2021 00:38:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244299; x=1643780299; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ijnjlyOXhm33bFLZ7zcRqWwYHaWw4JzS5EwIft2ja8A=; b=pjJDAYYoikyR0CWj9HhoDD7wSyzrM3ighM5qAfWXAFXj6jJn5ZIE/IJa p1efoGfVfTajvXlzUF8bVFngFbkpgrs07O7RGc/x9Y0WPML1soohC4dd5 wW03HHXHVkMFlodTsX5svh2oGW/M5k2r9RcY0WcUSaSEflsxanwHFhr0v Ro98Z8Rupx1iPi7cVc7t/Wml0T725qzLuUIBxhs1LoUGOp1rfCReJ/qdf nYYS1ms5HClJYqLGzh+onwIFPqG2OHOgD0xY8tJi1cKmEiCut/iPmR0K9 eVEUEhKhApeGcpNpkqPq2t0CAteO7KuKG1qW+y7pcME6abq7CupWIb3cX g==; IronPort-SDR: ElyyHHobDrmvaZCxo9T7V7TzZylLsj8y3SxjcYcj/yrvGnJ6VwEYAC8l4ASS+K6pvZr9kNaRXH 7fpxxyW6dq8wqZ7En7LenfFSGWLA3PGwv0ecK85S2FMICBAMJKLqvt2jWZsEawhUDLMBoUh+Tv okAPuMRJpYS2+mXhnHfnqog8kZHj5djk4Hrs1iPnhToh+I7J7uU9AiolfrwWY73Q9mGORRoewE 0HzBWSrOURqbpJ4foIdidEubW4TeEcweS4y3URiX0RFTGQ46nlyeDgJlGqGbzr7FTlY7hIcPy/ EE8= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="269301858" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:37:13 +0800 IronPort-SDR: d35i9q1dCzFpwnGXnfkJ5C89Rk6p9lfMUYBJXSmxvHEMazdd9K7INKUmrAbkBLHKNQoETl1iuq 1zqCrJjJ4dUzLcDdRL37wpWz5DxgOU3RAtDHXH8i2P2srn6iVP45gSuaIW/dGm/Ty+5mljopN2 W5BiHQwAqZuhZRdSEh8c8+bvB1FiKb0aWvmOyxLLS4T3zRGwBSjkmhhxorYhq/BOT2iO+pkNRD 2fgw3sq3oV6b/OO11+3UIrD/NBj7Js5/CTEtTLur35+gvPk1JW4WyJhBYpneAgazC2hfOYbUfF n5DeKsGK/z8O9kWV7JwIF/zt Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:19:22 -0800 IronPort-SDR: 0vM/mEbpN0ehFTgO9NEWGD3ivDSgBv+NT1lUUTpBmziW0eZbsps+cTZgG77BjxpRNjIoauYeWm R4tIqG0SJfQ31Wbp+9CYZX8b5OuP3nNyJv3rRc5PgdoN6GjoH9FwAXYLmqkYGe5V1txsSSXvbd J9+fZzjzrUgV/2qQjWF+gzl5EEULUA5SmBPWMPBFLxQF1PkZ7H/wUVaj2+Z+xXgP0rutREMZbB glw99w3g6N7H7ml1B/ao/fkpDRWs8yOiA+0/4/nvXFd7dNxsdngvrE0Q3EsKmrjRxEZX+2v7QY 6Ns= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:37:13 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 10/20] loop: remove extra variable in lo_req_flush Date: Mon, 1 Feb 2021 21:35:42 -0800 Message-Id: <20210202053552.4844-11-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The local variable file is used to pass it to the vfs_fsync(). We can get away with using lo->lo_backing_file instead of storing in a local variable which is not used anywhere else. No functional change in this patch. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- drivers/block/loop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index f9f352c7a56f..b8028c6d5ecc 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -452,8 +452,7 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos, static int lo_req_flush(struct loop_device *lo, struct request *rq) { - struct file *file = lo->lo_backing_file; - int ret = vfs_fsync(file, 0); + int ret = vfs_fsync(lo->lo_backing_file, 0); if (unlikely(ret && ret != -EINVAL)) ret = -EIO; From patchwork Tue Feb 2 05:35:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34341C433E0 for ; Tue, 2 Feb 2021 05:38:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED84164EAC for ; Tue, 2 Feb 2021 05:38:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231600AbhBBFi3 (ORCPT ); Tue, 2 Feb 2021 00:38:29 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:8116 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbhBBFi1 (ORCPT ); Tue, 2 Feb 2021 00:38:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244307; x=1643780307; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qIVA0C3ycXIeiJRxPQOf+nQs3Rs9IxQg6NJhJdQlGOE=; b=MWMrXHqP0XVzflYiGdeJP/f3+JEsaGVlFWZhCkYlyrigH4ArTKdALpiV 1/K9u6rDPAZuXE4yvDkack3c/va/XNBDt2jdmKAMQSrfD/Cdo1J5mBjlh Duwp8Y1/r881v0UCO7zHtIntG+5dVQFYyMhocjuoNcE5AipKuV76l+JLr BI+WTAuM+spi+X15J182kW52XngsK6GYbuq7t9ymplUa6s9K5Q7H7tdtg C1JJnOpZRs2VR0zCCuRbIXu7hb8IerAXM+fdXnLgN1E+1mz1eUfSq2oq6 FQwetohC2MCYZrUR22dTR2xINM7PahmMPL2Y7couP6MOlN+bAeOCWbT7D A==; IronPort-SDR: T+s7MclAQ3znUNT0jATANHT6FFNHqMczlfELsptL5I/y8RrCk7T7fx10fhNvewaQ4elJAUpPnb 3LpQpzpO6FcFx/UAj06JOTGQs6RtfVNmWf2cmlZgKjJnxkgfOTreQXA0JDwYmOrFCjWo+CPIbv ruus4a7us0EfS0AN+X3Ty19tTK79aIJJ47E/7sUSexb2kmbuYAI08Nec9PzhiQ5fL7YY1AVNGh p6zyWPCtEcVH+chCm2T9+Y+zW4AmO+1C0Nh4KqHnFA4RFYwckOs+v0b9jgf4AV0Xsnzf5Y9+n4 xP4= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="160067226" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:37:22 +0800 IronPort-SDR: gYkf1nsMkV7S4xOiFsv3STXtyfz30jEMME22Uyrr0CGTispKdsoNsmLeErbvsvUejNmZJSsY32 XOshf5Cx3yf1Odev7fGHVzOO7h7eGM3nJPjzSzMhOyV2ol5XeSTXlwkEYlK72baNq4Mwklk1z3 Tjf2bj3+4xIG9NSweJjgrA0EzNg9K9Db0Ztr6h6e3a6LPTmZR9c7SThIjv+19LnO6aulimyKvQ rSXwpdaW5hEht0thvH6uOsF77GmfpIQRQXBS6FHUNXXyCkazzNSlzlrx264ElbGmCF7jYVlFtO RzbQsnIlQ7/pRvqP6XADxKFb Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:19:30 -0800 IronPort-SDR: fnsAWigMe+SnwnJnl0pgI1o0a1QknBMm+LZyfLd1kfs7BrCnwzq0L+SXKVuofpN+BYv3Y3vuWd qPS+IJCFsI6dEzZnIU2uQ9LckjDyqDiDaYFxJFbcfO7RpWO8rVcj76VHRrKfre1IqQKWEnTdII j8/s9zH7ceAr75qth7oZx644P0Jp+7vnD76huhgGoWY83zg42frSW7cAH4RyDWBwvLyoZssOZ8 fijSkNZsxWYSsEChwDUhwk0q3FvWPbvlA5/Smfuj5QOykp/Y1UruCCRUQJV2b8urXBKNI/L4Ev ZVU= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:37:21 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 11/20] loop: remove local variable in lo_compat_ioctl Date: Mon, 1 Feb 2021 21:35:43 -0800 Message-Id: <20210202053552.4844-12-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead of storing the return values into the err variable just return the err from switch cases, since we don't do anything after switch with that error but return. This also removes the need for the local variable err in lo_compat_ioctl(). No functional change in this patch. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- drivers/block/loop.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index b8028c6d5ecc..d9cd0ac3d947 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1838,17 +1838,14 @@ static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { struct loop_device *lo = bdev->bd_disk->private_data; - int err; switch(cmd) { case LOOP_SET_STATUS: - err = loop_set_status_compat(lo, - (const struct compat_loop_info __user *)arg); - break; + return loop_set_status_compat(lo, + (const struct compat_loop_info __user *)arg); case LOOP_GET_STATUS: - err = loop_get_status_compat(lo, - (struct compat_loop_info __user *)arg); - break; + return loop_get_status_compat(lo, + (struct compat_loop_info __user *)arg); case LOOP_SET_CAPACITY: case LOOP_CLR_FD: case LOOP_GET_STATUS64: @@ -1860,13 +1857,10 @@ static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode, case LOOP_CHANGE_FD: case LOOP_SET_BLOCK_SIZE: case LOOP_SET_DIRECT_IO: - err = lo_ioctl(bdev, mode, cmd, arg); - break; + return lo_ioctl(bdev, mode, cmd, arg); default: - err = -ENOIOCTLCMD; - break; + return -ENOIOCTLCMD; } - return err; } #endif From patchwork Tue Feb 2 05:35:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 771D7C433E6 for ; Tue, 2 Feb 2021 05:38:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B2B164EDC for ; Tue, 2 Feb 2021 05:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbhBBFij (ORCPT ); Tue, 2 Feb 2021 00:38:39 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:57154 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbhBBFig (ORCPT ); Tue, 2 Feb 2021 00:38:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244376; x=1643780376; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ca4BtS6m9c3hxquO+nIemXua1oS2Hi6c1Fi0pcfSFNQ=; b=cXgxoEyLKWMN9xtHB0xRdBKGDRiGFpa0qCbcQJTUHljVKUU3gbhsVbHp MU01EKMtY5DsmT/dQ56SRHtmr82C5PI+TVLbWMWqIPp/eQ5k1gICtywQP lwPV2O5gdEL/BtGdbw7XrcgJmXoHPmaJGZ2pBcl+ADlD/GeaQc6V/Z/CO YaJ2ExVuPg5k2vnfvBnWd+p5oNwmQP4irRftXEC21d6MPK22nrrVadFS3 1/OgEV76QeE4hD/jumrfjGGmheA+tkD8JfeOye5oEClLQla81a55oDeSl 99KpvSz5FFm5R62m3A3Wsit85Max9wUBG+/vr//GFNgItIJVB1P6oX/gW Q==; IronPort-SDR: G4QAA02N2NVedITNwiYb9Wl5kPDtzQJgIorPZh+DcWaNe174J5aMQysrWtKX8Xb2NUdnRJvEhQ UBZdn9UBB7KVr/sOqryIsxrulwhylgVeUSiGZ1J6SDstHRXschvjSHCPd8djdJ8aBScWeBbI52 PaXoYxWeMI5OlPwtfxzcX/vQ6M45gGZ77wPSthj8P2P8wyrmz98pT4HT9ugj6Jn1mbWcFLRIKf AGXJcIcI0S/mDc+Eoivw4rO22VxhHdeQ9pnsIM3+DtS1wJP+1GWwNGn2lAp1v9ARK0EAlyAre6 WRo= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="262961968" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:37:57 +0800 IronPort-SDR: YxNqbQoaIXCXCV5G8X4AXIEtIyKCGURwV7veYVbs9A/vxTN9d+VBLScGwehjswH3OJ4wMAXQYW ugFMHMnVtvUhUkpO+Wpw3Sav6M5IWrhWgKEGVHiYz3czkuI3455puTlzMXE1NA9V6CMOf1SXiy CjL+ZVSyKkdUQ/vyokRFHpWtgGwI2Lo3k8rTmqafQNkITDE01lymh67SjH4G4RVH7V/4zQ9oKU QfKbYOdwaMPWNxKu1KdxIP5RvinuFp9a7L3xSMcHzAgxu1HEeVONcnOP2GImlECjwR5wXoUANJ OXbf/4AcchwoBtzvC3Ilq+D0 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:19:38 -0800 IronPort-SDR: tjijzQnVTCpda5knOfgUMlI3nOnqdIWXqmNywZ9AmjC8s6ZbnVEjKbRxrXllsd++joWDCYoyRx r2TpgtHbd4VJLGNmvWCQB9df4LwzTQoRj27KH8TJDtJYSlPKz4Fsf6AX2lnxbrKfeK9NJG1F2F gig9fXf48Bc391ZNRFSRocrSguJTAUBVkxcWSMNsDipQpk2IYAyou2xjFjBf9BYGlEOXgJClgs uweSJPw7tnM4dACWskhwYUyWtL5vhaGQl5v8A1taGGO/cfg0LTuiNMd2ObIYv2S0vvMOSiFCQG EWg= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:37:29 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 12/20] loop: cleanup lo_ioctl() Date: Mon, 1 Feb 2021 21:35:44 -0800 Message-Id: <20210202053552.4844-13-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead of storing the return values into the err variable just return the err from switch cases, since we don't do anything after switch with that error but return. This also removes the need for the local variable err in lo_ioctl(). Instead of declaring config variable twice in the set_fd and configire switch cases declare and initialize the loop config variabel that removes the need for memset. Also, move status64 switch case near to set status case. No functional change in this patch. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index d9cd0ac3d947..bc074ad00eaf 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1660,48 +1660,35 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, { struct loop_device *lo = bdev->bd_disk->private_data; void __user *argp = (void __user *) arg; - int err; + struct loop_config config = { }; switch (cmd) { - case LOOP_SET_FD: { + case LOOP_SET_FD: /* * Legacy case - pass in a zeroed out struct loop_config with * only the file descriptor set , which corresponds with the * default parameters we'd have used otherwise. */ - struct loop_config config; - - memset(&config, 0, sizeof(config)); config.fd = arg; - return loop_configure(lo, mode, bdev, &config); - } - case LOOP_CONFIGURE: { - struct loop_config config; - + case LOOP_CONFIGURE: if (copy_from_user(&config, argp, sizeof(config))) return -EFAULT; - return loop_configure(lo, mode, bdev, &config); - } case LOOP_CHANGE_FD: return loop_change_fd(lo, bdev, arg); case LOOP_CLR_FD: return loop_clr_fd(lo); case LOOP_SET_STATUS: - err = -EPERM; - if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) { - err = loop_set_status_old(lo, argp); - } - break; + if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) + return loop_set_status_old(lo, argp); + return -EPERM; + case LOOP_SET_STATUS64: + if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) + return loop_set_status64(lo, argp); + return -EPERM; case LOOP_GET_STATUS: return loop_get_status_old(lo, argp); - case LOOP_SET_STATUS64: - err = -EPERM; - if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) { - err = loop_set_status64(lo, argp); - } - break; case LOOP_GET_STATUS64: return loop_get_status64(lo, argp); case LOOP_SET_CAPACITY: @@ -1711,11 +1698,8 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, return -EPERM; fallthrough; default: - err = lo_simple_ioctl(lo, cmd, arg); - break; + return lo_simple_ioctl(lo, cmd, arg); } - - return err; } #ifdef CONFIG_COMPAT From patchwork Tue Feb 2 05:35:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5656DC433DB for ; Tue, 2 Feb 2021 05:38:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C0F764E9A for ; Tue, 2 Feb 2021 05:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbhBBFip (ORCPT ); Tue, 2 Feb 2021 00:38:45 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:61659 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbhBBFin (ORCPT ); Tue, 2 Feb 2021 00:38:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244323; x=1643780323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EdSLA1bpRX99HWzdwxlVGl5OPKodEri8svg7+742Pqc=; b=hOaFH1U89xpMHJ30ZWJQrNHluLkt0Yg0ukumwmpZRD4UJh+qIX+cbFBs S1WpwDX6aj2R68jbAHFpaoka9eluwUqYiTS+OhzUJy+Ug3CO1lMwXQOMa r3o0ZF+FdTz3SntLZ4CRDWK5HG8Elt1Un2pn/upDVnu1S+b+o7mc3E1mn r9aa5FBoQYqne2aFta+8hmzS59GbJxfh0+Tu94gwr6lyCD8OOU3MA2t3P 83cDlKqEZ2G4aN+canzih8f/7+nSjVNciOAy7XwdFS+Ey70zEblUBFGzU +sNzaJBiG30lMEd7z1JlIqSR6heAdpBE/vt7H3fSSLVm8j6CZMVdRC/N9 A==; IronPort-SDR: 94RSs+sAjwJw3/weNuvI8n5uWOZNNIFk/Jod3Sbk68c58KaAmlQJa1P49zVLxqbuXuPAFvLmAG RX0EpbcC6tFBQ2eA20psyppnuDz3ikCt/+WVLxsu3NrFyQ1gqZV6zg0WGCfAgYOM/HVU6N2m1+ dCeey19fM+CpEpUPe5Jc81/2t9anvVsspiKclAmRw0tGC6UrZfaJonhpHkcUN013yedmfgogAf lDp4v2EWN1lusL9hmi2JwUPLD2tHTLgg+igzN8HIuXoCS+LvoDQNcnEfFj6xZwsAN4yqGfSZx4 7ps= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="158885251" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:37:37 +0800 IronPort-SDR: mehnlaBIjNK3pAZChDJK3+C+PsxOEdWexZlbaFcn4SqkmrYCOxWo5t5SKxUzRGP9jibUtbHGNm E1t8RVJmZe6685Ady8Rr9Yg58ULh2FpZd+86SqstikspP8OspAdWwljK/JJOXlbdWp7kA+7qz/ im8bnxyaknHKmZqdW7ASOhC00L2EqdWrzG3bgUyXmmxXpPMHVRWute/C/1qBP6Ayx7cQh8oSEN DSaGUQo0L3UWiIeY/6UyQFGGVnWyN0w3Crl0WfLhjIyjJxTCRhJOjWqSCPMz99JfrIfXAty90W U29J5S9kpUtc/tOqvru7JAbI Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:19:47 -0800 IronPort-SDR: 4pg1ogMUobThUMrFRUuuaYEHKs34e2ADjWSNlALGgWIqesWvtLHvKfUWIIp95kKoOsFqg134ST wBuWQlHYOwMit9EQdJKdEHVaGZE7A4WTazQykuPN1V4xsGQd2x3bLHwuGbumJhW3WNcLZpDzmZ raRPQJGEU9vuUkt6/7fWiY/BmUTnNMGllLjGhYBnSOlbuiEYA0k/H4rPPgLQWYTa3X8ph+eNk3 qIgHrMyUr9lzvKTEPxIaC2Wkqf40rq6FRT4ifaHdmijz9ra/m7FwFq6rzr8LEmjG1PhqH+NhIk 4Tc= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:37:38 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 13/20] loop: remove memset in info64 to compat Date: Mon, 1 Feb 2021 21:35:45 -0800 Message-Id: <20210202053552.4844-14-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Initialize the local variable info to zero at the time of declataion. this also remove the need for the memset(). No functional change in this patch. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- drivers/block/loop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index bc074ad00eaf..667a3945bf39 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1759,9 +1759,8 @@ static noinline int loop_info64_to_compat(const struct loop_info64 *info64, struct compat_loop_info __user *arg) { - struct compat_loop_info info; + struct compat_loop_info info = { }; - memset(&info, 0, sizeof(info)); info.lo_number = info64->lo_number; info.lo_device = info64->lo_device; info.lo_inode = info64->lo_inode; From patchwork Tue Feb 2 05:35:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19567C433E0 for ; Tue, 2 Feb 2021 05:38:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E066364EDC for ; Tue, 2 Feb 2021 05:38:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231633AbhBBFig (ORCPT ); Tue, 2 Feb 2021 00:38:36 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:43351 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231469AbhBBFif (ORCPT ); Tue, 2 Feb 2021 00:38:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244314; x=1643780314; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rA9+ridQg7jh92JA0OnVA5Iy1grqYZCG75rmKGzyURM=; b=a34jXNczBwsSg1qhDeoZ6wsLI2cFAkmEoWahx6zRAb9Jo6W+EKixOlAw 6+caQ8L7nXjCvJvlQz3CIUXZ+u6obVij2/BBMn/iL6sqFDsjwWnJrYdjT LKulQwhOxUCtRfwAi66GmlxdUJAGKH7wyp/JZi7sBlRpdLs74v2xOopHe JjBJ7b8a50PcNBp7ETSdqnCealZfV3vx4CFt+lXIvrru2xKSeBT1ft9uc 6MA2DfK1BaT+HqVT/gux1KZHA8ta4xHa59BtFQBKxCYPK5HXa/TRRSMdc nPbIzDU2nCK5iXnTwpLgqZmTeD2K4svhIrEa0sDyh4+sYhSgHVNsNrwwU g==; IronPort-SDR: K5pkJarrSIWijUQBivBDdng6zz0HM1W5r+sbU6vRRLHB1W+xUIhMCxNZIPYxpLNGK5oWCS3LCr Se9S5t6T/1eqhU9LV4MPpZwtaR1OljrCOiyn+lnjfm2ralpFjDkEAuwHS9/1xNlG0rKY+ZU3WF Smv7XIk77P6zBXdUlTmhy45wByAbIdBSTbGO898Qy4yzlsGRLi6MBx8zjhwVQj+Hyu2Sq8i+Sp RZFV3hp17I8tcn7jC2bFi6BbOidkLl7GOpMe+aGyH0wLtXwQHv9TSx9OKCN9r9aoS7W9w325DN gyU= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="163334455" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:37:45 +0800 IronPort-SDR: 2dl9FDbesQdFQ+37KYhgkhrVquBImaxdeNuB71Ha9YRh6joQkNr87AZyh2IKzVw714EjrPSTXV O8MmP60dtegZXcspK6VhfssD6Nke+IK4z/eZHSqYexG4qewzclHy2dI6pFLEQ7yNaBuH05NbHw TMkQ4e3dCcqoph0OK4LrKnNXG7Jmd2n7YrgU6xuLzQpsJOMyzi/01CgaFEBTRYiBUxqZg1u38s GW7AdTvC7QZ3HOWcO/vXF3feXd0sqfQf314T7SVkEEq3LQFmgBfVhOaZwzQNtPlUGG5OlnEqR+ ipi5oDqdILoD0UULgvGQP57c Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:19:55 -0800 IronPort-SDR: sz3UrHErxF3C6b0x4WAwYOG8BLErBVf1DNTHIxnl8mbJ75rulnsBHGwiOFjypjhSOlk7/5Ol+A e8dZSTX7vlZekgMrx4AsPs6PecmpZrcG7QofasU7n7uj4/b6Qgr8P967RVO8hL9jQ0v13SL8yk uxdDte5zhuFJLTpiDRuRRxaIxRL48gDzP/E5aChFZGqFVQYymfpR3KTZ0bu3IU/YTHO9iS+Vxm G4x3+I5C9e/XK/WPFIFJsVn46LksxRvSOdee1gOUes+z4qfTZ6nC3v+Www2d9Qav4xOdO6PJdf 0FQ= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:37:46 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 14/20] loop: remove memset in info64 from compat Date: Mon, 1 Feb 2021 21:35:46 -0800 Message-Id: <20210202053552.4844-15-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In current code loop_info64_from_compat() is only called from the one caller loop_set_status_compat(). Initialize the info64 local variable to zero before we pass it to the loop_info64_compat() so that we can get rid of the memset in the loop_info64_from_compat(). Signed-off-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- drivers/block/loop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 667a3945bf39..2029ca399ea3 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1731,7 +1731,6 @@ loop_info64_from_compat(const struct compat_loop_info __user *arg, if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; - memset(info64, 0, sizeof(*info64)); info64->lo_number = info.lo_number; info64->lo_device = info.lo_device; info64->lo_inode = info.lo_inode; @@ -1794,7 +1793,7 @@ loop_info64_to_compat(const struct loop_info64 *info64, static int loop_set_status_compat(struct loop_device *lo, const struct compat_loop_info __user *arg) { - struct loop_info64 info64; + struct loop_info64 info64 = { }; int ret; ret = loop_info64_from_compat(arg, &info64); From patchwork Tue Feb 2 05:35:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E14C433DB for ; Tue, 2 Feb 2021 05:39:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3A8264EAC for ; Tue, 2 Feb 2021 05:39:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231612AbhBBFjB (ORCPT ); Tue, 2 Feb 2021 00:39:01 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:14239 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231726AbhBBFi7 (ORCPT ); Tue, 2 Feb 2021 00:38:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244339; x=1643780339; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eNON0hxAzYtFyH9oqwN+bwV/btPzvN0uc/SZgJwurdw=; b=r3oBlrcPLFSdDGyEEhdvJEpEUJqwlEotvOxQFlBIM+jrZjD9zyYhfQIp IP6E4NzGOMIkjjrEXqc30K96+53YT3z98cXfMGjh3cfnDwMSdR+hrjyAt /LMCXNCWlaHFDFg2SNKbwNOjv6HPS1ItCdhCOO2HEhIVPcXs4mQfrz26X PvjRAP3OGKref/N7dqxpoZMyRkfZhN5B7qI7Q4m7qspXqZRQ5LDbJK697 orpfRA3JgYQHoZVP83lAuqAjW1nKGGNPgZ6kRsjWngOig3JVum5GThA3G OvbZZGUpTXeB/0UEsFZONPmzROgDKLSGWW+mRlwJgq67vfj/IJ4Wgr4ld w==; IronPort-SDR: sw42MJ0ADhJLtx14v/sjzy1LHIMVs6ohM+QGE6Dsxz9E7zpfKM+cLHAgIVt8dZVEwX50MdK/ZF tkMuWVhxbIrwSrxoiioOtXt+vClBb8txqTWbwcSyCrOnlbja8NU/LdAoqcl5sgC0HPMstsbvc6 2b3PIvhXgTcRrkB3jPmlx2S1b2jNWwqfLSkBtGKuPRtl008LFtO9z7oPxmJTRyCrz03HZfUZEc QKMhHcPX/h6ax51PaIlarklDQkoEXw9DYH8QtFcbEbp8VyvZxkUbIR2I6XL4mQW6VQvsTld9l5 aSA= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="158885864" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:37:53 +0800 IronPort-SDR: UeL+bcB4VQHZb8HeQi5uaFBEOFElYMRXQavrc1OUPFA3OsFhdjfD/k9/ZLykHOsqAYfAfay//q FofTHMHhQGSMrVGGhS+wOa1GDkcBFOkSjWpdObPPO53nqkKqsEDVoppCZbwVFp0lQqVNgUog7/ ztdlt2kXHI0NcZn0FyR1T1rn+MMww4yIz84VNFAgDVkY0Ufw6VA99hUlZNtXNLtTatpcbTa4Gb rTbPeo6Cv9uemtvXSVgL1MH1J8G7Dg9INiy0yCbutADKRjK0GMFOA55WSfGWfNBojxyMnbMMae c56G6y2O9S9omnHMTaJMqt+U Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:22:03 -0800 IronPort-SDR: UEzaKyFqz/3mWQH94JnkW+Dfu/9qmUj5jkaFV3YOPAGfw8wL/YpBy5Oc06YiaDBLgIbmdEbgvQ gfx6xUMjpOlyDKEkSnKwQwWmrfLhVGJFKumgVslPW5W7ZZY+EX9tdRlWnLtVc7T6hLsMDeFjHt bcoxqP15VLoXXCNBJEQM/MKMv8HhpwkPOg39VeKb1bPik03+vkPN/4T4/UEINWvEf+YPb3rx9n rbPpF6BGR3yaXzIed9gmeE9ragdJHyDisV+cBubxUVUjIjJpClFEHYsJTAbFulD6um5a94WzRg 2tU= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:37:54 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 15/20] loop: remove memset in loop_info64_from_old() Date: Mon, 1 Feb 2021 21:35:47 -0800 Message-Id: <20210202053552.4844-16-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In current code loop_info64_from_old() is only called from the one caller loop_set_status_old(). Initialize the info64 local variable to zero before we pass it to the loop_info64_from_old() so that we can get rid of the memset in the loop_info64_from_old(). Signed-off-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- drivers/block/loop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 2029ca399ea3..62f622791fb5 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1460,7 +1460,6 @@ static int loop_get_status(struct loop_device *lo, static void loop_info64_from_old(const struct loop_info *info, struct loop_info64 *info64) { - memset(info64, 0, sizeof(*info64)); info64->lo_number = info->lo_number; info64->lo_device = info->lo_device; info64->lo_inode = info->lo_inode; @@ -1513,7 +1512,7 @@ static int loop_set_status_old(struct loop_device *lo, const struct loop_info __user *arg) { struct loop_info info; - struct loop_info64 info64; + struct loop_info64 info64 = { }; if (copy_from_user(&info, arg, sizeof (struct loop_info))) return -EFAULT; From patchwork Tue Feb 2 05:35:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D760C433DB for ; Tue, 2 Feb 2021 05:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA8A064EDC for ; Tue, 2 Feb 2021 05:39:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231679AbhBBFjP (ORCPT ); Tue, 2 Feb 2021 00:39:15 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:61699 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231641AbhBBFjI (ORCPT ); Tue, 2 Feb 2021 00:39:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244347; x=1643780347; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+Q2jC0OPZ8uqyBmu9/DnQ3WNz+pA3U0nEaVOd/URfOg=; b=aULJxgjeWqNm+7haoQjKNw4+YlSZfPvCrSLpcFNJ+w1MiEnYbuiiSMM1 i/qvFtvOUjfX+AAuGOeRiTXOEbcC+jZ7bZ5gA/yzH5QBtXibiGRFG8CDv HO44qirgSOU58E5wsLd9iwWnCEb7i6E9K3xg49lCzi5xo1Tep6WzWZr1Y uPcLC9cPYv+/LcK4bo1oq6MbObVkmCcIx0YVQUROOVoJuVLj6uhmJIwGe rtQa5SyDHjsGveaYIQvyk7iJRdIPAl04l7hE/rt7b7rQZKyKB1KuU8xc5 CTuv0qy6nS6XaNBMap/Zk23xg6lgQQkArNDwZ9w1jmdox6Wzm4udM43nS A==; IronPort-SDR: WIo2OwMSm2IQpV6BypL5EOxVI95j1xPnhJFyI7nV2Yaewhc4nYjb70VZAnmTyi4T9OBBDmCIsO 4LSkQcg6EkdhX2jePK5nCu+HhgI7CfJxM0BBVoVHUVqCH/QlIC8abr4aejj8QGu53TOJC+dreD l0sMOw47qExnP2UdroQnA0NuZUcne2vPttvCqOCA5lXq5cdvgtUo+Q1dXCOjsD6ZI0QvH3r9RU yuD8ONYv67LdQMUmNp1aERasLMhbUEQAGAb+p2XK3p8YXWlw0+qNLhhr1HV46ygyeQQcIDggNY XDU= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="158885272" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:38:02 +0800 IronPort-SDR: 3DSoLkbUEVLQSFN4Bj/wauBnG3osqsc1w75sHoYDLa4T6xYv4X+NiNbayAf4A1KJuCEDauSRzm HAh3Eb1bsPK3NB2SxQbdykXR44WtWQ10RzSfctCtEDwJC38qApf1+o0h/7957BKv0a2FOJcqQz MTqSzuT5G+3xIr81CvKyC+kCbJynZpuLQADwNJPLJFwVxqsjg61g6JRTPcsp9Cuhgvdv1Wi/VY OjtZ3yL9u5eITC4Ky0l4xbar8A6SCExawTSKdPt7at1eZrTQnaVEnFzQcoDYOD+42AZkD/1vZQ VvE8FEd5By2tvsS57KhFmG/x Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:20:11 -0800 IronPort-SDR: 8nOar2qtKuOOqOWFnecwIgTuu4TLlKI+cCvdRRKN6X4O4QOpYuTATAP6deam6NPhcFVS6EWMD0 9Dswy6Sj3wz4nOiKYQLT0u6U+FSSFqBpe0v9aYYPg1vVc6S4+HuuR0fxJqU2XCnKIbbxxxBRty 2VXzBs5NqB8iSG3GBCsgX24iH09vfKP3ZJPspD/mHVKj1cNlTvl8SiAY/FFdbrbHBVSWhcTCqo OEclhsJTDDcMtZtcW91hacIv/3mz+HFIj8RJbIZDODc4HgZZTSqEde3RaqSkkcGDCTjwViln3l oT4= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:38:03 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 16/20] loop: remove memset in loop_info64_to_old() Date: Mon, 1 Feb 2021 21:35:48 -0800 Message-Id: <20210202053552.4844-17-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In current code loop_info64_to_old() is only called from the one caller loop_get_status_old(). Initialize the info local variable to zero before we pass it to the loop_info64_from_old() so that we can get rid of the memset in the loop_info64_to_old(). Signed-off-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- drivers/block/loop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 62f622791fb5..af3e3bcd564d 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1481,7 +1481,6 @@ static void loop_info64_from_old(const struct loop_info *info, static int loop_info64_to_old(const struct loop_info64 *info64, struct loop_info *info) { - memset(info, 0, sizeof(*info)); info->lo_number = info64->lo_number; info->lo_device = info64->lo_device; info->lo_inode = info64->lo_inode; @@ -1533,7 +1532,7 @@ static int loop_set_status64(struct loop_device *lo, static int loop_get_status_old(struct loop_device *lo, struct loop_info __user *arg) { - struct loop_info info; + struct loop_info info = { }; struct loop_info64 info64; int err; From patchwork Tue Feb 2 05:35:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A3E4C433DB for ; Tue, 2 Feb 2021 05:38:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F179264EDC for ; Tue, 2 Feb 2021 05:38:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231638AbhBBFiy (ORCPT ); Tue, 2 Feb 2021 00:38:54 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:8090 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231468AbhBBFiw (ORCPT ); Tue, 2 Feb 2021 00:38:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244332; x=1643780332; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jnkcazWpDtA8Y/1t9LF2AY34gS9NTjFtP15AuXyA4aY=; b=YvjydcCaoR8GFAsLQXa2FJ65CYDsjfRmVs/N5jZr0kqipOd7qx2u/nQ6 1IWi7bYSma0OKfn2/PRyOtq+OZXGo8HZ6Xwjjq587rYMmQ5dYZtJyqrFH hRXQnKTnzm+FSX+Lo0mHzrtjRDDRpn+tVhIBtxtgGwPLpPahgKWybE2rW 4KKk7xRrpCkV61jjkxZAcchwvhaicpdm5wxXJ2g7sEoPxaDCBDbGhac7J desZDeRsiJdGEOylRz1UE0t7z7b4Vv4DOR6xSb3lK5oinMtUMwYSC8CJm a4yep606pFR92W+qq6CqmAK9CdwUfJM5/T/H19nCsWxEjbNgMFQ3LKDD9 g==; IronPort-SDR: tx3uaULpnFcHkTBfI+jhXTKnH46bXZ59e7rRU8Sn2X3qBRumPzd4tdTnw6mMA+GDczhAJ5SuOI nyGo1XdtZjOx7mUpPYiRqZr68wHbc1vK6RR8ZkLieMcpZWL1mPrcEWMAg8iiFKl9F/XgRUuKtm RFeT8f4S5iQ2Jp1UNjXucNlcTtlRGWe7y2IrUzVnUX3e9vVqkDg4SGCCtTwMwcGckbdgiIf/yA TefrZJYPgPlgs+6BDtFZNgvcpDlaxQbDWRPF5DHFogCAXZB+FJc6AWQIUof0oReFM7surzOk1Q CAg= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="160067278" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:38:12 +0800 IronPort-SDR: pik/+1ZHAisv2neR3qyRg9vzWTKgkP0JCB5TkZCOE7ykbm3sFIFU4mc++lNod1YTLKYS7j3v44 nt2a98qvht4XXTYBdayrf3xBmq9Snvw1kjNSTO6a/z4G6kETg5WA1cTwtt8z6HSxuctcg2rkyO RhIY6Srk9Zl+Ed56aYUy66a47KlUSo/ixxDl4VLivzXTQPzkzYDkcMlKGpigsbMl18jLzLAeOm vA64DIHZlUanvvdnwwrbW8t38vhSai7Q6waRGXPpQSOJBcXRoM993vNj3O9cZxunCKWk3LV+o5 irHO/ywe0uerU79M97XHn7pk Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:22:20 -0800 IronPort-SDR: +5mOU5TXeULAnc7u0ZFohTur92kAZA/7wh4ZTTmc1l31xYEr64rTKX2bApvecARDLbQeIWk6cz PyxlSQsW6qYIO9oTWQle47AtZ4ELoTyjuPgV3IdtfeYAoOar4Wqa2LrK+BcWBYw/X90lNe3WGt NbrxCgLAkDoUY8gCtEHrFZZT9PWJZMn0YZfwofIWEVutZt3QYNDgOSmYo94BmQYfMpUJaI033n rJ6RcqYk/giWbpB5aFxkUe4U7b7f5mdrMWmDXI3EVY9PCGejzNKlvxuFzkjKHeD+59IQK99woq mgo= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:38:12 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 17/20] loop: change fd set err at actual error condition Date: Mon, 1 Feb 2021 21:35:49 -0800 Message-Id: <20210202053552.4844-18-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The function loop_change_fd() set error = -ENXIO before checking loop state, error = -EINVAL before checking loop flags, error = -EBADF before calling fget and error = -EINVAL before comparing the old file size to the new file file. None of these error values are reused for the above conditions. Conditionally set the error after we actually know that error condition is true instead of setting it before the if check. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index af3e3bcd564d..89f9c73bb2af 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -704,19 +704,22 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, error = mutex_lock_killable(&lo->lo_mutex); if (error) return error; - error = -ENXIO; - if (lo->lo_state != Lo_bound) + if (lo->lo_state != Lo_bound) { + error = -ENXIO; goto out_err; + } /* the loop device has to be read-only */ - error = -EINVAL; - if (!(lo->lo_flags & LO_FLAGS_READ_ONLY)) + if (!(lo->lo_flags & LO_FLAGS_READ_ONLY)) { + error = -EINVAL; goto out_err; + } - error = -EBADF; file = fget(arg); - if (!file) + if (!file) { + error = -EBADF; goto out_err; + } error = loop_validate_file(file, bdev); if (error) @@ -724,11 +727,11 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, old_file = lo->lo_backing_file; - error = -EINVAL; - /* size of the new backing store needs to be the same */ - if (get_loop_size(lo, file) != get_loop_size(lo, old_file)) + if (get_loop_size(lo, file) != get_loop_size(lo, old_file)) { + error = -EINVAL; goto out_err; + } /* and ... switch */ blk_mq_freeze_queue(lo->lo_queue); From patchwork Tue Feb 2 05:35:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBE38C433E0 for ; Tue, 2 Feb 2021 05:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EF3664EDE for ; Tue, 2 Feb 2021 05:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231641AbhBBFjQ (ORCPT ); Tue, 2 Feb 2021 00:39:16 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:8116 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231658AbhBBFjJ (ORCPT ); Tue, 2 Feb 2021 00:39:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244349; x=1643780349; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3RBDbYn543ZOL7s6ZUD1kK+SJdSkbPKc01sGuIleXx0=; b=i1eCB+j5LVPDsABmYG5sKlR65dNuRjTkNk06sI0sk6YaY4DnxVwiavwF cijo1Hb5bD/8aMsqPPm/C3leqOx8oD+YarZQ6uSIug9jy4V5oKYiOQV3f 9tlpo027toP6Sx/uTjKU2tHN0qKXsi6SZpn5gnJKQBz879iDmoRh8NEyL Q2btBrkR0K8H6T455sdpsIqRYRg4bRnI33eTw8g92o0ZNxDqDkAs3/C1m n9UAomzEQyEkjEQ1Xna3JnXUCMm2t+0gZGDlHhxsixnq/McXVjWujQMaB fXyIZsADuCD4/VKUsP8bEkCfiepL681lgX1Vu6qFBVQvfNy/Yp81E6WM+ w==; IronPort-SDR: hJHsq1DxKBtcfP2RC7bH113ob2zeNuNKl8nN8ptsWzGTLVlQBSZSiugDBVgHmPDnFc/+KkkWWf kPROHz2Pk/GxcMLQiA6ZDCwGCbBQ84SOPchhyZsaF3xXDU0V/cIh1wStFeMizSVxT2qg6aEQUv ssNuUhBZKvtsz1YlOgvBqHJGp5OW9CUcjEWx8vYMewXiTb/c/E1mPX1KatVu2pQ5Nvv9P8f8RP bGSUKtBZ6CRLHJmfwmAtu8wIPIX0stQzn5otDu93V0SvW3jszi6S0hKNn/4GiCIyuLzHxDIDoj D+s= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="160067286" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:38:20 +0800 IronPort-SDR: sVbGT3N3AxDFBH9jQA4MWoLvLaFpXyVs7WbpG/N93TqTnw6UHJaGH3NpDnZlbFGCF+8Prx10NM s+XlsGeEu1f9Z0wB1Ptj0oCpsE4jvO1e0/yHUKRY1sd48grlK4Z8Crku+rYwRtlkeMDmgYmw8s l65+LzJPkl/pIQCfRAHkezC5H1aaZVHI+5SRuq5TLyGFfS60VIinsaSgC2nUjwkHAB5EJp6jvu S/iuQedy+svrQhsPCFxVTcztfiQUAywU0oxpLBHmj0j3pYV3K+5Pu7i55Kmi0XS74NFCaIMCSu bKKxjN/yyXH2ZkP0uGEL2S+L Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:22:29 -0800 IronPort-SDR: 1i8xr1R2g4aEPYzFHu7lKcGcS8I3TgEajL/ed2c0JC6KeJ0mTpHktFUZEtGhLPpOraBlEmhvCs rhLPYuvIBMpJ6I9zVrMVlocTKDUGNlgx99CzzCxpgrTYwhITaDPSKuzns+ppSuijejM7u4NCzg QuSIFFdV+zko+zkheekYiNktT42QXi4dFpb4BQ2HBqM+RQ4CFWPJtw3Qwh8nz9TWV6QB8zoqJW 5cY0mSN758Wj/UZ95S6YTq7dnlaJMCXDG2uLJLKwk4dtAxxUtq5raNNbFNE7BpfeZjbGH8Ere9 xXQ= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:38:20 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 18/20] loop: configure set err at actual error condition Date: Mon, 1 Feb 2021 21:35:50 -0800 Message-Id: <20210202053552.4844-19-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The function loop_configure() set error = -EBADF before calling fget(), error = -EBUSY before checking the state. None of these error values are reused for the above conditions. Conditionally set the error after we actually know that error condition is true instead of setting it before the if check. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 89f9c73bb2af..d99ae348e4e2 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1076,10 +1076,11 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, /* This is safe, since we have a reference from open(). */ __module_get(THIS_MODULE); - error = -EBADF; file = fget(config->fd); - if (!file) + if (!file) { + error = -EBADF; goto out; + } /* * If we don't hold exclusive handle for the device, upgrade to it @@ -1095,9 +1096,10 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, if (error) goto out_bdev; - error = -EBUSY; - if (lo->lo_state != Lo_unbound) + if (lo->lo_state != Lo_unbound) { + error = -EBUSY; goto out_unlock; + } error = loop_validate_file(file, bdev); if (error) From patchwork Tue Feb 2 05:35:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6B8FC433E0 for ; Tue, 2 Feb 2021 05:39:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A935D64EDC for ; Tue, 2 Feb 2021 05:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231706AbhBBFjZ (ORCPT ); Tue, 2 Feb 2021 00:39:25 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:61659 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbhBBFjZ (ORCPT ); Tue, 2 Feb 2021 00:39:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244364; x=1643780364; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wJVVyt+ZPivAtc76C1nI9owyC0Ff5319BZC4lKhOGIk=; b=lgCczbERwwAOLMOCAbOMr0zhKXwx5lvh0o5hSW2NfogMZTi3ln1HF/pd vLLLwsmv6cO1iQs2hOBSjJfxf7+KmruVDIRiiy1v1x1eysU6PbLu7KiDn 1T2dHLDUrg6O19NNwX+icgKcqqWJNOrOgJT0fFUdSmFfuXBRu7F54qbmD jyVcS6Gq87M7Qn0I0M3BymE9OH7/wuGpZNE/MR3XgyoTt6Lqd5mlKwOOn PwtX/dUkZtdcDy+M4Yfu9+AAZ4VFcnkI6v+sIpp/Y/1EVTt62+aN+EiGA RDF12RMP8royNdpvy/GU6pJ+a1Pg77hLJ7qXRUliCFgYE8AK8dXgivGL4 Q==; IronPort-SDR: pAd/r1oF8mCnZS+nyC+lhuJcfHlGsce2JqCWpGHgCSJFdgfr5HjbFO0oM3v877vy+kgu5P/qKT WyLIuGiGZzUkcPiKGNNW/jJFvHOivmzaCYx6TSuUdoVFxhspEV1GSLd7qSe4AH8IShmVgcMSyY SfH7stkmgI/Q6kjOJ4WMnlUpSNOgLYn7/SwjcawnH3e+xyz/DHnfoaQLYaBQCj9wzbEB3PC0+y hhaGDu+KAnzLUZAimCI2RVl61C5FHXKqNaQQ/H4Ogf4IZcfNyhUvAMcYWInF766mcYmxiZzmRB Hgs= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="158885310" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:38:29 +0800 IronPort-SDR: q8D9t0JtKwwMYCl3JfM8WQu1L9n0I6A1SKnI/bL1mPTqnwXbROO8/onl+kfgDqgj0uOmVQBgEU OdWwyxdyO63Qj6t3LmPMPO3baJB7eV7yVCYw9kQmg7MKPe6bWzvwGv7sZ5VCbwtcFNncf54bKG +iv+PkEaHRTEPEf1Ly8gbuCMUl7oC9VJGaxe/1zy+vfAZZD2H3V4UqM2uFHWrkZGsql6ydpCDl PsrgJLBKMu8/wrCNLX28HUXVmNJ0cEuEB40rD/4igzc7Td35yMp6GkgA84nRiPDR1dzOyf+Zfz nZO/kp9GH3K/RRS7AJG3iZF9 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:20:39 -0800 IronPort-SDR: PyYOk4TefLy5M2xByp3EsELWltBszA9fzJI5c1s8Q+Vhv29xbkXfPOyxzrkJVIBjc9veuySyjZ EOVIndrjuZeksTQNpUcybfMWdOt5YCrlR9/gUJdY0Ur4HeZ5+YzMqPGVNVpJ5HnvgFwFf1qeXu Q95lv09UriSWMQCf9Z4xI5vLSBL48Jm+ETJOl5ggT8ymCwR7sK6yEN+mDoeiKAauwv081w11Ev Ue15ccvMtG70tGI8rnmNLZ3hAyW2hzVqvd2bCIOcv59jBUinlzytp8AsRdhgkzDceTpS/4IcD8 udk= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:38:30 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 19/20] loop: set error value in case of actual error Date: Mon, 1 Feb 2021 21:35:51 -0800 Message-Id: <20210202053552.4844-20-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The function add loop_add() set err = -ENOMEM before the call to kzalloc(), err = -ENOMEM before the call to alloc_disk(). None of these error number values are shared. That requires err to be set explicitly before actual error happens. Conditionally set the error after we actually know that error condition is true insted of setting it before the if check. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index d99ae348e4e2..ef70795e36ab 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2062,10 +2062,11 @@ static int loop_add(struct loop_device **l, int i) lockdep_assert_held(&loop_ctl_mutex); - err = -ENOMEM; lo = kzalloc(sizeof(*lo), GFP_KERNEL); - if (!lo) + if (!lo) { + err = -ENOMEM; goto out; + } lo->lo_state = Lo_unbound; @@ -2081,7 +2082,6 @@ static int loop_add(struct loop_device **l, int i) goto out_free_dev; i = err; - err = -ENOMEM; lo->tag_set.ops = &loop_mq_ops; lo->tag_set.nr_hw_queues = 1; lo->tag_set.queue_depth = hw_queue_depth; @@ -2091,8 +2091,10 @@ static int loop_add(struct loop_device **l, int i) lo->tag_set.driver_data = lo; err = blk_mq_alloc_tag_set(&lo->tag_set); - if (err) + if (err) { + err = -ENOMEM; goto out_free_idr; + } lo->lo_queue = blk_mq_init_queue(&lo->tag_set); if (IS_ERR(lo->lo_queue)) { @@ -2111,10 +2113,11 @@ static int loop_add(struct loop_device **l, int i) */ blk_queue_flag_set(QUEUE_FLAG_NOMERGES, lo->lo_queue); - err = -ENOMEM; disk = lo->lo_disk = alloc_disk(1 << part_shift); - if (!disk) + if (!disk) { + err = -ENOMEM; goto out_free_queue; + } /* * Disable partition scanning by default. The in-kernel partition From patchwork Tue Feb 2 05:35:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12060721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DD66C433DB for ; Tue, 2 Feb 2021 05:39:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 022D364EDC for ; Tue, 2 Feb 2021 05:39:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231658AbhBBFjU (ORCPT ); Tue, 2 Feb 2021 00:39:20 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:43351 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbhBBFjT (ORCPT ); Tue, 2 Feb 2021 00:39:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1612244358; x=1643780358; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ohU0hoBnxnVD7RrmFfsPWCRZPgRPY5M/4trVfv1J0Ug=; b=B6g3d4IT/mGkvPH8mWBDPSPAG/ybd7cqIQJRg8L9xCg8jqKoRFlGeC6o 5THB0dlBYQHvJRjg+2m8l4TlLlksdQ/ef4Porf2ue102b8M+bVUow65s9 uPNigIO9qQioUqYNcy3wKbrZlZgMfDdXJ6+bMDjFwpBAOjTbuN5pwrE+a WfBNymOmo3sfx0dmD6UGM7xH0TFuFyWWftxT4P6tZk2Je7YB3TYM3FWZk mhk9G+4jNc95xzgYC9K8Vtm550h8OsVCgJxKYCwB58PVAmTKqDdAXHVnX R7AxfIdwSwxj2izSCYLwmegUlNL9K3FLDjrmt9YpEaWEEbIdrr2LvTpAb A==; IronPort-SDR: fXXp81jf8DVpf802unacaP2RAd//Ngw3QkTCVe6titzzPmwFtLQfAftIwd8fDE4Ew8/pBJFmpe ZOjTF4QzF31MjSJHAOPpxg+2iCm7fRF0V+l6IYJ7EF7quXZYO9ivtuDHY6HNX1aJgUtF76PF6G 4uy4voGpIbxjYUNBqfzbbq2ygCtW9CMF2p7jybH9u3WOG/53TAjyze8poba8/krj30PyF+HweE fncwPfYFu/lnKu3PVDmuU6xjApwli5qabJUFC0zcF4BiebasAB4Ts2Cxxwff/aKkzctGarSBIJ D7o= X-IronPort-AV: E=Sophos;i="5.79,394,1602518400"; d="scan'208";a="163334507" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Feb 2021 13:38:38 +0800 IronPort-SDR: QTO/kDHmt6U32a4VXvMyqroR47FPSwBgsFj0q2Fms/YHIWOp5gHI6CpJSPmcfhEWZz+J/femdm GuWQG5Z9oG1Lpv7WvPP+kb/CyXa/fnAWhMUNu+MpcI1QzIdLBsc6cKHxjxhv2sSSXv8YU10nwH rsVygq9h3/MsIt38HNv4/wyTF7gswPZXWr67mWEU3ytW04SGI54/9hPvEnA+YjAkzlikbVUpSF JDNY5V8f9a8VUokJWHt0sPUSInsi1JrvgMvxKyREy9BzjQ1basfyNPATpBAGpJYnsl7hEjIcys FffBKVjAYA5rn+H2WefgHDmF Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 21:22:47 -0800 IronPort-SDR: YdnTVhZiLQYId5VS+WERx7iRFtIki0Eaxihwdjkj3CJGczfRfjJeHDHGn8OEHZQv4MNj5eUMF4 9LogNh2kdIXvaEaiPo3tf1JekTUlf7/7Zt/oVvbUcUlKiDuoJ8JKtjM0LHUVQNXLr36oVdu1uM ZDxCRi/VPSFEMZp/ftt0rGW8IZE6jI4zaJIRvWt1JPkpJxMm5KGCUB4UwBfZXd5bWMQ2oxzrZO Vxi/WAs1tbltfg03TB6ayNk8YQ/jJ64VwA3wEGtMbteVPFYMOfnukjuSgrU3h3dRflUMBbmIaV Y24= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Feb 2021 21:38:38 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [RFC PATCH 20/20] loop: remove the extra line in declaration Date: Mon, 1 Feb 2021 21:35:52 -0800 Message-Id: <20210202053552.4844-21-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> References: <20210202053552.4844-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The initialization line fits into the one line nicely no need to break it to the next line. No functional change in this patch. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- drivers/block/loop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index ef70795e36ab..e691a8c6b04a 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2033,8 +2033,7 @@ static void loop_handle_cmd(struct loop_cmd *cmd) static void loop_queue_work(struct kthread_work *work) { - struct loop_cmd *cmd = - container_of(work, struct loop_cmd, work); + struct loop_cmd *cmd = container_of(work, struct loop_cmd, work); loop_handle_cmd(cmd); }