From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: david@fromorbit.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 5/6] libxfs: clean up _dir2_data_freescan
Date: Fri, 4 Nov 2016 16:09:52 -0700 [thread overview]
Message-ID: <20161104230952.GH32036@birch.djwong.org> (raw)
In-Reply-To: <b7044544-ebd4-b62c-4873-bcd04b1241ab@sandeen.net>
On Fri, Nov 04, 2016 at 05:58:57PM -0500, Eric Sandeen wrote:
> On 11/4/16 1:32 PM, Darrick J. Wong wrote:
> > Refactor the implementations of xfs_dir2_data_freescan into a
> > routine that takes the raw directory block parameters and
> > a second function that figures out the raw parameters from the
> > directory inode. This enables us to use the exact same code
> > for both userspace and the kernel, since repair knows exactly
> > which directory block geometry parameters it needs.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
>
> seems fine tho I can't say I like the new function name; what
> does "_hdr" mean? They both take a *hdr ...
>
> maybe _xfs_dir2_data_freescan or xfs_dir2_data_freescan_int?
I'll change it to xfs_dir2_data_freescan_geo().
--D
>
> *shrug*
>
> -Eric
>
> > ---
> > fs/xfs/libxfs/xfs_dir2.h | 3 +++
> > fs/xfs/libxfs/xfs_dir2_data.c | 24 +++++++++++++++++-------
> > 2 files changed, 20 insertions(+), 7 deletions(-)
> >
> >
> > diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
> > index becc926..42456de 100644
> > --- a/fs/xfs/libxfs/xfs_dir2.h
> > +++ b/fs/xfs/libxfs/xfs_dir2.h
> > @@ -157,6 +157,9 @@ extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r);
> > extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
> > struct xfs_buf *bp);
> >
> > +extern void xfs_dir2_data_freescan_hdr(struct xfs_da_geometry *geo,
> > + const struct xfs_dir_ops *ops,
> > + struct xfs_dir2_data_hdr *hdr, int *loghead);
> > extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
> > struct xfs_dir2_data_hdr *hdr, int *loghead);
> > extern void xfs_dir2_data_log_entry(struct xfs_da_args *args,
> > diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
> > index 725fc78..1729eb2 100644
> > --- a/fs/xfs/libxfs/xfs_dir2_data.c
> > +++ b/fs/xfs/libxfs/xfs_dir2_data.c
> > @@ -505,8 +505,9 @@ xfs_dir2_data_freeremove(
> > * Given a data block, reconstruct its bestfree map.
> > */
> > void
> > -xfs_dir2_data_freescan(
> > - struct xfs_inode *dp,
> > +xfs_dir2_data_freescan_hdr(
> > + struct xfs_da_geometry *geo,
> > + const struct xfs_dir_ops *ops,
> > struct xfs_dir2_data_hdr *hdr,
> > int *loghead)
> > {
> > @@ -516,7 +517,6 @@ xfs_dir2_data_freescan(
> > struct xfs_dir2_data_free *bf;
> > char *endp; /* end of block's data */
> > char *p; /* current entry pointer */
> > - struct xfs_da_geometry *geo = dp->i_mount->m_dir_geo;
> >
> > ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
> > hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
> > @@ -526,13 +526,13 @@ xfs_dir2_data_freescan(
> > /*
> > * Start by clearing the table.
> > */
> > - bf = dp->d_ops->data_bestfree_p(hdr);
> > + bf = ops->data_bestfree_p(hdr);
> > memset(bf, 0, sizeof(*bf) * XFS_DIR2_DATA_FD_COUNT);
> > *loghead = 1;
> > /*
> > * Set up pointers.
> > */
> > - p = (char *)dp->d_ops->data_entry_p(hdr);
> > + p = (char *)ops->data_entry_p(hdr);
> > if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
> > hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
> > btp = xfs_dir2_block_tail_p(geo, hdr);
> > @@ -559,12 +559,22 @@ xfs_dir2_data_freescan(
> > else {
> > dep = (xfs_dir2_data_entry_t *)p;
> > ASSERT((char *)dep - (char *)hdr ==
> > - be16_to_cpu(*dp->d_ops->data_entry_tag_p(dep)));
> > - p += dp->d_ops->data_entsize(dep->namelen);
> > + be16_to_cpu(*ops->data_entry_tag_p(dep)));
> > + p += ops->data_entsize(dep->namelen);
> > }
> > }
> > }
> >
> > +void
> > +xfs_dir2_data_freescan(
> > + struct xfs_inode *dp,
> > + struct xfs_dir2_data_hdr *hdr,
> > + int *loghead)
> > +{
> > + return xfs_dir2_data_freescan_hdr(dp->i_mount->m_dir_geo, dp->d_ops,
> > + hdr, loghead);
> > +}
> > +
> > /*
> > * Initialize a data block at the given block number in the directory.
> > * Give back the buffer for the created block.
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-11-04 23:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-04 18:31 [PATCH 0/6] xfs: miscellaneous libxfs cleanups Darrick J. Wong
2016-11-04 18:31 ` [PATCH 1/6] libxfs: convert ushort to unsigned short Darrick J. Wong
2016-11-04 19:09 ` Eric Sandeen
2016-11-04 20:31 ` Darrick J. Wong
2016-11-04 18:31 ` [PATCH 2/6] libxfs: synchronize dinode_verify with userspace Darrick J. Wong
2016-11-04 19:07 ` Eric Sandeen
2016-11-04 21:03 ` Darrick J. Wong
2016-11-04 18:31 ` [PATCH 3/6] libxfs: fix whitespace problems Darrick J. Wong
2016-11-04 19:03 ` Eric Sandeen
2016-11-04 18:32 ` [PATCH 4/6] libxfs: fix xfs_attr_shortform_bytesfit declaration Darrick J. Wong
2016-11-04 19:11 ` Eric Sandeen
2016-11-04 18:32 ` [PATCH 5/6] libxfs: clean up _dir2_data_freescan Darrick J. Wong
2016-11-04 22:58 ` Eric Sandeen
2016-11-04 23:09 ` Darrick J. Wong [this message]
2016-11-04 23:20 ` Eric Sandeen
2016-11-05 0:00 ` Darrick J. Wong
2016-11-04 18:32 ` [PATCH 6/6] xfs: don't call xfs_sb_quota_from_disk twice Eric Sandeen
2016-11-04 19:12 ` Eric Sandeen
2016-11-06 22:22 ` Dave Chinner
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=20161104230952.GH32036@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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).