From patchwork Thu Nov 17 05:46:56 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: 13046159 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 5872AC433FE for ; Thu, 17 Nov 2022 05:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239142AbiKQFsY (ORCPT ); Thu, 17 Nov 2022 00:48:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239283AbiKQFrm (ORCPT ); Thu, 17 Nov 2022 00:47:42 -0500 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE4196F345; Wed, 16 Nov 2022 21:47:18 -0800 (PST) Received: from pps.filterd (m0209318.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AH2rpXC013925; Thu, 17 Nov 2022 05:47:08 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=s9nYSSvrzuXC4t4tRiuFVyOoiBidvlyeIo/S/pFhUN8=; b=YNWmwXYz9BHNqJxSFrQN9ALebtpvVn3MD7L9AmCo9zFxWVIszLezC1UlMrWxv5ma5MY4 oARok6jzSZkopQvPUndLtKqwyWGGg8WSPkmUxkwOLUoPIoNfeh7D5gXYBF8fk0NIRU0b PR0Mo67vs1EMwILAGm32Qtu1Kv6Lyw2jid4aVd/HHpq6kTHc/rF66kZPIk2Vs7BKIdDD 1T1HSXxgf2Yw51AuD7R4f0QtGm+SWfMJlS1mWSwMQvDOSD+c95vy6UxUXpe0WE2sfcvf spx+NgVpfhf5Kr7fyNpZwR+VzikuwRnisMRRAQ5LT3JOCMW9kRa2Tmrl6wXWGKtmoJzo uA== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2044.outbound.protection.outlook.com [104.47.110.44]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3kvwhpgxpx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Nov 2022 05:47:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=meHWt1nF9OZ3e3HK1QO7UArItyFiR1t6H10ahNqqP8hW8koVwH4WwzdRdHOFlRY6mJObydOZ9kyF+vbuISrq0WHCrwKlpoPhq4/2Rx/ARwBDz+JDs9BbZf55WZE0J05l6fUWVuGq4+AjX0JGnj3KSbvD8M/xMhHNM4UJ++Bcvr7jSxQaJMgUHj5qMxFqPkdb8/pk7mbnY/ivPj02/hAf/GL8l3VxT887le6q/wqnwaF8f5zXX9Tjk6jj3piubpnvSpFlJsY+26sIH3uNVsV8eWs3qy3w4LXmsMnUwrgKp5yaaVwHU8r4KbWCTsOH4qiSQZKNqzQex+wmj4e02144YA== 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=s9nYSSvrzuXC4t4tRiuFVyOoiBidvlyeIo/S/pFhUN8=; b=oEWDkhF+d/0tXIvMLJ8tf+Voe3NEy468R8Q9LPup/18IVrorxnAhgz9eN8ksVJ7C5B4BM82WDTLuL043i9QIJkFumBgpJPbroGT/uKZHIt1nwd7+2wZ/GBWy8Pi/wfA4at8uZWyY0jkxdqGfuA/dKBUTN5w709i6NYtGHAu2gmx2pPBH2i+58SX2D3qnqHpmOGDEPcR3F6norN+0cS8jB2mD4yIRzelRZE5d/YO6fAw93R+TnrEb4+3UkjLGd+Zyzqfo1R+9JBJFvNZjep1XFVgMAeoHw+pfzZ6Hnd9Przqzef+qmS2TJ4BincSN4fQfjZISJpEjEPir3H6EX350Rg== 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:56 +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:56 +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 2/5] exfat: support dynamic allocate bh for exfat_entry_set_cache Thread-Topic: [PATCH v1 2/5] exfat: support dynamic allocate bh for exfat_entry_set_cache Thread-Index: Adj6RlW0h6tBo002TMOVyOUUojuPWw== Date: Thu, 17 Nov 2022 05:46:56 +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: 478d3d83-1bde-4bfe-c5bb-08dac85f2364 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /ryJaA3DiNi7c/i5wcJaXdeNU2YO/O1yhp8MjoYgXEa86TRbiWVyj2EqxE8vctIHCVNms9Q3CrzSRP36SUgYJnQkqtM6L68HCLR/Kgele2Y3bk21QfSyLv6lcmJzbMFXPJo02YCxltZTpeMZlxP2TsSGeO1+MbGaZmlmQ1DpwbEUCXBUNCpu7nNm2Gd50MSLP0uyfIk9jeiE1dii835+VI6FMUZQa7kGsphnPuwsewpherxCshuL2ox92JSFyLrxIuJJwO9oA1qrpKEAQYi5tG8yIaMLahnqSD9cqhY/JpUDbMJXt/G/EEc5QXxWXip4dO+an7GQO9g+WS+sUq8xv+QQ4jY3DYPwbpbCvwqxEx/Ei2g9u+n3cr1SYDD/5r/6TEEjpzweE+Z/3qAvIzChzH13PPykF+57ESQVHoT3N2J9TARCPFAdM8WQsGN5s/kFfFrSsDnwr/Pm8S1p1pKv34jCwYVqZkV/Nl0w8P7AwDAIqe/xWtYs6Rz2tBR2ERO8eRoLipiJZlXg4ZA95vcHiqm8WoldtsrSE82IvvX0gtRv2wutM3JchZgxA0MJRCkl3kYb7l8aVPBiq9+uGXNoKU/d4OC0yQModsq1lheMVI3hbDiH6tbiarikDRRggA1LFv71MLMK8OjVhzzzKHsAxJZ4qKNFOpiYP7O8uKJLp8J+BYgW/5l/cCJfCowL/AYG0mjt1pd5o997Yq7dMn9Amw== 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?AunPorKaWfH8yc+JS3v7tiWkLWwe?= =?utf-8?q?wGIELdGZlhWrVl64gqCm0p2oJFyVrNtLpNo/TXCKWTdv05Y7NP7sMdstYKISEEhuH?= =?utf-8?q?Fb9Z6Z5MLH720GXtJWrE809sxROltaO5TS1yv/V4wr5CK1PegrYeLyQRtZbxRhjY9?= =?utf-8?q?2iT9iqQNrs22PD2ZEMBYP6wnuP49AyGALnRceiKs7e09lzjFoiFvBZk+owWJHhlaT?= =?utf-8?q?PFF3XTX1dLQK1FXpgRzLHWLzvBDDhO987SrxDOdDdol3l3dvC6EhBrJUUzoMwfRCA?= =?utf-8?q?1jsgufzSXfLyjZuHChpL+4k4pQVEf+Tgw/XsHMV2MroRbsm99R4Er/vLd2BpS0E2n?= =?utf-8?q?H+XDvLYEPRw9PIwwbeBorJtYrDd2oY1HworIJjoohRBhXxd2xuHyqJsKZxnshei1/?= =?utf-8?q?LtV5aKc3+krVBIwJ4pG+fBJSQ7Ee8457e0MlDTIlDCCskefOXlLr0sNKt9yDPGqLb?= =?utf-8?q?8LJMBFhdQSlo2PeWR+VEtSUk7txnIIjP/R316WtMp5ObCWtQGcmb3MdFoHmkQgc03?= =?utf-8?q?fshzKwIY193ru13jTqYdGjlZE4uYP09PZ/LsXTdZP/qwEqnj5baf4EORw21a+14lF?= =?utf-8?q?bLRRZg3ms3yKfGt7scKyYPb8Krc0BKubQ6LHyqY63kFNxBLvXHOgo64n24mCVttEZ?= =?utf-8?q?aOMKt9Hh8t2BpQORCVrjwbhT1nHQv4vb4FNZNAmy3LSJgGw+Ty+08aE1NpkoWFcHN?= =?utf-8?q?oRdOikNJWVKYPWAObbVPtwrzHXoh5T6ORv2AdTmIQS57yqcyNcdgb2ASPOPT42dBE?= =?utf-8?q?D9eXGpyYuilGheDLAj3w2+g116fky+W15E1+ahCt9JXuasGd/oyEKeazWUHphAYpS?= =?utf-8?q?nkXZS3af/Ro3njlQ5ZZ3/tinlzXdbTR7N7MKlgyEHa+ZeOMJ28Xtqo//ewrQckdnG?= =?utf-8?q?8smgFP/+9BWTNb2lDz+XShTGTAU8EdYR6okmryd0JRKT9Rq5P2ftiMd36LhTdA1Q8?= =?utf-8?q?79REwpxqrtrdm9Qgdt19hrowsiG126qBugxFYCi46otTHJi7cGRTZvSRDvGAhaSl1?= =?utf-8?q?sMmmtFkb2jF5QwQM7A95tthaNz8DItLiyY9H1/exhim9SEqEAMaOxNdpnXVV8W+MW?= =?utf-8?q?10PlZeOSnL6VCNahxIBKUZm39wUpGIbvCGO/Pc1STR8PaNyIbJCtl22biH45ad6uR?= =?utf-8?q?dvzClqJp/v88rRUj4Gnc1E9Hsg9I9FxN7PnuSi3xZZGMCFwundODcFdzMxnMytVY5?= =?utf-8?q?VvYM9a9/ZSQ3UPC5fz2+wNbxtP57OqBO8XUwyyUxeK4hnFrF6cG/E4r1l7ynogpF3?= =?utf-8?q?PWNqPLwm7uu3DCgM2EbOe7RA7e8MKcnQKj5cj/Ih3wZkkl6GRbWI+h1R8l3i4nFSD?= =?utf-8?q?wvbxaeKC/KOeQ/q+YjAH7lGF7Brye9GNwNUTIukX/8RYDsNIyOLruJBGBWjp4n70L?= =?utf-8?q?9zUwhzggkvu9Bs+Lh/QGgKeU57J6f9oxGhcycUJxbIKTD5CDMCXJfZmtXOSKbQ6Sy?= =?utf-8?q?boOIPua8S/lKp9g9qDhGAzga926vX4npv8EUGXTFseVbdOptQZ2lNFVvtQmYh6DsF?= =?utf-8?q?dtCFV4n/cKbS?= MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6GXGN31fta0yQ3HQXB6oghIzp4W+O3xABf8WTnAP/PiVwPm5HYpTRFUkV2F/sdaPxT0rZolJ51LcEi27t+h0jVdkfEpjJoWA7potK8d7d4npoKXgY7ucnOzJBB8U3vJIMcffheENzcrMwcOTb3Go199DDaSoVym/vz96e/3tapdx0X05+gewzUs2KAAS4NU8WGzeQdTOcwi5xbcmUfUlapsGY5+dyZgbo25C1FBTxppPfRuVaYGppQCy50VwpeL9EB92AhD2x6v5rDXgu2FsG422RBKg+FX5L/wC/u7aIikmh+4NBAFW9e108xiiuNl2yLhltKn4w+v2HFMrZk6UOhmgImSCimd42kt7nJuL8O7gJAitUGg1HCMFpxJPTcycVTD8kWSmL1/APwthmjg9q6khEZteg+IpDFRJxFUCVzWCwAiU+Qq1Rrbz+h6xIJniGNpnRyLe8giOJwSwT+LHM0UhseRPWx1Zjuf0VOW52XngRGQdJS8/uWoYLsSWMydsp+/khqhRdD0zS6pHyuQ+OWRRP8YtufOjR5SEXbt4ITnBHLCEQqJ5QsaGDDdXrTIt3OxvQWCuNhOd3YuGpEjZY6fu/DngrgfglHBOjVhGh/0hsFvmyCiN7Ve7pcjFHgs+cWEaHFnjkLxo6v6aVJV5AvE8G/+H4FisycsAKbFurfgYey7cFocrGxVc1z12xxzD6mC5rte+6po1jfNMApesZXATXaWWtvdp8/7FiAbF1yAjZ9SNcuJWlfkYuGQA/dJ6NSYpiwU9V3YLkzz5mrZr9bP+btqTGWJg/3yQ42ZCygc2Y8ygDSuIVrLIVOpnLoha9mZ00+YNKcNF8gGkTJ+EtFTH8wquioA3Y4Lu9ribGM9XNsFm8KcV1WW5fCUcS1ED 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: 478d3d83-1bde-4bfe-c5bb-08dac85f2364 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Nov 2022 05:46:56.6963 (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: YZdYQUTEbm5ZkyC8B/oLHMg5xtRlhhXM6pnvvnE+Mjw7/zEpn65g+scKvNQqeNvSii6P35Wj+Qh0nsQHwP13rA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR04MB4134 X-Proofpoint-GUID: 822aN-kN3FM5WGLczgZ_DxNak25mcitc X-Proofpoint-ORIG-GUID: 822aN-kN3FM5WGLczgZ_DxNak25mcitc X-Sony-Outbound-GUID: 822aN-kN3FM5WGLczgZ_DxNak25mcitc 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 special cases, a file or a directory may occupied more than 19 directory entries, pre-allocating 3 bh is not enough. Such as - Support vendor secondary directory entry in the future. - Since file directory entry is damaged, the SecondaryCount field is bigger than 18. So this commit supports dynamic allocation of bh. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 15 +++++++++++++++ fs/exfat/exfat_fs.h | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 30d0ac43b66c..03e9c9e3966e 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -615,6 +615,10 @@ int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync) bforget(es->bh[i]); else brelse(es->bh[i]); + + if (IS_DYNAMIC_ES(es)) + kfree(es->bh); + kfree(es); return err; } @@ -847,6 +851,7 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb, /* byte offset in sector */ off = EXFAT_BLK_OFFSET(byte_offset, sb); es->start_off = off; + es->bh = es->__bh; /* sector offset in cluster */ sec = EXFAT_B_TO_BLK(byte_offset, sb); @@ -866,6 +871,16 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb, es->num_entries = num_entries; num_bh = EXFAT_B_TO_BLK_ROUND_UP(off + num_entries * DENTRY_SIZE, sb); + if (num_bh > ARRAY_SIZE(es->__bh)) { + es->bh = kmalloc_array(num_bh, sizeof(*es->bh), GFP_KERNEL); + if (!es->bh) { + brelse(bh); + kfree(es); + return NULL; + } + es->bh[0] = bh; + } + for (i = 1; i < num_bh; i++) { /* get the next sector */ if (exfat_is_last_sector_in_cluster(sbi, sec)) { diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 7d2493cda5d8..33a3d544365a 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -184,11 +184,14 @@ struct exfat_entry_set_cache { struct super_block *sb; unsigned int start_off; int num_bh; - struct buffer_head *bh[DIR_CACHE_SIZE]; + struct buffer_head *__bh[DIR_CACHE_SIZE]; + struct buffer_head **bh; unsigned int num_entries; bool modified; }; +#define IS_DYNAMIC_ES(es) ((es)->__bh != (es)->bh) + struct exfat_dir_entry { struct exfat_chain dir; int entry;