From patchwork Mon Dec 5 05:10:21 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: 13064132 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 4D998C4321E for ; Mon, 5 Dec 2022 05:10:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231530AbiLEFKm (ORCPT ); Mon, 5 Dec 2022 00:10:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231494AbiLEFKf (ORCPT ); Mon, 5 Dec 2022 00:10:35 -0500 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACF961007B; Sun, 4 Dec 2022 21:10:34 -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 2B54ssoi014669; Mon, 5 Dec 2022 05:10:25 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=KYCcM1idfex/9lRd28q6AkXweqmzSou4GSyVK+Y3jbw=; b=IUXbxzsU8/r88J0yfIJLopqOpmCWBab6XClmMSc3J2lYBBr9xNbNWkPyYuimPsxB6TSf isqSalErxdRqfoDzKyqQV/FYcsOucmgMgJsWYMXTEQ8oQrtrMI8rHxJ0k/pjdnKifaF/ QIFu8KaPC1L4XFcCseXzXeg9zzd1D0HFxa1CIYmTlqgvuIIA9zZDPeooYdTOeUCw8Cl1 3wDP+xqj7LS8Tw2bHR2NxfKiIPGCp8ZmyLRVVC/mf1nkKfvBfAQdcSl4fVN5GJBwWzT8 3D8ySIa09hPCl3lYkg3BPldnJqrkFMs9IelIZyLMlokKuz4ci4gZbNsbfVkyhUjlsvHT +g== 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 3m7ycb1ahf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 05:10:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ezgT5ui5cuGlLvYKveym/+XOAyrvskqO3DWbjlkSorbqX9gvYY3mQ7KipqEpLFtKkC+GnXP96S4XjmAbEOFoSpyqbPiSx5Szx4LXsUaIHleln3XStlgXw1qPgmC6sEiFAcZppdXkAzAwYooClcfD8ygtwr/K6U/v/wFC8SvI27Skyxwl90jEWW21W4yMCKftiAUAQ6P3739ClcvstOYB8cpBXAvVuKYDe4ZuZ87IP16AiKQaK3poYtJk6XwQkZOZf45RIjbdQJLflss1zSkJE5f/OXOq2KBHXsSOBJJlkzhhQ6L8xdOlNaHa4XvbbcsH2DO9AqQ0vJcwrxWb+uQpng== 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=KYCcM1idfex/9lRd28q6AkXweqmzSou4GSyVK+Y3jbw=; b=Zae3TfqEDQb0mIdr4Uyi6ke/rVQ5fQyajpeSbVa9zmU12dGKSFRHv0PmAy7WyhXi3fcOu96V0T47rUyHa6ud1ctHCBJZ8+nEq8ICOKjOFBlm7Kh7we9QUq4SiGw3t6adg6wM10BzDmdq4uVOdGZR9aaBfIr1nqd6bYo0/+PKQ4syCrewrA4GBPiMaRAISZz0UDTu1am/jBCt9eHtjg9q4/44z3eGnkVoggEtPkDy85BEr1TIqTAzh1V5WUP/W69u+9GaVh4t9colmRXwvr8OU/q31JZMRrSzD3dQJVJJfPJMtJz51OA6yBstnvKr1OSnnA7PLtmDQZKxm0+elG935A== 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 PSBPR04MB3909.apcprd04.prod.outlook.com (2603:1096:301:2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 05:10:22 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de%6]) with mapi id 15.20.5880.008; Mon, 5 Dec 2022 05:10:22 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v1 6/6] exfat: reuse exfat_find_location() to simplify exfat_get_dentry_set() Thread-Topic: [PATCH v1 6/6] exfat: reuse exfat_find_location() to simplify exfat_get_dentry_set() Thread-Index: AdkIZxYuFGc68+38TxOwJ6/NYKH6qw== Date: Mon, 5 Dec 2022 05:10:21 +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_|PSBPR04MB3909:EE_ x-ms-office365-filtering-correlation-id: eaed9b83-58d7-4664-e8d2-08dad67f02b4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Vnfb5eOlbQn+jlCA5xtiqKjtbyiXDZALBUvhSxxCENsb59/dP4rgmtNvfQK3GzpXk4Lo4Vv+hFTxmIBxreODEtu7IMShtaiLuZQI9vVOsiRbmFcIjkbkmRqoHW3XxHR9Psb//DY0EzJSNZ8ajH+meb82q4MxdGSVTvfqme8lv5RBFyi7b9IekfBCB7z37b1ExMM6mzs0zg3UB6sZCzWHUBb430P90n0sfrbS3WeMj6HXwvEx02aODRKKwhxegSSNDDdH9VA8YXlZihQX1ULT2ROxdbsMnC2i6bNEN77NXXM+23cY+fmLs8OC5RCDN9WN6c9pPmK2eO+JDGRxPvGJpdwCVPGsso2Vr4SOf6jYSAJz1oaFqgSMx8gYS5LBvAUvyU4h8Dp6HUO7K2Zeb0txYKzT0Fnj6+yKPhEM571dLQt5v5SU4yNEyDLJpNoppvoeWTUblokZbOmmi0ZBguTimGuK6qeMDw+CCMLyOJq8eelczxW3Yu5Xp7foceRnrG6PETcJ26YgCQ/XaJgHxalXRyrcR2e3qXswOSlJGuqVxdXOTxI/DhV5Oev0k0h2FGAh1RqQPK0i9mNUwKsP0V80dvZTL/+H/wzUVsHSMtbWWKb1VD78W7eX9L12vb9WuKwjGMgAfr8lq2jpzT0U6ODTQ8OOFq0tQz+uia0ct+Tgz0b76Sj6ds35nCDgaQqE/rg3QFjfAuALhu59ezEqHuw8gw== 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)(39860400002)(366004)(396003)(136003)(346002)(376002)(451199015)(26005)(316002)(107886003)(478600001)(6506007)(7696005)(54906003)(110136005)(9686003)(71200400001)(76116006)(66556008)(66476007)(8676002)(66946007)(4326008)(64756008)(66446008)(8936002)(52536014)(5660300002)(186003)(83380400001)(41300700001)(2906002)(122000001)(38100700002)(82960400001)(38070700005)(55016003)(86362001)(33656002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?lm64/RWcU/G8ON/0NQvSFSyrV612?= =?utf-8?q?rygIqGGssHqLOMOyMZJanobe3RpOrTSWZdwV7X/jplsFfYrmvwMmKkjPC3ZXoAdFs?= =?utf-8?q?cewP9qWbRXYIQ+wLav7r2ucwCFD6J8RNjmjM2FQmbk9RZS7Fh6oygJhbU/etH7wZm?= =?utf-8?q?R0VgOhHSUgkCPzhbhux6+UOlvRUQEU651Eh9UyHPvMlGbNoeTzAvMBZQXeHo9/IBK?= =?utf-8?q?GFPhaeU3nsD5kxHll4PYUbc+AEyM/SIJjEp+qOq99JI9Jy5wB+OvxatLFUcrW3mYV?= =?utf-8?q?4IflmduvkytAvKACjwLc1gmDclIM+c66cbfJeqerH9p/BDI3AWpUUuIqmCXVG1wRw?= =?utf-8?q?ATPEYgvE4PtOPq4G7LddXEEn3cDxuQQepR2HiRQ1T3+P3Akxik7GcHU+AmAiUGq0S?= =?utf-8?q?++u8+xxHX9dMeAvJsWvDV6vX1f7TamjhLCoQtL23x4dLXDnySdw56Ve5+CvE8dbO+?= =?utf-8?q?gAnPLtRnomB+zwJ0tkFrDQGAx1ADjcvGTSYRdgUdq8LWbyr2T78CJ3P/lo/OIyHNY?= =?utf-8?q?zoHEaLrmt5HSfJpCKE8PY0MtI8pCF/s0BHGIJSVi0OOHtbKVemn3mZET4ZPXR2vhp?= =?utf-8?q?XN/F7HVsz0AynNgRXhu+dOFriXATi0e7pBhhwzDJwTGhNdRWqiRCFBEIxEsb0hw7p?= =?utf-8?q?Tce75+6Tloynt5koVFItEIrXaoNPRDkvIHmwbi4/VZKrAy4indRmysHAGX87fvHn/?= =?utf-8?q?HAqMUdPo7HkNvojzqx4+XLcOA9sdyMOm3t8w2StfHg9ivEhzjb8JvwF++M9OrnNYv?= =?utf-8?q?GKZ1mWdVtJtEvn7GUUOr8GbvLoopgmwF/apCr2C8CcVnB8gvHCq+hdqfxJPfgTGTr?= =?utf-8?q?Od2TQgkGuWbI8XOB6/8mcoJOoukjH6jHIi0zPY76ojvTxIJKKNB38qiBAdhU9RvDC?= =?utf-8?q?p7B+gFr6WqRkkM+KwdRV/sbFcTCyjFn7NyPEEQetN9+VyFxroz0Bv2lon37bNX2vw?= =?utf-8?q?gGGYruaPLd26NpwdqoD5PVH5eFRnulYP+BWJYjHCG90eq4mTKmTIThr01nvnsCpK3?= =?utf-8?q?TaU+XxmzoQ3MxFbSQvZ33egbaISvvK3bmPQsAgsOe+++D1a2ypyB/gXtfRwHOQQkr?= =?utf-8?q?fQpmbhDaPfy2iHFnwKL/90wiKS2A1cF8A0N+Wgb9wJ6jDLYvrAV3Z0Q0d0cMTNyT9?= =?utf-8?q?Cq0oGBdJVMRjIog28cLFDLcvQcx95E2XQ3xA5IMvEJ5bi0U04odhAnd24cQPit5+R?= =?utf-8?q?LzzMm9oiWkrpVDScg3LE6PbrWOH9Kr8chw4mtEb6kYAnuFVk0grbUWHoW6pJXEoER?= =?utf-8?q?+I0KSZ+xzIb8K6Qor7WtVSVqQIpOPnbW/H1mM3wdOjuIQvMkAdyk3F4vHwKnA/Pws?= =?utf-8?q?ayuqgV/Rqip2rSC1YiN6siFldEvvWCukGztRECaJRMhG1PRckxvV4NG753JB1UIH1?= =?utf-8?q?xTYjKGdGMNJuK7yrFuXLnBy/pdUdr3sqoFQ4fv8ahIhO/U6St8Vkycn5wrfNVQ8/3?= =?utf-8?q?YVT/DkJzELOHytgMR2uc+2+WSchVjInd5Iuw30q5HGnXry3o02/EpT9/Das8uMA3a?= =?utf-8?q?l1AUx+zPrkM2?= MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: yd6H32pePViWfSjmdy+RAd6B7TnwkaBaW21HxOgJQ7Ux5OESwzQPliw0Rq5ZrCj9rd93vISSgV+c7I6yH6WxoCKpz9ns/oG6aBfvOzK57NBUsONxVmzWYh9jrqMKOoC2gRnqBw2mkN5QmXTtNHe463QV9O5xs7SE5n0MkUW8Z+a6SBVGlqPDgh5iteDd007FzoOnbgTtrw67SflnRQibYcQknX9sQyTub54t7O/Wg0FZHPQFAFn9MzG3jyIpEkyAfzMEw1LxCtWEJLZxdslkkBMFf9FtLTRJBy8tYwnhpMbyj78blp0YNO2gNuGJI9wnQO+3cXfNAmdHOQnP32/evF6bgPG8XCNF/ABIuinLShQvwi0Iii4I2coFxtvg2hqgX8KuYzREy4ZHy5VfJ3ntfUKXXPwiB0TblMSDmGRgzBxlmirut4Sl/esNQuA9vyoPCa7CiiRDFUkCY+SAJRtn3TgfFZ4fX+Q7ODaYvkuCiWa+A8GGKjkAFqtnTMYpqFXOK9nQ2hvNw1aev0G9M573FwvUFIQGvvAaNbjlxukybFyVgmiNtt5hEJe1iXazrHFF+J2QvfkcBffWPiowSxYvIfvQKq0+0NLOpaERWmlq0h6nue/vI0kGv5QIdaPKa2z2EWday+Il4qdC8UmXp2JbswJqCY74RHopczIxXYy44yXHpCa3Y54qWcxoFNgObhU8HFlnRHRsm/3ccq+vRaMTOwWAeT0U6a3nw63HSbpA6JejQ0VnNxah3YJrlBY/UuoiX2Ny/sCQOPrfKFaMearPJR7qjaijfAZqdAc+1LGGili3On0xxlFqy9VVewwckg71Z8529itfrP68L3dFoHgywsUql6AgJyPwSijQqd7FaijP+ZYDpFc/xH1FTcW7uosf 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: eaed9b83-58d7-4664-e8d2-08dad67f02b4 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2022 05:10:22.0478 (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: oWNnLK+ZqrO6bTPk0TcmhS2A86v0LDaxPxjRGDYEg2WLLzc91XSpauNoITIHZnw0GdRsS/52KynuLpH3Lia+Sw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSBPR04MB3909 X-Proofpoint-ORIG-GUID: COszx_92MyhTaBCaPQCIuB1Lbic_VTwb X-Proofpoint-GUID: COszx_92MyhTaBCaPQCIuB1Lbic_VTwb X-Sony-Outbound-GUID: COszx_92MyhTaBCaPQCIuB1Lbic_VTwb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-01_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In exfat_get_dentry_set(), part of the code is the same as exfat_find_location(), reuse exfat_find_location() to simplify exfat_get_dentry_set(). Code refinement, no functional changes. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 8121a7e073bc..834c0e634250 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -818,7 +818,7 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es, unsigned int type) { int ret, i, num_bh; - unsigned int off, byte_offset, clu = 0; + unsigned int off; sector_t sec; struct exfat_sb_info *sbi = EXFAT_SB(sb); struct exfat_dentry *ep; @@ -831,27 +831,16 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es, return -EIO; } - byte_offset = EXFAT_DEN_TO_B(entry); - ret = exfat_walk_fat_chain(sb, p_dir, byte_offset, &clu); + ret = exfat_find_location(sb, p_dir, entry, &sec, &off); if (ret) return ret; memset(es, 0, sizeof(*es)); es->sb = sb; es->modified = false; - - /* byte offset in cluster */ - byte_offset = EXFAT_CLU_OFFSET(byte_offset, sbi); - - /* 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); - sec += exfat_cluster_to_sector(sbi, clu); - bh = sb_bread(sb, sec); if (!bh) return -EIO; @@ -878,6 +867,8 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es, for (i = 1; i < num_bh; i++) { /* get the next sector */ if (exfat_is_last_sector_in_cluster(sbi, sec)) { + int clu = exfat_sector_to_cluster(sbi, sec); + if (p_dir->flags == ALLOC_NO_FAT_CHAIN) clu++; else if (exfat_get_next_cluster(sb, &clu))