From patchwork Thu Nov 17 05:46:16 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: 13046156 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 C110BC433FE for ; Thu, 17 Nov 2022 05:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234754AbiKQFqn (ORCPT ); Thu, 17 Nov 2022 00:46:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbiKQFqk (ORCPT ); Thu, 17 Nov 2022 00:46:40 -0500 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 845815F856; Wed, 16 Nov 2022 21:46:39 -0800 (PST) Received: from pps.filterd (m0209321.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AH3dCjF002252; Thu, 17 Nov 2022 05:46:22 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=ynyCX91+qKXzvHhkZ2kQzl6p4NUmG408AcZXWEyV5aY=; b=nYF8kIIQjZMKaYyTwxXPV11BbSL31CZOWLuyTKGw1iKDZam008Qb5aV+rWOaOxclWbp6 Yg147F2SriJfraN5g/Ks+pE0UX0CrkjoALuKBhBioC8KDKK5vDH6QlmmpbuBAWHoTdL9 W49QbZi1GxQQvBDvMracwmtYCDKdmyyFWYAqyMhxPu2XAZrIPb9t6lGno24hWWHRGG9N VbFISsoWfz90g9zf7BhUC5i/ercbwTujxmun/PEmihFtEqBBuz3CCPYA7ZjeOk+y8i+s d6E9JNGfcZivmyKHyROgRIW68L5zUy1blKeXdiGGJXeWhqvoVAGOTHwo2Qcuf9XLP6Oo gA== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2043.outbound.protection.outlook.com [104.47.26.43]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3kv3jmtjab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Nov 2022 05:46:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YsRfbZzIwq0K9UzHIx+/Zupk44Ae9KMQRKDG0kLKSd1YVR8xynYBqI4JzMuuhqfg9iXWsr5hj/2yZiKlCAETiJy+T3T+ITdZjzGdx5XW24oiLtU1qiafeCE5C4ry9PDhnq7qHp2y7qgZw7ifJMtpUWTjABCV5cJHLcSXmKViNqTt4Utod3XobGnsrDa0olP/DXkknVa/BJ21Upywva+MA1r5Tqdsu/O7di/hhy8KbP8DeKGh71mMJB4qtA1ROk0y0FZnElqw7OPLnZ0FkJ9hQv9AG6daSIKKaTToxrVy1wlsIJxbFvZ2m5UAgs72FozCD2Rdw1zZB/FUz4KORSzHgg== 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=ynyCX91+qKXzvHhkZ2kQzl6p4NUmG408AcZXWEyV5aY=; b=hDc/qUsI+BCS8iQVZt/fjUWzZV8ApY2a0QdAWz9dclUAxO5rY0wWQTFbEK55QpKMt/1rhfrDicQruxzsS4MvpTYcFDvBMirW/Ef4qAUWvsO1uPKsQOQWuPRbj2K5sRnRc/HUwBd/FxsusnIxxnq392PUhh8fBah6cPscd6+LFT/ZEc+GmK8KghSbHjHonZ8gh8iSHcBGlEeKa78fS4tC1U6AdE1GIDLud/6qN6I1rjwnMmaXSE1d1gHKr525wsuM0X3sc9E/3+zMB/7aSYMXsow9dW6wH37VmST3NU0uDGQ03xs2MHJ4EmhPyQPDfVR4E1Fh6fgp64XPxAymkc/7xQ== 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 PSAPR04MB4134.apcprd04.prod.outlook.com (2603:1096:301:38::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.9; Thu, 17 Nov 2022 05:46:16 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::708b:1447:3c12:c222]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::708b:1447:3c12:c222%7]) with mapi id 15.20.5834.007; Thu, 17 Nov 2022 05:46:16 +0000 From: "Yuezhang.Mo@sony.com" To: Namjae Jeon , Sungjong Seo CC: linux-kernel , linux-fsdevel , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v1 1/5] exfat: reduce the size of exfat_entry_set_cache Thread-Topic: [PATCH v1 1/5] exfat: reduce the size of exfat_entry_set_cache Thread-Index: Adj6RgjM4RrwzVx0Tk+pTmebpSgl7Q== Date: Thu, 17 Nov 2022 05:46:16 +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_|PSAPR04MB4134:EE_ x-ms-office365-filtering-correlation-id: 0f05fea6-c07e-4a3f-3b29-08dac85f0b46 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cKVGPCfwaX3STrgz2OUEy0mk+4YXP4094nS478G0KQE4RPXi0BpR81LsuBl3sSxOJBPxiZoWAdnt/bHX/rMC0rd93+2oG+4284bb8+qSpR6PS4mIhtFtmXvDI3COfBY3sb6+zVQJm+Be4NNCL/SHzXLsGbZ7iZ+vywB22vHeHPTVtjYnctstv4nbU2DqJ3IHrWCq01NhmKA8+9rQ6Y8GJTXZBRulVT51WqJDfoGxQhm6R8rJK85fVWeNYRyGrX6pCAq7x3R6g1Dkt+9qYLGlbf1jj/TdAGEk3ockeUzj2Lz0g40ARQIE5THIPgb+eaOiSPi/sfGBHVCT5DVw3mbDzxSSrtBlpdsdJBvKzjAzsvUbGZpELn7q1G9TiR7XsuTp2PbKxAUkARlOyJYoKBSMjr6vZ/KvJLOzVwDcn9xfBqKS+OO1cvEbGru0qIxEGxDTG3FMEXUdb4khzBHhvSm0jtmQazu7XRh0jJ/x8CtIu5Ufsj1yJmeplzjtGtLFTtEDLj4f9TAqHeN3d2Iix+cnHIsNbo0PHSVbQm9T90BuncbgVpP4CpTguTrjlSiJMlEfVKUJhKZHKLRU/mRbsJ5ahbcqUSwqsuE5fW0Fry8yVxxe2WfYoebUtbh3fViTR+Qfvl0yBBYCz7VPlIUcwulDV/2QoQzkeuZ/B7wkM47rXQb0N1cxtTB+pqT/XqzIsKCQ/hxnC7Z2O+5nByJoE+ACGA== 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:(13230022)(4636009)(136003)(346002)(376002)(39860400002)(366004)(396003)(451199015)(33656002)(316002)(110136005)(186003)(38070700005)(54906003)(71200400001)(107886003)(83380400001)(6506007)(26005)(478600001)(7696005)(9686003)(2906002)(86362001)(55016003)(66476007)(66556008)(66946007)(76116006)(64756008)(66446008)(8676002)(5660300002)(4326008)(8936002)(52536014)(38100700002)(82960400001)(41300700001)(122000001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?/0UvkCSrixtQ0H9fa4HbLg5lIcN1?= =?utf-8?q?UC778PHfk6njnQibwDbiYxsMjLJVJAkS9tEBJR5GUbUpNXvn0BM2RhVsaL2x52CDa?= =?utf-8?q?+ZiFcq/Rp2lMSdbIFzFaeZ4Gw0SAjcML7AWCT50imbFOuNBhwEFZNuh65v1hsEa5o?= =?utf-8?q?W9hSDHyTb3rS5jGgbiB+1B0HrBa8gitO7F+4YJ3BeBj/IsjT3kQq4lPeD1SA84OpB?= =?utf-8?q?sbB1L/MDmh+7b3CGDy7ybmYNksjp+8koP89KeZNI3OKAWh0W9t5WxdSzbAH3KZgbm?= =?utf-8?q?JVAakiwoqBYKdPaQD5SYu51g8IX7pjUwz7oRQ1g6Wdk49RWkimvXg83ppgnCFVn2v?= =?utf-8?q?Kh50ucCqall0iZAXLbdv0lG/hEBLpgosWlEza3pshWDQcGCjCy6S3lkd79fgf/LEK?= =?utf-8?q?GqNMDFvktA5/xVAYcZXTuygI30bAK35z15SscjvMMO9IM2HS99vl8bbSEA+IRXKvX?= =?utf-8?q?txQetXtQSy0aeaBRb15X4c+o+WVn/8RhEDU1zrjk985ZRpDpNF5aDBZKYHzWMsTX6?= =?utf-8?q?wBWkSVTg7zyr2uP4ph68g0kDh8PXDxw+zPNqtzTuQ6rzloZzGVwmAab+ZL3vwRdEe?= =?utf-8?q?hwsej14yG/1G2Zwxc4VxFY2QLY+dBv42tls4db6h/wice3WKy+IgWdhpuKtYTUSEG?= =?utf-8?q?7TYf9bv51dp9/bBr2TIu+oYD+1U6LzeCCT/abgHx/4QnA6t+rtXHzE42wDivBrTk5?= =?utf-8?q?26lOxwUaJiyFrw1MGVkKftohNGQGC5J/bgWL9B8NDlCxV/397+HP1QHEKOBxaApUe?= =?utf-8?q?4JdK8izmu+YVhDX5S5Sdv/zIUMTDEl0N/0+GZf/DKYExhkXM3ztImu00qN9RwornB?= =?utf-8?q?U/1QFfYhcmkL78fZvnXlqktQzD6MAJthwsPe3XmfFzWV7dkbOzoYbROHfJ5fJhY77?= =?utf-8?q?15TD99YHB/Abm1FFERgvtHmQaWsCLfxIIFzY+IlThapPAKyWBVRpFGltzF+GzNAtT?= =?utf-8?q?f4Fq8isYTuypardWPZ4bdQG8L30fUotLNKL8vQ/jC3oB4c6DZxFtTih+3Yt6ij6FA?= =?utf-8?q?60yDGRqBHcdeE5dUMyEFRm7HL0Zkzod6KwzJwXdEpZ+q2HXIyhKeweuojOD7eMS0m?= =?utf-8?q?Ld4lPLJTSJtqzu8RjUnjwUdB6FrUkStKkECvB0pl7XKahWFZEZYn4bwQgOizXHYRG?= =?utf-8?q?XfRS4IZ/JjismUamgSHRH4dqK/0y+0w+38Uv6txK4GU98CH85q++jv5mMewE9LSk/?= =?utf-8?q?HwMoZp2FMHZXQDCV6r/eK8CklTsFaQnuU7ARHDV/Nmzv27DM5a/18EUGm8fB2pr4V?= =?utf-8?q?E6Ph9nvvMrrSZDAuMLeYAFXgzmTtl5/emEnr5UQKt0MfT1blhW9FgT5FF2IC5LgZC?= =?utf-8?q?rRHC6WcS8diimLY68/I6LiHFiST6IuvuyrqROtKxl7Mwe0wdHKmN98SqRk0E6WKl6?= =?utf-8?q?y7hFhqx2uScUo/tPktBSS/ukLwGBbDcaAirU0KY5WOtqIGEQDvWGkEMlUC8bAeIpd?= =?utf-8?q?PVj2QwoHrnOeLq6L16yF9/xUfucNvUPWtEJeRg4x7m0BSQLBw9QXmNCTkKPs1xTp6?= =?utf-8?q?0zw0LH4TGrP2?= MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: bnbr9+7D6b9C//hJ/PgTPK+HKFHb0xLCTaNC7uCp0ySWz+7Bt3gnUDu0Xr5rHIr2oyGOz7S8cQ8Lri5T462VWTMj//fLMvWpn3jiywAPquD4qtWC4C8i3/cjAuyNtTP007IxF99hIfY5vtxP4xcsHX46/8rClCRBrCfW3/3P0xRWpdflKBCVCDhBhAy/S1pAtB+NMtK4fFbuo4LsfN2TNI2jXzn/iYbd/0lzr69IYDesqvFbnc4nb8MgvY6DYVUSTrDcGeHPiLAU9TYJ4lIu9OSL7IsMseXMkwlHvMO7KdD2awpkaX+me3HGhlh0C1x+O07UD9m7YbpNu33f6GJKU9Z4UBebCCA2wFQyoa6nEnUpT2ZgJ988s8JpeB/hSDZWfKWJoxKrpyqwx7/D+Gkqdf2Nj7i22MWthhhOs+VtjbCIXSihV5is/cMhrMOFpO/C0+Zg4DrYxUJUScVspzATyGyeNRuItEyAjJdhDqFM5MD6V8Xm87aTbLyPtaHk1YdjgOgJcmxig5UQXg8VV+JZxY02hgD2eQSxSighkFWKJ3fU7xXfzeZboivgxfwTVKVR7JdyOVUC4/vnbC6WxLGX721+Sx0m5N6LEV6/wBoOWtuBXDy4VRp6yvlZ3QN8//y4wMttm8yfIrpNI+111JhPbc4WK3t94ltyWYEUJML0FrYtr8467s9z3VRzLLsemJyIacM4nC/XXtBHpQJb578cGAWNEOVBTbEbfrejXbkFfNonGMBz1UrXPtTnyVrwWRuHDGwFXQGEAJrXtuco+ySgN6vCrlMZJp1djjDIOUovQ5xzKUd4zCs4noFYt8EkspMkctzgk7i3dFHMQiVy36GSHGnce1JGA+VxFc7KbyMZBjF9BQShxxEk7nq+VV2ejIL2 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: 0f05fea6-c07e-4a3f-3b29-08dac85f0b46 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Nov 2022 05:46:16.2634 (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: tqdR1xgG3CUIzKMjUnUh3hUJObxDQPk6pxKCd6PpcSq22evCnR9E3/9nRx8Hzm5EP3wlWKy0Aa0BQswNsaZn8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR04MB4134 X-Proofpoint-ORIG-GUID: qH7KW5O6m-y3xKEaRKlogaOXXF6BOZMU X-Proofpoint-GUID: qH7KW5O6m-y3xKEaRKlogaOXXF6BOZMU X-Sony-Outbound-GUID: qH7KW5O6m-y3xKEaRKlogaOXXF6BOZMU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-17_02,2022-11-16_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In normal, there are 19 directory entries at most for a file or a directory. - A file directory entry - A stream extension directory entry - 1~17 file name directory entry So the directory entries are in 3 sectors at most, it is enough for struct exfat_entry_set_cache to pre-allocate 3 bh. This commit changes the size of struct exfat_entry_set_cache as: Before After 32-bit system 88 32 bytes 64-bit system 168 48 bytes Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/exfat_fs.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index a8f8eee4937c..7d2493cda5d8 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -9,6 +9,7 @@ #include #include #include +#include #define EXFAT_ROOT_INO 1 @@ -41,6 +42,14 @@ enum { #define ES_2_ENTRIES 2 #define ES_ALL_ENTRIES 0 +#define ES_FILE_ENTRY 0 +#define ES_STREAM_ENTRY 1 +#define ES_FIRST_FILENAME_ENTRY 2 +#define EXFAT_FILENAME_ENTRY_NUM(name_len) \ + DIV_ROUND_UP(name_len, EXFAT_FILE_NAME_LEN) +#define ES_LAST_FILENAME_ENTRY(name_len) \ + (ES_FIRST_FILENAME_ENTRY + EXFAT_FILENAME_ENTRY_NUM(name_len)) + #define DIR_DELETED 0xFFFF0321 /* type values */ @@ -68,9 +77,6 @@ enum { #define MAX_NAME_LENGTH 255 /* max len of file name excluding NULL */ #define MAX_VFSNAME_BUF_SIZE ((MAX_NAME_LENGTH + 1) * MAX_CHARSET_SIZE) -/* Enough size to hold 256 dentry (even 512 Byte sector) */ -#define DIR_CACHE_SIZE (256*sizeof(struct exfat_dentry)/512+1) - #define EXFAT_HINT_NONE -1 #define EXFAT_MIN_SUBDIR 2 @@ -125,6 +131,16 @@ enum { #define BITS_PER_BYTE_MASK 0x7 #define IGNORED_BITS_REMAINED(clu, clu_base) ((1 << ((clu) - (clu_base))) - 1) +/* 19 entries = 1 file entry + 1 stream entry + 17 filename entries */ +#define ES_MAX_ENTRY_NUM ES_LAST_FILENAME_ENTRY(MAX_NAME_LENGTH) + +/* + * 19 entries x 32 bytes/entry = 608 bytes. + * The 608 bytes are in 3 sectors at most (even 512 Byte sector). + */ +#define DIR_CACHE_SIZE \ + (DIV_ROUND_UP(EXFAT_DEN_TO_B(ES_MAX_ENTRY_NUM), SECTOR_SIZE) + 1) + struct exfat_dentry_namebuf { char *lfn; int lfnbuf_len; /* usually MAX_UNINAME_BUF_SIZE */ @@ -166,11 +182,11 @@ struct exfat_hint { struct exfat_entry_set_cache { struct super_block *sb; - bool modified; unsigned int start_off; int num_bh; struct buffer_head *bh[DIR_CACHE_SIZE]; unsigned int num_entries; + bool modified; }; struct exfat_dir_entry {