linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: linux-xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH 0/3] xfs: reduce boilerplate around xfs_btree_init_block
Date: Thu, 22 Dec 2016 11:41:55 -0600	[thread overview]
Message-ID: <670e1f09-754d-4171-0a73-f918956eba2d@redhat.com> (raw)

We have this pattern all over the kernel & userspace:

                if (xfs_sb_version_hascrc(&mp->m_sb))
                        xfs_btree_init_block(mp, bp, XFS_ABTB_CRC_MAGIC, 0, 1,
                                                agno, XFS_BTREE_CRC_BLOCKS);
                else
                        xfs_btree_init_block(mp, bp, XFS_ABTB_MAGIC, 0, 1,
                                                agno, 0);

The last flag (XFS_BTREE_CRC_BLOCKS) can be gleaned from
the features on the superblock via mp just as the if/else does,
so no need to pass that in from the caller.  That's patch 1.

Then the difference is simply CRC vs not-CRC magic.  This can also
be determined inside the called function by passing in a btree number,
and looking up the proper magic in the xfs_magics array.

patch2 makes xfs_btree_magic() more generic, taking a 
crc flag & btnum, instead of just a cursor.

patch3 then makes use of xfs_btree_magic in the block init routine
to determine the proper magic.

With those changes, the if/else can go away, and we can simply call:

xfs_btree_init_block(mp, bp, XFS_BTNUM_BNO, 0, 1, agno, 0);

and let the lower function sort out crc vs. no crc differences
by itself.

It's not a huge reduction in code, but it reduces a lot of the
boilerplate, particularly in growfs code.  This may also make it
slightly easier to factor the growfs tree init code into a loop
(not sure about that, yet) and/or to move mkfs & growfs tree init
code into a libxfs/ call.

 libxfs/xfs_bmap.c       |   19 ++++---------------
 libxfs/xfs_bmap_btree.c |   10 ++--------
 libxfs/xfs_btree.c      |   34 +++++++++++++++++++++-------------
 libxfs/xfs_btree.h      |    4 ++--
 libxfs/xfs_types.h      |    2 ++
 xfs_fsops.c             |   39 +++++++++------------------------------
 6 files changed, 40 insertions(+), 68 deletions(-)

-Eric

             reply	other threads:[~2016-12-22 17:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-22 17:41 Eric Sandeen [this message]
2016-12-22 17:44 ` [PATCH 1/3] xfs: glean crc status from mp not flags in xfs_btree_init_block_int Eric Sandeen
2017-01-03 18:28   ` Brian Foster
2016-12-22 17:47 ` [PATCH 2/3] xfs: make xfs_btree_magic more generic Eric Sandeen
2016-12-22 19:22   ` Darrick J. Wong
2016-12-22 19:43   ` [PATCH 2/3 V2] " Eric Sandeen
2017-01-03 18:28     ` Brian Foster
2017-01-03 18:34       ` Eric Sandeen
2016-12-22 17:51 ` [PATCH 3/3] xfs: remove boilerplate around xfs_btree_init_block Eric Sandeen
2016-12-22 19:44   ` [PATCH 3/3 V2] " Eric Sandeen
2017-01-03 18:28     ` Brian Foster
2017-01-16 23:13 ` [PATCH 0/3] xfs: reduce " Eric Sandeen
2017-01-17  1:14   ` Darrick J. Wong

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=670e1f09-754d-4171-0a73-f918956eba2d@redhat.com \
    --to=sandeen@redhat.com \
    --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).