clean up the dabuf mappedbno interface v2
Hi all,
this (lightly tested) series cleanups the strange mappedbno argument to various dabuf helpers. If that argument has a positive value it is used as xfs_daddr_t to get/read the block, and otherwise it is overloaded for a flag. This series splits out the users that have a xfs_daddr_t to just use the buffer interfaces directly, and the replaces the magic with a flags argument and one properly named flag.
Changes since v1:
- return *nmaps = 0 for holes from xfs_dabuf_map
- add a new patch to refactor xfs_dabuf_map
PATCH 1/10 xfs: simplify mappedbno handling in xfs_da_{get,read}_buf
Shortcut the creation of xfs_bmbt_irec and xfs_buf_map for the case where the callers passed an already mapped xfs_daddr_t. This is in preparation for splitting these cases out entirely later. Also reject the mappedbno case for xfs_da_reada_buf as no callers currently uses it and it will be removed soon.
--- fs/xfs/libxfs/xfs_da_btree.c | 103 +++++++++++++++++------------------ 1 file changed, 51 insertions(+), 52 deletions(-)
fs/xfs/libxfs/xfs_da_btree.c +51 -52
@@ -110,6 +110,13 @@ xfs_da_state_free(xfs_da_state_t *state)kmem_cache_free (xfs_da_state_zone, state); } +static inline int xfs_dabuf_nfsb (struct xfs_mount *mp,int whichfork) +{ +if (whichfork ==XFS_DATA_FORK ) +return mp->m_dir_geo->fsbcount; +return mp->m_attr_geo->fsbcount; +} + void xfs_da3_node_hdr_from_disk( struct xfs_mount *mp,
@@ -2539,7 +2546,7 @@ xfs_dabuf_map( int *nmaps) {struct xfs_mount *mp = dp->i_mount; -int nfsb; +int nfsb =xfs_dabuf_nfsb (mp, whichfork);int error =0 ;struct xfs_bmbt_irec irec;struct xfs_bmbt_irec *irecs = &irec;
@@ -2548,35 +2555,13 @@ xfs_dabuf_map(ASSERT (map && *map);ASSERT (*nmaps ==1 ); -if (whichfork ==XFS_DATA_FORK ) - nfsb = mp->m_dir_geo->fsbcount; -else - nfsb = mp->m_attr_geo->fsbcount; - -/* -* Caller doesn't have a mapping. -2 means don't complain -* if we land in a hole. -*/ -if (mappedbno ==-1 || mappedbno ==-2 ) { -/* -* Optimize the one-block case. -*/ -if (nfsb !=1 ) - irecs =kmem_zalloc (sizeof (irec) * nfsb, -KM_NOFS ); - - nirecs = nfsb; - error =xfs_bmapi_read (dp, (xfs_fileoff_t )bno, nfsb, irecs, - &nirecs,xfs_bmapi_aflag (whichfork)); -if (error) - goto out; - }else { - irecs->br_startblock =XFS_DADDR_TO_FSB (mp, mappedbno); - irecs->br_startoff = (xfs_fileoff_t )bno; - irecs->br_blockcount = nfsb; - irecs->br_state =0 ; - nirecs =1 ; - } +if (nfsb !=1 ) + irecs =kmem_zalloc (sizeof (irec) * nfsb,KM_NOFS ); + nirecs = nfsb; + error =xfs_bmapi_read (dp, (xfs_fileoff_t )bno, nfsb, irecs, + &nirecs,xfs_bmapi_aflag (whichfork)); +if (error) + goto out;if (!xfs_da_map_covers_blocks (nirecs, irecs, bno, nfsb)) {/* Caller ok with no mapping. */
@@ -2616,24 +2601,29 @@ xfs_dabuf_map(*/ int xfs_da_get_buf ( -struct xfs_trans *trans, +struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t bno,xfs_daddr_t mappedbno,struct xfs_buf **bpp,int whichfork) { +struct xfs_mount *mp = dp->i_mount;struct xfs_buf *bp; -struct xfs_buf_map map; -struct xfs_buf_map *mapp; -int nmap; +struct xfs_buf_map map, *mapp = ↦ +int nmap =1 ;int error; *bpp =NULL ; - mapp = ↦ - nmap =1 ; - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, - &mapp, &nmap); + +if (mappedbno >=0 ) { + bp =xfs_trans_get_buf (tp, mp->m_ddev_targp, mappedbno, +XFS_FSB_TO_BB (mp, +xfs_dabuf_nfsb (mp, whichfork)),0 ); + goto done; + } + + error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap);if (error) {/* mapping a hole is not an error, but we don't continue */ if (error ==-1 )
@@ -2641,12 +2631,12 @@ xfs_da_get_buf( goto out_free; } - bp =xfs_trans_get_buf_map (trans, dp->i_mount->m_ddev_targp, - mapp, nmap,0 ); + bp =xfs_trans_get_buf_map (tp, mp->m_ddev_targp, mapp, nmap,0 ); +done: error = bp ? bp->b_error : -EIO ;if (error) {if (bp) -xfs_trans_brelse (trans, bp); +xfs_trans_brelse (tp, bp); goto out_free; }
@@ -2664,7 +2654,7 @@ xfs_da_get_buf(*/ int xfs_da_read_buf( - struct xfs_trans *trans, + struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t bno, xfs_daddr_t mappedbno,
@@ -2672,17 +2662,23 @@ xfs_da_read_buf(int whichfork, const struct xfs_buf_ops *ops) { + struct xfs_mount *mp = dp->i_mount;struct xfs_buf *bp; -struct xfs_buf_map map; -struct xfs_buf_map *mapp; -int nmap; +struct xfs_buf_map map, *mapp = ↦ +int nmap =1 ;int error; *bpp =NULL ; - mapp = ↦ - nmap =1 ; - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, - &mapp, &nmap); + +if (mappedbno >=0 ) { + error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, + mappedbno,XFS_FSB_TO_BB (mp, +xfs_dabuf_nfsb (mp, whichfork)), +0 , &bp, ops); + goto done; + } + + error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap);if (error) {/* mapping a hole is not an error, but we don't continue */ if (error ==-1 )
@@ -2690,9 +2686,9 @@ xfs_da_read_buf( goto out_free; } - error =xfs_trans_read_buf_map (dp->i_mount, trans, - dp->i_mount->m_ddev_targp, - mapp, nmap,0 , &bp, ops); + error =xfs_trans_read_buf_map (mp, tp, mp->m_ddev_targp, mapp, nmap,0 , + &bp, ops); +done:if (error) goto out_free;
@@ -2724,6 +2720,9 @@ xfs_da_reada_buf(int nmap;int error; +if (mappedbno >=0 ) +return -EINVAL ; + mapp = ↦ nmap =1 ; error = xfs_dabuf_map(dp, bno, mappedbno, whichfork,
Signature · 1 line
2.20.1
PATCH 2/10 xfs: refactor xfs_dabuf_map
In reply to Christoph HellwigMerge xfs_buf_map_from_irec and xfs_da_map_covers_blocks into a single loop in the caller.
--- fs/xfs/libxfs/xfs_da_btree.c | 156 ++++++++++++----------------------- 1 file changed, 54 insertions(+), 102 deletions(-)
fs/xfs/libxfs/xfs_da_btree.c +54 -102
@@ -2460,74 +2460,6 @@ xfs_da_shrink_inode(return error; } -/* -* See if the mapping(s) for this btree block are valid, i.e. -* don't contain holes, are logically contiguous, and cover the whole range. -*/ -STATIC int -xfs_da_map_covers_blocks ( -int nmap, -xfs_bmbt_irec_t *mapp, -xfs_dablk_t bno, -int count) -{ -int i; -xfs_fileoff_t off; - -for (i =0 , off = bno; i < nmap; i++) { -if (mapp[i].br_startblock ==HOLESTARTBLOCK || - mapp[i].br_startblock ==DELAYSTARTBLOCK ) { -return 0 ; - } -if (off != mapp[i].br_startoff) { -return 0 ; - } - off += mapp[i].br_blockcount; - } -return off == bno + count; -} - -/* -* Convert a struct xfs_bmbt_irec to a struct xfs_buf_map. -* -* For the single map case, it is assumed that the caller has provided a pointer -* to a valid xfs_buf_map. For the multiple map case, this function will -* allocate the xfs_buf_map to hold all the maps and replace the caller's single -* map pointer with the allocated map. -*/ -static int -xfs_buf_map_from_irec ( -struct xfs_mount *mp, -struct xfs_buf_map **mapp, -int *nmaps, -struct xfs_bmbt_irec *irecs, -int nirecs) -{ -struct xfs_buf_map *map; -int i; - -ASSERT (*nmaps ==1 ); -ASSERT (nirecs >=1 ); - -if (nirecs >1 ) { - map =kmem_zalloc (nirecs *sizeof (struct xfs_buf_map ), -KM_NOFS ); -if (!map) -return -ENOMEM ; - *mapp = map; - } - - *nmaps = nirecs; - map = *mapp; -for (i =0 ; i < *nmaps; i++) { -ASSERT (irecs[i].br_startblock !=DELAYSTARTBLOCK && - irecs[i].br_startblock !=HOLESTARTBLOCK ); - map[i].bm_bn =XFS_FSB_TO_DADDR (mp, irecs[i].br_startblock); - map[i].bm_len =XFS_FSB_TO_BB (mp, irecs[i].br_blockcount); - } -return 0 ; -} -/* * Map the block we are given ready for reading. There are three possible return * values:
@@ -2542,58 +2474,78 @@ xfs_dabuf_map(xfs_dablk_t bno, xfs_daddr_t mappedbno, int whichfork, - struct xfs_buf_map **map, + struct xfs_buf_map **mapp, int *nmaps) { struct xfs_mount *mp = dp->i_mount;int nfsb =xfs_dabuf_nfsb (mp, whichfork); -int error =0 ; -struct xfs_bmbt_irec irec; -struct xfs_bmbt_irec *irecs = &irec; -int nirecs; - -ASSERT (map && *map); -ASSERT (*nmaps ==1 ); +struct xfs_bmbt_irec irec, *irecs = &irec; +struct xfs_buf_map *map = *mapp; +xfs_fileoff_t off = bno; +int error =0 , nirecs, i; -if (nfsb !=1 ) +if (nfsb >1 ) irecs =kmem_zalloc (sizeof (irec) * nfsb,KM_NOFS ); + nirecs = nfsb; - error =xfs_bmapi_read (dp, (xfs_fileoff_t )bno, nfsb, irecs, - &nirecs,xfs_bmapi_aflag (whichfork)); + error =xfs_bmapi_read (dp, bno, nfsb, irecs, &nirecs, +xfs_bmapi_aflag (whichfork));if (error) - goto out; + goto out_free_irecs; -if (!xfs_da_map_covers_blocks (nirecs, irecs, bno, nfsb)) { -/* Caller ok with no mapping. */ -if (!XFS_IS_CORRUPT (mp, mappedbno !=-2 )) { - error =-1 ; - goto out; - } +/* +* Use the caller provided map for the single map case, else allocate a +* larger one that needs to be free by the caller. +*/ +if (nirecs >1 ) { + map =kmem_zalloc (nirecs *sizeof (struct xfs_buf_map ),KM_NOFS ); +if (!map) + goto out_free_irecs; + *mapp = map; + } -/* Caller expected a mapping, so abort. */ +for (i =0 ; i < nirecs; i++) { +if (irecs[i].br_startblock ==HOLESTARTBLOCK || + irecs[i].br_startblock ==DELAYSTARTBLOCK ) + goto invalid_mapping; +if (off != irecs[i].br_startoff) + goto invalid_mapping; + + map[i].bm_bn =XFS_FSB_TO_DADDR (mp, irecs[i].br_startblock); + map[i].bm_len =XFS_FSB_TO_BB (mp, irecs[i].br_blockcount); + off += irecs[i].br_blockcount; + } + +if (off != bno + nfsb) + goto invalid_mapping; + + *nmaps = nirecs; +out_free_irecs: +if (irecs != &irec) +kmem_free (irecs); +return error; + +invalid_mapping: +/* Caller ok with no mapping. */ +if (XFS_IS_CORRUPT (mp, mappedbno !=-2 )) { + error = -EFSCORRUPTED ;if (xfs_error_level >=XFS_ERRLEVEL_LOW ) { -int i; +xfs_alert (mp,"%s: bno %u inode %llu" , + __func__, bno, dp->i_ino); -xfs_alert (mp,"%s: bno %lld dir: inode %lld" , __func__, - (long long )bno, (long long )dp->i_ino); -for (i =0 ; i < *nmaps; i++) { +for (i =0 ; i < nirecs; i++) {xfs_alert (mp,"[%02d] br_startoff %lld br_startblock %lld br_blockcount %lld br_state %d" , - i, - (long long )irecs[i].br_startoff, - (long long )irecs[i].br_startblock, - (long long )irecs[i].br_blockcount, + i, irecs[i].br_startoff, + irecs[i].br_startblock, + irecs[i].br_blockcount, irecs[i].br_state); } } - error = -EFSCORRUPTED ; - goto out; + }else { + *nmaps =0 ; } - error =xfs_buf_map_from_irec (mp, map, nmaps, irecs, nirecs); -out: -if (irecs != &irec) -kmem_free (irecs); -return error; + goto out_free_irecs; }/*
Signature · 1 line
2.20.1
Re: [PATCH 02/10] xfs: refactor xfs_dabuf_map
Quoted 4 lines · Christoph Hellwig
Merge
xfs_buf_map_from_irecandxfs_da_map_covers_blocksinto a single loop in the caller.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok to me,
--D
Quoted 199 lines
--- fs/xfs/libxfs/xfs_da_btree.c | 156 ++++++++++++----------------------- 1 file changed, 54 insertions(+), 102 deletions(-)fs/xfs/libxfs/xfs_da_btree.c +54
-102@@ -2460,74 +2460,6 @@ xfs_da_shrink_inode(return error; } -/* -* See if the mapping(s) for this btree block are valid, i.e. -* don't contain holes, are logically contiguous, and cover the whole range. -*/ -STATIC int -xfs_da_map_covers_blocks ( -int nmap, -xfs_bmbt_irec_t *mapp, -xfs_dablk_t bno, -int count) -{ -int i; -xfs_fileoff_t off; - -for (i =0 , off = bno; i < nmap; i++) { -if (mapp[i].br_startblock ==HOLESTARTBLOCK || - mapp[i].br_startblock ==DELAYSTARTBLOCK ) { -return 0 ; - } -if (off != mapp[i].br_startoff) { -return 0 ; - } - off += mapp[i].br_blockcount; - } -return off == bno + count; -} - -/* -* Convert a struct xfs_bmbt_irec to a struct xfs_buf_map. -* -* For the single map case, it is assumed that the caller has provided a pointer -* to a valid xfs_buf_map. For the multiple map case, this function will -* allocate the xfs_buf_map to hold all the maps and replace the caller's single -* map pointer with the allocated map. -*/ -static int -xfs_buf_map_from_irec ( -struct xfs_mount *mp, -struct xfs_buf_map **mapp, -int *nmaps, -struct xfs_bmbt_irec *irecs, -int nirecs) -{ -struct xfs_buf_map *map; -int i; - -ASSERT (*nmaps ==1 ); -ASSERT (nirecs >=1 ); - -if (nirecs >1 ) { - map =kmem_zalloc (nirecs *sizeof (struct xfs_buf_map ), -KM_NOFS ); -if (!map) -return -ENOMEM ; - *mapp = map; - } - - *nmaps = nirecs; - map = *mapp; -for (i =0 ; i < *nmaps; i++) { -ASSERT (irecs[i].br_startblock !=DELAYSTARTBLOCK && - irecs[i].br_startblock !=HOLESTARTBLOCK ); - map[i].bm_bn =XFS_FSB_TO_DADDR (mp, irecs[i].br_startblock); - map[i].bm_len =XFS_FSB_TO_BB (mp, irecs[i].br_blockcount); - } -return 0 ; -} -/* * Map the block we are given ready for reading. There are three possible return * values: @@ -2542,58 +2474,78 @@ xfs_dabuf_map(xfs_dablk_t bno, xfs_daddr_t mappedbno, int whichfork, - struct xfs_buf_map **map, + struct xfs_buf_map **mapp, int *nmaps) { struct xfs_mount *mp = dp->i_mount;int nfsb =xfs_dabuf_nfsb (mp, whichfork); -int error =0 ; -struct xfs_bmbt_irec irec; -struct xfs_bmbt_irec *irecs = &irec; -int nirecs; - -ASSERT (map && *map); -ASSERT (*nmaps ==1 ); +struct xfs_bmbt_irec irec, *irecs = &irec; +struct xfs_buf_map *map = *mapp; +xfs_fileoff_t off = bno; +int error =0 , nirecs, i; -if (nfsb !=1 ) +if (nfsb >1 ) irecs =kmem_zalloc (sizeof (irec) * nfsb,KM_NOFS ); + nirecs = nfsb; - error =xfs_bmapi_read (dp, (xfs_fileoff_t )bno, nfsb, irecs, - &nirecs,xfs_bmapi_aflag (whichfork)); + error =xfs_bmapi_read (dp, bno, nfsb, irecs, &nirecs, +xfs_bmapi_aflag (whichfork));if (error) - goto out; + goto out_free_irecs; -if (!xfs_da_map_covers_blocks (nirecs, irecs, bno, nfsb)) { -/* Caller ok with no mapping. */ -if (!XFS_IS_CORRUPT (mp, mappedbno !=-2 )) { - error =-1 ; - goto out; - } +/* +* Use the caller provided map for the single map case, else allocate a +* larger one that needs to be free by the caller. +*/ +if (nirecs >1 ) { + map =kmem_zalloc (nirecs *sizeof (struct xfs_buf_map ),KM_NOFS ); +if (!map) + goto out_free_irecs; + *mapp = map; + } -/* Caller expected a mapping, so abort. */ +for (i =0 ; i < nirecs; i++) { +if (irecs[i].br_startblock ==HOLESTARTBLOCK || + irecs[i].br_startblock ==DELAYSTARTBLOCK ) + goto invalid_mapping; +if (off != irecs[i].br_startoff) + goto invalid_mapping; + + map[i].bm_bn =XFS_FSB_TO_DADDR (mp, irecs[i].br_startblock); + map[i].bm_len =XFS_FSB_TO_BB (mp, irecs[i].br_blockcount); + off += irecs[i].br_blockcount; + } + +if (off != bno + nfsb) + goto invalid_mapping; + + *nmaps = nirecs; +out_free_irecs: +if (irecs != &irec) +kmem_free (irecs); +return error; + +invalid_mapping: +/* Caller ok with no mapping. */ +if (XFS_IS_CORRUPT (mp, mappedbno !=-2 )) { + error = -EFSCORRUPTED ;if (xfs_error_level >=XFS_ERRLEVEL_LOW ) { -int i; +xfs_alert (mp,"%s: bno %u inode %llu" , + __func__, bno, dp->i_ino); -xfs_alert (mp,"%s: bno %lld dir: inode %lld" , __func__, - (long long )bno, (long long )dp->i_ino); -for (i =0 ; i < *nmaps; i++) { +for (i =0 ; i < nirecs; i++) {xfs_alert (mp,"[%02d] br_startoff %lld br_startblock %lld br_blockcount %lld br_state %d" , - i, - (long long )irecs[i].br_startoff, - (long long )irecs[i].br_startblock, - (long long )irecs[i].br_blockcount, + i, irecs[i].br_startoff, + irecs[i].br_startblock, + irecs[i].br_blockcount, irecs[i].br_state); } } - error = -EFSCORRUPTED ; - goto out; + }else { + *nmaps =0 ; } - error =xfs_buf_map_from_irec (mp, map, nmaps, irecs, nirecs); -out: -if (irecs != &irec) -kmem_free (irecs); -return error; + goto out_free_irecs; }/* Signature · 1 line
2.20.1
PATCH 3/10 xfs: improve the xfs_dabuf_map calling conventions
In reply to Christoph HellwigUse a flags argument with the XFS_DABUF_MAP_HOLE_OK flag to signal that a hole is okay and not corruption, and return 0 with *nmap set to 0 to signal that case in the return value instead of a nameless -1 return code.
--- fs/xfs/libxfs/xfs_da_btree.c | 39 +++++++++++++----------------------- fs/xfs/libxfs/xfs_da_btree.h | 3 +++ 2 files changed, 17 insertions(+), 25 deletions(-)
fs/xfs/libxfs/xfs_da_btree.c +14 -25
@@ -2460,19 +2460,11 @@ xfs_da_shrink_inode(return error; } -/* -* Map the block we are given ready for reading. There are three possible return -* values: -* -1 - will be returned if we land in a hole and mappedbno == -2 so the -* caller knows not to execute a subsequent read. -* 0 - if we mapped the block successfully -* >0 - positive error number if there was an error. -*/ static int xfs_dabuf_map (struct xfs_inode *dp,xfs_dablk_t bno, -xfs_daddr_t mappedbno, +unsigned int flags,int whichfork,struct xfs_buf_map **mapp,int *nmaps)
@@ -2527,7 +2519,7 @@ xfs_dabuf_map( invalid_mapping:/* Caller ok with no mapping. */ -if (XFS_IS_CORRUPT (mp, mappedbno !=-2 )) { +if (XFS_IS_CORRUPT (mp, !flags &XFS_DABUF_MAP_HOLE_OK )) { error = -EFSCORRUPTED ;if (xfs_error_level >=XFS_ERRLEVEL_LOW ) { xfs_alert(mp, "%s: bno %u inode %llu",
@@ -2575,13 +2567,11 @@ xfs_da_get_buf( goto done; } - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap); -if (error) { -/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) - error =0 ; + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap); +if (error || nmap ==0 ) goto out_free; - } bp =xfs_trans_get_buf_map (tp, mp->m_ddev_targp, mapp, nmap,0 ); done:
@@ -2630,13 +2620,11 @@ xfs_da_read_buf( goto done; } - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap); -if (error) { -/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) - error =0 ; + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap); +if (error || !nmap) goto out_free; - } error =xfs_trans_read_buf_map (mp, tp, mp->m_ddev_targp, mapp, nmap,0 , &bp, ops);
@@ -2677,11 +2665,12 @@ xfs_da_reada_buf( mapp = ↦ nmap =1 ; - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, - &mapp, &nmap); + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap);if (error) {/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) +if (error == -ENOENT ) error =0 ; goto out_free; }
fs/xfs/libxfs/xfs_da_btree.h +3 -0
@@ -194,6 +194,9 @@ int xfs_da3_node_read(struct xfs_trans *tp, struct xfs_inode *dp,/* * Utility routines. */ + +#define XFS_DABUF_MAP_HOLE_OK (1 << 0) +int xfs_da_grow_inode (xfs_da_args_t *args,xfs_dablk_t *new_blkno);int xfs_da_grow_inode_int (struct xfs_da_args *args,xfs_fileoff_t *bno,int count);
Signature · 1 line
2.20.1
Re: [PATCH 03/10] xfs: improve the xfs_dabuf_map calling conventions
Quoted 84 lines · Christoph Hellwig
Use a flags argument with the
XFS_DABUF_MAP_HOLE_OKflag to signal that a hole is okay and not corruption, and return 0 with *nmap set to 0 to signal that case in the return value instead of a nameless -1 return code.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_da_btree.c | 39 +++++++++++++----------------------- fs/xfs/libxfs/xfs_da_btree.h | 3 +++ 2 files changed, 17 insertions(+), 25 deletions(-)fs/xfs/libxfs/xfs_da_btree.c +10
-22@@ -2460,19 +2460,11 @@ xfs_da_shrink_inode(return error; } -/* -* Map the block we are given ready for reading. There are three possible return -* values: -* -1 - will be returned if we land in a hole and mappedbno == -2 so the -* caller knows not to execute a subsequent read. -* 0 - if we mapped the block successfully -* >0 - positive error number if there was an error. -*/ static int xfs_dabuf_map (struct xfs_inode *dp,xfs_dablk_t bno, -xfs_daddr_t mappedbno, +unsigned int flags,int whichfork,struct xfs_buf_map **mapp,int *nmaps)@@ -2527,7 +2519,7 @@ xfs_dabuf_map( invalid_mapping:/* Caller ok with no mapping. */ -if (XFS_IS_CORRUPT (mp, mappedbno !=-2 )) { +if (XFS_IS_CORRUPT (mp, !flags &XFS_DABUF_MAP_HOLE_OK )) { error = -EFSCORRUPTED ;if (xfs_error_level >=XFS_ERRLEVEL_LOW ) { xfs_alert(mp, "%s: bno %u inode %llu",@@ -2575,13 +2567,11 @@ xfs_da_get_buf( goto done; } - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap); -if (error) { -/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) - error =0 ; + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap); +if (error || nmap ==0 ) goto out_free; - } bp =xfs_trans_get_buf_map (tp, mp->m_ddev_targp, mapp, nmap,0 ); done:@@ -2630,13 +2620,11 @@ xfs_da_read_buf( goto done; } - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap); -if (error) { -/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) - error =0 ; + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap); +if (error || !nmap) goto out_free; - } error =xfs_trans_read_buf_map (mp, tp, mp->m_ddev_targp, mapp, nmap,0 , &bp, ops);@@ -2677,11 +2665,12 @@ xfs_da_reada_buf( mapp = ↦
fs/xfs/libxfs/xfs_da_btree.c xfs_da_reada_buf( · line 2673
Quoted 10 lines
fs/xfs/libxfs/xfs_da_btree.c +4
-3nmap =1 ; - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, - &mapp, &nmap); + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap);if (error) {/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) +if (error == -ENOENT )
Shouldn't this turn into:
if (error || !nmap)
goto out_free;
Otherwise looks ok to me.
--D
Quoted 20 lines
fs/xfs/libxfs/xfs_da_btree.c +0
-0error =0 ; goto out_free; }fs/xfs/libxfs/xfs_da_btree.h +3
-0@@ -194,6 +194,9 @@ int xfs_da3_node_read(struct xfs_trans *tp, struct xfs_inode *dp,/* * Utility routines. */ + +#define XFS_DABUF_MAP_HOLE_OK (1 << 0) +int xfs_da_grow_inode (xfs_da_args_t *args,xfs_dablk_t *new_blkno);int xfs_da_grow_inode_int (struct xfs_da_args *args,xfs_fileoff_t *bno,int count);Signature · 1 line
2.20.1
Re: [PATCH 03/10] xfs: improve the xfs_dabuf_map calling conventions
Quoted 12 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_da_btree.c xfs_da_reada_buf( · line 2673
Quoted 9 lines
fs/xfs/libxfs/xfs_da_btree.c +4
-3- error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, - &mapp, &nmap); + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap);if (error) {/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) +if (error == -ENOENT )Shouldn't this turn into:
Quoted 4 lines
if (error || !nmap)
goto out_free;Otherwise looks ok to me.
Yes, it should. Looks like that hunk got lost in the reshuffle.
Re: [PATCH 03/10] xfs: improve the xfs_dabuf_map calling conventions
Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_da_btree.c xfs_da_reada_buf( · line 2673
Quoted 9 lines
fs/xfs/libxfs/xfs_da_btree.c +4
-3- error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, - &mapp, &nmap); + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap);if (error) {/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) +if (error == -ENOENT )Shouldn't this turn into:
Quoted 6 lines
Quoted 4 lines
if (error || !nmap)
goto out_free;Otherwise looks ok to me.
Yes, it should. Looks like that hunk got lost in the reshuffle.
With that and the other change I mentioned, it seems to test ok. Do you want to respin the patch, or just let me keep my staged version?
--D
Re: [PATCH 03/10] xfs: improve the xfs_dabuf_map calling conventions
Quoted 17 lines · Darrick J. Wong
Quoted 16 lines · Christoph Hellwig
Quoted 15 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_da_btree.c xfs_da_reada_buf( · line 2673
Quoted 9 lines
fs/xfs/libxfs/xfs_da_btree.c +4
-3- error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, - &mapp, &nmap); + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap);if (error) {/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) +if (error == -ENOENT )Shouldn't this turn into:
if (error || !nmap)
goto out_free;
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Otherwise looks ok to me.
Yes, it should. Looks like that hunk got lost in the reshuffle.
With that and the other change I mentioned, it seems to test ok. Do you want to respin the patch, or just let me keep my staged version?
I've just done the respin and was about to re-start testing. If you have a sensible version I'll skip that and will let you proceed.
Darrick J. Wong
Reviewed-byRe: [PATCH 03/10] xfs: improve the xfs_dabuf_map calling conventions
Quoted 20 lines · Christoph Hellwig
Quoted 19 lines · Darrick J. Wong
Quoted 18 lines · Christoph Hellwig
Quoted 16 lines · Darrick J. Wong
Review
Quoted 9 lines
(quoted diff) +4
-3- error = xfs_dabuf_map(dp, bno, mappedbno, whichfork, - &mapp, &nmap); + error = xfs_dabuf_map(dp, bno, + mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0, + whichfork, &mapp, &nmap); if (error) { /* mapping a hole is not an error, but we don't continue */ - if (error == -1) + if (error == -ENOENT)Shouldn't this turn into:
if (error || !nmap)
goto out_free;Otherwise looks ok to me.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Yes, it should. Looks like that hunk got lost in the reshuffle.
With that and the other change I mentioned, it seems to test ok. Do you want to respin the patch, or just let me keep my staged version?
I've just done the respin and was about to re-start testing. If you have a sensible version I'll skip that and will let you proceed.
Here's what I've been testing with, though FWIW I'm about to go to bed so you might as well keep going, particularly if you see anything funny here.
--D
xfs: improve the xfs_dabuf_map calling conventions
Use a flags argument with the XFS_DABUF_MAP_HOLE_OK flag to signal that a hole is okay and not corruption, and return 0 with *nmap set to 0 to signal that case in the return value instead of a nameless -1 return code.
--- fs/xfs/libxfs/xfs_da_btree.c | 43 ++++++++++++++---------------------------- fs/xfs/libxfs/xfs_da_btree.h | 3 +++ 2 files changed, 17 insertions(+), 29 deletions(-)
fs/xfs/libxfs/xfs_da_btree.c +14 -29
@@ -2460,19 +2460,11 @@ xfs_da_shrink_inode(return error; } -/* -* Map the block we are given ready for reading. There are three possible return -* values: -* -1 - will be returned if we land in a hole and mappedbno == -2 so the -* caller knows not to execute a subsequent read. -* 0 - if we mapped the block successfully -* >0 - positive error number if there was an error. -*/ static int xfs_dabuf_map (struct xfs_inode *dp,xfs_dablk_t bno, -xfs_daddr_t mappedbno, +unsigned int flags,int whichfork,struct xfs_buf_map **mapp,int *nmaps)
@@ -2527,7 +2519,7 @@ xfs_dabuf_map( invalid_mapping:/* Caller ok with no mapping. */ -if (XFS_IS_CORRUPT (mp, mappedbno !=-2 )) { +if (XFS_IS_CORRUPT (mp, !(flags &XFS_DABUF_MAP_HOLE_OK ))) { error = -EFSCORRUPTED ;if (xfs_error_level >=XFS_ERRLEVEL_LOW ) { xfs_alert(mp, "%s: bno %u inode %llu",
@@ -2575,13 +2567,11 @@ xfs_da_get_buf( goto done; } - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap); -if (error) { -/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) - error =0 ; + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap); +if (error || nmap ==0 ) goto out_free; - } bp =xfs_trans_get_buf_map (tp, mp->m_ddev_targp, mapp, nmap,0 ); done:
@@ -2630,13 +2620,11 @@ xfs_da_read_buf( goto done; } - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap); -if (error) { -/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) - error =0 ; + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap); +if (error || !nmap) goto out_free; - } error =xfs_trans_read_buf_map (mp, tp, mp->m_ddev_targp, mapp, nmap,0 , &bp, ops);
@@ -2677,14 +2665,11 @@ xfs_da_reada_buf( mapp = ↦ nmap =1 ; - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, - &mapp, &nmap); -if (error) { -/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) - error =0 ; + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap); +if (error || !nmap) goto out_free; - } mappedbno = mapp[0 ].bm_bn;xfs_buf_readahead_map (dp->i_mount->m_ddev_targp, mapp, nmap, ops);
fs/xfs/libxfs/xfs_da_btree.h +3 -0
@@ -194,6 +194,9 @@ int xfs_da3_node_read(struct xfs_trans *tp, struct xfs_inode *dp,/* * Utility routines. */ + +#define XFS_DABUF_MAP_HOLE_OK (1 << 0) +int xfs_da_grow_inode (xfs_da_args_t *args,xfs_dablk_t *new_blkno);int xfs_da_grow_inode_int (struct xfs_da_args *args,xfs_fileoff_t *bno,int count);
Re: [PATCH 03/10] xfs: improve the xfs_dabuf_map calling conventions
Quoted 3 lines · Darrick J. Wong
Here's what I've been testing with, though FWIW I'm about to go to bed so you might as well keep going, particularly if you see anything funny here.
This looks the same as the version I have. It creates a trivial conflict with one of the later patches that I've also fixed up.
Re: [PATCH 03/10] xfs: improve the xfs_dabuf_map calling conventions
In reply to Christoph HellwigQuoted 37 lines · Christoph Hellwig
Use a flags argument with the
XFS_DABUF_MAP_HOLE_OKflag to signal that a hole is okay and not corruption, and return 0 with *nmap set to 0 to signal that case in the return value instead of a nameless -1 return code.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_da_btree.c | 39 +++++++++++++----------------------- fs/xfs/libxfs/xfs_da_btree.h | 3 +++ 2 files changed, 17 insertions(+), 25 deletions(-)fs/xfs/libxfs/xfs_da_btree.c +1
-9@@ -2460,19 +2460,11 @@ xfs_da_shrink_inode(return error; } -/* -* Map the block we are given ready for reading. There are three possible return -* values: -* -1 - will be returned if we land in a hole and mappedbno == -2 so the -* caller knows not to execute a subsequent read. -* 0 - if we mapped the block successfully -* >0 - positive error number if there was an error. -*/ static int xfs_dabuf_map (struct xfs_inode *dp,xfs_dablk_t bno, -xfs_daddr_t mappedbno, +unsigned int flags,int whichfork,struct xfs_buf_map **mapp,int *nmaps)
fs/xfs/libxfs/xfs_da_btree.c xfs_dabuf_map( · line 2522
Quoted 5 lines
fs/xfs/libxfs/xfs_da_btree.c +1
-1@@ -2527,7 +2519,7 @@ xfs_dabuf_map( invalid_mapping:/* Caller ok with no mapping. */ -if (XFS_IS_CORRUPT (mp, mappedbno !=-2 )) { +if (XFS_IS_CORRUPT (mp, !flags &XFS_DABUF_MAP_HOLE_OK )) {
Also I totally forgot to mention this flags test ^^^^^^^^ probably should have parentheses...
--D
Quoted 72 lines
fs/xfs/libxfs/xfs_da_btree.c +12
-15error = -EFSCORRUPTED ;if (xfs_error_level >=XFS_ERRLEVEL_LOW ) { xfs_alert(mp, "%s: bno %u inode %llu",@@ -2575,13 +2567,11 @@ xfs_da_get_buf( goto done; } - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap); -if (error) { -/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) - error =0 ; + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap); +if (error || nmap ==0 ) goto out_free; - } bp =xfs_trans_get_buf_map (tp, mp->m_ddev_targp, mapp, nmap,0 ); done:@@ -2630,13 +2620,11 @@ xfs_da_read_buf( goto done; } - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, &mapp, &nmap); -if (error) { -/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) - error =0 ; + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap); +if (error || !nmap) goto out_free; - } error =xfs_trans_read_buf_map (mp, tp, mp->m_ddev_targp, mapp, nmap,0 , &bp, ops);@@ -2677,11 +2665,12 @@ xfs_da_reada_buf( mapp = ↦ nmap =1 ; - error =xfs_dabuf_map (dp, bno, mappedbno, whichfork, - &mapp, &nmap); + error =xfs_dabuf_map (dp, bno, + mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , + whichfork, &mapp, &nmap);if (error) {/* mapping a hole is not an error, but we don't continue */ -if (error ==-1 ) +if (error == -ENOENT ) error =0 ; goto out_free; }fs/xfs/libxfs/xfs_da_btree.h +3
-0@@ -194,6 +194,9 @@ int xfs_da3_node_read(struct xfs_trans *tp, struct xfs_inode *dp,/* * Utility routines. */ + +#define XFS_DABUF_MAP_HOLE_OK (1 << 0) +int xfs_da_grow_inode (xfs_da_args_t *args,xfs_dablk_t *new_blkno);int xfs_da_grow_inode_int (struct xfs_da_args *args,xfs_fileoff_t *bno,int count);Signature · 1 line
2.20.1
PATCH 4/10 xfs: remove the mappedbno argument to xfs_da_reada_buf
In reply to Christoph HellwigReplace the mappedbno argument with the simple flags for xfs_da_reada_buf and xfs_dir3_data_readahead.
--- fs/xfs/libxfs/xfs_da_btree.c | 10 ++-------- fs/xfs/libxfs/xfs_da_btree.h | 4 ++-- fs/xfs/libxfs/xfs_dir2_data.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_priv.h | 4 ++-- fs/xfs/scrub/parent.c | 2 +- fs/xfs/xfs_dir2_readdir.c | 3 ++- fs/xfs/xfs_file.c | 2 +- 7 files changed, 13 insertions(+), 18 deletions(-)
fs/xfs/libxfs/xfs_da_btree.c +2 -8
@@ -2651,7 +2651,7 @@ intxfs_da_reada_buf ( struct xfs_inode *dp, xfs_dablk_t bno, - xfs_daddr_t mappedbno, + unsigned int flags, int whichfork, const struct xfs_buf_ops *ops) {
@@ -2660,14 +2660,9 @@ xfs_da_reada_buf(int nmap;int error; -if (mappedbno >=0 ) -return -EINVAL ; - mapp = ↦ nmap =1 ; - error =xfs_dabuf_map (dp, bno, - mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , - whichfork, &mapp, &nmap); + error =xfs_dabuf_map (dp, bno, flags, whichfork, &mapp, &nmap);if (error) {/* mapping a hole is not an error, but we don't continue */ if (error == -ENOENT )
@@ -2675,7 +2670,6 @@ xfs_da_reada_buf( goto out_free; } - mappedbno = mapp[0 ].bm_bn;xfs_buf_readahead_map (dp->i_mount->m_ddev_targp, mapp, nmap, ops); out_free:
fs/xfs/libxfs/xfs_da_btree.h +2 -2
@@ -208,8 +208,8 @@ int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp, struct xfs_buf **bpp, int whichfork, const struct xfs_buf_ops *ops);int xfs_da_reada_buf (struct xfs_inode *dp,xfs_dablk_t bno, -xfs_daddr_t mapped_bno,int whichfork, -const struct xfs_buf_ops *ops); +unsigned int flags,int whichfork, +const struct xfs_buf_ops *ops);int xfs_da_shrink_inode (xfs_da_args_t *args,xfs_dablk_t dead_blkno,struct xfs_buf *dead_buf);
fs/xfs/libxfs/xfs_dir2_data.c +3 -3
@@ -416,10 +416,10 @@ intxfs_dir3_data_readahead ( struct xfs_inode *dp, xfs_dablk_t bno, - xfs_daddr_t mapped_bno) + unsigned int flags) { - return xfs_da_reada_buf(dp, bno, mapped_bno, - XFS_DATA_FORK, &xfs_dir3_data_reada_buf_ops); + return xfs_da_reada_buf(dp, bno, flags, XFS_DATA_FORK, + &xfs_dir3_data_reada_buf_ops); }/*
fs/xfs/libxfs/xfs_dir2_priv.h +2 -2
@@ -79,8 +79,8 @@ extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);extern int xfs_dir3_data_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t bno,xfs_daddr_t mapped_bno,struct xfs_buf **bpp); -extern int xfs_dir3_data_readahead (struct xfs_inode *dp,xfs_dablk_t bno, -xfs_daddr_t mapped_bno); +int xfs_dir3_data_readahead (struct xfs_inode *dp,xfs_dablk_t bno, +unsigned int flags);extern struct xfs_dir2_data_free * xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr,
fs/xfs/scrub/parent.c +1 -1
@@ -80,7 +80,7 @@ xchk_parent_count_parent_dentries(*/ lock_mode =xfs_ilock_data_map_shared (parent);if (parent->i_d.di_nextents >0 ) - error =xfs_dir3_data_readahead (parent,0 ,-1 ); + error =xfs_dir3_data_readahead (parent,0 ,0 );xfs_iunlock (parent, lock_mode);if (error)return error;
fs/xfs/xfs_dir2_readdir.c +2 -1
@@ -314,7 +314,8 @@ xfs_dir2_leaf_readbuf(break ; }if (next_ra > *ra_blk) { -xfs_dir3_data_readahead (dp, next_ra,-2 ); +xfs_dir3_data_readahead (dp, next_ra, +XFS_DABUF_MAP_HOLE_OK ); *ra_blk = next_ra; } ra_want -= geo->fsbcount;
fs/xfs/xfs_file.c +1 -1
@@ -1104,7 +1104,7 @@ xfs_dir_open(*/ mode =xfs_ilock_data_map_shared (ip);if (ip->i_d.di_nextents >0 ) - error =xfs_dir3_data_readahead (ip,0 ,-1 ); + error =xfs_dir3_data_readahead (ip,0 ,0 );xfs_iunlock (ip, mode);return error; }
Signature · 1 line
2.20.1
PATCH 5/10 xfs: remove the mappedbno argument to xfs_attr3_leaf_read
In reply to Christoph HellwigThis argument is always hard coded to -1, so remove it.
--- fs/xfs/libxfs/xfs_attr.c | 10 +++++----- fs/xfs/libxfs/xfs_attr_leaf.c | 17 ++++++++--------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 +-- fs/xfs/xfs_attr_list.c | 5 +++-- 4 files changed, 17 insertions(+), 18 deletions(-)
fs/xfs/libxfs/xfs_attr.c +5 -5
@@ -589,7 +589,7 @@ xfs_attr_leaf_addname(*/ dp = args->dp; args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp); + error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &bp);if (error)return error;
@@ -715,7 +715,7 @@ xfs_attr_leaf_addname(* remove the "old" attr from that block (neat, huh!) */ error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, --1 , &bp); + &bp);if (error)return error;
@@ -769,7 +769,7 @@ xfs_attr_leaf_removename(*/ dp = args->dp; args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp); + error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &bp);if (error)return error;
@@ -813,7 +813,7 @@ xfs_attr_leaf_get(xfs_da_args_t *args)trace_xfs_attr_leaf_get (args); args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp); + error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &bp);if (error)return error;
@@ -1173,7 +1173,7 @@ xfs_attr_node_removename(ASSERT (state->path.blk[0 ].bp); state->path.blk[0 ].bp =NULL ; - error =xfs_attr3_leaf_read (args->trans, args->dp,0 ,-1 , &bp); + error =xfs_attr3_leaf_read (args->trans, args->dp,0 , &bp);if (error) goto out;
fs/xfs/libxfs/xfs_attr_leaf.c +8 -9
@@ -430,13 +430,12 @@ xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t bno, - xfs_daddr_t mappedbno, struct xfs_buf **bpp) { int err; - err =xfs_da_read_buf (tp, dp, bno, mappedbno, bpp, -XFS_ATTR_FORK , &xfs_attr3_leaf_buf_ops); + err =xfs_da_read_buf (tp, dp, bno,-1 , bpp,XFS_ATTR_FORK , + &xfs_attr3_leaf_buf_ops);if (!err && tp && *bpp)xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_ATTR_LEAF_BUF );return err;
@@ -1159,7 +1158,7 @@ xfs_attr3_leaf_to_node( error =xfs_da_grow_inode (args, &blkno);if (error) goto out; - error =xfs_attr3_leaf_read (args->trans, dp,0 ,-1 , &bp1); + error =xfs_attr3_leaf_read (args->trans, dp,0 , &bp1);if (error) goto out;
@@ -1996,7 +1995,7 @@ xfs_attr3_leaf_toosmall(if (blkno ==0 )continue ; error =xfs_attr3_leaf_read (state->args->trans, state->args->dp, - blkno,-1 , &bp); + blkno, &bp);if (error)return error;
@@ -2732,7 +2731,7 @@ xfs_attr3_leaf_clearflag(/* * Set up the operation. */ - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp); + error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &bp);if (error)return error;
@@ -2799,7 +2798,7 @@ xfs_attr3_leaf_setflag(/* * Set up the operation. */ - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp); + error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &bp);if (error)return error;
@@ -2861,7 +2860,7 @@ xfs_attr3_leaf_flipflags(/* * Read the block containing the "old" attr */ - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp1); + error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &bp1);if (error)return error;
@@ -2870,7 +2869,7 @@ xfs_attr3_leaf_flipflags(*/ if (args->blkno2 != args->blkno) { error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno2, --1 , &bp2); + &bp2);if (error)return error; }else {
fs/xfs/libxfs/xfs_attr_leaf.h +1 -2
@@ -108,8 +108,7 @@ int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp, struct xfs_buf *leaf2_bp);int xfs_attr_leaf_newentsize (struct xfs_da_args *args,int *local);int xfs_attr3_leaf_read (struct xfs_trans *tp,struct xfs_inode *dp, -xfs_dablk_t bno,xfs_daddr_t mappedbno, -struct xfs_buf **bpp); +xfs_dablk_t bno,struct xfs_buf **bpp);void xfs_attr3_leaf_hdr_from_disk (struct xfs_da_geometry *geo,struct xfs_attr3_icleaf_hdr *to,struct xfs_attr_leafblock *from);
fs/xfs/xfs_attr_list.c +3 -2
@@ -377,7 +377,8 @@ xfs_attr_node_list(break ; cursor->blkno = leafhdr.forw;xfs_trans_brelse (context->tp, bp); - error =xfs_attr3_leaf_read (context->tp, dp, cursor->blkno,-1 , &bp); + error =xfs_attr3_leaf_read (context->tp, dp, cursor->blkno, + &bp);if (error)return error; }
@@ -495,7 +496,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)trace_xfs_attr_leaf_list (context); context->cursor->blkno =0 ; - error =xfs_attr3_leaf_read (context->tp, context->dp,0 ,-1 , &bp); + error =xfs_attr3_leaf_read (context->tp, context->dp,0 , &bp);if (error)return error;
Signature · 1 line
2.20.1
PATCH 6/10 xfs: remove the mappedbno argument to xfs_dir3_leaf_read
In reply to Christoph HellwigThis argument is always hard coded to -1, so remove it.
--- fs/xfs/libxfs/xfs_dir2_leaf.c | 9 ++++----- fs/xfs/libxfs/xfs_dir2_priv.h | 4 ++-- fs/xfs/scrub/dir.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-)
fs/xfs/libxfs/xfs_dir2_leaf.c +4 -5
@@ -262,13 +262,12 @@ xfs_dir3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t fbno, - xfs_daddr_t mappedbno, struct xfs_buf **bpp) { int err; - err =xfs_da_read_buf (tp, dp, fbno, mappedbno, bpp, -XFS_DATA_FORK , &xfs_dir3_leaf1_buf_ops); + err =xfs_da_read_buf (tp, dp, fbno,-1 , bpp,XFS_DATA_FORK , + &xfs_dir3_leaf1_buf_ops);if (!err && tp && *bpp)xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_LEAF1_BUF );return err;
@@ -639,7 +638,7 @@ xfs_dir2_leaf_addname(trace_xfs_dir2_leaf_addname (args); - error =xfs_dir3_leaf_read (tp, dp, args->geo->leafblk,-1 , &lbp); + error =xfs_dir3_leaf_read (tp, dp, args->geo->leafblk, &lbp);if (error)return error;
@@ -1230,7 +1229,7 @@ xfs_dir2_leaf_lookup_int( tp = args->trans; mp = dp->i_mount; - error =xfs_dir3_leaf_read (tp, dp, args->geo->leafblk,-1 , &lbp); + error =xfs_dir3_leaf_read (tp, dp, args->geo->leafblk, &lbp);if (error)return error;
fs/xfs/libxfs/xfs_dir2_priv.h +2 -2
@@ -94,8 +94,8 @@ 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); +int xfs_dir3_leaf_read (struct xfs_trans *tp,struct xfs_inode *dp, +xfs_dablk_t fbno,struct xfs_buf **bpp);extern int xfs_dir3_leafn_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t fbno,xfs_daddr_t mappedbno,struct xfs_buf **bpp); extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
fs/xfs/scrub/dir.c +1 -1
@@ -497,7 +497,7 @@ xchk_directory_leaf1_bestfree(int error;/* Read the free space block. */ - error =xfs_dir3_leaf_read (sc->tp, sc->ip, lblk,-1 , &bp); + error =xfs_dir3_leaf_read (sc->tp, sc->ip, lblk, &bp);if (!xchk_fblock_process_error (sc,XFS_DATA_FORK , lblk, &error)) goto out;xchk_buffer_recheck (sc, bp);
Signature · 1 line
2.20.1
PATCH 7/10 xfs: remove the mappedbno argument to xfs_dir3_leafn_read
In reply to Christoph HellwigThis argument is always hard coded to -1, so remove it.
--- fs/xfs/libxfs/xfs_dir2_leaf.c | 5 ++--- fs/xfs/libxfs/xfs_dir2_node.c | 3 +-- fs/xfs/libxfs/xfs_dir2_priv.h | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-)
fs/xfs/libxfs/xfs_dir2_leaf.c +2 -3
@@ -278,13 +278,12 @@ xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t fbno, - xfs_daddr_t mappedbno, struct xfs_buf **bpp) { int err; - err =xfs_da_read_buf (tp, dp, fbno, mappedbno, bpp, -XFS_DATA_FORK , &xfs_dir3_leafn_buf_ops); + err =xfs_da_read_buf (tp, dp, fbno,-1 , bpp,XFS_DATA_FORK , + &xfs_dir3_leafn_buf_ops);if (!err && tp && *bpp)xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_LEAFN_BUF );return err;
fs/xfs/libxfs/xfs_dir2_node.c +1 -2
@@ -1553,8 +1553,7 @@ xfs_dir2_leafn_toosmall(/* * Read the sibling leaf block. */ - error =xfs_dir3_leafn_read (state->args->trans, dp, - blkno,-1 , &bp); + error =xfs_dir3_leafn_read (state->args->trans, dp, blkno, &bp);if (error)return error;
fs/xfs/libxfs/xfs_dir2_priv.h +2 -2
@@ -96,8 +96,8 @@ void xfs_dir2_leaf_hdr_to_disk(struct xfs_mount *mp, struct xfs_dir2_leaf *to, struct xfs_dir3_icleaf_hdr *from);int xfs_dir3_leaf_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t fbno,struct xfs_buf **bpp); -extern int xfs_dir3_leafn_read (struct xfs_trans *tp,struct xfs_inode *dp, -xfs_dablk_t fbno,xfs_daddr_t mappedbno,struct xfs_buf **bpp); +int xfs_dir3_leafn_read (struct xfs_trans *tp,struct xfs_inode *dp, +xfs_dablk_t fbno,struct xfs_buf **bpp);extern int xfs_dir2_block_to_leaf (struct xfs_da_args *args,struct xfs_buf *dbp);extern int xfs_dir2_leaf_addname (struct xfs_da_args *args);
Signature · 1 line
2.20.1
PATCH 8/10 xfs: split xfs_da3_node_read
In reply to Christoph HellwigSplit xfs_da3_node_read into one variant that always looks up the daddr and doesn't accept holes, and one that already has a daddr at hand. This is in preparation of splitting up xfs_da_read_buf in a similar way.
--- fs/xfs/libxfs/xfs_attr.c | 14 ++--- fs/xfs/libxfs/xfs_da_btree.c | 111 ++++++++++++++++++++--------------- fs/xfs/libxfs/xfs_da_btree.h | 6 +- fs/xfs/xfs_attr_inactive.c | 8 +-- fs/xfs/xfs_attr_list.c | 6 +- 5 files changed, 82 insertions(+), 63 deletions(-)
fs/xfs/libxfs/xfs_attr.c +6 -8
@@ -1266,10 +1266,9 @@ xfs_attr_refillstate(xfs_da_state_t *state)ASSERT ((path->active >=0 ) && (path->active <XFS_DA_NODE_MAXDEPTH ));for (blk = path->blk, level =0 ; level < path->active; blk++, level++) {if (blk->disk_blkno) { - error =xfs_da3_node_read (state->args->trans, - state->args->dp, - blk->blkno, blk->disk_blkno, - &blk->bp,XFS_ATTR_FORK ); + error =xfs_da3_node_read_mapped (state->args->trans, + state->args->dp, blk->disk_blkno, + &blk->bp,XFS_ATTR_FORK );if (error)return error; }else {
@@ -1285,10 +1284,9 @@ xfs_attr_refillstate(xfs_da_state_t *state)ASSERT ((path->active >=0 ) && (path->active <XFS_DA_NODE_MAXDEPTH ));for (blk = path->blk, level =0 ; level < path->active; blk++, level++) {if (blk->disk_blkno) { - error =xfs_da3_node_read (state->args->trans, - state->args->dp, - blk->blkno, blk->disk_blkno, - &blk->bp,XFS_ATTR_FORK ); + error =xfs_da3_node_read_mapped (state->args->trans, + state->args->dp, blk->disk_blkno, + &blk->bp,XFS_ATTR_FORK );if (error)return error; }else {
fs/xfs/libxfs/xfs_da_btree.c +65 -46
204 lines not on this page · raw message
fs/xfs/libxfs/xfs_da_btree.h +4 -2
@@ -188,8 +188,10 @@ int xfs_da3_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,int xfs_da3_blk_link (xfs_da_state_t *state,xfs_da_state_blk_t *old_blk,xfs_da_state_blk_t *new_blk);int xfs_da3_node_read (struct xfs_trans *tp,struct xfs_inode *dp, -xfs_dablk_t bno,xfs_daddr_t mappedbno, -struct xfs_buf **bpp,int which_fork); +xfs_dablk_t bno,struct xfs_buf **bpp,int whichfork); +int xfs_da3_node_read_mapped (struct xfs_trans *tp,struct xfs_inode *dp, +xfs_daddr_t mappedbno,struct xfs_buf **bpp, +int whichfork);/* * Utility routines.
fs/xfs/xfs_attr_inactive.c +4 -4
@@ -233,7 +233,7 @@ xfs_attr3_node_inactive(* traversal of the tree so we may deal with many blocks * before we come back to this one. */ - error =xfs_da3_node_read (*trans, dp, child_fsb,-1 , &child_bp, + error =xfs_da3_node_read (*trans, dp, child_fsb, &child_bp,XFS_ATTR_FORK );if (error)return error;
@@ -280,8 +280,8 @@ xfs_attr3_node_inactive(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 ); + error =xfs_da3_node_read_mapped (*trans, dp, + parent_blkno, &bp,XFS_ATTR_FORK );if (error)return error; xfs_da3_node_hdr_from_disk(dp->i_mount, &phdr,
@@ -322,7 +322,7 @@ xfs_attr3_root_inactive(* the extents in reverse order the extent containing * block 0 must still be there. */ - error =xfs_da3_node_read (*trans, dp,0 ,-1 , &bp,XFS_ATTR_FORK ); + error =xfs_da3_node_read (*trans, dp,0 , &bp,XFS_ATTR_FORK );if (error)return error; blkno = bp->b_bn;
fs/xfs/xfs_attr_list.c +3 -3
@@ -223,7 +223,7 @@ xfs_attr_node_list_lookup(ASSERT (*pbp ==NULL ); cursor->blkno =0 ;for (;;) { - error =xfs_da3_node_read (tp, dp, cursor->blkno,-1 , &bp, + error =xfs_da3_node_read (tp, dp, cursor->blkno, &bp,XFS_ATTR_FORK );if (error)return error;
@@ -309,8 +309,8 @@ xfs_attr_node_list(*/ bp =NULL ;if (cursor->blkno >0 ) { - error =xfs_da3_node_read (context->tp, dp, cursor->blkno,-1 , - &bp,XFS_ATTR_FORK ); + error =xfs_da3_node_read (context->tp, dp, cursor->blkno, &bp, +XFS_ATTR_FORK );if ((error !=0 ) && (error != -EFSCORRUPTED ))return error;if (bp) {
Signature · 1 line
2.20.1
PATCH 9/10 xfs: remove the mappedbno argument to xfs_da_read_buf
In reply to Christoph HellwigMove the code for reading an already mapped block into xfs_da3_node_read_mapped, which is the only caller ever passing a block number in the mappedbno argument and replace the mappedbno argument with the simple xfs_dabuf_get flags.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 34 ++++++++++++++++------------------ fs/xfs/libxfs/xfs_da_btree.h | 5 ++--- fs/xfs/libxfs/xfs_dir2_block.c | 4 ++-- fs/xfs/libxfs/xfs_dir2_data.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_leaf.c | 13 ++++++------- fs/xfs/libxfs/xfs_dir2_node.c | 14 +++++++------- fs/xfs/libxfs/xfs_dir2_priv.h | 4 ++-- fs/xfs/scrub/dabtree.c | 4 ++-- fs/xfs/scrub/dir.c | 9 +++++---- fs/xfs/xfs_dir2_readdir.c | 2 +- 11 files changed, 47 insertions(+), 50 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +1 -1
@@ -434,7 +434,7 @@ xfs_attr3_leaf_read( {int err; - err =xfs_da_read_buf (tp, dp, bno,-1 , bpp,XFS_ATTR_FORK , + err =xfs_da_read_buf (tp, dp, bno,0 , bpp,XFS_ATTR_FORK , &xfs_attr3_leaf_buf_ops);if (!err && tp && *bpp)xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_ATTR_LEAF_BUF );
fs/xfs/libxfs/xfs_da_btree.c +16 -18
@@ -369,7 +369,7 @@ xfs_da3_node_read( {int error; - error =xfs_da_read_buf (tp, dp, bno,-1 , bpp, whichfork, + error =xfs_da_read_buf (tp, dp, bno,0 , bpp, whichfork, &xfs_da3_node_buf_ops);if (error || !*bpp || !tp)return error;
@@ -384,12 +384,22 @@ xfs_da3_node_read_mapped( struct xfs_buf **bpp, int whichfork) { +struct xfs_mount *mp = dp->i_mount;int error; - error =xfs_da_read_buf (tp, dp,0 , mappedbno, bpp, whichfork, - &xfs_da3_node_buf_ops); -if (error || !*bpp || !tp) + error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, mappedbno, +XFS_FSB_TO_BB (mp,xfs_dabuf_nfsb (mp, whichfork)),0 , + bpp, &xfs_da3_node_buf_ops); +if (error || !*bpp)return error; + +if (whichfork ==XFS_ATTR_FORK ) +xfs_buf_set_ref (*bpp,XFS_ATTR_BTREE_REF ); +else +xfs_buf_set_ref (*bpp,XFS_DIR_BTREE_REF ); + +if (!tp) +return 0 ;return xfs_da3_node_set_type (tp, *bpp); }
@@ -2618,7 +2628,7 @@ xfs_da_read_buf(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t bno, - xfs_daddr_t mappedbno, + unsigned int flags, struct xfs_buf **bpp, int whichfork, const struct xfs_buf_ops *ops)
@@ -2630,24 +2640,12 @@ xfs_da_read_buf(int error; *bpp =NULL ; - -if (mappedbno >=0 ) { - error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, - mappedbno,XFS_FSB_TO_BB (mp, -xfs_dabuf_nfsb (mp, whichfork)), -0 , &bp, ops); - goto done; - } - - error =xfs_dabuf_map (dp, bno, - mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , - whichfork, &mapp, &nmap); + error =xfs_dabuf_map (dp, bno, flags, whichfork, &mapp, &nmap);if (error || !nmap) goto out_free; error =xfs_trans_read_buf_map (mp, tp, mp->m_ddev_targp, mapp, nmap,0 , &bp, ops); -done:if (error) goto out_free;
fs/xfs/libxfs/xfs_da_btree.h +2 -3
@@ -206,9 +206,8 @@ int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp, xfs_dablk_t bno, xfs_daddr_t mappedbno, struct xfs_buf **bp, int whichfork);int xfs_da_read_buf (struct xfs_trans *trans,struct xfs_inode *dp, -xfs_dablk_t bno,xfs_daddr_t mappedbno, -struct xfs_buf **bpp,int whichfork, -const struct xfs_buf_ops *ops); +xfs_dablk_t bno,unsigned int flags,struct xfs_buf **bpp, +int whichfork,const struct xfs_buf_ops *ops);int xfs_da_reada_buf (struct xfs_inode *dp,xfs_dablk_t bno,unsigned int flags,int whichfork,const struct xfs_buf_ops *ops);
fs/xfs/libxfs/xfs_dir2_block.c +2 -2
@@ -123,7 +123,7 @@ xfs_dir3_block_read(struct xfs_mount *mp = dp->i_mount;int err; - err =xfs_da_read_buf (tp, dp, mp->m_dir_geo->datablk,-1 , bpp, + err =xfs_da_read_buf (tp, dp, mp->m_dir_geo->datablk,0 , bpp,XFS_DATA_FORK , &xfs_dir3_block_buf_ops);if (!err && tp && *bpp)xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_BLOCK_BUF );
@@ -950,7 +950,7 @@ xfs_dir2_leaf_to_block(* Read the data block if we don't already have it, give up if it fails. */ if (!dbp) { - error =xfs_dir3_data_read (tp, dp, args->geo->datablk,-1 , &dbp); + error =xfs_dir3_data_read (tp, dp, args->geo->datablk,0 , &dbp);if (error)return error; }
fs/xfs/libxfs/xfs_dir2_data.c +3 -3
@@ -400,13 +400,13 @@ xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t bno, - xfs_daddr_t mapped_bno, + unsigned int flags, struct xfs_buf **bpp) { int err; - err =xfs_da_read_buf (tp, dp, bno, mapped_bno, bpp, -XFS_DATA_FORK , &xfs_dir3_data_buf_ops); + err =xfs_da_read_buf (tp, dp, bno, flags, bpp,XFS_DATA_FORK , + &xfs_dir3_data_buf_ops);if (!err && tp && *bpp)xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_DATA_BUF );return err;
fs/xfs/libxfs/xfs_dir2_leaf.c +6 -7
@@ -266,7 +266,7 @@ xfs_dir3_leaf_read( {int err; - err =xfs_da_read_buf (tp, dp, fbno,-1 , bpp,XFS_DATA_FORK , + err =xfs_da_read_buf (tp, dp, fbno,0 , bpp,XFS_DATA_FORK , &xfs_dir3_leaf1_buf_ops);if (!err && tp && *bpp)xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_LEAF1_BUF );
@@ -282,7 +282,7 @@ xfs_dir3_leafn_read( {int err; - err =xfs_da_read_buf (tp, dp, fbno,-1 , bpp,XFS_DATA_FORK , + err =xfs_da_read_buf (tp, dp, fbno,0 , bpp,XFS_DATA_FORK , &xfs_dir3_leafn_buf_ops);if (!err && tp && *bpp)xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_LEAFN_BUF );
@@ -826,7 +826,7 @@ xfs_dir2_leaf_addname(*/ error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (args->geo, use_block), --1 , &dbp); +0 , &dbp);if (error) {xfs_trans_brelse (tp, lbp);return error;
@@ -1268,7 +1268,7 @@ xfs_dir2_leaf_lookup_int(xfs_trans_brelse (tp, dbp); error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (args->geo, newdb), --1 , &dbp); +0 , &dbp);if (error) {xfs_trans_brelse (tp, lbp);return error;
@@ -1310,7 +1310,7 @@ xfs_dir2_leaf_lookup_int(xfs_trans_brelse (tp, dbp); error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (args->geo, cidb), --1 , &dbp); +0 , &dbp);if (error) {xfs_trans_brelse (tp, lbp);return error;
@@ -1602,8 +1602,7 @@ 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 (geo, db),-1 , - &dbp); + error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (geo, db),0 , &dbp);if (error)return error;
fs/xfs/libxfs/xfs_dir2_node.c +7 -7
@@ -212,14 +212,14 @@ __xfs_dir3_free_read(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t fbno, - xfs_daddr_t mappedbno, + unsigned int flags, struct xfs_buf **bpp) { xfs_failaddr_t fa;int err; - err =xfs_da_read_buf (tp, dp, fbno, mappedbno, bpp, -XFS_DATA_FORK , &xfs_dir3_free_buf_ops); + err =xfs_da_read_buf (tp, dp, fbno, flags, bpp,XFS_DATA_FORK , + &xfs_dir3_free_buf_ops);if (err || !*bpp)return err;
@@ -297,7 +297,7 @@ xfs_dir2_free_read(xfs_dablk_t fbno, struct xfs_buf **bpp) { - return __xfs_dir3_free_read(tp, dp, fbno, -1, bpp); + return __xfs_dir3_free_read(tp, dp, fbno, 0, bpp); } static int
@@ -307,7 +307,7 @@ xfs_dir2_free_try_read(xfs_dablk_t fbno, struct xfs_buf **bpp) { - return __xfs_dir3_free_read(tp, dp, fbno, -2, bpp); + return __xfs_dir3_free_read(tp, dp, fbno, XFS_DABUF_MAP_HOLE_OK, bpp); } static int
@@ -857,7 +857,7 @@ xfs_dir2_leafn_lookup_for_entry( error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (args->geo, newdb), --1 , &curbp); +0 , &curbp);if (error)return error; }
@@ -1940,7 +1940,7 @@ xfs_dir2_node_addname_int(/* Read the data block in. */ error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (args->geo, dbno), --1 , &dbp); +0 , &dbp); }if (error)return error;
fs/xfs/libxfs/xfs_dir2_priv.h +2 -2
@@ -77,8 +77,8 @@ extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);extern xfs_failaddr_t __xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp); -extern int xfs_dir3_data_read (struct xfs_trans *tp,struct xfs_inode *dp, -xfs_dablk_t bno,xfs_daddr_t mapped_bno,struct xfs_buf **bpp); +int xfs_dir3_data_read (struct xfs_trans *tp,struct xfs_inode *dp, +xfs_dablk_t bno,unsigned int flags,struct xfs_buf **bpp);int xfs_dir3_data_readahead (struct xfs_inode *dp,xfs_dablk_t bno,unsigned int flags);
fs/xfs/scrub/dabtree.c +2 -2
@@ -331,8 +331,8 @@ xchk_da_btree_block( goto out_nobuf;/* Read the buffer. */ - error =xfs_da_read_buf (dargs->trans, dargs->dp, blk->blkno,-2 , - &blk->bp, dargs->whichfork, + error =xfs_da_read_buf (dargs->trans, dargs->dp, blk->blkno, +XFS_DABUF_MAP_HOLE_OK , &blk->bp, dargs->whichfork, &xchk_da_btree_buf_ops);if (!xchk_da_process_error (ds, level, &error)) goto out_nobuf;
fs/xfs/scrub/dir.c +5 -4
@@ -229,7 +229,8 @@ xchk_dir_rec(xchk_da_set_corrupt (ds, level); goto out; } - error =xfs_dir3_data_read (ds->dargs.trans, dp, rec_bno,-2 , &bp); + error =xfs_dir3_data_read (ds->dargs.trans, dp, rec_bno, +XFS_DABUF_MAP_HOLE_OK , &bp);if (!xchk_fblock_process_error (ds->sc,XFS_DATA_FORK , rec_bno, &error)) goto out;
@@ -346,7 +347,7 @@ xchk_directory_data_bestfree( error =xfs_dir3_block_read (sc->tp, sc->ip, &bp); }else {/* dir data format */ - error =xfs_dir3_data_read (sc->tp, sc->ip, lblk,-1 , &bp); + error =xfs_dir3_data_read (sc->tp, sc->ip, lblk,0 , &bp); }if (!xchk_fblock_process_error (sc,XFS_DATA_FORK , lblk, &error)) goto out;
@@ -557,7 +558,7 @@ xchk_directory_leaf1_bestfree(if (best ==NULLDATAOFF )continue ; error =xfs_dir3_data_read (sc->tp, sc->ip, - i * args->geo->fsbcount,-1 , &dbp); + i * args->geo->fsbcount,0 , &dbp);if (!xchk_fblock_process_error (sc,XFS_DATA_FORK , lblk, &error))break ;
@@ -608,7 +609,7 @@ xchk_directory_free_bestfree( } error =xfs_dir3_data_read (sc->tp, sc->ip, (freehdr.firstdb + i) * args->geo->fsbcount, --1 , &dbp); +0 , &dbp);if (!xchk_fblock_process_error (sc,XFS_DATA_FORK , lblk, &error))break ;
fs/xfs/xfs_dir2_readdir.c +1 -1
@@ -279,7 +279,7 @@ xfs_dir2_leaf_readbuf( new_off =xfs_dir2_da_to_byte (geo, map.br_startoff);if (new_off > *cur_off) *cur_off = new_off; - error =xfs_dir3_data_read (args->trans, dp, map.br_startoff,-1 , &bp); + error =xfs_dir3_data_read (args->trans, dp, map.br_startoff,0 , &bp);if (error) goto out;
Signature · 1 line
2.20.1
PATCH 10/10 xfs: remove the mappedbno argument to xfs_da_get_buf
In reply to Christoph HellwigUse the xfs_da_get_buf_daddr function directly for the two callers that pass a mapped disk address, and then remove the mappedbno argument.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 4 ++-- fs/xfs/libxfs/xfs_da_btree.c | 18 +++--------------- fs/xfs/libxfs/xfs_da_btree.h | 3 +-- fs/xfs/libxfs/xfs_dir2_data.c | 2 +- fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 2 +- fs/xfs/xfs_attr_inactive.c | 24 +++++++++++++++++++----- 7 files changed, 28 insertions(+), 27 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +2 -2
@@ -1162,7 +1162,7 @@ xfs_attr3_leaf_to_node(if (error) goto out; - error =xfs_da_get_buf (args->trans, dp, blkno,-1 , &bp2,XFS_ATTR_FORK ); + error =xfs_da_get_buf (args->trans, dp, blkno, &bp2,XFS_ATTR_FORK );if (error) goto out;
@@ -1223,7 +1223,7 @@ xfs_attr3_leaf_create(trace_xfs_attr_leaf_create (args); - error =xfs_da_get_buf (args->trans, args->dp, blkno,-1 , &bp, + error =xfs_da_get_buf (args->trans, args->dp, blkno, &bp,XFS_ATTR_FORK );if (error)return error;
fs/xfs/libxfs/xfs_da_btree.c +3 -15
@@ -429,7 +429,7 @@ xfs_da3_node_create(trace_xfs_da_node_create (args);ASSERT (level <=XFS_DA_NODE_MAXDEPTH ); - error =xfs_da_get_buf (tp, dp, blkno,-1 , &bp, whichfork); + error =xfs_da_get_buf (tp, dp, blkno, &bp, whichfork);if (error)return error; bp->b_ops = &xfs_da3_node_buf_ops;
@@ -656,7 +656,7 @@ xfs_da3_root_split( dp = args->dp; tp = args->trans; - error =xfs_da_get_buf (tp, dp, blkno,-1 , &bp, args->whichfork); + error =xfs_da_get_buf (tp, dp, blkno, &bp, args->whichfork);if (error)return error; node = bp->b_addr;
@@ -2577,7 +2577,6 @@ xfs_da_get_buf(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t bno, - xfs_daddr_t mappedbno, struct xfs_buf **bpp, int whichfork) {
@@ -2588,22 +2587,11 @@ xfs_da_get_buf(int error; *bpp =NULL ; - -if (mappedbno >=0 ) { - bp =xfs_trans_get_buf (tp, mp->m_ddev_targp, mappedbno, -XFS_FSB_TO_BB (mp, -xfs_dabuf_nfsb (mp, whichfork)),0 ); - goto done; - } - - error =xfs_dabuf_map (dp, bno, - mappedbno ==-1 ?XFS_DABUF_MAP_HOLE_OK :0 , - whichfork, &mapp, &nmap); + error =xfs_dabuf_map (dp, bno,0 , whichfork, &mapp, &nmap);if (error || nmap ==0 ) goto out_free; bp =xfs_trans_get_buf_map (tp, mp->m_ddev_targp, mapp, nmap,0 ); -done: error = bp ? bp->b_error : -EIO ;if (error) {if (bp)
fs/xfs/libxfs/xfs_da_btree.h +1 -2
@@ -203,8 +203,7 @@ int xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno);int xfs_da_grow_inode_int (struct xfs_da_args *args,xfs_fileoff_t *bno,int count);int xfs_da_get_buf (struct xfs_trans *trans,struct xfs_inode *dp, -xfs_dablk_t bno,xfs_daddr_t mappedbno, -struct xfs_buf **bp,int whichfork); +xfs_dablk_t bno,struct xfs_buf **bp,int whichfork);int xfs_da_read_buf (struct xfs_trans *trans,struct xfs_inode *dp,xfs_dablk_t bno,unsigned int flags,struct xfs_buf **bpp,int whichfork,const struct xfs_buf_ops *ops);
fs/xfs/libxfs/xfs_dir2_data.c +1 -1
@@ -679,7 +679,7 @@ xfs_dir3_data_init(* Get the buffer set up for the block. */ error =xfs_da_get_buf (tp, dp,xfs_dir2_db_to_da (args->geo, blkno), --1 , &bp,XFS_DATA_FORK ); + &bp,XFS_DATA_FORK );if (error)return error; bp->b_ops = &xfs_dir3_data_buf_ops;
fs/xfs/libxfs/xfs_dir2_leaf.c +1 -1
@@ -355,7 +355,7 @@ xfs_dir3_leaf_get_buf( bno < xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET)); error =xfs_da_get_buf (tp, dp,xfs_dir2_db_to_da (args->geo, bno), --1 , &bp,XFS_DATA_FORK ); + &bp,XFS_DATA_FORK );if (error)return error;
fs/xfs/libxfs/xfs_dir2_node.c +1 -1
@@ -324,7 +324,7 @@ xfs_dir3_free_get_buf(struct xfs_dir3_icfree_hdr hdr; error =xfs_da_get_buf (tp, dp,xfs_dir2_db_to_da (args->geo, fbno), --1 , &bp,XFS_DATA_FORK ); + &bp,XFS_DATA_FORK );if (error)return error;
fs/xfs/xfs_attr_inactive.c +19 -5
@@ -196,6 +196,7 @@ xfs_attr3_node_inactive( struct xfs_buf *bp, int level) { +struct xfs_mount *mp = dp->i_mount;struct xfs_da_blkinfo *info;xfs_dablk_t child_fsb;xfs_daddr_t parent_blkno, child_blkno;
@@ -267,10 +268,16 @@ xfs_attr3_node_inactive(/* * Remove the subsidiary block from the cache and from the log. */ - error =xfs_da_get_buf (*trans, dp,0 , child_blkno, &child_bp, -XFS_ATTR_FORK ); -if (error) + child_bp =xfs_trans_get_buf (*trans, mp->m_ddev_targp, + child_blkno, +XFS_FSB_TO_BB (mp, mp->m_attr_geo->fsbcount),0 ); +if (!child_bp) +return -EIO ; + error = bp->b_error; +if (error) { +xfs_trans_brelse (*trans, child_bp);return error; + }xfs_trans_binval (*trans, child_bp);/*
@@ -311,6 +318,7 @@ xfs_attr3_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp) { + struct xfs_mount *mp = dp->i_mount;struct xfs_da_blkinfo *info;struct xfs_buf *bp;xfs_daddr_t blkno;
@@ -353,9 +361,15 @@ xfs_attr3_root_inactive(/* * Invalidate the incore copy of the root block. */ - error =xfs_da_get_buf (*trans, dp,0 , blkno, &bp,XFS_ATTR_FORK ); -if (error) + bp =xfs_trans_get_buf (*trans, mp->m_ddev_targp, blkno, +XFS_FSB_TO_BB (mp, mp->m_attr_geo->fsbcount),0 ); +if (!bp) +return -EIO ; + error = bp->b_error; +if (error) { +xfs_trans_brelse (*trans, bp);return error; + }xfs_trans_binval (*trans, bp);/* remove from cache */ /* * Commit the invalidate and start the next transaction.
Signature · 1 line
2.20.1