From patchwork Thu Nov 17 05:47:07 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: 21446 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp229903wrr; Wed, 16 Nov 2022 21:51:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6W52Xq7Dip5nnSXeOzW1IH5+aS0rL7Y8lMOziYTM3FQKII0yag+s66FodupgHu7l3l6Lzh X-Received: by 2002:aa7:d156:0:b0:468:51b0:295 with SMTP id r22-20020aa7d156000000b0046851b00295mr807293edo.319.1668664261648; Wed, 16 Nov 2022 21:51:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668664261; cv=pass; d=google.com; s=arc-20160816; b=JCDdyaWE5d3ullyh11lqbNFwBi7IcWPwr6mRnlqrW3KJWMcHeGc/Z7qkgfqpqMMXFM dg9rhiqnkE9P9EX99wz5LpNcd1D0FZyvoKLwbD+DilUypaOaApY4OTfE5qKzSNEQSQdI YNLb5SEX0Yu7ntpBYaUp+3Tte0X6u1XzYnDs62PjxtEX79xrL4qsEtKmsEwGzeLCl8gT wIJvAfOj7E3PEo05y/cidyY8wyPWiW3Db8xWAQLVmsFtke+0oDGDZAkzXot4Dwbdky6u M9ojE/wOmOgPSSCCRYUE709jku/DbtgDBcQ5x8ZVSSaObcVOwSY+L6ipNitHnN5/e1xP Cuog== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=pfrryum0nwBqLaw6YnsxOdwqLWKcFnA35ooE0Dq9NKc=; b=tJ8QQC02PA7/oWZwFUL1wWKwptplWnPYfFz1148gEhFCBSoR+jTNHGdYTjxKtfiWn4 hBKp7kr98v5LmfpNgUjQj0RuGG/7E22KQPKQJP/PRmxK9S+Wlv8+DN//sCL7p9FP9GEg w95Fk59CTS6Q/F7+X5f0Xk5iAwY6HnviUWehVkqYYnkpfhICTYUKLOVci4EGs9UcJ1Wi q337pcli+fKwEsooshJBEAfaN1GNL+kXSzsUvlszHaJea5w02o4qNRVBfqRuiM2pCoKP Py2sK1Gq0wXvo5iUAfC8RijaaMXRjm1GxRosc4BXMSAqkuLMdmRCnr40xKyGRyztB5Xv 8xpw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sony.com header.s=S1 header.b=p9zsiIvC; arc=pass (i=1 spf=pass spfdomain=sony.com dkim=pass dkdomain=sony.com dmarc=pass fromdomain=sony.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sony.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji5-20020a170907980500b007417c6edb0asi13184494ejc.402.2022.11.16.21.50.38; Wed, 16 Nov 2022 21:51:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sony.com header.s=S1 header.b=p9zsiIvC; arc=pass (i=1 spf=pass spfdomain=sony.com dkim=pass dkdomain=sony.com dmarc=pass fromdomain=sony.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sony.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239267AbiKQFs2 (ORCPT + 99 others); Thu, 17 Nov 2022 00:48:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239284AbiKQFrm (ORCPT ); Thu, 17 Nov 2022 00:47:42 -0500 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC4206F364; Wed, 16 Nov 2022 21:47:24 -0800 (PST) Received: from pps.filterd (m0209328.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AH5XDVk025497; Thu, 17 Nov 2022 05:47:14 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=pfrryum0nwBqLaw6YnsxOdwqLWKcFnA35ooE0Dq9NKc=; b=p9zsiIvCFk/sdlVaAlZbHLZheZRJvXUb+1shh783V7ntXK8j3BsA3jaIgScFG1FiuWYr OWr/zm9biWVVAuELsXKl204uTHfpi/UATrItMzMgG7JKqUty1ZJy5MvcIpUvG3k35U5m jp9PBoZlqmWNhNnN3TG7pCLiKfT5E3CAcLroM1LHyp/qB2AXcQcLAmiyuqyA9QAyXxpR ddQGUevW7GpCdrlD0Rsq72Lj11vdPnP25vJ4mGns6aCHtN1ka3ALe5/DANcxw1ZZf9hT gSDGrorwhifnuqiZYhFPwPlP/Z4iB4ce8g3bjn1S2zFE6YyGO39Xv5FwYQP5dIOMdcU7 GQ== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2046.outbound.protection.outlook.com [104.47.26.46]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3kvvy510ff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Nov 2022 05:47:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FPaAmVIEai7zjEHy2emwHGvXOUCBH8LJv7dJPSGknmVd79mS/5fGcT+/7IUjMS+s7M1Q2uqDJ/Vb1jyS6cu7GSqF90siHFnT2R5pDENba9z/3+A1XCZxnjWE05ZSTFC4NCIEiLKkVdxz2DyDk128CHUD4PgzEai5WLeiEBtuLyHPTyHN6LYqwDkAEQlMf8v0kyvyIXp3NRo9LbT7nSKFygnUaHBCgS3ZcewSNqsGBfecYsh+KPdXyQZRXxnVHITCVXICG46l5W2ACXWi1J3Ov8mzT/nQX1m60Ij47NwPZPoG8prgla2KBypUg51ln7G9kMuCWK4kS+h/8LGZ4LSccQ== 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=pfrryum0nwBqLaw6YnsxOdwqLWKcFnA35ooE0Dq9NKc=; b=KS+FhlpGInoEuheAqA3wkvRVW/FHx+ka8dfgP9otJazq+xtVofEQKItVny3pY/0wnoC7lS8Zh49VrOk1oZQlXf4YcU8HQiDUrb3lssBuXKKUP4dcOK1Hs11fl4AjL8SXfi1MK0A+U2gbuQkIwGoU0muAZGFvQ+zKWOIxvEMWoCHOLBtAKS9q1Pb9P3smDCAKCjMFTDUPfe6MOnb0D7AVR/k8+ttfKFn9t2pUeiWA0Rr7C+CikNuFKVXMlPK/6a3S81aSx8qzWvFQZcs55hvuHjqaYwoi0Mw3vpdNA0nQF1ByG6xBspshfcQ+h1Um8EYtNSwVK7kfVyJ4XNxEMgFuQA== 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:47:07 +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:47:07 +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 3/5] exfat: move exfat_entry_set_cache from heap to stack Thread-Topic: [PATCH v1 3/5] exfat: move exfat_entry_set_cache from heap to stack Thread-Index: Adj6RpvVSF/KosGjSpqM8sfPQ61zOA== Date: Thu, 17 Nov 2022 05:47:07 +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: 967433f4-de90-48f7-4c04-08dac85f29fd x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ClphalQ4xAofbc5pNJ3mceTO4o1FaVJKuvKQ4W2k42C6Yc/0TZX9DIwRc0xPizjh9LttxGqjY07poD+HnJ0b/jY4Fc57uGzLbv3hrReyrRwnoVeFvMgPef1l4nNSMmjxB/QNr+v9uZSsJWbzQzvO5pN38DuwWuqD+qVReBgqrEI92SQbddC5exdOVrqqpiygwmyqV0kxgHN2bGQ8z/2CPiHM+I7iPBMSu3EfRYUbM9nycD4Msp0YTzVsp3iHjFabu9Fnj5m9UZAnaF4r1NJEdpSSKOJUlIfwFemw8YNtCe1BskEPYxpcxWdJA5KI7VLewcnr9kj9VwMw46sU9ihrBXYLEO7qAIJdJ5X2r0oAWyyRQAQjLg1qZgnmdSQ7e7SoWq1oSmag4jxbYOeR2Wv/xZdAZMy0zadaGs4FzUQQbrEMjMOfjQvvcnV+PbzXF4DfWzkBpii6HN6IxUIusYpD5e1+vjpOIL4FBxtckZPxwAKl2qTNCnqwiEqTOzvHKg69gC1gz4CGR/NsxIHBpPe9Z83FvMp+OpNNSHF9ZeS2uPxL1VvOiD8xSus5sEFdXUbBK2/Cm5NuWYOeM2V9pecmWzqSikICeS/LgctIzOTGPIPPSicSiRwpwxX/QyPEc+czxJHA919iX3SoPF8rImgTaksrNAgFSyyPWsRhD145I5q6kV9z/Y5i1iwyuCM1jKj4VWopKKD6jpd9dHV1CWmwug== 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?p78D9c0n963vfRAagSf7wH5arFJ1?= =?utf-8?q?RFRFqyI7jtvfcX8mWMriH077m/OqAegXa6yI+OVQy3XAecuqgdn5xdX/NmhIpoxxg?= =?utf-8?q?YlFKcVlZc+d8NEO9LaDifkZOw3421zqZ/zToTFf8W+KQO5LXqlu6kVzOz6SDjzjRi?= =?utf-8?q?kCGdUjJ9PVhx79bXyu5sCWHVvoh2uo2fhwMdZJ/01+KKDEqyaRhA+5EFm90XWeh/P?= =?utf-8?q?G8LLxK1wMauf6O++G2EGD50OLwOtxSeze7wRrc55M3M+AaiZXS4xVLO44qv3hTmKd?= =?utf-8?q?p1s8l++ktcWorHX4x6u2posEBRWBvII02aqE//HmVzAo77NQlczfGTRAolhU07Zcn?= =?utf-8?q?QhKNeJ58QeH8X0pBVyh9ak1RSN8apUCUS4dS/pYAvx9EvCPzMBS8GOBQxjb1uCtBT?= =?utf-8?q?MoWgA9VAnRKVzZJ/RJggGK9E7ctuMMaP/EbuJZt9nje5VskqrYvDUryJWMJYxt5iK?= =?utf-8?q?+M28oLGPjm2m5l9sAZ3W7hahVJM3exzUNHDyiN9ZrO6srBbGyIBt2keUR0fUx6m/4?= =?utf-8?q?WL2QaM8KuzKs6Dgb6FIOhRS5eKawooUY8nAfEBUoKcYg3Pem+mbq4TfcOgRM6YkqQ?= =?utf-8?q?iZzjbjhJ9NYEOZ/tg+etO2EkxcogMaWOQHTWGyRlOTF5TLwv6Tky/PCFaVwbeDv1G?= =?utf-8?q?y/nguO7JH6ZU0VibFppqgXySwjx/qieSdfvk1mpqWt9VNjT6lLFbpYJaEhNAxRrLu?= =?utf-8?q?hjpsYactxe0wMQpU6gpD2x7L33zNbTu3uFS+ZtTdBXf285Z3AMICwzqf84sc/y9Dk?= =?utf-8?q?/MQ1gsdxPdYHBFuo7olef3KNKDSwmUROeE00SqT37InR2ysuSynXaIm4kuNZP6LRN?= =?utf-8?q?9dx+ZC10prJiHm6YQQ0jHMTOabhvBO7bkKg2hF5k++zjhIVe07yzMviwMi+08Hibc?= =?utf-8?q?TRLUFw+VWQMOQMSQt6mcBmhYnc+0tRwtF7RX5AG05RnbUwy1kVVTM31R2eM0O2e0F?= =?utf-8?q?IF31oWGg1uXA4k4zPGcwWSGV/olvZTurC5HulWxRTFWoQ9I1h9Xaqm4ZyaD+JtuGC?= =?utf-8?q?qSYi/LiJHFX+DVtsDionUH5EADJlrKFAVOsvfNTgiayF3yk+wmwNREZnK//eVU5ul?= =?utf-8?q?6209umLo88TTBlJg59dTEsp0O+zTq8RPTn873hTD+EwIzITfVaHVWbrRqXxB64lYi?= =?utf-8?q?z5DaTZ6GINSOIjkllJzmtrrY1cwZuxe8GrrRMWoQmP4ifiA5/vZjV5U4Rbtz7yW0w?= =?utf-8?q?SjMMkE59PE1m9kykG65nrXZHAHXwGU6qCD8jb3xdxDxPnwX4xCJecMn4LOZinHxR/?= =?utf-8?q?XfVlnEbmHKDdxN9wHhvzCBevS8aA7gI3glG9ckEPxDv60+D7DOmxw1uqiXoIAWtAI?= =?utf-8?q?euHSlwwJF/XqhbWg8jkkksms2J8B6D+asIzYC9qSmb/IAlGVBV+Thrp9HkIIl8VrP?= =?utf-8?q?dU1qNBcfT46H5LFwnK3ODNZrWTlLVHwFtH8MYS0ejAYJMcXd7qNmY6dlyjDJNVE/z?= =?utf-8?q?r21+zAD20QYZFsyYilkXt2+UVkdPN7635f7XopjwmmiCp9cYu2ajbMpn6lVdOoQ6C?= =?utf-8?q?eBaAQtpaYNoe?= MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: X1Gc1VgFRG1zX3RIndNVHNx/9QtJKo/MRGW7LdSSuB93fZQLlXW5/YyRFmbytXhjt6cmMFI5BOC7xGGflDkPVOCJXaGZcOniocawVo88BBTZXNmvuTt474YPSWKnVYzIhzvPyzV70PfGh43t+F4V4NwlsjA1bxBpofwV3NVPFJK2iuD9gICLrwNG3h0evOex5rp3TT0qbT3jDLc2eBsN5fkLOP8z15qzMY/DOXt6ORbQIUDQbuvzZyNMxutr5GQLaHbqEtfOpJ2ygvpUkbFcg2QEvVLEO+Fu3a1xRIxfehTD9V9IPiIG8Fm9rw8bdCWsKBbe1jMtQCIJlHfJdX2fSOBKXE91EqedAVyj6YHvc6v6JIujfUxY91EG+QDCpQeAESibBtjjpsHQ7wlB1mWDywZwWhTVtg1ANnY9NCLzNHc/9UxBZMALB+vUOAAo2mTJYM5pKI1cWNxQiAIF68VfzI81GcudWpiH5KSfYtQDuX1lGWls9VEQ5c/MkIztHQEcdy7y2BcDL1mVPdHvz32/y05u66bN8YKmkA4g22jxx8FW89dBgB+e37yAWujG6GHMMeKLUANCTdav5V0jKMCitZLFmcqWeuDyjmtscNY7rW5o9lRQuzVk1H5La0CHOx13hCvaIs7SZ2e7UqunPX3yAhMOVPdNZqZKinxu7lMSecDL4n+WX6SZp6iRJPE0rQ1W6GeQiQdgYvqad+puBctccackPFhFloxbAYLSeWh7XFHsaGsVmJQrSEuEgzdkFpguTGYItwoYBJ3t+/7Ze+JWJZnpwkLHJU1FTaJ50SmPpvqm/72NC5yTytJVBaT16OuIbpHrPvFDEqEkYrpxds1fJAeeczhLe6kTiDujoV5aB+ohZZ4h0BV5gnLLqWPVPSwf 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: 967433f4-de90-48f7-4c04-08dac85f29fd X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Nov 2022 05:47:07.8104 (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: EepwFgB4JX4pPnPWyUrS7yLB08DWfx+lhM8zr3heBZ0RnTtudvGcG1yoapXaEAzUcjHNN0G5Lw5i5wDS0I10Xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR04MB4134 X-Proofpoint-GUID: GihcvNhPVEh14OPD3UPvF0G_P-RXYa4Y X-Proofpoint-ORIG-GUID: GihcvNhPVEh14OPD3UPvF0G_P-RXYa4Y X-Sony-Outbound-GUID: GihcvNhPVEh14OPD3UPvF0G_P-RXYa4Y 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749721296833006738?= X-GMAIL-MSGID: =?utf-8?q?1749721296833006738?= The size of struct exfat_entry_set_cache is only 56 bytes on 64-bit system, and allocating from stack is more efficient than allocating from heap. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 35 +++++++++++++++-------------------- fs/exfat/exfat_fs.h | 5 +++-- fs/exfat/inode.c | 13 ++++++------- fs/exfat/namei.c | 11 +++++------ 4 files changed, 29 insertions(+), 35 deletions(-) -- 2.25.1 diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 03e9c9e3966e..a3fb609dd129 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -33,10 +33,9 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb, struct exfat_chain *p_dir, int entry, unsigned short *uniname) { int i; - struct exfat_entry_set_cache *es; + struct exfat_entry_set_cache es; - es = exfat_get_dentry_set(sb, p_dir, entry, ES_ALL_ENTRIES); - if (!es) + if (exfat_get_dentry_set(&es, sb, p_dir, entry, ES_ALL_ENTRIES)) return; /* @@ -45,8 +44,8 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb, * Third entry : first file-name entry * So, the index of first file-name dentry should start from 2. */ - for (i = 2; i < es->num_entries; i++) { - struct exfat_dentry *ep = exfat_get_dentry_cached(es, i); + for (i = 2; i < es.num_entries; i++) { + struct exfat_dentry *ep = exfat_get_dentry_cached(&es, i); /* end of name entry */ if (exfat_get_entry_type(ep) != TYPE_EXTEND) @@ -56,7 +55,7 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb, uniname += EXFAT_FILE_NAME_LEN; } - exfat_free_dentry_set(es, false); + exfat_free_dentry_set(&es, false); } /* read a directory entry from the opened directory */ @@ -619,7 +618,6 @@ int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync) if (IS_DYNAMIC_ES(es)) kfree(es->bh); - kfree(es); return err; } @@ -816,14 +814,14 @@ struct exfat_dentry *exfat_get_dentry_cached( * pointer of entry set on success, * NULL on failure. */ -struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb, - struct exfat_chain *p_dir, int entry, unsigned int type) +int exfat_get_dentry_set(struct exfat_entry_set_cache *es, + struct super_block *sb, struct exfat_chain *p_dir, int entry, + unsigned int type) { int ret, i, num_bh; unsigned int off, byte_offset, clu = 0; sector_t sec; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct exfat_entry_set_cache *es; struct exfat_dentry *ep; int num_entries; enum exfat_validate_dentry_mode mode = ES_MODE_STARTED; @@ -831,17 +829,15 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb, if (p_dir->dir == DIR_DELETED) { exfat_err(sb, "access to deleted dentry"); - return NULL; + return -EIO; } byte_offset = EXFAT_DEN_TO_B(entry); ret = exfat_walk_fat_chain(sb, p_dir, byte_offset, &clu); if (ret) - return NULL; + return ret; - es = kzalloc(sizeof(*es), GFP_KERNEL); - if (!es) - return NULL; + memset(es, 0, sizeof(*es)); es->sb = sb; es->modified = false; @@ -859,7 +855,7 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb, bh = sb_bread(sb, sec); if (!bh) - goto free_es; + return -EIO; es->bh[es->num_bh++] = bh; ep = exfat_get_dentry_cached(es, 0); @@ -875,8 +871,7 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb, es->bh = kmalloc_array(num_bh, sizeof(*es->bh), GFP_KERNEL); if (!es->bh) { brelse(bh); - kfree(es); - return NULL; + return -ENOMEM; } es->bh[0] = bh; } @@ -905,11 +900,11 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb, if (!exfat_validate_entry(exfat_get_entry_type(ep), &mode)) goto free_es; } - return es; + return 0; free_es: exfat_free_dentry_set(es, false); - return NULL; + return -EIO; } static inline void exfat_reset_empty_hint(struct exfat_hint_femp *hint_femp) diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 33a3d544365a..363b98bbfdd4 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -489,8 +489,9 @@ struct exfat_dentry *exfat_get_dentry(struct super_block *sb, struct exfat_chain *p_dir, int entry, struct buffer_head **bh); struct exfat_dentry *exfat_get_dentry_cached(struct exfat_entry_set_cache *es, int num); -struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb, - struct exfat_chain *p_dir, int entry, unsigned int type); +int exfat_get_dentry_set(struct exfat_entry_set_cache *es, + struct super_block *sb, struct exfat_chain *p_dir, int entry, + unsigned int type); int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync); int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir); diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 5590a1e83126..cdcf037a304f 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -21,7 +21,7 @@ int __exfat_write_inode(struct inode *inode, int sync) { unsigned long long on_disk_size; struct exfat_dentry *ep, *ep2; - struct exfat_entry_set_cache *es = NULL; + struct exfat_entry_set_cache es; struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); struct exfat_inode_info *ei = EXFAT_I(inode); @@ -42,11 +42,10 @@ int __exfat_write_inode(struct inode *inode, int sync) exfat_set_volume_dirty(sb); /* get the directory entry of given file or directory */ - es = exfat_get_dentry_set(sb, &(ei->dir), ei->entry, ES_ALL_ENTRIES); - if (!es) + if (exfat_get_dentry_set(&es, sb, &(ei->dir), ei->entry, ES_ALL_ENTRIES)) return -EIO; - ep = exfat_get_dentry_cached(es, 0); - ep2 = exfat_get_dentry_cached(es, 1); + ep = exfat_get_dentry_cached(&es, 0); + ep2 = exfat_get_dentry_cached(&es, 1); ep->dentry.file.attr = cpu_to_le16(exfat_make_attr(inode)); @@ -83,8 +82,8 @@ int __exfat_write_inode(struct inode *inode, int sync) ep2->dentry.stream.start_clu = EXFAT_FREE_CLUSTER; } - exfat_update_dir_chksum_with_entry_set(es); - return exfat_free_dentry_set(es, sync); + exfat_update_dir_chksum_with_entry_set(&es); + return exfat_free_dentry_set(&es, sync); } int exfat_write_inode(struct inode *inode, struct writeback_control *wbc) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 99e00a36c029..8d72527dfb78 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -604,7 +604,7 @@ static int exfat_find(struct inode *dir, struct qstr *qname, struct exfat_sb_info *sbi = EXFAT_SB(sb); struct exfat_inode_info *ei = EXFAT_I(dir); struct exfat_dentry *ep, *ep2; - struct exfat_entry_set_cache *es; + struct exfat_entry_set_cache es; /* for optimized dir & entry to prevent long traverse of cluster chain */ struct exfat_hint hint_opt; @@ -644,11 +644,10 @@ static int exfat_find(struct inode *dir, struct qstr *qname, if (cdir.flags & ALLOC_NO_FAT_CHAIN) cdir.size -= dentry / sbi->dentries_per_clu; dentry = hint_opt.eidx; - es = exfat_get_dentry_set(sb, &cdir, dentry, ES_2_ENTRIES); - if (!es) + if (exfat_get_dentry_set(&es, sb, &cdir, dentry, ES_2_ENTRIES)) return -EIO; - ep = exfat_get_dentry_cached(es, 0); - ep2 = exfat_get_dentry_cached(es, 1); + ep = exfat_get_dentry_cached(&es, 0); + ep2 = exfat_get_dentry_cached(&es, 1); info->type = exfat_get_entry_type(ep); info->attr = le16_to_cpu(ep->dentry.file.attr); @@ -677,7 +676,7 @@ static int exfat_find(struct inode *dir, struct qstr *qname, ep->dentry.file.access_time, ep->dentry.file.access_date, 0); - exfat_free_dentry_set(es, false); + exfat_free_dentry_set(&es, false); if (ei->start_clu == EXFAT_FREE_CLUSTER) { exfat_fs_error(sb,