Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp210566rwi; Sun, 30 Oct 2022 23:31:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57zWmmTpkG89Rl4ZD+dpYAeAHTpdfL1b6ueA5dVz8Qq3blsUUsYjt0GzoxtMHZRcjeESQK X-Received: by 2002:a17:907:7213:b0:791:8aa5:5635 with SMTP id dr19-20020a170907721300b007918aa55635mr11470957ejc.348.1667197914004; Sun, 30 Oct 2022 23:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667197913; cv=none; d=google.com; s=arc-20160816; b=EKXAP86p6OQxbAm+jpAo/ixL0VoIqv5UThKq2Ghng9YbISrH9uJutI/ojN5/i+2GiB vd6cDi6YKCcnq6baPdZDOLRPFPuNGb+eEjYV2Ib5piw3baRssRc2/ygapob4A5PtpSY1 1gk+jfwQc/UUdmbBvawnw+9tjmMYDLoepPLBwOL+AlKsNmasWTkGsjBoFxaBZWnH51BR iajfBnj+Ie1uF2oU17kuvZtJUGH88rNG++vftYvwLKBBBulEEWiGwoqRk8um5YB9AiDt c+BucGP8HX46rN3baP3RliMHlqDXW6iHgoPDWOd9XA7SHO5dRbbxT4uO63IS77AHBxGc BPsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:content-language :thread-index:content-transfer-encoding:mime-version:message-id:date :subject:in-reply-to:cc:to:from:dkim-signature:dkim-filter; bh=zrcuyzlSiXoFgoqpUlNcrlJrfzSJzWIX6MW85Q5KClg=; b=vDbJGaNCcVadpu5Wjuc0Fg0b/hnh6SdmGJj0OXKus1tsEH9zBbJB4uM8LESWiD04sF v6iFp1cNBlXYJDbQHExG387yBcoBcfhVlq+I+V3zItvouwOHRUAAAgNE+jqT575IX3U/ Ed0mnvB4mJlHQCV7Y1ktltqZklBdpYcp+8E3xL1SusuQ8avz4tOtGTzb/sGmdOAtF745 pDGnmOJedTgNtsyExENPxPPT+Awvd/VzmmaFvnNMvBo18gSsX/2oj6bTOZNj2VoE8Obk wEAD+lJMicLlp2vCc0c5bxfYpU4170t8s+mzRbwTqt6TInFXYttV9He2mXrxxYS+tKLB PwhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=WTaZtki4; 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=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg39-20020a170907a42700b0078db3ae83d0si7467655ejc.3.2022.10.30.23.31.29; Sun, 30 Oct 2022 23:31:53 -0700 (PDT) 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=@samsung.com header.s=mail20170921 header.b=WTaZtki4; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbiJaGRc (ORCPT + 99 others); Mon, 31 Oct 2022 02:17:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbiJaGRa (ORCPT ); Mon, 31 Oct 2022 02:17:30 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5629B6406 for ; Sun, 30 Oct 2022 23:17:25 -0700 (PDT) Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20221031061721epoutp03bceb5b561b6e023cebcc72d34a743dfb~jEuBMyIKG0721107211epoutp03C for ; Mon, 31 Oct 2022 06:17:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20221031061721epoutp03bceb5b561b6e023cebcc72d34a743dfb~jEuBMyIKG0721107211epoutp03C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1667197041; bh=zrcuyzlSiXoFgoqpUlNcrlJrfzSJzWIX6MW85Q5KClg=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=WTaZtki4V96+De/36Iip/kAB42efae7LjF2Q9kzBD195rxMJYddsrpMMmP6MmrKnG mNMQ19nCIxMV130WXzbpJ5OCjqyrcaBcU2+anzI/YuJaDMz5ZKiTztv0x3dEK1egDY pYC0tbzph2XRBZahAgCIDVneBc2vRWHKY+VcIB4k= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20221031061721epcas1p4351b13048df38ba807e5620cd531f3f8~jEuAzq6L91417814178epcas1p4-; Mon, 31 Oct 2022 06:17:21 +0000 (GMT) Received: from epsmges1p2.samsung.com (unknown [182.195.36.225]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4N12xX5lyYz4x9QC; Mon, 31 Oct 2022 06:17:20 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 9D.82.51827.0786F536; Mon, 31 Oct 2022 15:17:20 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221031061720epcas1p1f95ab18b14a8e51bf064f0dcffbfea27~jEt-xLQ663011430114epcas1p1K; Mon, 31 Oct 2022 06:17:20 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221031061720epsmtrp26b5afaa63382726c70cd73a9fffc97c2~jEt-wcoFa0949709497epsmtrp2L; Mon, 31 Oct 2022 06:17:20 +0000 (GMT) X-AuditID: b6c32a36-72a32a800000ca73-1b-635f6870f4ea Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id B5.68.18644.F686F536; Mon, 31 Oct 2022 15:17:19 +0900 (KST) Received: from W10PB11329 (unknown [10.253.152.129]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221031061719epsmtip1580399a80943acad7222d74c8ec369ae~jEt-f5IUM1526715267epsmtip1W; Mon, 31 Oct 2022 06:17:19 +0000 (GMT) From: "Sungjong Seo" To: "'Namjae Jeon'" Cc: "'linux-fsdevel'" , "'linux-kernel'" , In-Reply-To: Subject: RE: [PATCH v1 2/2] exfat: hint the empty entry which at the end of cluster chain Date: Mon, 31 Oct 2022 15:17:19 +0900 Message-ID: <014c01d8ecf0$6e74bc80$4b5e3580$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQJbGVKlRTjGnAJr8oRiJ7knPGKj+wGohbknrRZoyDA= Content-Language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKJsWRmVeSWpSXmKPExsWy7bCmvm5BRnyywbdeFYuJ05YyW+zZe5LF 4vKuOWwWW/4dYXVg8di0qpPNo2/LKkaPz5vkApijGhhtEouSMzLLUhVS85LzUzLz0m2VQkPc dC2UFDLyi0tslaINDY30DA3M9YyMjPSMLWOtjEyVFPISc1NtlSp0oXqVFIqSC4BqcyuLgQbk pOpBxfWKU/NSHLLyS0FO1CtOzC0uzUvXS87PVVIoS8wpBRqhpJ/wjTFj3sIb7AVr5SpanzWz NzC2SXQxcnJICJhIzH90mamLkYtDSGAHo8TFa39YIZxPjBL7PxyHcj4zStx8+JgJpmXqvDY2 iMQuRonlqz8zQjgvGSW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oYuTiEBHYwSmxat5api5EDKCElcXCfJoQpLHH4cDFIuZDA c0aJ7e0sIDabgK7Ekxs/mUFKRAS0Je6/SAeZwizQwijRsOskE8TIdYwS3T2r2EEaOAViJZ7f 2MsGYgsLREqcXfabFcRmEVCVmPGxhRHE5hWwlFg+5TczhC0ocXLmE7BlzEALnt58CmXLS2x/ O4cZ4n4Fid2fjoLNERGwkli7YwETRI2IxOzONuYJjMKzkIyahWTULCSjZiFpWcDIsopRMrWg ODc9t9iwwCgvtVyvODG3uDQvXS85P3cTIzgytLR2MO5Z9UHvECMTB+MhRgkOZiUR3vqz0clC vCmJlVWpRfnxRaU5qcWHGKU5WJTEeS90nYwXEkhPLEnNTk0tSC2CyTJxcEo1MFkL2qt9ZDi6 zHhlzWaJgMb+87PfbepNVlm37kdR5sljXTq5Mme5cztuvXh6SnAFy8TyY47JATvsDjxmatAt 12i5ISJ03ndv79N6t19bEp+tN95zSubWLDvdGpFJxnOjKhZUxv9Z+2TWMUWxR2sfBdidNZeO v8y0Rb/CzrB20VF3nx+xa1dZyf/9NT2ubF59lvjmoNu3xW4aPHozwfbv8+Ptf4t+BVxT72aW y5rbsDHntLsH68nbmzfdNVgoLqLX6ahy96KhnRz/08QX2stZlja95G7suct6LsVw8t6rjctZ vf+rzGd4kO9YxPVpq3ahyjLrqNuu22S37PjyVsvyQ1a6MOeCDFGmIxuPnpdfPE+JpTgj0VCL uag4EQBvL6JN+wIAAA== X-CMS-MailID: 20221031061720epcas1p1f95ab18b14a8e51bf064f0dcffbfea27 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE X-ArchiveUser: EV CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20221019072854epcas1p2a2b272458803045b4dfa95b17fb4f547 References: X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS 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 Hi, Yuezhang Mo, > After traversing all directory entries, hint the empty directory > entry no matter whether or not there are enough empty directory > entries. > > After this commit, hint the empty directory entries like this: > > 1. Hint the deleted directory entries if enough; > 2. Hint the deleted and unused directory entries which at the > end of the cluster chain no matter whether enough or not(Add > by this commit); > 3. If no any empty directory entries, hint the empty directory > entries in the new cluster(Add by this commit). > > This avoids repeated traversal of directory entries, reduces CPU > usage, and improves the performance of creating files and > directories(especially on low-performance CPUs). > > Test create 5000 files in a class 4 SD card on imx6q-sabrelite > with: > > for ((i=0;i<5;i++)); do > sync > time (for ((j=1;j<=1000;j++)); do touch file$((i*1000+j)); done) > done > > The more files, the more performance improvements. > > Before After Improvement > 1~1000 25.360s 22.168s 14.40% > 1001~2000 38.242s 28.72ss 33.15% > 2001~3000 49.134s 35.037s 40.23% > 3001~4000 62.042s 41.624s 49.05% > 4001~5000 73.629s 46.772s 57.42% > > Signed-off-by: Yuezhang Mo > Reviewed-by: Andy Wu > Reviewed-by: Aoyama Wataru > --- > fs/exfat/dir.c | 26 ++++++++++++++++++++++---- > fs/exfat/namei.c | 22 ++++++++++++++-------- > 2 files changed, 36 insertions(+), 12 deletions(-) > > diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c > index a569f285f4fd..7600f3521246 100644 > --- a/fs/exfat/dir.c > +++ b/fs/exfat/dir.c > @@ -936,18 +936,25 @@ struct exfat_entry_set_cache > *exfat_get_dentry_set(struct super_block *sb, > > static inline void exfat_hint_empty_entry(struct exfat_inode_info *ei, > struct exfat_hint_femp *candi_empty, struct exfat_chain *clu, > - int dentry, int num_entries) > + int dentry, int num_entries, int entry_type) > { > if (ei->hint_femp.eidx == EXFAT_HINT_NONE || > ei->hint_femp.count < num_entries || > ei->hint_femp.eidx > dentry) { > + int total_entries = EXFAT_B_TO_DEN(i_size_read(&ei- > >vfs_inode)); > + > if (candi_empty->count == 0) { > candi_empty->cur = *clu; > candi_empty->eidx = dentry; > } > > - candi_empty->count++; > - if (candi_empty->count == num_entries) > + if (entry_type == TYPE_UNUSED) > + candi_empty->count += total_entries - dentry; This seems like a very good approach. Perhaps the key fix that improved performance seems to be the handling of cases where empty space was not found and ended with TYPE_UNUSED. However, there are concerns about trusting and using the number of free entries after TYPE_UNUSED calculated based on directory size. This is because, unlike exFAT Spec., in the real world, unexpected TYPE_UNUSED entries may exist. :( That's why exfat_search_empty_slot() checks if there is any valid entry after TYPE_UNUSED. In my experience, they can be caused by a wrong FS driver and H/W defects, and the probability of occurrence is not low. Therefore, when the lookup ends with TYPE_UNUSED, if there are no empty entries found yet, it would be better to set the last empty entry to hint_femp.eidx and set hint_femp.count to 0. If so, even if the lookup ends with TYPE_UNUSED, exfat_search_empty_slot() can start searching from the position of the last empty entry and check whether there are actually empty entries as many as the required num_entries as now. what do you think? > + else > + candi_empty->count++; > + > + if (candi_empty->count == num_entries || > + candi_empty->count + candi_empty->eidx == total_entries) > ei->hint_femp = *candi_empty; > } > } [snip] > -- > 2.25.1