remove m_dirops
Hi all,
this series removes the indirect call to distinguish between the v4 and v5 formats for dir and attrs btree blocks, and for file type enabled vs not enabled formats. Indirect calls have always been rather expensive, and gotten even more so with the spectre workarounds.
This series removes almost 700 lines of code and shaves almost 6KB off the size of the xfs module.
PATCH 1/34 xfs: move incore structures out of xfs_da_format.h
Move the abstract in-memory version of various btree block headers out of xfs_da_format.h as they aren't on-disk formats.
--- fs/xfs/libxfs/xfs_attr_leaf.h | 23 ++++++++++++++ fs/xfs/libxfs/xfs_da_btree.h | 13 ++++++++ fs/xfs/libxfs/xfs_da_format.c | 1 + fs/xfs/libxfs/xfs_da_format.h | 57 ----------------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 ++ fs/xfs/libxfs/xfs_dir2_priv.h | 20 ++++++++++++ 6 files changed, 59 insertions(+), 57 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.h +23 -0
@@ -16,6 +16,29 @@ struct xfs_da_state_blk;struct xfs_inode ;struct xfs_trans ; +/* +* Incore version of the attribute leaf header. +*/ +struct xfs_attr3_icleaf_hdr { +uint32_t forw; +uint32_t back; +uint16_t magic; +uint16_t count; +uint16_t usedbytes; +/* +* Firstused is 32-bit here instead of 16-bit like the on-disk variant +* to support maximum fsb size of 64k without overflow issues throughout +* the attr code. Instead, the overflow condition is handled on +* conversion to/from disk. +*/ +uint32_t firstused; +__u8 holes; +struct { +uint16_t base; +uint16_t size; + } freemap[XFS_ATTR_LEAF_MAPSIZE ]; +}; +/* * Used to keep a list of "remote value" extents when unlinking an inode. */
fs/xfs/libxfs/xfs_da_btree.h +13 -0
@@ -124,6 +124,19 @@ typedef struct xfs_da_state {/* for dirv2 extrablk is data */ } xfs_da_state_t; +/* +* In-core version of the node header to abstract the differences in the v2 and +* v3 disk format of the headers. Callers need to convert to/from disk format as +* appropriate. +*/ +struct xfs_da3_icnode_hdr { +uint32_t forw; +uint32_t back; +uint16_t magic; +uint16_t count; +uint16_t level; +}; +/* * Utility macros to aid in logging changed structure fields. */
fs/xfs/libxfs/xfs_da_format.c +1 -0
@@ -13,6 +13,7 @@#include "xfs_mount.h" #include "xfs_inode.h" #include "xfs_dir2.h" +#include "xfs_dir2_priv.h" /* * Shortform directory ops
fs/xfs/libxfs/xfs_da_format.h +0 -57
81 lines not on this page · raw message
fs/xfs/libxfs/xfs_dir2.h +2 -0
@@ -18,6 +18,8 @@ struct xfs_dir2_sf_entry;struct xfs_dir2_data_hdr ;struct xfs_dir2_data_entry ;struct xfs_dir2_data_unused ; +struct xfs_dir3_icfree_hdr ; +struct xfs_dir3_icleaf_hdr ;extern struct xfs_name xfs_name_dotdot;
fs/xfs/libxfs/xfs_dir2_priv.h +20 -0
@@ -8,6 +8,26 @@struct dir_context ; +/* +* In-core version of the leaf and free block headers to abstract the +* differences in the v2 and v3 disk format of the headers. +*/ +struct xfs_dir3_icleaf_hdr { +uint32_t forw; +uint32_t back; +uint16_t magic; +uint16_t count; +uint16_t stale; +}; + +struct xfs_dir3_icfree_hdr { +uint32_t magic; +uint32_t firstdb; +uint32_t nvalid; +uint32_t nused; + +}; +/* xfs_dir2.c */ extern int xfs_dir2_grow_inode (struct xfs_da_args *args,int space,xfs_dir2_db_t *dbp);
Signature · 1 line
2.20.1
Re: [PATCH 01/34] xfs: move incore structures out of xfs_da_format.h
Quoted 4 lines · Christoph Hellwig
Move the abstract in-memory version of various btree block headers out of
xfs_da_format.has they aren't on-disk formats.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 215 lines
--- fs/xfs/libxfs/xfs_attr_leaf.h | 23 ++++++++++++++ fs/xfs/libxfs/xfs_da_btree.h | 13 ++++++++ fs/xfs/libxfs/xfs_da_format.c | 1 + fs/xfs/libxfs/xfs_da_format.h | 57 ----------------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 ++ fs/xfs/libxfs/xfs_dir2_priv.h | 20 ++++++++++++ 6 files changed, 59 insertions(+), 57 deletions(-)fs/xfs/libxfs/xfs_attr_leaf.h +23
-0@@ -16,6 +16,29 @@ struct xfs_da_state_blk;struct xfs_inode ;struct xfs_trans ; +/* +* Incore version of the attribute leaf header. +*/ +struct xfs_attr3_icleaf_hdr { +uint32_t forw; +uint32_t back; +uint16_t magic; +uint16_t count; +uint16_t usedbytes; +/* +* Firstused is 32-bit here instead of 16-bit like the on-disk variant +* to support maximum fsb size of 64k without overflow issues throughout +* the attr code. Instead, the overflow condition is handled on +* conversion to/from disk. +*/ +uint32_t firstused; +__u8 holes; +struct { +uint16_t base; +uint16_t size; + } freemap[XFS_ATTR_LEAF_MAPSIZE ]; +}; +/* * Used to keep a list of "remote value" extents when unlinking an inode. */ fs/xfs/libxfs/xfs_da_btree.h +13
-0@@ -124,6 +124,19 @@ typedef struct xfs_da_state {/* for dirv2 extrablk is data */ } xfs_da_state_t; +/* +* In-core version of the node header to abstract the differences in the v2 and +* v3 disk format of the headers. Callers need to convert to/from disk format as +* appropriate. +*/ +struct xfs_da3_icnode_hdr { +uint32_t forw; +uint32_t back; +uint16_t magic; +uint16_t count; +uint16_t level; +}; +/* * Utility macros to aid in logging changed structure fields. */ fs/xfs/libxfs/xfs_da_format.c +1
-0@@ -13,6 +13,7 @@#include "xfs_mount.h" #include "xfs_inode.h" #include "xfs_dir2.h" +#include "xfs_dir2_priv.h" /* * Shortform directory ops fs/xfs/libxfs/xfs_da_format.h +0
-57@@ -93,19 +93,6 @@ struct xfs_da3_intnode {struct xfs_da_node_entry __btree[]; }; -/* -* In-core version of the node header to abstract the differences in the v2 and -* v3 disk format of the headers. Callers need to convert to/from disk format as -* appropriate. -*/ -struct xfs_da3_icnode_hdr { -uint32_t forw; -uint32_t back; -uint16_t magic; -uint16_t count; -uint16_t level; -}; -/* * Directory version 2. * @@ -434,14 +421,6 @@ struct xfs_dir3_leaf_hdr {__be32 pad;/* 64 bit alignment */ }; -struct xfs_dir3_icleaf_hdr { -uint32_t forw; -uint32_t back; -uint16_t magic; -uint16_t count; -uint16_t stale; -}; -/* * Leaf block entry. */ @@ -520,19 +499,6 @@ struct xfs_dir3_free {#define XFS_DIR3_FREE_CRC_OFF offsetof(struct xfs_dir3_free, hdr.hdr.crc) -/* -* In core version of the free block header, abstracted away from on-disk format -* differences. Use this in the code, and convert to/from the disk version using -* xfs_dir3_free_hdr_from_disk/xfs_dir3_free_hdr_to_disk. -*/ -struct xfs_dir3_icfree_hdr { -uint32_t magic; -uint32_t firstdb; -uint32_t nvalid; -uint32_t nused; - -}; -/* * Single block format. * @@ -709,29 +675,6 @@ struct xfs_attr3_leafblock {*/ }; -/* -* incore, neutral version of the attribute leaf header -*/ -struct xfs_attr3_icleaf_hdr { -uint32_t forw; -uint32_t back; -uint16_t magic; -uint16_t count; -uint16_t usedbytes; -/* -* firstused is 32-bit here instead of 16-bit like the on-disk variant -* to support maximum fsb size of 64k without overflow issues throughout -* the attr code. Instead, the overflow condition is handled on -* conversion to/from disk. -*/ -uint32_t firstused; -__u8 holes; -struct { -uint16_t base; -uint16_t size; - } freemap[XFS_ATTR_LEAF_MAPSIZE ]; -}; -/* * Special value to represent fs block size in the leaf header firstused field. * Only used when block size overflows the 2-bytes available on disk. fs/xfs/libxfs/xfs_dir2.h +2
-0@@ -18,6 +18,8 @@ struct xfs_dir2_sf_entry;struct xfs_dir2_data_hdr ;struct xfs_dir2_data_entry ;struct xfs_dir2_data_unused ; +struct xfs_dir3_icfree_hdr ; +struct xfs_dir3_icleaf_hdr ;extern struct xfs_name xfs_name_dotdot;fs/xfs/libxfs/xfs_dir2_priv.h +20
-0@@ -8,6 +8,26 @@struct dir_context ; +/* +* In-core version of the leaf and free block headers to abstract the +* differences in the v2 and v3 disk format of the headers. +*/ +struct xfs_dir3_icleaf_hdr { +uint32_t forw; +uint32_t back; +uint16_t magic; +uint16_t count; +uint16_t stale; +}; + +struct xfs_dir3_icfree_hdr { +uint32_t magic; +uint32_t firstdb; +uint32_t nvalid; +uint32_t nused; + +}; +/* xfs_dir2.c */ extern int xfs_dir2_grow_inode (struct xfs_da_args *args,int space,xfs_dir2_db_t *dbp);Signature · 1 line
2.20.1
PATCH 2/34 xfs: refactor btree node scrubbing
In reply to Christoph HellwigBreak up xchk_da_btree_entry and handle looking up leaf node entries in the attr / dir callbacks, so that only the generic node handling is left in the common core code. Note that the checks for the crc enabled blocks are removed, as the scrubbing code already remaps the magic numbers earlier.
--- fs/xfs/scrub/attr.c | 12 ++++++----- fs/xfs/scrub/dabtree.c | 48 ++++++++++-------------------------------- fs/xfs/scrub/dabtree.h | 3 +-- fs/xfs/scrub/dir.c | 12 ++++++++--- 4 files changed, 28 insertions(+), 47 deletions(-)
fs/xfs/scrub/attr.c +7 -5
@@ -398,15 +398,14 @@ xchk_xattr_block( STATIC intxchk_xattr_rec (struct xchk_da_btree *ds, -int level, -void *rec) +int level) {struct xfs_mount *mp = ds->state->mp; -struct xfs_attr_leaf_entry *ent = rec; -struct xfs_da_state_blk *blk; +struct xfs_da_state_blk *blk = &ds->state->path.blk[level];struct xfs_attr_leaf_name_local *lentry;struct xfs_attr_leaf_name_remote *rentry;struct xfs_buf *bp; +struct xfs_attr_leaf_entry *ent;xfs_dahash_t calc_hash;xfs_dahash_t hash;int nameidx;
@@ -414,7 +413,10 @@ xchk_xattr_rec(unsigned int badflags;int error; - blk = &ds->state->path.blk[level]; +ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); + + ent = (void *)xfs_attr3_leaf_entryp (blk->bp->b_addr) + + (blk->index *sizeof (struct xfs_attr_leaf_entry ));/* Check the whole block, if necessary. */ error =xchk_xattr_block (ds, level);
fs/xfs/scrub/dabtree.c +11 -37
81 lines not on this page · raw message
fs/xfs/scrub/dabtree.h +1 -2
@@ -28,8 +28,7 @@ struct xchk_da_btree {int tree_level; }; -typedef int (*xchk_da_btree_rec_fn )(struct xchk_da_btree *ds, -int level,void *rec); +typedef int (*xchk_da_btree_rec_fn )(struct xchk_da_btree *ds,int level);/* Check for da btree operation errors. */ bool xchk_da_process_error (struct xchk_da_btree *ds,int level,int *error);
fs/xfs/scrub/dir.c +9 -3
@@ -179,14 +179,14 @@ xchk_dir_actor( STATIC intxchk_dir_rec (struct xchk_da_btree *ds, -int level, -void *rec) +int level) { +struct xfs_da_state_blk *blk = &ds->state->path.blk[level];struct xfs_mount *mp = ds->state->mp; -struct xfs_dir2_leaf_entry *ent = rec;struct xfs_inode *dp = ds->dargs.dp;struct xfs_dir2_data_entry *dent;struct xfs_buf *bp; +struct xfs_dir2_leaf_entry *ent;char *p, *endp;xfs_ino_t ino;xfs_dablk_t rec_bno;
@@ -198,6 +198,12 @@ xchk_dir_rec(unsigned int tag;int error; +ASSERT (blk->magic ==XFS_DIR2_LEAF1_MAGIC || + blk->magic ==XFS_DIR2_LEAFN_MAGIC ); + + ent = (void *)ds->dargs.dp->d_ops->leaf_ents_p (blk->bp->b_addr) + + (blk->index *sizeof (struct xfs_dir2_leaf_entry )); +/* Check the hash of the entry. */ error =xchk_da_btree_hash (ds, level, &ent->hashval);if (error)
Signature · 1 line
2.20.1
Re: [PATCH 02/34] xfs: refactor btree node scrubbing
Quoted 38 lines · Christoph Hellwig
Break up
xchk_da_btree_entryand handle looking up leaf node entries in the attr / dir callbacks, so that only the generic node handling is left in the common core code. Note that the checks for the crc enabled blocks are removed, as the scrubbing code already remaps the magic numbers earlier.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/scrub/attr.c | 12 ++++++----- fs/xfs/scrub/dabtree.c | 48 ++++++++++-------------------------------- fs/xfs/scrub/dabtree.h | 3 +-- fs/xfs/scrub/dir.c | 12 ++++++++--- 4 files changed, 28 insertions(+), 47 deletions(-)fs/xfs/scrub/attr.c +3
-4@@ -398,15 +398,14 @@ xchk_xattr_block( STATIC intxchk_xattr_rec (struct xchk_da_btree *ds, -int level, -void *rec) +int level) {struct xfs_mount *mp = ds->state->mp; -struct xfs_attr_leaf_entry *ent = rec; -struct xfs_da_state_blk *blk; +struct xfs_da_state_blk *blk = &ds->state->path.blk[level];struct xfs_attr_leaf_name_local *lentry;struct xfs_attr_leaf_name_remote *rentry;struct xfs_buf *bp; +struct xfs_attr_leaf_entry *ent;xfs_dahash_t calc_hash;xfs_dahash_t hash;int nameidx;
fs/xfs/scrub/attr.c xchk_xattr_rec( · line 419
Quoted 8 lines
fs/xfs/scrub/attr.c +4
-1@@ -414,7 +413,10 @@ xchk_xattr_rec(unsigned int badflags;int error; - blk = &ds->state->path.blk[level]; +ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); + + ent = (void *)xfs_attr3_leaf_entryp (blk->bp->b_addr) + + (blk->index *sizeof (struct xfs_attr_leaf_entry ));
Seeing as this function returns a pointer to struct xfs_attr_leaf_entry, why not clean this up to:
ent = xfs_attr3_leaf_entryp(...)[blk->index]; ?
Though looking at that, I wonder if a better option would be to incorporate the index as an argument to xfs_attr3_leaf_entryp?
(And yes, that's material for a separate patch...)
Quoted 57 lines
fs/xfs/scrub/attr.c +0
-0/* Check the whole block, if necessary. */ error =xchk_xattr_block (ds, level);fs/xfs/scrub/dabtree.c +8
-31@@ -77,40 +77,17 @@ xchk_da_set_corrupt( __return_address); } -/* Find an entry at a certain level in a da btree. */ -STATIC void * -xchk_da_btree_entry ( -struct xchk_da_btree *ds, -int level, -int rec) +static struct xfs_da_node_entry * +xchk_da_btree_node_entry ( +struct xchk_da_btree *ds, +int level) { -char *ents; -struct xfs_da_state_blk *blk; -void *baddr; +struct xfs_da_state_blk *blk = &ds->state->path.blk[level]; -/* Dispatch the entry finding function. */ - blk = &ds->state->path.blk[level]; - baddr = blk->bp->b_addr; -switch (blk->magic) { -case XFS_ATTR_LEAF_MAGIC : -case XFS_ATTR3_LEAF_MAGIC : - ents = (char *)xfs_attr3_leaf_entryp (baddr); -return ents + (rec *sizeof (struct xfs_attr_leaf_entry )); -case XFS_DIR2_LEAFN_MAGIC : -case XFS_DIR3_LEAFN_MAGIC : - ents = (char *)ds->dargs.dp->d_ops->leaf_ents_p (baddr); -return ents + (rec *sizeof (struct xfs_dir2_leaf_entry )); -case XFS_DIR2_LEAF1_MAGIC : -case XFS_DIR3_LEAF1_MAGIC : - ents = (char *)ds->dargs.dp->d_ops->leaf_ents_p (baddr); -return ents + (rec *sizeof (struct xfs_dir2_leaf_entry )); -case XFS_DA_NODE_MAGIC : -case XFS_DA3_NODE_MAGIC : - ents = (char *)ds->dargs.dp->d_ops->node_tree_p (baddr); -return ents + (rec *sizeof (struct xfs_da_node_entry )); - } +ASSERT (blk->magic ==XFS_DA_NODE_MAGIC ); -return NULL ; +return (void *)ds->dargs.dp->d_ops->node_tree_p (blk->bp->b_addr) + + (blk->index *sizeof (struct xfs_da_node_entry )); }/* Scrub a da btree hash (key). */
fs/xfs/scrub/dabtree.c xchk_da_btree_hash( · line 115
Quoted 3 lines
fs/xfs/scrub/dabtree.c +0
-0@@ -136,7 +113,7 @@ xchk_da_btree_hash(/* Is this hash no larger than the parent hash? */ blks = ds->state->path.blk;
gcc complained that blks is no longer necessary.
--D
Quoted 85 lines
fs/xfs/scrub/dabtree.c +3
-6- entry =xchk_da_btree_entry (ds, level -1 , blks[level -1 ].index); + entry =xchk_da_btree_node_entry (ds, level -1 ); parent_hash =be32_to_cpu (entry->hashval);if (parent_hash < hash)xchk_da_set_corrupt (ds, level);@@ -479,7 +456,6 @@ xchk_da_btree(struct xfs_mount *mp = sc->mp;struct xfs_da_state_blk *blks;struct xfs_da_node_entry *key; -void *rec;xfs_dablk_t blkno;int level;int error;@@ -538,9 +514,7 @@ xchk_da_btree( }/* Dispatch record scrubbing. */ - rec =xchk_da_btree_entry (&ds, level, - blks[level].index); - error =scrub_fn (&ds, level, rec); + error =scrub_fn (&ds, level);if (error)break ; if (xchk_should_terminate(sc, &error) ||@@ -562,7 +536,7 @@ xchk_da_btree( }/* Hashes in order for scrub? */ - key =xchk_da_btree_entry (&ds, level, blks[level].index); + key =xchk_da_btree_node_entry (&ds, level); error =xchk_da_btree_hash (&ds, level, &key->hashval);if (error) goto out;fs/xfs/scrub/dabtree.h +1
-2@@ -28,8 +28,7 @@ struct xchk_da_btree {int tree_level; }; -typedef int (*xchk_da_btree_rec_fn )(struct xchk_da_btree *ds, -int level,void *rec); +typedef int (*xchk_da_btree_rec_fn )(struct xchk_da_btree *ds,int level);/* Check for da btree operation errors. */ bool xchk_da_process_error (struct xchk_da_btree *ds,int level,int *error);fs/xfs/scrub/dir.c +9
-3@@ -179,14 +179,14 @@ xchk_dir_actor( STATIC intxchk_dir_rec (struct xchk_da_btree *ds, -int level, -void *rec) +int level) { +struct xfs_da_state_blk *blk = &ds->state->path.blk[level];struct xfs_mount *mp = ds->state->mp; -struct xfs_dir2_leaf_entry *ent = rec;struct xfs_inode *dp = ds->dargs.dp;struct xfs_dir2_data_entry *dent;struct xfs_buf *bp; +struct xfs_dir2_leaf_entry *ent;char *p, *endp;xfs_ino_t ino;xfs_dablk_t rec_bno;@@ -198,6 +198,12 @@ xchk_dir_rec(unsigned int tag;int error; +ASSERT (blk->magic ==XFS_DIR2_LEAF1_MAGIC || + blk->magic ==XFS_DIR2_LEAFN_MAGIC ); + + ent = (void *)ds->dargs.dp->d_ops->leaf_ents_p (blk->bp->b_addr) + + (blk->index *sizeof (struct xfs_dir2_leaf_entry )); +/* Check the hash of the entry. */ error =xchk_da_btree_hash (ds, level, &ent->hashval);if (error)Signature · 1 line
2.20.1
Re: [PATCH 02/34] xfs: refactor btree node scrubbing
Quoted 4 lines · Darrick J. Wong
Seeing as this function returns a pointer to struct
xfs_attr_leaf_entry, why not clean this up to:ent = xfs_attr3_leaf_entryp(...)[blk->index]; ?
Well, it should really be xfs_attr3_leaf_entryp + blk->index. But otherwise agreed and fixed up for the next version.
PATCH 3/34 xfs: devirtualize ->node_hdr_from_disk
In reply to Christoph HellwigReplace the ->node_hdr_from_disk dir ops method with a directly called xfs_da_node_hdr_from_disk helper that takes care of the v4 vs v5 difference.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 84 ++++++++++++++++++++++------------- fs/xfs/libxfs/xfs_da_btree.h | 3 ++ fs/xfs/libxfs/xfs_da_format.c | 33 -------------- fs/xfs/libxfs/xfs_dir2.h | 2 - fs/xfs/scrub/dabtree.c | 2 +- fs/xfs/xfs_attr_inactive.c | 2 +- fs/xfs/xfs_attr_list.c | 2 +- 8 files changed, 60 insertions(+), 70 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +1 -1
@@ -1185,7 +1185,7 @@ xfs_attr3_leaf_to_node(if (error) goto out; node = bp1->b_addr; - dp->d_ops->node_hdr_from_disk (&icnodehdr, node); +xfs_da3_node_hdr_from_disk (mp, &icnodehdr, node); btree = dp->d_ops->node_tree_p (node); leaf = bp2->b_addr;
fs/xfs/libxfs/xfs_da_btree.c +53 -31
230 lines not on this page · raw message
fs/xfs/libxfs/xfs_da_btree.h +3 -0
@@ -215,6 +215,9 @@ enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,xfs_da_state_t *xfs_da_state_alloc (void );void xfs_da_state_free (xfs_da_state_t *state); +void xfs_da3_node_hdr_from_disk (struct xfs_mount *mp, +struct xfs_da3_icnode_hdr *to,struct xfs_da_intnode *from); +extern struct kmem_zone *xfs_da_state_zone;extern const struct xfs_nameops xfs_default_nameops;
fs/xfs/libxfs/xfs_da_format.c +0 -33
@@ -510,19 +510,6 @@ xfs_da3_node_tree_p(struct xfs_da_intnode *dap)return ((struct xfs_da3_intnode *)dap)->__btree; } -static void -xfs_da2_node_hdr_from_disk ( -struct xfs_da3_icnode_hdr *to, -struct xfs_da_intnode *from) -{ -ASSERT (from->hdr.info.magic ==cpu_to_be16 (XFS_DA_NODE_MAGIC )); - to->forw =be32_to_cpu (from->hdr.info.forw); - to->back =be32_to_cpu (from->hdr.info.back); - to->magic =be16_to_cpu (from->hdr.info.magic); - to->count =be16_to_cpu (from->hdr.__count); - to->level =be16_to_cpu (from->hdr.__level); -} - static void xfs_da2_node_hdr_to_disk( struct xfs_da_intnode *to,
@@ -536,21 +523,6 @@ xfs_da2_node_hdr_to_disk( to->hdr.__level =cpu_to_be16 (from->level); } -static void -xfs_da3_node_hdr_from_disk ( -struct xfs_da3_icnode_hdr *to, -struct xfs_da_intnode *from) -{ -struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)from; - -ASSERT (from->hdr.info.magic ==cpu_to_be16 (XFS_DA3_NODE_MAGIC )); - to->forw =be32_to_cpu (hdr3->info.hdr.forw); - to->back =be32_to_cpu (hdr3->info.hdr.back); - to->magic =be16_to_cpu (hdr3->info.hdr.magic); - to->count =be16_to_cpu (hdr3->__count); - to->level =be16_to_cpu (hdr3->__level); -} - static void xfs_da3_node_hdr_to_disk( struct xfs_da_intnode *to,
@@ -727,7 +699,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .node_hdr_size = sizeof(struct xfs_da_node_hdr), .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da2_node_hdr_from_disk, .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
@@ -777,7 +748,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .node_hdr_size = sizeof(struct xfs_da_node_hdr), .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da2_node_hdr_from_disk, .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
@@ -827,7 +797,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .node_hdr_size = sizeof(struct xfs_da3_node_hdr), .node_hdr_to_disk = xfs_da3_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da3_node_hdr_from_disk, .node_tree_p = xfs_da3_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr),
@@ -842,14 +811,12 @@ static const struct xfs_dir_ops xfs_dir3_ops = {static const struct xfs_dir_ops xfs_dir2_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da_node_hdr ), .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da2_node_hdr_from_disk, .node_tree_p = xfs_da2_node_tree_p, };static const struct xfs_dir_ops xfs_dir3_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da3_node_hdr ), .node_hdr_to_disk = xfs_da3_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da3_node_hdr_from_disk, .node_tree_p = xfs_da3_node_tree_p, };
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -84,8 +84,6 @@ struct xfs_dir_ops {int node_hdr_size;void (*node_hdr_to_disk)(struct xfs_da_intnode *to,struct xfs_da3_icnode_hdr *from); -void (*node_hdr_from_disk)(struct xfs_da3_icnode_hdr *to, -struct xfs_da_intnode *from);struct xfs_da_node_entry * (*node_tree_p)(struct xfs_da_intnode *dap);
fs/xfs/scrub/dabtree.c +1 -1
@@ -410,7 +410,7 @@ xchk_da_btree_block( XFS_BLFT_DA_NODE_BUF); blk->magic =XFS_DA_NODE_MAGIC ; node = blk->bp->b_addr; - ip->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (ip->i_mount, &nodehdr, node); btree = ip->d_ops->node_tree_p (node); *pmaxrecs = nodehdr.count; blk->hashval =be32_to_cpu (btree[*pmaxrecs -1 ].hashval);
fs/xfs/xfs_attr_inactive.c +1 -1
@@ -213,7 +213,7 @@ xfs_attr3_node_inactive( } node = bp->b_addr; - dp->d_ops->node_hdr_from_disk (&ichdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &ichdr, node); parent_blkno = bp->b_bn;if (!ichdr.count) {xfs_trans_brelse (*trans, bp);
fs/xfs/xfs_attr_list.c +1 -1
@@ -240,7 +240,7 @@ xfs_attr_node_list_lookup( goto out_corruptbuf; } - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (mp, &nodehdr, node);/* Tree taller than we can handle; bail out! */ if (nodehdr.level >=XFS_DA_NODE_MAXDEPTH )
Signature · 1 line
2.20.1
Re: [PATCH 03/34] xfs: devirtualize ->node_hdr_from_disk
Quoted 5 lines · Christoph Hellwig
Replace the ->node_hdr_from_disk dir ops method with a directly called
xfs_da_node_hdr_from_diskhelper that takes care of the v4 vs v5 difference.Signed-off-by Christoph Hellwig <[email protected]>
Seems like a nice cleanup,
--D
Quoted 436 lines
--- fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 84 ++++++++++++++++++++++------------- fs/xfs/libxfs/xfs_da_btree.h | 3 ++ fs/xfs/libxfs/xfs_da_format.c | 33 -------------- fs/xfs/libxfs/xfs_dir2.h | 2 - fs/xfs/scrub/dabtree.c | 2 +- fs/xfs/xfs_attr_inactive.c | 2 +- fs/xfs/xfs_attr_list.c | 2 +- 8 files changed, 60 insertions(+), 70 deletions(-)fs/xfs/libxfs/xfs_attr_leaf.c +1
-1@@ -1185,7 +1185,7 @@ xfs_attr3_leaf_to_node(if (error) goto out; node = bp1->b_addr; - dp->d_ops->node_hdr_from_disk (&icnodehdr, node); +xfs_da3_node_hdr_from_disk (mp, &icnodehdr, node); btree = dp->d_ops->node_tree_p (node); leaf = bp2->b_addr;fs/xfs/libxfs/xfs_da_btree.c +53
-31@@ -110,6 +110,31 @@ xfs_da_state_free(xfs_da_state_t *state)kmem_zone_free (xfs_da_state_zone, state); } +void +xfs_da3_node_hdr_from_disk ( +struct xfs_mount *mp, +struct xfs_da3_icnode_hdr *to, +struct xfs_da_intnode *from) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_da3_intnode *from3 = (struct xfs_da3_intnode *)from; + + to->forw =be32_to_cpu (from3->hdr.info.hdr.forw); + to->back =be32_to_cpu (from3->hdr.info.hdr.back); + to->magic =be16_to_cpu (from3->hdr.info.hdr.magic); + to->count =be16_to_cpu (from3->hdr.__count); + to->level =be16_to_cpu (from3->hdr.__level); +ASSERT (to->magic ==XFS_DA3_NODE_MAGIC ); + }else { + to->forw =be32_to_cpu (from->hdr.info.forw); + to->back =be32_to_cpu (from->hdr.info.back); + to->magic =be16_to_cpu (from->hdr.info.magic); + to->count =be16_to_cpu (from->hdr.__count); + to->level =be16_to_cpu (from->hdr.__level); +ASSERT (to->magic ==XFS_DA_NODE_MAGIC ); + } +} +/* * Verify an xfs_da3_blkinfo structure. Note that the da3 fields are only * accessible on v5 filesystems. This header format is common across da node, @@ -145,12 +170,9 @@ xfs_da3_node_verify(struct xfs_mount *mp = bp->b_mount;struct xfs_da_intnode *hdr = bp->b_addr;struct xfs_da3_icnode_hdr ichdr; -const struct xfs_dir_ops *ops;xfs_failaddr_t fa; - ops =xfs_dir_get_ops (mp,NULL ); - - ops->node_hdr_from_disk (&ichdr, hdr); +xfs_da3_node_hdr_from_disk (mp, &ichdr, hdr); fa =xfs_da3_blkinfo_verify (bp, bp->b_addr);if (fa)@@ -577,7 +599,7 @@ xfs_da3_root_split( oldroot->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC)) {struct xfs_da3_icnode_hdr icnodehdr; - dp->d_ops->node_hdr_from_disk (&icnodehdr, oldroot); +xfs_da3_node_hdr_from_disk (dp->i_mount, &icnodehdr, oldroot); btree = dp->d_ops->node_tree_p (oldroot); size = (int )((char *)&btree[icnodehdr.count] - (char *)oldroot); level = icnodehdr.level;@@ -637,7 +659,7 @@ xfs_da3_root_split(return error; node = bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node); btree = dp->d_ops->node_tree_p (node); btree[0 ].hashval =cpu_to_be32 (blk1->hashval); btree[0 ].before =cpu_to_be32 (blk1->blkno);@@ -686,7 +708,7 @@ xfs_da3_node_split(trace_xfs_da_node_split (state->args); node = oldblk->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node);/* * With V2 dirs the extra block is data or freespace. @@ -733,7 +755,7 @@ xfs_da3_node_split(* If we had double-split op below us, then add the extra block too. */ node = oldblk->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node);if (oldblk->index <= nodehdr.count) { oldblk->index++;xfs_da3_node_add (state, oldblk, addblk);@@ -788,8 +810,8 @@ xfs_da3_node_rebalance( node1 = blk1->bp->b_addr; node2 = blk2->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr1, node1); - dp->d_ops->node_hdr_from_disk (&nodehdr2, node2); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr1, node1); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr2, node2); btree1 = dp->d_ops->node_tree_p (node1); btree2 = dp->d_ops->node_tree_p (node2);@@ -804,8 +826,8 @@ xfs_da3_node_rebalance( tmpnode = node1; node1 = node2; node2 = tmpnode; - dp->d_ops->node_hdr_from_disk (&nodehdr1, node1); - dp->d_ops->node_hdr_from_disk (&nodehdr2, node2); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr1, node1); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr2, node2); btree1 = dp->d_ops->node_tree_p (node1); btree2 = dp->d_ops->node_tree_p (node2); swap =1 ;@@ -886,8 +908,8 @@ xfs_da3_node_rebalance(if (swap) { node1 = blk1->bp->b_addr; node2 = blk2->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr1, node1); - dp->d_ops->node_hdr_from_disk (&nodehdr2, node2); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr1, node1); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr2, node2); btree1 = dp->d_ops->node_tree_p (node1); btree2 = dp->d_ops->node_tree_p (node2); }@@ -921,7 +943,7 @@ xfs_da3_node_add(trace_xfs_da_node_add (state->args); node = oldblk->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node); btree = dp->d_ops->node_tree_p (node);ASSERT (oldblk->index >=0 && oldblk->index <= nodehdr.count);@@ -1092,7 +1114,7 @@ xfs_da3_root_join( args = state->args; oldroot = root_blk->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&oldroothdr, oldroot); +xfs_da3_node_hdr_from_disk (dp->i_mount, &oldroothdr, oldroot);ASSERT (oldroothdr.forw ==0 );ASSERT (oldroothdr.back ==0 );@@ -1172,7 +1194,7 @@ xfs_da3_node_toosmall( blk = &state->path.blk[ state->path.active-1 ]; info = blk->bp->b_addr; node = (xfs_da_intnode_t *)info; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node);if (nodehdr.count > (state->args->geo->node_ents >>1 )) { *action =0 ;/* blk over 50%, don't try to join */ return 0 ;/* blk over 50%, don't try to join */ @@ -1230,7 +1252,7 @@ xfs_da3_node_toosmall(return error; node = bp->b_addr; - dp->d_ops->node_hdr_from_disk (&thdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &thdr, node);xfs_trans_brelse (state->args->trans, bp);if (count - thdr.count >=0 )@@ -1277,7 +1299,7 @@ xfs_da3_node_lasthash(struct xfs_da3_icnode_hdr nodehdr; node = bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node);if (count) *count = nodehdr.count;if (!nodehdr.count)@@ -1328,7 +1350,7 @@ xfs_da3_fixhashpath(struct xfs_da3_icnode_hdr nodehdr; node = blk->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node); btree = dp->d_ops->node_tree_p (node);if (be32_to_cpu (btree[blk->index].hashval) == lasthash)break ;@@ -1360,7 +1382,7 @@ xfs_da3_node_remove(trace_xfs_da_node_remove (state->args); node = drop_blk->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node);ASSERT (drop_blk->index < nodehdr.count);ASSERT (drop_blk->index >=0 );@@ -1416,8 +1438,8 @@ xfs_da3_node_unbalance( drop_node = drop_blk->bp->b_addr; save_node = save_blk->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&drop_hdr, drop_node); - dp->d_ops->node_hdr_from_disk (&save_hdr, save_node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &drop_hdr, drop_node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &save_hdr, save_node); drop_btree = dp->d_ops->node_tree_p (drop_node); save_btree = dp->d_ops->node_tree_p (save_node); tp = state->args->trans;@@ -1550,7 +1572,7 @@ xfs_da3_node_lookup_int(* Search an intermediate node for a match. */ node = blk->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node); btree = dp->d_ops->node_tree_p (node);/* Tree taller than we can handle; bail out! */ @@ -1678,8 +1700,8 @@ xfs_da3_node_order( node1 = node1_bp->b_addr; node2 = node2_bp->b_addr; - dp->d_ops->node_hdr_from_disk (&node1hdr, node1); - dp->d_ops->node_hdr_from_disk (&node2hdr, node2); +xfs_da3_node_hdr_from_disk (dp->i_mount, &node1hdr, node1); +xfs_da3_node_hdr_from_disk (dp->i_mount, &node2hdr, node2); btree1 = dp->d_ops->node_tree_p (node1); btree2 = dp->d_ops->node_tree_p (node2);@@ -1902,7 +1924,7 @@ xfs_da3_path_shift( level = (path->active-1 ) -1 ;/* skip bottom layer in path */ for (blk = &path->blk[level]; level >=0 ; blk--, level--) { node = blk->bp->b_addr; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node); btree = dp->d_ops->node_tree_p (node);if (forward && (blk->index < nodehdr.count -1 )) {@@ -1963,7 +1985,7 @@ xfs_da3_path_shift(case XFS_DA3_NODE_MAGIC : blk->magic =XFS_DA_NODE_MAGIC ; node = (xfs_da_intnode_t *)info; - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &nodehdr, node); btree = dp->d_ops->node_tree_p (node); blk->hashval =be32_to_cpu (btree[nodehdr.count -1 ].hashval);if (forward)@@ -2248,7 +2270,7 @@ xfs_da3_swap_lastblock(struct xfs_da3_icnode_hdr deadhdr; dead_node = (xfs_da_intnode_t *)dead_info; - dp->d_ops->node_hdr_from_disk (&deadhdr, dead_node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &deadhdr, dead_node); btree = dp->d_ops->node_tree_p (dead_node); dead_level = deadhdr.level; dead_hash =be32_to_cpu (btree[deadhdr.count -1 ].hashval);@@ -2308,7 +2330,7 @@ xfs_da3_swap_lastblock(if (error) goto done; par_node = par_buf->b_addr; - dp->d_ops->node_hdr_from_disk (&par_hdr, par_node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &par_hdr, par_node);if (level >=0 && level != par_hdr.level +1 ) {XFS_ERROR_REPORT ("xfs_da_swap_lastblock(4)" ,XFS_ERRLEVEL_LOW , mp);@@ -2359,7 +2381,7 @@ xfs_da3_swap_lastblock(if (error) goto done; par_node = par_buf->b_addr; - dp->d_ops->node_hdr_from_disk (&par_hdr, par_node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &par_hdr, par_node);if (par_hdr.level != level) {XFS_ERROR_REPORT ("xfs_da_swap_lastblock(7)" ,XFS_ERRLEVEL_LOW , mp);fs/xfs/libxfs/xfs_da_btree.h +3
-0@@ -215,6 +215,9 @@ enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,xfs_da_state_t *xfs_da_state_alloc (void );void xfs_da_state_free (xfs_da_state_t *state); +void xfs_da3_node_hdr_from_disk (struct xfs_mount *mp, +struct xfs_da3_icnode_hdr *to,struct xfs_da_intnode *from); +extern struct kmem_zone *xfs_da_state_zone;extern const struct xfs_nameops xfs_default_nameops;fs/xfs/libxfs/xfs_da_format.c +0
-33@@ -510,19 +510,6 @@ xfs_da3_node_tree_p(struct xfs_da_intnode *dap)return ((struct xfs_da3_intnode *)dap)->__btree; } -static void -xfs_da2_node_hdr_from_disk ( -struct xfs_da3_icnode_hdr *to, -struct xfs_da_intnode *from) -{ -ASSERT (from->hdr.info.magic ==cpu_to_be16 (XFS_DA_NODE_MAGIC )); - to->forw =be32_to_cpu (from->hdr.info.forw); - to->back =be32_to_cpu (from->hdr.info.back); - to->magic =be16_to_cpu (from->hdr.info.magic); - to->count =be16_to_cpu (from->hdr.__count); - to->level =be16_to_cpu (from->hdr.__level); -} - static void xfs_da2_node_hdr_to_disk( struct xfs_da_intnode *to,@@ -536,21 +523,6 @@ xfs_da2_node_hdr_to_disk( to->hdr.__level =cpu_to_be16 (from->level); } -static void -xfs_da3_node_hdr_from_disk ( -struct xfs_da3_icnode_hdr *to, -struct xfs_da_intnode *from) -{ -struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)from; - -ASSERT (from->hdr.info.magic ==cpu_to_be16 (XFS_DA3_NODE_MAGIC )); - to->forw =be32_to_cpu (hdr3->info.hdr.forw); - to->back =be32_to_cpu (hdr3->info.hdr.back); - to->magic =be16_to_cpu (hdr3->info.hdr.magic); - to->count =be16_to_cpu (hdr3->__count); - to->level =be16_to_cpu (hdr3->__level); -} - static void xfs_da3_node_hdr_to_disk( struct xfs_da_intnode *to,@@ -727,7 +699,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .node_hdr_size = sizeof(struct xfs_da_node_hdr), .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da2_node_hdr_from_disk, .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),@@ -777,7 +748,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .node_hdr_size = sizeof(struct xfs_da_node_hdr), .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da2_node_hdr_from_disk, .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),@@ -827,7 +797,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .node_hdr_size = sizeof(struct xfs_da3_node_hdr), .node_hdr_to_disk = xfs_da3_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da3_node_hdr_from_disk, .node_tree_p = xfs_da3_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr),@@ -842,14 +811,12 @@ static const struct xfs_dir_ops xfs_dir3_ops = {static const struct xfs_dir_ops xfs_dir2_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da_node_hdr ), .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da2_node_hdr_from_disk, .node_tree_p = xfs_da2_node_tree_p, };static const struct xfs_dir_ops xfs_dir3_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da3_node_hdr ), .node_hdr_to_disk = xfs_da3_node_hdr_to_disk, - .node_hdr_from_disk = xfs_da3_node_hdr_from_disk, .node_tree_p = xfs_da3_node_tree_p, };fs/xfs/libxfs/xfs_dir2.h +0
-2@@ -84,8 +84,6 @@ struct xfs_dir_ops {int node_hdr_size;void (*node_hdr_to_disk)(struct xfs_da_intnode *to,struct xfs_da3_icnode_hdr *from); -void (*node_hdr_from_disk)(struct xfs_da3_icnode_hdr *to, -struct xfs_da_intnode *from);struct xfs_da_node_entry * (*node_tree_p)(struct xfs_da_intnode *dap);fs/xfs/scrub/dabtree.c +1
-1@@ -410,7 +410,7 @@ xchk_da_btree_block( XFS_BLFT_DA_NODE_BUF); blk->magic =XFS_DA_NODE_MAGIC ; node = blk->bp->b_addr; - ip->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (ip->i_mount, &nodehdr, node); btree = ip->d_ops->node_tree_p (node); *pmaxrecs = nodehdr.count; blk->hashval =be32_to_cpu (btree[*pmaxrecs -1 ].hashval);fs/xfs/xfs_attr_inactive.c +1
-1@@ -213,7 +213,7 @@ xfs_attr3_node_inactive( } node = bp->b_addr; - dp->d_ops->node_hdr_from_disk (&ichdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &ichdr, node); parent_blkno = bp->b_bn;if (!ichdr.count) {xfs_trans_brelse (*trans, bp);fs/xfs/xfs_attr_list.c +1
-1@@ -240,7 +240,7 @@ xfs_attr_node_list_lookup( goto out_corruptbuf; } - dp->d_ops->node_hdr_from_disk (&nodehdr, node); +xfs_da3_node_hdr_from_disk (mp, &nodehdr, node);/* Tree taller than we can handle; bail out! */ if (nodehdr.level >=XFS_DA_NODE_MAXDEPTH )Signature · 1 line
2.20.1
PATCH 4/34 xfs: devirtualize ->node_hdr_to_disk
In reply to Christoph HellwigReplace the ->node_hdr_to_disk dir ops method with a directly called xfs_da_node_hdr_to_disk helper that takes care of the v4 vs v5 difference.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 39 ++++++++++++++++++++++++++++------- fs/xfs/libxfs/xfs_da_btree.h | 2 ++ fs/xfs/libxfs/xfs_da_format.c | 34 ------------------------------ fs/xfs/libxfs/xfs_dir2.h | 2 -- 5 files changed, 35 insertions(+), 44 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +1 -1
@@ -1196,7 +1196,7 @@ xfs_attr3_leaf_to_node( btree[0 ].hashval = entries[icleafhdr.count -1 ].hashval; btree[0 ].before =cpu_to_be32 (blkno); icnodehdr.count =1 ; - dp->d_ops->node_hdr_to_disk (node, &icnodehdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &icnodehdr);xfs_trans_log_buf (args->trans, bp1,0 , args->geo->blksize -1 ); error =0 ; out:
fs/xfs/libxfs/xfs_da_btree.c +32 -7
@@ -135,6 +135,31 @@ xfs_da3_node_hdr_from_disk( } } +void +xfs_da3_node_hdr_to_disk ( +struct xfs_mount *mp, +struct xfs_da_intnode *to, +struct xfs_da3_icnode_hdr *from) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_da3_intnode *to3 = (struct xfs_da3_intnode *)to; + +ASSERT (from->magic ==XFS_DA3_NODE_MAGIC ); + to3->hdr.info.hdr.forw =cpu_to_be32 (from->forw); + to3->hdr.info.hdr.back =cpu_to_be32 (from->back); + to3->hdr.info.hdr.magic =cpu_to_be16 (from->magic); + to3->hdr.__count =cpu_to_be16 (from->count); + to3->hdr.__level =cpu_to_be16 (from->level); + }else { +ASSERT (from->magic ==XFS_DA_NODE_MAGIC ); + to->hdr.info.forw =cpu_to_be32 (from->forw); + to->hdr.info.back =cpu_to_be32 (from->back); + to->hdr.info.magic =cpu_to_be16 (from->magic); + to->hdr.__count =cpu_to_be16 (from->count); + to->hdr.__level =cpu_to_be16 (from->level); + } +} +/* * Verify an xfs_da3_blkinfo structure. Note that the da3 fields are only * accessible on v5 filesystems. This header format is common across da node,
@@ -385,7 +410,7 @@ xfs_da3_node_create( } ichdr.level = level; - dp->d_ops->node_hdr_to_disk (node, &ichdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &ichdr);xfs_trans_log_buf (tp, bp,XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size));
@@ -666,7 +691,7 @@ xfs_da3_root_split( btree[1 ].hashval =cpu_to_be32 (blk2->hashval); btree[1 ].before =cpu_to_be32 (blk2->blkno); nodehdr.count =2 ; - dp->d_ops->node_hdr_to_disk (node, &nodehdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);#ifdef DEBUG if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
@@ -891,11 +916,11 @@ xfs_da3_node_rebalance(/* * Log header of node 1 and all current bits of node 2. */ - dp->d_ops->node_hdr_to_disk (node1, &nodehdr1); +xfs_da3_node_hdr_to_disk (dp->i_mount, node1, &nodehdr1);xfs_trans_log_buf (tp, blk1->bp,XFS_DA_LOGRANGE (node1, &node1->hdr, dp->d_ops->node_hdr_size)); - dp->d_ops->node_hdr_to_disk (node2, &nodehdr2); +xfs_da3_node_hdr_to_disk (dp->i_mount, node2, &nodehdr2); xfs_trans_log_buf(tp, blk2->bp, XFS_DA_LOGRANGE(node2, &node2->hdr, dp->d_ops->node_hdr_size +
@@ -967,7 +992,7 @@ xfs_da3_node_add( tmp + sizeof(*btree))); nodehdr.count +=1 ; - dp->d_ops->node_hdr_to_disk (node, &nodehdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);xfs_trans_log_buf (state->args->trans, oldblk->bp,XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size));
@@ -1403,7 +1428,7 @@ xfs_da3_node_remove(xfs_trans_log_buf (state->args->trans, drop_blk->bp,XFS_DA_LOGRANGE (node, &btree[index],sizeof (btree[index]))); nodehdr.count -=1 ; - dp->d_ops->node_hdr_to_disk (node, &nodehdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);xfs_trans_log_buf (state->args->trans, drop_blk->bp,XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size));
@@ -1475,7 +1500,7 @@ xfs_da3_node_unbalance(memcpy (&save_btree[sindex], &drop_btree[0 ], tmp); save_hdr.count += drop_hdr.count; - dp->d_ops->node_hdr_to_disk (save_node, &save_hdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, save_node, &save_hdr);xfs_trans_log_buf (tp, save_blk->bp,XFS_DA_LOGRANGE (save_node, &save_node->hdr, dp->d_ops->node_hdr_size));
fs/xfs/libxfs/xfs_da_btree.h +2 -0
@@ -217,6 +217,8 @@ void xfs_da_state_free(xfs_da_state_t *state);void xfs_da3_node_hdr_from_disk (struct xfs_mount *mp,struct xfs_da3_icnode_hdr *to,struct xfs_da_intnode *from); +void xfs_da3_node_hdr_to_disk (struct xfs_mount *mp, +struct xfs_da_intnode *to,struct xfs_da3_icnode_hdr *from);extern struct kmem_zone *xfs_da_state_zone;extern const struct xfs_nameops xfs_default_nameops;
fs/xfs/libxfs/xfs_da_format.c +0 -34
@@ -510,35 +510,6 @@ xfs_da3_node_tree_p(struct xfs_da_intnode *dap)return ((struct xfs_da3_intnode *)dap)->__btree; } -static void -xfs_da2_node_hdr_to_disk ( -struct xfs_da_intnode *to, -struct xfs_da3_icnode_hdr *from) -{ -ASSERT (from->magic ==XFS_DA_NODE_MAGIC ); - to->hdr.info.forw =cpu_to_be32 (from->forw); - to->hdr.info.back =cpu_to_be32 (from->back); - to->hdr.info.magic =cpu_to_be16 (from->magic); - to->hdr.__count =cpu_to_be16 (from->count); - to->hdr.__level =cpu_to_be16 (from->level); -} - -static void -xfs_da3_node_hdr_to_disk ( -struct xfs_da_intnode *to, -struct xfs_da3_icnode_hdr *from) -{ -struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)to; - -ASSERT (from->magic ==XFS_DA3_NODE_MAGIC ); - hdr3->info.hdr.forw =cpu_to_be32 (from->forw); - hdr3->info.hdr.back =cpu_to_be32 (from->back); - hdr3->info.hdr.magic =cpu_to_be16 (from->magic); - hdr3->__count =cpu_to_be16 (from->count); - hdr3->__level =cpu_to_be16 (from->level); -} - -/* * Directory free space block operations */
@@ -698,7 +669,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .leaf_ents_p = xfs_dir2_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
@@ -747,7 +717,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .leaf_ents_p = xfs_dir2_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
@@ -796,7 +765,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .leaf_ents_p = xfs_dir3_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da3_node_hdr), - .node_hdr_to_disk = xfs_da3_node_hdr_to_disk, .node_tree_p = xfs_da3_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr),
@@ -810,13 +778,11 @@ static const struct xfs_dir_ops xfs_dir3_ops = {static const struct xfs_dir_ops xfs_dir2_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da_node_hdr ), - .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, .node_tree_p = xfs_da2_node_tree_p, };static const struct xfs_dir_ops xfs_dir3_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da3_node_hdr ), - .node_hdr_to_disk = xfs_da3_node_hdr_to_disk, .node_tree_p = xfs_da3_node_tree_p, };
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -82,8 +82,6 @@ struct xfs_dir_ops { (*leaf_ents_p)(struct xfs_dir2_leaf *lp);int node_hdr_size; -void (*node_hdr_to_disk)(struct xfs_da_intnode *to, -struct xfs_da3_icnode_hdr *from);struct xfs_da_node_entry * (*node_tree_p)(struct xfs_da_intnode *dap);
Signature · 1 line
2.20.1
Re: [PATCH 04/34] xfs: devirtualize ->node_hdr_to_disk
Quoted 5 lines · Christoph Hellwig
Replace the ->node_hdr_to_disk dir ops method with a directly called
xfs_da_node_hdr_to_diskhelper that takes care of the v4 vs v5 difference.Signed-off-by Christoph Hellwig <[email protected]>
Nice substitution here too,
--D
Quoted 223 lines
--- fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 39 ++++++++++++++++++++++++++++------- fs/xfs/libxfs/xfs_da_btree.h | 2 ++ fs/xfs/libxfs/xfs_da_format.c | 34 ------------------------------ fs/xfs/libxfs/xfs_dir2.h | 2 -- 5 files changed, 35 insertions(+), 44 deletions(-)fs/xfs/libxfs/xfs_attr_leaf.c +1
-1@@ -1196,7 +1196,7 @@ xfs_attr3_leaf_to_node( btree[0 ].hashval = entries[icleafhdr.count -1 ].hashval; btree[0 ].before =cpu_to_be32 (blkno); icnodehdr.count =1 ; - dp->d_ops->node_hdr_to_disk (node, &icnodehdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &icnodehdr);xfs_trans_log_buf (args->trans, bp1,0 , args->geo->blksize -1 ); error =0 ; out:fs/xfs/libxfs/xfs_da_btree.c +32
-7@@ -135,6 +135,31 @@ xfs_da3_node_hdr_from_disk( } } +void +xfs_da3_node_hdr_to_disk ( +struct xfs_mount *mp, +struct xfs_da_intnode *to, +struct xfs_da3_icnode_hdr *from) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_da3_intnode *to3 = (struct xfs_da3_intnode *)to; + +ASSERT (from->magic ==XFS_DA3_NODE_MAGIC ); + to3->hdr.info.hdr.forw =cpu_to_be32 (from->forw); + to3->hdr.info.hdr.back =cpu_to_be32 (from->back); + to3->hdr.info.hdr.magic =cpu_to_be16 (from->magic); + to3->hdr.__count =cpu_to_be16 (from->count); + to3->hdr.__level =cpu_to_be16 (from->level); + }else { +ASSERT (from->magic ==XFS_DA_NODE_MAGIC ); + to->hdr.info.forw =cpu_to_be32 (from->forw); + to->hdr.info.back =cpu_to_be32 (from->back); + to->hdr.info.magic =cpu_to_be16 (from->magic); + to->hdr.__count =cpu_to_be16 (from->count); + to->hdr.__level =cpu_to_be16 (from->level); + } +} +/* * Verify an xfs_da3_blkinfo structure. Note that the da3 fields are only * accessible on v5 filesystems. This header format is common across da node, @@ -385,7 +410,7 @@ xfs_da3_node_create( } ichdr.level = level; - dp->d_ops->node_hdr_to_disk (node, &ichdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &ichdr);xfs_trans_log_buf (tp, bp,XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size));@@ -666,7 +691,7 @@ xfs_da3_root_split( btree[1 ].hashval =cpu_to_be32 (blk2->hashval); btree[1 ].before =cpu_to_be32 (blk2->blkno); nodehdr.count =2 ; - dp->d_ops->node_hdr_to_disk (node, &nodehdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);#ifdef DEBUG if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||@@ -891,11 +916,11 @@ xfs_da3_node_rebalance(/* * Log header of node 1 and all current bits of node 2. */ - dp->d_ops->node_hdr_to_disk (node1, &nodehdr1); +xfs_da3_node_hdr_to_disk (dp->i_mount, node1, &nodehdr1);xfs_trans_log_buf (tp, blk1->bp,XFS_DA_LOGRANGE (node1, &node1->hdr, dp->d_ops->node_hdr_size)); - dp->d_ops->node_hdr_to_disk (node2, &nodehdr2); +xfs_da3_node_hdr_to_disk (dp->i_mount, node2, &nodehdr2); xfs_trans_log_buf(tp, blk2->bp, XFS_DA_LOGRANGE(node2, &node2->hdr, dp->d_ops->node_hdr_size +@@ -967,7 +992,7 @@ xfs_da3_node_add( tmp + sizeof(*btree))); nodehdr.count +=1 ; - dp->d_ops->node_hdr_to_disk (node, &nodehdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);xfs_trans_log_buf (state->args->trans, oldblk->bp,XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size));@@ -1403,7 +1428,7 @@ xfs_da3_node_remove(xfs_trans_log_buf (state->args->trans, drop_blk->bp,XFS_DA_LOGRANGE (node, &btree[index],sizeof (btree[index]))); nodehdr.count -=1 ; - dp->d_ops->node_hdr_to_disk (node, &nodehdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);xfs_trans_log_buf (state->args->trans, drop_blk->bp,XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size));@@ -1475,7 +1500,7 @@ xfs_da3_node_unbalance(memcpy (&save_btree[sindex], &drop_btree[0 ], tmp); save_hdr.count += drop_hdr.count; - dp->d_ops->node_hdr_to_disk (save_node, &save_hdr); +xfs_da3_node_hdr_to_disk (dp->i_mount, save_node, &save_hdr);xfs_trans_log_buf (tp, save_blk->bp,XFS_DA_LOGRANGE (save_node, &save_node->hdr, dp->d_ops->node_hdr_size));fs/xfs/libxfs/xfs_da_btree.h +2
-0@@ -217,6 +217,8 @@ void xfs_da_state_free(xfs_da_state_t *state);void xfs_da3_node_hdr_from_disk (struct xfs_mount *mp,struct xfs_da3_icnode_hdr *to,struct xfs_da_intnode *from); +void xfs_da3_node_hdr_to_disk (struct xfs_mount *mp, +struct xfs_da_intnode *to,struct xfs_da3_icnode_hdr *from);extern struct kmem_zone *xfs_da_state_zone;extern const struct xfs_nameops xfs_default_nameops;fs/xfs/libxfs/xfs_da_format.c +0
-34@@ -510,35 +510,6 @@ xfs_da3_node_tree_p(struct xfs_da_intnode *dap)return ((struct xfs_da3_intnode *)dap)->__btree; } -static void -xfs_da2_node_hdr_to_disk ( -struct xfs_da_intnode *to, -struct xfs_da3_icnode_hdr *from) -{ -ASSERT (from->magic ==XFS_DA_NODE_MAGIC ); - to->hdr.info.forw =cpu_to_be32 (from->forw); - to->hdr.info.back =cpu_to_be32 (from->back); - to->hdr.info.magic =cpu_to_be16 (from->magic); - to->hdr.__count =cpu_to_be16 (from->count); - to->hdr.__level =cpu_to_be16 (from->level); -} - -static void -xfs_da3_node_hdr_to_disk ( -struct xfs_da_intnode *to, -struct xfs_da3_icnode_hdr *from) -{ -struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)to; - -ASSERT (from->magic ==XFS_DA3_NODE_MAGIC ); - hdr3->info.hdr.forw =cpu_to_be32 (from->forw); - hdr3->info.hdr.back =cpu_to_be32 (from->back); - hdr3->info.hdr.magic =cpu_to_be16 (from->magic); - hdr3->__count =cpu_to_be16 (from->count); - hdr3->__level =cpu_to_be16 (from->level); -} - -/* * Directory free space block operations */ @@ -698,7 +669,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .leaf_ents_p = xfs_dir2_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),@@ -747,7 +717,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .leaf_ents_p = xfs_dir2_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),@@ -796,7 +765,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .leaf_ents_p = xfs_dir3_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da3_node_hdr), - .node_hdr_to_disk = xfs_da3_node_hdr_to_disk, .node_tree_p = xfs_da3_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr),@@ -810,13 +778,11 @@ static const struct xfs_dir_ops xfs_dir3_ops = {static const struct xfs_dir_ops xfs_dir2_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da_node_hdr ), - .node_hdr_to_disk = xfs_da2_node_hdr_to_disk, .node_tree_p = xfs_da2_node_tree_p, };static const struct xfs_dir_ops xfs_dir3_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da3_node_hdr ), - .node_hdr_to_disk = xfs_da3_node_hdr_to_disk, .node_tree_p = xfs_da3_node_tree_p, };fs/xfs/libxfs/xfs_dir2.h +0
-2@@ -82,8 +82,6 @@ struct xfs_dir_ops { (*leaf_ents_p)(struct xfs_dir2_leaf *lp);int node_hdr_size; -void (*node_hdr_to_disk)(struct xfs_da_intnode *to, -struct xfs_da3_icnode_hdr *from);struct xfs_da_node_entry * (*node_tree_p)(struct xfs_da_intnode *dap);Signature · 1 line
2.20.1
PATCH 5/34 xfs: add a btree entries pointer to struct xfs_da3_icnode_hdr
In reply to Christoph HellwigAll but two callers of the ->node_tree_p dir operation already have a xfs_da3_icnode_hdr from a previous call to xfs_da3_node_hdr_from_disk at hand. Add a pointer to the btree entries to struct xfs_da3_icnode_hdr to clean up this pattern. The two remaining callers now expand the whole header as well, but that isn't very expensive and not in a super hot path anyway.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 6 ++-- fs/xfs/libxfs/xfs_da_btree.c | 68 ++++++++++++++++------------------- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 21 ----------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/scrub/dabtree.c | 6 ++-- fs/xfs/xfs_attr_inactive.c | 34 +++++++++--------- fs/xfs/xfs_attr_list.c | 2 +- 8 files changed, 55 insertions(+), 85 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +2 -4
@@ -1145,7 +1145,6 @@ xfs_attr3_leaf_to_node(struct xfs_attr_leafblock *leaf;struct xfs_attr3_icleaf_hdr icleafhdr;struct xfs_attr_leaf_entry *entries; -struct xfs_da_node_entry *btree;struct xfs_da3_icnode_hdr icnodehdr;struct xfs_da_intnode *node;struct xfs_inode *dp = args->dp;
@@ -1186,15 +1185,14 @@ xfs_attr3_leaf_to_node( goto out; node = bp1->b_addr;xfs_da3_node_hdr_from_disk (mp, &icnodehdr, node); - btree = dp->d_ops->node_tree_p (node); leaf = bp2->b_addr;xfs_attr3_leaf_hdr_from_disk (args->geo, &icleafhdr, leaf); entries =xfs_attr3_leaf_entryp (leaf);/* both on-disk, don't endian-flip twice */ - btree[0 ].hashval = entries[icleafhdr.count -1 ].hashval; - btree[0 ].before =cpu_to_be32 (blkno); + icnodehdr.btree[0 ].hashval = entries[icleafhdr.count -1 ].hashval; + icnodehdr.btree[0 ].before =cpu_to_be32 (blkno); icnodehdr.count =1 ;xfs_da3_node_hdr_to_disk (dp->i_mount, node, &icnodehdr);xfs_trans_log_buf (args->trans, bp1,0 , args->geo->blksize -1 );
fs/xfs/libxfs/xfs_da_btree.c +31 -37
212 lines not on this page · raw message
fs/xfs/libxfs/xfs_da_btree.h +1 -0
@@ -135,6 +135,7 @@ struct xfs_da3_icnode_hdr {uint16_t magic;uint16_t count;uint16_t level; +struct xfs_da_node_entry *btree; };/*
fs/xfs/libxfs/xfs_da_format.c +0 -21
@@ -494,22 +494,6 @@ xfs_dir3_leaf_hdr_to_disk( hdr3->stale =cpu_to_be16 (from->stale); } - -/* -* Directory/Attribute Node block operations -*/ -static struct xfs_da_node_entry * -xfs_da2_node_tree_p (struct xfs_da_intnode *dap) -{ -return dap->__btree; -} - -static struct xfs_da_node_entry * -xfs_da3_node_tree_p (struct xfs_da_intnode *dap) -{ -return ((struct xfs_da3_intnode *)dap)->__btree; -} -/* * Directory free space block operations */
@@ -669,7 +653,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .leaf_ents_p = xfs_dir2_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk,
@@ -717,7 +700,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .leaf_ents_p = xfs_dir2_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk,
@@ -765,7 +747,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .leaf_ents_p = xfs_dir3_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da3_node_hdr), - .node_tree_p = xfs_da3_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk,
@@ -778,12 +759,10 @@ static const struct xfs_dir_ops xfs_dir3_ops = {static const struct xfs_dir_ops xfs_dir2_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da_node_hdr ), - .node_tree_p = xfs_da2_node_tree_p, };static const struct xfs_dir_ops xfs_dir3_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da3_node_hdr ), - .node_tree_p = xfs_da3_node_tree_p, };/*
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -82,8 +82,6 @@ struct xfs_dir_ops { (*leaf_ents_p)(struct xfs_dir2_leaf *lp);int node_hdr_size; -struct xfs_da_node_entry * - (*node_tree_p)(struct xfs_da_intnode *dap);int free_hdr_size; void (*free_hdr_to_disk)(struct xfs_dir2_free *to,
fs/xfs/scrub/dabtree.c +4 -2
@@ -83,10 +83,12 @@ xchk_da_btree_node_entry( int level) {struct xfs_da_state_blk *blk = &ds->state->path.blk[level]; +struct xfs_da3_icnode_hdr hdr;ASSERT (blk->magic ==XFS_DA_NODE_MAGIC ); -return (void *)ds->dargs.dp->d_ops->node_tree_p (blk->bp->b_addr) + +xfs_da3_node_hdr_from_disk (ds->sc->mp, &hdr, blk->bp->b_addr); +return (void *)hdr.btree + (blk->index *sizeof (struct xfs_da_node_entry )); }
@@ -411,7 +413,7 @@ xchk_da_btree_block( blk->magic =XFS_DA_NODE_MAGIC ; node = blk->bp->b_addr;xfs_da3_node_hdr_from_disk (ip->i_mount, &nodehdr, node); - btree = ip->d_ops->node_tree_p (node); + btree = nodehdr.btree; *pmaxrecs = nodehdr.count; blk->hashval =be32_to_cpu (btree[*pmaxrecs -1 ].hashval);if (level ==0 ) {
fs/xfs/xfs_attr_inactive.c +16 -18
@@ -190,19 +190,17 @@ xfs_attr3_leaf_inactive(*/ STATIC intxfs_attr3_node_inactive ( -struct xfs_trans **trans, -struct xfs_inode *dp, -struct xfs_buf *bp, -int level) +struct xfs_trans **trans, +struct xfs_inode *dp, +struct xfs_buf *bp, +int level) { -xfs_da_blkinfo_t *info; -xfs_da_intnode_t *node; -xfs_dablk_t child_fsb; -xfs_daddr_t parent_blkno, child_blkno; -int error, i; -struct xfs_buf *child_bp; -struct xfs_da_node_entry *btree; +struct xfs_da_blkinfo *info; +xfs_dablk_t child_fsb; +xfs_daddr_t parent_blkno, child_blkno; +struct xfs_buf *child_bp;struct xfs_da3_icnode_hdr ichdr; +int error, i;/* * Since this code is recursive (gasp!) we must protect ourselves.
@@ -212,15 +210,13 @@ xfs_attr3_node_inactive(return -EFSCORRUPTED ; } - node = bp->b_addr; -xfs_da3_node_hdr_from_disk (dp->i_mount, &ichdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &ichdr, bp->b_addr); parent_blkno = bp->b_bn;if (!ichdr.count) {xfs_trans_brelse (*trans, bp);return 0 ; } - btree = dp->d_ops->node_tree_p (node); - child_fsb =be32_to_cpu (btree[0 ].before); + child_fsb =be32_to_cpu (ichdr.btree[0 ].before);xfs_trans_brelse (*trans, bp);/* no locks for later trans */ /*
@@ -279,13 +275,15 @@ xfs_attr3_node_inactive(* child block number. */ if (i +1 < ichdr.count) { +struct xfs_da3_icnode_hdr phdr; + error =xfs_da3_node_read (*trans, dp,0 , parent_blkno, &bp,XFS_ATTR_FORK );if (error)return error; - node = bp->b_addr; - btree = dp->d_ops->node_tree_p (node); - child_fsb =be32_to_cpu (btree[i +1 ].before); +xfs_da3_node_hdr_from_disk (dp->i_mount, &phdr, + bp->b_addr); + child_fsb =be32_to_cpu (phdr.btree[i +1 ].before);xfs_trans_brelse (*trans, bp); }/*
fs/xfs/xfs_attr_list.c +1 -1
@@ -254,7 +254,7 @@ xfs_attr_node_list_lookup(else expected_level--; - btree = dp->d_ops->node_tree_p (node); + btree = nodehdr.btree;for (i =0 ; i < nodehdr.count; btree++, i++) {if (cursor->hashval <=be32_to_cpu (btree->hashval)) { cursor->blkno =be32_to_cpu (btree->before);
Signature · 1 line
2.20.1
Re: [PATCH 05/34] xfs: add a btree entries pointer to struct xfs_da3_icnode_hdr
Quoted 19 lines · Christoph Hellwig
All but two callers of the ->node_tree_p dir operation already have a
xfs_da3_icnode_hdrfrom a previous call toxfs_da3_node_hdr_from_diskat hand. Add a pointer to the btree entries to structxfs_da3_icnode_hdrto clean up this pattern. The two remaining callers now expand the whole header as well, but that isn't very expensive and not in a super hot path anyway.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_attr_leaf.c | 6 ++-- fs/xfs/libxfs/xfs_da_btree.c | 68 ++++++++++++++++------------------- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 21 ----------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/scrub/dabtree.c | 6 ++-- fs/xfs/xfs_attr_inactive.c | 34 +++++++++--------- fs/xfs/xfs_attr_list.c | 2 +- 8 files changed, 55 insertions(+), 85 deletions(-)
<snip>
fs/xfs/libxfs/xfs_da_btree.h struct xfs_da3_icnode_hdr { · line 138
Quoted 9 lines
fs/xfs/libxfs/xfs_da_btree.h +1
-0@@ -135,6 +135,7 @@ struct xfs_da3_icnode_hdr {uint16_t magic;uint16_t count;uint16_t level; +struct xfs_da_node_entry *btree;
This adds to the incore node header structure a pointer to raw disk structures, right? Can we make this a little more explicit by naming the field "raw_entries" or something?
--D
Quoted 193 lines
fs/xfs/libxfs/xfs_da_btree.h +0
-0};/* fs/xfs/libxfs/xfs_da_format.c +0
-21@@ -494,22 +494,6 @@ xfs_dir3_leaf_hdr_to_disk( hdr3->stale =cpu_to_be16 (from->stale); } - -/* -* Directory/Attribute Node block operations -*/ -static struct xfs_da_node_entry * -xfs_da2_node_tree_p (struct xfs_da_intnode *dap) -{ -return dap->__btree; -} - -static struct xfs_da_node_entry * -xfs_da3_node_tree_p (struct xfs_da_intnode *dap) -{ -return ((struct xfs_da3_intnode *)dap)->__btree; -} -/* * Directory free space block operations */ @@ -669,7 +653,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .leaf_ents_p = xfs_dir2_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk,@@ -717,7 +700,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .leaf_ents_p = xfs_dir2_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .node_tree_p = xfs_da2_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk,@@ -765,7 +747,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .leaf_ents_p = xfs_dir3_leaf_ents_p, .node_hdr_size = sizeof(struct xfs_da3_node_hdr), - .node_tree_p = xfs_da3_node_tree_p, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk,@@ -778,12 +759,10 @@ static const struct xfs_dir_ops xfs_dir3_ops = {static const struct xfs_dir_ops xfs_dir2_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da_node_hdr ), - .node_tree_p = xfs_da2_node_tree_p, };static const struct xfs_dir_ops xfs_dir3_nondir_ops = { .node_hdr_size =sizeof (struct xfs_da3_node_hdr ), - .node_tree_p = xfs_da3_node_tree_p, };/* fs/xfs/libxfs/xfs_dir2.h +0
-2@@ -82,8 +82,6 @@ struct xfs_dir_ops { (*leaf_ents_p)(struct xfs_dir2_leaf *lp);int node_hdr_size; -struct xfs_da_node_entry * - (*node_tree_p)(struct xfs_da_intnode *dap);int free_hdr_size; void (*free_hdr_to_disk)(struct xfs_dir2_free *to,fs/xfs/scrub/dabtree.c +4
-2@@ -83,10 +83,12 @@ xchk_da_btree_node_entry( int level) {struct xfs_da_state_blk *blk = &ds->state->path.blk[level]; +struct xfs_da3_icnode_hdr hdr;ASSERT (blk->magic ==XFS_DA_NODE_MAGIC ); -return (void *)ds->dargs.dp->d_ops->node_tree_p (blk->bp->b_addr) + +xfs_da3_node_hdr_from_disk (ds->sc->mp, &hdr, blk->bp->b_addr); +return (void *)hdr.btree + (blk->index *sizeof (struct xfs_da_node_entry )); }@@ -411,7 +413,7 @@ xchk_da_btree_block( blk->magic =XFS_DA_NODE_MAGIC ; node = blk->bp->b_addr;xfs_da3_node_hdr_from_disk (ip->i_mount, &nodehdr, node); - btree = ip->d_ops->node_tree_p (node); + btree = nodehdr.btree; *pmaxrecs = nodehdr.count; blk->hashval =be32_to_cpu (btree[*pmaxrecs -1 ].hashval);if (level ==0 ) {fs/xfs/xfs_attr_inactive.c +16
-18@@ -190,19 +190,17 @@ xfs_attr3_leaf_inactive(*/ STATIC intxfs_attr3_node_inactive ( -struct xfs_trans **trans, -struct xfs_inode *dp, -struct xfs_buf *bp, -int level) +struct xfs_trans **trans, +struct xfs_inode *dp, +struct xfs_buf *bp, +int level) { -xfs_da_blkinfo_t *info; -xfs_da_intnode_t *node; -xfs_dablk_t child_fsb; -xfs_daddr_t parent_blkno, child_blkno; -int error, i; -struct xfs_buf *child_bp; -struct xfs_da_node_entry *btree; +struct xfs_da_blkinfo *info; +xfs_dablk_t child_fsb; +xfs_daddr_t parent_blkno, child_blkno; +struct xfs_buf *child_bp;struct xfs_da3_icnode_hdr ichdr; +int error, i;/* * Since this code is recursive (gasp!) we must protect ourselves. @@ -212,15 +210,13 @@ xfs_attr3_node_inactive(return -EFSCORRUPTED ; } - node = bp->b_addr; -xfs_da3_node_hdr_from_disk (dp->i_mount, &ichdr, node); +xfs_da3_node_hdr_from_disk (dp->i_mount, &ichdr, bp->b_addr); parent_blkno = bp->b_bn;if (!ichdr.count) {xfs_trans_brelse (*trans, bp);return 0 ; } - btree = dp->d_ops->node_tree_p (node); - child_fsb =be32_to_cpu (btree[0 ].before); + child_fsb =be32_to_cpu (ichdr.btree[0 ].before);xfs_trans_brelse (*trans, bp);/* no locks for later trans */ /* @@ -279,13 +275,15 @@ xfs_attr3_node_inactive(* child block number. */ if (i +1 < ichdr.count) { +struct xfs_da3_icnode_hdr phdr; + error =xfs_da3_node_read (*trans, dp,0 , parent_blkno, &bp,XFS_ATTR_FORK );if (error)return error; - node = bp->b_addr; - btree = dp->d_ops->node_tree_p (node); - child_fsb =be32_to_cpu (btree[i +1 ].before); +xfs_da3_node_hdr_from_disk (dp->i_mount, &phdr, + bp->b_addr); + child_fsb =be32_to_cpu (phdr.btree[i +1 ].before);xfs_trans_brelse (*trans, bp); }/* fs/xfs/xfs_attr_list.c +1
-1@@ -254,7 +254,7 @@ xfs_attr_node_list_lookup(else expected_level--; - btree = dp->d_ops->node_tree_p (node); + btree = nodehdr.btree;for (i =0 ; i < nodehdr.count; btree++, i++) {if (cursor->hashval <=be32_to_cpu (btree->hashval)) { cursor->blkno =be32_to_cpu (btree->before);Signature · 1 line
2.20.1
Re: [PATCH 05/34] xfs: add a btree entries pointer to struct xfs_da3_icnode_hdr
Quoted 23 lines · Darrick J. Wong
Quoted 19 lines · Christoph Hellwig
All but two callers of the ->node_tree_p dir operation already have a
xfs_da3_icnode_hdrfrom a previous call toxfs_da3_node_hdr_from_diskat hand. Add a pointer to the btree entries to structxfs_da3_icnode_hdrto clean up this pattern. The two remaining callers now expand the whole header as well, but that isn't very expensive and not in a super hot path anyway.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_attr_leaf.c | 6 ++-- fs/xfs/libxfs/xfs_da_btree.c | 68 ++++++++++++++++------------------- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 21 ----------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/scrub/dabtree.c | 6 ++-- fs/xfs/xfs_attr_inactive.c | 34 +++++++++--------- fs/xfs/xfs_attr_list.c | 2 +- 8 files changed, 55 insertions(+), 85 deletions(-)<snip>
Quoted 13 lines
fs/xfs/libxfs/xfs_da_btree.h struct xfs_da3_icnode_hdr { · line 138
Quoted 9 lines
fs/xfs/libxfs/xfs_da_btree.h +1
-0@@ -135,6 +135,7 @@ struct xfs_da3_icnode_hdr {uint16_t magic;uint16_t count;uint16_t level; +struct xfs_da_node_entry *btree;This adds to the incore node header structure a pointer to raw disk structures, right? Can we make this a little more explicit by naming the field "
raw_entries" or something?
Hmm, is that really so much of an issue? Even something that a comment wouldn't help? I'd kinda hate making identifiers extremely long, but if that's what is needed I can change it. Same for the other patches doing something similar.
Re: [PATCH 05/34] xfs: add a btree entries pointer to struct xfs_da3_icnode_hdr
Quoted 38 lines · Christoph Hellwig
Quoted 23 lines · Darrick J. Wong
Quoted 19 lines · Christoph Hellwig
All but two callers of the ->node_tree_p dir operation already have a
xfs_da3_icnode_hdrfrom a previous call toxfs_da3_node_hdr_from_diskat hand. Add a pointer to the btree entries to structxfs_da3_icnode_hdrto clean up this pattern. The two remaining callers now expand the whole header as well, but that isn't very expensive and not in a super hot path anyway.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_attr_leaf.c | 6 ++-- fs/xfs/libxfs/xfs_da_btree.c | 68 ++++++++++++++++------------------- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 21 ----------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/scrub/dabtree.c | 6 ++-- fs/xfs/xfs_attr_inactive.c | 34 +++++++++--------- fs/xfs/xfs_attr_list.c | 2 +- 8 files changed, 55 insertions(+), 85 deletions(-)<snip>
Quoted 13 lines
fs/xfs/libxfs/xfs_da_btree.h struct xfs_da3_icnode_hdr { · line 138
Quoted 9 lines
fs/xfs/libxfs/xfs_da_btree.h +1
-0@@ -135,6 +135,7 @@ struct xfs_da3_icnode_hdr {uint16_t magic;uint16_t count;uint16_t level; +struct xfs_da_node_entry *btree;This adds to the incore node header structure a pointer to raw disk structures, right? Can we make this a little more explicit by naming the field "
raw_entries" or something?
Quoted 4 lines
Hmm, is that really so much of an issue? Even something that a comment wouldn't help? I'd kinda hate making identifiers extremely long, but if that's what is needed I can change it. Same for the other patches doing something similar.
<shrug> I think a comment would work. Or just "__btree"...?
--D
PATCH 6/34 xfs: move the node header size to struct xfs_da_geometry
In reply to Christoph HellwigMove the node header size field to struct xfs_da_geometry, and remove the now unused non-directory dir ops infrastructure.
--- fs/xfs/libxfs/xfs_da_btree.c | 14 ++++++++------ fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 28 ---------------------------- fs/xfs/libxfs/xfs_dir2.c | 12 +++++++----- fs/xfs/libxfs/xfs_dir2.h | 4 ---- fs/xfs/xfs_iops.c | 1 - fs/xfs/xfs_mount.h | 1 - 7 files changed, 16 insertions(+), 45 deletions(-)
fs/xfs/libxfs/xfs_da_btree.c +8 -6
@@ -414,7 +414,7 @@ xfs_da3_node_create(xfs_da3_node_hdr_to_disk (dp->i_mount, node, &ichdr);xfs_trans_log_buf (tp, bp, -XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size)); +XFS_DA_LOGRANGE (node, &node->hdr, args->geo->node_hdr_size)); *bpp = bp;return 0 ;
@@ -920,12 +920,13 @@ xfs_da3_node_rebalance(*/ xfs_da3_node_hdr_to_disk (dp->i_mount, node1, &nodehdr1);xfs_trans_log_buf (tp, blk1->bp, -XFS_DA_LOGRANGE (node1, &node1->hdr, dp->d_ops->node_hdr_size)); +XFS_DA_LOGRANGE (node1, &node1->hdr, + state->args->geo->node_hdr_size));xfs_da3_node_hdr_to_disk (dp->i_mount, node2, &nodehdr2);xfs_trans_log_buf (tp, blk2->bp,XFS_DA_LOGRANGE (node2, &node2->hdr, - dp->d_ops->node_hdr_size + + state->args->geo->node_hdr_size + (sizeof (btree2[0 ]) * nodehdr2.count)));/*
@@ -996,7 +997,8 @@ xfs_da3_node_add( nodehdr.count +=1 ;xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);xfs_trans_log_buf (state->args->trans, oldblk->bp, -XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size)); +XFS_DA_LOGRANGE (node, &node->hdr, + state->args->geo->node_hdr_size));/* * Copy the last hash value from the oldblk to propagate upwards.
@@ -1426,7 +1428,7 @@ xfs_da3_node_remove( nodehdr.count -=1 ;xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);xfs_trans_log_buf (state->args->trans, drop_blk->bp, -XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size)); +XFS_DA_LOGRANGE (node, &node->hdr, state->args->geo->node_hdr_size));/* * Copy the last hash value from the block to propagate upwards.
@@ -1499,7 +1501,7 @@ xfs_da3_node_unbalance(xfs_da3_node_hdr_to_disk (dp->i_mount, save_node, &save_hdr);xfs_trans_log_buf (tp, save_blk->bp,XFS_DA_LOGRANGE (save_node, &save_node->hdr, - dp->d_ops->node_hdr_size)); + state->args->geo->node_hdr_size));/* * Save the last hashval in the remaining block for upward propagation.
fs/xfs/libxfs/xfs_da_btree.h +1 -0
@@ -22,6 +22,7 @@ struct xfs_da_geometry {int fsbcount;/* da block size in filesystem blocks */ uint8_t fsblog;/* log2 of _filesystem_ block size */ uint8_t blklog;/* log2 of da block size */ +int node_hdr_size;/* danode header size in bytes */ uint node_ents;/* # of entries in a danode */ int magicpct;/* 37% of block size in bytes */ xfs_dablk_t datablk;/* blockno of dir data v2 */
fs/xfs/libxfs/xfs_da_format.c +0 -28
@@ -652,8 +652,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p, - .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,
@@ -699,8 +697,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p, - .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,
@@ -746,8 +742,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .leaf_max_ents = xfs_dir3_max_leaf_ents, .leaf_ents_p = xfs_dir3_leaf_ents_p, - .node_hdr_size = sizeof(struct xfs_da3_node_hdr), - .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir3_free_hdr_from_disk,
@@ -757,14 +751,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .db_to_fdindex = xfs_dir3_db_to_fdindex, }; -static const struct xfs_dir_ops xfs_dir2_nondir_ops = { - .node_hdr_size =sizeof (struct xfs_da_node_hdr ), -}; - -static const struct xfs_dir_ops xfs_dir3_nondir_ops = { - .node_hdr_size =sizeof (struct xfs_da3_node_hdr ), -}; -/* * Return the ops structure according to the current config. If we are passed * an inode, then that overrides the default config we use which is based on
@@ -785,17 +771,3 @@ xfs_dir_get_ops(return &xfs_dir2_ftype_ops;return &xfs_dir2_ops; } - -const struct xfs_dir_ops * -xfs_nondir_get_ops ( -struct xfs_mount *mp, -struct xfs_inode *dp) -{ -if (dp) -return dp->d_ops; -if (mp->m_nondir_inode_ops) -return mp->m_nondir_inode_ops; -if (xfs_sb_version_hascrc (&mp->m_sb)) -return &xfs_dir3_nondir_ops; -return &xfs_dir2_nondir_ops; -}
fs/xfs/libxfs/xfs_dir2.c +7 -5
@@ -99,16 +99,13 @@ xfs_da_mount( struct xfs_mount *mp) {struct xfs_da_geometry *dageo; -int nodehdr_size;ASSERT (mp->m_sb.sb_versionnum &XFS_SB_VERSION_DIRV2BIT );ASSERT (xfs_dir2_dirblock_bytes (&mp->m_sb) <=XFS_MAX_BLOCKSIZE ); mp->m_dir_inode_ops =xfs_dir_get_ops (mp,NULL ); - mp->m_nondir_inode_ops =xfs_nondir_get_ops (mp,NULL ); - nodehdr_size = mp->m_dir_inode_ops->node_hdr_size; mp->m_dir_geo =kmem_zalloc (sizeof (struct xfs_da_geometry ),KM_MAYFAIL ); mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
@@ -125,6 +122,10 @@ xfs_da_mount( dageo->fsblog = mp->m_sb.sb_blocklog; dageo->blksize =xfs_dir2_dirblock_bytes (&mp->m_sb); dageo->fsbcount =1 << mp->m_sb.sb_dirblklog; +if (xfs_sb_version_hascrc (&mp->m_sb)) + dageo->node_hdr_size =sizeof (struct xfs_da3_node_hdr ); +else + dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr );/* * Now we've set up the block conversion variables, we can calculate the
@@ -133,7 +134,7 @@ xfs_da_mount( dageo->datablk =xfs_dir2_byte_to_da (dageo,XFS_DIR2_DATA_OFFSET ); dageo->leafblk =xfs_dir2_byte_to_da (dageo,XFS_DIR2_LEAF_OFFSET ); dageo->freeblk =xfs_dir2_byte_to_da (dageo,XFS_DIR2_FREE_OFFSET ); - dageo->node_ents = (dageo->blksize - nodehdr_size) / + dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) / (uint )sizeof (xfs_da_node_entry_t); dageo->magicpct = (dageo->blksize *37 ) /100 ;
@@ -143,7 +144,8 @@ xfs_da_mount( dageo->fsblog = mp->m_sb.sb_blocklog; dageo->blksize =1 << dageo->blklog; dageo->fsbcount =1 ; - dageo->node_ents = (dageo->blksize - nodehdr_size) / + dageo->node_hdr_size = mp->m_dir_geo->node_hdr_size; + dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) / (uint )sizeof (xfs_da_node_entry_t); dageo->magicpct = (dageo->blksize *37 ) /100 ;
fs/xfs/libxfs/xfs_dir2.h +0 -4
@@ -81,8 +81,6 @@ struct xfs_dir_ops {struct xfs_dir2_leaf_entry * (*leaf_ents_p)(struct xfs_dir2_leaf *lp); -int node_hdr_size; -int free_hdr_size;void (*free_hdr_to_disk)(struct xfs_dir2_free *to,struct xfs_dir3_icfree_hdr *from);
@@ -98,8 +96,6 @@ struct xfs_dir_ops {extern const struct xfs_dir_ops *xfs_dir_get_ops (struct xfs_mount *mp,struct xfs_inode *dp); -extern const struct xfs_dir_ops * -xfs_nondir_get_ops (struct xfs_mount *mp,struct xfs_inode *dp);/* * Generic directory interface routines
fs/xfs/xfs_iops.c +0 -1
@@ -1319,7 +1319,6 @@ xfs_setup_inode(lockdep_set_class (&ip->i_lock.mr_lock, &xfs_dir_ilock_class); ip->d_ops = ip->i_mount->m_dir_inode_ops; }else { - ip->d_ops = ip->i_mount->m_nondir_inode_ops;lockdep_set_class (&ip->i_lock.mr_lock, &xfs_nondir_ilock_class); }
fs/xfs/xfs_mount.h +0 -1
@@ -159,7 +159,6 @@ typedef struct xfs_mount {uint8_t m_sectbb_log;/* sectlog - BBSHIFT */ const struct xfs_nameops *m_dirnameops;/* vector of dir name ops */ const struct xfs_dir_ops *m_dir_inode_ops;/* vector of dir inode ops */ -const struct xfs_dir_ops *m_nondir_inode_ops;/* !dir inode ops */ uint m_chsize;/* size of next field */ atomic_t m_active_trans;/* number trans frozen */ struct xfs_mru_cache *m_filestream;/* per-mount filestream data */
Signature · 1 line
2.20.1
Re: [PATCH 06/34] xfs: move the node header size to struct xfs_da_geometry
Quoted 4 lines · Christoph Hellwig
Move the node header size field to struct
xfs_da_geometry, and remove the now unused non-directory dir ops infrastructure.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 243 lines
--- fs/xfs/libxfs/xfs_da_btree.c | 14 ++++++++------ fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 28 ---------------------------- fs/xfs/libxfs/xfs_dir2.c | 12 +++++++----- fs/xfs/libxfs/xfs_dir2.h | 4 ---- fs/xfs/xfs_iops.c | 1 - fs/xfs/xfs_mount.h | 1 - 7 files changed, 16 insertions(+), 45 deletions(-)fs/xfs/libxfs/xfs_da_btree.c +8
-6@@ -414,7 +414,7 @@ xfs_da3_node_create(xfs_da3_node_hdr_to_disk (dp->i_mount, node, &ichdr);xfs_trans_log_buf (tp, bp, -XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size)); +XFS_DA_LOGRANGE (node, &node->hdr, args->geo->node_hdr_size)); *bpp = bp;return 0 ;@@ -920,12 +920,13 @@ xfs_da3_node_rebalance(*/ xfs_da3_node_hdr_to_disk (dp->i_mount, node1, &nodehdr1);xfs_trans_log_buf (tp, blk1->bp, -XFS_DA_LOGRANGE (node1, &node1->hdr, dp->d_ops->node_hdr_size)); +XFS_DA_LOGRANGE (node1, &node1->hdr, + state->args->geo->node_hdr_size));xfs_da3_node_hdr_to_disk (dp->i_mount, node2, &nodehdr2);xfs_trans_log_buf (tp, blk2->bp,XFS_DA_LOGRANGE (node2, &node2->hdr, - dp->d_ops->node_hdr_size + + state->args->geo->node_hdr_size + (sizeof (btree2[0 ]) * nodehdr2.count)));/* @@ -996,7 +997,8 @@ xfs_da3_node_add( nodehdr.count +=1 ;xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);xfs_trans_log_buf (state->args->trans, oldblk->bp, -XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size)); +XFS_DA_LOGRANGE (node, &node->hdr, + state->args->geo->node_hdr_size));/* * Copy the last hash value from the oldblk to propagate upwards. @@ -1426,7 +1428,7 @@ xfs_da3_node_remove( nodehdr.count -=1 ;xfs_da3_node_hdr_to_disk (dp->i_mount, node, &nodehdr);xfs_trans_log_buf (state->args->trans, drop_blk->bp, -XFS_DA_LOGRANGE (node, &node->hdr, dp->d_ops->node_hdr_size)); +XFS_DA_LOGRANGE (node, &node->hdr, state->args->geo->node_hdr_size));/* * Copy the last hash value from the block to propagate upwards. @@ -1499,7 +1501,7 @@ xfs_da3_node_unbalance(xfs_da3_node_hdr_to_disk (dp->i_mount, save_node, &save_hdr);xfs_trans_log_buf (tp, save_blk->bp,XFS_DA_LOGRANGE (save_node, &save_node->hdr, - dp->d_ops->node_hdr_size)); + state->args->geo->node_hdr_size));/* * Save the last hashval in the remaining block for upward propagation. fs/xfs/libxfs/xfs_da_btree.h +1
-0@@ -22,6 +22,7 @@ struct xfs_da_geometry {int fsbcount;/* da block size in filesystem blocks */ uint8_t fsblog;/* log2 of _filesystem_ block size */ uint8_t blklog;/* log2 of da block size */ +int node_hdr_size;/* danode header size in bytes */ uint node_ents;/* # of entries in a danode */ int magicpct;/* 37% of block size in bytes */ xfs_dablk_t datablk;/* blockno of dir data v2 */ fs/xfs/libxfs/xfs_da_format.c +0
-28@@ -652,8 +652,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p, - .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,@@ -699,8 +697,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p, - .node_hdr_size = sizeof(struct xfs_da_node_hdr), - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,@@ -746,8 +742,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .leaf_max_ents = xfs_dir3_max_leaf_ents, .leaf_ents_p = xfs_dir3_leaf_ents_p, - .node_hdr_size = sizeof(struct xfs_da3_node_hdr), - .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir3_free_hdr_from_disk,@@ -757,14 +751,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .db_to_fdindex = xfs_dir3_db_to_fdindex, }; -static const struct xfs_dir_ops xfs_dir2_nondir_ops = { - .node_hdr_size =sizeof (struct xfs_da_node_hdr ), -}; - -static const struct xfs_dir_ops xfs_dir3_nondir_ops = { - .node_hdr_size =sizeof (struct xfs_da3_node_hdr ), -}; -/* * Return the ops structure according to the current config. If we are passed * an inode, then that overrides the default config we use which is based on @@ -785,17 +771,3 @@ xfs_dir_get_ops(return &xfs_dir2_ftype_ops;return &xfs_dir2_ops; } - -const struct xfs_dir_ops * -xfs_nondir_get_ops ( -struct xfs_mount *mp, -struct xfs_inode *dp) -{ -if (dp) -return dp->d_ops; -if (mp->m_nondir_inode_ops) -return mp->m_nondir_inode_ops; -if (xfs_sb_version_hascrc (&mp->m_sb)) -return &xfs_dir3_nondir_ops; -return &xfs_dir2_nondir_ops; -}fs/xfs/libxfs/xfs_dir2.c +7
-5@@ -99,16 +99,13 @@ xfs_da_mount( struct xfs_mount *mp) {struct xfs_da_geometry *dageo; -int nodehdr_size;ASSERT (mp->m_sb.sb_versionnum &XFS_SB_VERSION_DIRV2BIT );ASSERT (xfs_dir2_dirblock_bytes (&mp->m_sb) <=XFS_MAX_BLOCKSIZE ); mp->m_dir_inode_ops =xfs_dir_get_ops (mp,NULL ); - mp->m_nondir_inode_ops =xfs_nondir_get_ops (mp,NULL ); - nodehdr_size = mp->m_dir_inode_ops->node_hdr_size; mp->m_dir_geo =kmem_zalloc (sizeof (struct xfs_da_geometry ),KM_MAYFAIL ); mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),@@ -125,6 +122,10 @@ xfs_da_mount( dageo->fsblog = mp->m_sb.sb_blocklog; dageo->blksize =xfs_dir2_dirblock_bytes (&mp->m_sb); dageo->fsbcount =1 << mp->m_sb.sb_dirblklog; +if (xfs_sb_version_hascrc (&mp->m_sb)) + dageo->node_hdr_size =sizeof (struct xfs_da3_node_hdr ); +else + dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr );/* * Now we've set up the block conversion variables, we can calculate the @@ -133,7 +134,7 @@ xfs_da_mount( dageo->datablk =xfs_dir2_byte_to_da (dageo,XFS_DIR2_DATA_OFFSET ); dageo->leafblk =xfs_dir2_byte_to_da (dageo,XFS_DIR2_LEAF_OFFSET ); dageo->freeblk =xfs_dir2_byte_to_da (dageo,XFS_DIR2_FREE_OFFSET ); - dageo->node_ents = (dageo->blksize - nodehdr_size) / + dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) / (uint )sizeof (xfs_da_node_entry_t); dageo->magicpct = (dageo->blksize *37 ) /100 ;@@ -143,7 +144,8 @@ xfs_da_mount( dageo->fsblog = mp->m_sb.sb_blocklog; dageo->blksize =1 << dageo->blklog; dageo->fsbcount =1 ; - dageo->node_ents = (dageo->blksize - nodehdr_size) / + dageo->node_hdr_size = mp->m_dir_geo->node_hdr_size; + dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) / (uint )sizeof (xfs_da_node_entry_t); dageo->magicpct = (dageo->blksize *37 ) /100 ;fs/xfs/libxfs/xfs_dir2.h +0
-4@@ -81,8 +81,6 @@ struct xfs_dir_ops {struct xfs_dir2_leaf_entry * (*leaf_ents_p)(struct xfs_dir2_leaf *lp); -int node_hdr_size; -int free_hdr_size;void (*free_hdr_to_disk)(struct xfs_dir2_free *to,struct xfs_dir3_icfree_hdr *from);@@ -98,8 +96,6 @@ struct xfs_dir_ops {extern const struct xfs_dir_ops *xfs_dir_get_ops (struct xfs_mount *mp,struct xfs_inode *dp); -extern const struct xfs_dir_ops * -xfs_nondir_get_ops (struct xfs_mount *mp,struct xfs_inode *dp);/* * Generic directory interface routines fs/xfs/xfs_iops.c +0
-1@@ -1319,7 +1319,6 @@ xfs_setup_inode(lockdep_set_class (&ip->i_lock.mr_lock, &xfs_dir_ilock_class); ip->d_ops = ip->i_mount->m_dir_inode_ops; }else { - ip->d_ops = ip->i_mount->m_nondir_inode_ops;lockdep_set_class (&ip->i_lock.mr_lock, &xfs_nondir_ilock_class); }fs/xfs/xfs_mount.h +0
-1@@ -159,7 +159,6 @@ typedef struct xfs_mount {uint8_t m_sectbb_log;/* sectlog - BBSHIFT */ const struct xfs_nameops *m_dirnameops;/* vector of dir name ops */ const struct xfs_dir_ops *m_dir_inode_ops;/* vector of dir inode ops */ -const struct xfs_dir_ops *m_nondir_inode_ops;/* !dir inode ops */ uint m_chsize;/* size of next field */ atomic_t m_active_trans;/* number trans frozen */ struct xfs_mru_cache *m_filestream;/* per-mount filestream data */ Signature · 1 line
2.20.1
PATCH 7/34 xfs: devirtualize ->leaf_hdr_from_disk
In reply to Christoph HellwigReplace the ->leaf_hdr_from_disk dir ops method with a directly called xfs_dir2_leaf_hdr_from_disk helper that takes care of the differences between the v4 and v5 on-disk format.
--- fs/xfs/libxfs/xfs_da_btree.c | 5 ++-- fs/xfs/libxfs/xfs_da_format.c | 35 -------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_leaf.c | 45 ++++++++++++++++++++++++++++------ fs/xfs/libxfs/xfs_dir2_node.c | 28 ++++++++++----------- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/scrub/dir.c | 2 +- 8 files changed, 58 insertions(+), 63 deletions(-)
fs/xfs/libxfs/xfs_da_btree.c +3 -2
@@ -641,7 +641,7 @@ xfs_da3_root_split(struct xfs_dir2_leaf_entry *ents; leaf = (xfs_dir2_leaf_t *)oldroot; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf); ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC ||
@@ -2283,7 +2283,8 @@ xfs_da3_swap_lastblock(struct xfs_dir2_leaf_entry *ents; dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, dead_leaf2); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, + dead_leaf2); ents = dp->d_ops->leaf_ents_p (dead_leaf2); dead_level =0 ; dead_hash =be32_to_cpu (ents[leafhdr.count -1 ].hashval);
fs/xfs/libxfs/xfs_da_format.c +0 -35
@@ -430,21 +430,6 @@ xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp)return ((struct xfs_dir3_leaf *)lp)->__ents; } -static void -xfs_dir2_leaf_hdr_from_disk ( -struct xfs_dir3_icleaf_hdr *to, -struct xfs_dir2_leaf *from) -{ - to->forw =be32_to_cpu (from->hdr.info.forw); - to->back =be32_to_cpu (from->hdr.info.back); - to->magic =be16_to_cpu (from->hdr.info.magic); - to->count =be16_to_cpu (from->hdr.count); - to->stale =be16_to_cpu (from->hdr.stale); - -ASSERT (to->magic ==XFS_DIR2_LEAF1_MAGIC || - to->magic ==XFS_DIR2_LEAFN_MAGIC ); -} - static void xfs_dir2_leaf_hdr_to_disk( struct xfs_dir2_leaf *to,
@@ -460,23 +445,6 @@ xfs_dir2_leaf_hdr_to_disk( to->hdr.stale =cpu_to_be16 (from->stale); } -static void -xfs_dir3_leaf_hdr_from_disk ( -struct xfs_dir3_icleaf_hdr *to, -struct xfs_dir2_leaf *from) -{ -struct xfs_dir3_leaf_hdr *hdr3 = (struct xfs_dir3_leaf_hdr *)from; - - to->forw =be32_to_cpu (hdr3->info.hdr.forw); - to->back =be32_to_cpu (hdr3->info.hdr.back); - to->magic =be16_to_cpu (hdr3->info.hdr.magic); - to->count =be16_to_cpu (hdr3->count); - to->stale =be16_to_cpu (hdr3->stale); - -ASSERT (to->magic ==XFS_DIR3_LEAF1_MAGIC || - to->magic ==XFS_DIR3_LEAFN_MAGIC ); -} - static void xfs_dir3_leaf_hdr_to_disk( struct xfs_dir2_leaf *to,
@@ -648,7 +616,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk, - .leaf_hdr_from_disk = xfs_dir2_leaf_hdr_from_disk, .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p,
@@ -693,7 +660,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk, - .leaf_hdr_from_disk = xfs_dir2_leaf_hdr_from_disk, .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p,
@@ -738,7 +704,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr), .leaf_hdr_to_disk = xfs_dir3_leaf_hdr_to_disk, - .leaf_hdr_from_disk = xfs_dir3_leaf_hdr_from_disk, .leaf_max_ents = xfs_dir3_max_leaf_ents, .leaf_ents_p = xfs_dir3_leaf_ents_p,
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -75,8 +75,6 @@ struct xfs_dir_ops {int leaf_hdr_size;void (*leaf_hdr_to_disk)(struct xfs_dir2_leaf *to,struct xfs_dir3_icleaf_hdr *from); -void (*leaf_hdr_from_disk)(struct xfs_dir3_icleaf_hdr *to, -struct xfs_dir2_leaf *from);int (*leaf_max_ents)(struct xfs_da_geometry *geo);struct xfs_dir2_leaf_entry * (*leaf_ents_p)(struct xfs_dir2_leaf *lp);
fs/xfs/libxfs/xfs_dir2_block.c +1 -1
@@ -923,7 +923,7 @@ xfs_dir2_leaf_to_block( tp = args->trans; mp = dp->i_mount; leaf = lbp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf); ltp =xfs_dir2_leaf_tail_p (args->geo, leaf);
fs/xfs/libxfs/xfs_dir2_leaf.c +37 -8
99 lines not on this page · raw message
fs/xfs/libxfs/xfs_dir2_node.c +14 -14
@@ -45,7 +45,7 @@ xfs_dir3_leafn_check(struct xfs_dir2_leaf *leaf = bp->b_addr;struct xfs_dir3_icleaf_hdr leafhdr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf);if (leafhdr.magic ==XFS_DIR3_LEAFN_MAGIC ) {struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr;
@@ -438,7 +438,7 @@ xfs_dir2_leafn_add(trace_xfs_dir2_leafn_add (args, index); - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);/*
@@ -534,7 +534,7 @@ xfs_dir2_leaf_lasthash(struct xfs_dir2_leaf_entry *ents;struct xfs_dir3_icleaf_hdr leafhdr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC || leafhdr.magic == XFS_DIR3_LEAFN_MAGIC ||
@@ -583,7 +583,7 @@ xfs_dir2_leafn_lookup_for_addname( tp = args->trans; mp = dp->i_mount; leaf = bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);xfs_dir3_leaf_check (dp, bp);
@@ -735,7 +735,7 @@ xfs_dir2_leafn_lookup_for_entry( tp = args->trans; mp = dp->i_mount; leaf = bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);xfs_dir3_leaf_check (dp, bp);
@@ -971,8 +971,8 @@ xfs_dir2_leafn_order(struct xfs_dir3_icleaf_hdr hdr1;struct xfs_dir3_icleaf_hdr hdr2; - dp->d_ops->leaf_hdr_from_disk (&hdr1, leaf1); - dp->d_ops->leaf_hdr_from_disk (&hdr2, leaf2); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr1, leaf1); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr2, leaf2); ents1 = dp->d_ops->leaf_ents_p (leaf1); ents2 = dp->d_ops->leaf_ents_p (leaf2);
@@ -1024,8 +1024,8 @@ xfs_dir2_leafn_rebalance( leaf1 = blk1->bp->b_addr; leaf2 = blk2->bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&hdr1, leaf1); - dp->d_ops->leaf_hdr_from_disk (&hdr2, leaf2); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr1, leaf1); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr2, leaf2); ents1 = dp->d_ops->leaf_ents_p (leaf1); ents2 = dp->d_ops->leaf_ents_p (leaf2);
@@ -1222,7 +1222,7 @@ xfs_dir2_leafn_remove( dp = args->dp; tp = args->trans; leaf = bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);/*
@@ -1444,7 +1444,7 @@ xfs_dir2_leafn_toosmall(*/ blk = &state->path.blk[state->path.active -1 ]; leaf = blk->bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);xfs_dir3_leaf_check (dp, blk->bp);
@@ -1507,7 +1507,7 @@ xfs_dir2_leafn_toosmall( (state->args->geo->blksize >>2 ); leaf = bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&hdr2, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr2, leaf); ents = dp->d_ops->leaf_ents_p (leaf); count += hdr2.count - hdr2.stale; bytes -= count *sizeof (ents[0 ]);
@@ -1570,8 +1570,8 @@ xfs_dir2_leafn_unbalance( drop_leaf = drop_blk->bp->b_addr; save_leaf = save_blk->bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&savehdr, save_leaf); - dp->d_ops->leaf_hdr_from_disk (&drophdr, drop_leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &savehdr, save_leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &drophdr, drop_leaf); sents = dp->d_ops->leaf_ents_p (save_leaf); dents = dp->d_ops->leaf_ents_p (drop_leaf);
fs/xfs/libxfs/xfs_dir2_priv.h +2 -0
@@ -67,6 +67,8 @@ extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, struct xfs_buf **bpp);/* xfs_dir2_leaf.c */ +void xfs_dir2_leaf_hdr_from_disk (struct xfs_mount *mp, +struct xfs_dir3_icleaf_hdr *to,struct xfs_dir2_leaf *from);extern int xfs_dir3_leaf_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t fbno,xfs_daddr_t mappedbno,struct xfs_buf **bpp); extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
fs/xfs/scrub/dir.c +1 -1
@@ -504,7 +504,7 @@ xchk_directory_leaf1_bestfree(xchk_buffer_recheck (sc, bp); leaf = bp->b_addr; - d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (sc->ip->i_mount, &leafhdr, leaf); ents = d_ops->leaf_ents_p (leaf); ltp =xfs_dir2_leaf_tail_p (geo, leaf); bestcount =be32_to_cpu (ltp->bestcount);
Signature · 1 line
2.20.1
Re: [PATCH 07/34] xfs: devirtualize ->leaf_hdr_from_disk
Quoted 5 lines · Christoph Hellwig
Replace the ->leaf_hdr_from_disk dir ops method with a directly called
xfs_dir2_leaf_hdr_from_diskhelper that takes care of the differences between the v4 and v5 on-disk format.Signed-off-by Christoph Hellwig <[email protected]>
Mmmm nice cleanup,
--D
Quoted 384 lines
--- fs/xfs/libxfs/xfs_da_btree.c | 5 ++-- fs/xfs/libxfs/xfs_da_format.c | 35 -------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_leaf.c | 45 ++++++++++++++++++++++++++++------ fs/xfs/libxfs/xfs_dir2_node.c | 28 ++++++++++----------- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/scrub/dir.c | 2 +- 8 files changed, 58 insertions(+), 63 deletions(-)fs/xfs/libxfs/xfs_da_btree.c +3
-2@@ -641,7 +641,7 @@ xfs_da3_root_split(struct xfs_dir2_leaf_entry *ents; leaf = (xfs_dir2_leaf_t *)oldroot; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf); ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC ||@@ -2283,7 +2283,8 @@ xfs_da3_swap_lastblock(struct xfs_dir2_leaf_entry *ents; dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, dead_leaf2); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, + dead_leaf2); ents = dp->d_ops->leaf_ents_p (dead_leaf2); dead_level =0 ; dead_hash =be32_to_cpu (ents[leafhdr.count -1 ].hashval);fs/xfs/libxfs/xfs_da_format.c +0
-35@@ -430,21 +430,6 @@ xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp)return ((struct xfs_dir3_leaf *)lp)->__ents; } -static void -xfs_dir2_leaf_hdr_from_disk ( -struct xfs_dir3_icleaf_hdr *to, -struct xfs_dir2_leaf *from) -{ - to->forw =be32_to_cpu (from->hdr.info.forw); - to->back =be32_to_cpu (from->hdr.info.back); - to->magic =be16_to_cpu (from->hdr.info.magic); - to->count =be16_to_cpu (from->hdr.count); - to->stale =be16_to_cpu (from->hdr.stale); - -ASSERT (to->magic ==XFS_DIR2_LEAF1_MAGIC || - to->magic ==XFS_DIR2_LEAFN_MAGIC ); -} - static void xfs_dir2_leaf_hdr_to_disk( struct xfs_dir2_leaf *to,@@ -460,23 +445,6 @@ xfs_dir2_leaf_hdr_to_disk( to->hdr.stale =cpu_to_be16 (from->stale); } -static void -xfs_dir3_leaf_hdr_from_disk ( -struct xfs_dir3_icleaf_hdr *to, -struct xfs_dir2_leaf *from) -{ -struct xfs_dir3_leaf_hdr *hdr3 = (struct xfs_dir3_leaf_hdr *)from; - - to->forw =be32_to_cpu (hdr3->info.hdr.forw); - to->back =be32_to_cpu (hdr3->info.hdr.back); - to->magic =be16_to_cpu (hdr3->info.hdr.magic); - to->count =be16_to_cpu (hdr3->count); - to->stale =be16_to_cpu (hdr3->stale); - -ASSERT (to->magic ==XFS_DIR3_LEAF1_MAGIC || - to->magic ==XFS_DIR3_LEAFN_MAGIC ); -} - static void xfs_dir3_leaf_hdr_to_disk( struct xfs_dir2_leaf *to,@@ -648,7 +616,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk, - .leaf_hdr_from_disk = xfs_dir2_leaf_hdr_from_disk, .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p,@@ -693,7 +660,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk, - .leaf_hdr_from_disk = xfs_dir2_leaf_hdr_from_disk, .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p,@@ -738,7 +704,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr), .leaf_hdr_to_disk = xfs_dir3_leaf_hdr_to_disk, - .leaf_hdr_from_disk = xfs_dir3_leaf_hdr_from_disk, .leaf_max_ents = xfs_dir3_max_leaf_ents, .leaf_ents_p = xfs_dir3_leaf_ents_p,fs/xfs/libxfs/xfs_dir2.h +0
-2@@ -75,8 +75,6 @@ struct xfs_dir_ops {int leaf_hdr_size;void (*leaf_hdr_to_disk)(struct xfs_dir2_leaf *to,struct xfs_dir3_icleaf_hdr *from); -void (*leaf_hdr_from_disk)(struct xfs_dir3_icleaf_hdr *to, -struct xfs_dir2_leaf *from);int (*leaf_max_ents)(struct xfs_da_geometry *geo);struct xfs_dir2_leaf_entry * (*leaf_ents_p)(struct xfs_dir2_leaf *lp);fs/xfs/libxfs/xfs_dir2_block.c +1
-1@@ -923,7 +923,7 @@ xfs_dir2_leaf_to_block( tp = args->trans; mp = dp->i_mount; leaf = lbp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf); ltp =xfs_dir2_leaf_tail_p (args->geo, leaf);fs/xfs/libxfs/xfs_dir2_leaf.c +37
-8@@ -30,6 +30,35 @@ static void xfs_dir3_leaf_log_bests(struct xfs_da_args *args,static void xfs_dir3_leaf_log_tail (struct xfs_da_args *args,struct xfs_buf *bp); +void +xfs_dir2_leaf_hdr_from_disk ( +struct xfs_mount *mp, +struct xfs_dir3_icleaf_hdr *to, +struct xfs_dir2_leaf *from) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_dir3_leaf *from3 = (struct xfs_dir3_leaf *)from; + + to->forw =be32_to_cpu (from3->hdr.info.hdr.forw); + to->back =be32_to_cpu (from3->hdr.info.hdr.back); + to->magic =be16_to_cpu (from3->hdr.info.hdr.magic); + to->count =be16_to_cpu (from3->hdr.count); + to->stale =be16_to_cpu (from3->hdr.stale); + +ASSERT (to->magic ==XFS_DIR3_LEAF1_MAGIC || + to->magic ==XFS_DIR3_LEAFN_MAGIC ); + }else { + to->forw =be32_to_cpu (from->hdr.info.forw); + to->back =be32_to_cpu (from->hdr.info.back); + to->magic =be16_to_cpu (from->hdr.info.magic); + to->count =be16_to_cpu (from->hdr.count); + to->stale =be16_to_cpu (from->hdr.stale); + +ASSERT (to->magic ==XFS_DIR2_LEAF1_MAGIC || + to->magic ==XFS_DIR2_LEAFN_MAGIC ); + } +} +/* * Check the internal consistency of a leaf1 block. * Pop an assert if something is wrong. @@ -43,7 +72,7 @@ xfs_dir3_leaf1_check(struct xfs_dir2_leaf *leaf = bp->b_addr;struct xfs_dir3_icleaf_hdr leafhdr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf);if (leafhdr.magic ==XFS_DIR3_LEAF1_MAGIC ) {struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr;@@ -96,7 +125,7 @@ xfs_dir3_leaf_check_int( ops =xfs_dir_get_ops (mp, dp);if (!hdr) { - ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); hdr = &leafhdr; }@@ -381,7 +410,7 @@ xfs_dir2_block_to_leaf(/* * Set the counts in the leaf header. */ - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); leafhdr.count =be32_to_cpu (btp->count); leafhdr.stale =be32_to_cpu (btp->stale); dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr);@@ -608,7 +637,7 @@ xfs_dir2_leaf_addname( leaf = lbp->b_addr; ltp =xfs_dir2_leaf_tail_p (args->geo, leaf); ents = dp->d_ops->leaf_ents_p (leaf); - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); bestsp =xfs_dir2_leaf_bests_p (ltp); length = dp->d_ops->data_entsize (args->namelen);@@ -1197,7 +1226,7 @@ xfs_dir2_leaf_lookup_int( leaf = lbp->b_addr;xfs_dir3_leaf_check (dp, lbp); ents = dp->d_ops->leaf_ents_p (leaf); - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf);/* * Look for the first leaf entry with our hash value. @@ -1330,7 +1359,7 @@ xfs_dir2_leaf_removename( hdr = dbp->b_addr;xfs_dir3_data_check (dp, dbp); bf = dp->d_ops->data_bestfree_p (hdr); - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);/* * Point to the leaf entry, use that to point to the data entry. @@ -1509,7 +1538,7 @@ xfs_dir2_leaf_search_hash( leaf = lbp->b_addr; ents = args->dp->d_ops->leaf_ents_p (leaf); - args->dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (args->dp->i_mount, &leafhdr, leaf);/* * Note, the table cannot be empty, so we have to go through the loop. @@ -1697,7 +1726,7 @@ xfs_dir2_node_to_leaf(return 0 ; lbp = state->path.blk[0 ].bp; leaf = lbp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf);ASSERT (leafhdr.magic ==XFS_DIR2_LEAFN_MAGIC || leafhdr.magic ==XFS_DIR3_LEAFN_MAGIC );fs/xfs/libxfs/xfs_dir2_node.c +14
-14@@ -45,7 +45,7 @@ xfs_dir3_leafn_check(struct xfs_dir2_leaf *leaf = bp->b_addr;struct xfs_dir3_icleaf_hdr leafhdr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf);if (leafhdr.magic ==XFS_DIR3_LEAFN_MAGIC ) {struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr;@@ -438,7 +438,7 @@ xfs_dir2_leafn_add(trace_xfs_dir2_leafn_add (args, index); - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);/* @@ -534,7 +534,7 @@ xfs_dir2_leaf_lasthash(struct xfs_dir2_leaf_entry *ents;struct xfs_dir3_icleaf_hdr leafhdr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC || leafhdr.magic == XFS_DIR3_LEAFN_MAGIC ||@@ -583,7 +583,7 @@ xfs_dir2_leafn_lookup_for_addname( tp = args->trans; mp = dp->i_mount; leaf = bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);xfs_dir3_leaf_check (dp, bp);@@ -735,7 +735,7 @@ xfs_dir2_leafn_lookup_for_entry( tp = args->trans; mp = dp->i_mount; leaf = bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);xfs_dir3_leaf_check (dp, bp);@@ -971,8 +971,8 @@ xfs_dir2_leafn_order(struct xfs_dir3_icleaf_hdr hdr1;struct xfs_dir3_icleaf_hdr hdr2; - dp->d_ops->leaf_hdr_from_disk (&hdr1, leaf1); - dp->d_ops->leaf_hdr_from_disk (&hdr2, leaf2); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr1, leaf1); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr2, leaf2); ents1 = dp->d_ops->leaf_ents_p (leaf1); ents2 = dp->d_ops->leaf_ents_p (leaf2);@@ -1024,8 +1024,8 @@ xfs_dir2_leafn_rebalance( leaf1 = blk1->bp->b_addr; leaf2 = blk2->bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&hdr1, leaf1); - dp->d_ops->leaf_hdr_from_disk (&hdr2, leaf2); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr1, leaf1); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr2, leaf2); ents1 = dp->d_ops->leaf_ents_p (leaf1); ents2 = dp->d_ops->leaf_ents_p (leaf2);@@ -1222,7 +1222,7 @@ xfs_dir2_leafn_remove( dp = args->dp; tp = args->trans; leaf = bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);/* @@ -1444,7 +1444,7 @@ xfs_dir2_leafn_toosmall(*/ blk = &state->path.blk[state->path.active -1 ]; leaf = blk->bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = dp->d_ops->leaf_ents_p (leaf);xfs_dir3_leaf_check (dp, blk->bp);@@ -1507,7 +1507,7 @@ xfs_dir2_leafn_toosmall( (state->args->geo->blksize >>2 ); leaf = bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&hdr2, leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &hdr2, leaf); ents = dp->d_ops->leaf_ents_p (leaf); count += hdr2.count - hdr2.stale; bytes -= count *sizeof (ents[0 ]);@@ -1570,8 +1570,8 @@ xfs_dir2_leafn_unbalance( drop_leaf = drop_blk->bp->b_addr; save_leaf = save_blk->bp->b_addr; - dp->d_ops->leaf_hdr_from_disk (&savehdr, save_leaf); - dp->d_ops->leaf_hdr_from_disk (&drophdr, drop_leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &savehdr, save_leaf); +xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &drophdr, drop_leaf); sents = dp->d_ops->leaf_ents_p (save_leaf); dents = dp->d_ops->leaf_ents_p (drop_leaf);fs/xfs/libxfs/xfs_dir2_priv.h +2
-0@@ -67,6 +67,8 @@ extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, struct xfs_buf **bpp);/* xfs_dir2_leaf.c */ +void xfs_dir2_leaf_hdr_from_disk (struct xfs_mount *mp, +struct xfs_dir3_icleaf_hdr *to,struct xfs_dir2_leaf *from);extern int xfs_dir3_leaf_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t fbno,xfs_daddr_t mappedbno,struct xfs_buf **bpp); extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,fs/xfs/scrub/dir.c +1
-1@@ -504,7 +504,7 @@ xchk_directory_leaf1_bestfree(xchk_buffer_recheck (sc, bp); leaf = bp->b_addr; - d_ops->leaf_hdr_from_disk (&leafhdr, leaf); +xfs_dir2_leaf_hdr_from_disk (sc->ip->i_mount, &leafhdr, leaf); ents = d_ops->leaf_ents_p (leaf); ltp =xfs_dir2_leaf_tail_p (geo, leaf); bestcount =be32_to_cpu (ltp->bestcount);Signature · 1 line
2.20.1
PATCH 8/34 xfs: devirtualize ->leaf_hdr_to_disk
In reply to Christoph HellwigReplace the ->leaf_hdr_to_disk dir ops method with a directly called xfs_dir_leaf_hdr_to_disk helper that takes care of the differences between the v4 and v5 on-disk format.
--- fs/xfs/libxfs/xfs_da_format.c | 35 ------------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_leaf.c | 39 ++++++++++++++++++++++++++++++----- fs/xfs/libxfs/xfs_dir2_node.c | 12 +++++------ fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ 5 files changed, 42 insertions(+), 48 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -35
@@ -430,38 +430,6 @@ xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp)return ((struct xfs_dir3_leaf *)lp)->__ents; } -static void -xfs_dir2_leaf_hdr_to_disk ( -struct xfs_dir2_leaf *to, -struct xfs_dir3_icleaf_hdr *from) -{ -ASSERT (from->magic ==XFS_DIR2_LEAF1_MAGIC || - from->magic ==XFS_DIR2_LEAFN_MAGIC ); - - to->hdr.info.forw =cpu_to_be32 (from->forw); - to->hdr.info.back =cpu_to_be32 (from->back); - to->hdr.info.magic =cpu_to_be16 (from->magic); - to->hdr.count =cpu_to_be16 (from->count); - to->hdr.stale =cpu_to_be16 (from->stale); -} - -static void -xfs_dir3_leaf_hdr_to_disk ( -struct xfs_dir2_leaf *to, -struct xfs_dir3_icleaf_hdr *from) -{ -struct xfs_dir3_leaf_hdr *hdr3 = (struct xfs_dir3_leaf_hdr *)to; - -ASSERT (from->magic ==XFS_DIR3_LEAF1_MAGIC || - from->magic ==XFS_DIR3_LEAFN_MAGIC ); - - hdr3->info.hdr.forw =cpu_to_be32 (from->forw); - hdr3->info.hdr.back =cpu_to_be32 (from->back); - hdr3->info.hdr.magic =cpu_to_be16 (from->magic); - hdr3->count =cpu_to_be16 (from->count); - hdr3->stale =cpu_to_be16 (from->stale); -} -/* * Directory free space block operations */
@@ -615,7 +583,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_unused_p = xfs_dir2_data_unused_p, .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), - .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk, .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p,
@@ -659,7 +626,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_unused_p = xfs_dir2_data_unused_p, .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), - .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk, .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p,
@@ -703,7 +669,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_unused_p = xfs_dir3_data_unused_p, .leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr), - .leaf_hdr_to_disk = xfs_dir3_leaf_hdr_to_disk, .leaf_max_ents = xfs_dir3_max_leaf_ents, .leaf_ents_p = xfs_dir3_leaf_ents_p,
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -73,8 +73,6 @@ struct xfs_dir_ops { (*data_unused_p)(struct xfs_dir2_data_hdr *hdr);int leaf_hdr_size; -void (*leaf_hdr_to_disk)(struct xfs_dir2_leaf *to, -struct xfs_dir3_icleaf_hdr *from);int (*leaf_max_ents)(struct xfs_da_geometry *geo);struct xfs_dir2_leaf_entry * (*leaf_ents_p)(struct xfs_dir2_leaf *lp);
fs/xfs/libxfs/xfs_dir2_leaf.c +34 -5
@@ -59,6 +59,35 @@ xfs_dir2_leaf_hdr_from_disk( } } +void +xfs_dir2_leaf_hdr_to_disk ( +struct xfs_mount *mp, +struct xfs_dir2_leaf *to, +struct xfs_dir3_icleaf_hdr *from) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_dir3_leaf *to3 = (struct xfs_dir3_leaf *)to; + +ASSERT (from->magic ==XFS_DIR3_LEAF1_MAGIC || + from->magic ==XFS_DIR3_LEAFN_MAGIC ); + + to3->hdr.info.hdr.forw =cpu_to_be32 (from->forw); + to3->hdr.info.hdr.back =cpu_to_be32 (from->back); + to3->hdr.info.hdr.magic =cpu_to_be16 (from->magic); + to3->hdr.count =cpu_to_be16 (from->count); + to3->hdr.stale =cpu_to_be16 (from->stale); + }else { +ASSERT (from->magic ==XFS_DIR2_LEAF1_MAGIC || + from->magic ==XFS_DIR2_LEAFN_MAGIC ); + + to->hdr.info.forw =cpu_to_be32 (from->forw); + to->hdr.info.back =cpu_to_be32 (from->back); + to->hdr.info.magic =cpu_to_be16 (from->magic); + to->hdr.count =cpu_to_be16 (from->count); + to->hdr.stale =cpu_to_be16 (from->stale); + } +} +/* * Check the internal consistency of a leaf1 block. * Pop an assert if something is wrong.
@@ -413,7 +442,7 @@ xfs_dir2_block_to_leaf(xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); leafhdr.count =be32_to_cpu (btp->count); leafhdr.stale =be32_to_cpu (btp->stale); - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, lbp);/*
@@ -881,7 +910,7 @@ xfs_dir2_leaf_addname(/* * Log the leaf fields and give up the buffers. */ - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, lbp);xfs_dir3_leaf_log_ents (args, lbp, lfloglow, lfloghigh);xfs_dir3_leaf_check (dp, lbp);
@@ -934,7 +963,7 @@ xfs_dir3_leaf_compact( leafhdr->count -= leafhdr->stale; leafhdr->stale =0 ; - dp->d_ops->leaf_hdr_to_disk (leaf, leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, leafhdr);xfs_dir3_leaf_log_header (args, bp);if (loglow !=-1 )xfs_dir3_leaf_log_ents (args, bp, loglow, to -1 );
@@ -1384,7 +1413,7 @@ xfs_dir2_leaf_removename(* We just mark the leaf entry stale by putting a null in it. */ leafhdr.stale++; - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, lbp); lep->address =cpu_to_be32 (XFS_DIR2_NULL_DATAPTR );
@@ -1775,7 +1804,7 @@ xfs_dir2_node_to_leaf(memcpy (xfs_dir2_leaf_bests_p (ltp), dp->d_ops->free_bests_p (free), freehdr.nvalid *sizeof (xfs_dir2_data_off_t)); - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (mp, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, lbp);xfs_dir3_leaf_log_bests (args, lbp,0 ,be32_to_cpu (ltp->bestcount) -1 );xfs_dir3_leaf_log_tail (args, lbp);
fs/xfs/libxfs/xfs_dir2_node.c +6 -6
@@ -493,7 +493,7 @@ xfs_dir2_leafn_add( lep->address =cpu_to_be32 (xfs_dir2_db_off_to_dataptr (args->geo, args->blkno, args->index)); - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, bp);xfs_dir3_leaf_log_ents (args, bp, lfloglow, lfloghigh);xfs_dir3_leaf_check (dp, bp);
@@ -1073,8 +1073,8 @@ xfs_dir2_leafn_rebalance(ASSERT (hdr1.stale + hdr2.stale == oldstale);/* log the changes made when moving the entries */ - dp->d_ops->leaf_hdr_to_disk (leaf1, &hdr1); - dp->d_ops->leaf_hdr_to_disk (leaf2, &hdr2); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf1, &hdr1); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf2, &hdr2);xfs_dir3_leaf_log_header (args, blk1->bp);xfs_dir3_leaf_log_header (args, blk2->bp);
@@ -1243,7 +1243,7 @@ xfs_dir2_leafn_remove(* Log the leaf block changes. */ leafhdr.stale++; - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, bp); lep->address =cpu_to_be32 (XFS_DIR2_NULL_DATAPTR );
@@ -1599,8 +1599,8 @@ xfs_dir2_leafn_unbalance( save_blk->hashval =be32_to_cpu (sents[savehdr.count -1 ].hashval);/* log the changes made when moving the entries */ - dp->d_ops->leaf_hdr_to_disk (save_leaf, &savehdr); - dp->d_ops->leaf_hdr_to_disk (drop_leaf, &drophdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, save_leaf, &savehdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, drop_leaf, &drophdr);xfs_dir3_leaf_log_header (args, save_blk->bp);xfs_dir3_leaf_log_header (args, drop_blk->bp);
fs/xfs/libxfs/xfs_dir2_priv.h +2 -0
@@ -69,6 +69,8 @@ extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,/* xfs_dir2_leaf.c */ void xfs_dir2_leaf_hdr_from_disk (struct xfs_mount *mp,struct xfs_dir3_icleaf_hdr *to,struct xfs_dir2_leaf *from); +void xfs_dir2_leaf_hdr_to_disk (struct xfs_mount *mp,struct xfs_dir2_leaf *to, +struct xfs_dir3_icleaf_hdr *from);extern int xfs_dir3_leaf_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t fbno,xfs_daddr_t mappedbno,struct xfs_buf **bpp); extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
Signature · 1 line
2.20.1
Re: [PATCH 08/34] xfs: devirtualize ->leaf_hdr_to_disk
Quoted 5 lines · Christoph Hellwig
Replace the ->leaf_hdr_to_disk dir ops method with a directly called
xfs_dir_leaf_hdr_to_diskhelper that takes care of the differences between the v4 and v5 on-disk format.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 233 lines
--- fs/xfs/libxfs/xfs_da_format.c | 35 ------------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_leaf.c | 39 ++++++++++++++++++++++++++++++----- fs/xfs/libxfs/xfs_dir2_node.c | 12 +++++------ fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ 5 files changed, 42 insertions(+), 48 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-35@@ -430,38 +430,6 @@ xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp)return ((struct xfs_dir3_leaf *)lp)->__ents; } -static void -xfs_dir2_leaf_hdr_to_disk ( -struct xfs_dir2_leaf *to, -struct xfs_dir3_icleaf_hdr *from) -{ -ASSERT (from->magic ==XFS_DIR2_LEAF1_MAGIC || - from->magic ==XFS_DIR2_LEAFN_MAGIC ); - - to->hdr.info.forw =cpu_to_be32 (from->forw); - to->hdr.info.back =cpu_to_be32 (from->back); - to->hdr.info.magic =cpu_to_be16 (from->magic); - to->hdr.count =cpu_to_be16 (from->count); - to->hdr.stale =cpu_to_be16 (from->stale); -} - -static void -xfs_dir3_leaf_hdr_to_disk ( -struct xfs_dir2_leaf *to, -struct xfs_dir3_icleaf_hdr *from) -{ -struct xfs_dir3_leaf_hdr *hdr3 = (struct xfs_dir3_leaf_hdr *)to; - -ASSERT (from->magic ==XFS_DIR3_LEAF1_MAGIC || - from->magic ==XFS_DIR3_LEAFN_MAGIC ); - - hdr3->info.hdr.forw =cpu_to_be32 (from->forw); - hdr3->info.hdr.back =cpu_to_be32 (from->back); - hdr3->info.hdr.magic =cpu_to_be16 (from->magic); - hdr3->count =cpu_to_be16 (from->count); - hdr3->stale =cpu_to_be16 (from->stale); -} -/* * Directory free space block operations */ @@ -615,7 +583,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_unused_p = xfs_dir2_data_unused_p, .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), - .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk, .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p,@@ -659,7 +626,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_unused_p = xfs_dir2_data_unused_p, .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), - .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk, .leaf_max_ents = xfs_dir2_max_leaf_ents, .leaf_ents_p = xfs_dir2_leaf_ents_p,@@ -703,7 +669,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_unused_p = xfs_dir3_data_unused_p, .leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr), - .leaf_hdr_to_disk = xfs_dir3_leaf_hdr_to_disk, .leaf_max_ents = xfs_dir3_max_leaf_ents, .leaf_ents_p = xfs_dir3_leaf_ents_p,fs/xfs/libxfs/xfs_dir2.h +0
-2@@ -73,8 +73,6 @@ struct xfs_dir_ops { (*data_unused_p)(struct xfs_dir2_data_hdr *hdr);int leaf_hdr_size; -void (*leaf_hdr_to_disk)(struct xfs_dir2_leaf *to, -struct xfs_dir3_icleaf_hdr *from);int (*leaf_max_ents)(struct xfs_da_geometry *geo);struct xfs_dir2_leaf_entry * (*leaf_ents_p)(struct xfs_dir2_leaf *lp);fs/xfs/libxfs/xfs_dir2_leaf.c +34
-5@@ -59,6 +59,35 @@ xfs_dir2_leaf_hdr_from_disk( } } +void +xfs_dir2_leaf_hdr_to_disk ( +struct xfs_mount *mp, +struct xfs_dir2_leaf *to, +struct xfs_dir3_icleaf_hdr *from) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_dir3_leaf *to3 = (struct xfs_dir3_leaf *)to; + +ASSERT (from->magic ==XFS_DIR3_LEAF1_MAGIC || + from->magic ==XFS_DIR3_LEAFN_MAGIC ); + + to3->hdr.info.hdr.forw =cpu_to_be32 (from->forw); + to3->hdr.info.hdr.back =cpu_to_be32 (from->back); + to3->hdr.info.hdr.magic =cpu_to_be16 (from->magic); + to3->hdr.count =cpu_to_be16 (from->count); + to3->hdr.stale =cpu_to_be16 (from->stale); + }else { +ASSERT (from->magic ==XFS_DIR2_LEAF1_MAGIC || + from->magic ==XFS_DIR2_LEAFN_MAGIC ); + + to->hdr.info.forw =cpu_to_be32 (from->forw); + to->hdr.info.back =cpu_to_be32 (from->back); + to->hdr.info.magic =cpu_to_be16 (from->magic); + to->hdr.count =cpu_to_be16 (from->count); + to->hdr.stale =cpu_to_be16 (from->stale); + } +} +/* * Check the internal consistency of a leaf1 block. * Pop an assert if something is wrong. @@ -413,7 +442,7 @@ xfs_dir2_block_to_leaf(xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); leafhdr.count =be32_to_cpu (btp->count); leafhdr.stale =be32_to_cpu (btp->stale); - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, lbp);/* @@ -881,7 +910,7 @@ xfs_dir2_leaf_addname(/* * Log the leaf fields and give up the buffers. */ - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, lbp);xfs_dir3_leaf_log_ents (args, lbp, lfloglow, lfloghigh);xfs_dir3_leaf_check (dp, lbp);@@ -934,7 +963,7 @@ xfs_dir3_leaf_compact( leafhdr->count -= leafhdr->stale; leafhdr->stale =0 ; - dp->d_ops->leaf_hdr_to_disk (leaf, leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, leafhdr);xfs_dir3_leaf_log_header (args, bp);if (loglow !=-1 )xfs_dir3_leaf_log_ents (args, bp, loglow, to -1 );@@ -1384,7 +1413,7 @@ xfs_dir2_leaf_removename(* We just mark the leaf entry stale by putting a null in it. */ leafhdr.stale++; - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, lbp); lep->address =cpu_to_be32 (XFS_DIR2_NULL_DATAPTR );@@ -1775,7 +1804,7 @@ xfs_dir2_node_to_leaf(memcpy (xfs_dir2_leaf_bests_p (ltp), dp->d_ops->free_bests_p (free), freehdr.nvalid *sizeof (xfs_dir2_data_off_t)); - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (mp, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, lbp);xfs_dir3_leaf_log_bests (args, lbp,0 ,be32_to_cpu (ltp->bestcount) -1 );xfs_dir3_leaf_log_tail (args, lbp);fs/xfs/libxfs/xfs_dir2_node.c +6
-6@@ -493,7 +493,7 @@ xfs_dir2_leafn_add( lep->address =cpu_to_be32 (xfs_dir2_db_off_to_dataptr (args->geo, args->blkno, args->index)); - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, bp);xfs_dir3_leaf_log_ents (args, bp, lfloglow, lfloghigh);xfs_dir3_leaf_check (dp, bp);@@ -1073,8 +1073,8 @@ xfs_dir2_leafn_rebalance(ASSERT (hdr1.stale + hdr2.stale == oldstale);/* log the changes made when moving the entries */ - dp->d_ops->leaf_hdr_to_disk (leaf1, &hdr1); - dp->d_ops->leaf_hdr_to_disk (leaf2, &hdr2); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf1, &hdr1); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf2, &hdr2);xfs_dir3_leaf_log_header (args, blk1->bp);xfs_dir3_leaf_log_header (args, blk2->bp);@@ -1243,7 +1243,7 @@ xfs_dir2_leafn_remove(* Log the leaf block changes. */ leafhdr.stale++; - dp->d_ops->leaf_hdr_to_disk (leaf, &leafhdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, leaf, &leafhdr);xfs_dir3_leaf_log_header (args, bp); lep->address =cpu_to_be32 (XFS_DIR2_NULL_DATAPTR );@@ -1599,8 +1599,8 @@ xfs_dir2_leafn_unbalance( save_blk->hashval =be32_to_cpu (sents[savehdr.count -1 ].hashval);/* log the changes made when moving the entries */ - dp->d_ops->leaf_hdr_to_disk (save_leaf, &savehdr); - dp->d_ops->leaf_hdr_to_disk (drop_leaf, &drophdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, save_leaf, &savehdr); +xfs_dir2_leaf_hdr_to_disk (dp->i_mount, drop_leaf, &drophdr);xfs_dir3_leaf_log_header (args, save_blk->bp);xfs_dir3_leaf_log_header (args, drop_blk->bp);fs/xfs/libxfs/xfs_dir2_priv.h +2
-0@@ -69,6 +69,8 @@ extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,/* xfs_dir2_leaf.c */ void xfs_dir2_leaf_hdr_from_disk (struct xfs_mount *mp,struct xfs_dir3_icleaf_hdr *to,struct xfs_dir2_leaf *from); +void xfs_dir2_leaf_hdr_to_disk (struct xfs_mount *mp,struct xfs_dir2_leaf *to, +struct xfs_dir3_icleaf_hdr *from);extern int xfs_dir3_leaf_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t fbno,xfs_daddr_t mappedbno,struct xfs_buf **bpp); extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,Signature · 1 line
2.20.1
PATCH 9/34 xfs: add a entries pointer to struct xfs_dir3_icleaf_hdr
In reply to Christoph HellwigAll callers of the ->node_tree_p dir operation already have a struct xfs_dir3_icleaf_hdr from a previous call to xfs_da_leaf_hdr_from_disk at hand, or just need slight changes to the calling conventions to do so. Add a pointer to the entries to struct xfs_dir3_icleaf_hdr to clean up this pattern. To make this possible the xfs_dir3_leaf_log_ents function grow a new argument to pass the xfs_dir3_icleaf_hdr that call callers already have, and xfs_dir2_leaf_lookup_int returns the xfs_dir3_icleaf_hdr to the callers so that they can later use it.
--- fs/xfs/libxfs/xfs_da_btree.c | 7 +-- fs/xfs/libxfs/xfs_da_format.c | 15 ----- fs/xfs/libxfs/xfs_dir2.h | 2 - fs/xfs/libxfs/xfs_dir2_block.c | 7 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 101 +++++++++++++++------------------ fs/xfs/libxfs/xfs_dir2_node.c | 64 +++++++++------------ fs/xfs/libxfs/xfs_dir2_priv.h | 5 +- fs/xfs/scrub/dir.c | 13 +++-- 8 files changed, 88 insertions(+), 126 deletions(-)
fs/xfs/libxfs/xfs_da_btree.c +3 -4
@@ -638,15 +638,14 @@ xfs_da3_root_split(xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DA_NODE_BUF ); }else {struct xfs_dir3_icleaf_hdr leafhdr; -struct xfs_dir2_leaf_entry *ents; leaf = (xfs_dir2_leaf_t *)oldroot;xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); - ents = dp->d_ops->leaf_ents_p (leaf);ASSERT (leafhdr.magic ==XFS_DIR2_LEAFN_MAGIC || leafhdr.magic ==XFS_DIR3_LEAFN_MAGIC ); - size = (int )((char *)&ents[leafhdr.count] - (char *)leaf); + size = (int )((char *)&leafhdr.ents[leafhdr.count] - + (char *)leaf); level =0 ;/*
@@ -2285,7 +2284,7 @@ xfs_da3_swap_lastblock( dead_leaf2 = (xfs_dir2_leaf_t *)dead_info;xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, dead_leaf2); - ents = dp->d_ops->leaf_ents_p (dead_leaf2); + ents = leafhdr.ents; dead_level =0 ; dead_hash =be32_to_cpu (ents[leafhdr.count -1 ].hashval); }else {
fs/xfs/libxfs/xfs_da_format.c +0 -15
@@ -411,12 +411,6 @@ xfs_dir2_max_leaf_ents(struct xfs_da_geometry *geo) (uint )sizeof (struct xfs_dir2_leaf_entry ); } -static struct xfs_dir2_leaf_entry * -xfs_dir2_leaf_ents_p (struct xfs_dir2_leaf *lp) -{ -return lp->__ents; -} -static int xfs_dir3_max_leaf_ents (struct xfs_da_geometry *geo) {
@@ -424,12 +418,6 @@ xfs_dir3_max_leaf_ents(struct xfs_da_geometry *geo) (uint )sizeof (struct xfs_dir2_leaf_entry ); } -static struct xfs_dir2_leaf_entry * -xfs_dir3_leaf_ents_p (struct xfs_dir2_leaf *lp) -{ -return ((struct xfs_dir3_leaf *)lp)->__ents; -} -/* * Directory free space block operations */
@@ -584,7 +572,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_max_ents = xfs_dir2_max_leaf_ents, - .leaf_ents_p = xfs_dir2_leaf_ents_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk,
@@ -627,7 +614,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_max_ents = xfs_dir2_max_leaf_ents, - .leaf_ents_p = xfs_dir2_leaf_ents_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk,
@@ -670,7 +656,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr), .leaf_max_ents = xfs_dir3_max_leaf_ents, - .leaf_ents_p = xfs_dir3_leaf_ents_p, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk,
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -74,8 +74,6 @@ struct xfs_dir_ops {int leaf_hdr_size;int (*leaf_max_ents)(struct xfs_da_geometry *geo); -struct xfs_dir2_leaf_entry * - (*leaf_ents_p)(struct xfs_dir2_leaf *lp);int free_hdr_size; void (*free_hdr_to_disk)(struct xfs_dir2_free *to,
fs/xfs/libxfs/xfs_dir2_block.c +3 -4
@@ -914,7 +914,6 @@ xfs_dir2_leaf_to_block(__be16 *tagp;/* end of entry (tag) */ int to;/* block/leaf to index */ xfs_trans_t *tp;/* transaction pointer */ -struct xfs_dir2_leaf_entry *ents;struct xfs_dir3_icleaf_hdr leafhdr;trace_xfs_dir2_leaf_to_block (args);
@@ -924,7 +923,6 @@ xfs_dir2_leaf_to_block( mp = dp->i_mount; leaf = lbp->b_addr;xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); - ents = dp->d_ops->leaf_ents_p (leaf); ltp =xfs_dir2_leaf_tail_p (args->geo, leaf); ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC ||
@@ -1004,9 +1002,10 @@ xfs_dir2_leaf_to_block(*/ lep =xfs_dir2_block_leaf_p (btp);for (from = to =0 ; from < leafhdr.count; from++) { -if (ents[from].address ==cpu_to_be32 (XFS_DIR2_NULL_DATAPTR )) +if (leafhdr.ents[from].address == +cpu_to_be32 (XFS_DIR2_NULL_DATAPTR ))continue ; - lep[to++] = ents[from]; + lep[to++] = leafhdr.ents[from]; }ASSERT (to ==be32_to_cpu (btp->count));xfs_dir2_block_log_leaf (tp, dbp,0 ,be32_to_cpu (btp->count) -1 );
fs/xfs/libxfs/xfs_dir2_leaf.c +45 -56
324 lines not on this page · raw message
fs/xfs/libxfs/xfs_dir2_node.c +27 -37
226 lines not on this page · raw message
fs/xfs/libxfs/xfs_dir2_priv.h +3 -2
@@ -18,6 +18,7 @@ struct xfs_dir3_icleaf_hdr {uint16_t magic;uint16_t count;uint16_t stale; +struct xfs_dir2_leaf_entry *ents; };struct xfs_dir3_icfree_hdr {
@@ -25,7 +26,6 @@ struct xfs_dir3_icfree_hdr {uint32_t firstdb;uint32_t nvalid;uint32_t nused; - };/* xfs_dir2.c */
@@ -86,7 +86,8 @@ extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr,extern int xfs_dir3_leaf_get_buf (struct xfs_da_args *args,xfs_dir2_db_t bno,struct xfs_buf **bpp,uint16_t magic);extern void xfs_dir3_leaf_log_ents (struct xfs_da_args *args, -struct xfs_buf *bp,int first,int last); +struct xfs_dir3_icleaf_hdr *hdr,struct xfs_buf *bp,int first, +int last);extern void xfs_dir3_leaf_log_header (struct xfs_da_args *args,struct xfs_buf *bp);extern int xfs_dir2_leaf_lookup (struct xfs_da_args *args);
fs/xfs/scrub/dir.c +7 -6
@@ -195,13 +195,15 @@ xchk_dir_rec(xfs_dir2_dataptr_t ptr;xfs_dahash_t calc_hash;xfs_dahash_t hash; +struct xfs_dir3_icleaf_hdr hdr;unsigned int tag;int error;ASSERT (blk->magic ==XFS_DIR2_LEAF1_MAGIC || blk->magic ==XFS_DIR2_LEAFN_MAGIC ); - ent = (void *)ds->dargs.dp->d_ops->leaf_ents_p (blk->bp->b_addr) + +xfs_dir2_leaf_hdr_from_disk (mp, &hdr, blk->bp->b_addr); + ent = (void *)hdr.ents + (blk->index *sizeof (struct xfs_dir2_leaf_entry ));/* Check the hash of the entry. */
@@ -481,7 +483,6 @@ xchk_directory_leaf1_bestfree( xfs_dablk_t lblk) {struct xfs_dir3_icleaf_hdr leafhdr; -struct xfs_dir2_leaf_entry *ents;struct xfs_dir2_leaf_tail *ltp;struct xfs_dir2_leaf *leaf;struct xfs_buf *dbp;
@@ -505,7 +506,6 @@ xchk_directory_leaf1_bestfree( leaf = bp->b_addr;xfs_dir2_leaf_hdr_from_disk (sc->ip->i_mount, &leafhdr, leaf); - ents = d_ops->leaf_ents_p (leaf); ltp =xfs_dir2_leaf_tail_p (geo, leaf); bestcount =be32_to_cpu (ltp->bestcount); bestp =xfs_dir2_leaf_bests_p (ltp);
@@ -533,18 +533,19 @@ xchk_directory_leaf1_bestfree( }/* Leaves and bests don't overlap in leaf format. */ -if ((char *)&ents[leafhdr.count] > (char *)bestp) { +if ((char *)&leafhdr.ents[leafhdr.count] > (char *)bestp) {xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk); goto out; }/* Check hash value order, count stale entries. */ for (i =0 ; i < leafhdr.count; i++) { - hash =be32_to_cpu (ents[i].hashval); + hash =be32_to_cpu (leafhdr.ents[i].hashval);if (i >0 && lasthash > hash)xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk); lasthash = hash; -if (ents[i].address ==cpu_to_be32 (XFS_DIR2_NULL_DATAPTR )) +if (leafhdr.ents[i].address == +cpu_to_be32 (XFS_DIR2_NULL_DATAPTR )) stale++; }if (leafhdr.stale != stale)
Signature · 1 line
2.20.1
Re: [PATCH 09/34] xfs: add a entries pointer to struct xfs_dir3_icleaf_hdr
Quoted 10 lines · Christoph Hellwig
All callers of the ->node_tree_p dir operation already have a struct
xfs_dir3_icleaf_hdrfrom a previous call toxfs_da_leaf_hdr_from_diskat hand, or just need slight changes to the calling conventions to do so. Add a pointer to the entries to structxfs_dir3_icleaf_hdrto clean up this pattern. To make this possible thexfs_dir3_leaf_log_entsfunction grow a new argument to pass thexfs_dir3_icleaf_hdrthat call callers already have, andxfs_dir2_leaf_lookup_intreturns thexfs_dir3_icleaf_hdrto the callers so that they can later use it.Signed-off-by Christoph Hellwig <[email protected]>
Mostly looks ok...
<snip>
fs/xfs/libxfs/xfs_dir2_priv.h struct xfs_dir3_icleaf_hdr { · line 21
Quoted 9 lines
fs/xfs/libxfs/xfs_dir2_priv.h +1
-0@@ -18,6 +18,7 @@ struct xfs_dir3_icleaf_hdr {uint16_t magic;uint16_t count;uint16_t stale; +struct xfs_dir2_leaf_entry *ents;
...except for the same suggestion I had a few patches ago about being more explicit that this is a pointer to an array of raw on-disk structures which haven't been converted to cpu endianness.
--D
Quoted 84 lines
fs/xfs/libxfs/xfs_dir2_priv.h +2
-2};struct xfs_dir3_icfree_hdr {@@ -25,7 +26,6 @@ struct xfs_dir3_icfree_hdr {uint32_t firstdb;uint32_t nvalid;uint32_t nused; - };/* xfs_dir2.c */ @@ -86,7 +86,8 @@ extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr,extern int xfs_dir3_leaf_get_buf (struct xfs_da_args *args,xfs_dir2_db_t bno,struct xfs_buf **bpp,uint16_t magic);extern void xfs_dir3_leaf_log_ents (struct xfs_da_args *args, -struct xfs_buf *bp,int first,int last); +struct xfs_dir3_icleaf_hdr *hdr,struct xfs_buf *bp,int first, +int last);extern void xfs_dir3_leaf_log_header (struct xfs_da_args *args,struct xfs_buf *bp);extern int xfs_dir2_leaf_lookup (struct xfs_da_args *args);fs/xfs/scrub/dir.c +7
-6@@ -195,13 +195,15 @@ xchk_dir_rec(xfs_dir2_dataptr_t ptr;xfs_dahash_t calc_hash;xfs_dahash_t hash; +struct xfs_dir3_icleaf_hdr hdr;unsigned int tag;int error;ASSERT (blk->magic ==XFS_DIR2_LEAF1_MAGIC || blk->magic ==XFS_DIR2_LEAFN_MAGIC ); - ent = (void *)ds->dargs.dp->d_ops->leaf_ents_p (blk->bp->b_addr) + +xfs_dir2_leaf_hdr_from_disk (mp, &hdr, blk->bp->b_addr); + ent = (void *)hdr.ents + (blk->index *sizeof (struct xfs_dir2_leaf_entry ));/* Check the hash of the entry. */ @@ -481,7 +483,6 @@ xchk_directory_leaf1_bestfree( xfs_dablk_t lblk) {struct xfs_dir3_icleaf_hdr leafhdr; -struct xfs_dir2_leaf_entry *ents;struct xfs_dir2_leaf_tail *ltp;struct xfs_dir2_leaf *leaf;struct xfs_buf *dbp;@@ -505,7 +506,6 @@ xchk_directory_leaf1_bestfree( leaf = bp->b_addr;xfs_dir2_leaf_hdr_from_disk (sc->ip->i_mount, &leafhdr, leaf); - ents = d_ops->leaf_ents_p (leaf); ltp =xfs_dir2_leaf_tail_p (geo, leaf); bestcount =be32_to_cpu (ltp->bestcount); bestp =xfs_dir2_leaf_bests_p (ltp);@@ -533,18 +533,19 @@ xchk_directory_leaf1_bestfree( }/* Leaves and bests don't overlap in leaf format. */ -if ((char *)&ents[leafhdr.count] > (char *)bestp) { +if ((char *)&leafhdr.ents[leafhdr.count] > (char *)bestp) {xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk); goto out; }/* Check hash value order, count stale entries. */ for (i =0 ; i < leafhdr.count; i++) { - hash =be32_to_cpu (ents[i].hashval); + hash =be32_to_cpu (leafhdr.ents[i].hashval);if (i >0 && lasthash > hash)xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk); lasthash = hash; -if (ents[i].address ==cpu_to_be32 (XFS_DIR2_NULL_DATAPTR )) +if (leafhdr.ents[i].address == +cpu_to_be32 (XFS_DIR2_NULL_DATAPTR )) stale++; }if (leafhdr.stale != stale)Signature · 1 line
2.20.1
PATCH 10/34 xfs: move the dir2 leaf header size to struct xfs_da_geometry
In reply to Christoph HellwigMove the leaf header size towards our structure for dir/attr geometry parameters.
--- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 3 --- fs/xfs/libxfs/xfs_dir2.c | 7 +++++-- fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-)
fs/xfs/libxfs/xfs_da_btree.h +1 -0
@@ -26,6 +26,7 @@ struct xfs_da_geometry {uint node_ents;/* # of entries in a danode */ int magicpct;/* 37% of block size in bytes */ xfs_dablk_t datablk;/* blockno of dir data v2 */ +int leaf_hdr_size;/* dir2 leaf header size */ xfs_dablk_t leafblk;/* blockno of leaf data v2 */ xfs_dablk_t freeblk;/* blockno of free data v2 */ };
fs/xfs/libxfs/xfs_da_format.c +0 -3
@@ -570,7 +570,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_max_ents = xfs_dir2_max_leaf_ents, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
@@ -612,7 +611,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_max_ents = xfs_dir2_max_leaf_ents, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
@@ -654,7 +652,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - .leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr), .leaf_max_ents = xfs_dir3_max_leaf_ents, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr),
fs/xfs/libxfs/xfs_dir2.c +5 -2
@@ -122,10 +122,13 @@ xfs_da_mount( dageo->fsblog = mp->m_sb.sb_blocklog; dageo->blksize =xfs_dir2_dirblock_bytes (&mp->m_sb); dageo->fsbcount =1 << mp->m_sb.sb_dirblklog; -if (xfs_sb_version_hascrc (&mp->m_sb)) +if (xfs_sb_version_hascrc (&mp->m_sb)) { dageo->node_hdr_size =sizeof (struct xfs_da3_node_hdr ); -else + dageo->leaf_hdr_size =sizeof (struct xfs_dir3_leaf_hdr ); + }else { dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr ); + dageo->leaf_hdr_size =sizeof (struct xfs_dir2_leaf_hdr ); + }/* * Now we've set up the block conversion variables, we can calculate the
fs/xfs/libxfs/xfs_dir2.h +0 -1
@@ -72,7 +72,6 @@ struct xfs_dir_ops {struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); -int leaf_hdr_size;int (*leaf_max_ents)(struct xfs_da_geometry *geo);int free_hdr_size;
fs/xfs/libxfs/xfs_dir2_leaf.c +1 -1
@@ -1132,7 +1132,7 @@ xfs_dir3_leaf_log_header(xfs_trans_log_buf (args->trans, bp, (uint)((char *)&leaf->hdr - (char *)leaf), - args->dp->d_ops->leaf_hdr_size -1 ); + args->geo->leaf_hdr_size -1 ); }/*
fs/xfs/libxfs/xfs_dir2_node.c +2 -2
@@ -1334,7 +1334,7 @@ xfs_dir2_leafn_remove(* Return indication of whether this leaf block is empty enough * to justify trying to join it with a neighbor. */ - *rval = (dp->d_ops->leaf_hdr_size + + *rval = (args->geo->leaf_hdr_size + (uint )sizeof (leafhdr.ents) * (leafhdr.count - leafhdr.stale)) < args->geo->magicpct;return 0 ;
@@ -1440,7 +1440,7 @@ xfs_dir2_leafn_toosmall(xfs_dir3_leaf_check (dp, blk->bp); count = leafhdr.count - leafhdr.stale; - bytes = dp->d_ops->leaf_hdr_size + count *sizeof (ents[0 ]); + bytes = state->args->geo->leaf_hdr_size + count *sizeof (ents[0 ]);if (bytes > (state->args->geo->blksize >>1 )) {/* * Blk over 50%, don't try to join.
Signature · 1 line
2.20.1
Re: [PATCH 10/34] xfs: move the dir2 leaf header size to struct xfs_da_geometry
Quoted 4 lines · Christoph Hellwig
Move the leaf header size towards our structure for dir/attr geometry parameters.
Signed-off-by Christoph Hellwig <[email protected]>
Looks reasonable,
--D
Quoted 119 lines
--- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 3 --- fs/xfs/libxfs/xfs_dir2.c | 7 +++++-- fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-)fs/xfs/libxfs/xfs_da_btree.h +1
-0@@ -26,6 +26,7 @@ struct xfs_da_geometry {uint node_ents;/* # of entries in a danode */ int magicpct;/* 37% of block size in bytes */ xfs_dablk_t datablk;/* blockno of dir data v2 */ +int leaf_hdr_size;/* dir2 leaf header size */ xfs_dablk_t leafblk;/* blockno of leaf data v2 */ xfs_dablk_t freeblk;/* blockno of free data v2 */ };fs/xfs/libxfs/xfs_da_format.c +0
-3@@ -570,7 +570,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_max_ents = xfs_dir2_max_leaf_ents, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),@@ -612,7 +611,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr), .leaf_max_ents = xfs_dir2_max_leaf_ents, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),@@ -654,7 +652,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - .leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr), .leaf_max_ents = xfs_dir3_max_leaf_ents, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr),fs/xfs/libxfs/xfs_dir2.c +5
-2@@ -122,10 +122,13 @@ xfs_da_mount( dageo->fsblog = mp->m_sb.sb_blocklog; dageo->blksize =xfs_dir2_dirblock_bytes (&mp->m_sb); dageo->fsbcount =1 << mp->m_sb.sb_dirblklog; -if (xfs_sb_version_hascrc (&mp->m_sb)) +if (xfs_sb_version_hascrc (&mp->m_sb)) { dageo->node_hdr_size =sizeof (struct xfs_da3_node_hdr ); -else + dageo->leaf_hdr_size =sizeof (struct xfs_dir3_leaf_hdr ); + }else { dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr ); + dageo->leaf_hdr_size =sizeof (struct xfs_dir2_leaf_hdr ); + }/* * Now we've set up the block conversion variables, we can calculate the fs/xfs/libxfs/xfs_dir2.h +0
-1@@ -72,7 +72,6 @@ struct xfs_dir_ops {struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); -int leaf_hdr_size;int (*leaf_max_ents)(struct xfs_da_geometry *geo);int free_hdr_size;fs/xfs/libxfs/xfs_dir2_leaf.c +1
-1@@ -1132,7 +1132,7 @@ xfs_dir3_leaf_log_header(xfs_trans_log_buf (args->trans, bp, (uint)((char *)&leaf->hdr - (char *)leaf), - args->dp->d_ops->leaf_hdr_size -1 ); + args->geo->leaf_hdr_size -1 ); }/* fs/xfs/libxfs/xfs_dir2_node.c +2
-2@@ -1334,7 +1334,7 @@ xfs_dir2_leafn_remove(* Return indication of whether this leaf block is empty enough * to justify trying to join it with a neighbor. */ - *rval = (dp->d_ops->leaf_hdr_size + + *rval = (args->geo->leaf_hdr_size + (uint )sizeof (leafhdr.ents) * (leafhdr.count - leafhdr.stale)) < args->geo->magicpct;return 0 ;@@ -1440,7 +1440,7 @@ xfs_dir2_leafn_toosmall(xfs_dir3_leaf_check (dp, blk->bp); count = leafhdr.count - leafhdr.stale; - bytes = dp->d_ops->leaf_hdr_size + count *sizeof (ents[0 ]); + bytes = state->args->geo->leaf_hdr_size + count *sizeof (ents[0 ]);if (bytes > (state->args->geo->blksize >>1 )) {/* * Blk over 50%, don't try to join. Signature · 1 line
2.20.1
PATCH 11/34 xfs: move the max dir2 leaf entries count to struct xfs_da_geometry
In reply to Christoph HellwigMove the max leaf entries count towards our structure for dir/attr geometry parameters.
--- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 23 ----------------------- fs/xfs/libxfs/xfs_dir2.c | 2 ++ fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 2 +- fs/xfs/scrub/dir.c | 3 +-- 7 files changed, 6 insertions(+), 29 deletions(-)
fs/xfs/libxfs/xfs_da_btree.h +1 -0
@@ -27,6 +27,7 @@ struct xfs_da_geometry {int magicpct;/* 37% of block size in bytes */ xfs_dablk_t datablk;/* blockno of dir data v2 */ int leaf_hdr_size;/* dir2 leaf header size */ +unsigned int leaf_max_ents;/* # of entries in dir2 leaf */ xfs_dablk_t leafblk;/* blockno of leaf data v2 */ xfs_dablk_t freeblk;/* blockno of free data v2 */ };
fs/xfs/libxfs/xfs_da_format.c +0 -23
@@ -401,23 +401,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) } -/* -* Directory Leaf block operations -*/ -static int -xfs_dir2_max_leaf_ents (struct xfs_da_geometry *geo) -{ -return (geo->blksize -sizeof (struct xfs_dir2_leaf_hdr )) / - (uint )sizeof (struct xfs_dir2_leaf_entry ); -} - -static int -xfs_dir3_max_leaf_ents (struct xfs_da_geometry *geo) -{ -return (geo->blksize -sizeof (struct xfs_dir3_leaf_hdr )) / - (uint )sizeof (struct xfs_dir2_leaf_entry ); -} -/* * Directory free space block operations */
@@ -570,8 +553,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .leaf_max_ents = xfs_dir2_max_leaf_ents, - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,
@@ -611,8 +592,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .leaf_max_ents = xfs_dir2_max_leaf_ents, - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,
@@ -652,8 +631,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - .leaf_max_ents = xfs_dir3_max_leaf_ents, - .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir3_free_hdr_from_disk,
fs/xfs/libxfs/xfs_dir2.c +2 -0
@@ -129,6 +129,8 @@ xfs_da_mount( dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir2_leaf_hdr ); } + dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) / +sizeof (struct xfs_dir2_leaf_entry );/* * Now we've set up the block conversion variables, we can calculate the
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -72,8 +72,6 @@ struct xfs_dir_ops {struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); -int (*leaf_max_ents)(struct xfs_da_geometry *geo); -int free_hdr_size;void (*free_hdr_to_disk)(struct xfs_dir2_free *to,struct xfs_dir3_icfree_hdr *from);
fs/xfs/libxfs/xfs_dir2_leaf.c +1 -1
@@ -167,7 +167,7 @@ xfs_dir3_leaf_check_int(* Should factor in the size of the bests table as well. * We can deduce a value for that from di_size. */ -if (hdr->count > ops->leaf_max_ents (geo)) +if (hdr->count > geo->leaf_max_ents)return __this_address;/* Leaves and bests don't overlap in leaf format. */
fs/xfs/libxfs/xfs_dir2_node.c +1 -1
@@ -455,7 +455,7 @@ xfs_dir2_leafn_add(* a compact. */ -if (leafhdr.count == dp->d_ops->leaf_max_ents (args->geo)) { +if (leafhdr.count == args->geo->leaf_max_ents) {if (!leafhdr.stale)return -ENOSPC ; compact = leafhdr.stale >1 ;
fs/xfs/scrub/dir.c +1 -2
@@ -487,7 +487,6 @@ xchk_directory_leaf1_bestfree(struct xfs_dir2_leaf *leaf;struct xfs_buf *dbp;struct xfs_buf *bp; -const struct xfs_dir_ops *d_ops = sc->ip->d_ops;struct xfs_da_geometry *geo = sc->mp->m_dir_geo;__be16 *bestp;__u16 best;
@@ -527,7 +526,7 @@ xchk_directory_leaf1_bestfree( }/* Is the leaf count even remotely sane? */ -if (leafhdr.count > d_ops->leaf_max_ents (geo)) { +if (leafhdr.count > geo->leaf_max_ents) {xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk); goto out; }
Signature · 1 line
2.20.1
Re: [PATCH 11/34] xfs: move the max dir2 leaf entries count to struct xfs_da_geometry
Quoted 19 lines · Christoph Hellwig
Move the max leaf entries count towards our structure for dir/attr geometry parameters.
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 23 ----------------------- fs/xfs/libxfs/xfs_dir2.c | 2 ++ fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 2 +- fs/xfs/scrub/dir.c | 3 +-- 7 files changed, 6 insertions(+), 29 deletions(-)fs/xfs/libxfs/xfs_da_btree.h +0
-0
fs/xfs/libxfs/xfs_da_btree.h struct xfs_da_geometry { · line 30
Quoted 4 lines
fs/xfs/libxfs/xfs_da_btree.h +1
-0@@ -27,6 +27,7 @@ struct xfs_da_geometry {int magicpct;/* 37% of block size in bytes */ xfs_dablk_t datablk;/* blockno of dir data v2 */ int leaf_hdr_size;/* dir2 leaf header size */ +unsigned int leaf_max_ents;/* # of entries in dir2 leaf */
Why does this one get 'unsigned' but the header size fields don't? Or maybe I should rephase that: Why aren't the header sizes unsigned too?
Looks good to me otherwise,
--D
Quoted 134 lines
fs/xfs/libxfs/xfs_da_btree.h +0
-0xfs_dablk_t leafblk;/* blockno of leaf data v2 */ xfs_dablk_t freeblk;/* blockno of free data v2 */ };fs/xfs/libxfs/xfs_da_format.c +0
-23@@ -401,23 +401,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) } -/* -* Directory Leaf block operations -*/ -static int -xfs_dir2_max_leaf_ents (struct xfs_da_geometry *geo) -{ -return (geo->blksize -sizeof (struct xfs_dir2_leaf_hdr )) / - (uint )sizeof (struct xfs_dir2_leaf_entry ); -} - -static int -xfs_dir3_max_leaf_ents (struct xfs_da_geometry *geo) -{ -return (geo->blksize -sizeof (struct xfs_dir3_leaf_hdr )) / - (uint )sizeof (struct xfs_dir2_leaf_entry ); -} -/* * Directory free space block operations */ @@ -570,8 +553,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .leaf_max_ents = xfs_dir2_max_leaf_ents, - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,@@ -611,8 +592,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .leaf_max_ents = xfs_dir2_max_leaf_ents, - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,@@ -652,8 +631,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - .leaf_max_ents = xfs_dir3_max_leaf_ents, - .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk, .free_hdr_from_disk = xfs_dir3_free_hdr_from_disk,fs/xfs/libxfs/xfs_dir2.c +2
-0@@ -129,6 +129,8 @@ xfs_da_mount( dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir2_leaf_hdr ); } + dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) / +sizeof (struct xfs_dir2_leaf_entry );/* * Now we've set up the block conversion variables, we can calculate the fs/xfs/libxfs/xfs_dir2.h +0
-2@@ -72,8 +72,6 @@ struct xfs_dir_ops {struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); -int (*leaf_max_ents)(struct xfs_da_geometry *geo); -int free_hdr_size;void (*free_hdr_to_disk)(struct xfs_dir2_free *to,struct xfs_dir3_icfree_hdr *from);fs/xfs/libxfs/xfs_dir2_leaf.c +1
-1@@ -167,7 +167,7 @@ xfs_dir3_leaf_check_int(* Should factor in the size of the bests table as well. * We can deduce a value for that from di_size. */ -if (hdr->count > ops->leaf_max_ents (geo)) +if (hdr->count > geo->leaf_max_ents)return __this_address;/* Leaves and bests don't overlap in leaf format. */ fs/xfs/libxfs/xfs_dir2_node.c +1
-1@@ -455,7 +455,7 @@ xfs_dir2_leafn_add(* a compact. */ -if (leafhdr.count == dp->d_ops->leaf_max_ents (args->geo)) { +if (leafhdr.count == args->geo->leaf_max_ents) {if (!leafhdr.stale)return -ENOSPC ; compact = leafhdr.stale >1 ;fs/xfs/scrub/dir.c +1
-2@@ -487,7 +487,6 @@ xchk_directory_leaf1_bestfree(struct xfs_dir2_leaf *leaf;struct xfs_buf *dbp;struct xfs_buf *bp; -const struct xfs_dir_ops *d_ops = sc->ip->d_ops;struct xfs_da_geometry *geo = sc->mp->m_dir_geo;__be16 *bestp;__u16 best;@@ -527,7 +526,7 @@ xchk_directory_leaf1_bestfree( }/* Is the leaf count even remotely sane? */ -if (leafhdr.count > d_ops->leaf_max_ents (geo)) { +if (leafhdr.count > geo->leaf_max_ents) {xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk); goto out; }Signature · 1 line
2.20.1
Re: [PATCH 11/34] xfs: move the max dir2 leaf entries count to struct xfs_da_geometry
Quoted 5 lines · Darrick J. Wong
Quoted 5 lines
fs/xfs/libxfs/xfs_da_btree.h +0
-0@@ -27,6 +27,7 @@ struct xfs_da_geometry {
Quoted 8 lines
fs/xfs/libxfs/xfs_da_btree.h struct xfs_da_geometry { · line 30
Quoted 4 lines
fs/xfs/libxfs/xfs_da_btree.h +1
-0int magicpct;/* 37% of block size in bytes */ xfs_dablk_t datablk;/* blockno of dir data v2 */ int leaf_hdr_size;/* dir2 leaf header size */ +unsigned int leaf_max_ents;/* # of entries in dir2 leaf */ Why does this one get 'unsigned' but the header size fields don't? Or maybe I should rephase that: Why aren't the header sizes unsigned too?
They probably should all be unsigned and I should add a prep patch for the existing ones.
Re: [PATCH 11/34] xfs: move the max dir2 leaf entries count to struct xfs_da_geometry
Quoted 15 lines · Christoph Hellwig
Quoted 5 lines · Darrick J. Wong
Quoted 5 lines
fs/xfs/libxfs/xfs_da_btree.h +0
-0@@ -27,6 +27,7 @@ struct xfs_da_geometry {Quoted 8 lines
fs/xfs/libxfs/xfs_da_btree.h struct xfs_da_geometry { · line 30
Quoted 4 lines
fs/xfs/libxfs/xfs_da_btree.h +1
-0int magicpct;/* 37% of block size in bytes */ xfs_dablk_t datablk;/* blockno of dir data v2 */ int leaf_hdr_size;/* dir2 leaf header size */ +unsigned int leaf_max_ents;/* # of entries in dir2 leaf */ Why does this one get 'unsigned' but the header size fields don't? Or maybe I should rephase that: Why aren't the header sizes unsigned too?
Quoted 2 lines
They probably should all be unsigned and I should add a prep patch for the existing ones.
Sounds good!
--D
PATCH 12/34 xfs: devirtualize ->free_hdr_from_disk
In reply to Christoph HellwigReplace the ->free_hdr_from_disk dir ops method with a directly called xfs_dir_free_hdr_from_disk helper that takes care of the differences between the v4 and v5 on-disk format.
--- fs/xfs/libxfs/xfs_da_format.c | 30 ----------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_leaf.c | 14 +++-------- fs/xfs/libxfs/xfs_dir2_node.c | 46 +++++++++++++++++++++++++++-------- fs/xfs/libxfs/xfs_dir2_priv.h | 5 ++-- fs/xfs/scrub/dir.c | 2 +- 6 files changed, 43 insertions(+), 56 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -30
@@ -468,18 +468,6 @@ xfs_dir3_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)return db %xfs_dir3_free_max_bests (geo); } -static void -xfs_dir2_free_hdr_from_disk ( -struct xfs_dir3_icfree_hdr *to, -struct xfs_dir2_free *from) -{ - to->magic =be32_to_cpu (from->hdr.magic); - to->firstdb =be32_to_cpu (from->hdr.firstdb); - to->nvalid =be32_to_cpu (from->hdr.nvalid); - to->nused =be32_to_cpu (from->hdr.nused); -ASSERT (to->magic ==XFS_DIR2_FREE_MAGIC ); -} - static void xfs_dir2_free_hdr_to_disk( struct xfs_dir2_free *to,
@@ -493,21 +481,6 @@ xfs_dir2_free_hdr_to_disk( to->hdr.nused =cpu_to_be32 (from->nused); } -static void -xfs_dir3_free_hdr_from_disk ( -struct xfs_dir3_icfree_hdr *to, -struct xfs_dir2_free *from) -{ -struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)from; - - to->magic =be32_to_cpu (hdr3->hdr.magic); - to->firstdb =be32_to_cpu (hdr3->firstdb); - to->nvalid =be32_to_cpu (hdr3->nvalid); - to->nused =be32_to_cpu (hdr3->nused); - -ASSERT (to->magic ==XFS_DIR3_FREE_MAGIC ); -} - static void xfs_dir3_free_hdr_to_disk( struct xfs_dir2_free *to,
@@ -555,7 +528,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, - .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk, .free_max_bests = xfs_dir2_free_max_bests, .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb,
@@ -594,7 +566,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, - .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk, .free_max_bests = xfs_dir2_free_max_bests, .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb,
@@ -633,7 +604,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk, - .free_hdr_from_disk = xfs_dir3_free_hdr_from_disk, .free_max_bests = xfs_dir3_free_max_bests, .free_bests_p = xfs_dir3_free_bests_p, .db_to_fdb = xfs_dir3_db_to_fdb,
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -75,8 +75,6 @@ struct xfs_dir_ops {int free_hdr_size;void (*free_hdr_to_disk)(struct xfs_dir2_free *to,struct xfs_dir3_icfree_hdr *from); -void (*free_hdr_from_disk)(struct xfs_dir3_icfree_hdr *to, -struct xfs_dir2_free *from);int (*free_max_bests)(struct xfs_da_geometry *geo);__be16 * (*free_bests_p)(struct xfs_dir2_free *free); xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,
fs/xfs/libxfs/xfs_dir2_leaf.c +3 -11
@@ -113,7 +113,7 @@ xfs_dir3_leaf1_check( }else if (leafhdr.magic !=XFS_DIR2_LEAF1_MAGIC )return __this_address; -return xfs_dir3_leaf_check_int (dp->i_mount, dp, &leafhdr, leaf); +return xfs_dir3_leaf_check_int (dp->i_mount, &leafhdr, leaf); } static inline void
@@ -138,23 +138,15 @@ xfs_dir3_leaf_check(xfs_failaddr_t xfs_dir3_leaf_check_int (struct xfs_mount *mp, -struct xfs_inode *dp,struct xfs_dir3_icleaf_hdr *hdr,struct xfs_dir2_leaf *leaf) {xfs_dir2_leaf_tail_t *ltp;int stale;int i; -const struct xfs_dir_ops *ops;struct xfs_dir3_icleaf_hdr leafhdr;struct xfs_da_geometry *geo = mp->m_dir_geo; -/* -* we can be passed a null dp here from a verifier, so we need to go the -* hard way to get them. -*/ - ops =xfs_dir_get_ops (mp, dp); -if (!hdr) {xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); hdr = &leafhdr;
@@ -208,7 +200,7 @@ xfs_dir3_leaf_verify(if (fa)return fa; -return xfs_dir3_leaf_check_int (mp,NULL ,NULL , leaf); +return xfs_dir3_leaf_check_int (mp,NULL , leaf); } static void
@@ -1756,7 +1748,7 @@ xfs_dir2_node_to_leaf(if (error)return error; free = fbp->b_addr; - dp->d_ops->free_hdr_from_disk (&freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, &freehdr, free);ASSERT (!freehdr.firstdb);
fs/xfs/libxfs/xfs_dir2_node.c +36 -10
112 lines not on this page · raw message
fs/xfs/libxfs/xfs_dir2_priv.h +3 -2
@@ -104,10 +104,11 @@ xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,extern int xfs_dir2_node_to_leaf (struct xfs_da_state *state);extern xfs_failaddr_t xfs_dir3_leaf_check_int (struct xfs_mount *mp, -struct xfs_inode *dp,struct xfs_dir3_icleaf_hdr *hdr, -struct xfs_dir2_leaf *leaf); +struct xfs_dir3_icleaf_hdr *hdr,struct xfs_dir2_leaf *leaf);/* xfs_dir2_node.c */ +void xfs_dir2_free_hdr_from_disk (struct xfs_mount *mp, +struct xfs_dir3_icfree_hdr *to,struct xfs_dir2_free *from);extern int xfs_dir2_leaf_to_node (struct xfs_da_args *args,struct xfs_buf *lbp); extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp,
fs/xfs/scrub/dir.c +1 -1
@@ -601,7 +601,7 @@ xchk_directory_free_bestfree( }/* Check all the entries. */ - sc->ip->d_ops->free_hdr_from_disk (&freehdr, bp->b_addr); +xfs_dir2_free_hdr_from_disk (sc->ip->i_mount, &freehdr, bp->b_addr); bestp = sc->ip->d_ops->free_bests_p (bp->b_addr);for (i =0 ; i < freehdr.nvalid; i++, bestp++) { best =be16_to_cpu (*bestp);
Signature · 1 line
2.20.1
Re: [PATCH 12/34] xfs: devirtualize ->free_hdr_from_disk
Quoted 5 lines · Christoph Hellwig
Replace the ->free_hdr_from_disk dir ops method with a directly called
xfs_dir_free_hdr_from_diskhelper that takes care of the differences between the v4 and v5 on-disk format.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 307 lines
--- fs/xfs/libxfs/xfs_da_format.c | 30 ----------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_leaf.c | 14 +++-------- fs/xfs/libxfs/xfs_dir2_node.c | 46 +++++++++++++++++++++++++++-------- fs/xfs/libxfs/xfs_dir2_priv.h | 5 ++-- fs/xfs/scrub/dir.c | 2 +- 6 files changed, 43 insertions(+), 56 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-30@@ -468,18 +468,6 @@ xfs_dir3_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)return db %xfs_dir3_free_max_bests (geo); } -static void -xfs_dir2_free_hdr_from_disk ( -struct xfs_dir3_icfree_hdr *to, -struct xfs_dir2_free *from) -{ - to->magic =be32_to_cpu (from->hdr.magic); - to->firstdb =be32_to_cpu (from->hdr.firstdb); - to->nvalid =be32_to_cpu (from->hdr.nvalid); - to->nused =be32_to_cpu (from->hdr.nused); -ASSERT (to->magic ==XFS_DIR2_FREE_MAGIC ); -} - static void xfs_dir2_free_hdr_to_disk( struct xfs_dir2_free *to,@@ -493,21 +481,6 @@ xfs_dir2_free_hdr_to_disk( to->hdr.nused =cpu_to_be32 (from->nused); } -static void -xfs_dir3_free_hdr_from_disk ( -struct xfs_dir3_icfree_hdr *to, -struct xfs_dir2_free *from) -{ -struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)from; - - to->magic =be32_to_cpu (hdr3->hdr.magic); - to->firstdb =be32_to_cpu (hdr3->firstdb); - to->nvalid =be32_to_cpu (hdr3->nvalid); - to->nused =be32_to_cpu (hdr3->nused); - -ASSERT (to->magic ==XFS_DIR3_FREE_MAGIC ); -} - static void xfs_dir3_free_hdr_to_disk( struct xfs_dir2_free *to,@@ -555,7 +528,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, - .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk, .free_max_bests = xfs_dir2_free_max_bests, .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb,@@ -594,7 +566,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, - .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk, .free_max_bests = xfs_dir2_free_max_bests, .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb,@@ -633,7 +604,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk, - .free_hdr_from_disk = xfs_dir3_free_hdr_from_disk, .free_max_bests = xfs_dir3_free_max_bests, .free_bests_p = xfs_dir3_free_bests_p, .db_to_fdb = xfs_dir3_db_to_fdb,fs/xfs/libxfs/xfs_dir2.h +0
-2@@ -75,8 +75,6 @@ struct xfs_dir_ops {int free_hdr_size;void (*free_hdr_to_disk)(struct xfs_dir2_free *to,struct xfs_dir3_icfree_hdr *from); -void (*free_hdr_from_disk)(struct xfs_dir3_icfree_hdr *to, -struct xfs_dir2_free *from);int (*free_max_bests)(struct xfs_da_geometry *geo);__be16 * (*free_bests_p)(struct xfs_dir2_free *free); xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,fs/xfs/libxfs/xfs_dir2_leaf.c +3
-11@@ -113,7 +113,7 @@ xfs_dir3_leaf1_check( }else if (leafhdr.magic !=XFS_DIR2_LEAF1_MAGIC )return __this_address; -return xfs_dir3_leaf_check_int (dp->i_mount, dp, &leafhdr, leaf); +return xfs_dir3_leaf_check_int (dp->i_mount, &leafhdr, leaf); } static inline void@@ -138,23 +138,15 @@ xfs_dir3_leaf_check(xfs_failaddr_t xfs_dir3_leaf_check_int (struct xfs_mount *mp, -struct xfs_inode *dp,struct xfs_dir3_icleaf_hdr *hdr,struct xfs_dir2_leaf *leaf) {xfs_dir2_leaf_tail_t *ltp;int stale;int i; -const struct xfs_dir_ops *ops;struct xfs_dir3_icleaf_hdr leafhdr;struct xfs_da_geometry *geo = mp->m_dir_geo; -/* -* we can be passed a null dp here from a verifier, so we need to go the -* hard way to get them. -*/ - ops =xfs_dir_get_ops (mp, dp); -if (!hdr) {xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); hdr = &leafhdr;@@ -208,7 +200,7 @@ xfs_dir3_leaf_verify(if (fa)return fa; -return xfs_dir3_leaf_check_int (mp,NULL ,NULL , leaf); +return xfs_dir3_leaf_check_int (mp,NULL , leaf); } static void@@ -1756,7 +1748,7 @@ xfs_dir2_node_to_leaf(if (error)return error; free = fbp->b_addr; - dp->d_ops->free_hdr_from_disk (&freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, &freehdr, free);ASSERT (!freehdr.firstdb);fs/xfs/libxfs/xfs_dir2_node.c +36
-10@@ -54,7 +54,7 @@ xfs_dir3_leafn_check( }else if (leafhdr.magic !=XFS_DIR2_LEAFN_MAGIC )return __this_address; -return xfs_dir3_leaf_check_int (dp->i_mount, dp, &leafhdr, leaf); +return xfs_dir3_leaf_check_int (dp->i_mount, &leafhdr, leaf); } static inline void@@ -220,6 +220,30 @@ __xfs_dir3_free_read(return 0 ; } +void +xfs_dir2_free_hdr_from_disk ( +struct xfs_mount *mp, +struct xfs_dir3_icfree_hdr *to, +struct xfs_dir2_free *from) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_dir3_free *from3 = (struct xfs_dir3_free *)from; + + to->magic =be32_to_cpu (from3->hdr.hdr.magic); + to->firstdb =be32_to_cpu (from3->hdr.firstdb); + to->nvalid =be32_to_cpu (from3->hdr.nvalid); + to->nused =be32_to_cpu (from3->hdr.nused); + +ASSERT (to->magic ==XFS_DIR3_FREE_MAGIC ); + }else { + to->magic =be32_to_cpu (from->hdr.magic); + to->firstdb =be32_to_cpu (from->hdr.firstdb); + to->nvalid =be32_to_cpu (from->hdr.nvalid); + to->nused =be32_to_cpu (from->hdr.nused); +ASSERT (to->magic ==XFS_DIR2_FREE_MAGIC ); + } +} + int xfs_dir2_free_read( struct xfs_trans *tp,@@ -369,7 +393,7 @@ xfs_dir2_leaf_to_node(return error; free = fbp->b_addr; - dp->d_ops->free_hdr_from_disk (&freehdr, free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); leaf = lbp->b_addr; ltp =xfs_dir2_leaf_tail_p (args->geo, leaf); if (be32_to_cpu(ltp->bestcount) >@@ -509,7 +533,7 @@ xfs_dir2_free_hdr_check( {struct xfs_dir3_icfree_hdr hdr; - dp->d_ops->free_hdr_from_disk (&hdr, bp->b_addr); +xfs_dir2_free_hdr_from_disk (dp->i_mount, &hdr, bp->b_addr);ASSERT ((hdr.firstdb % dp->d_ops->free_max_bests (dp->i_mount->m_dir_geo)) ==0 );@@ -1117,7 +1141,7 @@ xfs_dir3_data_block_free(struct xfs_dir3_icfree_hdr freehdr;struct xfs_inode *dp = args->dp; - dp->d_ops->free_hdr_from_disk (&freehdr, free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); bests = dp->d_ops->free_bests_p (free);if (hdr) {/* @@ -1286,7 +1310,8 @@ xfs_dir2_leafn_remove(#ifdef DEBUG {struct xfs_dir3_icfree_hdr freehdr; - dp->d_ops->free_hdr_from_disk (&freehdr, free); + +xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free);ASSERT (freehdr.firstdb == dp->d_ops->free_max_bests (args->geo) * (fdb -xfs_dir2_byte_to_db (args->geo,XFS_DIR2_FREE_OFFSET )));@@ -1680,7 +1705,7 @@ xfs_dir2_node_add_datablk(return error; free = fbp->b_addr; bests = dp->d_ops->free_bests_p (free); - dp->d_ops->free_hdr_from_disk (&freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, &freehdr, free);/* Remember the first slot as our empty slot. */ freehdr.firstdb = (fbno - xfs_dir2_byte_to_db(args->geo,@@ -1689,7 +1714,7 @@ xfs_dir2_node_add_datablk( }else { free = fbp->b_addr; bests = dp->d_ops->free_bests_p (free); - dp->d_ops->free_hdr_from_disk (&freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, &freehdr, free); }/* Set the freespace block index from the data block number. */ @@ -1758,7 +1783,8 @@ xfs_dir2_node_find_freeblk(if (findex >=0 ) {/* caller already found the freespace for us. */ bests = dp->d_ops->free_bests_p (free); - dp->d_ops->free_hdr_from_disk (&freehdr, free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, + free);ASSERT (findex < freehdr.nvalid);ASSERT (be16_to_cpu (bests[findex]) !=NULLDATAOFF );@@ -1807,7 +1833,7 @@ xfs_dir2_node_find_freeblk( free = fbp->b_addr; bests = dp->d_ops->free_bests_p (free); - dp->d_ops->free_hdr_from_disk (&freehdr, free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free);/* Scan the free entry array for a large enough free space. */ for (findex = freehdr.nvalid -1 ; findex >=0 ; findex--) {@@ -2260,7 +2286,7 @@ xfs_dir2_node_trim_free(if (!bp)return 0 ; free = bp->b_addr; - dp->d_ops->free_hdr_from_disk (&freehdr, free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free);/* * If there are used entries, there's nothing to do. fs/xfs/libxfs/xfs_dir2_priv.h +3
-2@@ -104,10 +104,11 @@ xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,extern int xfs_dir2_node_to_leaf (struct xfs_da_state *state);extern xfs_failaddr_t xfs_dir3_leaf_check_int (struct xfs_mount *mp, -struct xfs_inode *dp,struct xfs_dir3_icleaf_hdr *hdr, -struct xfs_dir2_leaf *leaf); +struct xfs_dir3_icleaf_hdr *hdr,struct xfs_dir2_leaf *leaf);/* xfs_dir2_node.c */ +void xfs_dir2_free_hdr_from_disk (struct xfs_mount *mp, +struct xfs_dir3_icfree_hdr *to,struct xfs_dir2_free *from);extern int xfs_dir2_leaf_to_node (struct xfs_da_args *args,struct xfs_buf *lbp); extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp,fs/xfs/scrub/dir.c +1
-1@@ -601,7 +601,7 @@ xchk_directory_free_bestfree( }/* Check all the entries. */ - sc->ip->d_ops->free_hdr_from_disk (&freehdr, bp->b_addr); +xfs_dir2_free_hdr_from_disk (sc->ip->i_mount, &freehdr, bp->b_addr); bestp = sc->ip->d_ops->free_bests_p (bp->b_addr);for (i =0 ; i < freehdr.nvalid; i++, bestp++) { best =be16_to_cpu (*bestp);Signature · 1 line
2.20.1
PATCH 13/34 xfs: devirtualize ->free_hdr_to_disk
In reply to Christoph HellwigReplace the ->free_hdr_to_disk dir ops method with a directly called xfs_dir2_free_hdr_to_disk helper that takes care of the differences between the v4 and v5 on-disk format.
--- fs/xfs/libxfs/xfs_da_format.c | 31 ------------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_node.c | 33 +++++++++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 37 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -31
@@ -468,34 +468,6 @@ xfs_dir3_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)return db %xfs_dir3_free_max_bests (geo); } -static void -xfs_dir2_free_hdr_to_disk ( -struct xfs_dir2_free *to, -struct xfs_dir3_icfree_hdr *from) -{ -ASSERT (from->magic ==XFS_DIR2_FREE_MAGIC ); - - to->hdr.magic =cpu_to_be32 (from->magic); - to->hdr.firstdb =cpu_to_be32 (from->firstdb); - to->hdr.nvalid =cpu_to_be32 (from->nvalid); - to->hdr.nused =cpu_to_be32 (from->nused); -} - -static void -xfs_dir3_free_hdr_to_disk ( -struct xfs_dir2_free *to, -struct xfs_dir3_icfree_hdr *from) -{ -struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)to; - -ASSERT (from->magic ==XFS_DIR3_FREE_MAGIC ); - - hdr3->hdr.magic =cpu_to_be32 (from->magic); - hdr3->firstdb =cpu_to_be32 (from->firstdb); - hdr3->nvalid =cpu_to_be32 (from->nvalid); - hdr3->nused =cpu_to_be32 (from->nused); -} -static const struct xfs_dir_ops xfs_dir2_ops = { .sf_entsize = xfs_dir2_sf_entsize, .sf_nextentry = xfs_dir2_sf_nextentry,
@@ -527,7 +499,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_unused_p = xfs_dir2_data_unused_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), - .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_max_bests = xfs_dir2_free_max_bests, .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb,
@@ -565,7 +536,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_unused_p = xfs_dir2_data_unused_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), - .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_max_bests = xfs_dir2_free_max_bests, .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb,
@@ -603,7 +573,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_unused_p = xfs_dir3_data_unused_p, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), - .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk, .free_max_bests = xfs_dir3_free_max_bests, .free_bests_p = xfs_dir3_free_bests_p, .db_to_fdb = xfs_dir3_db_to_fdb,
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -73,8 +73,6 @@ struct xfs_dir_ops { (*data_unused_p)(struct xfs_dir2_data_hdr *hdr);int free_hdr_size; -void (*free_hdr_to_disk)(struct xfs_dir2_free *to, -struct xfs_dir3_icfree_hdr *from);int (*free_max_bests)(struct xfs_da_geometry *geo);__be16 * (*free_bests_p)(struct xfs_dir2_free *free); xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,
fs/xfs/libxfs/xfs_dir2_node.c +29 -4
@@ -244,6 +244,31 @@ xfs_dir2_free_hdr_from_disk( } } +static void +xfs_dir2_free_hdr_to_disk ( +struct xfs_mount *mp, +struct xfs_dir2_free *to, +struct xfs_dir3_icfree_hdr *from) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_dir3_free *to3 = (struct xfs_dir3_free *)to; + +ASSERT (from->magic ==XFS_DIR3_FREE_MAGIC ); + + to3->hdr.hdr.magic =cpu_to_be32 (from->magic); + to3->hdr.firstdb =cpu_to_be32 (from->firstdb); + to3->hdr.nvalid =cpu_to_be32 (from->nvalid); + to3->hdr.nused =cpu_to_be32 (from->nused); + }else { +ASSERT (from->magic ==XFS_DIR2_FREE_MAGIC ); + + to->hdr.magic =cpu_to_be32 (from->magic); + to->hdr.firstdb =cpu_to_be32 (from->firstdb); + to->hdr.nvalid =cpu_to_be32 (from->nvalid); + to->hdr.nused =cpu_to_be32 (from->nused); + } +} + int xfs_dir2_free_read( struct xfs_trans *tp,
@@ -302,7 +327,7 @@ xfs_dir3_free_get_buf(uuid_copy (&hdr3->hdr.uuid, &mp->m_sb.sb_meta_uuid); }else hdr.magic =XFS_DIR2_FREE_MAGIC ; - dp->d_ops->free_hdr_to_disk (bp->b_addr, &hdr); +xfs_dir2_free_hdr_to_disk (mp, bp->b_addr, &hdr); *bpp = bp;return 0 ; }
@@ -418,7 +443,7 @@ xfs_dir2_leaf_to_node( freehdr.nused = n; freehdr.nvalid =be32_to_cpu (ltp->bestcount); - dp->d_ops->free_hdr_to_disk (fbp->b_addr, &freehdr); +xfs_dir2_free_hdr_to_disk (dp->i_mount, fbp->b_addr, &freehdr);xfs_dir2_free_log_bests (args, fbp,0 , freehdr.nvalid -1 );xfs_dir2_free_log_header (args, fbp);
@@ -1176,7 +1201,7 @@ xfs_dir3_data_block_free( logfree =1 ; } - dp->d_ops->free_hdr_to_disk (free, &freehdr); +xfs_dir2_free_hdr_to_disk (dp->i_mount, free, &freehdr);xfs_dir2_free_log_header (args, fbp);/*
@@ -1733,7 +1758,7 @@ xfs_dir2_node_add_datablk(*/ if (bests[*findex] ==cpu_to_be16 (NULLDATAOFF )) { freehdr.nused++; - dp->d_ops->free_hdr_to_disk (fbp->b_addr, &freehdr); +xfs_dir2_free_hdr_to_disk (mp, fbp->b_addr, &freehdr);xfs_dir2_free_log_header (args, fbp); }
Signature · 1 line
2.20.1
Re: [PATCH 13/34] xfs: devirtualize ->free_hdr_to_disk
Quoted 5 lines · Christoph Hellwig
Replace the ->free_hdr_to_disk dir ops method with a directly called
xfs_dir2_free_hdr_to_diskhelper that takes care of the differences between the v4 and v5 on-disk format.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 157 lines
--- fs/xfs/libxfs/xfs_da_format.c | 31 ------------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- fs/xfs/libxfs/xfs_dir2_node.c | 33 +++++++++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 37 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-31@@ -468,34 +468,6 @@ xfs_dir3_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)return db %xfs_dir3_free_max_bests (geo); } -static void -xfs_dir2_free_hdr_to_disk ( -struct xfs_dir2_free *to, -struct xfs_dir3_icfree_hdr *from) -{ -ASSERT (from->magic ==XFS_DIR2_FREE_MAGIC ); - - to->hdr.magic =cpu_to_be32 (from->magic); - to->hdr.firstdb =cpu_to_be32 (from->firstdb); - to->hdr.nvalid =cpu_to_be32 (from->nvalid); - to->hdr.nused =cpu_to_be32 (from->nused); -} - -static void -xfs_dir3_free_hdr_to_disk ( -struct xfs_dir2_free *to, -struct xfs_dir3_icfree_hdr *from) -{ -struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)to; - -ASSERT (from->magic ==XFS_DIR3_FREE_MAGIC ); - - hdr3->hdr.magic =cpu_to_be32 (from->magic); - hdr3->firstdb =cpu_to_be32 (from->firstdb); - hdr3->nvalid =cpu_to_be32 (from->nvalid); - hdr3->nused =cpu_to_be32 (from->nused); -} -static const struct xfs_dir_ops xfs_dir2_ops = { .sf_entsize = xfs_dir2_sf_entsize, .sf_nextentry = xfs_dir2_sf_nextentry,@@ -527,7 +499,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_unused_p = xfs_dir2_data_unused_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), - .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_max_bests = xfs_dir2_free_max_bests, .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb,@@ -565,7 +536,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_unused_p = xfs_dir2_data_unused_p, .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), - .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk, .free_max_bests = xfs_dir2_free_max_bests, .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb,@@ -603,7 +573,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_unused_p = xfs_dir3_data_unused_p, .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), - .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk, .free_max_bests = xfs_dir3_free_max_bests, .free_bests_p = xfs_dir3_free_bests_p, .db_to_fdb = xfs_dir3_db_to_fdb,fs/xfs/libxfs/xfs_dir2.h +0
-2@@ -73,8 +73,6 @@ struct xfs_dir_ops { (*data_unused_p)(struct xfs_dir2_data_hdr *hdr);int free_hdr_size; -void (*free_hdr_to_disk)(struct xfs_dir2_free *to, -struct xfs_dir3_icfree_hdr *from);int (*free_max_bests)(struct xfs_da_geometry *geo);__be16 * (*free_bests_p)(struct xfs_dir2_free *free); xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,fs/xfs/libxfs/xfs_dir2_node.c +29
-4@@ -244,6 +244,31 @@ xfs_dir2_free_hdr_from_disk( } } +static void +xfs_dir2_free_hdr_to_disk ( +struct xfs_mount *mp, +struct xfs_dir2_free *to, +struct xfs_dir3_icfree_hdr *from) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_dir3_free *to3 = (struct xfs_dir3_free *)to; + +ASSERT (from->magic ==XFS_DIR3_FREE_MAGIC ); + + to3->hdr.hdr.magic =cpu_to_be32 (from->magic); + to3->hdr.firstdb =cpu_to_be32 (from->firstdb); + to3->hdr.nvalid =cpu_to_be32 (from->nvalid); + to3->hdr.nused =cpu_to_be32 (from->nused); + }else { +ASSERT (from->magic ==XFS_DIR2_FREE_MAGIC ); + + to->hdr.magic =cpu_to_be32 (from->magic); + to->hdr.firstdb =cpu_to_be32 (from->firstdb); + to->hdr.nvalid =cpu_to_be32 (from->nvalid); + to->hdr.nused =cpu_to_be32 (from->nused); + } +} + int xfs_dir2_free_read( struct xfs_trans *tp,@@ -302,7 +327,7 @@ xfs_dir3_free_get_buf(uuid_copy (&hdr3->hdr.uuid, &mp->m_sb.sb_meta_uuid); }else hdr.magic =XFS_DIR2_FREE_MAGIC ; - dp->d_ops->free_hdr_to_disk (bp->b_addr, &hdr); +xfs_dir2_free_hdr_to_disk (mp, bp->b_addr, &hdr); *bpp = bp;return 0 ; }@@ -418,7 +443,7 @@ xfs_dir2_leaf_to_node( freehdr.nused = n; freehdr.nvalid =be32_to_cpu (ltp->bestcount); - dp->d_ops->free_hdr_to_disk (fbp->b_addr, &freehdr); +xfs_dir2_free_hdr_to_disk (dp->i_mount, fbp->b_addr, &freehdr);xfs_dir2_free_log_bests (args, fbp,0 , freehdr.nvalid -1 );xfs_dir2_free_log_header (args, fbp);@@ -1176,7 +1201,7 @@ xfs_dir3_data_block_free( logfree =1 ; } - dp->d_ops->free_hdr_to_disk (free, &freehdr); +xfs_dir2_free_hdr_to_disk (dp->i_mount, free, &freehdr);xfs_dir2_free_log_header (args, fbp);/* @@ -1733,7 +1758,7 @@ xfs_dir2_node_add_datablk(*/ if (bests[*findex] ==cpu_to_be16 (NULLDATAOFF )) { freehdr.nused++; - dp->d_ops->free_hdr_to_disk (fbp->b_addr, &freehdr); +xfs_dir2_free_hdr_to_disk (mp, fbp->b_addr, &freehdr);xfs_dir2_free_log_header (args, fbp); }Signature · 1 line
2.20.1
PATCH 14/34 xfs: make the xfs_dir3_icfree_hdr available to xfs_dir2_node_addname_int
In reply to Christoph HellwigReturn the xfs_dir3_icfree_hdr used by the helpers called from xfs_dir2_node_addname_int to the main function to prepare for the next round of changes.
--- fs/xfs/libxfs/xfs_dir2_node.c | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-)
fs/xfs/libxfs/xfs_dir2_node.c +20 -22
@@ -1660,14 +1660,13 @@ xfs_dir2_node_add_datablk(xfs_dir2_db_t *dbno, struct xfs_buf **dbpp, struct xfs_buf **fbpp, + struct xfs_dir3_icfree_hdr *hdr, int *findex) { struct xfs_inode *dp = args->dp;struct xfs_trans *tp = args->trans;struct xfs_mount *mp = dp->i_mount; -struct xfs_dir3_icfree_hdr freehdr;struct xfs_dir2_data_free *bf; -struct xfs_dir2_data_hdr *hdr;struct xfs_dir2_free *free =NULL ;xfs_dir2_db_t fbno;struct xfs_buf *fbp;
@@ -1730,25 +1729,25 @@ xfs_dir2_node_add_datablk(return error; free = fbp->b_addr; bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (mp, &freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, hdr, free);/* Remember the first slot as our empty slot. */ - freehdr.firstdb = (fbno -xfs_dir2_byte_to_db (args->geo, + hdr->firstdb = (fbno -xfs_dir2_byte_to_db (args->geo,XFS_DIR2_FREE_OFFSET )) * dp->d_ops->free_max_bests (args->geo); }else { free = fbp->b_addr; bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (mp, &freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, hdr, free); }/* Set the freespace block index from the data block number. */ *findex = dp->d_ops->db_to_fdindex (args->geo, *dbno);/* Extend the freespace table if the new data block is off the end. */ -if (*findex >= freehdr.nvalid) { +if (*findex >= hdr->nvalid) {ASSERT (*findex < dp->d_ops->free_max_bests (args->geo)); - freehdr.nvalid = *findex +1 ; + hdr->nvalid = *findex +1 ; bests[*findex] =cpu_to_be16 (NULLDATAOFF ); }
@@ -1757,14 +1756,13 @@ xfs_dir2_node_add_datablk(* true) then update the header. */ if (bests[*findex] ==cpu_to_be16 (NULLDATAOFF )) { - freehdr.nused++; -xfs_dir2_free_hdr_to_disk (mp, fbp->b_addr, &freehdr); + hdr->nused++; +xfs_dir2_free_hdr_to_disk (mp, fbp->b_addr, hdr);xfs_dir2_free_log_header (args, fbp); }/* Update the freespace value for the new block in the table. */ - hdr = dbp->b_addr; - bf = dp->d_ops->data_bestfree_p (hdr); + bf = dp->d_ops->data_bestfree_p (dbp->b_addr); bests[*findex] = bf[0 ].length; *dbpp = dbp;
@@ -1778,10 +1776,10 @@ xfs_dir2_node_find_freeblk(struct xfs_da_state_blk *fblk, xfs_dir2_db_t *dbnop, struct xfs_buf **fbpp, + struct xfs_dir3_icfree_hdr *hdr, int *findexp, int length) { - struct xfs_dir3_icfree_hdr freehdr; struct xfs_dir2_free *free = NULL;struct xfs_inode *dp = args->dp;struct xfs_trans *tp = args->trans;
@@ -1808,13 +1806,12 @@ xfs_dir2_node_find_freeblk(if (findex >=0 ) {/* caller already found the freespace for us. */ bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, - free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, hdr, free); -ASSERT (findex < freehdr.nvalid); +ASSERT (findex < hdr->nvalid);ASSERT (be16_to_cpu (bests[findex]) !=NULLDATAOFF );ASSERT (be16_to_cpu (bests[findex]) >= length); - dbno = freehdr.firstdb + findex; + dbno = hdr->firstdb + findex; goto found_block; }
@@ -1858,13 +1855,13 @@ xfs_dir2_node_find_freeblk( free = fbp->b_addr; bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, hdr, free);/* Scan the free entry array for a large enough free space. */ -for (findex = freehdr.nvalid -1 ; findex >=0 ; findex--) { +for (findex = hdr->nvalid -1 ; findex >=0 ; findex--) {if (be16_to_cpu (bests[findex]) !=NULLDATAOFF &&be16_to_cpu (bests[findex]) >= length) { - dbno = freehdr.firstdb + findex; + dbno = hdr->firstdb + findex; goto found_block; } }
@@ -1898,6 +1895,7 @@ xfs_dir2_node_addname_int(struct xfs_dir2_free *free =NULL ;/* freespace block structure */ struct xfs_trans *tp = args->trans;struct xfs_inode *dp = args->dp; +struct xfs_dir3_icfree_hdr freehdr;struct xfs_buf *dbp;/* data block buffer */ struct xfs_buf *fbp;/* freespace buffer */ xfs_dir2_data_aoff_t aoff;
@@ -1912,8 +1910,8 @@ xfs_dir2_node_addname_int(__be16 *bests; length = dp->d_ops->data_entsize (args->namelen); - error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &findex, - length); + error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &freehdr, + &findex, length);if (error)return error;
@@ -1935,7 +1933,7 @@ xfs_dir2_node_addname_int(/* we're going to have to log the free block index later */ logfree =1 ; error =xfs_dir2_node_add_datablk (args, fblk, &dbno, &dbp, &fbp, - &findex); + &freehdr, &findex); }else {/* Read the data block in. */ error = xfs_dir3_data_read(tp, dp,
Signature · 1 line
2.20.1
Re: [PATCH 14/34] xfs: make the xfs_dir3_icfree_hdr available to xfs_dir2_node_addname_int
Quoted 3 lines · Christoph Hellwig
Return the
xfs_dir3_icfree_hdrused by the helpers called fromxfs_dir2_node_addname_intto the main function to prepare for the next round of changes.
How does this help? Is this purely to reduce stack usage? Or will we use this later to skip some xfs_dir2_free_hdr_from_disk calls?
--D
Quoted 151 lines
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_dir2_node.c | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-)fs/xfs/libxfs/xfs_dir2_node.c +20
-22@@ -1660,14 +1660,13 @@ xfs_dir2_node_add_datablk(xfs_dir2_db_t *dbno, struct xfs_buf **dbpp, struct xfs_buf **fbpp, + struct xfs_dir3_icfree_hdr *hdr, int *findex) { struct xfs_inode *dp = args->dp;struct xfs_trans *tp = args->trans;struct xfs_mount *mp = dp->i_mount; -struct xfs_dir3_icfree_hdr freehdr;struct xfs_dir2_data_free *bf; -struct xfs_dir2_data_hdr *hdr;struct xfs_dir2_free *free =NULL ;xfs_dir2_db_t fbno;struct xfs_buf *fbp;@@ -1730,25 +1729,25 @@ xfs_dir2_node_add_datablk(return error; free = fbp->b_addr; bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (mp, &freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, hdr, free);/* Remember the first slot as our empty slot. */ - freehdr.firstdb = (fbno -xfs_dir2_byte_to_db (args->geo, + hdr->firstdb = (fbno -xfs_dir2_byte_to_db (args->geo,XFS_DIR2_FREE_OFFSET )) * dp->d_ops->free_max_bests (args->geo); }else { free = fbp->b_addr; bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (mp, &freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, hdr, free); }/* Set the freespace block index from the data block number. */ *findex = dp->d_ops->db_to_fdindex (args->geo, *dbno);/* Extend the freespace table if the new data block is off the end. */ -if (*findex >= freehdr.nvalid) { +if (*findex >= hdr->nvalid) {ASSERT (*findex < dp->d_ops->free_max_bests (args->geo)); - freehdr.nvalid = *findex +1 ; + hdr->nvalid = *findex +1 ; bests[*findex] =cpu_to_be16 (NULLDATAOFF ); }@@ -1757,14 +1756,13 @@ xfs_dir2_node_add_datablk(* true) then update the header. */ if (bests[*findex] ==cpu_to_be16 (NULLDATAOFF )) { - freehdr.nused++; -xfs_dir2_free_hdr_to_disk (mp, fbp->b_addr, &freehdr); + hdr->nused++; +xfs_dir2_free_hdr_to_disk (mp, fbp->b_addr, hdr);xfs_dir2_free_log_header (args, fbp); }/* Update the freespace value for the new block in the table. */ - hdr = dbp->b_addr; - bf = dp->d_ops->data_bestfree_p (hdr); + bf = dp->d_ops->data_bestfree_p (dbp->b_addr); bests[*findex] = bf[0 ].length; *dbpp = dbp;@@ -1778,10 +1776,10 @@ xfs_dir2_node_find_freeblk(struct xfs_da_state_blk *fblk, xfs_dir2_db_t *dbnop, struct xfs_buf **fbpp, + struct xfs_dir3_icfree_hdr *hdr, int *findexp, int length) { - struct xfs_dir3_icfree_hdr freehdr; struct xfs_dir2_free *free = NULL;struct xfs_inode *dp = args->dp;struct xfs_trans *tp = args->trans;@@ -1808,13 +1806,12 @@ xfs_dir2_node_find_freeblk(if (findex >=0 ) {/* caller already found the freespace for us. */ bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, - free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, hdr, free); -ASSERT (findex < freehdr.nvalid); +ASSERT (findex < hdr->nvalid);ASSERT (be16_to_cpu (bests[findex]) !=NULLDATAOFF );ASSERT (be16_to_cpu (bests[findex]) >= length); - dbno = freehdr.firstdb + findex; + dbno = hdr->firstdb + findex; goto found_block; }@@ -1858,13 +1855,13 @@ xfs_dir2_node_find_freeblk( free = fbp->b_addr; bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, hdr, free);/* Scan the free entry array for a large enough free space. */ -for (findex = freehdr.nvalid -1 ; findex >=0 ; findex--) { +for (findex = hdr->nvalid -1 ; findex >=0 ; findex--) {if (be16_to_cpu (bests[findex]) !=NULLDATAOFF &&be16_to_cpu (bests[findex]) >= length) { - dbno = freehdr.firstdb + findex; + dbno = hdr->firstdb + findex; goto found_block; } }@@ -1898,6 +1895,7 @@ xfs_dir2_node_addname_int(struct xfs_dir2_free *free =NULL ;/* freespace block structure */ struct xfs_trans *tp = args->trans;struct xfs_inode *dp = args->dp; +struct xfs_dir3_icfree_hdr freehdr;struct xfs_buf *dbp;/* data block buffer */ struct xfs_buf *fbp;/* freespace buffer */ xfs_dir2_data_aoff_t aoff;@@ -1912,8 +1910,8 @@ xfs_dir2_node_addname_int(__be16 *bests; length = dp->d_ops->data_entsize (args->namelen); - error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &findex, - length); + error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &freehdr, + &findex, length);if (error)return error;@@ -1935,7 +1933,7 @@ xfs_dir2_node_addname_int(/* we're going to have to log the free block index later */ logfree =1 ; error =xfs_dir2_node_add_datablk (args, fblk, &dbno, &dbp, &fbp, - &findex); + &freehdr, &findex); }else {/* Read the data block in. */ error = xfs_dir3_data_read(tp, dp,Signature · 1 line
2.20.1
Re: [PATCH 14/34] xfs: make the xfs_dir3_icfree_hdr available to xfs_dir2_node_addname_int
Quoted 7 lines · Darrick J. Wong
Quoted 3 lines · Christoph Hellwig
Return the
xfs_dir3_icfree_hdrused by the helpers called fromxfs_dir2_node_addname_intto the main function to prepare for the next round of changes.How does this help? Is this purely to reduce stack usage? Or will we use this later to skip some
xfs_dir2_free_hdr_from_diskcalls?
The latter.
Re: [PATCH 14/34] xfs: make the xfs_dir3_icfree_hdr available to xfs_dir2_node_addname_int
Quoted 10 lines · Christoph Hellwig
Quoted 7 lines · Darrick J. Wong
Quoted 3 lines · Christoph Hellwig
Return the
xfs_dir3_icfree_hdrused by the helpers called fromxfs_dir2_node_addname_intto the main function to prepare for the next round of changes.How does this help? Is this purely to reduce stack usage? Or will we use this later to skip some
xfs_dir2_free_hdr_from_diskcalls?The latter.
Might be a good idea at least to hint at that in the commit message.
--D
PATCH 15/34 xfs: add a bests pointer to struct xfs_dir3_icfree_hdr
In reply to Christoph HellwigAll but two callers of the ->free_bests_p dir operation already have a struct xfs_dir3_icfree_hdr from a previous call to xfs_dir2_free_hdr_from_disk at hand. Add a pointer to the bests to struct xfs_dir3_icfree_hdr to clean up this pattern. To optimize this pattern, pass the struct xfs_dir3_icfree_hdr to xfs_dir2_free_log_bests instead of recalculating the pointer there.
--- fs/xfs/libxfs/xfs_da_format.c | 15 ------ fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 97 ++++++++++++++--------------------- fs/xfs/libxfs/xfs_dir2_priv.h | 1 + fs/xfs/scrub/dir.c | 6 +-- 6 files changed, 43 insertions(+), 83 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -15
@@ -411,12 +411,6 @@ xfs_dir2_free_max_bests(struct xfs_da_geometry *geo)sizeof (xfs_dir2_data_off_t); } -static __be16 * -xfs_dir2_free_bests_p (struct xfs_dir2_free *free) -{ -return (__be16 *)((char *)free +sizeof (struct xfs_dir2_free_hdr )); -} -/* * Convert data space db to the corresponding free db. */
@@ -443,12 +437,6 @@ xfs_dir3_free_max_bests(struct xfs_da_geometry *geo)sizeof (xfs_dir2_data_off_t); } -static __be16 * -xfs_dir3_free_bests_p (struct xfs_dir2_free *free) -{ -return (__be16 *)((char *)free +sizeof (struct xfs_dir3_free_hdr )); -} -/* * Convert data space db to the corresponding free db. */
@@ -500,7 +488,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_max_bests = xfs_dir2_free_max_bests, - .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex, };
@@ -537,7 +524,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_max_bests = xfs_dir2_free_max_bests, - .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex, };
@@ -574,7 +560,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_max_bests = xfs_dir3_free_max_bests, - .free_bests_p = xfs_dir3_free_bests_p, .db_to_fdb = xfs_dir3_db_to_fdb, .db_to_fdindex = xfs_dir3_db_to_fdindex, };
fs/xfs/libxfs/xfs_dir2.h +0 -1
@@ -74,7 +74,6 @@ struct xfs_dir_ops {int free_hdr_size;int (*free_max_bests)(struct xfs_da_geometry *geo); -__be16 * (*free_bests_p)(struct xfs_dir2_free *free);xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,xfs_dir2_db_t db); int (*db_to_fdindex)(struct xfs_da_geometry *geo,
fs/xfs/libxfs/xfs_dir2_leaf.c +2 -4
@@ -1678,7 +1678,6 @@ xfs_dir2_node_to_leaf(int error;/* error return code */ struct xfs_buf *fbp;/* buffer for freespace block */ xfs_fileoff_t fo;/* freespace file offset */ -xfs_dir2_free_t *free;/* freespace structure */ struct xfs_buf *lbp;/* buffer for leaf block */ xfs_dir2_leaf_tail_t *ltp;/* tail of leaf structure */ xfs_dir2_leaf_t *leaf;/* leaf structure */
@@ -1747,8 +1746,7 @@ xfs_dir2_node_to_leaf( error =xfs_dir2_free_read (tp, dp, args->geo->freeblk, &fbp);if (error)return error; - free = fbp->b_addr; -xfs_dir2_free_hdr_from_disk (mp, &freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, &freehdr, fbp->b_addr);ASSERT (!freehdr.firstdb);
@@ -1782,7 +1780,7 @@ xfs_dir2_node_to_leaf(/* * Set up the leaf bests table. */ -memcpy (xfs_dir2_leaf_bests_p (ltp), dp->d_ops->free_bests_p (free), +memcpy (xfs_dir2_leaf_bests_p (ltp), freehdr.bests, freehdr.nvalid *sizeof (xfs_dir2_data_off_t));xfs_dir2_leaf_hdr_to_disk (mp, leaf, &leafhdr);
fs/xfs/libxfs/xfs_dir2_node.c +38 -59
304 lines not on this page · raw message
fs/xfs/libxfs/xfs_dir2_priv.h +1 -0
@@ -26,6 +26,7 @@ struct xfs_dir3_icfree_hdr {uint32_t firstdb;uint32_t nvalid;uint32_t nused; +__be16 *bests; };/* xfs_dir2.c */
fs/xfs/scrub/dir.c +2 -4
@@ -581,7 +581,6 @@ xchk_directory_free_bestfree(struct xfs_dir3_icfree_hdr freehdr;struct xfs_buf *dbp;struct xfs_buf *bp; -__be16 *bestp;__u16 best;unsigned int stale =0 ;int i;
@@ -602,9 +601,8 @@ xchk_directory_free_bestfree(/* Check all the entries. */ xfs_dir2_free_hdr_from_disk (sc->ip->i_mount, &freehdr, bp->b_addr); - bestp = sc->ip->d_ops->free_bests_p (bp->b_addr); -for (i =0 ; i < freehdr.nvalid; i++, bestp++) { - best =be16_to_cpu (*bestp); +for (i =0 ; i < freehdr.nvalid; i++) { + best =be16_to_cpu (freehdr.bests[i]);if (best ==NULLDATAOFF ) { stale++;continue ;
Signature · 1 line
2.20.1
Re: [PATCH 15/34] xfs: add a bests pointer to struct xfs_dir3_icfree_hdr
Quoted 119 lines · Christoph Hellwig
All but two callers of the ->free_bests_p dir operation already have a struct
xfs_dir3_icfree_hdrfrom a previous call toxfs_dir2_free_hdr_from_diskat hand. Add a pointer to the bests to structxfs_dir3_icfree_hdrto clean up this pattern. To optimize this pattern, pass the structxfs_dir3_icfree_hdrtoxfs_dir2_free_log_bestsinstead of recalculating the pointer there.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_da_format.c | 15 ------ fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 97 ++++++++++++++--------------------- fs/xfs/libxfs/xfs_dir2_priv.h | 1 + fs/xfs/scrub/dir.c | 6 +-- 6 files changed, 43 insertions(+), 83 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-15@@ -411,12 +411,6 @@ xfs_dir2_free_max_bests(struct xfs_da_geometry *geo)sizeof (xfs_dir2_data_off_t); } -static __be16 * -xfs_dir2_free_bests_p (struct xfs_dir2_free *free) -{ -return (__be16 *)((char *)free +sizeof (struct xfs_dir2_free_hdr )); -} -/* * Convert data space db to the corresponding free db. */ @@ -443,12 +437,6 @@ xfs_dir3_free_max_bests(struct xfs_da_geometry *geo)sizeof (xfs_dir2_data_off_t); } -static __be16 * -xfs_dir3_free_bests_p (struct xfs_dir2_free *free) -{ -return (__be16 *)((char *)free +sizeof (struct xfs_dir3_free_hdr )); -} -/* * Convert data space db to the corresponding free db. */ @@ -500,7 +488,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_max_bests = xfs_dir2_free_max_bests, - .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex, };@@ -537,7 +524,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_max_bests = xfs_dir2_free_max_bests, - .free_bests_p = xfs_dir2_free_bests_p, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex, };@@ -574,7 +560,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_max_bests = xfs_dir3_free_max_bests, - .free_bests_p = xfs_dir3_free_bests_p, .db_to_fdb = xfs_dir3_db_to_fdb, .db_to_fdindex = xfs_dir3_db_to_fdindex, };fs/xfs/libxfs/xfs_dir2.h +0
-1@@ -74,7 +74,6 @@ struct xfs_dir_ops {int free_hdr_size;int (*free_max_bests)(struct xfs_da_geometry *geo); -__be16 * (*free_bests_p)(struct xfs_dir2_free *free);xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,xfs_dir2_db_t db); int (*db_to_fdindex)(struct xfs_da_geometry *geo,fs/xfs/libxfs/xfs_dir2_leaf.c +2
-4@@ -1678,7 +1678,6 @@ xfs_dir2_node_to_leaf(int error;/* error return code */ struct xfs_buf *fbp;/* buffer for freespace block */ xfs_fileoff_t fo;/* freespace file offset */ -xfs_dir2_free_t *free;/* freespace structure */ struct xfs_buf *lbp;/* buffer for leaf block */ xfs_dir2_leaf_tail_t *ltp;/* tail of leaf structure */ xfs_dir2_leaf_t *leaf;/* leaf structure */ @@ -1747,8 +1746,7 @@ xfs_dir2_node_to_leaf( error =xfs_dir2_free_read (tp, dp, args->geo->freeblk, &fbp);if (error)return error; - free = fbp->b_addr; -xfs_dir2_free_hdr_from_disk (mp, &freehdr, free); +xfs_dir2_free_hdr_from_disk (mp, &freehdr, fbp->b_addr);ASSERT (!freehdr.firstdb);@@ -1782,7 +1780,7 @@ xfs_dir2_node_to_leaf(/* * Set up the leaf bests table. */ -memcpy (xfs_dir2_leaf_bests_p (ltp), dp->d_ops->free_bests_p (free), +memcpy (xfs_dir2_leaf_bests_p (ltp), freehdr.bests, freehdr.nvalid *sizeof (xfs_dir2_data_off_t));xfs_dir2_leaf_hdr_to_disk (mp, leaf, &leafhdr);fs/xfs/libxfs/xfs_dir2_node.c +0
-0
fs/xfs/libxfs/xfs_dir2_node.c xfs_dir2_free_hdr_from_disk( · line 236
Quoted 4 lines
fs/xfs/libxfs/xfs_dir2_node.c +1
-0@@ -233,6 +233,7 @@ xfs_dir2_free_hdr_from_disk( to->firstdb =be32_to_cpu (from3->hdr.firstdb); to->nvalid =be32_to_cpu (from3->hdr.nvalid); to->nused =be32_to_cpu (from3->hdr.nused); + to->bests = (void *)from3 +sizeof (struct xfs_dir3_free_hdr );
Urgh, isn't void pointer arithmetic technically illegal according to C?
In any case, shouldn't this cast through struct xfs_dir3_free instead of open-coding details of the disk format that we've already captured? The same question also applies to the other patches that add pointers to ondisk leaf and intnode pointers into the incore header struct.
--D
Quoted 363 lines
fs/xfs/libxfs/xfs_dir2_node.c +37
-59ASSERT (to->magic ==XFS_DIR3_FREE_MAGIC ); }else {@@ -240,6 +241,8 @@ xfs_dir2_free_hdr_from_disk( to->firstdb =be32_to_cpu (from->hdr.firstdb); to->nvalid =be32_to_cpu (from->hdr.nvalid); to->nused =be32_to_cpu (from->hdr.nused); + to->bests = (void *)from +sizeof (struct xfs_dir2_free_hdr ); +ASSERT (to->magic ==XFS_DIR2_FREE_MAGIC ); } }@@ -338,21 +341,19 @@ xfs_dir3_free_get_buf( STATIC voidxfs_dir2_free_log_bests (struct xfs_da_args *args, +struct xfs_dir3_icfree_hdr *hdr,struct xfs_buf *bp,int first,/* first entry to log */ int last)/* last entry to log */ { -xfs_dir2_free_t *free;/* freespace structure */ -__be16 *bests; +struct xfs_dir2_free *free = bp->b_addr; - free = bp->b_addr; - bests = args->dp->d_ops->free_bests_p (free);ASSERT (free->hdr.magic ==cpu_to_be32 (XFS_DIR2_FREE_MAGIC ) || free->hdr.magic ==cpu_to_be32 (XFS_DIR3_FREE_MAGIC ));xfs_trans_log_buf (args->trans, bp, - (uint)((char *)&bests[first] - (char *)free), - (uint)((char *)&bests[last] - (char *)free + -sizeof (bests[0 ]) -1 )); + (char *)&hdr->bests[first] - (char *)free, + (char *)&hdr->bests[last] - (char *)free + +sizeof (hdr->bests[0 ]) -1 ); }/* @@ -388,14 +389,12 @@ xfs_dir2_leaf_to_node(int error;/* error return value */ struct xfs_buf *fbp;/* freespace buffer */ xfs_dir2_db_t fdb;/* freespace block number */ -xfs_dir2_free_t *free;/* freespace structure */ __be16 *from;/* pointer to freespace entry */ int i;/* leaf freespace index */ xfs_dir2_leaf_t *leaf;/* leaf structure */ xfs_dir2_leaf_tail_t *ltp;/* leaf tail structure */ int n;/* count of live freespc ents */ xfs_dir2_data_off_t off;/* freespace entry value */ -__be16 *to;/* pointer to freespace entry */ xfs_trans_t *tp;/* transaction pointer */ struct xfs_dir3_icfree_hdr freehdr;@@ -417,8 +416,7 @@ xfs_dir2_leaf_to_node(if (error)return error; - free = fbp->b_addr; -xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, fbp->b_addr); leaf = lbp->b_addr; ltp =xfs_dir2_leaf_tail_p (args->geo, leaf); if (be32_to_cpu(ltp->bestcount) >@@ -430,11 +428,11 @@ xfs_dir2_leaf_to_node(* Count active entries. */ from =xfs_dir2_leaf_bests_p (ltp); - to = dp->d_ops->free_bests_p (free); -for (i = n =0 ; i <be32_to_cpu (ltp->bestcount); i++, from++, to++) { -if ((off =be16_to_cpu (*from)) !=NULLDATAOFF ) +for (i = n =0 ; i <be32_to_cpu (ltp->bestcount); i++, from++) { + off =be16_to_cpu (*from); +if (off !=NULLDATAOFF ) n++; - *to =cpu_to_be16 (off); + freehdr.bests[i] =cpu_to_be16 (off); }/* @@ -444,7 +442,7 @@ xfs_dir2_leaf_to_node( freehdr.nvalid =be32_to_cpu (ltp->bestcount);xfs_dir2_free_hdr_to_disk (dp->i_mount, fbp->b_addr, &freehdr); -xfs_dir2_free_log_bests (args, fbp,0 , freehdr.nvalid -1 ); +xfs_dir2_free_log_bests (args, &freehdr, fbp,0 , freehdr.nvalid -1 );xfs_dir2_free_log_header (args, fbp);/* @@ -673,7 +671,7 @@ xfs_dir2_leafn_lookup_for_addname(* in hand, take a look at it. */ if (newdb != curdb) { -__be16 *bests; +struct xfs_dir3_icfree_hdr freehdr; curdb = newdb;/* @@ -708,8 +706,9 @@ xfs_dir2_leafn_lookup_for_addname(/* * If it has room, return it. */ - bests = dp->d_ops->free_bests_p (free); -if (unlikely (bests[fi] ==cpu_to_be16 (NULLDATAOFF ))) { +xfs_dir2_free_hdr_from_disk (mp, &freehdr, free); +if (unlikely (freehdr.bests[fi] == +cpu_to_be16 (NULLDATAOFF ))) {XFS_ERROR_REPORT ("xfs_dir2_leafn_lookup_int" ,XFS_ERRLEVEL_LOW , mp);if (curfdb != newfdb)@@ -717,7 +716,7 @@ xfs_dir2_leafn_lookup_for_addname(return -EFSCORRUPTED ; } curfdb = newfdb; -if (be16_to_cpu (bests[fi]) >= length) +if (be16_to_cpu (freehdr.bests[fi]) >= length) goto out; } }@@ -1162,19 +1161,17 @@ xfs_dir3_data_block_free( int longest) {int logfree =0 ; -__be16 *bests;struct xfs_dir3_icfree_hdr freehdr;struct xfs_inode *dp = args->dp;xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); - bests = dp->d_ops->free_bests_p (free);if (hdr) {/* * Data block is not empty, just set the free entry to the new * value. */ - bests[findex] =cpu_to_be16 (longest); -xfs_dir2_free_log_bests (args, fbp, findex, findex); + freehdr.bests[findex] =cpu_to_be16 (longest); +xfs_dir2_free_log_bests (args, &freehdr, fbp, findex, findex);return 0 ; }@@ -1190,14 +1187,14 @@ xfs_dir3_data_block_free(int i;/* free entry index */ for (i = findex -1 ; i >=0 ; i--) { -if (bests[i] !=cpu_to_be16 (NULLDATAOFF )) +if (freehdr.bests[i] !=cpu_to_be16 (NULLDATAOFF ))break ; } freehdr.nvalid = i +1 ; logfree =0 ; }else {/* Not the last entry, just punch it out. */ - bests[findex] =cpu_to_be16 (NULLDATAOFF ); + freehdr.bests[findex] =cpu_to_be16 (NULLDATAOFF ); logfree =1 ; }@@ -1226,7 +1223,7 @@ xfs_dir3_data_block_free(/* Log the free entry that changed, unless we got rid of it. */ if (logfree) -xfs_dir2_free_log_bests (args, fbp, findex, findex); +xfs_dir2_free_log_bests (args, &freehdr, fbp, findex, findex);return 0 ; }@@ -1667,11 +1664,9 @@ xfs_dir2_node_add_datablk(struct xfs_trans *tp = args->trans;struct xfs_mount *mp = dp->i_mount;struct xfs_dir2_data_free *bf; -struct xfs_dir2_free *free =NULL ;xfs_dir2_db_t fbno;struct xfs_buf *fbp;struct xfs_buf *dbp; -__be16 *bests =NULL ;int error;/* Not allowed to allocate, return failure. */ @@ -1727,18 +1722,14 @@ xfs_dir2_node_add_datablk( error =xfs_dir3_free_get_buf (args, fbno, &fbp);if (error)return error; - free = fbp->b_addr; - bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (mp, hdr, free); +xfs_dir2_free_hdr_from_disk (mp, hdr, fbp->b_addr);/* Remember the first slot as our empty slot. */ hdr->firstdb = (fbno -xfs_dir2_byte_to_db (args->geo,XFS_DIR2_FREE_OFFSET )) * dp->d_ops->free_max_bests (args->geo); }else { - free = fbp->b_addr; - bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (mp, hdr, free); +xfs_dir2_free_hdr_from_disk (mp, hdr, fbp->b_addr); }/* Set the freespace block index from the data block number. */ @@ -1748,14 +1739,14 @@ xfs_dir2_node_add_datablk(if (*findex >= hdr->nvalid) {ASSERT (*findex < dp->d_ops->free_max_bests (args->geo)); hdr->nvalid = *findex +1 ; - bests[*findex] =cpu_to_be16 (NULLDATAOFF ); + hdr->bests[*findex] =cpu_to_be16 (NULLDATAOFF ); }/* * If this entry was for an empty data block (this should always be * true) then update the header. */ -if (bests[*findex] ==cpu_to_be16 (NULLDATAOFF )) { +if (hdr->bests[*findex] ==cpu_to_be16 (NULLDATAOFF )) { hdr->nused++;xfs_dir2_free_hdr_to_disk (mp, fbp->b_addr, hdr);xfs_dir2_free_log_header (args, fbp);@@ -1763,7 +1754,7 @@ xfs_dir2_node_add_datablk(/* Update the freespace value for the new block in the table. */ bf = dp->d_ops->data_bestfree_p (dbp->b_addr); - bests[*findex] = bf[0 ].length; + hdr->bests[*findex] = bf[0 ].length; *dbpp = dbp; *fbpp = fbp;@@ -1780,7 +1771,6 @@ xfs_dir2_node_find_freeblk( int *findexp, int length) { -struct xfs_dir2_free *free =NULL ;struct xfs_inode *dp = args->dp;struct xfs_trans *tp = args->trans;struct xfs_buf *fbp =NULL ;@@ -1790,7 +1780,6 @@ xfs_dir2_node_find_freeblk(xfs_dir2_db_t dbno =-1 ;xfs_dir2_db_t fbno;xfs_fileoff_t fo; -__be16 *bests =NULL ;int findex =0 ;int error;@@ -1801,16 +1790,13 @@ xfs_dir2_node_find_freeblk(*/ if (fblk) { fbp = fblk->bp; - free = fbp->b_addr; findex = fblk->index; +xfs_dir2_free_hdr_from_disk (dp->i_mount, hdr, fbp->b_addr);if (findex >=0 ) {/* caller already found the freespace for us. */ - bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (dp->i_mount, hdr, free); -ASSERT (findex < hdr->nvalid); -ASSERT (be16_to_cpu (bests[findex]) !=NULLDATAOFF ); -ASSERT (be16_to_cpu (bests[findex]) >= length); +ASSERT (be16_to_cpu (hdr->bests[findex]) !=NULLDATAOFF ); +ASSERT (be16_to_cpu (hdr->bests[findex]) >= length); dbno = hdr->firstdb + findex; goto found_block; }@@ -1853,14 +1839,12 @@ xfs_dir2_node_find_freeblk(if (!fbp)continue ; - free = fbp->b_addr; - bests = dp->d_ops->free_bests_p (free); -xfs_dir2_free_hdr_from_disk (dp->i_mount, hdr, free); +xfs_dir2_free_hdr_from_disk (dp->i_mount, hdr, fbp->b_addr);/* Scan the free entry array for a large enough free space. */ for (findex = hdr->nvalid -1 ; findex >=0 ; findex--) { -if (be16_to_cpu (bests[findex]) !=NULLDATAOFF && -be16_to_cpu (bests[findex]) >= length) { +if (be16_to_cpu (hdr->bests[findex]) !=NULLDATAOFF && +be16_to_cpu (hdr->bests[findex]) >= length) { dbno = hdr->firstdb + findex; goto found_block; }@@ -1877,7 +1861,6 @@ xfs_dir2_node_find_freeblk(return 0 ; } -/* * Add the data entry for a node-format directory name addition. * The leaf entry is added in xfs_dir2_leafn_add. @@ -1892,7 +1875,6 @@ xfs_dir2_node_addname_int(struct xfs_dir2_data_entry *dep;/* data entry pointer */ struct xfs_dir2_data_hdr *hdr;/* data block header */ struct xfs_dir2_data_free *bf; -struct xfs_dir2_free *free =NULL ;/* freespace block structure */ struct xfs_trans *tp = args->trans;struct xfs_inode *dp = args->dp;struct xfs_dir3_icfree_hdr freehdr;@@ -1907,7 +1889,6 @@ xfs_dir2_node_addname_int(int needlog =0 ;/* need to log data header */ int needscan =0 ;/* need to rescan data frees */ __be16 *tagp;/* data entry tag pointer */ -__be16 *bests; length = dp->d_ops->data_entsize (args->namelen); error = xfs_dir2_node_find_freeblk(args, fblk, &dbno, &fbp, &freehdr,@@ -1978,16 +1959,14 @@ xfs_dir2_node_addname_int(xfs_dir2_data_log_header (args, dbp);/* If the freespace block entry is now wrong, update it. */ - free = fbp->b_addr; - bests = dp->d_ops->free_bests_p (free); -if (bests[findex] != bf[0 ].length) { - bests[findex] = bf[0 ].length; +if (freehdr.bests[findex] != bf[0 ].length) { + freehdr.bests[findex] = bf[0 ].length; logfree =1 ; }/* Log the freespace entry if needed. */ if (logfree) -xfs_dir2_free_log_bests (args, fbp, findex, findex); +xfs_dir2_free_log_bests (args, &freehdr, fbp, findex, findex);/* Return the data block and offset in args. */ args->blkno = (xfs_dablk_t )dbno;fs/xfs/libxfs/xfs_dir2_priv.h +1
-0@@ -26,6 +26,7 @@ struct xfs_dir3_icfree_hdr {uint32_t firstdb;uint32_t nvalid;uint32_t nused; +__be16 *bests; };/* xfs_dir2.c */ fs/xfs/scrub/dir.c +2
-4@@ -581,7 +581,6 @@ xchk_directory_free_bestfree(struct xfs_dir3_icfree_hdr freehdr;struct xfs_buf *dbp;struct xfs_buf *bp; -__be16 *bestp;__u16 best;unsigned int stale =0 ;int i;@@ -602,9 +601,8 @@ xchk_directory_free_bestfree(/* Check all the entries. */ xfs_dir2_free_hdr_from_disk (sc->ip->i_mount, &freehdr, bp->b_addr); - bestp = sc->ip->d_ops->free_bests_p (bp->b_addr); -for (i =0 ; i < freehdr.nvalid; i++, bestp++) { - best =be16_to_cpu (*bestp); +for (i =0 ; i < freehdr.nvalid; i++) { + best =be16_to_cpu (freehdr.bests[i]);if (best ==NULLDATAOFF ) { stale++;continue ;Signature · 1 line
2.20.1
Re: [PATCH 15/34] xfs: add a bests pointer to struct xfs_dir3_icfree_hdr
Quoted 7 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_dir2_node.c xfs_dir2_free_hdr_from_disk( · line 236
Quoted 5 lines
fs/xfs/libxfs/xfs_dir2_node.c +1
-0@@ -233,6 +233,7 @@ xfs_dir2_free_hdr_from_disk( to->firstdb =be32_to_cpu (from3->hdr.firstdb); to->nvalid =be32_to_cpu (from3->hdr.nvalid); to->nused =be32_to_cpu (from3->hdr.nused); + to->bests = (void *)from3 +sizeof (struct xfs_dir3_free_hdr );Urgh, isn't void pointer arithmetic technically illegal according to C?
It is not specified in ISO C, but clearly specified in the GNU C extensions and used all over the kernel.
Quoted 4 lines
In any case, shouldn't this cast through struct
xfs_dir3_freeinstead of open-coding details of the disk format that we've already captured? The same question also applies to the other patches that add pointers to ondisk leaf and intnode pointers into the incore header struct.
I don't really understand that sentence. What would do you instead?
Re: [PATCH 15/34] xfs: add a bests pointer to struct xfs_dir3_icfree_hdr
Quoted 11 lines · Christoph Hellwig
Quoted 7 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_dir2_node.c xfs_dir2_free_hdr_from_disk( · line 236
Quoted 5 lines
fs/xfs/libxfs/xfs_dir2_node.c +1
-0@@ -233,6 +233,7 @@ xfs_dir2_free_hdr_from_disk( to->firstdb =be32_to_cpu (from3->hdr.firstdb); to->nvalid =be32_to_cpu (from3->hdr.nvalid); to->nused =be32_to_cpu (from3->hdr.nused); + to->bests = (void *)from3 +sizeof (struct xfs_dir3_free_hdr );Urgh, isn't void pointer arithmetic technically illegal according to C?
It is not specified in ISO C, but clearly specified in the GNU C extensions and used all over the kernel.
Just out of curiosity, do you know if clang supports that extension?
Once in a while we get patches from them to fix various clang warnings, and at least as of a few years ago clang got grouchy about void pointer arithmetic.
Quoted 6 lines
Quoted 4 lines
In any case, shouldn't this cast through struct
xfs_dir3_freeinstead of open-coding details of the disk format that we've already captured? The same question also applies to the other patches that add pointers to ondisk leaf and intnode pointers into the incore header struct.I don't really understand that sentence. What would do you instead?
if (xfs_sb_version_hascrc(&mp->m_sb)) {
struct xfs_dir3_free *from3 = (struct xfs_dir3_free *)from;
...
to->nused = be32_to_cpu(from3->hdr.nused);
to->bests = &from3->bests[0];
}Since we're already passing around pointers to the xfs_dir[23]_free structure, we might as well use it instead of open-coding the arithmetic. Sorry that wasn't clear. :/
--D
Re: [PATCH 15/34] xfs: add a bests pointer to struct xfs_dir3_icfree_hdr
Quoted 4 lines · Darrick J. Wong
Quoted 2 lines
It is not specified in ISO C, but clearly specified in the GNU C extensions and used all over the kernel.
Just out of curiosity, do you know if clang supports that extension?
Yes. Basically any modern C compiler does.
Quoted 10 lines
Quoted 1 line
I don't really understand that sentence. What would do you instead?
if (xfs_sb_version_hascrc(&mp->m_sb)) { struct xfs_dir3_free *from3 = (struct xfs_dir3_free *)from; ... to->nused = be32_to_cpu(from3->hdr.nused); to->bests = &from3->bests[0]; }
Quoted 3 lines
Since we're already passing around pointers to the xfs_dir[23]_free structure, we might as well use it instead of open-coding the arithmetic. Sorry that wasn't clear. :/
Sure, that is much better and I'll switch to it.
PATCH 16/34 xfs: move the dir2 free header size to struct xfs_da_geometry
In reply to Christoph HellwigMove the free header size towards our structure for dir/attr geometry parameters.
--- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 3 --- fs/xfs/libxfs/xfs_dir2.c | 2 ++ fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_node.c | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_da_btree.h +1 -0
@@ -29,6 +29,7 @@ struct xfs_da_geometry {int leaf_hdr_size;/* dir2 leaf header size */ unsigned int leaf_max_ents;/* # of entries in dir2 leaf */ xfs_dablk_t leafblk;/* blockno of leaf data v2 */ +int free_hdr_size;/* dir2 free header size */ xfs_dablk_t freeblk;/* blockno of free data v2 */ };
fs/xfs/libxfs/xfs_da_format.c +0 -3
@@ -486,7 +486,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_max_bests = xfs_dir2_free_max_bests, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex,
@@ -522,7 +521,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_max_bests = xfs_dir2_free_max_bests, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex,
@@ -558,7 +556,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_max_bests = xfs_dir3_free_max_bests, .db_to_fdb = xfs_dir3_db_to_fdb, .db_to_fdindex = xfs_dir3_db_to_fdindex,
fs/xfs/libxfs/xfs_dir2.c +2 -0
@@ -125,9 +125,11 @@ xfs_da_mount(if (xfs_sb_version_hascrc (&mp->m_sb)) { dageo->node_hdr_size =sizeof (struct xfs_da3_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir3_leaf_hdr ); + dageo->free_hdr_size =sizeof (struct xfs_dir3_free_hdr ); }else { dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir2_leaf_hdr ); + dageo->free_hdr_size =sizeof (struct xfs_dir2_free_hdr ); } dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) /sizeof (struct xfs_dir2_leaf_entry );
fs/xfs/libxfs/xfs_dir2.h +0 -1
@@ -72,7 +72,6 @@ struct xfs_dir_ops {struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); -int free_hdr_size;int (*free_max_bests)(struct xfs_da_geometry *geo);xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,xfs_dir2_db_t db);
fs/xfs/libxfs/xfs_dir2_node.c +1 -1
@@ -372,7 +372,7 @@ xfs_dir2_free_log_header( free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));#endif xfs_trans_log_buf (args->trans, bp,0 , - args->dp->d_ops->free_hdr_size -1 ); + args->geo->free_hdr_size -1 ); }/*
Signature · 1 line
2.20.1
Re: [PATCH 16/34] xfs: move the dir2 free header size to struct xfs_da_geometry
Quoted 17 lines · Christoph Hellwig
Move the free header size towards our structure for dir/attr geometry parameters.
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 3 --- fs/xfs/libxfs/xfs_dir2.c | 2 ++ fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_node.c | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-)fs/xfs/libxfs/xfs_da_btree.h +0
-0
fs/xfs/libxfs/xfs_da_btree.h struct xfs_da_geometry { · line 32
Quoted 4 lines
fs/xfs/libxfs/xfs_da_btree.h +1
-0@@ -29,6 +29,7 @@ struct xfs_da_geometry {int leaf_hdr_size;/* dir2 leaf header size */ unsigned int leaf_max_ents;/* # of entries in dir2 leaf */ xfs_dablk_t leafblk;/* blockno of leaf data v2 */ +int free_hdr_size;/* dir2 free header size */
Shouldn't this be unsigned? Even if the original code wasn't this way?
Looks fine otherwise,
--D
Quoted 75 lines
fs/xfs/libxfs/xfs_da_btree.h +0
-0xfs_dablk_t freeblk;/* blockno of free data v2 */ };fs/xfs/libxfs/xfs_da_format.c +0
-3@@ -486,7 +486,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_max_bests = xfs_dir2_free_max_bests, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex,@@ -522,7 +521,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_max_bests = xfs_dir2_free_max_bests, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex,@@ -558,7 +556,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - .free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_max_bests = xfs_dir3_free_max_bests, .db_to_fdb = xfs_dir3_db_to_fdb, .db_to_fdindex = xfs_dir3_db_to_fdindex,fs/xfs/libxfs/xfs_dir2.c +2
-0@@ -125,9 +125,11 @@ xfs_da_mount(if (xfs_sb_version_hascrc (&mp->m_sb)) { dageo->node_hdr_size =sizeof (struct xfs_da3_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir3_leaf_hdr ); + dageo->free_hdr_size =sizeof (struct xfs_dir3_free_hdr ); }else { dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir2_leaf_hdr ); + dageo->free_hdr_size =sizeof (struct xfs_dir2_free_hdr ); } dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) /sizeof (struct xfs_dir2_leaf_entry );fs/xfs/libxfs/xfs_dir2.h +0
-1@@ -72,7 +72,6 @@ struct xfs_dir_ops {struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); -int free_hdr_size;int (*free_max_bests)(struct xfs_da_geometry *geo);xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,xfs_dir2_db_t db);fs/xfs/libxfs/xfs_dir2_node.c +1
-1@@ -372,7 +372,7 @@ xfs_dir2_free_log_header( free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));#endif xfs_trans_log_buf (args->trans, bp,0 , - args->dp->d_ops->free_hdr_size -1 ); + args->geo->free_hdr_size -1 ); }/* Signature · 1 line
2.20.1
PATCH 17/34 xfs: move the max dir2 free bests count to struct xfs_da_geometry
In reply to Christoph HellwigMove the max free bests count towards our structure for dir/attr geometry parameters.
--- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 29 ++++------------------------- fs/xfs/libxfs/xfs_dir2.c | 2 ++ fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_node.c | 12 +++++------- 5 files changed, 12 insertions(+), 33 deletions(-)
fs/xfs/libxfs/xfs_da_btree.h +1 -0
@@ -30,6 +30,7 @@ struct xfs_da_geometry {unsigned int leaf_max_ents;/* # of entries in dir2 leaf */ xfs_dablk_t leafblk;/* blockno of leaf data v2 */ int free_hdr_size;/* dir2 free header size */ +unsigned int free_max_bests;/* # of bests entries in dir2 free */ xfs_dablk_t freeblk;/* blockno of free data v2 */ };
fs/xfs/libxfs/xfs_da_format.c +4 -25
@@ -400,17 +400,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); } - -/* -* Directory free space block operations -*/ -static int -xfs_dir2_free_max_bests (struct xfs_da_geometry *geo) -{ -return (geo->blksize -sizeof (struct xfs_dir2_free_hdr )) / -sizeof (xfs_dir2_data_off_t); -} -/* * Convert data space db to the corresponding free db. */
@@ -418,7 +407,7 @@ static xfs_dir2_db_t xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db) {return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + - (db /xfs_dir2_free_max_bests (geo)); + (db / geo->free_max_bests); }/*
@@ -427,14 +416,7 @@ xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)static int xfs_dir2_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) { -return db %xfs_dir2_free_max_bests (geo); -} - -static int -xfs_dir3_free_max_bests (struct xfs_da_geometry *geo) -{ -return (geo->blksize -sizeof (struct xfs_dir3_free_hdr )) / -sizeof (xfs_dir2_data_off_t); +return db % geo->free_max_bests; }/*
@@ -444,7 +426,7 @@ static xfs_dir2_db_t xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db) {return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + - (db /xfs_dir3_free_max_bests (geo)); + (db / geo->free_max_bests); }/*
@@ -453,7 +435,7 @@ xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)static int xfs_dir3_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) { -return db %xfs_dir3_free_max_bests (geo); +return db % geo->free_max_bests; }static const struct xfs_dir_ops xfs_dir2_ops = {
@@ -486,7 +468,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .free_max_bests = xfs_dir2_free_max_bests, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex, };
@@ -521,7 +502,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .free_max_bests = xfs_dir2_free_max_bests, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex, };
@@ -556,7 +536,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - .free_max_bests = xfs_dir3_free_max_bests, .db_to_fdb = xfs_dir3_db_to_fdb, .db_to_fdindex = xfs_dir3_db_to_fdindex, };
fs/xfs/libxfs/xfs_dir2.c +2 -0
@@ -133,6 +133,8 @@ xfs_da_mount( } dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) /sizeof (struct xfs_dir2_leaf_entry ); + dageo->free_max_bests = (dageo->blksize - dageo->free_hdr_size) / +sizeof (xfs_dir2_data_off_t);/* * Now we've set up the block conversion variables, we can calculate the
fs/xfs/libxfs/xfs_dir2.h +0 -1
@@ -72,7 +72,6 @@ struct xfs_dir_ops {struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); -int (*free_max_bests)(struct xfs_da_geometry *geo);xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,xfs_dir2_db_t db); int (*db_to_fdindex)(struct xfs_da_geometry *geo,
fs/xfs/libxfs/xfs_dir2_node.c +5 -7
@@ -160,10 +160,9 @@ xfs_dir3_free_header_check( struct xfs_buf *bp) {struct xfs_mount *mp = dp->i_mount; +int maxbests = mp->m_dir_geo->free_max_bests;unsigned int firstdb; -int maxbests; - maxbests = dp->d_ops->free_max_bests (mp->m_dir_geo); firstdb = (xfs_dir2_da_to_db (mp->m_dir_geo, fbno) -xfs_dir2_byte_to_db (mp->m_dir_geo,XFS_DIR2_FREE_OFFSET )) * maxbests;
@@ -558,8 +557,7 @@ xfs_dir2_free_hdr_check(xfs_dir2_free_hdr_from_disk (dp->i_mount, &hdr, bp->b_addr); -ASSERT ((hdr.firstdb % - dp->d_ops->free_max_bests (dp->i_mount->m_dir_geo)) ==0 ); +ASSERT ((hdr.firstdb % dp->i_mount->m_dir_geo->free_max_bests) ==0 );ASSERT (hdr.firstdb <= db);ASSERT (db < hdr.firstdb + hdr.nvalid); }
@@ -1334,7 +1332,7 @@ xfs_dir2_leafn_remove(struct xfs_dir3_icfree_hdr freehdr;xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); -ASSERT (freehdr.firstdb == dp->d_ops->free_max_bests (args->geo) * +ASSERT (freehdr.firstdb == args->geo->free_max_bests * (fdb -xfs_dir2_byte_to_db (args->geo,XFS_DIR2_FREE_OFFSET ))); }
@@ -1727,7 +1725,7 @@ xfs_dir2_node_add_datablk(/* Remember the first slot as our empty slot. */ hdr->firstdb = (fbno -xfs_dir2_byte_to_db (args->geo,XFS_DIR2_FREE_OFFSET )) * - dp->d_ops->free_max_bests (args->geo); + args->geo->free_max_bests; }else {xfs_dir2_free_hdr_from_disk (mp, hdr, fbp->b_addr); }
@@ -1737,7 +1735,7 @@ xfs_dir2_node_add_datablk(/* Extend the freespace table if the new data block is off the end. */ if (*findex >= hdr->nvalid) { -ASSERT (*findex < dp->d_ops->free_max_bests (args->geo)); +ASSERT (*findex < args->geo->free_max_bests); hdr->nvalid = *findex +1 ; hdr->bests[*findex] =cpu_to_be16 (NULLDATAOFF ); }
Signature · 1 line
2.20.1
Re: [PATCH 17/34] xfs: move the max dir2 free bests count to struct xfs_da_geometry
Quoted 4 lines · Christoph Hellwig
Move the max free bests count towards our structure for dir/attr geometry parameters.
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 190 lines
--- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.c | 29 ++++------------------------- fs/xfs/libxfs/xfs_dir2.c | 2 ++ fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_node.c | 12 +++++------- 5 files changed, 12 insertions(+), 33 deletions(-)fs/xfs/libxfs/xfs_da_btree.h +1
-0@@ -30,6 +30,7 @@ struct xfs_da_geometry {unsigned int leaf_max_ents;/* # of entries in dir2 leaf */ xfs_dablk_t leafblk;/* blockno of leaf data v2 */ int free_hdr_size;/* dir2 free header size */ +unsigned int free_max_bests;/* # of bests entries in dir2 free */ xfs_dablk_t freeblk;/* blockno of free data v2 */ };fs/xfs/libxfs/xfs_da_format.c +4
-25@@ -400,17 +400,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); } - -/* -* Directory free space block operations -*/ -static int -xfs_dir2_free_max_bests (struct xfs_da_geometry *geo) -{ -return (geo->blksize -sizeof (struct xfs_dir2_free_hdr )) / -sizeof (xfs_dir2_data_off_t); -} -/* * Convert data space db to the corresponding free db. */ @@ -418,7 +407,7 @@ static xfs_dir2_db_t xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db) {return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + - (db /xfs_dir2_free_max_bests (geo)); + (db / geo->free_max_bests); }/* @@ -427,14 +416,7 @@ xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)static int xfs_dir2_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) { -return db %xfs_dir2_free_max_bests (geo); -} - -static int -xfs_dir3_free_max_bests (struct xfs_da_geometry *geo) -{ -return (geo->blksize -sizeof (struct xfs_dir3_free_hdr )) / -sizeof (xfs_dir2_data_off_t); +return db % geo->free_max_bests; }/* @@ -444,7 +426,7 @@ static xfs_dir2_db_t xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db) {return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + - (db /xfs_dir3_free_max_bests (geo)); + (db / geo->free_max_bests); }/* @@ -453,7 +435,7 @@ xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)static int xfs_dir3_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) { -return db %xfs_dir3_free_max_bests (geo); +return db % geo->free_max_bests; }static const struct xfs_dir_ops xfs_dir2_ops = {@@ -486,7 +468,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .free_max_bests = xfs_dir2_free_max_bests, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex, };@@ -521,7 +502,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - .free_max_bests = xfs_dir2_free_max_bests, .db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdindex = xfs_dir2_db_to_fdindex, };@@ -556,7 +536,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - .free_max_bests = xfs_dir3_free_max_bests, .db_to_fdb = xfs_dir3_db_to_fdb, .db_to_fdindex = xfs_dir3_db_to_fdindex, };fs/xfs/libxfs/xfs_dir2.c +2
-0@@ -133,6 +133,8 @@ xfs_da_mount( } dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) /sizeof (struct xfs_dir2_leaf_entry ); + dageo->free_max_bests = (dageo->blksize - dageo->free_hdr_size) / +sizeof (xfs_dir2_data_off_t);/* * Now we've set up the block conversion variables, we can calculate the fs/xfs/libxfs/xfs_dir2.h +0
-1@@ -72,7 +72,6 @@ struct xfs_dir_ops {struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); -int (*free_max_bests)(struct xfs_da_geometry *geo);xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,xfs_dir2_db_t db); int (*db_to_fdindex)(struct xfs_da_geometry *geo,fs/xfs/libxfs/xfs_dir2_node.c +5
-7@@ -160,10 +160,9 @@ xfs_dir3_free_header_check( struct xfs_buf *bp) {struct xfs_mount *mp = dp->i_mount; +int maxbests = mp->m_dir_geo->free_max_bests;unsigned int firstdb; -int maxbests; - maxbests = dp->d_ops->free_max_bests (mp->m_dir_geo); firstdb = (xfs_dir2_da_to_db (mp->m_dir_geo, fbno) -xfs_dir2_byte_to_db (mp->m_dir_geo,XFS_DIR2_FREE_OFFSET )) * maxbests;@@ -558,8 +557,7 @@ xfs_dir2_free_hdr_check(xfs_dir2_free_hdr_from_disk (dp->i_mount, &hdr, bp->b_addr); -ASSERT ((hdr.firstdb % - dp->d_ops->free_max_bests (dp->i_mount->m_dir_geo)) ==0 ); +ASSERT ((hdr.firstdb % dp->i_mount->m_dir_geo->free_max_bests) ==0 );ASSERT (hdr.firstdb <= db);ASSERT (db < hdr.firstdb + hdr.nvalid); }@@ -1334,7 +1332,7 @@ xfs_dir2_leafn_remove(struct xfs_dir3_icfree_hdr freehdr;xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); -ASSERT (freehdr.firstdb == dp->d_ops->free_max_bests (args->geo) * +ASSERT (freehdr.firstdb == args->geo->free_max_bests * (fdb -xfs_dir2_byte_to_db (args->geo,XFS_DIR2_FREE_OFFSET ))); }@@ -1727,7 +1725,7 @@ xfs_dir2_node_add_datablk(/* Remember the first slot as our empty slot. */ hdr->firstdb = (fbno -xfs_dir2_byte_to_db (args->geo,XFS_DIR2_FREE_OFFSET )) * - dp->d_ops->free_max_bests (args->geo); + args->geo->free_max_bests; }else {xfs_dir2_free_hdr_from_disk (mp, hdr, fbp->b_addr); }@@ -1737,7 +1735,7 @@ xfs_dir2_node_add_datablk(/* Extend the freespace table if the new data block is off the end. */ if (*findex >= hdr->nvalid) { -ASSERT (*findex < dp->d_ops->free_max_bests (args->geo)); +ASSERT (*findex < args->geo->free_max_bests); hdr->nvalid = *findex +1 ; hdr->bests[*findex] =cpu_to_be16 (NULLDATAOFF ); }Signature · 1 line
2.20.1
PATCH 18/34 xfs: devirtualize ->db_to_fdb and ->db_to_fdindex
In reply to Christoph HellwigNow that the max bests value is in struct xfs_da_geometry both instances of ->db_to_fdb and ->db_to_fdindex are identical. Replace them with local xfs_dir2_db_to_fdb and xfs_dir2_db_to_fdindex functions in xfs_dir2_node.c.
--- fs/xfs/libxfs/xfs_da_format.c | 47 ----------------------------------- fs/xfs/libxfs/xfs_dir2.h | 5 ---- fs/xfs/libxfs/xfs_dir2_node.c | 35 ++++++++++++++++++++------ 3 files changed, 27 insertions(+), 60 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -47
@@ -400,44 +400,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); } -/* -* Convert data space db to the corresponding free db. -*/ -static xfs_dir2_db_t -xfs_dir2_db_to_fdb (struct xfs_da_geometry *geo,xfs_dir2_db_t db) -{ -return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + - (db / geo->free_max_bests); -} - -/* -* Convert data space db to the corresponding index in a free db. -*/ -static int -xfs_dir2_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) -{ -return db % geo->free_max_bests; -} - -/* -* Convert data space db to the corresponding free db. -*/ -static xfs_dir2_db_t -xfs_dir3_db_to_fdb (struct xfs_da_geometry *geo,xfs_dir2_db_t db) -{ -return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + - (db / geo->free_max_bests); -} - -/* -* Convert data space db to the corresponding index in a free db. -*/ -static int -xfs_dir3_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) -{ -return db % geo->free_max_bests; -} -static const struct xfs_dir_ops xfs_dir2_ops = { .sf_entsize = xfs_dir2_sf_entsize, .sf_nextentry = xfs_dir2_sf_nextentry,
@@ -467,9 +429,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_first_entry_p = xfs_dir2_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - - .db_to_fdb = xfs_dir2_db_to_fdb, - .db_to_fdindex = xfs_dir2_db_to_fdindex, };static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
@@ -501,9 +460,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_first_entry_p = xfs_dir2_ftype_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - - .db_to_fdb = xfs_dir2_db_to_fdb, - .db_to_fdindex = xfs_dir2_db_to_fdindex, };static const struct xfs_dir_ops xfs_dir3_ops = {
@@ -535,9 +491,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_first_entry_p = xfs_dir3_data_first_entry_p, .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - - .db_to_fdb = xfs_dir3_db_to_fdb, - .db_to_fdindex = xfs_dir3_db_to_fdindex, };/*
fs/xfs/libxfs/xfs_dir2.h +0 -5
@@ -71,11 +71,6 @@ struct xfs_dir_ops { (*data_entry_p)(struct xfs_dir2_data_hdr *hdr);struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); - -xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo, -xfs_dir2_db_t db); -int (*db_to_fdindex)(struct xfs_da_geometry *geo, -xfs_dir2_db_t db); }; extern const struct xfs_dir_ops *
fs/xfs/libxfs/xfs_dir2_node.c +27 -8
@@ -33,6 +33,25 @@ static int xfs_dir2_leafn_remove(xfs_da_args_t *args, struct xfs_buf *bp, int index, xfs_da_state_blk_t *dblk, int *rval); +/* +* Convert data space db to the corresponding free db. +*/ +static xfs_dir2_db_t +xfs_dir2_db_to_fdb (struct xfs_da_geometry *geo,xfs_dir2_db_t db) +{ +return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + + (db / geo->free_max_bests); +} + +/* +* Convert data space db to the corresponding index in a free db. +*/ +static int +xfs_dir2_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) +{ +return db % geo->free_max_bests; +} +/* * Check internal consistency of a leafn block. */
@@ -676,7 +695,7 @@ xfs_dir2_leafn_lookup_for_addname(* Convert the data block to the free block * holding its freespace information. */ - newfdb = dp->d_ops->db_to_fdb (args->geo, newdb); + newfdb =xfs_dir2_db_to_fdb (args->geo, newdb);/* * If it's not the one we have in hand, read it in. */
@@ -700,7 +719,7 @@ xfs_dir2_leafn_lookup_for_addname(/* * Get the index for our entry. */ - fi = dp->d_ops->db_to_fdindex (args->geo, curdb); + fi =xfs_dir2_db_to_fdindex (args->geo, curdb);/* * If it has room, return it. */
@@ -1320,7 +1339,7 @@ xfs_dir2_leafn_remove(* Convert the data block number to a free block, * read in the free block. */ - fdb = dp->d_ops->db_to_fdb (args->geo, db); + fdb =xfs_dir2_db_to_fdb (args->geo, db); error =xfs_dir2_free_read (tp, dp,xfs_dir2_db_to_da (args->geo, fdb), &fbp);
@@ -1340,7 +1359,7 @@ xfs_dir2_leafn_remove(/* * Calculate which entry we need to fix. */ - findex = dp->d_ops->db_to_fdindex (args->geo, db); + findex =xfs_dir2_db_to_fdindex (args->geo, db); longest =be16_to_cpu (bf[0 ].length);/* * If the data block is now empty we can get rid of it
@@ -1683,7 +1702,7 @@ xfs_dir2_node_add_datablk(* Get the freespace block corresponding to the data block * that was just allocated. */ - fbno = dp->d_ops->db_to_fdb (args->geo, *dbno); + fbno =xfs_dir2_db_to_fdb (args->geo, *dbno); error =xfs_dir2_free_try_read (tp, dp,xfs_dir2_db_to_da (args->geo, fbno), &fbp);if (error)
@@ -1698,11 +1717,11 @@ xfs_dir2_node_add_datablk(if (error)return error; -if (dp->d_ops->db_to_fdb (args->geo, *dbno) != fbno) { +if (xfs_dir2_db_to_fdb (args->geo, *dbno) != fbno) {xfs_alert (mp,"%s: dir ino %llu needed freesp block %lld for data block %lld, got %lld" , __func__, (unsigned long long )dp->i_ino, - (long long )dp->d_ops->db_to_fdb (args->geo, *dbno), + (long long )xfs_dir2_db_to_fdb (args->geo, *dbno), (long long )*dbno, (long long )fbno);if (fblk) { xfs_alert(mp,
@@ -1731,7 +1750,7 @@ xfs_dir2_node_add_datablk( }/* Set the freespace block index from the data block number. */ - *findex = dp->d_ops->db_to_fdindex (args->geo, *dbno); + *findex =xfs_dir2_db_to_fdindex (args->geo, *dbno);/* Extend the freespace table if the new data block is off the end. */ if (*findex >= hdr->nvalid) {
Signature · 1 line
2.20.1
Re: [PATCH 18/34] xfs: devirtualize ->db_to_fdb and ->db_to_fdindex
Quoted 6 lines · Christoph Hellwig
Now that the max bests value is in struct
xfs_da_geometryboth instances of ->db_to_fdb and ->db_to_fdindex are identical. Replace them with localxfs_dir2_db_to_fdbandxfs_dir2_db_to_fdindexfunctions inxfs_dir2_node.c.Signed-off-by Christoph Hellwig <[email protected]>
Seems pretty straightforward,
--D
Quoted 202 lines
--- fs/xfs/libxfs/xfs_da_format.c | 47 ----------------------------------- fs/xfs/libxfs/xfs_dir2.h | 5 ---- fs/xfs/libxfs/xfs_dir2_node.c | 35 ++++++++++++++++++++------ 3 files changed, 27 insertions(+), 60 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-47@@ -400,44 +400,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); } -/* -* Convert data space db to the corresponding free db. -*/ -static xfs_dir2_db_t -xfs_dir2_db_to_fdb (struct xfs_da_geometry *geo,xfs_dir2_db_t db) -{ -return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + - (db / geo->free_max_bests); -} - -/* -* Convert data space db to the corresponding index in a free db. -*/ -static int -xfs_dir2_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) -{ -return db % geo->free_max_bests; -} - -/* -* Convert data space db to the corresponding free db. -*/ -static xfs_dir2_db_t -xfs_dir3_db_to_fdb (struct xfs_da_geometry *geo,xfs_dir2_db_t db) -{ -return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + - (db / geo->free_max_bests); -} - -/* -* Convert data space db to the corresponding index in a free db. -*/ -static int -xfs_dir3_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) -{ -return db % geo->free_max_bests; -} -static const struct xfs_dir_ops xfs_dir2_ops = { .sf_entsize = xfs_dir2_sf_entsize, .sf_nextentry = xfs_dir2_sf_nextentry,@@ -467,9 +429,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_first_entry_p = xfs_dir2_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - - .db_to_fdb = xfs_dir2_db_to_fdb, - .db_to_fdindex = xfs_dir2_db_to_fdindex, };static const struct xfs_dir_ops xfs_dir2_ftype_ops = {@@ -501,9 +460,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_first_entry_p = xfs_dir2_ftype_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, - - .db_to_fdb = xfs_dir2_db_to_fdb, - .db_to_fdindex = xfs_dir2_db_to_fdindex, };static const struct xfs_dir_ops xfs_dir3_ops = {@@ -535,9 +491,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .data_first_entry_p = xfs_dir3_data_first_entry_p, .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, - - .db_to_fdb = xfs_dir3_db_to_fdb, - .db_to_fdindex = xfs_dir3_db_to_fdindex, };/* fs/xfs/libxfs/xfs_dir2.h +0
-5@@ -71,11 +71,6 @@ struct xfs_dir_ops { (*data_entry_p)(struct xfs_dir2_data_hdr *hdr);struct xfs_dir2_data_unused * (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); - -xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo, -xfs_dir2_db_t db); -int (*db_to_fdindex)(struct xfs_da_geometry *geo, -xfs_dir2_db_t db); }; extern const struct xfs_dir_ops *fs/xfs/libxfs/xfs_dir2_node.c +27
-8@@ -33,6 +33,25 @@ static int xfs_dir2_leafn_remove(xfs_da_args_t *args, struct xfs_buf *bp, int index, xfs_da_state_blk_t *dblk, int *rval); +/* +* Convert data space db to the corresponding free db. +*/ +static xfs_dir2_db_t +xfs_dir2_db_to_fdb (struct xfs_da_geometry *geo,xfs_dir2_db_t db) +{ +return xfs_dir2_byte_to_db (geo,XFS_DIR2_FREE_OFFSET ) + + (db / geo->free_max_bests); +} + +/* +* Convert data space db to the corresponding index in a free db. +*/ +static int +xfs_dir2_db_to_fdindex (struct xfs_da_geometry *geo,xfs_dir2_db_t db) +{ +return db % geo->free_max_bests; +} +/* * Check internal consistency of a leafn block. */ @@ -676,7 +695,7 @@ xfs_dir2_leafn_lookup_for_addname(* Convert the data block to the free block * holding its freespace information. */ - newfdb = dp->d_ops->db_to_fdb (args->geo, newdb); + newfdb =xfs_dir2_db_to_fdb (args->geo, newdb);/* * If it's not the one we have in hand, read it in. */ @@ -700,7 +719,7 @@ xfs_dir2_leafn_lookup_for_addname(/* * Get the index for our entry. */ - fi = dp->d_ops->db_to_fdindex (args->geo, curdb); + fi =xfs_dir2_db_to_fdindex (args->geo, curdb);/* * If it has room, return it. */ @@ -1320,7 +1339,7 @@ xfs_dir2_leafn_remove(* Convert the data block number to a free block, * read in the free block. */ - fdb = dp->d_ops->db_to_fdb (args->geo, db); + fdb =xfs_dir2_db_to_fdb (args->geo, db); error =xfs_dir2_free_read (tp, dp,xfs_dir2_db_to_da (args->geo, fdb), &fbp);@@ -1340,7 +1359,7 @@ xfs_dir2_leafn_remove(/* * Calculate which entry we need to fix. */ - findex = dp->d_ops->db_to_fdindex (args->geo, db); + findex =xfs_dir2_db_to_fdindex (args->geo, db); longest =be16_to_cpu (bf[0 ].length);/* * If the data block is now empty we can get rid of it @@ -1683,7 +1702,7 @@ xfs_dir2_node_add_datablk(* Get the freespace block corresponding to the data block * that was just allocated. */ - fbno = dp->d_ops->db_to_fdb (args->geo, *dbno); + fbno =xfs_dir2_db_to_fdb (args->geo, *dbno); error =xfs_dir2_free_try_read (tp, dp,xfs_dir2_db_to_da (args->geo, fbno), &fbp);if (error)@@ -1698,11 +1717,11 @@ xfs_dir2_node_add_datablk(if (error)return error; -if (dp->d_ops->db_to_fdb (args->geo, *dbno) != fbno) { +if (xfs_dir2_db_to_fdb (args->geo, *dbno) != fbno) {xfs_alert (mp,"%s: dir ino %llu needed freesp block %lld for data block %lld, got %lld" , __func__, (unsigned long long )dp->i_ino, - (long long )dp->d_ops->db_to_fdb (args->geo, *dbno), + (long long )xfs_dir2_db_to_fdb (args->geo, *dbno), (long long )*dbno, (long long )fbno);if (fblk) { xfs_alert(mp,@@ -1731,7 +1750,7 @@ xfs_dir2_node_add_datablk( }/* Set the freespace block index from the data block number. */ - *findex = dp->d_ops->db_to_fdindex (args->geo, *dbno); + *findex =xfs_dir2_db_to_fdindex (args->geo, *dbno);/* Extend the freespace table if the new data block is off the end. */ if (*findex >= hdr->nvalid) {Signature · 1 line
2.20.1
PATCH 19/34 xfs: devirtualize ->sf_get_parent_ino and ->sf_put_parent_ino
In reply to Christoph HellwigThe parent inode handling is the same for all directory format variants, just use direct calls instead of going through a pointless indirect call.
--- fs/xfs/libxfs/xfs_da_format.c | 10 ++-------- fs/xfs/libxfs/xfs_dir2.h | 3 --- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/libxfs/xfs_dir2_sf.c | 20 ++++++++++---------- fs/xfs/xfs_dir2_readdir.c | 2 +- 6 files changed, 16 insertions(+), 23 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +2 -8
@@ -132,14 +132,14 @@ xfs_dir2_sf_put_ino(put_unaligned_be32 (ino, to); } -static xfs_ino_t +xfs_ino_t xfs_dir2_sf_get_parent_ino (struct xfs_dir2_sf_hdr *hdr) {return xfs_dir2_sf_get_ino (hdr, hdr->parent); } -static void +void xfs_dir2_sf_put_parent_ino (struct xfs_dir2_sf_hdr *hdr,xfs_ino_t ino)
@@ -407,8 +407,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .sf_put_ftype = xfs_dir2_sfe_put_ftype, .sf_get_ino = xfs_dir2_sfe_get_ino, .sf_put_ino = xfs_dir2_sfe_put_ino, - .sf_get_parent_ino = xfs_dir2_sf_get_parent_ino, - .sf_put_parent_ino = xfs_dir2_sf_put_parent_ino, .data_entsize = xfs_dir2_data_entsize, .data_get_ftype = xfs_dir2_data_get_ftype,
@@ -438,8 +436,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_get_ino = xfs_dir3_sfe_get_ino, .sf_put_ino = xfs_dir3_sfe_put_ino, - .sf_get_parent_ino = xfs_dir2_sf_get_parent_ino, - .sf_put_parent_ino = xfs_dir2_sf_put_parent_ino, .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype,
@@ -469,8 +465,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_get_ino = xfs_dir3_sfe_get_ino, .sf_put_ino = xfs_dir3_sfe_put_ino, - .sf_get_parent_ino = xfs_dir2_sf_get_parent_ino, - .sf_put_parent_ino = xfs_dir2_sf_put_parent_ino, .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype,
fs/xfs/libxfs/xfs_dir2.h +0 -3
@@ -44,9 +44,6 @@ struct xfs_dir_ops {void (*sf_put_ino)(struct xfs_dir2_sf_hdr *hdr,struct xfs_dir2_sf_entry *sfep,xfs_ino_t ino); -xfs_ino_t (*sf_get_parent_ino)(struct xfs_dir2_sf_hdr *hdr); -void (*sf_put_parent_ino)(struct xfs_dir2_sf_hdr *hdr, -xfs_ino_t ino);int (*data_entsize)(int len);uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);
fs/xfs/libxfs/xfs_dir2_block.c +1 -1
@@ -1163,7 +1163,7 @@ xfs_dir2_sf_to_block(* Create entry for .. */ dep = dp->d_ops->data_dotdot_entry_p (hdr); - dep->inumber =cpu_to_be64 (dp->d_ops->sf_get_parent_ino (sfp)); + dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_parent_ino (sfp)); dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ; dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR );
fs/xfs/libxfs/xfs_dir2_priv.h +2 -0
@@ -135,6 +135,8 @@ extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t fbno, struct xfs_buf **bpp);/* xfs_dir2_sf.c */ +xfs_ino_t xfs_dir2_sf_get_parent_ino (struct xfs_dir2_sf_hdr *hdr); +void xfs_dir2_sf_put_parent_ino (struct xfs_dir2_sf_hdr *hdr,xfs_ino_t ino);extern int xfs_dir2_block_sfsize (struct xfs_inode *dp,struct xfs_dir2_data_hdr *block,struct xfs_dir2_sf_hdr *sfhp); extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
fs/xfs/libxfs/xfs_dir2_sf.c +10 -10
@@ -125,7 +125,7 @@ xfs_dir2_block_sfsize(*/ sfhp->count = count; sfhp->i8count = i8count; - dp->d_ops->sf_put_parent_ino (sfhp, parent); +xfs_dir2_sf_put_parent_ino (sfhp, parent);return size; }
@@ -204,7 +204,7 @@ xfs_dir2_block_to_sf(else if (dep->namelen ==2 && dep->name[0 ] =='.' && dep->name[1 ] =='.' )ASSERT (be64_to_cpu (dep->inumber) == - dp->d_ops->sf_get_parent_ino (sfp)); +xfs_dir2_sf_get_parent_ino (sfp));/* * Normal entry, copy it into shortform. */
@@ -590,7 +590,7 @@ xfs_dir2_sf_check( sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; offset = dp->d_ops->data_first_offset; - ino = dp->d_ops->sf_get_parent_ino (sfp); + ino =xfs_dir2_sf_get_parent_ino (sfp); i8count = ino >XFS_DIR2_MAX_SHORT_INUM ; for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);
@@ -653,7 +653,7 @@ xfs_dir2_sf_verify( endp = (char *)sfp + size;/* Check .. entry */ - ino = dops->sf_get_parent_ino (sfp); + ino =xfs_dir2_sf_get_parent_ino (sfp); i8count = ino >XFS_DIR2_MAX_SHORT_INUM ; error =xfs_dir_ino_validate (mp, ino);if (error)
@@ -763,7 +763,7 @@ xfs_dir2_sf_create(/* * Now can put in the inode number, since i8count is set. */ - dp->d_ops->sf_put_parent_ino (sfp, pino); +xfs_dir2_sf_put_parent_ino (sfp, pino); sfp->count =0 ; dp->i_d.di_size = size;xfs_dir2_sf_check (args);
@@ -818,7 +818,7 @@ xfs_dir2_sf_lookup(*/ if (args->namelen ==2 && args->name[0 ] =='.' && args->name[1 ] =='.' ) { - args->inumber = dp->d_ops->sf_get_parent_ino (sfp); + args->inumber =xfs_dir2_sf_get_parent_ino (sfp); args->cmpresult =XFS_CMP_EXACT ; args->filetype =XFS_DIR3_FT_DIR ;return -EEXIST ;
@@ -1008,9 +1008,9 @@ xfs_dir2_sf_replace(*/ if (args->namelen ==2 && args->name[0 ] =='.' && args->name[1 ] =='.' ) { - ino = dp->d_ops->sf_get_parent_ino (sfp); + ino =xfs_dir2_sf_get_parent_ino (sfp);ASSERT (args->inumber != ino); - dp->d_ops->sf_put_parent_ino (sfp, args->inumber); +xfs_dir2_sf_put_parent_ino (sfp, args->inumber); }/* * Normal entry, look for the name.
@@ -1116,7 +1116,7 @@ xfs_dir2_sf_toino4(*/ sfp->count = oldsfp->count; sfp->i8count =0 ; - dp->d_ops->sf_put_parent_ino (sfp, dp->d_ops->sf_get_parent_ino (oldsfp)); +xfs_dir2_sf_put_parent_ino (sfp,xfs_dir2_sf_get_parent_ino (oldsfp));/* * Copy the entries field by field. */
@@ -1189,7 +1189,7 @@ xfs_dir2_sf_toino8(*/ sfp->count = oldsfp->count; sfp->i8count =1 ; - dp->d_ops->sf_put_parent_ino (sfp, dp->d_ops->sf_get_parent_ino (oldsfp)); +xfs_dir2_sf_put_parent_ino (sfp,xfs_dir2_sf_get_parent_ino (oldsfp));/* * Copy the entries field by field. */
fs/xfs/xfs_dir2_readdir.c +1 -1
@@ -92,7 +92,7 @@ xfs_dir2_sf_getdents(* Put .. entry unless we're starting past it. */ if (ctx->pos <= dotdot_offset) { - ino = dp->d_ops->sf_get_parent_ino (sfp); + ino =xfs_dir2_sf_get_parent_ino (sfp); ctx->pos = dotdot_offset &0x7fffffff ;if (!dir_emit (ctx,".." ,2 , ino,DT_DIR ))return 0 ;
Signature · 1 line
2.20.1
Re: [PATCH 19/34] xfs: devirtualize ->sf_get_parent_ino and ->sf_put_parent_ino
Quoted 5 lines · Christoph Hellwig
The parent inode handling is the same for all directory format variants, just use direct calls instead of going through a pointless indirect call.
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 201 lines
--- fs/xfs/libxfs/xfs_da_format.c | 10 ++-------- fs/xfs/libxfs/xfs_dir2.h | 3 --- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/libxfs/xfs_dir2_sf.c | 20 ++++++++++---------- fs/xfs/xfs_dir2_readdir.c | 2 +- 6 files changed, 16 insertions(+), 23 deletions(-)fs/xfs/libxfs/xfs_da_format.c +2
-8@@ -132,14 +132,14 @@ xfs_dir2_sf_put_ino(put_unaligned_be32 (ino, to); } -static xfs_ino_t +xfs_ino_t xfs_dir2_sf_get_parent_ino (struct xfs_dir2_sf_hdr *hdr) {return xfs_dir2_sf_get_ino (hdr, hdr->parent); } -static void +void xfs_dir2_sf_put_parent_ino (struct xfs_dir2_sf_hdr *hdr,xfs_ino_t ino)@@ -407,8 +407,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .sf_put_ftype = xfs_dir2_sfe_put_ftype, .sf_get_ino = xfs_dir2_sfe_get_ino, .sf_put_ino = xfs_dir2_sfe_put_ino, - .sf_get_parent_ino = xfs_dir2_sf_get_parent_ino, - .sf_put_parent_ino = xfs_dir2_sf_put_parent_ino, .data_entsize = xfs_dir2_data_entsize, .data_get_ftype = xfs_dir2_data_get_ftype,@@ -438,8 +436,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_get_ino = xfs_dir3_sfe_get_ino, .sf_put_ino = xfs_dir3_sfe_put_ino, - .sf_get_parent_ino = xfs_dir2_sf_get_parent_ino, - .sf_put_parent_ino = xfs_dir2_sf_put_parent_ino, .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype,@@ -469,8 +465,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { .sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_get_ino = xfs_dir3_sfe_get_ino, .sf_put_ino = xfs_dir3_sfe_put_ino, - .sf_get_parent_ino = xfs_dir2_sf_get_parent_ino, - .sf_put_parent_ino = xfs_dir2_sf_put_parent_ino, .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype,fs/xfs/libxfs/xfs_dir2.h +0
-3@@ -44,9 +44,6 @@ struct xfs_dir_ops {void (*sf_put_ino)(struct xfs_dir2_sf_hdr *hdr,struct xfs_dir2_sf_entry *sfep,xfs_ino_t ino); -xfs_ino_t (*sf_get_parent_ino)(struct xfs_dir2_sf_hdr *hdr); -void (*sf_put_parent_ino)(struct xfs_dir2_sf_hdr *hdr, -xfs_ino_t ino);int (*data_entsize)(int len);uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);fs/xfs/libxfs/xfs_dir2_block.c +1
-1@@ -1163,7 +1163,7 @@ xfs_dir2_sf_to_block(* Create entry for .. */ dep = dp->d_ops->data_dotdot_entry_p (hdr); - dep->inumber =cpu_to_be64 (dp->d_ops->sf_get_parent_ino (sfp)); + dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_parent_ino (sfp)); dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ; dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR );fs/xfs/libxfs/xfs_dir2_priv.h +2
-0@@ -135,6 +135,8 @@ extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t fbno, struct xfs_buf **bpp);/* xfs_dir2_sf.c */ +xfs_ino_t xfs_dir2_sf_get_parent_ino (struct xfs_dir2_sf_hdr *hdr); +void xfs_dir2_sf_put_parent_ino (struct xfs_dir2_sf_hdr *hdr,xfs_ino_t ino);extern int xfs_dir2_block_sfsize (struct xfs_inode *dp,struct xfs_dir2_data_hdr *block,struct xfs_dir2_sf_hdr *sfhp); extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,fs/xfs/libxfs/xfs_dir2_sf.c +10
-10@@ -125,7 +125,7 @@ xfs_dir2_block_sfsize(*/ sfhp->count = count; sfhp->i8count = i8count; - dp->d_ops->sf_put_parent_ino (sfhp, parent); +xfs_dir2_sf_put_parent_ino (sfhp, parent);return size; }@@ -204,7 +204,7 @@ xfs_dir2_block_to_sf(else if (dep->namelen ==2 && dep->name[0 ] =='.' && dep->name[1 ] =='.' )ASSERT (be64_to_cpu (dep->inumber) == - dp->d_ops->sf_get_parent_ino (sfp)); +xfs_dir2_sf_get_parent_ino (sfp));/* * Normal entry, copy it into shortform. */ @@ -590,7 +590,7 @@ xfs_dir2_sf_check( sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; offset = dp->d_ops->data_first_offset; - ino = dp->d_ops->sf_get_parent_ino (sfp); + ino =xfs_dir2_sf_get_parent_ino (sfp); i8count = ino >XFS_DIR2_MAX_SHORT_INUM ; for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);@@ -653,7 +653,7 @@ xfs_dir2_sf_verify( endp = (char *)sfp + size;/* Check .. entry */ - ino = dops->sf_get_parent_ino (sfp); + ino =xfs_dir2_sf_get_parent_ino (sfp); i8count = ino >XFS_DIR2_MAX_SHORT_INUM ; error =xfs_dir_ino_validate (mp, ino);if (error)@@ -763,7 +763,7 @@ xfs_dir2_sf_create(/* * Now can put in the inode number, since i8count is set. */ - dp->d_ops->sf_put_parent_ino (sfp, pino); +xfs_dir2_sf_put_parent_ino (sfp, pino); sfp->count =0 ; dp->i_d.di_size = size;xfs_dir2_sf_check (args);@@ -818,7 +818,7 @@ xfs_dir2_sf_lookup(*/ if (args->namelen ==2 && args->name[0 ] =='.' && args->name[1 ] =='.' ) { - args->inumber = dp->d_ops->sf_get_parent_ino (sfp); + args->inumber =xfs_dir2_sf_get_parent_ino (sfp); args->cmpresult =XFS_CMP_EXACT ; args->filetype =XFS_DIR3_FT_DIR ;return -EEXIST ;@@ -1008,9 +1008,9 @@ xfs_dir2_sf_replace(*/ if (args->namelen ==2 && args->name[0 ] =='.' && args->name[1 ] =='.' ) { - ino = dp->d_ops->sf_get_parent_ino (sfp); + ino =xfs_dir2_sf_get_parent_ino (sfp);ASSERT (args->inumber != ino); - dp->d_ops->sf_put_parent_ino (sfp, args->inumber); +xfs_dir2_sf_put_parent_ino (sfp, args->inumber); }/* * Normal entry, look for the name. @@ -1116,7 +1116,7 @@ xfs_dir2_sf_toino4(*/ sfp->count = oldsfp->count; sfp->i8count =0 ; - dp->d_ops->sf_put_parent_ino (sfp, dp->d_ops->sf_get_parent_ino (oldsfp)); +xfs_dir2_sf_put_parent_ino (sfp,xfs_dir2_sf_get_parent_ino (oldsfp));/* * Copy the entries field by field. */ @@ -1189,7 +1189,7 @@ xfs_dir2_sf_toino8(*/ sfp->count = oldsfp->count; sfp->i8count =1 ; - dp->d_ops->sf_put_parent_ino (sfp, dp->d_ops->sf_get_parent_ino (oldsfp)); +xfs_dir2_sf_put_parent_ino (sfp,xfs_dir2_sf_get_parent_ino (oldsfp));/* * Copy the entries field by field. */ fs/xfs/xfs_dir2_readdir.c +1
-1@@ -92,7 +92,7 @@ xfs_dir2_sf_getdents(* Put .. entry unless we're starting past it. */ if (ctx->pos <= dotdot_offset) { - ino = dp->d_ops->sf_get_parent_ino (sfp); + ino =xfs_dir2_sf_get_parent_ino (sfp); ctx->pos = dotdot_offset &0x7fffffff ;if (!dir_emit (ctx,".." ,2 , ino,DT_DIR ))return 0 ;Signature · 1 line
2.20.1
PATCH 20/34 xfs: devirtualize ->sf_entsize and ->sf_nextentry
In reply to Christoph HellwigJust check for file-type enabled directories directly.
--- fs/xfs/libxfs/xfs_da_format.c | 48 ----------------- fs/xfs/libxfs/xfs_dir2.h | 4 -- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_priv.h | 2 + fs/xfs/libxfs/xfs_dir2_sf.c | 99 ++++++++++++++++++++-------------- fs/xfs/xfs_dir2_readdir.c | 7 +-- 6 files changed, 66 insertions(+), 96 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -48
@@ -15,48 +15,6 @@#include "xfs_dir2.h" #include "xfs_dir2_priv.h" -/* -* Shortform directory ops -*/ -static int -xfs_dir2_sf_entsize ( -struct xfs_dir2_sf_hdr *hdr, -int len) -{ -int count =sizeof (struct xfs_dir2_sf_entry );/* namelen + offset */ - - count += len;/* name */ - count += hdr->i8count ?XFS_INO64_SIZE :XFS_INO32_SIZE ;/* ino # */ -return count; -} - -static int -xfs_dir3_sf_entsize ( -struct xfs_dir2_sf_hdr *hdr, -int len) -{ -return xfs_dir2_sf_entsize (hdr, len) +sizeof (uint8_t ); -} - -static struct xfs_dir2_sf_entry * -xfs_dir2_sf_nextentry ( -struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep) -{ -return (struct xfs_dir2_sf_entry *) - ((char *)sfep +xfs_dir2_sf_entsize (hdr, sfep->namelen)); -} - -static struct xfs_dir2_sf_entry * -xfs_dir3_sf_nextentry ( -struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep) -{ -return (struct xfs_dir2_sf_entry *) - ((char *)sfep +xfs_dir3_sf_entsize (hdr, sfep->namelen)); -} - -/* * For filetype enabled shortform directories, the file type field is stored at * the end of the name. Because it's only a single byte, endian conversion is
@@ -401,8 +359,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) }static const struct xfs_dir_ops xfs_dir2_ops = { - .sf_entsize = xfs_dir2_sf_entsize, - .sf_nextentry = xfs_dir2_sf_nextentry, .sf_get_ftype = xfs_dir2_sfe_get_ftype, .sf_put_ftype = xfs_dir2_sfe_put_ftype, .sf_get_ino = xfs_dir2_sfe_get_ino,
@@ -430,8 +386,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { - .sf_entsize = xfs_dir3_sf_entsize, - .sf_nextentry = xfs_dir3_sf_nextentry, .sf_get_ftype = xfs_dir3_sfe_get_ftype, .sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_get_ino = xfs_dir3_sfe_get_ino,
@@ -459,8 +413,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { };static const struct xfs_dir_ops xfs_dir3_ops = { - .sf_entsize = xfs_dir3_sf_entsize, - .sf_nextentry = xfs_dir3_sf_nextentry, .sf_get_ftype = xfs_dir3_sfe_get_ftype, .sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_get_ino = xfs_dir3_sfe_get_ino,
fs/xfs/libxfs/xfs_dir2.h +0 -4
@@ -32,10 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);* directory operations vector for encode/decode routines */ struct xfs_dir_ops { -int (*sf_entsize)(struct xfs_dir2_sf_hdr *hdr,int len); -struct xfs_dir2_sf_entry * - (*sf_nextentry)(struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep);uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep);void (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep,uint8_t ftype);
fs/xfs/libxfs/xfs_dir2_block.c +1 -1
@@ -1231,7 +1231,7 @@ xfs_dir2_sf_to_block(if (++i == sfp->count) sfep =NULL ;else - sfep = dp->d_ops->sf_nextentry (sfp, sfep); + sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); }/* Done with the temporary buffer */ kmem_free (sfp);
fs/xfs/libxfs/xfs_dir2_priv.h +2 -0
@@ -137,6 +137,8 @@ extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp,/* xfs_dir2_sf.c */ xfs_ino_t xfs_dir2_sf_get_parent_ino (struct xfs_dir2_sf_hdr *hdr);void xfs_dir2_sf_put_parent_ino (struct xfs_dir2_sf_hdr *hdr,xfs_ino_t ino); +struct xfs_dir2_sf_entry *xfs_dir2_sf_nextentry (struct xfs_mount *mp, +struct xfs_dir2_sf_hdr *hdr,struct xfs_dir2_sf_entry *sfep);extern int xfs_dir2_block_sfsize (struct xfs_inode *dp,struct xfs_dir2_data_hdr *block,struct xfs_dir2_sf_hdr *sfhp); extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
fs/xfs/libxfs/xfs_dir2_sf.c +59 -40
291 lines not on this page · raw message
fs/xfs/xfs_dir2_readdir.c +4 -3
@@ -48,6 +48,7 @@ xfs_dir2_sf_getdents( {int i;/* shortform entry number */ struct xfs_inode *dp = args->dp;/* incore directory inode */ +struct xfs_mount *mp = dp->i_mount;xfs_dir2_dataptr_t off;/* current entry's offset */ xfs_dir2_sf_entry_t *sfep;/* shortform directory entry */ xfs_dir2_sf_hdr_t *sfp;/* shortform structure */
@@ -109,7 +110,7 @@ xfs_dir2_sf_getdents( xfs_dir2_sf_get_offset(sfep));if (ctx->pos > off) { - sfep = dp->d_ops->sf_nextentry (sfp, sfep); + sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep);continue ; }
@@ -122,9 +123,9 @@ xfs_dir2_sf_getdents(return -EFSCORRUPTED ; }if (!dir_emit (ctx, (char *)sfep->name, sfep->namelen, ino, -xfs_dir3_get_dtype (dp->i_mount, filetype))) +xfs_dir3_get_dtype (mp, filetype)))return 0 ; - sfep = dp->d_ops->sf_nextentry (sfp, sfep); + sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); } ctx->pos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk + 1, 0) &
Signature · 1 line
2.20.1
Re: [PATCH 20/34] xfs: devirtualize ->sf_entsize and ->sf_nextentry
Quoted 3 lines · Christoph Hellwig
Just check for file-type enabled directories directly.
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 490 lines
--- fs/xfs/libxfs/xfs_da_format.c | 48 ----------------- fs/xfs/libxfs/xfs_dir2.h | 4 -- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_priv.h | 2 + fs/xfs/libxfs/xfs_dir2_sf.c | 99 ++++++++++++++++++++-------------- fs/xfs/xfs_dir2_readdir.c | 7 +-- 6 files changed, 66 insertions(+), 96 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-48@@ -15,48 +15,6 @@#include "xfs_dir2.h" #include "xfs_dir2_priv.h" -/* -* Shortform directory ops -*/ -static int -xfs_dir2_sf_entsize ( -struct xfs_dir2_sf_hdr *hdr, -int len) -{ -int count =sizeof (struct xfs_dir2_sf_entry );/* namelen + offset */ - - count += len;/* name */ - count += hdr->i8count ?XFS_INO64_SIZE :XFS_INO32_SIZE ;/* ino # */ -return count; -} - -static int -xfs_dir3_sf_entsize ( -struct xfs_dir2_sf_hdr *hdr, -int len) -{ -return xfs_dir2_sf_entsize (hdr, len) +sizeof (uint8_t ); -} - -static struct xfs_dir2_sf_entry * -xfs_dir2_sf_nextentry ( -struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep) -{ -return (struct xfs_dir2_sf_entry *) - ((char *)sfep +xfs_dir2_sf_entsize (hdr, sfep->namelen)); -} - -static struct xfs_dir2_sf_entry * -xfs_dir3_sf_nextentry ( -struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep) -{ -return (struct xfs_dir2_sf_entry *) - ((char *)sfep +xfs_dir3_sf_entsize (hdr, sfep->namelen)); -} - -/* * For filetype enabled shortform directories, the file type field is stored at * the end of the name. Because it's only a single byte, endian conversion is @@ -401,8 +359,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) }static const struct xfs_dir_ops xfs_dir2_ops = { - .sf_entsize = xfs_dir2_sf_entsize, - .sf_nextentry = xfs_dir2_sf_nextentry, .sf_get_ftype = xfs_dir2_sfe_get_ftype, .sf_put_ftype = xfs_dir2_sfe_put_ftype, .sf_get_ino = xfs_dir2_sfe_get_ino,@@ -430,8 +386,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { - .sf_entsize = xfs_dir3_sf_entsize, - .sf_nextentry = xfs_dir3_sf_nextentry, .sf_get_ftype = xfs_dir3_sfe_get_ftype, .sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_get_ino = xfs_dir3_sfe_get_ino,@@ -459,8 +413,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { };static const struct xfs_dir_ops xfs_dir3_ops = { - .sf_entsize = xfs_dir3_sf_entsize, - .sf_nextentry = xfs_dir3_sf_nextentry, .sf_get_ftype = xfs_dir3_sfe_get_ftype, .sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_get_ino = xfs_dir3_sfe_get_ino,fs/xfs/libxfs/xfs_dir2.h +0
-4@@ -32,10 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);* directory operations vector for encode/decode routines */ struct xfs_dir_ops { -int (*sf_entsize)(struct xfs_dir2_sf_hdr *hdr,int len); -struct xfs_dir2_sf_entry * - (*sf_nextentry)(struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep);uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep);void (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep,uint8_t ftype);fs/xfs/libxfs/xfs_dir2_block.c +1
-1@@ -1231,7 +1231,7 @@ xfs_dir2_sf_to_block(if (++i == sfp->count) sfep =NULL ;else - sfep = dp->d_ops->sf_nextentry (sfp, sfep); + sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); }/* Done with the temporary buffer */ kmem_free (sfp);fs/xfs/libxfs/xfs_dir2_priv.h +2
-0@@ -137,6 +137,8 @@ extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp,/* xfs_dir2_sf.c */ xfs_ino_t xfs_dir2_sf_get_parent_ino (struct xfs_dir2_sf_hdr *hdr);void xfs_dir2_sf_put_parent_ino (struct xfs_dir2_sf_hdr *hdr,xfs_ino_t ino); +struct xfs_dir2_sf_entry *xfs_dir2_sf_nextentry (struct xfs_mount *mp, +struct xfs_dir2_sf_hdr *hdr,struct xfs_dir2_sf_entry *sfep);extern int xfs_dir2_block_sfsize (struct xfs_inode *dp,struct xfs_dir2_data_hdr *block,struct xfs_dir2_sf_hdr *sfhp); extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,fs/xfs/libxfs/xfs_dir2_sf.c +59
-40@@ -37,6 +37,32 @@ static void xfs_dir2_sf_check(xfs_da_args_t *args);static void xfs_dir2_sf_toino4 (xfs_da_args_t *args);static void xfs_dir2_sf_toino8 (xfs_da_args_t *args); +static int +xfs_dir2_sf_entsize ( +struct xfs_mount *mp, +struct xfs_dir2_sf_hdr *hdr, +int len) +{ +int count = len; + + count +=sizeof (struct xfs_dir2_sf_entry );/* namelen + offset */ + count += hdr->i8count ?XFS_INO64_SIZE :XFS_INO32_SIZE ;/* ino # */ + +if (xfs_sb_version_hasftype (&mp->m_sb)) + count +=sizeof (uint8_t ); +return count; +} + +struct xfs_dir2_sf_entry * +xfs_dir2_sf_nextentry ( +struct xfs_mount *mp, +struct xfs_dir2_sf_hdr *hdr, +struct xfs_dir2_sf_entry *sfep) +{ +return (struct xfs_dir2_sf_entry *) + ((char *)sfep +xfs_dir2_sf_entsize (mp, hdr, sfep->namelen)); +} +/* * Given a block directory (dp/block), calculate its size as a shortform (sf) * directory and a header for the sf directory, if it will fit it the @@ -219,7 +245,7 @@ xfs_dir2_block_to_sf( dp->d_ops->sf_put_ftype (sfep, dp->d_ops->data_get_ftype (dep)); - sfep = dp->d_ops->sf_nextentry (sfp, sfep); + sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); } ptr += dp->d_ops->data_entsize (dep->namelen); }@@ -291,7 +317,7 @@ xfs_dir2_sf_addname(/* * Compute entry (and change in) size. */ - incr_isize = dp->d_ops->sf_entsize (sfp, args->namelen); + incr_isize =xfs_dir2_sf_entsize (dp->i_mount, sfp, args->namelen); objchange =0 ;/* @@ -364,18 +390,17 @@ xfs_dir2_sf_addname_easy( xfs_dir2_data_aoff_t offset, /* offset to use for new ent */ int new_isize) /* new directory size */ { +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;int byteoff;/* byte offset in sf dir */ -xfs_inode_t *dp;/* incore directory inode */ xfs_dir2_sf_hdr_t *sfp;/* shortform structure */ - dp = args->dp; - sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; byteoff = (int )((char *)sfep - (char *)sfp);/* * Grow the in-inode space. */ -xfs_idata_realloc (dp, dp->d_ops->sf_entsize (sfp, args->namelen), +xfs_idata_realloc (dp,xfs_dir2_sf_entsize (mp, sfp, args->namelen),XFS_DATA_FORK );/* * Need to set up again due to realloc of the inode data. @@ -416,9 +441,10 @@ xfs_dir2_sf_addname_hard( int objchange, /* changing inode number size */ int new_isize) /* new directory size */ { +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;int add_datasize;/* data size need for new ent */ char *buf;/* buffer for old */ -xfs_inode_t *dp;/* incore directory inode */ int eof;/* reached end of old dir */ int nbytes;/* temp for byte copies */ xfs_dir2_data_aoff_t new_offset;/* next offset value */ @@ -432,8 +458,6 @@ xfs_dir2_sf_addname_hard(/* * Copy the old directory to the stack buffer. */ - dp = args->dp; - sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; old_isize = (int )dp->i_d.di_size; buf =kmem_alloc (old_isize,0 );@@ -450,7 +474,7 @@ xfs_dir2_sf_addname_hard( eof = (char *)oldsfep == &buf[old_isize]; !eof; offset = new_offset + dp->d_ops->data_entsize(oldsfep->namelen), - oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep), + oldsfep = xfs_dir2_sf_nextentry(mp, oldsfp, oldsfep), eof = (char *)oldsfep == &buf[old_isize]) { new_offset =xfs_dir2_sf_get_offset (oldsfep);if (offset + add_datasize <= new_offset)@@ -488,7 +512,7 @@ xfs_dir2_sf_addname_hard(* If there's more left to copy, do that. */ if (!eof) { - sfep = dp->d_ops->sf_nextentry (sfp, sfep); + sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep);memcpy (sfep, oldsfep, old_isize - nbytes); }kmem_free (buf);@@ -510,7 +534,8 @@ xfs_dir2_sf_addname_pick( xfs_dir2_sf_entry_t **sfepp, /* out(1): new entry ptr */ xfs_dir2_data_aoff_t *offsetp) /* out(1): new offset */ { -xfs_inode_t *dp;/* incore directory inode */ +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;int holefit;/* found hole it will fit in */ int i;/* entry number */ xfs_dir2_data_aoff_t offset;/* data block offset */ @@ -519,8 +544,6 @@ xfs_dir2_sf_addname_pick(int size;/* entry's data size */ int used;/* data bytes used */ - dp = args->dp; - sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; size = dp->d_ops->data_entsize (args->namelen); offset = dp->d_ops->data_first_offset;@@ -536,7 +559,7 @@ xfs_dir2_sf_addname_pick( holefit = offset + size <=xfs_dir2_sf_get_offset (sfep); offset =xfs_dir2_sf_get_offset (sfep) + dp->d_ops->data_entsize (sfep->namelen); - sfep = dp->d_ops->sf_nextentry (sfp, sfep); + sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); }/* * Calculate data bytes used excluding the new entry, if this @@ -595,7 +618,7 @@ xfs_dir2_sf_check(for (i =0 , sfep =xfs_dir2_sf_firstentry (sfp); i < sfp->count; - i++, sfep = dp->d_ops->sf_nextentry (sfp, sfep)) { + i++, sfep =xfs_dir2_sf_nextentry (dp->i_mount, sfp, sfep)) {ASSERT (xfs_dir2_sf_get_offset (sfep) >= offset); ino = dp->d_ops->sf_get_ino (sfp, sfep); i8count += ino >XFS_DIR2_MAX_SHORT_INUM ;@@ -680,7 +703,7 @@ xfs_dir2_sf_verify(* within the data buffer. The next entry starts after the * name component, so nextentry is an acceptable test. */ - next_sfep = dops->sf_nextentry (sfp, sfep); + next_sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep);if (endp < (char *)next_sfep)return __this_address;@@ -779,7 +802,8 @@ int /* error */xfs_dir2_sf_lookup ( xfs_da_args_t *args) /* operation arguments */ { -xfs_inode_t *dp;/* incore directory inode */ +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;int i;/* entry index */ int error;xfs_dir2_sf_entry_t *sfep;/* shortform directory entry */ @@ -790,7 +814,6 @@ xfs_dir2_sf_lookup(trace_xfs_dir2_sf_lookup (args);xfs_dir2_sf_check (args); - dp = args->dp;ASSERT (dp->i_df.if_flags &XFS_IFINLINE );/* @@ -828,7 +851,7 @@ xfs_dir2_sf_lookup(*/ ci_sfep =NULL ;for (i =0 , sfep =xfs_dir2_sf_firstentry (sfp); i < sfp->count; - i++, sfep = dp->d_ops->sf_nextentry (sfp, sfep)) { + i++, sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep)) {/* * Compare name and if it's an exact match, return the inode * number. If it's the first case-insensitive match, store the @@ -864,8 +887,9 @@ int /* error */xfs_dir2_sf_removename ( xfs_da_args_t *args) { +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;int byteoff;/* offset of removed entry */ -xfs_inode_t *dp;/* incore directory inode */ int entsize;/* this entry's size */ int i;/* shortform entry index */ int newsize;/* new inode size */ @@ -875,8 +899,6 @@ xfs_dir2_sf_removename(trace_xfs_dir2_sf_removename (args); - dp = args->dp; -ASSERT (dp->i_df.if_flags &XFS_IFINLINE ); oldsize = (int )dp->i_d.di_size;/* @@ -895,7 +917,7 @@ xfs_dir2_sf_removename(* Find the one we're deleting. */ for (i =0 , sfep =xfs_dir2_sf_firstentry (sfp); i < sfp->count; - i++, sfep = dp->d_ops->sf_nextentry (sfp, sfep)) { + i++, sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep)) {if (xfs_da_compname (args, sfep->name, sfep->namelen) ==XFS_CMP_EXACT ) { ASSERT(dp->d_ops->sf_get_ino(sfp, sfep) ==@@ -912,7 +934,7 @@ xfs_dir2_sf_removename(* Calculate sizes. */ byteoff = (int )((char *)sfep - (char *)sfp); - entsize = dp->d_ops->sf_entsize (sfp, args->namelen); + entsize =xfs_dir2_sf_entsize (mp, sfp, args->namelen); newsize = oldsize - entsize;/* * Copy the part if any after the removed entry, sliding it down. @@ -951,7 +973,8 @@ int /* error */xfs_dir2_sf_replace ( xfs_da_args_t *args) /* operation arguments */ { -xfs_inode_t *dp;/* incore directory inode */ +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;int i;/* entry index */ xfs_ino_t ino=0 ;/* entry old inode number */ int i8elevated;/* sf_toino8 set i8count=1 */ @@ -960,14 +983,12 @@ xfs_dir2_sf_replace(trace_xfs_dir2_sf_replace (args); - dp = args->dp; -ASSERT (dp->i_df.if_flags &XFS_IFINLINE );/* * Bail out if the shortform directory is way too small. */ if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t , parent)) { -ASSERT (XFS_FORCED_SHUTDOWN (dp->i_mount)); +ASSERT (XFS_FORCED_SHUTDOWN (mp));return -EIO ; }ASSERT (dp->i_df.if_bytes == dp->i_d.di_size);@@ -1017,7 +1038,7 @@ xfs_dir2_sf_replace(*/ else {for (i =0 , sfep =xfs_dir2_sf_firstentry (sfp); i < sfp->count; - i++, sfep = dp->d_ops->sf_nextentry (sfp, sfep)) { + i++, sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep)) {if (xfs_da_compname (args, sfep->name, sfep->namelen) ==XFS_CMP_EXACT ) { ino = dp->d_ops->sf_get_ino (sfp, sfep);@@ -1076,8 +1097,9 @@ static voidxfs_dir2_sf_toino4 ( xfs_da_args_t *args) /* operation arguments */ { +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;char *buf;/* old dir's buffer */ -xfs_inode_t *dp;/* incore directory inode */ int i;/* entry index */ int newsize;/* new inode size */ xfs_dir2_sf_entry_t *oldsfep;/* old sf entry */ @@ -1088,8 +1110,6 @@ xfs_dir2_sf_toino4(trace_xfs_dir2_sf_toino4 (args); - dp = args->dp; -/* * Copy the old directory to the buffer. * Then nuke it from the inode, and add the new buffer to the inode. @@ -1123,8 +1143,8 @@ xfs_dir2_sf_toino4(for (i =0 , sfep =xfs_dir2_sf_firstentry (sfp), oldsfep =xfs_dir2_sf_firstentry (oldsfp); i < sfp->count; - i++, sfep = dp->d_ops->sf_nextentry (sfp, sfep), - oldsfep = dp->d_ops->sf_nextentry (oldsfp, oldsfep)) { + i++, sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep), + oldsfep =xfs_dir2_sf_nextentry (mp, oldsfp, oldsfep)) { sfep->namelen = oldsfep->namelen;memcpy (sfep->offset, oldsfep->offset,sizeof (sfep->offset));memcpy (sfep->name, oldsfep->name, sfep->namelen);@@ -1149,8 +1169,9 @@ static voidxfs_dir2_sf_toino8 ( xfs_da_args_t *args) /* operation arguments */ { +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;char *buf;/* old dir's buffer */ -xfs_inode_t *dp;/* incore directory inode */ int i;/* entry index */ int newsize;/* new inode size */ xfs_dir2_sf_entry_t *oldsfep;/* old sf entry */ @@ -1161,8 +1182,6 @@ xfs_dir2_sf_toino8(trace_xfs_dir2_sf_toino8 (args); - dp = args->dp; -/* * Copy the old directory to the buffer. * Then nuke it from the inode, and add the new buffer to the inode. @@ -1196,8 +1215,8 @@ xfs_dir2_sf_toino8(for (i =0 , sfep =xfs_dir2_sf_firstentry (sfp), oldsfep =xfs_dir2_sf_firstentry (oldsfp); i < sfp->count; - i++, sfep = dp->d_ops->sf_nextentry (sfp, sfep), - oldsfep = dp->d_ops->sf_nextentry (oldsfp, oldsfep)) { + i++, sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep), + oldsfep =xfs_dir2_sf_nextentry (mp, oldsfp, oldsfep)) { sfep->namelen = oldsfep->namelen;memcpy (sfep->offset, oldsfep->offset,sizeof (sfep->offset));memcpy (sfep->name, oldsfep->name, sfep->namelen);fs/xfs/xfs_dir2_readdir.c +4
-3@@ -48,6 +48,7 @@ xfs_dir2_sf_getdents( {int i;/* shortform entry number */ struct xfs_inode *dp = args->dp;/* incore directory inode */ +struct xfs_mount *mp = dp->i_mount;xfs_dir2_dataptr_t off;/* current entry's offset */ xfs_dir2_sf_entry_t *sfep;/* shortform directory entry */ xfs_dir2_sf_hdr_t *sfp;/* shortform structure */ @@ -109,7 +110,7 @@ xfs_dir2_sf_getdents( xfs_dir2_sf_get_offset(sfep));if (ctx->pos > off) { - sfep = dp->d_ops->sf_nextentry (sfp, sfep); + sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep);continue ; }@@ -122,9 +123,9 @@ xfs_dir2_sf_getdents(return -EFSCORRUPTED ; }if (!dir_emit (ctx, (char *)sfep->name, sfep->namelen, ino, -xfs_dir3_get_dtype (dp->i_mount, filetype))) +xfs_dir3_get_dtype (mp, filetype)))return 0 ; - sfep = dp->d_ops->sf_nextentry (sfp, sfep); + sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); } ctx->pos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk + 1, 0) &Signature · 1 line
2.20.1
PATCH 21/34 xfs: devirtualize ->sf_get_ino and ->sf_put_ino
In reply to Christoph HellwigReplace the ->sf_get_ino and ->sf_put_ino dir ops methods with directly called xfs_dir2_sf_get_ino nd xfs_dir2_sf_put_ino helpers that take care of the difference between the directory format with and without the file type field. Also move xfs_dir2_sf_get_parent_ino and xfs_dir2_sf_put_parent_ino to xfs_dir2_sf.c with the rest of the low-level short form entry handling.
--- fs/xfs/libxfs/xfs_da_format.c | 94 ---------------------------------- fs/xfs/libxfs/xfs_dir2.h | 5 -- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_priv.h | 2 + fs/xfs/libxfs/xfs_dir2_sf.c | 90 +++++++++++++++++++++++++++----- fs/xfs/xfs_dir2_readdir.c | 2 +- 6 files changed, 81 insertions(+), 114 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -94
@@ -58,94 +58,6 @@ xfs_dir3_sfe_put_ftype( sfep->name[sfep->namelen] = ftype; } -/* -* Inode numbers in short-form directories can come in two versions, -* either 4 bytes or 8 bytes wide. These helpers deal with the -* two forms transparently by looking at the headers i8count field. -* -* For 64-bit inode number the most significant byte must be zero. -*/ -static xfs_ino_t -xfs_dir2_sf_get_ino ( -struct xfs_dir2_sf_hdr *hdr, -uint8_t *from) -{ -if (hdr->i8count) -return get_unaligned_be64 (from) &0x00ffffffffffffffULL ; -else -return get_unaligned_be32 (from); -} - -static void -xfs_dir2_sf_put_ino ( -struct xfs_dir2_sf_hdr *hdr, -uint8_t *to, -xfs_ino_t ino) -{ -ASSERT ((ino &0xff00000000000000ULL ) ==0 ); - -if (hdr->i8count) -put_unaligned_be64 (ino, to); -else -put_unaligned_be32 (ino, to); -} - -xfs_ino_t -xfs_dir2_sf_get_parent_ino ( -struct xfs_dir2_sf_hdr *hdr) -{ -return xfs_dir2_sf_get_ino (hdr, hdr->parent); -} - -void -xfs_dir2_sf_put_parent_ino ( -struct xfs_dir2_sf_hdr *hdr, -xfs_ino_t ino) -{ -xfs_dir2_sf_put_ino (hdr, hdr->parent, ino); -} - -/* -* In short-form directory entries the inode numbers are stored at variable -* offset behind the entry name. If the entry stores a filetype value, then it -* sits between the name and the inode number. Hence the inode numbers may only -* be accessed through the helpers below. -*/ -static xfs_ino_t -xfs_dir2_sfe_get_ino ( -struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep) -{ -return xfs_dir2_sf_get_ino (hdr, &sfep->name[sfep->namelen]); -} - -static void -xfs_dir2_sfe_put_ino ( -struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep, -xfs_ino_t ino) -{ -xfs_dir2_sf_put_ino (hdr, &sfep->name[sfep->namelen], ino); -} - -static xfs_ino_t -xfs_dir3_sfe_get_ino ( -struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep) -{ -return xfs_dir2_sf_get_ino (hdr, &sfep->name[sfep->namelen +1 ]); -} - -static void -xfs_dir3_sfe_put_ino ( -struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep, -xfs_ino_t ino) -{ -xfs_dir2_sf_put_ino (hdr, &sfep->name[sfep->namelen +1 ], ino); -} - -/* * Directory data block operations */
@@ -361,8 +273,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)static const struct xfs_dir_ops xfs_dir2_ops = { .sf_get_ftype = xfs_dir2_sfe_get_ftype, .sf_put_ftype = xfs_dir2_sfe_put_ftype, - .sf_get_ino = xfs_dir2_sfe_get_ino, - .sf_put_ino = xfs_dir2_sfe_put_ino, .data_entsize = xfs_dir2_data_entsize, .data_get_ftype = xfs_dir2_data_get_ftype,
@@ -388,8 +298,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .sf_get_ftype = xfs_dir3_sfe_get_ftype, .sf_put_ftype = xfs_dir3_sfe_put_ftype, - .sf_get_ino = xfs_dir3_sfe_get_ino, - .sf_put_ino = xfs_dir3_sfe_put_ino, .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype,
@@ -415,8 +323,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {static const struct xfs_dir_ops xfs_dir3_ops = { .sf_get_ftype = xfs_dir3_sfe_get_ftype, .sf_put_ftype = xfs_dir3_sfe_put_ftype, - .sf_get_ino = xfs_dir3_sfe_get_ino, - .sf_put_ino = xfs_dir3_sfe_put_ino, .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype,
fs/xfs/libxfs/xfs_dir2.h +0 -5
@@ -35,11 +35,6 @@ struct xfs_dir_ops {uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep);void (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep,uint8_t ftype); -xfs_ino_t (*sf_get_ino)(struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep); -void (*sf_put_ino)(struct xfs_dir2_sf_hdr *hdr, -struct xfs_dir2_sf_entry *sfep, -xfs_ino_t ino);int (*data_entsize)(int len);uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);
fs/xfs/libxfs/xfs_dir2_block.c +1 -1
@@ -1214,7 +1214,7 @@ xfs_dir2_sf_to_block(* Copy a real entry. */ dep = (xfs_dir2_data_entry_t *)((char *)hdr + newoffset); - dep->inumber =cpu_to_be64 (dp->d_ops->sf_get_ino (sfp, sfep)); + dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_ino (mp, sfp, sfep)); dep->namelen = sfep->namelen; dp->d_ops->data_put_ftype (dep, dp->d_ops->sf_get_ftype (sfep));memcpy (dep->name, sfep->name, dep->namelen);
fs/xfs/libxfs/xfs_dir2_priv.h +2 -0
@@ -135,6 +135,8 @@ extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t fbno, struct xfs_buf **bpp);/* xfs_dir2_sf.c */ +xfs_ino_t xfs_dir2_sf_get_ino (struct xfs_mount *mp,struct xfs_dir2_sf_hdr *hdr, +struct xfs_dir2_sf_entry *sfep);xfs_ino_t xfs_dir2_sf_get_parent_ino (struct xfs_dir2_sf_hdr *hdr);void xfs_dir2_sf_put_parent_ino (struct xfs_dir2_sf_hdr *hdr,xfs_ino_t ino); struct xfs_dir2_sf_entry *xfs_dir2_sf_nextentry(struct xfs_mount *mp,
fs/xfs/libxfs/xfs_dir2_sf.c +77 -13
157 lines not on this page · raw message
fs/xfs/xfs_dir2_readdir.c +1 -1
@@ -114,7 +114,7 @@ xfs_dir2_sf_getdents(continue ; } - ino = dp->d_ops->sf_get_ino (sfp, sfep); + ino =xfs_dir2_sf_get_ino (mp, sfp, sfep); filetype = dp->d_ops->sf_get_ftype (sfep); ctx->pos = off &0x7fffffff ;if (!xfs_dir2_namecheck (sfep->name, sfep->namelen)) {
Signature · 1 line
2.20.1
Re: [PATCH 21/34] xfs: devirtualize ->sf_get_ino and ->sf_put_ino
Quoted 2 lines · Christoph Hellwig
Replace the ->sf_get_ino and ->sf_put_ino dir ops methods with directly called
xfs_dir2_sf_get_inondxfs_dir2_sf_put_inohelpers that take care
^^^ "and"
Quoted 6 lines
of the difference between the directory format with and without the file type field. Also move
xfs_dir2_sf_get_parent_inoandxfs_dir2_sf_put_parent_inotoxfs_dir2_sf.cwith the rest of the low-level short form entry handling.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok, except...
<snip>
Quoted 18 lines
fs/xfs/libxfs/xfs_dir2_sf.c +10
-0@@ -63,6 +63,69 @@ xfs_dir2_sf_nextentry( ((char *)sfep +xfs_dir2_sf_entsize (mp, hdr, sfep->namelen)); } +/* +* In short-form directory entries the inode numbers are stored at variable +* offset behind the entry name. If the entry stores a filetype value, then it +* sits between the name and the inode number. The actual inode numbers can +* come in two formats as well, either 4 bytes or 8 bytes wide. +*/ +xfs_ino_t +xfs_dir2_sf_get_ino( + struct xfs_mount *mp, + struct xfs_dir2_sf_hdr *hdr,
fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 85
Quoted 10 lines
fs/xfs/libxfs/xfs_dir2_sf.c +10
-0+ struct xfs_dir2_sf_entry *sfep) +{ +uint8_t *from = sfep->name + sfep->namelen; + +if (xfs_sb_version_hasftype (&mp->m_sb)) + from++; + +if (!hdr->i8count) +return get_unaligned_be32 (from); +return get_unaligned_be64 (from) &0x00ffffffffffffffULL ;
...maybe we ought to convert this to use XFS_MAXINUMBER instead of encoding magic numbers?
fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 97
Quoted 12 lines
fs/xfs/libxfs/xfs_dir2_sf.c +12
-0+} + +void +xfs_dir2_sf_put_ino ( +struct xfs_mount *mp, +struct xfs_dir2_sf_hdr *hdr, +struct xfs_dir2_sf_entry *sfep, +xfs_ino_t ino) +{ +uint8_t *to = sfep->name + sfep->namelen; + +ASSERT ((ino &0xff00000000000000ULL ) ==0 );
Same here...
Quoted 6 lines
fs/xfs/libxfs/xfs_dir2_sf.c +6
-0+if (xfs_sb_version_hasftype (&mp->m_sb)) + to++; + +if (hdr->i8count) +put_unaligned_be64 (ino, to); +else
fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 114
Quoted 10 lines
fs/xfs/libxfs/xfs_dir2_sf.c +10
-0+put_unaligned_be32 (ino, to); +} + +xfs_ino_t +xfs_dir2_sf_get_parent_ino ( +struct xfs_dir2_sf_hdr *hdr) +{ +if (!hdr->i8count) +return get_unaligned_be32 (hdr->parent); +return get_unaligned_be64 (hdr->parent) &0x00ffffffffffffffULL ;
And here...
fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 122
Quoted 8 lines
fs/xfs/libxfs/xfs_dir2_sf.c +8
-0+} + +void +xfs_dir2_sf_put_parent_ino ( +struct xfs_dir2_sf_hdr *hdr, +xfs_ino_t ino) +{ +ASSERT ((ino &0xff00000000000000ULL ) ==0 );
And here?
--D
Quoted 123 lines
fs/xfs/libxfs/xfs_dir2_sf.c +20
-13+if (hdr->i8count) +put_unaligned_be64 (ino, hdr->parent); +else +put_unaligned_be32 (ino, hdr->parent); +} +/* * Given a block directory (dp/block), calculate its size as a shortform (sf) * directory and a header for the sf directory, if it will fit it the @@ -240,7 +303,7 @@ xfs_dir2_block_to_sf( (xfs_dir2_data_aoff_t) ((char *)dep - (char *)hdr));memcpy (sfep->name, dep->name, dep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, +xfs_dir2_sf_put_ino (mp, sfp, sfep,be64_to_cpu (dep->inumber)); dp->d_ops->sf_put_ftype (sfep, dp->d_ops->data_get_ftype (dep));@@ -413,7 +476,7 @@ xfs_dir2_sf_addname_easy( sfep->namelen = args->namelen;xfs_dir2_sf_put_offset (sfep, offset);memcpy (sfep->name, args->name, sfep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, args->inumber); +xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype (sfep, args->filetype);/* @@ -503,7 +566,7 @@ xfs_dir2_sf_addname_hard( sfep->namelen = args->namelen;xfs_dir2_sf_put_offset (sfep, offset);memcpy (sfep->name, args->name, sfep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, args->inumber); +xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype (sfep, args->filetype); sfp->count++;if (args->inumber >XFS_DIR2_MAX_SHORT_INUM && !objchange)@@ -620,7 +683,7 @@ xfs_dir2_sf_check( i < sfp->count; i++, sfep = xfs_dir2_sf_nextentry(dp->i_mount, sfp, sfep)) {ASSERT (xfs_dir2_sf_get_offset (sfep) >= offset); - ino = dp->d_ops->sf_get_ino (sfp, sfep); + ino =xfs_dir2_sf_get_ino (dp->i_mount, sfp, sfep); i8count += ino >XFS_DIR2_MAX_SHORT_INUM ; offset = xfs_dir2_sf_get_offset(sfep) +@@ -712,7 +775,7 @@ xfs_dir2_sf_verify(return __this_address;/* Check the inode number. */ - ino = dops->sf_get_ino (sfp, sfep); + ino =xfs_dir2_sf_get_ino (mp, sfp, sfep); i8count += ino >XFS_DIR2_MAX_SHORT_INUM ; error =xfs_dir_ino_validate (mp, ino);if (error)@@ -861,7 +924,7 @@ xfs_dir2_sf_lookup( sfep->namelen);if (cmp !=XFS_CMP_DIFFERENT && cmp != args->cmpresult) { args->cmpresult = cmp; - args->inumber = dp->d_ops->sf_get_ino (sfp, sfep); + args->inumber =xfs_dir2_sf_get_ino (mp, sfp, sfep); args->filetype = dp->d_ops->sf_get_ftype (sfep);if (cmp ==XFS_CMP_EXACT )return -EEXIST ;@@ -920,7 +983,7 @@ xfs_dir2_sf_removename( i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep)) {if (xfs_da_compname (args, sfep->name, sfep->namelen) ==XFS_CMP_EXACT ) { -ASSERT (dp->d_ops->sf_get_ino (sfp, sfep) == +ASSERT (xfs_dir2_sf_get_ino (mp, sfp, sfep) == args->inumber);break ; }@@ -1041,9 +1104,10 @@ xfs_dir2_sf_replace( i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep)) {if (xfs_da_compname (args, sfep->name, sfep->namelen) ==XFS_CMP_EXACT ) { - ino = dp->d_ops->sf_get_ino (sfp, sfep); + ino =xfs_dir2_sf_get_ino (mp, sfp, sfep);ASSERT (args->inumber != ino); - dp->d_ops->sf_put_ino (sfp, sfep, args->inumber); +xfs_dir2_sf_put_ino (mp, sfp, sfep, + args->inumber); dp->d_ops->sf_put_ftype (sfep, args->filetype);break ; }@@ -1148,8 +1212,8 @@ xfs_dir2_sf_toino4( sfep->namelen = oldsfep->namelen;memcpy (sfep->offset, oldsfep->offset,sizeof (sfep->offset));memcpy (sfep->name, oldsfep->name, sfep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, - dp->d_ops->sf_get_ino (oldsfp, oldsfep)); +xfs_dir2_sf_put_ino (mp, sfp, sfep, +xfs_dir2_sf_get_ino (mp, oldsfp, oldsfep)); dp->d_ops->sf_put_ftype (sfep, dp->d_ops->sf_get_ftype (oldsfep)); }/* @@ -1220,8 +1284,8 @@ xfs_dir2_sf_toino8( sfep->namelen = oldsfep->namelen;memcpy (sfep->offset, oldsfep->offset,sizeof (sfep->offset));memcpy (sfep->name, oldsfep->name, sfep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, - dp->d_ops->sf_get_ino (oldsfp, oldsfep)); +xfs_dir2_sf_put_ino (mp, sfp, sfep, +xfs_dir2_sf_get_ino (mp, oldsfp, oldsfep)); dp->d_ops->sf_put_ftype (sfep, dp->d_ops->sf_get_ftype (oldsfep)); }/* fs/xfs/xfs_dir2_readdir.c +1
-1@@ -114,7 +114,7 @@ xfs_dir2_sf_getdents(continue ; } - ino = dp->d_ops->sf_get_ino (sfp, sfep); + ino =xfs_dir2_sf_get_ino (mp, sfp, sfep); filetype = dp->d_ops->sf_get_ftype (sfep); ctx->pos = off &0x7fffffff ;if (!xfs_dir2_namecheck (sfep->name, sfep->namelen)) {Signature · 1 line
2.20.1
Re: [PATCH 21/34] xfs: devirtualize ->sf_get_ino and ->sf_put_ino
Quoted 49 lines · Darrick J. Wong
Quoted 2 lines · Christoph Hellwig
Replace the ->sf_get_ino and ->sf_put_ino dir ops methods with directly called
xfs_dir2_sf_get_inondxfs_dir2_sf_put_inohelpers that take care^^^ "and"Quoted 6 lines
of the difference between the directory format with and without the file type field. Also move
xfs_dir2_sf_get_parent_inoandxfs_dir2_sf_put_parent_inotoxfs_dir2_sf.cwith the rest of the low-level short form entry handling.Signed-off-by Christoph Hellwig <[email protected]>Looks ok, except...
<snip>
Quoted 18 lines
fs/xfs/libxfs/xfs_dir2_sf.c +10
-0@@ -63,6 +63,69 @@ xfs_dir2_sf_nextentry( ((char *)sfep +xfs_dir2_sf_entsize (mp, hdr, sfep->namelen)); } +/* +* In short-form directory entries the inode numbers are stored at variable +* offset behind the entry name. If the entry stores a filetype value, then it +* sits between the name and the inode number. The actual inode numbers can +* come in two formats as well, either 4 bytes or 8 bytes wide. +*/ +xfs_ino_t +xfs_dir2_sf_get_ino( + struct xfs_mount *mp, + struct xfs_dir2_sf_hdr *hdr,fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 85
Quoted 10 lines
fs/xfs/libxfs/xfs_dir2_sf.c +10
-0+ struct xfs_dir2_sf_entry *sfep) +{ +uint8_t *from = sfep->name + sfep->namelen; + +if (xfs_sb_version_hasftype (&mp->m_sb)) + from++; + +if (!hdr->i8count) +return get_unaligned_be32 (from); +return get_unaligned_be64 (from) &0x00ffffffffffffffULL ;...maybe we ought to convert this to use
XFS_MAXINUMBERinstead of encoding magic numbers?
Quoted 4 lines
fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 89
Quoted 4 lines
fs/xfs/libxfs/xfs_dir2_sf.c +4
-0+} + +void +xfs_dir2_sf_put_ino(
Also, I think these helpers can be static now...
--D
Quoted 166 lines
fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 97
Quoted 8 lines
fs/xfs/libxfs/xfs_dir2_sf.c +8
-0+struct xfs_mount *mp, + struct xfs_dir2_sf_hdr *hdr, + struct xfs_dir2_sf_entry *sfep, + xfs_ino_t ino) +{ + uint8_t *to = sfep->name + sfep->namelen; + +ASSERT ((ino &0xff00000000000000ULL ) ==0 );Same here...
Quoted 6 lines
fs/xfs/libxfs/xfs_dir2_sf.c +6
-0+if (xfs_sb_version_hasftype (&mp->m_sb)) + to++; + +if (hdr->i8count) +put_unaligned_be64 (ino, to); +else fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 114
Quoted 10 lines
fs/xfs/libxfs/xfs_dir2_sf.c +10
-0+put_unaligned_be32 (ino, to); +} + +xfs_ino_t +xfs_dir2_sf_get_parent_ino ( +struct xfs_dir2_sf_hdr *hdr) +{ +if (!hdr->i8count) +return get_unaligned_be32 (hdr->parent); +return get_unaligned_be64 (hdr->parent) &0x00ffffffffffffffULL ;And here...
fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 122
Quoted 8 lines
fs/xfs/libxfs/xfs_dir2_sf.c +8
-0+} + +void +xfs_dir2_sf_put_parent_ino ( +struct xfs_dir2_sf_hdr *hdr, +xfs_ino_t ino) +{ +ASSERT ((ino &0xff00000000000000ULL ) ==0 );And here?
--D
Quoted 123 lines
fs/xfs/libxfs/xfs_dir2_sf.c +20
-13+if (hdr->i8count) +put_unaligned_be64 (ino, hdr->parent); +else +put_unaligned_be32 (ino, hdr->parent); +} +/* * Given a block directory (dp/block), calculate its size as a shortform (sf) * directory and a header for the sf directory, if it will fit it the @@ -240,7 +303,7 @@ xfs_dir2_block_to_sf( (xfs_dir2_data_aoff_t) ((char *)dep - (char *)hdr));memcpy (sfep->name, dep->name, dep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, +xfs_dir2_sf_put_ino (mp, sfp, sfep,be64_to_cpu (dep->inumber)); dp->d_ops->sf_put_ftype (sfep, dp->d_ops->data_get_ftype (dep));@@ -413,7 +476,7 @@ xfs_dir2_sf_addname_easy( sfep->namelen = args->namelen;xfs_dir2_sf_put_offset (sfep, offset);memcpy (sfep->name, args->name, sfep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, args->inumber); +xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype (sfep, args->filetype);/* @@ -503,7 +566,7 @@ xfs_dir2_sf_addname_hard( sfep->namelen = args->namelen;xfs_dir2_sf_put_offset (sfep, offset);memcpy (sfep->name, args->name, sfep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, args->inumber); +xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype (sfep, args->filetype); sfp->count++;if (args->inumber >XFS_DIR2_MAX_SHORT_INUM && !objchange)@@ -620,7 +683,7 @@ xfs_dir2_sf_check( i < sfp->count; i++, sfep = xfs_dir2_sf_nextentry(dp->i_mount, sfp, sfep)) {ASSERT (xfs_dir2_sf_get_offset (sfep) >= offset); - ino = dp->d_ops->sf_get_ino (sfp, sfep); + ino =xfs_dir2_sf_get_ino (dp->i_mount, sfp, sfep); i8count += ino >XFS_DIR2_MAX_SHORT_INUM ; offset = xfs_dir2_sf_get_offset(sfep) +@@ -712,7 +775,7 @@ xfs_dir2_sf_verify(return __this_address;/* Check the inode number. */ - ino = dops->sf_get_ino (sfp, sfep); + ino =xfs_dir2_sf_get_ino (mp, sfp, sfep); i8count += ino >XFS_DIR2_MAX_SHORT_INUM ; error =xfs_dir_ino_validate (mp, ino);if (error)@@ -861,7 +924,7 @@ xfs_dir2_sf_lookup( sfep->namelen);if (cmp !=XFS_CMP_DIFFERENT && cmp != args->cmpresult) { args->cmpresult = cmp; - args->inumber = dp->d_ops->sf_get_ino (sfp, sfep); + args->inumber =xfs_dir2_sf_get_ino (mp, sfp, sfep); args->filetype = dp->d_ops->sf_get_ftype (sfep);if (cmp ==XFS_CMP_EXACT )return -EEXIST ;@@ -920,7 +983,7 @@ xfs_dir2_sf_removename( i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep)) {if (xfs_da_compname (args, sfep->name, sfep->namelen) ==XFS_CMP_EXACT ) { -ASSERT (dp->d_ops->sf_get_ino (sfp, sfep) == +ASSERT (xfs_dir2_sf_get_ino (mp, sfp, sfep) == args->inumber);break ; }@@ -1041,9 +1104,10 @@ xfs_dir2_sf_replace( i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep)) {if (xfs_da_compname (args, sfep->name, sfep->namelen) ==XFS_CMP_EXACT ) { - ino = dp->d_ops->sf_get_ino (sfp, sfep); + ino =xfs_dir2_sf_get_ino (mp, sfp, sfep);ASSERT (args->inumber != ino); - dp->d_ops->sf_put_ino (sfp, sfep, args->inumber); +xfs_dir2_sf_put_ino (mp, sfp, sfep, + args->inumber); dp->d_ops->sf_put_ftype (sfep, args->filetype);break ; }@@ -1148,8 +1212,8 @@ xfs_dir2_sf_toino4( sfep->namelen = oldsfep->namelen;memcpy (sfep->offset, oldsfep->offset,sizeof (sfep->offset));memcpy (sfep->name, oldsfep->name, sfep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, - dp->d_ops->sf_get_ino (oldsfp, oldsfep)); +xfs_dir2_sf_put_ino (mp, sfp, sfep, +xfs_dir2_sf_get_ino (mp, oldsfp, oldsfep)); dp->d_ops->sf_put_ftype (sfep, dp->d_ops->sf_get_ftype (oldsfep)); }/* @@ -1220,8 +1284,8 @@ xfs_dir2_sf_toino8( sfep->namelen = oldsfep->namelen;memcpy (sfep->offset, oldsfep->offset,sizeof (sfep->offset));memcpy (sfep->name, oldsfep->name, sfep->namelen); - dp->d_ops->sf_put_ino (sfp, sfep, - dp->d_ops->sf_get_ino (oldsfp, oldsfep)); +xfs_dir2_sf_put_ino (mp, sfp, sfep, +xfs_dir2_sf_get_ino (mp, oldsfp, oldsfep)); dp->d_ops->sf_put_ftype (sfep, dp->d_ops->sf_get_ftype (oldsfep)); }/* fs/xfs/xfs_dir2_readdir.c +1
-1@@ -114,7 +114,7 @@ xfs_dir2_sf_getdents(continue ; } - ino = dp->d_ops->sf_get_ino (sfp, sfep); + ino =xfs_dir2_sf_get_ino (mp, sfp, sfep); filetype = dp->d_ops->sf_get_ftype (sfep); ctx->pos = off &0x7fffffff ;if (!xfs_dir2_namecheck (sfep->name, sfep->namelen)) {Signature · 1 line
2.20.1
Re: [PATCH 21/34] xfs: devirtualize ->sf_get_ino and ->sf_put_ino
Quoted 6 lines · Darrick J. Wong
Quoted 4 lines
fs/xfs/libxfs/xfs_dir2_sf.c xfs_dir2_sf_nextentry( · line 89
Quoted 4 lines
fs/xfs/libxfs/xfs_dir2_sf.c +4
-0+} + +void +xfs_dir2_sf_put_ino(Also, I think these helpers can be static now...
xfs_dir2_sf_put_ino can and should be marked static. xfs_dir2_sf_get_ino is used elsewhere, though.
PATCH 22/34 xfs: devirtualize ->sf_get_ftype and ->sf_put_ftype
In reply to Christoph HellwigReplace the ->sf_get_ftype and ->sf_put_ftype dir ops methods with directly called xfs_dir2_sf_get_ftype and xfs_dir2_sf_put_ftype helpers that takes care of the differences between the directory format with and without the file type field.
--- fs/xfs/libxfs/xfs_da_format.c | 52 ----------------------------- fs/xfs/libxfs/xfs_dir2.h | 4 --- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/libxfs/xfs_dir2_sf.c | 60 ++++++++++++++++++++++++++-------- fs/xfs/xfs_dir2_readdir.c | 2 +- 6 files changed, 50 insertions(+), 72 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -52
@@ -15,49 +15,6 @@#include "xfs_dir2.h" #include "xfs_dir2_priv.h" -/* -* For filetype enabled shortform directories, the file type field is stored at -* the end of the name. Because it's only a single byte, endian conversion is -* not necessary. For non-filetype enable directories, the type is always -* unknown and we never store the value. -*/ -static uint8_t -xfs_dir2_sfe_get_ftype ( -struct xfs_dir2_sf_entry *sfep) -{ -return XFS_DIR3_FT_UNKNOWN ; -} - -static void -xfs_dir2_sfe_put_ftype ( -struct xfs_dir2_sf_entry *sfep, -uint8_t ftype) -{ -ASSERT (ftype <XFS_DIR3_FT_MAX ); -} - -static uint8_t -xfs_dir3_sfe_get_ftype ( -struct xfs_dir2_sf_entry *sfep) -{ -uint8_t ftype; - - ftype = sfep->name[sfep->namelen]; -if (ftype >=XFS_DIR3_FT_MAX ) -return XFS_DIR3_FT_UNKNOWN ; -return ftype; -} - -static void -xfs_dir3_sfe_put_ftype ( -struct xfs_dir2_sf_entry *sfep, -uint8_t ftype) -{ -ASSERT (ftype <XFS_DIR3_FT_MAX ); - - sfep->name[sfep->namelen] = ftype; -} -/* * Directory data block operations */
@@ -271,9 +228,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) }static const struct xfs_dir_ops xfs_dir2_ops = { - .sf_get_ftype = xfs_dir2_sfe_get_ftype, - .sf_put_ftype = xfs_dir2_sfe_put_ftype, - .data_entsize = xfs_dir2_data_entsize, .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype,
@@ -296,9 +250,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { - .sf_get_ftype = xfs_dir3_sfe_get_ftype, - .sf_put_ftype = xfs_dir3_sfe_put_ftype, - .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype,
@@ -321,9 +272,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { };static const struct xfs_dir_ops xfs_dir3_ops = { - .sf_get_ftype = xfs_dir3_sfe_get_ftype, - .sf_put_ftype = xfs_dir3_sfe_put_ftype, - .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype,
fs/xfs/libxfs/xfs_dir2.h +0 -4
@@ -32,10 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);* directory operations vector for encode/decode routines */ struct xfs_dir_ops { -uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep); -void (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep, -uint8_t ftype); -int (*data_entsize)(int len);uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep); void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,
fs/xfs/libxfs/xfs_dir2_block.c +1 -1
@@ -1216,7 +1216,7 @@ xfs_dir2_sf_to_block( dep = (xfs_dir2_data_entry_t *)((char *)hdr + newoffset); dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_ino (mp, sfp, sfep)); dep->namelen = sfep->namelen; - dp->d_ops->data_put_ftype (dep, dp->d_ops->sf_get_ftype (sfep)); + dp->d_ops->data_put_ftype (dep,xfs_dir2_sf_get_ftype (mp, sfep));memcpy (dep->name, sfep->name, dep->namelen); tagp = dp->d_ops->data_entry_tag_p (dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);
fs/xfs/libxfs/xfs_dir2_priv.h +2 -0
@@ -139,6 +139,8 @@ xfs_ino_t xfs_dir2_sf_get_ino(struct xfs_mount *mp, struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_entry *sfep);xfs_ino_t xfs_dir2_sf_get_parent_ino (struct xfs_dir2_sf_hdr *hdr);void xfs_dir2_sf_put_parent_ino (struct xfs_dir2_sf_hdr *hdr,xfs_ino_t ino); +uint8_t xfs_dir2_sf_get_ftype (struct xfs_mount *mp, +struct xfs_dir2_sf_entry *sfep);struct xfs_dir2_sf_entry *xfs_dir2_sf_nextentry (struct xfs_mount *mp,struct xfs_dir2_sf_hdr *hdr,struct xfs_dir2_sf_entry *sfep); extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
fs/xfs/libxfs/xfs_dir2_sf.c +46 -14
137 lines not on this page · raw message
fs/xfs/xfs_dir2_readdir.c +1 -1
@@ -115,7 +115,7 @@ xfs_dir2_sf_getdents( } ino =xfs_dir2_sf_get_ino (mp, sfp, sfep); - filetype = dp->d_ops->sf_get_ftype (sfep); + filetype =xfs_dir2_sf_get_ftype (mp, sfep); ctx->pos = off &0x7fffffff ;if (!xfs_dir2_namecheck (sfep->name, sfep->namelen)) { XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW,
Signature · 1 line
2.20.1
Re: [PATCH 22/34] xfs: devirtualize ->sf_get_ftype and ->sf_put_ftype
Quoted 6 lines · Christoph Hellwig
Replace the ->sf_get_ftype and ->sf_put_ftype dir ops methods with directly called
xfs_dir2_sf_get_ftypeandxfs_dir2_sf_put_ftypehelpers that takes care of the differences between the directory format with and without the file type field.Signed-off-by Christoph Hellwig <[email protected]>
Seems reasonable to me,
--D
Quoted 303 lines
--- fs/xfs/libxfs/xfs_da_format.c | 52 ----------------------------- fs/xfs/libxfs/xfs_dir2.h | 4 --- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/libxfs/xfs_dir2_sf.c | 60 ++++++++++++++++++++++++++-------- fs/xfs/xfs_dir2_readdir.c | 2 +- 6 files changed, 50 insertions(+), 72 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-52@@ -15,49 +15,6 @@#include "xfs_dir2.h" #include "xfs_dir2_priv.h" -/* -* For filetype enabled shortform directories, the file type field is stored at -* the end of the name. Because it's only a single byte, endian conversion is -* not necessary. For non-filetype enable directories, the type is always -* unknown and we never store the value. -*/ -static uint8_t -xfs_dir2_sfe_get_ftype ( -struct xfs_dir2_sf_entry *sfep) -{ -return XFS_DIR3_FT_UNKNOWN ; -} - -static void -xfs_dir2_sfe_put_ftype ( -struct xfs_dir2_sf_entry *sfep, -uint8_t ftype) -{ -ASSERT (ftype <XFS_DIR3_FT_MAX ); -} - -static uint8_t -xfs_dir3_sfe_get_ftype ( -struct xfs_dir2_sf_entry *sfep) -{ -uint8_t ftype; - - ftype = sfep->name[sfep->namelen]; -if (ftype >=XFS_DIR3_FT_MAX ) -return XFS_DIR3_FT_UNKNOWN ; -return ftype; -} - -static void -xfs_dir3_sfe_put_ftype ( -struct xfs_dir2_sf_entry *sfep, -uint8_t ftype) -{ -ASSERT (ftype <XFS_DIR3_FT_MAX ); - - sfep->name[sfep->namelen] = ftype; -} -/* * Directory data block operations */ @@ -271,9 +228,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) }static const struct xfs_dir_ops xfs_dir2_ops = { - .sf_get_ftype = xfs_dir2_sfe_get_ftype, - .sf_put_ftype = xfs_dir2_sfe_put_ftype, - .data_entsize = xfs_dir2_data_entsize, .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype,@@ -296,9 +250,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { - .sf_get_ftype = xfs_dir3_sfe_get_ftype, - .sf_put_ftype = xfs_dir3_sfe_put_ftype, - .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype,@@ -321,9 +272,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { };static const struct xfs_dir_ops xfs_dir3_ops = { - .sf_get_ftype = xfs_dir3_sfe_get_ftype, - .sf_put_ftype = xfs_dir3_sfe_put_ftype, - .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype,fs/xfs/libxfs/xfs_dir2.h +0
-4@@ -32,10 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);* directory operations vector for encode/decode routines */ struct xfs_dir_ops { -uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep); -void (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep, -uint8_t ftype); -int (*data_entsize)(int len);uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep); void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,fs/xfs/libxfs/xfs_dir2_block.c +1
-1@@ -1216,7 +1216,7 @@ xfs_dir2_sf_to_block( dep = (xfs_dir2_data_entry_t *)((char *)hdr + newoffset); dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_ino (mp, sfp, sfep)); dep->namelen = sfep->namelen; - dp->d_ops->data_put_ftype (dep, dp->d_ops->sf_get_ftype (sfep)); + dp->d_ops->data_put_ftype (dep,xfs_dir2_sf_get_ftype (mp, sfep));memcpy (dep->name, sfep->name, dep->namelen); tagp = dp->d_ops->data_entry_tag_p (dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);fs/xfs/libxfs/xfs_dir2_priv.h +2
-0@@ -139,6 +139,8 @@ xfs_ino_t xfs_dir2_sf_get_ino(struct xfs_mount *mp, struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_entry *sfep);xfs_ino_t xfs_dir2_sf_get_parent_ino (struct xfs_dir2_sf_hdr *hdr);void xfs_dir2_sf_put_parent_ino (struct xfs_dir2_sf_hdr *hdr,xfs_ino_t ino); +uint8_t xfs_dir2_sf_get_ftype (struct xfs_mount *mp, +struct xfs_dir2_sf_entry *sfep);struct xfs_dir2_sf_entry *xfs_dir2_sf_nextentry (struct xfs_mount *mp,struct xfs_dir2_sf_hdr *hdr,struct xfs_dir2_sf_entry *sfep); extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,fs/xfs/libxfs/xfs_dir2_sf.c +46
-14@@ -126,6 +126,37 @@ xfs_dir2_sf_put_parent_ino(put_unaligned_be32 (ino, hdr->parent); } +/* +* The file type field is stored at the end of the name for filetype enabled +* shortform directories, or not at all otherwise. +*/ +uint8_t +xfs_dir2_sf_get_ftype ( +struct xfs_mount *mp, +struct xfs_dir2_sf_entry *sfep) +{ +if (xfs_sb_version_hasftype (&mp->m_sb)) { +uint8_t ftype = sfep->name[sfep->namelen]; + +if (ftype <XFS_DIR3_FT_MAX ) +return ftype; + } + +return XFS_DIR3_FT_UNKNOWN ; +} + +static void +xfs_dir2_sf_put_ftype ( +struct xfs_mount *mp, +struct xfs_dir2_sf_entry *sfep, +uint8_t ftype) +{ +ASSERT (ftype <XFS_DIR3_FT_MAX ); + +if (xfs_sb_version_hasftype (&mp->m_sb)) + sfep->name[sfep->namelen] = ftype; +} +/* * Given a block directory (dp/block), calculate its size as a shortform (sf) * directory and a header for the sf directory, if it will fit it the @@ -305,7 +336,7 @@ xfs_dir2_block_to_sf(memcpy (sfep->name, dep->name, dep->namelen);xfs_dir2_sf_put_ino (mp, sfp, sfep,be64_to_cpu (dep->inumber)); - dp->d_ops->sf_put_ftype (sfep, +xfs_dir2_sf_put_ftype (mp, sfep, dp->d_ops->data_get_ftype (dep)); sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep);@@ -477,7 +508,7 @@ xfs_dir2_sf_addname_easy(xfs_dir2_sf_put_offset (sfep, offset);memcpy (sfep->name, args->name, sfep->namelen);xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber); - dp->d_ops->sf_put_ftype (sfep, args->filetype); +xfs_dir2_sf_put_ftype (mp, sfep, args->filetype);/* * Update the header and inode. @@ -567,7 +598,7 @@ xfs_dir2_sf_addname_hard(xfs_dir2_sf_put_offset (sfep, offset);memcpy (sfep->name, args->name, sfep->namelen);xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber); - dp->d_ops->sf_put_ftype (sfep, args->filetype); +xfs_dir2_sf_put_ftype (mp, sfep, args->filetype); sfp->count++;if (args->inumber >XFS_DIR2_MAX_SHORT_INUM && !objchange) sfp->i8count++;@@ -664,7 +695,8 @@ static voidxfs_dir2_sf_check ( xfs_da_args_t *args) /* operation arguments */ { -xfs_inode_t *dp;/* incore directory inode */ +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;int i;/* entry number */ int i8count;/* number of big inode#s */ xfs_ino_t ino;/* entry inode number */ @@ -672,8 +704,6 @@ xfs_dir2_sf_check(xfs_dir2_sf_entry_t *sfep;/* shortform dir entry */ xfs_dir2_sf_hdr_t *sfp;/* shortform structure */ - dp = args->dp; - sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; offset = dp->d_ops->data_first_offset; ino =xfs_dir2_sf_get_parent_ino (sfp);@@ -681,14 +711,14 @@ xfs_dir2_sf_check(for (i =0 , sfep =xfs_dir2_sf_firstentry (sfp); i < sfp->count; - i++, sfep =xfs_dir2_sf_nextentry (dp->i_mount, sfp, sfep)) { + i++, sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep)) {ASSERT (xfs_dir2_sf_get_offset (sfep) >= offset); - ino =xfs_dir2_sf_get_ino (dp->i_mount, sfp, sfep); + ino =xfs_dir2_sf_get_ino (mp, sfp, sfep); i8count += ino >XFS_DIR2_MAX_SHORT_INUM ; offset =xfs_dir2_sf_get_offset (sfep) + dp->d_ops->data_entsize (sfep->namelen); -ASSERT (dp->d_ops->sf_get_ftype (sfep) <XFS_DIR3_FT_MAX ); +ASSERT (xfs_dir2_sf_get_ftype (mp, sfep) <XFS_DIR3_FT_MAX ); }ASSERT (i8count == sfp->i8count);ASSERT ((char *)sfep - (char *)sfp == dp->i_d.di_size);@@ -782,7 +812,7 @@ xfs_dir2_sf_verify(return __this_address;/* Check the file type. */ - filetype = dops->sf_get_ftype (sfep); + filetype =xfs_dir2_sf_get_ftype (mp, sfep);if (filetype >=XFS_DIR3_FT_MAX )return __this_address;@@ -925,7 +955,7 @@ xfs_dir2_sf_lookup(if (cmp !=XFS_CMP_DIFFERENT && cmp != args->cmpresult) { args->cmpresult = cmp; args->inumber =xfs_dir2_sf_get_ino (mp, sfp, sfep); - args->filetype = dp->d_ops->sf_get_ftype (sfep); + args->filetype =xfs_dir2_sf_get_ftype (mp, sfep);if (cmp ==XFS_CMP_EXACT )return -EEXIST ; ci_sfep = sfep;@@ -1108,7 +1138,7 @@ xfs_dir2_sf_replace(ASSERT (args->inumber != ino);xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber); - dp->d_ops->sf_put_ftype (sfep, args->filetype); +xfs_dir2_sf_put_ftype (mp, sfep, args->filetype);break ; } }@@ -1214,7 +1244,8 @@ xfs_dir2_sf_toino4(memcpy (sfep->name, oldsfep->name, sfep->namelen);xfs_dir2_sf_put_ino (mp, sfp, sfep,xfs_dir2_sf_get_ino (mp, oldsfp, oldsfep)); - dp->d_ops->sf_put_ftype (sfep, dp->d_ops->sf_get_ftype (oldsfep)); +xfs_dir2_sf_put_ftype (mp, sfep, +xfs_dir2_sf_get_ftype (mp, oldsfep)); }/* * Clean up the inode. @@ -1286,7 +1317,8 @@ xfs_dir2_sf_toino8(memcpy (sfep->name, oldsfep->name, sfep->namelen);xfs_dir2_sf_put_ino (mp, sfp, sfep,xfs_dir2_sf_get_ino (mp, oldsfp, oldsfep)); - dp->d_ops->sf_put_ftype (sfep, dp->d_ops->sf_get_ftype (oldsfep)); +xfs_dir2_sf_put_ftype (mp, sfep, +xfs_dir2_sf_get_ftype (mp, oldsfep)); }/* * Clean up the inode. fs/xfs/xfs_dir2_readdir.c +1
-1@@ -115,7 +115,7 @@ xfs_dir2_sf_getdents( } ino =xfs_dir2_sf_get_ino (mp, sfp, sfep); - filetype = dp->d_ops->sf_get_ftype (sfep); + filetype =xfs_dir2_sf_get_ftype (mp, sfep); ctx->pos = off &0x7fffffff ;if (!xfs_dir2_namecheck (sfep->name, sfep->namelen)) { XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW,Signature · 1 line
2.20.1
PATCH 23/34 xfs: remove the ->data_dot_entry_p and ->data_dotdot_entry_p methods
In reply to Christoph HellwigReplace the only user of the ->data_dot_entry_p and ->data_dotdot_entry_p dir ops methods with direct calculations using ->data_dot_offset and ->data_dotdot_offset.
--- fs/xfs/libxfs/xfs_da_format.c | 52 ---------------------------------- fs/xfs/libxfs/xfs_dir2.h | 4 --- fs/xfs/libxfs/xfs_dir2_block.c | 4 +-- 3 files changed, 2 insertions(+), 58 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -52
@@ -111,26 +111,6 @@ xfs_dir3_data_entry_tag_p( xfs_dir3_data_entsize(dep->namelen) - sizeof(__be16)); } -/* -* location of . and .. in data space (always block 0) -*/ -static struct xfs_dir2_data_entry * -xfs_dir2_data_dot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr )); -} - -static struct xfs_dir2_data_entry * -xfs_dir2_data_dotdot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR2_DATA_ENTSIZE (1 )); -} -static struct xfs_dir2_data_entry *xfs_dir2_data_first_entry_p (struct xfs_dir2_data_hdr *hdr)
@@ -141,15 +121,6 @@ xfs_dir2_data_first_entry_p( XFS_DIR2_DATA_ENTSIZE(2)); } -static struct xfs_dir2_data_entry * -xfs_dir2_ftype_data_dotdot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 )); -} -static struct xfs_dir2_data_entry *xfs_dir2_ftype_data_first_entry_p (struct xfs_dir2_data_hdr *hdr)
@@ -160,23 +131,6 @@ xfs_dir2_ftype_data_first_entry_p( XFS_DIR3_DATA_ENTSIZE(2)); } -static struct xfs_dir2_data_entry * -xfs_dir3_data_dot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); -} - -static struct xfs_dir2_data_entry * -xfs_dir3_data_dotdot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 )); -} -static struct xfs_dir2_data_entry *xfs_dir3_data_first_entry_p (struct xfs_dir2_data_hdr *hdr)
@@ -242,8 +196,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { XFS_DIR2_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - .data_dot_entry_p = xfs_dir2_data_dot_entry_p, - .data_dotdot_entry_p = xfs_dir2_data_dotdot_entry_p, .data_first_entry_p = xfs_dir2_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p,
@@ -264,8 +216,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - .data_dot_entry_p = xfs_dir2_data_dot_entry_p, - .data_dotdot_entry_p = xfs_dir2_ftype_data_dotdot_entry_p, .data_first_entry_p = xfs_dir2_ftype_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p,
@@ -286,8 +236,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir3_data_hdr), - .data_dot_entry_p = xfs_dir3_data_dot_entry_p, - .data_dotdot_entry_p = xfs_dir3_data_dotdot_entry_p, .data_first_entry_p = xfs_dir3_data_first_entry_p, .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p,
fs/xfs/libxfs/xfs_dir2.h +0 -4
@@ -45,10 +45,6 @@ struct xfs_dir_ops {xfs_dir2_data_aoff_t data_first_offset;size_t data_entry_offset; -struct xfs_dir2_data_entry * - (*data_dot_entry_p)(struct xfs_dir2_data_hdr *hdr); -struct xfs_dir2_data_entry * - (*data_dotdot_entry_p)(struct xfs_dir2_data_hdr *hdr);struct xfs_dir2_data_entry * (*data_first_entry_p)(struct xfs_dir2_data_hdr *hdr); struct xfs_dir2_data_entry *
fs/xfs/libxfs/xfs_dir2_block.c +2 -2
@@ -1148,7 +1148,7 @@ xfs_dir2_sf_to_block(/* * Create entry for . */ - dep = dp->d_ops->data_dot_entry_p (hdr); + dep = (void *)hdr + dp->d_ops->data_dot_offset; dep->inumber =cpu_to_be64 (dp->i_ino); dep->namelen =1 ; dep->name[0 ] ='.' ;
@@ -1162,7 +1162,7 @@ xfs_dir2_sf_to_block(/* * Create entry for .. */ - dep = dp->d_ops->data_dotdot_entry_p (hdr); + dep = (void *)hdr + dp->d_ops->data_dotdot_offset; dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_parent_ino (sfp)); dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ;
Signature · 1 line
2.20.1
Re: [PATCH 23/34] xfs: remove the ->data_dot_entry_p and ->data_dotdot_entry_p methods
Quoted 129 lines · Christoph Hellwig
Replace the only user of the ->data_dot_entry_p and ->data_dotdot_entry_p dir ops methods with direct calculations using ->data_dot_offset and ->data_dotdot_offset.
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_da_format.c | 52 ---------------------------------- fs/xfs/libxfs/xfs_dir2.h | 4 --- fs/xfs/libxfs/xfs_dir2_block.c | 4 +-- 3 files changed, 2 insertions(+), 58 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-52@@ -111,26 +111,6 @@ xfs_dir3_data_entry_tag_p( xfs_dir3_data_entsize(dep->namelen) - sizeof(__be16)); } -/* -* location of . and .. in data space (always block 0) -*/ -static struct xfs_dir2_data_entry * -xfs_dir2_data_dot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr )); -} - -static struct xfs_dir2_data_entry * -xfs_dir2_data_dotdot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR2_DATA_ENTSIZE (1 )); -} -static struct xfs_dir2_data_entry *xfs_dir2_data_first_entry_p (struct xfs_dir2_data_hdr *hdr)@@ -141,15 +121,6 @@ xfs_dir2_data_first_entry_p( XFS_DIR2_DATA_ENTSIZE(2)); } -static struct xfs_dir2_data_entry * -xfs_dir2_ftype_data_dotdot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 )); -} -static struct xfs_dir2_data_entry *xfs_dir2_ftype_data_first_entry_p (struct xfs_dir2_data_hdr *hdr)@@ -160,23 +131,6 @@ xfs_dir2_ftype_data_first_entry_p( XFS_DIR3_DATA_ENTSIZE(2)); } -static struct xfs_dir2_data_entry * -xfs_dir3_data_dot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); -} - -static struct xfs_dir2_data_entry * -xfs_dir3_data_dotdot_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 )); -} -static struct xfs_dir2_data_entry *xfs_dir3_data_first_entry_p (struct xfs_dir2_data_hdr *hdr)@@ -242,8 +196,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { XFS_DIR2_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - .data_dot_entry_p = xfs_dir2_data_dot_entry_p, - .data_dotdot_entry_p = xfs_dir2_data_dotdot_entry_p, .data_first_entry_p = xfs_dir2_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p,@@ -264,8 +216,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - .data_dot_entry_p = xfs_dir2_data_dot_entry_p, - .data_dotdot_entry_p = xfs_dir2_ftype_data_dotdot_entry_p, .data_first_entry_p = xfs_dir2_ftype_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p,@@ -286,8 +236,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir3_data_hdr), - .data_dot_entry_p = xfs_dir3_data_dot_entry_p, - .data_dotdot_entry_p = xfs_dir3_data_dotdot_entry_p, .data_first_entry_p = xfs_dir3_data_first_entry_p, .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p,fs/xfs/libxfs/xfs_dir2.h +0
-4@@ -45,10 +45,6 @@ struct xfs_dir_ops {xfs_dir2_data_aoff_t data_first_offset;size_t data_entry_offset; -struct xfs_dir2_data_entry * - (*data_dot_entry_p)(struct xfs_dir2_data_hdr *hdr); -struct xfs_dir2_data_entry * - (*data_dotdot_entry_p)(struct xfs_dir2_data_hdr *hdr);struct xfs_dir2_data_entry * (*data_first_entry_p)(struct xfs_dir2_data_hdr *hdr); struct xfs_dir2_data_entry *fs/xfs/libxfs/xfs_dir2_block.c +0
-0
fs/xfs/libxfs/xfs_dir2_block.c xfs_dir2_sf_to_block( · line 1151
Quoted 5 lines
fs/xfs/libxfs/xfs_dir2_block.c +1
-1@@ -1148,7 +1148,7 @@ xfs_dir2_sf_to_block(/* * Create entry for . */ - dep = dp->d_ops->data_dot_entry_p (hdr); + dep = (void *)hdr + dp->d_ops->data_dot_offset;
Same complaint about (void *) arithmetic as last time.
Also, why not leave a static inline helper function or two to encapsulate the pointer arithmetic and ensure type checking?
--D
Quoted 15 lines
fs/xfs/libxfs/xfs_dir2_block.c +1
-1dep->inumber =cpu_to_be64 (dp->i_ino); dep->namelen =1 ; dep->name[0 ] ='.' ;@@ -1162,7 +1162,7 @@ xfs_dir2_sf_to_block(/* * Create entry for .. */ - dep = dp->d_ops->data_dotdot_entry_p (hdr); + dep = (void *)hdr + dp->d_ops->data_dotdot_offset; dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_parent_ino (sfp)); dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ;Signature · 1 line
2.20.1
PATCH 24/34 xfs: remove the unused ->data_first_entry_p method
In reply to Christoph Hellwig--- fs/xfs/libxfs/xfs_da_format.c | 33 --------------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- 2 files changed, 35 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -33
@@ -111,36 +111,6 @@ xfs_dir3_data_entry_tag_p( xfs_dir3_data_entsize(dep->namelen) - sizeof(__be16)); } -static struct xfs_dir2_data_entry * -xfs_dir2_data_first_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR2_DATA_ENTSIZE (1 ) + -XFS_DIR2_DATA_ENTSIZE (2 )); -} - -static struct xfs_dir2_data_entry * -xfs_dir2_ftype_data_first_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ) + -XFS_DIR3_DATA_ENTSIZE (2 )); -} - -static struct xfs_dir2_data_entry * -xfs_dir3_data_first_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ) + -XFS_DIR3_DATA_ENTSIZE (2 )); -} -static struct xfs_dir2_data_free *xfs_dir2_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) {
@@ -196,7 +166,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { XFS_DIR2_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - .data_first_entry_p = xfs_dir2_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, };
@@ -216,7 +185,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - .data_first_entry_p = xfs_dir2_ftype_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, };
@@ -236,7 +204,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir3_data_hdr), - .data_first_entry_p = xfs_dir3_data_first_entry_p, .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, };
fs/xfs/libxfs/xfs_dir2.h +0 -2
@@ -45,8 +45,6 @@ struct xfs_dir_ops {xfs_dir2_data_aoff_t data_first_offset;size_t data_entry_offset; -struct xfs_dir2_data_entry * - (*data_first_entry_p)(struct xfs_dir2_data_hdr *hdr);struct xfs_dir2_data_entry * (*data_entry_p)(struct xfs_dir2_data_hdr *hdr); struct xfs_dir2_data_unused *
Signature · 1 line
2.20.1
Re: [PATCH 24/34] xfs: remove the unused ->data_first_entry_p method
Quoted 1 line · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
LOL.
--D
Quoted 86 lines
--- fs/xfs/libxfs/xfs_da_format.c | 33 --------------------------------- fs/xfs/libxfs/xfs_dir2.h | 2 -- 2 files changed, 35 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-33@@ -111,36 +111,6 @@ xfs_dir3_data_entry_tag_p( xfs_dir3_data_entsize(dep->namelen) - sizeof(__be16)); } -static struct xfs_dir2_data_entry * -xfs_dir2_data_first_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR2_DATA_ENTSIZE (1 ) + -XFS_DIR2_DATA_ENTSIZE (2 )); -} - -static struct xfs_dir2_data_entry * -xfs_dir2_ftype_data_first_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ) + -XFS_DIR3_DATA_ENTSIZE (2 )); -} - -static struct xfs_dir2_data_entry * -xfs_dir3_data_first_entry_p ( -struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ) + -XFS_DIR3_DATA_ENTSIZE (2 )); -} -static struct xfs_dir2_data_free *xfs_dir2_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) {@@ -196,7 +166,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { XFS_DIR2_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - .data_first_entry_p = xfs_dir2_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, };@@ -216,7 +185,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - .data_first_entry_p = xfs_dir2_ftype_data_first_entry_p, .data_entry_p = xfs_dir2_data_entry_p, .data_unused_p = xfs_dir2_data_unused_p, };@@ -236,7 +204,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir3_data_hdr), - .data_first_entry_p = xfs_dir3_data_first_entry_p, .data_entry_p = xfs_dir3_data_entry_p, .data_unused_p = xfs_dir3_data_unused_p, };fs/xfs/libxfs/xfs_dir2.h +0
-2@@ -45,8 +45,6 @@ struct xfs_dir_ops {xfs_dir2_data_aoff_t data_first_offset;size_t data_entry_offset; -struct xfs_dir2_data_entry * - (*data_first_entry_p)(struct xfs_dir2_data_hdr *hdr);struct xfs_dir2_data_entry * (*data_entry_p)(struct xfs_dir2_data_hdr *hdr); struct xfs_dir2_data_unused *Signature · 1 line
2.20.1
PATCH 25/34 xfs: remove the ->data_entry_entry_p method
In reply to Christoph HellwigReplace the users of the ->data_entry_entry_p dir ops method with a direct calculation using ->data_entry_offset.
--- fs/xfs/libxfs/xfs_da_format.c | 37 ---------------------------------- fs/xfs/libxfs/xfs_dir2.h | 5 ----- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_data.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_sf.c | 2 +- fs/xfs/scrub/dir.c | 4 ++-- fs/xfs/xfs_dir2_readdir.c | 4 ++-- 7 files changed, 9 insertions(+), 51 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -37
@@ -123,34 +123,6 @@ xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)return ((struct xfs_dir3_data_hdr *)hdr)->best_free; } -static struct xfs_dir2_data_entry * -xfs_dir2_data_entry_p (struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr )); -} - -static struct xfs_dir2_data_unused * -xfs_dir2_data_unused_p (struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_unused *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr )); -} - -static struct xfs_dir2_data_entry * -xfs_dir3_data_entry_p (struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); -} - -static struct xfs_dir2_data_unused * -xfs_dir3_data_unused_p (struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_unused *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); -} -static const struct xfs_dir_ops xfs_dir2_ops = { .data_entsize = xfs_dir2_data_entsize, .data_get_ftype = xfs_dir2_data_get_ftype,
@@ -165,9 +137,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {XFS_DIR2_DATA_ENTSIZE (1 ) + XFS_DIR2_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - - .data_entry_p = xfs_dir2_data_entry_p, - .data_unused_p = xfs_dir2_data_unused_p, };static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
@@ -184,9 +153,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {XFS_DIR3_DATA_ENTSIZE (1 ) + XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - - .data_entry_p = xfs_dir2_data_entry_p, - .data_unused_p = xfs_dir2_data_unused_p, };static const struct xfs_dir_ops xfs_dir3_ops = {
@@ -203,9 +169,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { XFS_DIR3_DATA_ENTSIZE(1) + XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir3_data_hdr), - - .data_entry_p = xfs_dir3_data_entry_p, - .data_unused_p = xfs_dir3_data_unused_p, };/*
fs/xfs/libxfs/xfs_dir2.h +0 -5
@@ -44,11 +44,6 @@ struct xfs_dir_ops {xfs_dir2_data_aoff_t data_dotdot_offset;xfs_dir2_data_aoff_t data_first_offset;size_t data_entry_offset; - -struct xfs_dir2_data_entry * - (*data_entry_p)(struct xfs_dir2_data_hdr *hdr); -struct xfs_dir2_data_unused * - (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); }; extern const struct xfs_dir_ops *
fs/xfs/libxfs/xfs_dir2_block.c +1 -1
@@ -1122,7 +1122,7 @@ xfs_dir2_sf_to_block(* The whole thing is initialized to free by the init routine. * Say we're using the leaf and tail area. */ - dup = dp->d_ops->data_unused_p (hdr); + dup = (void *)hdr + dp->d_ops->data_entry_offset; needlog = needscan =0 ; error =xfs_dir2_data_use_free (args, bp, dup, args->geo->blksize - i, i, &needlog, &needscan);
fs/xfs/libxfs/xfs_dir2_data.c +3 -3
@@ -71,7 +71,7 @@ __xfs_dir3_data_check(return __this_address; hdr = bp->b_addr; - p = (char *)ops->data_entry_p (hdr); + p = (char *)hdr + ops->data_entry_offset;switch (hdr->magic) {case cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC ):
@@ -587,7 +587,7 @@ xfs_dir2_data_freescan_int(/* * Set up pointers. */ - p = (char *)ops->data_entry_p (hdr); + p = (char *)hdr + ops->data_entry_offset; endp =xfs_dir3_data_endp (geo, hdr);/* * Loop over the block's entries.
@@ -685,7 +685,7 @@ xfs_dir3_data_init(/* * Set up an unused entry for the block's body. */ - dup = dp->d_ops->data_unused_p (hdr); + dup = (void *)hdr + dp->d_ops->data_entry_offset; dup->freetag =cpu_to_be16 (XFS_DIR2_DATA_FREE_TAG ); t = args->geo->blksize - (uint )dp->d_ops->data_entry_offset;
fs/xfs/libxfs/xfs_dir2_sf.c +1 -1
@@ -296,7 +296,7 @@ xfs_dir2_block_to_sf(/* * Set up to loop over the block's entries. */ - ptr = (char *)dp->d_ops->data_entry_p (hdr); + ptr = (char *)hdr + dp->d_ops->data_entry_offset; endptr =xfs_dir3_data_endp (args->geo, hdr); sfep =xfs_dir2_sf_firstentry (sfp);/*
fs/xfs/scrub/dir.c +2 -2
@@ -241,7 +241,7 @@ xchk_dir_rec( dent = (struct xfs_dir2_data_entry *)(((char *)bp->b_addr) + off);/* Make sure we got a real directory entry. */ - p = (char *)mp->m_dir_inode_ops->data_entry_p (bp->b_addr); + p = bp->b_addr + mp->m_dir_inode_ops->data_entry_offset; endp =xfs_dir3_data_endp (mp->m_dir_geo, bp->b_addr);if (!endp) {xchk_fblock_set_corrupt (ds->sc,XFS_DATA_FORK , rec_bno);
@@ -391,7 +391,7 @@ xchk_directory_data_bestfree( }/* Make sure the bestfrees are actually the best free spaces. */ - ptr = (char *)d_ops->data_entry_p (bp->b_addr); + ptr = bp->b_addr + d_ops->data_entry_offset; endptr =xfs_dir3_data_endp (mp->m_dir_geo, bp->b_addr);/* Iterate the entries, stopping when we hit or go past the end. */
fs/xfs/xfs_dir2_readdir.c +2 -2
@@ -176,7 +176,7 @@ xfs_dir2_block_getdents(/* * Set up values for the loop. */ - ptr = (char *)dp->d_ops->data_entry_p (hdr); + ptr = (char *)hdr + dp->d_ops->data_entry_offset; endptr =xfs_dir3_data_endp (geo, hdr);/*
@@ -410,7 +410,7 @@ xfs_dir2_leaf_getdents(/* * Find our position in the block. */ - ptr = (char *)dp->d_ops->data_entry_p (hdr); + ptr = (char *)hdr + dp->d_ops->data_entry_offset; byteoff =xfs_dir2_byte_to_off (geo, curoff);/* * Skip past the header.
Signature · 1 line
2.20.1
Re: [PATCH 25/34] xfs: remove the ->data_entry_entry_p method
Quoted 192 lines · Christoph Hellwig
Replace the users of the ->data_entry_entry_p dir ops method with a direct calculation using ->data_entry_offset.
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_da_format.c | 37 ---------------------------------- fs/xfs/libxfs/xfs_dir2.h | 5 ----- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_data.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_sf.c | 2 +- fs/xfs/scrub/dir.c | 4 ++-- fs/xfs/xfs_dir2_readdir.c | 4 ++-- 7 files changed, 9 insertions(+), 51 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-37@@ -123,34 +123,6 @@ xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)return ((struct xfs_dir3_data_hdr *)hdr)->best_free; } -static struct xfs_dir2_data_entry * -xfs_dir2_data_entry_p (struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr )); -} - -static struct xfs_dir2_data_unused * -xfs_dir2_data_unused_p (struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_unused *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr )); -} - -static struct xfs_dir2_data_entry * -xfs_dir3_data_entry_p (struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_entry *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); -} - -static struct xfs_dir2_data_unused * -xfs_dir3_data_unused_p (struct xfs_dir2_data_hdr *hdr) -{ -return (struct xfs_dir2_data_unused *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); -} -static const struct xfs_dir_ops xfs_dir2_ops = { .data_entsize = xfs_dir2_data_entsize, .data_get_ftype = xfs_dir2_data_get_ftype,@@ -165,9 +137,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {XFS_DIR2_DATA_ENTSIZE (1 ) + XFS_DIR2_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - - .data_entry_p = xfs_dir2_data_entry_p, - .data_unused_p = xfs_dir2_data_unused_p, };static const struct xfs_dir_ops xfs_dir2_ftype_ops = {@@ -184,9 +153,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {XFS_DIR3_DATA_ENTSIZE (1 ) + XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), - - .data_entry_p = xfs_dir2_data_entry_p, - .data_unused_p = xfs_dir2_data_unused_p, };static const struct xfs_dir_ops xfs_dir3_ops = {@@ -203,9 +169,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { XFS_DIR3_DATA_ENTSIZE(1) + XFS_DIR3_DATA_ENTSIZE(2), .data_entry_offset = sizeof(struct xfs_dir3_data_hdr), - - .data_entry_p = xfs_dir3_data_entry_p, - .data_unused_p = xfs_dir3_data_unused_p, };/* fs/xfs/libxfs/xfs_dir2.h +0
-5@@ -44,11 +44,6 @@ struct xfs_dir_ops {xfs_dir2_data_aoff_t data_dotdot_offset;xfs_dir2_data_aoff_t data_first_offset;size_t data_entry_offset; - -struct xfs_dir2_data_entry * - (*data_entry_p)(struct xfs_dir2_data_hdr *hdr); -struct xfs_dir2_data_unused * - (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); }; extern const struct xfs_dir_ops *fs/xfs/libxfs/xfs_dir2_block.c +1
-1@@ -1122,7 +1122,7 @@ xfs_dir2_sf_to_block(* The whole thing is initialized to free by the init routine. * Say we're using the leaf and tail area. */ - dup = dp->d_ops->data_unused_p (hdr); + dup = (void *)hdr + dp->d_ops->data_entry_offset; needlog = needscan =0 ; error =xfs_dir2_data_use_free (args, bp, dup, args->geo->blksize - i, i, &needlog, &needscan);fs/xfs/libxfs/xfs_dir2_data.c +3
-3@@ -71,7 +71,7 @@ __xfs_dir3_data_check(return __this_address; hdr = bp->b_addr; - p = (char *)ops->data_entry_p (hdr); + p = (char *)hdr + ops->data_entry_offset;switch (hdr->magic) {case cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC ):@@ -587,7 +587,7 @@ xfs_dir2_data_freescan_int(/* * Set up pointers. */ - p = (char *)ops->data_entry_p (hdr); + p = (char *)hdr + ops->data_entry_offset; endp =xfs_dir3_data_endp (geo, hdr);/* * Loop over the block's entries. @@ -685,7 +685,7 @@ xfs_dir3_data_init(/* * Set up an unused entry for the block's body. */ - dup = dp->d_ops->data_unused_p (hdr); + dup = (void *)hdr + dp->d_ops->data_entry_offset; dup->freetag =cpu_to_be16 (XFS_DIR2_DATA_FREE_TAG ); t = args->geo->blksize - (uint )dp->d_ops->data_entry_offset;fs/xfs/libxfs/xfs_dir2_sf.c +1
-1@@ -296,7 +296,7 @@ xfs_dir2_block_to_sf(/* * Set up to loop over the block's entries. */ - ptr = (char *)dp->d_ops->data_entry_p (hdr); + ptr = (char *)hdr + dp->d_ops->data_entry_offset; endptr =xfs_dir3_data_endp (args->geo, hdr); sfep =xfs_dir2_sf_firstentry (sfp);/* fs/xfs/scrub/dir.c +2
-2@@ -241,7 +241,7 @@ xchk_dir_rec( dent = (struct xfs_dir2_data_entry *)(((char *)bp->b_addr) + off);/* Make sure we got a real directory entry. */ - p = (char *)mp->m_dir_inode_ops->data_entry_p (bp->b_addr); + p = bp->b_addr + mp->m_dir_inode_ops->data_entry_offset; endp =xfs_dir3_data_endp (mp->m_dir_geo, bp->b_addr);if (!endp) {xchk_fblock_set_corrupt (ds->sc,XFS_DATA_FORK , rec_bno);@@ -391,7 +391,7 @@ xchk_directory_data_bestfree( }/* Make sure the bestfrees are actually the best free spaces. */ - ptr = (char *)d_ops->data_entry_p (bp->b_addr); + ptr = bp->b_addr + d_ops->data_entry_offset; endptr =xfs_dir3_data_endp (mp->m_dir_geo, bp->b_addr);/* Iterate the entries, stopping when we hit or go past the end. */ fs/xfs/xfs_dir2_readdir.c +1
-1@@ -176,7 +176,7 @@ xfs_dir2_block_getdents(/* * Set up values for the loop. */ - ptr = (char *)dp->d_ops->data_entry_p (hdr); + ptr = (char *)hdr + dp->d_ops->data_entry_offset; endptr =xfs_dir3_data_endp (geo, hdr);/*
fs/xfs/xfs_dir2_readdir.c xfs_dir2_leaf_getdents( · line 413
Quoted 5 lines
fs/xfs/xfs_dir2_readdir.c +1
-1@@ -410,7 +410,7 @@ xfs_dir2_leaf_getdents(/* * Find our position in the block. */ - ptr = (char *)dp->d_ops->data_entry_p (hdr); + ptr = (char *)hdr + dp->d_ops->data_entry_offset;
/me thinks we're open-coding this calculation enough to warrant a static inline helper...
--D
Quoted 6 lines
fs/xfs/xfs_dir2_readdir.c +0
-0byteoff =xfs_dir2_byte_to_off (geo, curoff);/* * Skip past the header. Signature · 1 line
2.20.1
PATCH 26/34 xfs: devirtualize ->data_entsize
In reply to Christoph HellwigReplace the ->data_entsize dir ops method with a directly called xfs_dir2_data_entsize helper that takes care of the differences between the directory format with and without the file type field.
--- fs/xfs/libxfs/xfs_da_format.c | 22 ++++++++-------------- fs/xfs/libxfs/xfs_dir2.h | 3 +-- fs/xfs/libxfs/xfs_dir2_block.c | 5 +++-- fs/xfs/libxfs/xfs_dir2_data.c | 13 ++++++------- fs/xfs/libxfs/xfs_dir2_leaf.c | 5 +++-- fs/xfs/libxfs/xfs_dir2_node.c | 7 ++++--- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/libxfs/xfs_dir2_sf.c | 14 +++++++------- fs/xfs/scrub/dir.c | 4 ++-- fs/xfs/xfs_dir2_readdir.c | 9 +++++---- 10 files changed, 41 insertions(+), 43 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +8 -14
@@ -41,18 +41,15 @@ sizeof(xfs_dir2_data_off_t) + sizeof(uint8_t)), \ XFS_DIR2_DATA_ALIGN) -static int +int xfs_dir2_data_entsize ( +struct xfs_mount *mp,int n) { -return XFS_DIR2_DATA_ENTSIZE (n); -} - -static int -xfs_dir3_data_entsize ( -int n) -{ -return XFS_DIR3_DATA_ENTSIZE (n); +if (xfs_sb_version_hasftype (&mp->m_sb)) +return XFS_DIR3_DATA_ENTSIZE (n); +else +return XFS_DIR2_DATA_ENTSIZE (n); } static uint8_t
@@ -100,7 +97,7 @@ xfs_dir2_data_entry_tag_p( struct xfs_dir2_data_entry *dep) {return (__be16 *)((char *)dep + -xfs_dir2_data_entsize (dep->namelen) -sizeof (__be16)); +XFS_DIR2_DATA_ENTSIZE (dep->namelen) -sizeof (__be16)); } static __be16 *
@@ -108,7 +105,7 @@ xfs_dir3_data_entry_tag_p( struct xfs_dir2_data_entry *dep) {return (__be16 *)((char *)dep + -xfs_dir3_data_entsize (dep->namelen) -sizeof (__be16)); +XFS_DIR3_DATA_ENTSIZE (dep->namelen) -sizeof (__be16)); } static struct xfs_dir2_data_free *
@@ -124,7 +121,6 @@ xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr) }static const struct xfs_dir_ops xfs_dir2_ops = { - .data_entsize = xfs_dir2_data_entsize, .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype, .data_entry_tag_p = xfs_dir2_data_entry_tag_p,
@@ -140,7 +136,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { - .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, .data_entry_tag_p = xfs_dir3_data_entry_tag_p,
@@ -156,7 +151,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { };static const struct xfs_dir_ops xfs_dir3_ops = { - .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, .data_entry_tag_p = xfs_dir3_data_entry_tag_p,
fs/xfs/libxfs/xfs_dir2.h +1 -2
@@ -32,7 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);* directory operations vector for encode/decode routines */ struct xfs_dir_ops { -int (*data_entsize)(int len);uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,uint8_t ftype);
@@ -87,7 +86,7 @@ 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_int (struct xfs_da_geometry *geo, +extern void xfs_dir2_data_freescan_int (struct xfs_mount *mp,const struct xfs_dir_ops *ops,struct xfs_dir2_data_hdr *hdr,int *loghead); extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
fs/xfs/libxfs/xfs_dir2_block.c +3 -2
@@ -355,7 +355,7 @@ xfs_dir2_block_addname(if (error)return error; - len = dp->d_ops->data_entsize (args->namelen); + len =xfs_dir2_data_entsize (dp->i_mount, args->namelen);/* * Set up pointers to parts of the block.
@@ -791,7 +791,8 @@ xfs_dir2_block_removename( needlog = needscan =0 ;xfs_dir2_data_make_free (args, bp, (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), - dp->d_ops->data_entsize (dep->namelen), &needlog, &needscan); +xfs_dir2_data_entsize (dp->i_mount, dep->namelen), &needlog, + &needscan);/* * Fix up the block tail. */
fs/xfs/libxfs/xfs_dir2_data.c +6 -7
@@ -173,7 +173,7 @@ __xfs_dir3_data_check(return __this_address;if (xfs_dir_ino_validate (mp,be64_to_cpu (dep->inumber)))return __this_address; -if (endp < p + ops->data_entsize (dep->namelen)) +if (endp < p +xfs_dir2_data_entsize (mp, dep->namelen))return __this_address;if (be16_to_cpu (*ops->data_entry_tag_p (dep)) != (char *)dep - (char *)hdr)
@@ -198,7 +198,7 @@ __xfs_dir3_data_check(if (i >=be32_to_cpu (btp->count))return __this_address; } - p += ops->data_entsize (dep->namelen); + p +=xfs_dir2_data_entsize (mp, dep->namelen); }/* * Need to have seen all the entries and all the bestfree slots.
@@ -562,7 +562,7 @@ xfs_dir2_data_freeremove(*/ void xfs_dir2_data_freescan_int ( -struct xfs_da_geometry *geo, +struct xfs_mount *mp,const struct xfs_dir_ops *ops,struct xfs_dir2_data_hdr *hdr,int *loghead)
@@ -588,7 +588,7 @@ xfs_dir2_data_freescan_int(* Set up pointers. */ p = (char *)hdr + ops->data_entry_offset; - endp =xfs_dir3_data_endp (geo, hdr); + endp =xfs_dir3_data_endp (mp->m_dir_geo, hdr);/* * Loop over the block's entries. */
@@ -610,7 +610,7 @@ xfs_dir2_data_freescan_int( dep = (xfs_dir2_data_entry_t *)p;ASSERT ((char *)dep - (char *)hdr ==be16_to_cpu (*ops->data_entry_tag_p (dep))); - p += ops->data_entsize (dep->namelen); + p +=xfs_dir2_data_entsize (mp, dep->namelen); } } }
@@ -621,8 +621,7 @@ xfs_dir2_data_freescan(struct xfs_dir2_data_hdr *hdr, int *loghead) { - return xfs_dir2_data_freescan_int(dp->i_mount->m_dir_geo, dp->d_ops, -hdr ,loghead ); + return xfs_dir2_data_freescan_int(dp->i_mount, dp->d_ops, hdr, loghead); }/*
fs/xfs/libxfs/xfs_dir2_leaf.c +3 -2
@@ -660,7 +660,7 @@ xfs_dir2_leaf_addname(xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = leafhdr.ents; bestsp =xfs_dir2_leaf_bests_p (ltp); - length = dp->d_ops->data_entsize (args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->namelen);/* * See if there are any entries with the same hash value
@@ -1395,7 +1395,8 @@ xfs_dir2_leaf_removename(*/ xfs_dir2_data_make_free (args, dbp, (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), - dp->d_ops->data_entsize (dep->namelen), &needlog, &needscan); +xfs_dir2_data_entsize (dp->i_mount, dep->namelen), &needlog, + &needscan);/* * We just mark the leaf entry stale by putting a null in it. */
fs/xfs/libxfs/xfs_dir2_node.c +4 -3
@@ -662,7 +662,7 @@ xfs_dir2_leafn_lookup_for_addname(ASSERT (free->hdr.magic ==cpu_to_be32 (XFS_DIR2_FREE_MAGIC ) || free->hdr.magic ==cpu_to_be32 (XFS_DIR3_FREE_MAGIC )); } - length = dp->d_ops->data_entsize (args->namelen); + length =xfs_dir2_data_entsize (mp, args->namelen);/* * Loop over leaf entries with the right hash value. */
@@ -1314,7 +1314,8 @@ xfs_dir2_leafn_remove( longest =be16_to_cpu (bf[0 ].length); needlog = needscan =0 ;xfs_dir2_data_make_free (args, dbp, off, - dp->d_ops->data_entsize (dep->namelen), &needlog, &needscan); +xfs_dir2_data_entsize (dp->i_mount, dep->namelen), &needlog, + &needscan);/* * Rescan the data block freespaces for bestfree. * Log the data block header if needed.
@@ -1907,7 +1908,7 @@ xfs_dir2_node_addname_int(int needscan =0 ;/* need to rescan data frees */ __be16 *tagp;/* data entry tag pointer */ - length = dp->d_ops->data_entsize (args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->namelen); error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &freehdr, &findex, length);if (error)
fs/xfs/libxfs/xfs_dir2_priv.h +2 -0
@@ -47,6 +47,8 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args, struct xfs_buf *lbp, struct xfs_buf *dbp);/* xfs_dir2_data.c */ +int xfs_dir2_data_entsize (struct xfs_mount *mp,int n); +#ifdef DEBUG extern void xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp);#else
fs/xfs/libxfs/xfs_dir2_sf.c +7 -7
@@ -341,7 +341,7 @@ xfs_dir2_block_to_sf( sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); } - ptr += dp->d_ops->data_entsize (dep->namelen); + ptr +=xfs_dir2_data_entsize (mp, dep->namelen); }ASSERT ((char *)sfep - (char *)sfp == size);
@@ -564,10 +564,10 @@ xfs_dir2_sf_addname_hard(*/ for (offset = dp->d_ops->data_first_offset, oldsfep =xfs_dir2_sf_firstentry (oldsfp), - add_datasize = dp->d_ops->data_entsize (args->namelen), + add_datasize =xfs_dir2_data_entsize (mp, args->namelen), eof = (char *)oldsfep == &buf[old_isize]; !eof; - offset = new_offset + dp->d_ops->data_entsize (oldsfep->namelen), + offset = new_offset +xfs_dir2_data_entsize (mp, oldsfep->namelen), oldsfep =xfs_dir2_sf_nextentry (mp, oldsfp, oldsfep), eof = (char *)oldsfep == &buf[old_isize]) { new_offset =xfs_dir2_sf_get_offset (oldsfep);
@@ -639,7 +639,7 @@ xfs_dir2_sf_addname_pick(int used;/* data bytes used */ sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - size = dp->d_ops->data_entsize (args->namelen); + size =xfs_dir2_data_entsize (mp, args->namelen); offset = dp->d_ops->data_first_offset; sfep =xfs_dir2_sf_firstentry (sfp); holefit =0 ;
@@ -652,7 +652,7 @@ xfs_dir2_sf_addname_pick(if (!holefit) holefit = offset + size <=xfs_dir2_sf_get_offset (sfep); offset =xfs_dir2_sf_get_offset (sfep) + - dp->d_ops->data_entsize (sfep->namelen); +xfs_dir2_data_entsize (mp, sfep->namelen); sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); }/*
@@ -717,7 +717,7 @@ xfs_dir2_sf_check( i8count += ino >XFS_DIR2_MAX_SHORT_INUM ; offset =xfs_dir2_sf_get_offset (sfep) + - dp->d_ops->data_entsize (sfep->namelen); +xfs_dir2_data_entsize (mp, sfep->namelen);ASSERT (xfs_dir2_sf_get_ftype (mp, sfep) <XFS_DIR3_FT_MAX ); }ASSERT (i8count == sfp->i8count);
@@ -817,7 +817,7 @@ xfs_dir2_sf_verify(return __this_address; offset =xfs_dir2_sf_get_offset (sfep) + - dops->data_entsize (sfep->namelen); +xfs_dir2_data_entsize (mp, sfep->namelen); sfep = next_sfep; }
fs/xfs/scrub/dir.c +2 -2
@@ -259,7 +259,7 @@ xchk_dir_rec( dep = (struct xfs_dir2_data_entry *)p;if (dep == dent)break ; - p += mp->m_dir_inode_ops->data_entsize (dep->namelen); + p +=xfs_dir2_data_entsize (mp, dep->namelen); }if (p >= endp) {xchk_fblock_set_corrupt (ds->sc,XFS_DATA_FORK , rec_bno);
@@ -402,7 +402,7 @@ xchk_directory_data_bestfree(struct xfs_dir2_data_entry *dep; dep = (struct xfs_dir2_data_entry *)ptr; - newlen = d_ops->data_entsize (dep->namelen); + newlen =xfs_dir2_data_entsize (mp, dep->namelen);if (newlen <=0 ) {xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk);
fs/xfs/xfs_dir2_readdir.c +5 -4
@@ -200,7 +200,7 @@ xfs_dir2_block_getdents(/* * Bump pointer for the next iteration. */ - ptr += dp->d_ops->data_entsize (dep->namelen); + ptr +=xfs_dir2_data_entsize (dp->i_mount, dep->namelen);/* * The entry is before the desired starting point, skip it. */
@@ -355,6 +355,7 @@ xfs_dir2_leaf_getdents( size_t bufsize) {struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;struct xfs_buf *bp =NULL ;/* data block buffer */ xfs_dir2_data_hdr_t *hdr;/* data block header */ xfs_dir2_data_entry_t *dep;/* data entry */
@@ -432,8 +433,8 @@ xfs_dir2_leaf_getdents(continue ; } dep = (xfs_dir2_data_entry_t *)ptr; - length = - dp->d_ops->data_entsize (dep->namelen); + length =xfs_dir2_data_entsize (mp, + dep->namelen); ptr += length; }/*
@@ -464,7 +465,7 @@ xfs_dir2_leaf_getdents( } dep = (xfs_dir2_data_entry_t *)ptr; - length = dp->d_ops->data_entsize (dep->namelen); + length =xfs_dir2_data_entsize (mp, dep->namelen); filetype = dp->d_ops->data_get_ftype (dep); ctx->pos =xfs_dir2_byte_to_dataptr (curoff) &0x7fffffff ;
Signature · 1 line
2.20.1
Re: [PATCH 26/34] xfs: devirtualize ->data_entsize
Quoted 23 lines · Christoph Hellwig
Replace the ->data_entsize dir ops method with a directly called
xfs_dir2_data_entsizehelper that takes care of the differences between the directory format with and without the file type field.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_da_format.c | 22 ++++++++-------------- fs/xfs/libxfs/xfs_dir2.h | 3 +-- fs/xfs/libxfs/xfs_dir2_block.c | 5 +++-- fs/xfs/libxfs/xfs_dir2_data.c | 13 ++++++------- fs/xfs/libxfs/xfs_dir2_leaf.c | 5 +++-- fs/xfs/libxfs/xfs_dir2_node.c | 7 ++++--- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/libxfs/xfs_dir2_sf.c | 14 +++++++------- fs/xfs/scrub/dir.c | 4 ++-- fs/xfs/xfs_dir2_readdir.c | 9 +++++---- 10 files changed, 41 insertions(+), 43 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-0
fs/xfs/libxfs/xfs_da_format.c line 47
Quoted 8 lines
fs/xfs/libxfs/xfs_da_format.c +2
-1@@ -41,18 +41,15 @@ sizeof(xfs_dir2_data_off_t) + sizeof(uint8_t)), \ XFS_DIR2_DATA_ALIGN) -static int +int xfs_dir2_data_entsize ( +struct xfs_mount *mp,int n)
@namelen, not just @n?
Oh, you do change that later.
--D
Quoted 357 lines
fs/xfs/libxfs/xfs_da_format.c +6
-13{ -return XFS_DIR2_DATA_ENTSIZE (n); -} - -static int -xfs_dir3_data_entsize ( -int n) -{ -return XFS_DIR3_DATA_ENTSIZE (n); +if (xfs_sb_version_hasftype (&mp->m_sb)) +return XFS_DIR3_DATA_ENTSIZE (n); +else +return XFS_DIR2_DATA_ENTSIZE (n); } static uint8_t@@ -100,7 +97,7 @@ xfs_dir2_data_entry_tag_p( struct xfs_dir2_data_entry *dep) {return (__be16 *)((char *)dep + -xfs_dir2_data_entsize (dep->namelen) -sizeof (__be16)); +XFS_DIR2_DATA_ENTSIZE (dep->namelen) -sizeof (__be16)); } static __be16 *@@ -108,7 +105,7 @@ xfs_dir3_data_entry_tag_p( struct xfs_dir2_data_entry *dep) {return (__be16 *)((char *)dep + -xfs_dir3_data_entsize (dep->namelen) -sizeof (__be16)); +XFS_DIR3_DATA_ENTSIZE (dep->namelen) -sizeof (__be16)); } static struct xfs_dir2_data_free *@@ -124,7 +121,6 @@ xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr) }static const struct xfs_dir_ops xfs_dir2_ops = { - .data_entsize = xfs_dir2_data_entsize, .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype, .data_entry_tag_p = xfs_dir2_data_entry_tag_p,@@ -140,7 +136,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { - .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, .data_entry_tag_p = xfs_dir3_data_entry_tag_p,@@ -156,7 +151,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { };static const struct xfs_dir_ops xfs_dir3_ops = { - .data_entsize = xfs_dir3_data_entsize, .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, .data_entry_tag_p = xfs_dir3_data_entry_tag_p,fs/xfs/libxfs/xfs_dir2.h +1
-2@@ -32,7 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);* directory operations vector for encode/decode routines */ struct xfs_dir_ops { -int (*data_entsize)(int len);uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,uint8_t ftype);@@ -87,7 +86,7 @@ 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_int (struct xfs_da_geometry *geo, +extern void xfs_dir2_data_freescan_int (struct xfs_mount *mp,const struct xfs_dir_ops *ops,struct xfs_dir2_data_hdr *hdr,int *loghead); extern void xfs_dir2_data_freescan(struct xfs_inode *dp,fs/xfs/libxfs/xfs_dir2_block.c +3
-2@@ -355,7 +355,7 @@ xfs_dir2_block_addname(if (error)return error; - len = dp->d_ops->data_entsize (args->namelen); + len =xfs_dir2_data_entsize (dp->i_mount, args->namelen);/* * Set up pointers to parts of the block. @@ -791,7 +791,8 @@ xfs_dir2_block_removename( needlog = needscan =0 ;xfs_dir2_data_make_free (args, bp, (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), - dp->d_ops->data_entsize (dep->namelen), &needlog, &needscan); +xfs_dir2_data_entsize (dp->i_mount, dep->namelen), &needlog, + &needscan);/* * Fix up the block tail. */ fs/xfs/libxfs/xfs_dir2_data.c +6
-7@@ -173,7 +173,7 @@ __xfs_dir3_data_check(return __this_address;if (xfs_dir_ino_validate (mp,be64_to_cpu (dep->inumber)))return __this_address; -if (endp < p + ops->data_entsize (dep->namelen)) +if (endp < p +xfs_dir2_data_entsize (mp, dep->namelen))return __this_address;if (be16_to_cpu (*ops->data_entry_tag_p (dep)) != (char *)dep - (char *)hdr)@@ -198,7 +198,7 @@ __xfs_dir3_data_check(if (i >=be32_to_cpu (btp->count))return __this_address; } - p += ops->data_entsize (dep->namelen); + p +=xfs_dir2_data_entsize (mp, dep->namelen); }/* * Need to have seen all the entries and all the bestfree slots. @@ -562,7 +562,7 @@ xfs_dir2_data_freeremove(*/ void xfs_dir2_data_freescan_int ( -struct xfs_da_geometry *geo, +struct xfs_mount *mp,const struct xfs_dir_ops *ops,struct xfs_dir2_data_hdr *hdr,int *loghead)@@ -588,7 +588,7 @@ xfs_dir2_data_freescan_int(* Set up pointers. */ p = (char *)hdr + ops->data_entry_offset; - endp =xfs_dir3_data_endp (geo, hdr); + endp =xfs_dir3_data_endp (mp->m_dir_geo, hdr);/* * Loop over the block's entries. */ @@ -610,7 +610,7 @@ xfs_dir2_data_freescan_int( dep = (xfs_dir2_data_entry_t *)p;ASSERT ((char *)dep - (char *)hdr ==be16_to_cpu (*ops->data_entry_tag_p (dep))); - p += ops->data_entsize (dep->namelen); + p +=xfs_dir2_data_entsize (mp, dep->namelen); } } }@@ -621,8 +621,7 @@ xfs_dir2_data_freescan(struct xfs_dir2_data_hdr *hdr, int *loghead) { - return xfs_dir2_data_freescan_int(dp->i_mount->m_dir_geo, dp->d_ops, -hdr ,loghead ); + return xfs_dir2_data_freescan_int(dp->i_mount, dp->d_ops, hdr, loghead); }/* fs/xfs/libxfs/xfs_dir2_leaf.c +3
-2@@ -660,7 +660,7 @@ xfs_dir2_leaf_addname(xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = leafhdr.ents; bestsp =xfs_dir2_leaf_bests_p (ltp); - length = dp->d_ops->data_entsize (args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->namelen);/* * See if there are any entries with the same hash value @@ -1395,7 +1395,8 @@ xfs_dir2_leaf_removename(*/ xfs_dir2_data_make_free (args, dbp, (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), - dp->d_ops->data_entsize (dep->namelen), &needlog, &needscan); +xfs_dir2_data_entsize (dp->i_mount, dep->namelen), &needlog, + &needscan);/* * We just mark the leaf entry stale by putting a null in it. */ fs/xfs/libxfs/xfs_dir2_node.c +4
-3@@ -662,7 +662,7 @@ xfs_dir2_leafn_lookup_for_addname(ASSERT (free->hdr.magic ==cpu_to_be32 (XFS_DIR2_FREE_MAGIC ) || free->hdr.magic ==cpu_to_be32 (XFS_DIR3_FREE_MAGIC )); } - length = dp->d_ops->data_entsize (args->namelen); + length =xfs_dir2_data_entsize (mp, args->namelen);/* * Loop over leaf entries with the right hash value. */ @@ -1314,7 +1314,8 @@ xfs_dir2_leafn_remove( longest =be16_to_cpu (bf[0 ].length); needlog = needscan =0 ;xfs_dir2_data_make_free (args, dbp, off, - dp->d_ops->data_entsize (dep->namelen), &needlog, &needscan); +xfs_dir2_data_entsize (dp->i_mount, dep->namelen), &needlog, + &needscan);/* * Rescan the data block freespaces for bestfree. * Log the data block header if needed. @@ -1907,7 +1908,7 @@ xfs_dir2_node_addname_int(int needscan =0 ;/* need to rescan data frees */ __be16 *tagp;/* data entry tag pointer */ - length = dp->d_ops->data_entsize (args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->namelen); error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &freehdr, &findex, length);if (error)fs/xfs/libxfs/xfs_dir2_priv.h +2
-0@@ -47,6 +47,8 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args, struct xfs_buf *lbp, struct xfs_buf *dbp);/* xfs_dir2_data.c */ +int xfs_dir2_data_entsize (struct xfs_mount *mp,int n); +#ifdef DEBUG extern void xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp);#else fs/xfs/libxfs/xfs_dir2_sf.c +7
-7@@ -341,7 +341,7 @@ xfs_dir2_block_to_sf( sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); } - ptr += dp->d_ops->data_entsize (dep->namelen); + ptr +=xfs_dir2_data_entsize (mp, dep->namelen); }ASSERT ((char *)sfep - (char *)sfp == size);@@ -564,10 +564,10 @@ xfs_dir2_sf_addname_hard(*/ for (offset = dp->d_ops->data_first_offset, oldsfep =xfs_dir2_sf_firstentry (oldsfp), - add_datasize = dp->d_ops->data_entsize (args->namelen), + add_datasize =xfs_dir2_data_entsize (mp, args->namelen), eof = (char *)oldsfep == &buf[old_isize]; !eof; - offset = new_offset + dp->d_ops->data_entsize (oldsfep->namelen), + offset = new_offset +xfs_dir2_data_entsize (mp, oldsfep->namelen), oldsfep =xfs_dir2_sf_nextentry (mp, oldsfp, oldsfep), eof = (char *)oldsfep == &buf[old_isize]) { new_offset =xfs_dir2_sf_get_offset (oldsfep);@@ -639,7 +639,7 @@ xfs_dir2_sf_addname_pick(int used;/* data bytes used */ sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - size = dp->d_ops->data_entsize (args->namelen); + size =xfs_dir2_data_entsize (mp, args->namelen); offset = dp->d_ops->data_first_offset; sfep =xfs_dir2_sf_firstentry (sfp); holefit =0 ;@@ -652,7 +652,7 @@ xfs_dir2_sf_addname_pick(if (!holefit) holefit = offset + size <=xfs_dir2_sf_get_offset (sfep); offset =xfs_dir2_sf_get_offset (sfep) + - dp->d_ops->data_entsize (sfep->namelen); +xfs_dir2_data_entsize (mp, sfep->namelen); sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); }/* @@ -717,7 +717,7 @@ xfs_dir2_sf_check( i8count += ino >XFS_DIR2_MAX_SHORT_INUM ; offset =xfs_dir2_sf_get_offset (sfep) + - dp->d_ops->data_entsize (sfep->namelen); +xfs_dir2_data_entsize (mp, sfep->namelen);ASSERT (xfs_dir2_sf_get_ftype (mp, sfep) <XFS_DIR3_FT_MAX ); }ASSERT (i8count == sfp->i8count);@@ -817,7 +817,7 @@ xfs_dir2_sf_verify(return __this_address; offset =xfs_dir2_sf_get_offset (sfep) + - dops->data_entsize (sfep->namelen); +xfs_dir2_data_entsize (mp, sfep->namelen); sfep = next_sfep; }fs/xfs/scrub/dir.c +2
-2@@ -259,7 +259,7 @@ xchk_dir_rec( dep = (struct xfs_dir2_data_entry *)p;if (dep == dent)break ; - p += mp->m_dir_inode_ops->data_entsize (dep->namelen); + p +=xfs_dir2_data_entsize (mp, dep->namelen); }if (p >= endp) {xchk_fblock_set_corrupt (ds->sc,XFS_DATA_FORK , rec_bno);@@ -402,7 +402,7 @@ xchk_directory_data_bestfree(struct xfs_dir2_data_entry *dep; dep = (struct xfs_dir2_data_entry *)ptr; - newlen = d_ops->data_entsize (dep->namelen); + newlen =xfs_dir2_data_entsize (mp, dep->namelen);if (newlen <=0 ) {xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk);fs/xfs/xfs_dir2_readdir.c +5
-4@@ -200,7 +200,7 @@ xfs_dir2_block_getdents(/* * Bump pointer for the next iteration. */ - ptr += dp->d_ops->data_entsize (dep->namelen); + ptr +=xfs_dir2_data_entsize (dp->i_mount, dep->namelen);/* * The entry is before the desired starting point, skip it. */ @@ -355,6 +355,7 @@ xfs_dir2_leaf_getdents( size_t bufsize) {struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount;struct xfs_buf *bp =NULL ;/* data block buffer */ xfs_dir2_data_hdr_t *hdr;/* data block header */ xfs_dir2_data_entry_t *dep;/* data entry */ @@ -432,8 +433,8 @@ xfs_dir2_leaf_getdents(continue ; } dep = (xfs_dir2_data_entry_t *)ptr; - length = - dp->d_ops->data_entsize (dep->namelen); + length =xfs_dir2_data_entsize (mp, + dep->namelen); ptr += length; }/* @@ -464,7 +465,7 @@ xfs_dir2_leaf_getdents( } dep = (xfs_dir2_data_entry_t *)ptr; - length = dp->d_ops->data_entsize (dep->namelen); + length =xfs_dir2_data_entsize (mp, dep->namelen); filetype = dp->d_ops->data_get_ftype (dep); ctx->pos =xfs_dir2_byte_to_dataptr (curoff) &0x7fffffff ;Signature · 1 line
2.20.1
PATCH 27/34 xfs: devirtualize ->data_entry_tag_p
In reply to Christoph HellwigReplace the ->data_entry_tag_p dir ops method with a directly called xfs_dir2_data_entry_tag_p helper that takes care of the differences between the directory format with and without the file type field.
--- fs/xfs/libxfs/xfs_da_format.c | 22 ---------------------- fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_block.c | 8 ++++---- fs/xfs/libxfs/xfs_dir2_data.c | 21 ++++++++++++++++++--- fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 2 +- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/scrub/dir.c | 2 +- 8 files changed, 27 insertions(+), 33 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -22
@@ -89,25 +89,6 @@ xfs_dir3_data_put_ftype( dep->name[dep->namelen] = type; } -/* -* Pointer to an entry's tag word. -*/ -static __be16 * -xfs_dir2_data_entry_tag_p ( -struct xfs_dir2_data_entry *dep) -{ -return (__be16 *)((char *)dep + -XFS_DIR2_DATA_ENTSIZE (dep->namelen) -sizeof (__be16)); -} - -static __be16 * -xfs_dir3_data_entry_tag_p ( -struct xfs_dir2_data_entry *dep) -{ -return (__be16 *)((char *)dep + -XFS_DIR3_DATA_ENTSIZE (dep->namelen) -sizeof (__be16)); -} -static struct xfs_dir2_data_free *xfs_dir2_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) {
@@ -123,7 +104,6 @@ xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)static const struct xfs_dir_ops xfs_dir2_ops = { .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype, - .data_entry_tag_p = xfs_dir2_data_entry_tag_p, .data_bestfree_p = xfs_dir2_data_bestfree_p, .data_dot_offset =sizeof (struct xfs_dir2_data_hdr ),
@@ -138,7 +118,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, - .data_entry_tag_p = xfs_dir3_data_entry_tag_p, .data_bestfree_p = xfs_dir2_data_bestfree_p, .data_dot_offset =sizeof (struct xfs_dir2_data_hdr ),
@@ -153,7 +132,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {static const struct xfs_dir_ops xfs_dir3_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, - .data_entry_tag_p = xfs_dir3_data_entry_tag_p, .data_bestfree_p = xfs_dir3_data_bestfree_p, .data_dot_offset =sizeof (struct xfs_dir3_data_hdr ),
fs/xfs/libxfs/xfs_dir2.h +0 -1
@@ -35,7 +35,6 @@ struct xfs_dir_ops {uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,uint8_t ftype); -__be16 * (*data_entry_tag_p)(struct xfs_dir2_data_entry *dep);struct xfs_dir2_data_free * (*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr);
fs/xfs/libxfs/xfs_dir2_block.c +4 -4
@@ -542,7 +542,7 @@ xfs_dir2_block_addname( dep->namelen = args->namelen;memcpy (dep->name, args->name, args->namelen); dp->d_ops->data_put_ftype (dep, args->filetype); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);/* * Clean up the bestfree array and log the header, tail, and entry.
@@ -1154,7 +1154,7 @@ xfs_dir2_sf_to_block( dep->namelen =1 ; dep->name[0 ] ='.' ; dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR ); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep); blp[0 ].hashval =cpu_to_be32 (xfs_dir_hash_dot);
@@ -1168,7 +1168,7 @@ xfs_dir2_sf_to_block( dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ; dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR ); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep); blp[1 ].hashval =cpu_to_be32 (xfs_dir_hash_dotdot);
@@ -1219,7 +1219,7 @@ xfs_dir2_sf_to_block( dep->namelen = sfep->namelen; dp->d_ops->data_put_ftype (dep,xfs_dir2_sf_get_ftype (mp, sfep));memcpy (dep->name, sfep->name, dep->namelen); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep); name.name = sfep->name;
fs/xfs/libxfs/xfs_dir2_data.c +18 -3
@@ -17,12 +17,25 @@#include "xfs_trans.h" #include "xfs_buf_item.h" #include "xfs_log.h" +#include "xfs_dir2_priv.h" static xfs_failaddr_t xfs_dir2_data_freefind_verify (struct xfs_dir2_data_hdr *hdr,struct xfs_dir2_data_free *bf,struct xfs_dir2_data_unused *dup,struct xfs_dir2_data_free **bf_ent); +/* +* Pointer to an entry's tag word. +*/ +__be16 * +xfs_dir2_data_entry_tag_p ( +struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep) +{ +return (__be16 *)((char *)dep + +xfs_dir2_data_entsize (mp, dep->namelen) -sizeof (__be16)); +} +/* * Check the consistency of the data block. * The input can also be a block-format directory.
@@ -175,7 +188,7 @@ __xfs_dir3_data_check(return __this_address;if (endp < p +xfs_dir2_data_entsize (mp, dep->namelen))return __this_address; -if (be16_to_cpu (*ops->data_entry_tag_p (dep)) != +if (be16_to_cpu (*xfs_dir2_data_entry_tag_p (mp, dep)) != (char *)dep - (char *)hdr)return __this_address;if (ops->data_get_ftype (dep) >=XFS_DIR3_FT_MAX )
@@ -609,7 +622,8 @@ xfs_dir2_data_freescan_int(else { dep = (xfs_dir2_data_entry_t *)p;ASSERT ((char *)dep - (char *)hdr == -be16_to_cpu (*ops->data_entry_tag_p (dep))); +be16_to_cpu (*xfs_dir2_data_entry_tag_p (mp, + dep))); p +=xfs_dir2_data_entsize (mp, dep->namelen); } }
@@ -709,6 +723,7 @@ xfs_dir2_data_log_entry(struct xfs_buf *bp, xfs_dir2_data_entry_t *dep) /* data entry pointer */ { + struct xfs_mount *mp = bp->b_mount;struct xfs_dir2_data_hdr *hdr = bp->b_addr; ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
@@ -717,7 +732,7 @@ xfs_dir2_data_log_entry( hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));xfs_trans_log_buf (args->trans, bp, (uint)((char *)dep - (char *)hdr), - (uint)((char *)(args->dp->d_ops->data_entry_tag_p (dep) +1 ) - + (uint)((char *)(xfs_dir2_data_entry_tag_p (mp, dep) +1 ) - (char *)hdr -1 )); }
fs/xfs/libxfs/xfs_dir2_leaf.c +1 -1
@@ -866,7 +866,7 @@ xfs_dir2_leaf_addname( dep->namelen = args->namelen;memcpy (dep->name, args->name, dep->namelen); dp->d_ops->data_put_ftype (dep, args->filetype); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);/* * Need to scan fix up the bestfree table.
fs/xfs/libxfs/xfs_dir2_node.c +1 -1
@@ -1966,7 +1966,7 @@ xfs_dir2_node_addname_int( dep->namelen = args->namelen;memcpy (dep->name, args->name, dep->namelen); dp->d_ops->data_put_ftype (dep, args->filetype); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, dbp, dep);
fs/xfs/libxfs/xfs_dir2_priv.h +2 -0
@@ -48,6 +48,8 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,/* xfs_dir2_data.c */ int xfs_dir2_data_entsize (struct xfs_mount *mp,int n); +__be16 *xfs_dir2_data_entry_tag_p (struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep);#ifdef DEBUG extern void xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp);
fs/xfs/scrub/dir.c +1 -1
@@ -269,7 +269,7 @@ xchk_dir_rec(/* Retrieve the entry, sanity check it, and compare hashes. */ ino =be64_to_cpu (dent->inumber); hash =be32_to_cpu (ent->hashval); - tag =be16_to_cpup (dp->d_ops->data_entry_tag_p (dent)); + tag =be16_to_cpup (xfs_dir2_data_entry_tag_p (mp, dent));if (!xfs_verify_dir_ino (mp, ino) || tag != off)xchk_fblock_set_corrupt (ds->sc,XFS_DATA_FORK , rec_bno);if (dent->namelen ==0 ) {
Signature · 1 line
2.20.1
Re: [PATCH 27/34] xfs: devirtualize ->data_entry_tag_p
Quoted 5 lines · Christoph Hellwig
Replace the ->data_entry_tag_p dir ops method with a directly called
xfs_dir2_data_entry_tag_phelper that takes care of the differences between the directory format with and without the file type field.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 238 lines
--- fs/xfs/libxfs/xfs_da_format.c | 22 ---------------------- fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/libxfs/xfs_dir2_block.c | 8 ++++---- fs/xfs/libxfs/xfs_dir2_data.c | 21 ++++++++++++++++++--- fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 2 +- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/scrub/dir.c | 2 +- 8 files changed, 27 insertions(+), 33 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-22@@ -89,25 +89,6 @@ xfs_dir3_data_put_ftype( dep->name[dep->namelen] = type; } -/* -* Pointer to an entry's tag word. -*/ -static __be16 * -xfs_dir2_data_entry_tag_p ( -struct xfs_dir2_data_entry *dep) -{ -return (__be16 *)((char *)dep + -XFS_DIR2_DATA_ENTSIZE (dep->namelen) -sizeof (__be16)); -} - -static __be16 * -xfs_dir3_data_entry_tag_p ( -struct xfs_dir2_data_entry *dep) -{ -return (__be16 *)((char *)dep + -XFS_DIR3_DATA_ENTSIZE (dep->namelen) -sizeof (__be16)); -} -static struct xfs_dir2_data_free *xfs_dir2_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) {@@ -123,7 +104,6 @@ xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)static const struct xfs_dir_ops xfs_dir2_ops = { .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype, - .data_entry_tag_p = xfs_dir2_data_entry_tag_p, .data_bestfree_p = xfs_dir2_data_bestfree_p, .data_dot_offset =sizeof (struct xfs_dir2_data_hdr ),@@ -138,7 +118,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, - .data_entry_tag_p = xfs_dir3_data_entry_tag_p, .data_bestfree_p = xfs_dir2_data_bestfree_p, .data_dot_offset =sizeof (struct xfs_dir2_data_hdr ),@@ -153,7 +132,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {static const struct xfs_dir_ops xfs_dir3_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, - .data_entry_tag_p = xfs_dir3_data_entry_tag_p, .data_bestfree_p = xfs_dir3_data_bestfree_p, .data_dot_offset =sizeof (struct xfs_dir3_data_hdr ),fs/xfs/libxfs/xfs_dir2.h +0
-1@@ -35,7 +35,6 @@ struct xfs_dir_ops {uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,uint8_t ftype); -__be16 * (*data_entry_tag_p)(struct xfs_dir2_data_entry *dep);struct xfs_dir2_data_free * (*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr);fs/xfs/libxfs/xfs_dir2_block.c +4
-4@@ -542,7 +542,7 @@ xfs_dir2_block_addname( dep->namelen = args->namelen;memcpy (dep->name, args->name, args->namelen); dp->d_ops->data_put_ftype (dep, args->filetype); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);/* * Clean up the bestfree array and log the header, tail, and entry. @@ -1154,7 +1154,7 @@ xfs_dir2_sf_to_block( dep->namelen =1 ; dep->name[0 ] ='.' ; dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR ); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep); blp[0 ].hashval =cpu_to_be32 (xfs_dir_hash_dot);@@ -1168,7 +1168,7 @@ xfs_dir2_sf_to_block( dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ; dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR ); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep); blp[1 ].hashval =cpu_to_be32 (xfs_dir_hash_dotdot);@@ -1219,7 +1219,7 @@ xfs_dir2_sf_to_block( dep->namelen = sfep->namelen; dp->d_ops->data_put_ftype (dep,xfs_dir2_sf_get_ftype (mp, sfep));memcpy (dep->name, sfep->name, dep->namelen); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep); name.name = sfep->name;fs/xfs/libxfs/xfs_dir2_data.c +18
-3@@ -17,12 +17,25 @@#include "xfs_trans.h" #include "xfs_buf_item.h" #include "xfs_log.h" +#include "xfs_dir2_priv.h" static xfs_failaddr_t xfs_dir2_data_freefind_verify (struct xfs_dir2_data_hdr *hdr,struct xfs_dir2_data_free *bf,struct xfs_dir2_data_unused *dup,struct xfs_dir2_data_free **bf_ent); +/* +* Pointer to an entry's tag word. +*/ +__be16 * +xfs_dir2_data_entry_tag_p ( +struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep) +{ +return (__be16 *)((char *)dep + +xfs_dir2_data_entsize (mp, dep->namelen) -sizeof (__be16)); +} +/* * Check the consistency of the data block. * The input can also be a block-format directory. @@ -175,7 +188,7 @@ __xfs_dir3_data_check(return __this_address;if (endp < p +xfs_dir2_data_entsize (mp, dep->namelen))return __this_address; -if (be16_to_cpu (*ops->data_entry_tag_p (dep)) != +if (be16_to_cpu (*xfs_dir2_data_entry_tag_p (mp, dep)) != (char *)dep - (char *)hdr)return __this_address;if (ops->data_get_ftype (dep) >=XFS_DIR3_FT_MAX )@@ -609,7 +622,8 @@ xfs_dir2_data_freescan_int(else { dep = (xfs_dir2_data_entry_t *)p;ASSERT ((char *)dep - (char *)hdr == -be16_to_cpu (*ops->data_entry_tag_p (dep))); +be16_to_cpu (*xfs_dir2_data_entry_tag_p (mp, + dep))); p +=xfs_dir2_data_entsize (mp, dep->namelen); } }@@ -709,6 +723,7 @@ xfs_dir2_data_log_entry(struct xfs_buf *bp, xfs_dir2_data_entry_t *dep) /* data entry pointer */ { + struct xfs_mount *mp = bp->b_mount;struct xfs_dir2_data_hdr *hdr = bp->b_addr; ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||@@ -717,7 +732,7 @@ xfs_dir2_data_log_entry( hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));xfs_trans_log_buf (args->trans, bp, (uint)((char *)dep - (char *)hdr), - (uint)((char *)(args->dp->d_ops->data_entry_tag_p (dep) +1 ) - + (uint)((char *)(xfs_dir2_data_entry_tag_p (mp, dep) +1 ) - (char *)hdr -1 )); }fs/xfs/libxfs/xfs_dir2_leaf.c +1
-1@@ -866,7 +866,7 @@ xfs_dir2_leaf_addname( dep->namelen = args->namelen;memcpy (dep->name, args->name, dep->namelen); dp->d_ops->data_put_ftype (dep, args->filetype); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);/* * Need to scan fix up the bestfree table. fs/xfs/libxfs/xfs_dir2_node.c +1
-1@@ -1966,7 +1966,7 @@ xfs_dir2_node_addname_int( dep->namelen = args->namelen;memcpy (dep->name, args->name, dep->namelen); dp->d_ops->data_put_ftype (dep, args->filetype); - tagp = dp->d_ops->data_entry_tag_p (dep); + tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, dbp, dep);fs/xfs/libxfs/xfs_dir2_priv.h +2
-0@@ -48,6 +48,8 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,/* xfs_dir2_data.c */ int xfs_dir2_data_entsize (struct xfs_mount *mp,int n); +__be16 *xfs_dir2_data_entry_tag_p (struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep);#ifdef DEBUG extern void xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp);fs/xfs/scrub/dir.c +1
-1@@ -269,7 +269,7 @@ xchk_dir_rec(/* Retrieve the entry, sanity check it, and compare hashes. */ ino =be64_to_cpu (dent->inumber); hash =be32_to_cpu (ent->hashval); - tag =be16_to_cpup (dp->d_ops->data_entry_tag_p (dent)); + tag =be16_to_cpup (xfs_dir2_data_entry_tag_p (mp, dent));if (!xfs_verify_dir_ino (mp, ino) || tag != off)xchk_fblock_set_corrupt (ds->sc,XFS_DATA_FORK , rec_bno);if (dent->namelen ==0 ) {Signature · 1 line
2.20.1
PATCH 28/34 xfs: move the dir2 data block fixed offsets to struct xfs_da_geometry
In reply to Christoph HellwigMove the data block fixed offsets towards our structure for dir/attr geometry parameters.
--- fs/xfs/libxfs/xfs_da_btree.h | 5 +++++ fs/xfs/libxfs/xfs_da_format.c | 24 ------------------------ fs/xfs/libxfs/xfs_dir2.c | 9 +++++++++ fs/xfs/libxfs/xfs_dir2.h | 5 ----- fs/xfs/libxfs/xfs_dir2_block.c | 11 ++++++----- fs/xfs/libxfs/xfs_dir2_data.c | 18 +++++++++--------- fs/xfs/libxfs/xfs_dir2_leaf.c | 22 ++++++++++++---------- fs/xfs/libxfs/xfs_dir2_node.c | 24 +++++++++++------------- fs/xfs/libxfs/xfs_dir2_sf.c | 16 +++++----------- fs/xfs/scrub/dir.c | 4 ++-- fs/xfs/xfs_dir2_readdir.c | 13 +++++-------- 11 files changed, 64 insertions(+), 87 deletions(-)
fs/xfs/libxfs/xfs_da_btree.h +5 -0
@@ -32,6 +32,11 @@ struct xfs_da_geometry {int free_hdr_size;/* dir2 free header size */ unsigned int free_max_bests;/* # of bests entries in dir2 free */ xfs_dablk_t freeblk;/* blockno of free data v2 */ + +xfs_dir2_data_aoff_t data_dot_offset; +xfs_dir2_data_aoff_t data_dotdot_offset; +xfs_dir2_data_aoff_t data_first_offset; +size_t data_entry_offset; };/*========================================================================
fs/xfs/libxfs/xfs_da_format.c +0 -24
@@ -105,42 +105,18 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype, .data_bestfree_p = xfs_dir2_data_bestfree_p, - - .data_dot_offset = sizeof(struct xfs_dir2_data_hdr), - .data_dotdot_offset =sizeof (struct xfs_dir2_data_hdr ) + - XFS_DIR2_DATA_ENTSIZE(1), - .data_first_offset =sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR2_DATA_ENTSIZE (1 ) + - XFS_DIR2_DATA_ENTSIZE(2), - .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, .data_bestfree_p = xfs_dir2_data_bestfree_p, - - .data_dot_offset =sizeof (struct xfs_dir2_data_hdr ), - .data_dotdot_offset =sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ), - .data_first_offset =sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ) + -XFS_DIR3_DATA_ENTSIZE (2 ), - .data_entry_offset =sizeof (struct xfs_dir2_data_hdr ), };static const struct xfs_dir_ops xfs_dir3_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, .data_bestfree_p = xfs_dir3_data_bestfree_p, - - .data_dot_offset =sizeof (struct xfs_dir3_data_hdr ), - .data_dotdot_offset =sizeof (struct xfs_dir3_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ), - .data_first_offset =sizeof (struct xfs_dir3_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ) + -XFS_DIR3_DATA_ENTSIZE (2 ), - .data_entry_offset =sizeof (struct xfs_dir3_data_hdr ), };/*
fs/xfs/libxfs/xfs_dir2.c +9 -0
@@ -126,16 +126,25 @@ xfs_da_mount( dageo->node_hdr_size =sizeof (struct xfs_da3_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir3_leaf_hdr ); dageo->free_hdr_size =sizeof (struct xfs_dir3_free_hdr ); + dageo->data_entry_offset = dageo->data_dot_offset = +sizeof (struct xfs_dir3_data_hdr ); }else { dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir2_leaf_hdr ); dageo->free_hdr_size =sizeof (struct xfs_dir2_free_hdr ); + dageo->data_entry_offset = dageo->data_dot_offset = +sizeof (struct xfs_dir2_data_hdr ); } dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) /sizeof (struct xfs_dir2_leaf_entry ); dageo->free_max_bests = (dageo->blksize - dageo->free_hdr_size) /sizeof (xfs_dir2_data_off_t); + dageo->data_dotdot_offset = dageo->data_dot_offset + +xfs_dir2_data_entsize (mp,1 ); + dageo->data_first_offset = dageo->data_dotdot_offset + +xfs_dir2_data_entsize (mp,2 ); +/* * Now we've set up the block conversion variables, we can calculate the * segment block constants using the geometry structure.
fs/xfs/libxfs/xfs_dir2.h +0 -5
@@ -37,11 +37,6 @@ struct xfs_dir_ops { uint8_t ftype);struct xfs_dir2_data_free * (*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr); - -xfs_dir2_data_aoff_t data_dot_offset; -xfs_dir2_data_aoff_t data_dotdot_offset; -xfs_dir2_data_aoff_t data_first_offset; -size_t data_entry_offset; }; extern const struct xfs_dir_ops *
fs/xfs/libxfs/xfs_dir2_block.c +6 -5
@@ -937,7 +937,7 @@ xfs_dir2_leaf_to_block(while (dp->i_d.di_size > args->geo->blksize) {int hdrsz; - hdrsz = dp->d_ops->data_entry_offset; + hdrsz = args->geo->data_entry_offset; bestsp =xfs_dir2_leaf_bests_p (ltp);if (be16_to_cpu (bestsp[be32_to_cpu (ltp->bestcount) -1 ]) == args->geo->blksize - hdrsz) {
@@ -1041,6 +1041,7 @@ int /* error */xfs_dir2_sf_to_block ( xfs_da_args_t *args) /* operation arguments */ { +struct xfs_da_geometry *geo = args->geo;xfs_dir2_db_t blkno;/* dir-relative block # (0) */ xfs_dir2_data_hdr_t *hdr;/* block header */ xfs_dir2_leaf_entry_t *blp;/* block leaf entries */
@@ -1123,7 +1124,7 @@ xfs_dir2_sf_to_block(* The whole thing is initialized to free by the init routine. * Say we're using the leaf and tail area. */ - dup = (void *)hdr + dp->d_ops->data_entry_offset; + dup = (void *)hdr + args->geo->data_entry_offset; needlog = needscan =0 ; error =xfs_dir2_data_use_free (args, bp, dup, args->geo->blksize - i, i, &needlog, &needscan);
@@ -1149,7 +1150,7 @@ xfs_dir2_sf_to_block(/* * Create entry for . */ - dep = (void *)hdr + dp->d_ops->data_dot_offset; + dep = (void *)hdr + geo->data_dot_offset; dep->inumber =cpu_to_be64 (dp->i_ino); dep->namelen =1 ; dep->name[0 ] ='.' ;
@@ -1163,7 +1164,7 @@ xfs_dir2_sf_to_block(/* * Create entry for .. */ - dep = (void *)hdr + dp->d_ops->data_dotdot_offset; + dep = (void *)hdr + geo->data_dotdot_offset; dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_parent_ino (sfp)); dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ;
@@ -1174,7 +1175,7 @@ xfs_dir2_sf_to_block( blp[1 ].hashval =cpu_to_be32 (xfs_dir_hash_dotdot); blp[1 ].address =cpu_to_be32 (xfs_dir2_byte_to_dataptr ( (char *)dep - (char *)hdr)); - offset = dp->d_ops->data_first_offset; + offset = geo->data_first_offset;/* * Loop over existing entries, stuff them in. */
fs/xfs/libxfs/xfs_dir2_data.c +9 -9
@@ -84,7 +84,7 @@ __xfs_dir3_data_check(return __this_address; hdr = bp->b_addr; - p = (char *)hdr + ops->data_entry_offset; + p = (char *)hdr + geo->data_entry_offset;switch (hdr->magic) {case cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC ):
@@ -580,6 +580,7 @@ xfs_dir2_data_freescan_int(struct xfs_dir2_data_hdr *hdr, int *loghead) { + struct xfs_da_geometry *geo = mp->m_dir_geo;xfs_dir2_data_entry_t *dep;/* active data entry */ xfs_dir2_data_unused_t *dup;/* unused data entry */ struct xfs_dir2_data_free *bf;
@@ -600,8 +601,8 @@ xfs_dir2_data_freescan_int(/* * Set up pointers. */ - p = (char *)hdr + ops->data_entry_offset; - endp =xfs_dir3_data_endp (mp->m_dir_geo, hdr); + p = (char *)hdr + geo->data_entry_offset; + endp =xfs_dir3_data_endp (geo, hdr);/* * Loop over the block's entries. */
@@ -689,7 +690,7 @@ xfs_dir3_data_init( hdr->magic =cpu_to_be32 (XFS_DIR2_DATA_MAGIC ); bf = dp->d_ops->data_bestfree_p (hdr); - bf[0 ].offset =cpu_to_be16 (dp->d_ops->data_entry_offset); + bf[0 ].offset =cpu_to_be16 (args->geo->data_entry_offset);for (i =1 ; i <XFS_DIR2_DATA_FD_COUNT ; i++) { bf[i].length =0 ; bf[i].offset =0 ;
@@ -698,10 +699,10 @@ xfs_dir3_data_init(/* * Set up an unused entry for the block's body. */ - dup = (void *)hdr + dp->d_ops->data_entry_offset; + dup = (void *)hdr + args->geo->data_entry_offset; dup->freetag =cpu_to_be16 (XFS_DIR2_DATA_FREE_TAG ); - t = args->geo->blksize - (uint )dp->d_ops->data_entry_offset; + t = args->geo->blksize - args->geo->data_entry_offset; bf[0 ].length =cpu_to_be16 (t); dup->length =cpu_to_be16 (t); *xfs_dir2_data_unused_tag_p (dup) =cpu_to_be16 ((char *)dup - (char *)hdr);
@@ -753,8 +754,7 @@ xfs_dir2_data_log_header( hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));#endif -xfs_trans_log_buf (args->trans, bp,0 , - args->dp->d_ops->data_entry_offset -1 ); +xfs_trans_log_buf (args->trans, bp,0 , args->geo->data_entry_offset -1 ); }/*
@@ -822,7 +822,7 @@ xfs_dir2_data_make_free(* If this isn't the start of the block, then back up to * the previous entry and see if it's free. */ -if (offset > args->dp->d_ops->data_entry_offset) { +if (offset > args->geo->data_entry_offset) {__be16 *tagp;/* tag just before us */ tagp = (__be16 *)((char *)hdr + offset) -1 ;
fs/xfs/libxfs/xfs_dir2_leaf.c +12 -10
@@ -1343,6 +1343,7 @@ int /* error */xfs_dir2_leaf_removename ( xfs_da_args_t *args) /* operation arguments */ { +struct xfs_da_geometry *geo = args->geo;__be16 *bestsp;/* leaf block best freespace */ xfs_dir2_data_hdr_t *hdr;/* data block header */ xfs_dir2_db_t db;/* data block number */
@@ -1381,12 +1382,12 @@ xfs_dir2_leaf_removename(* Point to the leaf entry, use that to point to the data entry. */ lep = &leafhdr.ents[index]; - db =xfs_dir2_dataptr_to_db (args->geo,be32_to_cpu (lep->address)); + db =xfs_dir2_dataptr_to_db (geo,be32_to_cpu (lep->address)); dep = (xfs_dir2_data_entry_t *)((char *)hdr + -xfs_dir2_dataptr_to_off (args->geo,be32_to_cpu (lep->address))); +xfs_dir2_dataptr_to_off (geo,be32_to_cpu (lep->address))); needscan = needlog =0 ; oldbest =be16_to_cpu (bf[0 ].length); - ltp =xfs_dir2_leaf_tail_p (args->geo, leaf); + ltp =xfs_dir2_leaf_tail_p (geo, leaf); bestsp =xfs_dir2_leaf_bests_p (ltp);if (be16_to_cpu (bestsp[db]) != oldbest)return -EFSCORRUPTED ;
@@ -1428,8 +1429,8 @@ xfs_dir2_leaf_removename(* If the data block is now empty then get rid of the data block. */ if (be16_to_cpu (bf[0 ].length) == - args->geo->blksize - dp->d_ops->data_entry_offset) { -ASSERT (db != args->geo->datablk); + geo->blksize - geo->data_entry_offset) { +ASSERT (db != geo->datablk);if ((error =xfs_dir2_shrink_inode (args, db, dbp))) {/* * Nope, can't get rid of it because it caused
@@ -1471,7 +1472,7 @@ xfs_dir2_leaf_removename(/* * If the data block was not the first one, drop it. */ - else if (db != args->geo->datablk) + else if (db != geo->datablk) dbp =NULL ;xfs_dir3_leaf_check (dp, lbp);
@@ -1592,6 +1593,7 @@ xfs_dir2_leaf_trim_data( struct xfs_buf *lbp, /* leaf buffer */ xfs_dir2_db_t db) /* data block number */ { +struct xfs_da_geometry *geo = args->geo;__be16 *bestsp;/* leaf bests table */ struct xfs_buf *dbp;/* data block buffer */ xfs_inode_t *dp;/* incore directory inode */
@@ -1605,13 +1607,13 @@ xfs_dir2_leaf_trim_data(/* * Read the offending data block. We need its buffer. */ - error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (args->geo, db), --1 , &dbp); + error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (geo, db),-1 , + &dbp);if (error)return error; leaf = lbp->b_addr; - ltp =xfs_dir2_leaf_tail_p (args->geo, leaf); + ltp =xfs_dir2_leaf_tail_p (geo, leaf);#ifdef DEBUG {
@@ -1621,7 +1623,7 @@ xfs_dir2_leaf_trim_data(ASSERT (hdr->magic ==cpu_to_be32 (XFS_DIR2_DATA_MAGIC ) || hdr->magic ==cpu_to_be32 (XFS_DIR3_DATA_MAGIC ));ASSERT (be16_to_cpu (bf[0 ].length) == - args->geo->blksize - dp->d_ops->data_entry_offset); + geo->blksize - geo->data_entry_offset); ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); }#endif
fs/xfs/libxfs/xfs_dir2_node.c +11 -13
@@ -1257,6 +1257,7 @@ xfs_dir2_leafn_remove( xfs_da_state_blk_t *dblk, /* data block */ int *rval) /* resulting block needs join */ { +struct xfs_da_geometry *geo = args->geo;xfs_dir2_data_hdr_t *hdr;/* data block header */ xfs_dir2_db_t db;/* data block number */ struct xfs_buf *dbp;/* data block buffer */
@@ -1287,9 +1288,9 @@ xfs_dir2_leafn_remove(/* * Extract the data block and offset from the entry. */ - db =xfs_dir2_dataptr_to_db (args->geo,be32_to_cpu (lep->address)); + db =xfs_dir2_dataptr_to_db (geo,be32_to_cpu (lep->address));ASSERT (dblk->blkno == db); - off =xfs_dir2_dataptr_to_off (args->geo,be32_to_cpu (lep->address)); + off =xfs_dir2_dataptr_to_off (geo,be32_to_cpu (lep->address));ASSERT (dblk->index == off);/*
@@ -1340,9 +1341,8 @@ xfs_dir2_leafn_remove(* Convert the data block number to a free block, * read in the free block. */ - fdb =xfs_dir2_db_to_fdb (args->geo, db); - error =xfs_dir2_free_read (tp, dp, -xfs_dir2_db_to_da (args->geo, fdb), + fdb =xfs_dir2_db_to_fdb (geo, db); + error =xfs_dir2_free_read (tp, dp,xfs_dir2_db_to_da (geo, fdb), &fbp);if (error)return error;
@@ -1352,22 +1352,20 @@ xfs_dir2_leafn_remove(struct xfs_dir3_icfree_hdr freehdr;xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); -ASSERT (freehdr.firstdb == args->geo->free_max_bests * - (fdb -xfs_dir2_byte_to_db (args->geo, - XFS_DIR2_FREE_OFFSET))); +ASSERT (freehdr.firstdb == geo->free_max_bests * + (fdb - xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET))); }#endif /* * Calculate which entry we need to fix. */ - findex =xfs_dir2_db_to_fdindex (args->geo, db); + findex =xfs_dir2_db_to_fdindex (geo, db); longest =be16_to_cpu (bf[0 ].length);/* * If the data block is now empty we can get rid of it * (usually). */ -if (longest == args->geo->blksize - - dp->d_ops->data_entry_offset) { +if (longest == geo->blksize - geo->data_entry_offset) {/* * Try to punch out the data block. */
@@ -1399,9 +1397,9 @@ xfs_dir2_leafn_remove(* Return indication of whether this leaf block is empty enough * to justify trying to join it with a neighbor. */ - *rval = (args->geo->leaf_hdr_size + + *rval = (geo->leaf_hdr_size + (uint )sizeof (leafhdr.ents) * (leafhdr.count - leafhdr.stale)) < - args->geo->magicpct; + geo->magicpct;return 0 ; }
fs/xfs/libxfs/xfs_dir2_sf.c +5 -11
@@ -296,7 +296,7 @@ xfs_dir2_block_to_sf(/* * Set up to loop over the block's entries. */ - ptr = (char *)hdr + dp->d_ops->data_entry_offset; + ptr = (char *)hdr + args->geo->data_entry_offset; endptr =xfs_dir3_data_endp (args->geo, hdr); sfep =xfs_dir2_sf_firstentry (sfp);/*
@@ -562,7 +562,7 @@ xfs_dir2_sf_addname_hard(* to insert the new entry. * If it's going to end up at the end then oldsfep will point there. */ - for (offset = dp->d_ops->data_first_offset, + for (offset = args->geo->data_first_offset, oldsfep = xfs_dir2_sf_firstentry(oldsfp), add_datasize = xfs_dir2_data_entsize(mp, args->namelen), eof = (char *)oldsfep == &buf[old_isize];
@@ -640,7 +640,7 @@ xfs_dir2_sf_addname_pick( sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; size =xfs_dir2_data_entsize (mp, args->namelen); - offset = dp->d_ops->data_first_offset; + offset = args->geo->data_first_offset; sfep =xfs_dir2_sf_firstentry (sfp); holefit =0 ;/*
@@ -705,7 +705,7 @@ xfs_dir2_sf_check(xfs_dir2_sf_hdr_t *sfp;/* shortform structure */ sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - offset = dp->d_ops->data_first_offset; + offset = args->geo->data_first_offset; ino =xfs_dir2_sf_get_parent_ino (sfp); i8count = ino >XFS_DIR2_MAX_SHORT_INUM ;
@@ -738,7 +738,6 @@ xfs_dir2_sf_verify(struct xfs_dir2_sf_entry *sfep;struct xfs_dir2_sf_entry *next_sfep;char *endp; -const struct xfs_dir_ops *dops;struct xfs_ifork *ifp;xfs_ino_t ino;int i;
@@ -749,11 +748,6 @@ xfs_dir2_sf_verify(uint8_t filetype;ASSERT (ip->i_d.di_format ==XFS_DINODE_FMT_LOCAL ); -/* -* xfs_iread calls us before xfs_setup_inode sets up ip->d_ops, -* so we can only trust the mountpoint to have the right pointer. -*/ - dops =xfs_dir_get_ops (mp,NULL ); ifp =XFS_IFORK_PTR (ip,XFS_DATA_FORK ); sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data;
@@ -774,7 +768,7 @@ xfs_dir2_sf_verify( error =xfs_dir_ino_validate (mp, ino);if (error)return __this_address; - offset = dops->data_first_offset; + offset = mp->m_dir_geo->data_first_offset;/* Check all reported entries */ sfep =xfs_dir2_sf_firstentry (sfp);
fs/xfs/scrub/dir.c +2 -2
@@ -241,7 +241,7 @@ xchk_dir_rec( dent = (struct xfs_dir2_data_entry *)(((char *)bp->b_addr) + off);/* Make sure we got a real directory entry. */ - p = bp->b_addr + mp->m_dir_inode_ops->data_entry_offset; + p = bp->b_addr + mp->m_dir_geo->data_entry_offset; endp =xfs_dir3_data_endp (mp->m_dir_geo, bp->b_addr);if (!endp) {xchk_fblock_set_corrupt (ds->sc,XFS_DATA_FORK , rec_bno);
@@ -391,7 +391,7 @@ xchk_directory_data_bestfree( }/* Make sure the bestfrees are actually the best free spaces. */ - ptr = bp->b_addr + d_ops->data_entry_offset; + ptr = bp->b_addr + mp->m_dir_geo->data_entry_offset; endptr =xfs_dir3_data_endp (mp->m_dir_geo, bp->b_addr);/* Iterate the entries, stopping when we hit or go past the end. */
fs/xfs/xfs_dir2_readdir.c +5 -8
@@ -71,14 +71,11 @@ xfs_dir2_sf_getdents(/* * Precalculate offsets for . and .. as we will always need them. -* -* XXX(hch): the second argument is sometimes 0 and sometimes -* geo->datablk */ dot_offset =xfs_dir2_db_off_to_dataptr (geo, geo->datablk, - dp->d_ops->data_dot_offset); + geo->data_dot_offset); dotdot_offset =xfs_dir2_db_off_to_dataptr (geo, geo->datablk, - dp->d_ops->data_dotdot_offset); + geo->data_dotdot_offset);/* * Put . entry unless we're starting past it.
@@ -176,7 +173,7 @@ xfs_dir2_block_getdents(/* * Set up values for the loop. */ - ptr = (char *)hdr + dp->d_ops->data_entry_offset; + ptr = (char *)hdr + geo->data_entry_offset; endptr =xfs_dir3_data_endp (geo, hdr);/*
@@ -411,13 +408,13 @@ xfs_dir2_leaf_getdents(/* * Find our position in the block. */ - ptr = (char *)hdr + dp->d_ops->data_entry_offset; + ptr = (char *)hdr + geo->data_entry_offset; byteoff =xfs_dir2_byte_to_off (geo, curoff);/* * Skip past the header. */ if (byteoff ==0 ) - curoff += dp->d_ops->data_entry_offset; + curoff += geo->data_entry_offset;/* * Skip past entries until we reach our offset. */
Signature · 1 line
2.20.1
Re: [PATCH 28/34] xfs: move the dir2 data block fixed offsets to struct xfs_da_geometry
Quoted 4 lines · Christoph Hellwig
Move the data block fixed offsets towards our structure for dir/attr geometry parameters.
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 550 lines
--- fs/xfs/libxfs/xfs_da_btree.h | 5 +++++ fs/xfs/libxfs/xfs_da_format.c | 24 ------------------------ fs/xfs/libxfs/xfs_dir2.c | 9 +++++++++ fs/xfs/libxfs/xfs_dir2.h | 5 ----- fs/xfs/libxfs/xfs_dir2_block.c | 11 ++++++----- fs/xfs/libxfs/xfs_dir2_data.c | 18 +++++++++--------- fs/xfs/libxfs/xfs_dir2_leaf.c | 22 ++++++++++++---------- fs/xfs/libxfs/xfs_dir2_node.c | 24 +++++++++++------------- fs/xfs/libxfs/xfs_dir2_sf.c | 16 +++++----------- fs/xfs/scrub/dir.c | 4 ++-- fs/xfs/xfs_dir2_readdir.c | 13 +++++-------- 11 files changed, 64 insertions(+), 87 deletions(-)fs/xfs/libxfs/xfs_da_btree.h +5
-0@@ -32,6 +32,11 @@ struct xfs_da_geometry {int free_hdr_size;/* dir2 free header size */ unsigned int free_max_bests;/* # of bests entries in dir2 free */ xfs_dablk_t freeblk;/* blockno of free data v2 */ + +xfs_dir2_data_aoff_t data_dot_offset; +xfs_dir2_data_aoff_t data_dotdot_offset; +xfs_dir2_data_aoff_t data_first_offset; +size_t data_entry_offset; };/*======================================================================== fs/xfs/libxfs/xfs_da_format.c +0
-24@@ -105,42 +105,18 @@ static const struct xfs_dir_ops xfs_dir2_ops = { .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype, .data_bestfree_p = xfs_dir2_data_bestfree_p, - - .data_dot_offset = sizeof(struct xfs_dir2_data_hdr), - .data_dotdot_offset =sizeof (struct xfs_dir2_data_hdr ) + - XFS_DIR2_DATA_ENTSIZE(1), - .data_first_offset =sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR2_DATA_ENTSIZE (1 ) + - XFS_DIR2_DATA_ENTSIZE(2), - .data_entry_offset = sizeof(struct xfs_dir2_data_hdr), };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, .data_bestfree_p = xfs_dir2_data_bestfree_p, - - .data_dot_offset =sizeof (struct xfs_dir2_data_hdr ), - .data_dotdot_offset =sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ), - .data_first_offset =sizeof (struct xfs_dir2_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ) + -XFS_DIR3_DATA_ENTSIZE (2 ), - .data_entry_offset =sizeof (struct xfs_dir2_data_hdr ), };static const struct xfs_dir_ops xfs_dir3_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, .data_bestfree_p = xfs_dir3_data_bestfree_p, - - .data_dot_offset =sizeof (struct xfs_dir3_data_hdr ), - .data_dotdot_offset =sizeof (struct xfs_dir3_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ), - .data_first_offset =sizeof (struct xfs_dir3_data_hdr ) + -XFS_DIR3_DATA_ENTSIZE (1 ) + -XFS_DIR3_DATA_ENTSIZE (2 ), - .data_entry_offset =sizeof (struct xfs_dir3_data_hdr ), };/* fs/xfs/libxfs/xfs_dir2.c +9
-0@@ -126,16 +126,25 @@ xfs_da_mount( dageo->node_hdr_size =sizeof (struct xfs_da3_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir3_leaf_hdr ); dageo->free_hdr_size =sizeof (struct xfs_dir3_free_hdr ); + dageo->data_entry_offset = dageo->data_dot_offset = +sizeof (struct xfs_dir3_data_hdr ); }else { dageo->node_hdr_size =sizeof (struct xfs_da_node_hdr ); dageo->leaf_hdr_size =sizeof (struct xfs_dir2_leaf_hdr ); dageo->free_hdr_size =sizeof (struct xfs_dir2_free_hdr ); + dageo->data_entry_offset = dageo->data_dot_offset = +sizeof (struct xfs_dir2_data_hdr ); } dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) /sizeof (struct xfs_dir2_leaf_entry ); dageo->free_max_bests = (dageo->blksize - dageo->free_hdr_size) /sizeof (xfs_dir2_data_off_t); + dageo->data_dotdot_offset = dageo->data_dot_offset + +xfs_dir2_data_entsize (mp,1 ); + dageo->data_first_offset = dageo->data_dotdot_offset + +xfs_dir2_data_entsize (mp,2 ); +/* * Now we've set up the block conversion variables, we can calculate the * segment block constants using the geometry structure. fs/xfs/libxfs/xfs_dir2.h +0
-5@@ -37,11 +37,6 @@ struct xfs_dir_ops { uint8_t ftype);struct xfs_dir2_data_free * (*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr); - -xfs_dir2_data_aoff_t data_dot_offset; -xfs_dir2_data_aoff_t data_dotdot_offset; -xfs_dir2_data_aoff_t data_first_offset; -size_t data_entry_offset; }; extern const struct xfs_dir_ops *fs/xfs/libxfs/xfs_dir2_block.c +6
-5@@ -937,7 +937,7 @@ xfs_dir2_leaf_to_block(while (dp->i_d.di_size > args->geo->blksize) {int hdrsz; - hdrsz = dp->d_ops->data_entry_offset; + hdrsz = args->geo->data_entry_offset; bestsp =xfs_dir2_leaf_bests_p (ltp);if (be16_to_cpu (bestsp[be32_to_cpu (ltp->bestcount) -1 ]) == args->geo->blksize - hdrsz) {@@ -1041,6 +1041,7 @@ int /* error */xfs_dir2_sf_to_block ( xfs_da_args_t *args) /* operation arguments */ { +struct xfs_da_geometry *geo = args->geo;xfs_dir2_db_t blkno;/* dir-relative block # (0) */ xfs_dir2_data_hdr_t *hdr;/* block header */ xfs_dir2_leaf_entry_t *blp;/* block leaf entries */ @@ -1123,7 +1124,7 @@ xfs_dir2_sf_to_block(* The whole thing is initialized to free by the init routine. * Say we're using the leaf and tail area. */ - dup = (void *)hdr + dp->d_ops->data_entry_offset; + dup = (void *)hdr + args->geo->data_entry_offset; needlog = needscan =0 ; error =xfs_dir2_data_use_free (args, bp, dup, args->geo->blksize - i, i, &needlog, &needscan);@@ -1149,7 +1150,7 @@ xfs_dir2_sf_to_block(/* * Create entry for . */ - dep = (void *)hdr + dp->d_ops->data_dot_offset; + dep = (void *)hdr + geo->data_dot_offset; dep->inumber =cpu_to_be64 (dp->i_ino); dep->namelen =1 ; dep->name[0 ] ='.' ;@@ -1163,7 +1164,7 @@ xfs_dir2_sf_to_block(/* * Create entry for .. */ - dep = (void *)hdr + dp->d_ops->data_dotdot_offset; + dep = (void *)hdr + geo->data_dotdot_offset; dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_parent_ino (sfp)); dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ;@@ -1174,7 +1175,7 @@ xfs_dir2_sf_to_block( blp[1 ].hashval =cpu_to_be32 (xfs_dir_hash_dotdot); blp[1 ].address =cpu_to_be32 (xfs_dir2_byte_to_dataptr ( (char *)dep - (char *)hdr)); - offset = dp->d_ops->data_first_offset; + offset = geo->data_first_offset;/* * Loop over existing entries, stuff them in. */ fs/xfs/libxfs/xfs_dir2_data.c +9
-9@@ -84,7 +84,7 @@ __xfs_dir3_data_check(return __this_address; hdr = bp->b_addr; - p = (char *)hdr + ops->data_entry_offset; + p = (char *)hdr + geo->data_entry_offset;switch (hdr->magic) {case cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC ):@@ -580,6 +580,7 @@ xfs_dir2_data_freescan_int(struct xfs_dir2_data_hdr *hdr, int *loghead) { + struct xfs_da_geometry *geo = mp->m_dir_geo;xfs_dir2_data_entry_t *dep;/* active data entry */ xfs_dir2_data_unused_t *dup;/* unused data entry */ struct xfs_dir2_data_free *bf;@@ -600,8 +601,8 @@ xfs_dir2_data_freescan_int(/* * Set up pointers. */ - p = (char *)hdr + ops->data_entry_offset; - endp =xfs_dir3_data_endp (mp->m_dir_geo, hdr); + p = (char *)hdr + geo->data_entry_offset; + endp =xfs_dir3_data_endp (geo, hdr);/* * Loop over the block's entries. */ @@ -689,7 +690,7 @@ xfs_dir3_data_init( hdr->magic =cpu_to_be32 (XFS_DIR2_DATA_MAGIC ); bf = dp->d_ops->data_bestfree_p (hdr); - bf[0 ].offset =cpu_to_be16 (dp->d_ops->data_entry_offset); + bf[0 ].offset =cpu_to_be16 (args->geo->data_entry_offset);for (i =1 ; i <XFS_DIR2_DATA_FD_COUNT ; i++) { bf[i].length =0 ; bf[i].offset =0 ;@@ -698,10 +699,10 @@ xfs_dir3_data_init(/* * Set up an unused entry for the block's body. */ - dup = (void *)hdr + dp->d_ops->data_entry_offset; + dup = (void *)hdr + args->geo->data_entry_offset; dup->freetag =cpu_to_be16 (XFS_DIR2_DATA_FREE_TAG ); - t = args->geo->blksize - (uint )dp->d_ops->data_entry_offset; + t = args->geo->blksize - args->geo->data_entry_offset; bf[0 ].length =cpu_to_be16 (t); dup->length =cpu_to_be16 (t); *xfs_dir2_data_unused_tag_p (dup) =cpu_to_be16 ((char *)dup - (char *)hdr);@@ -753,8 +754,7 @@ xfs_dir2_data_log_header( hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));#endif -xfs_trans_log_buf (args->trans, bp,0 , - args->dp->d_ops->data_entry_offset -1 ); +xfs_trans_log_buf (args->trans, bp,0 , args->geo->data_entry_offset -1 ); }/* @@ -822,7 +822,7 @@ xfs_dir2_data_make_free(* If this isn't the start of the block, then back up to * the previous entry and see if it's free. */ -if (offset > args->dp->d_ops->data_entry_offset) { +if (offset > args->geo->data_entry_offset) {__be16 *tagp;/* tag just before us */ tagp = (__be16 *)((char *)hdr + offset) -1 ;fs/xfs/libxfs/xfs_dir2_leaf.c +12
-10@@ -1343,6 +1343,7 @@ int /* error */xfs_dir2_leaf_removename ( xfs_da_args_t *args) /* operation arguments */ { +struct xfs_da_geometry *geo = args->geo;__be16 *bestsp;/* leaf block best freespace */ xfs_dir2_data_hdr_t *hdr;/* data block header */ xfs_dir2_db_t db;/* data block number */ @@ -1381,12 +1382,12 @@ xfs_dir2_leaf_removename(* Point to the leaf entry, use that to point to the data entry. */ lep = &leafhdr.ents[index]; - db =xfs_dir2_dataptr_to_db (args->geo,be32_to_cpu (lep->address)); + db =xfs_dir2_dataptr_to_db (geo,be32_to_cpu (lep->address)); dep = (xfs_dir2_data_entry_t *)((char *)hdr + -xfs_dir2_dataptr_to_off (args->geo,be32_to_cpu (lep->address))); +xfs_dir2_dataptr_to_off (geo,be32_to_cpu (lep->address))); needscan = needlog =0 ; oldbest =be16_to_cpu (bf[0 ].length); - ltp =xfs_dir2_leaf_tail_p (args->geo, leaf); + ltp =xfs_dir2_leaf_tail_p (geo, leaf); bestsp =xfs_dir2_leaf_bests_p (ltp);if (be16_to_cpu (bestsp[db]) != oldbest)return -EFSCORRUPTED ;@@ -1428,8 +1429,8 @@ xfs_dir2_leaf_removename(* If the data block is now empty then get rid of the data block. */ if (be16_to_cpu (bf[0 ].length) == - args->geo->blksize - dp->d_ops->data_entry_offset) { -ASSERT (db != args->geo->datablk); + geo->blksize - geo->data_entry_offset) { +ASSERT (db != geo->datablk);if ((error =xfs_dir2_shrink_inode (args, db, dbp))) {/* * Nope, can't get rid of it because it caused @@ -1471,7 +1472,7 @@ xfs_dir2_leaf_removename(/* * If the data block was not the first one, drop it. */ - else if (db != args->geo->datablk) + else if (db != geo->datablk) dbp =NULL ;xfs_dir3_leaf_check (dp, lbp);@@ -1592,6 +1593,7 @@ xfs_dir2_leaf_trim_data( struct xfs_buf *lbp, /* leaf buffer */ xfs_dir2_db_t db) /* data block number */ { +struct xfs_da_geometry *geo = args->geo;__be16 *bestsp;/* leaf bests table */ struct xfs_buf *dbp;/* data block buffer */ xfs_inode_t *dp;/* incore directory inode */ @@ -1605,13 +1607,13 @@ xfs_dir2_leaf_trim_data(/* * Read the offending data block. We need its buffer. */ - error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (args->geo, db), --1 , &dbp); + error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (geo, db),-1 , + &dbp);if (error)return error; leaf = lbp->b_addr; - ltp =xfs_dir2_leaf_tail_p (args->geo, leaf); + ltp =xfs_dir2_leaf_tail_p (geo, leaf);#ifdef DEBUG {@@ -1621,7 +1623,7 @@ xfs_dir2_leaf_trim_data(ASSERT (hdr->magic ==cpu_to_be32 (XFS_DIR2_DATA_MAGIC ) || hdr->magic ==cpu_to_be32 (XFS_DIR3_DATA_MAGIC ));ASSERT (be16_to_cpu (bf[0 ].length) == - args->geo->blksize - dp->d_ops->data_entry_offset); + geo->blksize - geo->data_entry_offset); ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); }#endif fs/xfs/libxfs/xfs_dir2_node.c +11
-13@@ -1257,6 +1257,7 @@ xfs_dir2_leafn_remove( xfs_da_state_blk_t *dblk, /* data block */ int *rval) /* resulting block needs join */ { +struct xfs_da_geometry *geo = args->geo;xfs_dir2_data_hdr_t *hdr;/* data block header */ xfs_dir2_db_t db;/* data block number */ struct xfs_buf *dbp;/* data block buffer */ @@ -1287,9 +1288,9 @@ xfs_dir2_leafn_remove(/* * Extract the data block and offset from the entry. */ - db =xfs_dir2_dataptr_to_db (args->geo,be32_to_cpu (lep->address)); + db =xfs_dir2_dataptr_to_db (geo,be32_to_cpu (lep->address));ASSERT (dblk->blkno == db); - off =xfs_dir2_dataptr_to_off (args->geo,be32_to_cpu (lep->address)); + off =xfs_dir2_dataptr_to_off (geo,be32_to_cpu (lep->address));ASSERT (dblk->index == off);/* @@ -1340,9 +1341,8 @@ xfs_dir2_leafn_remove(* Convert the data block number to a free block, * read in the free block. */ - fdb =xfs_dir2_db_to_fdb (args->geo, db); - error =xfs_dir2_free_read (tp, dp, -xfs_dir2_db_to_da (args->geo, fdb), + fdb =xfs_dir2_db_to_fdb (geo, db); + error =xfs_dir2_free_read (tp, dp,xfs_dir2_db_to_da (geo, fdb), &fbp);if (error)return error;@@ -1352,22 +1352,20 @@ xfs_dir2_leafn_remove(struct xfs_dir3_icfree_hdr freehdr;xfs_dir2_free_hdr_from_disk (dp->i_mount, &freehdr, free); -ASSERT (freehdr.firstdb == args->geo->free_max_bests * - (fdb -xfs_dir2_byte_to_db (args->geo, - XFS_DIR2_FREE_OFFSET))); +ASSERT (freehdr.firstdb == geo->free_max_bests * + (fdb - xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET))); }#endif /* * Calculate which entry we need to fix. */ - findex =xfs_dir2_db_to_fdindex (args->geo, db); + findex =xfs_dir2_db_to_fdindex (geo, db); longest =be16_to_cpu (bf[0 ].length);/* * If the data block is now empty we can get rid of it * (usually). */ -if (longest == args->geo->blksize - - dp->d_ops->data_entry_offset) { +if (longest == geo->blksize - geo->data_entry_offset) {/* * Try to punch out the data block. */ @@ -1399,9 +1397,9 @@ xfs_dir2_leafn_remove(* Return indication of whether this leaf block is empty enough * to justify trying to join it with a neighbor. */ - *rval = (args->geo->leaf_hdr_size + + *rval = (geo->leaf_hdr_size + (uint )sizeof (leafhdr.ents) * (leafhdr.count - leafhdr.stale)) < - args->geo->magicpct; + geo->magicpct;return 0 ; }fs/xfs/libxfs/xfs_dir2_sf.c +5
-11@@ -296,7 +296,7 @@ xfs_dir2_block_to_sf(/* * Set up to loop over the block's entries. */ - ptr = (char *)hdr + dp->d_ops->data_entry_offset; + ptr = (char *)hdr + args->geo->data_entry_offset; endptr =xfs_dir3_data_endp (args->geo, hdr); sfep =xfs_dir2_sf_firstentry (sfp);/* @@ -562,7 +562,7 @@ xfs_dir2_sf_addname_hard(* to insert the new entry. * If it's going to end up at the end then oldsfep will point there. */ - for (offset = dp->d_ops->data_first_offset, + for (offset = args->geo->data_first_offset, oldsfep = xfs_dir2_sf_firstentry(oldsfp), add_datasize = xfs_dir2_data_entsize(mp, args->namelen), eof = (char *)oldsfep == &buf[old_isize];@@ -640,7 +640,7 @@ xfs_dir2_sf_addname_pick( sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; size =xfs_dir2_data_entsize (mp, args->namelen); - offset = dp->d_ops->data_first_offset; + offset = args->geo->data_first_offset; sfep =xfs_dir2_sf_firstentry (sfp); holefit =0 ;/* @@ -705,7 +705,7 @@ xfs_dir2_sf_check(xfs_dir2_sf_hdr_t *sfp;/* shortform structure */ sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - offset = dp->d_ops->data_first_offset; + offset = args->geo->data_first_offset; ino =xfs_dir2_sf_get_parent_ino (sfp); i8count = ino >XFS_DIR2_MAX_SHORT_INUM ;@@ -738,7 +738,6 @@ xfs_dir2_sf_verify(struct xfs_dir2_sf_entry *sfep;struct xfs_dir2_sf_entry *next_sfep;char *endp; -const struct xfs_dir_ops *dops;struct xfs_ifork *ifp;xfs_ino_t ino;int i;@@ -749,11 +748,6 @@ xfs_dir2_sf_verify(uint8_t filetype;ASSERT (ip->i_d.di_format ==XFS_DINODE_FMT_LOCAL ); -/* -* xfs_iread calls us before xfs_setup_inode sets up ip->d_ops, -* so we can only trust the mountpoint to have the right pointer. -*/ - dops =xfs_dir_get_ops (mp,NULL ); ifp =XFS_IFORK_PTR (ip,XFS_DATA_FORK ); sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data;@@ -774,7 +768,7 @@ xfs_dir2_sf_verify( error =xfs_dir_ino_validate (mp, ino);if (error)return __this_address; - offset = dops->data_first_offset; + offset = mp->m_dir_geo->data_first_offset;/* Check all reported entries */ sfep =xfs_dir2_sf_firstentry (sfp);fs/xfs/scrub/dir.c +2
-2@@ -241,7 +241,7 @@ xchk_dir_rec( dent = (struct xfs_dir2_data_entry *)(((char *)bp->b_addr) + off);/* Make sure we got a real directory entry. */ - p = bp->b_addr + mp->m_dir_inode_ops->data_entry_offset; + p = bp->b_addr + mp->m_dir_geo->data_entry_offset; endp =xfs_dir3_data_endp (mp->m_dir_geo, bp->b_addr);if (!endp) {xchk_fblock_set_corrupt (ds->sc,XFS_DATA_FORK , rec_bno);@@ -391,7 +391,7 @@ xchk_directory_data_bestfree( }/* Make sure the bestfrees are actually the best free spaces. */ - ptr = bp->b_addr + d_ops->data_entry_offset; + ptr = bp->b_addr + mp->m_dir_geo->data_entry_offset; endptr =xfs_dir3_data_endp (mp->m_dir_geo, bp->b_addr);/* Iterate the entries, stopping when we hit or go past the end. */ fs/xfs/xfs_dir2_readdir.c +5
-8@@ -71,14 +71,11 @@ xfs_dir2_sf_getdents(/* * Precalculate offsets for . and .. as we will always need them. -* -* XXX(hch): the second argument is sometimes 0 and sometimes -* geo->datablk */ dot_offset =xfs_dir2_db_off_to_dataptr (geo, geo->datablk, - dp->d_ops->data_dot_offset); + geo->data_dot_offset); dotdot_offset =xfs_dir2_db_off_to_dataptr (geo, geo->datablk, - dp->d_ops->data_dotdot_offset); + geo->data_dotdot_offset);/* * Put . entry unless we're starting past it. @@ -176,7 +173,7 @@ xfs_dir2_block_getdents(/* * Set up values for the loop. */ - ptr = (char *)hdr + dp->d_ops->data_entry_offset; + ptr = (char *)hdr + geo->data_entry_offset; endptr =xfs_dir3_data_endp (geo, hdr);/* @@ -411,13 +408,13 @@ xfs_dir2_leaf_getdents(/* * Find our position in the block. */ - ptr = (char *)hdr + dp->d_ops->data_entry_offset; + ptr = (char *)hdr + geo->data_entry_offset; byteoff =xfs_dir2_byte_to_off (geo, curoff);/* * Skip past the header. */ if (byteoff ==0 ) - curoff += dp->d_ops->data_entry_offset; + curoff += geo->data_entry_offset;/* * Skip past entries until we reach our offset. */ Signature · 1 line
2.20.1
PATCH 29/34 xfs: cleanup xfs_dir2_data_entsize
In reply to Christoph HellwigRemove the XFS_DIR2_DATA_ENTSIZE and XFS_DIR3_DATA_ENTSIZE and open code them in their only caller.
--- fs/xfs/libxfs/xfs_da_format.c | 33 --------------------------------- fs/xfs/libxfs/xfs_dir2_data.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 33 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -33
@@ -19,39 +19,6 @@* Directory data block operations */ -/* -* For special situations, the dirent size ends up fixed because we always know -* what the size of the entry is. That's true for the "." and "..", and -* therefore we know that they are a fixed size and hence their offsets are -* constant, as is the first entry. -* -* Hence, this calculation is written as a macro to be able to be calculated at -* compile time and so certain offsets can be calculated directly in the -* structure initaliser via the macro. There are two macros - one for dirents -* with ftype and without so there are no unresolvable conditionals in the -* calculations. We also use round_up() as XFS_DIR2_DATA_ALIGN is always a power -* of 2 and the compiler doesn't reject it (unlike roundup()). -*/ -#define XFS_DIR2_DATA_ENTSIZE (n) \ - round_up((offsetof(struct xfs_dir2_data_entry, name[0]) + (n) + \ - sizeof(xfs_dir2_data_off_t)), XFS_DIR2_DATA_ALIGN) - -#define XFS_DIR3_DATA_ENTSIZE (n) \ - round_up((offsetof(struct xfs_dir2_data_entry, name[0]) + (n) + \ - sizeof(xfs_dir2_data_off_t) + sizeof(uint8_t)), \ - XFS_DIR2_DATA_ALIGN) - -int -xfs_dir2_data_entsize ( -struct xfs_mount *mp, -int n) -{ -if (xfs_sb_version_hasftype (&mp->m_sb)) -return XFS_DIR3_DATA_ENTSIZE (n); -else -return XFS_DIR2_DATA_ENTSIZE (n); -} -static uint8_t xfs_dir2_data_get_ftype (struct xfs_dir2_data_entry *dep)
fs/xfs/libxfs/xfs_dir2_data.c +14 -0
@@ -24,6 +24,20 @@ static xfs_failaddr_t xfs_dir2_data_freefind_verify(struct xfs_dir2_data_unused *dup, struct xfs_dir2_data_free **bf_ent); +int +xfs_dir2_data_entsize ( +struct xfs_mount *mp, +int namelen) +{ +size_t len; + + len = offsetof(struct xfs_dir2_data_entry, name[0]) + namelen + +sizeof (xfs_dir2_data_off_t)/* tag */ ; +if (xfs_sb_version_hasftype (&mp->m_sb)) + len +=sizeof (uint8_t ); +return round_up (len,XFS_DIR2_DATA_ALIGN ); +} +/* * Pointer to an entry's tag word. */
Signature · 1 line
2.20.1
Re: [PATCH 29/34] xfs: cleanup xfs_dir2_data_entsize
Quoted 4 lines · Christoph Hellwig
Remove the
XFS_DIR2_DATA_ENTSIZEandXFS_DIR3_DATA_ENTSIZEand open code them in their only caller.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 77 lines
--- fs/xfs/libxfs/xfs_da_format.c | 33 --------------------------------- fs/xfs/libxfs/xfs_dir2_data.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 33 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-33@@ -19,39 +19,6 @@* Directory data block operations */ -/* -* For special situations, the dirent size ends up fixed because we always know -* what the size of the entry is. That's true for the "." and "..", and -* therefore we know that they are a fixed size and hence their offsets are -* constant, as is the first entry. -* -* Hence, this calculation is written as a macro to be able to be calculated at -* compile time and so certain offsets can be calculated directly in the -* structure initaliser via the macro. There are two macros - one for dirents -* with ftype and without so there are no unresolvable conditionals in the -* calculations. We also use round_up() as XFS_DIR2_DATA_ALIGN is always a power -* of 2 and the compiler doesn't reject it (unlike roundup()). -*/ -#define XFS_DIR2_DATA_ENTSIZE (n) \ - round_up((offsetof(struct xfs_dir2_data_entry, name[0]) + (n) + \ - sizeof(xfs_dir2_data_off_t)), XFS_DIR2_DATA_ALIGN) - -#define XFS_DIR3_DATA_ENTSIZE (n) \ - round_up((offsetof(struct xfs_dir2_data_entry, name[0]) + (n) + \ - sizeof(xfs_dir2_data_off_t) + sizeof(uint8_t)), \ - XFS_DIR2_DATA_ALIGN) - -int -xfs_dir2_data_entsize ( -struct xfs_mount *mp, -int n) -{ -if (xfs_sb_version_hasftype (&mp->m_sb)) -return XFS_DIR3_DATA_ENTSIZE (n); -else -return XFS_DIR2_DATA_ENTSIZE (n); -} -static uint8_t xfs_dir2_data_get_ftype (struct xfs_dir2_data_entry *dep)fs/xfs/libxfs/xfs_dir2_data.c +14
-0@@ -24,6 +24,20 @@ static xfs_failaddr_t xfs_dir2_data_freefind_verify(struct xfs_dir2_data_unused *dup, struct xfs_dir2_data_free **bf_ent); +int +xfs_dir2_data_entsize ( +struct xfs_mount *mp, +int namelen) +{ +size_t len; + + len = offsetof(struct xfs_dir2_data_entry, name[0]) + namelen + +sizeof (xfs_dir2_data_off_t)/* tag */ ; +if (xfs_sb_version_hasftype (&mp->m_sb)) + len +=sizeof (uint8_t ); +return round_up (len,XFS_DIR2_DATA_ALIGN ); +} +/* * Pointer to an entry's tag word. */ Signature · 1 line
2.20.1