RFC: remove the if_flags field in struct xfs_ifork
Hi all,
given how much confusion the ifork flags cause I thought we'd better off just removing them as all the information is available from other fields in the ifork structure anyway.
Only very lightly tested so far and thus for conceptual review. It will need a rebase of the attr initialization fixes anyway.
Diffstat:
libxfs/xfs_attr.c | 53 ++++++++++------ libxfs/xfs_attr.h | 1 libxfs/xfs_attr_leaf.c | 13 +--- libxfs/xfs_bmap.c | 141 +++++++++++++-------------------------------- libxfs/xfs_bmap.h | 1 libxfs/xfs_btree_staging.c | 1 libxfs/xfs_dir2_block.c | 2 libxfs/xfs_dir2_sf.c | 12 +-- libxfs/xfs_inode_fork.c | 22 +------ libxfs/xfs_inode_fork.h | 14 +--- scrub/bmap.c | 15 +--- scrub/symlink.c | 2 xfs_aops.c | 3 xfs_attr_list.c | 2 xfs_bmap_util.c | 20 ++---- xfs_dir2_readdir.c | 10 +-- xfs_dquot.c | 8 -- xfs_inode.c | 9 -- xfs_ioctl.c | 2 xfs_iomap.c | 20 ++---- xfs_iops.c | 4 - xfs_qm.c | 8 -- xfs_reflink.c | 8 -- xfs_symlink.c | 6 - 24 files changed, 141 insertions(+), 236 deletions(-)
PATCH 1/7 xfs: move the XFS_IFEXTENTS check into xfs_iread_extents
Move the XFS_IFEXTENTS check from the callers into xfs_iread_extents to simplify the code.
--- fs/xfs/libxfs/xfs_bmap.c | 82 ++++++++++++++++----------------------- fs/xfs/scrub/bmap.c | 9 ++--- fs/xfs/xfs_bmap_util.c | 16 +++----- fs/xfs/xfs_dir2_readdir.c | 8 ++-- fs/xfs/xfs_dquot.c | 8 ++-- fs/xfs/xfs_iomap.c | 16 +++----- fs/xfs/xfs_qm.c | 8 ++-- fs/xfs/xfs_reflink.c | 8 ++-- 8 files changed, 62 insertions(+), 93 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +34 -48
@@ -1223,6 +1223,9 @@ xfs_iread_extents(ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +if (ifp->if_flags &XFS_IFEXTENTS ) +return 0 ; +if (XFS_IS_CORRUPT (mp, ifp->if_format !=XFS_DINODE_FMT_BTREE )) { error = -EFSCORRUPTED ; goto out;
@@ -1278,11 +1281,9 @@ xfs_bmap_first_unused(ASSERT (xfs_ifork_has_extents (ifp)); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error; lowest = max = *first_unused;for_each_xfs_iext (ifp, &icur, &got) {
@@ -1330,11 +1331,9 @@ xfs_bmap_last_before(return -EFSCORRUPTED ; } -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (!xfs_iext_lookup_extent_before (ip, ifp, last_block, &icur, &got)) *last_block =0 ;
@@ -1353,11 +1352,9 @@ xfs_bmap_last_extent(struct xfs_iext_cursor icur;int error; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;xfs_iext_last (ifp, &icur);if (!xfs_iext_get_extent (ifp, &icur, rec))
@@ -3984,11 +3981,9 @@ xfs_bmapi_read(XFS_STATS_INC (mp, xs_blk_mapr); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (NULL , ip, whichfork); +if (error) +return error;if (!xfs_iext_lookup_extent (ip, ifp, bno, &icur, &got)) eof = true;
@@ -4468,11 +4463,9 @@ xfs_bmapi_write(XFS_STATS_INC (mp, xs_blk_mapw); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) - goto error0; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) + goto error0;if (!xfs_iext_lookup_extent (ip, ifp, bno, &bma.icur, &bma.got)) eof = true;
@@ -4751,11 +4744,9 @@ xfs_bmapi_remap(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (xfs_iext_lookup_extent (ip, ifp, bno, &icur, &got)) {/* make sure we only reflink into a hole. */
@@ -5426,9 +5417,10 @@ __xfs_bunmapi(else max_len = len; -if (!(ifp->if_flags &XFS_IFEXTENTS ) && - (error =xfs_iread_extents (tp, ip, whichfork))) + error =xfs_iread_extents (tp, ip, whichfork); +if (error)return error; +if (xfs_iext_count (ifp) ==0 ) { *rlen =0 ;return 0 ;
@@ -5914,11 +5906,9 @@ xfs_bmap_collapse_extents(ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork);
@@ -6031,11 +6021,9 @@ xfs_bmap_insert_extents(ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork);
@@ -6134,12 +6122,10 @@ xfs_bmap_split_extent(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { -/* Read in all the extents */ - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } +/* Read in all the extents */ + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;/* * If there are not extents, or split_fsb lies in a hole we are done.
fs/xfs/scrub/bmap.c +4 -5
@@ -449,11 +449,10 @@ xchk_bmap_btree(/* Load the incore bmap cache if it's not loaded. */ info->was_loaded = ifp->if_flags &XFS_IFEXTENTS ; -if (!info->was_loaded) { - error =xfs_iread_extents (sc->tp, ip, whichfork); -if (!xchk_fblock_process_error (sc, whichfork,0 , &error)) - goto out; - } + + error =xfs_iread_extents (sc->tp, ip, whichfork); +if (!xchk_fblock_process_error (sc, whichfork,0 , &error)) + goto out;/* Check the btree structure. */ cur =xfs_bmbt_init_cursor (mp, sc->tp, ip, whichfork);
fs/xfs/xfs_bmap_util.c +6 -10
@@ -225,11 +225,9 @@ xfs_bmap_count_blocks(switch (ifp->if_format) {case XFS_DINODE_FMT_BTREE : -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error; cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); error =xfs_btree_count_blocks (cur, &btblocks);
@@ -471,11 +469,9 @@ xfs_getbmap( first_bno = bno =XFS_BB_TO_FSBT (mp, bmv->bmv_offset); len =XFS_BB_TO_FSB (mp, bmv->bmv_length); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip, whichfork); -if (error) - goto out_unlock_ilock; - } + error =xfs_iread_extents (NULL , ip, whichfork); +if (error) + goto out_unlock_ilock;if (!xfs_iext_lookup_extent (ip, ifp, bno, &icur, &got)) {/*
fs/xfs/xfs_dir2_readdir.c +3 -5
@@ -258,11 +258,9 @@ xfs_dir2_leaf_readbuf(int ra_want;int error =0 ; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (args->trans, dp,XFS_DATA_FORK ); -if (error) - goto out; - } + error =xfs_iread_extents (args->trans, dp,XFS_DATA_FORK ); +if (error) + goto out;/* * Look for mapped directory blocks at or above the current offset.
fs/xfs/xfs_dquot.c +3 -5
@@ -748,11 +748,9 @@ xfs_dq_get_next_id( start = (xfs_fsblock_t )next_id / mp->m_quotainfo->qi_dqperchunk; lock_flags =xfs_ilock_data_map_shared (quotip); -if (!(quotip->i_df.if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , quotip,XFS_DATA_FORK ); -if (error) -return error; - } + error =xfs_iread_extents (NULL , quotip,XFS_DATA_FORK ); +if (error) +return error;if (xfs_iext_lookup_extent (quotip, "ip->i_df, start, &cur, &got)) {/* contiguous chunk, bump startoff for the id calculation */
fs/xfs/xfs_iomap.c +6 -10
@@ -893,11 +893,9 @@ xfs_buffered_write_iomap_begin(XFS_STATS_INC (mp, xs_blk_mapw); -if (!(ip->i_df.if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); -if (error) - goto out_unlock; - } + error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); +if (error) + goto out_unlock;/* * Search the data fork first to look up our source mapping. We
@@ -1208,11 +1206,9 @@ xfs_seek_iomap_begin(return -EIO ; lockmode =xfs_ilock_data_map_shared (ip); -if (!(ip->i_df.if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); -if (error) - goto out_unlock; - } + error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); +if (error) + goto out_unlock;if (xfs_iext_lookup_extent (ip, &ip->i_df, offset_fsb, &icur, &imap)) {/*
fs/xfs/xfs_qm.c +3 -5
@@ -1165,11 +1165,9 @@ xfs_qm_dqusage_adjust(if (XFS_IS_REALTIME_INODE (ip)) {struct xfs_ifork *ifp =XFS_IFORK_PTR (ip,XFS_DATA_FORK ); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); -if (error) - goto error0; - } + error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); +if (error) + goto error0;xfs_bmap_count_leaves (ifp, &rtblks); }
fs/xfs/xfs_reflink.c +3 -5
@@ -1392,11 +1392,9 @@ xfs_reflink_inode_has_shared_extents(int error; ifp =XFS_IFORK_PTR (ip,XFS_DATA_FORK ); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); +if (error) +return error; *has_shared = false; found =xfs_iext_lookup_extent (ip, ifp,0 , &icur, &got);
Signature · 1 line
2.30.1
Re: [PATCH 1/7] xfs: move the XFS_IFEXTENTS check into xfs_iread_extents
Quoted 5 lines · Christoph Hellwig
Move the
XFS_IFEXTENTScheck from the callers intoxfs_iread_extentsto simplify the code.Signed-off-by Christoph Hellwig <[email protected]>---
Looks reasonable enough on its own:
Quoted 341 lines
fs/xfs/libxfs/xfs_bmap.c | 82 ++++++++++++++++----------------------- fs/xfs/scrub/bmap.c | 9 ++--- fs/xfs/xfs_bmap_util.c | 16 +++----- fs/xfs/xfs_dir2_readdir.c | 8 ++-- fs/xfs/xfs_dquot.c | 8 ++-- fs/xfs/xfs_iomap.c | 16 +++----- fs/xfs/xfs_qm.c | 8 ++-- fs/xfs/xfs_reflink.c | 8 ++-- 8 files changed, 62 insertions(+), 93 deletions(-)fs/xfs/libxfs/xfs_bmap.c +34
-48@@ -1223,6 +1223,9 @@ xfs_iread_extents(ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +if (ifp->if_flags &XFS_IFEXTENTS ) +return 0 ; +if (XFS_IS_CORRUPT (mp, ifp->if_format !=XFS_DINODE_FMT_BTREE )) { error = -EFSCORRUPTED ; goto out;@@ -1278,11 +1281,9 @@ xfs_bmap_first_unused(ASSERT (xfs_ifork_has_extents (ifp)); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error; lowest = max = *first_unused;for_each_xfs_iext (ifp, &icur, &got) {@@ -1330,11 +1331,9 @@ xfs_bmap_last_before(return -EFSCORRUPTED ; } -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (!xfs_iext_lookup_extent_before (ip, ifp, last_block, &icur, &got)) *last_block =0 ;@@ -1353,11 +1352,9 @@ xfs_bmap_last_extent(struct xfs_iext_cursor icur;int error; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;xfs_iext_last (ifp, &icur);if (!xfs_iext_get_extent (ifp, &icur, rec))@@ -3984,11 +3981,9 @@ xfs_bmapi_read(XFS_STATS_INC (mp, xs_blk_mapr); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (NULL , ip, whichfork); +if (error) +return error;if (!xfs_iext_lookup_extent (ip, ifp, bno, &icur, &got)) eof = true;@@ -4468,11 +4463,9 @@ xfs_bmapi_write(XFS_STATS_INC (mp, xs_blk_mapw); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) - goto error0; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) + goto error0;if (!xfs_iext_lookup_extent (ip, ifp, bno, &bma.icur, &bma.got)) eof = true;@@ -4751,11 +4744,9 @@ xfs_bmapi_remap(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (xfs_iext_lookup_extent (ip, ifp, bno, &icur, &got)) {/* make sure we only reflink into a hole. */ @@ -5426,9 +5417,10 @@ __xfs_bunmapi(else max_len = len; -if (!(ifp->if_flags &XFS_IFEXTENTS ) && - (error =xfs_iread_extents (tp, ip, whichfork))) + error =xfs_iread_extents (tp, ip, whichfork); +if (error)return error; +if (xfs_iext_count (ifp) ==0 ) { *rlen =0 ;return 0 ;@@ -5914,11 +5906,9 @@ xfs_bmap_collapse_extents(ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork);@@ -6031,11 +6021,9 @@ xfs_bmap_insert_extents(ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork);@@ -6134,12 +6122,10 @@ xfs_bmap_split_extent(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { -/* Read in all the extents */ - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } +/* Read in all the extents */ + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;/* * If there are not extents, or split_fsb lies in a hole we are done. fs/xfs/scrub/bmap.c +4
-5@@ -449,11 +449,10 @@ xchk_bmap_btree(/* Load the incore bmap cache if it's not loaded. */ info->was_loaded = ifp->if_flags &XFS_IFEXTENTS ; -if (!info->was_loaded) { - error =xfs_iread_extents (sc->tp, ip, whichfork); -if (!xchk_fblock_process_error (sc, whichfork,0 , &error)) - goto out; - } + + error =xfs_iread_extents (sc->tp, ip, whichfork); +if (!xchk_fblock_process_error (sc, whichfork,0 , &error)) + goto out;/* Check the btree structure. */ cur =xfs_bmbt_init_cursor (mp, sc->tp, ip, whichfork);fs/xfs/xfs_bmap_util.c +6
-10@@ -225,11 +225,9 @@ xfs_bmap_count_blocks(switch (ifp->if_format) {case XFS_DINODE_FMT_BTREE : -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error; cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); error =xfs_btree_count_blocks (cur, &btblocks);@@ -471,11 +469,9 @@ xfs_getbmap( first_bno = bno =XFS_BB_TO_FSBT (mp, bmv->bmv_offset); len =XFS_BB_TO_FSB (mp, bmv->bmv_length); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip, whichfork); -if (error) - goto out_unlock_ilock; - } + error =xfs_iread_extents (NULL , ip, whichfork); +if (error) + goto out_unlock_ilock;if (!xfs_iext_lookup_extent (ip, ifp, bno, &icur, &got)) {/* fs/xfs/xfs_dir2_readdir.c +3
-5@@ -258,11 +258,9 @@ xfs_dir2_leaf_readbuf(int ra_want;int error =0 ; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (args->trans, dp,XFS_DATA_FORK ); -if (error) - goto out; - } + error =xfs_iread_extents (args->trans, dp,XFS_DATA_FORK ); +if (error) + goto out;/* * Look for mapped directory blocks at or above the current offset. fs/xfs/xfs_dquot.c +3
-5@@ -748,11 +748,9 @@ xfs_dq_get_next_id( start = (xfs_fsblock_t )next_id / mp->m_quotainfo->qi_dqperchunk; lock_flags =xfs_ilock_data_map_shared (quotip); -if (!(quotip->i_df.if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , quotip,XFS_DATA_FORK ); -if (error) -return error; - } + error =xfs_iread_extents (NULL , quotip,XFS_DATA_FORK ); +if (error) +return error;if (xfs_iext_lookup_extent (quotip, "ip->i_df, start, &cur, &got)) {/* contiguous chunk, bump startoff for the id calculation */ fs/xfs/xfs_iomap.c +6
-10@@ -893,11 +893,9 @@ xfs_buffered_write_iomap_begin(XFS_STATS_INC (mp, xs_blk_mapw); -if (!(ip->i_df.if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); -if (error) - goto out_unlock; - } + error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); +if (error) + goto out_unlock;/* * Search the data fork first to look up our source mapping. We @@ -1208,11 +1206,9 @@ xfs_seek_iomap_begin(return -EIO ; lockmode =xfs_ilock_data_map_shared (ip); -if (!(ip->i_df.if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); -if (error) - goto out_unlock; - } + error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); +if (error) + goto out_unlock;if (xfs_iext_lookup_extent (ip, &ip->i_df, offset_fsb, &icur, &imap)) {/* fs/xfs/xfs_qm.c +3
-5@@ -1165,11 +1165,9 @@ xfs_qm_dqusage_adjust(if (XFS_IS_REALTIME_INODE (ip)) {struct xfs_ifork *ifp =XFS_IFORK_PTR (ip,XFS_DATA_FORK ); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); -if (error) - goto error0; - } + error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); +if (error) + goto error0;xfs_bmap_count_leaves (ifp, &rtblks); }fs/xfs/xfs_reflink.c +3
-5@@ -1392,11 +1392,9 @@ xfs_reflink_inode_has_shared_extents(int error; ifp =XFS_IFORK_PTR (ip,XFS_DATA_FORK ); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); +if (error) +return error; *has_shared = false; found =xfs_iext_lookup_extent (ip, ifp,0 , &icur, &got);Signature · 1 line
2.30.1
Re: [PATCH 1/7] xfs: move the XFS_IFEXTENTS check into xfs_iread_extents
In reply to Christoph HellwigQuoted 20 lines · Christoph Hellwig
Move the
XFS_IFEXTENTScheck from the callers intoxfs_iread_extentsto simplify the code.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 82 ++++++++++++++++----------------------- fs/xfs/scrub/bmap.c | 9 ++--- fs/xfs/xfs_bmap_util.c | 16 +++----- fs/xfs/xfs_dir2_readdir.c | 8 ++-- fs/xfs/xfs_dquot.c | 8 ++-- fs/xfs/xfs_iomap.c | 16 +++----- fs/xfs/xfs_qm.c | 8 ++-- fs/xfs/xfs_reflink.c | 8 ++-- 8 files changed, 62 insertions(+), 93 deletions(-)fs/xfs/libxfs/xfs_bmap.c +0
-0
fs/xfs/libxfs/xfs_bmap.c xfs_iread_extents( · line 1224
Quoted 2 lines
fs/xfs/libxfs/xfs_bmap.c +0
-0@@ -1223,6 +1223,9 @@ xfs_iread_extents(ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));
Since we now call xfs_iread_extents unconditionally, this assert will trip every time someone wants to bmapi_read the extent data after the extent data has been loaded in, because xfs_ilock_data_map_shared tells callers they only need to take ILOCK_SHARED... right?
--D
Quoted 323 lines
fs/xfs/libxfs/xfs_bmap.c +34
-48+if (ifp->if_flags &XFS_IFEXTENTS ) +return 0 ; +if (XFS_IS_CORRUPT (mp, ifp->if_format !=XFS_DINODE_FMT_BTREE )) { error = -EFSCORRUPTED ; goto out;@@ -1278,11 +1281,9 @@ xfs_bmap_first_unused(ASSERT (xfs_ifork_has_extents (ifp)); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error; lowest = max = *first_unused;for_each_xfs_iext (ifp, &icur, &got) {@@ -1330,11 +1331,9 @@ xfs_bmap_last_before(return -EFSCORRUPTED ; } -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (!xfs_iext_lookup_extent_before (ip, ifp, last_block, &icur, &got)) *last_block =0 ;@@ -1353,11 +1352,9 @@ xfs_bmap_last_extent(struct xfs_iext_cursor icur;int error; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;xfs_iext_last (ifp, &icur);if (!xfs_iext_get_extent (ifp, &icur, rec))@@ -3984,11 +3981,9 @@ xfs_bmapi_read(XFS_STATS_INC (mp, xs_blk_mapr); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (NULL , ip, whichfork); +if (error) +return error;if (!xfs_iext_lookup_extent (ip, ifp, bno, &icur, &got)) eof = true;@@ -4468,11 +4463,9 @@ xfs_bmapi_write(XFS_STATS_INC (mp, xs_blk_mapw); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) - goto error0; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) + goto error0;if (!xfs_iext_lookup_extent (ip, ifp, bno, &bma.icur, &bma.got)) eof = true;@@ -4751,11 +4744,9 @@ xfs_bmapi_remap(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (xfs_iext_lookup_extent (ip, ifp, bno, &icur, &got)) {/* make sure we only reflink into a hole. */ @@ -5426,9 +5417,10 @@ __xfs_bunmapi(else max_len = len; -if (!(ifp->if_flags &XFS_IFEXTENTS ) && - (error =xfs_iread_extents (tp, ip, whichfork))) + error =xfs_iread_extents (tp, ip, whichfork); +if (error)return error; +if (xfs_iext_count (ifp) ==0 ) { *rlen =0 ;return 0 ;@@ -5914,11 +5906,9 @@ xfs_bmap_collapse_extents(ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork);@@ -6031,11 +6021,9 @@ xfs_bmap_insert_extents(ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork);@@ -6134,12 +6122,10 @@ xfs_bmap_split_extent(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { -/* Read in all the extents */ - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } +/* Read in all the extents */ + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error;/* * If there are not extents, or split_fsb lies in a hole we are done. fs/xfs/scrub/bmap.c +4
-5@@ -449,11 +449,10 @@ xchk_bmap_btree(/* Load the incore bmap cache if it's not loaded. */ info->was_loaded = ifp->if_flags &XFS_IFEXTENTS ; -if (!info->was_loaded) { - error =xfs_iread_extents (sc->tp, ip, whichfork); -if (!xchk_fblock_process_error (sc, whichfork,0 , &error)) - goto out; - } + + error =xfs_iread_extents (sc->tp, ip, whichfork); +if (!xchk_fblock_process_error (sc, whichfork,0 , &error)) + goto out;/* Check the btree structure. */ cur =xfs_bmbt_init_cursor (mp, sc->tp, ip, whichfork);fs/xfs/xfs_bmap_util.c +6
-10@@ -225,11 +225,9 @@ xfs_bmap_count_blocks(switch (ifp->if_format) {case XFS_DINODE_FMT_BTREE : -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip, whichfork); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error; cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); error =xfs_btree_count_blocks (cur, &btblocks);@@ -471,11 +469,9 @@ xfs_getbmap( first_bno = bno =XFS_BB_TO_FSBT (mp, bmv->bmv_offset); len =XFS_BB_TO_FSB (mp, bmv->bmv_length); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip, whichfork); -if (error) - goto out_unlock_ilock; - } + error =xfs_iread_extents (NULL , ip, whichfork); +if (error) + goto out_unlock_ilock;if (!xfs_iext_lookup_extent (ip, ifp, bno, &icur, &got)) {/* fs/xfs/xfs_dir2_readdir.c +3
-5@@ -258,11 +258,9 @@ xfs_dir2_leaf_readbuf(int ra_want;int error =0 ; -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (args->trans, dp,XFS_DATA_FORK ); -if (error) - goto out; - } + error =xfs_iread_extents (args->trans, dp,XFS_DATA_FORK ); +if (error) + goto out;/* * Look for mapped directory blocks at or above the current offset. fs/xfs/xfs_dquot.c +3
-5@@ -748,11 +748,9 @@ xfs_dq_get_next_id( start = (xfs_fsblock_t )next_id / mp->m_quotainfo->qi_dqperchunk; lock_flags =xfs_ilock_data_map_shared (quotip); -if (!(quotip->i_df.if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , quotip,XFS_DATA_FORK ); -if (error) -return error; - } + error =xfs_iread_extents (NULL , quotip,XFS_DATA_FORK ); +if (error) +return error;if (xfs_iext_lookup_extent (quotip, "ip->i_df, start, &cur, &got)) {/* contiguous chunk, bump startoff for the id calculation */ fs/xfs/xfs_iomap.c +6
-10@@ -893,11 +893,9 @@ xfs_buffered_write_iomap_begin(XFS_STATS_INC (mp, xs_blk_mapw); -if (!(ip->i_df.if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); -if (error) - goto out_unlock; - } + error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); +if (error) + goto out_unlock;/* * Search the data fork first to look up our source mapping. We @@ -1208,11 +1206,9 @@ xfs_seek_iomap_begin(return -EIO ; lockmode =xfs_ilock_data_map_shared (ip); -if (!(ip->i_df.if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); -if (error) - goto out_unlock; - } + error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK ); +if (error) + goto out_unlock;if (xfs_iext_lookup_extent (ip, &ip->i_df, offset_fsb, &icur, &imap)) {/* fs/xfs/xfs_qm.c +3
-5@@ -1165,11 +1165,9 @@ xfs_qm_dqusage_adjust(if (XFS_IS_REALTIME_INODE (ip)) {struct xfs_ifork *ifp =XFS_IFORK_PTR (ip,XFS_DATA_FORK ); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); -if (error) - goto error0; - } + error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); +if (error) + goto error0;xfs_bmap_count_leaves (ifp, &rtblks); }fs/xfs/xfs_reflink.c +3
-5@@ -1392,11 +1392,9 @@ xfs_reflink_inode_has_shared_extents(int error; ifp =XFS_IFORK_PTR (ip,XFS_DATA_FORK ); -if (!(ifp->if_flags &XFS_IFEXTENTS )) { - error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); -if (error) -return error; - } + error =xfs_iread_extents (tp, ip,XFS_DATA_FORK ); +if (error) +return error; *has_shared = false; found =xfs_iext_lookup_extent (ip, ifp,0 , &icur, &got);Signature · 1 line
2.30.1
Re: [PATCH 1/7] xfs: move the XFS_IFEXTENTS check into xfs_iread_extents
Quoted 11 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_bmap.c xfs_iread_extents( · line 1224
Quoted 6 lines
index
5574d345d066ed..b8cab14ca8ce8d100644fs/xfs/libxfs/xfs_bmap.c +0
-0@@ -1223,6 +1223,9 @@ xfs_iread_extents(ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));Since we now call
xfs_iread_extentsunconditionally, this assert will trip every time someone wants tobmapi_readthe extent data after the extent data has been loaded in, becausexfs_ilock_data_map_sharedtells callers they only need to takeILOCK_SHARED... right?
Yes. I've already moved this down in my local tree, as xfstests generic/001 hits this once XFS_DEBUG is enabled. I also had to fix the inode variable name in a few places to even make that config compile. As said this was _very_ lightly tested - I only did a quick run on a non-debug config, but that passed with flying colors :)
PATCH 2/7 xfs: rename and simplify xfs_bmap_one_block
In reply to Christoph Hellwigxfs_bmap_one_block is only called for the attribute fork. Move it to xfs_attr.c, drop the unused whichfork argument and code only executed for the data fork and rename the result to xfs_attr_is_leaf.
--- fs/xfs/libxfs/xfs_attr.c | 30 +++++++++++++++++++++++++----- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_bmap.c | 32 -------------------------------- fs/xfs/libxfs/xfs_bmap.h | 1 - fs/xfs/xfs_attr_list.c | 2 +- 5 files changed, 27 insertions(+), 39 deletions(-)
fs/xfs/libxfs/xfs_attr.c +25 -5
@@ -70,6 +70,26 @@ xfs_inode_hasattr(return 1 ; } +/* +* Returns true if the there is exactly only block in the attr fork, in which +* case the attribute fork consists of a single leaf block entry. +*/ +bool +xfs_attr_is_leaf ( +struct xfs_inode *ip) +{ +struct xfs_ifork *ifp = ip->i_afp; +struct xfs_iext_cursor icur; +struct xfs_bmbt_irec imap; + +if (ifp->if_nextents !=1 || ifp->if_format !=XFS_DINODE_FMT_EXTENTS ) +return false; + +xfs_iext_first (ifp, &icur); +xfs_iext_get_extent (ifp, &icur, &imap); +return imap.br_startoff ==0 && imap.br_blockcount ==1 ; +} +/*======================================================================== * Overall external interface routines. *========================================================================*/
@@ -89,7 +109,7 @@ xfs_attr_get_ilocked(if (args->dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL )return xfs_attr_shortform_getvalue (args); -if (xfs_bmap_one_block (args->dp,XFS_ATTR_FORK )) +if (xfs_attr_is_leaf (args->dp))return xfs_attr_leaf_get (args);return xfs_attr_node_get (args); }
@@ -293,7 +313,7 @@ xfs_attr_set_args(return error; } -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { +if (xfs_attr_is_leaf (dp)) { error =xfs_attr_leaf_addname (args);if (error != -ENOSPC )return error;
@@ -347,7 +367,7 @@ xfs_has_attr(return xfs_attr_sf_findname (args,NULL ,NULL ); } -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { +if (xfs_attr_is_leaf (dp)) { error =xfs_attr_leaf_hasname (args, &bp);if (bp)
@@ -374,7 +394,7 @@ xfs_attr_remove_args( }else if (dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL ) {ASSERT (dp->i_afp->if_flags &XFS_IFINLINE ); error =xfs_attr_shortform_remove (args); - }else if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { + }else if (xfs_attr_is_leaf (dp)) { error =xfs_attr_leaf_removename (args); }else { error =xfs_attr_node_removename (args);
@@ -1282,7 +1302,7 @@ xfs_attr_node_removename(/* * If the result is small enough, push it all into the inode. */ -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) +if (xfs_attr_is_leaf (dp)) error =xfs_attr_node_shrink (args, state); out:
fs/xfs/libxfs/xfs_attr.h +1 -0
@@ -85,6 +85,7 @@ int xfs_attr_inactive(struct xfs_inode *dp);int xfs_attr_list_ilocked (struct xfs_attr_list_context *);int xfs_attr_list (struct xfs_attr_list_context *);int xfs_inode_hasattr (struct xfs_inode *ip); +bool xfs_attr_is_leaf (struct xfs_inode *ip);int xfs_attr_get_ilocked (struct xfs_da_args *args);int xfs_attr_get (struct xfs_da_args *args);int xfs_attr_set (struct xfs_da_args *args);
fs/xfs/libxfs/xfs_bmap.c +0 -32
@@ -1435,38 +1435,6 @@ xfs_bmap_last_offset(return 0 ; } -/* -* Returns whether the selected fork of the inode has exactly one -* block or not. For the data fork we check this matches di_size, -* implying the file's range is 0..bsize-1. -*/ -int /* 1=>1 block, 0=>otherwise */ -xfs_bmap_one_block ( -struct xfs_inode *ip,/* incore inode */ -int whichfork)/* data or attr fork */ -{ -struct xfs_ifork *ifp =XFS_IFORK_PTR (ip, whichfork); -int rval;/* return value */ -struct xfs_bmbt_irec s;/* internal version of extent */ -struct xfs_iext_cursor icur; - -#ifndef DEBUG -if (whichfork ==XFS_DATA_FORK ) -return XFS_ISIZE (ip) == ip->i_mount->m_sb.sb_blocksize; -#endif /* !DEBUG */ -if (ifp->if_nextents !=1 ) -return 0 ; -if (ifp->if_format !=XFS_DINODE_FMT_EXTENTS ) -return 0 ; -ASSERT (ifp->if_flags &XFS_IFEXTENTS ); -xfs_iext_first (ifp, &icur); -xfs_iext_get_extent (ifp, &icur, &s); - rval = s.br_startoff ==0 && s.br_blockcount ==1 ; -if (rval && whichfork ==XFS_DATA_FORK ) -ASSERT (XFS_ISIZE (ip) == ip->i_mount->m_sb.sb_blocksize); -return rval; -} -/* * Extent tree manipulation functions used during allocation. */
fs/xfs/libxfs/xfs_bmap.h +0 -1
@@ -199,7 +199,6 @@ int xfs_bmap_last_before(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t *last_block, int whichfork);int xfs_bmap_last_offset (struct xfs_inode *ip,xfs_fileoff_t *unused,int whichfork); -int xfs_bmap_one_block (struct xfs_inode *ip,int whichfork);int xfs_bmapi_read (struct xfs_inode *ip,xfs_fileoff_t bno,xfs_filblks_t len,struct xfs_bmbt_irec *mval,int *nmap,int flags);
fs/xfs/xfs_attr_list.c +1 -1
@@ -514,7 +514,7 @@ xfs_attr_list_ilocked(return 0 ;if (dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL )return xfs_attr_shortform_list (context); -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) +if (xfs_attr_is_leaf (dp))return xfs_attr_leaf_list (context);return xfs_attr_node_list (context); }
Signature · 1 line
2.30.1
Re: [PATCH 2/7] xfs: rename and simplify xfs_bmap_one_block
Quoted 6 lines · Christoph Hellwig
xfs_bmap_one_blockis only called for the attribute fork. Move it toxfs_attr.c, drop the unused whichfork argument and code only executed for the data fork and rename the result toxfs_attr_is_leaf.Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 166 lines
fs/xfs/libxfs/xfs_attr.c | 30 +++++++++++++++++++++++++----- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_bmap.c | 32 -------------------------------- fs/xfs/libxfs/xfs_bmap.h | 1 - fs/xfs/xfs_attr_list.c | 2 +- 5 files changed, 27 insertions(+), 39 deletions(-)fs/xfs/libxfs/xfs_attr.c +25
-5@@ -70,6 +70,26 @@ xfs_inode_hasattr(return 1 ; } +/* +* Returns true if the there is exactly only block in the attr fork, in which +* case the attribute fork consists of a single leaf block entry. +*/ +bool +xfs_attr_is_leaf ( +struct xfs_inode *ip) +{ +struct xfs_ifork *ifp = ip->i_afp; +struct xfs_iext_cursor icur; +struct xfs_bmbt_irec imap; + +if (ifp->if_nextents !=1 || ifp->if_format !=XFS_DINODE_FMT_EXTENTS ) +return false; + +xfs_iext_first (ifp, &icur); +xfs_iext_get_extent (ifp, &icur, &imap); +return imap.br_startoff ==0 && imap.br_blockcount ==1 ; +} +/*======================================================================== * Overall external interface routines. *========================================================================*/ @@ -89,7 +109,7 @@ xfs_attr_get_ilocked(if (args->dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL )return xfs_attr_shortform_getvalue (args); -if (xfs_bmap_one_block (args->dp,XFS_ATTR_FORK )) +if (xfs_attr_is_leaf (args->dp))return xfs_attr_leaf_get (args);return xfs_attr_node_get (args); }@@ -293,7 +313,7 @@ xfs_attr_set_args(return error; } -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { +if (xfs_attr_is_leaf (dp)) { error =xfs_attr_leaf_addname (args);if (error != -ENOSPC )return error;@@ -347,7 +367,7 @@ xfs_has_attr(return xfs_attr_sf_findname (args,NULL ,NULL ); } -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { +if (xfs_attr_is_leaf (dp)) { error =xfs_attr_leaf_hasname (args, &bp);if (bp)@@ -374,7 +394,7 @@ xfs_attr_remove_args( }else if (dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL ) {ASSERT (dp->i_afp->if_flags &XFS_IFINLINE ); error =xfs_attr_shortform_remove (args); - }else if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { + }else if (xfs_attr_is_leaf (dp)) { error =xfs_attr_leaf_removename (args); }else { error =xfs_attr_node_removename (args);@@ -1282,7 +1302,7 @@ xfs_attr_node_removename(/* * If the result is small enough, push it all into the inode. */ -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) +if (xfs_attr_is_leaf (dp)) error =xfs_attr_node_shrink (args, state); out:fs/xfs/libxfs/xfs_attr.h +1
-0@@ -85,6 +85,7 @@ int xfs_attr_inactive(struct xfs_inode *dp);int xfs_attr_list_ilocked (struct xfs_attr_list_context *);int xfs_attr_list (struct xfs_attr_list_context *);int xfs_inode_hasattr (struct xfs_inode *ip); +bool xfs_attr_is_leaf (struct xfs_inode *ip);int xfs_attr_get_ilocked (struct xfs_da_args *args);int xfs_attr_get (struct xfs_da_args *args);int xfs_attr_set (struct xfs_da_args *args);fs/xfs/libxfs/xfs_bmap.c +0
-32@@ -1435,38 +1435,6 @@ xfs_bmap_last_offset(return 0 ; } -/* -* Returns whether the selected fork of the inode has exactly one -* block or not. For the data fork we check this matches di_size, -* implying the file's range is 0..bsize-1. -*/ -int /* 1=>1 block, 0=>otherwise */ -xfs_bmap_one_block ( -struct xfs_inode *ip,/* incore inode */ -int whichfork)/* data or attr fork */ -{ -struct xfs_ifork *ifp =XFS_IFORK_PTR (ip, whichfork); -int rval;/* return value */ -struct xfs_bmbt_irec s;/* internal version of extent */ -struct xfs_iext_cursor icur; - -#ifndef DEBUG -if (whichfork ==XFS_DATA_FORK ) -return XFS_ISIZE (ip) == ip->i_mount->m_sb.sb_blocksize; -#endif /* !DEBUG */ -if (ifp->if_nextents !=1 ) -return 0 ; -if (ifp->if_format !=XFS_DINODE_FMT_EXTENTS ) -return 0 ; -ASSERT (ifp->if_flags &XFS_IFEXTENTS ); -xfs_iext_first (ifp, &icur); -xfs_iext_get_extent (ifp, &icur, &s); - rval = s.br_startoff ==0 && s.br_blockcount ==1 ; -if (rval && whichfork ==XFS_DATA_FORK ) -ASSERT (XFS_ISIZE (ip) == ip->i_mount->m_sb.sb_blocksize); -return rval; -} -/* * Extent tree manipulation functions used during allocation. */ fs/xfs/libxfs/xfs_bmap.h +0
-1@@ -199,7 +199,6 @@ int xfs_bmap_last_before(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t *last_block, int whichfork);int xfs_bmap_last_offset (struct xfs_inode *ip,xfs_fileoff_t *unused,int whichfork); -int xfs_bmap_one_block (struct xfs_inode *ip,int whichfork);int xfs_bmapi_read (struct xfs_inode *ip,xfs_fileoff_t bno,xfs_filblks_t len,struct xfs_bmbt_irec *mval,int *nmap,int flags);fs/xfs/xfs_attr_list.c +1
-1@@ -514,7 +514,7 @@ xfs_attr_list_ilocked(return 0 ;if (dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL )return xfs_attr_shortform_list (context); -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) +if (xfs_attr_is_leaf (dp))return xfs_attr_leaf_list (context);return xfs_attr_node_list (context); }Signature · 1 line
2.30.1
PATCH 3/7 xfs: simplify xfs_attr_remove_args
In reply to Christoph HellwigDirectly return from the subfunctions and avoid the error variable. Also remove the not really needed dp local variable.
--- fs/xfs/libxfs/xfs_attr.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
fs/xfs/libxfs/xfs_attr.c +8 -13
@@ -386,21 +386,16 @@ intxfs_attr_remove_args ( struct xfs_da_args *args) { -struct xfs_inode *dp = args->dp; -int error; +if (!xfs_inode_hasattr (args->dp)) +return -ENOATTR ; -if (!xfs_inode_hasattr (dp)) { - error = -ENOATTR ; - }else if (dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL ) { -ASSERT (dp->i_afp->if_flags &XFS_IFINLINE ); - error =xfs_attr_shortform_remove (args); - }else if (xfs_attr_is_leaf (dp)) { - error =xfs_attr_leaf_removename (args); - }else { - error =xfs_attr_node_removename (args); +if (args->dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL ) { +ASSERT (args->dp->i_afp->if_flags &XFS_IFINLINE ); +return xfs_attr_shortform_remove (args); } - -return error; +if (xfs_attr_is_leaf (args->dp)) +return xfs_attr_leaf_removename (args); +return xfs_attr_node_removename (args); }/*
Signature · 1 line
2.30.1
Re: [PATCH 3/7] xfs: simplify xfs_attr_remove_args
Quoted 5 lines · Christoph Hellwig
Directly return from the subfunctions and avoid the error variable. Also remove the not really needed dp local variable.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 40 lines
fs/xfs/libxfs/xfs_attr.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)fs/xfs/libxfs/xfs_attr.c +8
-13@@ -386,21 +386,16 @@ intxfs_attr_remove_args ( struct xfs_da_args *args) { -struct xfs_inode *dp = args->dp; -int error; +if (!xfs_inode_hasattr (args->dp)) +return -ENOATTR ; -if (!xfs_inode_hasattr (dp)) { - error = -ENOATTR ; - }else if (dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL ) { -ASSERT (dp->i_afp->if_flags &XFS_IFINLINE ); - error =xfs_attr_shortform_remove (args); - }else if (xfs_attr_is_leaf (dp)) { - error =xfs_attr_leaf_removename (args); - }else { - error =xfs_attr_node_removename (args); +if (args->dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL ) { +ASSERT (args->dp->i_afp->if_flags &XFS_IFINLINE ); +return xfs_attr_shortform_remove (args); } - -return error; +if (xfs_attr_is_leaf (args->dp)) +return xfs_attr_leaf_removename (args); +return xfs_attr_node_removename (args); }/* Signature · 1 line
2.30.1
PATCH 4/7 xfs: only look at the fork format in xfs_idestroy_fork
In reply to Christoph HellwigStop using the XFS_IFEXTENTS flag, and instead switch on the fork format in xfs_idestroy_fork to decide how to cleanup.
--- fs/xfs/libxfs/xfs_inode_fork.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
fs/xfs/libxfs/xfs_inode_fork.c +6 -7
@@ -522,17 +522,16 @@ xfs_idestroy_fork( ifp->if_broot =NULL ; } -/* -* If the format is local, then we can't have an extents array so just -* look for an inline data array. If we're not local then we may or may -* not have an extents list, so check and free it up if we do. -*/ -if (ifp->if_format ==XFS_DINODE_FMT_LOCAL ) { +switch (ifp->if_format) { +case XFS_DINODE_FMT_LOCAL :kmem_free (ifp->if_u1.if_data); ifp->if_u1.if_data =NULL ; - }else if (ifp->if_flags &XFS_IFEXTENTS ) { +break ; +case XFS_DINODE_FMT_EXTENTS : +case XFS_DINODE_FMT_BTREE :if (ifp->if_height)xfs_iext_destroy (ifp); +break ; } }
Signature · 1 line
2.30.1
Re: [PATCH 4/7] xfs: only look at the fork format in xfs_idestroy_fork
Quoted 5 lines · Christoph Hellwig
Stop using the
XFS_IFEXTENTSflag, and instead switch on the fork format inxfs_idestroy_forkto decide how to cleanup.Signed-off-by Christoph Hellwig <[email protected]>---
And FWIW the remaining patches seem generally reasonable to me at a quick read through. I'll probably have to take a closer look at the details once this is more solidified..
Brian
Quoted 34 lines
fs/xfs/libxfs/xfs_inode_fork.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)fs/xfs/libxfs/xfs_inode_fork.c +6
-7@@ -522,17 +522,16 @@ xfs_idestroy_fork( ifp->if_broot =NULL ; } -/* -* If the format is local, then we can't have an extents array so just -* look for an inline data array. If we're not local then we may or may -* not have an extents list, so check and free it up if we do. -*/ -if (ifp->if_format ==XFS_DINODE_FMT_LOCAL ) { +switch (ifp->if_format) { +case XFS_DINODE_FMT_LOCAL :kmem_free (ifp->if_u1.if_data); ifp->if_u1.if_data =NULL ; - }else if (ifp->if_flags &XFS_IFEXTENTS ) { +break ; +case XFS_DINODE_FMT_EXTENTS : +case XFS_DINODE_FMT_BTREE :if (ifp->if_height)xfs_iext_destroy (ifp); +break ; } }Signature · 1 line
2.30.1
PATCH 5/7 xfs: remove XFS_IFBROOT
In reply to Christoph HellwigJust check for a btree format fork instead of the using the equivalent in-memory XFS_IFBROOT flag.
--- fs/xfs/libxfs/xfs_bmap.c | 16 +++++++--------- fs/xfs/libxfs/xfs_btree_staging.c | 1 - fs/xfs/libxfs/xfs_inode_fork.c | 4 +--- fs/xfs/libxfs/xfs_inode_fork.h | 1 - 4 files changed, 8 insertions(+), 14 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +7 -9
@@ -631,7 +631,6 @@ xfs_bmap_btree_to_extents( cur->bc_bufs[0 ] =NULL ;xfs_iroot_realloc (ip,-1 , whichfork);ASSERT (ifp->if_broot ==NULL ); -ASSERT ((ifp->if_flags &XFS_IFBROOT ) ==0 ); ifp->if_format =XFS_DINODE_FMT_EXTENTS ; *logflagsp |=XFS_ILOG_CORE |xfs_ilog_fext (whichfork);return 0 ;
@@ -675,7 +674,6 @@ xfs_bmap_extents_to_btree(* to expand the root. */ xfs_iroot_realloc (ip,1 , whichfork); - ifp->if_flags |=XFS_IFBROOT ;/* * Fill in the root.
@@ -4189,7 +4187,7 @@ xfs_bmapi_allocate(return error; } -if ((ifp->if_flags &XFS_IFBROOT ) && !bma->cur) +if (ifp->if_format ==XFS_DINODE_FMT_BTREE && !bma->cur) bma->cur =xfs_bmbt_init_cursor (mp, bma->tp, bma->ip, whichfork);/* * Bump the number of extents we've allocated
@@ -4262,7 +4260,7 @@ xfs_bmapi_convert_unwritten(* Modify (by adding) the state flag, if writing. */ ASSERT (mval->br_blockcount <= len); -if ((ifp->if_flags &XFS_IFBROOT ) && !bma->cur) { +if (ifp->if_format ==XFS_DINODE_FMT_BTREE && !bma->cur) { bma->cur =xfs_bmbt_init_cursor (bma->ip->i_mount, bma->tp, bma->ip, whichfork); }
@@ -4725,7 +4723,7 @@ xfs_bmapi_remap( ip->i_d.di_nblocks += len;xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); -if (ifp->if_flags &XFS_IFBROOT ) { +if (ifp->if_format ==XFS_DINODE_FMT_BTREE ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_ino.flags =0 ; }
@@ -5404,7 +5402,7 @@ __xfs_bunmapi( end--; logflags =0 ; -if (ifp->if_flags &XFS_IFBROOT ) { +if (ifp->if_format ==XFS_DINODE_FMT_BTREE ) {ASSERT (ifp->if_format ==XFS_DINODE_FMT_BTREE ); cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_ino.flags =0 ;
@@ -5878,7 +5876,7 @@ xfs_bmap_collapse_extents(if (error)return error; -if (ifp->if_flags &XFS_IFBROOT ) { +if (ifp->if_format ==XFS_DINODE_FMT_BTREE ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_ino.flags =0 ; }
@@ -5993,7 +5991,7 @@ xfs_bmap_insert_extents(if (error)return error; -if (ifp->if_flags &XFS_IFBROOT ) { +if (ifp->if_format ==XFS_DINODE_FMT_BTREE ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_ino.flags =0 ; }
@@ -6108,7 +6106,7 @@ xfs_bmap_split_extent( new.br_blockcount = got.br_blockcount - gotblkcnt; new.br_state = got.br_state; -if (ifp->if_flags &XFS_IFBROOT ) { +if (ifp->if_format ==XFS_DINODE_FMT_BTREE ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_ino.flags =0 ; error =xfs_bmbt_lookup_eq (cur, &got, &i);
fs/xfs/libxfs/xfs_btree_staging.c +0 -1
@@ -387,7 +387,6 @@ xfs_btree_bload_prep_block( new_size = bbl->iroot_size (cur, nr_this_block, priv); ifp->if_broot =kmem_zalloc (new_size,0 ); ifp->if_broot_bytes = (int )new_size; - ifp->if_flags |=XFS_IFBROOT ;/* Initialize it and send it out. */ xfs_btree_init_block_int(cur->bc_mp, ifp->if_broot,
fs/xfs/libxfs/xfs_inode_fork.c +1 -3
@@ -60,7 +60,7 @@ xfs_init_local_fork( } ifp->if_bytes = size; - ifp->if_flags &= ~(XFS_IFEXTENTS |XFS_IFBROOT ); + ifp->if_flags &= ~XFS_IFEXTENTS ; ifp->if_flags |=XFS_IFINLINE ; }
@@ -214,7 +214,6 @@ xfs_iformat_btree(xfs_bmdr_to_bmbt (ip, dfp,XFS_DFORK_SIZE (dip, ip->i_mount, whichfork), ifp->if_broot, size); ifp->if_flags &= ~XFS_IFEXTENTS ; - ifp->if_flags |=XFS_IFBROOT ; ifp->if_bytes =0 ; ifp->if_u1.if_root =NULL ;
@@ -433,7 +432,6 @@ xfs_iroot_realloc( XFS_BMBT_BLOCK_LEN(ip->i_mount)); }else { new_broot =NULL ; - ifp->if_flags &= ~XFS_IFBROOT ; }/*
fs/xfs/libxfs/xfs_inode_fork.h +0 -1
@@ -32,7 +32,6 @@ struct xfs_ifork {*/ #define XFS_IFINLINE 0x01/* Inline data is read in */ #define XFS_IFEXTENTS 0x02/* All extent pointers are read in */ -#define XFS_IFBROOT 0x04/* i_broot points to the bmap b-tree root */ /* * Worst-case increase in the fork extent count when we're adding a single
Signature · 1 line
2.30.1
PATCH 6/7 xfs: remove XFS_IFINLINE
In reply to Christoph HellwigJust check for an inline format fork instead of the using the equivalent in-memory XFS_IFINLINE flag.
--- fs/xfs/libxfs/xfs_attr.c | 8 ++------ fs/xfs/libxfs/xfs_attr_leaf.c | 9 +++------ fs/xfs/libxfs/xfs_bmap.c | 3 +-- fs/xfs/libxfs/xfs_dir2_block.c | 2 +- fs/xfs/libxfs/xfs_dir2_sf.c | 11 +++++------ fs/xfs/libxfs/xfs_inode_fork.c | 1 - fs/xfs/libxfs/xfs_inode_fork.h | 1 - fs/xfs/scrub/symlink.c | 2 +- fs/xfs/xfs_dir2_readdir.c | 2 +- fs/xfs/xfs_iops.c | 4 ++-- fs/xfs/xfs_symlink.c | 4 ++-- 11 files changed, 18 insertions(+), 29 deletions(-)
fs/xfs/libxfs/xfs_attr.c +2 -6
@@ -362,10 +362,8 @@ xfs_has_attr(if (!xfs_inode_hasattr (dp))return -ENOATTR ; -if (dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL ) { -ASSERT (dp->i_afp->if_flags &XFS_IFINLINE ); +if (dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL )return xfs_attr_sf_findname (args,NULL ,NULL ); - }if (xfs_attr_is_leaf (dp)) { error =xfs_attr_leaf_hasname (args, &bp);
@@ -389,10 +387,8 @@ xfs_attr_remove_args(if (!xfs_inode_hasattr (args->dp))return -ENOATTR ; -if (args->dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL ) { -ASSERT (args->dp->i_afp->if_flags &XFS_IFINLINE ); +if (args->dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL )return xfs_attr_shortform_remove (args); - }if (xfs_attr_is_leaf (args->dp))return xfs_attr_leaf_removename (args);return xfs_attr_node_removename (args);
fs/xfs/libxfs/xfs_attr_leaf.c +3 -6
@@ -654,9 +654,6 @@ xfs_attr_shortform_create(if (ifp->if_format ==XFS_DINODE_FMT_EXTENTS ) { ifp->if_flags &= ~XFS_IFEXTENTS ;/* just in case */ ifp->if_format =XFS_DINODE_FMT_LOCAL ; - ifp->if_flags |=XFS_IFINLINE ; - }else { -ASSERT (ifp->if_flags &XFS_IFINLINE ); }xfs_idata_realloc (dp,sizeof (*hdr),XFS_ATTR_FORK ); hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;
@@ -733,7 +730,7 @@ xfs_attr_shortform_add( dp->i_d.di_forkoff = forkoff; ifp = dp->i_afp; -ASSERT (ifp->if_flags &XFS_IFINLINE ); +ASSERT (ifp->if_format ==XFS_DINODE_FMT_LOCAL ); sf = (struct xfs_attr_shortform *)ifp->if_u1.if_data;if (xfs_attr_sf_findname (args, &sfe,NULL ) == -EEXIST )ASSERT (0 );
@@ -851,7 +848,7 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args)trace_xfs_attr_sf_lookup (args); ifp = args->dp->i_afp; -ASSERT (ifp->if_flags &XFS_IFINLINE ); +ASSERT (ifp->if_format ==XFS_DINODE_FMT_LOCAL ); sf = (struct xfs_attr_shortform *)ifp->if_u1.if_data; sfe = &sf->list[0 ]; for (i = 0; i < sf->hdr.count;
@@ -878,7 +875,7 @@ xfs_attr_shortform_getvalue(struct xfs_attr_sf_entry *sfe;int i; -ASSERT (args->dp->i_afp->if_flags ==XFS_IFINLINE ); +ASSERT (args->dp->i_afp->if_format ==XFS_DINODE_FMT_LOCAL ); sf = (struct xfs_attr_shortform *)args->dp->i_afp->if_u1.if_data; sfe = &sf->list[0 ]; for (i = 0; i < sf->hdr.count;
fs/xfs/libxfs/xfs_bmap.c +1 -2
@@ -803,7 +803,6 @@ xfs_bmap_local_to_extents_empty(ASSERT (ifp->if_nextents ==0 );xfs_bmap_forkoff_reset (ip, whichfork); - ifp->if_flags &= ~XFS_IFINLINE ; ifp->if_flags |=XFS_IFEXTENTS ; ifp->if_u1.if_root =NULL ; ifp->if_height =0 ;
@@ -848,7 +847,7 @@ xfs_bmap_local_to_extents( flags =0 ; error =0 ; -ASSERT ((ifp->if_flags & (XFS_IFINLINE |XFS_IFEXTENTS )) ==XFS_IFINLINE ); +ASSERT (!(ifp->if_flags &XFS_IFEXTENTS ));memset (&args,0 ,sizeof (args)); args.tp = tp; args.mp = ip->i_mount;
fs/xfs/libxfs/xfs_dir2_block.c +1 -1
@@ -1096,7 +1096,7 @@ xfs_dir2_sf_to_block(trace_xfs_dir2_sf_to_block (args); -ASSERT (ifp->if_flags &XFS_IFINLINE ); +ASSERT (ifp->if_format ==XFS_DINODE_FMT_LOCAL );ASSERT (dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr , parent)); oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data;
fs/xfs/libxfs/xfs_dir2_sf.c +5 -6
@@ -378,7 +378,7 @@ xfs_dir2_sf_addname(ASSERT (xfs_dir2_sf_lookup (args) == -ENOENT ); dp = args->dp; -ASSERT (dp->i_df.if_flags &XFS_IFINLINE ); +ASSERT (dp->i_df.if_format ==XFS_DINODE_FMT_LOCAL );ASSERT (dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_d.di_size);ASSERT (dp->i_df.if_u1.if_data !=NULL );
@@ -830,9 +830,8 @@ xfs_dir2_sf_create( dp->i_df.if_flags &= ~XFS_IFEXTENTS ;/* just in case */ dp->i_df.if_format =XFS_DINODE_FMT_LOCAL ;xfs_trans_log_inode (args->trans, dp,XFS_ILOG_CORE ); - dp->i_df.if_flags |=XFS_IFINLINE ; } -ASSERT (dp->i_df.if_flags &XFS_IFINLINE ); +ASSERT (dp->i_df.if_format ==XFS_DINODE_FMT_LOCAL );ASSERT (dp->i_df.if_bytes ==0 ); i8count = pino >XFS_DIR2_MAX_SHORT_INUM ; size =xfs_dir2_sf_hdr_size (i8count);
@@ -877,7 +876,7 @@ xfs_dir2_sf_lookup(xfs_dir2_sf_check (args); -ASSERT (dp->i_df.if_flags &XFS_IFINLINE ); +ASSERT (dp->i_df.if_format ==XFS_DINODE_FMT_LOCAL );ASSERT (dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_d.di_size);ASSERT (dp->i_df.if_u1.if_data !=NULL );
@@ -954,7 +953,7 @@ xfs_dir2_sf_removename(trace_xfs_dir2_sf_removename (args); -ASSERT (dp->i_df.if_flags &XFS_IFINLINE ); +ASSERT (dp->i_df.if_format ==XFS_DINODE_FMT_LOCAL ); oldsize = (int )dp->i_d.di_size;ASSERT (oldsize >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == oldsize);
@@ -1053,7 +1052,7 @@ xfs_dir2_sf_replace(trace_xfs_dir2_sf_replace (args); -ASSERT (dp->i_df.if_flags &XFS_IFINLINE ); +ASSERT (dp->i_df.if_format ==XFS_DINODE_FMT_LOCAL );ASSERT (dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_d.di_size);ASSERT (dp->i_df.if_u1.if_data !=NULL );
fs/xfs/libxfs/xfs_inode_fork.c +0 -1
@@ -61,7 +61,6 @@ xfs_init_local_fork( ifp->if_bytes = size; ifp->if_flags &= ~XFS_IFEXTENTS ; - ifp->if_flags |=XFS_IFINLINE ; }/*
fs/xfs/libxfs/xfs_inode_fork.h +0 -1
@@ -30,7 +30,6 @@ struct xfs_ifork {/* * Per-fork incore inode flags. */ -#define XFS_IFINLINE 0x01/* Inline data is read in */ #define XFS_IFEXTENTS 0x02/* All extent pointers are read in */ /*
fs/xfs/scrub/symlink.c +1 -1
@@ -52,7 +52,7 @@ xchk_symlink( }/* Inline symlink? */ -if (ifp->if_flags &XFS_IFINLINE ) { +if (ifp->if_format ==XFS_DINODE_FMT_LOCAL ) {if (len >XFS_IFORK_DSIZE (ip) || len >strnlen (ifp->if_u1.if_data,XFS_IFORK_DSIZE (ip)))xchk_fblock_set_corrupt (sc,XFS_DATA_FORK ,0 );
fs/xfs/xfs_dir2_readdir.c +1 -1
@@ -57,7 +57,7 @@ xfs_dir2_sf_getdents(xfs_ino_t ino;struct xfs_da_geometry *geo = args->geo; -ASSERT (dp->i_df.if_flags &XFS_IFINLINE ); +ASSERT (dp->i_df.if_format ==XFS_DINODE_FMT_LOCAL );ASSERT (dp->i_df.if_bytes == dp->i_d.di_size);ASSERT (dp->i_df.if_u1.if_data !=NULL );
fs/xfs/xfs_iops.c +2 -2
@@ -519,7 +519,7 @@ xfs_vn_get_link_inline(struct xfs_inode *ip =XFS_I (inode);char *link; -ASSERT (ip->i_df.if_flags &XFS_IFINLINE ); +ASSERT (dp->i_df.if_format ==XFS_DINODE_FMT_LOCAL );/* * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED if
@@ -1402,7 +1402,7 @@ xfs_setup_iops( inode->i_fop = &xfs_dir_file_operations;break ;case S_IFLNK : -if (ip->i_df.if_flags &XFS_IFINLINE ) +if (ip->i_df.if_format ==XFS_DINODE_FMT_LOCAL ) inode->i_op = &xfs_inline_symlink_inode_operations;else inode->i_op = &xfs_symlink_inode_operations;
fs/xfs/xfs_symlink.c +2 -2
@@ -104,7 +104,7 @@ xfs_readlink(trace_xfs_readlink (ip); -ASSERT (!(ip->i_df.if_flags &XFS_IFINLINE )); +ASSERT (dp->i_df.if_format !=XFS_DINODE_FMT_LOCAL );if (XFS_FORCED_SHUTDOWN (mp))return -EIO ;
@@ -492,7 +492,7 @@ xfs_inactive_symlink(* Inline fork state gets removed by xfs_difree() so we have nothing to * do here in that case. */ -if (ip->i_df.if_flags &XFS_IFINLINE ) { +if (ip->i_df.if_format ==XFS_DINODE_FMT_LOCAL ) {xfs_iunlock (ip,XFS_ILOCK_EXCL );return 0 ; }
Signature · 1 line
2.30.1
kernel test robot
build botRe: [PATCH 6/7] xfs: remove XFS_IFINLINE
I love your patch! Yet something to improve:
Hi Christoph,
I love your patch! Yet something to improve:
[auto build test ERROR on xfs-linux/for-next]
[also build test ERROR on v5.12-rc5 next-20210401]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christoph-Hellwig/xfs-move-the-XFS_IFEXTENTS-check-into-xfs_iread_extents/20210402-232422 base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next config: x86_64-randconfig-r034-20210401 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project b23a314146956dd29b719ab537608ced736fc036)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/3a376a77f4296e338a26df75eb05a1b7ae0def2a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christoph-Hellwig/xfs-move-the-XFS_IFEXTENTS-check-into-xfs_iread_extents/20210402-232422 git checkout 3a376a77f4296e338a26df75eb05a1b7ae0def2a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> fs/xfs/xfs_iops.c:522:9: error: use of undeclared identifier 'dp'
ASSERT(dp->i_df.if_format == XFS_DINODE_FMT_LOCAL);
^
1 error generated.
--
>> fs/xfs/xfs_symlink.c:107:9: error: use of undeclared identifier 'dp'
ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_LOCAL);
^1 error generated.
vim +/dp +522 fs/xfs/xfs_iops.c
512
513 STATIC const char *
514 xfs_vn_get_link_inline(
515 struct dentry *dentry,
516 struct inode *inode,
517 struct delayed_call *done)
518 {
519 struct xfs_inode *ip = XFS_I(inode);
520 char *link;
521
> 522 ASSERT(dp->i_df.if_format == XFS_DINODE_FMT_LOCAL);
523
524 /*
525 * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED if
526 * if_data is junk.
527 */
528 link = ip->i_df.if_u1.if_data;
529 if (XFS_IS_CORRUPT(ip->i_mount, !link))
530 return ERR_PTR(-EFSCORRUPTED);
531 return link;
532 }
533
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH 6/7] xfs: remove XFS_IFINLINE
In reply to Christoph HellwigI love your patch! Yet something to improve:
Hi Christoph,
I love your patch! Yet something to improve:
[auto build test ERROR on xfs-linux/for-next]
[also build test ERROR on v5.12-rc5 next-20210401]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christoph-Hellwig/xfs-move-the-XFS_IFEXTENTS-check-into-xfs_iread_extents/20210402-232422 base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next config: microblaze-randconfig-r036-20210401 (attached as .config) compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/3a376a77f4296e338a26df75eb05a1b7ae0def2a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christoph-Hellwig/xfs-move-the-XFS_IFEXTENTS-check-into-xfs_iread_extents/20210402-232422 git checkout 3a376a77f4296e338a26df75eb05a1b7ae0def2a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
In file included from include/linux/string.h:6,
from include/linux/uuid.h:12,
from fs/xfs/xfs_linux.h:10,
from fs/xfs/xfs.h:22,
from fs/xfs/xfs_iops.c:6:
fs/xfs/xfs_iops.c: In function 'xfs_vn_get_link_inline':
>> fs/xfs/xfs_iops.c:522:9: error: 'dp' undeclared (first use in this function); did you mean 'ip'?
522 | ASSERT(dp->i_df.if_format == XFS_DINODE_FMT_LOCAL);
| ^~
include/linux/compiler.h:77:40: note: in definition of macro 'likely'
77 | # define likely(x) __builtin_expect(!!(x), 1)
| ^
fs/xfs/xfs_iops.c:522:2: note: in expansion of macro 'ASSERT'
522 | ASSERT(dp->i_df.if_format == XFS_DINODE_FMT_LOCAL);
| ^~~~~~
fs/xfs/xfs_iops.c:522:9: note: each undeclared identifier is reported only once for each function it appears in
522 | ASSERT(dp->i_df.if_format == XFS_DINODE_FMT_LOCAL);
| ^~
include/linux/compiler.h:77:40: note: in definition of macro 'likely'
77 | # define likely(x) __builtin_expect(!!(x), 1)
| ^
fs/xfs/xfs_iops.c:522:2: note: in expansion of macro 'ASSERT'
522 | ASSERT(dp->i_df.if_format == XFS_DINODE_FMT_LOCAL);
| ^~~~~~
--
In file included from include/linux/string.h:6,
from include/linux/uuid.h:12,
from fs/xfs/xfs_linux.h:10,
from fs/xfs/xfs.h:22,
from fs/xfs/xfs_symlink.c:7:
fs/xfs/xfs_symlink.c: In function 'xfs_readlink':
>> fs/xfs/xfs_symlink.c:107:9: error: 'dp' undeclared (first use in this function); did you mean 'mp'?
107 | ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_LOCAL);
| ^~
include/linux/compiler.h:77:40: note: in definition of macro 'likely'
77 | # define likely(x) __builtin_expect(!!(x), 1)
| ^
fs/xfs/xfs_symlink.c:107:2: note: in expansion of macro 'ASSERT'
107 | ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_LOCAL);
| ^~~~~~
fs/xfs/xfs_symlink.c:107:9: note: each undeclared identifier is reported only once for each function it appears in
107 | ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_LOCAL);
| ^~
include/linux/compiler.h:77:40: note: in definition of macro 'likely'
77 | # define likely(x) __builtin_expect(!!(x), 1)
| ^
fs/xfs/xfs_symlink.c:107:2: note: in expansion of macro 'ASSERT'
107 | ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_LOCAL);
| ^~~~~~vim +522 fs/xfs/xfs_iops.c
512
513 STATIC const char *
514 xfs_vn_get_link_inline(
515 struct dentry *dentry,
516 struct inode *inode,
517 struct delayed_call *done)
518 {
519 struct xfs_inode *ip = XFS_I(inode);
520 char *link;
521
> 522 ASSERT(dp->i_df.if_format == XFS_DINODE_FMT_LOCAL);
523
524 /*
525 * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED if
526 * if_data is junk.
527 */
528 link = ip->i_df.if_u1.if_data;
529 if (XFS_IS_CORRUPT(ip->i_mount, !link))
530 return ERR_PTR(-EFSCORRUPTED);
531 return link;
532 }
533
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 7/7 xfs: remove XFS_IFEXTENTS
In reply to Christoph HellwigThe in-memory XFS_IFEXTENTS is now only used to check if an inode with extents still needs the extents to be read into memory before doing operations that need the extent map. Add a new xfs_need_iread_extents helper that returns true for btree format forks that do not have any entries in the in-memory extent btree, and use that instead of checking the XFS_IFEXTENTS flag.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 4 +--- fs/xfs/libxfs/xfs_bmap.c | 14 ++------------ fs/xfs/libxfs/xfs_dir2_sf.c | 1 - fs/xfs/libxfs/xfs_inode_fork.c | 6 ------ fs/xfs/libxfs/xfs_inode_fork.h | 12 ++++++------ fs/xfs/scrub/bmap.c | 6 +----- fs/xfs/xfs_aops.c | 3 +-- fs/xfs/xfs_bmap_util.c | 4 ++-- fs/xfs/xfs_inode.c | 9 ++------- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_iomap.c | 4 ++-- fs/xfs/xfs_symlink.c | 2 +- 12 files changed, 19 insertions(+), 48 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +1 -3
@@ -651,10 +651,8 @@ xfs_attr_shortform_create(trace_xfs_attr_sf_create (args);ASSERT (ifp->if_bytes ==0 ); -if (ifp->if_format ==XFS_DINODE_FMT_EXTENTS ) { - ifp->if_flags &= ~XFS_IFEXTENTS ;/* just in case */ +if (ifp->if_format ==XFS_DINODE_FMT_EXTENTS ) ifp->if_format =XFS_DINODE_FMT_LOCAL ; - }xfs_idata_realloc (dp,sizeof (*hdr),XFS_ATTR_FORK ); hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;memset (hdr,0 ,sizeof (*hdr));
fs/xfs/libxfs/xfs_bmap.c +2 -12
@@ -603,7 +603,7 @@ xfs_bmap_btree_to_extents(ASSERT (cur);ASSERT (whichfork !=XFS_COW_FORK ); -ASSERT (ifp->if_flags &XFS_IFEXTENTS ); +ASSERT (!xfs_need_iread_extents (ifp));ASSERT (ifp->if_format ==XFS_DINODE_FMT_BTREE );ASSERT (be16_to_cpu (rblock->bb_level) ==1 );ASSERT (be16_to_cpu (rblock->bb_numrecs) ==1 );
@@ -803,7 +803,6 @@ xfs_bmap_local_to_extents_empty(ASSERT (ifp->if_nextents ==0 );xfs_bmap_forkoff_reset (ip, whichfork); - ifp->if_flags |=XFS_IFEXTENTS ; ifp->if_u1.if_root =NULL ; ifp->if_height =0 ; ifp->if_format =XFS_DINODE_FMT_EXTENTS ;
@@ -847,7 +846,6 @@ xfs_bmap_local_to_extents( flags =0 ; error =0 ; -ASSERT (!(ifp->if_flags &XFS_IFEXTENTS ));memset (&args,0 ,sizeof (args)); args.tp = tp; args.mp = ip->i_mount;
@@ -1092,7 +1090,6 @@ xfs_bmap_add_attrfork(ASSERT (ip->i_afp ==NULL ); ip->i_afp =xfs_ifork_alloc (XFS_DINODE_FMT_EXTENTS ,0 ); - ip->i_afp->if_flags =XFS_IFEXTENTS ; logflags =0 ;switch (ip->i_df.if_format) {case XFS_DINODE_FMT_LOCAL :
@@ -1220,14 +1217,9 @@ xfs_iread_extents(ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); -if (ifp->if_flags &XFS_IFEXTENTS ) +if (!xfs_need_iread_extents (ifp))return 0 ; -if (XFS_IS_CORRUPT (mp, ifp->if_format !=XFS_DINODE_FMT_BTREE )) { - error = -EFSCORRUPTED ; - goto out; - } - ir.loaded =0 ;xfs_iext_first (ifp, &ir.icur); cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork);
@@ -1242,8 +1234,6 @@ xfs_iread_extents( goto out; }ASSERT (ir.loaded ==xfs_iext_count (ifp)); - - ifp->if_flags |=XFS_IFEXTENTS ;return 0 ; out:xfs_iext_destroy (ifp);
fs/xfs/libxfs/xfs_dir2_sf.c +0 -1
@@ -827,7 +827,6 @@ xfs_dir2_sf_create(* convert it to local format. */ if (dp->i_df.if_format ==XFS_DINODE_FMT_EXTENTS ) { - dp->i_df.if_flags &= ~XFS_IFEXTENTS ;/* just in case */ dp->i_df.if_format =XFS_DINODE_FMT_LOCAL ;xfs_trans_log_inode (args->trans, dp,XFS_ILOG_CORE ); }
fs/xfs/libxfs/xfs_inode_fork.c +0 -6
@@ -60,7 +60,6 @@ xfs_init_local_fork( } ifp->if_bytes = size; - ifp->if_flags &= ~XFS_IFEXTENTS ; }/*
@@ -150,7 +149,6 @@ xfs_iformat_extents(xfs_iext_next (ifp, &icur); } } - ifp->if_flags |=XFS_IFEXTENTS ;return 0 ; }
@@ -212,7 +210,6 @@ xfs_iformat_btree(*/ xfs_bmdr_to_bmbt (ip, dfp,XFS_DFORK_SIZE (dip, ip->i_mount, whichfork), ifp->if_broot, size); - ifp->if_flags &= ~XFS_IFEXTENTS ; ifp->if_bytes =0 ; ifp->if_u1.if_root =NULL ;
@@ -622,8 +619,6 @@ xfs_iflush_fork(break ;case XFS_DINODE_FMT_EXTENTS : -ASSERT ((ifp->if_flags &XFS_IFEXTENTS ) || - !(iip->ili_fields & extflag[whichfork]));if ((iip->ili_fields & extflag[whichfork]) && (ifp->if_bytes >0 )) {ASSERT (ifp->if_nextents >0 );
@@ -683,7 +678,6 @@ xfs_ifork_init_cow( ip->i_cowfp =kmem_cache_zalloc (xfs_ifork_zone,GFP_NOFS | __GFP_NOFAIL); - ip->i_cowfp->if_flags =XFS_IFEXTENTS ; ip->i_cowfp->if_format =XFS_DINODE_FMT_EXTENTS ; }
fs/xfs/libxfs/xfs_inode_fork.h +6 -6
@@ -22,16 +22,10 @@ struct xfs_ifork {char *if_data;/* inline file data */ } if_u1;short if_broot_bytes;/* bytes allocated for root */ -unsigned char if_flags;/* per-fork flags */ int8_t if_format;/* format of this fork */ xfs_extnum_t if_nextents;/* # of extents in this fork */ }; -/* -* Per-fork incore inode flags. -*/ -#define XFS_IFEXTENTS 0x02/* All extent pointers are read in */ -/* * Worst-case increase in the fork extent count when we're adding a single * extent to a fork and there's no possibility of splitting an existing mapping.
@@ -236,4 +230,10 @@ int xfs_ifork_verify_local_attr(struct xfs_inode *ip);int xfs_iext_count_may_overflow (struct xfs_inode *ip,int whichfork,int nr_to_add); +/* returns true if the fork has extents but they are not read in yet. */ +static inline bool xfs_need_iread_extents (struct xfs_ifork *ifp) +{ +return ifp->if_format ==XFS_DINODE_FMT_BTREE && ifp->if_height ==0 ; +} +#endif /* __XFS_INODE_FORK_H__ */
fs/xfs/scrub/bmap.c +1 -5
@@ -448,7 +448,7 @@ xchk_bmap_btree(int error;/* Load the incore bmap cache if it's not loaded. */ - info->was_loaded = ifp->if_flags &XFS_IFEXTENTS ; + info->was_loaded = !xfs_need_iread_extents (ifp); error =xfs_iread_extents (sc->tp, ip, whichfork);if (!xchk_fblock_process_error (sc, whichfork,0 , &error))
@@ -674,10 +674,6 @@ xchk_bmap(/* No mappings to check. */ goto out;case XFS_DINODE_FMT_EXTENTS : -if (!(ifp->if_flags &XFS_IFEXTENTS )) { -xchk_fblock_set_corrupt (sc, whichfork,0 ); - goto out; - }break ;case XFS_DINODE_FMT_BTREE :if (whichfork ==XFS_COW_FORK ) {
fs/xfs/xfs_aops.c +1 -2
@@ -384,8 +384,7 @@ xfs_map_blocks( cow_fsb =NULLFILEOFF ; whichfork =XFS_DATA_FORK ;xfs_ilock (ip,XFS_ILOCK_SHARED ); -ASSERT (ip->i_df.if_format !=XFS_DINODE_FMT_BTREE || - (ip->i_df.if_flags &XFS_IFEXTENTS )); +ASSERT (!xfs_need_iread_extents (&ip->i_df));/* * Check if this is offset is covered by a COW extents, and if yes use
fs/xfs/xfs_bmap_util.c +2 -2
@@ -554,7 +554,7 @@ xfs_bmap_punch_delalloc_range(struct xfs_iext_cursor icur;int error =0 ; -ASSERT (ifp->if_flags &XFS_IFEXTENTS ); +ASSERT (!xfs_need_iread_extents (ifp));xfs_ilock (ip,XFS_ILOCK_EXCL );if (!xfs_iext_lookup_extent_before (ip, ifp, &end_fsb, &icur, &got))
@@ -609,7 +609,7 @@ xfs_can_free_eofblocks(struct xfs_inode *ip, bool force)return false;/* If we haven't read in the extent list, then don't do it now. */ -if (!(ip->i_df.if_flags &XFS_IFEXTENTS )) +if (xfs_need_iread_extents (&ip->i_df))return false;/*
fs/xfs/xfs_inode.c +2 -7
@@ -111,8 +111,7 @@ xfs_ilock_data_map_shared( {uint lock_mode =XFS_ILOCK_SHARED ; -if (ip->i_df.if_format ==XFS_DINODE_FMT_BTREE && - (ip->i_df.if_flags &XFS_IFEXTENTS ) ==0 ) +if (xfs_need_iread_extents (&ip->i_df)) lock_mode =XFS_ILOCK_EXCL ;xfs_ilock (ip, lock_mode);return lock_mode;
@@ -124,9 +123,7 @@ xfs_ilock_attr_map_shared( {uint lock_mode =XFS_ILOCK_SHARED ; -if (ip->i_afp && - ip->i_afp->if_format ==XFS_DINODE_FMT_BTREE && - (ip->i_afp->if_flags &XFS_IFEXTENTS ) ==0 ) +if (ip->i_afp &&xfs_need_iread_extents (ip->i_afp)) lock_mode =XFS_ILOCK_EXCL ;xfs_ilock (ip, lock_mode);return lock_mode;
@@ -858,7 +855,6 @@ xfs_init_new_inode(case S_IFBLK :case S_IFSOCK : ip->i_df.if_format =XFS_DINODE_FMT_DEV ; - ip->i_df.if_flags =0 ; flags |=XFS_ILOG_DEV ;break ;case S_IFREG :
@@ -870,7 +866,6 @@ xfs_init_new_inode(/* FALLTHROUGH */ case S_IFLNK : ip->i_df.if_format =XFS_DINODE_FMT_EXTENTS ; - ip->i_df.if_flags =XFS_IFEXTENTS ; ip->i_df.if_bytes =0 ; ip->i_df.if_u1.if_root =NULL ;break ;
fs/xfs/xfs_ioctl.c +1 -1
@@ -1124,7 +1124,7 @@ xfs_fill_fsxattr( fa->fsx_cowextsize = ip->i_d.di_cowextsize << ip->i_mount->m_sb.sb_blocklog; fa->fsx_projid = ip->i_d.di_projid; -if (ifp && (ifp->if_flags &XFS_IFEXTENTS )) +if (ifp && !xfs_need_iread_extents (ifp)) fa->fsx_nextents =xfs_iext_count (ifp);else fa->fsx_nextents =xfs_ifork_nextents (ifp);
fs/xfs/xfs_iomap.c +2 -2
@@ -159,7 +159,7 @@ xfs_iomap_eof_align_last_fsb(struct xfs_bmbt_irec irec;struct xfs_iext_cursor icur; -ASSERT (ifp->if_flags &XFS_IFEXTENTS ); +ASSERT (!xfs_need_iread_extents (ifp));/* * Always round up the allocation request to the extent hint boundary.
@@ -666,7 +666,7 @@ xfs_ilock_for_iomap(* is an opencoded xfs_ilock_data_map_shared() call but with * non-blocking behaviour. */ -if (!(ip->i_df.if_flags &XFS_IFEXTENTS )) { +if (xfs_need_iread_extents (&ip->i_df)) {if (flags &IOMAP_NOWAIT )return -EAGAIN ; mode =XFS_ILOCK_EXCL ;
fs/xfs/xfs_symlink.c +1 -1
@@ -377,7 +377,7 @@ xfs_inactive_symlink_rmt(xfs_trans_t *tp; mp = ip->i_mount; -ASSERT (ip->i_df.if_flags &XFS_IFEXTENTS ); +ASSERT (!xfs_need_iread_extents (&ip->i_df));/* * We're freeing a symlink that has some * blocks allocated to it. Free the
Signature · 1 line
2.30.1