From patchwork Tue Jun 22 23:19: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: 12338729 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 62D9BC2B9F4 for ; Tue, 22 Jun 2021 23:20:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47F3960FE3 for ; Tue, 22 Jun 2021 23:20:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbhFVXWh (ORCPT ); Tue, 22 Jun 2021 19:22:37 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:13293 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229833AbhFVXWg (ORCPT ); Tue, 22 Jun 2021 19:22:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1624404021; x=1655940021; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FHYthCo6y2D8P2noT1iu3VWbPN7E+He+UXKaBy5aFXY=; b=WCGkTjpIPCvm9SfcQPl1AUF4OEfUG0vukm81Xz5UF0qDFNhrHy8U9rDw oRV2idTIcjOE3yhWdkz0saln6sxmOjPXX19vE+ssK8Q6nHColHdgUwMpG pWWNA3wGYNBA3bV8n0buCebwislVQMyjnkqkVwl03OarpqqtBcvlgc4VQ HIqKAFhkKZqP9MBtoEXgJrec9xp4ylapi9NXC1M7MVc/R4VcD7apwilKz PZ+8iU6is7QQo2MK8EKmylIYXH30rw4kn6nU9mqnLNsGhiny78fPHdzgm 9DHWBQOMzbfONCa1t90Sz0p3/ZmvCjUXdkcPkKQB0ExuKoDN+PidPPQdZ Q==; IronPort-SDR: ix6eArFwIsHOS/et80oVkIysl9LQykNWEs3EoDRaD8CAxbCsaxv1lvvb943V7mPOBgGF2rU76R KHQkyMhFgW8cI9BaZboFZn2qpr0nAbIOvv4gAcHsKxwHYOebP6Iqg+l1fX0w2fGCGC8U6hei3a X2tfhAAbQQgm+fcDjBOe3lqZDND7JkD8mj72h3+pB0hgqCM4CkSGbar09gsTTsPWN2HMlG5DuF z9fyKLeFH9ptY/1x3IZNs8PyGONSwbWIgzUmV2VEcTnZ7fPn7Vf7zcHf+Yp9G0bjBsFoiQ08aA /A4= X-IronPort-AV: E=Sophos;i="5.83,292,1616428800"; d="scan'208";a="276419072" 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; 23 Jun 2021 07:20:29 +0800 IronPort-SDR: DBYSUF+fSlcmDZeunPrnhfpgPIU8MJEG2PXazkNCdKAJtMPOD1oWP3bW4ycpVkIGdzLXrwgN3l nlBrT1wmlNp4z5pH92Eh8L5LsQFFhvobVl5kAYk2P8zE/S6RlfzWqI68fErl5xTFPix3kSknkf Ltfltr8HqDIy5TXWpZDoS62KAfDYDQ4kY9xdSTlrwSMBo7d+qJPk2/wpCf0lgSgGJx0UZ/KM7K DHkL0pSvjDDPs8pRmnPzMVVEMy+XgsMcu275LkfQoAafCPSwbXixtp60iJValxLTZ0bVNr8l5+ JNPxPTiNZcmZR5QSqSZR6jn+ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:57:26 -0700 IronPort-SDR: 3j0+j1yabzmT1QTW92oQHXoYoopE2TjIUIBAULgDV8iGwxJVni45uNv+6Y5OxtM95UFHiQBDFY ILgjqcEomYIqAwU7EB/ub/UGRKUdpbhCV/T4fttFxr7woVphQRJkoX466ZvKWo93KIhzNnKgMp pIxrfhRe9E48Qgx8uOc40WdlVlB16r3IJ7anz/GzEIiBw/LzrdYBfkgrSBpbYwgS3HTl6XgMsG EJEmK7B12U8SQHAHK6QThQ4gYVMJMRQvpeQ/ixKFHtq6iiqfmk/K0eOBBDv2zIpNOZo5/kBynz Yzw= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2021 16:20:10 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 1/9] loop: use sysfs_emit() in the sysfs offset show Date: Tue, 22 Jun 2021 16:19:43 -0700 Message-Id: <20210622231952.5625-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1.dirty In-Reply-To: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> References: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Output defects can exist in sysfs content using sprintf and snprintf. sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows that the size of the temporary buffer and ensures that no overrun is done for offset attribute. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 081eb9aaeba8..847faa6c48fc 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -807,7 +807,7 @@ 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 sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_offset); } static ssize_t loop_attr_sizelimit_show(struct loop_device *lo, char *buf) From patchwork Tue Jun 22 23:19: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: 12338731 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 8E0ACC48BE5 for ; Tue, 22 Jun 2021 23:20:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 774DF600EF for ; Tue, 22 Jun 2021 23:20:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbhFVXWi (ORCPT ); Tue, 22 Jun 2021 19:22:38 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:5566 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbhFVXWh (ORCPT ); Tue, 22 Jun 2021 19:22:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1624404020; x=1655940020; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bivCQGXwuOn77OzvqHMukBeOj693hXYMPyQOqoyfTxU=; b=NUUgpxQcw0vdTpk8CXa1VgUZ4TL69DbGkrXPxpewlHcjB1RyOHBulGET FS/0TiZQMVQzSzEqZql9b3IsRjxGacw9b1mwd75vsoEXeKP0iSlfec46Y dzPzPK84HcCkBTfm4ukqQuA1KySfQQ+wb6EDGhlWBcB+pSWnTUT8+xqMY xCo5xw4Ac6EPqdmKc/HQkA/lYkpLQBA5RbaoQswuUFYAji2+A/TKnqlq1 al920mBEzPvN7XbKO7IDP30Qq5W14R67osFR7yBHy6R4xj5PbJoTk7U9+ zN8Y69a3sHo53DINC0hHR/OCWiSTEap0ACQBbnR6fThluIqjzpEnT6Ags g==; IronPort-SDR: b8gQVEH3xn5w6d1PzfjLbLMiFcqJC4vWEk32dLt1j+cl5shboXGki/HN9smjEgza7Z1xIjPNob G1qQp2IvfocdTg+vFlOeHWujsogR/4UlH9m+XitdZI//kLMBGeCM7hgFZCkF+akSP/6FJYvNi/ Jkgf0a89DC6ZG6EtpEgOHn7VqbnE4VlluB2FNKUBS2NmtXK3jitjf1eOib+AzNrDAuWDi4XkAV SJT4XU6KjORGXWokhYiFqYowVLudYNbQkHcxKpEJ/tbhFWfSUyUfXZSCMxVcclzPApg1jtGW8d ipE= X-IronPort-AV: E=Sophos;i="5.83,292,1616428800"; d="scan'208";a="177421333" 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; 23 Jun 2021 07:20:19 +0800 IronPort-SDR: pUIlU+r2B2tCfA4oDszfIfgOBEk0112T2R/U5ULMPLSfRzW3CqPRMx7FCf4YJoz6ue6d7JN2vl UNt/ihU3gqdUbtPMIgpz4iWgNILicP/Mzs72vZvsLxyqFasw18Ll89+PeTGgGjTXx/yFNuEUvZ 93yiEHIhkQnuWbp0WwoPBdLV9qrKGaSisdNYGLjrXyu7rPUrjO3OSYuMx/iDz66AEDU3TQUYem uzHmj7tfD0F5kquMl9POGg/82QiENki+vwRwbu6bU8h1PB8W4V+JpxvlC8W9dgNpfo5FGV/mQU 04EULdlvXC+C/Z8HaNLoyMrc Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:57:36 -0700 IronPort-SDR: cvCtA8lrXJ8VKgYbW71j1EboSPRupSu6QJDcfdnvO0C5l0bjf3ThC7EWDYekzN7CxsDzUuYrOa /dY1tmoGqJyxfOqfWrePSnxvtvcEMsZlDteCHU75Y3vw146K8TRCX8T3eC99GjPVpoDQaNEzen B0k4Q4tLto0BnlasUMyatQJu7wWXFSLlYbQIsEb5VotD49yuEu4NKFP0EC2etryJWpYfNfYmgd ndWUIjC65mStuGFG4EhUIFghFKgjvMlKChVBkTNU2CbHs1xStNdU92hXbKoAZpT+GggEBSKdQt DjU= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2021 16:20:20 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 2/9] loop: use sysfs_emit() in the sysfs sizelimit show Date: Tue, 22 Jun 2021 16:19:44 -0700 Message-Id: <20210622231952.5625-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1.dirty In-Reply-To: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> References: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Output defects can exist in sysfs content using sprintf and snprintf. sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows that the size of the temporary buffer and ensures that no overrun is done for sizelimit attribute. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 847faa6c48fc..084fa914a399 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -812,7 +812,7 @@ static ssize_t loop_attr_offset_show(struct loop_device *lo, char *buf) 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 sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit); } static ssize_t loop_attr_autoclear_show(struct loop_device *lo, char *buf) From patchwork Tue Jun 22 23:19: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: 12338733 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 8E06CC2B9F4 for ; Tue, 22 Jun 2021 23:20:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 777F360FE3 for ; Tue, 22 Jun 2021 23:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbhFVXWq (ORCPT ); Tue, 22 Jun 2021 19:22:46 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:13320 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbhFVXWq (ORCPT ); Tue, 22 Jun 2021 19:22:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1624404036; x=1655940036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9nbTJ+gg0XaJsT5Gy2yJ9AVn3OP0irj0uDzoD29dxVQ=; b=kUqcHLcHCMIgIpBo3UHXQlP8PI0UzB5gSwSXt+hf6cM3yxvGDWhwIspK r/WQTrrazP0T8NMKmQmq4X84WFIZPVV75p+ksV/Vx3pLyiY9qDHEIYXo7 yYqEoShnnO0UbbrGFdwxdH463wSge9WYZ6Tz6DrzVpEDpr1Q4cm/lJZxc ZtLc+d/nVSbEQN6BgOnu9UI6uL41X7iJgptbF6lUY4pjCNCP2KhWQ3Sk8 Zm7JG8IMpSpo9twWIEkJG6usb49KW8e5yXnwko3cbIoo7Oc6JK7v1muu7 8TjavV3BgORqzDkFrrDAYKiVBcAv4cdu4Buom524U5AV68f8K3/yMCVMx g==; IronPort-SDR: m/ZkQp55GIk83ib8U0JYJ5s6pMdVRtMebJVOw0XCp1jygPiFoKjPGQcVHZT1h2fpwteQTAnNqI C5brLcTPQWpAmvQXsFGNC8FI8QXwsuCi9B33+4ycqJU9dSAk66YbMjG669OEfhj2rD6CgDiilc 7GaVWvg4m5x6v9AD3SVNYiNGGXpzWhVZK/N3mhxyupB0h4oFauaVJGcGTpoDuMax+oi1294Lhz fIvoaNSgjO/gtlc/G5l3bIcQNOvnVNKcsMNFCgWE+2w91VfnMBOZYbT/qNIRV+SCZX/WGaZF5E TUo= X-IronPort-AV: E=Sophos;i="5.83,292,1616428800"; d="scan'208";a="276419106" 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; 23 Jun 2021 07:20:36 +0800 IronPort-SDR: RpCT6o9wkGQwO9o5DpsI2XcXzeay4ejT9pDPAfAaNMo8jh7Ip61LyjetRrWDwCcjqPUDWbUK6n EU163PD+s3/PGj4guQDDgwc5kx8/y+MCWPkizDsDZa+7Gl//SHMdpGeATwI9HihYb/PgDJhU/A NK3rRmaX3cfNDI83k6oALl99Zx0BVt6WQMKp5NfA+pr/xH9jfBujok/9y/YTsoUpklIF31AV5i Cr0cV9m/IH6x85k6CPTba5ONYKex1x7EffGy02+9WO9HqEIrLXT9axZcFzI4GLPT3NRyJ/V38F dQt2sl3Lkr8CobQt3N1pYLhX Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:57:47 -0700 IronPort-SDR: k5PmqSZMGU6Q7TGdlg9UfSZRxuLysozXpuLyxkFz4ADR0p0zj4pA9FYVj9EhKmoegs2hqlTNJD cU+q8vUWFY9c+1t5IKAUO0mvnRHvAuy51ao/2YeXyUyUYkAsfLq2c8HxOA6Bom+Mr5W6rkT6gZ GkEkGQ78sZ5h8orrgSrM4Dn82aaqI0SqBLkqEg6ce8rxcTteiZA8yoWdOPTKbP2z2oCrHjzoJe y2IOSfcaGZ+8kOEnp6eORm/OCgof6yd952PDcd8coz0y4inM3R1jDF5zIvFGcQTSAI7xSkGXm3 B+g= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2021 16:20:30 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 3/9] loop: use sysfs_emit() in the sysfs autoclear show Date: Tue, 22 Jun 2021 16:19:45 -0700 Message-Id: <20210622231952.5625-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1.dirty In-Reply-To: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> References: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Output defects can exist in sysfs content using sprintf and snprintf. sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows that the size of the temporary buffer and ensures that no overrun is done for autoclear attribute. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 084fa914a399..3b11d9f21018 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -819,7 +819,7 @@ 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 sysfs_emit(buf, "%s\n", autoclear ? "1" : "0"); } static ssize_t loop_attr_partscan_show(struct loop_device *lo, char *buf) From patchwork Tue Jun 22 23:19: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: 12338735 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 3262FC2B9F4 for ; Tue, 22 Jun 2021 23:20:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C4DD60041 for ; Tue, 22 Jun 2021 23:20:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbhFVXW5 (ORCPT ); Tue, 22 Jun 2021 19:22:57 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:62383 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229746AbhFVXW5 (ORCPT ); Tue, 22 Jun 2021 19:22:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1624404040; x=1655940040; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=daMI8xz3xkwQtAbMLhZwGVIJc5mfksDozBereM86/uU=; b=BIK2npv8GsooO0z0Nau4T/R9Hf90bm2xpu6NnlisznPxIwp4K8YYo+Ga RpHtaVBQXVQvewQRvFlXh3U1eMNJNHCgs+gzsU077meDd9pG7NmVwc742 vMhpoMj+b5ihVpjHaU7KdnIjxONQRx6ZkDkpnw5fRKNoEifJAIkzUUygk z12QeF73Ycpsw2jpRINFc07NQz72AuI5jKfEeRhLI7LW5oQi2bzemKuJO ZXOPmCol8or5rVgmHGOqew2vnFnEqUDxhEKHTP7h2WEaOMgaSeYaqINy9 X2pIkRt19J26n5yiBD2JVV5FvRuDDX7jQcqyj/5IAhrWCKdeUU644Hc4J g==; IronPort-SDR: +eyf6RP7RZ+/+kbiz/JE3QtnyLbAirTX29krHRpA2LGFz3AmIewkLy2R/0tnUvRhzfPM3iz8ms fsqtT2dsNdh4BNScp37yftwj/j9FiNbw8mGIXFrsS4TNraySq8VNZgOe/9GszGgjY1pX6auByN dcQpVmXRBCthj2MSv0jfZexOrLFZphil4HmiVt34nvO9tgDmbniWn2c4TMQvpYmXf1PMae/N+R QImnbp0Q2UF7VKb1W8SqG13y4huaI84IOM15f3rOVcAy4oFwg3KYFyEIoCmYnHLm3WNRnnkW29 UIQ= X-IronPort-AV: E=Sophos;i="5.83,292,1616428800"; d="scan'208";a="171883455" 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; 23 Jun 2021 07:20:40 +0800 IronPort-SDR: Hr7jiv2mxzSO4cvLkRcg+WwwDcqhxcf+aagJS2KGRVSTQEZmKv7cEPMR1ruJsmb11/tr/McoDW M2vH4KG4KZ/YYnezRMyJSVWODTn1oeF0sHmTIt5xhXeCPXV5CVl7spRNhQRWmYHgAdZaM7g7/2 xyomkEjT3OVUUHtiR99BVoIHCJk50K/FKQJ4Jj4V4geYrO+gt2vO0+AVkT11n9RZLPu/fxTmCN BPm8OcPv0UyIAZCxwO2Wj/+7CRUHptimZa1pIVXT+l1DWxE3C+SUV2d3TqP1yf+8RvbhdKXumF tENy6vInm0FOPRLCiKGcfK4W Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:59:17 -0700 IronPort-SDR: NmVdKf1AujvDdVmMmWpGJsMzjepTBjgrqx7xJk+p0qsthJDNAZ4Aci2v3keYTtuP9SLWOy0ISk 5OnWjdjBn3ZvC8z1eRkUIjtx/Hd7636th2eXhV7GzEWOb9mTKa5FdLFPjlEGRIj4unG//NLXfB 9ZJvp61jbHWHj8MX1LInEu8xrEU/PLPAglKtksJaLt1pESZFswQgFFeGKaiM/YnSveE8PLqGeR ZUeCZxoJEGzt9IVrNV9JMWknZ7SXFHTWAakrJZLFS8Xm0eT064uHksiQ33W2LSBg0udZIm0J4X pH0= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2021 16:20:40 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 4/9] loop: use sysfs_emit() in the sysfs partscan show Date: Tue, 22 Jun 2021 16:19:46 -0700 Message-Id: <20210622231952.5625-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1.dirty In-Reply-To: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> References: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Output defects can exist in sysfs content using sprintf and snprintf. sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows that the size of the temporary buffer and ensures that no overrun is done for partscan attribute. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 3b11d9f21018..96bc4544328f 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -826,7 +826,7 @@ 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 sysfs_emit(buf, "%s\n", partscan ? "1" : "0"); } static ssize_t loop_attr_dio_show(struct loop_device *lo, char *buf) From patchwork Tue Jun 22 23:19: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: 12338737 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 2A89FC2B9F4 for ; Tue, 22 Jun 2021 23:20:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F370560FE3 for ; Tue, 22 Jun 2021 23:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbhFVXXI (ORCPT ); Tue, 22 Jun 2021 19:23:08 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:61491 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbhFVXXI (ORCPT ); Tue, 22 Jun 2021 19:23:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1624404052; x=1655940052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yIR8dgubVaiyXuSuG9UYvWP6cQhn2PvoFhkM+C2mSHw=; b=f+Bwnk5MHoUAOz/bFgQed1RrSUgD1JMxpBpo6JWqp0EGsdOxSsh46jmB ymBLFaj8rtMxJ3rSCr+obiF6EUpz1Tvoy5x3fhDpGvdjtqNJDylHyxJiB +00t0GWU0nc+4F651nLOk6ZHwZ6Ig7Uy/s++M/qBPw7Vfj3ovHaSQKh0K BmBNv1MWZGDgEkuTiULWunCUv5bQZJ7nsa0Nug284+oQku2GNQwFRjPJt EaWFx/v6xBLO2wCpJe8Wv7B8WFEk0jcnaJ1BPiRbajijFDkyhajcZwdyq JD3WRtP8WzpI2Iumyskz06AkmIAtYUeBfwxrRf482ktyWXWqKB27eBS+o Q==; IronPort-SDR: ia126zKYfXpu9t+0YhsmJqY5qo7gU3JBNSD11XJW4SIcjkP7jdDmxYEsMJcreT1kzoD6xRsBxY Br6Yr84f5hmNe8tukAvXSSOvgn9Pgd8Rnl7aOKqnt63Y71KmboyQEXiDgdqJHG9srf03v6XHFV hgxoRhTBGVY/1wqZCXwmaB7/W6USCl4iRlq3dRoMLyP4CKUKlAxMOKfowtMqmxeAXLCEBFUd3d 19AtKMe0A1OQsGKLsq7uKRUJTw9vV+8c016oojXEimD1t31NL8kwYdUUvmx8yby9RRHLcM7xIX Q6Q= X-IronPort-AV: E=Sophos;i="5.83,292,1616428800"; d="scan'208";a="173198963" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2021 07:20:51 +0800 IronPort-SDR: 5d9TgDWFjdYKJwUzJuhPfns3C0mAiimnfoYJnHundh/Z0YZMK3nAqUUZjPUH/PvC+uyWzF6d1r 1f7LhksucSJEk7VtbuANopio6YDk5VGR/HEnVBCeRtvaMdhy6sIJL/bSYvtT2QjLZLYAUdDWGj ZNnO4nnqSaAs2PQF24oOtjqjElBkzFK5/ykBN7GysQSO2kgAk4jaTqYw8Bc+xTWrlcD30oKyKy zm6c/s/rQBxRG4DjZA14y8vTAXHG4RlMpx0ghnGORQGpPpQjO0po9UFv5LUuNhhjVn3uo+3j5Y 86o47kbIwkaafknsgN6CshqI Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:59:27 -0700 IronPort-SDR: tvwxBYIQQYqCSjw1BLEfH7WgC0W00T3IJA++ykWKVm2WrITeyYicr4yuN4YKHqBolk3pTSznPS 5rRHIVoBN92nZ1MhXHEUKV+mRrDuXpjIWZxY18+mdgZBFIeEZmKm4KUnitr+h7DV2Ae2FzHqgY 1qTyRwIuSI0D+8OBPOr2gcvxkIDK2Cn8DbsdE1eBZmekW+ZG+8v/OFtFiLsk2yyzzUwNsjLNZ2 NULpT0qADrZUoRCBnlwJHgaAavz65iwPM/Kruj6ALn12z03/fV1sdmcjtqtZKIud088zxSLuc0 j5Q= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2021 16:20:50 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 5/9] loop: use sysfs_emit() in the sysfs dio show Date: Tue, 22 Jun 2021 16:19:47 -0700 Message-Id: <20210622231952.5625-6-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1.dirty In-Reply-To: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> References: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Output defects can exist in sysfs content using sprintf and snprintf. sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows that the size of the temporary buffer and ensures that no overrun is done for dio attribute. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 96bc4544328f..abb9f05e5a53 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -833,7 +833,7 @@ 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 sysfs_emit(buf, "%s\n", dio ? "1" : "0"); } LOOP_ATTR_RO(backing_file); From patchwork Tue Jun 22 23:19: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: 12338739 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 BC251C2B9F4 for ; Tue, 22 Jun 2021 23:21:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B68A600EF for ; Tue, 22 Jun 2021 23:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbhFVXXR (ORCPT ); Tue, 22 Jun 2021 19:23:17 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:20440 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbhFVXXR (ORCPT ); Tue, 22 Jun 2021 19:23:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1624404060; x=1655940060; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZpDFB6Gpfr8TaRMuM24DVDTZp0S08wtIDr6hUfkIAAI=; b=HuYivQT6T2pQQJz3NfkGGIobs05lzk+7BOgxbt3rZc4zvlPaPrbSWiRT OAuJWet/ahs2njnILt/szBi1QW3GCTP4L37vFuHUkAMcyTU6RoXxEc7++ wdTRuLuFkAhKBk6PWh4o+WQGm9urrNKaJ3iHbJ68WIRwGY7+Q8QiDv6vh QJ+2RDaj0Y2kI4+rKqdW66XzADPi1mr6PnhZ1yzMoBEhAz/2T5S1CBiRV d2uYYOvKbs/8p2wTC7uFzGw1J7lR0WxuXHuh7f3P+Op440NlqcLnbP04+ 2v5XJQRWFfUDKx5FwLOOczf96fw2MlhHOOmzNkxSD5WZ6wOnARhrawUwq Q==; IronPort-SDR: 5KHDzmRhey9LcB2/M3aUJ6XCHzoSVTLBhgkLVvmRFYQQV4xGzdHw3/c6F682BZbY0CHoeyjnqA GINuiyUmcq6Dzq7lsBs2wCNFGQNQZfRZPkgnZ/4+bFgRCCKFGx2rQ82Ohbgk257AZoBdoX1smI 0HJY8yOa/W3Xg/R08QwG80vqyKVTuQF9I6vXhBz4cnrDI3ubC/MEElkcG0FvZ70gm0rj/tK6TA jmVw0YmrPGHZbi7u5xEqWub75Tp23VoARiShUSWKHnHBeOAHmZBhiPrblYQ1hZOeFYWcCvDyX5 VLg= X-IronPort-AV: E=Sophos;i="5.83,292,1616428800"; d="scan'208";a="172632959" 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; 23 Jun 2021 07:21:00 +0800 IronPort-SDR: OYo6Nrc9NN0aemBGeClxlN7oxtsaiEXMpji0cTTr7UdxmF9SHtFIk3dEh8FXfxH2ix5jkx1+Tk gpzWzkQ9b4DnFg/eQ+I1geBUXI0PnULdsY8BxRV9p4UglCmOycZYH/ncoYM58xR4HNQedoYWhg Iza1U0ilFaLkmLqJn4Vlyno3olhocN5hEn9X3TQ6tAo+xaJM7ff7cOshGOkuNn2bM0ixGKrudz LvGFqf/sU/8YA+ad1cWX1u4gZ436Td0MRF4srj4iskaFjb6v54yiWz48fP1GOpEHGh5lIMvgwu iStkRBHWi/8emYlUigSHAee1 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:58:17 -0700 IronPort-SDR: L21GhuGJV3SA9BU2o3e0IBLKsAg1K1zS/fBo8W/WK12ujLAgr+6fJ4Yp3pWN0dr1z8GKx6zE5N QiSDTDJ/4yWel4FmK6mORB1Zzz8lSqwS6wo0gdRuEVAGZRDibYuuTNn9zK9rHE1QX+MfYkSXhk datC46KxhSUn67qIXDRS2muitiSPAqEnecUO/NP5Yi9mgxcvA9NyMuggq9TYDEpAxCoA8OGgIt EuMBh4UO1tkSTCfKyVlk5XiJHqiXRCM54TW4TFtKRqYLQewW7YrEwcv0oxALse3noyFytxUO0I tSo= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2021 16:21:00 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 6/9] loop: remove extra variable in lo_fallocate() Date: Tue, 22 Jun 2021 16:19:48 -0700 Message-Id: <20210622231952.5625-7-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1.dirty In-Reply-To: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> References: <20210622231952.5625-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 --- 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 abb9f05e5a53..52f0b68466c0 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -437,12 +437,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 Jun 22 23:19: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: 12338741 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 0093EC2B9F4 for ; Tue, 22 Jun 2021 23:21:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD754600EF for ; Tue, 22 Jun 2021 23:21:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbhFVXX2 (ORCPT ); Tue, 22 Jun 2021 19:23:28 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:61517 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbhFVXX1 (ORCPT ); Tue, 22 Jun 2021 19:23:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1624404071; x=1655940071; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BuJA9NFnzcyZCKSjmej6LJK8UsPzKQjsqj/RGHYligI=; b=WxUtREpTpjtmsw0NjUwjC3c9Pux3aUKQMd1i/OaSZGNA9V1kOwbIFKpH xOCGmdeHP9OyJEQhfqa5+GApsMpo2k813K0hQAqID2o8BhqWoi3mN1S6d yaFwXhgB14YEKYSZFPfB592ZYzgKIshV+0g7+T/YeTHiPS1YCDrZm0sFn ebr7E6eOcLO5dAs2zGaa39DWtn1JOShMldRhLeHxxsQeeoHEpOC3L1xfh H+AOSViI90j2KEYtubUGaNZD294gDKgkhQeLKki+O0SSL9EPtXQrhnx51 g4NZe9OnSMOUal2c2HbN4kkHma5xKKijdmhCfGjDWixcO6RxFfZhxS6gN g==; IronPort-SDR: DSopaqNY533BZ16axO8khiDS88U5mVwGK3Va8z/iaNJOCExAzCPxYpxKxqcESOIdJ0IvCClqwX S6UQdjFjfuTFEylYNyh8pZMm9xK0CdGinfC71CWVrKH7CLKxtlzX5war4tUncQk2HdL1En+ech qqAC1nl/pBwt+kLgGsZS/Kkj9JMoZmW6uM1qLns30NUaLaBUfCjJR6Tp1niTIVb4Y1q6R9zB61 yOUbmhFOgknEqhwQg1z0qLiAu7cFyu/T3nLFOlVpUyiiGjFLvAkBui4P7DvM7/MTFs3DqSo+WB 89w= X-IronPort-AV: E=Sophos;i="5.83,292,1616428800"; d="scan'208";a="173199020" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2021 07:21:11 +0800 IronPort-SDR: Hm7rLE8E8YNuYosrsFY9IziTCzlwhSZWEk85FLHOhUKiEJlAorw/SnPXLRZ/v11BTqKQrOBJ3T n/Ec39SlGGRnr8W4oMMXQ+4C9aLzHNjJAQG/3iJdl3to4f761N7V5/upjYgUGXTdyANY0MW5Kw 9nA6gw1u5HkYilvwy8/gj0W9jwOet56ruKTXN48dwa9JKI/S2HRKG0H4r1rU7XmlUMAg4fE9qk qgUrjrvyCCozsLMeVYNq3PJ3tGz31dk0+zPasipo3yA/GnhA8gL+j6vz9wWPvJIbwgtvA2Mn+k Pf0jL5u9ZfJr+aA4lS7SE1n3 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:59:48 -0700 IronPort-SDR: rQMcRMmHveJVZnMXmybCxXh8x1+62x1sTwsVSa03pf0GvEDaJt75sr+SATZ+9TfzicOxswXkjb bw1DTLrYRu2s5adm5ZpzJFrnc4kzlmifcQPWm1+pwDwqRwSwYiks/dfYUfFc77R+OuCr4DBnqK dt77VVqWnpj84WfBXG+1SAMi/35inCqa99DZbnlzlMKe6UrPwLMeq6yhSRtn07DXsUOUkxlZva +F28dhxy89zFFpyBFRLM+bAzKqxpe/lzROV6611A8lDKeNBEqmfuOyQkOwFjeGSpmplZAoCbwD IGw= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2021 16:21:11 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 7/9] loop: remove extra variable in lo_req_flush Date: Tue, 22 Jun 2021 16:19:49 -0700 Message-Id: <20210622231952.5625-8-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1.dirty In-Reply-To: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> References: <20210622231952.5625-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 --- 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 52f0b68466c0..58b315342af2 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -455,8 +455,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 Jun 22 23:19: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: 12338743 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 5D259C2B9F4 for ; Tue, 22 Jun 2021 23:21:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39F1060FE3 for ; Tue, 22 Jun 2021 23:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbhFVXXh (ORCPT ); Tue, 22 Jun 2021 19:23:37 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:20476 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbhFVXXh (ORCPT ); Tue, 22 Jun 2021 19:23:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1624404079; x=1655940079; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t40odd6V29S8avxaZzWGWVtQNrj5GX4pB2nkwFs3pO0=; b=bjNedOadCeysWvMhyflWtos8k6YHbNqfGfdRVkusXbUVi08RV0i/FzkH 2/VVqZjKMGL7jehRHTvc7iJUAaDsJkf36Pclxn0ZGOEZ4t3TYs0bF9qjD Ty+K3WnbM8HWfn9AlAepTzkKhUn/w2ILkenDBnEZz/N2Dz1t/x1pjkIfd 8IOx7jsjX5g1zXC7uSgsf/u1n7V5zSwrMkGzsVDXU1VvHMjMZCJ2tEq5N NvOgy01ceov/D6b1gJuzmp4O8USfFsQzGgWSkr+0Narzy2QWCfSiibEOj 0uYVEVohpy3TX3iaRVKr+nqU4/NDLctPf1+pMVACmo1qkxy4oOWv19jO9 g==; IronPort-SDR: AxjsT1zto02Hy4VP6t6jlv0WBEngKofQi5Gm+BV+RHqYPpBIZGYvherCi2ocX5Bfl8QlHfrW3b UIcyRMtOThVLQu2p4/NAlofRQy82ucyhSiwRckqvvOMtaFzHybNaNgR5xKB1D6qGF92d6fSEMx yywt8Be+uE/SHkhZ5Nstp4+lvv21g4qZNUxa1o3nZn1huVtklj2cl/KD/xh3hzoiynZBVTF+He 0m0YedWbsdIHYAbJXwlWZ9JgyOITmBCYmSJiVALlfEhI6IF52cWXwGf7crNhKOtrEWOMj0MoJc V+w= X-IronPort-AV: E=Sophos;i="5.83,292,1616428800"; d="scan'208";a="172632971" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2021 07:21:19 +0800 IronPort-SDR: 2ctxYcyFL7dVmNeviOvsz/NRVr6VTi2VuwZi0nfqbP4R4Qx4HofeVmefkk6DjfLHKqbD8veuBB dhLuPLWX4OEGqDRL08jKYFr+zLRJNC7NmKrLscOxL+6apOinFzGdoz/pTmLlVqbXr6xbPLkY6p pdRMREyUqcdLS8MRvBvbqEDjf45nl2EjAQCbzEb1x48CO9q0OWVaZBngbop0b2JsSrpym0r6WE 9U3sHSjzoTmwnjlDePxeeW9HFOrqytJCnzHSD5lOv/cyVnDYRhBM3mAYiShYT5KfsBp5wlkGM2 uZ5Hnc9eYfPLnIeeyl3+HMop Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:59:58 -0700 IronPort-SDR: wJJnZtwQ3HsIGWjGJnOHsfRmx4e9YL2+EjKIAN1T4KyZnwQOFOkpe0GrUDE9gX1v8AVeqmy5nr 0UESd9f/1BglmOugZO3bPX6F1/CXcmMV5wL3UoTYR64c0TscL7l8YCvWSkeZ2K6wGv+ihJvvv/ pBTPQXsuHWZMAdwQidOkplhCzmT/56wDAc7osiG8H/5ldHC5fRZrVEyKZKFUhg7GgP/yWfo3QE E2Q/iZuFB0WSXjZmG25HBbBkraYmz//nNtjqD1vSDbNPRXq4D8m/0cyy1M6dHHoHWpjyEj3u2s k2E= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2021 16:21:21 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 8/9] loop: remove the extra line in declaration Date: Tue, 22 Jun 2021 16:19:50 -0700 Message-Id: <20210622231952.5625-9-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1.dirty In-Reply-To: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> References: <20210622231952.5625-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 --- 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 58b315342af2..6fc3cfa87598 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2046,8 +2046,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); } From patchwork Tue Jun 22 23:19: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: 12338745 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 37E07C2B9F4 for ; Tue, 22 Jun 2021 23:21:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B7A760FE3 for ; Tue, 22 Jun 2021 23:21:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbhFVXXr (ORCPT ); Tue, 22 Jun 2021 19:23:47 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:20487 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbhFVXXr (ORCPT ); Tue, 22 Jun 2021 19:23:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1624404090; x=1655940090; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mkrG5OhOeau3/D7CoH4TV50m5QWgVZ9GZ/QlhOJfxyk=; b=qPnjPdL2E59DsMclh5K20KssNmDpDXbMkpdjXRZycFqIgwyf1u58dnyc Xd4OJKC8wVY0AjJBZ+WBlxgvmnhG2WCjuXX9iglGTGJJLnNtVZi2MhM0N LTdt4J8WXGsFxlEAWhB1VCbsHLGRNW2M3jgdR6a7b+BnBCX5gujWl4b8Y ltCU/HYp+VKCxCzu2/EVfIt7l318bI9fOjYVRpSyGYNjM6jA0h7z3FNy2 OpLexY0/SJr9r/AvS3oZbg4/DRCggUGn8swlStq3lgNZf0qYfwF1psSuS zFfe0/qXCl/gyz6zlV7bTU4XqT6/Jv9FUJD2FzbU/8Hnx8cRZunaaQ++0 Q==; IronPort-SDR: oW+CNjulOyEjckEVCh8xyf0CHeFMoTnUHAwBf8/dZGUTpgGSsaGfYPYKscFxx1Yn+nbs7I5tfF p7A2DF4frQJZwAEP/xXBGAElrUDCbr4RnvXJOntYrgMHDYBqvKXlk4OKuMK2XHpjaVtkV25z+K jPJFV6jr/VyFk/yZJ/RMBCTs7VFKYU/kM7vScjHNHt8qO39kMdtKBwgTyYG35bA2s0gy1W2usU Bfc9jOduFa7Jl7hy0mIV88Sci+N+JM/DBBJ2ZKFbCO2+tWOPkG5RJj7F+4SllBj7agB/MZPZe8 6/I= X-IronPort-AV: E=Sophos;i="5.83,292,1616428800"; d="scan'208";a="172632974" 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; 23 Jun 2021 07:21:30 +0800 IronPort-SDR: 4WyhNfacwCujCWVkMsrtuvuJXJgyhVJ28Z7c0VlBuVJdUe10V5FKSFekReBP0vpkqT79OCut8H J/kdJs744oqWJ8YtYciepUhbnoBtuOPyasRakxMe4+NqyiUaHZvYsXqmQv5i2duUvrJ1Il0EtW IW+s583D4bEw1fNCwB4OWtKp1LAQWZtyciPWRqN+ALJsRVizdyyD2WmjSfX9pP1AwSXw8SQ+H5 8zRZnm6MhBNXEsBHRePnzPNEqP4iZrpLwBe22aplDxc53ZUcqKNHV2/7XPzGsqzWgAbZ9Gkexw dmd6J0Z3+dpRDxunbHwbA9S0 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:58:48 -0700 IronPort-SDR: bMsUB95T8TkEVE9HPJo9y0KqL89emsQIZnc/wBjTHMfCnlrHft/ez625sWgtG44N2m3D8nd6Ho utF2JWAPWhLfiy1exEKa9H2YPULsw/x29RT0mHa7RN+9aU1UIE5K6fdzXKMwF/CHJSCynUK/lt AJWB6LWtuOmgWV9keVXHSHPnqBFVbIinFslRJK1NYvQpcOd1YEqH7lxDD/3xpXtjS6SKX5M66n C+uBNZ4xyut6PN6b89RYm1fVhED0hJzKWXTDDauV9kVpoudtmsj866WzMSAW52keiEc4oR/f5v M7w= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Jun 2021 16:21:31 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, Chaitanya Kulkarni Subject: [PATCH 9/9] loop: allow user to set the queue depth Date: Tue, 22 Jun 2021 16:19:51 -0700 Message-Id: <20210622231952.5625-10-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1.dirty In-Reply-To: <20210622231952.5625-1-chaitanya.kulkarni@wdc.com> References: <20210622231952.5625-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 6fc3cfa87598..c0d54ffd6ef3 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1942,6 +1942,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); @@ -2094,7 +2097,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;