From: Chandan Babu R <chandan.babu@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org, djwong@kernel.org
Subject: Re: [PATCH V3 05/12] xfs: Introduce xfs_dfork_nextents() helper
Date: Tue, 28 Sep 2021 15:16:59 +0530 [thread overview]
Message-ID: <87a6jx117w.fsf@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <20210927224649.GK1756565@dread.disaster.area>
On 28 Sep 2021 at 04:16, Dave Chinner wrote:
> On Thu, Sep 16, 2021 at 03:36:40PM +0530, Chandan Babu R wrote:
>> This commit replaces the macro XFS_DFORK_NEXTENTS() with the helper function
>> xfs_dfork_nextents(). As of this commit, xfs_dfork_nextents() returns the same
>> value as XFS_DFORK_NEXTENTS(). A future commit which extends inode's extent
>> counter fields will add more logic to this helper.
>>
>> This commit also replaces direct accesses to xfs_dinode->di_[a]nextents
>> with calls to xfs_dfork_nextents().
>>
>> No functional changes have been made.
>>
>> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
>> ---
>> fs/xfs/libxfs/xfs_format.h | 28 +++++++++++++++++++++----
>> fs/xfs/libxfs/xfs_inode_buf.c | 16 +++++++++-----
>> fs/xfs/libxfs/xfs_inode_fork.c | 10 +++++----
>> fs/xfs/scrub/inode.c | 18 +++++++++-------
>> fs/xfs/scrub/inode_repair.c | 38 +++++++++++++++++++++-------------
>> 5 files changed, 75 insertions(+), 35 deletions(-)
>>
>> diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
>> index ed8a5354bcbf..b4638052801f 100644
>> --- a/fs/xfs/libxfs/xfs_format.h
>> +++ b/fs/xfs/libxfs/xfs_format.h
>> @@ -930,10 +930,30 @@ enum xfs_dinode_fmt {
>> ((w) == XFS_DATA_FORK ? \
>> (dip)->di_format : \
>> (dip)->di_aformat)
>> -#define XFS_DFORK_NEXTENTS(dip,w) \
>> - ((w) == XFS_DATA_FORK ? \
>> - be32_to_cpu((dip)->di_nextents) : \
>> - be16_to_cpu((dip)->di_anextents))
>> +
>> +static inline xfs_extnum_t
>> +xfs_dfork_nextents(
>> + struct xfs_dinode *dip,
>> + int whichfork)
>> +{
>> + xfs_extnum_t nextents = 0;
>> +
>> + switch (whichfork) {
>> + case XFS_DATA_FORK:
>> + nextents = be32_to_cpu(dip->di_nextents);
>> + break;
>> +
>
> No need for whitespace line after the break, and this could just
> return the value directly.
>
Ok. I will fix this.
>> + case XFS_ATTR_FORK:
>> + nextents = be16_to_cpu(dip->di_anextents);
>> + break;
>> +
>> + default:
>> + ASSERT(0);
>> + break;
>> + }
>> +
>> + return nextents;
>> +}
>
> I think that all the conditional inode fork macros
> should be moved to libxfs/xfs_inode_fork.h as they are converted.
>
> These macros are not acutally part of the on-disk format definition
> (which is what xfs_format.h is supposed to contain) - it's code that
> parses the on-disk format and that is supposed to be in
> libxfs/xfs_inode_fork.[ch]....
>
> Next thing: the caller almost always knows what fork it wants
> the extents for - only 3 callers have a whichfork variable. So,
> perhaps:
>
> static inline xfs_extnum_t
> xfs_dfork_data_extents(
> struct xfs_dinode *dip)
> {
> return be32_to_cpu(dip->di_nextents);
> }
>
> static inline xfs_extnum_t
> xfs_dfork_attr_extents(
> struct xfs_dinode *dip)
> {
> return be16_to_cpu(dip->di_anextents);
> }
>
> static inline xfs_extnum_t
> xfs_dfork_extents(
> struct xfs_dinode *dip,
> int whichfork)
> {
> switch (whichfork) {
> case XFS_DATA_FORK:
> return xfs_dfork_data_extents(dip);
> case XFS_ATTR_FORK:
> return xfs_dfork_attr_extents(dip);
> default:
> ASSERT(0);
> break;
> }
> return 0;
> }
>
> So we don't have to rely on the compiler optimising away the switch
> statement correctly to produce optimal code.
>
I will fix this too.
>> --- a/fs/xfs/libxfs/xfs_inode_buf.c
>> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
>> @@ -342,9 +342,11 @@ xfs_dinode_verify_fork(
>> struct xfs_mount *mp,
>> int whichfork)
>> {
>> - xfs_extnum_t di_nextents = XFS_DFORK_NEXTENTS(dip, whichfork);
>> + xfs_extnum_t di_nextents;
>> xfs_extnum_t max_extents;
>>
>> + di_nextents = xfs_dfork_nextents(dip, whichfork);
>> +
>> switch (XFS_DFORK_FORMAT(dip, whichfork)) {
>> case XFS_DINODE_FMT_LOCAL:
>> /*
>> @@ -474,6 +476,8 @@ xfs_dinode_verify(
>> uint16_t flags;
>> uint64_t flags2;
>> uint64_t di_size;
>> + xfs_extnum_t nextents;
>> + xfs_rfsblock_t nblocks;
>
> That's a block number type, not a block count:
>
> typedef uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */
> ....
> typedef uint64_t xfs_filblks_t; /* number of blocks in a file */
>
> The latter is the appropriate type to use here.
>
> Oh, the struct xfs_inode and the struct xfs_log_dinode makes
> this same type mistake. Ok, that's a cleanup for another day....
>
I will add this cleanup to my todo list.
--
chandan
next prev parent reply other threads:[~2021-09-28 9:47 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 10:06 [PATCH V3 00/12] xfs: Extend per-inode extent counters Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 01/12] xfs: Move extent count limits to xfs_format.h Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 02/12] xfs: Introduce xfs_iext_max_nextents() helper Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 03/12] xfs: Rename MAXEXTNUM, MAXAEXTNUM to XFS_IFORK_EXTCNT_MAXS32, XFS_IFORK_EXTCNT_MAXS16 Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 04/12] xfs: Use xfs_extnum_t instead of basic data types Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 05/12] xfs: Introduce xfs_dfork_nextents() helper Chandan Babu R
2021-09-27 22:46 ` Dave Chinner
2021-09-28 9:46 ` Chandan Babu R [this message]
2021-09-16 10:06 ` [PATCH V3 06/12] xfs: xfs_dfork_nextents: Return extent count via an out argument Chandan Babu R
2021-09-30 1:19 ` Dave Chinner
2021-09-16 10:06 ` [PATCH V3 07/12] xfs: Rename inode's extent counter fields based on their width Chandan Babu R
2021-09-27 23:46 ` Dave Chinner
2021-09-28 4:04 ` Dave Chinner
2021-09-29 17:03 ` Chandan Babu R
2021-09-30 0:40 ` Dave Chinner
2021-09-30 4:31 ` Dave Chinner
2021-09-30 7:30 ` Chandan Babu R
2021-09-30 22:55 ` Dave Chinner
2021-10-07 10:52 ` Chandan Babu R
2021-10-10 21:49 ` Dave Chinner
2021-10-13 14:44 ` Chandan Babu R
2021-10-14 2:00 ` Dave Chinner
2021-10-14 10:07 ` Chandan Babu R
2021-10-21 10:27 ` Chandan Babu R
2021-09-28 9:47 ` Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 08/12] xfs: Promote xfs_extnum_t and xfs_aextnum_t to 64 and 32-bits respectively Chandan Babu R
2021-09-28 0:47 ` Dave Chinner
2021-09-28 9:47 ` Chandan Babu R
2021-09-28 23:08 ` Dave Chinner
2021-09-29 17:04 ` Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 09/12] xfs: Enable bulkstat ioctl to support 64-bit per-inode extent counters Chandan Babu R
2021-09-27 23:06 ` Dave Chinner
2021-09-28 9:49 ` Chandan Babu R
2021-09-28 23:39 ` Dave Chinner
2021-09-29 17:04 ` Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 10/12] xfs: Extend per-inode extent counter widths Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 11/12] xfs: Add XFS_SB_FEAT_INCOMPAT_NREXT64 to XFS_SB_FEAT_INCOMPAT_ALL Chandan Babu R
2021-09-16 10:06 ` [PATCH V3 12/12] xfs: Define max extent length based on on-disk format definition Chandan Babu R
2021-09-28 0:33 ` Dave Chinner
2021-09-28 10:07 ` Chandan Babu R
2021-09-18 0:03 ` [PATCH V3 00/12] xfs: Extend per-inode extent counters Darrick J. Wong
2021-09-18 3:36 ` [External] : " 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=87a6jx117w.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;
as well as URLs for NNTP newsgroup(s).