From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2198213B2BA; Tue, 27 Feb 2024 14:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709042603; cv=none; b=F4YwdAy7QPa6qh5WuCSXXRwk9qR/itoh7w1oLXTViSciqK8PjerXarZI/4q/Igvo+ffKGsPT4nWWJgh+yaYgOLr6nnYfig6tTaw88gyxzFayreo0g3teP1K6jPvnM80OsE77S7pOqrVTHfKWIWA51rIsyk07en9wvXe/RssyIag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709042603; c=relaxed/simple; bh=AQHiYjiz2dleTPEzxoPa0v/Obqw/eu0oNoNQIS05kNk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ViURR1TMrR4ZFfiau9o8RLlx4cHTH36Ue37duWvUz9dTw29kRtoOAGFz7FemUy/i4ulvjFgQCnRNOpJyDbosoPwi7pEB+5BQiN5paybQ2WNpgw1rj/llhUkpWAfp4WUxW9VyJuBjDJM7I59QVADDt7uFWAmyCX8ZpLjPIS3xxSs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OZgUj/Qu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="OZgUj/Qu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51AEDC433F1; Tue, 27 Feb 2024 14:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709042602; bh=AQHiYjiz2dleTPEzxoPa0v/Obqw/eu0oNoNQIS05kNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZgUj/Qut1S6yc4gev33j4bwnZ/Q5YmIXrzCkILTnTlmYQkjKLYF5FUraHhuj2AGK nDKnyLlueE+3ecYuIUAXVnzkYmv2ErfFK4Q32v0aBei7+t98HXhf1LILYzZ+Sm07Z1 k/vviPYAL8vCCb3QNo4uoAkLAwRGAeUbAYWr0acI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Konstantin Komarov , Sasha Levin Subject: [PATCH 5.15 053/245] fs/ntfs3: Improve ntfs_dir_count Date: Tue, 27 Feb 2024 14:24:01 +0100 Message-ID: <20240227131616.848980379@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131615.098467438@linuxfoundation.org> References: <20240227131615.098467438@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konstantin Komarov [ Upstream commit 6a799c928b78b14999b7705c4cca0f88e297fe96 ] Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/dir.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index c2fb76bb28f47..72cdfa8727d3c 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -515,11 +515,9 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs, struct INDEX_HDR *hdr; const struct ATTR_FILE_NAME *fname; u32 e_size, off, end; - u64 vbo = 0; size_t drs = 0, fles = 0, bit = 0; - loff_t i_size = ni->vfs_inode.i_size; struct indx_node *node = NULL; - u8 index_bits = ni->dir.index_bits; + size_t max_indx = ni->vfs_inode.i_size >> ni->dir.index_bits; if (is_empty) *is_empty = true; @@ -563,7 +561,7 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs, fles += 1; } - if (vbo >= i_size) + if (bit >= max_indx) goto out; err = indx_used_bit(&ni->dir, ni, &bit); @@ -573,8 +571,7 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs, if (bit == MINUS_ONE_T) goto out; - vbo = (u64)bit << index_bits; - if (vbo >= i_size) + if (bit >= max_indx) goto out; err = indx_read(&ni->dir, ni, bit << ni->dir.idx2vbn_bits, @@ -584,7 +581,6 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs, hdr = &node->index->ihdr; bit += 1; - vbo = (u64)bit << ni->dir.idx2vbn_bits; } out: -- 2.43.0