All of lore.kernel.org
 help / color / mirror / Atom feed
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 V9.1] xfs: Directory's data fork extent counter can never overflow
Date: Tue, 12 Apr 2022 09:09:11 +0530	[thread overview]
Message-ID: <87o8170y3k.fsf@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <20220411220752.GA16824@magnolia>

On 12 Apr 2022 at 03:37, Darrick J. Wong wrote:
> On Sat, Apr 09, 2022 at 07:17:21PM +0530, Chandan Babu R wrote:
>> The maximum file size that can be represented by the data fork extent counter
>> in the worst case occurs when all extents are 1 block in length and each block
>> is 1KB in size.
>> 
>> With XFS_MAX_EXTCNT_DATA_FORK_SMALL representing maximum extent count and with
>> 1KB sized blocks, a file can reach upto,
>> (2^31) * 1KB = 2TB
>> 
>> This is much larger than the theoretical maximum size of a directory
>> i.e. XFS_DIR2_SPACE_SIZE * 3 = ~96GB.
>> 
>> Since a directory's inode can never overflow its data fork extent counter,
>> this commit removes all the overflow checks associated with
>> it. xfs_dinode_verify() now performs a rough check to verify if a diretory's
>> data fork is larger than 96GB.
>> 
>> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
>> ---
>>  fs/xfs/libxfs/xfs_bmap.c       | 20 -------------
>>  fs/xfs/libxfs/xfs_da_btree.h   |  1 +
>>  fs/xfs/libxfs/xfs_da_format.h  |  1 +
>>  fs/xfs/libxfs/xfs_dir2.c       |  2 ++
>>  fs/xfs/libxfs/xfs_format.h     | 13 ++++++++
>>  fs/xfs/libxfs/xfs_inode_buf.c  |  3 ++
>>  fs/xfs/libxfs/xfs_inode_fork.h | 13 --------
>>  fs/xfs/xfs_inode.c             | 55 ++--------------------------------
>>  fs/xfs/xfs_symlink.c           |  5 ----
>>  9 files changed, 22 insertions(+), 91 deletions(-)
>> 
>> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
>> index 1254d4d4821e..4fab0c92ab70 100644
>> --- a/fs/xfs/libxfs/xfs_bmap.c
>> +++ b/fs/xfs/libxfs/xfs_bmap.c
>> @@ -5147,26 +5147,6 @@ xfs_bmap_del_extent_real(
>>  		 * Deleting the middle of the extent.
>>  		 */
>>  
>> -		/*
>> -		 * For directories, -ENOSPC is returned since a directory entry
>> -		 * remove operation must not fail due to low extent count
>> -		 * availability. -ENOSPC will be handled by higher layers of XFS
>> -		 * by letting the corresponding empty Data/Free blocks to linger
>> -		 * until a future remove operation. Dabtree blocks would be
>> -		 * swapped with the last block in the leaf space and then the
>> -		 * new last block will be unmapped.
>> -		 *
>> -		 * The above logic also applies to the source directory entry of
>> -		 * a rename operation.
>> -		 */
>> -		error = xfs_iext_count_may_overflow(ip, whichfork, 1);
>> -		if (error) {
>> -			ASSERT(S_ISDIR(VFS_I(ip)->i_mode) &&
>> -				whichfork == XFS_DATA_FORK);
>> -			error = -ENOSPC;
>> -			goto done;
>> -		}
>> -
>>  		old = got;
>>  
>>  		got.br_blockcount = del->br_startoff - got.br_startoff;
>> diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h
>> index 0faf7d9ac241..7f08f6de48bf 100644
>> --- a/fs/xfs/libxfs/xfs_da_btree.h
>> +++ b/fs/xfs/libxfs/xfs_da_btree.h
>> @@ -30,6 +30,7 @@ struct xfs_da_geometry {
>>  	unsigned int	free_hdr_size;	/* dir2 free header size */
>>  	unsigned int	free_max_bests;	/* # of bests entries in dir2 free */
>>  	xfs_dablk_t	freeblk;	/* blockno of free data v2 */
>> +	xfs_extnum_t	max_extents;	/* Max. extents in corresponding fork */
>>  
>>  	xfs_dir2_data_aoff_t data_first_offset;
>>  	size_t		data_entry_offset;
>> diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
>> index 5a49caa5c9df..95354b7ab7f5 100644
>> --- a/fs/xfs/libxfs/xfs_da_format.h
>> +++ b/fs/xfs/libxfs/xfs_da_format.h
>> @@ -277,6 +277,7 @@ xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr)
>>   * Directory address space divided into sections,
>>   * spaces separated by 32GB.
>>   */
>> +#define	XFS_DIR2_MAX_SPACES	3
>>  #define	XFS_DIR2_SPACE_SIZE	(1ULL << (32 + XFS_DIR2_DATA_ALIGN_LOG))
>>  #define	XFS_DIR2_DATA_SPACE	0
>>  #define	XFS_DIR2_DATA_OFFSET	(XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE)
>> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
>> index 5f1e4799e8fa..52c764ecc015 100644
>> --- a/fs/xfs/libxfs/xfs_dir2.c
>> +++ b/fs/xfs/libxfs/xfs_dir2.c
>> @@ -150,6 +150,8 @@ xfs_da_mount(
>>  	dageo->freeblk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_FREE_OFFSET);
>>  	dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) /
>>  				(uint)sizeof(xfs_da_node_entry_t);
>> +	dageo->max_extents = (XFS_DIR2_MAX_SPACES * XFS_DIR2_SPACE_SIZE) >>
>> +					mp->m_sb.sb_blocklog;
>>  	dageo->magicpct = (dageo->blksize * 37) / 100;
>>  
>>  	/* set up attribute geometry - single fsb only */
>
> Shouldn't we set up mp->m_attr_geo.max_extents too?  Even if all we do
> is set it to XFS_MAX_EXTCNT_ATTR_FORK_{SMALL,LARGE}?  I get that nothing
> will use it anywhere, but we shouldn't leave uninitialized geometry
> structure variables around.
>

