remove the if_flags field in struct xfs_ifork
Hi all,
this series removes the if_flags field in struct xfs_ifork, as all the information is available from other fields in the ifork structure anyway.
Diffstat:
libxfs/xfs_attr.c | 53 ++++++++++------ libxfs/xfs_attr.h | 1 libxfs/xfs_attr_leaf.c | 13 +--- libxfs/xfs_bmap.c | 143 +++++++++++++-------------------------------- 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 | 10 --- 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, 142 insertions(+), 238 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
@@ -1227,6 +1227,9 @@ xfs_iread_extents(struct xfs_btree_cur *cur;int error; +if (ifp->if_flags &XFS_IFEXTENTS ) +return 0 ; +ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));if (XFS_IS_CORRUPT (mp, ifp->if_format !=XFS_DINODE_FMT_BTREE )) {
@@ -1284,11 +1287,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) {
@@ -1336,11 +1337,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 ;
@@ -1359,11 +1358,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))
@@ -3991,11 +3988,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;
@@ -4475,11 +4470,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;
@@ -4758,11 +4751,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. */
@@ -5433,9 +5424,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 ;
@@ -5921,11 +5913,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);
@@ -6038,11 +6028,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);
@@ -6141,12 +6129,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
@@ -448,11 +448,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
@@ -894,11 +894,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
@@ -1209,11 +1207,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]>Reviewed-by Brian Foster <[email protected]>
Looks better this time,
--D
Quoted 342 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@@ -1227,6 +1227,9 @@ xfs_iread_extents(struct xfs_btree_cur *cur;int error; +if (ifp->if_flags &XFS_IFEXTENTS ) +return 0 ; +ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));if (XFS_IS_CORRUPT (mp, ifp->if_format !=XFS_DINODE_FMT_BTREE )) {@@ -1284,11 +1287,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) {@@ -1336,11 +1337,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 ;@@ -1359,11 +1358,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))@@ -3991,11 +3988,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;@@ -4475,11 +4470,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;@@ -4758,11 +4751,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. */ @@ -5433,9 +5424,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 ;@@ -5921,11 +5913,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);@@ -6038,11 +6028,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);@@ -6141,12 +6129,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@@ -448,11 +448,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@@ -894,11 +894,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 @@ -1209,11 +1207,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
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);
@@ -1283,7 +1303,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
@@ -1441,38 +1441,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 i_disk_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
@@ -200,7 +200,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 30 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]>Reviewed-by Brian Foster <[email protected]>--- 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 +8
-0@@ -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) +{
fs/xfs/libxfs/xfs_attr.c xfs_inode_hasattr( · line 90
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +10
-0+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 ;
/me kinda wonders if this ought to be mp->m_attr_geo->fsbcount, but seeing as adding support for large xattr blocks would require a full audit anyway, it's probably not worth fussing over.
--D
Quoted 133 lines
fs/xfs/libxfs/xfs_attr.c +7
-5+} +/*======================================================================== * 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);@@ -1283,7 +1303,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@@ -1441,38 +1441,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 i_disk_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@@ -200,7 +200,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]>Reviewed-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 41 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]>Reviewed-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 35 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
@@ -633,7 +633,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 ;
@@ -677,7 +676,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.
@@ -4196,7 +4194,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
@@ -4269,7 +4267,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); }
@@ -4732,7 +4730,7 @@ xfs_bmapi_remap( ip->i_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 ; }
@@ -5411,7 +5409,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 ;
@@ -5885,7 +5883,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 ; }
@@ -6000,7 +5998,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 ; }
@@ -6115,7 +6113,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
Re: [PATCH 5/7] xfs: remove XFS_IFBROOT
Quoted 11 lines · Christoph Hellwig
Just check for a btree format fork instead of the using the equivalent in-memory
XFS_IFBROOTflag.Signed-off-by Christoph Hellwig <[email protected]>--- 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_btree_staging.c xfs_btree_bload_prep_block( · line 392
Quoted 12 lines
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,
IIRC, these bits are used in xfsprogs for efficient btree repair. Taking a closer look, I see AG metadata btree repair implementations, but nothing that seems to use the ifake variant. Am I missing something or is this code currently unused?
In any event, the comments for xfs_btree_stage_ifakeroot() suggest that ->if_format should be initialized properly when a fake inode fork is transferred to a cursor and the rest of the patch looks fine to me:
Quoted 44 lines
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
Re: [PATCH 5/7] xfs: remove XFS_IFBROOT
Quoted 23 lines · Brian Foster
Quoted 11 lines · Christoph Hellwig
Just check for a btree format fork instead of the using the equivalent in-memory
XFS_IFBROOTflag.Signed-off-by Christoph Hellwig <[email protected]>--- 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(-)...
Quoted 10 lines
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 ;
Quoted 7 lines
fs/xfs/libxfs/xfs_btree_staging.c xfs_btree_bload_prep_block( · line 392
Quoted 2 lines
fs/xfs/libxfs/xfs_btree_staging.c +0
-0/* Initialize it and send it out. */ xfs_btree_init_block_int(cur->bc_mp, ifp->if_broot,IIRC, these bits are used in xfsprogs for efficient btree repair. Taking a closer look, I see AG metadata btree repair implementations, but nothing that seems to use the ifake variant. Am I missing something or is this code currently unused?
Currently unused. The first user will be bmbt reconstruction, whenever I get back to that, some day. Now that upper levels can relog deferred ops when the log head approaches the tail, online btree repair can hang on to EFIs for the new tree blocks during the bulkload without risking a log livelock.
That series is stuck behind:
1 Quotaoff cleanups (suggested as part of:)
2 Incore inode walk refactoring (suggested as part of:)
3 Preserving inode sickness reports through aborted ireclaim (bugs
found while working on:)
4 Deferred inode inactivation (customer requirement / needed for rmapbt
repairs)
5 Reducing transaction reservations when reflink/rmap are enabled
(dchinner complaint)
6 Various scrub enhancements
7 Repair infrastructure changes needed for online bulkloading 8 Online repair of AG btrees
It's 9th in line (and 81st in the patch stack), so it's going to be at least another ~5 kernel cycles until review completes on the preceeding patchsets so that repair gets back to the front of the line.
--D
Quoted 51 lines
In any event, the comments for
xfs_btree_stage_ifakeroot()suggest that ->if_format should be initialized properly when a fake inode fork is transferred to a cursor and the rest of the patch looks fine to me:Reviewed-by Brian Foster <[email protected]>Quoted 44 lines
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
Re: [PATCH 5/7] xfs: remove XFS_IFBROOT
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Just check for a btree format fork instead of the using the equivalent in-memory
XFS_IFBROOTflag.Signed-off-by Christoph Hellwig <[email protected]>
Looks pretty straightforward to me...
--D
Quoted 146 lines
--- 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@@ -633,7 +633,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 ;@@ -677,7 +676,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. @@ -4196,7 +4194,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 @@ -4269,7 +4267,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); }@@ -4732,7 +4730,7 @@ xfs_bmapi_remap( ip->i_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 ; }@@ -5411,7 +5409,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 ;@@ -5885,7 +5883,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 ; }@@ -6000,7 +5998,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 ; }@@ -6115,7 +6113,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_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
@@ -805,7 +805,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 ;
@@ -850,7 +849,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_disk_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_disk_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_disk_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_disk_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_disk_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_disk_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_disk_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_disk_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
@@ -51,7 +51,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_disk_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 (ip->i_df.if_format ==XFS_DINODE_FMT_LOCAL );/* * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED if
@@ -1401,7 +1401,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 (ip->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
Re: [PATCH 6/7] xfs: remove XFS_IFINLINE
Quoted 5 lines · Christoph Hellwig
Just check for an inline format fork instead of the using the equivalent in-memory
XFS_IFINLINEflag.Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 264 lines
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_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@@ -805,7 +805,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 ;@@ -850,7 +849,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_disk_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_disk_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_disk_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_disk_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_disk_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_disk_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_disk_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_disk_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@@ -51,7 +51,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_disk_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 (ip->i_df.if_format ==XFS_DINODE_FMT_LOCAL );/* * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED if @@ -1401,7 +1401,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 (ip->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
Re: [PATCH 6/7] xfs: remove XFS_IFINLINE
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Just check for an inline format fork instead of the using the equivalent in-memory
XFS_IFINLINEflag.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 265 lines
--- 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_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@@ -805,7 +805,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 ;@@ -850,7 +849,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_disk_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_disk_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_disk_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_disk_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_disk_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_disk_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_disk_size >= offsetof(struct xfs_dir2_sf_hdr , parent));ASSERT (dp->i_df.if_bytes == dp->i_disk_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@@ -51,7 +51,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_disk_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 (ip->i_df.if_format ==XFS_DINODE_FMT_LOCAL );/* * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED if @@ -1401,7 +1401,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 (ip->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
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 | 10 ++-------- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_iomap.c | 4 ++-- fs/xfs/xfs_symlink.c | 2 +- 12 files changed, 19 insertions(+), 49 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
@@ -605,7 +605,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 );
@@ -805,7 +805,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 ;
@@ -849,7 +848,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;
@@ -1098,7 +1096,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 :
@@ -1224,16 +1221,11 @@ xfs_iread_extents(struct xfs_btree_cur *cur;int error; -if (ifp->if_flags &XFS_IFEXTENTS ) +if (!xfs_need_iread_extents (ifp))return 0 ;ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); -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);
@@ -1248,8 +1240,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
@@ -447,7 +447,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))
@@ -673,10 +673,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
@@ -291,8 +291,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))
@@ -625,7 +625,7 @@ xfs_can_free_eofblocks(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 -8
@@ -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;
@@ -843,7 +840,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 :
@@ -855,7 +851,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 ;
@@ -875,7 +870,6 @@ xfs_init_new_inode(if (init_xattrs &&xfs_sb_version_hasattr (&mp->m_sb)) { ip->i_forkoff =xfs_default_attroffset (ip) >>3 ; ip->i_afp =xfs_ifork_alloc (XFS_DINODE_FMT_EXTENTS ,0 ); - ip->i_afp->if_flags =XFS_IFEXTENTS ; }/*
fs/xfs/xfs_ioctl.c +1 -1
@@ -1126,7 +1126,7 @@ xfs_fill_fsxattr(if (ip->i_diflags2 &XFS_DIFLAG2_COWEXTSIZE ) fa->fsx_cowextsize =XFS_FSB_TO_B (mp, ip->i_cowextsize); fa->fsx_projid = ip->i_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.
@@ -667,7 +667,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
Re: [PATCH 7/7] xfs: remove XFS_IFEXTENTS
Quoted 9 lines · Christoph Hellwig
The in-memory
XFS_IFEXTENTSis 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 newxfs_need_iread_extentshelper 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 theXFS_IFEXTENTSflag.Signed-off-by Christoph Hellwig <[email protected]>---
Looks sane to me:
Quoted 343 lines
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 | 10 ++-------- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_iomap.c | 4 ++-- fs/xfs/xfs_symlink.c | 2 +- 12 files changed, 19 insertions(+), 49 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@@ -605,7 +605,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 );@@ -805,7 +805,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 ;@@ -849,7 +848,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;@@ -1098,7 +1096,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 :@@ -1224,16 +1221,11 @@ xfs_iread_extents(struct xfs_btree_cur *cur;int error; -if (ifp->if_flags &XFS_IFEXTENTS ) +if (!xfs_need_iread_extents (ifp))return 0 ;ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); -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);@@ -1248,8 +1240,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@@ -447,7 +447,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))@@ -673,10 +673,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@@ -291,8 +291,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))@@ -625,7 +625,7 @@ xfs_can_free_eofblocks(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
-8@@ -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;@@ -843,7 +840,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 :@@ -855,7 +851,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 ;@@ -875,7 +870,6 @@ xfs_init_new_inode(if (init_xattrs &&xfs_sb_version_hasattr (&mp->m_sb)) { ip->i_forkoff =xfs_default_attroffset (ip) >>3 ; ip->i_afp =xfs_ifork_alloc (XFS_DINODE_FMT_EXTENTS ,0 ); - ip->i_afp->if_flags =XFS_IFEXTENTS ; }/* fs/xfs/xfs_ioctl.c +1
-1@@ -1126,7 +1126,7 @@ xfs_fill_fsxattr(if (ip->i_diflags2 &XFS_DIFLAG2_COWEXTSIZE ) fa->fsx_cowextsize =XFS_FSB_TO_B (mp, ip->i_cowextsize); fa->fsx_projid = ip->i_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. @@ -667,7 +667,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
Re: [PATCH 7/7] xfs: remove XFS_IFEXTENTS
In reply to Christoph HellwigQuoted 8 lines · Christoph Hellwig
The in-memory
XFS_IFEXTENTSis 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 newxfs_need_iread_extentshelper 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 theXFS_IFEXTENTSflag.Signed-off-by Christoph Hellwig <[email protected]>
The series seems reasonable to me, though I wonder if Dave will have strong(er) opinions?
<shrug> Seeing how we already had a go-round where Dave and stumbled over each other about the somewhat duplicative flags and format fields I'm inclined to take this sooner or later just to eliminate the ambiguity...
--D
Quoted 344 lines
--- 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 | 10 ++-------- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_iomap.c | 4 ++-- fs/xfs/xfs_symlink.c | 2 +- 12 files changed, 19 insertions(+), 49 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@@ -605,7 +605,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 );@@ -805,7 +805,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 ;@@ -849,7 +848,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;@@ -1098,7 +1096,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 :@@ -1224,16 +1221,11 @@ xfs_iread_extents(struct xfs_btree_cur *cur;int error; -if (ifp->if_flags &XFS_IFEXTENTS ) +if (!xfs_need_iread_extents (ifp))return 0 ;ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); -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);@@ -1248,8 +1240,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@@ -447,7 +447,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))@@ -673,10 +673,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@@ -291,8 +291,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))@@ -625,7 +625,7 @@ xfs_can_free_eofblocks(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
-8@@ -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;@@ -843,7 +840,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 :@@ -855,7 +851,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 ;@@ -875,7 +870,6 @@ xfs_init_new_inode(if (init_xattrs &&xfs_sb_version_hasattr (&mp->m_sb)) { ip->i_forkoff =xfs_default_attroffset (ip) >>3 ; ip->i_afp =xfs_ifork_alloc (XFS_DINODE_FMT_EXTENTS ,0 ); - ip->i_afp->if_flags =XFS_IFEXTENTS ; }/* fs/xfs/xfs_ioctl.c +1
-1@@ -1126,7 +1126,7 @@ xfs_fill_fsxattr(if (ip->i_diflags2 &XFS_DIFLAG2_COWEXTSIZE ) fa->fsx_cowextsize =XFS_FSB_TO_B (mp, ip->i_cowextsize); fa->fsx_projid = ip->i_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. @@ -667,7 +667,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
Re: [PATCH 7/7] xfs: remove XFS_IFEXTENTS
Quoted 4 lines · Darrick J. Wong
<shrug> Seeing how we already had a go-round where Dave and stumbled over each other about the somewhat duplicative flags and format fields I'm inclined to take this sooner or later just to eliminate the ambiguity...
Do you want me to resend for the comment that Brian wants to see, or do you want to just fold that in?
Re: [PATCH 7/7] xfs: remove XFS_IFEXTENTS
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
<shrug> Seeing how we already had a go-round where Dave and stumbled over each other about the somewhat duplicative flags and format fields I'm inclined to take this sooner or later just to eliminate the ambiguity...
Do you want me to resend for the comment that Brian wants to see, or do you want to just fold that in?
Hm? I thought Brian was describing a comment that's already in xfs_btree_staging.c around line 195 as his reason for adding an RVB?
--D
Re: [PATCH 7/7] xfs: remove XFS_IFEXTENTS
Quoted 7 lines · Darrick J. Wong
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
<shrug> Seeing how we already had a go-round where Dave and stumbled over each other about the somewhat duplicative flags and format fields I'm inclined to take this sooner or later just to eliminate the ambiguity...
Quoted 5 lines
Quoted 2 lines
Do you want me to resend for the comment that Brian wants to see, or do you want to just fold that in?
Hm? I thought Brian was describing a comment that's already in
xfs_btree_staging.caround line 195 as his reason for adding an RVB?
Oh, indeed. I somehow misread his mail as asking to add this comment.
Re: [PATCH 7/7] xfs: remove XFS_IFEXTENTS
In reply to Darrick J. WongQuoted 8 lines · Darrick J. Wong
Quoted 7 lines · Christoph Hellwig
The in-memory
XFS_IFEXTENTSis 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 newxfs_need_iread_extentshelper 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 theXFS_IFEXTENTSflag.
Quoted 4 lines
Quoted 1 line
Signed-off-by Christoph Hellwig <[email protected]>The series seems reasonable to me, though I wonder if Dave will have strong(er) opinions?
No, I've already said I'm fine with making these changes to remove the ambiguity. I've only briefly scan of the patches, but I didn't see anything that I disagree with that would make me stop, context switch and ask to be changed...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]