Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp45088lqg; Fri, 26 Apr 2024 08:20:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRZeE36ngsLN3neEbqzhJQ3+Ub2SbJmYtY6sUNq8NWPG6Ih6Ix3Cbbhm0tisLJDOFL61WvvBkEYyLgGFO6qrTCL/cgnKW1ljeYKyGloA== X-Google-Smtp-Source: AGHT+IFG2qhFmg4yKD7bhqOtXP0ZILr3sDCqdgDa0SVhnlvk6vWMlD2/3iWb2NKWTHOFqW8K06fm X-Received: by 2002:a05:6870:2a4a:b0:22e:c844:6baf with SMTP id jd10-20020a0568702a4a00b0022ec8446bafmr3124646oab.35.1714144848184; Fri, 26 Apr 2024 08:20:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714144848; cv=pass; d=google.com; s=arc-20160816; b=YdLmV9UAmJD/V++LhbFNpY0R27rV+tlBiQQjGV9OIUT5JaygrlrpSAXJND+BnvlXhn rS4tHUG1Nax2A3N1fJlu4Nv4mAP1BeS/n33SYi6IXKsDD7cZ7rivE85H5dpp8xHHq5ZZ ivc086Kz+g287ZBn/j/hHMZekg2UDvImRVyWYZr6C+WCSGzRlVp+jrKw9sZa6/0UR2Si iKnPFRKEo+GU/s8BrHrK5Y9fW3KmFJYIEodcIsSa4tNNPN/N366YAdOkBlG+zoiKzJSv 6tblcNO7eKWZXZkSXuXFnyVEW+THE2PCh6+IpSYSAmuIESPcAU45qvLQJsfLDcjVmJ6/ Metw== 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=PckJ3Kl5mhdRgaos8O3xu1mkq2Ha0TAVKZa5xIeclQ8=; fh=YDkxQ9bCqOMdOIokw+29HHCbazkFRSDHpMoph5ANiXg=; b=JEC1QjB3fk0o6jJRMtDMoJtx5KWf4pSTL6Vb6BEFYVpWVV6BP/d1iA9D+PBIY/p1O6 GNomMAKPqydhjhRq6SjOtANoWRTuSJl8uOYS6rp/1Q3YHT/ZsW9lOtzZbWv68Z9I2Z83 m4dnAdTFyV0OhF5tUjJ8n/U4Q36m30iyTedt44M92DY/qjSuFvaKkd32PWchRrHsZ/3l qPPDc20K0n87tE+Z9TLmCY0u6BMHmGG9udG/rs8E0cv5I6tgp/xey91BWsCa9FcRyrwt I1wWYR7mBI8rz/wlGB02JVdHAGJLYFkZ2VFvMAg4zKRYae+xQKMVuU2kzyZ3Qkpkvlde F8eA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QWzOlfNd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-160264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id hg23-20020a05622a611700b004374db6f999si19891948qtb.146.2024.04.26.08.20.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:20:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QWzOlfNd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-160264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 820531C21299 for ; Fri, 26 Apr 2024 15:20:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E190B1514CC; Fri, 26 Apr 2024 15:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QWzOlfNd" 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 0FDFD14884A; Fri, 26 Apr 2024 15:16:19 +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=1714144580; cv=none; b=pfLRZMG5ygTafu66dsTK/fmSCk+RJivU10Qkh99PilcGn6TLnkg2pub5MXeexTppZvyIg9Gh/HBtaGjy3BHMSLdlTkspA9bjIKuVv4x6A+3sHg4c3E0Y8FT1fr3sGyDy+BbbaDULllV/GQsKtajGDlpRlZ5pEZgXADhD/oT9guM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714144580; c=relaxed/simple; bh=6O55S30yhSxrufIxUQivUWS2HXmNr/eDu8y7coHNiko=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RbELHZRXenY9PBP8AQIjcncyx8aFLzwzOTO+Qbgu99Y9wt4SUiLASgJefWkpMHL2P+ayEJmuKMxqIWG0PtgaM/QQ+JZumnn3qWGtmkK2aRD2IxQaNGZiYdYUMKcR6DRo4ovvnG0KglNxDXfSBUGlkWqtXWQbHJ9+3GafSE3Aju8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QWzOlfNd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9827EC113CD; Fri, 26 Apr 2024 15:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714144579; bh=6O55S30yhSxrufIxUQivUWS2HXmNr/eDu8y7coHNiko=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QWzOlfNdDph2jErkCnqNMCbQeWTzFhb2h4H1oYGTesbJPcQh8LSQpUKKE205Jcb/h iq08eAB/2LjOYi2aO0WdTHjGqGFGM2fT+AxUqZrrA1/Vx284yxMk8O10R7990N1yzQ 0FmNOa1nA8H9RIGLGZPaz2CN9KCdUrkbPyhcVeLPKAPFbQjTxZ657KjXyJyQ+4QFeF 4BtJLDH5OkHBwrIBK9i1oOL+PzxwBiYHrvtScoa+yX4GSem3ha0AOTwy7AdnpWsnva aWlMqV6Cqmo5+cZplCJBxOCI01Vtn5pJvQFi92otmTH7uKBSbDSyh1lINOGayFfOIy UYRlMRIC/uXLA== Date: Fri, 26 Apr 2024 08:16:19 -0700 From: "Darrick J. Wong" To: "Pankaj Raghav (Samsung)" Cc: willy@infradead.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: Re: [PATCH v4 10/11] xfs: make the calculation generic in xfs_sb_validate_fsb_count() Message-ID: <20240426151619.GF360919@frogsfrogsfrogs> References: <20240425113746.335530-1-kernel@pankajraghav.com> <20240425113746.335530-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: <20240425113746.335530-11-kernel@pankajraghav.com> On Thu, Apr 25, 2024 at 01:37:45PM +0200, 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 Looks ok, Reviewed-by: Darrick J. Wong --D > --- > 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; > + > + 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; > } > -- > 2.34.1 > >