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+hVasCOYnk8wjNfq4rhmCgSgZqDFX?= =?utf-8?q?+uAGwS+iAypELoFr5jUun8DBL1Yr1CGgTgfRFZtcB+CmkDuRO4KsMcFcTqE3vl0wC?= =?utf-8?q?Ok2L521hdTiX2kQpORsNA51CgBMZhVQxe6NG+3AJclECv+ABYobwnS7vK+6r/sWQY?= =?utf-8?q?Ih4O24HA+HSQ9ZO/eCz889Ye0StxKHMCUnxd6Wa5VWQ3XiHNDgWZOUY9+ih7+Od+A?= =?utf-8?q?PCIZkrlpNobBI5UegLwNjuC+vwOmMDwB9PDuqzUPe/ohWKuW4nS/pkEKiuEaN/zlq?= =?utf-8?q?sa3veZGnMJ84Uj8SUGIwDq9HT5uoU8d5OjghPzpzcOEQREuF4PEd0aMYDDzIFf3Vh?= =?utf-8?q?2X1d7ngmL241sHRy8MxHsyshVq7Ilt4A6jeYaHZwSrBhftv+0Wn7QMJiNbmTqGLo0?= =?utf-8?q?3S+43oIcPHJXFpNNJda2kZa1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l60+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,