Re: [PATCH V9.1] xfs: Enable bulkstat ioctl to support 64-bit per-inode extent counters

Chandan Babu R
2022-04-13T07:48:28Z

On 13 Apr 2022 at 08:27, Darrick J. Wong wrote:
> On Sat, Apr 09, 2022 at 07:27:09PM +0530, Chandan Babu R wrote:
>> The following changes are made to enable userspace to obtain 64-bit extent
>> counters,
>> 1. Carve out a new 64-bit field xfs_bulkstat->bs_extents64 from
>> xfs_bulkstat->bs_pad[] to hold 64-bit extent counter.
>> 2. Define the new flag XFS_BULK_IREQ_BULKSTAT for userspace to indicate that
>> it is capable of receiving 64-bit extent counters.
>>
>> Reviewed-by: Dave Chinner <dchinner@redhat.com>
>> Suggested-by: Darrick J. Wong <djwong@kernel.org>
>> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
>> ---
>> fs/xfs/libxfs/xfs_fs.h | 20 ++++++++++++++++----
>> fs/xfs/xfs_ioctl.c | 3 +++
>> fs/xfs/xfs_itable.c | 9 ++++++++-
>> fs/xfs/xfs_itable.h | 3 +++
>> 4 files changed, 30 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
>> index 1f7238db35cc..2a42bfb85c3b 100644
>> --- a/fs/xfs/libxfs/xfs_fs.h
>> +++ b/fs/xfs/libxfs/xfs_fs.h
>> @@ -378,7 +378,7 @@ struct xfs_bulkstat {
>> uint32_t bs_extsize_blks; /* extent size hint, blocks */
>>
>> uint32_t bs_nlink; /* number of links */
>> - uint32_t bs_extents; /* number of extents */
>> + uint32_t bs_extents; /* 32-bit data fork extent counter */
>> uint32_t bs_aextents; /* attribute number of extents */
>> uint16_t bs_version; /* structure version */
>> uint16_t bs_forkoff; /* inode fork offset in bytes */
>> @@ -387,8 +387,9 @@ struct xfs_bulkstat {
>> uint16_t bs_checked; /* checked inode metadata */
>> uint16_t bs_mode; /* type and mode */
>> uint16_t bs_pad2; /* zeroed */
>> + uint64_t bs_extents64; /* 64-bit data fork extent counter */
>>
>> - uint64_t bs_pad[7]; /* zeroed */
>> + uint64_t bs_pad[6]; /* zeroed */
>> };
>>
>> #define XFS_BULKSTAT_VERSION_V1 (1)
>> @@ -469,8 +470,19 @@ struct xfs_bulk_ireq {
>> */
>> #define XFS_BULK_IREQ_SPECIAL (1 << 1)
>>
>> -#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \
>> - XFS_BULK_IREQ_SPECIAL)
>> +/*
>> + * Return data fork extent count via xfs_bulkstat->bs_extents64 field and assign
>> + * 0 to xfs_bulkstat->bs_extents when the flag is set. Otherwise, use
>> + * xfs_bulkstat->bs_extents for returning data fork extent count and set
>> + * xfs_bulkstat->bs_extents64 to 0. In the second case, return -EOVERFLOW and
>> + * assign 0 to xfs_bulkstat->bs_extents if data fork extent count is larger than
>> + * XFS_MAX_EXTCNT_DATA_FORK_OLD.
>> + */
>> +#define XFS_BULK_IREQ_NREXT64 (1 << 2)
>
> This /probably/ ought to be (1U << 2) but ... fmeh, I don't have gcc 5
> and don't care to install it, so because the logic looks ok to me:
>

I have changed XFS_BULK_IREQ_* flags to have unsigned values.

So with this patchset, XFS_IWALK_*, XFS_BULK_IREQ_* and XFS_IBULK_* flags will
have unsigned values.

I will execute fstests before sending a pull request.

>
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
>

Thanks to Dave and you for taking time to review various versions of this
patchset.

--
chandan