From patchwork Mon Mar 18 05:21:48 2024 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: 13594975 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) (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 4A04C21360 for ; Mon, 18 Mar 2024 05:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.183.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739326; cv=fail; b=ana/fyxE0mVgl4DRSVZfR8GcGXCB/uOV+i58L9EcEPb4PvYiSyyiIOX7BqOqoq+ferEkwIOHQd9zAy2b3a0yu154DlbbqSjEmRnEtxyZ/sKZ1IkrEOSCxsdTP+Qypwmh5ConBZ0gOZV0k2rjCTQ9PGJeIOZQaBOgDNvYsTJJLjI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739326; c=relaxed/simple; bh=tGGczJ9m9PcWARzDZadMOKJG0URnpH6jy1dU3BbjM3g=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=oAF0GkRbqx5E9xQLxJQ8X2OU3V1mzJU+O7800nK5tNcEBoy9GYgwVqNnV+mDcpej0itktu4NbKh1VXF2/x1Q7xJbAby3BW3ZOtrwTcBbX7owS7YXGD+rP60rPsrBsqCVVQNhxRvq4XYpEFYn+sCtYFKWkfVw3ELhxCLqoKY3y9s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=CbODJunq; arc=fail smtp.client-ip=185.132.183.11 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="CbODJunq" Received: from pps.filterd (m0209324.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42I4lDBB008885; Mon, 18 Mar 2024 05:21:54 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=tGGczJ9m9PcWARzDZadMOKJG0URnpH6jy1dU3BbjM3g=; b=CbODJunqvgMHGEhxFSS6OvnEmMriBAi6grplJKS1JPdYyNvcqyTfG+e2cvwCp9jpXojY IX7CvBREQp0kmvc1fqxFl45TEuFIlaGqEX0evaP1nwPowaqY+30j+AftlUhrxgsJy1JA gWRSbN3fDM6kCQ4pYRtoEY10hoBMOaDFanPaF+9952ZAN9baaK2iT8VNhXPTPa8Zakwd xACFvrUL4BW6WGMmUCUQO1+yS9vVWqC7RtG6fod95B1RKeVsfe0yKSaURJ+SXd8MsDdB EqMaJbFIWip/NxXSd8SbZXqkCyMFZ4BMDcnPpZaM9jLFSNl64SOMSVflbnqvCZm3UOh6 Tg== 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 3ww0k4hrhj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:21:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f7jJYTOxX0RZJUwRMo7D6HdVSJa7Cxr4A9FOriCuzACpcKdovh7/ppbslWJnQyDWeWa/udTN4W+0vTEEBwq5SlqEJGZdlne832sbANp0rvrchvGTfjrqgPAE+NTLWBI35BswF1C+QNVbIbYF2Ql5JXxpfgGfJ90qy2ks0ZsVNxgF9vs6Vj/luT+k9p2fibpF8V7p+r4IKR9YjdXIwamdh2cn3UMeWWoBSP+MfCzX0lFPsJov3RYolDQq3vqSeaEp/GIiRs2qDjs2AYZewik4Y+k+vSuXGEpI1/B3nnuqwLcohvCNaOLZZT+LGhsh8ZWN9PDnZsIuDugTUpoyZnl21Q== 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=tGGczJ9m9PcWARzDZadMOKJG0URnpH6jy1dU3BbjM3g=; b=g0ko7p7G0gAqHrQE9sRUsOvkU4QLuqoVbRgPRRRpTPJRIyyuXuM7puqB8DzulkUGANT4/YOmpzTZ02fkwihbaeJlrjneEmERxsB5injIn11oq9IxpQvbiIJFc1UQ5gxHSY6YwSIb0ZtM6uxqJRyj3BkxSO/YCs15kI1EbqwkrTADcl2ssS8hhTAQ16vWCeWS0Dmt4reR0dfR3/wws2MX3UJvSBbuiwnkc5hDVdhq74wlrdDe6rl8HJH1+iqBaugOgf0sMS+nhbNDBCZl6kHuAqwxbLoCs2Wdljo5IK6jdP3fu4etA2lZIJZpWbPMelbT4TcUsXC62sQbPqgsii6GgQ== 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 SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:21:48 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:21:48 +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 v4 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Topic: [PATCH v4 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Index: Adin2HOA2tU4zpe2RByNSy9FrS5gf3RGYqUA Date: Mon, 18 Mar 2024 05:21:48 +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_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: 132814f5-2de2-440e-6d98-08dc470b4f94 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ELGLP7T8dqqxNXfFmejjkFmBbywP5MwrcKd4uDBqzIBikeRYyeMu8H9qZQE1okek8OQmxAwazD1TsAHqilYEbyM3DxhalLu3AGhh7HvvTooV4J0oWYZr+8hRulskWAROuddTrhUj8KtL5neQ9IDyFp6y6W2alF4buSLIiISZQGEQdOrsujc232DN3AJAOG6GwyPfVTK/iFjw7dpHOJ7axUsjp5XLduEzR2nk716U+BQuPhl6IOSLuGjRzQVso4dLygj4kk3cGsi1jHqeL48l5Unl5HbJVAQI0+gH/YnsIuLNjirsun5aElEjKXO+UzuTQR/UT0n6A8Ib9xbQr3+ddD2LyDTqmlPKBBdy0ZT+Hjkk73elKtVPKGg+iS9kcvslOzhWLwOTMFbjdf1vJ3Cd4rlWfmssUmhnMYhNopUe21O9FWHrA57Umd/61pI3TeKp7vABvN/X8NIXvzkyS/y4TK1lIRs6FPcutmBOzJ9tq8O+xAA9BaYELVHk+2LZLZIOF+FIxWopIcPxxR4EA3dDvBpANIw7cLB6a7vjcjmLFaode73TbwD/4RfH2tUnG4jrlBUgd73/4VlV9hSt/S/3g5UXSp8oO4/5RP/uEhTxX+sY4ZP+nW6oBo3iu++JwThb8kBXrBzZPu47K3uWNP3xjl0+9zjoudNLlZFnW5CbUeIkaEd93ugY1ezm3fff/ci0dCSMkgH4IsgNcjLv+2QZ2A== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?7YaGCpuT6S6UKynJObikQd+3NcRY?= =?utf-8?q?D7P05DVeRQqjChe/eoFG4rJyRZxgbPRN9grjPn2T0FknCnkcuwOM1jg7B3sEvXuW6?= =?utf-8?q?wkxINwqwRB1r1Kj2KtAQPMpaB9r01yPZKszRnWe+7OS1Ybsyv6rkt8AyElz8iI3Jv?= =?utf-8?q?TLQ78u5nrdOHb7oggXl5h4jonWfxiwERRyfPKQGVHmUk+8e7tkLNB0h2E1uD1AW74?= =?utf-8?q?qmM56F42thH22FRkyYRGG0S3r5A3PoYD/Q+7uQlFcnjn7eUSMHZlwgpqNcgnplLQI?= =?utf-8?q?qC4RmdF2uUX52HMSIjLjyBfmi+oz4rec33wxXJSpGkzZslYiJmpzxrffZkI/MXQQ5?= =?utf-8?q?yjQIkCBAfVdyZOmaU1MfnF6LOwcnObfsF7VdL/ORy5ZHA0QzRwBM2VPuopFeXyi6O?= =?utf-8?q?RSE1GpTi9deYMXrbPSBH68uJOdQ+t5l1gbiZphz55SyTqHkMe28MpIJ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ytIQDmjYahl?= =?utf-8?q?3Ia4w9tlgGULWcbwXUrqv3zMIwElUyisT2dR/xI9AYr/QpQIAYrVxIEm/Tt9/PvxP?= =?utf-8?q?F+OPQha3wnblIneXAu0qtNAFbhUBsXMN+H2TJ+vW16xZKoQsYD9gHMLpDyMqljXdg?= =?utf-8?q?j2B2rIGpSk9P3tHTjxfbhgl2BIpsqaPxs/lVne7zYoX8CLm2T9Nj53/KfxEqREmiH?= =?utf-8?q?o0JOzeG7QP4h?= 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: aF3mza3dVLo5ETriLAjOBSn+G+ZAUqh/tFAhbWR8LZ/1B0ZCLQ6cgRxMabTtX7PAxY9njK9iPhAXAAA9p67y1NmYU2uyhI+5M/6s15zl2r5aguurEVQWDu2Otx5epq4IGAf0iWBKp9OoPgvAKyvmP1dEHyLyoCxduDLoOgaYGXOYoCJPYJ4Eo7fc79cJ1ycSy7DZLY57bAEtvH/BgSA+1dWNJIZjJ772oUKjom1sUY4tnf3OgnaEQU7otsiz1FAGq/sfS1EJlVz6u+K9RwHkCwAu78MUxWhoLnru3h2h3NT5VdtAsi7ZUFnzbx/FDToy4Kd7tACBnak7HMzaGX9RStKrGJ8iSdDftx2Dtgi46WFyAtSRehf3G0hUPAamAEzusShrDNu/zLQPYNp2WVmm4VXNKWPPe8X3qDOTMQ9d6aKNs30I75gDMfbh4RSUF2dClFAqO57lQGNl6Hyvh5mdChwIaxA0IVwFurDL5U9qkjHG1vNceF5QkRRGNPG8cPBnMAB185WFEL8kS6DmxIvFIkH34tZLcJZ+NHH/0b1Q+1uApmbeHloYxZ71AhDUTdj6awR+HV5XdZ0YY/pkjADdm0+L0c8PYNdkKjiiWs6jyKkhAUWqzvPRs+Pfm0tZMnOB 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: 132814f5-2de2-440e-6d98-08dc470b4f94 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:21:48.4549 (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: CP0xi+wmOAd/oaaesjAaJovQ7xHJuDEXJvTHgTXPPkYDM1QIuqBfVoJeXuYyV/KGIkzbJJTSPvsFXCddxug2KQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-GUID: 9ArBJt-qUJF2-HrEm71HoiPBcWbkiry9 X-Proofpoint-ORIG-GUID: 9ArBJt-qUJF2-HrEm71HoiPBcWbkiry9 X-Sony-Outbound-GUID: 9ArBJt-qUJF2-HrEm71HoiPBcWbkiry9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- 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 e228cdfcc9c9..0065d2abc983 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 c6f684bf7b92..ecc5f6a3ad87 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;