linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] xfs: reduce boilerplate around xfs_btree_init_block
@ 2016-12-22 17:41 Eric Sandeen
  2016-12-22 17:44 ` [PATCH 1/3] xfs: glean crc status from mp not flags in xfs_btree_init_block_int Eric Sandeen
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Eric Sandeen @ 2016-12-22 17:41 UTC (permalink / raw)
  To: linux-xfs

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-01-17  1:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-22 17:41 [PATCH 0/3] xfs: reduce boilerplate around xfs_btree_init_block Eric Sandeen
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

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).