From patchwork Mon Nov 11 06:43:57 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: 13870312 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 F131713957C for ; Mon, 11 Nov 2024 07:04:18 +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=1731308663; cv=fail; b=LKqjdN9EIUE539E8d6qPMAZBAAl786/UfIhpkxnLGtGbjehaw1L87cNhWguhXoGl1PFIIIuKMSx1XC9sPECVtXY+Ci1eM5d99nLA2dkpteq9P7fPpyzpAVSx4CRiaEnB63pi81h/+buqmjqNAinlBBv6Pvpri0av4IOcHHj92yA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731308663; c=relaxed/simple; bh=bO5VlqTrbMlRXyjf019z5gy6BXjCOrI5A9nWGXo7QaE=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=Zb0sOuOyy6o720QDi5yEspL0nV5aRwZrgt8tYl6Xq9np3ZtOoyVOUka8Nq2iFrLvfCUUnMDQISNoJ6njdNLr9VmEGnRIzUVXJR+KaZCp5CEBa8zwpA9q7izIq3+FX+7sL+LWKrxvK122V+5nMd8WPv775lCMVDdMxlGAwsZ0+hw= 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=it7096cX; 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="it7096cX" Received: from pps.filterd (m0209329.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AB3haIl018734; Mon, 11 Nov 2024 06:44:07 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=bO5VlqTrbMlRXyjf019z5gy6BXjCO rI5A9nWGXo7QaE=; b=it7096cXPkzCFV11ymSRUwyK2m9ugPNR7p1cwwpUSXylo kDUtlLrnpVD9Fx2q7CMpLN5JYd9SCX6WmqBQdJViERJkzLEdnbt62MIG0SefYz9H /gPDga3HdQTFnLTsoGGjo03ClOdZN4Ck5MevmrFh130FhDoBlZw+fLWeFiUqo7Ey t71NWGottfoNrewAUCJ9uJmMTeI4XZqw8CZ+yKwnIcZzPmqcRfZGClWAOOjsRin4 Qgc6a9brDACFAHizMwBb4IkTrtq8Cd0kN+WLSGH32DoXxOCJvkipriyeSwuscG81 yMqYEiQ9ohbKZ1DT6kYgeVblQrshgQgjWMf1Mkbdg== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2049.outbound.protection.outlook.com [104.47.26.49]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 42t0gm9e20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Nov 2024 06:44:06 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JFOnLyK17pss7c4xxsEvcHKP9dF+TuiMuASTiiNyqfy9/xvquQniOUngVceP9Pme9Td5vRRhn9g0h9SWoykAe1pWOloTx4Fq6h/LuMonUhb+OoIIc8saTzVmd5cIoVL7nCvuoqHksccVjVGqUoCeUpBthVFql675bXZdhc1zLVdTOcfHvOWpz9dw2AtqSJ82TUeaAGo3u1JLFfpKRW7LCCW+7fVQS1jKLLcbo/2vngBK65Lcruzp7CGQL+AJ77h+ijQKBgrV7vWcEpQ6QhrJH9qx5/O4UMxLA5l47/Ym6CNea/PTBwatRJtFOo7M4nj4CcFC4aVxfNBUxuJthxvPBA== 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=bO5VlqTrbMlRXyjf019z5gy6BXjCOrI5A9nWGXo7QaE=; b=guWMNEarMIvfnW/QiuALOV7pskTZpNdkc5jz+aMUokgrbG9P+WKy5rpLKMGaKodcl8OY5sfjrWR5H+v9gkK3fITxnOFaHs2yAKhrAcuOUFLTVNyvyCbpPPda89l88UTk7x0EgkwSF2IRzoF9bKAjjIRT3HmhR9H87ZvS6WNIypc2TuCwE5HAAh1ffEZb9p454nbJoBu8o59N5/17U8pnfZAdtv85vJJG70fsYc39HHXYsA6QwviOwcVjazt/A+TtP96N1XaPw0mzbN2SbiXdz75+mVu7OChMNB2VJxdxo2vDTamJ64Ol8XOCFeyIAwMX774yXbJAybWrMIMe9ryTLw== 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 TYZPR04MB6982.apcprd04.prod.outlook.com (2603:1096:400:33c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Mon, 11 Nov 2024 06:43:58 +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.8137.022; Mon, 11 Nov 2024 06:43:58 +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 v2 6/6] exfat: reduce FAT chain traversal Thread-Topic: [PATCH v2 6/6] exfat: reduce FAT chain traversal Thread-Index: AdsE8b4RfJK5gfSvTPOO1A+ob2WK5wvEsVPA Date: Mon, 11 Nov 2024 06:43:57 +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_|TYZPR04MB6982:EE_ x-ms-office365-filtering-correlation-id: 9aabe35a-2d09-4955-8775-08dd021c381e 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|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?iUfs6Gx1QU5wP8MXc2Jti0Jzma70wmr?= =?utf-8?q?hsS417j8ELGmr1rRyMjyMkI2qgYaIyJWYmwLYn8jbvZ0uvpZcmPX6Ft1ImwhNtCX5?= =?utf-8?q?qkDw6j7kdDiBUsNLzYVw39usbl2YQYhO24Vio0HgQiEPKQTyB1Onu1Sqyt1igQFnZ?= =?utf-8?q?vVd9OydBF9GQRjwqxwJwqsYgYy349EFlWR3Ef1ia5+Xc+TGew8thDZQBVGmEpKt+W?= =?utf-8?q?rrGNFNKZoh66mzllmvkxvPREMCxHbSeUE6jCGnrWoi3E6osJ2SGzXrTakAdnuquCY?= =?utf-8?q?e7pKzN1QHWt211Bd1eBPo71dKBodlq/e5GIjpjgmJ3JaDbfeufGhYV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lNtDHPq+mco?= =?utf-8?q?wNiB0HgxASTVjL56eNOHYLtZgwEDh2WZ4+O4bU//iXIUn4SRxsDADMOgJjeJTp6KW?= =?utf-8?q?3nhZIRKutXaOPHdfYxouYJwQTfmxiS+4mTzH+KqC1RUleTh7/Ef/IdLI=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)(1800799024)(366016)(376014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?UrWSHQk0kZZcu+FBW5Oyl6TDnim/?= =?utf-8?q?qmsFUCPYrPJmfUsn5OyCuRWeIqmbgaxEZBS7NHHa1dZ0ULtrDI+Go39ojWNSZiYvD?= =?utf-8?q?SYVXVftiO71o5F+tb/o9tR0IAK0ZSF6mhl0gJfyAYLNEMvN5SFG4dmo4SM2E9jgKL?= =?utf-8?q?nR1yjW67H3hlxs3XpUk2T1EfREpG29dvkGhFvC2078SqWwFeICVhuQ3HG5p+on7y8?= =?utf-8?q?RDemEPqFREO4YJYVXWpLwASPSkj0jjnQGVOPg5eboG9Wj3OHqGGBkmdmQE0TR1VT9?= =?utf-8?q?4VtsdaK4lxASLXYMsCeGFnW59svrPbJwqrioqeqtyMDp8RMWOM1diGHNAIZKf7xNt?= =?utf-8?q?P1PUzxpDWMgIT1qC/k8uxomvlH4f//oj1GKhlEjsmO00Nme8dFSVJspCAG9aEje96?= =?utf-8?q?HIxx35M8WlnWpEgZxiZFH7e0699FK+rR2C8TTNz9RcpRNOuAKJO0evKxValkrMBYW?= =?utf-8?q?NQG0StJYjnqFCubFWyDFkmuWBk4bpPyQR4LA3qqrffhqKeWR+wbRb5YK47k437aYM?= =?utf-8?q?8FyCKfiBKXRKQU7hHrG9WgUEZA8zSTwB9FA3RM6Vy8KWZk73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z0zz3m+IOtsRbcpsTf?= =?utf-8?q?BKrv8tZ8DPLv4Tra+wsEb8HPESQIp42iK7lCYSNEg2Ppw+9xBVodJmbUmtA6WpVfb?= =?utf-8?q?+itSKq8pyxt+?= 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: s2Fcaf6F2JcpLf9lGLhi5j5TUXW3Fr0M/hrxo8xz9xAcFyRb5sIZwcik3dnNCvuBdHCdUgUmyZv/gYij8DDHbsYMRtJpVwJGHmOOTlOqgRuzOoah4hgtJXlRp4NPMkHtmZCprzjyZN4C6J+glckZ64zqOn5OyCpeMrDhHlVPIqNfbx2ivLA6Bq6EL3NOUaQpLcZSNIp7dZhzJrZ+pWiXTjfi3eOzokx8jVAUHlBsnhYpT5GszIl+/D/ds4wmsfPdLG6tT8V6VIHafku77d6oAZ06aauxxeSXbEOD7Ydlp3InsPRWWg5cWEZUK6ixB7zPDkCSNFYpNFzrlycbFoCwU9F/HKy/uZTdIDkooYXOP3JpgIAddj7t8lXjqjJqIYjhz24QTTIWkWkWjNGUp1uIRDb5ctuhhUXRvDayi02Ix7NX1cmCHieQEwMTu3oprPM/M1hmnkEyhMkfv/oeNOl3h8Yf7aTFOWqSV+6RaZlaYN9qQDVj4PJAhHw6PQU3z3dXQ4yp3BxxM2gtJ89ctQt/dMrkrqJgf5ysT5xUeWQ2ciz6pJiNVkqZjY/hOQ9IoX95hth0xJrWCZ2mxlO4qnLg5ORFInMDMZ46kyFf1PpeZc3+jcmQWbgl7OtdK3BrHl1E 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: 9aabe35a-2d09-4955-8775-08dd021c381e X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Nov 2024 06:43:57.9872 (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: YxBmVZnrGCGNxqicnEiWYSZ2n2QmRCPCYgk8Q57W1O75LP5UcsDR+rZq3ZC5M36bOmkTnv/w99AbeFFyI+Mjpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB6982 X-Proofpoint-GUID: A0c2HQatp6gYjx2sIVxr3lVlqGYRa_4h X-Proofpoint-ORIG-GUID: A0c2HQatp6gYjx2sIVxr3lVlqGYRa_4h X-Sony-Outbound-GUID: A0c2HQatp6gYjx2sIVxr3lVlqGYRa_4h 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-11_06,2024-11-08_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 e2d3a06fb5e3..d1cc58aabbe0 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 7b5f962f074d..4079809a5997 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 39297d449dd3..5f5bbbdde194 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);