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 439BD187326; Tue, 7 May 2024 21:13:11 +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=1715116391; cv=none; b=Hnh21CmUJRzP+ZLw/p9xQ26jd30cbQ9d5z1LuuuplYDz8v7gwPUKtxaQEN2h9olDqmhxqCZoxPJ0hq1DDuFPw24QVfo2vrnjSZfBcoaYm6kmbNoIlRWKtsi6crnoRT6DPjBXw38gVjSskWYSFQvgsyH5XZZu5G7ZlsodUyInAWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715116391; c=relaxed/simple; bh=TrK/HQl6cRzmC2myzYV+mRcGrE69UCP6jKEvenXWgnw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=il8Z2ggSFXkQpvIAjBSuwQNUWdYNKmJ5pFHViRetlemQag7TFdClkSaA7qVGLeDHNssM5iPv4jt/fHKyvoC46gkuEWOAjIoIODH24G8bIEez8dW7MvatyE+nMuvGkjJhGUmja0/mCFec+yxJYfeHzFPjrW0vTV9UK7FB9qBKQ04= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C5MvJLhy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C5MvJLhy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16510C2BBFC; Tue, 7 May 2024 21:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715116391; bh=TrK/HQl6cRzmC2myzYV+mRcGrE69UCP6jKEvenXWgnw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C5MvJLhyKfV8u/qyAsvf2tSznMLAqpQHln891YiqiPBldbclCZO1XL1eXx2jpD0Rn Ji16VjrUx9yyjmFN25KCetsvxb+165k7+rG7VfxV+q6pdtfq0iBZM/XPIbWIjdVTyW vJfTwYXK1+BkPzSepiOF0qCAYfJanyStbFUteGbLBnezH6dj4CajsC0mv0gVnyGUqu y4t7AtOfWyAkMLv0Gc4K2dh5GBk5j97unEIGpMI8VR6IitKp1EAzH9I38e2UAZLY09 ctCXei+OdYArXRug+Usmau5Dk7tFwNl83w/d8VHO2QbZvU9xm1508Fru7LMxUup7fx 7xCre+ouriTYA== Date: Tue, 7 May 2024 14:13:10 -0700 From: "Darrick J. Wong" To: John Garry Cc: Luis Chamberlain , akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, hare@suse.de, ritesh.list@gmail.com, ziy@nvidia.com, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, gost.dev@samsung.com, p.raghav@samsung.com, kernel@pankajraghav.com Subject: Re: [PATCH v5 10/11] xfs: make the calculation generic in xfs_sb_validate_fsb_count() Message-ID: <20240507211310.GW360919@frogsfrogsfrogs> References: <20240503095353.3798063-1-mcgrof@kernel.org> <20240503095353.3798063-11-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, May 07, 2024 at 09:40:58AM +0100, John Garry wrote: > On 03/05/2024 10:53, Luis Chamberlain wrote: > > From: Pankaj Raghav > > > > Instead of assuming that PAGE_SHIFT is always higher than the blocklog, > > make the calculation generic so that page cache count can be calculated > > correctly for LBS. > > > > Signed-off-by: Pankaj Raghav > > Reviewed-by: Darrick J. Wong > > --- > > fs/xfs/xfs_mount.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c > > index df370eb5dc15..56d71282972a 100644 > > --- a/fs/xfs/xfs_mount.c > > +++ b/fs/xfs/xfs_mount.c > > @@ -133,9 +133,16 @@ xfs_sb_validate_fsb_count( > > { > > ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); > > ASSERT(sbp->sb_blocklog >= BBSHIFT); > > + uint64_t max_index; > > + uint64_t max_bytes; Extra nit: the ^ indentation of the names should have tabs, like the other xfs functions. --D > nit: any other XFS code which I have seen puts the declarations before any > ASSERT() calls > > > + > > + if (check_shl_overflow(nblocks, sbp->sb_blocklog, &max_bytes)) > > + return -EFBIG; > > /* Limited by ULONG_MAX of page cache index */ > > - if (nblocks >> (PAGE_SHIFT - sbp->sb_blocklog) > ULONG_MAX) > > + max_index = max_bytes >> PAGE_SHIFT; > > + > > + if (max_index > ULONG_MAX) > > return -EFBIG; > > return 0; > > } > >