From patchwork Thu Dec 28 06:59:29 2023 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: 13505640 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ABE75380 for ; Thu, 28 Dec 2023 06:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="fmtAALpK" Received: from pps.filterd (m0209319.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS3gfMp019601; Thu, 28 Dec 2023 06:59:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=S1; bh=9aEat5jpRfNCXPHqsxpidsDdlP+cU+rq/gmZBV0mvXg=; b=fmtAALpKz9kpPOsoZR55s9vSjp0vHsTV2sGgI3lxCijR4qD/dbT7vuphha60/nTju1Uh Gfsuq/yja904q9q3hPpWxX7aL2tiJJkEASkuRG6YZzsHpE76sFRgiQD1j4JceeO5ffOE g2s8qQjDcIER7RNxwmsdvSmf1jl0NQvnEdMp2Jn+PPTcYiWr3C8z1RQAw7Et96z3BA5+ KaCun1ST1LBqyZYVlgoign8v6A8K2bd7j+mpBi2jhnAtoql97FReLSzq33SiDeihTQPo 5UDEvS+2mH0XoQzWevQ5U+v4l62vgTL5pc2A+t9ekTjl16vF1h6C5Y9GyqqZFk2wUduo FA== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2041.outbound.protection.outlook.com [104.47.26.41]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3v5qxtbseb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 06:59:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LgIsKTeL0c+JUyqgEfq6DxbcZC7JTebnzPf9SD+lhFbAFw40i2cFiw7U8pRGvSbU/n78gAWatDaHD9UP4xcUZ2sab5He/yJdjdCQ3o+gk/rviH0iTmWE156KYKD6gdo/zBDH0UQ+g/cBooGaIg7EZwrwYV2ym57hrbTAG4rK9fQ4DPVrZdAHKNCtHTjiCM1dzmdLZf+N8252h9jdSRIbQ64+SDif0A3cW4xH9WFeqpGGaUzKQAvrYMPBe5GMwO22vX3Nc3LEFhBGC1q75ZqKnxg3cgo0jJFcE089F7EJLd6alGz2+Z+ToYiQCDc062sHPuyq+Rd66jLFlqxXrXOHcw== 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=9aEat5jpRfNCXPHqsxpidsDdlP+cU+rq/gmZBV0mvXg=; b=W+cNoy1QZhPjAJ0lPl+bEZ56vBH1s5do8/IJt2qjtPvxUFJ22kPiS6x4oLD06L45LXqB37L+zUf/okSAX8JB9XJl+DFeSJwdMe2BXetWp60aRnVTUZ07/XzG26QIHbNQx3BTmjCMEhEobbvfOJWVcE5Q3JGP5BYYAgORtG4hFB2qztMJHltJsIDsMukCYhW+fc6X2QX75byvPI6S+SOBppq3ByEa4Hmw+sq67VTPzf7DGp1S+uZy0GkRO1HW3GDojBPfRUn8LZf1/URTX5V1PnAq+JhscjgOrp7ZqdnXMAGNvu2ZxX10Ma324obaizC1Nc0wytBrCOmjXQmaKGTD0w== 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 PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by KL1PR04MB6878.apcprd04.prod.outlook.com (2603:1096:820:d5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Thu, 28 Dec 2023 06:59:29 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 06:59:29 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Topic: [PATCH v2 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Index: Ado5WWe+YqWTBtMuRk+HhqyeamrfBw== Date: Thu, 28 Dec 2023 06:59:29 +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-traffictypediagnostic: PUZPR04MB6316:EE_|KL1PR04MB6878:EE_ x-ms-office365-filtering-correlation-id: c413ab52-5c95-4afe-23f4-08dc0772895f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Prn3cQUrphXhP1Ha3pnAny24I3Tbts0fH5L9ngzCMjBUTjgISoHLxufdMXRXO6GZMDK3GGdQUHBrpKymd5ktCLflqxW8gAy8LOWH1yenW6eirIM062vzmq5ryCd/dOLl8Joku+gXOR8eTozSKMK8pttQjG8oVvRpjO5DAlnL+heA3sxMn+VbgruKxMxDR0n7stTW/Wlz7Oc8/6+Z6ID2JPHuCj1R65oc5iFyHtjofiEJ1ZRGX00ZfOUls3pGSzTIWNwxvM35v1K/zFOTn+iE2/uEEdTtFgWP5leM87jdeQejxilI6pJL3XZThwHfZKrAaEX8Izju+eNJCIDWGk1K+osbQ4s+clccuvH0+IK7abpRshB+1v054CGuAhghSx47oYAqcxrSCCsKQ7Bl0QsgRjo8D46x3ofn/pdKXn8/nZrPtT+qQUHI2bF9cr80QFuI7eYJHxtBUBPNZUDy+omF2mpCZNd/ObFEA/1Y0uqOx46x2IElX4vfjqEm3tK3Wqk0mEO4ks6wyNXfC57ApXGPT9NRwqKxH+S8PxPwUMO/VmMHTqJG8BFLYyHzOCgqIZBukBQKy+dMxh/k2hTGbiCSOcGXNhDjRzYZOlcvl0l8nyxo2XgIYFCK1bMZOP5SlnhR x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(346002)(396003)(366004)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(33656002)(9686003)(6506007)(71200400001)(83380400001)(7696005)(478600001)(107886003)(26005)(38100700002)(122000001)(82960400001)(41300700001)(316002)(54906003)(110136005)(66556008)(66946007)(66446008)(66476007)(64756008)(4326008)(8676002)(8936002)(52536014)(5660300002)(76116006)(2906002)(38070700009)(55016003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?eV5qKp94oeW6lZ0mnbbWYTtUDUaK?= =?utf-8?q?cn9TPD7cVxtA5kp7xBuzlQyBkQVNJVD0O3Li1wAp1gQ/Fs9Ji1KjX4kMgYEF3ehDY?= =?utf-8?q?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YbegMhrxxyFToxkPMVyMf2mA0vOiTX2GycCUVyVGOmVoCCa9IBZfAS3ufZPxl+8?= =?utf-8?q?H8bkxPMbpy06gy2lUrX/nYnapGunYC4sOV23wpOr/mkKsL6tHEoYDbv+M/8NySOgt?= =?utf-8?q?VTsYWzN6qpAdM3oLn5KGnmBT/IEJG65sP0mobgfFeOZiGG9SfeYCkOm1IRdBC87+C?= =?utf-8?q?Hn/dgerDBcnwF0bVWVbp8tSdFatLZw+5UppdBC4i2IzMrCWZRlGpJ5dsDjkrkqLXr?= =?utf-8?q?A+VGCGvZyyxgFe+HmUNkjjKvnL1kVcp6cn0A1tQAygj/GPxMFamRYx82ZTvCFcfhf?= =?utf-8?q?le8QlaqhECev97D2OKe4izqKr6nK157sPB6wOK2iaEqzH1sEl2BLNKxVOPeTtjrLi?= =?utf-8?q?M8yy18j4yx7egeMS8cPmgZ+UHsZrf53JEY61X38LTRTEp87AP8OFTLuAEiLenUxKF?= =?utf-8?q?EKB3bv6AFEi4dw9v6CoiNIP3ju2uvKgMui839darXYN0+84FFlr0abFNKtvq3GDNw?= =?utf-8?q?a8H7BNpXJqhAB9URM4atp78FqXqEvCD9M/GTeBmPw6T2MxAH52XvYLuVUp6IbJS5j?= =?utf-8?q?tEb9GbhPwLfr?= Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: PCngojDGt0mqf/IrvwLII8AR4cWvcXCMaetMNMaiUOD1NuG7UXwRd7O37eoZsu3fY6xOXvbE+e5X7HEbzi++Kw2ZEmSlVzCSfOHoIyxdsVqBzXQzAMZ6pb0jXJd7uhe3S/gDZwedOKBou7j7/lQYwCLSe3KlLnf4Ve78WTdFBnUass/Q3xXqXjOGXqf1NG3YqpkyYgJjgWt73ZIbOMZ64E8qH7BWAmIg8nXnRqbDTOsmr/6839b2Z7DTJQiJATLjtS6/sbGawx/i+r2B/7E5b071SV8aVnuJ7En19WLppEgde3+B6MchFNldEDv12yoYmFZy805NWUDcgRG6SowJ74nGxvBT6EAAhi9le8T5pX0VfR/dX/dtMDbkBYDMO3o5+g7AKLmhEF9nN4WEgQyrh18tGVasJ5lCuvJ/U7pjtjfYryhrSGwLVx2eB6yv0S1WToUTLVDH2wuIbkqPMCzk1jzjOXWmmBV2ct+YSsgEPj8wpMDJ2McFEAzYVHScLIJKHj+J/aNHUszkxLgAMVOS5nY5VWMT+n7Bdy/eW6RsjwikQvthkuv6aLiM3EW9kdAC0p6cFVUkME/NnngGOt6o7+ik79iseYvKZTDKdU5iZyKtDRpcev2ysPnYwnl9DFyy X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c413ab52-5c95-4afe-23f4-08dc0772895f X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 06:59:29.1827 (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: xAyUSpEtLcpTish3wM1DIEEZT3bOGtNNunmKuX7uG5kJun0LY7eodv1jxWh/67jzCcunAurQjAg1F3YUwYOq/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR04MB6878 X-Proofpoint-GUID: di4rX-cnHdT_nmLuzjt4w99uaH9_HSQB X-Proofpoint-ORIG-GUID: di4rX-cnHdT_nmLuzjt4w99uaH9_HSQB X-Sony-Outbound-GUID: di4rX-cnHdT_nmLuzjt4w99uaH9_HSQB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 After this conversion, if "dirsync" or "sync" is enabled, the number of synchronized dentries in exfat_add_entry() will change from 2 to 1. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 37 +++++++++---------------------------- fs/exfat/exfat_fs.h | 6 +++--- fs/exfat/namei.c | 12 ++++++++++-- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index a5c8cd19aca6..42f96ee6b9d3 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -448,53 +448,34 @@ static void exfat_init_name_entry(struct exfat_dentry *ep, } } -int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, unsigned int type, unsigned int start_clu, - unsigned long long size) +void exfat_init_dir_entry(struct exfat_entry_set_cache *es, + unsigned int type, unsigned int start_clu, + unsigned long long size, struct timespec64 *ts) { - struct super_block *sb = inode->i_sb; + struct super_block *sb = es->sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct timespec64 ts = current_time(inode); struct exfat_dentry *ep; - struct buffer_head *bh; - - /* - * We cannot use exfat_get_dentry_set here because file ep is not - * initialized yet. - */ - ep = exfat_get_dentry(sb, p_dir, entry, &bh); - if (!ep) - return -EIO; + ep = exfat_get_dentry_cached(es, ES_IDX_FILE); exfat_set_entry_type(ep, type); - exfat_set_entry_time(sbi, &ts, + exfat_set_entry_time(sbi, ts, &ep->dentry.file.create_tz, &ep->dentry.file.create_time, &ep->dentry.file.create_date, &ep->dentry.file.create_time_cs); - exfat_set_entry_time(sbi, &ts, + exfat_set_entry_time(sbi, ts, &ep->dentry.file.modify_tz, &ep->dentry.file.modify_time, &ep->dentry.file.modify_date, &ep->dentry.file.modify_time_cs); - exfat_set_entry_time(sbi, &ts, + exfat_set_entry_time(sbi, ts, &ep->dentry.file.access_tz, &ep->dentry.file.access_time, &ep->dentry.file.access_date, NULL); - exfat_update_bh(bh, IS_DIRSYNC(inode)); - brelse(bh); - - ep = exfat_get_dentry(sb, p_dir, entry + 1, &bh); - if (!ep) - return -EIO; - + ep = exfat_get_dentry_cached(es, ES_IDX_STREAM); exfat_init_stream_entry(ep, start_clu, size); - exfat_update_bh(bh, IS_DIRSYNC(inode)); - brelse(bh); - - return 0; } int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir, diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 542136b14a2e..b77cf654750a 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -480,9 +480,9 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster, extern const struct inode_operations exfat_dir_inode_operations; extern const struct file_operations exfat_dir_operations; unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry); -int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, unsigned int type, unsigned int start_clu, - unsigned long long size); +void exfat_init_dir_entry(struct exfat_entry_set_cache *es, + unsigned int type, unsigned int start_clu, + unsigned long long size, struct timespec64 *ts); int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, int entry, int num_entries, struct exfat_uni_name *p_uniname); int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir, diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 9c549fd11fc8..07506f3882bb 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -499,6 +499,8 @@ static int exfat_add_entry(struct inode *inode, const char *path, struct exfat_sb_info *sbi = EXFAT_SB(sb); struct exfat_uni_name uniname; struct exfat_chain clu; + struct timespec64 ts = current_time(inode); + struct exfat_entry_set_cache es; int clu_size = 0; unsigned int start_clu = EXFAT_FREE_CLUSTER; @@ -531,8 +533,14 @@ static int exfat_add_entry(struct inode *inode, const char *path, /* fill the dos name directory entry information of the created file. * the first cluster is not determined yet. (0) */ - ret = exfat_init_dir_entry(inode, p_dir, dentry, type, - start_clu, clu_size); + + ret = exfat_get_empty_dentry_set(&es, sb, p_dir, dentry, num_entries); + if (ret) + goto out; + + exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts); + + ret = exfat_put_dentry_set(&es, IS_DIRSYNC(inode)); if (ret) goto out;