xfs: modernize the realtime volume
Subsystems (4)
PATCH 26/41 xfs_db: widen block type mask to 64 bits
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
We're about to enlarge enum dbm beyond 32 items, so we need to widen the block type mask to 64 bits to avoid problems.
--- db/check.c | 72 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 36 deletions(-)
db/check.c +36 -36
@@ -282,9 +282,9 @@ static void check_set_rdbmap(xfs_rfsblock_t bno, xfs_extlen_t len, dbm_t type1, dbm_t type2);static void check_summary (void );static void checknot_dbmap (xfs_agnumber_t agno,xfs_agblock_t agbno, -xfs_extlen_t len,int typemask); +xfs_extlen_t len,uint64_t typemask);static void checknot_rdbmap (xfs_rfsblock_t bno,xfs_extlen_t len, -int typemask); +uint64_t typemask);static void dir_hash_add (xfs_dahash_t hash,xfs_dir2_dataptr_t addr);static void dir_hash_check (inodata_t *id,int v);
@@ -904,7 +904,7 @@ blockget_f(if (!tflag) {/* are we in test mode, faking out freespace? */ for (agno =0 ; agno < mp->m_sb.sb_agcount; agno++)checknot_dbmap (agno,0 , mp->m_sb.sb_agblocks, - (1 <<DBM_UNKNOWN ) | (1 <<DBM_FREE1 )); + (1ULL <<DBM_UNKNOWN ) | (1ULL <<DBM_FREE1 )); }for (agno =0 ; agno < mp->m_sb.sb_agcount; agno++)check_linkcounts (agno);
@@ -912,7 +912,7 @@ blockget_f(checknot_rdbmap (0 , (xfs_extlen_t)(mp->m_sb.sb_rextents * mp->m_sb.sb_rextsize), -1 <<DBM_UNKNOWN ); +1ULL <<DBM_UNKNOWN );check_summary (); }if (mp->m_sb.sb_icount != icount) {
@@ -1083,7 +1083,7 @@ blocktrash_f(int c;int count;int done; -int goodmask; +uint64_t goodmask;int i;ltab_t *lentab;int lentablen;
@@ -1095,7 +1095,7 @@ blocktrash_f(xfs_rfsblock_t randb;uint seed;int sopt; -int tmask; +uint64_t tmask;bool this_block = false;int bit_offset =-1 ;
@@ -1108,27 +1108,27 @@ blocktrash_f( seed = (unsigned int )(now.tv_sec ^ now.tv_usec); sopt =0 ; tmask =0 ; - goodmask = (1 <<DBM_AGF ) | - (1 <<DBM_AGFL ) | - (1 <<DBM_AGI ) | - (1 <<DBM_ATTR ) | - (1 <<DBM_BTBMAPA ) | - (1 <<DBM_BTBMAPD ) | - (1 <<DBM_BTBNO ) | - (1 <<DBM_BTCNT ) | - (1 <<DBM_BTINO ) | - (1 <<DBM_DIR ) | - (1 <<DBM_INODE ) | - (1 <<DBM_LOG ) | - (1 <<DBM_QUOTA ) | - (1 <<DBM_RTBITMAP ) | - (1 <<DBM_RTSUM ) | - (1 <<DBM_BTRTRMAP ) | - (1 <<DBM_SYMLINK ) | - (1 <<DBM_BTFINO ) | - (1 <<DBM_BTRMAP ) | - (1 <<DBM_BTREFC ) | - (1 <<DBM_SB ); + goodmask = (1ULL <<DBM_AGF ) | + (1ULL <<DBM_AGFL ) | + (1ULL <<DBM_AGI ) | + (1ULL <<DBM_ATTR ) | + (1ULL <<DBM_BTBMAPA ) | + (1ULL <<DBM_BTBMAPD ) | + (1ULL <<DBM_BTBNO ) | + (1ULL <<DBM_BTCNT ) | + (1ULL <<DBM_BTINO ) | + (1ULL <<DBM_DIR ) | + (1ULL <<DBM_INODE ) | + (1ULL <<DBM_LOG ) | + (1ULL <<DBM_QUOTA ) | + (1ULL <<DBM_RTBITMAP ) | + (1ULL <<DBM_RTSUM ) | + (1ULL <<DBM_BTRTRMAP ) | + (1ULL <<DBM_SYMLINK ) | + (1ULL <<DBM_BTFINO ) | + (1ULL <<DBM_BTRMAP ) | + (1ULL <<DBM_BTREFC ) | + (1ULL <<DBM_SB );while ((c =getopt (argc, argv,"0123n:o:s:t:x:y:z" )) !=EOF ) {switch (c) {case '0' :
@@ -1174,11 +1174,11 @@ blocktrash_f(if (strcmp (typename[i], optarg) ==0 )break ; } -if (!typename[i] || (((1 << i) & goodmask) ==0 )) { +if (!typename[i] || (((1ULL << i) & goodmask) ==0 )) {dbprintf (_ ("bad blocktrash type %s\n" ), optarg);return 0 ; } - tmask |=1 << i; + tmask |=1ULL << i;break ;case 'x' : min = (int )strtol (optarg, &p,0 );
@@ -1217,7 +1217,7 @@ blocktrash_f(return 0 ; }if (tmask ==0 ) - tmask = goodmask & ~((1 <<DBM_LOG ) | (1 <<DBM_SB )); + tmask = goodmask & ~((1ULL <<DBM_LOG ) | (1ULL <<DBM_SB )); lentab =xmalloc (sizeof (ltab_t)); lentab->min = lentab->max = min; lentablen =1 ;
@@ -1242,7 +1242,7 @@ blocktrash_f(for (agbno =0 , p = dbmap[agno]; agbno < mp->m_sb.sb_agblocks; agbno++, p++) { -if ((1 << *p) & tmask) +if ((1ULL << *p) & tmask) blocks++; } }
@@ -1259,7 +1259,7 @@ blocktrash_f(for (agbno =0 , p = dbmap[agno]; agbno < mp->m_sb.sb_agblocks; agbno++, p++) { -if (!((1 << *p) & tmask)) +if (!((1ULL << *p) & tmask))continue ;if (bi++ < randb)continue ;
@@ -1802,7 +1802,7 @@ checknot_dbmap(xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_extlen_t len, - int typemask) + uint64_t typemask) { xfs_extlen_t i;char *p;
@@ -1810,7 +1810,7 @@ checknot_dbmap(if (!check_range (agno, agbno, len))return ;for (i =0 , p = &dbmap[agno][agbno]; i < len; i++, p++) { -if ((1 << *p) & typemask) { +if ((1ULL << *p) & typemask) {if (!sflag ||CHECK_BLISTA (agno, agbno + i))dbprintf (_ ("block %u/%u type %s not expected\n" ), agno, agbno + i, typename[(dbm_t)*p]);
@@ -1823,7 +1823,7 @@ static voidchecknot_rdbmap ( xfs_rfsblock_t bno, xfs_extlen_t len, - int typemask) + uint64_t typemask) { xfs_extlen_t i;char *p;
@@ -1831,7 +1831,7 @@ checknot_rdbmap(if (!check_rrange (bno, len))return ;for (i =0 , p = &dbmap[mp->m_sb.sb_agcount][bno]; i < len; i++, p++) { -if ((1 << *p) & typemask) { +if ((1ULL << *p) & typemask) {if (!sflag ||CHECK_BLIST (bno + i))dbprintf (_ ("rtblock %llu type %s not expected\n" ), bno + i, typename[(dbm_t)*p]);
PATCH 27/41 xfs_db: support rudimentary checks of the rtrefcount btree
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Perform some fairly superficial checks of the rtrefcount btree. We'll do more sophisticated checks in xfs_repair, but provide enough of a spot-check here that we can do simple things.
--- db/check.c | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- db/inode.c | 14 +++ db/inode.h | 1 3 files changed, 261 insertions(+), 8 deletions(-)
db/check.c +246 -8
@@ -59,6 +59,8 @@ typedef enum {DBM_COWDATA ,DBM_RTSB ,DBM_BTRTRMAP , +DBM_BTRTREFC , +DBM_RLRTDATA , DBM_NDBM } dbm_t;
@@ -193,6 +195,8 @@ static const char *typename[] = {"cowdata" ,"rtsb" ,"btrtrmap" , +"btrtrefc" , +"rlrtdata" , NULL };
@@ -268,7 +272,7 @@ static void check_linkcounts(xfs_agnumber_t agno);static int check_range (xfs_agnumber_t agno,xfs_agblock_t agbno,xfs_extlen_t len);static void check_rdbmap (xfs_rfsblock_t bno,xfs_extlen_t len, -dbm_t type); +dbm_t type,bool is_reflink);static int check_rinomap (xfs_rfsblock_t bno,xfs_extlen_t len,xfs_ino_t c_ino);static void check_rootdir (void );
@@ -348,6 +352,9 @@ static xfs_ino_t process_sf_dir_v2(struct xfs_dinode *dip, int *dot,static void process_rtrmap (struct inodata *id,struct xfs_dinode *dip,xfs_rfsblock_t *toti); +static void process_rtrefc (struct inodata *id, +struct xfs_dinode *dip, +xfs_rfsblock_t *toti);static void quota_add (xfs_dqid_t *p,xfs_dqid_t *g,xfs_dqid_t *u,int dq,xfs_qcnt_t bc,xfs_qcnt_t ic,xfs_qcnt_t rc);
@@ -379,6 +386,12 @@ static void scanfunc_rtrmap(struct xfs_btree_block *block, xfs_rfsblock_t *toti, xfs_extnum_t *nex, blkmap_t **blkmapp, int isroot, typnm_t btype); +static void scanfunc_rtrefc (struct xfs_btree_block *block, +int level,dbm_t type,xfs_fsblock_t bno, +inodata_t *id,xfs_rfsblock_t *totd, +xfs_rfsblock_t *toti,xfs_extnum_t *nex, +blkmap_t **blkmapp,int isroot, +typnm_t btype);static void scanfunc_bno (struct xfs_btree_block *block,int level,xfs_agf_t *agf,xfs_agblock_t bno,int isroot);
@@ -1128,6 +1141,7 @@ blocktrash_f( (1ULL <<DBM_BTFINO ) | (1ULL <<DBM_BTRMAP ) | (1ULL <<DBM_BTREFC ) | + (1ULL <<DBM_BTRTREFC ) | (1ULL <<DBM_SB );while ((c =getopt (argc, argv,"0123n:o:s:t:x:y:z" )) !=EOF ) {switch (c) {
@@ -1562,7 +1576,8 @@ static voidcheck_rdbmap ( xfs_rfsblock_t bno, xfs_extlen_t len, - dbm_t type) + dbm_t type, + bool ignore_reflink) { xfs_extlen_t i;char *p;
@@ -1574,6 +1589,9 @@ check_rdbmap( error++;break ; } +if (ignore_reflink && (*p ==DBM_UNKNOWN || *p ==DBM_RTDATA || + *p ==DBM_RLRTDATA )) +continue ;if ((dbm_t)*p != type) {if (!sflag ||CHECK_BLIST (bno + i)) dbprintf(_("rtblock %llu expected type %s got "
@@ -1600,6 +1618,8 @@ check_rinomap( bno, bno + len - 1, c_ino);return 0 ; } +if (xfs_has_rtreflink (mp)) +return 0 ;for (i =0 , rval =1 , idp = &inomap[mp->m_sb.sb_agcount][bno]; i < len; i++, idp++) {
@@ -1740,6 +1760,26 @@ check_set_dbmap( } } +/* +* We don't check the accuracy of reference counts -- all we do is ensure +* that a data block never crosses with non-data blocks. repair can check +* those kinds of things. +* +* So with that in mind, if we're setting a block to be data or rldata, +* don't complain so long as the block is currently unknown, data, or rldata. +* Don't let blocks downgrade from rldata -> data. +*/ +static bool +is_rtreflink ( +dbm_t type2) +{ +if (!xfs_has_rtreflink (mp)) +return false; +if (type2 ==DBM_RTDATA || type2 ==DBM_RLRTDATA ) +return true; +return false; +} + static void check_set_rdbmap( xfs_rfsblock_t bno,
@@ -1753,7 +1793,7 @@ check_set_rdbmap(if (!check_rrange (bno, len))return ; -check_rdbmap (bno, len, type1); +check_rdbmap (bno, len, type1,is_rtreflink (type2)); mayprint = verbose | blist_size;for (i =0 , p = &dbmap[mp->m_sb.sb_agcount][bno]; i < len; i++, p++) {if (!rdbmap_boundscheck (bno + i)) {
@@ -2863,7 +2903,7 @@ process_inode( 0 /* type 15 unused */ };static char *fmtnames[] = { -"dev" ,"local" ,"extents" ,"btree" ,"uuid" ,"rmap" +"dev" ,"local" ,"extents" ,"btree" ,"uuid" ,"rmap" ,"refcount" }; ino =XFS_AGINO_TO_INO (mp,be32_to_cpu (agf->agf_seqno), agino);
@@ -2942,6 +2982,16 @@ process_inode( error++;return ; } + }else if (is_rtrefcount_inode (ino)) { +if (!S_ISREG (mode) || dip->di_format !=XFS_DINODE_FMT_REFCOUNT ) { +if (v) +dbprintf ( +_ ("bad format %d for rtrefc inode %lld type %#o\n" ), + dip->di_format, (long long )ino, + mode &S_IFMT ); + error++; +return ; + } }else if ((((mode &S_IFMT ) >>12 ) >15 ) || (!(okfmts[(mode &S_IFMT ) >>12 ] & (1 << dip->di_format)))) {if (v)
@@ -3018,6 +3068,9 @@ process_inode( }else if (is_rtrmap_inode (id->ino)) { type =DBM_BTRTRMAP ; blkmap =blkmap_alloc (be32_to_cpu (dip->di_nextents)); + }else if (is_rtrefcount_inode (id->ino)) { + type =DBM_BTRTREFC ; + blkmap =blkmap_alloc (be32_to_cpu (dip->di_nextents)); }else type =DBM_DATA ;
@@ -3053,6 +3106,10 @@ process_inode( id->rgno =rtgroup_for_rtrmap_ino (mp, id->ino);process_rtrmap (id, dip, &totiblocks);break ; +case XFS_DINODE_FMT_REFCOUNT : + id->rgno =rtgroup_for_rtrefcount_ino (mp, id->ino); +process_rtrefc (id, dip, &totiblocks); +break ; }if (dip->di_forkoff) { sbversion |=XFS_SB_VERSION_ATTRBIT ;
@@ -3079,6 +3136,7 @@ process_inode(case DBM_RTSUM :case DBM_SYMLINK :case DBM_BTRTRMAP : +case DBM_BTRTREFC :case DBM_UNKNOWN : bc = totdblocks + totiblocks + atotdblocks + atotiblocks;
@@ -3883,8 +3941,7 @@ process_rtrmap( i,be32_to_cpu (rp[i].rm_startblock), be32_to_cpu(rp[i].rm_startblock)); }else { - lastblock =be32_to_cpu (rp[i].rm_startblock) + -be32_to_cpu (rp[i].rm_blockcount); + lastblock =be32_to_cpu (rp[i].rm_startblock); } }return ;
@@ -3899,6 +3956,79 @@ process_rtrmap( } } +static void +process_rtrefc ( +struct inodata *id, +struct xfs_dinode *dip, +xfs_rfsblock_t *toti) +{ +xfs_extnum_t nex =0 ; +xfs_rfsblock_t totd =0 ; +struct xfs_rtrefcount_root *dib; +int whichfork =XFS_DATA_FORK ; +int i; +int maxrecs; +xfs_rtrefcount_ptr_t *pp; + +if (id->rgno ==NULLRGNUMBER ) { +dbprintf ( +_ ("rt group for refcount ino %lld not found\n" ), + id->ino); + error++; +return ; + } + + dib = (struct xfs_rtrefcount_root *)XFS_DFORK_PTR (dip, whichfork); +if (be16_to_cpu (dib->bb_level) >= mp->m_rtrefc_maxlevels) { +if (!sflag || id->ilist) +dbprintf (_ ("level for ino %lld rtrefc root too " +"large (%u)\n" ), + id->ino, +be16_to_cpu (dib->bb_level)); + error++; +return ; + } + maxrecs =libxfs_rtrefcountbt_droot_maxrecs ( +XFS_DFORK_SIZE (dip, mp, whichfork), + dib->bb_level ==0 ); +if (be16_to_cpu (dib->bb_numrecs) > maxrecs) { +if (!sflag || id->ilist) +dbprintf (_ ("numrecs for ino %lld rtrefc root too " +"large (%u)\n" ), + id->ino, +be16_to_cpu (dib->bb_numrecs)); + error++; +return ; + } +if (be16_to_cpu (dib->bb_level) ==0 ) { +struct xfs_refcount_rec *rp; +xfs_fsblock_t lastblock; + + rp =xfs_rtrefcount_droot_rec_addr (dib,1 ); + lastblock =0 ; +for (i =0 ; i <be16_to_cpu (dib->bb_numrecs); i++) { +if (be32_to_cpu (rp[i].rc_startblock) < lastblock) { +dbprintf (_ ( +"out-of-order rtrefc btree record %d (%u %u) root\n" ), + i,be32_to_cpu (rp[i].rc_startblock), +be32_to_cpu (rp[i].rc_startblock)); + }else { + lastblock =be32_to_cpu (rp[i].rc_startblock) + +be32_to_cpu (rp[i].rc_blockcount); + } + } +return ; + }else { + pp =xfs_rtrefcount_droot_ptr_addr (dib,1 , maxrecs); +for (i =0 ; i <be16_to_cpu (dib->bb_numrecs); i++) +scan_lbtree (get_unaligned_be64 (&pp[i]), +be16_to_cpu (dib->bb_level), + scanfunc_rtrefc,DBM_BTRTREFC , + id, &totd, toti, + &nex,NULL ,1 ,TYP_RTREFCBT ); + } +} + static xfs_ino_t process_sf_dir_v2( struct xfs_dinode *dip,
@@ -5056,8 +5186,7 @@ scanfunc_rtrmap(be32_to_cpu (rp[i].rm_blockcount), agno, bno, lastblock); }else { - lastblock =be32_to_cpu (rp[i].rm_startblock) + -be32_to_cpu (rp[i].rm_blockcount); + lastblock =be32_to_cpu (rp[i].rm_startblock); } }return ;
@@ -5173,6 +5302,115 @@ scanfunc_refcnt( TYP_REFCBT); } +static void +scanfunc_rtrefc ( +struct xfs_btree_block *block, +int level, +dbm_t type, +xfs_fsblock_t bno, +inodata_t *id, +xfs_rfsblock_t *totd, +xfs_rfsblock_t *toti, +xfs_extnum_t *nex, +blkmap_t **blkmapp, +int isroot, +typnm_t btype) +{ +xfs_agblock_t agbno; +xfs_agnumber_t agno; +int i; +xfs_rtrefcount_ptr_t *pp; +struct xfs_refcount_rec *rp; +xfs_rtblock_t lastblock; + + agno =XFS_FSB_TO_AGNO (mp, bno); + agbno =XFS_FSB_TO_AGBNO (mp, bno); +if (be32_to_cpu (block->bb_magic) !=XFS_RTREFC_CRC_MAGIC ) { +dbprintf (_ ("bad magic # %#x in rtrefcbt block %u/%u\n" ), +be32_to_cpu (block->bb_magic), agno, agbno); + serious_error++; +return ; + } +if (be16_to_cpu (block->bb_level) != level) { +if (!sflag) +dbprintf (_ ("expected level %d got %d in rtrefcntbt block " +"%u/%u\n" ), + level,be16_to_cpu (block->bb_level), agno, agbno); + error++; + } +set_dbmap (agno, agbno,1 , type, agno, agbno); +set_inomap (agno, agbno,1 , id); + (*toti)++; +if (level ==0 ) { +if (be16_to_cpu (block->bb_numrecs) > mp->m_rtrefc_mxr[0 ] || + (isroot ==0 &&be16_to_cpu (block->bb_numrecs) < mp->m_rtrefc_mnr[0 ])) { +dbprintf (_ ("bad btree nrecs (%u, min=%u, max=%u) in " +"rtrefcntbt block %u/%u\n" ), +be16_to_cpu (block->bb_numrecs), mp->m_rtrefc_mnr[0 ], + mp->m_rtrefc_mxr[0 ], agno, agbno); + serious_error++; +return ; + } + rp =xfs_rtrefcount_rec_addr (block,1 ); + lastblock =0 ; +for (i =0 ; i <be16_to_cpu (block->bb_numrecs); i++) { +xfs_rtblock_t rtbno; + +if (be32_to_cpu (rp[i].rc_refcount) ==1 ) { +xfs_fsblock_t bno; +char *msg; + + bno =be32_to_cpu (rp[i].rc_startblock); +if (bno &XFS_REFC_COWFLAG ) { + bno &= ~XFS_REFC_COWFLAG ; + msg =_ ( +"leftover rt CoW extent (%lu) len %u\n" ); + }else { + msg =_ ( +"leftover rt CoW extent at unexpected address (%lu) len %lu\n" ); + } +dbprintf (msg, + agbno, +be32_to_cpu (rp[i].rc_blockcount)); + rtbno =xfs_rgbno_to_rtb (mp, id->rgno, bno); +set_rdbmap (rtbno, +be32_to_cpu (rp[i].rc_blockcount), +DBM_COWDATA ); + }else { + rtbno =xfs_rgbno_to_rtb (mp, id->rgno, +be32_to_cpu (rp[i].rc_startblock)); +set_rdbmap (rtbno, +be32_to_cpu (rp[i].rc_blockcount), +DBM_RLRTDATA ); + } +if (be32_to_cpu (rp[i].rc_startblock) < lastblock) { +dbprintf (_ ( +"out-of-order rt refcnt btree record %d (%llu %llu) block %llu\n" ), + i,be32_to_cpu (rp[i].rc_startblock), +be32_to_cpu (rp[i].rc_startblock), + bno); + }else { + lastblock =be32_to_cpu (rp[i].rc_startblock) + +be32_to_cpu (rp[i].rc_blockcount); + } + } +return ; + } +if (be16_to_cpu (block->bb_numrecs) > mp->m_rtrefc_mxr[1 ] || + (isroot ==0 &&be16_to_cpu (block->bb_numrecs) < mp->m_rtrefc_mnr[1 ])) { +dbprintf (_ ("bad btree nrecs (%u, min=%u, max=%u) in rtrefcntbt " +"block %u/%u\n" ), +be16_to_cpu (block->bb_numrecs), mp->m_rtrefc_mnr[1 ], + mp->m_rtrefc_mxr[1 ], agno, agbno); + serious_error++; +return ; + } + pp =xfs_rtrefcount_ptr_addr (block,1 , mp->m_rtrefc_mxr[1 ]); +for (i =0 ; i <be16_to_cpu (block->bb_numrecs); i++) +scan_lbtree (be64_to_cpu (pp[i]), level, scanfunc_rtrefc, + type, id, totd, toti, nex, blkmapp,0 , btype); +} + static void set_dbmap( xfs_agnumber_t agno,
db/inode.c +14 -0
@@ -642,6 +642,7 @@ inode_init(void)struct rtgroup_inodes {xfs_ino_t rmap_ino; +xfs_ino_t refcount_ino; };static struct rtgroup_inodes *rtgroup_inodes;
@@ -700,6 +701,7 @@ set_rtgroup_refcount_inode(if (rtino ==NULLFSINO )return EFSCORRUPTED ; + rtgroup_inodes[rgno].refcount_ino = rtino;return bitmap_set (refcount_inodes, rtino,1 ); }
@@ -760,6 +762,18 @@ bool is_rtrefcount_inode(xfs_ino_t ino)return bitmap_test (refcount_inodes, ino,1 ); } +xfs_rgnumber_t rtgroup_for_rtrefcount_ino (struct xfs_mount *mp,xfs_ino_t ino) +{ +unsigned int i; + +for (i =0 ; i < mp->m_sb.sb_rgcount; i++) { +if (rtgroup_inodes[i].refcount_ino == ino) +return i; + } + +return NULLRGNUMBER ; +} +typnm_t inode_next_type (void ) {
db/inode.h +1 -0
@@ -28,3 +28,4 @@ int init_rtmeta_inode_bitmaps(struct xfs_mount *mp);bool is_rtrmap_inode (xfs_ino_t ino);xfs_rgnumber_t rtgroup_for_rtrmap_ino (struct xfs_mount *mp,xfs_ino_t ino);bool is_rtrefcount_inode (xfs_ino_t ino); +xfs_rgnumber_t rtgroup_for_rtrefcount_ino (struct xfs_mount *mp,xfs_ino_t ino);
PATCH 28/41 xfs_db: copy the realtime refcount btree
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Copy the realtime refcountbt when we're metadumping the filesystem.
--- db/metadump.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+)
db/metadump.c +125 -0
@@ -717,6 +717,54 @@ copy_refcount_btree(return scan_btree (agno, root, levels,TYP_REFCBT , agf, scanfunc_refcntbt); } +static int +scanfunc_rtrefcbt ( +struct xfs_btree_block *block, +xfs_agnumber_t agno, +xfs_agblock_t agbno, +int level, +typnm_t btype, +void *arg) +{ +xfs_rtrefcount_ptr_t *pp; +int i; +int numrecs; + +if (level ==0 ) +return 1 ; + + numrecs =be16_to_cpu (block->bb_numrecs); +if (numrecs > mp->m_rtrefc_mxr[1 ]) { +if (show_warnings) +print_warning ("invalid numrecs (%u) in %s block %u/%u" , + numrecs, typtab[btype].name, agno, agbno); +return 1 ; + } + + pp =xfs_rtrefcount_ptr_addr (block,1 , mp->m_rtrefc_mxr[1 ]); +for (i =0 ; i < numrecs; i++) { +xfs_agnumber_t pagno; +xfs_agblock_t pbno; + + pagno =XFS_FSB_TO_AGNO (mp,get_unaligned_be64 (&pp[i])); + pbno =XFS_FSB_TO_AGBNO (mp,get_unaligned_be64 (&pp[i])); + +if (pbno ==0 || pbno > mp->m_sb.sb_agblocks || + pagno > mp->m_sb.sb_agcount) { +if (show_warnings) +print_warning ("invalid block number (%u/%u) " +"in inode %llu %s block %u/%u" , + pagno, pbno, (long long )cur_ino, + typtab[btype].name, agno, agbno); +continue ; + } +if (!scan_btree (pagno, pbno, level, btype, arg, + scanfunc_rtrefcbt)) +return 0 ; + } +return 1 ; +} +/* filename and extended attribute obfuscation routines */ struct name_ent {
@@ -2458,6 +2506,80 @@ process_rtrmap(return 1 ; } +static int +process_rtrefc ( +struct xfs_dinode *dip, +typnm_t itype) +{ +struct xfs_rtrefcount_root *dib; +int i; +xfs_rtrefcount_ptr_t *pp; +int level; +int nrecs; +int maxrecs; +int whichfork; +typnm_t btype; + +if (itype ==TYP_ATTR && show_warnings) { +print_warning ("ignoring rtrefcbt root in inode %llu attr fork" , + (long long )cur_ino); +return 1 ; + } + + whichfork =XFS_DATA_FORK ; + btype =TYP_RTREFCBT ; + + dib = (struct xfs_rtrefcount_root *)XFS_DFORK_PTR (dip, whichfork); + level =be16_to_cpu (dib->bb_level); + nrecs =be16_to_cpu (dib->bb_numrecs); + +if (level > mp->m_rtrefc_maxlevels) { +if (show_warnings) +print_warning ("invalid level (%u) in inode %lld %s " +"root" , level, (long long )cur_ino, + typtab[btype].name); +return 1 ; + } + +if (level ==0 ) +return 1 ; + + maxrecs =libxfs_rtrefcountbt_droot_maxrecs ( +XFS_DFORK_SIZE (dip, mp, whichfork), + false); +if (nrecs > maxrecs) { +if (show_warnings) +print_warning ("invalid numrecs (%u) in inode %lld %s " +"root" , nrecs, (long long )cur_ino, + typtab[btype].name); +return 1 ; + } + + pp =xfs_rtrefcount_droot_ptr_addr (dib,1 , maxrecs); +for (i =0 ; i < nrecs; i++) { +xfs_agnumber_t ag; +xfs_agblock_t bno; + + ag =XFS_FSB_TO_AGNO (mp,get_unaligned_be64 (&pp[i])); + bno =XFS_FSB_TO_AGBNO (mp,get_unaligned_be64 (&pp[i])); + +if (bno ==0 || bno > mp->m_sb.sb_agblocks || + ag > mp->m_sb.sb_agcount) { +if (show_warnings) +print_warning ("invalid block number (%u/%u) " +"in inode %llu %s root" , ag, + bno, (long long )cur_ino, + typtab[btype].name); +continue ; + } + +if (!scan_btree (ag, bno, level, btype, &itype, + scanfunc_rtrefcbt)) +return 0 ; + } +return 1 ; +} + static int process_inode_data( struct xfs_dinode *dip,
@@ -2505,6 +2627,9 @@ process_inode_data(case XFS_DINODE_FMT_RMAP :return process_rtrmap (dip, itype); + +case XFS_DINODE_FMT_REFCOUNT : +return process_rtrefc (dip, itype); }return 1 ; }
PATCH 29/41 xfs_spaceman: report health of the realtime refcount btree
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Report the health of the realtime reference count btree.
--- spaceman/health.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
spaceman/health.c +10 -0
@@ -44,6 +44,11 @@ static bool has_rtrmapbt(const struct xfs_fsop_geom *g)return g->rtblocks >0 && (g->flags &XFS_FSOP_GEOM_FLAGS_RMAPBT ); } +static bool has_rtreflink (const struct xfs_fsop_geom *g) +{ +return g->rtblocks >0 && (g->flags &XFS_FSOP_GEOM_FLAGS_REFLINK ); +} +struct flag_map {unsigned int mask;bool (*has_fn)(const struct xfs_fsop_geom *g);
@@ -153,6 +158,11 @@ static const struct flag_map rtgroup_flags[] = { .descr = "realtime reverse mappings btree", .has_fn = has_rtrmapbt, }, + { + .mask = XFS_RTGROUP_GEOM_SICK_REFCNTBT, + .descr = "realtime reference count btree", + .has_fn = has_rtreflink, + }, {0}, };
PATCH 30/41 xfs_repair: allow CoW staging extents in the realtime rmap records
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Don't flag the rt rmap btree as having errors if there are CoW staging extent records in it and the filesystem supports. As far as reporting leftover staging extents, we'll report them when we scan the rt refcount btree, in a future patch.
--- repair/scan.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
repair/scan.c +14 -3
@@ -1414,9 +1414,20 @@ _("invalid length %llu in record %u of %s\n"),continue ; } -/* We only store file data and superblocks in the rtrmap. */ -if (XFS_RMAP_NON_INODE_OWNER (owner) && - owner !=XFS_RMAP_OWN_FS ) { +/* +* We only store file data, COW data, and superblocks in the +* rtrmap. +*/ +if (owner ==XFS_RMAP_OWN_COW ) { +if (!xfs_has_reflink (mp)) { +do_warn ( +_ ("invalid CoW staging extent in record %u of %s\n" ), + i, name); + suspect++; +continue ; + } + }else if (XFS_RMAP_NON_INODE_OWNER (owner) && + owner !=XFS_RMAP_OWN_FS ) {do_warn (_ ("invalid owner %lld in record %u of %s\n" ), (long long int )owner, i, name);
PATCH 31/41 xfs_repair: use realtime refcount btree data to check block types
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Use the realtime refcount btree to pre-populate the block type information so that when repair iterates the primary metadata, we can confirm the block type.
--- repair/dinode.c | 152 ++++++++++++++++++++++++++++ repair/rmap.c | 9 ++ repair/rmap.h | 3 + repair/scan.c | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- repair/scan.h | 33 ++++++ 5 files changed, 490 insertions(+), 6 deletions(-)
repair/dinode.c +152 -0
@@ -274,6 +274,8 @@ _("bad state in rt extent map %" PRIu64 "\n"),break ;case XR_E_INUSE :case XR_E_MULT : +if (xfs_has_rtreflink (mp)) +break ;set_rtbmap (ext,XR_E_MULT );break ;case XR_E_FREE1 :
@@ -348,6 +350,8 @@ _("data fork in rt inode %" PRIu64 " found rt metadata extent %" PRIu64 " in rtreturn 1 ;case XR_E_INUSE :case XR_E_MULT : +if (xfs_has_rtreflink (mp)) +break ;do_warn (_ ("data fork in rt inode %" PRIu64" claims used rt extent %" PRIu64"\n" ), ino, b);
@@ -1012,6 +1016,148 @@ _("bad rtrmap btree ptr 0x%" PRIx64 " in ino %" PRIu64 "\n"),return suspect ?1 :0 ; } +/* +* return 1 if inode should be cleared, 0 otherwise +*/ +static int +process_rtrefc ( +struct xfs_mount *mp, +xfs_agnumber_t agno, +xfs_agino_t ino, +struct xfs_dinode *dip, +int type, +int *dirty, +xfs_rfsblock_t *tot, +uint64_t *nex, +blkmap_t **blkmapp, +int check_dups) +{ +struct refc_priv priv = { .nr_blocks =0 }; +struct xfs_rtrefcount_root *dib; +xfs_rtrefcount_ptr_t *pp; +struct xfs_refcount_key *kp; +struct xfs_refcount_rec *rp; +char *forkname =get_forkname (XFS_DATA_FORK ); +xfs_rgblock_t oldkey, key; +xfs_ino_t lino; +xfs_fsblock_t bno; +size_t droot_sz; +int i; +int level; +int numrecs; +int dmxr; +int suspect =0 ; +int error; + +/* We rebuild the rtrefcountbt, so no need to process blocks again. */ +if (check_dups) { + *tot =be64_to_cpu (dip->di_nblocks); +return 0 ; + } + + lino =XFS_AGINO_TO_INO (mp, agno, ino); + +/* +* This refcount btree inode must be a metadata inode reachable via +* /realtime/$rgno.refcount in the metadata directory tree. +*/ +if (!(dip->di_flags2 &be64_to_cpu (XFS_DIFLAG2_METADATA ))) { +do_warn ( +_ ("rtrefcount inode %" PRIu64" not flagged as metadata\n" ), + lino); +return 1 ; + } + + priv.rgno =rtgroup_for_rtrefcount_inode (mp, ino); +if (priv.rgno ==NULLRGNUMBER ) { +do_warn ( +_ ("could not associate refcount inode %" PRIu64" with any rtgroup\n" ), + lino); +return 1 ; + } + + dib = (struct xfs_rtrefcount_root *)XFS_DFORK_PTR (dip,XFS_DATA_FORK ); + *tot =0 ; + *nex =0 ; + + level =be16_to_cpu (dib->bb_level); + numrecs =be16_to_cpu (dib->bb_numrecs); + +if (level > mp->m_rtrefc_maxlevels) { +do_warn ( +_ ("bad level %d in inode %" PRIu64" rtrefcount btree root block\n" ), + level, lino); +return 1 ; + } + +/* +* use rtroot/dfork_dsize since the root block is in the data fork +*/ + droot_sz =xfs_rtrefcount_droot_space_calc (level, numrecs); +if (droot_sz >XFS_DFORK_SIZE (dip, mp,XFS_DATA_FORK )) { +do_warn ( +_ ("computed size of rtrefcountbt root (%zu bytes) is greater than space in " +"inode %" PRIu64" %s fork\n" ), + droot_sz, lino, forkname); +return 1 ; + } + +if (level ==0 ) { + rp =xfs_rtrefcount_droot_rec_addr (dib,1 ); + error =process_rtrefc_reclist (mp, rp, numrecs, + &priv,"rtrefcountbt root" ); +if (error) { +refcount_avoid_check (); +return 1 ; + } +return 0 ; + } + + dmxr =libxfs_rtrefcountbt_droot_maxrecs ( +XFS_DFORK_SIZE (dip, mp,XFS_DATA_FORK ), false); + pp =xfs_rtrefcount_droot_ptr_addr (dib,1 , dmxr); + +/* check for in-order keys */ +for (i =0 ; i < numrecs; i++) { + kp =xfs_rtrefcount_droot_key_addr (dib, i +1 ); + + key =be32_to_cpu (kp->rc_startblock); +if (i ==0 ) { + oldkey = key; +continue ; + } +if (key < oldkey) { +do_warn ( +_ ("out of order key %u in rtrefcount root ino %" PRIu64"\n" ), + i, lino); + suspect++; +continue ; + } + oldkey = key; + } + +/* probe keys */ +for (i =0 ; i < numrecs; i++) { + bno =get_unaligned_be64 (&pp[i]); + +if (!libxfs_verify_fsbno (mp, bno)) { +do_warn ( +_ ("bad rtrefcount btree ptr 0x%" PRIx64" in ino %" PRIu64"\n" ), + bno, lino); +return 1 ; + } + +if (scan_lbtree (bno, level, scan_rtrefcbt, + type,XFS_DATA_FORK , lino, tot, nex, blkmapp, +NULL ,0 ,1 , check_dups,XFS_RTREFC_CRC_MAGIC , + &priv, &xfs_rtrefcountbt_buf_ops)) +return 1 ; + } + + *tot = priv.nr_blocks; +return suspect ?1 :0 ; +} +/* * return 1 if inode should be cleared, 0 otherwise */
@@ -1807,6 +1953,7 @@ check_dinode_mode_format(case XFS_DINODE_FMT_RMAP :case XFS_DINODE_FMT_EXTENTS :case XFS_DINODE_FMT_BTREE : +case XFS_DINODE_FMT_REFCOUNT :return 0 ; }return -1 ;
@@ -2236,6 +2383,10 @@ process_inode_data_fork( err =process_rtrmap (mp, agno, ino, dino, type, dirty, totblocks, nextents, dblkmap, check_dups);break ; +case XFS_DINODE_FMT_REFCOUNT : + err =process_rtrefc (mp, agno, ino, dino, type, dirty, + totblocks, nextents, dblkmap, check_dups); +break ;case XFS_DINODE_FMT_DEV : err =0 ;break ;
@@ -2296,6 +2447,7 @@ _("would have tried to rebuild inode %"PRIu64" data fork\n"),break ;case XFS_DINODE_FMT_DEV :case XFS_DINODE_FMT_RMAP : +case XFS_DINODE_FMT_REFCOUNT : err =0 ;break ;default :
repair/rmap.c +9 -0
@@ -250,6 +250,15 @@ bool is_rtrmap_inode(xfs_ino_t ino)return bitmap_test (rmap_inodes, ino,1 ); } +xfs_rgnumber_t +rtgroup_for_rtrefcount_inode ( +struct xfs_mount *mp, +xfs_ino_t ino) +{ +/* This will be implemented later. */ +return NULLRGNUMBER ; +} +/* * Initialize per-AG reverse map data. */
repair/rmap.h +3 -0
@@ -66,4 +66,7 @@ bool is_rtrmap_inode(xfs_ino_t ino);xfs_ino_t rtgroup_rmap_ino (struct xfs_rtgroup *rtg);int populate_rtgroup_rmapbt (struct xfs_rtgroup *rtg,struct xfs_inode *ip); +xfs_rgnumber_t rtgroup_for_rtrefcount_inode (struct xfs_mount *mp, +xfs_ino_t ino); +#endif /* RMAP_H_ */
repair/scan.c +293 -6
311 lines not on this page · raw message
repair/scan.h +33 -0
@@ -100,4 +100,37 @@ int scan_rtrmapbt(uint64_t magic, void *priv); +struct refc_priv { +struct xfs_refcount_irec last_rec; +xfs_agblock_t nr_blocks; +xfs_rgnumber_t rgno; +}; + +int +process_rtrefc_reclist ( +struct xfs_mount *mp, +struct xfs_refcount_rec *rp, +int numrecs, +struct refc_priv *refc_priv, +const char *name); + +int +scan_rtrefcbt ( +struct xfs_btree_block *block, +int level, +int type, +int whichfork, +xfs_fsblock_t bno, +xfs_ino_t ino, +xfs_rfsblock_t *tot, +uint64_t *nex, +struct blkmap **blkmapp, +bmap_cursor_t *bm_cursor, +int suspect, +int isroot, +int check_dups, +int *dirty, +uint64_t magic, +void *priv); +#endif /* _XR_SCAN_H */
PATCH 32/41 xfs_repair: find and mark the rtrefcountbt inode
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Make sure that we find the realtime refcountbt inode and mark it appropriately, just in case we find a rogue inode claiming to be an rtrefcount, or just plain garbage in the superblock field.
--- repair/dino_chunks.c | 11 ++++++ repair/dinode.c | 29 ++++++++++++++++- repair/dir2.c | 2 + repair/incore.h | 1 + repair/rmap.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++- repair/rmap.h | 3 +- repair/scan.c | 8 ++--- 7 files changed, 133 insertions(+), 8 deletions(-)
repair/dino_chunks.c +11 -0
@@ -1027,6 +1027,17 @@ process_inode_chunk(_ ("would clear realtime rmap inode %" PRIu64"\n" ), ino); } + }else if (is_rtrefcount_ino (ino)) { +refcount_avoid_check (mp); +if (!no_modify) { +do_warn ( +_ ("cleared realtime refcount inode %" PRIu64"\n" ), + ino); + }else { +do_warn ( +_ ("would clear realtime refcount inode %" PRIu64"\n" ), + ino); + } }else if (!no_modify) {do_warn (_ ("cleared inode %" PRIu64"\n" ), ino);
repair/dinode.c +28 -1
@@ -156,6 +156,9 @@ clear_dinode(xfs_mount_t *mp, struct xfs_dinode *dino, xfs_ino_t ino_num)if (is_rtrmap_inode (ino_num))rmap_avoid_check (mp); +if (is_rtrefcount_ino (ino_num)) +refcount_avoid_check (mp); +/* and clear the forks */ memset (XFS_DFORK_DPTR (dino),0 ,XFS_LITINO (mp));return ;
@@ -1067,6 +1070,12 @@ _("rtrefcount inode %" PRIu64 " not flagged as metadata\n"), lino);return 1 ; } +if (type !=XR_INO_RTREFC ) { +do_warn ( +_ ("rtrefcount inode %" PRIu64" was not found in the metadata directory tree\n" ), + lino); +return 1 ; + } priv.rgno =rtgroup_for_rtrefcount_inode (mp, ino);if (priv.rgno ==NULLRGNUMBER ) {
@@ -1107,7 +1116,7 @@ _("computed size of rtrefcountbt root (%zu bytes) is greater than space in " error =process_rtrefc_reclist (mp, rp, numrecs, &priv,"rtrefcountbt root" );if (error) { -refcount_avoid_check (); +refcount_avoid_check (mp);return 1 ; }return 0 ;
@@ -2063,6 +2072,9 @@ process_check_sb_inodes(if (is_rtrmap_inode (lino))return process_check_rt_inode (mp, dinoc, lino, type, dirty,XR_INO_RTRMAP ,_ ("realtime rmap btree" )); +if (is_rtrefcount_ino (lino)) +return process_check_rt_inode (mp, dinoc, lino, type, dirty, +XR_INO_RTREFC ,_ ("realtime refcount btree" ));return 0 ; }
@@ -2172,6 +2184,18 @@ _("found inode %" PRIu64 " claiming to be a rtrmapbt file, but rmapbt is disable }break ; +case XR_INO_RTREFC : +/* +* if we have no refcountbt, any inode claiming +* to be a real-time file is bogus +*/ +if (!xfs_has_reflink (mp)) { +do_warn ( +_ ("found inode %" PRIu64" claiming to be a rtrefcountbt file, but reflink is disabled\n" ), lino); +return 1 ; + } +break ; +default :break ; }
@@ -3299,6 +3323,8 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"), type =XR_INO_PQUOTA ; else if (is_rtrmap_inode(lino)) type =XR_INO_RTRMAP ; + else if (is_rtrefcount_ino(lino)) + type =XR_INO_RTREFC ; else type =XR_INO_DATA ;break ;
@@ -3405,6 +3431,7 @@ _("Bad CoW extent size %u on inode %" PRIu64 ", "),case XR_INO_GQUOTA :case XR_INO_PQUOTA :case XR_INO_RTRMAP : +case XR_INO_RTREFC :/* * This inode was recognized as being filesystem * metadata, so preserve the inode and its contents for
repair/dir2.c +2 -0
@@ -157,6 +157,8 @@ is_meta_ino( reason =_ ("realtime summary" ); else if (is_rtrmap_inode(lino)) reason =_ ("realtime rmap" ); + else if (is_rtrefcount_ino(lino)) + reason =_ ("realtime refcount" ); else if (lino == mp->m_sb.sb_uquotino) reason =_ ("user quota" ); else if (lino == mp->m_sb.sb_gquotino)
repair/incore.h +1 -0
@@ -225,6 +225,7 @@ int count_bcnt_extents(xfs_agnumber_t);#define XR_INO_GQUOTA 13/* group quota inode */ #define XR_INO_PQUOTA 14/* project quota inode */ #define XR_INO_RTRMAP 15/* realtime rmap */ +#define XR_INO_RTREFC 16/* realtime refcount */ /* inode allocation tree */
repair/rmap.c +85 -2
143 lines not on this page · raw message
repair/rmap.h +2 -1
@@ -41,7 +41,7 @@ extern void rmap_high_key_from_rec(struct xfs_rmap_irec *rec,extern int compute_refcounts (struct xfs_mount *,xfs_agnumber_t );uint64_t refcount_record_count (struct xfs_mount *mp,xfs_agnumber_t agno);extern int init_refcount_cursor (xfs_agnumber_t ,struct xfs_slab_cursor **); -extern void refcount_avoid_check (void ); +extern void refcount_avoid_check (struct xfs_mount *mp);void check_refcounts (struct xfs_mount *mp,xfs_agnumber_t agno); extern void record_inode_reflink_flag(struct xfs_mount *, struct xfs_dinode *,
@@ -68,5 +68,6 @@ int populate_rtgroup_rmapbt(struct xfs_rtgroup *rtg, struct xfs_inode *ip);xfs_rgnumber_t rtgroup_for_rtrefcount_inode (struct xfs_mount *mp,xfs_ino_t ino); +bool is_rtrefcount_ino (xfs_ino_t ino);#endif /* RMAP_H_ */
repair/scan.c +4 -4
@@ -1985,7 +1985,7 @@ _("extent (%u/%u) len %u claimed, state is %d\n"),libxfs_perag_put (pag); out:if (suspect) -refcount_avoid_check (); +refcount_avoid_check (mp);return ; }
@@ -2275,7 +2275,7 @@ _("%s btree block claimed (state %d), agno %d, agbno %d, suspect %d\n"), } out:if (suspect) { -refcount_avoid_check (); +refcount_avoid_check (mp);return 1 ; }
@@ -3138,7 +3138,7 @@ validate_agf(if (levels ==0 || levels > mp->m_refc_maxlevels) {do_warn (_ ("bad levels %u for refcountbt root, agno %d\n" ), levels, agno); -refcount_avoid_check (); +refcount_avoid_check (mp); } bno =be32_to_cpu (agf->agf_refcount_root);
@@ -3156,7 +3156,7 @@ validate_agf( }else {do_warn (_ ("bad agbno %u for refcntbt root, agno %d\n" ), bno, agno); -refcount_avoid_check (); +refcount_avoid_check (mp); } }
PATCH 33/41 xfs_repair: compute refcount data for the realtime groups
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
At the end of phase 4, compute reference count information for realtime groups from the realtime rmap information collected, just like we do for AGs in the data section.
--- repair/phase4.c | 19 ++++++++++++++++++- repair/rmap.c | 17 ++++++++++++----- repair/rmap.h | 2 +- 3 files changed, 31 insertions(+), 7 deletions(-)
repair/phase4.c +18 -1
@@ -173,13 +173,28 @@ compute_ag_refcounts( {int error; - error =compute_refcounts (wq->wq_ctx, agno); + error =compute_refcounts (wq->wq_ctx, false, agno);if (error)do_error (_ ("%s while computing reference count records.\n" ),strerror (error)); } +static void +compute_rt_refcounts ( +struct workqueue *wq, +xfs_agnumber_t rgno, +void *arg) +{ +int error; + + error =compute_refcounts (wq->wq_ctx, true, rgno); +if (error) +do_error ( +_ ("%s while computing realtime reference count records.\n" ), +strerror (error)); +} + static void process_inode_reflink_flags( struct workqueue *wq,
@@ -227,6 +242,8 @@ process_rmap_data(create_work_queue (&wq, mp,platform_nproc ());for (i =0 ; i < mp->m_sb.sb_agcount; i++)queue_work (&wq, compute_ag_refcounts, i,NULL ); +for (i =0 ; i < mp->m_sb.sb_rgcount; i++) +queue_work (&wq, compute_rt_refcounts, i,NULL );destroy_work_queue (&wq);create_work_queue (&wq, mp,platform_nproc ());
repair/rmap.c +12 -5
@@ -137,6 +137,11 @@ rmaps_init_rt(if (error) goto nomem; + error =init_slab (&ag_rmap->ar_refcount_items, +sizeof (struct xfs_refcount_irec )); +if (error) + goto nomem; + ag_rmap->rg_rmap_ino =NULLFSINO ; ag_rmap->rg_refcount_ino =NULLFSINO ;return ;
@@ -1061,6 +1066,7 @@ mark_reflink_inodes( static void refcount_emit( struct xfs_mount *mp, + bool isrt, xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_extlen_t len,
@@ -1070,7 +1076,7 @@ refcount_emit(int error;struct xfs_slab *rlslab; - rlslab =rmaps_for_group (false, agno)->ar_refcount_items; + rlslab =rmaps_for_group (isrt, agno)->ar_refcount_items;ASSERT (nr_rmaps >0 ); dbg_printf("REFL: agno=%u pblk=%u, len=%u -> refcount=%zu\n",
@@ -1189,6 +1195,7 @@ refcount_push_rmaps_at(int compute_refcounts (struct xfs_mount *mp, +bool isrt,xfs_agnumber_t agno) {struct rcbag *rcstack;
@@ -1204,12 +1211,12 @@ compute_refcounts(if (!xfs_has_reflink (mp))return 0 ; -if (rmaps_for_group (false, agno)->ar_xfbtree ==NULL ) +if (rmaps_for_group (isrt, agno)->ar_xfbtree ==NULL )return 0 ; - nr_rmaps =rmap_record_count (mp, false, agno); + nr_rmaps =rmap_record_count (mp, isrt, agno); - error =rmap_init_mem_cursor (mp,NULL , false, agno, &rmcur); + error =rmap_init_mem_cursor (mp,NULL , isrt, agno, &rmcur);if (error)return error;
@@ -1266,7 +1273,7 @@ compute_refcounts(ASSERT (nbno > cbno);if (rcbag_count (rcstack) != old_stack_height) {if (old_stack_height >1 ) { -refcount_emit (mp, agno, cbno, +refcount_emit (mp, isrt, agno, cbno, nbno - cbno, old_stack_height); }
repair/rmap.h +1 -1
@@ -38,7 +38,7 @@ extern int64_t rmap_diffkeys(struct xfs_rmap_irec *kp1,extern void rmap_high_key_from_rec (struct xfs_rmap_irec *rec,struct xfs_rmap_irec *key); -extern int compute_refcounts (struct xfs_mount *,xfs_agnumber_t ); +int compute_refcounts (struct xfs_mount *mp,bool isrt,xfs_agnumber_t agno);uint64_t refcount_record_count (struct xfs_mount *mp,xfs_agnumber_t agno);extern int init_refcount_cursor (xfs_agnumber_t ,struct xfs_slab_cursor **);extern void refcount_avoid_check (struct xfs_mount *mp);
PATCH 34/41 xfs_repair: check existing realtime refcountbt entries against observed refcounts
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Once we've finished collecting reverse mapping observations from the metadata scan, check those observations against the realtime refcount btree (particularly if we're in -n mode) to detect rtrefcountbt problems.
--- libxfs/libxfs_api_defs.h | 1 repair/agbtree.c | 2 repair/phase4.c | 11 +++ repair/rmap.c | 200 +++++++++++++++++++++++++++++++++++----------- repair/rmap.h | 4 + 5 files changed, 170 insertions(+), 48 deletions(-)
libxfs/libxfs_api_defs.h +1 -0
@@ -252,6 +252,7 @@#define xfs_rtrefcountbt_create_path libxfs_rtrefcountbt_create_path#define xfs_rtrefcountbt_droot_maxrecs libxfs_rtrefcountbt_droot_maxrecs +#define xfs_rtrefcountbt_init_cursor libxfs_rtrefcountbt_init_cursor#define xfs_rtrefcountbt_maxlevels_ondisk libxfs_rtrefcountbt_maxlevels_ondisk#define xfs_rtrefcountbt_maxrecs libxfs_rtrefcountbt_maxrecs
repair/agbtree.c +1 -1
@@ -738,7 +738,7 @@ build_refcount_tree( {int error; - error =init_refcount_cursor (agno, &btr->slab_cursor); + error =init_refcount_cursor (false, agno, &btr->slab_cursor);if (error)do_error (_ ("Insufficient memory to construct refcount cursor.\n" ));
repair/phase4.c +11 -0
@@ -219,6 +219,15 @@ check_refcount_btrees(check_refcounts (wq->wq_ctx, agno); } +static void +check_rt_refcount_btrees ( +struct workqueue *wq, +xfs_agnumber_t agno, +void *arg) +{ +check_rtrefcounts (wq->wq_ctx, agno); +} +static void process_rmap_data (struct xfs_mount *mp)
@@ -251,6 +260,8 @@ process_rmap_data(queue_work (&wq, process_inode_reflink_flags, i,NULL );queue_work (&wq, check_refcount_btrees, i,NULL ); } +for (i =0 ; i < mp->m_sb.sb_rgcount; i++) +queue_work (&wq, check_rt_refcount_btrees, i,NULL );destroy_work_queue (&wq); }
repair/rmap.c +154 -46
246 lines not on this page · raw message
repair/rmap.h +3 -1
@@ -40,9 +40,11 @@ extern void rmap_high_key_from_rec(struct xfs_rmap_irec *rec,int compute_refcounts (struct xfs_mount *mp,bool isrt,xfs_agnumber_t agno);uint64_t refcount_record_count (struct xfs_mount *mp,xfs_agnumber_t agno); -extern int init_refcount_cursor (xfs_agnumber_t ,struct xfs_slab_cursor **); +int init_refcount_cursor (bool isrt,xfs_agnumber_t agno, +struct xfs_slab_cursor **pcur);extern void refcount_avoid_check (struct xfs_mount *mp);void check_refcounts (struct xfs_mount *mp,xfs_agnumber_t agno); +void check_rtrefcounts (struct xfs_mount *mp,xfs_rgnumber_t rgno);extern void record_inode_reflink_flag (struct xfs_mount *,struct xfs_dinode *,xfs_agnumber_t ,xfs_agino_t ,xfs_ino_t );
PATCH 35/41 xfs_repair: reject unwritten shared extents
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
We don't allow sharing of unwritten extents, which means that repair should reject an unwritten extent if someone else has already claimed the space.
--- repair/dinode.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
repair/dinode.c +18 -5
@@ -277,7 +277,8 @@ _("bad state in rt extent map %" PRIu64 "\n"),break ;case XR_E_INUSE :case XR_E_MULT : -if (xfs_has_rtreflink (mp)) +if (xfs_has_rtreflink (mp) && + irec->br_state ==XFS_EXT_NORM )break ;set_rtbmap (ext,XR_E_MULT );break ;
@@ -353,8 +354,14 @@ _("data fork in rt inode %" PRIu64 " found rt metadata extent %" PRIu64 " in rtreturn 1 ;case XR_E_INUSE :case XR_E_MULT : -if (xfs_has_rtreflink (mp)) -break ; +if (xfs_has_rtreflink (mp)) { +if (irec->br_state ==XFS_EXT_NORM ) +break ; +do_warn ( +_ ("data fork in rt inode %" PRIu64" claims shared unwritten rt extent %" PRIu64"\n" ), + ino, b); +return 1 ; + }do_warn (_ ("data fork in rt inode %" PRIu64" claims used rt extent %" PRIu64"\n" ), ino, b);
@@ -671,8 +678,14 @@ _("%s fork in inode %" PRIu64 " claims metadata block %" PRIu64 "\n"),case XR_E_INUSE :case XR_E_MULT :if (type ==XR_INO_DATA && -xfs_has_reflink (mp)) -break ; +xfs_has_reflink (mp)) { +if (irec.br_state ==XFS_EXT_NORM ) +break ; +do_warn ( +_ ("%s fork in %s inode %" PRIu64" claims shared unwritten block %" PRIu64"\n" ), + forkname, ftype, ino, b); + goto done; + }do_warn (_ ("%s fork in %s inode %" PRIu64" claims used block %" PRIu64"\n" ), forkname, ftype, ino, b);
PATCH 36/41 xfs_repair: rebuild the realtime refcount btree
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Use the collected reference count information to rebuild the btree.
--- libxfs/libxfs_api_defs.h | 4 + repair/Makefile | 1 repair/agbtree.c | 2 repair/phase6.c | 115 ++++++++++++++++++++ repair/rmap.c | 12 ++ repair/rmap.h | 5 + repair/rtrefcount_repair.c | 248 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 384 insertions(+), 3 deletions(-) create mode 100644 repair/rtrefcount_repair.c
libxfs/libxfs_api_defs.h +4 -0
@@ -250,11 +250,15 @@#define xfs_rtgroup_update_secondary_sbs libxfs_rtgroup_update_secondary_sbs#define xfs_rtgroup_update_super libxfs_rtgroup_update_super +#define xfs_rtrefcountbt_absolute_maxlevels libxfs_rtrefcountbt_absolute_maxlevels +#define xfs_rtrefcountbt_commit_staged_btree libxfs_rtrefcountbt_commit_staged_btree +#define xfs_rtrefcountbt_create libxfs_rtrefcountbt_create#define xfs_rtrefcountbt_create_path libxfs_rtrefcountbt_create_path#define xfs_rtrefcountbt_droot_maxrecs libxfs_rtrefcountbt_droot_maxrecs#define xfs_rtrefcountbt_init_cursor libxfs_rtrefcountbt_init_cursor#define xfs_rtrefcountbt_maxlevels_ondisk libxfs_rtrefcountbt_maxlevels_ondisk#define xfs_rtrefcountbt_maxrecs libxfs_rtrefcountbt_maxrecs +#define xfs_rtrefcountbt_stage_cursor libxfs_rtrefcountbt_stage_cursor#define xfs_rtrmapbt_calc_reserves libxfs_rtrmapbt_calc_reserves#define xfs_rtrmapbt_commit_staged_btree libxfs_rtrmapbt_commit_staged_btree
repair/Makefile +1 -0
@@ -70,6 +70,7 @@ CFILES = \ rcbag.c \ rmap.c \ rt.c \ + rtrefcount_repair.c \ rtrmap_repair.c \ sb.c \ scan.c \
repair/agbtree.c +1 -1
@@ -721,7 +721,7 @@ init_refc_cursor(/* Compute how many blocks we'll need. */ error = -libxfs_btree_bload_compute_geometry (btr->cur, &btr->bload, -refcount_record_count (sc->mp, agno)); +refcount_record_count (sc->mp, false, agno));if (error)do_error (_ ("Unable to compute refcount btree geometry, error %d.\n" ), error);
repair/phase6.c +115 -0
127 lines not on this page · raw message
repair/rmap.c +11 -1
@@ -1871,9 +1871,10 @@ _("Unable to fix reflink flag on inode %"PRIu64".\n"),uint64_t refcount_record_count (struct xfs_mount *mp, +bool isrt,xfs_agnumber_t agno) { -struct xfs_ag_rmap *x =rmaps_for_group (false, agno); +struct xfs_ag_rmap *x =rmaps_for_group (isrt, agno);return slab_count (x->ar_refcount_items); }
@@ -2219,3 +2220,12 @@ rtgroup_rmap_ino(return ar->rg_rmap_ino; } + +xfs_ino_t +rtgroup_refcount_ino ( +struct xfs_rtgroup *rtg) +{ +struct xfs_ag_rmap *ar =rmaps_for_group (true, rtg->rtg_rgno); + +return ar->rg_refcount_ino; +}
repair/rmap.h +4 -1
@@ -39,7 +39,8 @@ extern void rmap_high_key_from_rec(struct xfs_rmap_irec *rec, struct xfs_rmap_irec *key);int compute_refcounts (struct xfs_mount *mp,bool isrt,xfs_agnumber_t agno); -uint64_t refcount_record_count (struct xfs_mount *mp,xfs_agnumber_t agno); +uint64_t refcount_record_count (struct xfs_mount *mp,bool isrt, +xfs_agnumber_t agno);int init_refcount_cursor (bool isrt,xfs_agnumber_t agno,struct xfs_slab_cursor **pcur);extern void refcount_avoid_check (struct xfs_mount *mp);
@@ -71,5 +72,7 @@ int populate_rtgroup_rmapbt(struct xfs_rtgroup *rtg, struct xfs_inode *ip);xfs_rgnumber_t rtgroup_for_rtrefcount_inode (struct xfs_mount *mp,xfs_ino_t ino);bool is_rtrefcount_ino (xfs_ino_t ino); +xfs_ino_t rtgroup_refcount_ino (struct xfs_rtgroup *rtg); +int populate_rtgroup_refcountbt (struct xfs_rtgroup *rtg,struct xfs_inode *ip);#endif /* RMAP_H_ */
repair/rtrefcount_repair.c new file +248 -0
248 lines not on this page · raw message
PATCH 37/41 xfs_repair: allow realtime files to have the reflink flag set
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that we allow reflink on the realtime volume, allow that combination of inode flags if the feature's enabled. Note that we now allow inodes to have rtinherit even if there's no realtime volume, since the kernel has never restricted that.
--- repair/dinode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
repair/dinode.c +4 -2
@@ -3186,7 +3186,8 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"), }if ((flags2 &XFS_DIFLAG2_REFLINK ) && - (flags & (XFS_DIFLAG_REALTIME |XFS_DIFLAG_RTINHERIT ))) { + !xfs_has_rtreflink (mp) && + (flags &XFS_DIFLAG_REALTIME )) {if (!uncertain) { do_warn( _("Cannot have a reflinked realtime inode %" PRIu64 "\n"),
@@ -3218,7 +3219,8 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"), }if ((flags2 &XFS_DIFLAG2_COWEXTSIZE ) && - (flags & (XFS_DIFLAG_REALTIME |XFS_DIFLAG_RTINHERIT ))) { + !xfs_has_rtreflink (mp) && + (flags &XFS_DIFLAG_REALTIME )) {if (!uncertain) { do_warn( _("Cannot have CoW extent size hint on a realtime inode %" PRIu64 "\n"),
PATCH 38/41 xfs_repair: validate CoW extent size hint on rtinherit directories
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
XFS allows a sysadmin to change the rt extent size when adding a rt section to a filesystem after formatting. If there are any directories with both a cowextsize hint and rtinherit set, the hint could become misaligned with the new rextsize. Offer to fix the problem if we're in modify mode and the verifier didn't trip. If we're in dry run mode, we let the kernel fix it.
--- repair/dinode.c | 64 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 21 deletions(-)
repair/dinode.c +43 -21
@@ -2795,6 +2795,47 @@ _("Bad extent size hint %u on inode %" PRIu64 ", "), } } +static void +validate_cowextsize ( +struct xfs_mount *mp, +struct xfs_dinode *dino, +xfs_ino_t lino, +int *dirty) +{ +uint16_t flags =be16_to_cpu (dino->di_flags); +uint64_t flags2 =be64_to_cpu (dino->di_flags2); +unsigned int value =be32_to_cpu (dino->di_cowextsize); +bool misaligned = false; +bool bad; + +/* +* XFS allows a sysadmin to change the rt extent size when adding a +* rt section to a filesystem after formatting. If there are any +* directories with both a cowextsize hint and rtinherit set, the +* hint could become misaligned with the new rextsize. +*/ +if ((flags2 &XFS_DIFLAG2_COWEXTSIZE ) && + (flags &XFS_DIFLAG_RTINHERIT ) && + value % mp->m_sb.sb_rextsize >0 ) + misaligned = true; + +/* Complain if the verifier fails. */ + bad =libxfs_inode_validate_cowextsize (mp, value, +be16_to_cpu (dino->di_mode), flags, flags2) !=NULL ; +if (bad || misaligned) { +do_warn ( +_ ("Bad CoW extent size hint %u on inode %" PRIu64", " ), +be32_to_cpu (dino->di_cowextsize), lino); +if (!no_modify) { +do_warn (_ ("resetting to zero\n" )); + dino->di_flags2 &= ~cpu_to_be64 (XFS_DIFLAG2_COWEXTSIZE ); + dino->di_cowextsize =0 ; + *dirty =1 ; + }else +do_warn (_ ("would reset to zero\n" )); + } +} +/* * returns 0 if the inode is ok, 1 if the inode is corrupt * check_dups can be set to 1 *only* when called by the
@@ -3372,27 +3413,8 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"),validate_extsize (mp, dino, lino, dirty); -/* -* Only (regular files and directories) with COWEXTSIZE flags -* set can have extsize set. -*/ -if (dino->di_version >=3 && -libxfs_inode_validate_cowextsize (mp, -be32_to_cpu (dino->di_cowextsize), -be16_to_cpu (dino->di_mode), -be16_to_cpu (dino->di_flags), -be64_to_cpu (dino->di_flags2)) !=NULL ) { -do_warn ( -_ ("Bad CoW extent size %u on inode %" PRIu64", " ), -be32_to_cpu (dino->di_cowextsize), lino); -if (!no_modify) { -do_warn (_ ("resetting to zero\n" )); - dino->di_flags2 &= ~cpu_to_be64 (XFS_DIFLAG2_COWEXTSIZE ); - dino->di_cowextsize =0 ; - *dirty =1 ; - }else -do_warn (_ ("would reset to zero\n" )); - } +if (dino->di_version >=3 ) +validate_cowextsize (mp, dino, lino, dirty);/* nsec fields cannot be larger than 1 billion */ check_nsec ("atime" , lino, dino, &dino->di_atime, dirty);
PATCH 39/41 xfs_repair: allow sysadmins to add realtime reflink
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Allow the sysadmin to use xfs_repair to upgrade an existing filesystem to support the realtime reference count btree, and therefore reflink on realtime volumes.
--- libxfs/libxfs_api_defs.h | 1 + repair/phase2.c | 75 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-)
libxfs/libxfs_api_defs.h +1 -0
@@ -251,6 +251,7 @@#define xfs_rtgroup_update_super libxfs_rtgroup_update_super#define xfs_rtrefcountbt_absolute_maxlevels libxfs_rtrefcountbt_absolute_maxlevels +#define xfs_rtrefcountbt_calc_reserves libxfs_rtrefcountbt_calc_reserves#define xfs_rtrefcountbt_commit_staged_btree libxfs_rtrefcountbt_commit_staged_btree#define xfs_rtrefcountbt_create libxfs_rtrefcountbt_create#define xfs_rtrefcountbt_create_path libxfs_rtrefcountbt_create_path
repair/phase2.c +73 -2
105 lines not on this page · raw message
PATCH 40/41 mkfs: validate CoW extent size hint when rtinherit is set
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Extent size hints exist to nudge the behavior of the file data block allocator towards trying to make aligned allocations. Therefore, it doesn't make sense to allow a hint that isn't a multiple of the fundamental allocation unit for a given file.
This means that if the sysadmin is formatting with rtinherit set on the root dir, validate_cowextsize_hint needs to check the hint value on a simulated realtime file to make sure that it's correct. This hasn't been necessary in the past since one cannot have a CoW hint without a reflink filesystem, and we previously didn't allow rt reflink filesystems.
--- mkfs/xfs_mkfs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
mkfs/xfs_mkfs.c +20 -0
@@ -2669,6 +2669,26 @@ _("illegal CoW extent size hint %lld, must be less than %u.\n"), min(XFS_MAX_BMBT_EXTLEN, mp->m_sb.sb_agblocks / 2));usage (); } + +/* +* If the value is to be passed on to realtime files, revalidate with +* a realtime file so that we know the hint and flag that get passed on +* to realtime files will be correct. +*/ +if (!(cli->fsx.fsx_xflags &FS_XFLAG_RTINHERIT )) +return ; + + fa =libxfs_inode_validate_cowextsize (mp, cli->fsx.fsx_cowextsize, +S_IFREG ,XFS_DIFLAG_REALTIME , flags2); + +if (fa) { +fprintf (stderr, +_ ("illegal CoW extent size hint %lld, must be less than %u and a multiple of %u. %p\n" ), + (long long )cli->fsx.fsx_cowextsize, +min (XFS_MAX_BMBT_EXTLEN , mp->m_sb.sb_agblocks /2 ), + mp->m_sb.sb_rextsize, fa); +usage (); + } }/* Complain if this filesystem is not a supported configuration. */
PATCH 41/41 mkfs: enable reflink on the realtime device
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Allow the creation of filesystems with both reflink and realtime volumes enabled. For now we don't support a realtime extent size > 1.
--- libxfs/init.c | 4 ++-- mkfs/proto.c | 44 +++++++++++++++++++++++++++++++++++++++++ mkfs/xfs_mkfs.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 100 insertions(+), 7 deletions(-)
libxfs/init.c +2 -2
@@ -448,9 +448,9 @@ rtmount_init(if (mp->m_sb.sb_rblocks ==0 )return 0 ; -if (xfs_has_reflink (mp)) { +if (xfs_has_reflink (mp) && mp->m_sb.sb_rextsize >1 ) {fprintf (stderr, -_ ("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n" ), +_ ("%s: Reflink not compatible with realtime extent size > 1. Please try a newer xfsprogs.\n" ), progname);return -1 ; }
mkfs/proto.c +44 -0
56 lines not on this page · raw message
mkfs/xfs_mkfs.c +54 -5
88 lines not on this page · raw message
cover libxfs: reflink with large realtime extents
In reply to Darrick J. WongHi all,
Now that we've landed support for reflink on the realtime device for cases where the rt extent size is the same as the fs block size, enhance the reflink code further to support cases where the rt extent size is a power-of-two multiple of the fs block size. This enables us to do data block sharing (for example) for much larger allocation units by dirtying pagecache around shared extents and expanding writeback to write back shared extents fully.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=realtime-reflink-extsize
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-reflink-extsize
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-reflink-extsize
--- libxfs/init.c | 7 ------- libxfs/xfs_bmap.c | 22 ++++++++++++++++++++++ libxfs/xfs_inode_buf.c | 20 ++++++-------------- mkfs/xfs_mkfs.c | 37 ------------------------------------- 4 files changed, 28 insertions(+), 58 deletions(-)
PATCH 1/3 xfs: enable extent size hints for CoW when rtextsize > 1
From: Darrick J. Wong <[email protected]>
CoW extent size hints are not allowed on filesystems that have large realtime extents because we only want to perform the minimum required amount of write-around (aka write amplification) for shared extents.
On filesystems where rtextsize > 1, allocations can only be done in units of full rt extents, which means that we can only map an entire rt extent's worth of blocks into the data fork. Hole punch requests become conversions to unwritten if the request isn't aligned properly.
Because a copy-write fundamentally requires remapping, this means that we also can only do copy-writes of a full rt extent. This is too expensive for large hint sizes, since it's all or nothing.
--- libxfs/xfs_bmap.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
libxfs/xfs_bmap.c +22 -0
@@ -6445,6 +6445,28 @@ xfs_get_cowextsz_hint(if (ip->i_diflags2 &XFS_DIFLAG2_COWEXTSIZE ) a = ip->i_cowextsize;if (XFS_IS_REALTIME_INODE (ip)) { +/* +* For realtime files, the realtime extent is the fundamental +* unit of allocation. This means that data sharing and CoW +* remapping can only be done in those units. For filesystems +* where the extent size is larger than one block, write +* requests that are not aligned to an extent boundary employ +* an unshare-around strategy to ensure that all pages for a +* shared extent are fully dirtied. +* +* Because the remapping alignment requirement applies equally +* to all CoW writes, any regular overwrites that could be +* turned (by a speculative CoW preallocation) into a CoW write +* must either employ this dirty-around strategy, or be smart +* enough to ignore the CoW fork mapping unless the entire +* extent is dirty or becomes shared by writeback time. Doing +* the first would dramatically increase write amplification, +* and the second would require deeper insight into the state +* of the page cache during a writeback request. For now, we +* ignore the hint. +*/ +if (ip->i_mount->m_sb.sb_rextsize >1 ) +return ip->i_mount->m_sb.sb_rextsize; b =0 ;if (ip->i_diflags &XFS_DIFLAG_EXTSIZE ) b = ip->i_extsize;
PATCH 2/3 xfs: fix integer overflow when validating extent size hints
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Both file extent size hints are stored as 32-bit quantities, in units of filesystem blocks. As part of validating the hints, we convert these quantities to bytes to ensure that the hint is congruent with the file's allocation size.
The maximum possible hint value is 2097151 (aka XFS_MAX_BMBT_EXTLEN). If the file allocation unit is larger than 2048, the unit conversion will exceed 32 bits in size, which overflows the uint32_t used to store the value used in the comparison. This isn't a problem for files on the data device since the hint will always be a multiple of the block size. However, this is a problem for realtime files because the rtextent size can be any integer number of fs blocks, and truncation of upper bits changes the outcome of division.
Eliminate the overflow by performing the congruency check in units of blocks, not bytes. Otherwise, we get errors like this:
$ truncate -s 500T /tmp/a $ mkfs.xfs -f -N /tmp/a -d extszinherit=2097151,rtinherit=1 -r extsize=28k illegal extent size hint 2097151, must be less than 2097151 and a multiple of 7.
--- libxfs/xfs_inode_buf.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
libxfs/xfs_inode_buf.c +6 -14
@@ -737,13 +737,11 @@ xfs_inode_validate_extsize(bool rt_flag;bool hint_flag;bool inherit_flag; -uint32_t extsize_bytes; -uint32_t blocksize_bytes; +uint32_t alloc_unit =1 ; rt_flag = (flags &XFS_DIFLAG_REALTIME ); hint_flag = (flags &XFS_DIFLAG_EXTSIZE ); inherit_flag = (flags &XFS_DIFLAG_EXTSZINHERIT ); - extsize_bytes =XFS_FSB_TO_B (mp, extsize);/* * This comment describes a historic gap in this verifier function.
@@ -772,9 +770,7 @@ xfs_inode_validate_extsize(*/ if (rt_flag) - blocksize_bytes =XFS_FSB_TO_B (mp, mp->m_sb.sb_rextsize); -else - blocksize_bytes = mp->m_sb.sb_blocksize; + alloc_unit = mp->m_sb.sb_rextsize;if ((hint_flag || inherit_flag) && !(S_ISDIR (mode) ||S_ISREG (mode)))return __this_address;
@@ -792,7 +788,7 @@ xfs_inode_validate_extsize(if (mode && !(hint_flag || inherit_flag) && extsize !=0 )return __this_address; -if (extsize_bytes % blocksize_bytes) +if (extsize % alloc_unit)return __this_address;if (extsize >XFS_MAX_BMBT_EXTLEN )
@@ -827,12 +823,10 @@ xfs_inode_validate_cowextsize( {bool rt_flag;bool hint_flag; -uint32_t cowextsize_bytes; -uint32_t blocksize_bytes; +uint32_t alloc_unit =1 ; rt_flag = (flags &XFS_DIFLAG_REALTIME ); hint_flag = (flags2 &XFS_DIFLAG2_COWEXTSIZE ); - cowextsize_bytes =XFS_FSB_TO_B (mp, cowextsize);/* * Similar to extent size hints, a directory can be configured to
@@ -847,9 +841,7 @@ xfs_inode_validate_cowextsize(*/ if (rt_flag) - blocksize_bytes =XFS_FSB_TO_B (mp, mp->m_sb.sb_rextsize); -else - blocksize_bytes = mp->m_sb.sb_blocksize; + alloc_unit = mp->m_sb.sb_rextsize;if (hint_flag && !xfs_has_reflink (mp))return __this_address;
@@ -864,7 +856,7 @@ xfs_inode_validate_cowextsize(if (mode && !hint_flag && cowextsize !=0 )return __this_address; -if (cowextsize_bytes % blocksize_bytes) +if (cowextsize % alloc_unit)return __this_address;if (cowextsize >XFS_MAX_BMBT_EXTLEN )
PATCH 3/3 mkfs: enable reflink with realtime extent sizes > 1
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Allow creation of filesystems with reflink enabled and realtime extent size larger than 1 block.
--- libxfs/init.c | 7 ------- mkfs/xfs_mkfs.c | 37 ------------------------------------- 2 files changed, 44 deletions(-)
libxfs/init.c +0 -7
@@ -448,13 +448,6 @@ rtmount_init(if (mp->m_sb.sb_rblocks ==0 )return 0 ; -if (xfs_has_reflink (mp) && mp->m_sb.sb_rextsize >1 ) { -fprintf (stderr, -_ ("%s: Reflink not compatible with realtime extent size > 1. Please try a newer xfsprogs.\n" ), - progname); -return -1 ; - } -if (mp->m_rtdev_targp->bt_bdev ==0 && !xfs_is_debugger (mp)) {fprintf (stderr,_ ("%s: filesystem has a realtime subvolume\n" ), progname);
mkfs/xfs_mkfs.c +0 -37
@@ -2385,24 +2385,6 @@ _("inode btree counters not supported without finobt support\n")); }if (cli->xi->rtname) { -if (cli->rtextsize && cli->sb_feat.reflink) { -if (cli_opt_set (&mopts,M_REFLINK )) { -fprintf (stderr, -_ ("reflink not supported on realtime devices with rt extent size specified\n" )); -usage (); - } - cli->sb_feat.reflink = false; - } -if (cli->blocksize <XFS_MIN_RTEXTSIZE && cli->sb_feat.reflink) { -if (cli_opt_set (&mopts,M_REFLINK )) { -fprintf (stderr, -_ ("reflink not supported on realtime devices with blocksize %d < %d\n" ), - cli->blocksize, -XFS_MIN_RTEXTSIZE ); -usage (); - } - cli->sb_feat.reflink = false; - }if (!cli->sb_feat.rtgroups && cli->sb_feat.reflink) {if (cli_opt_set (&mopts,M_REFLINK ) &&cli_opt_set (&ropts,R_RTGROUPS )) {
@@ -2582,19 +2564,6 @@ validate_rtextsize(usage (); } cfg->rtextblocks = (xfs_extlen_t)(rtextbytes >> cfg->blocklog); - }else if (cli->sb_feat.reflink && cli->xi->rtname) { -/* -* reflink doesn't support rt extent size > 1FSB yet, so set -* an extent size of 1FSB. Make sure we still satisfy the -* minimum rt extent size. -*/ -if (cfg->blocksize <XFS_MIN_RTEXTSIZE ) { -fprintf (stderr, -_ ("reflink not supported on rt volume with blocksize %d\n" ), - cfg->blocksize); -usage (); - } - cfg->rtextblocks =1 ; }else {/* * If realtime extsize has not been specified by the user,
@@ -2626,12 +2595,6 @@ validate_rtextsize( } }ASSERT (cfg->rtextblocks); - -if (cli->sb_feat.reflink && cfg->rtblocks >0 && cfg->rtextblocks >1 ) { -fprintf (stderr, -_ ("reflink not supported on realtime with extent sizes > 1\n" )); -usage (); - } }/* Validate the incoming extsize hint. */
cover libxfs: enable quota for realtime voluems
In reply to Darrick J. WongHi all,
At some point, I realized that I've refactored enough of the quota code in XFS that I should evaluate whether or not quota actually works on realtime volumes. It turns out that with two exceptions, it actually does seem to work properly! There are three broken pieces that I've found so far: chown doesn't work, the quota accounting goes wrong when the rt bitmap changes size, and the VFS quota ioctls don't report the realtime warning counts or limits. Hence this series fixes two things in XFS and re-enables rt quota after a break of a couple decades.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=realtime-quotas
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-quotas
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-quotas
--- include/xqm.h | 5 ++++- quota/state.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
PATCH 1/1 xfs_quota: report warning limits for realtime space quotas
From: Darrick J. Wong <[email protected]>
Report the number of warnings that a user will get for exceeding the soft limit of a realtime volume.
--- include/xqm.h | 5 ++++- quota/state.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
include/xqm.h +4 -1
@@ -184,7 +184,10 @@ struct fs_quota_statv {__s32 qs_rtbtimelimit;/* limit for rt blks timer */ __u16 qs_bwarnlimit;/* limit for num warnings */ __u16 qs_iwarnlimit;/* limit for num warnings */ - __u64 qs_pad2[8]; /* for future proofing */ +__u16 qs_rtbwarnlimit;/* limit for rt blks warnings */ +__u16 qs_pad3; +__u32 qs_pad4; + __u64 qs_pad2[7]; /* for future proofing */ };#endif /* __XQM_H__ */
quota/state.c +1 -0
@@ -244,6 +244,7 @@ state_quotafile_stat(state_warnlimit (fp,XFS_INODE_QUOTA , sv->qs_iwarnlimit);state_timelimit (fp,XFS_RTBLOCK_QUOTA , sv->qs_rtbtimelimit); +state_warnlimit (fp,XFS_RTBLOCK_QUOTA , sv->qs_rtbwarnlimit); } static void
cover fstests: test upgrading older features
In reply to Darrick J. WongHi all,
Here is a general regression test to make sure that we can invoke the xfs_repair feature to add new features to V5 filesystems without errors. There are already targeted functionality tests for inobtcount and bigtime; this new one exists as a general upgrade exerciser.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=upgrade-older-features
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=upgrade-older-features
--- tests/xfs/769 | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/769.out | 2 2 files changed, 250 insertions(+) create mode 100755 tests/xfs/769 create mode 100644 tests/xfs/769.out
PATCH 1/1 xfs: test upgrading old features
From: Darrick J. Wong <[email protected]>
Test the ability to add older v5 features.
--- tests/xfs/769 | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/769.out | 2 2 files changed, 250 insertions(+) create mode 100755 tests/xfs/769 create mode 100644 tests/xfs/769.out
tests/xfs/769 new file +248 -0
@@ -0,0 +1,248 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 769 +# +# Test upgrading filesystems with new features. +# +. ./common/preamble +_begin_fstest auto mkfs repair + +# Import common functions. +. ./common/filter +. ./common/populate + +# real QA test starts here +_supported_fs xfs + +test -w /dev/ttyprintk || _notrun "test requires writable /dev/ttyprintk" +_require_check_dmesg +_require_scratch_nocheck +_require_scratch_xfs_crc + +# Does repair know how to add a particular feature to a filesystem? +check_repair_upgrade() +{ + $XFS_REPAIR_PROG -c "$1=narf" 2>&1 | \ + grep -q 'unknown option' && return 1 + return 0 +} + +# Are we configured for realtime? +rt_configured() +{ + test "$USE_EXTERNAL" = "yes" && test -n "$SCRATCH_RTDEV" +} + +# Compute the MKFS_OPTIONS string for a particular feature upgrade test +compute_mkfs_options() +{ + local m_opts="" + local caller_options="$MKFS_OPTIONS" + + for feat in "${FEATURES[@]}"; do + local feat_state="${FEATURE_STATE["${feat}"]}" + + if echo "$caller_options" | grep -E -w -q "${feat}=[0-9]*"; then + # Change the caller's options + caller_options="$(echo "$caller_options" | \ + sed -e "s/\([^[:alnum:]]\)${feat}=[0-9]*/\1${feat}=${feat_state}/g")" + else + # Add it to our list of new mkfs flags + m_opts="${feat}=${feat_state},${m_opts}" + fi + done + + test -n "$m_opts" && m_opts=" -m $m_opts" + + echo "$caller_options$m_opts" +} + +# Log the start of an upgrade. +function upgrade_start_message() +{ + local feat="$1" + + echo "Add $feat to filesystem" +} + +# Find dmesg log messages since we started a particular upgrade test +function dmesg_since_feature_upgrade_start() +{ + local feat_logmsg="$(upgrade_start_message "$1")" + + # search the dmesg log of last run of $seqnum for possible failures + # use sed \cregexpc address type, since $seqnum contains "/" + dmesg | \ + tac | \ + sed -ne "0,\#run fstests $seqnum at $date_time#p" | \ + sed -ne "0,\#${feat_logmsg}#p" | \ + tac +} + +# Did the mount fail because this feature is not supported? +function feature_unsupported() +{ + local feat="$1" + + dmesg_since_feature_upgrade_start "$feat" | \ + grep -q 'has unknown.*features' +} + +# Exercise the scratch fs +function scratch_fsstress() +{ + echo moo > $SCRATCH_MNT/sample.txt + $FSSTRESS_PROG -n $((TIME_FACTOR * 1000)) -p $((LOAD_FACTOR * 4)) \ + -d $SCRATCH_MNT/data >> $seqres.full +} + +# Exercise the filesystem a little bit and emit a manifest. +function pre_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res before upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + scratch_fsstress + find $SCRATCH_MNT -type f -print0 | xargs -r -0 md5sum > $tmp.manifest + _scratch_unmount + return 0 +} + +# Check the manifest and exercise the filesystem more +function post_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res after upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + md5sum --quiet -c $tmp.manifest || \ + echo "fs contents ^^^ changed after adding $feat" + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after adding $feat" + + # Try to mount the fs in case the check unmounted it + _try_scratch_mount &>> $seqres.full + + scratch_fsstress + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after exercising $feat" + + # Try to unmount the fs in case the check didn't + _scratch_unmount &>> $seqres.full + return 0 +} + +# Create a list of fs features in the order that support for them was added +# to the kernel driver. For each feature upgrade test, we enable all the +# features that came before it and none of the ones after, which means we're +# testing incremental migrations. We start each run with a clean fs so that +# errors and unsatisfied requirements (log size, root ino position, etc) in one +# upgrade don't spread failure to the rest of the tests. +FEATURES=() +if rt_configured; then + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +else + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade rmapbt && FEATURES+=("rmapbt") + check_repair_upgrade reflink && FEATURES+=("reflink") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +fi + +test "${#FEATURES[@]}" -eq 0 && \ + _notrun "xfs_repair does not know how to add V5 features" + +declare -A FEATURE_STATE +for f in "${FEATURES[@]}"; do + FEATURE_STATE["$f"]=0 +done + +for feat in "${FEATURES[@]}"; do + echo "-----------------------" >> $seqres.full + + upgrade_start_message "$feat" | tee -a $seqres.full /dev/ttyprintk > /dev/null + + opts="$(compute_mkfs_options)" + echo "mkfs.xfs $opts" >> $seqres.full + + # Format filesystem + MKFS_OPTIONS="$opts" _scratch_mkfs &>> $seqres.full + res=$? + outcome="mkfs returns $res for $feat upgrade test" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + continue + fi + + # Create some files to make things interesting. + pre_exercise "$feat" || break + + # Upgrade the fs + _scratch_xfs_repair -c "${feat}=1" &> $tmp.upgrade + res=$? + cat $tmp.upgrade >> $seqres.full + grep -q "^Adding" $tmp.upgrade || \ + echo "xfs_repair ignored command to add $feat" + + outcome="xfs_repair returns $res while adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + # Couldn't upgrade filesystem, move on to the next feature. + FEATURE_STATE["$feat"]=1 + continue + fi + + # Make sure repair runs cleanly afterwards + _scratch_xfs_repair -n &>> $seqres.full + res=$? + outcome="xfs_repair -n returns $res after adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + fi + + # Make sure we can still exercise the filesystem. + post_exercise "$feat" || break + + # Update feature state for next run + FEATURE_STATE["$feat"]=1 +done + +# success, all done +echo Silence is golden. +status=0 +exit
tests/xfs/769.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 769 +Silence is golden.
Re: [PATCH 1/1] xfs: test upgrading old features
Quoted 28 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Test the ability to add older v5 features.
Signed-off-by Darrick J. Wong <[email protected]>--- tests/xfs/769 | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/769.out | 2 2 files changed, 250 insertions(+) create mode 100755 tests/xfs/769 create mode 100644 tests/xfs/769.outtests/xfs/769 new file +9
-0@@ -0,0 +1,248 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 769 +# +# Test upgrading filesystems with new features. +# +. ./common/preamble
tests/xfs/769 line 19
Quoted 10 lines
tests/xfs/769 new file +10
-0+_begin_fstest auto mkfs repair + +# Import common functions. +. ./common/filter +. ./common/populate + +# real QA test starts here +_supported_fs xfs + +test -w /dev/ttyprintk || _notrun "test requires writable /dev/ttyprintk"
Hi Darrick,
I'm not sure why /dev/ttyprintk is necessary. I think sometimes we might not have this driver, but has /dev/kmsg. Can /dev/kmsg be a replacement of ttyprintk ?
Thanks,
Zorro
Quoted 238 lines
tests/xfs/769 new file +229
-0+_require_check_dmesg +_require_scratch_nocheck +_require_scratch_xfs_crc + +# Does repair know how to add a particular feature to a filesystem? +check_repair_upgrade() +{ + $XFS_REPAIR_PROG -c "$1=narf" 2>&1 | \ + grep -q 'unknown option' && return 1 + return 0 +} + +# Are we configured for realtime? +rt_configured() +{ + test "$USE_EXTERNAL" = "yes" && test -n "$SCRATCH_RTDEV" +} + +# Compute the MKFS_OPTIONS string for a particular feature upgrade test +compute_mkfs_options() +{ + local m_opts="" + local caller_options="$MKFS_OPTIONS" + + for feat in "${FEATURES[@]}"; do + local feat_state="${FEATURE_STATE["${feat}"]}" + + if echo "$caller_options" | grep -E -w -q "${feat}=[0-9]*"; then + # Change the caller's options + caller_options="$(echo "$caller_options" | \ + sed -e "s/\([^[:alnum:]]\)${feat}=[0-9]*/\1${feat}=${feat_state}/g")" + else + # Add it to our list of new mkfs flags + m_opts="${feat}=${feat_state},${m_opts}" + fi + done + + test -n "$m_opts" && m_opts=" -m $m_opts" + + echo "$caller_options$m_opts" +} + +# Log the start of an upgrade. +function upgrade_start_message() +{ + local feat="$1" + + echo "Add $feat to filesystem" +} + +# Find dmesg log messages since we started a particular upgrade test +function dmesg_since_feature_upgrade_start() +{ + local feat_logmsg="$(upgrade_start_message "$1")" + + # search the dmesg log of last run of $seqnum for possible failures + # use sed \cregexpc address type, since $seqnum contains "/" + dmesg | \ + tac | \ + sed -ne "0,\#run fstests $seqnum at $date_time#p" | \ + sed -ne "0,\#${feat_logmsg}#p" | \ + tac +} + +# Did the mount fail because this feature is not supported? +function feature_unsupported() +{ + local feat="$1" + + dmesg_since_feature_upgrade_start "$feat" | \ + grep -q 'has unknown.*features' +} + +# Exercise the scratch fs +function scratch_fsstress() +{ + echo moo > $SCRATCH_MNT/sample.txt + $FSSTRESS_PROG -n $((TIME_FACTOR * 1000)) -p $((LOAD_FACTOR * 4)) \ + -d $SCRATCH_MNT/data >> $seqres.full +} + +# Exercise the filesystem a little bit and emit a manifest. +function pre_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res before upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + scratch_fsstress + find $SCRATCH_MNT -type f -print0 | xargs -r -0 md5sum > $tmp.manifest + _scratch_unmount + return 0 +} + +# Check the manifest and exercise the filesystem more +function post_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res after upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + md5sum --quiet -c $tmp.manifest || \ + echo "fs contents ^^^ changed after adding $feat" + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after adding $feat" + + # Try to mount the fs in case the check unmounted it + _try_scratch_mount &>> $seqres.full + + scratch_fsstress + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after exercising $feat" + + # Try to unmount the fs in case the check didn't + _scratch_unmount &>> $seqres.full + return 0 +} + +# Create a list of fs features in the order that support for them was added +# to the kernel driver. For each feature upgrade test, we enable all the +# features that came before it and none of the ones after, which means we're +# testing incremental migrations. We start each run with a clean fs so that +# errors and unsatisfied requirements (log size, root ino position, etc) in one +# upgrade don't spread failure to the rest of the tests. +FEATURES=() +if rt_configured; then + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +else + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade rmapbt && FEATURES+=("rmapbt") + check_repair_upgrade reflink && FEATURES+=("reflink") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +fi + +test "${#FEATURES[@]}" -eq 0 && \ + _notrun "xfs_repair does not know how to add V5 features" + +declare -A FEATURE_STATE +for f in "${FEATURES[@]}"; do + FEATURE_STATE["$f"]=0 +done + +for feat in "${FEATURES[@]}"; do + echo "-----------------------" >> $seqres.full + + upgrade_start_message "$feat" | tee -a $seqres.full /dev/ttyprintk > /dev/null + + opts="$(compute_mkfs_options)" + echo "mkfs.xfs $opts" >> $seqres.full + + # Format filesystem + MKFS_OPTIONS="$opts" _scratch_mkfs &>> $seqres.full + res=$? + outcome="mkfs returns $res for $feat upgrade test" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + continue + fi + + # Create some files to make things interesting. + pre_exercise "$feat" || break + + # Upgrade the fs + _scratch_xfs_repair -c "${feat}=1" &> $tmp.upgrade + res=$? + cat $tmp.upgrade >> $seqres.full + grep -q "^Adding" $tmp.upgrade || \ + echo "xfs_repair ignored command to add $feat" + + outcome="xfs_repair returns $res while adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + # Couldn't upgrade filesystem, move on to the next feature. + FEATURE_STATE["$feat"]=1 + continue + fi + + # Make sure repair runs cleanly afterwards + _scratch_xfs_repair -n &>> $seqres.full + res=$? + outcome="xfs_repair -n returns $res after adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + fi + + # Make sure we can still exercise the filesystem. + post_exercise "$feat" || break + + # Update feature state for next run + FEATURE_STATE["$feat"]=1 +done + +# success, all done +echo Silence is golden. +status=0 +exittests/xfs/769.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 769 +Silence is golden.
Re: [PATCH 1/1] xfs: test upgrading old features
Quoted 42 lines · Zorro Lang
Quoted 28 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Test the ability to add older v5 features.
Signed-off-by Darrick J. Wong <[email protected]>--- tests/xfs/769 | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/769.out | 2 2 files changed, 250 insertions(+) create mode 100755 tests/xfs/769 create mode 100644 tests/xfs/769.outtests/xfs/769 new file +9
-0@@ -0,0 +1,248 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 769 +# +# Test upgrading filesystems with new features. +# +. ./common/preambletests/xfs/769 line 19
Quoted 10 lines
tests/xfs/769 new file +10
-0+_begin_fstest auto mkfs repair + +# Import common functions. +. ./common/filter +. ./common/populate + +# real QA test starts here +_supported_fs xfs + +test -w /dev/ttyprintk || _notrun "test requires writable /dev/ttyprintk"Hi Darrick,
Quoted 3 lines
I'm not sure why
/dev/ttyprintkis necessary. I think sometimes we might not have this driver, but has/dev/kmsg. Can/dev/kmsgbe a replacement of ttyprintk ?
The kernel logging here is for debugging purposes -- if the upgrade corrupts the fs and the kernel splats, whoever triages the failure can have at least some clue as to where things went wrong.
I think the _notrun line should go away though.
--D
Quoted 243 lines
Thanks,
ZorroQuoted 238 lines
tests/xfs/769 new file +229
-0+_require_check_dmesg +_require_scratch_nocheck +_require_scratch_xfs_crc + +# Does repair know how to add a particular feature to a filesystem? +check_repair_upgrade() +{ + $XFS_REPAIR_PROG -c "$1=narf" 2>&1 | \ + grep -q 'unknown option' && return 1 + return 0 +} + +# Are we configured for realtime? +rt_configured() +{ + test "$USE_EXTERNAL" = "yes" && test -n "$SCRATCH_RTDEV" +} + +# Compute the MKFS_OPTIONS string for a particular feature upgrade test +compute_mkfs_options() +{ + local m_opts="" + local caller_options="$MKFS_OPTIONS" + + for feat in "${FEATURES[@]}"; do + local feat_state="${FEATURE_STATE["${feat}"]}" + + if echo "$caller_options" | grep -E -w -q "${feat}=[0-9]*"; then + # Change the caller's options + caller_options="$(echo "$caller_options" | \ + sed -e "s/\([^[:alnum:]]\)${feat}=[0-9]*/\1${feat}=${feat_state}/g")" + else + # Add it to our list of new mkfs flags + m_opts="${feat}=${feat_state},${m_opts}" + fi + done + + test -n "$m_opts" && m_opts=" -m $m_opts" + + echo "$caller_options$m_opts" +} + +# Log the start of an upgrade. +function upgrade_start_message() +{ + local feat="$1" + + echo "Add $feat to filesystem" +} + +# Find dmesg log messages since we started a particular upgrade test +function dmesg_since_feature_upgrade_start() +{ + local feat_logmsg="$(upgrade_start_message "$1")" + + # search the dmesg log of last run of $seqnum for possible failures + # use sed \cregexpc address type, since $seqnum contains "/" + dmesg | \ + tac | \ + sed -ne "0,\#run fstests $seqnum at $date_time#p" | \ + sed -ne "0,\#${feat_logmsg}#p" | \ + tac +} + +# Did the mount fail because this feature is not supported? +function feature_unsupported() +{ + local feat="$1" + + dmesg_since_feature_upgrade_start "$feat" | \ + grep -q 'has unknown.*features' +} + +# Exercise the scratch fs +function scratch_fsstress() +{ + echo moo > $SCRATCH_MNT/sample.txt + $FSSTRESS_PROG -n $((TIME_FACTOR * 1000)) -p $((LOAD_FACTOR * 4)) \ + -d $SCRATCH_MNT/data >> $seqres.full +} + +# Exercise the filesystem a little bit and emit a manifest. +function pre_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res before upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + scratch_fsstress + find $SCRATCH_MNT -type f -print0 | xargs -r -0 md5sum > $tmp.manifest + _scratch_unmount + return 0 +} + +# Check the manifest and exercise the filesystem more +function post_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res after upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + md5sum --quiet -c $tmp.manifest || \ + echo "fs contents ^^^ changed after adding $feat" + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after adding $feat" + + # Try to mount the fs in case the check unmounted it + _try_scratch_mount &>> $seqres.full + + scratch_fsstress + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after exercising $feat" + + # Try to unmount the fs in case the check didn't + _scratch_unmount &>> $seqres.full + return 0 +} + +# Create a list of fs features in the order that support for them was added +# to the kernel driver. For each feature upgrade test, we enable all the +# features that came before it and none of the ones after, which means we're +# testing incremental migrations. We start each run with a clean fs so that +# errors and unsatisfied requirements (log size, root ino position, etc) in one +# upgrade don't spread failure to the rest of the tests. +FEATURES=() +if rt_configured; then + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +else + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade rmapbt && FEATURES+=("rmapbt") + check_repair_upgrade reflink && FEATURES+=("reflink") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +fi + +test "${#FEATURES[@]}" -eq 0 && \ + _notrun "xfs_repair does not know how to add V5 features" + +declare -A FEATURE_STATE +for f in "${FEATURES[@]}"; do + FEATURE_STATE["$f"]=0 +done + +for feat in "${FEATURES[@]}"; do + echo "-----------------------" >> $seqres.full + + upgrade_start_message "$feat" | tee -a $seqres.full /dev/ttyprintk > /dev/null + + opts="$(compute_mkfs_options)" + echo "mkfs.xfs $opts" >> $seqres.full + + # Format filesystem + MKFS_OPTIONS="$opts" _scratch_mkfs &>> $seqres.full + res=$? + outcome="mkfs returns $res for $feat upgrade test" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + continue + fi + + # Create some files to make things interesting. + pre_exercise "$feat" || break + + # Upgrade the fs + _scratch_xfs_repair -c "${feat}=1" &> $tmp.upgrade + res=$? + cat $tmp.upgrade >> $seqres.full + grep -q "^Adding" $tmp.upgrade || \ + echo "xfs_repair ignored command to add $feat" + + outcome="xfs_repair returns $res while adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + # Couldn't upgrade filesystem, move on to the next feature. + FEATURE_STATE["$feat"]=1 + continue + fi + + # Make sure repair runs cleanly afterwards + _scratch_xfs_repair -n &>> $seqres.full + res=$? + outcome="xfs_repair -n returns $res after adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + fi + + # Make sure we can still exercise the filesystem. + post_exercise "$feat" || break + + # Update feature state for next run + FEATURE_STATE["$feat"]=1 +done + +# success, all done +echo Silence is golden. +status=0 +exittests/xfs/769.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 769 +Silence is golden.
Re: [PATCH 1/1] xfs: test upgrading old features
Quoted 47 lines · Darrick J. Wong
Quoted 42 lines · Zorro Lang
Quoted 28 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Test the ability to add older v5 features.
Signed-off-by Darrick J. Wong <[email protected]>--- tests/xfs/769 | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/769.out | 2 2 files changed, 250 insertions(+) create mode 100755 tests/xfs/769 create mode 100644 tests/xfs/769.outtests/xfs/769 new file +9
-0@@ -0,0 +1,248 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 769 +# +# Test upgrading filesystems with new features. +# +. ./common/preambletests/xfs/769 line 19
Quoted 10 lines
tests/xfs/769 new file +10
-0+_begin_fstest auto mkfs repair + +# Import common functions. +. ./common/filter +. ./common/populate + +# real QA test starts here +_supported_fs xfs + +test -w /dev/ttyprintk || _notrun "test requires writable /dev/ttyprintk"Hi Darrick,
Quoted 3 lines
I'm not sure why
/dev/ttyprintkis necessary. I think sometimes we might not have this driver, but has/dev/kmsg. Can/dev/kmsgbe a replacement of ttyprintk ?
Quoted 5 lines
The kernel logging here is for debugging purposes -- if the upgrade corrupts the fs and the kernel splats, whoever triages the failure can have at least some clue as to where things went wrong.
I think the
_notrunline should go away though.
If only for debugging, better to let this case keep running without ttyprintk. Or it'll _notrun on many systems without ttyprintk driver.
There's a log_dmesg() helper in common/rc, the /dev/kmsg might be more often. As you've called *_require_check_dmesg*, it helps to check kmsg file. So how about use it? Or making a helper to write messages to ttyprintk, then fallback to kmsg if ttyprintk is missing ?
Thanks,
Zorro
Quoted 247 lines
--D
Quoted 243 lines
Thanks,
ZorroQuoted 238 lines
tests/xfs/769 new file +229
-0+_require_check_dmesg +_require_scratch_nocheck +_require_scratch_xfs_crc + +# Does repair know how to add a particular feature to a filesystem? +check_repair_upgrade() +{ + $XFS_REPAIR_PROG -c "$1=narf" 2>&1 | \ + grep -q 'unknown option' && return 1 + return 0 +} + +# Are we configured for realtime? +rt_configured() +{ + test "$USE_EXTERNAL" = "yes" && test -n "$SCRATCH_RTDEV" +} + +# Compute the MKFS_OPTIONS string for a particular feature upgrade test +compute_mkfs_options() +{ + local m_opts="" + local caller_options="$MKFS_OPTIONS" + + for feat in "${FEATURES[@]}"; do + local feat_state="${FEATURE_STATE["${feat}"]}" + + if echo "$caller_options" | grep -E -w -q "${feat}=[0-9]*"; then + # Change the caller's options + caller_options="$(echo "$caller_options" | \ + sed -e "s/\([^[:alnum:]]\)${feat}=[0-9]*/\1${feat}=${feat_state}/g")" + else + # Add it to our list of new mkfs flags + m_opts="${feat}=${feat_state},${m_opts}" + fi + done + + test -n "$m_opts" && m_opts=" -m $m_opts" + + echo "$caller_options$m_opts" +} + +# Log the start of an upgrade. +function upgrade_start_message() +{ + local feat="$1" + + echo "Add $feat to filesystem" +} + +# Find dmesg log messages since we started a particular upgrade test +function dmesg_since_feature_upgrade_start() +{ + local feat_logmsg="$(upgrade_start_message "$1")" + + # search the dmesg log of last run of $seqnum for possible failures + # use sed \cregexpc address type, since $seqnum contains "/" + dmesg | \ + tac | \ + sed -ne "0,\#run fstests $seqnum at $date_time#p" | \ + sed -ne "0,\#${feat_logmsg}#p" | \ + tac +} + +# Did the mount fail because this feature is not supported? +function feature_unsupported() +{ + local feat="$1" + + dmesg_since_feature_upgrade_start "$feat" | \ + grep -q 'has unknown.*features' +} + +# Exercise the scratch fs +function scratch_fsstress() +{ + echo moo > $SCRATCH_MNT/sample.txt + $FSSTRESS_PROG -n $((TIME_FACTOR * 1000)) -p $((LOAD_FACTOR * 4)) \ + -d $SCRATCH_MNT/data >> $seqres.full +} + +# Exercise the filesystem a little bit and emit a manifest. +function pre_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res before upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + scratch_fsstress + find $SCRATCH_MNT -type f -print0 | xargs -r -0 md5sum > $tmp.manifest + _scratch_unmount + return 0 +} + +# Check the manifest and exercise the filesystem more +function post_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res after upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + md5sum --quiet -c $tmp.manifest || \ + echo "fs contents ^^^ changed after adding $feat" + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after adding $feat" + + # Try to mount the fs in case the check unmounted it + _try_scratch_mount &>> $seqres.full + + scratch_fsstress + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after exercising $feat" + + # Try to unmount the fs in case the check didn't + _scratch_unmount &>> $seqres.full + return 0 +} + +# Create a list of fs features in the order that support for them was added +# to the kernel driver. For each feature upgrade test, we enable all the +# features that came before it and none of the ones after, which means we're +# testing incremental migrations. We start each run with a clean fs so that +# errors and unsatisfied requirements (log size, root ino position, etc) in one +# upgrade don't spread failure to the rest of the tests. +FEATURES=() +if rt_configured; then + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +else + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade rmapbt && FEATURES+=("rmapbt") + check_repair_upgrade reflink && FEATURES+=("reflink") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +fi + +test "${#FEATURES[@]}" -eq 0 && \ + _notrun "xfs_repair does not know how to add V5 features" + +declare -A FEATURE_STATE +for f in "${FEATURES[@]}"; do + FEATURE_STATE["$f"]=0 +done + +for feat in "${FEATURES[@]}"; do + echo "-----------------------" >> $seqres.full + + upgrade_start_message "$feat" | tee -a $seqres.full /dev/ttyprintk > /dev/null + + opts="$(compute_mkfs_options)" + echo "mkfs.xfs $opts" >> $seqres.full + + # Format filesystem + MKFS_OPTIONS="$opts" _scratch_mkfs &>> $seqres.full + res=$? + outcome="mkfs returns $res for $feat upgrade test" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + continue + fi + + # Create some files to make things interesting. + pre_exercise "$feat" || break + + # Upgrade the fs + _scratch_xfs_repair -c "${feat}=1" &> $tmp.upgrade + res=$? + cat $tmp.upgrade >> $seqres.full + grep -q "^Adding" $tmp.upgrade || \ + echo "xfs_repair ignored command to add $feat" + + outcome="xfs_repair returns $res while adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + # Couldn't upgrade filesystem, move on to the next feature. + FEATURE_STATE["$feat"]=1 + continue + fi + + # Make sure repair runs cleanly afterwards + _scratch_xfs_repair -n &>> $seqres.full + res=$? + outcome="xfs_repair -n returns $res after adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + fi + + # Make sure we can still exercise the filesystem. + post_exercise "$feat" || break + + # Update feature state for next run + FEATURE_STATE["$feat"]=1 +done + +# success, all done +echo Silence is golden. +status=0 +exittests/xfs/769.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 769 +Silence is golden.
Re: [PATCH 1/1] xfs: test upgrading old features
Quoted 54 lines · Zorro Lang
Quoted 47 lines · Darrick J. Wong
Quoted 42 lines · Zorro Lang
Quoted 28 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Test the ability to add older v5 features.
Signed-off-by Darrick J. Wong <[email protected]>--- tests/xfs/769 | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/769.out | 2 2 files changed, 250 insertions(+) create mode 100755 tests/xfs/769 create mode 100644 tests/xfs/769.outtests/xfs/769 new file +9
-0@@ -0,0 +1,248 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 769 +# +# Test upgrading filesystems with new features. +# +. ./common/preambletests/xfs/769 line 19
Quoted 10 lines
tests/xfs/769 new file +10
-0+_begin_fstest auto mkfs repair + +# Import common functions. +. ./common/filter +. ./common/populate + +# real QA test starts here +_supported_fs xfs + +test -w /dev/ttyprintk || _notrun "test requires writable /dev/ttyprintk"Hi Darrick,
Quoted 3 lines
I'm not sure why
/dev/ttyprintkis necessary. I think sometimes we might not have this driver, but has/dev/kmsg. Can/dev/kmsgbe a replacement of ttyprintk ?Quoted 5 lines
The kernel logging here is for debugging purposes -- if the upgrade corrupts the fs and the kernel splats, whoever triages the failure can have at least some clue as to where things went wrong.
I think the
_notrunline should go away though.
Quoted 7 lines
If only for debugging, better to let this case keep running without ttyprintk. Or it'll
_notrunon many systems without ttyprintk driver.There's a
log_dmesg()helper in common/rc, the/dev/kmsgmight be more often. As you've called *_require_check_dmesg*, it helps to check kmsg file. So how about use it? Or making a helper to write messages to ttyprintk, then fallback to kmsg if ttyprintk is missing ?
Yeah, I can hoist the ttyprintk usage into a helper that emits to ttyprintk or kmsg depending on what's available.
--D
Quoted 251 lines
Thanks,
ZorroQuoted 247 lines
--D
Quoted 243 lines
Thanks,
ZorroQuoted 238 lines
tests/xfs/769 new file +229
-0+_require_check_dmesg +_require_scratch_nocheck +_require_scratch_xfs_crc + +# Does repair know how to add a particular feature to a filesystem? +check_repair_upgrade() +{ + $XFS_REPAIR_PROG -c "$1=narf" 2>&1 | \ + grep -q 'unknown option' && return 1 + return 0 +} + +# Are we configured for realtime? +rt_configured() +{ + test "$USE_EXTERNAL" = "yes" && test -n "$SCRATCH_RTDEV" +} + +# Compute the MKFS_OPTIONS string for a particular feature upgrade test +compute_mkfs_options() +{ + local m_opts="" + local caller_options="$MKFS_OPTIONS" + + for feat in "${FEATURES[@]}"; do + local feat_state="${FEATURE_STATE["${feat}"]}" + + if echo "$caller_options" | grep -E -w -q "${feat}=[0-9]*"; then + # Change the caller's options + caller_options="$(echo "$caller_options" | \ + sed -e "s/\([^[:alnum:]]\)${feat}=[0-9]*/\1${feat}=${feat_state}/g")" + else + # Add it to our list of new mkfs flags + m_opts="${feat}=${feat_state},${m_opts}" + fi + done + + test -n "$m_opts" && m_opts=" -m $m_opts" + + echo "$caller_options$m_opts" +} + +# Log the start of an upgrade. +function upgrade_start_message() +{ + local feat="$1" + + echo "Add $feat to filesystem" +} + +# Find dmesg log messages since we started a particular upgrade test +function dmesg_since_feature_upgrade_start() +{ + local feat_logmsg="$(upgrade_start_message "$1")" + + # search the dmesg log of last run of $seqnum for possible failures + # use sed \cregexpc address type, since $seqnum contains "/" + dmesg | \ + tac | \ + sed -ne "0,\#run fstests $seqnum at $date_time#p" | \ + sed -ne "0,\#${feat_logmsg}#p" | \ + tac +} + +# Did the mount fail because this feature is not supported? +function feature_unsupported() +{ + local feat="$1" + + dmesg_since_feature_upgrade_start "$feat" | \ + grep -q 'has unknown.*features' +} + +# Exercise the scratch fs +function scratch_fsstress() +{ + echo moo > $SCRATCH_MNT/sample.txt + $FSSTRESS_PROG -n $((TIME_FACTOR * 1000)) -p $((LOAD_FACTOR * 4)) \ + -d $SCRATCH_MNT/data >> $seqres.full +} + +# Exercise the filesystem a little bit and emit a manifest. +function pre_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res before upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + scratch_fsstress + find $SCRATCH_MNT -type f -print0 | xargs -r -0 md5sum > $tmp.manifest + _scratch_unmount + return 0 +} + +# Check the manifest and exercise the filesystem more +function post_exercise() +{ + local feat="$1" + + _try_scratch_mount &> $tmp.mount + res=$? + # If the kernel doesn't support the filesystem even after a + # fresh format, skip the rest of the upgrade test quietly. + if [ $res -eq 32 ] && feature_unsupported "$feat"; then + echo "mount failed due to unsupported feature $feat" >> $seqres.full + return 1 + fi + if [ $res -ne 0 ]; then + cat $tmp.mount + echo "mount failed with $res after upgrading to $feat" | \ + tee -a $seqres.full + return 1 + fi + + md5sum --quiet -c $tmp.manifest || \ + echo "fs contents ^^^ changed after adding $feat" + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after adding $feat" + + # Try to mount the fs in case the check unmounted it + _try_scratch_mount &>> $seqres.full + + scratch_fsstress + + iam="check" _check_scratch_fs || \ + echo "scratch fs check failed after exercising $feat" + + # Try to unmount the fs in case the check didn't + _scratch_unmount &>> $seqres.full + return 0 +} + +# Create a list of fs features in the order that support for them was added +# to the kernel driver. For each feature upgrade test, we enable all the +# features that came before it and none of the ones after, which means we're +# testing incremental migrations. We start each run with a clean fs so that +# errors and unsatisfied requirements (log size, root ino position, etc) in one +# upgrade don't spread failure to the rest of the tests. +FEATURES=() +if rt_configured; then + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +else + check_repair_upgrade finobt && FEATURES+=("finobt") + check_repair_upgrade rmapbt && FEATURES+=("rmapbt") + check_repair_upgrade reflink && FEATURES+=("reflink") + check_repair_upgrade inobtcount && FEATURES+=("inobtcount") + check_repair_upgrade bigtime && FEATURES+=("bigtime") +fi + +test "${#FEATURES[@]}" -eq 0 && \ + _notrun "xfs_repair does not know how to add V5 features" + +declare -A FEATURE_STATE +for f in "${FEATURES[@]}"; do + FEATURE_STATE["$f"]=0 +done + +for feat in "${FEATURES[@]}"; do + echo "-----------------------" >> $seqres.full + + upgrade_start_message "$feat" | tee -a $seqres.full /dev/ttyprintk > /dev/null + + opts="$(compute_mkfs_options)" + echo "mkfs.xfs $opts" >> $seqres.full + + # Format filesystem + MKFS_OPTIONS="$opts" _scratch_mkfs &>> $seqres.full + res=$? + outcome="mkfs returns $res for $feat upgrade test" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + continue + fi + + # Create some files to make things interesting. + pre_exercise "$feat" || break + + # Upgrade the fs + _scratch_xfs_repair -c "${feat}=1" &> $tmp.upgrade + res=$? + cat $tmp.upgrade >> $seqres.full + grep -q "^Adding" $tmp.upgrade || \ + echo "xfs_repair ignored command to add $feat" + + outcome="xfs_repair returns $res while adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + # Couldn't upgrade filesystem, move on to the next feature. + FEATURE_STATE["$feat"]=1 + continue + fi + + # Make sure repair runs cleanly afterwards + _scratch_xfs_repair -n &>> $seqres.full + res=$? + outcome="xfs_repair -n returns $res after adding $feat" + echo "$outcome" >> $seqres.full + if [ $res -ne 0 ]; then + echo "$outcome" + fi + + # Make sure we can still exercise the filesystem. + post_exercise "$feat" || break + + # Update feature state for next run + FEATURE_STATE["$feat"]=1 +done + +# success, all done +echo Silence is golden. +status=0 +exittests/xfs/769.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 769 +Silence is golden.
cover fstests: test XFS metadata directories
In reply to Darrick J. WongHi all,
Adjust fstests as needed to support the XFS metadata directory feature, and add some new tests for online fsck and fuzz testing of the ondisk metadata.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=metadir
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=metadir
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=metadir
xfsdocs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-documentation.git/log/?h=metadir
--- common/filter | 7 +++- common/repair | 4 ++ common/xfs | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++- tests/xfs/007 | 16 +++++---- tests/xfs/030 | 1 + tests/xfs/033 | 1 + tests/xfs/050 | 1 + tests/xfs/122.out | 1 + tests/xfs/153 | 1 + tests/xfs/1546 | 37 +++++++++++++++++++++ tests/xfs/1546.out | 4 ++ tests/xfs/1547 | 37 +++++++++++++++++++++ tests/xfs/1547.out | 4 ++ tests/xfs/1548 | 37 +++++++++++++++++++++ tests/xfs/1548.out | 4 ++ tests/xfs/1549 | 38 ++++++++++++++++++++++ tests/xfs/1549.out | 4 ++ tests/xfs/1550 | 37 +++++++++++++++++++++ tests/xfs/1550.out | 4 ++ tests/xfs/1551 | 37 +++++++++++++++++++++ tests/xfs/1551.out | 4 ++ tests/xfs/1552 | 37 +++++++++++++++++++++ tests/xfs/1552.out | 4 ++ tests/xfs/1553 | 38 ++++++++++++++++++++++ tests/xfs/1553.out | 4 ++ tests/xfs/1562 | 9 +---- tests/xfs/1563 | 9 +---- tests/xfs/1564 | 9 +---- tests/xfs/1565 | 9 +---- tests/xfs/1566 | 9 +---- tests/xfs/1567 | 9 +---- tests/xfs/1568 | 9 +---- tests/xfs/1569 | 9 +---- tests/xfs/178 | 1 + tests/xfs/206 | 3 +- tests/xfs/299 | 1 + tests/xfs/330 | 6 +++ tests/xfs/509 | 21 +++++++++++- tests/xfs/529 | 5 +-- tests/xfs/530 | 6 +-- tests/xfs/769 | 2 + 41 files changed, 491 insertions(+), 78 deletions(-) create mode 100755 tests/xfs/1546 create mode 100644 tests/xfs/1546.out create mode 100755 tests/xfs/1547 create mode 100644 tests/xfs/1547.out create mode 100755 tests/xfs/1548 create mode 100644 tests/xfs/1548.out create mode 100755 tests/xfs/1549 create mode 100644 tests/xfs/1549.out create mode 100755 tests/xfs/1550 create mode 100644 tests/xfs/1550.out create mode 100755 tests/xfs/1551 create mode 100644 tests/xfs/1551.out create mode 100755 tests/xfs/1552 create mode 100644 tests/xfs/1552.out create mode 100755 tests/xfs/1553 create mode 100644 tests/xfs/1553.out
PATCH 1/9 xfs/122: fix metadirino
From: Darrick J. Wong <[email protected]>
Fix xfs/122 to work properly with metadirino.
--- tests/xfs/122.out | 1 + 1 file changed, 1 insertion(+)
tests/xfs/122.out +1 -0
@@ -35,6 +35,7 @@ offsetof(xfs_sb_t, sb_logsunit) = 196 offsetof(xfs_sb_t, sb_lsn) = 240 offsetof(xfs_sb_t, sb_magicnum) = 0 offsetof(xfs_sb_t, sb_meta_uuid) = 248 +offsetof(xfs_sb_t, sb_metadirino) = 264 offsetof(xfs_sb_t, sb_pquotino) = 232 offsetof(xfs_sb_t, sb_qflags) = 176 offsetof(xfs_sb_t, sb_rblocks) = 16
PATCH 2/9 various: fix finding metadata inode numbers when metadir is enabled
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
There are a number of tests that use xfs_db to examine the contents of metadata inodes to check correct functioning. The logic is scattered everywhere and won't work with metadata directory trees, so make a shared helper to find these inodes.
--- common/xfs | 32 ++++++++++++++++++++++++++++++-- tests/xfs/007 | 16 +++++++++------- tests/xfs/1562 | 9 ++------- tests/xfs/1563 | 9 ++------- tests/xfs/1564 | 9 ++------- tests/xfs/1565 | 9 ++------- tests/xfs/1566 | 9 ++------- tests/xfs/1567 | 9 ++------- tests/xfs/1568 | 9 ++------- tests/xfs/1569 | 9 ++------- tests/xfs/529 | 5 ++--- tests/xfs/530 | 6 ++---- 12 files changed, 59 insertions(+), 72 deletions(-)
common/xfs +30 -2
@@ -1396,7 +1396,7 @@ _scratch_get_bmx_prefix() { _scratch_get_iext_count() { - local ino=$1 + local selector=$1 local whichfork=$2 local field=""
@@ -1411,7 +1411,7 @@ _scratch_get_iext_count() return 1 esac - _scratch_xfs_get_metadata_field $field "inode $ino" + _scratch_xfs_get_metadata_field $field "$selector" } #
@@ -1742,3 +1742,31 @@ _require_xfs_scratch_atomicswap() _notrun "atomicswap dependencies not supported by scratch filesystem type: $FSTYP" _scratch_unmount } + +# Find a metadata file within an xfs filesystem. The sole argument is the +# name of the field within the superblock. +_scratch_xfs_find_metafile() +{ + local metafile="$1" + local selector= + + if ! _check_scratch_xfs_features METADIR > /dev/null; then + sb_field="$(_scratch_xfs_get_sb_field "$metafile")" + if echo "$sb_field" | grep -q -w 'not found'; then + return 1 + fi + selector="inode $sb_field" + else + case "${metafile}" in + "rootino") selector="path /";; + "uquotino") selector="path -m /quota/user";; + "gquotino") selector="path -m /quota/group";; + "pquotino") selector="path -m /quota/project";; + "rbmino") selector="path -m /realtime/bitmap";; + "rsumino") selector="path -m /realtime/summary";; + esac + fi + + echo "${selector}" + return 0 +}
tests/xfs/007 +9 -7
@@ -22,6 +22,11 @@ _require_xfs_quota _scratch_mkfs_xfs | _filter_mkfs > /dev/null 2> $tmp.mkfs . $tmp.mkfs +get_qfile_nblocks() { + local selector="$(_scratch_xfs_find_metafile "$1")" + _scratch_xfs_db -c "$selector" -c "p core.nblocks" +} + do_test() { qino_1=$1
@@ -31,12 +36,9 @@ do_test() echo "*** umount" _scratch_unmount - QINO_1=`_scratch_xfs_get_sb_field $qino_1` - QINO_2=`_scratch_xfs_get_sb_field $qino_2` - echo "*** Usage before quotarm ***" - _scratch_xfs_db -c "inode $QINO_1" -c "p core.nblocks" - _scratch_xfs_db -c "inode $QINO_2" -c "p core.nblocks" + get_qfile_nblocks $qino_1 + get_qfile_nblocks $qino_2 _qmount echo "*** turn off $off_opts quotas"
@@ -66,8 +68,8 @@ do_test() _scratch_unmount echo "*** Usage after quotarm ***" - _scratch_xfs_db -c "inode $QINO_1" -c "p core.nblocks" - _scratch_xfs_db -c "inode $QINO_2" -c "p core.nblocks" + get_qfile_nblocks $qino_1 + get_qfile_nblocks $qino_2 } # Test user and group first
tests/xfs/1562 +2 -7
@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.bitmap') -else - path=('sb' 'addr rbmino') -fi -_scratch_xfs_fuzz_metadata '' 'online' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rbmino)" +_scratch_xfs_fuzz_metadata '' 'online' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" # success, all done
tests/xfs/1563 +2 -7
@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.summary') -else - path=('sb' 'addr rsumino') -fi -_scratch_xfs_fuzz_metadata '' 'online' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rsumino)" +_scratch_xfs_fuzz_metadata '' 'online' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" # success, all done
tests/xfs/1564 +2 -7
@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.bitmap') -else - path=('sb' 'addr rbmino') -fi -_scratch_xfs_fuzz_metadata '' 'offline' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rbmino)" +_scratch_xfs_fuzz_metadata '' 'offline' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" # success, all done
tests/xfs/1565 +2 -7
@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.summary') -else - path=('sb' 'addr rsumino') -fi -_scratch_xfs_fuzz_metadata '' 'offline' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rsumino)" +_scratch_xfs_fuzz_metadata '' 'offline' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" # success, all done
tests/xfs/1566 +2 -7
@@ -28,13 +28,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.bitmap') -else - path=('sb' 'addr rbmino') -fi -_scratch_xfs_fuzz_metadata '' 'both' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rbmino)" +_scratch_xfs_fuzz_metadata '' 'both' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" # success, all done
tests/xfs/1567 +2 -7
@@ -28,13 +28,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.summary') -else - path=('sb' 'addr rsumino') -fi -_scratch_xfs_fuzz_metadata '' 'both' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rsumino)" +_scratch_xfs_fuzz_metadata '' 'both' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" # success, all done
tests/xfs/1568 +2 -7
@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.bitmap') -else - path=('sb' 'addr rbmino') -fi -_scratch_xfs_fuzz_metadata '' 'none' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rbmino)" +_scratch_xfs_fuzz_metadata '' 'none' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" # success, all done
tests/xfs/1569 +2 -7
@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.summary') -else - path=('sb' 'addr rsumino') -fi -_scratch_xfs_fuzz_metadata '' 'none' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rsumino)" +_scratch_xfs_fuzz_metadata '' 'none' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" # success, all done
tests/xfs/529 +2 -3
@@ -159,9 +159,8 @@ done _scratch_unmount >> $seqres.full echo "Verify uquota inode's extent count" -uquotino=$(_scratch_xfs_get_metadata_field 'uquotino' 'sb 0') - -nextents=$(_scratch_get_iext_count $uquotino data || \ +selector="$(_scratch_xfs_find_metafile uquotino)" +nextents=$(_scratch_get_iext_count "$selector" data || \ _fail "Unable to obtain inode fork's extent count") if (( $nextents > 10 )); then echo "Extent count overflow check failed: nextents = $nextents"
tests/xfs/530 +2 -4
@@ -104,10 +104,8 @@ _scratch_unmount >> $seqres.full echo "Verify rbmino's and rsumino's extent count" for rtino in rbmino rsumino; do - ino=$(_scratch_xfs_get_metadata_field $rtino "sb 0") - echo "$rtino = $ino" >> $seqres.full - - nextents=$(_scratch_get_iext_count $ino data || \ + selector="$(_scratch_xfs_find_metafile "$rtino")" + nextents=$(_scratch_get_iext_count "$selector" data || \ _fail "Unable to obtain inode fork's extent count") if (( $nextents > 10 )); then echo "Extent count overflow check failed: nextents = $nextents"
Re: [PATCH 2/9] various: fix finding metadata inode numbers when metadir is enabled
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
There are a number of tests that use
xfs_dbto examine the contents of metadata inodes to check correct functioning. The logic is scattered everywhere and won't work with metadata directory trees, so make a shared helper to find these inodes.Signed-off-by Darrick J. Wong <[email protected]>
Quoted 11 lines
--- common/xfs | 32 ++++++++++++++++++++++++++++++-- tests/xfs/007 | 16 +++++++++------- tests/xfs/1562 | 9 ++------- tests/xfs/1563 | 9 ++------- tests/xfs/1564 | 9 ++------- tests/xfs/1565 | 9 ++------- tests/xfs/1566 | 9 ++------- tests/xfs/1567 | 9 ++------- tests/xfs/1568 | 9 ++------- tests/xfs/1569 | 9 ++-------
These case names are temporary names, I've renamed them when I merged them, so this patch need to rebase. Sorry for this trouble :)
Thanks,
Zorro
Quoted 295 lines
tests/xfs/529 | 5 ++--- tests/xfs/530 | 6 ++---- 12 files changed, 59 insertions(+), 72 deletions(-)common/xfs +30
-2@@ -1396,7 +1396,7 @@ _scratch_get_bmx_prefix() { _scratch_get_iext_count() { - local ino=$1 + local selector=$1 local whichfork=$2 local field=""@@ -1411,7 +1411,7 @@ _scratch_get_iext_count() return 1 esac - _scratch_xfs_get_metadata_field $field "inode $ino" + _scratch_xfs_get_metadata_field $field "$selector" } #@@ -1742,3 +1742,31 @@ _require_xfs_scratch_atomicswap() _notrun "atomicswap dependencies not supported by scratch filesystem type: $FSTYP" _scratch_unmount } + +# Find a metadata file within an xfs filesystem. The sole argument is the +# name of the field within the superblock. +_scratch_xfs_find_metafile() +{ + local metafile="$1" + local selector= + + if ! _check_scratch_xfs_features METADIR > /dev/null; then + sb_field="$(_scratch_xfs_get_sb_field "$metafile")" + if echo "$sb_field" | grep -q -w 'not found'; then + return 1 + fi + selector="inode $sb_field" + else + case "${metafile}" in + "rootino") selector="path /";; + "uquotino") selector="path -m /quota/user";; + "gquotino") selector="path -m /quota/group";; + "pquotino") selector="path -m /quota/project";; + "rbmino") selector="path -m /realtime/bitmap";; + "rsumino") selector="path -m /realtime/summary";; + esac + fi + + echo "${selector}" + return 0 +}tests/xfs/007 +9
-7@@ -22,6 +22,11 @@ _require_xfs_quota _scratch_mkfs_xfs | _filter_mkfs > /dev/null 2> $tmp.mkfs . $tmp.mkfs +get_qfile_nblocks() { + local selector="$(_scratch_xfs_find_metafile "$1")" + _scratch_xfs_db -c "$selector" -c "p core.nblocks" +} + do_test() { qino_1=$1@@ -31,12 +36,9 @@ do_test() echo "*** umount" _scratch_unmount - QINO_1=`_scratch_xfs_get_sb_field $qino_1` - QINO_2=`_scratch_xfs_get_sb_field $qino_2` - echo "*** Usage before quotarm ***" - _scratch_xfs_db -c "inode $QINO_1" -c "p core.nblocks" - _scratch_xfs_db -c "inode $QINO_2" -c "p core.nblocks" + get_qfile_nblocks $qino_1 + get_qfile_nblocks $qino_2 _qmount echo "*** turn off $off_opts quotas"@@ -66,8 +68,8 @@ do_test() _scratch_unmount echo "*** Usage after quotarm ***" - _scratch_xfs_db -c "inode $QINO_1" -c "p core.nblocks" - _scratch_xfs_db -c "inode $QINO_2" -c "p core.nblocks" + get_qfile_nblocks $qino_1 + get_qfile_nblocks $qino_2 } # Test user and group firsttests/xfs/1562 +2
-7@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.bitmap') -else - path=('sb' 'addr rbmino') -fi -_scratch_xfs_fuzz_metadata '' 'online' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rbmino)" +_scratch_xfs_fuzz_metadata '' 'online' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" # success, all donetests/xfs/1563 +2
-7@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.summary') -else - path=('sb' 'addr rsumino') -fi -_scratch_xfs_fuzz_metadata '' 'online' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rsumino)" +_scratch_xfs_fuzz_metadata '' 'online' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" # success, all donetests/xfs/1564 +2
-7@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.bitmap') -else - path=('sb' 'addr rbmino') -fi -_scratch_xfs_fuzz_metadata '' 'offline' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rbmino)" +_scratch_xfs_fuzz_metadata '' 'offline' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" # success, all donetests/xfs/1565 +2
-7@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.summary') -else - path=('sb' 'addr rsumino') -fi -_scratch_xfs_fuzz_metadata '' 'offline' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rsumino)" +_scratch_xfs_fuzz_metadata '' 'offline' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" # success, all donetests/xfs/1566 +2
-7@@ -28,13 +28,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.bitmap') -else - path=('sb' 'addr rbmino') -fi -_scratch_xfs_fuzz_metadata '' 'both' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rbmino)" +_scratch_xfs_fuzz_metadata '' 'both' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" # success, all donetests/xfs/1567 +2
-7@@ -28,13 +28,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.summary') -else - path=('sb' 'addr rsumino') -fi -_scratch_xfs_fuzz_metadata '' 'both' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rsumino)" +_scratch_xfs_fuzz_metadata '' 'both' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" # success, all donetests/xfs/1568 +2
-7@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.bitmap') -else - path=('sb' 'addr rbmino') -fi -_scratch_xfs_fuzz_metadata '' 'none' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rbmino)" +_scratch_xfs_fuzz_metadata '' 'none' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" # success, all donetests/xfs/1569 +2
-7@@ -27,13 +27,8 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary') -if [ -n "$is_metadir" ]; then - path=('path -m /realtime/0.summary') -else - path=('sb' 'addr rsumino') -fi -_scratch_xfs_fuzz_metadata '' 'none' "${path[@]}" 'dblock 0' >> $seqres.full +path="$(_scratch_xfs_find_metafile rsumino)" +_scratch_xfs_fuzz_metadata '' 'none' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" # success, all donetests/xfs/529 +2
-3@@ -159,9 +159,8 @@ done _scratch_unmount >> $seqres.full echo "Verify uquota inode's extent count" -uquotino=$(_scratch_xfs_get_metadata_field 'uquotino' 'sb 0') - -nextents=$(_scratch_get_iext_count $uquotino data || \ +selector="$(_scratch_xfs_find_metafile uquotino)" +nextents=$(_scratch_get_iext_count "$selector" data || \ _fail "Unable to obtain inode fork's extent count") if (( $nextents > 10 )); then echo "Extent count overflow check failed: nextents = $nextents"tests/xfs/530 +2
-4@@ -104,10 +104,8 @@ _scratch_unmount >> $seqres.full echo "Verify rbmino's and rsumino's extent count" for rtino in rbmino rsumino; do - ino=$(_scratch_xfs_get_metadata_field $rtino "sb 0") - echo "$rtino = $ino" >> $seqres.full - - nextents=$(_scratch_get_iext_count $ino data || \ + selector="$(_scratch_xfs_find_metafile "$rtino")" + nextents=$(_scratch_get_iext_count "$selector" data || \ _fail "Unable to obtain inode fork's extent count") if (( $nextents > 10 )); then echo "Extent count overflow check failed: nextents = $nextents"
PATCH 3/9 xfs/{030,033,178}: forcibly disable metadata directory trees
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The golden output for thests tests encode the xfs_repair output when we fuzz various parts of the filesystem. With metadata directory trees enabled, however, the golden output changes dramatically to reflect reconstruction of the metadata directory tree.
To avoid regressions, add a helper to force metadata directories off via MKFS_OPTIONS.
--- common/xfs | 13 +++++++++++++ tests/xfs/030 | 1 + tests/xfs/033 | 1 + tests/xfs/178 | 1 + 4 files changed, 16 insertions(+)
common/xfs +13 -0
@@ -1770,3 +1770,16 @@ _scratch_xfs_find_metafile() echo "${selector}" return 0 } + +# Force metadata directories off. +_scratch_xfs_force_no_metadir() +{ + if echo "$MKFS_OPTIONS" | grep -q 'metadir='; then + MKFS_OPTIONS="$(echo "$MKFS_OPTIONS" | sed -e 's/metadir=\([01]\)/metadir=0/g')" + return + fi + + if grep -q 'metadir=' $MKFS_XFS_PROG; then + MKFS_OPTIONS="-m metadir=0 $MKFS_OPTIONS" + fi +}
tests/xfs/030 +1 -0
@@ -50,6 +50,7 @@ _supported_fs xfs _require_scratch _require_no_large_scratch_dev +_scratch_xfs_force_no_metadir DSIZE="-dsize=100m,agcount=6"
tests/xfs/033 +1 -0
@@ -53,6 +53,7 @@ _supported_fs xfs _require_scratch _require_no_large_scratch_dev +_scratch_xfs_force_no_metadir # devzero blows away 512byte blocks, so make 512byte inodes (at least) _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
tests/xfs/178 +1 -0
@@ -45,6 +45,7 @@ _supported_fs xfs # fix filesystem, new mkfs.xfs will be fine. _require_scratch +_scratch_xfs_force_no_metadir _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs test "${PIPESTATUS[0]}" -eq 0 || _fail "mkfs failed!"
PATCH 4/9 common/repair: patch up repair sb inode value complaints
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that we've refactored xfs_repair to be more consistent in how it reports unexpected superblock inode pointer values, we have to fix up the fstests repair filters to emulate the old golden output.
--- common/repair | 4 ++++ 1 file changed, 4 insertions(+)
common/repair +4 -0
@@ -28,6 +28,10 @@ _filter_repair() perl -ne ' # for sb /- agno = / && next; # remove each AG line (variable number) +s/realtime bitmap inode pointer/realtime bitmap ino pointer/; +s/sb realtime bitmap inode value/sb realtime bitmap inode/; +s/realtime summary inode pointer/realtime summary ino pointer/; +s/sb realtime summary inode value/sb realtime summary inode/; s/(pointer to) (\d+)/\1 INO/; # Changed inode output in 5.5.0 s/sb root inode value /sb root inode /;
PATCH 5/9 xfs/206: update for metadata directory support
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Filter 'metadir=' out of the golden output so that metadata directories don't cause this test to regress.
--- tests/xfs/206 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/xfs/206 +2 -1
@@ -64,7 +64,8 @@ mkfs_filter() -e "s/\(sunit=\)\([0-9]* blks,\)/\10 blks,/" \ -e "s/, lazy-count=[0-9]//" \ -e "/.*crc=/d" \ - -e "/^Default configuration/d" + -e "/^Default configuration/d" \ + -e "/metadir=.*/d" } # mkfs slightly smaller than that, small log for speed.
PATCH 6/9 xfs/{050,144,153,299,330}: update quota reports to leave out metadir files
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Remove the metadata directory tree directories from the quota reporting in these tests so that we don't regress the golden output.
--- common/filter | 7 +++++-- common/xfs | 23 +++++++++++++++++++++++ tests/xfs/050 | 1 + tests/xfs/153 | 1 + tests/xfs/299 | 1 + tests/xfs/330 | 6 +++++- 6 files changed, 36 insertions(+), 3 deletions(-)
common/filter +5 -2
@@ -618,11 +618,14 @@ _filter_getcap() # Filter user/group/project id numbers out of quota reports, and standardize # the block counts to use filesystem block size. Callers must set the id and -# bsize variables before calling this function. +# bsize variables before calling this function. The qhidden_rootfiles variable +# (by default zero) is the number of root files to filter out of the inode +# count part of the quota report. _filter_quota_report() { test -n "$id" || echo "id must be set" test -n "$bsize" || echo "block size must be set" + test -n "$qhidden_rootfiles" || qhidden_rootfiles=0 tr -s '[:space:]' | \ perl -npe '
@@ -630,7 +633,7 @@ _filter_quota_report() s/^\#0 \d+ /[ROOT] 0 /g; s/6 days/7 days/g' | perl -npe ' - $val = 0; + $val = '"$qhidden_rootfiles"'; if ($ENV{'LARGE_SCRATCH_DEV'}) { $val = $ENV{'NUM_SPACE_FILES'}; }
common/xfs +23 -0
@@ -1783,3 +1783,26 @@ _scratch_xfs_force_no_metadir() MKFS_OPTIONS="-m metadir=0 $MKFS_OPTIONS" fi } + +# Decide if a mount filesystem has metadata directory trees. +_xfs_mount_has_metadir() { + local mount="$1" + + # spaceman (and its info command) predate metadir + test ! -e "$XFS_SPACEMAN_PROG" && return 1 + $XFS_SPACEMAN_PROG -c "info" "$mount" | grep -q 'metadir=1' +} + +# Compute the number of files in the metadata directory tree. +_xfs_calc_metadir_files() { + local mount="$1" + + if ! _xfs_mount_has_metadir "$mount"; then + echo 0 + return + fi + + local regfiles="$($XFS_IO_PROG -c 'bulkstat' "$mount" | grep '^bs_ino' | wc -l)" + local metafiles="$($XFS_IO_PROG -c 'bulkstat -m' "$mount" 2>&1 | grep '^bs_ino' | wc -l)" + echo $((metafiles - regfiles)) +}
tests/xfs/050 +1 -0
@@ -34,6 +34,7 @@ _require_xfs_quota _scratch_mkfs >/dev/null 2>&1 _scratch_mount bsize=$(_get_file_block_size $SCRATCH_MNT) +qhidden_rootfiles=$(_xfs_calc_metadir_files $SCRATCH_MNT) _scratch_unmount bsoft=$(( 200 * $bsize ))
tests/xfs/153 +1 -0
@@ -39,6 +39,7 @@ _require_test_program "vfs/mount-idmapped" _scratch_mkfs >/dev/null 2>&1 _scratch_mount bsize=$(_get_file_block_size $SCRATCH_MNT) +qhidden_rootfiles=$(_xfs_calc_metadir_files $SCRATCH_MNT) _scratch_unmount bsoft=$(( 200 * $bsize ))
tests/xfs/299 +1 -0
@@ -159,6 +159,7 @@ _qmount_option "uquota,gquota,pquota" _qmount bsize=$(_get_file_block_size $SCRATCH_MNT) +qhidden_rootfiles=$(_xfs_calc_metadir_files $SCRATCH_MNT) bsoft=$(( 100 * $bsize )) bhard=$(( 500 * $bsize ))
tests/xfs/330 +5 -1
@@ -26,7 +26,10 @@ _require_nobody do_repquota() { - repquota $SCRATCH_MNT | grep -E '^(fsgqa|root|nobody)' | sort -r + repquota $SCRATCH_MNT | grep -E '^(fsgqa|root|nobody)' | sort -r | \ + perl -npe ' + $val = '"$qhidden_rootfiles"'; + s/(^root\s+--\s+\S+\s+\S+\s+\S+\s+)(\S+)/$1@{[$2 - $val]}/g' } rm -f "$seqres.full"
@@ -35,6 +38,7 @@ echo "Format and mount" _scratch_mkfs > "$seqres.full" 2>&1 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS" _scratch_mount >> "$seqres.full" 2>&1 +qhidden_rootfiles=$(_xfs_calc_metadir_files $SCRATCH_MNT) quotacheck -u -g $SCRATCH_MNT 2> /dev/null quotaon $SCRATCH_MNT 2> /dev/null
PATCH 7/9 xfs/769: add metadir upgrade to test matrix
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Add metadata directory trees to the features that this test will try to upgrade.
--- tests/xfs/769 | 2 ++ 1 file changed, 2 insertions(+)
tests/xfs/769 +2 -0
@@ -174,12 +174,14 @@ if rt_configured; then check_repair_upgrade finobt && FEATURES+=("finobt") check_repair_upgrade inobtcount && FEATURES+=("inobtcount") check_repair_upgrade bigtime && FEATURES+=("bigtime") + check_repair_upgrade metadir && FEATURES+=("metadir") else check_repair_upgrade finobt && FEATURES+=("finobt") check_repair_upgrade rmapbt && FEATURES+=("rmapbt") check_repair_upgrade reflink && FEATURES+=("reflink") check_repair_upgrade inobtcount && FEATURES+=("inobtcount") check_repair_upgrade bigtime && FEATURES+=("bigtime") + check_repair_upgrade metadir && FEATURES+=("metadir") fi test "${#FEATURES[@]}" -eq 0 && \
PATCH 8/9 xfs/509: adjust inumbers accounting for metadata directories
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The INUMBERS ioctl exports data from the inode btree directly -- the number of inodes it reports is taken from ir_freemask and includes all the files in the metadata directory tree. BULKSTAT, on the other hand, only reports non-metadata files. When metadir is enabled, this will (eventually) cause a discrepancy in the inode counts that is large enough to exceed the tolerances, thereby causing a test failure.
Correct this by counting the files in the metadata directory and subtracting that from the INUMBERS totals.
--- tests/xfs/509 | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
tests/xfs/509 +19 -2
@@ -91,13 +91,13 @@ inumbers_count() bstat_versions | while read v_tag v_flag; do echo -n "inumbers all($v_tag): " nr=$(inumbers_fs $SCRATCH_MNT $v_flag) - _within_tolerance "inumbers" $nr $expect $tolerance -v + _within_tolerance "inumbers" $((nr - METADATA_FILES)) $expect $tolerance -v local agcount=$(_xfs_mount_agcount $SCRATCH_MNT) for batchsize in 71 2 1; do echo -n "inumbers $batchsize($v_tag): " nr=$(inumbers_ag $agcount $batchsize $SCRATCH_MNT $v_flag) - _within_tolerance "inumbers" $nr $expect $tolerance -v + _within_tolerance "inumbers" $((nr - METADATA_FILES)) $expect $tolerance -v done done }
@@ -143,9 +143,26 @@ _supported_fs xfs DIRCOUNT=8 INOCOUNT=$((2048 / DIRCOUNT)) +# Count everything in the metadata directory tree. +count_metadir_files() { + local metadirs=('/realtime' '/quota') + local db_args=('-f') + + for m in "${metadirs[@]}"; do + db_args+=('-c' "ls -m $m") + done + + local ret=$(_scratch_xfs_db "${db_args[@]}" 2>/dev/null | grep regular | wc -l) + test -z "$ret" && ret=0 + echo $ret +} + _scratch_mkfs "-d agcount=$DIRCOUNT" >> $seqres.full 2>&1 || _fail "mkfs failed" _scratch_mount +METADATA_FILES=$(count_metadir_files) +echo "found $METADATA_FILES metadata files" >> $seqres.full + # Figure out if we have v5 bulkstat/inumbers ioctls. has_v5= bs_root_out="$($XFS_IO_PROG -c 'bulkstat_single root' $SCRATCH_MNT 2>>$seqres.full)"
PATCH 9/9 xfs: create fuzz tests for metadata directories
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Create fuzz tests to make sure that all the validation works for metadata directories and subdirectories.
--- common/xfs | 22 ++++++++++++++++++++++ tests/xfs/1546 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/1546.out | 4 ++++ tests/xfs/1547 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/1547.out | 4 ++++ tests/xfs/1548 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/1548.out | 4 ++++ tests/xfs/1549 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1549.out | 4 ++++ tests/xfs/1550 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/1550.out | 4 ++++ tests/xfs/1551 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/1551.out | 4 ++++ tests/xfs/1552 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/1552.out | 4 ++++ tests/xfs/1553 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1553.out | 4 ++++ 17 files changed, 352 insertions(+) create mode 100755 tests/xfs/1546 create mode 100644 tests/xfs/1546.out create mode 100755 tests/xfs/1547 create mode 100644 tests/xfs/1547.out create mode 100755 tests/xfs/1548 create mode 100644 tests/xfs/1548.out create mode 100755 tests/xfs/1549 create mode 100644 tests/xfs/1549.out create mode 100755 tests/xfs/1550 create mode 100644 tests/xfs/1550.out create mode 100755 tests/xfs/1551 create mode 100644 tests/xfs/1551.out create mode 100755 tests/xfs/1552 create mode 100644 tests/xfs/1552.out create mode 100755 tests/xfs/1553 create mode 100644 tests/xfs/1553.out
common/xfs +22 -0
@@ -1806,3 +1806,25 @@ _xfs_calc_metadir_files() { local metafiles="$($XFS_IO_PROG -c 'bulkstat -m' "$mount" 2>&1 | grep '^bs_ino' | wc -l)" echo $((metafiles - regfiles)) } + +_require_xfs_mkfs_metadir() +{ + _scratch_mkfs_xfs_supported -m metadir=1 >/dev/null 2>&1 || \ + _notrun "mkfs.xfs doesn't have metadir features" +} + +_require_xfs_scratch_metadir() +{ + _require_xfs_mkfs_metadir + _require_scratch + + _scratch_mkfs -m metadir=1 &> /dev/null + _require_scratch_xfs_features METADIR + _try_scratch_mount + res=$? + if [ $res -ne 0 ]; then + _notrun "mounting with metadir not supported by filesystem type: $FSTYP" + else + _scratch_unmount + fi +}
tests/xfs/1546 new file +37 -0
@@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1546 +# +# Populate a XFS filesystem and fuzz every metadir root field. +# Use xfs_scrub to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /') + +echo "Fuzz metadir root" +_scratch_xfs_fuzz_metadata '' 'online' 'path -m /' >> $seqres.full +echo "Done fuzzing metadir root" + +# success, all done +status=0 +exit
tests/xfs/1546.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1546 +Format and populate +Fuzz metadir root +Done fuzzing metadir root
tests/xfs/1547 new file +37 -0
@@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1547 +# +# Populate a XFS filesystem and fuzz every metadir root field. +# Use xfs_repair to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /') + +echo "Fuzz metadir root" +_scratch_xfs_fuzz_metadata '' 'offline' 'path -m /' >> $seqres.full +echo "Done fuzzing metadir root" + +# success, all done +status=0 +exit
tests/xfs/1547.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1547 +Format and populate +Fuzz metadir root +Done fuzzing metadir root
tests/xfs/1548 new file +37 -0
@@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1548 +# +# Populate a XFS filesystem and fuzz every metadir root field. +# Do not fix the filesystem, to test metadata verifiers. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_norepair + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /') + +echo "Fuzz metadir root" +_scratch_xfs_fuzz_metadata '' 'none' 'path -m /' >> $seqres.full +echo "Done fuzzing metadir root" + +# success, all done +status=0 +exit
tests/xfs/1548.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1548 +Format and populate +Fuzz metadir root +Done fuzzing metadir root
tests/xfs/1549 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1549 +# +# Populate a XFS filesystem and fuzz every metadir root field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_bothrepair + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /') + +echo "Fuzz metadir root" +_scratch_xfs_fuzz_metadata '' 'both' 'path -m /' >> $seqres.full +echo "Done fuzzing metadir root" + +# success, all done +status=0 +exit
tests/xfs/1549.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1549 +Format and populate +Fuzz metadir root +Done fuzzing metadir root
tests/xfs/1550 new file +37 -0
@@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1550 +# +# Populate a XFS filesystem and fuzz every metadir subdir field. +# Use xfs_scrub to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_scrub dangerous_online_repair + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime') + +echo "Fuzz metadir subdir" +_scratch_xfs_fuzz_metadata '' 'online' 'path -m /realtime' >> $seqres.full +echo "Done fuzzing metadir subdir" + +# success, all done +status=0 +exit
tests/xfs/1550.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1550 +Format and populate +Fuzz metadir subdir +Done fuzzing metadir subdir
tests/xfs/1551 new file +37 -0
@@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1551 +# +# Populate a XFS filesystem and fuzz every metadir subdir field. +# Use xfs_repair to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime') + +echo "Fuzz metadir subdir" +_scratch_xfs_fuzz_metadata '' 'offline' 'path -m /realtime' >> $seqres.full +echo "Done fuzzing metadir subdir" + +# success, all done +status=0 +exit
tests/xfs/1551.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1551 +Format and populate +Fuzz metadir subdir +Done fuzzing metadir subdir
tests/xfs/1552 new file +37 -0
@@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1552 +# +# Populate a XFS filesystem and fuzz every metadir subdir field. +# Do not fix the filesystem, to test metadata verifiers. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_norepair + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime') + +echo "Fuzz metadir subdir" +_scratch_xfs_fuzz_metadata '' 'none' 'path -m /realtime' >> $seqres.full +echo "Done fuzzing metadir subdir" + +# success, all done +status=0 +exit
tests/xfs/1552.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1552 +Format and populate +Fuzz metadir subdir +Done fuzzing metadir subdir
tests/xfs/1553 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1553 +# +# Populate a XFS filesystem and fuzz every metadir subdir field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_bothrepair + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime') + +echo "Fuzz metadir subdir" +_scratch_xfs_fuzz_metadata '' 'both' 'path -m /realtime' >> $seqres.full +echo "Done fuzzing metadir subdir" + +# success, all done +status=0 +exit
tests/xfs/1553.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1553 +Format and populate +Fuzz metadir subdir +Done fuzzing metadir subdir
cover fstests: support metadump to external devices
In reply to Darrick J. WongHi all,
This series modifies fstests to take advantage of the fact that xfs_metadump and xfs_mdrestore now support capturing the contents of an external log in a metadump, and restoring it on the other end. The first part of this series refactors and cleans up the common code a bit, and the rest add the actual support. Once this is merged, we'll be able to cache metadumps of populated filesystems with external log devices, which will enable faster fuzz testing.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=metadump-external-devices
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=metadump-external-devices
--- common/ext4 | 17 ++++++++++++- common/fuzzy | 7 +++++ common/populate | 72 ++++++++++++++++++++++++++++--------------------------- common/xfs | 39 ++++++++++++++++++++++++++++-- 4 files changed, 95 insertions(+), 40 deletions(-)
PATCH 1/4 common/populate: refactor caching of metadumps to a helper
From: Darrick J. Wong <[email protected]>
Hoist out of _scratch_populate_cached all the code that we use to save a metadump of the populated filesystem. We're going to make this more involved for XFS in the next few patches so that we can take advantage of the new support for external devices in metadump/mdrestore.
--- common/populate | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)
common/populate +28 -9
@@ -938,6 +938,31 @@ _scratch_populate_restore_cached() { return 1 } +# Take a metadump of the scratch filesystem and cache it for later. +_scratch_populate_save_metadump() +{ + local metadump_file="$1" + + case "${FSTYP}" in + "xfs") + local logdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + logdev=$SCRATCH_LOGDEV + + _xfs_metadump "$metadump_file" "$SCRATCH_DEV" "$logdev" \ + compress + res=$? + ;; + "ext2"|"ext3"|"ext4") + _ext4_metadump "${SCRATCH_DEV}" "${metadump_file}" compress + res=$? + ;; + *) + _fail "Don't know how to save a ${FSTYP} filesystem." + esac + return $res +} + # Populate a scratch FS from scratch or from a cached image. _scratch_populate_cached() { local meta_descr="$(_scratch_populate_cache_tag "$@")"
@@ -961,26 +986,20 @@ _scratch_populate_cached() { # Oh well, just create one from scratch _scratch_mkfs - echo "${meta_descr}" > "${populate_metadump_descr}" case "${FSTYP}" in "xfs") _scratch_xfs_populate $@ _scratch_xfs_populate_check - - local logdev=none - [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ - logdev=$SCRATCH_LOGDEV - - _xfs_metadump "$POPULATE_METADUMP" "$SCRATCH_DEV" "$logdev" \ - compress ;; "ext2"|"ext3"|"ext4") _scratch_ext4_populate $@ _scratch_ext4_populate_check - _ext4_metadump "${SCRATCH_DEV}" "${POPULATE_METADUMP}" compress ;; *) _fail "Don't know how to populate a ${FSTYP} filesystem." ;; esac + + _scratch_populate_save_metadump "${POPULATE_METADUMP}" && \ + echo "${meta_descr}" > "${populate_metadump_descr}" }
PATCH 2/4 common/xfs: wipe external logs during mdrestore operations
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The XFS metadump file format doesn't support the capture of external log devices, which means that mdrestore ought to wipe the external log and run xfs_repair to rewrite the log device as needed to get the restored filesystem to work again. The common/populate code could already do this, so push it to the common xfs helper.
While we're at it, fix the uncareful usage of SCRATCH_LOGDEV in the populate code.
--- common/fuzzy | 7 ++++++- common/populate | 19 ++++++------------- common/xfs | 21 +++++++++++++++++++-- 3 files changed, 31 insertions(+), 16 deletions(-)
common/fuzzy +6 -1
@@ -297,7 +297,12 @@ __scratch_xfs_fuzz_unmount() __scratch_xfs_fuzz_mdrestore() { __scratch_xfs_fuzz_unmount - _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" || \ + + local logdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + logdev=$SCRATCH_LOGDEV + + _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" "${logdev}" || \ _fail "${POPULATE_METADUMP}: Could not find metadump to restore?" }
common/populate +6 -13
@@ -902,21 +902,14 @@ _scratch_populate_cache_tag() { _scratch_populate_restore_cached() { local metadump="$1" + local logdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + logdev=$SCRATCH_LOGDEV + case "${FSTYP}" in "xfs") - _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" - res=$? - test $res -ne 0 && return $res - - # Cached images should have been unmounted cleanly, so if - # there's an external log we need to wipe it and run repair to - # format it to match this filesystem. - if [ -n "${SCRATCH_LOGDEV}" ]; then - $WIPEFS_PROG -a "${SCRATCH_LOGDEV}" - _scratch_xfs_repair - res=$? - fi - return $res + _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" "${logdev}" + return $? ;; "ext2"|"ext3"|"ext4") _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}"
common/xfs +19 -2
@@ -682,7 +682,8 @@ _xfs_metadump() { _xfs_mdrestore() { local metadump="$1" local device="$2" - shift; shift + local logdev="$3" + shift; shift; shift local options="$@" # If we're configured for compressed dumps and there isn't already an
@@ -696,6 +697,18 @@ _xfs_mdrestore() { test -r "$metadump" || return 1 $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" + res=$? + test $res -ne 0 && return $res + + # Cached images should have been unmounted cleanly, so if there's an + # external log we need to wipe it and run repair to format it to match + # this filesystem. + if [ "${logdev}" != "none" ]; then + $WIPEFS_PROG -a "${logdev}" + _scratch_xfs_repair + res=$? + fi + return $res } # Snapshot the metadata on the scratch device
@@ -717,7 +730,11 @@ _scratch_xfs_mdrestore() local metadump=$1 shift - _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$@" + local logdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + logdev=$SCRATCH_LOGDEV + + _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$logdev" "$@" } # run xfs_check and friends on a FS.
PATCH 3/4 common/ext4: reformat external logs during mdrestore operations
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The e2image file format doesn't support the capture of external log devices, which means that mdrestore ought to reformat the external log to get the restored filesystem to work again. The common/populate code could already do this, so push it to the common ext4 helper.
While we're at it, fix the uncareful usage of SCRATCH_LOGDEV in the populate code.
--- common/ext4 | 17 ++++++++++++++++- common/populate | 16 ++-------------- 2 files changed, 18 insertions(+), 15 deletions(-)
common/ext4 +16 -1
@@ -134,7 +134,8 @@ _ext4_mdrestore() { local metadump="$1" local device="$2" - shift; shift + local logdev="$3" + shift; shift; shift local options="$@" # If we're configured for compressed dumps and there isn't already an
@@ -148,6 +149,20 @@ _ext4_mdrestore() test -r "$metadump" || return 1 $E2IMAGE_PROG $options -r "${metadump}" "${SCRATCH_DEV}" + res=$? + test $res -ne 0 && return $res + + # ext4 cannot e2image external logs, so we have to reformat the log + # device to match the restored fs + if [ "${logdev}" != "none" ]; then + local fsuuid="$($DUMPE2FS_PROG -h "${SCRATCH_DEV}" 2>/dev/null | \ + grep 'Journal UUID:' | \ + sed -e 's/Journal UUID:[[:space:]]*//g')" + $MKFS_EXT4_PROG -O journal_dev "${logdev}" \ + -F -U "${fsuuid}" + res=$? + fi + return $res } # this test requires the ext4 kernel support crc feature on scratch device
common/populate +2 -14
@@ -912,20 +912,8 @@ _scratch_populate_restore_cached() { return $? ;; "ext2"|"ext3"|"ext4") - _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" - ret=$? - test $ret -ne 0 && return $ret - - # ext4 cannot e2image external logs, so we have to reformat - # the scratch device to match the restored fs - if [ -n "${SCRATCH_LOGDEV}" ]; then - local fsuuid="$($DUMPE2FS_PROG -h "${SCRATCH_DEV}" 2>/dev/null | \ - grep 'Journal UUID:' | \ - sed -e 's/Journal UUID:[[:space:]]*//g')" - $MKFS_EXT4_PROG -O journal_dev "${SCRATCH_LOGDEV}" \ - -F -U "${fsuuid}" - fi - return 0 + _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" "${logdev}" + return $? ;; esac return 1
PATCH 4/4 common/xfs: capture external logs during metadump/mdrestore
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
If xfs_metadump supports the -x switch to capture the contents of external log devices and there is an external log device, add the option to the command line to enable preservation.
Similarly, if xfs_mdrestore supports the -l switch and there's an external scratch log, pass the option so that we can restore log contents.
--- common/xfs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
common/xfs +18 -0
@@ -667,9 +667,20 @@ _xfs_metadump() { shift; shift; shift; shift local options="$@" test -z "$options" && options="-a -o" + local metadump_has_dash_x + + # Does metadump support capturing from external devices? + $XFS_METADUMP_PROG --help 2>&1 | grep -q -- '-[a-zA-Z]*[wW]x' && \ + metadump_has_dash_x=1 if [ "$logdev" != "none" ]; then options="$options -l $logdev" + + # Tell metadump to capture the log device + if [ -n "$metadump_has_dash_x" ]; then + options="$options -x" + unset metadump_has_dash_x + fi fi $XFS_METADUMP_PROG $options "$device" "$metadump"
@@ -696,6 +707,13 @@ _xfs_mdrestore() { fi test -r "$metadump" || return 1 + # Does mdrestore support restoring to external log devices? If so, + # restore to it, and do not wipe it afterwards. + if [ "$logdev" != "none" ] && $XFS_MDRESTORE_PROG --help 2>&1 | grep -q -- '-l logdev'; then + options="$options -l $logdev" + logdev="none" + fi + $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" res=$? test $res -ne 0 && return $res
cover xfsprogs: shard the realtime section
In reply to Darrick J. WongHi all,
Right now, the realtime section uses a single pair of metadata inodes to store the free space information. This presents a scalability problem since every thread trying to allocate or free rt extents have to lock these files. It would be very useful if we could begin to tackle these problems by sharding the realtime section, so create the notion of realtime groups, which are similar to allocation groups on the data section.
While we're at it, define a superblock to be stamped into the start of each rt section. This enables utilities such as blkid to identify block devices containing realtime sections, and helpfully avoids the situation where a file extent can cross an rtgroup boundary.
The best advantage for rtgroups will become evident later when we get to adding rmap and reflink to the realtime volume, since the geometry constraints are the same for rt groups and AGs. Hence we can reuse all that code directly.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=realtime-groups
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-groups
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-groups
--- common/fuzzy | 33 +++++++++++++++---- common/populate | 12 ++++++- common/xfs | 83 ++++++++++++++++++++++++++++++++++++++++------- src/punch-alternating.c | 28 +++++++++++++++- tests/xfs/114 | 4 ++ tests/xfs/122 | 2 + tests/xfs/122.out | 8 +++++ tests/xfs/146 | 2 + tests/xfs/185 | 2 + tests/xfs/187 | 3 +- tests/xfs/206 | 3 +- tests/xfs/271 | 3 +- tests/xfs/341 | 4 +- tests/xfs/449 | 6 +++ tests/xfs/556 | 16 ++++++--- tests/xfs/800 | 2 + tests/xfs/840 | 2 + tests/xfs/841 | 2 + 18 files changed, 176 insertions(+), 39 deletions(-)
PATCH 1/12 xfs/122: update for rtgroups
From: Darrick J. Wong <[email protected]>
Add our new metadata for realtime allocation groups to the ondisk checking.
--- tests/xfs/122.out | 5 +++++ 1 file changed, 5 insertions(+)
tests/xfs/122.out +5 -0
@@ -44,6 +44,9 @@ offsetof(xfs_sb_t, sb_rbmino) = 64 offsetof(xfs_sb_t, sb_rextents) = 24 offsetof(xfs_sb_t, sb_rextsize) = 80 offsetof(xfs_sb_t, sb_rextslog) = 125 +offsetof(xfs_sb_t, sb_rgblklog) = 280 +offsetof(xfs_sb_t, sb_rgblocks) = 272 +offsetof(xfs_sb_t, sb_rgcount) = 276 offsetof(xfs_sb_t, sb_rootino) = 56 offsetof(xfs_sb_t, sb_rrmapino) = 264 offsetof(xfs_sb_t, sb_rsumino) = 72
@@ -112,9 +115,11 @@ sizeof(struct xfs_refcount_key) = 4 sizeof(struct xfs_refcount_rec) = 12 sizeof(struct xfs_rmap_key) = 20 sizeof(struct xfs_rmap_rec) = 24 +sizeof(struct xfs_rtgroup_geometry) = 128 sizeof(struct xfs_rtrmap_key) = 24 sizeof(struct xfs_rtrmap_rec) = 32 sizeof(struct xfs_rtrmap_root) = 4 +sizeof(struct xfs_rtsb) = 104 sizeof(struct xfs_rud_log_format) = 16 sizeof(struct xfs_rui_log_format) = 16 sizeof(struct xfs_scrub_metadata) = 64
PATCH 2/12 punch-alternating: detect xfs realtime files with large allocation units
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
For files on the XFS realtime volume, it's possible that the file allocation unit (aka the minimum size we have to punch to deallocate file blocks) could be greater than a single fs block. This utility assumed that it's always possible to punch a single fs block, but for these types of files, all that does is zeroes the page cache. While that's what most *user applications* want, fstests uses punching to fragment file mapping metadata and/or fragment free space, so adapt this test for that purpose by detecting realtime files.
--- src/punch-alternating.c | 28 +++++++++++++++++++++++++++- tests/xfs/114 | 4 ++++ tests/xfs/146 | 2 +- tests/xfs/187 | 3 ++- tests/xfs/341 | 4 ++-- 5 files changed, 36 insertions(+), 5 deletions(-)
src/punch-alternating.c +27 -1
@@ -20,6 +20,28 @@ void usage(char *cmd)exit (1 ); } +/* Compute the file allocation unit size for an XFS file. */ +static int detect_xfs_alloc_unit (int fd) +{ +struct fsxattr fsx; +struct xfs_fsop_geom fsgeom; +int ret; + + ret =ioctl (fd,XFS_IOC_FSGEOMETRY , &fsgeom); +if (ret) +return -1 ; + + ret =ioctl (fd,XFS_IOC_FSGETXATTR , &fsx); +if (ret) +return -1 ; + + ret = fsgeom.blocksize; +if (fsx.fsx_xflags &XFS_XFLAG_REALTIME ) + ret *= fsgeom.rtextsize; + +return ret; +} +int main (int argc,char *argv[]) {struct stat s;
@@ -82,7 +104,11 @@ int main(int argc, char *argv[]) goto err; sz = s.st_size; - blksz = sf.f_bsize; + c =detect_xfs_alloc_unit (fd); +if (c >0 ) + blksz = c; +else + blksz = sf.f_bsize; mode =FALLOC_FL_PUNCH_HOLE |FALLOC_FL_KEEP_SIZE ; for (offset = start_offset * blksz;
tests/xfs/114 +4 -0
@@ -49,6 +49,10 @@ $XFS_IO_PROG -f \ -c "pwrite -S 0x68 -b 1048576 0 $len2" \ $SCRATCH_MNT/f2 >> $seqres.full +# The arguments to punch-alternating must be specified in units of file +# allocation units, so we divide the argument by $file_blksz. We already +# verified that $blksz is congruent with $file_blksz, so the fpunch parameters +# will always align with the file allocation unit. $here/src/punch-alternating -o $((16 * blksz / file_blksz)) \ -s $((blksz / file_blksz)) \ -i $((blksz * 2 / file_blksz)) \
tests/xfs/146 +1 -1
@@ -68,7 +68,7 @@ _xfs_force_bdev realtime $SCRATCH_MNT # Allocate some stuff at the start, to force the first falloc of the ouch file # to happen somewhere in the middle of the rt volume $XFS_IO_PROG -f -c 'falloc 0 64m' "$SCRATCH_MNT/b" -$here/src/punch-alternating -i $((rextblks * 2)) -s $((rextblks)) "$SCRATCH_MNT/b" +$here/src/punch-alternating "$SCRATCH_MNT/b" avail="$(df -P "$SCRATCH_MNT" | awk 'END {print $4}')"1 toobig="$((avail * 2))"
tests/xfs/187 +2 -1
@@ -132,7 +132,8 @@ $XFS_IO_PROG -f -c "truncate $required_sz" -c "falloc 0 $remap_sz" $SCRATCH_MNT/ # Punch out every other extent of the last two sections, to fragment free space. frag_sz=$((remap_sz * 3)) punch_off=$((bigfile_sz - frag_sz)) -$here/src/punch-alternating $SCRATCH_MNT/bigfile -o $((punch_off / fsbsize)) -i $((rtextsize_blks * 2)) -s $rtextsize_blks +rtextsize_bytes=$((fsbsize * rtextsize_blks)) +$here/src/punch-alternating $SCRATCH_MNT/bigfile -o $((punch_off / rtextsize_bytes)) # Make sure we have some free rtextents. free_rtx=$($XFS_IO_PROG -c 'statfs' $SCRATCH_MNT | grep statfs.f_bavail | awk '{print $3}')
tests/xfs/341 +2 -2
@@ -43,8 +43,8 @@ len=$((blocks * rtextsz)) echo "Create some files" $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full -$here/src/punch-alternating -i $((2 * rtextsz_blks)) -s $rtextsz_blks $SCRATCH_MNT/f1 >> "$seqres.full" -$here/src/punch-alternating -i $((2 * rtextsz_blks)) -s $rtextsz_blks $SCRATCH_MNT/f2 >> "$seqres.full" +$here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full" +$here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full" echo garbage > $SCRATCH_MNT/f3 ino=$(stat -c '%i' $SCRATCH_MNT/f3) _scratch_unmount
PATCH 3/12 xfs/206: update mkfs filtering for rt groups feature
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Filter out the new mkfs lines that show the rtgroup information, since this test is heavily dependent on old mkfs output.
--- tests/xfs/206 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/xfs/206 +2 -1
@@ -65,7 +65,8 @@ mkfs_filter() -e "s/, lazy-count=[0-9]//" \ -e "/.*crc=/d" \ -e "/^Default configuration/d" \ - -e "/metadir=.*/d" + -e "/metadir=.*/d" \ + -e '/rgcount=/d' } # mkfs slightly smaller than that, small log for speed.
PATCH 4/12 common: pass the realtime device to xfs_db when possible
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Teach xfstests to pass the realtime device to xfs_db when it supports that option.
--- common/xfs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
common/xfs +15 -3
@@ -281,10 +281,10 @@ _xfs_check() { OPTS=" " DBOPTS=" " - USAGE="Usage: xfs_check [-fsvV] [-l logdev] [-i ino]... [-b bno]... special" + USAGE="Usage: xfs_check [-fsvV] [-l logdev] [-R rtdev] [-i ino]... [-b bno]... special" OPTIND=1 - while getopts "b:fi:l:stvV" c; do + while getopts "b:fi:l:stvVR:" c; do case $c in s) OPTS=$OPTS"-s ";; t) OPTS=$OPTS"-t ";;
@@ -296,12 +296,14 @@ _xfs_check() V) $XFS_DB_PROG -p xfs_check -V return $? ;; + R) DBOPTS="$DBOPTS -R $OPTARG";; esac done set -- extra $@ shift $OPTIND case $# in - 1) ${XFS_DB_PROG}${DBOPTS} -F -i -p xfs_check -c "check$OPTS" $1 + 1) echo "${XFS_DB_PROG}${DBOPTS} -F -i -p xfs_check -c check$OPTS $1" >> /dev/ttyprintk + ${XFS_DB_PROG}${DBOPTS} -F -i -p xfs_check -c "check$OPTS" $1 status=$? ;; 2) echo $USAGE 1>&1
@@ -339,6 +341,11 @@ _scratch_xfs_db_options() SCRATCH_OPTIONS="" [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV" + if [ "$USE_EXTERNAL" = yes ] && [ ! -z "$SCRATCH_RTDEV" ]; then + $XFS_DB_PROG --help 2>&1 | grep -q -- '-R rtdev' || \ + _notrun 'xfs_db does not support rt devices' + SCRATCH_OPTIONS="$SCRATCH_OPTIONS -R$SCRATCH_RTDEV" + fi echo $SCRATCH_OPTIONS $* $SCRATCH_DEV }
@@ -403,6 +410,11 @@ _scratch_xfs_check() SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV" [ "$LARGE_SCRATCH_DEV" = yes ] && \ SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t" + if [ "$USE_EXTERNAL" = yes ] && [ ! -z "$SCRATCH_RTDEV" ]; then + $XFS_DB_PROG --help 2>&1 | grep -q -- '-R rtdev' || \ + _notrun 'xfs_db does not support rt devices' + SCRATCH_OPTIONS="$SCRATCH_OPTIONS -R$SCRATCH_RTDEV" + fi _xfs_check $SCRATCH_OPTIONS $* $SCRATCH_DEV }
PATCH 5/12 common: filter rtgroups when we're disabling metadir
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
If we're forcing a filesystem to be created without the metadir feature, we should forcibly disable rtgroups as well.
--- common/xfs | 4 ++++ 1 file changed, 4 insertions(+)
common/xfs +4 -0
@@ -1821,6 +1821,10 @@ _scratch_xfs_find_metafile() # Force metadata directories off. _scratch_xfs_force_no_metadir() { + if echo "$MKFS_OPTIONS" | grep -q 'rtgroups='; then + MKFS_OPTIONS="$(echo "$MKFS_OPTIONS" | sed -e 's/rtgroups=\([01]\)/rtgroups=0/g')" + fi + if echo "$MKFS_OPTIONS" | grep -q 'metadir='; then MKFS_OPTIONS="$(echo "$MKFS_OPTIONS" | sed -e 's/metadir=\([01]\)/metadir=0/g')" return
PATCH 6/12 xfs/185: update for rtgroups
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Send the fallocate results to seqres.full, since it doesn't matter if the call fails as long as we get the layout that we wanted. This test already has code to check the layout, so there's no point in failing on random ENOSPC errors.
--- tests/xfs/185 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/xfs/185 +1 -1
@@ -100,7 +100,7 @@ test "$ddbytes" -lt "$((rtbytes + (10 * rtextsize) ))" || \ # easy because fallocate for the first rt file always starts allocating at # physical offset zero. alloc_rtx="$((rtbytes / rtextsize))" -$XFS_IO_PROG -c "falloc 0 $((alloc_rtx * rtextsize))" $rtfile +$XFS_IO_PROG -c "falloc 0 $((alloc_rtx * rtextsize))" $rtfile &>> $seqres.full expected_end="$(( (alloc_rtx * rtextsize - 1) / 512 ))"
PATCH 7/12 xfs/449: update test to know about xfs_db -R
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The realtime groups feature added a -R flag to xfs_db so that users can pass in the realtime device. Since we've now modified the _scratch_xfs_db to use this facility, we can update the test to do exact comparisons of the xfs_db info command against the mkfs output.
--- tests/xfs/449 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tests/xfs/449 +5 -1
@@ -32,7 +32,11 @@ echo DB >> $seqres.full cat $tmp.dbinfo >> $seqres.full # xfs_db doesn't take a rtdev argument, so it reports "realtime=external". # mkfs does, so make a quick substitution -diff -u <(cat $tmp.mkfs | sed -e 's/realtime =\/.*extsz=/realtime =external extsz=/g') $tmp.dbinfo +if $XFS_DB_PROG --help 2>&1 | grep -q -- '-R rtdev'; then + diff -u $tmp.mkfs $tmp.dbinfo +else + diff -u <(cat $tmp.mkfs | sed -e 's/realtime =\/.*extsz=/realtime =external extsz=/g') $tmp.dbinfo +fi _scratch_mount
PATCH 8/12 xfs/122: update for rtbitmap headers
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
--- tests/xfs/122.out | 1 + 1 file changed, 1 insertion(+)
tests/xfs/122.out +1 -0
@@ -115,6 +115,7 @@ sizeof(struct xfs_refcount_key) = 4 sizeof(struct xfs_refcount_rec) = 12 sizeof(struct xfs_rmap_key) = 20 sizeof(struct xfs_rmap_rec) = 24 +sizeof(struct xfs_rtbuf_blkinfo) = 48 sizeof(struct xfs_rtgroup_geometry) = 128 sizeof(struct xfs_rtrmap_key) = 24 sizeof(struct xfs_rtrmap_rec) = 32
PATCH 9/12 xfs/122: udpate test to pick up rtword/suminfo ondisk unions
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Update this test to check that the ondisk unions for rt bitmap word and rt summary counts are always the correct size.
--- tests/xfs/122 | 2 +- tests/xfs/122.out | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
tests/xfs/122 +1 -1
@@ -187,7 +187,7 @@ echo 'int main(int argc, char *argv[]) {' >>$cprog # cat /usr/include/xfs/xfs*.h | indent |\ _attribute_filter |\ -grep -E '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' |\ +grep -E '(} *xfs_.*_t|^(union|struct) xfs_[a-z0-9_]*$)' |\ grep -E -v -f $tmp.ignore |\ sed -e 's/^.*}[[:space:]]*//g' -e 's/;.*$//g' -e 's/_t, /_t\n/g' |\ sort | uniq |\
tests/xfs/122.out +2 -0
@@ -128,6 +128,8 @@ sizeof(struct xfs_swap_extent) = 64 sizeof(struct xfs_sxd_log_format) = 16 sizeof(struct xfs_sxi_log_format) = 80 sizeof(struct xfs_unmount_log_format) = 8 +sizeof(union xfs_rtword_ondisk) = 4 +sizeof(union xfs_suminfo_ondisk) = 4 sizeof(xfs_agf_t) = 224 sizeof(xfs_agfl_t) = 36 sizeof(xfs_agi_t) = 344
PATCH 10/12 xfs/27[46],xfs/556: fix tests to deal with rtgroups output in bmap/fsmap commands
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Fix these tests to deal with the xfs_io bmap and fsmap commands printing out realtime group numbers if the feature is enabled.
--- common/xfs | 4 ++++ tests/xfs/271 | 3 ++- tests/xfs/556 | 16 ++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-)
common/xfs +4 -0
@@ -486,6 +486,10 @@ _xfs_has_feature() feat="rtextents" feat_regex="[1-9][0-9]*" ;; + "rtgroups") + feat="rgcount" + feat_regex="[1-9][0-9]*" + ;; esac local answer="$($XFS_INFO_PROG "$fs" 2>&1 | grep -E -w -c "$feat=$feat_regex")"
tests/xfs/271 +2 -1
@@ -31,6 +31,7 @@ _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount agcount=$(_xfs_mount_agcount $SCRATCH_MNT) +rgcount=$(_xfs_mount_rgcount $SCRATCH_MNT) # mkfs lays out btree root blocks in the order bnobt, cntbt, inobt, finobt, # rmapbt, refcountbt, and then allocates AGFL blocks. Since GETFSMAP has the
@@ -48,7 +49,7 @@ cat $TEST_DIR/fsmap >> $seqres.full echo "Check AG header" | tee -a $seqres.full grep 'static fs metadata[[:space:]]*[0-9]*[[:space:]]*(0\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout -_within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $agcount 0 -v +_within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $((agcount + rgcount)) 0 -v echo "Check freesp/rmap btrees" | tee -a $seqres.full grep 'per-AG metadata[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
tests/xfs/556 +10 -6
@@ -47,16 +47,20 @@ victim=$SCRATCH_MNT/a file_blksz=$(_get_file_block_size $SCRATCH_MNT) $XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((4 * file_blksz))" -c "fsync" $victim >> $seqres.full unset errordev -_xfs_is_realtime_file $victim && errordev="RT" + +awk_len_prog='{print $6}' +if _xfs_is_realtime_file $victim; then + if ! _xfs_has_feature $SCRATCH_MNT rtgroups; then + awk_len_prog='{print $4}' + fi + errordev="RT" +fi bmap_str="$($XFS_IO_PROG -c "bmap -elpv" $victim | grep "^[[:space:]]*0:")" echo "$errordev:$bmap_str" >> $seqres.full phys="$(echo "$bmap_str" | $AWK_PROG '{print $3}')" -if [ "$errordev" = "RT" ]; then - len="$(echo "$bmap_str" | $AWK_PROG '{print $4}')" -else - len="$(echo "$bmap_str" | $AWK_PROG '{print $6}')" -fi +len="$(echo "$bmap_str" | $AWK_PROG "$awk_len_prog")" + fs_blksz=$(_get_block_size $SCRATCH_MNT) echo "file_blksz:$file_blksz:fs_blksz:$fs_blksz" >> $seqres.full kernel_sectors_per_fs_block=$((fs_blksz / 512))
PATCH 11/12 common/xfs: capture realtime devices during metadump/mdrestore
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
If xfs_metadump supports the -x and -R switches to capture the contents of realtime devices and there is a realtime device, add the option to the command line to enable preservation.
Similarly, if xfs_mdrestore supports the -R switch and there's an external scratch rtdev, pass the option so that we can restore rtdev contents.
--- common/fuzzy | 6 +++++- common/populate | 12 ++++++++++-- common/xfs | 48 +++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 54 insertions(+), 12 deletions(-)
common/fuzzy +5 -1
@@ -302,7 +302,11 @@ __scratch_xfs_fuzz_mdrestore() [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ logdev=$SCRATCH_LOGDEV - _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" "${logdev}" || \ + local rtdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \ + rtdev=$SCRATCH_RTDEV + + _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" "${logdev}" "${rtdev}" || \ _fail "${POPULATE_METADUMP}: Could not find metadump to restore?" }
common/populate +10 -2
@@ -908,7 +908,11 @@ _scratch_populate_restore_cached() { case "${FSTYP}" in "xfs") - _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" "${logdev}" + local rtdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \ + rtdev=$SCRATCH_RTDEV + + _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" "${logdev}" "${rtdev}" return $? ;; "ext2"|"ext3"|"ext4")
@@ -930,8 +934,12 @@ _scratch_populate_save_metadump() [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ logdev=$SCRATCH_LOGDEV + local rtdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \ + rtdev=$SCRATCH_RTDEV + _xfs_metadump "$metadump_file" "$SCRATCH_DEV" "$logdev" \ - compress + "$rtdev" compress res=$? ;; "ext2"|"ext3"|"ext4")
common/xfs +39 -9
113 lines not on this page · raw message
PATCH 12/12 common/fuzzy: adapt the scrub stress tests to support rtgroups
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Adapt the scrub stress testing framework to support checking realtime group metadata.
--- common/fuzzy | 27 ++++++++++++++++++++++----- common/xfs | 9 +++++++++ tests/xfs/800 | 2 +- tests/xfs/840 | 2 +- tests/xfs/841 | 2 +- 5 files changed, 34 insertions(+), 8 deletions(-)
common/fuzzy +22 -5
@@ -817,8 +817,10 @@ __stress_one_scrub_loop() { local scrub_tgt="$3" local scrub_startat="$4" local start_agno="$5" - shift; shift; shift; shift; shift + local start_rgno="$6" + shift; shift; shift; shift; shift; shift local agcount="$(_xfs_mount_agcount $SCRATCH_MNT)" + local rgcount="$(_xfs_mount_rgcount $SCRATCH_MNT)" local xfs_io_args=() for arg in "$@"; do
@@ -831,6 +833,12 @@ __stress_one_scrub_loop() { local ag_arg="$(echo "$arg" | sed -e "s|%agno%|$agno|g")" xfs_io_args+=('-c' "$ag_arg") done + elif echo "$arg" | grep -q -w '%rgno%'; then + # Substitute the rtgroup number + for ((rgno = start_rgno; rgno < rgcount; rgno++)); do + local rg_arg="$(echo "$arg" | sed -e "s|%rgno%|$rgno|g")" + xfs_io_args+=('-c' "$rg_arg") + done else xfs_io_args+=('-c' "$arg") fi
@@ -1201,7 +1209,9 @@ _scratch_xfs_stress_scrub_cleanup() { __stress_scrub_check_commands() { local scrub_tgt="$1" local start_agno="$2" - shift; shift + local start_rgno="$3" + shift; shift; shift + local rgcount="$(_xfs_mount_rgcount $SCRATCH_MNT)" local cooked_tgt="$scrub_tgt" case "$scrub_tgt" in
@@ -1231,6 +1241,10 @@ __stress_scrub_check_commands() { cooked_arg="$(echo "$cooked_arg" | sed -e 's/^repair/repair -R/g')" fi cooked_arg="$(echo "$cooked_arg" | sed -e "s/%agno%/$start_agno/g")" + if echo "$cooked_arg" | grep -q -w '%rgno%'; then + test "$rgcount" -eq 0 && continue + cooked_arg="$(echo "$cooked_arg" | sed -e "s/%rgno%/$start_rgno/g")" + fi testio=`$XFS_IO_PROG -x -c "$cooked_arg" "$cooked_tgt" 2>&1` echo $testio | grep -q "Unknown type" && \ _notrun "xfs_io scrub subcommand support is missing"
@@ -1256,6 +1270,7 @@ __stress_scrub_check_commands() { # in a separate loop. If zero -i options are specified, do not run. # Callers must check each of these commands (via _require_xfs_io_command) # before calling here. +# -R For %rgno% substitution, start with this rtgroup instead of rtgroup 0. # -r Run fsstress for this amount of time, then remount the fs ro or rw. # The default is to run fsstress continuously with no remount, unless # XFS_SCRUB_STRESS_REMOUNT_PERIOD is set.
@@ -1301,6 +1316,7 @@ _scratch_xfs_stress_scrub() { local remount_period="${XFS_SCRUB_STRESS_REMOUNT_PERIOD}" local stress_tgt="${XFS_SCRUB_STRESS_TARGET:-default}" local start_agno=0 + local start_rgno=0 __SCRUB_STRESS_FREEZE_PID="" __SCRUB_STRESS_REMOUNT_LOOP=""
@@ -1308,12 +1324,13 @@ _scratch_xfs_stress_scrub() { touch "$runningfile" OPTIND=1 - while getopts "a:fi:r:s:S:t:w:x:X:" c; do + while getopts "a:fi:r:R:s:S:t:w:x:X:" c; do case "$c" in a) start_agno="$OPTARG";; f) freeze=yes;; i) io_args+=("$OPTARG");; r) remount_period="$OPTARG";; + R) start_rgno="$OPTARG";; s) one_scrub_args+=("$OPTARG");; S) xfs_scrub_args+=("$OPTARG");; t) scrub_tgt="$OPTARG";;
@@ -1324,7 +1341,7 @@ _scratch_xfs_stress_scrub() { esac done - __stress_scrub_check_commands "$scrub_tgt" "$start_agno" \ + __stress_scrub_check_commands "$scrub_tgt" "$start_agno" "$start_rgno" \ "${one_scrub_args[@]}" if ! command -v "__stress_scrub_${exerciser}_loop" &>/dev/null; then
@@ -1372,7 +1389,7 @@ _scratch_xfs_stress_scrub() { if [ "${#one_scrub_args[@]}" -gt 0 ]; then __stress_one_scrub_loop "$end" "$runningfile" "$scrub_tgt" \ - "$scrub_startat" "$start_agno" \ + "$scrub_startat" "$start_agno" "$start_rgno" \ "${one_scrub_args[@]}" & fi
common/xfs +9 -0
@@ -1524,6 +1524,15 @@ _xfs_mount_agcount() $XFS_INFO_PROG "$1" | sed -n "s/^.*agcount=\([[:digit:]]*\).*/\1/p" } +# Find rtgroup count of mounted filesystem +_xfs_mount_rgcount() +{ + local rtgroups="$($XFS_INFO_PROG "$1" | grep rgcount= | sed -e 's/^.*rgcount=\([0-9]*\).*$/\1/g')" + + test -z "$rtgroups" && rtgroups=0 + echo "$rtgroups" +} + # Wipe the superblock of each XFS AGs _try_wipe_scratch_xfs() {
tests/xfs/800 +1 -1
@@ -32,7 +32,7 @@ _require_xfs_stress_scrub _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount _require_xfs_has_feature "$SCRATCH_MNT" realtime -_scratch_xfs_stress_scrub -s "scrub rtbitmap" +_scratch_xfs_stress_scrub -s "scrub rtbitmap" -s "scrub rgbitmap %rgno%" # success, all done echo Silence is golden
tests/xfs/840 +1 -1
@@ -39,7 +39,7 @@ alloc_unit=$(_get_file_block_size $SCRATCH_MNT) scratchfile=$SCRATCH_MNT/file touch $scratchfile $XFS_IO_PROG -x -c 'inject force_repair' $SCRATCH_MNT -__stress_scrub_check_commands "$scratchfile" "" 'repair bmapbtd' +__stress_scrub_check_commands "$scratchfile" "" "" 'repair bmapbtd' # Compute the number of extent records needed to guarantee btree format, # assuming 16 bytes for each ondisk extent record
tests/xfs/841 +1 -1
@@ -39,7 +39,7 @@ scratchfile=$SCRATCH_MNT/file mkdir $scratchdir touch $scratchfile $XFS_IO_PROG -x -c 'inject force_repair' $SCRATCH_MNT -__stress_scrub_check_commands "$scratchdir" "" 'repair directory' +__stress_scrub_check_commands "$scratchdir" "" "" 'repair directory' # Create a 2-dirblock directory total_size=$((alloc_unit * 2))
cover fstests: fixes for realtime rmap
In reply to Darrick J. WongHi all,
Fix a few regressions in fstests when rmap is enabled on the realtime volume.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=realtime-rmap
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-rmap
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-rmap
xfsdocs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-documentation.git/log/?h=realtime-rmap
--- common/populate | 36 +++++++++++++++++++++++++++++++++++- common/xfs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/104 | 1 + tests/xfs/122.out | 5 ++--- tests/xfs/1528 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/1528.out | 4 ++++ tests/xfs/1529 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1529.out | 4 ++++ tests/xfs/272 | 2 +- tests/xfs/276 | 2 +- tests/xfs/277 | 2 +- tests/xfs/291 | 3 ++- tests/xfs/332 | 6 +----- tests/xfs/332.out | 2 -- tests/xfs/333 | 45 --------------------------------------------- tests/xfs/333.out | 6 ------ tests/xfs/337 | 2 +- tests/xfs/338 | 21 ++++++++++++++++----- tests/xfs/339 | 5 +++-- tests/xfs/340 | 15 ++++++++++----- tests/xfs/341 | 12 ++++-------- tests/xfs/341.out | 1 - tests/xfs/342 | 4 ++-- tests/xfs/343 | 2 ++ tests/xfs/406 | 6 ++++-- tests/xfs/407 | 6 ++++-- tests/xfs/408 | 7 +++++-- tests/xfs/409 | 7 +++++-- tests/xfs/443 | 9 +++++---- tests/xfs/481 | 6 ++++-- tests/xfs/482 | 7 +++++-- tests/xfs/769 | 29 ++++++++++++++++++++++++++++- tests/xfs/781 | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/781.out | 2 ++ tests/xfs/817 | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/817.out | 2 ++ tests/xfs/821 | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/821.out | 2 ++ 38 files changed, 414 insertions(+), 107 deletions(-) create mode 100755 tests/xfs/1528 create mode 100644 tests/xfs/1528.out create mode 100755 tests/xfs/1529 create mode 100644 tests/xfs/1529.out delete mode 100755 tests/xfs/333 delete mode 100644 tests/xfs/333.out create mode 100755 tests/xfs/781 create mode 100644 tests/xfs/781.out create mode 100755 tests/xfs/817 create mode 100644 tests/xfs/817.out create mode 100755 tests/xfs/821 create mode 100644 tests/xfs/821.out
PATCH 1/13 xfs: fix tests that try to access the realtime rmap inode
From: Darrick J. Wong <[email protected]>
The realtime rmap tests were added to fstests a long time ago. Since they were added, we decided to create a metadata file directory structure instead of adding more fields to the superblock. Therefore, fix all the tests that try to access these paths.
While we're at it, fix xfs/409 to run the *online* scrub program like it's supposed to. xfs/408 is the fuzzer for xfs_repair testing.
--- common/xfs | 18 ++++++++++++++++++ tests/xfs/122.out | 1 - tests/xfs/333 | 45 --------------------------------------------- tests/xfs/333.out | 6 ------ tests/xfs/337 | 2 +- tests/xfs/338 | 21 ++++++++++++++++----- tests/xfs/339 | 5 +++-- tests/xfs/340 | 15 ++++++++++----- tests/xfs/341 | 2 +- tests/xfs/342 | 4 ++-- 10 files changed, 51 insertions(+), 68 deletions(-) delete mode 100755 tests/xfs/333 delete mode 100644 tests/xfs/333.out
common/xfs +18 -0
@@ -1922,3 +1922,21 @@ _require_xfs_scratch_metadir() _scratch_unmount fi } + +# Resolve a metadata directory tree path and return the inode number. +_scratch_metadir_lookup() { + local res="$(_scratch_xfs_db -c "ls -i -m $1")" + test "${PIPESTATUS[0]}" -eq 0 && echo "$res" +} + +# Figure out which directory entry we have to change to update the rtrmap +# inode pointer. Assumes the /realtime directory is a short format dir. +_scratch_find_rt_metadir_entry() { + local sfkey="$(_scratch_xfs_db -c 'path -m /realtime' -c print | \ + grep "\"$1\"" | \ + sed -e 's/.name.*$//g' -e 's/\[/\\[/g' -e 's/\]/\\]/g' )" + test -n "$sfkey" || return 1 + _scratch_xfs_db -c 'path -m /realtime' -c print | \ + grep "${sfkey}.inumber" | awk '{print $1}' + return 0 +}
tests/xfs/122.out +0 -1
@@ -48,7 +48,6 @@ offsetof(xfs_sb_t, sb_rgblklog) = 280 offsetof(xfs_sb_t, sb_rgblocks) = 272 offsetof(xfs_sb_t, sb_rgcount) = 276 offsetof(xfs_sb_t, sb_rootino) = 56 -offsetof(xfs_sb_t, sb_rrmapino) = 264 offsetof(xfs_sb_t, sb_rsumino) = 72 offsetof(xfs_sb_t, sb_sectlog) = 121 offsetof(xfs_sb_t, sb_sectsize) = 102
tests/xfs/333 deleted +0 -45
45 lines not on this page · raw message
tests/xfs/333.out deleted +0 -6
@@ -1,6 +0,0 @@ -QA output created by 333 -Format and mount -Create some files -Corrupt fs -mount: Structure needs cleaning -Test done, mount should have failed
tests/xfs/337 +1 -1
@@ -53,7 +53,7 @@ echo "+ check fs" _scratch_xfs_repair -n >> $seqres.full 2>&1 || echo "xfs_repair should not fail" echo "+ corrupt image" -_scratch_xfs_db -x -c "sb" -c "addr rrmapino" -c "addr u3.rtrmapbt.ptrs[1]" \ +_scratch_xfs_db -x -c "path -m /realtime/0.rmap" -c "addr u3.rtrmapbt.ptrs[1]" \ -c "stack" -c "blocktrash -x 4096 -y 4096 -n 8 -3 -z" \ >> $seqres.full 2>&1
tests/xfs/338 +16 -5
@@ -29,13 +29,24 @@ $XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f2 >> $seqres.full _scratch_unmount echo "Corrupt fs" -_scratch_xfs_db -x -c 'sb 0' -c 'addr rrmapino' \ - -c 'write core.nlinkv2 0' -c 'write core.mode 0' -c 'sb 0' \ - -c 'write rrmapino 0' >> $seqres.full -_try_scratch_mount >> $seqres.full 2>&1 && echo "mount should have failed" +rtrmap_sfentry="$(_scratch_find_rt_metadir_entry 0.rmap)" +test -n "$rtrmap_sfentry" || _fail "Could not find rtrmap metadir entry?" +_scratch_xfs_db -x -c 'path -m /realtime/0.rmap' \ + -c 'write core.nlinkv2 0' -c 'write core.mode 0' \ + -c 'path -m /realtime' \ + -c "write $rtrmap_sfentry 0" >> $seqres.full +if _try_scratch_mount >> $seqres.full 2>&1; then + echo "mount should have failed" + _scratch_unmount +else + # If the verifiers are working properly, the mount will fail because + # we fuzzed the metadata root directory. This causes loud complaints + # to dmesg, so we want to ignore those. + _disable_dmesg_check +fi echo "Repair fs" -_scratch_unmount 2>&1 | _filter_scratch +_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot _repair_scratch_fs >> $seqres.full 2>&1 echo "Try to create more files (again)"
tests/xfs/339 +3 -2
@@ -31,7 +31,8 @@ ln $SCRATCH_MNT/f3 $SCRATCH_MNT/f4 _scratch_unmount echo "Corrupt fs" -rrmapino=`_scratch_xfs_get_sb_field rrmapino` +rrmapino=$(_scratch_metadir_lookup /realtime/0.rmap) +test -n "$rrmapino" || _fail "Could not find rtrmap inode?" _scratch_xfs_set_metadata_field "u3.sfdir3.list[3].inumber.i4" $rrmapino \ 'sb 0' 'addr rootino' >> $seqres.full _scratch_mount
@@ -43,7 +44,7 @@ echo "Try to create more files" $XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f5 >> $seqres.full 2>&1 echo "Repair fs" -_scratch_unmount 2>&1 | _filter_scratch +_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot _repair_scratch_fs >> $seqres.full 2>&1 echo "Try to create more files (again)"
tests/xfs/340 +10 -5
@@ -31,16 +31,21 @@ ino=$(stat -c '%i' $SCRATCH_MNT/f3) _scratch_unmount echo "Corrupt fs" -rrmapino=$(_scratch_xfs_get_sb_field rrmapino) -_scratch_xfs_db -x -c "inode $rrmapino" \ +rtrmap_sfentry="$(_scratch_find_rt_metadir_entry 0.rmap)" +test -n "$rtrmap_sfentry" || _fail "Could not find rtrmap metadir entry?" +rrmapino=$(_scratch_metadir_lookup /realtime/0.rmap) +test -n "$rrmapino" || _fail "Could not find rtrmap inode?" +_scratch_xfs_db -x -c "path -m /realtime/0.rmap" \ -c 'write core.format 2' -c 'write core.size 0' \ - -c 'write core.nblocks 0' -c 'sb 0' -c 'addr rootino' \ + -c 'write core.nblocks 0' \ + -c 'sb 0' -c 'addr rootino' \ -c "write u3.sfdir3.list[2].inumber.i4 $rrmapino" \ - -c 'sb 0' -c "write rrmapino $ino" >> $seqres.full + -c 'path -m /realtime' \ + -c "write $rtrmap_sfentry $ino" >> $seqres.full _try_scratch_mount >> $seqres.full 2>&1 && echo "mount should have failed" echo "Repair fs" -_scratch_unmount 2>&1 | _filter_scratch +_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot _repair_scratch_fs >> $seqres.full 2>&1 echo "Try to create more files (again)"
tests/xfs/341 +1 -1
@@ -53,7 +53,7 @@ echo "Corrupt fs" fsbno=$(_scratch_xfs_db -c "inode $ino" -c 'bmap' | grep 'flag 0' | head -n 1 | \ sed -e 's/^.*startblock \([0-9]*\) .*$/\1/g') -_scratch_xfs_db -x -c 'sb 0' -c 'addr rrmapino' \ +_scratch_xfs_db -x -c 'path -m /realtime/0.rmap' \ -c "write u3.rtrmapbt.ptrs[1] $fsbno" -c 'p' >> $seqres.full _scratch_mount
tests/xfs/342 +2 -2
@@ -47,9 +47,9 @@ ino=$(stat -c '%i' $SCRATCH_MNT/f3) _scratch_unmount echo "Corrupt fs" -_scratch_xfs_db -c 'sb 0' -c 'addr rrmapino' -c 'p u3.rtrmapbt.ptrs[1]' >> $seqres.full +_scratch_xfs_db -c 'path -m /realtime/0.rmap' -c 'p u3.rtrmapbt.ptrs[1]' >> $seqres.full -fsbno=$(_scratch_xfs_db -c 'sb 0' -c 'addr rrmapino' \ +fsbno=$(_scratch_xfs_db -c 'path -m /realtime/0.rmap' \ -c 'p u3.rtrmapbt.ptrs[1]' | sed -e 's/^.*://g') _scratch_xfs_db -x -c "inode $ino" -c "write u3.bmx[0].startblock $fsbno" >> $seqres.full _scratch_mount
PATCH 2/13 fuzz: for fuzzing the rtrmapbt, find the path to the rt rmap btree file
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The fs population code creates a realtime rmap btree in /some/ realtime group with at least two levels. This rmapbt file isn't necessarily the one for group 0, so we need to find it programmatically.
--- common/xfs | 33 +++++++++++++++++++++++++++++++++ tests/xfs/406 | 6 ++++-- tests/xfs/407 | 6 ++++-- tests/xfs/408 | 7 +++++-- tests/xfs/409 | 7 +++++-- tests/xfs/481 | 6 ++++-- tests/xfs/482 | 7 +++++-- 7 files changed, 60 insertions(+), 12 deletions(-)
common/xfs +33 -0
@@ -1814,6 +1814,39 @@ _scratch_xfs_find_agbtree_height() { return 1 } +# Find us the path to the inode containing a realtime btree with a specific +# height. +_scratch_xfs_find_rgbtree_height() { + local bt_type="$1" + local bt_height="$2" + local rgcount=$(_xfs_mount_rgcount $SCRATCH_DEV) + local path + local path_format + local bt_prefix + + case "${bt_type}" in + "rmap") + path_format="/realtime/%u.rmap" + bt_prefix="u3.rtrmapbt" + ;; + *) + _fail "Don't know about rt btree ${bt_type}" + ;; + esac + + for ((rgno = 0; rgno < rgcount; rgno++)); do + path="$(printf "${path_format}" "${rgno}")" + bt_level=$(_scratch_xfs_db -c "path -m ${path}" -c "p ${bt_prefix}.level" | awk '{print $3}') + # "level" is the actual level within the btree + if [ "${bt_level}" -eq "$((bt_height - 1))" ]; then + echo "${path}" + return 0 + fi + done + + return 1 +} + _require_xfs_mkfs_atomicswap() { # atomicswap can be activated on rmap or reflink filesystems.
tests/xfs/406 +4 -2
@@ -26,10 +26,12 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 -inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'sb 0' 'addr rrmapino') +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") echo "Fuzz rtrmapbt recs" -_scratch_xfs_fuzz_metadata '' 'offline' 'sb 0' 'addr rrmapino' "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full +_scratch_xfs_fuzz_metadata '' 'offline' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full echo "Done fuzzing rtrmapbt recs" # success, all done
tests/xfs/407 +4 -2
@@ -26,10 +26,12 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 -inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'sb 0' 'addr rrmapino') +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 1)" || \ + _fail "could not find two-level rtrmapbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") echo "Fuzz rtrmapbt recs" -_scratch_xfs_fuzz_metadata '' 'online' 'sb 0' 'addr rrmapino' "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full +_scratch_xfs_fuzz_metadata '' 'online' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full echo "Done fuzzing rtrmapbt recs" # success, all done
tests/xfs/408 +5 -2
@@ -4,7 +4,7 @@ # # FS QA Test No. 408 # -# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field. +# Populate a XFS filesystem and fuzz every rtrmapbt key/pointer field. # Use xfs_repair to fix the corruption. # . ./common/preamble
@@ -26,8 +26,11 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" + echo "Fuzz rtrmapbt keyptrs" -_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' 'sb 0' 'addr rrmapino' >> $seqres.full +_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' "path -m $path" >> $seqres.full echo "Done fuzzing rtrmapbt keyptrs" # success, all done
tests/xfs/409 +5 -2
@@ -4,7 +4,7 @@ # # FS QA Test No. 409 # -# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field. +# Populate a XFS filesystem and fuzz every rtrmapbt key/pointer field. # Use xfs_scrub to fix the corruption. # . ./common/preamble
@@ -26,8 +26,11 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" + echo "Fuzz rtrmapbt keyptrs" -_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' 'sb 0' 'addr rrmapino' >> $seqres.full +_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'online' "path -m $path" >> $seqres.full echo "Done fuzzing rtrmapbt keyptrs" # success, all done
tests/xfs/481 +4 -2
@@ -27,10 +27,12 @@ _disable_dmesg_check echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 -inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'sb 0' 'addr rrmapino') +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") echo "Fuzz rtrmapbt recs" -_scratch_xfs_fuzz_metadata '' 'none' 'sb 0' 'addr rrmapino' "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full +_scratch_xfs_fuzz_metadata '' 'none' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full echo "Done fuzzing rtrmapbt recs" # success, all done
tests/xfs/482 +5 -2
@@ -4,7 +4,7 @@ # # FS QA Test No. 482 # -# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field. +# Populate a XFS filesystem and fuzz every rtrmapbt key/pointer field. # Do not fix the filesystem, to test metadata verifiers. . ./common/preamble
@@ -27,8 +27,11 @@ _disable_dmesg_check echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" + echo "Fuzz rtrmapbt keyptrs" -_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' 'sb 0' 'addr rrmapino' >> $seqres.full +_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' "path -m $path" >> $seqres.full echo "Done fuzzing rtrmapbt keyptrs" # success, all done
PATCH 3/13 xfs: race fsstress with realtime rmap btree scrub and repair
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Race checking and rebuilding realtime rmap btrees with fsstress.
--- tests/xfs/781 | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/781.out | 2 ++ tests/xfs/817 | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/817.out | 2 ++ tests/xfs/821 | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/821.out | 2 ++ 6 files changed, 132 insertions(+) create mode 100755 tests/xfs/781 create mode 100644 tests/xfs/781.out create mode 100755 tests/xfs/817 create mode 100644 tests/xfs/817.out create mode 100755 tests/xfs/821 create mode 100644 tests/xfs/821.out
tests/xfs/781 new file +42 -0
@@ -0,0 +1,42 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Oracle. Inc. All Rights Reserved. +# +# FS QA Test No. 781 +# +# Race fsstress and rtrmapbt repair for a while to see if we crash or livelock. +# +. ./common/preamble +_begin_fstest online_repair dangerous_fsstress_repair + +_cleanup() { + _scratch_xfs_stress_scrub_cleanup &> /dev/null + cd / + rm -r -f $tmp.* +} +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/fuzzy +. ./common/inject +. ./common/xfs + +# real QA test starts here +_supported_fs xfs +_require_realtime +_require_scratch +_require_xfs_stress_online_repair + +_scratch_mkfs > "$seqres.full" 2>&1 +_scratch_mount +_require_xfs_has_feature "$SCRATCH_MNT" realtime +_require_xfs_has_feature "$SCRATCH_MNT" rmapbt +_xfs_force_bdev realtime $SCRATCH_MNT + +_scratch_xfs_stress_online_repair -s "repair rtrmapbt %rgno%" + +# success, all done +echo Silence is golden +status=0 +exit
tests/xfs/781.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 781 +Silence is golden
tests/xfs/817 new file +42 -0
42 lines not on this page · raw message
tests/xfs/817.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 817 +Silence is golden
tests/xfs/821 new file +42 -0
42 lines not on this page · raw message
tests/xfs/821.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 821 +Silence is golden
PATCH 4/13 xfs/769: add rtrmapbt upgrade to test matrix
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Add realtime reverse mapping btrees to the features that this test will try to upgrade.
--- tests/xfs/769 | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
tests/xfs/769 +28 -1
@@ -35,11 +35,36 @@ rt_configured() test "$USE_EXTERNAL" = "yes" && test -n "$SCRATCH_RTDEV" } +need_rtgroups() +{ + local feat="$1" + + # if realtime isn't configured, we don't need rt groups + rt_configured || return 1 + + # rt rmap btrees require rt groups but rt groups cannot be added to + # an existing filesystem, so we must force it on at mkfs time + test "${FEATURE_STATE["rmapbt"]}" -eq 1 && return 0 + test "$feat" = "rmapbt" && return 0 + + return 1 +} + # Compute the MKFS_OPTIONS string for a particular feature upgrade test compute_mkfs_options() { + local feat="$1" local m_opts="" local caller_options="$MKFS_OPTIONS" + local rtgroups + + need_rtgroups "$feat" && rtgroups=1 + if echo "$caller_options" | grep -q 'rtgroups='; then + test -z "$rtgroups" && rtgroups=0 + caller_options="$(echo "$caller_options" | sed -e 's/rtgroups=*[0-9]*/rtgroups='$rtgroups'/g')" + elif [ -n "$rtgroups" ]; then + caller_options="$caller_options -r rtgroups=$rtgroups" + fi for feat in "${FEATURES[@]}"; do local feat_state="${FEATURE_STATE["${feat}"]}"
@@ -171,10 +196,12 @@ function post_exercise() # upgrade don't spread failure to the rest of the tests. FEATURES=() if rt_configured; then + # rmap wasn't added to rt devices until after metadir check_repair_upgrade finobt && FEATURES+=("finobt") check_repair_upgrade inobtcount && FEATURES+=("inobtcount") check_repair_upgrade bigtime && FEATURES+=("bigtime") check_repair_upgrade metadir && FEATURES+=("metadir") + check_repair_upgrade rmapbt && FEATURES+=("rmapbt") else check_repair_upgrade finobt && FEATURES+=("finobt") check_repair_upgrade rmapbt && FEATURES+=("rmapbt")
@@ -197,7 +224,7 @@ for feat in "${FEATURES[@]}"; do upgrade_start_message "$feat" | tee -a $seqres.full /dev/ttyprintk > /dev/null - opts="$(compute_mkfs_options)" + opts="$(compute_mkfs_options "$feat")" echo "mkfs.xfs $opts" >> $seqres.full # Format filesystem
PATCH 5/13 xfs/122: update for rtgroups-based realtime rmap btrees
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that we've redesigned realtime rmap to require that the rt section be sharded into allocation groups of no more than 2^31 blocks, we've reduced the size of the ondisk structures and therefore need to update this test.
--- tests/xfs/122.out | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/xfs/122.out +2 -2
@@ -116,8 +116,8 @@ sizeof(struct xfs_rmap_key) = 20 sizeof(struct xfs_rmap_rec) = 24 sizeof(struct xfs_rtbuf_blkinfo) = 48 sizeof(struct xfs_rtgroup_geometry) = 128 -sizeof(struct xfs_rtrmap_key) = 24 -sizeof(struct xfs_rtrmap_rec) = 32 +sizeof(struct xfs_rtrmap_key) = 20 +sizeof(struct xfs_rtrmap_rec) = 24 sizeof(struct xfs_rtrmap_root) = 4 sizeof(struct xfs_rtsb) = 104 sizeof(struct xfs_rud_log_format) = 16
PATCH 6/13 xfs: fix various problems with fsmap detecting the data device
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Various tests of realtime rmap functionality assumed that the data device could be picked out from the GETFSMAP output by looking for static fs metadata. This is no longer true, since rtgroups have a static superblock header at the start, so update these tests.
--- tests/xfs/272 | 2 +- tests/xfs/276 | 2 +- tests/xfs/277 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
tests/xfs/272 +1 -1
@@ -57,7 +57,7 @@ cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total c done echo "Check device field of FS metadata and regular file" -data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') +data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') test "${data_dev}" = "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?"
tests/xfs/276 +1 -1
@@ -61,7 +61,7 @@ cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total c done echo "Check device field of FS metadata and realtime file" -data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') +data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*[[:space:]]*[0-9]*$" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') test "${data_dev}" != "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?"
tests/xfs/277 +1 -1
@@ -38,7 +38,7 @@ $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT | tr '[]()' ' ' > $TEST_DIR/fsmap echo "Check device field of FS metadata and journalling log" -data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') +data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') journal_dev=$(grep 'journalling log' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') test "${data_dev}" = "${journal_dev}" || echo "data ${data_dev} journal ${journal_dev}?"
PATCH 7/13 xfs/341: update test for rtgroup-based rmap
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that we're sharding the realtime volume into multiple allocation groups, update this test to reflect the new reality. The realtime rmap btree record and key sizes have shrunk, and we can't guarantee that a quick file write actually hits the same rt group as the one we fuzzed, so eliminate the file write test since we're really only curious if xfs_repair will fix the problem.
--- tests/xfs/341 | 10 +++------- tests/xfs/341.out | 1 - 2 files changed, 3 insertions(+), 8 deletions(-)
tests/xfs/341 +3 -7
@@ -32,10 +32,10 @@ blksz="$(_get_block_size $SCRATCH_MNT)" rtextsz_blks=$((rtextsz / blksz)) # inode core size is at least 176 bytes; btree header is 56 bytes; -# rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes. +# rtrmap record is 24 bytes; and rtrmap key/pointer are 48 bytes. i_core_size="$(_xfs_get_inode_core_bytes $SCRATCH_MNT)" -i_ptrs=$(( (isize - i_core_size) / 56 )) -bt_recs=$(( (blksz - 56) / 32 )) +i_ptrs=$(( (isize - i_core_size) / 48 )) +bt_recs=$(( (blksz - 56) / 24 )) blocks=$((i_ptrs * bt_recs + 1)) len=$((blocks * rtextsz))
@@ -57,10 +57,6 @@ _scratch_xfs_db -x -c 'path -m /realtime/0.rmap' \ -c "write u3.rtrmapbt.ptrs[1] $fsbno" -c 'p' >> $seqres.full _scratch_mount -echo "Try to create more files" -$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f5 >> $seqres.full 2>&1 -test -e $SCRATCH_MNT/f5 && echo "should not have been able to write f5" - echo "Repair fs" _scratch_unmount 2>&1 | _filter_scratch _repair_scratch_fs >> $seqres.full 2>&1
tests/xfs/341.out +0 -1
@@ -2,6 +2,5 @@ QA output created by 341 Format and mount Create some files Corrupt fs -Try to create more files Repair fs Try to create more files (again)
PATCH 8/13 xfs/3{43,32}: adapt tests for rt extent size greater than 1
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Both of these tests for the realtime volume can fail when the rt extent size is larger than a single block.
332 is a read-write functionality test that encodes md5sum in the output, so we need to skip it if $blksz isn't congruent with the extent size, because the fcollapse call will fail.
343 is a test of the rmap btree, so the fix here is simpler -- make $blksz the file allocation unit, and get rid of the md5sum in the golden output.
--- tests/xfs/332 | 6 +----- tests/xfs/332.out | 2 -- tests/xfs/343 | 2 ++ 3 files changed, 3 insertions(+), 7 deletions(-)
tests/xfs/332 +1 -5
@@ -28,7 +28,7 @@ rm -f "$seqres.full" echo "Format and mount" _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount -blksz=65536 +blksz=$(_get_file_block_size $SCRATCH_MNT) # 65536 blocks=16 len=$((blocks * blksz))
@@ -45,10 +45,6 @@ $XFS_IO_PROG -c "fpunch $blksz $blksz" \ -c "fcollapse $((9 * blksz)) $blksz" \ -c "finsert $((10 * blksz)) $blksz" $SCRATCH_MNT/f1 >> $seqres.full -echo "Check file" -md5sum $SCRATCH_MNT/f1 | _filter_scratch -od -tx1 -Ad -c $SCRATCH_MNT/f1 >> $seqres.full - echo "Unmount" _scratch_unmount
tests/xfs/332.out +0 -2
@@ -2,8 +2,6 @@ QA output created by 332 Format and mount Create some files Manipulate file -Check file -e45c5707fcf6817e914ffb6ce37a0ac7 SCRATCH_MNT/f1 Unmount Try a regular fsmap Try a bad fsmap
tests/xfs/343 +2 -0
@@ -31,6 +31,8 @@ blksz=65536 blocks=16 len=$((blocks * blksz)) +_require_congruent_file_oplen $SCRATCH_MNT $blksz + echo "Create some files" $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
PATCH 9/13 xfs: skip tests if formatting small filesystem fails
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
There are a few tests that try to exercise XFS functionality with an unusually small (< 500MB) filesystem. Formatting can fail if the test configuration also specifies a very large realtime device because mkfs hits ENOSPC when allocating the realtime metadata. The test proceeds anyway (which causes an immediate mount failure) so we might as well skip these.
--- tests/xfs/104 | 1 + tests/xfs/291 | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
tests/xfs/104 +1 -0
@@ -16,6 +16,7 @@ _create_scratch() { echo "*** mkfs" _scratch_mkfs_xfs $@ | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs + test "${PIPESTATUS[0]}" -eq 0 || _notrun "formatting small scratch fs failed" . $tmp.mkfs echo "*** mount"
tests/xfs/291 +2 -1
@@ -18,7 +18,8 @@ _require_command "$XFS_MDRESTORE_PROG" "xfs_mdrestore" # real QA test starts here _require_scratch logblks=$(_scratch_find_xfs_min_logblocks -n size=16k -d size=133m) -_scratch_mkfs_xfs -n size=16k -l size=${logblks}b -d size=133m >> $seqres.full 2>&1 +_scratch_mkfs_xfs -n size=16k -l size=${logblks}b -d size=133m >> $seqres.full 2>&1 || \ + _notrun "formatting small scratch fs failed" _scratch_mount # First we cause very badly fragmented freespace, then
PATCH 10/13 xfs/443: use file allocation unit, not dbsize
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
We can only punch in units of file allocation boundaries, so update this test to use that instead of the fs blocksize.
--- tests/xfs/443 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tests/xfs/443 +5 -4
@@ -40,14 +40,15 @@ _scratch_mount file1=$SCRATCH_MNT/file1 file2=$SCRATCH_MNT/file2 +file_blksz=$(_get_file_block_size $SCRATCH_MNT) # The goal is run an extent swap where one of the associated files has the # minimum number of extents to remain in btree format. First, create a couple # files with large enough extent counts (200 or so should be plenty) to ensure # btree format on the largest possible inode size filesystems. -$XFS_IO_PROG -fc "falloc 0 $((400 * dbsize))" $file1 +$XFS_IO_PROG -fc "falloc 0 $((400 * file_blksz))" $file1 $here/src/punch-alternating $file1 -$XFS_IO_PROG -fc "falloc 0 $((400 * dbsize))" $file2 +$XFS_IO_PROG -fc "falloc 0 $((400 * file_blksz))" $file2 $here/src/punch-alternating $file2 # Now run an extent swap at every possible extent count down to 0. Depending on
@@ -55,12 +56,12 @@ $here/src/punch-alternating $file2 # btree format. for i in $(seq 1 2 399); do # punch one extent from the tmpfile and swap - $XFS_IO_PROG -c "fpunch $((i * dbsize)) $dbsize" $file2 + $XFS_IO_PROG -c "fpunch $((i * file_blksz)) $file_blksz" $file2 $XFS_IO_PROG -c "swapext $file2" $file1 # punch the same extent from the old fork (now in file2) to resync the # extent counts and repeat - $XFS_IO_PROG -c "fpunch $((i * dbsize)) $dbsize" $file2 + $XFS_IO_PROG -c "fpunch $((i * file_blksz)) $file_blksz" $file2 done # sanity check that no extents are left over
PATCH 11/13 populate: adjust rtrmap calculations for rtgroups
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that we've sharded the realtime volume and created per-group rmap btrees, we need to adjust downward the size of rtrmapbt records since the block counts are now 32-bit instead of 64-bit.
--- common/populate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/populate +1 -1
@@ -379,7 +379,7 @@ _scratch_xfs_populate() { is_rt="$(_xfs_get_rtextents "$SCRATCH_MNT")" if [ $is_rmapbt -gt 0 ] && [ $is_rt -gt 0 ]; then echo "+ rtrmapbt btree" - nr="$((blksz * 2 / 32))" + nr="$((blksz * 2 / 24))" $XFS_IO_PROG -R -f -c 'truncate 0' "${SCRATCH_MNT}/RTRMAPBT" __populate_create_file $((blksz * nr)) "${SCRATCH_MNT}/RTRMAPBT" fi
PATCH 12/13 populate: check that we created a realtime rmap btree of the given height
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Make sure that we actually create an rt rmap btree of the desired height somewhere in the filesystem.
--- common/populate | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
common/populate +34 -0
@@ -631,6 +631,37 @@ __populate_check_xfs_agbtree_height() { return 1 } +# Check that there's at least one rt btree with multiple levels +__populate_check_xfs_rgbtree_height() { + local bt_type="$1" + local rgcount=$(_scratch_xfs_db -c 'sb 0' -c 'p rgcount' | awk '{print $3}') + local path + local path_format + local bt_prefix + + case "${bt_type}" in + "rmap") + path_format="/realtime/%u.rmap" + bt_prefix="u3.rtrmapbt" + ;; + *) + _fail "Don't know about rt btree ${bt_type}" + ;; + esac + + for ((rgno = 0; rgno < rgcount; rgno++)); do + path="$(printf "${path_format}" "${rgno}")" + bt_level=$(_scratch_xfs_db -c "path -m ${path}" -c "p ${bt_prefix}.level" | awk '{print $3}') + # "level" is the actual level within the btree + if [ "${bt_level}" -gt 0 ]; then + return 0 + fi + done + + __populate_fail "Failed to create rt ${bt_type} of sufficient height!" + return 1 +} + # Check that populate created all the types of files we wanted _scratch_xfs_populate_check() { _scratch_mount
@@ -654,6 +685,7 @@ _scratch_xfs_populate_check() { is_finobt=$(_xfs_has_feature "$SCRATCH_MNT" finobt -v) is_rmapbt=$(_xfs_has_feature "$SCRATCH_MNT" rmapbt -v) is_reflink=$(_xfs_has_feature "$SCRATCH_MNT" reflink -v) + is_rt="$(_xfs_get_rtextents "$SCRATCH_MNT")" blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" dblksz="$(_xfs_get_dir_blocksize "$SCRATCH_MNT")"
@@ -684,6 +716,8 @@ _scratch_xfs_populate_check() { test $is_finobt -ne 0 && __populate_check_xfs_agbtree_height "fino" test $is_rmapbt -ne 0 && __populate_check_xfs_agbtree_height "rmap" test $is_reflink -ne 0 && __populate_check_xfs_agbtree_height "refcnt" + test $is_rmapbt -ne 0 && test $is_rt -gt 0 && \ + __populate_check_xfs_rgbtree_height "rmap" } # Check data fork format of ext4 file
PATCH 13/13 fuzzy: create missing fuzz tests for rt rmap btrees
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Back when I first created the fuzz tests for the realtime rmap btree, I forgot a couple of things. Add tests to fuzz rtrmap btree leaf records, and node keys.
--- tests/xfs/1528 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/1528.out | 4 ++++ tests/xfs/1529 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1529.out | 4 ++++ tests/xfs/407 | 2 +- 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100755 tests/xfs/1528 create mode 100644 tests/xfs/1528.out create mode 100755 tests/xfs/1529 create mode 100644 tests/xfs/1529.out
tests/xfs/1528 new file +41 -0
@@ -0,0 +1,41 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1528 +# +# Populate a XFS filesystem and fuzz every rtrmapbt record field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_bothrepair realtime + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_realtime +_require_xfs_scratch_rmapbt +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") + +echo "Fuzz rtrmapbt recs" +_scratch_xfs_fuzz_metadata '' 'both' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full +echo "Done fuzzing rtrmapbt recs" + +# success, all done +status=0 +exit
tests/xfs/1528.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1528 +Format and populate +Fuzz rtrmapbt recs +Done fuzzing rtrmapbt recs
tests/xfs/1529 new file +40 -0
@@ -0,0 +1,40 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1529 +# +# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_bothrepair realtime + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +# real QA test starts here +_supported_fs xfs +_require_realtime +_require_xfs_scratch_rmapbt +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" + +echo "Fuzz rtrmapbt keyptrs" +_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' "path -m $path" >> $seqres.full +echo "Done fuzzing rtrmapbt keyptrs" + +# success, all done +status=0 +exit
tests/xfs/1529.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1529 +Format and populate +Fuzz rtrmapbt keyptrs +Done fuzzing rtrmapbt keyptrs
tests/xfs/407 +1 -1
@@ -26,7 +26,7 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 -path="$(_scratch_xfs_find_rgbtree_height 'rmap' 1)" || \ +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ _fail "could not find two-level rtrmapbt" inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path")
cover fstests: reflink on the realtime device
In reply to Darrick J. WongHi all,
This patchset enables use of the file data block sharing feature (i.e. reflink) on the realtime device. It follows the same basic sequence as the realtime rmap series -- first a few cleanups; then widening of the API parameters; and introduction of the new btree format and inode fork format. Next comes enabling CoW and remapping for the rt device; new scrub, repair, and health reporting code; and at the end we implement some code to lengthen write requests so that rt extents are always CoWed fully.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=realtime-reflink
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-reflink
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-reflink
xfsdocs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-documentation.git/log/?h=realtime-reflink
--- common/populate | 26 ++++++++++++++++++--- common/xfs | 15 ++++++++++++ tests/generic/331 | 12 ++++++++- tests/generic/331.out | 2 +- tests/xfs/122.out | 3 ++ tests/xfs/131 | 48 -------------------------------------- tests/xfs/131.out | 5 ---- tests/xfs/1538 | 41 ++++++++++++++++++++++++++++++++ tests/xfs/1538.out | 4 +++ tests/xfs/1539 | 41 ++++++++++++++++++++++++++++++++ tests/xfs/1539.out | 4 +++ tests/xfs/1540 | 41 ++++++++++++++++++++++++++++++++ tests/xfs/1540.out | 4 +++ tests/xfs/1541 | 42 +++++++++++++++++++++++++++++++++ tests/xfs/1541.out | 4 +++ tests/xfs/1542 | 41 ++++++++++++++++++++++++++++++++ tests/xfs/1542.out | 4 +++ tests/xfs/1543 | 40 ++++++++++++++++++++++++++++++++ tests/xfs/1543.out | 4 +++ tests/xfs/1544 | 40 ++++++++++++++++++++++++++++++++ tests/xfs/1544.out | 4 +++ tests/xfs/1545 | 41 ++++++++++++++++++++++++++++++++ tests/xfs/1545.out | 4 +++ tests/xfs/240 | 13 +++++++++- tests/xfs/240.out | 2 +- tests/xfs/243 | 5 ++++ tests/xfs/272 | 40 +++++++++++++++++++++----------- tests/xfs/274 | 62 ++++++++++++++++++++++++++++++++++--------------- tests/xfs/769 | 3 ++ tests/xfs/818 | 43 ++++++++++++++++++++++++++++++++++ tests/xfs/818.out | 2 ++ tests/xfs/819 | 43 ++++++++++++++++++++++++++++++++++ tests/xfs/819.out | 2 ++ 33 files changed, 590 insertions(+), 95 deletions(-) delete mode 100755 tests/xfs/131 delete mode 100644 tests/xfs/131.out create mode 100755 tests/xfs/1538 create mode 100644 tests/xfs/1538.out create mode 100755 tests/xfs/1539 create mode 100644 tests/xfs/1539.out create mode 100755 tests/xfs/1540 create mode 100644 tests/xfs/1540.out create mode 100755 tests/xfs/1541 create mode 100644 tests/xfs/1541.out create mode 100755 tests/xfs/1542 create mode 100644 tests/xfs/1542.out create mode 100755 tests/xfs/1543 create mode 100644 tests/xfs/1543.out create mode 100755 tests/xfs/1544 create mode 100644 tests/xfs/1544.out create mode 100755 tests/xfs/1545 create mode 100644 tests/xfs/1545.out create mode 100755 tests/xfs/818 create mode 100644 tests/xfs/818.out create mode 100755 tests/xfs/819 create mode 100644 tests/xfs/819.out
PATCH 1/10 xfs/122: update fields for realtime reflink
From: Darrick J. Wong <[email protected]>
Add a few more ondisk structures for realtime reflink.
--- tests/xfs/122.out | 3 +++ 1 file changed, 3 insertions(+)
tests/xfs/122.out +3 -0
@@ -116,6 +116,9 @@ sizeof(struct xfs_rmap_key) = 20 sizeof(struct xfs_rmap_rec) = 24 sizeof(struct xfs_rtbuf_blkinfo) = 48 sizeof(struct xfs_rtgroup_geometry) = 128 +sizeof(struct xfs_rtrefcount_key) = 4 +sizeof(struct xfs_rtrefcount_rec) = 12 +sizeof(struct xfs_rtrefcount_root) = 4 sizeof(struct xfs_rtrmap_key) = 20 sizeof(struct xfs_rtrmap_rec) = 24 sizeof(struct xfs_rtrmap_root) = 4
PATCH 2/10 common/populate: create realtime refcount btree
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Populate a realtime refcount btree when we're creating a sample fs.
--- common/populate | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
common/populate +23 -3
@@ -367,16 +367,30 @@ _scratch_xfs_populate() { rm -f "${dir}/${f}" done - # Reverse-mapping btree + is_rt="$(_xfs_get_rtextents "$SCRATCH_MNT")" is_rmapbt="$(_xfs_has_feature "$SCRATCH_MNT" rmapbt -v)" + is_reflink="$(_xfs_has_feature "$SCRATCH_MNT" reflink -v)" + + # Reverse-mapping btree if [ $is_rmapbt -gt 0 ]; then echo "+ rmapbt btree" nr="$((blksz * 2 / 24))" __populate_create_file $((blksz * nr)) "${SCRATCH_MNT}/RMAPBT" fi + # Realtime Reference-count btree comes before the rtrmapbt so that + # the refcount entries are created in rtgroup 0. + if [ $is_reflink -gt 0 ] && [ $is_rt -gt 0 ]; then + echo "+ rtreflink btree" + rt_blksz=$(_xfs_get_rtextsize "$SCRATCH_MNT") + nr="$((rt_blksz * 2 / 12))" + $XFS_IO_PROG -R -f -c 'truncate 0' "${SCRATCH_MNT}/RTREFCOUNTBT" + __populate_create_file $((blksz * nr)) "${SCRATCH_MNT}/RTREFCOUNTBT" + $XFS_IO_PROG -R -f -c 'truncate 0' "${SCRATCH_MNT}/RTREFCOUNTBT2" + cp --reflink=always "${SCRATCH_MNT}/RTREFCOUNTBT" "${SCRATCH_MNT}/RTREFCOUNTBT2" + fi + # Realtime Reverse-mapping btree - is_rt="$(_xfs_get_rtextents "$SCRATCH_MNT")" if [ $is_rmapbt -gt 0 ] && [ $is_rt -gt 0 ]; then echo "+ rtrmapbt btree" nr="$((blksz * 2 / 24))"
@@ -385,7 +399,6 @@ _scratch_xfs_populate() { fi # Reference-count btree - is_reflink="$(_xfs_has_feature "$SCRATCH_MNT" reflink -v)" if [ $is_reflink -gt 0 ]; then echo "+ reflink btree" nr="$((blksz * 2 / 12))"
@@ -403,6 +416,7 @@ _scratch_xfs_populate() { __populate_fragment_file "${SCRATCH_MNT}/RMAPBT" __populate_fragment_file "${SCRATCH_MNT}/RTRMAPBT" __populate_fragment_file "${SCRATCH_MNT}/REFCOUNTBT" + __populate_fragment_file "${SCRATCH_MNT}/RTREFCOUNTBT" umount "${SCRATCH_MNT}" }
@@ -644,6 +658,10 @@ __populate_check_xfs_rgbtree_height() { path_format="/realtime/%u.rmap" bt_prefix="u3.rtrmapbt" ;; + "refcnt") + path_format="/realtime/%u.refcount" + bt_prefix="u3.rtrefcbt" + ;; *) _fail "Don't know about rt btree ${bt_type}" ;;
@@ -718,6 +736,8 @@ _scratch_xfs_populate_check() { test $is_reflink -ne 0 && __populate_check_xfs_agbtree_height "refcnt" test $is_rmapbt -ne 0 && test $is_rt -gt 0 && \ __populate_check_xfs_rgbtree_height "rmap" + test $is_reflink -ne 0 && test $is_rt -gt 0 && \ + __populate_check_xfs_rgbtree_height "refcnt" } # Check data fork format of ext4 file
PATCH 3/10 xfs: create fuzz tests for the realtime refcount btree
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Create fuzz tests for the realtime refcount btree record and key/ptr blocks.
--- common/xfs | 4 ++++ tests/xfs/1538 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/1538.out | 4 ++++ tests/xfs/1539 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/1539.out | 4 ++++ tests/xfs/1540 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/1540.out | 4 ++++ tests/xfs/1541 | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1541.out | 4 ++++ tests/xfs/1542 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/1542.out | 4 ++++ tests/xfs/1543 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1543.out | 4 ++++ tests/xfs/1544 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1544.out | 4 ++++ tests/xfs/1545 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/1545.out | 4 ++++ 17 files changed, 363 insertions(+) create mode 100755 tests/xfs/1538 create mode 100644 tests/xfs/1538.out create mode 100755 tests/xfs/1539 create mode 100644 tests/xfs/1539.out create mode 100755 tests/xfs/1540 create mode 100644 tests/xfs/1540.out create mode 100755 tests/xfs/1541 create mode 100644 tests/xfs/1541.out create mode 100755 tests/xfs/1542 create mode 100644 tests/xfs/1542.out create mode 100755 tests/xfs/1543 create mode 100644 tests/xfs/1543.out create mode 100755 tests/xfs/1544 create mode 100644 tests/xfs/1544.out create mode 100755 tests/xfs/1545 create mode 100644 tests/xfs/1545.out
common/xfs +4 -0
@@ -1829,6 +1829,10 @@ _scratch_xfs_find_rgbtree_height() { path_format="/realtime/%u.rmap" bt_prefix="u3.rtrmapbt" ;; + "refcnt") + path_format="/realtime/%u.refcount" + bt_prefix="u3.rtrefcbt" + ;; *) _fail "Don't know about rt btree ${bt_type}" ;;
tests/xfs/1538 new file +41 -0
41 lines not on this page · raw message
tests/xfs/1538.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1538 +Format and populate +Fuzz rtrefcountbt recs +Done fuzzing rtrefcountbt recs
tests/xfs/1539 new file +41 -0
41 lines not on this page · raw message
tests/xfs/1539.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1539 +Format and populate +Fuzz rtrefcountbt recs +Done fuzzing rtrefcountbt recs
tests/xfs/1540 new file +41 -0
41 lines not on this page · raw message
tests/xfs/1540.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1540 +Format and populate +Fuzz rtrefcountbt recs +Done fuzzing rtrefcountbt recs
tests/xfs/1541 new file +42 -0
42 lines not on this page · raw message
tests/xfs/1541.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1541 +Format and populate +Fuzz rtrefcountbt recs +Done fuzzing rtrefcountbt recs
tests/xfs/1542 new file +41 -0
41 lines not on this page · raw message
tests/xfs/1542.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1542 +Format and populate +Fuzz rtrefcountbt keyptrs +Done fuzzing rtrefcountbt keyptrs
tests/xfs/1543 new file +40 -0
@@ -0,0 +1,40 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1543 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt key/ptr field. +# Use xfs_repair to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_scrub dangerous_repair realtime + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +# real QA test starts here +_supported_fs xfs +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" + +echo "Fuzz rtrefcountbt keyptrs" +_scratch_xfs_fuzz_metadata '(rtrefcbt)' 'offline' "path -m $path" >> $seqres.full +echo "Done fuzzing rtrefcountbt keyptrs" + +# success, all done +status=0 +exit
tests/xfs/1543.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1543 +Format and populate +Fuzz rtrefcountbt keyptrs +Done fuzzing rtrefcountbt keyptrs
tests/xfs/1544 new file +40 -0
@@ -0,0 +1,40 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1544 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt key/ptr field. +# Do not fix the filesystem, to test metadata verifiers. + +. ./common/preamble +_begin_fstest dangerous_fuzzers dangerous_norepair realtime + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +# real QA test starts here +_supported_fs xfs +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" + +echo "Fuzz rtrefcountbt keyptrs" +_scratch_xfs_fuzz_metadata '(rtrefcbt)' 'none' "path -m $path" >> $seqres.full +echo "Done fuzzing rtrefcountbt keyptrs" + +# success, all done +status=0 +exit
tests/xfs/1544.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1544 +Format and populate +Fuzz rtrefcountbt keyptrs +Done fuzzing rtrefcountbt keyptrs
tests/xfs/1545 new file +41 -0
41 lines not on this page · raw message
tests/xfs/1545.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1545 +Format and populate +Fuzz rtrefcountbt keyptrs +Done fuzzing rtrefcountbt keyptrs
PATCH 4/10 xfs/27[24]: adapt for checking files on the realtime volume
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Adapt both tests to behave properly if the two files being tested are on the realtime volume.
--- tests/xfs/272 | 40 +++++++++++++++++++++++++------------ tests/xfs/274 | 62 ++++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 70 insertions(+), 32 deletions(-)
tests/xfs/272 +27 -13
@@ -40,26 +40,40 @@ $here/src/punch-alternating $SCRATCH_MNT/urk >> $seqres.full ino=$(stat -c '%i' $SCRATCH_MNT/urk) echo "Get fsmap" | tee -a $seqres.full -$XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT | tr '[]()' ' ' > $TEST_DIR/fsmap +cat $TEST_DIR/fsmap >> $seqres.full echo "Get bmap" | tee -a $seqres.full -$XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk >> $seqres.full $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk | grep '^[[:space:]]*[0-9]*:' | grep -v 'hole' | tr '[]()' ' ' > $TEST_DIR/bmap +cat $TEST_DIR/bmap >> $seqres.full echo "Check bmap and fsmap" | tee -a $seqres.full -cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do - qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total}$" - echo "${qstr}" >> $seqres.full - grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full - found=$(grep -c "${qstr}" $TEST_DIR/fsmap) - test $found -eq 1 || echo "Unexpected output for offset ${offrange}." -done +if $XFS_IO_PROG -c 'stat -v' $SCRATCH_MNT/urk | grep -q realtime; then + # file on rt volume + cat $TEST_DIR/bmap | while read ext offrange colon rtblockrange total crap; do + qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${rtblockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${total}$" + echo "${qstr}" >> $seqres.full + grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full + found=$(grep -c "${qstr}" $TEST_DIR/fsmap) + test $found -eq 1 || echo "Unexpected output for offset ${offrange}." + done -echo "Check device field of FS metadata and regular file" -data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') -rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') -test "${data_dev}" = "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?" + echo "Check device field of FS metadata and regular file" +else + # file on data volume + cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do + qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total}$" + echo "${qstr}" >> $seqres.full + grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full + found=$(grep -c "${qstr}" $TEST_DIR/fsmap) + test $found -eq 1 || echo "Unexpected output for offset ${offrange}." + done + + echo "Check device field of FS metadata and regular file" + data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') + rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') + test "${data_dev}" = "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?" +fi # success, all done status=0
tests/xfs/274 +43 -19
77 lines not on this page · raw message
PATCH 5/10 xfs/243: don't run when realtime storage is the default
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Realtime volumes don't support delayed allocation, so don't run this test when the mkfs configuration specifies realtime creation by default.
--- tests/xfs/243 | 5 +++++ 1 file changed, 5 insertions(+)
tests/xfs/243 +5 -0
@@ -38,6 +38,11 @@ echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 _scratch_mount >> $seqres.full 2>&1 +# XFS does not support delayed allocation on realtime volumes (even for COW) +# so skip this test on those platforms. +$XFS_IO_PROG -c 'stat -v' $SCRATCH_MNT | grep -q "xflags.*rt-inherit" && + _notrun "delalloc not used for CoW on realtime device" + testdir=$SCRATCH_MNT/test-$seq mkdir $testdir
PATCH 6/10 xfs: race fsstress with realtime refcount btree scrub and repair
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Race checking and rebuilding realtime refcount btrees with fsstress.
--- tests/xfs/818 | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/xfs/818.out | 2 ++ tests/xfs/819 | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/xfs/819.out | 2 ++ 4 files changed, 90 insertions(+) create mode 100755 tests/xfs/818 create mode 100644 tests/xfs/818.out create mode 100755 tests/xfs/819 create mode 100644 tests/xfs/819.out
tests/xfs/818 new file +43 -0
@@ -0,0 +1,43 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Oracle. Inc. All Rights Reserved. +# +# FS QA Test No. 818 +# +# Race fsstress and rt refcount btree scrub for a while to see if we crash or +# livelock. +# +. ./common/preamble +_begin_fstest scrub dangerous_fsstress_scrub + +_cleanup() { + _scratch_xfs_stress_scrub_cleanup &> /dev/null + cd / + rm -r -f $tmp.* +} +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/fuzzy +. ./common/inject +. ./common/xfs + +# real QA test starts here +_supported_fs xfs +_require_realtime +_require_scratch +_require_xfs_stress_scrub + +_scratch_mkfs > "$seqres.full" 2>&1 +_scratch_mount +_require_xfs_has_feature "$SCRATCH_MNT" realtime +_require_xfs_has_feature "$SCRATCH_MNT" reflink +_xfs_force_bdev realtime $SCRATCH_MNT + +_scratch_xfs_stress_scrub -s "scrub rtrefcountbt %rgno%" + +# success, all done +echo Silence is golden +status=0 +exit
tests/xfs/818.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 818 +Silence is golden
tests/xfs/819 new file +43 -0
43 lines not on this page · raw message
tests/xfs/819.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 819 +Silence is golden
PATCH 7/10 xfs: remove xfs/131 now that we allow reflink on realtime volumes
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Remove this test, since we now support reflink on the rt volume.
--- tests/xfs/131 | 48 ------------------------------------------------ tests/xfs/131.out | 5 ----- 2 files changed, 53 deletions(-) delete mode 100755 tests/xfs/131 delete mode 100644 tests/xfs/131.out
tests/xfs/131 deleted +0 -48
@@ -1,48 +0,0 @@ -#! /bin/bash -# SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved. -# -# FS QA Test No. 131 -# -# Ensure that we can't reflink realtime files. -# -. ./common/preamble -_begin_fstest auto quick clone realtime - -# Override the default cleanup function. -_cleanup() -{ - cd / - umount $SCRATCH_MNT > /dev/null 2>&1 - rm -rf $tmp.* $testdir $metadump_file -} - -# Import common functions. -. ./common/filter -. ./common/reflink - -# real QA test starts here -_supported_fs xfs -_require_realtime -_require_scratch_reflink -_require_cp_reflink - -echo "Format and mount scratch device" -_scratch_mkfs >> $seqres.full -_scratch_mount - -testdir=$SCRATCH_MNT/test-$seq -mkdir $testdir - -echo "Create the original file blocks" -blksz=65536 -$XFS_IO_PROG -R -f -c "truncate $blksz" $testdir/file1 - -echo "Reflink every block" -_cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch - -test -s $testdir/file2 && _fail "Should not be able to reflink a realtime file." - -# success, all done -status=0 -exit
tests/xfs/131.out deleted +0 -5
@@ -1,5 +0,0 @@ -QA output created by 131 -Format and mount scratch device -Create the original file blocks -Reflink every block -cp: failed to clone 'SCRATCH_MNT/test-131/file2' from 'SCRATCH_MNT/test-131/file1': Invalid argument
PATCH 8/10 xfs/769: add rtreflink upgrade to test matrix
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Add realtime reflink to the features that this test will try to upgrade.
--- tests/xfs/769 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/xfs/769 +2 -1
@@ -196,12 +196,13 @@ function post_exercise() # upgrade don't spread failure to the rest of the tests. FEATURES=() if rt_configured; then - # rmap wasn't added to rt devices until after metadir + # reflink & rmap weren't added to rt devices until after metadir check_repair_upgrade finobt && FEATURES+=("finobt") check_repair_upgrade inobtcount && FEATURES+=("inobtcount") check_repair_upgrade bigtime && FEATURES+=("bigtime") check_repair_upgrade metadir && FEATURES+=("metadir") check_repair_upgrade rmapbt && FEATURES+=("rmapbt") + check_repair_upgrade reflink && FEATURES+=("reflink") else check_repair_upgrade finobt && FEATURES+=("finobt") check_repair_upgrade rmapbt && FEATURES+=("rmapbt")
PATCH 9/10 generic/331,xfs/240: support files that skip delayed allocation
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The goal of this test is to ensure that log recovery finishes a copy on write operation in the event of temporary media errors. It's important that the test observe some sort of IO error once we switch the scratch device to fail all IOs, but regrettably the test encoded the specific behavior of XFS and btrfs when the test was written -- the aio write to the page cache doesn't have to touch the disk and succeeds, and the fdatasync flushes things to disk and hits the IO error.
However, this is not how things work on the XFS realtime device. There is no delalloc on realtime, so the aio write allocates an unwritten extent to stage the write. The allocation fails due to EIO, so it's the write call that fails. Therefore, all we need to do is to detect an IO error at any point between the write and the fdatasync call to be satisfied that the test does what we want to do.
--- tests/generic/331 | 12 ++++++++++-- tests/generic/331.out | 2 +- tests/xfs/240 | 13 +++++++++++-- tests/xfs/240.out | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-)
tests/generic/331 +10 -2
@@ -59,9 +59,17 @@ echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full sync + +# If the filesystem supports delalloc, then the fdatasync will report an IO +# error. If the write goes directly to disk, then aiocp will return nonzero. +unset write_failed _dmerror_load_error_table -$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full -$XFS_IO_PROG -c "fdatasync" $testdir/file2 +$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 &>> $seqres.full || \ + write_failed=1 +$XFS_IO_PROG -c "fdatasync" $testdir/file2 2>&1 | grep -q 'Input.output error' && \ + write_failed=1 +test -n $write_failed && echo "write failed" + _dmerror_load_working_table _dmerror_unmount _dmerror_mount
tests/generic/331.out +1 -1
@@ -5,7 +5,7 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-331/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-331/file2 CoW and unmount -fdatasync: Input/output error +write failed Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-331/file1 d94b0ab13385aba594411c174b1cc13c SCRATCH_MNT/test-331/file2
tests/xfs/240 +11 -2
@@ -66,8 +66,17 @@ $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full sync _dmerror_load_error_table -$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full -$XFS_IO_PROG -c "fdatasync" $testdir/file2 + +# If the filesystem supports delalloc, then the fdatasync will report an IO +# error. If the write goes directly to disk, then aiocp will return nonzero. +unset write_failed +_dmerror_load_error_table +$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 &>> $seqres.full || \ + write_failed=1 +$XFS_IO_PROG -c "fdatasync" $testdir/file2 2>&1 | grep -q 'Input.output error' && \ + write_failed=1 +test -n $write_failed && echo "write failed" + _dmerror_load_working_table _dmerror_unmount _dmerror_mount
tests/xfs/240.out +1 -1
@@ -5,7 +5,7 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-240/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-240/file2 CoW and unmount -fdatasync: Input/output error +write failed Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-240/file1 d94b0ab13385aba594411c174b1cc13c SCRATCH_MNT/test-240/file2
PATCH 10/10 common/xfs: fix _xfs_get_file_block_size when rtinherit is set and no rt section
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
It's possible for the sysadmin to set rtinherit on the directory tree even if there isn't a realtime section attached to the filesystem. When this is the case, the realtime flag is /not/ passed to new files, and file data is written to the data device. The file allocation unit for the file is the fs blocksize, and it is not correct to use the rt extent.
fstests can be fooled into doing the incorrect thing if test runner puts '-d rtinherit=1 -r extsize=28k' into MKFS_OPTIONS without configuring a realtime device. This causes many tests to do the wrong thing because they think they must operate on units of 28k (and not 4k). Fix this.
--- common/xfs | 11 +++++++++++ 1 file changed, 11 insertions(+)
common/xfs +11 -0
@@ -207,6 +207,8 @@ _xfs_get_file_block_size() { local path="$1" + # If rtinherit or realtime are not set on the path, then all files + # will be created on the data device. if ! ($XFS_IO_PROG -c "stat -v" "$path" 2>&1 | grep -E -q '(rt-inherit|realtime)'); then _get_block_size "$path" return
@@ -217,6 +219,15 @@ _xfs_get_file_block_size() while ! $XFS_INFO_PROG "$path" &>/dev/null && [ "$path" != "/" ]; do path="$(dirname "$path")" done + + # If there's no realtime section, the rtinherit and rextsize settings + # are irrelevant -- all files are created on the data device. + if $XFS_INFO_PROG "$path" | grep -q 'realtime =none'; then + _get_block_size "$path" + return + fi + + # Otherwise, report the rt extent size. _xfs_get_rtextsize "$path" }
cover fstests: reflink with large realtime extents
In reply to Darrick J. WongHi all,
Now that we've landed support for reflink on the realtime device for cases where the rt extent size is the same as the fs block size, enhance the reflink code further to support cases where the rt extent size is a power-of-two multiple of the fs block size. This enables us to do data block sharing (for example) for much larger allocation units by dirtying pagecache around shared extents and expanding writeback to write back shared extents fully.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=realtime-reflink-extsize
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-reflink-extsize
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-reflink-extsize
--- common/rc | 23 +++++++ common/reflink | 27 +++++++++ tests/generic/145 | 1 tests/generic/147 | 1 tests/generic/261 | 1 tests/generic/262 | 1 tests/generic/303 | 8 ++- tests/generic/331 | 1 tests/generic/353 | 3 + tests/generic/517 | 1 tests/generic/657 | 1 tests/generic/658 | 1 tests/generic/659 | 1 tests/generic/660 | 1 tests/generic/663 | 1 tests/generic/664 | 1 tests/generic/665 | 1 tests/generic/670 | 1 tests/generic/672 | 1 tests/xfs/1212 | 1 tests/xfs/180 | 1 tests/xfs/182 | 1 tests/xfs/184 | 1 tests/xfs/192 | 1 tests/xfs/200 | 1 tests/xfs/204 | 1 tests/xfs/208 | 1 tests/xfs/315 | 1 tests/xfs/326 | 6 ++ tests/xfs/420 | 3 + tests/xfs/421 | 3 + tests/xfs/919 | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/919.out | 84 +++++++++++++++++++++++++++ 33 files changed, 342 insertions(+), 2 deletions(-) create mode 100755 tests/xfs/919 create mode 100644 tests/xfs/919.out
PATCH 1/4 xfs: make sure that CoW will write around when rextsize > 1
From: Darrick J. Wong <[email protected]>
Make sure that CoW triggers the intended copy-around behavior when we write a tiny amount to the middle of a large rt extent.
--- tests/xfs/919 | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/919.out | 84 +++++++++++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100755 tests/xfs/919 create mode 100644 tests/xfs/919.out
tests/xfs/919 new file +163 -0
@@ -0,0 +1,163 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 919 +# +# Make sure that copy on write actually does the intended write-around when we +# stage a tiny modification to a large shared realtime extent. We should never +# end up with multiple rt extents mapped to the same region. +# +. ./common/preamble +_begin_fstest auto quick clone realtime + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_supported_fs xfs +_require_xfs_io_command "fpunch" +_require_xfs_io_command "fzero" +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "finsert" +_require_xfs_io_command "funshare" +_require_realtime +_require_scratch_reflink + +rtextsz=262144 +filesz=$((rtextsz * 3)) + +echo "Format filesystem and populate" +_scratch_mkfs -m reflink=1 -r extsize=$rtextsz > $seqres.full +_scratch_mount >> $seqres.full + +# Force all our files to be on the realtime device +_xfs_force_bdev realtime $SCRATCH_MNT + +check_file() { + $XFS_IO_PROG -c fsync -c 'bmap -elpv' $1 >> $seqres.full + md5sum $SCRATCH_MNT/a | _filter_scratch + md5sum $1 | _filter_scratch +} + +rtextsz_got=$(_xfs_get_rtextsize "$SCRATCH_MNT") +test $rtextsz_got -eq $rtextsz || \ + _notrun "got rtextsize $rtextsz_got, wanted $rtextsz" + +_pwrite_byte 0x59 0 $filesz $SCRATCH_MNT/a >> $seqres.full +sync +md5sum $SCRATCH_MNT/a | _filter_scratch +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/a >> $seqres.full + +echo "pwrite 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/b +_pwrite_byte 0x00 345678 1 $SCRATCH_MNT/b >> $seqres.full +check_file $SCRATCH_MNT/b + +echo "mwrite 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/c +$XFS_IO_PROG -c "mmap -rw 0 $filesz" -c "mwrite -S 0x00 345678 1" -c msync $SCRATCH_MNT/c +check_file $SCRATCH_MNT/c + +echo "fzero 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/d +$XFS_IO_PROG -c "fzero 345678 1" $SCRATCH_MNT/d +check_file $SCRATCH_MNT/d + +echo "fpunch 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/e +$XFS_IO_PROG -c "fpunch 345678 1" $SCRATCH_MNT/e +check_file $SCRATCH_MNT/e + +echo "funshare 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/f +$XFS_IO_PROG -c "funshare 345678 1" $SCRATCH_MNT/f +check_file $SCRATCH_MNT/f + +echo "pwrite 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/g +_pwrite_byte 0x00 327680 65536 $SCRATCH_MNT/g >> $seqres.full +check_file $SCRATCH_MNT/g + +echo "mwrite 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/h +$XFS_IO_PROG -c "mmap -rw 0 $filesz" -c "mwrite -S 0x00 327680 65536" -c msync $SCRATCH_MNT/h +check_file $SCRATCH_MNT/h + +echo "fzero 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/i +$XFS_IO_PROG -c "fzero 327680 65536" $SCRATCH_MNT/i +check_file $SCRATCH_MNT/i + +echo "fpunch 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/j +$XFS_IO_PROG -c "fpunch 327680 65536" $SCRATCH_MNT/j +check_file $SCRATCH_MNT/j + +echo "funshare 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/k +$XFS_IO_PROG -c "funshare 327680 65536" $SCRATCH_MNT/k +check_file $SCRATCH_MNT/k + +echo "pwrite 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/l +_pwrite_byte 0x00 262144 262144 $SCRATCH_MNT/l >> $seqres.full +check_file $SCRATCH_MNT/l + +echo "mwrite 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/m +$XFS_IO_PROG -c "mmap -rw 0 $filesz" -c "mwrite -S 0x00 262144 262144" -c msync $SCRATCH_MNT/m +check_file $SCRATCH_MNT/m + +echo "fzero 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/n +$XFS_IO_PROG -c "fzero 262144 262144" $SCRATCH_MNT/n +check_file $SCRATCH_MNT/n + +echo "fpunch 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/o +$XFS_IO_PROG -c "fpunch 262144 262144" $SCRATCH_MNT/o +check_file $SCRATCH_MNT/o + +echo "funshare 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/p +$XFS_IO_PROG -c "funshare 262144 262144" $SCRATCH_MNT/p +check_file $SCRATCH_MNT/p + +echo "fcollapse 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/q +$XFS_IO_PROG -c "fcollapse 262144 262144" $SCRATCH_MNT/q +check_file $SCRATCH_MNT/q + +echo "finsert 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/r +$XFS_IO_PROG -c "finsert 262144 262144" $SCRATCH_MNT/r +check_file $SCRATCH_MNT/r + +echo "copy unwritten blocks in large rtext" | tee -a $seqres.full +$XFS_IO_PROG -f -c "falloc 0 $filesz" -c 'pwrite -S 0x59 345678 1' $SCRATCH_MNT/s >> $seqres.full +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/s >> $seqres.full +_cp_reflink $SCRATCH_MNT/s $SCRATCH_MNT/t +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/s >> $seqres.full +$XFS_IO_PROG -f -c 'pwrite -S 0x59 1048576 1' $SCRATCH_MNT/s >> $seqres.full +$XFS_IO_PROG -f -c 'pwrite -S 0x59 1048576 1' $SCRATCH_MNT/t >> $seqres.full +check_file $SCRATCH_MNT/s +check_file $SCRATCH_MNT/t + +echo "test writing to shared unwritten extent" | tee -a $seqres.full +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/s >> $seqres.full +_cp_reflink $SCRATCH_MNT/s $SCRATCH_MNT/u +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/s >> $seqres.full +$XFS_IO_PROG -f -c 'pwrite -S 0x59 345678 1' $SCRATCH_MNT/u >> $seqres.full +check_file $SCRATCH_MNT/u + +echo "Remount and recheck" | tee -a $seqres.full +md5sum $SCRATCH_MNT/a | _filter_scratch +for i in b c d e f g h i j k l m n o p q r s t u; do + check_file $SCRATCH_MNT/$i | grep -v SCRATCH_MNT.a +done + +# success, all done +status=0 +exit
tests/xfs/919.out new file +84 -0
84 lines not on this page · raw message
PATCH 2/4 xfs: skip cowextsize hint fragmentation tests on realtime volumes
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The XFS CoW extent size hint is ignored on realtime filesystems when the rt extent size set to a unit larger than a single filesystem block because it is assumed that the larger allocation unit is the administrator's sole and mandatory anti-fragmentation strategy. As such, we can skip these tests.
--- common/reflink | 27 +++++++++++++++++++++++++++ tests/xfs/180 | 1 + tests/xfs/182 | 1 + tests/xfs/184 | 1 + tests/xfs/192 | 1 + tests/xfs/200 | 1 + tests/xfs/204 | 1 + tests/xfs/208 | 1 + tests/xfs/315 | 1 + tests/xfs/326 | 6 ++++++ 10 files changed, 41 insertions(+)
common/reflink +27 -0
@@ -521,3 +521,30 @@ _sweave_reflink_rainbow_delalloc() { _pwrite_byte 0x62 $((blksz * i)) $blksz $dfile.chk done } + +# Require that the COW extent size hint can actually be used to combat +# fragmentation on the scratch filesystem. This is (so far) true for any +# filesystem except for the ones where the realtime extent size is larger +# than one fs block, for it is assumed that setting a rt extent size is the +# preferred fragmentation avoidance strategy. +_require_scratch_cowextsize_useful() { + local testfile=$SCRATCH_MNT/hascowextsize + local param="${1:-1m}" + + rm -f $testfile + touch $testfile + local before="$($XFS_IO_PROG -c 'cowextsize' $testfile)" + + $XFS_IO_PROG -c "cowextsize $param" $testfile + local after="$($XFS_IO_PROG -c 'cowextsize' $testfile)" + rm -f $testfile + + test "$before" != "$after" || \ + _notrun "setting cowextsize to $param had no effect" + + local fileblocksize=$(_get_file_block_size $SCRATCH_MNT) + local fsblocksize=$(_get_block_size $SCRATCH_MNT) + + test $fsblocksize -eq $fileblocksize || \ + _notrun "XFS does not support cowextsize when rt extsize ($fileblocksize) > 1FSB ($fsblocksize)" +}
tests/xfs/180 +1 -0
@@ -37,6 +37,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir)
tests/xfs/182 +1 -0
@@ -39,6 +39,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir)
tests/xfs/184 +1 -0
@@ -39,6 +39,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir)
tests/xfs/192 +1 -0
@@ -41,6 +41,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir)
tests/xfs/200 +1 -0
@@ -41,6 +41,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir)
tests/xfs/204 +1 -0
@@ -43,6 +43,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir)
tests/xfs/208 +1 -0
@@ -40,6 +40,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_file_block_size $testdir)
tests/xfs/315 +1 -0
@@ -38,6 +38,7 @@ echo "Format filesystem" _scratch_mkfs >/dev/null 2>&1 _scratch_mount >> $seqres.full _require_congruent_file_oplen $SCRATCH_MNT $blksz +_require_scratch_cowextsize_useful $sz $XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
tests/xfs/326 +6 -0
@@ -55,6 +55,12 @@ $XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT # staging extent for an unshared extent and trips over the injected error. _require_no_xfs_always_cow +# This test uses a very large cowextszhint to manipulate the COW fork to +# contain a large unwritten extent before injecting the error. XFS ignores +# cowextsize when the realtime extent size is greater than 1FSB, so this test +# cannot set up the preconditions for the test. +_require_scratch_cowextsize_useful $sz + echo "Create files" _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
PATCH 3/4 misc: add more congruent oplen testing
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Do more checking for file allocation operation op length congruency. This prevents tests from failing with EINVAL when the realtime extent size is something weird like 28k or 1GB.
--- tests/generic/145 | 1 + tests/generic/147 | 1 + tests/generic/261 | 1 + tests/generic/262 | 1 + tests/generic/331 | 1 + tests/generic/353 | 3 ++- tests/generic/517 | 1 + tests/generic/657 | 1 + tests/generic/658 | 1 + tests/generic/659 | 1 + tests/generic/660 | 1 + tests/generic/663 | 1 + tests/generic/664 | 1 + tests/generic/665 | 1 + tests/generic/670 | 1 + tests/generic/672 | 1 + tests/xfs/1212 | 1 + tests/xfs/420 | 3 +++ tests/xfs/421 | 3 +++ 19 files changed, 24 insertions(+), 1 deletion(-)
tests/generic/145 +1 -0
@@ -36,6 +36,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $TEST_DIR $blksz _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full _pwrite_byte 0x62 $blksz $blksz $testdir/file1 >> $seqres.full _pwrite_byte 0x63 $((blksz * 2)) $blksz $testdir/file1 >> $seqres.full
tests/generic/147 +1 -0
@@ -35,6 +35,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $TEST_DIR $blksz _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full _pwrite_byte 0x62 $blksz $blksz $testdir/file1 >> $seqres.full _pwrite_byte 0x63 $((blksz * 2)) $blksz $testdir/file1 >> $seqres.full
tests/generic/261 +1 -0
@@ -29,6 +29,7 @@ testdir=$SCRATCH_MNT/test-$seq mkdir $testdir blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=5 filesize=$((blksz * nr))
tests/generic/262 +1 -0
@@ -29,6 +29,7 @@ testdir=$SCRATCH_MNT/test-$seq mkdir $testdir blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=4 filesize=$((blksz * nr))
tests/generic/331 +1 -0
@@ -38,6 +38,7 @@ testdir=$SCRATCH_MNT/test-$seq mkdir $testdir blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=640 bufnr=128 filesize=$((blksz * nr))
tests/generic/353 +2 -1
@@ -29,7 +29,8 @@ _require_xfs_io_command "fiemap" _scratch_mkfs > /dev/null 2>&1 _scratch_mount -blocksize=64k +blocksize=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blocksize file1="$SCRATCH_MNT/file1" file2="$SCRATCH_MNT/file2"
tests/generic/517 +1 -0
@@ -21,6 +21,7 @@ _require_scratch_dedupe _scratch_mkfs >>$seqres.full 2>&1 _scratch_mount +_require_congruent_file_oplen $SCRATCH_MNT 65536 # The first byte with a value of 0xae starts at an offset (512Kb + 100) which is # not a multiple of the block size.
tests/generic/657 +1 -0
@@ -30,6 +30,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
tests/generic/658 +1 -0
@@ -31,6 +31,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
tests/generic/659 +1 -0
@@ -31,6 +31,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
tests/generic/660 +1 -0
@@ -31,6 +31,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
tests/generic/663 +1 -0
@@ -32,6 +32,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _sweave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
tests/generic/664 +1 -0
@@ -34,6 +34,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _sweave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
tests/generic/665 +1 -0
@@ -34,6 +34,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _sweave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
tests/generic/670 +1 -0
@@ -31,6 +31,7 @@ mkdir $testdir loops=512 nr_loops=$((loops - 1)) blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz echo "Initialize files" echo >> $seqres.full
tests/generic/672 +1 -0
@@ -30,6 +30,7 @@ mkdir $testdir loops=1024 nr_loops=$((loops - 1)) blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz echo "Initialize files" echo >> $seqres.full
tests/xfs/1212 +1 -0
@@ -32,6 +32,7 @@ _require_xfs_io_error_injection "bmap_finish_one" _scratch_mkfs >> $seqres.full _scratch_mount +_require_congruent_file_oplen $SCRATCH_MNT 65536 # Create original file _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full
tests/xfs/420 +3 -0
@@ -69,6 +69,9 @@ exercise_lseek() { } blksz=65536 +# Golden output encodes SEEK_HOLE/DATA output, which depends on COW only +# happening on $blksz granularity +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=8 filesize=$((blksz * nr))
tests/xfs/421 +3 -0
@@ -51,6 +51,9 @@ testdir=$SCRATCH_MNT/test-$seq mkdir $testdir blksz=65536 +# Golden output encodes SEEK_HOLE/DATA output, which depends on COW only +# happening on $blksz granularity +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=8 filesize=$((blksz * nr))
PATCH 4/4 generic/303: avoid test failures on weird rt extent sizes
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Fix this test to skip the high offset reflink test if (on XFS) the rt extent size isn't congruent with the chosen target offset.
--- common/rc | 23 +++++++++++++++++++++++ tests/generic/303 | 8 +++++++- 2 files changed, 30 insertions(+), 1 deletion(-)
common/rc +23 -0
@@ -4488,6 +4488,29 @@ _get_file_block_size() esac } +_test_congruent_file_oplen() +{ + local file="$1" + local alloc_unit=$(_get_file_block_size "$file") + local oplen="$2" + + case $FSTYP in + nfs*|cifs|9p|virtiofs|ceph|glusterfs|overlay|pvfs2) + # Network filesystems don't know about (or tell the client + # about) the underlying file allocation unit and they generally + # pass the file IO request to the underlying filesystem, so we + # don't have anything to check here. + return + ;; + esac + + if [ $alloc_unit -gt $oplen ]; then + return 1 + fi + test $((oplen % alloc_unit)) -eq 0 || return 1 + return 0 +} + # Given a file path and a byte length of a file operation under test, ensure # that the length is an integer multiple of the file's allocation unit size. # In other words, skip the test unless (oplen ≡ alloc_unit mod 0). This is
tests/generic/303 +7 -1
@@ -48,7 +48,13 @@ echo "Reflink past maximum file size in dest file (should fail)" _reflink_range $testdir/file1 0 $testdir/file5 4611686018427322368 $len >> $seqres.full echo "Reflink high offset to low offset" -_reflink_range $testdir/file1 $bigoff_64k $testdir/file6 1048576 65535 >> $seqres.full +oplen=1048576 +if _test_congruent_file_oplen $testdir $oplen; then + _reflink_range $testdir/file1 $bigoff_64k $testdir/file6 $oplen 65535 >> $seqres.full +else + # If we can't do the ficlonerange test, fake it in the output file + $XFS_IO_PROG -f -c 'pwrite -S 0x61 1114110 1' $testdir/file6 >> $seqres.full +fi echo "Reflink past source file EOF (should fail)" _reflink_range $testdir/file2 524288 $testdir/file7 0 1048576 >> $seqres.full
cover fstests: functional tests for rt quota
In reply to Darrick J. WongHi all,
The sole patch in this series sets up functional testing for quota on the xfs realtime device.
If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=realtime-quotas
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-quotas
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-quotas
--- common/quota | 30 ++++++++++ tests/xfs/767 | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/767.out | 41 +++++++++++++ 3 files changed, 238 insertions(+) create mode 100755 tests/xfs/767 create mode 100644 tests/xfs/767.out
PATCH 1/1 xfs: regression testing of quota on the realtime device
From: Darrick J. Wong <[email protected]>
Make sure that quota accounting and enforcement work correctly for realtime volumes on XFS.
--- common/quota | 30 ++++++++++ tests/xfs/767 | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/767.out | 41 +++++++++++++ 3 files changed, 238 insertions(+) create mode 100755 tests/xfs/767 create mode 100644 tests/xfs/767.out
common/quota +30 -0
@@ -117,6 +117,36 @@ _require_xfs_quota_acct_enabled() _notrun "$qtype: accounting not enabled on $fsname filesystem." } +# Decide if the mounted filesystem supports realtime quotas. +_require_rtquota() +{ + local dev="$1" + test -z "$dev" && dev="$TEST_DEV" + local rtdev="$2" + test -z "$rtdev" && rtdev="$TEST_RTDEV" + + test "$FSTYP" = "xfs" || \ + _notrun "Realtime quota only supported on xfs" + + [ -n "$XFS_QUOTA_PROG" ] || \ + _notrun "xfs_quota user tool not installed" + + $here/src/feature -q $dev || \ + _notrun "Installed kernel does not support XFS quotas" + + test -b "$rtdev" || \ + _notrun "No realtime device supplied?" + + test "$USE_EXTERNAL" = "yes" || \ + _notrun "Realtime requires USE_EXTERNAL='yes'" + + $here/src/feature -U $dev || \ + $here/src/feature -G $dev || \ + $here/src/feature -P $dev || \ + _notrun "Mounted rt filesystem does not have quotas enabled" + +} + # # checks that xfs_quota can operate on foreign (non-xfs) filesystems # Skips check on xfs filesystems, old xfs_quota is fine there.
tests/xfs/767 new file +167 -0
167 lines not on this page · raw message
tests/xfs/767.out new file +41 -0
41 lines not on this page · raw message