From: Chandan Babu R <chandan.babu@oracle.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org, david@fromorbit.com
Subject: Re: [PATCH V4 11/16] xfs: Introduce macros to represent new maximum extent counts for data/attr forks
Date: Wed, 05 Jan 2022 19:16:53 +0530 [thread overview]
Message-ID: <87v8yy8fci.fsf@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <20220105004205.GR31583@magnolia>
On 05 Jan 2022 at 06:12, Darrick J. Wong wrote:
> On Tue, Dec 14, 2021 at 02:15:14PM +0530, Chandan Babu R wrote:
>> This commit defines new macros to represent maximum extent counts allowed by
>> filesystems which have support for large per-inode extent counters.
>>
>> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
>> ---
>> fs/xfs/libxfs/xfs_bmap.c | 8 +++-----
>> fs/xfs/libxfs/xfs_bmap_btree.c | 2 +-
>> fs/xfs/libxfs/xfs_format.h | 8 +++++---
>> fs/xfs/libxfs/xfs_inode_buf.c | 3 ++-
>> fs/xfs/libxfs/xfs_inode_fork.c | 2 +-
>> fs/xfs/libxfs/xfs_inode_fork.h | 19 +++++++++++++++----
>> 6 files changed, 27 insertions(+), 15 deletions(-)
>>
>> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
>> index 4113622e9733..0ce58e4a9c44 100644
>> --- a/fs/xfs/libxfs/xfs_bmap.c
>> +++ b/fs/xfs/libxfs/xfs_bmap.c
>> @@ -61,10 +61,8 @@ xfs_bmap_compute_maxlevels(
>> int sz; /* root block size */
>>
>> /*
>> - * The maximum number of extents in a file, hence the maximum number of
>> - * leaf entries, is controlled by the size of the on-disk extent count,
>> - * either a signed 32-bit number for the data fork, or a signed 16-bit
>> - * number for the attr fork.
>> + * The maximum number of extents in a fork, hence the maximum number of
>> + * leaf entries, is controlled by the size of the on-disk extent count.
>> *
>> * Note that we can no longer assume that if we are in ATTR1 that the
>> * fork offset of all the inodes will be
>> @@ -74,7 +72,7 @@ xfs_bmap_compute_maxlevels(
>> * ATTR2 we have to assume the worst case scenario of a minimum size
>> * available.
>> */
>> - maxleafents = xfs_iext_max_nextents(whichfork);
>> + maxleafents = xfs_iext_max_nextents(xfs_has_nrext64(mp), whichfork);
>> if (whichfork == XFS_DATA_FORK)
>> sz = XFS_BMDR_SPACE_CALC(MINDBTPTRS);
>> else
>> diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
>> index 453309fc85f2..e8d21d69b9ff 100644
>> --- a/fs/xfs/libxfs/xfs_bmap_btree.c
>> +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
>> @@ -611,7 +611,7 @@ xfs_bmbt_maxlevels_ondisk(void)
>> minrecs[1] = xfs_bmbt_block_maxrecs(blocklen, false) / 2;
>>
>> /* One extra level for the inode root. */
>> - return xfs_btree_compute_maxlevels(minrecs, MAXEXTNUM) + 1;
>> + return xfs_btree_compute_maxlevels(minrecs, XFS_MAX_EXTCNT_DATA_FORK) + 1;
>> }
>>
>> /*
>> diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
>> index 9934c320bf01..eff86f6c4c99 100644
>> --- a/fs/xfs/libxfs/xfs_format.h
>> +++ b/fs/xfs/libxfs/xfs_format.h
>> @@ -873,9 +873,11 @@ enum xfs_dinode_fmt {
>> /*
>> * Max values for extlen, extnum, aextnum.
>> */
>> -#define MAXEXTLEN ((xfs_extlen_t)0x001fffff) /* 21 bits */
>> -#define MAXEXTNUM ((xfs_extnum_t)0x7fffffff) /* signed int */
>> -#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */
>> +#define MAXEXTLEN ((xfs_extlen_t)0x1fffff) /* 21 bits */
>> +#define XFS_MAX_EXTCNT_DATA_FORK ((xfs_extnum_t)0xffffffffffff) /* Unsigned 48-bits */
>> +#define XFS_MAX_EXTCNT_ATTR_FORK ((xfs_aextnum_t)0xffffffff) /* Unsigned 32-bits */
>> +#define XFS_MAX_EXTCNT_DATA_FORK_OLD ((xfs_extnum_t)0x7fffffff) /* Signed 32-bits */
>> +#define XFS_MAX_EXTCNT_ATTR_FORK_OLD ((xfs_aextnum_t)0x7fff) /* Signed 16-bits */
>
> Could you change the #define value to a shift and subtract like you do
> for MAXEXTLEN^WXFS_MAX_BMBT_EXTLEN in patch 16?
>
> e.g.
>
> #define XFS_MAX_EXTCNT_DATA_FORK ((xfs_extnum_t)((1ULL << 48) - 1))
Sure. I will incorporate the above change.
>
> Also, you might want to document briefly in this header file why it is
> that the bmbt is limited to 2^48 extents even though the dinode fields
> are 64 bits wide and there can be up to 2^54 blocks mapped by a fork.
> ISTR the reason is to avoid having the bmbt cursor cache have to handle
> a 12-level btree or something, right?
>
> (Sorry, it's been a while...)
>
The discussion initially started with the observation that anything more than
2^43 extents on a 1k block sized filesystem can cause a BMBT tree's height to
become larger than XFS_BTREE_MAXLEVELS (i.e. 9). Increasing the value of
XFS_BTREE_MAXLEVELS was not an option since that would cause the following
sequence of events,
1. An increase in the rmapbt's maximum height (on filesystems which have both
reflink and rmap features enabled).
2. An increase in transaction reservation values.
However this is no longer an issue since the btree cursor now contains a
variable length array and XFS_BTREE_MAXLEVELS is now removed.
2^48 as the maximum extent count was arrived at based on the following logic,
2^63 (max file size) / 64k (max block size) = 2^47
i.e. 2^47 can be a valid upper bound for all block sizes.
Rounding up 47 to the nearest multiple of bits-per-byte results in 48. Hence
2^48 was chosen as the maximum data fork extent count.
I will include the above description in the next version of the patchset.
>>
>> /*
>> * Inode minimum and maximum sizes.
>> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
>> index 860d32816909..34f360a38603 100644
>> --- a/fs/xfs/libxfs/xfs_inode_buf.c
>> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
>> @@ -361,7 +361,8 @@ xfs_dinode_verify_fork(
>> return __this_address;
>> break;
>> case XFS_DINODE_FMT_BTREE:
>> - max_extents = xfs_iext_max_nextents(whichfork);
>> + max_extents = xfs_iext_max_nextents(xfs_dinode_has_nrext64(dip),
>> + whichfork);
>> if (di_nextents > max_extents)
>> return __this_address;
>> break;
>> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
>> index ce690abe5dce..a3a3b54f9c55 100644
>> --- a/fs/xfs/libxfs/xfs_inode_fork.c
>> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
>> @@ -746,7 +746,7 @@ xfs_iext_count_may_overflow(
>> if (whichfork == XFS_COW_FORK)
>> return 0;
>>
>> - max_exts = xfs_iext_max_nextents(whichfork);
>> + max_exts = xfs_iext_max_nextents(xfs_inode_has_nrext64(ip), whichfork);
>>
>> if (XFS_TEST_ERROR(false, ip->i_mount, XFS_ERRTAG_REDUCE_MAX_IEXTENTS))
>> max_exts = 10;
>> diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
>> index 4a8b77d425df..0cfc351648f9 100644
>> --- a/fs/xfs/libxfs/xfs_inode_fork.h
>> +++ b/fs/xfs/libxfs/xfs_inode_fork.h
>> @@ -133,12 +133,23 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp)
>> return ifp->if_format;
>> }
>>
>> -static inline xfs_extnum_t xfs_iext_max_nextents(int whichfork)
>> +static inline xfs_extnum_t xfs_iext_max_nextents(bool has_big_extcnt,
>
> has_nrext64, to be consistent with most everywhere else?
>
You are right. I will fix this.
> --D
>
>> + int whichfork)
>> {
>> - if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK)
>> - return MAXEXTNUM;
>> + switch (whichfork) {
>> + case XFS_DATA_FORK:
>> + case XFS_COW_FORK:
>> + return has_big_extcnt ? XFS_MAX_EXTCNT_DATA_FORK
>> + : XFS_MAX_EXTCNT_DATA_FORK_OLD;
>> +
>> + case XFS_ATTR_FORK:
>> + return has_big_extcnt ? XFS_MAX_EXTCNT_ATTR_FORK
>> + : XFS_MAX_EXTCNT_ATTR_FORK_OLD;
>>
>> - return MAXAEXTNUM;
>> + default:
>> + ASSERT(0);
>> + return 0;
>> + }
>> }
>>
>> static inline xfs_extnum_t
>> --
>> 2.30.2
>>
--
chandan
next prev parent reply other threads:[~2022-01-05 13:47 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-14 8:45 [PATCH V4 00/16] xfs: Extend per-inode extent counters Chandan Babu R
2021-12-14 8:45 ` [PATCH V4 01/16] xfs: Move extent count limits to xfs_format.h Chandan Babu R
2022-01-04 23:28 ` Darrick J. Wong
2021-12-14 8:45 ` [PATCH V4 02/16] xfs: Introduce xfs_iext_max_nextents() helper Chandan Babu R
2022-01-04 23:30 ` Darrick J. Wong
2021-12-14 8:45 ` [PATCH V4 03/16] xfs: Use xfs_extnum_t instead of basic data types Chandan Babu R
2021-12-14 8:45 ` [PATCH V4 04/16] xfs: Introduce xfs_dfork_nextents() helper Chandan Babu R
2022-01-04 23:48 ` Darrick J. Wong
2021-12-14 8:45 ` [PATCH V4 05/16] xfs: Use basic types to define xfs_log_dinode's di_nextents and di_anextents Chandan Babu R
2022-01-04 23:50 ` Darrick J. Wong
2022-01-05 13:43 ` Chandan Babu R
2021-12-14 8:45 ` [PATCH V4 06/16] xfs: Promote xfs_extnum_t and xfs_aextnum_t to 64 and 32-bits respectively Chandan Babu R
2021-12-14 14:54 ` kernel test robot
2021-12-14 15:05 ` kernel test robot
2021-12-14 15:15 ` kernel test robot
2021-12-15 9:19 ` Chandan Babu R
2022-01-04 23:54 ` Darrick J. Wong
2022-01-05 14:14 ` Chandan Babu R
2022-01-05 17:21 ` Darrick J. Wong
2022-01-06 7:03 ` Chandan Babu R
2022-01-06 20:31 ` Darrick J. Wong
2021-12-14 8:45 ` [PATCH V4 07/16] xfs: Introduce XFS_SB_FEAT_INCOMPAT_NREXT64 and associated per-fs feature bit Chandan Babu R
2022-01-05 0:03 ` Darrick J. Wong
2021-12-14 8:45 ` [PATCH V4 08/16] xfs: Introduce XFS_FSOP_GEOM_FLAGS_NREXT64 Chandan Babu R
2022-01-05 0:05 ` Darrick J. Wong
2022-01-05 13:44 ` Chandan Babu R
2022-01-05 17:22 ` Darrick J. Wong
2021-12-14 8:45 ` [PATCH V4 09/16] xfs: Introduce XFS_DIFLAG2_NREXT64 and associated helpers Chandan Babu R
2022-01-05 0:43 ` Darrick J. Wong
2021-12-14 8:45 ` [PATCH V4 10/16] xfs: Use xfs_rfsblock_t to count maximum blocks that can be used by BMBT Chandan Babu R
2021-12-14 18:15 ` kernel test robot
2021-12-14 8:45 ` [PATCH V4 11/16] xfs: Introduce macros to represent new maximum extent counts for data/attr forks Chandan Babu R
2022-01-05 0:42 ` Darrick J. Wong
2022-01-05 13:46 ` Chandan Babu R [this message]
2021-12-14 8:45 ` [PATCH V4 12/16] xfs: Introduce per-inode 64-bit extent counters Chandan Babu R
2022-01-05 1:04 ` Darrick J. Wong
2022-01-05 13:47 ` Chandan Babu R
2021-12-14 8:45 ` [PATCH V4 13/16] xfs: Conditionally upgrade existing inodes to use " Chandan Babu R
2022-01-05 0:18 ` Darrick J. Wong
2022-01-05 13:49 ` Chandan Babu R
2021-12-14 8:45 ` [PATCH V4 14/16] xfs: Enable bulkstat ioctl to support 64-bit per-inode " Chandan Babu R
2022-01-05 0:28 ` Darrick J. Wong
2022-01-05 13:50 ` Chandan Babu R
2021-12-14 8:45 ` [PATCH V4 15/16] xfs: Add XFS_SB_FEAT_INCOMPAT_NREXT64 to the list of supported flags Chandan Babu R
2022-01-05 0:47 ` Darrick J. Wong
2021-12-14 8:45 ` [PATCH V4 16/16] xfs: Define max extent length based on on-disk format definition Chandan Babu R
2022-01-05 0:47 ` Darrick J. Wong
2022-01-05 13:51 ` Chandan Babu R
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v8yy8fci.fsf@debian-BULLSEYE-live-builder-AMD64 \
--to=chandan.babu@oracle.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox