From patchwork Fri Mar 25 03:00:55 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: 12791231 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 DD7CAC433FE for ; Fri, 25 Mar 2022 03:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239594AbiCYDEs (ORCPT ); Thu, 24 Mar 2022 23:04:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235171AbiCYDEr (ORCPT ); Thu, 24 Mar 2022 23:04:47 -0400 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03CB5DEA2; Thu, 24 Mar 2022 20:03:10 -0700 (PDT) Received: from pps.filterd (m0209329.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22OMIu1N005584; Fri, 25 Mar 2022 03:02:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=S1; bh=W/BR76FJAR0Q/Axofy7KQ0iSLYspBCOn/K/AW/pAGuU=; b=jwDwjWjqg7tZMigZKDeBctz7W5bOjySEvO01qUWawhwGe0+D1GbJMsG9wn/7i3YIw5J7 R/48yrdPyYuTbOwqjMekE6XPzWLJCecU/zVSXRJkuiS2PDZRG26F+dGU/PuQGgUkkO1p CIm8ZDlKZNN9Iz+4xWK0inbBOEv6Ocle9ncoYUXb8yttvJrBSY3pzDciHEYN5WP4hQs+ DICLOMiQeW1zGEdm43cZex9Ekj9KzxCV+X192S/Z9j6bf5e5SEuMhgOa3RoaTgVrPyX4 mBDQb12C/M9O/taj/LyZVYWzsecjnDwwiOUspoenSrBcEk8oYjW84S0ibefJdgg44ntQ MQ== Received: from apc01-sg2-obe.outbound.protection.outlook.com (mail-sgaapc01lp2113.outbound.protection.outlook.com [104.47.26.113]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3ew5txd9eb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Mar 2022 03:02:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A5p5GJU6r9CUJyWDHb4ksbaWeSN5olE/RpPRt+2CnhXnz00ldj4dpw63/O98RgYl/1WnKeY0iHfCTqIgKwpoBXLWFehol1swQZ+HOObXMrTniZ4bhOdgIg49oLTYwMFVhIgeTpjVToJKH8imTjExRf3f2Yq+VFpD7GPdQNLvzIfbTQn1QeN1S2VRi+sXRsx7iFr9GuhNf65hsexy2Rj/cNyqPzdMPKYujzW1QatbiARvyFVhtKwYyhCLXwVt+FpsQQLqizbchQxLPotD0qp09spnVQhKSwxaPk2GLSuWFUtU76bHbcA5oTXPlD4tFV1JGgQvbLOHpgCCVf4FxngQig== 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=W/BR76FJAR0Q/Axofy7KQ0iSLYspBCOn/K/AW/pAGuU=; b=LUNBMiIgFf5ht72ZJ/kfktH2VCMBAtCrM8Cmv2i/O5XqUeSyKulfKdt8yEEjzvzRdKTeHRK5KTK8Q/7/5j5zNazHaV0YbyUh8z18IAdpW7XMBSrRNrE2cPjyTE6cYBv2CxVDGPF9oEF9isO60X+uO3s/VgBEQIeiGKj1QLEL72JqfEIMdBvSj8lERSlDraKUO3MfQgSZfK+nk8+jUFet6w5zUwuJSeOuKmbETq/c5o+Ira9s4kbbtr7s/oqLOyOVqO95QX26j/nlDcw1q2fa7kNb/11jSMLikAejoE8MnF+ckH9gQCZ0e2HEyMfQjGQM31sMtxwHszkPX1wCYwZawg== 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 SG2PR04MB4074.apcprd04.prod.outlook.com (2603:1096:0:d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Fri, 25 Mar 2022 03:00:55 +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.5102.019; Fri, 25 Mar 2022 03:00:55 +0000 From: "Yuezhang.Mo@sony.com" To: Namjae Jeon , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH] exfat: reduce block requests when zeroing a cluster Thread-Topic: [PATCH] exfat: reduce block requests when zeroing a cluster Thread-Index: Adg/8vGi1uwGLxPQRBCWtJcMeyhbsg== Date: Fri, 25 Mar 2022 03:00:55 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 291f2d7f-4271-49d9-5b9a-08da0e0bae24 x-ms-traffictypediagnostic: SG2PR04MB4074: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: prkP3+Au6Pu8tgThZ1bPr+E9yQe0dK8FQBBzSsScPnggI+z9x7tyijo63gwDecVTLRgUkh9CdejFOF8s1OK4dlNFbzCYP+ih+c2DtZu8FmS1HSHiMRJKBUOG+3TrU0xP1I1PomtGFoqhhi4UqMBercVQulO3Yxe8K573mVeM/yGBmANXXJUIrAGcO9gG8zwQAUsjGLDjnwJupJYsWiLuewKBflpd7mGbf7iHYlWuBNGxyKamnPv2faafkR2KHxCXVHUuFm34lYZTRRHn0emEPkl061Wm0+7gPVioDrShfo0MJfvr3Q1SY/4xCvh2FAFTt+aIQ4nDQ0ldUSwv1jxA12c+n/OmuMtA/xS3DGgPcy3w0Fga6fI51HqoC++HiD6kPptr9FpzkXxaxojz1b9JAae3C5p7/lxwI48AdB3BLMJSSZdWCfNuHkaOpiB2BVvIu0/aRuEEvhKsbZ9ZA0SKjg14w0Br4QSGm3WSfp2dZ+o9m+6j/q3XDG6af6ZiLAQRF8cVMwvvZw8Vm1pj4dZqagKBYO5Jn4JlmiQ2Wl0Qfl2RcUNwhIjidorBQNbcB0MPhL0o06Y9GJfKWY+Zby7Sgg/w56Q3UiIgNHxiB+Nip6mBYI/JOrIldoo8/mti3IKBkGKVgfUYpRLdEZIGghQq7p7Y+5hNyBwM3Te/dv32MEaKNH2landqgKqZjD9r92jtpIFz1c2FCpV37wCoXviMeQ== 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)(508600001)(38100700002)(54906003)(2906002)(6506007)(7696005)(55016003)(33656002)(122000001)(71200400001)(107886003)(8936002)(8676002)(86362001)(82960400001)(26005)(186003)(5660300002)(52536014)(66946007)(64756008)(76116006)(4326008)(66556008)(66446008)(66476007)(38070700005)(316002)(110136005)(9686003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?zM7Xwk2pQOITXoO2t/ISJGdFZX9P?= =?utf-8?q?/98qVAVt11Adz2ktIE4Fp4yWaowkc+2qjARx/O/bOaNrkmKPIDmHJlibnL5OTp25b?= =?utf-8?q?idyoJ2pWHg2Ho/FZK0fHHT1oBm1pKOtnyoYDbHK+IzkNoFbWJWpBD4J9FItgMKSIw?= =?utf-8?q?8g7i7HgEtLF1BOiHPBpq1PSe+Hmki347mJJ+LXzMP3g0kF9mnHA7W3kpW4ml28i3f?= =?utf-8?q?cKAA2Ab3OjnXz46pNgoGyN7fL1jhDXLBJkxk/r4TPiyo3dONpYlV+X3e4kf0RGiVD?= =?utf-8?q?7oYQp0MY2gxyjrQgTpmOvf3VuI0rkJtrP+myVrbUK1VTR/aW90SRL+4mdPdQ+JLEk?= =?utf-8?q?SEHjZ+dziJlgLrOveThghjIg1JlKx+yEHlnQMedDXUDMp3BVyE1NxdS6P+DTmb2e/?= =?utf-8?q?R4EBFSwGrGdhrtdlVpNhfW3pzjS/zW5OzFAZratzhooRXUr+IryM4fkf5uV0uMQ47?= =?utf-8?q?Sy6EPJdxrhYj5SE0qslzcVPfCp9ieJui3ceZlSecXqDBb57gML+AVPSKFrA6ip4M5?= =?utf-8?q?mJVopwaTr6+LS+K6sVhZ6WY3ViSh9aP5AOBgoeIS19fbVGbeCEPhZubEsvyt9/8so?= =?utf-8?q?XyWkqMC7vy47nXwTYxCBaw8D9YJ353SxCXEvKQeKgFfkkl1AjkCYByF2tRwfeBJxq?= =?utf-8?q?ZT2xggbLKjPr9gBuaL2rv8ckLuxnkilTDUqjSmlyO1SWEr4qo0HAL/97454Nzp4wg?= =?utf-8?q?eUhzCw9eyVBLkiEetw3OtY7hQIRjfpOr/3eiCspZiWdP6we6DtG4eDI79N0qbSUUF?= =?utf-8?q?0vlWG2PJUV6rpc/3TD8CLSoT583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XA=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: 291f2d7f-4271-49d9-5b9a-08da0e0bae24 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Mar 2022 03:00:55.4300 (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: 7jcNidJ0a0MNu5T1BesVjaQCFqtOomtmB+FequW5LKY6fRGb+R6Jijt/l4lwfLIUwVTTFbZrrcTIdAAYPHCK2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR04MB4074 X-Proofpoint-GUID: WNFHklwGFTQoNibahJOZ7j26KD1dsqCc X-Proofpoint-ORIG-GUID: WNFHklwGFTQoNibahJOZ7j26KD1dsqCc X-Sony-Outbound-GUID: WNFHklwGFTQoNibahJOZ7j26KD1dsqCc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-24_08,2022-03-24_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 clxscore=1011 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203250014 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 --- fs/exfat/fatent.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index c3c9afee7418..b7de3d0758f4 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" @@ -233,10 +234,10 @@ 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; + struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping; 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; @@ -250,30 +251,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 filemap_write_and_wait_range(mapping, + 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,