OSDN Git Service

xfs: Directory's data fork extent counter can never overflow
authorChandan Babu R <chandan.babu@oracle.com>
Tue, 29 Mar 2022 06:14:00 +0000 (06:14 +0000)
committerChandan Babu R <chandan.babu@oracle.com>
Wed, 13 Apr 2022 07:02:07 +0000 (07:02 +0000)
commit83a21c18441f75aec64548692b52d34582b98a6a
treed8163c99fb4ae8707be6cec9cf2211f00659a216
parent52a4a14842ef940e5bab1c949e5adc8f027327dc
xfs: Directory's data fork extent counter can never overflow

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.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
fs/xfs/libxfs/xfs_bmap.c
fs/xfs/libxfs/xfs_da_btree.h
fs/xfs/libxfs/xfs_da_format.h
fs/xfs/libxfs/xfs_dir2.c
fs/xfs/libxfs/xfs_format.h
fs/xfs/libxfs/xfs_inode_buf.c
fs/xfs/libxfs/xfs_inode_fork.h
fs/xfs/xfs_inode.c
fs/xfs/xfs_symlink.c