I had left it to be initialized to the value of zero as an indicator that the
field has an invalid value. But I think your suggestion is indeed correct
since we can assign the field with either XFS_MAX_EXTCNT_ATTR_FORK_SMALL or
XFS_MAX_EXTCNT_ATTR_FORK_LARGE. I will post a v9.2 patch soon.

-- 
chandan

  reply	other threads:[~2022-04-12  3:39 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  6:18 [PATCH V9 00/19] xfs: Extend per-inode extent counters Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 01/19] xfs: Move extent count limits to xfs_format.h Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 02/19] xfs: Define max extent length based on on-disk format definition Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 03/19] xfs: Introduce xfs_iext_max_nextents() helper Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 04/19] xfs: Use xfs_extnum_t instead of basic data types Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 05/19] xfs: Introduce xfs_dfork_nextents() helper Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 06/19] xfs: Use basic types to define xfs_log_dinode's di_nextents and di_anextents Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 07/19] xfs: Promote xfs_extnum_t and xfs_aextnum_t to 64 and 32-bits respectively Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 08/19] xfs: Introduce XFS_SB_FEAT_INCOMPAT_NREXT64 and associated per-fs feature bit Chandan Babu R
2022-04-07  0:50   ` Dave Chinner
2022-04-06  6:18 ` [PATCH V9 09/19] xfs: Introduce XFS_FSOP_GEOM_FLAGS_NREXT64 Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 10/19] xfs: Introduce XFS_DIFLAG2_NREXT64 and associated helpers Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 11/19] xfs: Use uint64_t to count maximum blocks that can be used by BMBT Chandan Babu R
2022-04-07  0:52   ` Dave Chinner
2022-04-06  6:18 ` [PATCH V9 12/19] xfs: Introduce macros to represent new maximum extent counts for data/attr forks Chandan Babu R
2022-04-07  1:05   ` Dave Chinner
2022-04-07  1:58     ` Darrick J. Wong
2022-04-07  2:44       ` Dave Chinner
2022-04-07  8:18         ` Chandan Babu R
2022-04-07  8:56           ` Dave Chinner
2022-04-07  8:18       ` Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 13/19] xfs: Replace numbered inode recovery error messages with descriptive ones Chandan Babu R
2022-04-07  1:50   ` Darrick J. Wong
2022-04-06  6:18 ` [PATCH V9 14/19] xfs: Introduce per-inode 64-bit extent counters Chandan Babu R
2022-04-06 19:03   ` kernel test robot
2022-04-07  1:07     ` Dave Chinner
2022-04-07  1:07       ` Dave Chinner
2022-04-07  8:18       ` Chandan Babu R
2022-04-07  8:18         ` Chandan Babu R
2022-04-06  6:18 ` [PATCH V9 15/19] xfs: Directory's data fork extent counter can never overflow Chandan Babu R
2022-04-07  1:13   ` Dave Chinner
2022-04-07  1:48     ` Darrick J. Wong
2022-04-07  8:19       ` Chandan Babu R
2022-04-09 13:47   ` [PATCH V9.1] " Chandan Babu R
2022-04-11  1:33     ` Dave Chinner
2022-04-11 22:07     ` Darrick J. Wong
2022-04-12  3:39       ` Chandan Babu R [this message]
2022-04-12 14:02   ` [PATCH V9.2] " Chandan Babu R
2022-04-12 17:04     ` Darrick J. Wong
2022-04-06  6:19 ` [PATCH V9 16/19] xfs: Conditionally upgrade existing inodes to use large extent counters Chandan Babu R
2022-04-07  1:22   ` Dave Chinner
2022-04-07  1:46     ` Darrick J. Wong
2022-04-07  8:19     ` Chandan Babu R
2022-04-07  1:46   ` Darrick J. Wong
2022-04-07  2:00     ` Darrick J. Wong
2022-04-07  8:19     ` Chandan Babu R
2022-04-09 13:52   ` [PATCH V9.1] " Chandan Babu R
2022-04-11  1:34     ` Dave Chinner
2022-04-06  6:19 ` [PATCH V9 17/19] xfs: Decouple XFS_IBULK flags from XFS_IWALK flags Chandan Babu R
2022-04-07  1:29   ` Darrick J. Wong
2022-04-06  6:19 ` [PATCH V9 18/19] xfs: Enable bulkstat ioctl to support 64-bit per-inode extent counters Chandan Babu R
2022-04-07  1:29   ` Darrick J. Wong
2022-04-07  1:42     ` Dave Chinner
2022-04-07  8:20     ` Chandan Babu R
2022-04-09 13:57   ` [PATCH V9.1] " Chandan Babu R
2022-04-11  2:56     ` Dave Chinner
2022-04-13  2:57     ` Darrick J. Wong
2022-04-13  7:48       ` Chandan Babu R
2022-04-06  6:19 ` [PATCH V9 19/19] xfs: Add XFS_SB_FEAT_INCOMPAT_NREXT64 to the list of supported flags Chandan Babu R
2022-04-07  1:23   ` Dave Chinner
2022-04-07  1:26   ` Darrick J. Wong
2022-04-09 13:23 ` [PATCH V9.1] xfs: Introduce macros to represent new maximum extent counts for data/attr forks 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=87o8170y3k.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.