From nobody Fri Sep 12 00:17:40 2025 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 D6ADBC4167B for ; Wed, 6 Dec 2023 15:10:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442430AbjLFPK2 (ORCPT ); Wed, 6 Dec 2023 10:10:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442448AbjLFPKV (ORCPT ); Wed, 6 Dec 2023 10:10:21 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31BBADE; Wed, 6 Dec 2023 07:10:27 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id D92B11E1A; Wed, 6 Dec 2023 15:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875040; bh=/GAY4vh49Ey49PjOB0D7aW4BJClWKFEVXZZb9RVpvm8=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=bV1feHdOoc85vxuNTcRIuuIj4OKvvVliIheZoWfeIjMagZtKTIExoG1tZP5GKcmcC 2Xm3LxPkbcoWDpxWt3fxCzNeybO3lNj/Zk/uh1gmH2/1enCbGpFcHF7wyUjchAGCIv 2RCP2b2+LXWKnHQCqKpaT1lY7nUqnYMKO5UJM8XU= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:10:24 +0300 Message-ID: Date: Wed, 6 Dec 2023 18:10:24 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 03/16] fs/ntfs3: Improve ntfs_dir_count Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/dir.c | 10 +++------- =C2=A01 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index 22ede4da0450..726122ecd39b 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -515,11 +515,9 @@ static int ntfs_dir_count(struct inode *dir, bool=20 *is_empty, size_t *dirs, =C2=A0=C2=A0=C2=A0 =C2=A0struct INDEX_HDR *hdr; =C2=A0=C2=A0=C2=A0 =C2=A0const struct ATTR_FILE_NAME *fname; =C2=A0=C2=A0=C2=A0 =C2=A0u32 e_size, off, end; -=C2=A0=C2=A0 =C2=A0u64 vbo =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0size_t drs =3D 0, fles =3D 0, bit =3D 0; -=C2=A0=C2=A0 =C2=A0loff_t i_size =3D ni->vfs_inode.i_size; =C2=A0=C2=A0=C2=A0 =C2=A0struct indx_node *node =3D NULL; -=C2=A0=C2=A0 =C2=A0u8 index_bits =3D ni->dir.index_bits; +=C2=A0=C2=A0 =C2=A0size_t max_indx =3D ni->vfs_inode.i_size >> ni->dir.ind= ex_bits; =C2=A0=C2=A0=C2=A0 =C2=A0if (is_empty) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0*is_empty =3D true; @@ -563,7 +561,7 @@ static int ntfs_dir_count(struct inode *dir, bool=20 *is_empty, size_t *dirs, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0fles +=3D 1; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (vbo >=3D i_size) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (bit >=3D max_indx) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D indx_used_bit(&ni->dir= , ni, &bit); @@ -573,8 +571,7 @@ static int ntfs_dir_count(struct inode *dir, bool=20 *is_empty, size_t *dirs, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (bit =3D=3D MINUS_ONE_T) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0vbo =3D (u64)bit << index_bits; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (vbo >=3D i_size) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (bit >=3D max_indx) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D indx_read(&ni->dir, ni= , bit << ni->dir.idx2vbn_bits, @@ -584,7 +581,6 @@ static int ntfs_dir_count(struct inode *dir, bool=20 *is_empty, size_t *dirs, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0hdr =3D &node->index->ihdr; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0bit +=3D 1; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0vbo =3D (u64)bit << ni->dir.idx2vbn_= bits; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0out: --=20 2.34.1