shrink struct xfs_imap
Hi all,
struct xfs_imap is embedded into struct xfs_inode and takes up considerable space. This series applies some relatively easy shrinkage to it. It it based on top of the "remove struct xfs_inode.i_ino" series.
A git tree is also available:
git://git.infradead.org/users/hch/xfs.git xfs-shrink-imap
Gitweb:
https://git.infradead.org/?p=users/hch/xfs.git;a=shortlog;h=refs/heads/xfs-shrink-imap
Diffstat:
libxfs/xfs_ialloc.c | 88 ++++++++++++++++++++----------------------------- libxfs/xfs_inode_buf.c | 20 +++++------ libxfs/xfs_inode_buf.h | 13 +++---- scrub/ialloc.c | 11 +++--- scrub/ialloc_repair.c | 7 +-- scrub/inode_repair.c | 12 ++++-- scrub/trace.h | 12 +++--- xfs_icache.c | 2 - xfs_inode_item.c | 20 +++++++---- xfs_itable.c | 2 - xfs_iunlink_item.c | 2 - 11 files changed, 90 insertions(+), 99 deletions(-)
PATCH 1/5 xfs: cleanup xfs_imap
Reshuffle the code a bit so that the imap_lookup and filling out of the xfs_imap structure aren't duplicated.
--- fs/xfs/libxfs/xfs_ialloc.c | 64 +++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 35 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +29 -35
@@ -2511,44 +2511,38 @@ xfs_imap(* inodes in stale state on disk. Hence we have to do a btree lookup * in all cases where an untrusted inode number is passed. */ -if (flags &XFS_IGET_UNTRUSTED ) { - error =xfs_imap_lookup (pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); -if (error) -return error; - goto out_map; - } +if (!(flags &XFS_IGET_UNTRUSTED )) { +/* +* If the inode cluster size is the same or smaller than the +* blocksize, get to the buffer by simple arithmetics. +*/ +if (M_IGEO (mp)->blocks_per_cluster ==1 ) { + cluster_agbno = agbno; + offset =XFS_INO_TO_OFFSET (mp, ino); +ASSERT (offset < mp->m_sb.sb_inopblock); + goto out; + } -/* -* If the inode cluster size is the same as the blocksize or -* smaller we get to the buffer by simple arithmetics. -*/ -if (M_IGEO (mp)->blocks_per_cluster ==1 ) { - offset =XFS_INO_TO_OFFSET (mp, ino); -ASSERT (offset < mp->m_sb.sb_inopblock); - - imap->im_blkno =xfs_agbno_to_daddr (pag, agbno); - imap->im_len =XFS_FSB_TO_BB (mp,1 ); - imap->im_boffset = (unsigned short )(offset << - mp->m_sb.sb_inodelog); -return 0 ; - } +/* +* If the inode chunks are aligned, use simple maths to find the +* location. +*/ +if (M_IGEO (mp)->inoalign_mask) { + offset_agbno = agbno &M_IGEO (mp)->inoalign_mask; + chunk_agbno = agbno - offset_agbno; + goto out_map; + } -/* -* If the inode chunks are aligned then use simple maths to -* find the location. Otherwise we have to do a btree -* lookup to find the location. -*/ -if (M_IGEO (mp)->inoalign_mask) { - offset_agbno = agbno &M_IGEO (mp)->inoalign_mask; - chunk_agbno = agbno - offset_agbno; - }else { - error =xfs_imap_lookup (pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); -if (error) -return error; +/* +* Otherwise we have to do a btree lookup to find the location. +*/ } + error =xfs_imap_lookup (pag, tp, agino, agbno, &chunk_agbno, + &offset_agbno, flags); +if (error) +return error; + out_map:ASSERT (agbno >= chunk_agbno); cluster_agbno = chunk_agbno +
@@ -2556,7 +2550,7 @@ xfs_imap( M_IGEO(mp)->blocks_per_cluster); offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +XFS_INO_TO_OFFSET (mp, ino); - +out: imap->im_blkno =xfs_agbno_to_daddr (pag, cluster_agbno); imap->im_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog);
Signature · 1 line
2.53.0
Re: [PATCH 1/5] xfs: cleanup xfs_imap
Quoted 4 lines · Christoph Hellwig
Reshuffle the code a bit so that the
imap_lookupand filling out of thexfs_imapstructure aren't duplicated.Signed-off-by Christoph Hellwig <[email protected]>
This is pretty straightforward so
--D
Quoted 94 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 64 +++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 35 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +29
-35@@ -2511,44 +2511,38 @@ xfs_imap(* inodes in stale state on disk. Hence we have to do a btree lookup * in all cases where an untrusted inode number is passed. */ -if (flags &XFS_IGET_UNTRUSTED ) { - error =xfs_imap_lookup (pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); -if (error) -return error; - goto out_map; - } +if (!(flags &XFS_IGET_UNTRUSTED )) { +/* +* If the inode cluster size is the same or smaller than the +* blocksize, get to the buffer by simple arithmetics. +*/ +if (M_IGEO (mp)->blocks_per_cluster ==1 ) { + cluster_agbno = agbno; + offset =XFS_INO_TO_OFFSET (mp, ino); +ASSERT (offset < mp->m_sb.sb_inopblock); + goto out; + } -/* -* If the inode cluster size is the same as the blocksize or -* smaller we get to the buffer by simple arithmetics. -*/ -if (M_IGEO (mp)->blocks_per_cluster ==1 ) { - offset =XFS_INO_TO_OFFSET (mp, ino); -ASSERT (offset < mp->m_sb.sb_inopblock); - - imap->im_blkno =xfs_agbno_to_daddr (pag, agbno); - imap->im_len =XFS_FSB_TO_BB (mp,1 ); - imap->im_boffset = (unsigned short )(offset << - mp->m_sb.sb_inodelog); -return 0 ; - } +/* +* If the inode chunks are aligned, use simple maths to find the +* location. +*/ +if (M_IGEO (mp)->inoalign_mask) { + offset_agbno = agbno &M_IGEO (mp)->inoalign_mask; + chunk_agbno = agbno - offset_agbno; + goto out_map; + } -/* -* If the inode chunks are aligned then use simple maths to -* find the location. Otherwise we have to do a btree -* lookup to find the location. -*/ -if (M_IGEO (mp)->inoalign_mask) { - offset_agbno = agbno &M_IGEO (mp)->inoalign_mask; - chunk_agbno = agbno - offset_agbno; - }else { - error =xfs_imap_lookup (pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); -if (error) -return error; +/* +* Otherwise we have to do a btree lookup to find the location. +*/ } + error =xfs_imap_lookup (pag, tp, agino, agbno, &chunk_agbno, + &offset_agbno, flags); +if (error) +return error; + out_map:ASSERT (agbno >= chunk_agbno); cluster_agbno = chunk_agbno +@@ -2556,7 +2550,7 @@ xfs_imap( M_IGEO(mp)->blocks_per_cluster); offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +XFS_INO_TO_OFFSET (mp, ino); - +out: imap->im_blkno =xfs_agbno_to_daddr (pag, cluster_agbno); imap->im_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog);Signature · 1 line
2.53.0
Re: [PATCH 1/5] xfs: cleanup xfs_imap
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Reshuffle the code a bit so that the
imap_lookupand filling out of thexfs_imapstructure aren't duplicated.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 94 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 64 +++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 35 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +29
-35@@ -2511,44 +2511,38 @@ xfs_imap(* inodes in stale state on disk. Hence we have to do a btree lookup * in all cases where an untrusted inode number is passed. */ -if (flags &XFS_IGET_UNTRUSTED ) { - error =xfs_imap_lookup (pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); -if (error) -return error; - goto out_map; - } +if (!(flags &XFS_IGET_UNTRUSTED )) { +/* +* If the inode cluster size is the same or smaller than the +* blocksize, get to the buffer by simple arithmetics. +*/ +if (M_IGEO (mp)->blocks_per_cluster ==1 ) { + cluster_agbno = agbno; + offset =XFS_INO_TO_OFFSET (mp, ino); +ASSERT (offset < mp->m_sb.sb_inopblock); + goto out; + } -/* -* If the inode cluster size is the same as the blocksize or -* smaller we get to the buffer by simple arithmetics. -*/ -if (M_IGEO (mp)->blocks_per_cluster ==1 ) { - offset =XFS_INO_TO_OFFSET (mp, ino); -ASSERT (offset < mp->m_sb.sb_inopblock); - - imap->im_blkno =xfs_agbno_to_daddr (pag, agbno); - imap->im_len =XFS_FSB_TO_BB (mp,1 ); - imap->im_boffset = (unsigned short )(offset << - mp->m_sb.sb_inodelog); -return 0 ; - } +/* +* If the inode chunks are aligned, use simple maths to find the +* location. +*/ +if (M_IGEO (mp)->inoalign_mask) { + offset_agbno = agbno &M_IGEO (mp)->inoalign_mask; + chunk_agbno = agbno - offset_agbno; + goto out_map; + } -/* -* If the inode chunks are aligned then use simple maths to -* find the location. Otherwise we have to do a btree -* lookup to find the location. -*/ -if (M_IGEO (mp)->inoalign_mask) { - offset_agbno = agbno &M_IGEO (mp)->inoalign_mask; - chunk_agbno = agbno - offset_agbno; - }else { - error =xfs_imap_lookup (pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); -if (error) -return error; +/* +* Otherwise we have to do a btree lookup to find the location. +*/ } + error =xfs_imap_lookup (pag, tp, agino, agbno, &chunk_agbno, + &offset_agbno, flags); +if (error) +return error; + out_map:ASSERT (agbno >= chunk_agbno); cluster_agbno = chunk_agbno +@@ -2556,7 +2550,7 @@ xfs_imap( M_IGEO(mp)->blocks_per_cluster); offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +XFS_INO_TO_OFFSET (mp, ino); - +out: imap->im_blkno =xfs_agbno_to_daddr (pag, cluster_agbno); imap->im_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog);Signature · 1 line
2.53.0
PATCH 2/5 xfs: remove im_len field in struct xfs_imap
In reply to Christoph Hellwigim_len is always set to the same value for a given file system, which makes it redundant.
--- fs/xfs/libxfs/xfs_ialloc.c | 10 +++++----- fs/xfs/libxfs/xfs_inode_buf.c | 3 ++- fs/xfs/libxfs/xfs_inode_buf.h | 1 - fs/xfs/scrub/ialloc.c | 4 ++-- fs/xfs/scrub/ialloc_repair.c | 1 - fs/xfs/scrub/inode_repair.c | 11 +++++++---- fs/xfs/xfs_inode_item.c | 3 ++- 7 files changed, 18 insertions(+), 15 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +5 -5
@@ -2552,7 +2552,6 @@ xfs_imap(XFS_INO_TO_OFFSET (mp, ino); out: imap->im_blkno =xfs_agbno_to_daddr (pag, cluster_agbno); - imap->im_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog);/*
@@ -2561,12 +2560,13 @@ xfs_imap(* read_buf and panicing when we get an error from the * driver. */ -if ((imap->im_blkno + imap->im_len) > +if (imap->im_blkno + +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster) >XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)) {xfs_alert (mp, -"%s: (im_blkno (0x%llx) + im_len (0x%llx)) > sb_dblocks (0x%llx)" , - __func__, (unsigned long long ) imap->im_blkno, - (unsigned long long ) imap->im_len, +"%s: (im_blkno (0x%llx) + len (0x%x)) > sb_dblocks (0x%llx)" , + __func__, imap->im_blkno, +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks));return -EINVAL ; }
fs/xfs/libxfs/xfs_inode_buf.c +2 -1
@@ -137,7 +137,8 @@ xfs_imap_to_bp(int error; error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, imap->im_blkno, - imap->im_len,0 , bpp, &xfs_inode_buf_ops); +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), +0 , bpp, &xfs_inode_buf_ops);if (xfs_metadata_is_sick (error))xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, imap->im_blkno),XFS_SICK_AG_INODES );
fs/xfs/libxfs/xfs_inode_buf.h +0 -1
@@ -15,7 +15,6 @@ struct xfs_dinode;*/ struct xfs_imap {xfs_daddr_t im_blkno;/* starting BB of inode chunk */ -unsigned short im_len;/* length in BBs of inode chunk */ unsigned short im_boffset;/* inode offset in block in bytes */ };
fs/xfs/scrub/ialloc.c +2 -2
@@ -395,7 +395,6 @@ xchk_iallocbt_check_cluster(*/ ir_holemask = (irec->ir_holemask & cluster_mask); imap.im_blkno =xfs_agbno_to_daddr (to_perag (bs->cur->bc_group), agbno); - imap.im_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); imap.im_boffset =XFS_INO_TO_OFFSET (mp, irec->ir_startino) << mp->m_sb.sb_inodelog;
@@ -406,7 +405,8 @@ xchk_iallocbt_check_cluster( }trace_xchk_iallocbt_check_cluster (to_perag (bs->cur->bc_group), - irec->ir_startino, imap.im_blkno, imap.im_len, + irec->ir_startino, imap.im_blkno, +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), cluster_base, nr_inodes, cluster_mask, ir_holemask,XFS_INO_TO_OFFSET (mp, irec->ir_startino + cluster_base));
fs/xfs/scrub/ialloc_repair.c +0 -1
@@ -306,7 +306,6 @@ xrep_ibt_process_cluster(* either inode btree. */ imap.im_blkno =xfs_agbno_to_daddr (sc->sa.pag, cluster_bno); - imap.im_len =XFS_FSB_TO_BB (mp, igeo->blocks_per_cluster); imap.im_boffset =0 ; error =xfs_imap_to_bp (mp, sc->tp, &imap, &cluster_bp);if (error)
fs/xfs/scrub/inode_repair.c +7 -4
@@ -1547,6 +1547,7 @@ xrep_dinode_core( struct xrep_inode *ri) {struct xfs_scrub *sc = ri->sc; +struct xfs_mount *mp = sc->mp;struct xfs_buf *bp;struct xfs_dinode *dip;xfs_ino_t ino = sc->sm->sm_ino;
@@ -1559,8 +1560,10 @@ xrep_dinode_core(return error;/* Read the inode cluster buffer. */ - error =xfs_trans_read_buf (sc->mp, sc->tp, sc->mp->m_ddev_targp, - ri->imap.im_blkno, ri->imap.im_len,0 , &bp,NULL ); + error =xfs_trans_read_buf (mp, sc->tp, mp->m_ddev_targp, + ri->imap.im_blkno, +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), +0 , &bp,NULL );if (error)return error;
@@ -1583,10 +1586,10 @@ xrep_dinode_core( write:/* Write out the inode. */ trace_xrep_dinode_fixed (sc, dip); -xfs_dinode_calc_crc (sc->mp, dip); +xfs_dinode_calc_crc (mp, dip);xfs_trans_buf_set_type (sc->tp, bp,XFS_BLFT_DINO_BUF );xfs_trans_log_buf (sc->tp, bp, ri->imap.im_boffset, - ri->imap.im_boffset + sc->mp->m_sb.sb_inodesize -1 ); + ri->imap.im_boffset + mp->m_sb.sb_inodesize -1 );/* * In theory, we've fixed the ondisk inode record enough that we should
fs/xfs/xfs_inode_item.c +2 -1
@@ -647,13 +647,14 @@ xfs_inode_item_format( {struct xfs_inode_log_item *iip =INODE_ITEM (lip);struct xfs_inode *ip = iip->ili_inode; +struct xfs_mount *mp = ip->i_mount;struct xfs_inode_log_format *ilf; ilf =xlog_format_start (lfb,XLOG_REG_TYPE_IFORMAT ); ilf->ilf_type =XFS_LI_INODE ; ilf->ilf_ino =I_INO (ip); ilf->ilf_blkno = ip->i_imap.im_blkno; - ilf->ilf_len = ip->i_imap.im_len; + ilf->ilf_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); ilf->ilf_boffset = ip->i_imap.im_boffset; ilf->ilf_fields =XFS_ILOG_CORE ; ilf->ilf_size =2 ;/* format + core */
Signature · 1 line
2.53.0
Re: [PATCH 2/5] xfs: remove im_len field in struct xfs_imap
Quoted 4 lines · Christoph Hellwig
im_lenis always set to the same value for a given file system, which makes it redundant.Signed-off-by Christoph Hellwig <[email protected]>
Yeah, we don't need to be wasting memory on that...
--D
Quoted 162 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 10 +++++----- fs/xfs/libxfs/xfs_inode_buf.c | 3 ++- fs/xfs/libxfs/xfs_inode_buf.h | 1 - fs/xfs/scrub/ialloc.c | 4 ++-- fs/xfs/scrub/ialloc_repair.c | 1 - fs/xfs/scrub/inode_repair.c | 11 +++++++---- fs/xfs/xfs_inode_item.c | 3 ++- 7 files changed, 18 insertions(+), 15 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +5
-5@@ -2552,7 +2552,6 @@ xfs_imap(XFS_INO_TO_OFFSET (mp, ino); out: imap->im_blkno =xfs_agbno_to_daddr (pag, cluster_agbno); - imap->im_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog);/* @@ -2561,12 +2560,13 @@ xfs_imap(* read_buf and panicing when we get an error from the * driver. */ -if ((imap->im_blkno + imap->im_len) > +if (imap->im_blkno + +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster) >XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)) {xfs_alert (mp, -"%s: (im_blkno (0x%llx) + im_len (0x%llx)) > sb_dblocks (0x%llx)" , - __func__, (unsigned long long ) imap->im_blkno, - (unsigned long long ) imap->im_len, +"%s: (im_blkno (0x%llx) + len (0x%x)) > sb_dblocks (0x%llx)" , + __func__, imap->im_blkno, +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks));return -EINVAL ; }fs/xfs/libxfs/xfs_inode_buf.c +2
-1@@ -137,7 +137,8 @@ xfs_imap_to_bp(int error; error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, imap->im_blkno, - imap->im_len,0 , bpp, &xfs_inode_buf_ops); +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), +0 , bpp, &xfs_inode_buf_ops);if (xfs_metadata_is_sick (error))xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, imap->im_blkno),XFS_SICK_AG_INODES );fs/xfs/libxfs/xfs_inode_buf.h +0
-1@@ -15,7 +15,6 @@ struct xfs_dinode;*/ struct xfs_imap {xfs_daddr_t im_blkno;/* starting BB of inode chunk */ -unsigned short im_len;/* length in BBs of inode chunk */ unsigned short im_boffset;/* inode offset in block in bytes */ };fs/xfs/scrub/ialloc.c +2
-2@@ -395,7 +395,6 @@ xchk_iallocbt_check_cluster(*/ ir_holemask = (irec->ir_holemask & cluster_mask); imap.im_blkno =xfs_agbno_to_daddr (to_perag (bs->cur->bc_group), agbno); - imap.im_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); imap.im_boffset =XFS_INO_TO_OFFSET (mp, irec->ir_startino) << mp->m_sb.sb_inodelog;@@ -406,7 +405,8 @@ xchk_iallocbt_check_cluster( }trace_xchk_iallocbt_check_cluster (to_perag (bs->cur->bc_group), - irec->ir_startino, imap.im_blkno, imap.im_len, + irec->ir_startino, imap.im_blkno, +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), cluster_base, nr_inodes, cluster_mask, ir_holemask,XFS_INO_TO_OFFSET (mp, irec->ir_startino + cluster_base));fs/xfs/scrub/ialloc_repair.c +0
-1@@ -306,7 +306,6 @@ xrep_ibt_process_cluster(* either inode btree. */ imap.im_blkno =xfs_agbno_to_daddr (sc->sa.pag, cluster_bno); - imap.im_len =XFS_FSB_TO_BB (mp, igeo->blocks_per_cluster); imap.im_boffset =0 ; error =xfs_imap_to_bp (mp, sc->tp, &imap, &cluster_bp);if (error)fs/xfs/scrub/inode_repair.c +7
-4@@ -1547,6 +1547,7 @@ xrep_dinode_core( struct xrep_inode *ri) {struct xfs_scrub *sc = ri->sc; +struct xfs_mount *mp = sc->mp;struct xfs_buf *bp;struct xfs_dinode *dip;xfs_ino_t ino = sc->sm->sm_ino;@@ -1559,8 +1560,10 @@ xrep_dinode_core(return error;/* Read the inode cluster buffer. */ - error =xfs_trans_read_buf (sc->mp, sc->tp, sc->mp->m_ddev_targp, - ri->imap.im_blkno, ri->imap.im_len,0 , &bp,NULL ); + error =xfs_trans_read_buf (mp, sc->tp, mp->m_ddev_targp, + ri->imap.im_blkno, +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), +0 , &bp,NULL );if (error)return error;@@ -1583,10 +1586,10 @@ xrep_dinode_core( write:/* Write out the inode. */ trace_xrep_dinode_fixed (sc, dip); -xfs_dinode_calc_crc (sc->mp, dip); +xfs_dinode_calc_crc (mp, dip);xfs_trans_buf_set_type (sc->tp, bp,XFS_BLFT_DINO_BUF );xfs_trans_log_buf (sc->tp, bp, ri->imap.im_boffset, - ri->imap.im_boffset + sc->mp->m_sb.sb_inodesize -1 ); + ri->imap.im_boffset + mp->m_sb.sb_inodesize -1 );/* * In theory, we've fixed the ondisk inode record enough that we should fs/xfs/xfs_inode_item.c +2
-1@@ -647,13 +647,14 @@ xfs_inode_item_format( {struct xfs_inode_log_item *iip =INODE_ITEM (lip);struct xfs_inode *ip = iip->ili_inode; +struct xfs_mount *mp = ip->i_mount;struct xfs_inode_log_format *ilf; ilf =xlog_format_start (lfb,XLOG_REG_TYPE_IFORMAT ); ilf->ilf_type =XFS_LI_INODE ; ilf->ilf_ino =I_INO (ip); ilf->ilf_blkno = ip->i_imap.im_blkno; - ilf->ilf_len = ip->i_imap.im_len; + ilf->ilf_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); ilf->ilf_boffset = ip->i_imap.im_boffset; ilf->ilf_fields =XFS_ILOG_CORE ; ilf->ilf_size =2 ;/* format + core */ Signature · 1 line
2.53.0
Re: [PATCH 2/5] xfs: remove im_len field in struct xfs_imap
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
im_lenis always set to the same value for a given file system, which makes it redundant.Signed-off-by Christoph Hellwig <[email protected]>
Straight forward.
Quoted 162 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 10 +++++----- fs/xfs/libxfs/xfs_inode_buf.c | 3 ++- fs/xfs/libxfs/xfs_inode_buf.h | 1 - fs/xfs/scrub/ialloc.c | 4 ++-- fs/xfs/scrub/ialloc_repair.c | 1 - fs/xfs/scrub/inode_repair.c | 11 +++++++---- fs/xfs/xfs_inode_item.c | 3 ++- 7 files changed, 18 insertions(+), 15 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +5
-5@@ -2552,7 +2552,6 @@ xfs_imap(XFS_INO_TO_OFFSET (mp, ino); out: imap->im_blkno =xfs_agbno_to_daddr (pag, cluster_agbno); - imap->im_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog);/* @@ -2561,12 +2560,13 @@ xfs_imap(* read_buf and panicing when we get an error from the * driver. */ -if ((imap->im_blkno + imap->im_len) > +if (imap->im_blkno + +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster) >XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)) {xfs_alert (mp, -"%s: (im_blkno (0x%llx) + im_len (0x%llx)) > sb_dblocks (0x%llx)" , - __func__, (unsigned long long ) imap->im_blkno, - (unsigned long long ) imap->im_len, +"%s: (im_blkno (0x%llx) + len (0x%x)) > sb_dblocks (0x%llx)" , + __func__, imap->im_blkno, +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks));return -EINVAL ; }fs/xfs/libxfs/xfs_inode_buf.c +2
-1@@ -137,7 +137,8 @@ xfs_imap_to_bp(int error; error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, imap->im_blkno, - imap->im_len,0 , bpp, &xfs_inode_buf_ops); +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), +0 , bpp, &xfs_inode_buf_ops);if (xfs_metadata_is_sick (error))xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, imap->im_blkno),XFS_SICK_AG_INODES );fs/xfs/libxfs/xfs_inode_buf.h +0
-1@@ -15,7 +15,6 @@ struct xfs_dinode;*/ struct xfs_imap {xfs_daddr_t im_blkno;/* starting BB of inode chunk */ -unsigned short im_len;/* length in BBs of inode chunk */ unsigned short im_boffset;/* inode offset in block in bytes */ };fs/xfs/scrub/ialloc.c +2
-2@@ -395,7 +395,6 @@ xchk_iallocbt_check_cluster(*/ ir_holemask = (irec->ir_holemask & cluster_mask); imap.im_blkno =xfs_agbno_to_daddr (to_perag (bs->cur->bc_group), agbno); - imap.im_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); imap.im_boffset =XFS_INO_TO_OFFSET (mp, irec->ir_startino) << mp->m_sb.sb_inodelog;@@ -406,7 +405,8 @@ xchk_iallocbt_check_cluster( }trace_xchk_iallocbt_check_cluster (to_perag (bs->cur->bc_group), - irec->ir_startino, imap.im_blkno, imap.im_len, + irec->ir_startino, imap.im_blkno, +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), cluster_base, nr_inodes, cluster_mask, ir_holemask,XFS_INO_TO_OFFSET (mp, irec->ir_startino + cluster_base));fs/xfs/scrub/ialloc_repair.c +0
-1@@ -306,7 +306,6 @@ xrep_ibt_process_cluster(* either inode btree. */ imap.im_blkno =xfs_agbno_to_daddr (sc->sa.pag, cluster_bno); - imap.im_len =XFS_FSB_TO_BB (mp, igeo->blocks_per_cluster); imap.im_boffset =0 ; error =xfs_imap_to_bp (mp, sc->tp, &imap, &cluster_bp);if (error)fs/xfs/scrub/inode_repair.c +7
-4@@ -1547,6 +1547,7 @@ xrep_dinode_core( struct xrep_inode *ri) {struct xfs_scrub *sc = ri->sc; +struct xfs_mount *mp = sc->mp;struct xfs_buf *bp;struct xfs_dinode *dip;xfs_ino_t ino = sc->sm->sm_ino;@@ -1559,8 +1560,10 @@ xrep_dinode_core(return error;/* Read the inode cluster buffer. */ - error =xfs_trans_read_buf (sc->mp, sc->tp, sc->mp->m_ddev_targp, - ri->imap.im_blkno, ri->imap.im_len,0 , &bp,NULL ); + error =xfs_trans_read_buf (mp, sc->tp, mp->m_ddev_targp, + ri->imap.im_blkno, +XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), +0 , &bp,NULL );if (error)return error;@@ -1583,10 +1586,10 @@ xrep_dinode_core( write:/* Write out the inode. */ trace_xrep_dinode_fixed (sc, dip); -xfs_dinode_calc_crc (sc->mp, dip); +xfs_dinode_calc_crc (mp, dip);xfs_trans_buf_set_type (sc->tp, bp,XFS_BLFT_DINO_BUF );xfs_trans_log_buf (sc->tp, bp, ri->imap.im_boffset, - ri->imap.im_boffset + sc->mp->m_sb.sb_inodesize -1 ); + ri->imap.im_boffset + mp->m_sb.sb_inodesize -1 );/* * In theory, we've fixed the ondisk inode record enough that we should fs/xfs/xfs_inode_item.c +2
-1@@ -647,13 +647,14 @@ xfs_inode_item_format( {struct xfs_inode_log_item *iip =INODE_ITEM (lip);struct xfs_inode *ip = iip->ili_inode; +struct xfs_mount *mp = ip->i_mount;struct xfs_inode_log_format *ilf; ilf =xlog_format_start (lfb,XLOG_REG_TYPE_IFORMAT ); ilf->ilf_type =XFS_LI_INODE ; ilf->ilf_ino =I_INO (ip); ilf->ilf_blkno = ip->i_imap.im_blkno; - ilf->ilf_len = ip->i_imap.im_len; + ilf->ilf_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); ilf->ilf_boffset = ip->i_imap.im_boffset; ilf->ilf_fields =XFS_ILOG_CORE ; ilf->ilf_size =2 ;/* format + core */ Signature · 1 line
2.53.0
PATCH 3/5 xfs: massage xfs_imap_to_bp into xfs_read_icluster
In reply to Christoph Hellwigxfs_imap_to_bp only uses the im_blkno field from struct xfs_imap, so pass that directly. Rename the function to xfs_read_icluster, which describes the functionality much better and matches other helpers like xfs_read_agf and xfs_read_agi.
--- fs/xfs/libxfs/xfs_ialloc.c | 2 +- fs/xfs/libxfs/xfs_inode_buf.c | 12 +++++------- fs/xfs/libxfs/xfs_inode_buf.h | 6 +++--- fs/xfs/scrub/ialloc.c | 3 ++- fs/xfs/scrub/ialloc_repair.c | 7 +++---- fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_inode_item.c | 3 ++- fs/xfs/xfs_iunlink_item.c | 2 +- 8 files changed, 18 insertions(+), 19 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +1 -1
@@ -1075,7 +1075,7 @@ xfs_dialloc_check_ino(if (error)return -EAGAIN ; - error =xfs_imap_to_bp (pag_mount (pag), tp, &imap, &bp); + error =xfs_read_icluster (pag_mount (pag), tp, imap.im_blkno, &bp);if (error)return -EAGAIN ;
fs/xfs/libxfs/xfs_inode_buf.c +5 -7
@@ -123,24 +123,22 @@ const struct xfs_buf_ops xfs_inode_buf_ra_ops = {/* -* This routine is called to map an inode to the buffer containing the on-disk -* version of the inode. It returns a pointer to the buffer containing the -* on-disk inode in the bpp parameter. +* Read the inode cluster at @bno and return it in @bpp. */ int -xfs_imap_to_bp ( +xfs_read_icluster (struct xfs_mount *mp,struct xfs_trans *tp, -struct xfs_imap *imap, +xfs_daddr_t bno,struct xfs_buf **bpp) {int error; - error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, imap->im_blkno, + error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, bno,XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),0 , bpp, &xfs_inode_buf_ops);if (xfs_metadata_is_sick (error)) -xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, imap->im_blkno), +xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, bno),XFS_SICK_AG_INODES );return error; }
fs/xfs/libxfs/xfs_inode_buf.h +3 -3
@@ -11,15 +11,15 @@ struct xfs_dinode;/* * Inode location information. Stored in the inode and passed to -* xfs_imap_to_bp() to get a buffer and dinode for a given inode. +* xfs_read_icluster() to get a buffer and dinode for a given inode. */ struct xfs_imap {xfs_daddr_t im_blkno;/* starting BB of inode chunk */ unsigned short im_boffset;/* inode offset in block in bytes */ }; -int xfs_imap_to_bp (struct xfs_mount *mp,struct xfs_trans *tp, -struct xfs_imap *imap,struct xfs_buf **bpp); +int xfs_read_icluster (struct xfs_mount *mp,struct xfs_trans *tp, +xfs_daddr_t bno,struct xfs_buf **bpp);void xfs_dinode_calc_crc (struct xfs_mount *mp,struct xfs_dinode *dip);void xfs_inode_to_disk (struct xfs_inode *ip,struct xfs_dinode *to,xfs_lsn_t lsn);
fs/xfs/scrub/ialloc.c +2 -1
@@ -429,7 +429,8 @@ xchk_iallocbt_check_cluster( &XFS_RMAP_OINFO_INODES);/* Grab the inode cluster buffer. */ - error =xfs_imap_to_bp (mp, bs->cur->bc_tp, &imap, &cluster_bp); + error =xfs_read_icluster (mp, bs->cur->bc_tp, imap.im_blkno, + &cluster_bp);if (!xchk_btree_xref_process_error (bs->sc, bs->cur,0 , &error))return error;
fs/xfs/scrub/ialloc_repair.c +3 -4
@@ -287,7 +287,6 @@ xrep_ibt_process_cluster( struct xrep_ibt *ri, xfs_agblock_t cluster_bno) { -struct xfs_imap imap;struct xfs_buf *cluster_bp;struct xfs_scrub *sc = ri->sc;struct xfs_mount *mp = sc->mp;
@@ -305,9 +304,9 @@ xrep_ibt_process_cluster(* inobt because imap_to_bp directly maps the buffer without touching * either inode btree. */ - imap.im_blkno =xfs_agbno_to_daddr (sc->sa.pag, cluster_bno); - imap.im_boffset =0 ; - error =xfs_imap_to_bp (mp, sc->tp, &imap, &cluster_bp); + error =xfs_read_icluster (mp, sc->tp, +xfs_agbno_to_daddr (sc->sa.pag, cluster_bno), + &cluster_bp);if (error)return error;
fs/xfs/xfs_icache.c +1 -1
@@ -663,7 +663,7 @@ xfs_iget_cache_miss( }else {struct xfs_buf *bp; - error =xfs_imap_to_bp (mp, tp, &ip->i_imap, &bp); + error =xfs_read_icluster (mp, tp, ip->i_imap.im_blkno, &bp);if (error) goto out_destroy;
fs/xfs/xfs_inode_item.c +2 -1
@@ -167,7 +167,8 @@ xfs_inode_item_precommit(* here. */ spin_unlock (&iip->ili_lock); - error =xfs_imap_to_bp (ip->i_mount, tp, &ip->i_imap, &bp); + error =xfs_read_icluster (ip->i_mount, tp, ip->i_imap.im_blkno, + &bp);if (error)return error;
fs/xfs/xfs_iunlink_item.c +1 -1
@@ -59,7 +59,7 @@ xfs_iunlink_log_dinode(int offset;int error; - error =xfs_imap_to_bp (tp->t_mountp, tp, &ip->i_imap, &ibp); + error =xfs_read_icluster (tp->t_mountp, tp, ip->i_imap.im_blkno, &ibp);if (error)return error;/*
Signature · 1 line
2.53.0
Re: [PATCH 3/5] xfs: massage xfs_imap_to_bp into xfs_read_icluster
Quoted 40 lines · Christoph Hellwig
xfs_imap_to_bponly uses theim_blknofield from structxfs_imap, so pass that directly. Rename the function toxfs_read_icluster, which describes the functionality much better and matches other helpers likexfs_read_agfandxfs_read_agi.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_ialloc.c | 2 +- fs/xfs/libxfs/xfs_inode_buf.c | 12 +++++------- fs/xfs/libxfs/xfs_inode_buf.h | 6 +++--- fs/xfs/scrub/ialloc.c | 3 ++- fs/xfs/scrub/ialloc_repair.c | 7 +++---- fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_inode_item.c | 3 ++- fs/xfs/xfs_iunlink_item.c | 2 +- 8 files changed, 18 insertions(+), 19 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +1
-1@@ -1075,7 +1075,7 @@ xfs_dialloc_check_ino(if (error)return -EAGAIN ; - error =xfs_imap_to_bp (pag_mount (pag), tp, &imap, &bp); + error =xfs_read_icluster (pag_mount (pag), tp, imap.im_blkno, &bp);if (error)return -EAGAIN ;fs/xfs/libxfs/xfs_inode_buf.c +0
-2@@ -123,24 +123,22 @@ const struct xfs_buf_ops xfs_inode_buf_ra_ops = {/* -* This routine is called to map an inode to the buffer containing the on-disk -* version of the inode. It returns a pointer to the buffer containing the
fs/xfs/libxfs/xfs_inode_buf.c const struct xfs_buf_ops xfs_inode_buf_ra_ops = { · line 132
Quoted 10 lines
fs/xfs/libxfs/xfs_inode_buf.c +3
-3-* on-disk inode in the bpp parameter. +* Read the inode cluster at @bno and return it in @bpp. */ int -xfs_imap_to_bp( +xfs_read_icluster( struct xfs_mount *mp, struct xfs_trans *tp, - struct xfs_imap *imap, + xfs_daddr_t bno,
Hmm. Most of the code I've looked at in xfs uses "bno" for xfs_{fs,ag,rt,rg}block_t variables.
Though for xfs_daddr_t values it's less clear -- half seem to use bno, the rest just call it daddr. Maybe this function should s/bno/daddr/ ?
Don't really care either, though.
--D
Quoted 120 lines
fs/xfs/libxfs/xfs_inode_buf.c +2
-2struct xfs_buf **bpp) {int error; - error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, imap->im_blkno, + error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, bno,XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),0 , bpp, &xfs_inode_buf_ops);if (xfs_metadata_is_sick (error)) -xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, imap->im_blkno), +xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, bno),XFS_SICK_AG_INODES );return error; }fs/xfs/libxfs/xfs_inode_buf.h +3
-3@@ -11,15 +11,15 @@ struct xfs_dinode;/* * Inode location information. Stored in the inode and passed to -* xfs_imap_to_bp() to get a buffer and dinode for a given inode. +* xfs_read_icluster() to get a buffer and dinode for a given inode. */ struct xfs_imap {xfs_daddr_t im_blkno;/* starting BB of inode chunk */ unsigned short im_boffset;/* inode offset in block in bytes */ }; -int xfs_imap_to_bp (struct xfs_mount *mp,struct xfs_trans *tp, -struct xfs_imap *imap,struct xfs_buf **bpp); +int xfs_read_icluster (struct xfs_mount *mp,struct xfs_trans *tp, +xfs_daddr_t bno,struct xfs_buf **bpp);void xfs_dinode_calc_crc (struct xfs_mount *mp,struct xfs_dinode *dip);void xfs_inode_to_disk (struct xfs_inode *ip,struct xfs_dinode *to,xfs_lsn_t lsn);fs/xfs/scrub/ialloc.c +2
-1@@ -429,7 +429,8 @@ xchk_iallocbt_check_cluster( &XFS_RMAP_OINFO_INODES);/* Grab the inode cluster buffer. */ - error =xfs_imap_to_bp (mp, bs->cur->bc_tp, &imap, &cluster_bp); + error =xfs_read_icluster (mp, bs->cur->bc_tp, imap.im_blkno, + &cluster_bp);if (!xchk_btree_xref_process_error (bs->sc, bs->cur,0 , &error))return error;fs/xfs/scrub/ialloc_repair.c +3
-4@@ -287,7 +287,6 @@ xrep_ibt_process_cluster( struct xrep_ibt *ri, xfs_agblock_t cluster_bno) { -struct xfs_imap imap;struct xfs_buf *cluster_bp;struct xfs_scrub *sc = ri->sc;struct xfs_mount *mp = sc->mp;@@ -305,9 +304,9 @@ xrep_ibt_process_cluster(* inobt because imap_to_bp directly maps the buffer without touching * either inode btree. */ - imap.im_blkno =xfs_agbno_to_daddr (sc->sa.pag, cluster_bno); - imap.im_boffset =0 ; - error =xfs_imap_to_bp (mp, sc->tp, &imap, &cluster_bp); + error =xfs_read_icluster (mp, sc->tp, +xfs_agbno_to_daddr (sc->sa.pag, cluster_bno), + &cluster_bp);if (error)return error;fs/xfs/xfs_icache.c +1
-1@@ -663,7 +663,7 @@ xfs_iget_cache_miss( }else {struct xfs_buf *bp; - error =xfs_imap_to_bp (mp, tp, &ip->i_imap, &bp); + error =xfs_read_icluster (mp, tp, ip->i_imap.im_blkno, &bp);if (error) goto out_destroy;fs/xfs/xfs_inode_item.c +2
-1@@ -167,7 +167,8 @@ xfs_inode_item_precommit(* here. */ spin_unlock (&iip->ili_lock); - error =xfs_imap_to_bp (ip->i_mount, tp, &ip->i_imap, &bp); + error =xfs_read_icluster (ip->i_mount, tp, ip->i_imap.im_blkno, + &bp);if (error)return error;fs/xfs/xfs_iunlink_item.c +1
-1@@ -59,7 +59,7 @@ xfs_iunlink_log_dinode(int offset;int error; - error =xfs_imap_to_bp (tp->t_mountp, tp, &ip->i_imap, &ibp); + error =xfs_read_icluster (tp->t_mountp, tp, ip->i_imap.im_blkno, &ibp);if (error)return error;/* Signature · 1 line
2.53.0
Re: [PATCH 3/5] xfs: massage xfs_imap_to_bp into xfs_read_icluster
Quoted 10 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_inode_buf.c const struct xfs_buf_ops xfs_inode_buf_ra_ops = { · line 132
Quoted 4 lines
fs/xfs/libxfs/xfs_inode_buf.c +1
-1struct xfs_mount *mp, struct xfs_trans *tp, - struct xfs_imap *imap, + xfs_daddr_t bno,Hmm. Most of the code I've looked at in xfs uses "bno" for xfs_{fs,ag,rt,rg}block_t variables.
Though for
xfs_daddr_tvalues it's less clear -- half seem to use bno, the rest just call it daddr. Maybe this function should s/bno/daddr/ ?
Sounds reasonable, but as you noticed this is replaced by an agbno a little later anyway.
Re: [PATCH 3/5] xfs: massage xfs_imap_to_bp into xfs_read_icluster
In reply to Christoph HellwigQuoted 7 lines · Christoph Hellwig
xfs_imap_to_bponly uses theim_blknofield from structxfs_imap, so pass that directly. Rename the function toxfs_read_icluster, which describes the functionality much better and matches other helpers likexfs_read_agfandxfs_read_agi.Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 163 lines
fs/xfs/libxfs/xfs_ialloc.c | 2 +- fs/xfs/libxfs/xfs_inode_buf.c | 12 +++++------- fs/xfs/libxfs/xfs_inode_buf.h | 6 +++--- fs/xfs/scrub/ialloc.c | 3 ++- fs/xfs/scrub/ialloc_repair.c | 7 +++---- fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_inode_item.c | 3 ++- fs/xfs/xfs_iunlink_item.c | 2 +- 8 files changed, 18 insertions(+), 19 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +1
-1@@ -1075,7 +1075,7 @@ xfs_dialloc_check_ino(if (error)return -EAGAIN ; - error =xfs_imap_to_bp (pag_mount (pag), tp, &imap, &bp); + error =xfs_read_icluster (pag_mount (pag), tp, imap.im_blkno, &bp);if (error)return -EAGAIN ;fs/xfs/libxfs/xfs_inode_buf.c +5
-7@@ -123,24 +123,22 @@ const struct xfs_buf_ops xfs_inode_buf_ra_ops = {/* -* This routine is called to map an inode to the buffer containing the on-disk -* version of the inode. It returns a pointer to the buffer containing the -* on-disk inode in the bpp parameter. +* Read the inode cluster at @bno and return it in @bpp. */ int -xfs_imap_to_bp ( +xfs_read_icluster (struct xfs_mount *mp,struct xfs_trans *tp, -struct xfs_imap *imap, +xfs_daddr_t bno,struct xfs_buf **bpp) {int error; - error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, imap->im_blkno, + error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, bno,XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),0 , bpp, &xfs_inode_buf_ops);if (xfs_metadata_is_sick (error)) -xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, imap->im_blkno), +xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, bno),XFS_SICK_AG_INODES );return error; }fs/xfs/libxfs/xfs_inode_buf.h +3
-3@@ -11,15 +11,15 @@ struct xfs_dinode;/* * Inode location information. Stored in the inode and passed to -* xfs_imap_to_bp() to get a buffer and dinode for a given inode. +* xfs_read_icluster() to get a buffer and dinode for a given inode. */ struct xfs_imap {xfs_daddr_t im_blkno;/* starting BB of inode chunk */ unsigned short im_boffset;/* inode offset in block in bytes */ }; -int xfs_imap_to_bp (struct xfs_mount *mp,struct xfs_trans *tp, -struct xfs_imap *imap,struct xfs_buf **bpp); +int xfs_read_icluster (struct xfs_mount *mp,struct xfs_trans *tp, +xfs_daddr_t bno,struct xfs_buf **bpp);void xfs_dinode_calc_crc (struct xfs_mount *mp,struct xfs_dinode *dip);void xfs_inode_to_disk (struct xfs_inode *ip,struct xfs_dinode *to,xfs_lsn_t lsn);fs/xfs/scrub/ialloc.c +2
-1@@ -429,7 +429,8 @@ xchk_iallocbt_check_cluster( &XFS_RMAP_OINFO_INODES);/* Grab the inode cluster buffer. */ - error =xfs_imap_to_bp (mp, bs->cur->bc_tp, &imap, &cluster_bp); + error =xfs_read_icluster (mp, bs->cur->bc_tp, imap.im_blkno, + &cluster_bp);if (!xchk_btree_xref_process_error (bs->sc, bs->cur,0 , &error))return error;fs/xfs/scrub/ialloc_repair.c +3
-4@@ -287,7 +287,6 @@ xrep_ibt_process_cluster( struct xrep_ibt *ri, xfs_agblock_t cluster_bno) { -struct xfs_imap imap;struct xfs_buf *cluster_bp;struct xfs_scrub *sc = ri->sc;struct xfs_mount *mp = sc->mp;@@ -305,9 +304,9 @@ xrep_ibt_process_cluster(* inobt because imap_to_bp directly maps the buffer without touching * either inode btree. */ - imap.im_blkno =xfs_agbno_to_daddr (sc->sa.pag, cluster_bno); - imap.im_boffset =0 ; - error =xfs_imap_to_bp (mp, sc->tp, &imap, &cluster_bp); + error =xfs_read_icluster (mp, sc->tp, +xfs_agbno_to_daddr (sc->sa.pag, cluster_bno), + &cluster_bp);if (error)return error;fs/xfs/xfs_icache.c +1
-1@@ -663,7 +663,7 @@ xfs_iget_cache_miss( }else {struct xfs_buf *bp; - error =xfs_imap_to_bp (mp, tp, &ip->i_imap, &bp); + error =xfs_read_icluster (mp, tp, ip->i_imap.im_blkno, &bp);if (error) goto out_destroy;fs/xfs/xfs_inode_item.c +2
-1@@ -167,7 +167,8 @@ xfs_inode_item_precommit(* here. */ spin_unlock (&iip->ili_lock); - error =xfs_imap_to_bp (ip->i_mount, tp, &ip->i_imap, &bp); + error =xfs_read_icluster (ip->i_mount, tp, ip->i_imap.im_blkno, + &bp);if (error)return error;fs/xfs/xfs_iunlink_item.c +1
-1@@ -59,7 +59,7 @@ xfs_iunlink_log_dinode(int offset;int error; - error =xfs_imap_to_bp (tp->t_mountp, tp, &ip->i_imap, &ibp); + error =xfs_read_icluster (tp->t_mountp, tp, ip->i_imap.im_blkno, &ibp);if (error)return error;/* Signature · 1 line
2.53.0
PATCH 4/5 xfs: store an agbno in struct xfs_imap
In reply to Christoph HellwigThe xfs_imap structure is embedded into the xfs_inode, which means the size of it directly affects the inode size. Replacing the xfs_daddr_t with an xfs_agbno_t and taking the AG information from other easily available sources allows us to shrink the structure including the typical padding from 16 bytes to 8 bytes.
As a side-effect the debugging check in xfs_imap() naturally now converges to a stricter variant that checks that the cluster is located inside a single AG, and not just inside the entire device.
--- fs/xfs/libxfs/xfs_ialloc.c | 24 +++++++----------------- fs/xfs/libxfs/xfs_inode_buf.c | 11 ++++++----- fs/xfs/libxfs/xfs_inode_buf.h | 8 ++++---- fs/xfs/scrub/ialloc.c | 8 ++++---- fs/xfs/scrub/ialloc_repair.c | 3 +-- fs/xfs/scrub/inode_repair.c | 3 ++- fs/xfs/scrub/trace.h | 12 ++++++------ fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_inode_item.c | 18 +++++++++++------- fs/xfs/xfs_itable.c | 2 +- fs/xfs/xfs_iunlink_item.c | 2 +- 11 files changed, 44 insertions(+), 49 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +7 -17
@@ -1075,7 +1075,7 @@ xfs_dialloc_check_ino(if (error)return -EAGAIN ; - error =xfs_read_icluster (pag_mount (pag), tp, imap.im_blkno, &bp); + error =xfs_read_icluster (pag, tp, imap.im_agbno, &bp);if (error)return -EAGAIN ;
@@ -2551,23 +2551,13 @@ xfs_imap( offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +XFS_INO_TO_OFFSET (mp, ino); out: - imap->im_blkno =xfs_agbno_to_daddr (pag, cluster_agbno); + imap->im_agbno = cluster_agbno; imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog); - -/* -* If the inode number maps to a block outside the bounds -* of the file system then return NULL rather than calling -* read_buf and panicing when we get an error from the -* driver. -*/ -if (imap->im_blkno + -XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster) > -XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)) { -xfs_alert (mp, -"%s: (im_blkno (0x%llx) + len (0x%x)) > sb_dblocks (0x%llx)" , - __func__, imap->im_blkno, -XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), -XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)); +if (imap->im_agbno +M_IGEO (mp)->blocks_per_cluster > +pag_group (pag)->xg_block_count) { +xfs_alert (mp,"inode cluster out of range: %u/%u > %u" , + imap->im_agbno,M_IGEO (mp)->blocks_per_cluster, +pag_group (pag)->xg_block_count);return -EINVAL ; }return 0 ;
fs/xfs/libxfs/xfs_inode_buf.c +6 -5
@@ -127,19 +127,20 @@ const struct xfs_buf_ops xfs_inode_buf_ra_ops = {*/ int xfs_read_icluster ( -struct xfs_mount *mp, +struct xfs_perag *pag,struct xfs_trans *tp, -xfs_daddr_t bno, +xfs_agblock_t agbno,struct xfs_buf **bpp) { +struct xfs_mount *mp =pag_mount (pag);int error; - error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, bno, + error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, +xfs_agbno_to_daddr (pag, agbno),XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),0 , bpp, &xfs_inode_buf_ops);if (xfs_metadata_is_sick (error)) -xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, bno), -XFS_SICK_AG_INODES ); +xfs_agno_mark_sick (mp,pag_agno (pag),XFS_SICK_AG_INODES );return error; }
fs/xfs/libxfs/xfs_inode_buf.h +4 -4
@@ -14,12 +14,12 @@ struct xfs_dinode;* xfs_read_icluster() to get a buffer and dinode for a given inode. */ struct xfs_imap { -xfs_daddr_t im_blkno;/* starting BB of inode chunk */ -unsigned short im_boffset;/* inode offset in block in bytes */ +xfs_agblock_t im_agbno;/* starting agbno of inode cluster */ +unsigned short im_boffset;/* offset in inode cluster in bytes */ }; -int xfs_read_icluster (struct xfs_mount *mp,struct xfs_trans *tp, -xfs_daddr_t bno,struct xfs_buf **bpp); +int xfs_read_icluster (struct xfs_perag *pag,struct xfs_trans *tp, +xfs_agblock_t agbno,struct xfs_buf **bpp);void xfs_dinode_calc_crc (struct xfs_mount *mp,struct xfs_dinode *dip);void xfs_inode_to_disk (struct xfs_inode *ip,struct xfs_dinode *to,xfs_lsn_t lsn);
fs/xfs/scrub/ialloc.c +4 -4
@@ -363,6 +363,7 @@ xchk_iallocbt_check_cluster(struct xfs_inobt_rec_incore *irec, unsigned int cluster_base) { + struct xfs_perag *pag = to_perag(bs->cur->bc_group);struct xfs_imap imap;struct xfs_mount *mp = bs->cur->bc_mp;struct xfs_buf *cluster_bp;
@@ -394,7 +395,7 @@ xchk_iallocbt_check_cluster(* ir_startino can be large enough to make im_boffset nonzero. */ ir_holemask = (irec->ir_holemask & cluster_mask); - imap.im_blkno =xfs_agbno_to_daddr (to_perag (bs->cur->bc_group), agbno); + imap.im_agbno = agbno; imap.im_boffset =XFS_INO_TO_OFFSET (mp, irec->ir_startino) << mp->m_sb.sb_inodelog;
@@ -404,8 +405,7 @@ xchk_iallocbt_check_cluster(return 0 ; } - trace_xchk_iallocbt_check_cluster(to_perag(bs->cur->bc_group), - irec->ir_startino, imap.im_blkno, + trace_xchk_iallocbt_check_cluster(pag, irec->ir_startino, imap.im_agbno, XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), cluster_base, nr_inodes, cluster_mask, ir_holemask, XFS_INO_TO_OFFSET(mp, irec->ir_startino +
@@ -429,7 +429,7 @@ xchk_iallocbt_check_cluster( &XFS_RMAP_OINFO_INODES);/* Grab the inode cluster buffer. */ - error =xfs_read_icluster (mp, bs->cur->bc_tp, imap.im_blkno, + error =xfs_read_icluster (pag, bs->cur->bc_tp, imap.im_agbno, &cluster_bp);if (!xchk_btree_xref_process_error (bs->sc, bs->cur,0 , &error))return error;
fs/xfs/scrub/ialloc_repair.c +1 -2
@@ -304,8 +304,7 @@ xrep_ibt_process_cluster(* inobt because imap_to_bp directly maps the buffer without touching * either inode btree. */ - error =xfs_read_icluster (mp, sc->tp, -xfs_agbno_to_daddr (sc->sa.pag, cluster_bno), + error =xfs_read_icluster (sc->sa.pag, sc->tp, cluster_bno, &cluster_bp);if (error)return error;
fs/xfs/scrub/inode_repair.c +2 -1
@@ -1561,7 +1561,8 @@ xrep_dinode_core(/* Read the inode cluster buffer. */ error =xfs_trans_read_buf (mp, sc->tp, mp->m_ddev_targp, - ri->imap.im_blkno, +XFS_AGB_TO_DADDR (mp,XFS_INO_TO_AGNO (mp, ino), + ri->imap.im_agbno),XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),0 , &bp,NULL );if (error)
fs/xfs/scrub/trace.h +6 -6
@@ -785,17 +785,17 @@ TRACE_EVENT(xchk_xref_error, TRACE_EVENT(xchk_iallocbt_check_cluster, TP_PROTO(const struct xfs_perag *pag, xfs_agino_t startino, - xfs_daddr_t map_daddr, unsigned short map_len, + xfs_agblock_t map_agblock, unsigned short map_len, unsigned int chunk_ino, unsigned int nr_inodes, uint16_t cluster_mask, uint16_t holemask, unsigned int cluster_ino), - TP_ARGS(pag, startino, map_daddr, map_len, chunk_ino, nr_inodes, + TP_ARGS(pag, startino, map_agblock, map_len, chunk_ino, nr_inodes, cluster_mask, holemask, cluster_ino), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) __field(xfs_agino_t, startino) - __field(xfs_daddr_t, map_daddr) + __field(xfs_agblock_t, map_agblock) __field(unsigned short, map_len) __field(unsigned int, chunk_ino) __field(unsigned int, nr_inodes)
@@ -807,7 +807,7 @@ TRACE_EVENT(xchk_iallocbt_check_cluster, __entry->dev =pag_mount (pag)->m_super->s_dev; __entry->agno =pag_agno (pag); __entry->startino = startino; - __entry->map_daddr = map_daddr; + __entry->map_agblock = map_agblock; __entry->map_len = map_len; __entry->chunk_ino = chunk_ino; __entry->nr_inodes = nr_inodes;
@@ -815,11 +815,11 @@ TRACE_EVENT(xchk_iallocbt_check_cluster, __entry->holemask = holemask; __entry->cluster_ino = cluster_ino; ), - TP_printk("dev %d:%d agno 0x%x startino 0x%x daddr 0x%llx bbcount 0x%x chunkino 0x%x nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino 0x%x", + TP_printk("dev %d:%d agno 0x%x startino 0x%x agblock 0x%x bbcount 0x%x chunkino 0x%x nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino 0x%x", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno, __entry->startino, - __entry->map_daddr, + __entry->map_agblock, __entry->map_len, __entry->chunk_ino, __entry->nr_inodes,
fs/xfs/xfs_icache.c +1 -1
@@ -663,7 +663,7 @@ xfs_iget_cache_miss( }else {struct xfs_buf *bp; - error =xfs_read_icluster (mp, tp, ip->i_imap.im_blkno, &bp); + error =xfs_read_icluster (pag, tp, ip->i_imap.im_agbno, &bp);if (error) goto out_destroy;
fs/xfs/xfs_inode_item.c +11 -7
@@ -18,6 +18,7 @@#include "xfs_buf_item.h" #include "xfs_log.h" #include "xfs_log_priv.h" +#include "xfs_ag.h" #include "xfs_error.h" #include "xfs_rtbitmap.h"
@@ -104,6 +105,7 @@ xfs_inode_item_precommit( {struct xfs_inode_log_item *iip =INODE_ITEM (lip);struct xfs_inode *ip = iip->ili_inode; +struct xfs_mount *mp = ip->i_mount;struct inode *inode =VFS_I (ip);unsigned int flags = iip->ili_dirty_flags;
@@ -124,8 +126,7 @@ xfs_inode_item_precommit(* to upgrade this inode to bigtime format, do so now. */ if ((flags & (XFS_ILOG_CORE |XFS_ILOG_TIMESTAMP )) && -xfs_has_bigtime (ip->i_mount) && - !xfs_inode_has_bigtime (ip)) { +xfs_has_bigtime (mp) && !xfs_inode_has_bigtime (ip)) { ip->i_diflags2 |=XFS_DIFLAG2_BIGTIME ; flags |=XFS_ILOG_CORE ; }
@@ -138,14 +139,14 @@ xfs_inode_item_precommit(*/ if (ip->i_diflags &XFS_DIFLAG_RTINHERIT ) {if ((ip->i_diflags &XFS_DIFLAG_EXTSZINHERIT ) && -xfs_extlen_to_rtxmod (ip->i_mount, ip->i_extsize) >0 ) { +xfs_extlen_to_rtxmod (mp, ip->i_extsize) >0 ) { ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE |XFS_DIFLAG_EXTSZINHERIT ); ip->i_extsize =0 ; flags |=XFS_ILOG_CORE ; }if ((ip->i_diflags2 &XFS_DIFLAG2_COWEXTSIZE ) && -xfs_extlen_to_rtxmod (ip->i_mount, ip->i_cowextsize) >0 ) { +xfs_extlen_to_rtxmod (mp, ip->i_cowextsize) >0 ) { ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE ; ip->i_cowextsize =0 ; flags |=XFS_ILOG_CORE ;
@@ -154,6 +155,7 @@ xfs_inode_item_precommit(spin_lock (&iip->ili_lock);if (!iip->ili_item.li_buf) { +struct xfs_perag *pag;struct xfs_buf *bp;int error;
@@ -167,8 +169,9 @@ xfs_inode_item_precommit(* here. */ spin_unlock (&iip->ili_lock); - error =xfs_read_icluster (ip->i_mount, tp, ip->i_imap.im_blkno, - &bp); + pag =xfs_perag_get (mp,XFS_INODE_TO_AGNO (ip)); + error =xfs_read_icluster (pag, tp, ip->i_imap.im_agbno, &bp); +xfs_perag_put (pag);if (error)return error;
@@ -654,7 +657,8 @@ xfs_inode_item_format( ilf =xlog_format_start (lfb,XLOG_REG_TYPE_IFORMAT ); ilf->ilf_type =XFS_LI_INODE ; ilf->ilf_ino =I_INO (ip); - ilf->ilf_blkno = ip->i_imap.im_blkno; + ilf->ilf_blkno =XFS_AGB_TO_DADDR (mp,XFS_INODE_TO_AGNO (ip), + ip->i_imap.im_agbno); ilf->ilf_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); ilf->ilf_boffset = ip->i_imap.im_boffset; ilf->ilf_fields =XFS_ILOG_CORE ;
fs/xfs/xfs_itable.c +1 -1
@@ -97,7 +97,7 @@ xfs_bulkstat_one_int( }ASSERT (ip !=NULL ); -ASSERT (ip->i_imap.im_blkno !=0 ); +ASSERT (ip->i_imap.im_agbno !=0 ); inode =VFS_I (ip); vfsuid =i_uid_into_vfsuid (idmap, inode); vfsgid =i_gid_into_vfsgid (idmap, inode);
fs/xfs/xfs_iunlink_item.c +1 -1
@@ -59,7 +59,7 @@ xfs_iunlink_log_dinode(int offset;int error; - error =xfs_read_icluster (tp->t_mountp, tp, ip->i_imap.im_blkno, &ibp); + error =xfs_read_icluster (iup->pag, tp, ip->i_imap.im_agbno, &ibp);if (error)return error;/*
Signature · 1 line
2.53.0
Re: [PATCH 4/5] xfs: store an agbno in struct xfs_imap
Quoted 5 lines · Christoph Hellwig
The
xfs_imapstructure is embedded into thexfs_inode, which means the size of it directly affects the inode size. Replacing thexfs_daddr_twith anxfs_agbno_tand taking the AG information from other easily available sources allows us to shrink the structure including the typical padding from 16 bytes to 8 bytes.
Hah!!
Quoted 67 lines
As a side-effect the debugging check in
xfs_imap()naturally now converges to a stricter variant that checks that the cluster is located inside a single AG, and not just inside the entire device.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_ialloc.c | 24 +++++++----------------- fs/xfs/libxfs/xfs_inode_buf.c | 11 ++++++----- fs/xfs/libxfs/xfs_inode_buf.h | 8 ++++---- fs/xfs/scrub/ialloc.c | 8 ++++---- fs/xfs/scrub/ialloc_repair.c | 3 +-- fs/xfs/scrub/inode_repair.c | 3 ++- fs/xfs/scrub/trace.h | 12 ++++++------ fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_inode_item.c | 18 +++++++++++------- fs/xfs/xfs_itable.c | 2 +- fs/xfs/xfs_iunlink_item.c | 2 +- 11 files changed, 44 insertions(+), 49 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +7
-17@@ -1075,7 +1075,7 @@ xfs_dialloc_check_ino(if (error)return -EAGAIN ; - error =xfs_read_icluster (pag_mount (pag), tp, imap.im_blkno, &bp); + error =xfs_read_icluster (pag, tp, imap.im_agbno, &bp);if (error)return -EAGAIN ;@@ -2551,23 +2551,13 @@ xfs_imap( offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +XFS_INO_TO_OFFSET (mp, ino); out: - imap->im_blkno =xfs_agbno_to_daddr (pag, cluster_agbno); + imap->im_agbno = cluster_agbno; imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog); - -/* -* If the inode number maps to a block outside the bounds -* of the file system then return NULL rather than calling -* read_buf and panicing when we get an error from the -* driver. -*/ -if (imap->im_blkno + -XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster) > -XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)) { -xfs_alert (mp, -"%s: (im_blkno (0x%llx) + len (0x%x)) > sb_dblocks (0x%llx)" , - __func__, imap->im_blkno, -XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), -XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)); +if (imap->im_agbno +M_IGEO (mp)->blocks_per_cluster > +pag_group (pag)->xg_block_count) { +xfs_alert (mp,"inode cluster out of range: %u/%u > %u" , + imap->im_agbno,M_IGEO (mp)->blocks_per_cluster, +pag_group (pag)->xg_block_count);return -EINVAL ; }return 0 ;fs/xfs/libxfs/xfs_inode_buf.c +0
-0
fs/xfs/libxfs/xfs_inode_buf.c const struct xfs_buf_ops xfs_inode_buf_ra_ops = { · line 132
Quoted 8 lines
fs/xfs/libxfs/xfs_inode_buf.c +2
-2@@ -127,19 +127,20 @@ const struct xfs_buf_ops xfs_inode_buf_ra_ops = {*/ int xfs_read_icluster( - struct xfs_mount *mp, + struct xfs_perag *pag, struct xfs_trans *tp, - xfs_daddr_t bno, + xfs_agblock_t agbno,
Never mind, ignore my mumbling in the reply to the previous patch about daddr variable names.
For this and the previous patch,
--D
Quoted 274 lines
fs/xfs/libxfs/xfs_inode_buf.c +4
-3struct xfs_buf **bpp) { +struct xfs_mount *mp =pag_mount (pag);int error; - error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, bno, + error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, +xfs_agbno_to_daddr (pag, agbno),XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),0 , bpp, &xfs_inode_buf_ops);if (xfs_metadata_is_sick (error)) -xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, bno), -XFS_SICK_AG_INODES ); +xfs_agno_mark_sick (mp,pag_agno (pag),XFS_SICK_AG_INODES );return error; }fs/xfs/libxfs/xfs_inode_buf.h +4
-4@@ -14,12 +14,12 @@ struct xfs_dinode;* xfs_read_icluster() to get a buffer and dinode for a given inode. */ struct xfs_imap { -xfs_daddr_t im_blkno;/* starting BB of inode chunk */ -unsigned short im_boffset;/* inode offset in block in bytes */ +xfs_agblock_t im_agbno;/* starting agbno of inode cluster */ +unsigned short im_boffset;/* offset in inode cluster in bytes */ }; -int xfs_read_icluster (struct xfs_mount *mp,struct xfs_trans *tp, -xfs_daddr_t bno,struct xfs_buf **bpp); +int xfs_read_icluster (struct xfs_perag *pag,struct xfs_trans *tp, +xfs_agblock_t agbno,struct xfs_buf **bpp);void xfs_dinode_calc_crc (struct xfs_mount *mp,struct xfs_dinode *dip);void xfs_inode_to_disk (struct xfs_inode *ip,struct xfs_dinode *to,xfs_lsn_t lsn);fs/xfs/scrub/ialloc.c +4
-4@@ -363,6 +363,7 @@ xchk_iallocbt_check_cluster(struct xfs_inobt_rec_incore *irec, unsigned int cluster_base) { + struct xfs_perag *pag = to_perag(bs->cur->bc_group);struct xfs_imap imap;struct xfs_mount *mp = bs->cur->bc_mp;struct xfs_buf *cluster_bp;@@ -394,7 +395,7 @@ xchk_iallocbt_check_cluster(* ir_startino can be large enough to make im_boffset nonzero. */ ir_holemask = (irec->ir_holemask & cluster_mask); - imap.im_blkno =xfs_agbno_to_daddr (to_perag (bs->cur->bc_group), agbno); + imap.im_agbno = agbno; imap.im_boffset =XFS_INO_TO_OFFSET (mp, irec->ir_startino) << mp->m_sb.sb_inodelog;@@ -404,8 +405,7 @@ xchk_iallocbt_check_cluster(return 0 ; } - trace_xchk_iallocbt_check_cluster(to_perag(bs->cur->bc_group), - irec->ir_startino, imap.im_blkno, + trace_xchk_iallocbt_check_cluster(pag, irec->ir_startino, imap.im_agbno, XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), cluster_base, nr_inodes, cluster_mask, ir_holemask, XFS_INO_TO_OFFSET(mp, irec->ir_startino +@@ -429,7 +429,7 @@ xchk_iallocbt_check_cluster( &XFS_RMAP_OINFO_INODES);/* Grab the inode cluster buffer. */ - error =xfs_read_icluster (mp, bs->cur->bc_tp, imap.im_blkno, + error =xfs_read_icluster (pag, bs->cur->bc_tp, imap.im_agbno, &cluster_bp);if (!xchk_btree_xref_process_error (bs->sc, bs->cur,0 , &error))return error;fs/xfs/scrub/ialloc_repair.c +1
-2@@ -304,8 +304,7 @@ xrep_ibt_process_cluster(* inobt because imap_to_bp directly maps the buffer without touching * either inode btree. */ - error =xfs_read_icluster (mp, sc->tp, -xfs_agbno_to_daddr (sc->sa.pag, cluster_bno), + error =xfs_read_icluster (sc->sa.pag, sc->tp, cluster_bno, &cluster_bp);if (error)return error;fs/xfs/scrub/inode_repair.c +2
-1@@ -1561,7 +1561,8 @@ xrep_dinode_core(/* Read the inode cluster buffer. */ error =xfs_trans_read_buf (mp, sc->tp, mp->m_ddev_targp, - ri->imap.im_blkno, +XFS_AGB_TO_DADDR (mp,XFS_INO_TO_AGNO (mp, ino), + ri->imap.im_agbno),XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),0 , &bp,NULL );if (error)fs/xfs/scrub/trace.h +6
-6@@ -785,17 +785,17 @@ TRACE_EVENT(xchk_xref_error, TRACE_EVENT(xchk_iallocbt_check_cluster, TP_PROTO(const struct xfs_perag *pag, xfs_agino_t startino, - xfs_daddr_t map_daddr, unsigned short map_len, + xfs_agblock_t map_agblock, unsigned short map_len, unsigned int chunk_ino, unsigned int nr_inodes, uint16_t cluster_mask, uint16_t holemask, unsigned int cluster_ino), - TP_ARGS(pag, startino, map_daddr, map_len, chunk_ino, nr_inodes, + TP_ARGS(pag, startino, map_agblock, map_len, chunk_ino, nr_inodes, cluster_mask, holemask, cluster_ino), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) __field(xfs_agino_t, startino) - __field(xfs_daddr_t, map_daddr) + __field(xfs_agblock_t, map_agblock) __field(unsigned short, map_len) __field(unsigned int, chunk_ino) __field(unsigned int, nr_inodes)@@ -807,7 +807,7 @@ TRACE_EVENT(xchk_iallocbt_check_cluster, __entry->dev =pag_mount (pag)->m_super->s_dev; __entry->agno =pag_agno (pag); __entry->startino = startino; - __entry->map_daddr = map_daddr; + __entry->map_agblock = map_agblock; __entry->map_len = map_len; __entry->chunk_ino = chunk_ino; __entry->nr_inodes = nr_inodes;@@ -815,11 +815,11 @@ TRACE_EVENT(xchk_iallocbt_check_cluster, __entry->holemask = holemask; __entry->cluster_ino = cluster_ino; ), - TP_printk("dev %d:%d agno 0x%x startino 0x%x daddr 0x%llx bbcount 0x%x chunkino 0x%x nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino 0x%x", + TP_printk("dev %d:%d agno 0x%x startino 0x%x agblock 0x%x bbcount 0x%x chunkino 0x%x nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino 0x%x", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno, __entry->startino, - __entry->map_daddr, + __entry->map_agblock, __entry->map_len, __entry->chunk_ino, __entry->nr_inodes,fs/xfs/xfs_icache.c +1
-1@@ -663,7 +663,7 @@ xfs_iget_cache_miss( }else {struct xfs_buf *bp; - error =xfs_read_icluster (mp, tp, ip->i_imap.im_blkno, &bp); + error =xfs_read_icluster (pag, tp, ip->i_imap.im_agbno, &bp);if (error) goto out_destroy;fs/xfs/xfs_inode_item.c +11
-7@@ -18,6 +18,7 @@#include "xfs_buf_item.h" #include "xfs_log.h" #include "xfs_log_priv.h" +#include "xfs_ag.h" #include "xfs_error.h" #include "xfs_rtbitmap.h" @@ -104,6 +105,7 @@ xfs_inode_item_precommit( {struct xfs_inode_log_item *iip =INODE_ITEM (lip);struct xfs_inode *ip = iip->ili_inode; +struct xfs_mount *mp = ip->i_mount;struct inode *inode =VFS_I (ip);unsigned int flags = iip->ili_dirty_flags;@@ -124,8 +126,7 @@ xfs_inode_item_precommit(* to upgrade this inode to bigtime format, do so now. */ if ((flags & (XFS_ILOG_CORE |XFS_ILOG_TIMESTAMP )) && -xfs_has_bigtime (ip->i_mount) && - !xfs_inode_has_bigtime (ip)) { +xfs_has_bigtime (mp) && !xfs_inode_has_bigtime (ip)) { ip->i_diflags2 |=XFS_DIFLAG2_BIGTIME ; flags |=XFS_ILOG_CORE ; }@@ -138,14 +139,14 @@ xfs_inode_item_precommit(*/ if (ip->i_diflags &XFS_DIFLAG_RTINHERIT ) {if ((ip->i_diflags &XFS_DIFLAG_EXTSZINHERIT ) && -xfs_extlen_to_rtxmod (ip->i_mount, ip->i_extsize) >0 ) { +xfs_extlen_to_rtxmod (mp, ip->i_extsize) >0 ) { ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE |XFS_DIFLAG_EXTSZINHERIT ); ip->i_extsize =0 ; flags |=XFS_ILOG_CORE ; }if ((ip->i_diflags2 &XFS_DIFLAG2_COWEXTSIZE ) && -xfs_extlen_to_rtxmod (ip->i_mount, ip->i_cowextsize) >0 ) { +xfs_extlen_to_rtxmod (mp, ip->i_cowextsize) >0 ) { ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE ; ip->i_cowextsize =0 ; flags |=XFS_ILOG_CORE ;@@ -154,6 +155,7 @@ xfs_inode_item_precommit(spin_lock (&iip->ili_lock);if (!iip->ili_item.li_buf) { +struct xfs_perag *pag;struct xfs_buf *bp;int error;@@ -167,8 +169,9 @@ xfs_inode_item_precommit(* here. */ spin_unlock (&iip->ili_lock); - error =xfs_read_icluster (ip->i_mount, tp, ip->i_imap.im_blkno, - &bp); + pag =xfs_perag_get (mp,XFS_INODE_TO_AGNO (ip)); + error =xfs_read_icluster (pag, tp, ip->i_imap.im_agbno, &bp); +xfs_perag_put (pag);if (error)return error;@@ -654,7 +657,8 @@ xfs_inode_item_format( ilf =xlog_format_start (lfb,XLOG_REG_TYPE_IFORMAT ); ilf->ilf_type =XFS_LI_INODE ; ilf->ilf_ino =I_INO (ip); - ilf->ilf_blkno = ip->i_imap.im_blkno; + ilf->ilf_blkno =XFS_AGB_TO_DADDR (mp,XFS_INODE_TO_AGNO (ip), + ip->i_imap.im_agbno); ilf->ilf_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); ilf->ilf_boffset = ip->i_imap.im_boffset; ilf->ilf_fields =XFS_ILOG_CORE ;fs/xfs/xfs_itable.c +1
-1@@ -97,7 +97,7 @@ xfs_bulkstat_one_int( }ASSERT (ip !=NULL ); -ASSERT (ip->i_imap.im_blkno !=0 ); +ASSERT (ip->i_imap.im_agbno !=0 ); inode =VFS_I (ip); vfsuid =i_uid_into_vfsuid (idmap, inode); vfsgid =i_gid_into_vfsgid (idmap, inode);fs/xfs/xfs_iunlink_item.c +1
-1@@ -59,7 +59,7 @@ xfs_iunlink_log_dinode(int offset;int error; - error =xfs_read_icluster (tp->t_mountp, tp, ip->i_imap.im_blkno, &ibp); + error =xfs_read_icluster (iup->pag, tp, ip->i_imap.im_agbno, &ibp);if (error)return error;/* Signature · 1 line
2.53.0
Re: [PATCH 4/5] xfs: store an agbno in struct xfs_imap
In reply to Christoph HellwigQuoted 11 lines · Christoph Hellwig
The
xfs_imapstructure is embedded into thexfs_inode, which means the size of it directly affects the inode size. Replacing thexfs_daddr_twith anxfs_agbno_tand taking the AG information from other easily available sources allows us to shrink the structure including the typical padding from 16 bytes to 8 bytes.As a side-effect the debugging check in
xfs_imap()naturally now converges to a stricter variant that checks that the cluster is located inside a single AG, and not just inside the entire device.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 344 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 24 +++++++----------------- fs/xfs/libxfs/xfs_inode_buf.c | 11 ++++++----- fs/xfs/libxfs/xfs_inode_buf.h | 8 ++++---- fs/xfs/scrub/ialloc.c | 8 ++++---- fs/xfs/scrub/ialloc_repair.c | 3 +-- fs/xfs/scrub/inode_repair.c | 3 ++- fs/xfs/scrub/trace.h | 12 ++++++------ fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_inode_item.c | 18 +++++++++++------- fs/xfs/xfs_itable.c | 2 +- fs/xfs/xfs_iunlink_item.c | 2 +- 11 files changed, 44 insertions(+), 49 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +7
-17@@ -1075,7 +1075,7 @@ xfs_dialloc_check_ino(if (error)return -EAGAIN ; - error =xfs_read_icluster (pag_mount (pag), tp, imap.im_blkno, &bp); + error =xfs_read_icluster (pag, tp, imap.im_agbno, &bp);if (error)return -EAGAIN ;@@ -2551,23 +2551,13 @@ xfs_imap( offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +XFS_INO_TO_OFFSET (mp, ino); out: - imap->im_blkno =xfs_agbno_to_daddr (pag, cluster_agbno); + imap->im_agbno = cluster_agbno; imap->im_boffset = (unsigned short )(offset << mp->m_sb.sb_inodelog); - -/* -* If the inode number maps to a block outside the bounds -* of the file system then return NULL rather than calling -* read_buf and panicing when we get an error from the -* driver. -*/ -if (imap->im_blkno + -XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster) > -XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)) { -xfs_alert (mp, -"%s: (im_blkno (0x%llx) + len (0x%x)) > sb_dblocks (0x%llx)" , - __func__, imap->im_blkno, -XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster), -XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)); +if (imap->im_agbno +M_IGEO (mp)->blocks_per_cluster > +pag_group (pag)->xg_block_count) { +xfs_alert (mp,"inode cluster out of range: %u/%u > %u" , + imap->im_agbno,M_IGEO (mp)->blocks_per_cluster, +pag_group (pag)->xg_block_count);return -EINVAL ; }return 0 ;fs/xfs/libxfs/xfs_inode_buf.c +6
-5@@ -127,19 +127,20 @@ const struct xfs_buf_ops xfs_inode_buf_ra_ops = {*/ int xfs_read_icluster ( -struct xfs_mount *mp, +struct xfs_perag *pag,struct xfs_trans *tp, -xfs_daddr_t bno, +xfs_agblock_t agbno,struct xfs_buf **bpp) { +struct xfs_mount *mp =pag_mount (pag);int error; - error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, bno, + error =xfs_trans_read_buf (mp, tp, mp->m_ddev_targp, +xfs_agbno_to_daddr (pag, agbno),XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),0 , bpp, &xfs_inode_buf_ops);if (xfs_metadata_is_sick (error)) -xfs_agno_mark_sick (mp,xfs_daddr_to_agno (mp, bno), -XFS_SICK_AG_INODES ); +xfs_agno_mark_sick (mp,pag_agno (pag),XFS_SICK_AG_INODES );return error; }fs/xfs/libxfs/xfs_inode_buf.h +4
-4@@ -14,12 +14,12 @@ struct xfs_dinode;* xfs_read_icluster() to get a buffer and dinode for a given inode. */ struct xfs_imap { -xfs_daddr_t im_blkno;/* starting BB of inode chunk */ -unsigned short im_boffset;/* inode offset in block in bytes */ +xfs_agblock_t im_agbno;/* starting agbno of inode cluster */ +unsigned short im_boffset;/* offset in inode cluster in bytes */ }; -int xfs_read_icluster (struct xfs_mount *mp,struct xfs_trans *tp, -xfs_daddr_t bno,struct xfs_buf **bpp); +int xfs_read_icluster (struct xfs_perag *pag,struct xfs_trans *tp, +xfs_agblock_t agbno,struct xfs_buf **bpp);void xfs_dinode_calc_crc (struct xfs_mount *mp,struct xfs_dinode *dip);void xfs_inode_to_disk (struct xfs_inode *ip,struct xfs_dinode *to,xfs_lsn_t lsn);fs/xfs/scrub/ialloc.c +4
-4@@ -363,6 +363,7 @@ xchk_iallocbt_check_cluster(struct xfs_inobt_rec_incore *irec, unsigned int cluster_base) { + struct xfs_perag *pag = to_perag(bs->cur->bc_group);struct xfs_imap imap;struct xfs_mount *mp = bs->cur->bc_mp;struct xfs_buf *cluster_bp;@@ -394,7 +395,7 @@ xchk_iallocbt_check_cluster(* ir_startino can be large enough to make im_boffset nonzero. */ ir_holemask = (irec->ir_holemask & cluster_mask); - imap.im_blkno =xfs_agbno_to_daddr (to_perag (bs->cur->bc_group), agbno); + imap.im_agbno = agbno; imap.im_boffset =XFS_INO_TO_OFFSET (mp, irec->ir_startino) << mp->m_sb.sb_inodelog;@@ -404,8 +405,7 @@ xchk_iallocbt_check_cluster(return 0 ; } - trace_xchk_iallocbt_check_cluster(to_perag(bs->cur->bc_group), - irec->ir_startino, imap.im_blkno, + trace_xchk_iallocbt_check_cluster(pag, irec->ir_startino, imap.im_agbno, XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), cluster_base, nr_inodes, cluster_mask, ir_holemask, XFS_INO_TO_OFFSET(mp, irec->ir_startino +@@ -429,7 +429,7 @@ xchk_iallocbt_check_cluster( &XFS_RMAP_OINFO_INODES);/* Grab the inode cluster buffer. */ - error =xfs_read_icluster (mp, bs->cur->bc_tp, imap.im_blkno, + error =xfs_read_icluster (pag, bs->cur->bc_tp, imap.im_agbno, &cluster_bp);if (!xchk_btree_xref_process_error (bs->sc, bs->cur,0 , &error))return error;fs/xfs/scrub/ialloc_repair.c +1
-2@@ -304,8 +304,7 @@ xrep_ibt_process_cluster(* inobt because imap_to_bp directly maps the buffer without touching * either inode btree. */ - error =xfs_read_icluster (mp, sc->tp, -xfs_agbno_to_daddr (sc->sa.pag, cluster_bno), + error =xfs_read_icluster (sc->sa.pag, sc->tp, cluster_bno, &cluster_bp);if (error)return error;fs/xfs/scrub/inode_repair.c +2
-1@@ -1561,7 +1561,8 @@ xrep_dinode_core(/* Read the inode cluster buffer. */ error =xfs_trans_read_buf (mp, sc->tp, mp->m_ddev_targp, - ri->imap.im_blkno, +XFS_AGB_TO_DADDR (mp,XFS_INO_TO_AGNO (mp, ino), + ri->imap.im_agbno),XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster),0 , &bp,NULL );if (error)fs/xfs/scrub/trace.h +6
-6@@ -785,17 +785,17 @@ TRACE_EVENT(xchk_xref_error, TRACE_EVENT(xchk_iallocbt_check_cluster, TP_PROTO(const struct xfs_perag *pag, xfs_agino_t startino, - xfs_daddr_t map_daddr, unsigned short map_len, + xfs_agblock_t map_agblock, unsigned short map_len, unsigned int chunk_ino, unsigned int nr_inodes, uint16_t cluster_mask, uint16_t holemask, unsigned int cluster_ino), - TP_ARGS(pag, startino, map_daddr, map_len, chunk_ino, nr_inodes, + TP_ARGS(pag, startino, map_agblock, map_len, chunk_ino, nr_inodes, cluster_mask, holemask, cluster_ino), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) __field(xfs_agino_t, startino) - __field(xfs_daddr_t, map_daddr) + __field(xfs_agblock_t, map_agblock) __field(unsigned short, map_len) __field(unsigned int, chunk_ino) __field(unsigned int, nr_inodes)@@ -807,7 +807,7 @@ TRACE_EVENT(xchk_iallocbt_check_cluster, __entry->dev =pag_mount (pag)->m_super->s_dev; __entry->agno =pag_agno (pag); __entry->startino = startino; - __entry->map_daddr = map_daddr; + __entry->map_agblock = map_agblock; __entry->map_len = map_len; __entry->chunk_ino = chunk_ino; __entry->nr_inodes = nr_inodes;@@ -815,11 +815,11 @@ TRACE_EVENT(xchk_iallocbt_check_cluster, __entry->holemask = holemask; __entry->cluster_ino = cluster_ino; ), - TP_printk("dev %d:%d agno 0x%x startino 0x%x daddr 0x%llx bbcount 0x%x chunkino 0x%x nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino 0x%x", + TP_printk("dev %d:%d agno 0x%x startino 0x%x agblock 0x%x bbcount 0x%x chunkino 0x%x nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino 0x%x", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno, __entry->startino, - __entry->map_daddr, + __entry->map_agblock, __entry->map_len, __entry->chunk_ino, __entry->nr_inodes,fs/xfs/xfs_icache.c +1
-1@@ -663,7 +663,7 @@ xfs_iget_cache_miss( }else {struct xfs_buf *bp; - error =xfs_read_icluster (mp, tp, ip->i_imap.im_blkno, &bp); + error =xfs_read_icluster (pag, tp, ip->i_imap.im_agbno, &bp);if (error) goto out_destroy;fs/xfs/xfs_inode_item.c +11
-7@@ -18,6 +18,7 @@#include "xfs_buf_item.h" #include "xfs_log.h" #include "xfs_log_priv.h" +#include "xfs_ag.h" #include "xfs_error.h" #include "xfs_rtbitmap.h" @@ -104,6 +105,7 @@ xfs_inode_item_precommit( {struct xfs_inode_log_item *iip =INODE_ITEM (lip);struct xfs_inode *ip = iip->ili_inode; +struct xfs_mount *mp = ip->i_mount;struct inode *inode =VFS_I (ip);unsigned int flags = iip->ili_dirty_flags;@@ -124,8 +126,7 @@ xfs_inode_item_precommit(* to upgrade this inode to bigtime format, do so now. */ if ((flags & (XFS_ILOG_CORE |XFS_ILOG_TIMESTAMP )) && -xfs_has_bigtime (ip->i_mount) && - !xfs_inode_has_bigtime (ip)) { +xfs_has_bigtime (mp) && !xfs_inode_has_bigtime (ip)) { ip->i_diflags2 |=XFS_DIFLAG2_BIGTIME ; flags |=XFS_ILOG_CORE ; }@@ -138,14 +139,14 @@ xfs_inode_item_precommit(*/ if (ip->i_diflags &XFS_DIFLAG_RTINHERIT ) {if ((ip->i_diflags &XFS_DIFLAG_EXTSZINHERIT ) && -xfs_extlen_to_rtxmod (ip->i_mount, ip->i_extsize) >0 ) { +xfs_extlen_to_rtxmod (mp, ip->i_extsize) >0 ) { ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE |XFS_DIFLAG_EXTSZINHERIT ); ip->i_extsize =0 ; flags |=XFS_ILOG_CORE ; }if ((ip->i_diflags2 &XFS_DIFLAG2_COWEXTSIZE ) && -xfs_extlen_to_rtxmod (ip->i_mount, ip->i_cowextsize) >0 ) { +xfs_extlen_to_rtxmod (mp, ip->i_cowextsize) >0 ) { ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE ; ip->i_cowextsize =0 ; flags |=XFS_ILOG_CORE ;@@ -154,6 +155,7 @@ xfs_inode_item_precommit(spin_lock (&iip->ili_lock);if (!iip->ili_item.li_buf) { +struct xfs_perag *pag;struct xfs_buf *bp;int error;@@ -167,8 +169,9 @@ xfs_inode_item_precommit(* here. */ spin_unlock (&iip->ili_lock); - error =xfs_read_icluster (ip->i_mount, tp, ip->i_imap.im_blkno, - &bp); + pag =xfs_perag_get (mp,XFS_INODE_TO_AGNO (ip)); + error =xfs_read_icluster (pag, tp, ip->i_imap.im_agbno, &bp); +xfs_perag_put (pag);if (error)return error;@@ -654,7 +657,8 @@ xfs_inode_item_format( ilf =xlog_format_start (lfb,XLOG_REG_TYPE_IFORMAT ); ilf->ilf_type =XFS_LI_INODE ; ilf->ilf_ino =I_INO (ip); - ilf->ilf_blkno = ip->i_imap.im_blkno; + ilf->ilf_blkno =XFS_AGB_TO_DADDR (mp,XFS_INODE_TO_AGNO (ip), + ip->i_imap.im_agbno); ilf->ilf_len =XFS_FSB_TO_BB (mp,M_IGEO (mp)->blocks_per_cluster); ilf->ilf_boffset = ip->i_imap.im_boffset; ilf->ilf_fields =XFS_ILOG_CORE ;fs/xfs/xfs_itable.c +1
-1@@ -97,7 +97,7 @@ xfs_bulkstat_one_int( }ASSERT (ip !=NULL ); -ASSERT (ip->i_imap.im_blkno !=0 ); +ASSERT (ip->i_imap.im_agbno !=0 ); inode =VFS_I (ip); vfsuid =i_uid_into_vfsuid (idmap, inode); vfsgid =i_gid_into_vfsgid (idmap, inode);fs/xfs/xfs_iunlink_item.c +1
-1@@ -59,7 +59,7 @@ xfs_iunlink_log_dinode(int offset;int error; - error =xfs_read_icluster (tp->t_mountp, tp, ip->i_imap.im_blkno, &ibp); + error =xfs_read_icluster (iup->pag, tp, ip->i_imap.im_agbno, &ibp);if (error)return error;/* Signature · 1 line
2.53.0
PATCH 5/5 xfs: mark struct xfs_imap as __packed
In reply to Christoph HellwigThis returns 2 bytes of padding at the to struct xfs_inode into which this structure is embedded.
--- fs/xfs/libxfs/xfs_inode_buf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_inode_buf.h +1 -1
@@ -16,7 +16,7 @@ struct xfs_dinode;struct xfs_imap {xfs_agblock_t im_agbno;/* starting agbno of inode cluster */ unsigned short im_boffset;/* offset in inode cluster in bytes */ -}; +} __packed;int xfs_read_icluster (struct xfs_perag *pag,struct xfs_trans *tp,xfs_agblock_t agbno,struct xfs_buf **bpp);
Signature · 1 line
2.53.0
Re: [PATCH 5/5] xfs: mark struct xfs_imap as __packed
Quoted 13 lines · Christoph Hellwig
This returns 2 bytes of padding at the to struct
xfs_inodeinto which this structure is embedded.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_inode_buf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/libxfs/xfs_inode_buf.h +0
-0
fs/xfs/libxfs/xfs_inode_buf.h struct xfs_dinode; · line 19
Quoted 5 lines
fs/xfs/libxfs/xfs_inode_buf.h +1
-1@@ -16,7 +16,7 @@ struct xfs_dinode;struct xfs_imap {xfs_agblock_t im_agbno;/* starting agbno of inode cluster */ unsigned short im_boffset;/* offset in inode cluster in bytes */ -}; +} __packed;
Nice and compact now!
--D
Quoted 7 lines
fs/xfs/libxfs/xfs_inode_buf.h +0
-0int xfs_read_icluster (struct xfs_perag *pag,struct xfs_trans *tp,xfs_agblock_t agbno,struct xfs_buf **bpp);Signature · 1 line
2.53.0
Re: [PATCH 5/5] xfs: mark struct xfs_imap as __packed
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
This returns 2 bytes of padding at the to struct
xfs_inodeinto which this structure is embedded.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 20 lines
--- fs/xfs/libxfs/xfs_inode_buf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/libxfs/xfs_inode_buf.h +1
-1@@ -16,7 +16,7 @@ struct xfs_dinode;struct xfs_imap {xfs_agblock_t im_agbno;/* starting agbno of inode cluster */ unsigned short im_boffset;/* offset in inode cluster in bytes */ -}; +} __packed;int xfs_read_icluster (struct xfs_perag *pag,struct xfs_trans *tp,xfs_agblock_t agbno,struct xfs_buf **bpp);Signature · 1 line
2.53.0
Quoted 9 lines · Christoph Hellwig
struct
xfs_imapis embedded into structxfs_inodeand takes up considerable space. This series applies some relatively easy shrinkage to it. It it based on top of the "remove struct xfs_inode.i_ino" series.A git tree is also available:
git://git.infradead.org/users/hch/xfs.gitxfs-shrink-imap[...]
Applied to for-next, thanks!
[1/5] xfs: cleanup xfs_imap
commit: 41397e7ca8a06507ae6f52f68cd27b0812e9a561
[2/5] xfs: remove im_len field in struct xfs_imap
commit: 33451947c4f0f91df74af2db4384143446a1157a
[3/5] xfs: massage xfs_imap_to_bp into xfs_read_icluster
commit: caffb4252cf15c5c3bbe7ff1f48f24f4015edb9c
[4/5] xfs: store an agbno in struct xfs_imap
commit: 9b64ca202f364a6bf8e19bdd20953bc2d776c67f
[5/5] xfs: mark struct xfs_imap as __packed
commit: 4f16139d8e296ec5403c3ebbe874dcd5c57648caBest regards,
Signature · 1 line
Carlos Maiolino <[email protected]>