Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1115778lqt; Fri, 7 Jun 2024 08:23:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdD5Xj4Z9CZ0EYbHHdRXsY1+RUknfzyOxlCenAulGJqndCBlYgWYUrZs+jEBfFzcifxjN8zr2jliVmBz3ia8C28/ZgNLEiPXeVKvZdjQ== X-Google-Smtp-Source: AGHT+IFLFiKkBvahSzCI3Yi3om+BNaJiNH4jgUqiD5p7uOy9Kkynb4eFtxxMvxxQtwzRHQ2BMjFb X-Received: by 2002:a05:6e02:1c45:b0:374:6379:b343 with SMTP id e9e14a558f8ab-3758030b78dmr35285905ab.6.1717773818784; Fri, 07 Jun 2024 08:23:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717773818; cv=pass; d=google.com; s=arc-20160816; b=Jc6c7Q6mOviY+4DBVn38itYsV8TAtL/eRHoLxVkLeaBRPR4k+rtCgFjjWtN+DiFeQw bV3G9b93DFYB4d7QxhPuiCoy9vM++Bpl1TsRJymVJZbPYgQa6YRxV3YvvCHr7sPH9UQA wPaIfVzY7MK//sHqnQNfli6ZXVN6q3cFkbqUp1vl4YkfRi/KYplO9Hboeolj8eXS77sw iiMceil+b0f2uQstsUJthJ7jyd9q6JtgtcDuLyt9+MdOsYLlH7eLnuNA3fMx6nGmH30l dTDWaTqRqN7++zY+kofAbkjAsgEQ2fU+J+8+B3M0hi3W2n75gk5kS96H49sFWgrgtqCZ zTNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Bne/CkGLFb5Q+0r/mTCjdzHVWDyDH0TqoTxmXgBXKCE=; fh=pqFiGWrwOnMOz7J5JEcls+uL5JrBxW7q4gBZg6HAuoA=; b=RWSqjzUzfY3DXBseLzVfrMhZ8983OO2DZVaup8Hln0UxBlerJdabP9/VAcRM5bUU1n WV9fvcDxdCdWCGtLRelDANgEU/VKagWuXwALzwyEiOzzIqzOrmb1fW4VapE2KhuvDyKM 58Ts3din6qT45EPLxLki8R+mBTqKgUXxF1yEaNrqe27EuHWTGbNz+kqEn6zZw30iwuxA UnvIumYaU98AJunjbmwFxCkXQp+e/zkCDj/IlSVVX5xv0sDzib5lVx8Ijh9mtr1bDqXz r+vTpZBU4nuI2ua3QvrNUze0xFQBePivIsYgz09bb2dZeFIm4Y4RuvozrDJzGW3B2/3P C7wg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b="Cn0j/AWN"; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-206353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206353-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2895a6b1si3154062a12.609.2024.06.07.08.23.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 08:23:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206353-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=@pankajraghav.com header.s=MBO0001 header.b="Cn0j/AWN"; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-206353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206353-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com 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 CF518B26B34 for ; Fri, 7 Jun 2024 15:07:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91BB419AD45; Fri, 7 Jun 2024 15:06:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b="Cn0j/AWN" Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) (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 BA9C6198E86; Fri, 7 Jun 2024 15:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.161 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717772786; cv=none; b=Bk35oMO9Hg3zig2DJNq8ILaGRQn3ukv7EIFbEd7q9NhprIB7n5oSZV5MBTQpNs47CTOZhuUiKg5VOEgYBcH+FYyazKVJojiC9AdE0cZCU/HB0KgAhCQRnBl45rkBYvLhImANVSfV9XOj0akQtL8cAW7E5yZM3LepIjdcO6HTmrw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717772786; c=relaxed/simple; bh=+6r70PXGOoDrgZczKyCNEqRz+H9Krx2IBf5jtzdMkms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZyBaINdgPiff2608z4qXZg82sgXlbnqWhFoLG390v63sGiQCk4l8mv28oWx4YLF8fBBMvYX1FbKWxea/Lj64zMkegsttTKoDwx2oYDN+sPVl++j+J+qo1ySNFPenqKNciA7MMqB9P1eaDY2NeC3vU22+TREE0rjrHxwSdVmzHXc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com; spf=pass smtp.mailfrom=pankajraghav.com; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b=Cn0j/AWN; arc=none smtp.client-ip=80.241.56.161 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pankajraghav.com Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4VwkrP1CCjz9snn; Fri, 7 Jun 2024 16:59:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1717772389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bne/CkGLFb5Q+0r/mTCjdzHVWDyDH0TqoTxmXgBXKCE=; b=Cn0j/AWNicr8OHAovh1eFeMf2drV755n5F+zvZ1MdbQyUkqzCsMz2XxYhmPOC2AHubjaPN By+3Lnr4JK0aS27yj94k9MEkCJckWgq9jK1c1j3LFluOxy7/JDiNmX3uKasP8JO2jy6GXs qtnId+YktikV8HX2Fv9n7TpvJhdGTgqufWtf8fk40FJTjnJd+iomWBoBupp3MQc3ELjc3X lWt6MxodQqcZvTxBpdTkn7wBci1296lYMYsDoQYaUOU31D2WNUvNG6Mk1PrmUiDTt3/QKy Q7qtduMYWr9zGNNdSdW+wsgGejLyBrAGbz1EjEttBWc9C32hcnrBwyRzNil4Ng== From: "Pankaj Raghav (Samsung)" To: david@fromorbit.com, djwong@kernel.org, chandan.babu@oracle.com, brauner@kernel.org, akpm@linux-foundation.org, willy@infradead.org Cc: mcgrof@kernel.org, linux-mm@kvack.org, hare@suse.de, linux-kernel@vger.kernel.org, yang@os.amperecomputing.com, Zi Yan , linux-xfs@vger.kernel.org, p.raghav@samsung.com, linux-fsdevel@vger.kernel.org, kernel@pankajraghav.com, hch@lst.de, gost.dev@samsung.com, cl@os.amperecomputing.com, john.g.garry@oracle.com Subject: [PATCH v7 10/11] xfs: make the calculation generic in xfs_sb_validate_fsb_count() Date: Fri, 7 Jun 2024 14:59:01 +0000 Message-ID: <20240607145902.1137853-11-kernel@pankajraghav.com> In-Reply-To: <20240607145902.1137853-1-kernel@pankajraghav.com> References: <20240607145902.1137853-1-kernel@pankajraghav.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4VwkrP1CCjz9snn 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. Reviewed-by: Darrick J. Wong Signed-off-by: Pankaj Raghav --- fs/xfs/xfs_mount.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 09eef1721ef4..46cb0384143b 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -132,11 +132,19 @@ xfs_sb_validate_fsb_count( xfs_sb_t *sbp, uint64_t nblocks) { + uint64_t max_index; + uint64_t max_bytes; + ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); ASSERT(sbp->sb_blocklog >= BBSHIFT); + 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.44.1