Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3021073lqp; Mon, 25 Mar 2024 17:20:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUMAoryrktKwsRXMYij4PlSlp9YE6qfa4v8esfzBQ82MrH5clSwVNj0Z6cUxOYH5J2/EgWtwL8R6PaGnxfnbM+P4ocesQdZUKd2BOiCNQ== X-Google-Smtp-Source: AGHT+IHSA5wP2oqPEA4B8uWseOD/KgNhLdx26Lyjtcx+Vxog1Y4cwZh3OdBoqCZ/mhX+SFejySst X-Received: by 2002:a05:6870:461b:b0:21e:e6d1:616c with SMTP id z27-20020a056870461b00b0021ee6d1616cmr1477742oao.31.1711412422738; Mon, 25 Mar 2024 17:20:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711412422; cv=pass; d=google.com; s=arc-20160816; b=pSnQf6TXYeva6H1OkH/ECoqZAuXSXDv9Ht+jI9yJlJKvsRTFUtMeeDOM4h+HykTo8E msc4/61zqU5qzlcxb2UKVp4qoeFuXOBbhO953hdx3MC4AfuE5QaXfw4MZGVYhmakow8B IRc+fGe0A7YFHoOqBT14lv7Xsj7BQ/w/2/J+05NQqjW4JIOmptKpvAodWe7mhtUKrtBM vRb7oYsiTWEBoC/fi1bha89Tc4R0QMMxc6XIpXzAGLiCvHZb5l55j7Pvv5tqr5h2JSNo CuNkITlmn7KQjo37UzRrF7N5G9McTT5uN2helJtJH0vm7iAOmF3V/fHJRyQIV+IP1jCG zWTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eTY9tWsMxZ2K3aQkEZJpivPTdRpw7VkLZH41dnj2hEQ=; fh=orJjJvyEwaV5M4bBWhICE74rxtqEfPg7DRA68dX8YsY=; b=ontGaZYpN9eC7FdVIQHhXJYEPWXP2xnRBCzCBfL+pbYQLDXuxlFGGurp/b2O2erjoW X7Wn0wmFKUf915J07IAF2Ghl/sxLLEUiZJTZrvBndH9/utToJzwALlfhFyO80yAXI4Ma gnh0qYDVdKlvjJsmi+sfLY0yVwhf0yNlquIjyzoc3Z4rq5EtMbUjvVLxEoVl9a+h2Dca Ayo6WhG0IL4Fr8WFODFjRgBtOFbUqK3f0L4qLQKbQtVfkySTpvpXlKBG8xacMFAaYGjt wE+k+WwtOtF1EHNOIjt5AsvX4wYUQXFwu6/3XSKwVafKzMzEg7L77ZKBE9qxJ3a+RPmI l2yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=SJro86af; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-117791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117791-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d33-20020a631d21000000b005dc85b86649si8354656pgd.686.2024.03.25.17.20.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 17:20:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=SJro86af; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-117791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117791-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F32C7B6430F for ; Mon, 25 Mar 2024 19:16:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE1411798C; Mon, 25 Mar 2024 19:16:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SJro86af" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 780AA9461; Mon, 25 Mar 2024 19:16:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711394166; cv=none; b=t/0bw7BV9+OCUnbj/GpKLu6Wa5dTXi5aGhFCiTn2Wsx8LUP4rKBBKo+qUocFDFfD5OlFgfxmeZwdTV1JbEmBB43jbU7PUKs5dL+18SW9nR+ekgijwVMM5p+yhLrKU3VWs4mW/LMJPjYkyJctETLJyWL9RkcL9x+jjf8vFRfuzhI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711394166; c=relaxed/simple; bh=l8mYrO7LA7D7hbrR36TT9zl2GYA+uskKnO6cZSSL8pE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RFMvZrTF9lKngr+2ia3HmwKXlBpdbE1eyf7sYvsWOg6wUSv6HHOLAKpAaCedCvJczwAkCCH56ARb1APeefAzyZJnlsbNQ7soxWJlYU+s7/v2A/xSIyTi3OJ75puVKwpmGaX7ihQfK0AH7E9Nc2vkr1c5ksLvr8wKsVkjacsHxMI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=SJro86af; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=eTY9tWsMxZ2K3aQkEZJpivPTdRpw7VkLZH41dnj2hEQ=; b=SJro86afQ01NTvzMF0k9zFPIAC /zDtpbnYDk4Wq8eoVWQaQ+LHAzjV04+AV+k/5bl0HtvL37X6+HOgXTl4f3F+dzJCDkKas5fqqVl0D OMtxfNkM+XfKVaSeT+mrUxjjNtMrfSrzvNvUaL0TuIhy2sO6l8OwwcR+LAt6SwywwbLxtL9ewACEx uBLMVJ3hO0GN0KjqBmNMJYXQcHAf2j39ql2S9LHSNM+DRKd1SLPHiQbXabKxZGdLoqIjqUn0YTvMn BySYDpMd0Wl43aynAvcRrRb6x4Rz7tskCiTSaueKWv95Ne79I399pH+ZOXra7Hi7/7U83/uekccK3 szsgYAQA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ropnb-0000000H9QS-2aiZ; Mon, 25 Mar 2024 19:15:59 +0000 Date: Mon, 25 Mar 2024 19:15:59 +0000 From: Matthew Wilcox To: "Pankaj Raghav (Samsung)" Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, gost.dev@samsung.com, chandan.babu@oracle.com, hare@suse.de, mcgrof@kernel.org, djwong@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, david@fromorbit.com, akpm@linux-foundation.org, Pankaj Raghav Subject: Re: [PATCH v3 10/11] xfs: make the calculation generic in xfs_sb_validate_fsb_count() Message-ID: References: <20240313170253.2324812-1-kernel@pankajraghav.com> <20240313170253.2324812-11-kernel@pankajraghav.com> Precedence: bulk X-Mailing-List: linux-kernel@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: <20240313170253.2324812-11-kernel@pankajraghav.com> On Wed, Mar 13, 2024 at 06:02:52PM +0100, Pankaj Raghav (Samsung) 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 > --- > 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 aabb25dc3efa..9cf800586da7 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); but ... you're still asserting that PAGE_SHIFT is larger than blocklog. Shouldn't you delete that assertion? > ASSERT(sbp->sb_blocklog >= BBSHIFT); > + uint64_t max_index; > + uint64_t max_bytes; > + > + 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; This kind of depends on the implementation details of the page cache. We have MAX_LFS_FILESIZE to abstract that; maybe that should be used here?