From patchwork Tue Dec 13 02:37:12 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: 32604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2596663wrr; Mon, 12 Dec 2022 18:49:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6E7ORc/SeWum2jDHKG6T/sSvLGkcqEAyv4vwkYsM5ewmztXcDFx1pBO7wNGpk4IeirNzhW X-Received: by 2002:aa7:8818:0:b0:577:9807:543b with SMTP id c24-20020aa78818000000b005779807543bmr19199915pfo.16.1670899776542; Mon, 12 Dec 2022 18:49:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670899776; cv=pass; d=google.com; s=arc-20160816; b=asXYqQS38e/FgVmGjrZoNhVQ0+KjZLCnAgcWyj4j5ZCho8pIfJSwoeC4W0b9PYJ0QX WcFIlLQTTaSxBF+FODcjaa7YkvIXKtupF14P2rrLOHkxLM7+/twxA6Y0ofpdk2hZqoZT YMNfDOJb/4Ve1NJPafvqUbu5P8c9EDLIRbllf4B194Nat1Ouv+EPfI3i/uLKVcXtlxSa jOZzzg/jYstmAJqgZriaoh1CeZyIPGnQ8L0WW9cC0CN1nY75GXmgfNwtZZgktOijd7xH i6CoRNyT0gW7xBcVU7Ev8VgNW01lw+WOpZNNaX4RVG9v6kXX4nOCCrBesKmuQo7tRRZY ouzQ== 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=ltF9uTLyurlLxk/wr/RfDjvUK/5Qter81QMsfjKp15I=; b=lIuOoQxVtdeKy35tprPiK4L/Rx+CbsdPTWm8s5O84eO7Dz40jw6Iw3j1hYlQx9/u3l 1wE9FWb6UGAwnPuSJIXsPopxIfBXX3mj2/c9wVsNnAbU7Fl7cyvYHJq5bSW6QNiqg7+h mTqESpj+zODLCRkBpleQ7ITqtwl95POFbBKk0wYPbgD62dSNa8Hiqtpd48NZcy0Ot7yf /e9bOQPSOd6Nu6cRpAGWBvuVwGkiexb5XSzrRLytFD7T9B+2W4dZQcs4OnUyEPOpekIO G+1T8HLncqxbfrsdeWhZKvYxHZSUpNUx9mwEff1m8f61vZb4SNnC6eEwAo5MedzaZvuk XqNw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sony.com header.s=S1 header.b=ohkH+aWB; 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 s7-20020a056a0008c700b00577967328b5si11930474pfu.250.2022.12.12.18.49.22; Mon, 12 Dec 2022 18:49:36 -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=ohkH+aWB; 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 S234425AbiLMCjV (ORCPT + 99 others); Mon, 12 Dec 2022 21:39:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234286AbiLMCiH (ORCPT ); Mon, 12 Dec 2022 21:38:07 -0500 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9866A1DF3C; Mon, 12 Dec 2022 18:37:30 -0800 (PST) Received: from pps.filterd (m0209320.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BCMfxV6023229; Tue, 13 Dec 2022 02:37:19 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=ltF9uTLyurlLxk/wr/RfDjvUK/5Qter81QMsfjKp15I=; b=ohkH+aWBI2GvkcAz6gUo24qmpRuz1Pwz0ntS/N99zsCktlutodEgqSGWi+XtWq9CgFAF xleFx3Gghuvq2imB42mofocgRODJKFx/cYnKSuJXx0TQ9WKPKhCxMDsq6zz0z6o7nZQv dcA1+KyKMT820xhEE/LJneiA9Qi75nnQwoIWXQy3c4ZtWSIHwzVaXXe4QS68FPiUw5Y6 RDysU9g1CPM6kP/4RaWsm2ejanrzBSeQmZgqpH4k3G+L4W8iKD7Gj+YxRMDkynX8GoPs FqdusU2onmVRYmqko6NYgAsCj/MFU2fZmEO7l9ugp8S1l2bMREVqj53TrQtfuuNK8BJ3 pQ== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2047.outbound.protection.outlook.com [104.47.110.47]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3mcg0majja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2022 02:37:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I7CK2nQ2tJgHigANthGgiEk7pHjiGlR0NvdFhbPYh+DioI8FhNVdJwatGuwU4fQG7y5Lhh0R1y5TNo8Ur+/dEOQGOm0yvUIll8txznTn49UJ/i6eqGVLZv9OsxndtyJqo9yw2DMwUyy5daryAjdpkpEuGU0oAmnQOtFPi1r1qAGj1Xl2xj9f//X6FsFudrMiHt14Pe3H5ba6HsBo/5GhcaMXgcpHvA823sLM6WLLqayvwNb73BxUjD/JJ+fvMegsq9bfPXMa6oxaKd7tm3ewWmbxREqoi/nYtpaicDaWbxuDXbdN5iUSOSJPx6uNJlQnDzn3Ze+ur6FbpHT/xZSWNg== 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=ltF9uTLyurlLxk/wr/RfDjvUK/5Qter81QMsfjKp15I=; b=VFeWVKj5746KGTOuxg39ByYOG0toPQZXOzt0DDzYPh4oECePTy6fwBFkzQ+skxNzXkJKHDxGLVdTfcVOOL6sRCkmxq5l4B3ZYIhim4tUYFJ6QaiDeOu37cuNpV6CqSlLy+cHFt8GkfouGGWetTFsL3gDiPIPY0ax0FrnKw+JJWvomH6/jXNDTWQNSP0X7u4JXr+ZtF5Kkl84BnEUg03VwNNnteRZVsT1R+0yQsImVVTzKp3W4zccnGk3wlqs7h9b9DoasxeNaQw+IVXuJZmAC5xSIEzGf60kYYXBHOggGG1WFG9R86TFPV7z9dZ+f7j6wMAWrg2Bg/FeHhCq/FR8Pw== 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 SEZPR04MB6948.apcprd04.prod.outlook.com (2603:1096:101:e1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.10; Tue, 13 Dec 2022 02:37:12 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de%7]) with mapi id 15.20.5924.009; Tue, 13 Dec 2022 02:37:12 +0000 From: "Yuezhang.Mo@sony.com" To: "sj1557.seo@samsung.com" , "linkinjeon@kernel.org" CC: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 7/7] exfat: reuse exfat_find_location() to simplify exfat_get_dentry_set() Thread-Topic: [PATCH v2 7/7] exfat: reuse exfat_find_location() to simplify exfat_get_dentry_set() Thread-Index: AdkOmtAgzNiu6amqRB+LFDMxgmm87w== Date: Tue, 13 Dec 2022 02:37:12 +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_|SEZPR04MB6948:EE_ x-ms-office365-filtering-correlation-id: 427fdb53-7c89-479f-da5f-08dadcb2f096 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xeG+1cplfLPI9/tNIYu9q/jV897rfBboPfcEDlkImtlfjC+yQ0LsdBgKiadY038yshp2WTzSnVMbqfMr2eGb65DpswipzTL1lYUcpuAJFZO/JIiXZofQ3FRzoGuD57H7FSXUehjg8f1pWukQDvy34DVZJvUyepP7dGcNEPype7EMsncJ8bm61W5Er6VdR/+JNDxfSYhh2BP9ZQaHQdqQlZWWQO8a+JT8U3d7O7I7n8I5hy2JWlpYNNc/i1LLM5QKp6wD05y0xW3tMZI/skMf0MRtWjIOc7+jC4hAvCb4fw3cv6Mb/XwI+PAoA3LWvy09d92GKnEWahKg/JcQjxQtHWa9PxQGzc8tw5KqrhF4oBIL3u3aBw3Hkw+xqLbkxYNmsgQ1UePRHGhmXQSxtv9ldUDYU+YjZgqSM3JGK6FxpwiqjJFqa24HJ+rWIgHb5BayJdC+q4csmvFnIIO5jRjYkFivoqw2IYKMdo2j7HHloSia005i1KFpBvtHUGlAry6wbE2upolBcq22aSUd65PeepFuDs1OjDQK6O744BwJo0GBBybAZzgKSJPMab1l2B+nHUeMyT+2exT5HGwOTubeub8O6awAWb+SK2Bs4P3W39Iz/yMKXJH85BxtG6F5RCjX0DB0HH/t9oSPGAU/MvAdYsuj2UxmFeFdbUG9S1sBDlHbCZILtTNNkzoPXZCRfnleD14VnrN3pdLB8yntoQ3u8w== 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)(376002)(136003)(366004)(346002)(396003)(451199015)(86362001)(82960400001)(38070700005)(2906002)(8936002)(4326008)(8676002)(66946007)(66476007)(66446008)(64756008)(66556008)(5660300002)(122000001)(38100700002)(33656002)(83380400001)(478600001)(110136005)(316002)(54906003)(71200400001)(76116006)(55016003)(52536014)(41300700001)(6506007)(7696005)(26005)(186003)(9686003)(107886003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?VzI0AkcNSZDJKDLRy5DqzeQOLT3R?= =?utf-8?q?UODrwu//63cqh+WeV5deJaHmU4DeMtQG0GXnf4JZTZuF+NDHsVOeGnbkHrqORHHCM?= =?utf-8?q?ByypcKnpYE7BHqITlSpVCvfG7dRw/0Xq6Bx+/bTc9CB+/zK35yr4jc7ZFTDF5HUyt?= =?utf-8?q?QM4VFMJjBEFfuwv2xOefMY4AdWUFFkVieaWE/c+X1IZdh5XJHo9wYi6TPHSVSEumH?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f-8?q?iVGdCvgpP5IC/TktVbKY00l3ROiYR5eXvzFvfeIvFBxkk610fWBSarVyoHIh36ks1?= =?utf-8?q?YdmgushV4zyayWeaol5Phr7JBWWR8OSilrl9ubyxa2DgdfxbYMsd/+yyg9gv2smk5?= =?utf-8?q?ARmG/mZ9qfwOFXlAYdT8XBvPk/pohP7UnsaQyQDVDAar6i1QHEWehEToctIlEt4ri?= =?utf-8?q?id3rUMCDf8ALNd/8VDXggHOZ1QmR6wx4Q00NcmqEeX9o+KcbcwR3Z62f2F2DGEcMe?= =?utf-8?q?CHZKxT1xXtT9As3rpUQfYBFwsdNbAATBiomd2QWBmSYYBoD8YQFK1IQvpkENsWf/h?= =?utf-8?q?gmhdLOr3T7+Vt+gFsT61eXe6INWxyD+mELmkCWwqHaaJmsrygw/4Leig5mmiep+S8?= =?utf-8?q?XAFJ2mK+8Vs4Cuz8oTDfbTDodofKByA5ob2mzpEzbQWaBIDGfJYPxPFh5CQA1xhQJ?= =?utf-8?q?XqsEp4NY7e8L?= MIME-Version: 1.0 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: 427fdb53-7c89-479f-da5f-08dadcb2f096 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Dec 2022 02:37:12.4897 (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: ZQVunxTc0T/emDD56OvA1A6H2TGpey9TBd1j1lucr31AmiD7Yf513JMvm1g/PMtkiMV7cPG6uik1Kd2GErJrVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR04MB6948 X-Proofpoint-GUID: -hwfYQiqcOJKK0uDBA7JtewPG_HJGGiG X-Proofpoint-ORIG-GUID: -hwfYQiqcOJKK0uDBA7JtewPG_HJGGiG X-Sony-Outbound-GUID: -hwfYQiqcOJKK0uDBA7JtewPG_HJGGiG 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-12_02,2022-12-12_02,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?1752065404277863513?= X-GMAIL-MSGID: =?utf-8?q?1752065404277863513?= 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(-) -- 2.25.1 diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 8121a7e073bc..1dfa67f307f1 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)) { + unsigned 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))