From patchwork Fri Apr 8 03:07:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 12806006 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 6F51DC433F5 for ; Fri, 8 Apr 2022 03:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233859AbiDHDLJ (ORCPT ); Thu, 7 Apr 2022 23:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231199AbiDHDLG (ORCPT ); Thu, 7 Apr 2022 23:11:06 -0400 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2DE4106124; Thu, 7 Apr 2022 20:09:02 -0700 (PDT) Received: from pps.filterd (m0209326.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 2382kRDi008391; Fri, 8 Apr 2022 03:08:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=S1; bh=JspmJYtyelfjVeO+f5YWb8WrG8nbY3WkFaGaB2cB3dU=; b=N8caXLslSYWZXj8VnKUTuVUG5Y3iDP4PVQKD2cqziy6/vn/4q0NWm2F0u5PvEvpSOxQs 3+tNPHZWxM/X/F73I27D48ENh7zE5X1yypYzlDYliAxF9mBUcHQcFYy9nxmJXD0n8DDd B37qwCP7t4EViyennJKPCY/iQsFQnsBXmydfrEumptVw3Evw3b45E7onVNaN5A3qKLSw WEg9gS6xy4h6A2huwVkPH7lC2vJZT8mHqXsiGPcfZ7AxTFDxo8zILaPFFwuVhXBEOiSk 61+Ac8x73TWMkGd1pIrPDahsHou9u7bOwnRkC7rt8k2uwAqcYm69NBYopjEXi1k6/FX1 yA== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2046.outbound.protection.outlook.com [104.47.110.46]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3f8yhgjfuf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 08 Apr 2022 03:08:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a6Ba0FH2Drse94ZLm+XUyaG5HTqJKkZghNhdoLKzGbJk5/AJnHzcFzZmX6nbOvfaC/zUA+yPkbaPzGSrfy3jJg5wJeica0VqhbfdqZZbLGiliq+Z5I/1W7t/ODSMKhryzxfxJARkUWMSFG5KX9gwH/S4gR2qbmXrtznRIC71ETH8Pv2MWe/6zhKFhueex9su9sHydfT1Z5tCTO9glIZ9joqqumTr7zSbIBaGUttuUpCWqcRUAoecYh8e8VCwugHrJFt/6+Py0J0EmW3ddIgxV51KlwRH9LempU1PVUNoiy/cm0cu4kDZ+ycM8MxLZ2qGpglQJyZPmyllrYExQJFysA== 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=JspmJYtyelfjVeO+f5YWb8WrG8nbY3WkFaGaB2cB3dU=; b=imuZIO1l1rApmhV08jTt0gnR/aDCDEh9avKh8mU+8JeIUqCwavbyrn/AKbWRbowG4fblYDIIQW2CItDh4yMXNbEhomarUsjqU0QfrF5KsF3D6dl5Hy/+fa7+BlRuVPa9hHAaAFEzgHNyNYCz3hmsNQ50bIMmt5jxnKEbR/9/etDoHaiLUK/r4e2d376ypUMVNmr9DFhIKxqwIO3gKS1Pg12dbcb9EsPcRHLV1RqPKatXGEVQvH79Y/hkmOvyV8UbpI6icOtmTAS7PiofZSkqEdqpPItdUlcnCiStZvDR5ZdTY3Bgp/oFkyCigKYXCLnyCiAwnWIhXt/CXUHwfw/1BQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from HK2PR04MB3891.apcprd04.prod.outlook.com (2603:1096:202:35::13) by SG2PR04MB3866.apcprd04.prod.outlook.com (2603:1096:4:a3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 03:07:44 +0000 Received: from HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7440:bc88:211:6094]) by HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7440:bc88:211:6094%4]) with mapi id 15.20.5144.022; Fri, 8 Apr 2022 03:07:44 +0000 From: "Yuezhang.Mo@sony.com" To: Namjae Jeon , "sj1557.seo@samsung.com" CC: "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" , Christoph Hellwig , "axboe@kernel.dk" Subject: [PATCH v3 1/2] block: add sync_blockdev_range() Thread-Topic: [PATCH v3 1/2] block: add sync_blockdev_range() Thread-Index: AdhK9MP60JwULp2VR8uDBNc4RhsS9w== Date: Fri, 8 Apr 2022 03:07:43 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9f7d933d-0756-44a7-d52f-08da190cf363 x-ms-traffictypediagnostic: SG2PR04MB3866:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pbHZ9mgY5JLQb6d0TyFJPfTT8JAuQ3w3mBUtN4HJC/A3IdL1hoAd8LXA1Z+0mWLVSlLwMCjiC0oy5OCG3JmY27hiAh3pEqKPde7b/9ikIXXKhi/9O9IqnIqwPK0XkFdO+ljYMQacz6t/4UzxFzNPrcMedRZ09yMrw6WCQW3fM8R9aMvmdtf1490l9TqK7S8hPespWzrib7dZq/iL6ZMqHQMsCU150H8+qOAPchOfKiZi0JDugNm/ZJfGMB1vOrfNMJE7hSz1IHR98G4N7aOlxjp91VFq6zBNUz6sNCjOJGyspkeaj6TiSB3EaVCbA1Ezaf6RY3HxlCxfUQPJjwFEn1IQ8GaAI5SOncreVtTOH3RiBS4XInwlsIiVj134VSN/mjszSZdwZud26t4J6zoDcXmH1h3Da+C4Gt98sW8/3tqCTXa+FEEVbbmAQ6UG1Vm9vn1xS6xPllwhFVIehZfiVviUUWB522AgqwtFElV8dhDPoxATfBPnAE5AfUGZCbWkNbTLL97HxVwmQEZj/Wa/xly1KDhsyQizfv7hRBoTRzNf/JTO2xLdTeodfpAvvJljAqcPfgyauUZG3yzMf66g0SUJakW/Ug/nzX+ynOXg2mBFH+DO0flXkZXsjfBe3WWQCy2Y3+ZAIe14AdqAp576+QABjlsOJPSyJaHTPKsSRSfdbF2djNIsLJ4hlWXMRiWjjS7D/nUWdVR+/OBreIjhjA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HK2PR04MB3891.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(83380400001)(7696005)(6506007)(52536014)(71200400001)(82960400001)(5660300002)(33656002)(8936002)(38070700005)(2906002)(508600001)(86362001)(99936003)(55016003)(9686003)(54906003)(186003)(26005)(122000001)(38100700002)(110136005)(316002)(76116006)(4326008)(66556008)(66476007)(66446008)(64756008)(66946007)(8676002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?P+deAR1A+SLr0C4RAyaOv5dVM/vl?= =?utf-8?q?O44M8x1C5NiGNEoECZGnYvNVIhXMxBXizhWcL3+5fLtN4yDWgIFB/om46gX7djDaa?= =?utf-8?q?6eiS/jZmIonGUM6Uhru+lZBmm+vlgrR4XHfDxbtnyxT4YibqYb0jcIShXY27OMyDz?= =?utf-8?q?wrn+OvUoldgZ4Ala6df7E+hKww9cCLVvLuSZeVXh7NB9KnM8mZIrOym3ZdfXt/zyI?= =?utf-8?q?bMskTz2B3kxRhEwaC2/8Mvmy4xqWzrBeYE/08LYRoJxv42MLCYVYVYQlvPYMVNoqE?= =?utf-8?q?JrffqJID6Ods4vLtZoww+UHruOKKGFhGGAuQ6Zwx66jE+xVisFhAxO5bojRDoGTnG?= =?utf-8?q?HSViP3x31VSSCVi0lmduL0IKOsTQoMpwMiSqx/yvHnXDyrF+169PTYWm4Mc6K1ahe?= =?utf-8?q?AoaV0Ioa9LOpYQF/KVrIW04lQoHMIY0WzEHTvuu8jRlmIJ0HMZ9S/FcErskYJnn/J?= =?utf-8?q?U04tgl+aHL/Hm4uR2PfjvRliHAHCnLNHUsWVCAxlzd2DNTVHI8yw8Rqfjl2YZVHZ0?= =?utf-8?q?baW9YFivPC8PzKOEyl2vTK9GsQjPakIEwBNdffItp1CcE5TlGB/0GgDHtM8vFOzmM?= =?utf-8?q?rO6nnbeIPAW9aai3akyy8ut+N4HhYfIGyJl+pxbU52W8oZXuMQ0NlEYSfTXMa/mTN?= =?utf-8?q?76xjvULyTckh+b0ifBxOzKlr3DotKPY+YHFPiymLeAbUay97qpbn2HUCfmxheWNyG?= =?utf-8?q?X6KmqdsvodZzW3goFKU2aXrvxCsLZpK1gJioUW1nnu/2Q3LR797G0p/n3iQgbLnUU?= =?utf-8?q?DsK3ko4vHg3QcgHMK7X1n7XjHf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RTE4zGL0yX4Djz6w=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: HK2PR04MB3891.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f7d933d-0756-44a7-d52f-08da190cf363 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2022 03:07:43.9429 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: W4+ceSZXVfCysEoCkDisFfzxOABTRQRSvSJyDwalSG7oy/zQkAhjlz3idJW7M/m6K4pO/MsqutPXFBgOx9vR7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR04MB3866 X-Proofpoint-GUID: y0no5m2ISEEEJiwXFFTQT2d89UdtKtCz X-Proofpoint-ORIG-GUID: y0no5m2ISEEEJiwXFFTQT2d89UdtKtCz X-Sony-Outbound-GUID: y0no5m2ISEEEJiwXFFTQT2d89UdtKtCz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-08_01,2022-04-07_01,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org sync_blockdev_range() is to support syncing multiple sectors with as few block device requests as possible, it is helpful to make the block device to give full play to its performance. Signed-off-by: Yuezhang Mo Suggested-by: Christoph Hellwig Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru cc: Jens Axboe Reviewed-by: Christoph Hellwig Reviewed-by: Jens Axboe --- block/bdev.c | 7 +++++++ include/linux/blkdev.h | 1 + 2 files changed, 8 insertions(+) diff --git a/block/bdev.c b/block/bdev.c index 13de871fa816..8b549b071bd6 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -200,6 +200,13 @@ int sync_blockdev(struct block_device *bdev) } EXPORT_SYMBOL(sync_blockdev); +int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend) +{ + return filemap_write_and_wait_range(bdev->bd_inode->i_mapping, + lstart, lend); +} +EXPORT_SYMBOL(sync_blockdev_range); + /* * Write out and wait upon all dirty data associated with this * device. Filesystem data as well as the underlying block diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 60d016138997..331cc6918ee9 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1547,6 +1547,7 @@ int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart, #ifdef CONFIG_BLOCK void invalidate_bdev(struct block_device *bdev); int sync_blockdev(struct block_device *bdev); +int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend); int sync_blockdev_nowait(struct block_device *bdev); void sync_bdevs(bool wait); void printk_all_partitions(void); From patchwork Fri Apr 8 03:07:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 12806008 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 0116DC433EF for ; Fri, 8 Apr 2022 03:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233884AbiDHDLQ (ORCPT ); Thu, 7 Apr 2022 23:11:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233810AbiDHDLG (ORCPT ); Thu, 7 Apr 2022 23:11:06 -0400 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F30EB1760CE; Thu, 7 Apr 2022 20:09:02 -0700 (PDT) Received: from pps.filterd (m0209326.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 2382kRDj008391; Fri, 8 Apr 2022 03:08:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=S1; bh=0krr7e9nrzxJOPqIh4uE9P3WM/AXnl7MPvIRxZA70Os=; b=DVLUkUudwJ7wCt0V3mFL9EZTd3zABDOjw97XsnwxDBxo5o34YJnCeBXxZzLi3BC9T+Z5 sshxY894FMCDhDoxKmlhwAfF8ew7qpbzwFiUT0rXHsdMOh8MTuaRBxIWULuNWmGCqGx1 5pEyVR4Uxp0Ey3YjS38Kbl2dHmdlMcmyU9t9RUZ+eG62bcp4FFtTBSVd8BtFYrqopYBx 2apm+awQXI+1cTxPjeISoBo5X32RQtif/O+8zluvOx+XlLWmzD69Nx8/snF88vkCk4nC JOWLDX2D4OVN90KM6rp46TZ2WXF4c+dvciYkcSppdSC9ImoOGleEawEUZOyg8teZN77J ew== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2046.outbound.protection.outlook.com [104.47.110.46]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3f8yhgjfuf-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 08 Apr 2022 03:08:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vmbiq4Yy81P+IiWp1GKacpT9DmmS5ni9pUeybmT7KGDHEklzSLO7SDrUBJWEnRMgCESguYT8yreQdcH1JX+1FpjAptKzEbARDueCAcRXT20XaRjK5JLx6KVXwlS23g16WSFZA6COu7cS9J0VDaPFztl9idfFI9netmRMZQu3c62xP8NPgdkFuQLO8hETbfMwA425l6WZ07onExweeJG9Tat/C4/eOkL15ozAc5cxYUe0eGByF+SWZ6kgJglOUVRp8lwjZbVzd4dVecNEIBi3PadhxEWxqCIUfquUKIidw5y6wUYTxtvWvbB/Zst15tiz9ilvYrQJ4RvgbF9RKiL2pw== 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=0krr7e9nrzxJOPqIh4uE9P3WM/AXnl7MPvIRxZA70Os=; b=EMW8D5hJka3LCBYt5zvwpjEwhU9ynS7I/Y2HQv+HjeEJpmD4Vmtyru/oUMdIm4QXbEbCDlT6orZmErWhj38tphE5UUttmmfTLjERszpb1eH/OBNpqo/gL3DMsybmUCHuNxL3l/pQATBCkbnMqyN1ulSpjZ5WBmNZx3z9MWwNW1E+YD7l5TvYvRr0g7ZrDEdDKC4aqKHQMIYwtP+F93Es4irz7rUJFnqv5P4Y3xwmTOQNUNc7K2aXkojPZAQCXykFW68876aOP94rWye4JCrJucqM7Q/r+aqtunWFFYtHfEMFQZJnQpm+BVgTJ0uVWgL0BGnTJuc4VE7FIcxPhp0l7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from HK2PR04MB3891.apcprd04.prod.outlook.com (2603:1096:202:35::13) by SG2PR04MB3866.apcprd04.prod.outlook.com (2603:1096:4:a3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 03:07:41 +0000 Received: from HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7440:bc88:211:6094]) by HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7440:bc88:211:6094%4]) with mapi id 15.20.5144.022; Fri, 8 Apr 2022 03:07:41 +0000 From: "Yuezhang.Mo@sony.com" To: Namjae Jeon , "sj1557.seo@samsung.com" CC: "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" , Christoph Hellwig Subject: [PATCH v3 2/2] exfat: reduce block requests when zeroing a cluster Thread-Topic: [PATCH v3 2/2] exfat: reduce block requests when zeroing a cluster Thread-Index: AdhK9YQZ0JQytWEmS0yTn9FT+MKl5w== Date: Fri, 8 Apr 2022 03:07:41 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: baf56c2d-8dea-4f1e-dafe-08da190cf1dc x-ms-traffictypediagnostic: SG2PR04MB3866:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sYS7NdcW3Hab95su6fFgYfFKLhvDHY255j3L3Wd17NB7M8VKw25jGxvApcC6HCTP6/93DoxpnwhtFwCZ93lN7wdQ8Xj9+gl6Rz5jRBNCgoaSz3Q3UsMgNUTfmCERXR1hybGvf/YGZWO6ZgVFMjQRgQkBvMZJuv79Ljmv2l8pTUiG6ebRSODXIpP/qjkiCCuM5nDcA82uJOqUq9EkqhZodnL2aiLU9yXJc77iisbpoBxcngLNMmjJp/rEomdoVSu32UYrO3K2v0xklm9jPVkHJ65Pq80is532Aw7DoJiJeY9Jg7TDvlf3Yv3g2zC+avC0/jsuAwLPez9yw6oNwnqao5TxqIuS+Q7WhJsNh5B7AmrUjzkorSfgDxHKOW3ix57N1IW3PsFXJHoYABXL40c3Hqs3edo75PYbO5dvrn9ecaxrXUxHrOrvRYb/x3Of5fMsmh2TsV7vP0DHUW7c/iMGRn93nUMuyx0seyHCr2mddG0xAtEbIc0FKFH1VW04EgsX099hKHz51k68/xzVV87QSt+PLo+hghy5dkjyVk1nSOfr18Q11Gk8WqcCU3XVE6YOa/xBvS7W5RousU5fKjWNCVuwuoyaxj+oUzq1GnDSCquZsLxhhCx2BwJ2Tgi4CGQ72+1H5aeSVzCu8mSDsOHOixcdjjvSkMXbmujwr8hPt+N7IhxNwzo66NqRSLv0QRYlgjXcjGGyXPwY+YgvIhALYw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HK2PR04MB3891.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(83380400001)(7696005)(6506007)(52536014)(71200400001)(82960400001)(5660300002)(33656002)(8936002)(38070700005)(2906002)(508600001)(86362001)(99936003)(55016003)(9686003)(54906003)(186003)(26005)(122000001)(38100700002)(110136005)(316002)(76116006)(4326008)(66556008)(66476007)(66446008)(64756008)(66946007)(8676002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?ieal17u7RqacDBoEzbI75KDSn2/z?= =?utf-8?q?XYyASZTU0EOfHwaNQiz++wO0cMzrbgt7mk7q0pi+aVMhtN5fnZ5f8XQfWuqRQwq+q?= =?utf-8?q?9TTnS8cfJHr3RKuAykZ3HEnJEWe96vmTGqWZS4FW8sjlnTVLkhAcbltlUVUpR8fqh?= =?utf-8?q?5/7rYPzPDm4CVh/sjDneZGOZefSCm+9xWcPyxMqgB9eBulniIWe83ySNvKLklaN5v?= =?utf-8?q?vuOcDsuwGw/3d+jQqcZMAw7nNOHPXg/Vxg94aVtGgPwNRBxBZV+gowdzt6zgcPP/3?= =?utf-8?q?3xOUKd4ZZKmEefHhYQwNHhi3+KzU4un3EFJ6hiyl5uelOjWcMsquUMmdSHgTfG4VB?= =?utf-8?q?f5xYIC/EnizuiGuCtATcwntEY9fd8xKzbSl8+hVasCOYnk8wjNfq4rhmCgSgZqDF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HRZcM+IijP?= =?utf-8?q?fmXSNCVp09uYf+oFiSEmD1lZ7uvZGMMjefs0S4VCiWsxry8qwVgZ3uV6dOluRtmlL?= =?utf-8?q?Cof/80hPNYHNqqoQXTS5eqyoMLwCRzqFVxcAulIJYi5/wFIFCPGA3ZwtIOm3VRa0X?= =?utf-8?q?5CXqx0u0atdrHcHJ3k0GpDMhp44D/fnVchh40ViTnKpHa7GgfLad1pMW3sHUesLt9?= =?utf-8?q?7iBXGXMkVPOS3B5Ok4sziLVjFv4q4ACQ8GDIT/DObRraONWXhzeIncf9n4s21TYcS?= =?utf-8?q?JgZ3O/6HndxvcBMhh1/cKFyRjPExCzB8cQF0yi7umZf96n/WeX4QaQ8EVirVYwkT5?= =?utf-8?q?HM0DbSg4MMgM/6AKC5QURYKCit6NYpp+NIOHTKvqRn1GpIhdro3YTqjvZeJBUq1g3?= =?utf-8?q?Kx1/wLB7kQ5WB0NpHKLBl60+KgcaX9cg=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: HK2PR04MB3891.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: baf56c2d-8dea-4f1e-dafe-08da190cf1dc X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2022 03:07:41.3962 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Wrk6lSGFdIo4BmvzTUOsOJGzeXI50rEPG1Y4y0K5/82j5BL2Qkqekgrh41klNxKXSjSED/hELyRCeY9IbEYWJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR04MB3866 X-Proofpoint-GUID: tLklq7rBgPtmX-nt0DBHn8LQr12_UJ32 X-Proofpoint-ORIG-GUID: tLklq7rBgPtmX-nt0DBHn8LQr12_UJ32 X-Sony-Outbound-GUID: tLklq7rBgPtmX-nt0DBHn8LQr12_UJ32 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-08_01,2022-04-07_01,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org If 'dirsync' is enabled, when zeroing a cluster, submitting sector by sector will generate many block requests, will cause the block device to not fully perform its performance. This commit makes the sectors in a cluster to be submitted in once, it will reduce the number of block requests. This will make the block device to give full play to its performance. Test create 1000 directories on SD card with: $ time (for ((i=0;i<1000;i++)); do mkdir dir${i}; done) Performance has been improved by more than 73% on imx6q-sabrelite. Cluster size Before After Improvement 64 KBytes 3m34.036s 0m56.052s 73.8% 128 KBytes 6m2.644s 1m13.354s 79.8% 256 KBytes 11m22.202s 1m39.451s 85.4% imx6q-sabrelite: - CPU: 792 MHz x4 - Memory: 1GB DDR3 - SD Card: SanDisk 8GB Class 4 Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru Reviewed-by: Christoph Hellwig --- fs/exfat/fatent.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index a3464e56a7e1..04e1126ce971 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "exfat_raw.h" #include "exfat_fs.h" @@ -274,10 +275,9 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu) { struct super_block *sb = dir->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct buffer_head *bhs[MAX_BUF_PER_PAGE]; - int nr_bhs = MAX_BUF_PER_PAGE; + struct buffer_head *bh; sector_t blknr, last_blknr; - int err, i, n; + int i; blknr = exfat_cluster_to_sector(sbi, clu); last_blknr = blknr + sbi->sect_per_clus; @@ -291,30 +291,23 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu) } /* Zeroing the unused blocks on this cluster */ - while (blknr < last_blknr) { - for (n = 0; n < nr_bhs && blknr < last_blknr; n++, blknr++) { - bhs[n] = sb_getblk(sb, blknr); - if (!bhs[n]) { - err = -ENOMEM; - goto release_bhs; - } - memset(bhs[n]->b_data, 0, sb->s_blocksize); - } - - err = exfat_update_bhs(bhs, n, IS_DIRSYNC(dir)); - if (err) - goto release_bhs; + for (i = blknr; i < last_blknr; i++) { + bh = sb_getblk(sb, i); + if (!bh) + return -ENOMEM; - for (i = 0; i < n; i++) - brelse(bhs[i]); + memset(bh->b_data, 0, sb->s_blocksize); + set_buffer_uptodate(bh); + mark_buffer_dirty(bh); + brelse(bh); } - return 0; -release_bhs: - exfat_err(sb, "failed zeroed sect %llu\n", (unsigned long long)blknr); - for (i = 0; i < n; i++) - bforget(bhs[i]); - return err; + if (IS_DIRSYNC(dir)) + return sync_blockdev_range(sb->s_bdev, + EXFAT_BLK_TO_B(blknr, sb), + EXFAT_BLK_TO_B(last_blknr, sb) - 1); + + return 0; } int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,