From patchwork Tue Feb 15 21:33:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12747637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D57DEC433EF for ; Tue, 15 Feb 2022 21:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244427AbiBOVd4 (ORCPT ); Tue, 15 Feb 2022 16:33:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244424AbiBOVdz (ORCPT ); Tue, 15 Feb 2022 16:33:55 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2044.outbound.protection.outlook.com [40.107.100.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7187F5438 for ; Tue, 15 Feb 2022 13:33:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AjnT73r0Wdo6G81yc/QQ1EsXUUW8Wff+RS6h6Hj64uzfOfESc9JIbJhzjpdDIQy/tRCgqdEF/5wj2/HRoo6+oF0V3c8hMDHzr1u3IQJx+iQ6Aa7y7naoKApo1omi7sXruTx1OU1nPekvsUG0zhD3bH9Fq8FjXPQEN7LX0JxxFyuh0kTyDnl1Ey9mbbzg80AnHeWOqZKv3hMPTZ0/on24LddHxWYBHz4xVUboxELjTr1djq4tz8kz0DtTm9tUPVTciL9Ff3BSbzk076r2Y/Z2N/mFA/LOIF1fPSPr6cK1VFgtMVB6Knh66wcHzCtcfXYrK58QruaFLGy9TvrOzw4SQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jcz2fh/9i6/EbRPkqP+gdhL0pMYnnOhoKwwO+bvKdUU=; b=RLIOdOis+j7RAh/JxDXshYwR2L5TGXK4qpWD73qZ6aqKvHSt1x1BX4TVIAaoPbToRj4ovaFMmjSJSQk5yS/cPrLxv0DqmOEqU9wxzgB33nn7oB85fD61mVYttEzVodQk+Jm/AT0FUUAeisMpeQMW78BxJSiGLWQg8M8QM+/3zcLjHWxqCx6+nSOjukiJMRJL7Ypvjft9woCVq5J8ExRS6GoEoMX+SNIKrydftYMFGPAI1AE7b75ptdGMtuckEEIaVHooHyRRVGRxcL8LfN11oCxL0I6ftDSd51DR4rZAAmgP68C1dcX66mnXDHstgzBQFdySwRh1E0YSsRibZSpu/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=oracle.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jcz2fh/9i6/EbRPkqP+gdhL0pMYnnOhoKwwO+bvKdUU=; b=gB4mOhCjvvurZ39ap/WIk1iCS0mQEpNc5l9EVJ4vBs/z0GvIMpn8v670GEqEyP23T5pbze/IJ9kIqFO0zu85JzAnwHsWcpBGG9w6RXT7UQ7MmuloguGpVHtv4VEYO81rYKm/c2RfmJs4BRBQVlvJo+7Q/zfBwk2j3bOi0mmMjnC5gYuVlAwkNYR3ZQan+rXoJQA0twM3DFcEL6EsMDtXw7zU24+J1ooMCj4gjzwNbIsS/OvgiYMDHTMdrbZTIA2XfeoeLhclwodPCpeuQwfJ/tN9s6j7JE8ADvi8iz6107BMjpjPrd7bgndXkMoer/yVo2wVKdba5zz8Y4Yj/XzQCA== Received: from DM5PR04CA0059.namprd04.prod.outlook.com (2603:10b6:3:ef::21) by MN2PR12MB4455.namprd12.prod.outlook.com (2603:10b6:208:265::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Tue, 15 Feb 2022 21:33:42 +0000 Received: from DM6NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ef:cafe::ba) by DM5PR04CA0059.outlook.office365.com (2603:10b6:3:ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Tue, 15 Feb 2022 21:33:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT032.mail.protection.outlook.com (10.13.173.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 21:33:41 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 15 Feb 2022 21:33:28 +0000 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Tue, 15 Feb 2022 13:33:27 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V3 1/4] loop: use sysfs_emit() in the sysfs xxx show() Date: Tue, 15 Feb 2022 13:33:07 -0800 Message-ID: <20220215213310.7264-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220215213310.7264-1-kch@nvidia.com> References: <20220215213310.7264-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b4ea3ed-9d00-4342-46e3-08d9f0cad665 X-MS-TrafficTypeDiagnostic: MN2PR12MB4455:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:561; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uFp9S/ROItYwVILh7aeWpc2JCbKiVzaznrI0Yxd8D6NuxBk6imbsHq+EFb+FEqAbjCgAIazcC8CZm3A2kunz49qBXgbDbS7VqfvdOevoOa76NioHC8SgItRnyatxdP/aAKKpkvSVqPZ6qRbcj1cBFZmXDOo8nChTpR5CNqcOH7JqeGo+7UyqW8LlV/v0w3hD8Aa8sFVG1q2NZfC4gX2iLh4GNgeeZO/NbfOtpnoKm2bdVZpQpP5DLDibrycwZGsf6f7/++ORloFlNT2oaV1i8KXyWUnf2P2D4Zb9n9qdE5/8rxBMznDJuNLQ4NsPOj8hiLzcctk3ckdClYq4yhMVOkrJwjI6t4QPTywMD8I5ujkxPdEnJ7yVgxZyOUcbQ7hLNAO1p2Iir7flmy7U6SFcdJA3cKuwJY54dZG7/8gAROi0KhcopriDurey8J30OHf5efcMxJIxKu/W50nu7ucVoEn3T1SFgAhya7aHajJxAy+U25GeP42nV+foT2gG4cwIIK1RGNkxYjF6hFoQcg4RyE+1n1fyU0chspa+I0XsoG3Gk2ZwTeQEGpJw1THid0Oq7FXNbSshpYavF28ByEHz2x1k0NliX6dWM2m3fP1y6xTS1S1nETEQ6hKWiL9H7qbUKWJbR2DnH7aAgFRtBckEamUsl4IYwM4Gf28rw4kTThqQN8QQVeOjm3V+Rs2bsJpERL2I3vP5ji5dirughnGXJyXI1N2XkN96AAFf6u11Gag= X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(4326008)(36756003)(8676002)(40460700003)(8936002)(5660300002)(2906002)(70206006)(70586007)(316002)(508600001)(6916009)(54906003)(16526019)(2616005)(26005)(356005)(6666004)(36860700001)(186003)(82310400004)(426003)(336012)(83380400001)(1076003)(81166007)(7696005)(47076005)(13513002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 21:33:41.9407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b4ea3ed-9d00-4342-46e3-08d9f0cad665 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4455 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org 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 the size of the temporary buffer and ensures that no overrun is done for offset attribute in loop_attr_[offset|sizelimit|autoclear|partscan|dio]_show() callbacks. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani --- drivers/block/loop.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index bdea448d2419..a55e5eda1d17 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -680,33 +680,33 @@ 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) { - 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) { 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) { 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) { 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 Feb 15 21:33:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12747636 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59B9AC433F5 for ; Tue, 15 Feb 2022 21:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244415AbiBOVdz (ORCPT ); Tue, 15 Feb 2022 16:33:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244427AbiBOVdz (ORCPT ); Tue, 15 Feb 2022 16:33:55 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2056.outbound.protection.outlook.com [40.107.244.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6C36F5437 for ; Tue, 15 Feb 2022 13:33:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WlN5DjckrGPNmRDSpY3gLP7J6P5lU3StG5RzJwWqpHgGuJsx+WwfwQ1KHLGvWreRzZgaUASQ/A8Jh6MwRbifDNrW7QDGCrKbHWGQsk1FF/1gkJGmeoV7GjOJAHVgTBd6UKZ2lGA6i40u0w75xPl14RWeHWxangMlKLRABcxb9IU7Wm6omoxyBE48hZWCP0237hupmwFs6xvf5s8bUrNCKJM7bCiB99Wc6dVH++qEr4PeG6V5KduJGGlKUWkCik1LisA5dLJCk1WWjEZ+a3fgxMltNuWpZEzGtyDvkp400ff7CyiPJZrh2+Id5qkTm0YX7f76OCiZ9FmPLOm44oL5JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tPRL8HISYCbWUWa86yzKyPNqFQr5skJ1vmQY5DJJ4s4=; b=FG6clXy+h4+ZEEPG08EeYrICOqEPkdfZb6GP/tv+0jTW4BJbAWuKvAbHfe9oie+ROHE4UQveloVq0gchIPY3f3l/E6sYRnF6euN5sbBtL8ejxlu17Bewqo+DI1caKjN1H9eTnCGf0GB7phc7UglbjvTPypTNPHFhpoZ+xnbPL6Oqxl7cTEMRbR1pNhe51JnR8hFkzL/zirEZokCn9/xzy5JzQdlnYLxIGzVApb8rse5O9iKfYRWTcNM5aVYSzTOCDQ0+CFmvE9u/L2IioFT6FqwduhI3ZaHy9djjyN82mTfsnilMc9S09aFZ8YkVZ0ipWz4GdA0SG8mW0laIK5ayNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=oracle.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tPRL8HISYCbWUWa86yzKyPNqFQr5skJ1vmQY5DJJ4s4=; b=mHBs3eicdUnEa7YEyhyV3x3SJ4D9bVwDEEjUQb/TQgKuwGzYSD0IRns5yYyABa4zTe57l00/ckYeK8UrwFGpbDLkpkkG8tRs9i0DY+9EDT4SmLwnL0EoTyKKakSpYu+APaDqiGjWhco29mZ+kXlGmlIrCJqw6Njj6lSBMqHi2XNuka2kQkArXG9DL08VXe4kH7B/8dxBU/NFXm/R3uNT37eKxlAbyUXzXr0/lQbW+69xVSoQvhomR67NPJURLq/weyYeZ2bqYt003LyGOIV991UpX5JaRKzDxdduP2jESDc1s0+UsNbvGVQ0LULYO+WA+AIXcckb460IdpRjwu3QFA== Received: from BN6PR14CA0031.namprd14.prod.outlook.com (2603:10b6:404:13f::17) by BY5PR12MB3940.namprd12.prod.outlook.com (2603:10b6:a03:1a8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.16; Tue, 15 Feb 2022 21:33:40 +0000 Received: from BN8NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:404:13f:cafe::94) by BN6PR14CA0031.outlook.office365.com (2603:10b6:404:13f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.14 via Frontend Transport; Tue, 15 Feb 2022 21:33:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT029.mail.protection.outlook.com (10.13.177.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 21:33:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 15 Feb 2022 21:33:39 +0000 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Tue, 15 Feb 2022 13:33:38 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V3 2/4] loop: remove extra variable in lo_fallocate() Date: Tue, 15 Feb 2022 13:33:08 -0800 Message-ID: <20220215213310.7264-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220215213310.7264-1-kch@nvidia.com> References: <20220215213310.7264-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d4df9a6a-a4a9-4887-1f21-08d9f0cad58f X-MS-TrafficTypeDiagnostic: BY5PR12MB3940:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kscNHtOS8TEb9J8oqLoYAj8WRO2X5HvC2ACOAecWkGr/kKyB31rn14defUIJJds6K8YG01b5dXA4zbLNWcup/kWWxC/ZiojJEsSEY3q3A+vh7PHLP4vTvkHqlA8+F5GUU3Ts3Eje1gs4l5Fu5iJ6p5iqaJUWripp3uZyBchPr5zmsWmXvo3198dQEJs1+3CpfVqM5ct9BBSZfZF7rCwpu37FpYQQThboW1j4nZegIAt447+ymGYI7WUyITURhNtDpABYoXWlUx+46qr5mXAgwR9wLK/jXm54llGPR/cu82DmbYScefdKiO+TpFQ+pQ/sQ1eNYbtsV6FY86GvDoT2eRTrbKhMA9vrLcOUYFoaJMHFmBmizg5s9O/rD99qnEUveuN5hZ17yQcWuErRDCq/t954dl7ubIxOyYYFF7eH05JbyqMAI7ArNeCcJsZIQibQrAVIMgASW5Hj2xE4MHi2noEtS97PEQJHQNPYKctkGjgBfp9Q7OB9LlHtz6pDpWa1WdHDas4acd3XrZtwrTUKoMzI7a4saNZ7gX+23TvrP2zMq3WwtTSfqET0PWMVNYT5BN/YE1rgK1T23+qlS8fOLvvnh8PqTUwqp4YaBuiaPicf881wnAHrV0SnRYLsyRTI/7kcMCUhUem9c44RQnRWtodVb3nsvhdXO96+3PPofzMmOMVdbXjFyEZdpx35vuZUPA8lXGbhOcmelIxQHenSTQ== X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(6666004)(26005)(16526019)(1076003)(7696005)(186003)(4744005)(316002)(508600001)(6916009)(2906002)(426003)(36756003)(336012)(2616005)(8936002)(47076005)(5660300002)(36860700001)(54906003)(8676002)(4326008)(70586007)(40460700003)(83380400001)(356005)(82310400004)(70206006)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 21:33:40.4903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4df9a6a-a4a9-4887-1f21-08d9f0cad58f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3940 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: Himanshu Madhani --- 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 a55e5eda1d17..77c61eaaa6e4 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -308,12 +308,11 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos, * a.k.a. discard/zerorange. */ 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 15 21:33:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12747638 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A702EC433F5 for ; Tue, 15 Feb 2022 21:33:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244424AbiBOVeE (ORCPT ); Tue, 15 Feb 2022 16:34:04 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242007AbiBOVeE (ORCPT ); Tue, 15 Feb 2022 16:34:04 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2083.outbound.protection.outlook.com [40.107.102.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF48AFABEF for ; Tue, 15 Feb 2022 13:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y/dkl1p8Um7GQZjXytdffEJKPfkG50P5R/YAHMch/cM+AWyXQqmO2odOpldsBO0nmdPk+Ww6R9k7CoznLroN/sg8Aq2IA9yiB8WOAn35m6LWOTuVkjt93N/OMU8+BSjj2NqLrLX62phXpzIzGvZBoW6GBWrnPyCYh+IGH3gWETlIhHDE22DuMmwN121ARSUF4Zw0dIgQpTpa2XmXRrDoiAdX2Fvgk90YNPeGoV7EgXKlWmQbWz0emU/44UWYHL1fsvD08zsJmxVsW87RmIYCTiYgX7G3lxIv1wSKSHXyRMv0hxRVMGTlSrJl9maOYCgTgxAYHYN8KCgHeBczWDouzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oBaNSjKaFgvWSO7NQJV5wU9zY8iE7LQJaYZZRHkKAwQ=; b=YtkAzKq73EysGKOSGQk6x8JpR78nVu49pXSq+0Qr68GKEcTx+SAcVONdBVbo9P83geOrQwh5BX/jZFiskv/HOFOF/Ds0F+WFHEPoFOjm/PgznOEWCcva4qku01JdR1Oug/mIQeEbLn7EEQ6Slu9fKtFISegZsdPo2krDj2LYC4aFxf9Llt7JJK1wjmSWoxKUPyxMAotkeAHUpSqi3aDdCtaKQG814cMLlb8VOR/vif9KNoKAte0Vso/+U6rZzGW6zJK6TA+VJBnIXmBGkXQKwpo6+TgIU2eihLaJi9JsF/5E6Bn1ueBThptyx4A6tqp/5/UWBkYnfoqrVp8Pv0sV1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=oracle.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oBaNSjKaFgvWSO7NQJV5wU9zY8iE7LQJaYZZRHkKAwQ=; b=O7KRopY8Mr5/wMAs53sDYnQDafA/Osq1puUUtg/Oa/dKGi/T9ANUMd96IMlY+X3/B9cORJnORrDe2rmHeD74hY6jy1zMzJfGbm8DsBDubZ70/E7vNG4Z1yMwdYCqZRFCQ9wlqbv6jmj3QHUhzZKDEtjtb8MlKY0c+nz9as/TuYFsD38tATqU/AgZ3CQHLv9V7fviibIAMhg/KVc0rXeLb3GsZTimERn8MIyjzUko1vPPoSfbRAr/vteZgJEfFQXhnFUXYmX5nEYNcKQCyihZ10cG2E4K6SaxcExNE2ZXdkwIcb0xHzUvJJT3xBj2AHj0R3bEwJajKJR8oYlJALaoVw== Received: from BN6PR1401CA0005.namprd14.prod.outlook.com (2603:10b6:405:4b::15) by LV2PR12MB5776.namprd12.prod.outlook.com (2603:10b6:408:178::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.17; Tue, 15 Feb 2022 21:33:52 +0000 Received: from BN8NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:405:4b:cafe::73) by BN6PR1401CA0005.outlook.office365.com (2603:10b6:405:4b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Tue, 15 Feb 2022 21:33:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT051.mail.protection.outlook.com (10.13.177.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 21:33:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 15 Feb 2022 21:33:50 +0000 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Tue, 15 Feb 2022 13:33:50 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V3 3/4] loop: remove extra variable in lo_req_flush Date: Tue, 15 Feb 2022 13:33:09 -0800 Message-ID: <20220215213310.7264-4-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220215213310.7264-1-kch@nvidia.com> References: <20220215213310.7264-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: afb56daa-0326-4eda-ca16-08d9f0cadc40 X-MS-TrafficTypeDiagnostic: LV2PR12MB5776:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AOPm+mY5Bhx63Z6QtoAh+729hd3XEyUdGElA61BIL04Y6ZG3IeWDxGSD/Yl289vlzrcikYgAgrHih3zBaDqVcvIpg5qxpdHB1zI0g+RQbmrVwYBaZcnQbtH/oVaobAfLmsVNlPypGk6g+F5iYaLhFZyyWkpAbS+mfyjxj4ikGb/FpoCwd1Wq264KRZi6wvVBoEAbBUG+KEHQMMKl2FGza4XtGEkAebxa9gs4Hoj4wHy/UrmRQZ9IfnHthwhY4lDTJgJAhTGA8t8RkCMOljJQTb71xAM+uluzefkdBaKnFzFEHdruPJ4j19aXZp7G8VRaGV7pmvjDudxHFNq9mt6mlHo57MGyx2Pt08gkdk8y5asBANWRdN7jj8F8/lofT7GqfQXuFDbod5XrzLP4ZWvh21Cjxsjd9dGv5b/lsapB3Ff5Ll1gnS1u2E8brSa94GKB6B3CcOl8dL7O3nx/9JEqYmM1sP7d3EimAO3ROS9MKwCMrwbRtqRshhIxJNJkB5T1RkkdGiX3UetKD7p7uzL2tVdB8e9v5UbFLb5+35+ik0NmdV986ZzeKRURC/1f6KERF+qLCySg/FZzvL/08g4mCTn7MNNLjsD+geK3NLsJ6eTZMJheGiEdThnELnn961Gz7lB8eF09BAMuh9T9HKF+ulbEkg981zMT7zSriKlJO883gQ0gqzvVRRFe7JPpzG2ZlpdqqJNxfR8ILddfn8kZrA== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(36860700001)(7696005)(6916009)(6666004)(54906003)(2616005)(36756003)(8936002)(16526019)(5660300002)(82310400004)(83380400001)(356005)(70586007)(2906002)(40460700003)(4744005)(4326008)(336012)(508600001)(26005)(1076003)(47076005)(81166007)(8676002)(316002)(186003)(426003)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 21:33:51.7210 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: afb56daa-0326-4eda-ca16-08d9f0cadc40 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5776 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: Himanshu Madhani --- 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 77c61eaaa6e4..18b30a56bfc4 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -326,8 +326,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 15 21:33:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12747639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E6B8C433F5 for ; Tue, 15 Feb 2022 21:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbiBOVeS (ORCPT ); Tue, 15 Feb 2022 16:34:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241795AbiBOVeR (ORCPT ); Tue, 15 Feb 2022 16:34:17 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 950E8FABEF for ; Tue, 15 Feb 2022 13:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ijAeyG7DU74i54CVPTi4jRdeW4p4IuQceSgMKSzqXF9rCqvKP0y6jQmMDz7Bnmv/Gv1xDaYXA85NbnBI65xGGPaDrqRzxc3Nqgc83uihJHO7b9UYv4NeljNp+DFfDkDr97ftrUfBoq/LofDWQgzLM0zOfZtkIgrs+WBilQ/fHfVHNxxNxWNiJHSMKF3ytWuxuF3EfbjwrdS3/zTK3msWmvqyrzp4Xmg0RNygjpSB0ncUJSUVsW6W3IkfzhOI7ryuJSlBIEH891B5l26NDHYyjw9U6OHWWZVi6Ot/Ld1ok0wDYY6W7B1oMfmEJg3eM6Qlb7CUAf1olYE2Y4a87GLu2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s9u3XF3wiAIYV3Ut+Ec8ykfdNogvmp6E9IteWwTDl5U=; b=INLE7f5Utmsz5fZaRGmhoOW8hwXU/sST3b4mzbc68vQAnP7ZyDVNY9ynU/IG4rjJVv5Dq7qUxl5JIulr8Poa8RVWEr3jNlMZqbNSs2S3b9UGmxnAvQ16ORJ1LV9N1bSV/uN8TNqGyUL4Zkab1VVAJsbUGXa45vQKSl/Ytpd2HX6qkZ8NcGnHmA6MAoy9JP7f349f+uexskl+zShG8GHSJzqxCQxScjyjyu+7uqJ5aOp27OV6KVg04y8qEWwiZBQULd83HpBZeARw1ZSVKTVI7VFniLPBoWETCdyOInzasH85QmxK13kOtZWsDAycT2htzBtUBzPD4SYBDc1GAMVNEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=oracle.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s9u3XF3wiAIYV3Ut+Ec8ykfdNogvmp6E9IteWwTDl5U=; b=h1SwIr4HoiLbjSlW8uLd3o7sQfgksyUqRzRYsexRGrPJ/FMr3jGUuELjw9MAFU88QJdOaTLMtqOll+ry8vKSKqqY6dFzoGSWKSLjkd+zuqANKa79wHCH9m3bm1hjil3JMBjvfq66+8UM802bB+W5qSF5MCHUd56+oj+n/9WqBEJKoLsqCphgvw6BdXzK6M0G5P+aX0BLf6I96egDOSPUzO+ahsapkQClGShF5j6qQTPhRZ2ozuNTEHilias+q8PP2ZthSSXRuIpLoTECukFoi1gM79koB4Z6zGKh6g75Cm6N6R/oNlDuIOfWkx9k69hR8lGzQZiwkl2hpyAkpYgUxw== Received: from DM6PR06CA0090.namprd06.prod.outlook.com (2603:10b6:5:336::23) by SA0PR12MB4463.namprd12.prod.outlook.com (2603:10b6:806:92::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Tue, 15 Feb 2022 21:34:04 +0000 Received: from DM6NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:5:336:cafe::17) by DM6PR06CA0090.outlook.office365.com (2603:10b6:5:336::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 21:34:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT042.mail.protection.outlook.com (10.13.173.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Tue, 15 Feb 2022 21:34:03 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 15 Feb 2022 21:34:01 +0000 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Tue, 15 Feb 2022 13:34:01 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V3 4/4] loop: allow user to set the queue depth Date: Tue, 15 Feb 2022 13:33:10 -0800 Message-ID: <20220215213310.7264-5-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220215213310.7264-1-kch@nvidia.com> References: <20220215213310.7264-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 669fba71-f92c-4663-d4b6-08d9f0cae34b X-MS-TrafficTypeDiagnostic: SA0PR12MB4463:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eGfa488zyAAuXDitOd9ZuZWDf3YLyfWzUXkdogOI32S85xR0shM0sKxhiutUnXK3foxkIOj5b/2CsMID5o9Tm2AUMYqp0O8dht0puvMeCxYmYThVDwLOsF2dVljZhdswwcb9EaQN0IqoMlF8EvYk+qUdBlP4hj8X07GPo2OsdZJ19Rs/hBlPhBES5YdzXRyH+OeUy9UR98tTkWmQi28A2rgEYPjS2i741PklvTxbwFQl5A1mtDDw5l96YJzN3taay8qzB5W9KgcjXohcAYyhYgQJooU7wBULfcmGG6o8pPVmIkI6MSq3K93PDXUSBCVQH3sPcuGscgjoZ5oSqljDHrWUKuACaizPzC7DYTtHCeFkylhD6rSuncb5pl4gUOxR2nZFP8/42TWXEJgMEfu+kgg6OGxIA1mOIhwDEMrAq9DneW15kPHupvYmWfd3vTMZOMU/G91Cz1D7BPqBlFwJCEqgmVWh7c33JAe6AIAgdiogQX4PAyX2l0Y6pOW/9fqo6X7tBdHRhGqPeztjUBeiJ0Y5BKR3pAfLHkpSESlO5tv5YdjOVKrasCwGgfrI7xJhh1nMlvRAeRiPOcl+k/yLO90CgPxd12bxS0g+piOlYSEF23XlyVSMEeR+Jj4lG7/cSFWYm80Vr20tkj/NKz65EXeCbCVPCNAVmNzSJP4uN5f8bLa6nPghYXdgW+/mC6ir/+neJ77q8IP2zNdt/TKeYA== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(186003)(16526019)(70206006)(4326008)(70586007)(82310400004)(26005)(36860700001)(7696005)(1076003)(8936002)(5660300002)(83380400001)(2616005)(8676002)(6666004)(40460700003)(47076005)(54906003)(6916009)(336012)(426003)(81166007)(316002)(2906002)(36756003)(356005)(508600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2022 21:34:03.5687 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 669fba71-f92c-4663-d4b6-08d9f0cae34b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4463 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 Reviewed-by: Himanshu Madhani --- Detailed test log for this module param is at the end of the cover-letter. --- drivers/block/loop.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 18b30a56bfc4..c9a732a22767 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -85,6 +85,7 @@ #include #define LOOP_IDLE_WORKER_TIMEOUT (60 * HZ) +#define LOOP_DEFAULT_HW_Q_DEPTH (128) static DEFINE_IDR(loop_index_idr); static DEFINE_MUTEX(loop_ctl_mutex); @@ -1785,6 +1786,24 @@ 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 = LOOP_DEFAULT_HW_Q_DEPTH; + +static int loop_set_hw_queue_depth(const char *s, const struct kernel_param *p) +{ + int ret = kstrtoint(s, 10, &hw_queue_depth); + + return (ret || (hw_queue_depth < 1)) ? -EINVAL : 0; +} + +static const struct kernel_param_ops loop_hw_qdepth_param_ops = { + .set = loop_set_hw_queue_depth, + .get = param_get_int, +}; + +device_param_cb(hw_queue_depth, &loop_hw_qdepth_param_ops, &hw_queue_depth, 0444); +MODULE_PARM_DESC(hw_queue_depth, "Queue depth for each hardware queue. Default: 128"); + MODULE_LICENSE("GPL"); MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR); @@ -1979,7 +1998,7 @@ static int loop_add(int i) 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 |