From patchwork Mon Nov 18 02:02:19 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: 13878026 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 66C19286A9 for ; Mon, 18 Nov 2024 02:02:39 +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=1731895361; cv=fail; b=ryYwEoPJo8AUBCgEDxKg3z2BYIWFdEMFN3iKDTy7ePYj1TinMQ7xF3lhjbC1aVXgCMOWQsQG5EWTr6X5apgiKoFsdaxmRt3Nup7ihI4in0DU2DI31H76Q+m0Hfu//V5xiWGHiqZdh+x8DUAwXhjiVGiqYAX+EnsZbROLTPCLFOM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731895361; c=relaxed/simple; bh=JAWdN+uzREyOMv6PuS9IagPUa30B53PRl9rwKzZIAk0=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=gXHMXez4QzGh0d67UXcltN23ocYSo4cPxsyQYdPntxviPdmnpT2Lm6NWh0K+TQCtoWJQwZtn1MjTVKzbjkuEuEJVvuLPwSn5gWBDdN1rxFlaifoMymEgQod8eq3DvItazrqKHBeeB6Cgws0FJFhm+zT1/6+t0nDyBBveYSt9xOU= 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=SFOVDr3f; 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="SFOVDr3f" Received: from pps.filterd (m0209325.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI0RsiN008585; Mon, 18 Nov 2024 02:02:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=S1; bh=JAWdN+uzREyOMv6PuS9IagPUa30B5 3PRl9rwKzZIAk0=; b=SFOVDr3fjhxnTxTuBKQ7kg63kEUMRoXkMD5d6HEaZfdH8 TvfCMBUUsunwtKlEkf612rI19ZbYL1ctAbWpDVqo2qM9EAJm3QWIqqg+8kRXrNlP 3868RL8HedcDDCiZpzopaLJDnlDvpbt8dBH/oejUQbB6nJ1l4qUTqway+oZyDQpV F3kO1+Z0bap9a+zQ1IAgjtTb3c0qTPszDjgoeLgb0fKUCyt14I1NCx7fYRYmgfqb W6rMPLwp5gvZYD+UDrT77crAqqJVFCMkESw1laTVN5bD5C4485go2PcB4/Clvujy rNQsFhmLcGpsAfzj8rCcJ4lC2xqgWpihD2wRJ35hQ== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2047.outbound.protection.outlook.com [104.47.110.47]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 42xmbes3sm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 02:02:29 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A82+3vMfbIHeeSgXZlzjchiirHqSLHf4qCrOqWz5ngQvhMteA/iz39nDcZpe+yUMYCPvrGNd1k3O/9XB9VQXpaYNIbwmOezib8t7w97n1UMFV1oOQ6fGo3b2cWjcUhQsdpIL1cCo4YAMr04CvvMeqHuXAwFLsGGUMBc0bmIsI8VlAo7AaS2RQmij2dQCMv22HJH71LQNKKoDIJcUE44RmGwGAU/+wzBpCrS1ULnIN7Wyx+zOvulknaiYNrbfyE/W0UZUafHu31pYK6WuAxnBXnVs5YbCk3G6LK88AhssVN/B9c52gWFwtvT8uDo1F35z5htkhlXuwzYiWXy2Orxatg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JAWdN+uzREyOMv6PuS9IagPUa30B53PRl9rwKzZIAk0=; b=cawC/HFy9XICZUpDuFDBJib7yBUt048VLFskWIjS8XD04eLApMXU8F6XQ8aiFimo5oRwEfPLIcEGjSz66z+XkVERrACTUyMZMo2o9yoc6Arzy/OVDTrWQMJRPROcp1avYQ3guBuqtdeN1Y6ZAnWAw97sj4ZOP/xFTZ7sF33G1YHlFhdkN3cLoohtHZ6rdgXA2kmv7uI1Qgo0N05tVphiE41jIemVLnSt1YaBD8QXtlmj7zpAHAfOMu3K7BJVDvXuoKJ/EH9rqaLP8ynJL/GzaRuLZfEvbx0u+xu1zMzdiiPx2fCTwRxmh2x6xfPuUon3H7VD+0riRwrLteYdVkgPyQ== 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 OS8PR04MB8100.apcprd04.prod.outlook.com (2603:1096:604:28c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 02:02:20 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::409e:64d3:cee0:7b06]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::409e:64d3:cee0:7b06%4]) with mapi id 15.20.8158.013; Mon, 18 Nov 2024 02:02:19 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Wataru.Aoyama@sony.com" Subject: [PATCH v3 7/7] exfat: reduce FAT chain traversal Thread-Topic: [PATCH v3 7/7] exfat: reduce FAT chain traversal Thread-Index: AdsE8b4Rg6sTcpHXTLKC6v4wl4SyRA0a1tqQ Date: Mon, 18 Nov 2024 02:02:19 +0000 Message-ID: Accept-Language: en-US, zh-CN Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|OS8PR04MB8100:EE_ x-ms-office365-filtering-correlation-id: ee62788d-d1db-4717-e92c-08dd077508e0 x-proofpoint-id: d8690225-876f-412f-87c6-a7cb45557a4c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?vTZbJpMBlYNMbzmJ2JJaLFYPy6lbOZp?= =?utf-8?q?bYeDn4iP3wpoTGyvAAfgLHG1WMu7jHvBEZYM2MjbxSbPHwhSkSZahPgR8UcTGU0Cl?= =?utf-8?q?JCw/1xyQsB+4QLhdFeVEHgZTDx+HvYcTfuwAPriQPMYiW0czvOD9r80jBZk1N68dO?= =?utf-8?q?tx7P6WJa1Iibd4qppCizjDEuuEZREFslaSPN1+8UnlVe0P9xq3Nso3dwKwhQrKy9W?= =?utf-8?q?Qx1BFFlPMKQBirr3I2zoZ8/tD5G+PIAiE+l7FJbyllcEv/wnDXTZCdj5aHAMCKkWE?= =?utf-8?q?WRRXZv6WBGtZ1oKhd24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eG8BYPyprTgWi5W47P4RyTxLZ0QO3q/Zyy6YTC4ehhx/GW?= =?utf-8?q?ggm/AnwtbnZlZMhejfBNl2gNc4zqp3vMOkP05jQ8MVet957fHC4eU9RGp+T5LbGGD?= =?utf-8?q?XTN47IlCW7hVS2BUN8m2lmGvkAu7BOUuVeLvaJhZ3S60gIDxflmwlPqA=3D?= 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:(13230040)(376014)(1800799024)(366016)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?nWpBD2irQwo6naAtLKd7S0kkwi80?= =?utf-8?q?XWCSUb5VucgR8OsAPNb33PaIcCGkLU4VoE6NT41mRl4oE4IWP+0rUYBCm8r75eHu+?= =?utf-8?q?+lI3Pby8smvqzRpdx4zUah+iX8pu1n9zlBtAr1HCWqNUKI+jfPozYwy5EdacRO4td?= =?utf-8?q?5ZKNJ3GGo3c9nZtYt1A1CGjEajicKc7TD+sbBnv6vthAJDAec663iT2R5hqnv29GQ?= =?utf-8?q?VRnzTotVOIqfOaeLwFHm+vQJFYK59AN2KXiNngFl3Zd1WZhU0wZRVbfaR+YNeFJmI?= =?utf-8?q?zAKWZOvPhcPFjQpbNdy4nFLpApnzjQR8xtxB3qeWpuSF4KkuTNaLQvIbP5YwIbWcf?= =?utf-8?q?wLaemSYtoL0T6uH6VDbvl4s+OC0JWnv6bkr4IUtvpflmronsejhec9XjXhLLdvKZ1?= =?utf-8?q?emwwQspXPF8q0V8h0U/wPC4M8l+eG3YnL+xnmyKFsYmLxOBLkUF/eCm8LK/+0H0Ez?= =?utf-8?q?BnDEMgVRk2E/tvIBjlGLvkWQKI5LAgfxjRhRa05lGiZbE/sLe42XYo1Sh6niLfsGC?= =?utf-8?q?OsOEA3b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Gc5Ux+kjgPRox0lVxyi81hurUcryDCaAO?= =?utf-8?q?0OKiy2pFrpVt755rGQ22whAGYCVB9SuL8Lr6FFWxVMZKFK1lHHoEMhTMLAN36SDLx?= =?utf-8?q?8bRMc2IGx6M7?= 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: hYlej/y7hgnoD0mQwYMNg5P19cm4QiOhm36/aBBgR2K7ZytxrVwmhQvKhtuYfoq8TXFSMZn+rgluWasxrmdPlpIYhfgCR1tku31juTtZbYcAq5eU72H6+oHy3RPVLC9/G06dwWrkxHimKfCHZjm3/ywDa6x24iolNBKyN0nwDkMDpE+czlHqYsQL/P0IpWjvYBakYSE5g7j9RXg1UoIRWVmoH23CI9Khq85sHmVShWo8sSyV8wXFUM7whE93jLwbCkxTP7I8hehAozlJ5LoP968Ka8zafT1DvoYJNqBDJ/AAAF2Z8K338NBK0/mREAaTySaYFNZwU901qb4gepH0Sli0AeYcxBjuJvuWIDFOFv4EQu7N/z2gQ9TF/v0NrmF8WzMCRiUICaAVklSAnum7T02fRKGqpML1zfyi+woknu2QG7HlsFGoMhxL/B+diAxxyTrcWM6HHSKPdkFbB+0A41IR2l7ALvof2RjyNsx4Dttn7HS/9kY8a7k3xzOI4FFyRGZksm7K4L8NVZt44ZVQZZGP3RESPy3NoFCDVTDNVFiRswfq2XI4+bo713cTkx9V++ZQZKXhzZ+78NetQ9WdtvLvJAhaiOe0O/fDUG/g2brzrKZkvciRQOTVmwWFm8J0 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: ee62788d-d1db-4717-e92c-08dd077508e0 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Nov 2024 02:02:19.7576 (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: ks3SFl5pRITKYirAkQoiYBGh9a+SquYybBRTIbZgn4mYGdMbubI1AecSDLotFGdfLTuYVVM5ZYbNelnROejXuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS8PR04MB8100 X-Proofpoint-GUID: TaMVQaQd7pwa7CKOCv9GXwzwoZXwt3R6 X-Proofpoint-ORIG-GUID: TaMVQaQd7pwa7CKOCv9GXwzwoZXwt3R6 X-Sony-Outbound-GUID: TaMVQaQd7pwa7CKOCv9GXwzwoZXwt3R6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-17_24,2024-11-14_01,2024-09-30_01 Before this commit, ->dir and ->entry of exfat_inode_info record the first cluster of the parent directory and the directory entry index starting from this cluster. The directory entry set will be gotten during write-back-inode/rmdir/ unlink/rename. If the clusters of the parent directory are not continuous, the FAT chain will be traversed from the first cluster of the parent directory to find the cluster where ->entry is located. After this commit, ->dir records the cluster where the first directory entry in the directory entry set is located, and ->entry records the directory entry index in the cluster, so that there is almost no need to access the FAT when getting the directory entry set. Signed-off-by: Yuezhang Mo Reviewed-by: Aoyama Wataru Reviewed-by: Daniel Palmer --- fs/exfat/dir.c | 5 +++-- fs/exfat/exfat_fs.h | 4 ++++ fs/exfat/namei.c | 32 +++++++++++++++++++++++++------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 24149e0ebb82..fe0a9b8a0cd0 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -148,7 +148,8 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent ep = exfat_get_dentry(sb, &clu, i + 1, &bh); if (!ep) return -EIO; - dir_entry->entry = dentry; + dir_entry->entry = i; + dir_entry->dir = clu; brelse(bh); ei->hint_bmap.off = EXFAT_DEN_TO_CLU(dentry, sbi); @@ -256,7 +257,7 @@ static int exfat_iterate(struct file *file, struct dir_context *ctx) if (!nb->lfn[0]) goto end_of_dir; - i_pos = ((loff_t)ei->start_clu << 32) | (de.entry & 0xffffffff); + i_pos = ((loff_t)de.dir.dir << 32) | (de.entry & 0xffffffff); tmp = exfat_iget(sb, i_pos); if (tmp) { inum = tmp->i_ino; diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 28cc18d29236..78be6964a8a0 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -204,7 +204,9 @@ struct exfat_entry_set_cache { #define IS_DYNAMIC_ES(es) ((es)->__bh != (es)->bh) struct exfat_dir_entry { + /* the cluster where file dentry is located */ struct exfat_chain dir; + /* the index of file dentry in ->dir */ int entry; unsigned int type; unsigned int start_clu; @@ -290,7 +292,9 @@ struct exfat_sb_info { * EXFAT file system inode in-memory data */ struct exfat_inode_info { + /* the cluster where file dentry is located */ struct exfat_chain dir; + /* the index of file dentry in ->dir */ int entry; unsigned int type; unsigned short attr; diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 83786938f06c..8388582c2529 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -288,8 +288,22 @@ static int exfat_check_max_dentries(struct inode *inode) return 0; } -/* find empty directory entry. - * if there isn't any empty slot, expand cluster chain. +/* + * Find an empty directory entry set. + * + * If there isn't any empty slot, expand cluster chain. + * + * in: + * inode: inode of the parent directory + * num_entries: specifies how many dentries in the empty directory entry set + * + * out: + * p_dir: the cluster where the empty directory entry set is located + * es: The found empty directory entry set + * + * return: + * the directory entry index in p_dir is returned on succeeds + * -error code is returned on failure */ static int exfat_find_empty_entry(struct inode *inode, struct exfat_chain *p_dir, int num_entries, @@ -380,7 +394,10 @@ static int exfat_find_empty_entry(struct inode *inode, inode->i_blocks += sbi->cluster_size >> 9; } - return dentry; + p_dir->dir = exfat_sector_to_cluster(sbi, es->bh[0]->b_blocknr); + p_dir->size -= dentry / sbi->dentries_per_clu; + + return dentry & (sbi->dentries_per_clu - 1); } /* @@ -612,15 +629,16 @@ static int exfat_find(struct inode *dir, struct qstr *qname, if (dentry < 0) return dentry; /* -error value */ - info->dir = cdir; - info->entry = dentry; - info->num_subdirs = 0; - /* adjust cdir to the optimized value */ cdir.dir = hint_opt.clu; if (cdir.flags & ALLOC_NO_FAT_CHAIN) cdir.size -= dentry / sbi->dentries_per_clu; dentry = hint_opt.eidx; + + info->dir = cdir; + info->entry = dentry; + info->num_subdirs = 0; + if (exfat_get_dentry_set(&es, sb, &cdir, dentry, ES_2_ENTRIES)) return -EIO; ep = exfat_get_dentry_cached(&es, ES_IDX_FILE);