xfsprogs: 4.13 rollup
cover xfsprogs: 4.13 rollup
Hi all,
Here are a few patches I have for xfsprogs 4.13. The first two continue some cleanups we did in libxfs, and a fix for 4.12's metadump stdout switcheroo. The next two are patches to xfs_db to enable dumping and writing of directory and attribute block fields. Finally, introduce the fuzz command that enables us to do easy fuzz testing of XFS metadata.
--Darrick
PATCH 1/7 xfs: remove double-underscore integer types
From: Darrick J. Wong <[email protected]>
This is a purely mechanical patch that removes the private __{u,}int{8,16,32,64}_t typedefs in favor of using the system {u,}int{8,16,32,64}_t typedefs. This is the sed script used to perform the transformation and fix the resulting whitespace and indentation errors:
s/typedef\t__uint8_t/typedef __uint8_t\t/g
s/typedef\t__uint/typedef __uint/g
s/typedef\t__int\([0-9]*\)_t/typedef int\1_t\t/g
s/__uint8_t\t/__uint8_t\t\t/g
s/__uint/uint/g
s/__int\([0-9]*\)_t\t/__int\1_t\t\t/g
s/__int/int/g
/^typedef.*int[0-9]*_t;$/d
--- copy/xfs_copy.c | 14 ++++---- copy/xfs_copy.h | 2 + db/attr.c | 8 ++--- db/attrshort.c | 4 +- db/bit.c | 4 +- db/bit.h | 2 + db/block.c | 8 ++--- db/check.c | 18 +++++------ db/convert.c | 28 ++++++++--------- db/faddr.c | 14 ++++---- db/field.c | 44 +++++++++++++------------- db/fprint.c | 8 ++--- db/frag.c | 8 ++--- db/inode.c | 34 ++++++++++---------- db/io.c | 2 + db/io.h | 6 ++-- db/metadump.c | 12 ++++--- db/sb.c | 6 ++-- fsr/xfs_fsr.c | 2 + include/darwin.h | 18 +++++------ include/freebsd.h | 6 ++-- include/gnukfreebsd.h | 6 ++-- include/libxcmd.h | 6 ++-- include/linux.h | 8 ++--- include/xfs_arch.h | 22 +++++++------ include/xfs_inode.h | 4 +- include/xfs_log_recover.h | 2 + include/xfs_metadump.h | 4 +- include/xfs_mount.h | 22 +++++++------ libhandle/handle.c | 2 + libhandle/jdm.c | 2 + libxcmd/topology.c | 14 ++++---- libxfs/darwin.c | 2 + libxfs/freebsd.c | 2 + libxfs/init.c | 2 + libxfs/irix.c | 2 + libxfs/libxfs_priv.h | 4 +- libxfs/linux.c | 2 + libxfs/logitem.c | 2 + libxfs/radix-tree.c | 8 ++--- libxfs/rdwr.c | 6 ++-- libxfs/util.c | 8 ++--- logprint/log_misc.c | 6 ++-- mdrestore/xfs_mdrestore.c | 2 + mkfs/proto.c | 2 + mkfs/xfs_mkfs.c | 76 +++++++++++++++++++++++---------------------- quota/edit.c | 64 +++++++++++++++++++------------------- quota/free.c | 44 +++++++++++++------------- quota/quot.c | 24 +++++++------- quota/quota.c | 4 +- quota/quota.h | 12 ++++--- quota/report.c | 4 +- quota/state.c | 2 + quota/util.c | 66 ++++++++++++++++++++------------------- repair/README | 2 + repair/agheader.h | 14 ++++---- repair/attr_repair.h | 26 ++++++++------- repair/avl64.c | 38 +++++++++++------------ repair/avl64.h | 18 +++++------ repair/dinode.c | 38 +++++++++++------------ repair/dinode.h | 4 +- repair/dir2.c | 2 + repair/globals.h | 16 +++++---- repair/incore.c | 10 +++--- repair/incore.h | 46 ++++++++++++++------------- repair/incore_ext.c | 6 ++-- repair/incore_ino.c | 72 +++++++++++++++++++++---------------------- repair/phase2.c | 2 + repair/phase3.c | 6 ++-- repair/phase4.c | 4 +- repair/phase5.c | 28 ++++++++--------- repair/phase6.c | 16 +++++---- repair/phase7.c | 6 ++-- repair/progress.c | 30 +++++++++--------- repair/progress.h | 4 +- repair/rmap.c | 18 +++++------ repair/rmap.h | 2 + repair/sb.c | 24 +++++++------- repair/scan.c | 50 +++++++++++++++--------------- repair/scan.h | 12 ++++--- 80 files changed, 589 insertions(+), 589 deletions(-)
copy/xfs_copy.c +7 -7
@@ -43,7 +43,7 @@ unsigned int source_sectorsize; /* source disk sectorsize */xfs_agblock_t first_agbno; -__uint64_t barcount[11 ]; +uint64_t barcount[11 ];unsigned int num_targets;target_control *target;
@@ -313,7 +313,7 @@ usage(void) }void -init_bar (__uint64_t source_blocks) +init_bar (uint64_t source_blocks) {int i;
@@ -322,7 +322,7 @@ init_bar(__uint64_t source_blocks) }int -bump_bar (int tenths,__uint64_t numblocks) +bump_bar (int tenths,uint64_t numblocks) {static char *bar[11 ] = {" 0% " ,
@@ -534,8 +534,8 @@ main(int argc, char **argv)xfs_off_t pos;size_t length;int c; -__uint64_t size, sizeb; -__uint64_t numblocks =0 ; +uint64_t size, sizeb; +uint64_t numblocks =0 ;int wblocks =0 ;int num_threads =0 ;struct dioattr d;
@@ -951,8 +951,8 @@ main(int argc, char **argv) num_ags = mp->m_sb.sb_agcount;init_bar (mp->m_sb.sb_blocksize /BBSIZE - * ((__uint64_t )mp->m_sb.sb_dblocks - - (__uint64_t )mp->m_sb.sb_fdblocks +10 * num_ags)); + * ((uint64_t )mp->m_sb.sb_dblocks + - (uint64_t )mp->m_sb.sb_fdblocks +10 * num_ags)); kids = num_targets;
copy/xfs_copy.h +1 -1
@@ -76,7 +76,7 @@ typedef struct {typedef int thread_id ;typedef int tm_index ;/* index into thread mask array */ -typedef __uint32_t thread_mask ;/* a thread mask */ +typedef uint32_t thread_mask ;/* a thread mask */ typedef struct { char *name;
db/attr.c +4 -4
@@ -77,16 +77,16 @@ const field_t attr_leaf_entry_flds[] = { { "nameidx", FLDT_UINT16D, OI(LEOFF(nameidx)), C1, 0, TYP_NONE }, { "flags", FLDT_UINT8X, OI(LEOFF(flags)), C1, FLD_SKIPALL, TYP_NONE }, { "incomplete", FLDT_UINT1, -OI (LEOFF (flags) +bitsz (__uint8_t) -XFS_ATTR_INCOMPLETE_BIT -1 ),C1 , +OI (LEOFF (flags) +bitsz (uint8_t) -XFS_ATTR_INCOMPLETE_BIT -1 ),C1 , 0, TYP_NONE }, { "root", FLDT_UINT1, -OI (LEOFF (flags) +bitsz (__uint8_t) -XFS_ATTR_ROOT_BIT -1 ),C1 ,0 , +OI (LEOFF (flags) +bitsz (uint8_t) -XFS_ATTR_ROOT_BIT -1 ),C1 ,0 , TYP_NONE }, { "secure", FLDT_UINT1, -OI (LEOFF (flags) +bitsz (__uint8_t) -XFS_ATTR_SECURE_BIT -1 ),C1 ,0 , +OI (LEOFF (flags) +bitsz (uint8_t) -XFS_ATTR_SECURE_BIT -1 ),C1 ,0 , TYP_NONE }, { "local", FLDT_UINT1, -OI (LEOFF (flags) +bitsz (__uint8_t) -XFS_ATTR_LOCAL_BIT -1 ),C1 ,0 , +OI (LEOFF (flags) +bitsz (uint8_t) -XFS_ATTR_LOCAL_BIT -1 ),C1 ,0 , TYP_NONE }, { "pad2", FLDT_UINT8X, OI(LEOFF(pad2)), C1, FLD_SKIPALL, TYP_NONE }, { NULL }
db/attrshort.c +2 -2
@@ -51,10 +51,10 @@ const field_t attr_sf_entry_flds[] = { { "valuelen", FLDT_UINT8D, OI(EOFF(valuelen)), C1, 0, TYP_NONE }, { "flags", FLDT_UINT8X, OI(EOFF(flags)), C1, FLD_SKIPALL, TYP_NONE }, { "root", FLDT_UINT1, -OI (EOFF (flags) +bitsz (__uint8_t) -XFS_ATTR_ROOT_BIT -1 ),C1 ,0 , +OI (EOFF (flags) +bitsz (uint8_t) -XFS_ATTR_ROOT_BIT -1 ),C1 ,0 , TYP_NONE }, { "secure", FLDT_UINT1, -OI (EOFF (flags) +bitsz (__uint8_t) -XFS_ATTR_SECURE_BIT -1 ),C1 ,0 , +OI (EOFF (flags) +bitsz (uint8_t) -XFS_ATTR_SECURE_BIT -1 ),C1 ,0 , TYP_NONE }, { "name", FLDT_CHARNS, OI(EOFF(nameval)), attr_sf_entry_name_count, FLD_COUNT, TYP_NONE },
db/bit.c +2 -2
@@ -60,7 +60,7 @@ setbit( } } -__int64_t +int64_t getbitval( void *obj, int bitoff,
@@ -70,7 +70,7 @@ getbitval(int bit;int i;char *p; -__int64_t rval; +int64_t rval;int signext;int z1, z2, z3, z4;
db/bit.h +1 -1
@@ -25,5 +25,5 @@#define BVUNSIGNED 0#define BVSIGNED 1 -extern __int64_t getbitval (void *obj,int bitoff,int nbits,int flags); +extern int64_t getbitval (void *obj,int bitoff,int nbits,int flags);extern void setbitval (void *obuf,int bitoff,int nbits,void *ibuf);
db/block.c +4 -4
@@ -98,7 +98,7 @@ ablock_f( } dfsbno = bm.startblock + (bno - bm.startoff);ASSERT (typtab[TYP_ATTR ].typnm ==TYP_ATTR ); -set_cur (&typtab[TYP_ATTR ], (__int64_t )XFS_FSB_TO_DADDR (mp, dfsbno), +set_cur (&typtab[TYP_ATTR ], (int64_t )XFS_FSB_TO_DADDR (mp, dfsbno), blkbb,DB_RING_ADD ,NULL );return 0 ; }
@@ -128,14 +128,14 @@ daddr_f(int argc, char **argv) { - __int64_t d; + int64_t d;char *p;if (argc ==1 ) {dbprintf (_ ("current daddr is %lld\n" ), iocur_top->off >>BBSHIFT );return 0 ; } - d = (__int64_t )strtoull (argv[1 ], &p,0 ); + d = (int64_t )strtoull (argv[1 ], &p,0 );if (*p !='\0' || d >= mp->m_sb.sb_dblocks << (mp->m_sb.sb_blocklog -BBSHIFT )) {dbprintf (_ ("bad daddr %s\n" ), argv[1 ]);
@@ -197,7 +197,7 @@ dblock_f(ASSERT (typtab[type].typnm == type);if (nex >1 )make_bbmap (&bbmap, nex, bmp); -set_cur (&typtab[type], (__int64_t )XFS_FSB_TO_DADDR (mp, dfsbno), +set_cur (&typtab[type], (int64_t )XFS_FSB_TO_DADDR (mp, dfsbno), nb * blkbb,DB_RING_ADD , nex >1 ? &bbmap :NULL );free (bmp);return 0 ;
db/check.c +9 -9
@@ -114,8 +114,8 @@ typedef struct dirhash {static xfs_extlen_t agffreeblks;static xfs_extlen_t agflongest; -static __uint64_t agf_aggr_freeblks;/* aggregate count over all */ -static __uint32_t agfbtreeblks; +static uint64_t agf_aggr_freeblks;/* aggregate count over all */ +static uint32_t agfbtreeblks;static int lazycount;static xfs_agino_t agicount;static xfs_agino_t agifreecount;
@@ -124,10 +124,10 @@ static int blist_size;static char **dbmap;/* really dbm_t:8 */ static dirhash_t **dirhash;static int error; -static __uint64_t fdblocks; -static __uint64_t frextents; -static __uint64_t icount; -static __uint64_t ifree; +static uint64_t fdblocks; +static uint64_t frextents; +static uint64_t icount; +static uint64_t ifree;static inodata_t ***inodata;static int inodata_hash_size;static inodata_t ***inomap;
@@ -1187,7 +1187,7 @@ blocktrash_f( goto out; }for (i =0 ; i < count; i++) { - randb = (xfs_rfsblock_t)((((__int64_t )random () <<32 ) | + randb = (xfs_rfsblock_t)((((int64_t )random () <<32 ) |random ()) % blocks); for (bi = 0, agno = 0, done = 0; !done && agno < mp->m_sb.sb_agcount;
@@ -3032,7 +3032,7 @@ process_leaf_node_dir_v2( }if (v)dbprintf (_ ("dir inode %lld block %u=%llu\n" ), id->ino, - (__uint32_t )dbno, + (uint32_t )dbno, (xfs_fsblock_t )bmp->startblock);push_cur ();if (nex >1 )
@@ -3045,7 +3045,7 @@ process_leaf_node_dir_v2(if (!sflag || v)dbprintf (_ ("can't read block %u for directory " "inode %lld\n" ), - (__uint32_t )dbno, id->ino); + (uint32_t )dbno, id->ino); error++;pop_cur (); dbno += mp->m_dir_geo->fsbcount -1 ;
db/convert.c +14 -14
@@ -24,13 +24,13 @@#define M (A ) (1 << CT_ ## A)#define agblock_to_bytes (x) \ - ((__uint64_t)(x) << mp->m_sb.sb_blocklog) + ((uint64_t)(x) << mp->m_sb.sb_blocklog)#define agino_to_bytes (x) \ - ((__uint64_t)(x) << mp->m_sb.sb_inodelog) + ((uint64_t)(x) << mp->m_sb.sb_inodelog)#define agnumber_to_bytes (x) \ - agblock_to_bytes((__uint64_t)(x) * mp->m_sb.sb_agblocks) + agblock_to_bytes((uint64_t)(x) * mp->m_sb.sb_agblocks)#define daddr_to_bytes (x) \ - ((__uint64_t)(x) << BBSHIFT) + ((uint64_t)(x) << BBSHIFT)#define fsblock_to_bytes (x) \ (agnumber_to_bytes(XFS_FSB_TO_AGNO(mp, (x))) + \ agblock_to_bytes(XFS_FSB_TO_AGBNO(mp, (x))))
@@ -38,7 +38,7 @@ (agnumber_to_bytes (XFS_INO_TO_AGNO (mp, (x))) + \ agino_to_bytes(XFS_INO_TO_AGINO(mp, (x))))#define inoidx_to_bytes (x) \ - ((__uint64_t)(x) << mp->m_sb.sb_inodelog) + ((uint64_t)(x) << mp->m_sb.sb_inodelog) typedef enum { CT_NONE = -1,
@@ -68,7 +68,7 @@ typedef union {xfs_agnumber_t agnumber;int bboff;int blkoff; -__uint64_t byte; +uint64_t byte;xfs_daddr_t daddr;xfs_fsblock_t fsblock;xfs_ino_t ino;
@@ -76,7 +76,7 @@ typedef union {int inooff; } cval_t; -static __uint64_t bytevalue (ctype_t ctype,cval_t *val); +static uint64_t bytevalue (ctype_t ctype,cval_t *val);static int convert_f (int argc,char **argv);static int getvalue (char *s,ctype_t ctype,cval_t *val);static ctype_t lookupcty (char *ctyname);
@@ -118,7 +118,7 @@ static const cmdinfo_t convert_cmd = {"convert" ,NULL , convert_f,3 ,9 ,0 ,"type num [type num]... type" , "convert from one address form to another", NULL }; -static __uint64_t +static uint64_t bytevalue (ctype_t ctype,cval_t *val) {switch (ctype) {
@@ -129,9 +129,9 @@ bytevalue(ctype_t ctype, cval_t *val)case CT_AGNUMBER :return agnumber_to_bytes (val->agnumber);case CT_BBOFF : -return (__uint64_t )val->bboff; +return (uint64_t )val->bboff;case CT_BLKOFF : -return (__uint64_t )val->blkoff; +return (uint64_t )val->blkoff;case CT_BYTE :return val->byte;case CT_DADDR :
@@ -143,7 +143,7 @@ bytevalue(ctype_t ctype, cval_t *val)case CT_INOIDX :return inoidx_to_bytes (val->inoidx);case CT_INOOFF : -return (__uint64_t )val->inooff; +return (uint64_t )val->inooff;case CT_NONE :case NCTS :break ;
@@ -160,7 +160,7 @@ convert_f(int argc, char **argv)cval_t cvals[NCTS ] = {};int i;int mask; -__uint64_t v; +uint64_t v;ctype_t wtype;/* move past the "convert" command */
@@ -262,7 +262,7 @@ static int getvalue(char *s, ctype_t ctype, cval_t *val) {char *p; -__uint64_t v; +uint64_t v; v =strtoull (s, &p,0 );if (*p !='\0' ) {
@@ -286,7 +286,7 @@ getvalue(char *s, ctype_t ctype, cval_t *val) val->blkoff = (int )v;break ;case CT_BYTE : - val->byte = (__uint64_t )v; + val->byte = (uint64_t )v;break ;case CT_DADDR : val->daddr = (xfs_daddr_t )v;
db/faddr.c +7 -7
@@ -79,11 +79,11 @@ fa_attrblock( typnm_t next) {bmap_ext_t bm; -__uint32_t bno; +uint32_t bno;xfs_fsblock_t dfsbno;int nex; - bno = (__uint32_t )getbitval (obj, bit,bitsz (bno),BVUNSIGNED ); + bno = (uint32_t )getbitval (obj, bit,bitsz (bno),BVUNSIGNED );if (bno ==0 ) {dbprintf (_ ("null attribute block number, cannot set new addr\n" ));return ;
@@ -96,7 +96,7 @@ fa_attrblock( } dfsbno = bm.startblock + (bno - bm.startoff);ASSERT (typtab[next].typnm == next); -set_cur (&typtab[next], (__int64_t )XFS_FSB_TO_DADDR (mp, dfsbno), blkbb, +set_cur (&typtab[next], (int64_t )XFS_FSB_TO_DADDR (mp, dfsbno), blkbb,DB_RING_ADD ,NULL ); }
@@ -276,11 +276,11 @@ fa_dirblock( {bbmap_t bbmap;bmap_ext_t *bmp; -__uint32_t bno; +uint32_t bno;xfs_fsblock_t dfsbno;int nex; - bno = (__uint32_t )getbitval (obj, bit,bitsz (bno),BVUNSIGNED ); + bno = (uint32_t )getbitval (obj, bit,bitsz (bno),BVUNSIGNED );if (bno ==0 ) {dbprintf (_ ("null directory block number, cannot set new addr\n" ));return ;
@@ -297,7 +297,7 @@ fa_dirblock(ASSERT (typtab[next].typnm == next);if (nex >1 )make_bbmap (&bbmap, nex, bmp); -set_cur (&typtab[next], (__int64_t )XFS_FSB_TO_DADDR (mp, dfsbno), +set_cur (&typtab[next], (int64_t )XFS_FSB_TO_DADDR (mp, dfsbno),XFS_FSB_TO_BB (mp, mp->m_dir_geo->fsbcount),DB_RING_ADD , nex >1 ? &bbmap :NULL );free (bmp);
@@ -317,7 +317,7 @@ fa_drfsbno(return ; }ASSERT (typtab[next].typnm == next); -set_cur (&typtab[next], (__int64_t )XFS_FSB_TO_BB (mp, bno), blkbb, +set_cur (&typtab[next], (int64_t )XFS_FSB_TO_BB (mp, bno), blkbb,DB_RING_ADD ,NULL ); }
db/field.c +22 -22
99 lines not on this page · raw message
db/fprint.c +4 -4
@@ -80,7 +80,7 @@ fp_num(int bitpos;int i;int isnull; -__int64_t val; +int64_t val; for (i = 0, bitpos = bit; i < count && !seenint();
@@ -100,7 +100,7 @@ fp_num(else if (size >32 )dbprintf (fmtstr, val);else -dbprintf (fmtstr, (__int32_t )val); +dbprintf (fmtstr, (int32_t )val);if (i < count -1 )dbprintf (" " ); }
@@ -203,7 +203,7 @@ fp_crc( {int bitpos;int i; -__int64_t val; +int64_t val;char *ok;switch (iocur_crc_valid ()) {
@@ -230,7 +230,7 @@ fp_crc(if (size >32 )dbprintf (fmtstr, val, ok);else -dbprintf (fmtstr, (__int32_t )val, ok); +dbprintf (fmtstr, (int32_t )val, ok);if (i < count -1 )dbprintf (" " ); }
db/frag.c +4 -4
@@ -42,8 +42,8 @@ typedef struct extmap {static int aflag;static int dflag; -static __uint64_t extcount_actual; -static __uint64_t extcount_ideal; +static uint64_t extcount_actual; +static uint64_t extcount_ideal;static int fflag;static int lflag;static int qflag;
@@ -310,8 +310,8 @@ process_inode(xfs_agino_t agino, xfs_dinode_t *dip) { - __uint64_t actual; -__uint64_t ideal; + uint64_t actual; +uint64_t ideal;xfs_ino_t ino;int skipa;int skipd;
db/inode.c +17 -17
@@ -119,49 +119,49 @@ const field_t inode_core_flds[] = { { "dmstate", FLDT_UINT16D, OI(COFF(dmstate)), C1, 0, TYP_NONE }, { "flags", FLDT_UINT16X, OI(COFF(flags)), C1, FLD_SKIPALL, TYP_NONE }, { "newrtbm", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_NEWRTBM_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NEWRTBM_BIT -1 ),C1 , 0, TYP_NONE }, { "prealloc", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_PREALLOC_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_PREALLOC_BIT -1 ),C1 , 0, TYP_NONE }, { "realtime", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_REALTIME_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_REALTIME_BIT -1 ),C1 , 0, TYP_NONE }, { "immutable", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_IMMUTABLE_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_IMMUTABLE_BIT -1 ),C1 , 0, TYP_NONE }, { "append", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_APPEND_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_APPEND_BIT -1 ),C1 , 0, TYP_NONE }, { "sync", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_SYNC_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_SYNC_BIT -1 ),C1 , 0, TYP_NONE }, { "noatime", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_NOATIME_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NOATIME_BIT -1 ),C1 , 0, TYP_NONE }, { "nodump", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_NODUMP_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NODUMP_BIT -1 ),C1 , 0, TYP_NONE }, { "rtinherit", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_RTINHERIT_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_RTINHERIT_BIT -1 ),C1 , 0, TYP_NONE }, { "projinherit", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_PROJINHERIT_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_PROJINHERIT_BIT -1 ),C1 , 0, TYP_NONE }, { "nosymlinks", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_NOSYMLINKS_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NOSYMLINKS_BIT -1 ),C1 , 0, TYP_NONE }, { "extsz", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_EXTSIZE_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSIZE_BIT -1 ),C1 , 0, TYP_NONE }, { "extszinherit", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_EXTSZINHERIT_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSZINHERIT_BIT -1 ),C1 , 0, TYP_NONE }, { "nodefrag", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_NODEFRAG_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NODEFRAG_BIT -1 ),C1 , 0, TYP_NONE }, { "filestream", FLDT_UINT1, -OI (COFF (flags) +bitsz (__uint16_t) -XFS_DIFLAG_FILESTREAM_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_FILESTREAM_BIT -1 ),C1 , 0, TYP_NONE }, { "gen", FLDT_UINT32D, OI(COFF(gen)), C1, 0, TYP_NONE }, { NULL }
@@ -177,10 +177,10 @@ const field_t inode_v3_flds[] = { { "inumber", FLDT_INO, OI(COFF(ino)), C1, 0, TYP_NONE }, { "uuid", FLDT_UUID, OI(COFF(uuid)), C1, 0, TYP_NONE }, { "reflink", FLDT_UINT1, -OI (COFF (flags2) +bitsz (__uint64_t) -XFS_DIFLAG2_REFLINK_BIT -1 ),C1 , +OI (COFF (flags2) +bitsz (uint64_t) -XFS_DIFLAG2_REFLINK_BIT -1 ),C1 , 0, TYP_NONE }, { "cowextsz", FLDT_UINT1, -OI (COFF (flags2) +bitsz (__uint64_t) -XFS_DIFLAG2_COWEXTSIZE_BIT -1 ),C1 , +OI (COFF (flags2) +bitsz (uint64_t) -XFS_DIFLAG2_COWEXTSIZE_BIT -1 ),C1 , 0, TYP_NONE }, { NULL } };
db/io.c +1 -1
@@ -545,7 +545,7 @@ set_cur(struct xfs_buf *bp;xfs_ino_t dirino;xfs_ino_t ino; -__uint16_t mode; +uint16_t mode;const struct xfs_buf_ops *ops = type ? type->bops :NULL ;if (iocur_sp <0 ) {
db/io.h +3 -3
@@ -25,7 +25,7 @@ typedef struct bbmap { } bbmap_t; typedef struct iocur { - __int64_t bb; /* BB number in filesystem of buf */ + int64_t bb; /* BB number in filesystem of buf */ int blen; /* length of "buf", bb's */ int boff; /* data - buf */ void *buf; /* base address of buffer */
@@ -33,7 +33,7 @@ typedef struct iocur {xfs_ino_t dirino;/* current directory inode number */ xfs_ino_t ino;/* current inode number */ int len;/* length of "data", bytes */ -__uint16_t mode;/* current inode's mode */ +uint16_t mode;/* current inode's mode */ xfs_off_t off;/* fs offset of "data" in bytes */ const struct typ *typ;/* type of "data" */ bbmap_t *bbmap;/* map daddr if fragmented */
@@ -57,7 +57,7 @@ extern void off_cur(int off, int len);extern void pop_cur (void );extern void print_iocur (char *tag,iocur_t *ioc);extern void push_cur (void ); -extern int read_buf (__int64_t daddr,int count,void *bufp); +extern int read_buf (int64_t daddr,int count,void *bufp);extern void write_cur (void );extern void set_cur (const struct typ *type,xfs_daddr_t blknum,int len,int ring_add,bbmap_t *bbmap);
db/metadump.c +6 -6
@@ -175,7 +175,7 @@ write_index(void)static int write_buf_segment (char *data, -__int64_t off, +int64_t off,int len) {int i;
@@ -1256,7 +1256,7 @@ process_sf_dir( {struct xfs_dir2_sf_hdr *sfp;xfs_dir2_sf_entry_t *sfep; -__uint64_t ino_dir_size; +uint64_t ino_dir_size;int i; sfp = (struct xfs_dir2_sf_hdr *)XFS_DFORK_DPTR (dip);
@@ -1322,7 +1322,7 @@ process_sf_dir(static void obfuscate_path_components (char *buf, -__uint64_t len) +uint64_t len) {unsigned char *comp = (unsigned char *)buf;unsigned char *end = comp + len;
@@ -1359,7 +1359,7 @@ static voidprocess_sf_symlink ( xfs_dinode_t *dip) { -__uint64_t len; +uint64_t len;char *buf; len =be64_to_cpu (dip->di_size);
@@ -1631,7 +1631,7 @@ process_attr_block(xfs_attr_leaf_entry_t *entry;xfs_attr_leaf_name_local_t *local;xfs_attr_leaf_name_remote_t *remote; -__uint32_t bs = mp->m_sb.sb_blocksize; +uint32_t bs = mp->m_sb.sb_blocksize;char *first_name;
@@ -2270,7 +2270,7 @@ process_inode(return success; } -static __uint32_t inodes_copied =0 ; +static uint32_t inodes_copied =0 ;static int copy_inode_chunk(
db/sb.c +3 -3
@@ -606,7 +606,7 @@ version_help(void) }static int -do_version (xfs_agnumber_t agno,__uint16_t version,__uint32_t features) +do_version (xfs_agnumber_t agno,uint16_t version,uint32_t features) {xfs_sb_t tsb;
@@ -710,8 +710,8 @@ version_f(int argc, char **argv) { - __uint16_t version = 0; -__uint32_t features =0 ; + uint16_t version = 0; +uint32_t features =0 ;xfs_agnumber_t ag;if (argc ==2 ) {/* WRITE VERSION */
fsr/xfs_fsr.c +1 -1
@@ -54,7 +54,7 @@ struct getbmap *outmap = NULL;int outmap_size =0 ;int RealUid;int tmp_agi; -static __int64_t minimumfree =2048 ; +static int64_t minimumfree =2048 ;#define MNTTYPE_XFS "xfs"
include/darwin.h +9 -9
@@ -125,15 +125,15 @@ typedef signed int __s32;typedef unsigned long long int __u64 ;typedef signed long long int __s64 ; -#define __int8_t int8_t -#define __int16_t int16_t -#define __int32_t int32_t -#define __int32_t int32_t -#define __int64_t int64_t -#define __uint8_t u_int8_t -#define __uint16_t u_int16_t -#define __uint32_t u_int32_t -#define __uint64_t u_int64_t +#define int8_t int8_t +#define int16_t int16_t +#define int32_t int32_t +#define int32_t int32_t +#define int64_t int64_t +#define uint8_t u_int8_t +#define uint16_t u_int16_t +#define uint32_t u_int32_t +#define uint64_t u_int64_ttypedef off_t xfs_off_t ;typedef u_int64_t xfs_ino_t ;
include/freebsd.h +3 -3
@@ -50,9 +50,9 @@ typedef unsigned long long int __u64;typedef signed long long int __s64 ;typedef off_t xfs_off_t ; -typedef __uint64_t xfs_ino_t ; -typedef __uint32_t xfs_dev_t ; -typedef __int64_t xfs_daddr_t ; +typedef uint64_t xfs_ino_t ; +typedef uint32_t xfs_dev_t ; +typedef int64_t xfs_daddr_t ;typedef __u32 xfs_nlink_t ;#define O_LARGEFILE 0
include/gnukfreebsd.h +3 -3
@@ -46,9 +46,9 @@ typedef unsigned long long int __u64;typedef signed long long int __s64 ;typedef off_t xfs_off_t ; -typedef __uint64_t xfs_ino_t ; -typedef __uint32_t xfs_dev_t ; -typedef __int64_t xfs_daddr_t ; +typedef uint64_t xfs_ino_t ; +typedef uint32_t xfs_dev_t ; +typedef int64_t xfs_daddr_t ;typedef __u32 xfs_nlink_t ;#define HAVE_FID 1
include/libxcmd.h +3 -3
@@ -42,10 +42,10 @@ get_topology(extern void calc_default_ag_geometry (int blocklog, -__uint64_t dblocks, +uint64_t dblocks,int multidisk, -__uint64_t *agsize, -__uint64_t *agcount); +uint64_t *agsize, +uint64_t *agcount);extern int check_overwrite(
include/linux.h +4 -4
@@ -132,7 +132,7 @@ static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)static __inline__int platform_discard_blocks (int fd,uint64_t start,uint64_t len) { -__uint64_t range[2 ] = { start, len }; +uint64_t range[2 ] = { start, len };if (ioctl (fd,BLKDISCARD , &range) <0 )return errno;
@@ -144,9 +144,9 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len)#define EFSBADCRC EBADMSG/* Bad CRC detected */ typedef off_t xfs_off_t ; -typedef __uint64_t xfs_ino_t ; -typedef __uint32_t xfs_dev_t ; -typedef __int64_t xfs_daddr_t ; +typedef uint64_t xfs_ino_t ; +typedef uint32_t xfs_dev_t ; +typedef int64_t xfs_daddr_t ;typedef __u32 xfs_nlink_t ;/**
include/xfs_arch.h +11 -11
@@ -244,39 +244,39 @@ static inline void be64_add_cpu(__be64 *a, __s64 b) *a =cpu_to_be64 (be64_to_cpu (*a) + b); } -static inline __uint16_t get_unaligned_be16 (void *p) +static inline uint16_t get_unaligned_be16 (void *p) { -__uint8_t *__p = p; +uint8_t *__p = p;return __p[0 ] <<8 | __p[1 ]; } -static inline __uint32_t get_unaligned_be32 (void *p) +static inline uint32_t get_unaligned_be32 (void *p) { -__uint8_t *__p = p; +uint8_t *__p = p;return __p[0 ] <<24 | __p[1 ] <<16 | __p[2 ] <<8 | __p[3 ]; } -static inline __uint64_t get_unaligned_be64 (void *p) +static inline uint64_t get_unaligned_be64 (void *p) { -return (__uint64_t )get_unaligned_be32 (p) <<32 | +return (uint64_t )get_unaligned_be32 (p) <<32 |get_unaligned_be32 (p +4 ); } -static inline void put_unaligned_be16 (__uint16_t val,void *p) +static inline void put_unaligned_be16 (uint16_t val,void *p) { -__uint8_t *__p = p; +uint8_t *__p = p; *__p++ = val >>8 ; *__p++ = val; } -static inline void put_unaligned_be32 (__uint32_t val,void *p) +static inline void put_unaligned_be32 (uint32_t val,void *p) { -__uint8_t *__p = p; +uint8_t *__p = p;put_unaligned_be16 (val >>16 , __p);put_unaligned_be16 (val, __p +2 ); } -static inline void put_unaligned_be64 (__uint64_t val,void *p) +static inline void put_unaligned_be64 (uint64_t val,void *p) {put_unaligned_be32 (val >>32 , p);put_unaligned_be32 (val, p +4 );
include/xfs_inode.h +2 -2
@@ -123,8 +123,8 @@ xfs_get_projid(struct xfs_icdinode *id)static inline void xfs_set_projid (struct xfs_icdinode *id,prid_t projid) { - id->di_projid_hi = (__uint16_t) (projid >>16 ); - id->di_projid_lo = (__uint16_t) (projid &0xffff ); + id->di_projid_hi = (uint16_t ) (projid >>16 ); + id->di_projid_lo = (uint16_t ) (projid &0xffff ); }static inline bool xfs_is_reflink_inode (struct xfs_inode *ip)
include/xfs_log_recover.h +1 -1
@@ -26,7 +26,7 @@#define XLOG_RHASH_SIZE 16#define XLOG_RHASH_SHIFT 2#define XLOG_RHASH (tid) \ - ((((__uint32_t)tid)>>XLOG_RHASH_SHIFT) & (XLOG_RHASH_SIZE-1)) + ((((uint32_t)tid)>>XLOG_RHASH_SHIFT) & (XLOG_RHASH_SIZE-1))#define XLOG_MAX_REGIONS_IN_ITEM (XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK / 2 + 1)
include/xfs_metadump.h +2 -2
@@ -24,8 +24,8 @@typedef struct xfs_metablock {__be32 mb_magic;__be16 mb_count; -__uint8_t mb_blocklog; -__uint8_t mb_info; +uint8_t mb_blocklog; +uint8_t mb_info;/* followed by an array of xfs_daddr_t */ }xfs_metablock_t ;
include/xfs_mount.h +11 -11
@@ -48,12 +48,12 @@ typedef struct xfs_mount {#define m_dev m_ddev_targp#define m_logdev m_logdev_targp#define m_rtdev m_rtdev_targp -__uint8_t m_dircook_elog;/* log d-cookie entry bits */ -__uint8_t m_blkbit_log;/* blocklog + NBBY */ -__uint8_t m_blkbb_log;/* blocklog - BBSHIFT */ -__uint8_t m_sectbb_log;/* sectorlog - BBSHIFT */ -__uint8_t m_agno_log;/* log #ag's */ -__uint8_t m_agino_log;/* #bits for agino in inum */ +uint8_t m_dircook_elog;/* log d-cookie entry bits */ +uint8_t m_blkbit_log;/* blocklog + NBBY */ +uint8_t m_blkbb_log;/* blocklog - BBSHIFT */ +uint8_t m_sectbb_log;/* sectorlog - BBSHIFT */ +uint8_t m_agno_log;/* log #ag's */ +uint8_t m_agino_log;/* #bits for agino in inum */ uint m_inode_cluster_size;/* min inode buf size */ uint m_blockmask;/* sb_blocksize-1 */ uint m_blockwsize;/* sb_blocksize in words */
@@ -88,7 +88,7 @@ typedef struct xfs_mount {int m_litino;/* size of inode union area */ int m_inoalign_mask;/* mask sb_inoalignmt if used */ struct xfs_trans_resv m_resv;/* precomputed res values */ -__uint64_t m_maxicount;/* maximum inode count */ +uint64_t m_maxicount;/* maximum inode count */ int m_dalign;/* stripe unit */ int m_swidth;/* stripe width */ int m_sinoalign;/* stripe unit inode alignmnt */
@@ -144,12 +144,12 @@ typedef struct xfs_perag {char pagi_init;/* this agi's entry is initialized */ char pagf_metadata;/* the agf is preferred to be metadata */ char pagi_inodeok;/* The agi is ok for inodes */ -__uint8_t pagf_levels[XFS_BTNUM_AGF ]; +uint8_t pagf_levels[XFS_BTNUM_AGF ];/* # of levels in bno & cnt btree */ -__uint32_t pagf_flcount;/* count of blocks in freelist */ +uint32_t pagf_flcount;/* count of blocks in freelist */ xfs_extlen_t pagf_freeblks;/* total free blocks */ xfs_extlen_t pagf_longest;/* longest free space */ -__uint32_t pagf_btreeblks;/* # of blocks held in AGF btrees */ +uint32_t pagf_btreeblks;/* # of blocks held in AGF btrees */ xfs_agino_t pagi_freecount;/* number of free inodes */ xfs_agino_t pagi_count;/* number of allocated inodes */
@@ -169,7 +169,7 @@ typedef struct xfs_perag {struct xfs_ag_resv pag_agfl_resv;/* reference count */ -__uint8_t pagf_refcount_level; +uint8_t pagf_refcount_level; } xfs_perag_t; static inline struct xfs_ag_resv *
libhandle/handle.c +1 -1
@@ -232,7 +232,7 @@ obj_to_handle( {char hbuf [MAXHANSIZ ];int ret; -__uint32_t handlen; +uint32_t handlen;xfs_fsop_handlereq_t hreq;if (opcode ==XFS_IOC_FD_TO_HANDLE ) {
libhandle/jdm.c +1 -1
@@ -36,7 +36,7 @@ typedef struct filehandle {fshandle_t fh_fshandle;/* handle of fs containing this inode */ int16_t fh_sz_following;/* bytes in handle after this member */ char fh_pad[FILEHANDLE_SZ_PAD ];/* padding, must be zeroed */ -__uint32_t fh_gen;/* generation count */ +uint32_t fh_gen;/* generation count */ xfs_ino_t fh_ino;/* 64 bit ino */ } filehandle_t;
libxcmd/topology.c +7 -7
@@ -23,19 +23,19 @@#endif /* ENABLE_BLKID */ #include "xfs_multidisk.h" -#define TERABYTES (count, blog) ((__uint64_t)(count) << (40 - (blog))) -#define GIGABYTES (count, blog) ((__uint64_t)(count) << (30 - (blog))) -#define MEGABYTES (count, blog) ((__uint64_t)(count) << (20 - (blog))) +#define TERABYTES (count, blog) ((uint64_t)(count) << (40 - (blog))) +#define GIGABYTES (count, blog) ((uint64_t)(count) << (30 - (blog))) +#define MEGABYTES (count, blog) ((uint64_t)(count) << (20 - (blog)))void calc_default_ag_geometry (int blocklog, -__uint64_t dblocks, +uint64_t dblocks,int multidisk, -__uint64_t *agsize, -__uint64_t *agcount) +uint64_t *agsize, +uint64_t *agcount) { -__uint64_t blocks =0 ; +uint64_t blocks =0 ;int shift =0 ;/*
libxfs/darwin.c +1 -1
@@ -68,7 +68,7 @@ platform_flush_device(int fd, dev_t device)void platform_findsizes (char *path,int fd,long long *sz,int *bsz) { -__uint64_t size; +uint64_t size;struct stat st;if (fstat (fd, &st) <0 ) {
libxfs/freebsd.c +1 -1
@@ -109,7 +109,7 @@ void platform_findsizes(char *path, int fd, long long *sz, int *bsz) {struct stat st; -__int64_t size; +int64_t size;u_int ssize;if (fstat (fd, &st) <0 ) {
libxfs/init.c +1 -1
@@ -546,7 +546,7 @@ libxfs_initialize_perag(* the max inode percentage. */ if (mp->m_maxicount) { -__uint64_t icount; +uint64_t icount; icount = sbp->sb_dblocks * sbp->sb_imax_pct;do_div (icount,100 );
libxfs/irix.c +1 -1
@@ -22,7 +22,7 @@int platform_has_uuid =0 ;extern char *progname; -extern __int64_t findsize (char *); +extern int64_t findsize (char *);int platform_check_ismounted (char *name,char *block,struct stat *s,int verbose)
libxfs/libxfs_priv.h +2 -2
@@ -296,8 +296,8 @@ roundup_pow_of_two(uint v)return 0 ; } -static inline __uint64_t -roundup_64 (__uint64_t x,__uint32_t y) +static inline uint64_t +roundup_64 (uint64_t x,uint32_t y) { x += y -1 ;do_div (x, y);
libxfs/linux.c +1 -1
@@ -163,7 +163,7 @@ void platform_findsizes(char *path, int fd, long long *sz, int *bsz) {struct stat st; -__uint64_t size; +uint64_t size;int error;if (fstat (fd, &st) <0 ) {
libxfs/logitem.c +1 -1
@@ -121,7 +121,7 @@ xfs_buf_item_init( bip->bli_item.li_mountp = mp; bip->bli_buf = bp; bip->bli_format.blf_type =XFS_LI_BUF ; - bip->bli_format.blf_blkno = (__int64_t )XFS_BUF_ADDR (bp); + bip->bli_format.blf_blkno = (int64_t )XFS_BUF_ADDR (bp); bip->bli_format.blf_len = (unsigned short )BTOBB (XFS_BUF_COUNT (bp));XFS_BUF_SET_FSPRIVATE (bp, bip); }
libxfs/radix-tree.c +4 -4
@@ -66,21 +66,21 @@ static unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH];static inline void tag_set (struct radix_tree_node *node,unsigned int tag,int offset) { - *((__uint32_t *)node->tags[tag] + (offset >>5 )) |= (1 << (offset &31 )); + *((uint32_t *)node->tags[tag] + (offset >>5 )) |= (1 << (offset &31 )); }static inline void tag_clear (struct radix_tree_node *node,unsigned int tag,int offset) { -__uint32_t *p = (__uint32_t *)node->tags[tag] + (offset >>5 ); -__uint32_t m =1 << (offset &31 ); +uint32_t *p = (uint32_t *)node->tags[tag] + (offset >>5 ); +uint32_t m =1 << (offset &31 ); *p &= ~m; }static inline int tag_get (struct radix_tree_node *node,unsigned int tag,int offset) { -return 1 & (((const __uint32_t *)node->tags[tag])[offset >>5 ] >> (offset &31 )); +return 1 & (((const uint32_t *)node->tags[tag])[offset >>5 ] >> (offset &31 )); }/*
libxfs/rdwr.c +3 -3
@@ -118,9 +118,9 @@ static void unmount_record(void *p)xlog_op_header_t *op = (xlog_op_header_t *)p;/* the data section must be 32 bit size aligned */ struct { -__uint16_t magic; -__uint16_t pad1; -__uint32_t pad2;/* may as well make it 64 bits */ +uint16_t magic; +uint16_t pad1; +uint32_t pad2;/* may as well make it 64 bits */ } magic = {XLOG_UNMOUNT_TYPE ,0 ,0 };memset (p,0 ,BBSIZE );
libxfs/util.c +4 -4
@@ -170,8 +170,8 @@ libxfs_trans_ichgtime(if (flags &XFS_ICHGTIME_CHG )VFS_I (ip)->i_ctime = tv;if (flags &XFS_ICHGTIME_CREATE ) { - ip->i_d.di_crtime.t_sec = (__int32_t )tv.tv_sec; - ip->i_d.di_crtime.t_nsec = (__int32_t )tv.tv_nsec; + ip->i_d.di_crtime.t_sec = (int32_t )tv.tv_sec; + ip->i_d.di_crtime.t_nsec = (int32_t )tv.tv_nsec; } }
@@ -261,8 +261,8 @@ libxfs_ialloc(ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_meta_uuid));VFS_I (ip)->i_version =1 ; ip->i_d.di_flags2 =0 ; - ip->i_d.di_crtime.t_sec = (__int32_t )VFS_I (ip)->i_mtime.tv_sec; - ip->i_d.di_crtime.t_nsec = (__int32_t )VFS_I (ip)->i_mtime.tv_nsec; + ip->i_d.di_crtime.t_sec = (int32_t )VFS_I (ip)->i_mtime.tv_sec; + ip->i_d.di_crtime.t_nsec = (int32_t )VFS_I (ip)->i_mtime.tv_nsec; } flags =XFS_ILOG_CORE ;
logprint/log_misc.c +3 -3
@@ -166,12 +166,12 @@ xlog_print_trans_header(char **ptr, int len) {xfs_trans_header_t *h;char *cptr = *ptr; -__uint32_t magic; +uint32_t magic;char *magic_c = (char *)&magic; *ptr += len; - magic=*(__uint32_t *)cptr;/* XXX be32_to_cpu soon */ + magic=*(uint32_t *)cptr;/* XXX be32_to_cpu soon */ if (len >=4 ) {#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -201,7 +201,7 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)int num, skip;int super_block =0 ;int bucket, col, buckets; -__int64_t blkno; +int64_t blkno;xfs_buf_log_format_t lbuf;int size, blen, map_size, struct_size;__be64 x, y;
mdrestore/xfs_mdrestore.c +1 -1
@@ -66,7 +66,7 @@ perform_restore(int mb_count;xfs_metablock_t tmb;xfs_sb_t sb; -__int64_t bytes_read; +int64_t bytes_read;/* * read in first blocks (superblock 0), set "inprogress" flag for it,
mkfs/proto.c +1 -1
@@ -667,7 +667,7 @@ rtinit( mp->m_sb.sb_rbmino = rbmip->i_ino; rbmip->i_d.di_size = mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize; rbmip->i_d.di_flags =XFS_DIFLAG_NEWRTBM ; - *(__uint64_t *)&VFS_I (rbmip)->i_atime =0 ; + *(uint64_t *)&VFS_I (rbmip)->i_atime =0 ;libxfs_trans_log_inode (tp, rbmip,XFS_ILOG_CORE );libxfs_log_sb (tp); mp->m_rbmip = rbmip;
mkfs/xfs_mkfs.c +38 -38
204 lines not on this page · raw message
quota/edit.c +32 -32
127 lines not on this page · raw message
quota/free.c +22 -22
66 lines not on this page · raw message
quota/quot.c +12 -12
@@ -26,17 +26,17 @@typedef struct du {struct du *next; -__uint64_t blocks; -__uint64_t blocks30; -__uint64_t blocks60; -__uint64_t blocks90; -__uint64_t nfiles; -__uint32_t id; +uint64_t blocks; +uint64_t blocks30; +uint64_t blocks60; +uint64_t blocks90; +uint64_t nfiles; +uint32_t id; }du_t ;#define TSIZE 500 -static __uint64_t sizes[TSIZE ]; -static __uint64_t overflow; +static uint64_t sizes[TSIZE ]; +static uint64_t overflow;#define NDU 60000#define DUHASH 8209
@@ -84,8 +84,8 @@ quot_bulkstat_add( {du_t *dp;du_t **hp; -__uint64_t size; -__uint32_t i, id; +uint64_t size; +uint32_t i, id;if ((p->bs_mode &S_IFMT ) ==0 )return ;
@@ -203,7 +203,7 @@ qcompare(return 0 ; } -typedef char *(*idtoname_t )(__uint32_t ); +typedef char *(*idtoname_t )(uint32_t );static void quot_report_mount_any_type(
@@ -291,7 +291,7 @@ quot_histogram_mount(fs_path_t *mount, uint flags) { -__uint64_t t =0 ; + uint64_t t = 0;int i;fprintf (fp,_ ("%s (%s):\n" ), mount->fs_name, mount->fs_dir);
quota/quota.c +2 -2
@@ -52,7 +52,7 @@ quota_help(void) static int quota_mount( FILE *fp, - __uint32_t id, + uint32_t id, char *name, uint form, uint type,
@@ -181,7 +181,7 @@ quota_mount( static void quota( FILE *fp, - __uint32_t id, + uint32_t id, char *name, uint form, uint type,
quota/quota.h +6 -6
@@ -53,9 +53,9 @@ enum {extern char *type_to_string (uint __type);extern char *form_to_string (uint __form);extern char *time_to_string (time_t __time,uint __flags); -extern char *bbs_to_string (__uint64_t __v,char *__c,uint __size); -extern char *num_to_string (__uint64_t __v,char *__c,uint __size); -extern char *pct_to_string (__uint64_t __v,__uint64_t __t,char *__c,uint __s); +extern char *bbs_to_string (uint64_t __v,char *__c,uint __size); +extern char *num_to_string (uint64_t __v,char *__c,uint __size); +extern char *pct_to_string (uint64_t __v,uint64_t __t,char *__c,uint __s);extern FILE *fopen_write_secure (char *__filename);
@@ -81,7 +81,7 @@ enum {* Identifier (uid/gid/prid) cache routines */ #define NMAX 32 -extern char *uid_to_name (__uint32_t __uid); -extern char *gid_to_name (__uint32_t __gid); -extern char *prid_to_name (__uint32_t __prid); +extern char *uid_to_name (uint32_t __uid); +extern char *gid_to_name (uint32_t __gid); +extern char *prid_to_name (uint32_t __prid);extern bool isdigits_only (const char *);
quota/report.c +2 -2
@@ -333,9 +333,9 @@ report_header( static int report_mount( FILE *fp, - __uint32_t id, + uint32_t id, char *name, - __uint32_t *oid, + uint32_t *oid, uint form, uint type, fs_path_t *mount,
quota/state.c +1 -1
@@ -135,7 +135,7 @@ static voidstate_timelimit (FILE *fp, uint form, - __uint32_t timelimit) + uint32_t timelimit) { fprintf(fp, _("%s grace time: %s\n"), form_to_string(form),
quota/util.c +33 -33
138 lines not on this page · raw message
repair/README +1 -1
@@ -189,7 +189,7 @@ D - 0) look at usage of XFS_MAKE_IPTR(). It does the right D - 0) look at references to XFS_INODES_PER_CHUNK. change the - ones that really mean sizeof(__uint64_t)*NBBY to + ones that really mean sizeof(uint64_t)*NBBY to something else (like that only defined as a constant INOS_PER_IREC. this isn't as important since XFS_INODES_PER_CHUNK will never chang
repair/agheader.h +7 -7
@@ -20,7 +20,7 @@ typedef struct fs_geometry {/* * these types should match the superblock types */ -__uint32_t sb_blocksize;/* blocksize (bytes) */ +uint32_t sb_blocksize;/* blocksize (bytes) */ xfs_rfsblock_t sb_dblocks;/* # data blocks */ xfs_rfsblock_t sb_rblocks;/* # realtime blocks */ xfs_rtblock_t sb_rextents;/* # realtime extents */
@@ -30,9 +30,9 @@ typedef struct fs_geometry {xfs_agnumber_t sb_agcount;/* # of ags */ xfs_extlen_t sb_rbmblocks;/* # of rt bitmap blocks */ xfs_extlen_t sb_logblocks;/* # of log blocks */ -__uint16_t sb_sectsize;/* volume sector size (bytes) */ -__uint16_t sb_inodesize;/* inode size (bytes) */ -__uint8_t sb_imax_pct;/* max % of fs for inode space */ +uint16_t sb_sectsize;/* volume sector size (bytes) */ +uint16_t sb_inodesize;/* inode size (bytes) */ +uint8_t sb_imax_pct;/* max % of fs for inode space */ /* * these don't have to match the superblock types but are placed
@@ -49,10 +49,10 @@ typedef struct fs_geometry {/* * fields after this point have to be checked manually in compare_sb() */ -__uint8_t sb_shared_vn;/* shared version number */ +uint8_t sb_shared_vn;/* shared version number */ xfs_extlen_t sb_inoalignmt;/* inode chunk alignment, fsblocks */ -__uint32_t sb_unit;/* stripe or raid unit */ -__uint32_t sb_width;/* stripe or width unit */ +uint32_t sb_unit;/* stripe or raid unit */ +uint32_t sb_width;/* stripe or width unit */ /* * these don't have to match, they track superblock properties
repair/attr_repair.h +13 -13
@@ -32,10 +32,10 @@#define ACL_WRITE 02#define ACL_EXECUTE 01 -typedef __uint16_t xfs_acl_perm_t ; -typedef __int32_t xfs_acl_type_t ; -typedef __int32_t xfs_acl_tag_t ; -typedef __int32_t xfs_acl_id_t ; +typedef uint16_t xfs_acl_perm_t ; +typedef int32_t xfs_acl_type_t ; +typedef int32_t xfs_acl_tag_t ; +typedef int32_t xfs_acl_id_t ;/* * "icacl" = in-core ACL. There is no equivalent in the XFS kernel code,
@@ -50,7 +50,7 @@ struct xfs_icacl_entry { };struct xfs_icacl { -__int32_t acl_cnt; +int32_t acl_cnt;struct xfs_icacl_entry acl_entry[0 ]; };
@@ -59,14 +59,14 @@ struct xfs_icacl {*/ #define XFS_MAC_MAX_SETS 250typedef struct xfs_mac_label { -__uint8_t ml_msen_type;/* MSEN label type */ -__uint8_t ml_mint_type;/* MINT label type */ -__uint8_t ml_level;/* Hierarchical level */ -__uint8_t ml_grade;/* Hierarchical grade */ -__uint16_t ml_catcount;/* Category count */ -__uint16_t ml_divcount;/* Division count */ +uint8_t ml_msen_type;/* MSEN label type */ +uint8_t ml_mint_type;/* MINT label type */ +uint8_t ml_level;/* Hierarchical level */ +uint8_t ml_grade;/* Hierarchical grade */ +uint16_t ml_catcount;/* Category count */ +uint16_t ml_divcount;/* Division count */ /* Category set, then Division set */ -__uint16_t ml_list[XFS_MAC_MAX_SETS ]; +uint16_t ml_list[XFS_MAC_MAX_SETS ]; }xfs_mac_label_t ;/* MSEN label type names. Choose an upper case ASCII character. */
@@ -93,7 +93,7 @@ typedef struct xfs_mac_label {/* * Capabilities (IRIX) */ -typedef __uint64_t xfs_cap_value_t ; +typedef uint64_t xfs_cap_value_t ; typedef struct xfs_cap_set { xfs_cap_value_t cap_effective; /* use in capability checks */
repair/avl64.c +19 -19
@@ -70,8 +70,8 @@ avl64_checktree( avl64node_t *root) {avl64node_t *nlast, *nnext, *np; -__uint64_t offset =0 ; -__uint64_t end; +uint64_t offset =0 ; +uint64_t end; nlast = nnext = root;
@@ -583,8 +583,8 @@ avl64_delete(avl64node_t *avl64_findanyrange (avl64tree_desc_t *tree, -__uint64_t start, -__uint64_t end, +uint64_t start, +uint64_t end,int checklen) {avl64node_t *np = tree->avl_root;
@@ -655,7 +655,7 @@ avl64_findanyrange(avl64node_t *avl64_findrange (avl64tree_desc_t *tree, -__uint64_t value) +uint64_t value) {avl64node_t *np = tree->avl_root;
@@ -682,10 +682,10 @@ avl64_findrange(avl64node_t *avl64_find (avl64tree_desc_t *tree, -__uint64_t value) +uint64_t value) {avl64node_t *np = tree->avl_root; -__uint64_t nvalue; +uint64_t nvalue;while (np) { nvalue =AVL_START (tree, np);
@@ -909,8 +909,8 @@ staticavl64node_t *avl64_insert_find_growth (avl64tree_desc_t *tree, -__uint64_t start,/* range start at start, */ -__uint64_t end,/* exclusive */ +uint64_t start,/* range start at start, */ +uint64_t end,/* exclusive */ int *growthp)/* OUT */ {avl64node_t *root = tree->avl_root;
@@ -963,7 +963,7 @@ avl64_insert_grow( int growth) {avl64node_t *nnext; -__uint64_t start =AVL_START (tree, newnode); +uint64_t start =AVL_START (tree, newnode);if (growth ==AVL_BACK ) {
@@ -1005,8 +1005,8 @@ avl64_insert( avl64node_t *newnode) {avl64node_t *np; -__uint64_t start =AVL_START (tree, newnode); -__uint64_t end =AVL_END (tree, newnode); +uint64_t start =AVL_START (tree, newnode); +uint64_t end =AVL_END (tree, newnode);int growth;ASSERT (newnode);
@@ -1159,16 +1159,16 @@ avl64ops_t avl_debug_ops = { avl_debug_end, } -static __uint64_t +static uint64_t avl64_debug_start (avl64node_t *node) { -return (__uint64_t )(struct avl_debug_node *)node->avl_start; +return (uint64_t )(struct avl_debug_node *)node->avl_start; } -static __uint64_t +static uint64_t avl64_debug_end (avl64node_t *node) { -return (__uint64_t) +return (uint64_t ) ((struct avl_debug_node *)node->avl_start + (struct avl_debug_node *)node->avl_size); }
@@ -1304,7 +1304,7 @@ main()avl64node_t *avl64_findadjacent (avl64tree_desc_t *tree, -__uint64_t value, +uint64_t value,int dir) {avl64node_t *np = tree->avl_root;
@@ -1378,8 +1378,8 @@ avl64_findadjacent(void avl64_findranges (avl64tree_desc_t *tree, -__uint64_t start, -__uint64_t end, +uint64_t start, +uint64_t end,avl64node_t **startp,avl64node_t **endp) {
repair/avl64.h +9 -9
@@ -32,8 +32,8 @@ typedef struct avl64node {* avl-tree operations */ typedef struct avl64ops { -__uint64_t (*avl_start)(avl64node_t *); -__uint64_t (*avl_end)(avl64node_t *); +uint64_t (*avl_start)(avl64node_t *); +uint64_t (*avl_end)(avl64node_t *); }avl64ops_t ;/*
@@ -89,32 +89,32 @@ avl64_init_tree(avl64node_t *avl64_findrange (avl64tree_desc_t *tree, -__uint64_t value); +uint64_t value);avl64node_t *avl64_find (avl64tree_desc_t *tree, -__uint64_t value); +uint64_t value);avl64node_t *avl64_findanyrange (avl64tree_desc_t *tree, -__uint64_t start, -__uint64_t end, +uint64_t start, +uint64_t end,int checklen);avl64node_t *avl64_findadjacent (avl64tree_desc_t *tree, -__uint64_t value, +uint64_t value,int dir);void avl64_findranges (avl64tree_desc_t *tree, -__uint64_t start, -__uint64_t end, +uint64_t start, +uint64_t end,avl64node_t **startp,avl64node_t **endp);
repair/dinode.c +19 -19
@@ -746,7 +746,7 @@ _("%s fork in ino %" PRIu64 " claims dup extent, "case XR_E_FREE1 :do_warn (_ ("%s fork in ino %" PRIu64" claims free block %" PRIu64"\n" ), - forkname, ino, (__uint64_t ) b); + forkname, ino, (uint64_t ) b);/* fall through ... */ case XR_E_INUSE1 :/* seen by rmap */ case XR_E_UNKNOWN :
@@ -923,7 +923,7 @@ process_btinode(int type, int *dirty, xfs_rfsblock_t *tot, - __uint64_t *nex, + uint64_t *nex, blkmap_t **blkmapp, int whichfork, int check_dups)
@@ -939,7 +939,7 @@ process_btinode(int level;int numrecs;bmap_cursor_t cursor; -__uint64_t magic; +uint64_t magic; dib = (xfs_bmdr_block_t *)XFS_DFORK_PTR (dip, whichfork); lino =XFS_AGINO_TO_INO (mp, agno, ino);
@@ -1098,7 +1098,7 @@ process_exinode(int type, int *dirty, xfs_rfsblock_t *tot, - __uint64_t *nex, + uint64_t *nex, blkmap_t **blkmapp, int whichfork, int check_dups)
@@ -1200,14 +1200,14 @@ process_symlink_extlist(xfs_mount_t *mp, xfs_ino_t lino, xfs_dinode_t *dino)do_warn (_ ("mismatch between format (%d) and size (%" PRId64") in symlink ino %" PRIu64"\n" ), dino->di_format, - (__int64_t )be64_to_cpu (dino->di_size), lino); + (int64_t )be64_to_cpu (dino->di_size), lino);return 1 ; }if (dino->di_format ==XFS_DINODE_FMT_LOCAL ) {do_warn (_ ("mismatch between format (%d) and size (%" PRId64") in symlink inode %" PRIu64"\n" ), dino->di_format, - (__int64_t )be64_to_cpu (dino->di_size), lino); + (int64_t )be64_to_cpu (dino->di_size), lino);return 1 ; }
@@ -1454,22 +1454,22 @@ _("inode %" PRIu64 " has bad inode type (IFMNT)\n"), lino);case XR_INO_CHRDEV :do_warn (_ ("size of character device inode %" PRIu64" != 0 (%" PRId64" bytes)\n" ), lino, - (__int64_t )be64_to_cpu (dino->di_size)); + (int64_t )be64_to_cpu (dino->di_size));break ;case XR_INO_BLKDEV :do_warn (_ ("size of block device inode %" PRIu64" != 0 (%" PRId64" bytes)\n" ), lino, - (__int64_t )be64_to_cpu (dino->di_size)); + (int64_t )be64_to_cpu (dino->di_size));break ;case XR_INO_SOCK :do_warn (_ ("size of socket inode %" PRIu64" != 0 (%" PRId64" bytes)\n" ), lino, - (__int64_t )be64_to_cpu (dino->di_size)); + (int64_t )be64_to_cpu (dino->di_size));break ;case XR_INO_FIFO :do_warn (_ ("size of fifo inode %" PRIu64" != 0 (%" PRId64" bytes)\n" ), lino, - (__int64_t )be64_to_cpu (dino->di_size)); + (int64_t )be64_to_cpu (dino->di_size));break ;default : do_warn(_("Internal error - process_misc_ino_types, "
@@ -1743,12 +1743,12 @@ _("found inode %" PRIu64 " claiming to be a real-time file\n"), lino);break ;case XR_INO_RTBITMAP : -if (size != (__int64_t )mp->m_sb.sb_rbmblocks * +if (size != (int64_t )mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize) {do_warn (_ ("realtime bitmap inode %" PRIu64" has bad size %" PRId64" (should be %" PRIu64")\n" ), lino, size, - (__int64_t ) mp->m_sb.sb_rbmblocks * + (int64_t ) mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize);return 1 ; }
@@ -1817,8 +1817,8 @@ static intprocess_inode_blocks_and_extents ( xfs_dinode_t *dino, xfs_rfsblock_t nblocks, - __uint64_t nextents, - __uint64_t anextents, + uint64_t nextents, + uint64_t anextents, xfs_ino_t lino, int *dirty) {
@@ -1908,7 +1908,7 @@ process_inode_data_fork(int type, int *dirty, xfs_rfsblock_t *totblocks, - __uint64_t *nextents, + uint64_t *nextents, blkmap_t **dblkmap, int check_dups) {
@@ -2017,7 +2017,7 @@ process_inode_attr_fork(int type, int *dirty, xfs_rfsblock_t *atotblocks, - __uint64_t *anextents, + uint64_t *anextents, int check_dups, int extra_attr_check, int *retval)
@@ -2228,8 +2228,8 @@ process_dinode_int(xfs_mount_t *mp,int di_mode;int type;int retval =0 ; -__uint64_t nextents; -__uint64_t anextents; +uint64_t nextents; +uint64_t anextents;xfs_ino_t lino;const int is_free =0 ;const int is_used =1 ;
@@ -2346,7 +2346,7 @@ _("inode identifier %llu mismatch on inode %" PRIu64 "\n"),if (!uncertain)do_warn (_ ("bad (negative) size %" PRId64" on inode %" PRIu64"\n" ), - (__int64_t )be64_to_cpu (dino->di_size), + (int64_t )be64_to_cpu (dino->di_size), lino);if (verify_mode)return 1 ;
repair/dinode.h +2 -2
@@ -46,8 +46,8 @@ process_bmbt_reclist(xfs_mount_t *mp,xfs_ino_t ino, xfs_rfsblock_t *tot, struct blkmap **blkmapp, - __uint64_t *first_key, - __uint64_t *last_key, + uint64_t *first_key, + uint64_t *last_key, int whichfork);int
repair/dir2.c +1 -1
@@ -160,7 +160,7 @@ process_sf_dir2(int bad_sfnamelen;int i;int i8; -__int64_t ino_dir_size; +int64_t ino_dir_size;int ino_off;ino_tree_node_t *irec_p;int junkit;
repair/globals.h +8 -8
@@ -141,7 +141,7 @@ EXTERN int inodes_per_cluster; EXTERN unsigned int glob_agcount; EXTERN int chunks_pblock; /* # of 64-ino chunks per allocation */ EXTERN int max_symlink_blocks; -EXTERN __int64_t fs_max_file_offset; +EXTERN int64_t fs_max_file_offset;/* realtime info */
@@ -161,16 +161,16 @@ EXTERN int full_ino_ex_data;/*/* superblock counters */ -EXTERN __uint64_t sb_icount; /* allocated (made) inodes */ -EXTERN __uint64_t sb_ifree; /* free inodes */ -EXTERN __uint64_t sb_fdblocks; /* free data blocks */ -EXTERN __uint64_t sb_frextents; /* free realtime extents */ +EXTERN uint64_t sb_icount; /* allocated (made) inodes */ +EXTERN uint64_t sb_ifree; /* free inodes */ +EXTERN uint64_t sb_fdblocks; /* free data blocks */ +EXTERN uint64_t sb_frextents; /* free realtime extents *//* superblock geometry info */ EXTERN xfs_extlen_t sb_inoalignmt; -EXTERN __uint32_t sb_unit; -EXTERN __uint32_t sb_width; +EXTERN uint32_t sb_unit; +EXTERN uint32_t sb_width;struct aglock {pthread_mutex_t lock __attribute__((__aligned__ (64 )));
@@ -178,7 +178,7 @@ struct aglock { EXTERN struct aglock *ag_locks; EXTERN int report_interval; -EXTERN __uint64_t *prog_rpt_done; +EXTERN uint64_t *prog_rpt_done; EXTERN int ag_stride; EXTERN int thread_count;
repair/incore.c +5 -5
@@ -179,7 +179,7 @@ get_bmap_ext(static uint64_t *rt_bmap;static size_t rt_bmap_size; -/* block records fit into __uint64_t's units */ +/* block records fit into uint64_t's units */ #define XR_BB_UNIT 64/* number of bits/unit */ #define XR_BB 4/* bits per block record */ #define XR_BB_NUM (XR_BB_UNIT/XR_BB)/* number of records per unit */
@@ -203,8 +203,8 @@ set_rtbmap( { *(rt_bmap + bno /XR_BB_NUM ) = ((*(rt_bmap + bno /XR_BB_NUM ) & - (~((__uint64_t )XR_BB_MASK << ((bno %XR_BB_NUM ) *XR_BB )))) | - (((__uint64_t ) state) << ((bno %XR_BB_NUM ) *XR_BB ))); + (~((uint64_t )XR_BB_MASK << ((bno %XR_BB_NUM ) *XR_BB )))) | + (((uint64_t ) state) << ((bno %XR_BB_NUM ) *XR_BB ))); } static void
@@ -222,9 +222,9 @@ init_rt_bmap(return ; rt_bmap_size =roundup (mp->m_sb.sb_rextents / (NBBY /XR_BB ), -sizeof (__uint64_t)); +sizeof (uint64_t )); - rt_bmap =memalign (sizeof (__uint64_t), rt_bmap_size); + rt_bmap =memalign (sizeof (uint64_t ), rt_bmap_size);if (!rt_bmap) { do_error( _("couldn't allocate realtime block map, size = %" PRIu64 "\n"),
repair/incore.h +23 -23
100 lines not on this page · raw message
repair/incore_ext.c +3 -3
@@ -721,13 +721,13 @@ search_rt_dup_extent(xfs_mount_t *mp, xfs_rtblock_t bno)return (ret); } -static __uint64_t +static uint64_t avl64_rt_ext_start (avl64node_t *node) {return (((rt_extent_tree_node_t *) node)->rt_startblock); } -static __uint64_t +static uint64_t avl64_ext_end (avl64node_t *node) { return(((rt_extent_tree_node_t *) node)->rt_startblock +
@@ -834,7 +834,7 @@ count_extents(xfs_agnumber_t agno, avltree_desc_t *tree, int whichtree)int count_bno_extents_blocks (xfs_agnumber_t agno,uint *numblocks) { -__uint64_t nblocks; +uint64_t nblocks;extent_tree_node_t *node;int i =0 ;
repair/incore_ino.c +36 -36
221 lines not on this page · raw message
repair/phase2.c +1 -1
@@ -179,7 +179,7 @@ phase2( bad_ino_btree =0 ; -set_progress_msg (PROG_FMT_SCAN_AG , (__uint64_t ) glob_agcount); +set_progress_msg (PROG_FMT_SCAN_AG , (uint64_t ) glob_agcount);scan_ags (mp, scan_threads);
repair/phase3.c +3 -3
@@ -122,7 +122,7 @@ phase3(else do_log (_ (" - scan (but don't clear) agi unlinked lists...\n" )); -set_progress_msg (PROG_FMT_AGI_UNLINKED , (__uint64_t ) glob_agcount); +set_progress_msg (PROG_FMT_AGI_UNLINKED , (uint64_t ) glob_agcount);/* first clear the agi unlinked AGI list */ if (!no_modify) {
@@ -142,7 +142,7 @@ phase3(do_log (_ (" - process known inodes and perform inode discovery...\n" )); -set_progress_msg (PROG_FMT_PROCESS_INO , (__uint64_t ) mp->m_sb.sb_icount); +set_progress_msg (PROG_FMT_PROCESS_INO , (uint64_t ) mp->m_sb.sb_icount);process_ags (mp);
@@ -152,7 +152,7 @@ phase3(* process newly discovered inode chunks */ do_log (_ (" - process newly discovered inodes...\n" )); -set_progress_msg (PROG_FMT_NEW_INODES , (__uint64_t ) glob_agcount); +set_progress_msg (PROG_FMT_NEW_INODES , (uint64_t ) glob_agcount); counts =calloc (sizeof (*counts), mp->m_sb.sb_agcount);if (!counts) {
repair/phase4.c +2 -2
@@ -290,7 +290,7 @@ phase4(xfs_mount_t *mp)do_log (_ ("Phase 4 - check for duplicate blocks...\n" ));do_log (_ (" - setting up duplicate extent list...\n" )); -set_progress_msg (PROG_FMT_DUP_EXTENT , (__uint64_t ) glob_agcount); +set_progress_msg (PROG_FMT_DUP_EXTENT , (uint64_t ) glob_agcount); irec =find_inode_rec (mp,XFS_INO_TO_AGNO (mp, mp->m_sb.sb_rootino),XFS_INO_TO_AGINO (mp, mp->m_sb.sb_rootino));
@@ -404,7 +404,7 @@ phase4(xfs_mount_t *mp)reset_bmaps (mp);do_log (_ (" - check for inodes claiming duplicate blocks...\n" )); -set_progress_msg (PROG_FMT_DUP_BLOCKS , (__uint64_t ) mp->m_sb.sb_icount); +set_progress_msg (PROG_FMT_DUP_BLOCKS , (uint64_t ) mp->m_sb.sb_icount);/* * ok, now process the inodes -- signal 2-pass check per inode.
repair/phase5.c +14 -14
@@ -86,9 +86,9 @@ struct agi_stat {xfs_agino_t freecount; }; -static __uint64_t *sb_icount_ag;/* allocated inodes per ag */ -static __uint64_t *sb_ifree_ag;/* free inodes per ag */ -static __uint64_t *sb_fdblocks_ag;/* free data blocks per ag */ +static uint64_t *sb_icount_ag;/* allocated inodes per ag */ +static uint64_t *sb_ifree_ag;/* free inodes per ag */ +static uint64_t *sb_fdblocks_ag;/* free data blocks per ag */ static int mk_incore_fstree (xfs_mount_t *mp,xfs_agnumber_t agno)
@@ -886,10 +886,10 @@ build_freespace_tree(xfs_mount_t *mp, xfs_agnumber_t agno,*/ static void init_ino_cursor (xfs_mount_t *mp,xfs_agnumber_t agno,bt_status_t *btree_curs, -__uint64_t *num_inos,__uint64_t *num_free_inos,int finobt) +uint64_t *num_inos,uint64_t *num_free_inos,int finobt) { -__uint64_t ninos; -__uint64_t nfinos; +uint64_t ninos; +uint64_t nfinos;int rec_nfinos;int rec_ninos;ino_tree_node_t *ino_rec;
@@ -2193,10 +2193,10 @@ phase5_func(xfs_agnumber_t agno, struct xfs_slab *lost_fsb) { - __uint64_t num_inos; -__uint64_t num_free_inos; -__uint64_t finobt_num_inos; -__uint64_t finobt_num_free_inos; + uint64_t num_inos; +uint64_t num_free_inos; +uint64_t finobt_num_inos; +uint64_t finobt_num_free_inos;bt_status_t bno_btree_curs;bt_status_t bcnt_btree_curs;bt_status_t ino_btree_curs;
@@ -2471,7 +2471,7 @@ phase5(xfs_mount_t *mp)int error;do_log (_ ("Phase 5 - rebuild AG headers and trees...\n" )); -set_progress_msg (PROG_FMT_REBUILD_AG , (__uint64_t )glob_agcount); +set_progress_msg (PROG_FMT_REBUILD_AG , (uint64_t )glob_agcount);#ifdef XR_BLD_FREE_TRACE fprintf(stderr, "inobt level 1, maxrec = %d, minrec = %d\n",
@@ -2497,15 +2497,15 @@ phase5(xfs_mount_t *mp)keep_fsinos (mp);/* allocate per ag counters */ - sb_icount_ag =calloc (mp->m_sb.sb_agcount,sizeof (__uint64_t)); + sb_icount_ag =calloc (mp->m_sb.sb_agcount,sizeof (uint64_t ));if (sb_icount_ag ==NULL )do_error (_ ("cannot alloc sb_icount_ag buffers\n" )); - sb_ifree_ag =calloc (mp->m_sb.sb_agcount,sizeof (__uint64_t)); + sb_ifree_ag =calloc (mp->m_sb.sb_agcount,sizeof (uint64_t ));if (sb_ifree_ag ==NULL )do_error (_ ("cannot alloc sb_ifree_ag buffers\n" )); - sb_fdblocks_ag =calloc (mp->m_sb.sb_agcount,sizeof (__uint64_t)); + sb_fdblocks_ag =calloc (mp->m_sb.sb_agcount,sizeof (uint64_t ));if (sb_fdblocks_ag ==NULL )do_error (_ ("cannot alloc sb_fdblocks_ag buffers\n" ));
repair/phase6.c +8 -8
@@ -82,7 +82,7 @@ typedef struct dir_hash_ent {struct dir_hash_ent *nextbyhash;/* next in name bucket */ struct dir_hash_ent *nextbyorder;/* next in order added */ xfs_dahash_t hashval;/* hash value of name */ -__uint32_t address;/* offset of data entry */ +uint32_t address;/* offset of data entry */ xfs_ino_t inum;/* inode num of entry */ short junkit;/* name starts with / */ short seen;/* have seen leaf entry */
@@ -170,11 +170,11 @@ static intdir_hash_add ( xfs_mount_t *mp, dir_hash_tab_t *hashtab, - __uint32_t addr, + uint32_t addr, xfs_ino_t inum, int namelen, unsigned char *name, - __uint8_t ftype) + uint8_t ftype) {xfs_dahash_t hash =0 ;int byaddr;
@@ -357,7 +357,7 @@ static voiddir_hash_update_ftype ( dir_hash_tab_t *hashtab, xfs_dir2_dataptr_t addr, - __uint8_t ftype) + uint8_t ftype) {int i;dir_hash_ent_t *p;
@@ -1791,8 +1791,8 @@ longform_dir2_entry_check_data(/* validate ftype field if supported */ if (xfs_sb_version_hasftype (&mp->m_sb)) { -__uint8_t dir_ftype; -__uint8_t ino_ftype; +uint8_t dir_ftype; +uint8_t ino_ftype; dir_ftype =M_DIROPS (mp)->data_get_ftype (dep); ino_ftype =get_inode_ftype (irec, ino_offset);
@@ -2703,8 +2703,8 @@ _("entry \"%s\" (ino %" PRIu64 ") in dir %" PRIu64 " is a duplicate name"),/* validate ftype field if supported */ if (xfs_sb_version_hasftype (&mp->m_sb)) { -__uint8_t dir_ftype; -__uint8_t ino_ftype; +uint8_t dir_ftype; +uint8_t ino_ftype; dir_ftype =M_DIROPS (mp)->sf_get_ftype (sfep); ino_ftype =get_inode_ftype (irec, ino_offset);
repair/phase7.c +3 -3
@@ -32,7 +32,7 @@ static voidupdate_inode_nlinks ( xfs_mount_t *mp, xfs_ino_t ino, - __uint32_t nlinks) + uint32_t nlinks) {xfs_trans_t *tp;xfs_inode_t *ip;
@@ -104,7 +104,7 @@ do_link_updates( {ino_tree_node_t *irec;int j; -__uint32_t nrefs; +uint32_t nrefs;for (irec =findfirst_inode_rec (agno); irec; irec =next_ino_rec (irec)) {
@@ -143,7 +143,7 @@ phase7(else do_log (_ ("Phase 7 - verify link counts...\n" )); -set_progress_msg (PROGRESS_FMT_CORR_LINK , (__uint64_t ) glob_agcount); +set_progress_msg (PROGRESS_FMT_CORR_LINK , (uint64_t ) glob_agcount);create_work_queue (&wq, mp, scan_threads);
repair/progress.c +15 -15
@@ -85,8 +85,8 @@ pthread_t report_thread;typedef struct msg_block_s {pthread_mutex_t mutex;progress_rpt_t *format; -__uint64_t *done; -__uint64_t *total; +uint64_t *done; +uint64_t *total;int count;int interval; }msg_block_t ;
@@ -96,14 +96,14 @@ typedef struct phase_times_s {time_t start;time_t end;time_t duration; -__uint64_t item_counts[4 ]; +uint64_t item_counts[4 ]; } phase_times_t;static phase_times_t phase_times[8 ];static void *progress_rpt_thread (void *);static int current_phase;static int running; -static __uint64_t prog_rpt_total; +static uint64_t prog_rpt_total;void init_progress_rpt (void )
@@ -113,11 +113,11 @@ init_progress_rpt (void)* allocate the done vector */ -if ((prog_rpt_done = (__uint64_t *) -malloc (sizeof (__uint64_t)*glob_agcount)) ==NULL ) { +if ((prog_rpt_done = (uint64_t *) +malloc (sizeof (uint64_t )*glob_agcount)) ==NULL ) {do_error (_ ("cannot malloc pointer to done vector\n" )); } -bzero (prog_rpt_done,sizeof (__uint64_t)*glob_agcount); +bzero (prog_rpt_done,sizeof (uint64_t )*glob_agcount);/* * Setup comm block, start the thread
@@ -165,10 +165,10 @@ progress_rpt_thread (void *p)timer_t timerid;struct itimerspec timespec;char *msgbuf; -__uint64_t *donep; -__uint64_t sum; +uint64_t *donep; +uint64_t sum;msg_block_t *msgp = (msg_block_t *)p; -__uint64_t percent; +uint64_t percent;/* It's possible to get here very early w/ no progress msg set */ if (!msgp->format)
@@ -286,7 +286,7 @@ progress_rpt_thread (void *p) }int -set_progress_msg (int report,__uint64_t total) +set_progress_msg (int report,uint64_t total) {if (!ag_stride)
@@ -300,7 +300,7 @@ set_progress_msg (int report, __uint64_t total)/* reset all the accumulative totals */ if (prog_rpt_done) -bzero (prog_rpt_done,sizeof (__uint64_t)*glob_agcount); +bzero (prog_rpt_done,sizeof (uint64_t )*glob_agcount);if (pthread_mutex_unlock (&global_msgs.mutex))do_error (_ ("set_progress_msg: cannot unlock progress mutex\n" ));
@@ -308,14 +308,14 @@ set_progress_msg (int report, __uint64_t total)return (0 ); } -__uint64_t +uint64_t print_final_rpt (void ) {int i;struct tm *tmp;time_t now; -__uint64_t *donep; -__uint64_t sum; +uint64_t *donep; +uint64_t sum;msg_block_t *msgp = &global_msgs;char msgbuf[DURATION_BUF_SIZE ];
repair/progress.h +2 -2
@@ -32,8 +32,8 @@extern void init_progress_rpt (void );extern void stop_progress_rpt (void );extern void summary_report (void ); -extern int set_progress_msg (int report,__uint64_t total); -extern __uint64_t print_final_rpt (void ); +extern int set_progress_msg (int report,uint64_t total); +extern uint64_t print_final_rpt (void );extern char *timestamp (int end,int phase,char *buf);extern char *duration (int val,char *buf);extern int do_parallel;
repair/rmap.c +9 -9
@@ -343,7 +343,7 @@ _("Insufficient memory while allocating raw metadata reverse mapping slabs."));static int find_first_zero_bit ( -__uint64_t mask) +uint64_t mask) {int n;int b =0 ;
@@ -356,7 +356,7 @@ find_first_zero_bit(static int popcnt ( -__uint64_t mask) +uint64_t mask) {int n;int b =0 ;
@@ -1064,14 +1064,14 @@ _("Incorrect reverse-mapping: saw (%u/%u) %slen %u owner %"PRId64" %s%soff \* Compare the key fields of two rmap records -- positive if key1 > key2, * negative if key1 < key2, and zero if equal. */ -__int64_t +int64_t rmap_diffkeys (struct xfs_rmap_irec *kp1,struct xfs_rmap_irec *kp2) {__u64 oa;__u64 ob; -__int64_t d; +int64_t d;struct xfs_rmap_irec tmp; tmp = *kp1;
@@ -1081,7 +1081,7 @@ rmap_diffkeys( tmp.rm_flags &= ~XFS_RMAP_REC_FLAGS ; ob =libxfs_rmap_irec_offset_pack (&tmp); - d = (__int64_t )kp1->rm_startblock - kp2->rm_startblock; + d = (int64_t )kp1->rm_startblock - kp2->rm_startblock;if (d)return d;
@@ -1192,10 +1192,10 @@ fix_inode_reflink_flags( {struct ino_tree_node *irec;int bit; -__uint64_t was; -__uint64_t is; -__uint64_t diff; -__uint64_t mask; +uint64_t was; +uint64_t is; +uint64_t diff; +uint64_t mask;int error =0 ;xfs_agino_t agino;
repair/rmap.h +1 -1
@@ -44,7 +44,7 @@ extern int rmap_init_cursor(xfs_agnumber_t, struct xfs_slab_cursor **);extern void rmap_avoid_check (void );extern int rmaps_verify_btree (struct xfs_mount *,xfs_agnumber_t ); -extern __int64_t rmap_diffkeys (struct xfs_rmap_irec *kp1, +extern int64_t rmap_diffkeys (struct xfs_rmap_irec *kp1,struct xfs_rmap_irec *kp2);extern void rmap_high_key_from_rec (struct xfs_rmap_irec *rec,struct xfs_rmap_irec *key);
repair/sb.c +12 -12
@@ -40,7 +40,7 @@ copy_sb(xfs_sb_t *source, xfs_sb_t *dest)xfs_ino_t uquotino;xfs_ino_t gquotino;xfs_ino_t pquotino; -__uint16_t versionnum; +uint16_t versionnum; rootino = dest->sb_rootino; rbmino = dest->sb_rbmino;
@@ -106,8 +106,8 @@ verify_sb_blocksize(xfs_sb_t *sb)static int __find_secondary_sb (xfs_sb_t *rsb, -__uint64_t start, -__uint64_t skip) +uint64_t start, +uint64_t skip) {xfs_off_t off;xfs_sb_t *sb;
@@ -187,13 +187,13 @@ __find_secondary_sb(static int guess_default_geometry ( -__uint64_t *agsize, -__uint64_t *agcount, +uint64_t *agsize, +uint64_t *agcount,libxfs_init_t *x) {struct fs_topology ft;int blocklog; -__uint64_t dblocks; +uint64_t dblocks;int multidisk;memset (&ft,0 ,sizeof (ft));
@@ -216,9 +216,9 @@ int find_secondary_sb(xfs_sb_t *rsb) {int retval =0 ; -__uint64_t agcount; -__uint64_t agsize; -__uint64_t skip; +uint64_t agcount; +uint64_t agsize; +uint64_t skip;int blocklog;/*
@@ -229,7 +229,7 @@ find_secondary_sb(xfs_sb_t *rsb)do_warn (_ ("\nattempting to find secondary superblock...\n" ));if (verify_sb_blocksize (rsb) ==0 ) { - skip = (__uint64_t )rsb->sb_agblocks * rsb->sb_blocksize; + skip = (uint64_t )rsb->sb_agblocks * rsb->sb_blocksize;if (skip >=XFS_AG_MIN_BYTES && skip <=XFS_AG_MAX_BYTES ) retval =__find_secondary_sb (rsb, skip, skip); }
@@ -343,7 +343,7 @@ sb_validate_ino_align(struct xfs_sb *sb)int verify_sb (char *sb_buf,xfs_sb_t *sb,int is_primary_sb) { -__uint32_t bsize; +uint32_t bsize;int i;int ret;
@@ -399,7 +399,7 @@ verify_sb(char *sb_buf, xfs_sb_t *sb, int is_primary_sb) sb->sb_dblocks < XFS_MIN_DBLOCKS(sb))return (XR_BAD_FS_SIZE_DATA ); -if (sb->sb_agblklog != (__uint8_t )libxfs_log2_roundup (sb->sb_agblocks)) +if (sb->sb_agblklog != (uint8_t )libxfs_log2_roundup (sb->sb_agblocks))return (XR_BAD_FS_SIZE_DATA ); if (sb->sb_inodesize < XFS_DINODE_MIN_SIZE ||
repair/scan.c +25 -25
71 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [PATCH 1/7] xfs: remove double-underscore integer types
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
This is a purely mechanical patch that removes the private __{u,}int{8,16,32,64}_t typedefs in favor of using the system {u,}int{8,16,32,64}_t typedefs. This is the sed script used to perform the transformation and fix the resulting whitespace and indentation errors:
Quoted 9 lines
s/typedef\t__uint8_t/typedef __uint8_t\t/g
s/typedef\t__uint/typedef __uint/g
s/typedef\t__int\([0-9]*\)_t/typedef int\1_t\t/g
s/__uint8_t\t/__uint8_t\t\t/g
s/__uint/uint/g
s/__int\([0-9]*\)_t\t/__int\1_t\t\t/g
s/__int/int/g
/^typedef.*int[0-9]*_t;$/d
Thanks - I did this too and fixed up some incidentals, interdiff follows.
and I'll add the delta below on the way in if you don't mind.
(just issues on the changed lines that would have been caught if done manually, I think - mostly whitespace nitpicks)
Thanks,
-Eric
db/inode.c +5 -5
@@ -146,22 +146,22 @@OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_RTINHERIT_BIT -1 ),C1 , 0, TYP_NONE }, { "projinherit", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_PROJINHERIT_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_PROJINHERIT_BIT -1 ),C1 , 0, TYP_NONE }, { "nosymlinks", FLDT_UINT1,OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NOSYMLINKS_BIT -1 ),C1 , 0, TYP_NONE }, { "extsz", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSIZE_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSIZE_BIT -1 ),C1 , 0, TYP_NONE }, { "extszinherit", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSZINHERIT_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSZINHERIT_BIT -1 ),C1 , 0, TYP_NONE }, { "nodefrag", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NODEFRAG_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NODEFRAG_BIT -1 ),C1 , 0, TYP_NONE }, { "filestream", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_FILESTREAM_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_FILESTREAM_BIT -1 ),C1 , 0, TYP_NONE }, { "gen", FLDT_UINT32D, OI(COFF(gen)), C1, 0, TYP_NONE }, { NULL }
db/metadump.c +1 -1
@@ -2270,7 +2270,7 @@return success; } -static uint32_t inodes_copied =0 ; +static uint32_t inodes_copied;static int copy_inode_chunk(
logprint/log_misc.c +1 -1
@@ -171,7 +171,7 @@ *ptr += len; - magic=*(uint32_t *)cptr;/* XXX be32_to_cpu soon */ + magic = *(uint32_t *)cptr;/* XXX be32_to_cpu soon */ if (len >=4 ) {#if __BYTE_ORDER == __LITTLE_ENDIAN
repair/globals.h +2 -2
@@ -177,8 +177,8 @@ }; EXTERN struct aglock *ag_locks; -EXTERN int report_interval; -EXTERN uint64_t *prog_rpt_done; +EXTERN int report_interval; +EXTERN uint64_t *prog_rpt_done; EXTERN int ag_stride; EXTERN int thread_count;
repair/phase5.c +1 -1
@@ -2471,7 +2471,7 @@int error;do_log (_ ("Phase 5 - rebuild AG headers and trees...\n" )); -set_progress_msg (PROG_FMT_REBUILD_AG , (uint64_t )glob_agcount); +set_progress_msg (PROG_FMT_REBUILD_AG , (uint64_t )glob_agcount);#ifdef XR_BLD_FREE_TRACE fprintf(stderr, "inobt level 1, maxrec = %d, minrec = %d\n",
repair/progress.c +2 -2
@@ -114,7 +114,7 @@*/ if ((prog_rpt_done = (uint64_t *) -malloc (sizeof (uint64_t )*glob_agcount)) ==NULL ) { +malloc (sizeof (uint64_t )*glob_agcount)) ==NULL ) {do_error (_ ("cannot malloc pointer to done vector\n" )); }bzero (prog_rpt_done,sizeof (uint64_t )*glob_agcount);
@@ -286,7 +286,7 @@ }int -set_progress_msg (int report,uint64_t total) +set_progress_msg (int report,uint64_t total) {if (!ag_stride)
Darrick J. Wong
Reviewed-byRe: [PATCH 1/7] xfs: remove double-underscore integer types
Quoted 19 lines · Eric Sandeen
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
This is a purely mechanical patch that removes the private __{u,}int{8,16,32,64}_t typedefs in favor of using the system {u,}int{8,16,32,64}_t typedefs. This is the sed script used to perform the transformation and fix the resulting whitespace and indentation errors:
Quoted 9 lines
s/typedef\t__uint8_t/typedef __uint8_t\t/g
s/typedef\t__uint/typedef __uint/g
s/typedef\t__int\([0-9]*\)_t/typedef int\1_t\t/g
s/__uint8_t\t/__uint8_t\t\t/g
s/__uint/uint/g
s/__int\([0-9]*\)_t\t/__int\1_t\t\t/g
s/__int/int/g
/^typedef.*int[0-9]*_t;$/d
Quoted 8 lines
Thanks - I did this too and fixed up some incidentals, interdiff follows.
Reviewed-by Eric Sandeen <[email protected]>and I'll add the delta below on the way in if you don't mind.
(just issues on the changed lines that would have been caught if done manually, I think - mostly whitespace nitpicks)
Looks fine to me,
--D
Quoted 114 lines
Thanks,
-Ericdiff -u
b/db/inode.cb/db/inode.cdb/inode.c +5
-5@@ -146,22 +146,22 @@OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_RTINHERIT_BIT -1 ),C1 , 0, TYP_NONE }, { "projinherit", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_PROJINHERIT_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_PROJINHERIT_BIT -1 ),C1 , 0, TYP_NONE }, { "nosymlinks", FLDT_UINT1,OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NOSYMLINKS_BIT -1 ),C1 , 0, TYP_NONE }, { "extsz", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSIZE_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSIZE_BIT -1 ),C1 , 0, TYP_NONE }, { "extszinherit", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSZINHERIT_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_EXTSZINHERIT_BIT -1 ),C1 , 0, TYP_NONE }, { "nodefrag", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NODEFRAG_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_NODEFRAG_BIT -1 ),C1 , 0, TYP_NONE }, { "filestream", FLDT_UINT1, -OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_FILESTREAM_BIT -1 ),C1 , +OI (COFF (flags) +bitsz (uint16_t) -XFS_DIFLAG_FILESTREAM_BIT -1 ),C1 , 0, TYP_NONE }, { "gen", FLDT_UINT32D, OI(COFF(gen)), C1, 0, TYP_NONE }, { NULL }diff -u
b/db/metadump.cb/db/metadump.cdb/metadump.c +1
-1@@ -2270,7 +2270,7 @@return success; } -static uint32_t inodes_copied =0 ; +static uint32_t inodes_copied;static int copy_inode_chunk(diff -u
b/logprint/log_misc.cb/logprint/log_misc.clogprint/log_misc.c +1
-1@@ -171,7 +171,7 @@ *ptr += len; - magic=*(uint32_t *)cptr;/* XXX be32_to_cpu soon */ + magic = *(uint32_t *)cptr;/* XXX be32_to_cpu soon */ if (len >=4 ) {#if __BYTE_ORDER == __LITTLE_ENDIANdiff -u
b/repair/globals.hb/repair/globals.hrepair/globals.h +2
-2@@ -177,8 +177,8 @@ }; EXTERN struct aglock *ag_locks; -EXTERN int report_interval; -EXTERN uint64_t *prog_rpt_done; +EXTERN int report_interval; +EXTERN uint64_t *prog_rpt_done; EXTERN int ag_stride; EXTERN int thread_count;diff -u
b/repair/phase5.cb/repair/phase5.crepair/phase5.c +1
-1@@ -2471,7 +2471,7 @@int error;do_log (_ ("Phase 5 - rebuild AG headers and trees...\n" )); -set_progress_msg (PROG_FMT_REBUILD_AG , (uint64_t )glob_agcount); +set_progress_msg (PROG_FMT_REBUILD_AG , (uint64_t )glob_agcount);#ifdef XR_BLD_FREE_TRACE fprintf(stderr, "inobt level 1, maxrec = %d, minrec = %d\n",diff -u
b/repair/progress.cb/repair/progress.crepair/progress.c +2
-3@@ -114,7 +114,7 @@*/ if ((prog_rpt_done = (uint64_t *) -malloc (sizeof (uint64_t )*glob_agcount)) ==NULL ) { +malloc (sizeof (uint64_t )*glob_agcount)) ==NULL ) {do_error (_ ("cannot malloc pointer to done vector\n" )); }bzero (prog_rpt_done,sizeof (uint64_t )*glob_agcount);@@ -286,7 +286,7 @@ }int -set_progress_msg (int report,uint64_t total) +set_progress_msg (int report,uint64_t total) {if (!ag_stride) --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/7] xfs: remove double-underscore integer types
In reply to Darrick J. WongHi,
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
This is a purely mechanical patch that removes the private __{u,}int{8,16,32,64}_t typedefs in favor of using the system {u,}int{8,16,32,64}_t typedefs. This is the sed script used to perform the transformation and fix the resulting whitespace and indentation errors:
Quoted 9 lines
s/typedef\t__uint8_t/typedef __uint8_t\t/g
s/typedef\t__uint/typedef __uint/g
s/typedef\t__int\([0-9]*\)_t/typedef int\1_t\t/g
s/__uint8_t\t/__uint8_t\t\t/g
s/__uint/uint/g
s/__int\([0-9]*\)_t\t/__int\1_t\t\t/g
s/__int/int/g
/^typedef.*int[0-9]*_t;$/d
Loos fine, with a few space X tabs cosmetic changes maybe worth to change?
Anyway, just a suggestion, changing it or not:
Quoted 8 lines
Signed-off-by Darrick J. Wong <[email protected]>---
db/bit.h +0
-0
db/bit.h line 29
Quoted 6 lines
db/bit.h +1
-1@@ -25,5 +25,5 @@#define BVUNSIGNED 0#define BVSIGNED 1 -extern __int64_t getbitval (void *obj,int bitoff,int nbits,int flags); +extern int64_t getbitval (void *obj,int bitoff,int nbits,int flags);extern void setbitval (void *obuf,int bitoff,int nbits,void *ibuf);
^ Maybe worth to fix this space x tabs while in this code?
Quoted 23 lines
db/io.h +2
-2@@ -25,7 +25,7 @@ typedef struct bbmap { } bbmap_t; typedef struct iocur { - __int64_t bb; /* BB number in filesystem of buf */ + int64_t bb; /* BB number in filesystem of buf */ int blen; /* length of "buf", bb's */ int boff; /* data - buf */ void *buf; /* base address of buffer */@@ -33,7 +33,7 @@ typedef struct iocur {xfs_ino_t dirino;/* current directory inode number */ xfs_ino_t ino;/* current inode number */ int len;/* length of "data", bytes */ -__uint16_t mode;/* current inode's mode */ +uint16_t mode;/* current inode's mode */ xfs_off_t off;/* fs offset of "data" in bytes */ const struct typ *typ;/* type of "data" */ bbmap_t *bbmap;/* map daddr if fragmented */
db/io.h extern void off_cur(int off, int len); · line 61
Quoted 6 lines
db/io.h +1
-1@@ -57,7 +57,7 @@ extern void off_cur(int off, int len);extern void pop_cur (void );extern void print_iocur (char *tag,iocur_t *ioc);extern void push_cur (void ); -extern int read_buf (__int64_t daddr,int count,void *bufp); +extern int read_buf (int64_t daddr,int count,void *bufp);extern void write_cur (void );
^^
Quoted 30 lines
db/sb.c +3
-3@@ -606,7 +606,7 @@ version_help(void) }static int -do_version (xfs_agnumber_t agno,__uint16_t version,__uint32_t features) +do_version (xfs_agnumber_t agno,uint16_t version,uint32_t features) {xfs_sb_t tsb;@@ -710,8 +710,8 @@ version_f(int argc, char **argv) { - __uint16_t version = 0; -__uint32_t features =0 ; + uint16_t version = 0; +uint32_t features =0 ;xfs_agnumber_t ag;if (argc ==2 ) {/* WRITE VERSION */ fsr/xfs_fsr.c +0
-0
fsr/xfs_fsr.c struct getbmap *outmap = NULL; · line 54
Quoted 1 line
fsr/xfs_fsr.c +0
-0@@ -54,7 +54,7 @@ struct getbmap *outmap = NULL;int outmap_size =0 ;
^^^
fsr/xfs_fsr.c struct getbmap *outmap = NULL; · line 60
Quoted 7 lines
fsr/xfs_fsr.c +1
-1int RealUid;int tmp_agi; -static __int64_t minimumfree =2048 ; +static int64_t minimumfree =2048 ;#define MNTTYPE_XFS "xfs"
^^^
Quoted 12 lines
include/xfs_arch.h +1
-2@@ -244,39 +244,39 @@ static inline void be64_add_cpu(__be64 *a, __s64 b) *a =cpu_to_be64 (be64_to_cpu (*a) + b); } -static inline __uint16_t get_unaligned_be16 (void *p) +static inline uint16_t get_unaligned_be16 (void *p) { -__uint8_t *__p = p;
include/xfs_arch.h static inline void be64_add_cpu(__be64 *a, __s64 b) · line 256
Quoted 10 lines
include/xfs_arch.h +3
-2+uint8_t *__p = p;return __p[0 ] <<8 | __p[1 ]; } -static inline __uint32_t get_unaligned_be32 (void *p) +static inline uint32_t get_unaligned_be32 (void *p) { -__uint8_t *__p = p; +uint8_t *__p = p;return __p[0 ] <<24 | __p[1 ] <<16 | __p[2 ] <<8 | __p[3 ];
^^^
Quoted 6 lines
include/xfs_arch.h +0
-0/* libxfs/rdwr.c +0
-0
libxfs/rdwr.c static void unmount_record(void *p) · line 124
Quoted 10 lines
libxfs/rdwr.c +3
-3@@ -118,9 +118,9 @@ static void unmount_record(void *p)xlog_op_header_t *op = (xlog_op_header_t *)p;/* the data section must be 32 bit size aligned */ struct { -__uint16_t magic; -__uint16_t pad1; -__uint32_t pad2;/* may as well make it 64 bits */ +uint16_t magic; +uint16_t pad1; +uint32_t pad2;/* may as well make it 64 bits */ } magic = {XLOG_UNMOUNT_TYPE ,0 ,0 };
^^^
logprint/log_misc.c xlog_print_trans_header(char **ptr, int len) · line 171
Quoted 12 lines
logprint/log_misc.c +1
-1@@ -166,12 +166,12 @@ xlog_print_trans_header(char **ptr, int len) {xfs_trans_header_t *h;char *cptr = *ptr; -__uint32_t magic; +uint32_t magic;char *magic_c = (char *)&magic;
^^^^
Quoted 8 lines
logprint/log_misc.c +1
-1*ptr += len; - magic=*(__uint32_t *)cptr;/* XXX be32_to_cpu soon */ + magic=*(uint32_t *)cptr;/* XXX be32_to_cpu soon */ if (len >=4 ) {#if __BYTE_ORDER == __LITTLE_ENDIAN
logprint/log_misc.c xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops) · line 207
Quoted 8 lines
logprint/log_misc.c +1
-1@@ -201,7 +201,7 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)int num, skip;int super_block =0 ;int bucket, col, buckets; -__int64_t blkno; +int64_t blkno;xfs_buf_log_format_t lbuf;int size, blen, map_size, struct_size;__be64 x, y;
^^^
Quoted 14 lines
repair/attr_repair.h +0
-5@@ -32,10 +32,10 @@#define ACL_WRITE 02 #define ACL_EXECUTE 01 */ #define XFS_MAC_MAX_SETS 250 typedef struct xfs_mac_label { - __uint8_t ml_msen_type; /* MSEN label type */ - __uint8_t ml_mint_type; /* MINT label type */ - __uint8_t ml_level; /* Hierarchical level */ - __uint8_t ml_grade; /* Hierarchical grade */ - __uint16_t ml_catcount; /* Category count */
repair/attr_repair.h struct xfs_icacl { · line 69
Quoted 10 lines
repair/attr_repair.h +7
-2-__uint16_t ml_divcount;/* Division count */ +uint8_t ml_msen_type;/* MSEN label type */ +uint8_t ml_mint_type;/* MINT label type */ +uint8_t ml_level;/* Hierarchical level */ +uint8_t ml_grade;/* Hierarchical grade */ +uint16_t ml_catcount;/* Category count */ +uint16_t ml_divcount;/* Division count */ /* Category set, then Division set */ -__uint16_t ml_list[XFS_MAC_MAX_SETS ]; +uint16_t ml_list[XFS_MAC_MAX_SETS ];
^^^
Quoted 19 lines
}
xfs_mac_label_t;repair/avl64.c +2
-2@@ -70,8 +70,8 @@ avl64_checktree( avl64node_t *root) {avl64node_t *nlast, *nnext, *np; -__uint64_t offset =0 ; -__uint64_t end; +uint64_t offset =0 ; +uint64_t end; nlast = nnext = root;
avl64node_t*
avl64_insert_find_growth(
repair/avl64.c static · line 914
Quoted 6 lines
repair/avl64.c +2
-2avl64tree_desc_t *tree, - __uint64_t start, /* range start at start, */ - __uint64_t end, /* exclusive */ + uint64_t start, /* range start at start, */ + uint64_t end, /* exclusive */ int *growthp) /* OUT */
^^^
repair/avl64.c avl64_findadjacent( · line 1383
Quoted 11 lines
{
repair/avl64.c +2
-2avl64node_t *np = tree->avl_root;@@ -1378,8 +1378,8 @@ avl64_findadjacent( void avl64_findranges( avl64tree_desc_t *tree, - __uint64_t start, - __uint64_t end, + uint64_t start, + uint64_t end, avl64node_t **startp,
^^^
Quoted 17 lines
repair/avl64.c +0
-0avl64node_t **endp) {repair/avl64.h +2
-2@@ -32,8 +32,8 @@ typedef struct avl64node {* avl-tree operations */ avl64node_t * avl64_findanyrange( avl64tree_desc_t *tree, - __uint64_t start, - __uint64_t end, + uint64_t start, + uint64_t end,
Quoted 1 line
int checklen);
^^^
Quoted 7 lines
avl64node_t*
avl64_findadjacent(repair/avl64.h +1
-1avl64tree_desc_t *tree, - __uint64_t value, + uint64_t value,
repair/avl64.h avl64_init_tree( · line 118
Quoted 10 lines
repair/avl64.h +2
-2int dir); void avl64_findranges( avl64tree_desc_t *tree, - __uint64_t start, - __uint64_t end, + uint64_t start, + uint64_t end, avl64node_t **startp,
^^^
Quoted 2 lines
avl64node_t**endp);
Signature · 1 line
Carlos
Darrick J. Wong
Reviewed-byRe: [PATCH 1/7] xfs: remove double-underscore integer types
Quoted 40 lines · Carlos Maiolino
Hi,
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
This is a purely mechanical patch that removes the private __{u,}int{8,16,32,64}_t typedefs in favor of using the system {u,}int{8,16,32,64}_t typedefs. This is the sed script used to perform the transformation and fix the resulting whitespace and indentation errors:
Quoted 9 lines
s/typedef\t__uint8_t/typedef __uint8_t\t/g
s/typedef\t__uint/typedef __uint/g
s/typedef\t__int\([0-9]*\)_t/typedef int\1_t\t/g
s/__uint8_t\t/__uint8_t\t\t/g
s/__uint/uint/g
s/__int\([0-9]*\)_t\t/__int\1_t\t\t/g
s/__int/int/g
/^typedef.*int[0-9]*_t;$/dLoos fine, with a few space X tabs cosmetic changes maybe worth to change?
Anyway, just a suggestion, changing it or not:
Reviewed-by Carlos Maiolino <[email protected]>Quoted 11 lines
Signed-off-by Darrick J. Wong <[email protected]>---
db/bit.h +0
-0@@ -25,5 +25,5 @@#define BVUNSIGNED 0#define BVSIGNED 1
Quoted 5 lines
db/bit.h line 29
Quoted 3 lines
db/bit.h +1
-1-extern __int64_t getbitval (void *obj,int bitoff,int nbits,int flags); +extern int64_t getbitval (void *obj,int bitoff,int nbits,int flags);extern void setbitval (void *obuf,int bitoff,int nbits,void *ibuf);^ Maybe worth to fix this space x tabs while in this code?
Different cleanup patch, please. The double-underscore cleanup patch should /only/ touch double underscore types, and nothing else. I think Eric fixed a few cases of extra whitespace that drifts this patch away from the giant sed blob, but whatever already too hot here to bikeshed further over whitespace. :)
--D
Quoted 268 lines
Quoted 23 lines
db/io.h +2
-2@@ -25,7 +25,7 @@ typedef struct bbmap { } bbmap_t; typedef struct iocur { - __int64_t bb; /* BB number in filesystem of buf */ + int64_t bb; /* BB number in filesystem of buf */ int blen; /* length of "buf", bb's */ int boff; /* data - buf */ void *buf; /* base address of buffer */@@ -33,7 +33,7 @@ typedef struct iocur {xfs_ino_t dirino;/* current directory inode number */ xfs_ino_t ino;/* current inode number */ int len;/* length of "data", bytes */ -__uint16_t mode;/* current inode's mode */ +uint16_t mode;/* current inode's mode */ xfs_off_t off;/* fs offset of "data" in bytes */ const struct typ *typ;/* type of "data" */ bbmap_t *bbmap;/* map daddr if fragmented */ db/io.h extern void off_cur(int off, int len); · line 61
Quoted 6 lines
db/io.h +1
-1@@ -57,7 +57,7 @@ extern void off_cur(int off, int len);extern void pop_cur (void );extern void print_iocur (char *tag,iocur_t *ioc);extern void push_cur (void ); -extern int read_buf (__int64_t daddr,int count,void *bufp); +extern int read_buf (int64_t daddr,int count,void *bufp);extern void write_cur (void );^^Quoted 30 lines
db/sb.c +3
-3@@ -606,7 +606,7 @@ version_help(void) }static int -do_version (xfs_agnumber_t agno,__uint16_t version,__uint32_t features) +do_version (xfs_agnumber_t agno,uint16_t version,uint32_t features) {xfs_sb_t tsb;@@ -710,8 +710,8 @@ version_f(int argc, char **argv) { - __uint16_t version = 0; -__uint32_t features =0 ; + uint16_t version = 0; +uint32_t features =0 ;xfs_agnumber_t ag;if (argc ==2 ) {/* WRITE VERSION */ fsr/xfs_fsr.c +0
-0fsr/xfs_fsr.c struct getbmap *outmap = NULL; · line 54
Quoted 1 line
fsr/xfs_fsr.c +0
-0@@ -54,7 +54,7 @@ struct getbmap *outmap = NULL;int outmap_size =0 ;^^^fsr/xfs_fsr.c struct getbmap *outmap = NULL; · line 60
Quoted 7 lines
fsr/xfs_fsr.c +1
-1int RealUid;int tmp_agi; -static __int64_t minimumfree =2048 ; +static int64_t minimumfree =2048 ;#define MNTTYPE_XFS "xfs"^^^Quoted 12 lines
include/xfs_arch.h +1
-2@@ -244,39 +244,39 @@ static inline void be64_add_cpu(__be64 *a, __s64 b) *a =cpu_to_be64 (be64_to_cpu (*a) + b); } -static inline __uint16_t get_unaligned_be16 (void *p) +static inline uint16_t get_unaligned_be16 (void *p) { -__uint8_t *__p = p;include/xfs_arch.h static inline void be64_add_cpu(__be64 *a, __s64 b) · line 256
Quoted 10 lines
include/xfs_arch.h +3
-2+uint8_t *__p = p;return __p[0 ] <<8 | __p[1 ]; } -static inline __uint32_t get_unaligned_be32 (void *p) +static inline uint32_t get_unaligned_be32 (void *p) { -__uint8_t *__p = p; +uint8_t *__p = p;return __p[0 ] <<24 | __p[1 ] <<16 | __p[2 ] <<8 | __p[3 ];^^^
Quoted 6 lines
include/xfs_arch.h +0
-0/* libxfs/rdwr.c +0
-0libxfs/rdwr.c static void unmount_record(void *p) · line 124
Quoted 10 lines
libxfs/rdwr.c +3
-3@@ -118,9 +118,9 @@ static void unmount_record(void *p)xlog_op_header_t *op = (xlog_op_header_t *)p;/* the data section must be 32 bit size aligned */ struct { -__uint16_t magic; -__uint16_t pad1; -__uint32_t pad2;/* may as well make it 64 bits */ +uint16_t magic; +uint16_t pad1; +uint32_t pad2;/* may as well make it 64 bits */ } magic = {XLOG_UNMOUNT_TYPE ,0 ,0 };^^^logprint/log_misc.c xlog_print_trans_header(char **ptr, int len) · line 171
Quoted 12 lines
logprint/log_misc.c +1
-1@@ -166,12 +166,12 @@ xlog_print_trans_header(char **ptr, int len) {xfs_trans_header_t *h;char *cptr = *ptr; -__uint32_t magic; +uint32_t magic;char *magic_c = (char *)&magic;^^^^Quoted 8 lines
logprint/log_misc.c +1
-1*ptr += len; - magic=*(__uint32_t *)cptr;/* XXX be32_to_cpu soon */ + magic=*(uint32_t *)cptr;/* XXX be32_to_cpu soon */ if (len >=4 ) {#if __BYTE_ORDER == __LITTLE_ENDIANlogprint/log_misc.c xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops) · line 207
Quoted 8 lines
logprint/log_misc.c +1
-1@@ -201,7 +201,7 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)int num, skip;int super_block =0 ;int bucket, col, buckets; -__int64_t blkno; +int64_t blkno;xfs_buf_log_format_t lbuf;int size, blen, map_size, struct_size;__be64 x, y;^^^Quoted 14 lines
repair/attr_repair.h +0
-5@@ -32,10 +32,10 @@#define ACL_WRITE 02 #define ACL_EXECUTE 01 */ #define XFS_MAC_MAX_SETS 250 typedef struct xfs_mac_label { - __uint8_t ml_msen_type; /* MSEN label type */ - __uint8_t ml_mint_type; /* MINT label type */ - __uint8_t ml_level; /* Hierarchical level */ - __uint8_t ml_grade; /* Hierarchical grade */ - __uint16_t ml_catcount; /* Category count */repair/attr_repair.h struct xfs_icacl { · line 69
Quoted 10 lines
repair/attr_repair.h +7
-2-__uint16_t ml_divcount;/* Division count */ +uint8_t ml_msen_type;/* MSEN label type */ +uint8_t ml_mint_type;/* MINT label type */ +uint8_t ml_level;/* Hierarchical level */ +uint8_t ml_grade;/* Hierarchical grade */ +uint16_t ml_catcount;/* Category count */ +uint16_t ml_divcount;/* Division count */ /* Category set, then Division set */ -__uint16_t ml_list[XFS_MAC_MAX_SETS ]; +uint16_t ml_list[XFS_MAC_MAX_SETS ];^^^Quoted 19 lines
}
xfs_mac_label_t;repair/avl64.c +2
-2@@ -70,8 +70,8 @@ avl64_checktree( avl64node_t *root) {avl64node_t *nlast, *nnext, *np; -__uint64_t offset =0 ; -__uint64_t end; +uint64_t offset =0 ; +uint64_t end; nlast = nnext = root;
avl64node_t*
avl64_insert_find_growth(repair/avl64.c static · line 914
Quoted 6 lines
repair/avl64.c +2
-2avl64tree_desc_t *tree, - __uint64_t start, /* range start at start, */ - __uint64_t end, /* exclusive */ + uint64_t start, /* range start at start, */ + uint64_t end, /* exclusive */ int *growthp) /* OUT */^^^repair/avl64.c avl64_findadjacent( · line 1383
Quoted 11 lines
{
repair/avl64.c +2
-2avl64node_t *np = tree->avl_root;@@ -1378,8 +1378,8 @@ avl64_findadjacent( void avl64_findranges( avl64tree_desc_t *tree, - __uint64_t start, - __uint64_t end, + uint64_t start, + uint64_t end, avl64node_t **startp,^^^Quoted 17 lines
repair/avl64.c +0
-0avl64node_t **endp) {repair/avl64.h +2
-2@@ -32,8 +32,8 @@ typedef struct avl64node {* avl-tree operations */ avl64node_t * avl64_findanyrange( avl64tree_desc_t *tree, - __uint64_t start, - __uint64_t end, + uint64_t start, + uint64_t end,Quoted 1 line
int checklen);
^^^Quoted 7 lines
avl64node_t*
avl64_findadjacent(repair/avl64.h +1
-1avl64tree_desc_t *tree, - __uint64_t value, + uint64_t value,repair/avl64.h avl64_init_tree( · line 118
Quoted 10 lines
repair/avl64.h +2
-2int dir); void avl64_findranges( avl64tree_desc_t *tree, - __uint64_t start, - __uint64_t end, + uint64_t start, + uint64_t end, avl64node_t **startp,^^^Quoted 2 lines
avl64node_t**endp);Signature · 5 lines
Carlos -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/7 xfs_repair: fix symlink target length checks by changing MAXPATHLEN to XFS_SYMLINK_MAXLEN
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
XFS has a maximum symlink target length of 1024 bytes; this is a holdover from the Irix days. Unfortunately, the constant establishing this was 'MAXPATHLEN', and is /not/ the same as the Linux MAXPATHLEN, which is 4096.
The kernel enforces its 1024 byte MAXPATHLEN on symlink targets, but xfsprogs picks up the (Linux) system 4096 byte MAXPATHLEN, which means that xfs_repair doesn't complain about oversized symlinks.
Since this is an on-disk format constraint, put the define in the XFS namespace. As a side effect of the rename, xfs_repair wil detect oversized symlinks and clean them off the system.
--- repair/dinode.c | 6 +++--- repair/xfs_repair.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
repair/dinode.c +3 -3
@@ -1259,7 +1259,7 @@ null_check(char *name, int length) {int i; -ASSERT (length <MAXPATHLEN ); +ASSERT (length <XFS_SYMLINK_MAXLEN );for (i =0 ; i < length; i++, name++) {if (*name =='\0' )
@@ -1371,7 +1371,7 @@ process_symlink( blkmap_t *blkmap) {char *symlink; -char data[MAXPATHLEN ]; +char data[XFS_SYMLINK_MAXLEN ];/* * check size against kernel symlink limits. we know
@@ -1379,7 +1379,7 @@ process_symlink(* the inode is structurally ok so we don't have to check * for that */ -if (be64_to_cpu (dino->di_size) >=MAXPATHLEN ) { +if (be64_to_cpu (dino->di_size) >=XFS_SYMLINK_MAXLEN ) {do_warn (_ ("symlink in inode %" PRIu64" too long (%llu chars)\n" ), lino, (unsigned long long )be64_to_cpu (dino->di_size));return (1 );
repair/xfs_repair.c +1 -1
@@ -761,7 +761,7 @@ main(int argc, char **argv) glob_agcount = mp->m_sb.sb_agcount; chunks_pblock = mp->m_sb.sb_inopblock /XFS_INODES_PER_CHUNK ; - max_symlink_blocks =libxfs_symlink_blocks (mp,MAXPATHLEN ); + max_symlink_blocks =libxfs_symlink_blocks (mp,XFS_SYMLINK_MAXLEN ); inodes_per_cluster =MAX (mp->m_sb.sb_inopblock, mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog);
Re: [PATCH 2/7] xfs_repair: fix symlink target length checks by changing MAXPATHLEN to XFS_SYMLINK_MAXLEN
Quoted 7 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
XFS has a maximum symlink target length of 1024 bytes; this is a holdover from the Irix days. Unfortunately, the constant establishing this was 'MAXPATHLEN', and is /not/ the same as the Linux MAXPATHLEN, which is 4096.
Quoted 7 lines
The kernel enforces its 1024 byte MAXPATHLEN on symlink targets, but xfsprogs picks up the (Linux) system 4096 byte MAXPATHLEN, which means that
xfs_repairdoesn't complain about oversized symlinks.Since this is an on-disk format constraint, put the define in the XFS namespace. As a side effect of the rename,
xfs_repairwil detect oversized symlinks and clean them off the system.
null_check() is only used for symlinks today, but it's not described as such, so I was on the fence about shortening the ASSERT in there.
but meh, not worth haggling over.
Quoted 57 lines
Signed-off-by Darrick J. Wong <[email protected]>--- repair/dinode.c | 6 +++--- repair/xfs_repair.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)repair/dinode.c +3
-3@@ -1259,7 +1259,7 @@ null_check(char *name, int length) {int i; -ASSERT (length <MAXPATHLEN ); +ASSERT (length <XFS_SYMLINK_MAXLEN );for (i =0 ; i < length; i++, name++) {if (*name =='\0' )@@ -1371,7 +1371,7 @@ process_symlink( blkmap_t *blkmap) {char *symlink; -char data[MAXPATHLEN ]; +char data[XFS_SYMLINK_MAXLEN ];/* * check size against kernel symlink limits. we know @@ -1379,7 +1379,7 @@ process_symlink(* the inode is structurally ok so we don't have to check * for that */ -if (be64_to_cpu (dino->di_size) >=MAXPATHLEN ) { +if (be64_to_cpu (dino->di_size) >=XFS_SYMLINK_MAXLEN ) {do_warn (_ ("symlink in inode %" PRIu64" too long (%llu chars)\n" ), lino, (unsigned long long )be64_to_cpu (dino->di_size));return (1 );repair/xfs_repair.c +1
-2@@ -761,7 +761,7 @@ main(int argc, char **argv) glob_agcount = mp->m_sb.sb_agcount; chunks_pblock = mp->m_sb.sb_inopblock /XFS_INODES_PER_CHUNK ; - max_symlink_blocks =libxfs_symlink_blocks (mp,MAXPATHLEN ); + max_symlink_blocks =libxfs_symlink_blocks (mp,XFS_SYMLINK_MAXLEN ); inodes_per_cluster =MAX (mp->m_sb.sb_inopblock, mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog); --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/7] xfs_repair: fix symlink target length checks by changing MAXPATHLEN to XFS_SYMLINK_MAXLEN
In reply to Darrick J. WongQuoted 11 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
XFS has a maximum symlink target length of 1024 bytes; this is a holdover from the Irix days. Unfortunately, the constant establishing this was 'MAXPATHLEN', and is /not/ the same as the Linux MAXPATHLEN, which is 4096.
The kernel enforces its 1024 byte MAXPATHLEN on symlink targets, but xfsprogs picks up the (Linux) system 4096 byte MAXPATHLEN, which means that
xfs_repairdoesn't complain about oversized symlinks.
Quoted 5 lines
Since this is an on-disk format constraint, put the define in the XFS namespace. As a side effect of the rename,
xfs_repairwil detect oversized symlinks and clean them off the system.Signed-off-by Darrick J. Wong <[email protected]>
Quoted 55 lines
--- repair/dinode.c | 6 +++--- repair/xfs_repair.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)repair/dinode.c +3
-3@@ -1259,7 +1259,7 @@ null_check(char *name, int length) {int i; -ASSERT (length <MAXPATHLEN ); +ASSERT (length <XFS_SYMLINK_MAXLEN );for (i =0 ; i < length; i++, name++) {if (*name =='\0' )@@ -1371,7 +1371,7 @@ process_symlink( blkmap_t *blkmap) {char *symlink; -char data[MAXPATHLEN ]; +char data[XFS_SYMLINK_MAXLEN ];/* * check size against kernel symlink limits. we know @@ -1379,7 +1379,7 @@ process_symlink(* the inode is structurally ok so we don't have to check * for that */ -if (be64_to_cpu (dino->di_size) >=MAXPATHLEN ) { +if (be64_to_cpu (dino->di_size) >=XFS_SYMLINK_MAXLEN ) {do_warn (_ ("symlink in inode %" PRIu64" too long (%llu chars)\n" ), lino, (unsigned long long )be64_to_cpu (dino->di_size));return (1 );repair/xfs_repair.c +1
-2@@ -761,7 +761,7 @@ main(int argc, char **argv) glob_agcount = mp->m_sb.sb_agcount; chunks_pblock = mp->m_sb.sb_inopblock /XFS_INODES_PER_CHUNK ; - max_symlink_blocks =libxfs_symlink_blocks (mp,MAXPATHLEN ); + max_symlink_blocks =libxfs_symlink_blocks (mp,XFS_SYMLINK_MAXLEN ); inodes_per_cluster =MAX (mp->m_sb.sb_inopblock, mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog); --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Carlos
PATCH 3/7 xfs_db: fix metadump redirection (again)
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
In patch 4944defad4 ("xfs_db: redirect printfs when metadumping to stdout"), we solved the problem of xfs_db printfs ending up in the metadump stream by reassigning stdout for the duration of a stdout metadump. Unfortunately, musl doesn't allow stdout to be reassigned (in their view "extern FILE *stdout" means "extern FILE * const stdout"), so we abandon the old approach in favor of playing games with dup() to switch the raw file descriptors.
While we're at it, fix a regression where an unconverted outf test allows progress info to end up in the metadump stream.
--- db/metadump.c | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)
db/metadump.c +36 -11
@@ -78,6 +78,7 @@ static int obfuscate = 1;static int zero_stale_data =1 ;static int show_warnings =0 ;static int progress_since_warning =0 ; +static bool stdout_metadump;void metadump_init (void )
@@ -137,7 +138,7 @@ print_progress(const char *fmt, ...)va_end (ap); buf[sizeof (buf)-1 ] ='\0' ; - f = (outf == stdout) ? stderr : stdout; + f = stdout_metadump ? stderr : stdout;fprintf (f,"\r%-59s" , buf);fflush (f); progress_since_warning =1 ;
@@ -2750,7 +2751,8 @@ metadump_f(xfs_agnumber_t agno;int c;int start_iocur_sp; -bool stdout_metadump = false; +int outfd =-1 ; +int ret;char *p; exitcode =1 ;
@@ -2870,16 +2872,35 @@ metadump_f(* metadump operation so that dbprintf and other messages * are sent to the console instead of polluting the * metadump stream. +* +* We get to do this the hard way because musl doesn't +* allow reassignment of stdout. */ - outf = stdout; - stdout = stderr; +fflush (stdout); + outfd =dup (STDOUT_FILENO ); +if (outfd <0 ) { +perror ("opening dump stream" ); + goto out; + } + ret =dup2 (STDERR_FILENO ,STDOUT_FILENO ); +if (ret <0 ) { +perror ("redirecting stdout" ); +close (outfd); + goto out; + } + outf =fdopen (outfd,"a" ); +if (outf ==NULL ) { +fprintf (stderr,"cannot create dump stream\n" ); +dup2 (outfd,1 ); +close (outfd); + goto out; + } stdout_metadump = true; }else { outf =fopen (argv[optind],"wb" );if (outf ==NULL ) {print_warning ("cannot create dump file" ); -free (metablock); -return 0 ; + goto out; } }
@@ -2907,15 +2928,19 @@ metadump_f(if (progress_since_warning)fputc ('\n' , stdout_metadump ? stderr : stdout); -if (stdout_metadump) - stdout = outf; -else -fclose (outf); +if (stdout_metadump) { +fflush (outf); +fflush (stdout); + ret =dup2 (outfd,STDOUT_FILENO ); +if (ret <0 ) +perror ("un-redirecting stdout" ); + } +fclose (outf);/* cleanup iocur stack */ while (iocur_sp > start_iocur_sp)pop_cur (); - +out:free (metablock);return 0 ;
Re: [PATCH 3/7] xfs_db: fix metadump redirection (again)
Quoted 10 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
In patch
4944defad4("xfs_db: redirect printfs when metadumping to stdout"), we solved the problem ofxfs_dbprintfs ending up in the metadump stream by reassigning stdout for the duration of a stdout metadump. Unfortunately, musl doesn't allow stdout to be reassigned (in their view "extern FILE *stdout" means "extern FILE * const stdout"), so we abandon the old approach in favor of playing games withdup()to switch the raw file descriptors.
Quoted 4 lines
While we're at it, fix a regression where an unconverted outf test allows progress info to end up in the metadump stream.
Signed-off-by Darrick J. Wong <[email protected]>
Yuck! I mean ... thanks! ;)
Quoted 102 lines
--- db/metadump.c | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)db/metadump.c +36
-11@@ -78,6 +78,7 @@ static int obfuscate = 1;static int zero_stale_data =1 ;static int show_warnings =0 ;static int progress_since_warning =0 ; +static bool stdout_metadump;void metadump_init (void )@@ -137,7 +138,7 @@ print_progress(const char *fmt, ...)va_end (ap); buf[sizeof (buf)-1 ] ='\0' ; - f = (outf == stdout) ? stderr : stdout; + f = stdout_metadump ? stderr : stdout;fprintf (f,"\r%-59s" , buf);fflush (f); progress_since_warning =1 ;@@ -2750,7 +2751,8 @@ metadump_f(xfs_agnumber_t agno;int c;int start_iocur_sp; -bool stdout_metadump = false; +int outfd =-1 ; +int ret;char *p; exitcode =1 ;@@ -2870,16 +2872,35 @@ metadump_f(* metadump operation so that dbprintf and other messages * are sent to the console instead of polluting the * metadump stream. +* +* We get to do this the hard way because musl doesn't +* allow reassignment of stdout. */ - outf = stdout; - stdout = stderr; +fflush (stdout); + outfd =dup (STDOUT_FILENO ); +if (outfd <0 ) { +perror ("opening dump stream" ); + goto out; + } + ret =dup2 (STDERR_FILENO ,STDOUT_FILENO ); +if (ret <0 ) { +perror ("redirecting stdout" ); +close (outfd); + goto out; + } + outf =fdopen (outfd,"a" ); +if (outf ==NULL ) { +fprintf (stderr,"cannot create dump stream\n" ); +dup2 (outfd,1 ); +close (outfd); + goto out; + } stdout_metadump = true; }else { outf =fopen (argv[optind],"wb" );if (outf ==NULL ) {print_warning ("cannot create dump file" ); -free (metablock); -return 0 ; + goto out; } }@@ -2907,15 +2928,19 @@ metadump_f(if (progress_since_warning)fputc ('\n' , stdout_metadump ? stderr : stdout); -if (stdout_metadump) - stdout = outf; -else -fclose (outf); +if (stdout_metadump) { +fflush (outf); +fflush (stdout); + ret =dup2 (outfd,STDOUT_FILENO ); +if (ret <0 ) +perror ("un-redirecting stdout" ); + } +fclose (outf);/* cleanup iocur stack */ while (iocur_sp > start_iocur_sp)pop_cur (); - +out:free (metablock);return 0 ;
PATCH v2 3/7 xfs_db: fix metadump redirection (again)
In reply to Darrick J. WongIn patch 4944defad4 ("xfs_db: redirect printfs when metadumping to stdout"), we solved the problem of xfs_db printfs ending up in the metadump stream by reassigning stdout for the duration of a stdout metadump. Unfortunately, musl doesn't allow stdout to be reassigned (in their view "extern FILE *stdout" means "extern FILE * const stdout"), so we abandon the old approach in favor of playing games with dup() to switch the raw file descriptors.
While we're at it, fix a regression where an unconverted outf test allows progress info to end up in the metadump stream.
---
v2: fix STDOUT_FILENO usage
--- db/metadump.c | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)
db/metadump.c +36 -11
@@ -78,6 +78,7 @@ static int obfuscate = 1;static int zero_stale_data =1 ;static int show_warnings =0 ;static int progress_since_warning =0 ; +static bool stdout_metadump;void metadump_init (void )
@@ -137,7 +138,7 @@ print_progress(const char *fmt, ...)va_end (ap); buf[sizeof (buf)-1 ] ='\0' ; - f = (outf == stdout) ? stderr : stdout; + f = stdout_metadump ? stderr : stdout;fprintf (f,"\r%-59s" , buf);fflush (f); progress_since_warning =1 ;
@@ -2750,7 +2751,8 @@ metadump_f(xfs_agnumber_t agno;int c;int start_iocur_sp; -bool stdout_metadump = false; +int outfd =-1 ; +int ret;char *p; exitcode =1 ;
@@ -2870,16 +2872,35 @@ metadump_f(* metadump operation so that dbprintf and other messages * are sent to the console instead of polluting the * metadump stream. +* +* We get to do this the hard way because musl doesn't +* allow reassignment of stdout. */ - outf = stdout; - stdout = stderr; +fflush (stdout); + outfd =dup (STDOUT_FILENO ); +if (outfd <0 ) { +perror ("opening dump stream" ); + goto out; + } + ret =dup2 (STDERR_FILENO ,STDOUT_FILENO ); +if (ret <0 ) { +perror ("redirecting stdout" ); +close (outfd); + goto out; + } + outf =fdopen (outfd,"a" ); +if (outf ==NULL ) { +fprintf (stderr,"cannot create dump stream\n" ); +dup2 (outfd,STDOUT_FILENO ); +close (outfd); + goto out; + } stdout_metadump = true; }else { outf =fopen (argv[optind],"wb" );if (outf ==NULL ) {print_warning ("cannot create dump file" ); -free (metablock); -return 0 ; + goto out; } }
@@ -2907,15 +2928,19 @@ metadump_f(if (progress_since_warning)fputc ('\n' , stdout_metadump ? stderr : stdout); -if (stdout_metadump) - stdout = outf; -else -fclose (outf); +if (stdout_metadump) { +fflush (outf); +fflush (stdout); + ret =dup2 (outfd,STDOUT_FILENO ); +if (ret <0 ) +perror ("un-redirecting stdout" ); + } +fclose (outf);/* cleanup iocur stack */ while (iocur_sp > start_iocur_sp)pop_cur (); - +out:free (metablock);return 0 ;
Re: [PATCH v2 3/7] xfs_db: fix metadump redirection (again)
Quoted 8 lines · Darrick J. Wong
In patch
4944defad4("xfs_db: redirect printfs when metadumping to stdout"), we solved the problem ofxfs_dbprintfs ending up in the metadump stream by reassigning stdout for the duration of a stdout metadump. Unfortunately, musl doesn't allow stdout to be reassigned (in their view "extern FILE *stdout" means "extern FILE * const stdout"), so we abandon the old approach in favor of playing games withdup()to switch the raw file descriptors.
Quoted 6 lines
While we're at it, fix a regression where an unconverted outf test allows progress info to end up in the metadump stream.
Signed-off-by Darrick J. Wong <[email protected]>---
v2: fixSTDOUT_FILENOusage
Quoted 104 lines
--- db/metadump.c | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)db/metadump.c +36
-12@@ -78,6 +78,7 @@ static int obfuscate = 1;static int zero_stale_data =1 ;static int show_warnings =0 ;static int progress_since_warning =0 ; +static bool stdout_metadump;void metadump_init (void )@@ -137,7 +138,7 @@ print_progress(const char *fmt, ...)va_end (ap); buf[sizeof (buf)-1 ] ='\0' ; - f = (outf == stdout) ? stderr : stdout; + f = stdout_metadump ? stderr : stdout;fprintf (f,"\r%-59s" , buf);fflush (f); progress_since_warning =1 ;@@ -2750,7 +2751,8 @@ metadump_f(xfs_agnumber_t agno;int c;int start_iocur_sp; -bool stdout_metadump = false; +int outfd =-1 ; +int ret;char *p; exitcode =1 ;@@ -2870,16 +2872,35 @@ metadump_f(* metadump operation so that dbprintf and other messages * are sent to the console instead of polluting the * metadump stream. +* +* We get to do this the hard way because musl doesn't +* allow reassignment of stdout. */ - outf = stdout; - stdout = stderr; +fflush (stdout); + outfd =dup (STDOUT_FILENO ); +if (outfd <0 ) { +perror ("opening dump stream" ); + goto out; + } + ret =dup2 (STDERR_FILENO ,STDOUT_FILENO ); +if (ret <0 ) { +perror ("redirecting stdout" ); +close (outfd); + goto out; + } + outf =fdopen (outfd,"a" ); +if (outf ==NULL ) { +fprintf (stderr,"cannot create dump stream\n" ); +dup2 (outfd,STDOUT_FILENO ); +close (outfd); + goto out; + } stdout_metadump = true; }else { outf =fopen (argv[optind],"wb" );if (outf ==NULL ) {print_warning ("cannot create dump file" ); -free (metablock); -return 0 ; + goto out; } }@@ -2907,15 +2928,19 @@ metadump_f(if (progress_since_warning)fputc ('\n' , stdout_metadump ? stderr : stdout); -if (stdout_metadump) - stdout = outf; -else -fclose (outf); +if (stdout_metadump) { +fflush (outf); +fflush (stdout); + ret =dup2 (outfd,STDOUT_FILENO ); +if (ret <0 ) +perror ("un-redirecting stdout" ); + } +fclose (outf);/* cleanup iocur stack */ while (iocur_sp > start_iocur_sp)pop_cur (); - +out:free (metablock);return 0 ; --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Carlos
PATCH 4/7 xfs_db: dump dir/attr btrees
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Dump the directory or extended attribute btree contents.
--- db/btdump.c | 251 +++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man8/xfs_db.8 | 1 2 files changed, 252 insertions(+)
db/btdump.c +251 -0
@@ -227,6 +227,252 @@ dump_inode(return ret; } +static bool +dir_has_rightsib ( +void *block, +int level) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return lhdr.forw !=0 ; +} + +static int +dir_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR2_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR2_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +dir3_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR3_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static bool +attr_has_rightsib ( +void *block, +int level) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return lhdr.hdr.info.forw !=0 ; +} + +static int +attr_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +attr3_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +struct dabprinter { +const char *print_node_entries; +const char *print_leaf_entries; +const char *go_node_forward; +const char *go_leaf_forward; +const char *go_down; +bool (*has_rightsib)(void *,int ); +int (*level)(void *); +}; + +static struct dabprinter attr_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.forw" , + .go_leaf_forward ="hdr.info.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr_level, +}; + +static struct dabprinter attr3_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.hdr.forw" , + .go_leaf_forward ="hdr.info.hdr.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr3_level, +}; + +static struct dabprinter dir_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.hdr.forw" , + .go_leaf_forward ="lhdr.info.hdr.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir_level, +}; + +static struct dabprinter dir3_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.forw" , + .go_leaf_forward ="lhdr.info.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir3_level, +}; + +static int +dump_dablevel ( +int level, +struct dabprinter *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +unsigned int nr; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + nr =1 ; +do { + last_daddr = iocur_top->bb; +dbprintf (_ ("%s level %u block %u daddr %llu\n" ), + iocur_top->typ->name, level, nr, last_daddr); + ret =eval ("print %s" , level >0 ? dbp->print_node_entries : + dbp->print_leaf_entries); +if (ret) + goto err; +if (dbp->has_rightsib (iocur_top->data, level)) { + ret =eval ("addr %s" , level >0 ? dbp->go_node_forward : + dbp->go_leaf_forward); +if (ret) + goto err; + } + nr++; + }while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + +static int +dump_dabtree ( +bool dump_node_blocks, +struct dabprinter *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +int level; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + cur_agno =XFS_FSB_TO_AGNO (mp,XFS_DADDR_TO_FSB (mp, iocur_top->bb)); + level = dbp->level (iocur_top->data); +if (level <0 ) { +printf (_ ("Current location is not part of a dir/attr btree.\n" )); + goto err; + } + +do { + last_daddr = iocur_top->bb; +if (level >0 ) { +if (dump_node_blocks) { + ret =dump_dablevel (level, dbp); +if (ret) + goto err; + } + ret =eval ("addr %s" , dbp->go_down); + }else { + ret =dump_dablevel (level, dbp); + } +if (ret) + goto err; + level--; + }while (level >=0 && + iocur_top->bb != orig_daddr && + iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + static int btdump_f( int argc,
@@ -234,6 +480,7 @@ btdump_f( {bool aflag = false;bool iflag = false; +bool crc =xfs_sb_version_hascrc (&mp->m_sb);int c;if (cur_typ ==NULL ) {
@@ -276,6 +523,10 @@ btdump_f(return dump_btree_long (iflag);case TYP_INODE :return dump_inode (iflag, aflag); +case TYP_ATTR : +return dump_dabtree (iflag, crc ? &attr3_print : &attr_print); +case TYP_DIR2 : +return dump_dabtree (iflag, crc ? &dir3_print : &dir_print);default :dbprintf (_ ("type \"%s\" is not a btree type or inode\n" ), cur_typ->name);
man/man8/xfs_db.8 +1 -0
@@ -335,6 +335,7 @@ area of the inode, if neither option is given then both areas are shown. .B btdump [-a] [-i] If the cursor points to a btree node, dump the btree from that block downward. If instead the cursor points to an inode, dump the data fork block mapping btree if there is one. +If the cursor points to a directory or extended attribute btree node, dump that. By default, only records stored in the btree are dumped. .RS 1.0i .TP 0.4i
Re: [PATCH 4/7] xfs_db: dump dir/attr btrees
Quoted 86 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Dump the directory or extended attribute btree contents.
Signed-off-by Darrick J. Wong <[email protected]>--- db/btdump.c | 251 +++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man8/xfs_db.8 | 1 2 files changed, 252 insertions(+)db/btdump.c +67
-0@@ -227,6 +227,252 @@ dump_inode(return ret; } +static bool +dir_has_rightsib ( +void *block, +int level) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return lhdr.forw !=0 ; +} + +static int +dir_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR2_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR2_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +dir3_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR3_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static bool +attr_has_rightsib ( +void *block, +int level) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ;
db/btdump.c dump_inode( · line 306
Quoted 10 lines
db/btdump.c +10
-0+ } +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return lhdr.hdr.info.forw !=0 ; +} + +static int +attr_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr;
funky whitespace
Quoted 9 lines
db/btdump.c +9
-0+struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level;
db/btdump.c dump_inode( · line 325
Quoted 10 lines
db/btdump.c +10
-0+default : +return -1 ; + } +} + +static int +attr3_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr;
... again
Quoted 65 lines
db/btdump.c +65
-0+struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +struct dabprinter { +const char *print_node_entries; +const char *print_leaf_entries; +const char *go_node_forward; +const char *go_leaf_forward; +const char *go_down; +bool (*has_rightsib)(void *,int ); +int (*level)(void *); +}; + +static struct dabprinter attr_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.forw" , + .go_leaf_forward ="hdr.info.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr_level, +}; + +static struct dabprinter attr3_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.hdr.forw" , + .go_leaf_forward ="hdr.info.hdr.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr3_level, +}; + +static struct dabprinter dir_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.hdr.forw" , + .go_leaf_forward ="lhdr.info.hdr.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir_level, +}; + +static struct dabprinter dir3_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.forw" , + .go_leaf_forward ="lhdr.info.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir3_level, +}; + +static int
db/btdump.c dump_inode( · line 400
Quoted 10 lines
db/btdump.c +10
-0+dump_dablevel ( + int level, + struct dabprinter *dbp) +{ + xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +unsigned int nr; +int ret; + + ret =eval ("push" );
stupid question, is this different from simply push_cur()?
Quoted 102 lines
db/btdump.c +80
-0+if (ret) +return ret; + + nr =1 ; +do { + last_daddr = iocur_top->bb; +dbprintf (_ ("%s level %u block %u daddr %llu\n" ), + iocur_top->typ->name, level, nr, last_daddr); + ret =eval ("print %s" , level >0 ? dbp->print_node_entries : + dbp->print_leaf_entries); +if (ret) + goto err; +if (dbp->has_rightsib (iocur_top->data, level)) { + ret =eval ("addr %s" , level >0 ? dbp->go_node_forward : + dbp->go_leaf_forward); +if (ret) + goto err; + } + nr++; + }while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + +static int +dump_dabtree ( +bool dump_node_blocks, +struct dabprinter *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +int level; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + cur_agno =XFS_FSB_TO_AGNO (mp,XFS_DADDR_TO_FSB (mp, iocur_top->bb)); + level = dbp->level (iocur_top->data); +if (level <0 ) { +printf (_ ("Current location is not part of a dir/attr btree.\n" )); + goto err; + } + +do { + last_daddr = iocur_top->bb; +if (level >0 ) { +if (dump_node_blocks) { + ret =dump_dablevel (level, dbp); +if (ret) + goto err; + } + ret =eval ("addr %s" , dbp->go_down); + }else { + ret =dump_dablevel (level, dbp); + } +if (ret) + goto err; + level--; + }while (level >=0 && + iocur_top->bb != orig_daddr && + iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + static int btdump_f( int argc,@@ -234,6 +480,7 @@ btdump_f( {bool aflag = false;bool iflag = false; +bool crc =xfs_sb_version_hascrc (&mp->m_sb);int c;if (cur_typ ==NULL ) {@@ -276,6 +523,10 @@ btdump_f(return dump_btree_long (iflag);case TYP_INODE :return dump_inode (iflag, aflag); +case TYP_ATTR : +return dump_dabtree (iflag, crc ? &attr3_print : &attr_print); +case TYP_DIR2 : +return dump_dabtree (iflag, crc ? &dir3_print : &dir_print);default :dbprintf (_ ("type \"%s\" is not a btree type or inode\n" ), cur_typ->name);man/man8/xfs_db.8 +0
-0
man/man8/xfs_db.8 area of the inode, if neither option is given then both areas are shown. · line 339
Quoted 5 lines
man/man8/xfs_db.8 +1
-0@@ -335,6 +335,7 @@ area of the inode, if neither option is given then both areas are shown. .B btdump [-a] [-i] If the cursor points to a btree node, dump the btree from that block downward. If instead the cursor points to an inode, dump the data fork block mapping btree if there is one. +If the cursor points to a directory or extended attribute btree node, dump that. By default, only records stored in the btree are dumped.
adding this to the command long help would be nice too
xfs_db> help btdump
btdump [-a] [-i] -- dump btree
If the cursor points to a btree block, 'btdump' dumps the btree downward from that block. If the cursor points to an inode, the data fork btree root is selected by default.
Options:
-a -- Display an inode's extended attribute fork btree. -i -- Print internal btree nodes.
Quoted 3 lines
man/man8/xfs_db.8 +0
-0.RS 1.0i .TP 0.4i
Re: [PATCH 4/7] xfs_db: dump dir/attr btrees
Quoted 113 lines · Eric Sandeen
Quoted 86 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Dump the directory or extended attribute btree contents.
Signed-off-by Darrick J. Wong <[email protected]>--- db/btdump.c | 251 +++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man8/xfs_db.8 | 1 2 files changed, 252 insertions(+)db/btdump.c +67
-0@@ -227,6 +227,252 @@ dump_inode(return ret; } +static bool +dir_has_rightsib ( +void *block, +int level) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return lhdr.forw !=0 ; +} + +static int +dir_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR2_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR2_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +dir3_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR3_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static bool +attr_has_rightsib ( +void *block, +int level) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ;db/btdump.c dump_inode( · line 306
Quoted 10 lines
db/btdump.c +10
-0+ } +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return lhdr.hdr.info.forw !=0 ; +} + +static int +attr_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr;funky whitespace
Quoted 13 lines
db/btdump.c +13
-0+struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +}
Quoted 8 lines
db/btdump.c dump_inode( · line 325
Quoted 6 lines
db/btdump.c +6
-0+ +static int +attr3_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr;... again
Fixed both.
Quoted 69 lines
Quoted 69 lines
db/btdump.c +69
-0+struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +struct dabprinter { +const char *print_node_entries; +const char *print_leaf_entries; +const char *go_node_forward; +const char *go_leaf_forward; +const char *go_down; +bool (*has_rightsib)(void *,int ); +int (*level)(void *); +}; + +static struct dabprinter attr_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.forw" , + .go_leaf_forward ="hdr.info.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr_level, +}; + +static struct dabprinter attr3_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.hdr.forw" , + .go_leaf_forward ="hdr.info.hdr.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr3_level, +}; + +static struct dabprinter dir_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.hdr.forw" , + .go_leaf_forward ="lhdr.info.hdr.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir_level, +}; + +static struct dabprinter dir3_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.forw" , + .go_leaf_forward ="lhdr.info.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir3_level, +}; + +static int +dump_dablevel ( +int level, +struct dabprinter *dbp) +{
Quoted 8 lines
db/btdump.c dump_inode( · line 400
Quoted 6 lines
db/btdump.c +6
-0+xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +unsigned int nr; +int ret; + + ret =eval ("push" );stupid question, is this different from simply
push_cur()?
Yes, we need set_cur() to finish initializing iocur_top.
Quoted 113 lines
Quoted 102 lines
db/btdump.c +80
-0+if (ret) +return ret; + + nr =1 ; +do { + last_daddr = iocur_top->bb; +dbprintf (_ ("%s level %u block %u daddr %llu\n" ), + iocur_top->typ->name, level, nr, last_daddr); + ret =eval ("print %s" , level >0 ? dbp->print_node_entries : + dbp->print_leaf_entries); +if (ret) + goto err; +if (dbp->has_rightsib (iocur_top->data, level)) { + ret =eval ("addr %s" , level >0 ? dbp->go_node_forward : + dbp->go_leaf_forward); +if (ret) + goto err; + } + nr++; + }while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + +static int +dump_dabtree ( +bool dump_node_blocks, +struct dabprinter *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +int level; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + cur_agno =XFS_FSB_TO_AGNO (mp,XFS_DADDR_TO_FSB (mp, iocur_top->bb)); + level = dbp->level (iocur_top->data); +if (level <0 ) { +printf (_ ("Current location is not part of a dir/attr btree.\n" )); + goto err; + } + +do { + last_daddr = iocur_top->bb; +if (level >0 ) { +if (dump_node_blocks) { + ret =dump_dablevel (level, dbp); +if (ret) + goto err; + } + ret =eval ("addr %s" , dbp->go_down); + }else { + ret =dump_dablevel (level, dbp); + } +if (ret) + goto err; + level--; + }while (level >=0 && + iocur_top->bb != orig_daddr && + iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + static int btdump_f( int argc,@@ -234,6 +480,7 @@ btdump_f( {bool aflag = false;bool iflag = false; +bool crc =xfs_sb_version_hascrc (&mp->m_sb);int c;if (cur_typ ==NULL ) {@@ -276,6 +523,10 @@ btdump_f(return dump_btree_long (iflag);case TYP_INODE :return dump_inode (iflag, aflag); +case TYP_ATTR : +return dump_dabtree (iflag, crc ? &attr3_print : &attr_print); +case TYP_DIR2 : +return dump_dabtree (iflag, crc ? &dir3_print : &dir_print);default :dbprintf (_ ("type \"%s\" is not a btree type or inode\n" ), cur_typ->name);man/man8/xfs_db.8 +0
-0man/man8/xfs_db.8 area of the inode, if neither option is given then both areas are shown. · line 339
Quoted 5 lines
man/man8/xfs_db.8 +1
-0@@ -335,6 +335,7 @@ area of the inode, if neither option is given then both areas are shown. .B btdump [-a] [-i] If the cursor points to a btree node, dump the btree from that block downward. If instead the cursor points to an inode, dump the data fork block mapping btree if there is one. +If the cursor points to a directory or extended attribute btree node, dump that. By default, only records stored in the btree are dumped.adding this to the command long help would be nice too
xfs_db> help btdump
btdump [-a] [-i] -- dump btree
Quoted 7 lines
If the cursor points to a btree block, 'btdump' dumps the btree downward from that block. If the cursor points to an inode, the data fork btree root is selected by default.
Options:
-a -- Display an inode's extended attribute fork btree. -i -- Print internal btree nodes.
Will do.
--D
Quoted 11 lines
man/man8/xfs_db.8 area of the inode, if neither option is given then both areas are shown. · line 341
Quoted 6 lines
man/man8/xfs_db.8 +0
-0.RS 1.0i .TP 0.4i--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 4/7 xfs_db: dump dir/attr btrees
In reply to Darrick J. WongDump the directory or extended attribute btree contents.
--- db/btdump.c | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man8/xfs_db.8 | 1 2 files changed, 255 insertions(+), 1 deletion(-)
db/btdump.c +254 -1
@@ -32,7 +32,9 @@ btdump_help(void)"\n" " If the cursor points to a btree block, 'btdump' dumps the btree\n" " downward from that block. If the cursor points to an inode,\n" -" the data fork btree root is selected by default.\n" +" the data fork btree root is selected by default. If the cursor\n" +" points to a directory or extended attribute btree node, the tree\n" +" will be printed downward from that block.\n" "\n" " Options:\n" " -a -- Display an inode's extended attribute fork btree.\n"
@@ -227,6 +229,252 @@ dump_inode(return ret; } +static bool +dir_has_rightsib ( +void *block, +int level) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return lhdr.forw !=0 ; +} + +static int +dir_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR2_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR2_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +dir3_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR3_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static bool +attr_has_rightsib ( +void *block, +int level) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return lhdr.hdr.info.forw !=0 ; +} + +static int +attr_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +attr3_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +struct dabprinter_ops { +const char *print_node_entries; +const char *print_leaf_entries; +const char *go_node_forward; +const char *go_leaf_forward; +const char *go_down; +bool (*has_rightsib)(void *,int ); +int (*level)(void *); +}; + +static struct dabprinter_ops attr_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.forw" , + .go_leaf_forward ="hdr.info.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr_level, +}; + +static struct dabprinter_ops attr3_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.hdr.forw" , + .go_leaf_forward ="hdr.info.hdr.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr3_level, +}; + +static struct dabprinter_ops dir_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.hdr.forw" , + .go_leaf_forward ="lhdr.info.hdr.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir_level, +}; + +static struct dabprinter_ops dir3_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.forw" , + .go_leaf_forward ="lhdr.info.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir3_level, +}; + +static int +dump_dablevel ( +int level, +struct dabprinter_ops *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +unsigned int nr; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + nr =1 ; +do { + last_daddr = iocur_top->bb; +dbprintf (_ ("%s level %u block %u daddr %llu\n" ), + iocur_top->typ->name, level, nr, last_daddr); + ret =eval ("print %s" , level >0 ? dbp->print_node_entries : + dbp->print_leaf_entries); +if (ret) + goto err; +if (dbp->has_rightsib (iocur_top->data, level)) { + ret =eval ("addr %s" , level >0 ? dbp->go_node_forward : + dbp->go_leaf_forward); +if (ret) + goto err; + } + nr++; + }while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + +static int +dump_dabtree ( +bool dump_node_blocks, +struct dabprinter_ops *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +int level; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + cur_agno =XFS_FSB_TO_AGNO (mp,XFS_DADDR_TO_FSB (mp, iocur_top->bb)); + level = dbp->level (iocur_top->data); +if (level <0 ) { +printf (_ ("Current location is not part of a dir/attr btree.\n" )); + goto err; + } + +do { + last_daddr = iocur_top->bb; +if (level >0 ) { +if (dump_node_blocks) { + ret =dump_dablevel (level, dbp); +if (ret) + goto err; + } + ret =eval ("addr %s" , dbp->go_down); + }else { + ret =dump_dablevel (level, dbp); + } +if (ret) + goto err; + level--; + }while (level >=0 && + iocur_top->bb != orig_daddr && + iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + static int btdump_f( int argc,
@@ -234,6 +482,7 @@ btdump_f( {bool aflag = false;bool iflag = false; +bool crc =xfs_sb_version_hascrc (&mp->m_sb);int c;if (cur_typ ==NULL ) {
@@ -276,6 +525,10 @@ btdump_f(return dump_btree_long (iflag);case TYP_INODE :return dump_inode (iflag, aflag); +case TYP_ATTR : +return dump_dabtree (iflag, crc ? &attr3_print : &attr_print); +case TYP_DIR2 : +return dump_dabtree (iflag, crc ? &dir3_print : &dir_print);default :dbprintf (_ ("type \"%s\" is not a btree type or inode\n" ), cur_typ->name);
man/man8/xfs_db.8 +1 -0
@@ -335,6 +335,7 @@ area of the inode, if neither option is given then both areas are shown. .B btdump [-a] [-i] If the cursor points to a btree node, dump the btree from that block downward. If instead the cursor points to an inode, dump the data fork block mapping btree if there is one. +If the cursor points to a directory or extended attribute btree node, dump that. By default, only records stored in the btree are dumped. .RS 1.0i .TP 0.4i
Re: [PATCH v2 4/7] xfs_db: dump dir/attr btrees
Quoted 3 lines · Darrick J. Wong
Dump the directory or extended attribute btree contents.
Signed-off-by Darrick J. Wong <[email protected]>
Quoted 309 lines
--- db/btdump.c | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man8/xfs_db.8 | 1 2 files changed, 255 insertions(+), 1 deletion(-)db/btdump.c +254
-1@@ -32,7 +32,9 @@ btdump_help(void)"\n" " If the cursor points to a btree block, 'btdump' dumps the btree\n" " downward from that block. If the cursor points to an inode,\n" -" the data fork btree root is selected by default.\n" +" the data fork btree root is selected by default. If the cursor\n" +" points to a directory or extended attribute btree node, the tree\n" +" will be printed downward from that block.\n" "\n" " Options:\n" " -a -- Display an inode's extended attribute fork btree.\n" @@ -227,6 +229,252 @@ dump_inode(return ret; } +static bool +dir_has_rightsib ( +void *block, +int level) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return lhdr.forw !=0 ; +} + +static int +dir_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR2_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR2_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +dir3_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR3_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static bool +attr_has_rightsib ( +void *block, +int level) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return lhdr.hdr.info.forw !=0 ; +} + +static int +attr_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +attr3_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +struct dabprinter_ops { +const char *print_node_entries; +const char *print_leaf_entries; +const char *go_node_forward; +const char *go_leaf_forward; +const char *go_down; +bool (*has_rightsib)(void *,int ); +int (*level)(void *); +}; + +static struct dabprinter_ops attr_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.forw" , + .go_leaf_forward ="hdr.info.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr_level, +}; + +static struct dabprinter_ops attr3_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.hdr.forw" , + .go_leaf_forward ="hdr.info.hdr.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr3_level, +}; + +static struct dabprinter_ops dir_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.hdr.forw" , + .go_leaf_forward ="lhdr.info.hdr.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir_level, +}; + +static struct dabprinter_ops dir3_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.forw" , + .go_leaf_forward ="lhdr.info.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir3_level, +}; + +static int +dump_dablevel ( +int level, +struct dabprinter_ops *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +unsigned int nr; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + nr =1 ; +do { + last_daddr = iocur_top->bb; +dbprintf (_ ("%s level %u block %u daddr %llu\n" ), + iocur_top->typ->name, level, nr, last_daddr); + ret =eval ("print %s" , level >0 ? dbp->print_node_entries : + dbp->print_leaf_entries); +if (ret) + goto err; +if (dbp->has_rightsib (iocur_top->data, level)) { + ret =eval ("addr %s" , level >0 ? dbp->go_node_forward : + dbp->go_leaf_forward); +if (ret) + goto err; + } + nr++; + }while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + +static int +dump_dabtree ( +bool dump_node_blocks, +struct dabprinter_ops *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +int level; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + cur_agno =XFS_FSB_TO_AGNO (mp,XFS_DADDR_TO_FSB (mp, iocur_top->bb)); + level = dbp->level (iocur_top->data); +if (level <0 ) { +printf (_ ("Current location is not part of a dir/attr btree.\n" )); + goto err; + } + +do { + last_daddr = iocur_top->bb; +if (level >0 ) { +if (dump_node_blocks) { + ret =dump_dablevel (level, dbp); +if (ret) + goto err; + } + ret =eval ("addr %s" , dbp->go_down); + }else { + ret =dump_dablevel (level, dbp); + } +if (ret) + goto err; + level--; + }while (level >=0 && + iocur_top->bb != orig_daddr && + iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + static int btdump_f( int argc,@@ -234,6 +482,7 @@ btdump_f( {bool aflag = false;bool iflag = false; +bool crc =xfs_sb_version_hascrc (&mp->m_sb);int c;if (cur_typ ==NULL ) {@@ -276,6 +525,10 @@ btdump_f(return dump_btree_long (iflag);case TYP_INODE :return dump_inode (iflag, aflag); +case TYP_ATTR : +return dump_dabtree (iflag, crc ? &attr3_print : &attr_print); +case TYP_DIR2 : +return dump_dabtree (iflag, crc ? &dir3_print : &dir_print);default :dbprintf (_ ("type \"%s\" is not a btree type or inode\n" ), cur_typ->name);man/man8/xfs_db.8 +1
-1@@ -335,6 +335,7 @@ area of the inode, if neither option is given then both areas are shown. .B btdump [-a] [-i] If the cursor points to a btree node, dump the btree from that block downward. If instead the cursor points to an inode, dump the data fork block mapping btree if there is one. +If the cursor points to a directory or extended attribute btree node, dump that. By default, only records stored in the btree are dumped. .RS 1.0i .TP 0.4i --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 4/7] xfs_db: dump dir/attr btrees
In reply to Darrick J. WongQuoted 2 lines · Darrick J. Wong
Dump the directory or extended attribute btree contents.
Sweet, thanks
Quoted 309 lines
Signed-off-by Darrick J. Wong <[email protected]>--- db/btdump.c | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++++ man/man8/xfs_db.8 | 1 2 files changed, 255 insertions(+), 1 deletion(-)db/btdump.c +254
-1@@ -32,7 +32,9 @@ btdump_help(void)"\n" " If the cursor points to a btree block, 'btdump' dumps the btree\n" " downward from that block. If the cursor points to an inode,\n" -" the data fork btree root is selected by default.\n" +" the data fork btree root is selected by default. If the cursor\n" +" points to a directory or extended attribute btree node, the tree\n" +" will be printed downward from that block.\n" "\n" " Options:\n" " -a -- Display an inode's extended attribute fork btree.\n" @@ -227,6 +229,252 @@ dump_inode(return ret; } +static bool +dir_has_rightsib ( +void *block, +int level) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return lhdr.forw !=0 ; +} + +static int +dir_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR2_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR2_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +dir3_level ( +void *block) +{ +struct xfs_dir3_icleaf_hdr lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_DIR3_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ): +M_DIROPS (mp)->leaf_hdr_from_disk (&lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static bool +attr_has_rightsib ( +void *block, +int level) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +if (level >0 ) { +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.forw !=0 ; + } +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return lhdr.hdr.info.forw !=0 ; +} + +static int +attr_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +static int +attr3_level ( +void *block) +{ +struct xfs_attr_leafblock lhdr; +struct xfs_da3_icnode_hdr nhdr; + +switch (((struct xfs_da_intnode *)block)->hdr.info.magic) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ): +xfs_attr3_leaf_hdr_to_disk (mp->m_attr_geo, &lhdr, block); +return 0 ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +M_DIROPS (mp)->node_hdr_from_disk (&nhdr, block); +return nhdr.level; +default : +return -1 ; + } +} + +struct dabprinter_ops { +const char *print_node_entries; +const char *print_leaf_entries; +const char *go_node_forward; +const char *go_leaf_forward; +const char *go_down; +bool (*has_rightsib)(void *,int ); +int (*level)(void *); +}; + +static struct dabprinter_ops attr_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.forw" , + .go_leaf_forward ="hdr.info.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr_level, +}; + +static struct dabprinter_ops attr3_print = { + .print_node_entries ="btree" , + .print_leaf_entries ="entries nvlist" , + .go_node_forward ="hdr.info.hdr.forw" , + .go_leaf_forward ="hdr.info.hdr.forw" , + .go_down ="btree[0].before" , + .has_rightsib = attr_has_rightsib, + .level = attr3_level, +}; + +static struct dabprinter_ops dir_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.hdr.forw" , + .go_leaf_forward ="lhdr.info.hdr.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir_level, +}; + +static struct dabprinter_ops dir3_print = { + .print_node_entries ="nbtree" , + .print_leaf_entries ="lents" , + .go_node_forward ="nhdr.info.forw" , + .go_leaf_forward ="lhdr.info.forw" , + .go_down ="nbtree[0].before" , + .has_rightsib = dir_has_rightsib, + .level = dir3_level, +}; + +static int +dump_dablevel ( +int level, +struct dabprinter_ops *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +unsigned int nr; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + nr =1 ; +do { + last_daddr = iocur_top->bb; +dbprintf (_ ("%s level %u block %u daddr %llu\n" ), + iocur_top->typ->name, level, nr, last_daddr); + ret =eval ("print %s" , level >0 ? dbp->print_node_entries : + dbp->print_leaf_entries); +if (ret) + goto err; +if (dbp->has_rightsib (iocur_top->data, level)) { + ret =eval ("addr %s" , level >0 ? dbp->go_node_forward : + dbp->go_leaf_forward); +if (ret) + goto err; + } + nr++; + }while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + +static int +dump_dabtree ( +bool dump_node_blocks, +struct dabprinter_ops *dbp) +{ +xfs_daddr_t orig_daddr = iocur_top->bb; +xfs_daddr_t last_daddr; +int level; +int ret; + + ret =eval ("push" ); +if (ret) +return ret; + + cur_agno =XFS_FSB_TO_AGNO (mp,XFS_DADDR_TO_FSB (mp, iocur_top->bb)); + level = dbp->level (iocur_top->data); +if (level <0 ) { +printf (_ ("Current location is not part of a dir/attr btree.\n" )); + goto err; + } + +do { + last_daddr = iocur_top->bb; +if (level >0 ) { +if (dump_node_blocks) { + ret =dump_dablevel (level, dbp); +if (ret) + goto err; + } + ret =eval ("addr %s" , dbp->go_down); + }else { + ret =dump_dablevel (level, dbp); + } +if (ret) + goto err; + level--; + }while (level >=0 && + iocur_top->bb != orig_daddr && + iocur_top->bb != last_daddr); + + ret =eval ("pop" ); +return ret; +err: +eval ("pop" ); +return ret; +} + static int btdump_f( int argc,@@ -234,6 +482,7 @@ btdump_f( {bool aflag = false;bool iflag = false; +bool crc =xfs_sb_version_hascrc (&mp->m_sb);int c;if (cur_typ ==NULL ) {@@ -276,6 +525,10 @@ btdump_f(return dump_btree_long (iflag);case TYP_INODE :return dump_inode (iflag, aflag); +case TYP_ATTR : +return dump_dabtree (iflag, crc ? &attr3_print : &attr_print); +case TYP_DIR2 : +return dump_dabtree (iflag, crc ? &dir3_print : &dir_print);default :dbprintf (_ ("type \"%s\" is not a btree type or inode\n" ), cur_typ->name);man/man8/xfs_db.8 +1
-1@@ -335,6 +335,7 @@ area of the inode, if neither option is given then both areas are shown. .B btdump [-a] [-i] If the cursor points to a btree node, dump the btree from that block downward. If instead the cursor points to an inode, dump the data fork block mapping btree if there is one. +If the cursor points to a directory or extended attribute btree node, dump that. By default, only records stored in the btree are dumped. .RS 1.0i .TP 0.4i --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Carlos
Re: [PATCH v2 4/7] xfs_db: dump dir/attr btrees
In reply to Darrick J. WongQuoted 3 lines · Darrick J. Wong
Dump the directory or extended attribute btree contents.
Signed-off-by Darrick J. Wong <[email protected]>
Btw, this is missing a changelog comparing with the V1, but I believe it doesn't go to the patch description anyway.
Signature · 1 line
Carlos
Re: [PATCH v2 4/7] xfs_db: dump dir/attr btrees
Quoted 7 lines · Carlos Maiolino
Quoted 3 lines · Darrick J. Wong
Dump the directory or extended attribute btree contents.
Signed-off-by Darrick J. Wong <[email protected]>Btw, this is missing a changelog comparing with the V1, but I believe it doesn't go to the patch description anyway.
---
v2: fix whitespace problems, rename ops struct to have _ops in name, amend help screen to say that we can dump dir/attr btrees now.
---
--D
Quoted 8 lines
Signature · 6 lines
-- Carlos -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/7 xfs_db: print attribute remote value blocks
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Teach xfs_db how to print the contents of xattr remote value blocks.
--- db/attr.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ db/attr.h | 1 + db/field.c | 3 +++ db/field.h | 1 + 4 files changed, 64 insertions(+)
db/attr.c +59 -0
@@ -41,6 +41,9 @@ static int attr_leaf_nvlist_offset(void *obj, int startoff, int idx);static int attr_node_btree_count (void *obj,int startoff);static int attr_node_hdr_count (void *obj,int startoff); +static int attr_remote_count (void *obj,int startoff); +static int attr3_remote_count (void *obj,int startoff); +const field_t attr_hfld[] = { {"" ,FLDT_ATTR ,OI (0 ),C1 ,0 ,TYP_NONE }, {NULL }
@@ -53,6 +56,7 @@ const field_t attr_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR_NODE_HDR ,OI (NOFF (hdr)), attr_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "data", FLDT_CHARNS, OI(0), attr_remote_count, FLD_COUNT, TYP_NONE }, { "entries", FLDT_ATTR_LEAF_ENTRY, OI(LOFF(entries)), attr_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(NOFF(__btree)), attr_node_btree_count,
@@ -197,6 +201,33 @@ attr3_leaf_hdr_count(return be16_to_cpu (leaf->hdr.info.hdr.magic) ==XFS_ATTR3_LEAF_MAGIC ; } +static int +attr_remote_count ( +void *obj, +int startoff) +{ +if (attr_leaf_hdr_count (obj, startoff) ==0 && +attr_node_hdr_count (obj, startoff) ==0 ) +return mp->m_sb.sb_blocksize; +return 0 ; +} + +static int +attr3_remote_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_rmt_hdr *hdr = obj; + +ASSERT (startoff ==0 ); + +if (hdr->rm_magic !=cpu_to_be32 (XFS_ATTR3_RMT_MAGIC )) +return 0 ; +if (be32_to_cpu (hdr->rm_bytes) +sizeof (*hdr) > mp->m_sb.sb_blocksize) +return mp->m_sb.sb_blocksize -sizeof (*hdr); +return be32_to_cpu (hdr->rm_bytes); +} +typedef int (*attr_leaf_entry_walk_f )(struct xfs_attr_leafblock *,struct xfs_attr_leaf_entry *,int ); static int
@@ -477,6 +508,17 @@ attr3_node_hdr_count(return be16_to_cpu (node->hdr.info.hdr.magic) ==XFS_DA3_NODE_MAGIC ; } +static int +attr3_remote_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_rmt_hdr *node = obj; + +ASSERT (startoff ==0 ); +return be32_to_cpu (node->rm_magic) ==XFS_ATTR3_RMT_MAGIC ; +} + int attr_size( void *obj,
@@ -501,6 +543,8 @@ const field_t attr3_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR3_NODE_HDR ,OI (N3OFF (hdr)), attr3_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "hdr", FLDT_ATTR3_REMOTE_HDR, OI(0), attr3_remote_hdr_count, + FLD_COUNT, TYP_NONE }, { "entries", FLDT_ATTR_LEAF_ENTRY, OI(L3OFF(entries)), attr3_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(N3OFF(__btree)),
@@ -543,6 +587,21 @@ const field_t attr3_node_hdr_flds[] = { { NULL } }; +#define RM3OFF (f) bitize(offsetof(struct xfs_attr3_rmt_hdr, rm_ ## f)) +const struct field attr3_remote_crc_flds[] = { + {"magic" ,FLDT_UINT32X ,OI (RM3OFF (magic)),C1 ,0 ,TYP_NONE }, + {"offset" ,FLDT_UINT32D ,OI (RM3OFF (offset)),C1 ,0 ,TYP_NONE }, + {"bytes" ,FLDT_UINT32D ,OI (RM3OFF (bytes)),C1 ,0 ,TYP_NONE }, + {"crc" ,FLDT_CRC ,OI (RM3OFF (crc)),C1 ,0 ,TYP_NONE }, + {"uuid" ,FLDT_UUID ,OI (RM3OFF (uuid)),C1 ,0 ,TYP_NONE }, + {"owner" ,FLDT_INO ,OI (RM3OFF (owner)),C1 ,0 ,TYP_NONE }, + {"bno" ,FLDT_DFSBNO ,OI (RM3OFF (blkno)),C1 ,0 ,TYP_BMAPBTD }, + {"lsn" ,FLDT_UINT64X ,OI (RM3OFF (lsn)),C1 ,0 ,TYP_NONE }, + {"data" ,FLDT_CHARNS ,OI (bitize (sizeof (struct xfs_attr3_rmt_hdr ))), + attr3_remote_count,FLD_COUNT ,TYP_NONE }, + {NULL } +}; +/* * Special read verifier for attribute buffers. Detect the magic number * appropriately and set the correct verifier and call it.
db/attr.h +1 -0
@@ -32,6 +32,7 @@ extern const field_t attr3_leaf_hdr_flds[];extern const field_t attr3_node_hdr_flds[];extern const field_t attr3_blkinfo_flds[];extern const field_t attr3_node_hdr_flds[]; +extern const field_t attr3_remote_crc_flds[];extern int attr_leaf_name_size (void *obj,int startoff,int idx);extern int attr_size (void *obj,int startoff,int idx);
db/field.c +3 -0
@@ -99,6 +99,9 @@ const ftattr_t ftattrtab[] = { {FLDT_ATTR3_NODE_HDR ,"attr3_node_hdr" ,NULL , (char *)attr3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)), 0, NULL, attr3_node_hdr_flds }, + { FLDT_ATTR3_REMOTE_HDR, "attr3_remote_hdr", NULL, + (char *)attr3_remote_crc_flds, attr_size,FTARG_SIZE ,NULL , + attr3_remote_crc_flds }, { FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size, FTARG_SIZE, NULL, bmapbta_flds },
db/field.h +1 -0
@@ -47,6 +47,7 @@ typedef enum fldt {FLDT_ATTR3_BLKINFO ,FLDT_ATTR3_LEAF_HDR ,FLDT_ATTR3_NODE_HDR , +FLDT_ATTR3_REMOTE_HDR ,FLDT_BMAPBTA , FLDT_BMAPBTA_CRC,
Re: [PATCH 5/7] xfs_db: print attribute remote value blocks
Quoted 3 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Teach
xfs_dbhow to print the contents of xattr remote value blocks.
The xfs_db manpage explains what the various attr fields are (hdr, entries, and nvlist) - should the new fields be added to the manpage?
Quoted 24 lines
Signed-off-by Darrick J. Wong <[email protected]>--- db/attr.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ db/attr.h | 1 + db/field.c | 3 +++ db/field.h | 1 + 4 files changed, 64 insertions(+)db/attr.c +3
-0@@ -41,6 +41,9 @@ static int attr_leaf_nvlist_offset(void *obj, int startoff, int idx);static int attr_node_btree_count (void *obj,int startoff);static int attr_node_hdr_count (void *obj,int startoff); +static int attr_remote_count (void *obj,int startoff); +static int attr3_remote_count (void *obj,int startoff); +const field_t attr_hfld[] = { {"" ,FLDT_ATTR ,OI (0 ),C1 ,0 ,TYP_NONE }, {NULL }
db/attr.c const field_t attr_flds[] = { · line 59
Quoted 4 lines
db/attr.c +1
-0@@ -53,6 +56,7 @@ const field_t attr_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR_NODE_HDR ,OI (NOFF (hdr)), attr_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "data", FLDT_CHARNS, OI(0), attr_remote_count, FLD_COUNT, TYP_NONE },
I never know how we choose names in xfs_db. Should this be "value?" Or do you prefer "data" because it may not be the start of, or the full, value?
Quoted 21 lines
db/attr.c +14
-0{"entries" ,FLDT_ATTR_LEAF_ENTRY ,OI (LOFF (entries)), attr_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(NOFF(__btree)), attr_node_btree_count,@@ -197,6 +201,33 @@ attr3_leaf_hdr_count(return be16_to_cpu (leaf->hdr.info.hdr.magic) ==XFS_ATTR3_LEAF_MAGIC ; } +static int +attr_remote_count ( +void *obj, +int startoff) +{ +if (attr_leaf_hdr_count (obj, startoff) ==0 && +attr_node_hdr_count (obj, startoff) ==0 ) +return mp->m_sb.sb_blocksize; +return 0 ; +} + +static int +attr3_remote_count( + void *obj,
db/attr.c attr3_leaf_hdr_count( · line 227
Quoted 10 lines
db/attr.c +10
-0+ int startoff) +{ +struct xfs_attr3_rmt_hdr *hdr = obj; + +ASSERT (startoff ==0 ); + +if (hdr->rm_magic !=cpu_to_be32 (XFS_ATTR3_RMT_MAGIC )) +return 0 ; +if (be32_to_cpu (hdr->rm_bytes) +sizeof (*hdr) > mp->m_sb.sb_blocksize) +return mp->m_sb.sb_blocksize -sizeof (*hdr);
XFS_ATTR3_RMT_BUF_SPACE() ? (h/t bfoster!)
maybe even:
if (be32_to_cpu(hdr->rm_bytes) > XFS_ATTR3_RMT_BUF_SPACE
return XFS_ATTR3_RMT_BUF_SPACE
Quoted 25 lines
db/attr.c +14
-0+return be32_to_cpu (hdr->rm_bytes); +} +typedef int (*attr_leaf_entry_walk_f )(struct xfs_attr_leafblock *,struct xfs_attr_leaf_entry *,int ); static int@@ -477,6 +508,17 @@ attr3_node_hdr_count(return be16_to_cpu (node->hdr.info.hdr.magic) ==XFS_DA3_NODE_MAGIC ; } +static int +attr3_remote_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_rmt_hdr *node = obj; + +ASSERT (startoff ==0 ); +return be32_to_cpu (node->rm_magic) ==XFS_ATTR3_RMT_MAGIC ; +} + int attr_size( void *obj,
db/attr.c const field_t attr3_flds[] = { · line 547
Quoted 5 lines
db/attr.c +2
-0@@ -501,6 +543,8 @@ const field_t attr3_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR3_NODE_HDR ,OI (N3OFF (hdr)), attr3_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "hdr", FLDT_ATTR3_REMOTE_HDR, OI(0), attr3_remote_hdr_count, + FLD_COUNT, TYP_NONE },
I'm probably just confused - I get it that attr_flds has no remote header type (there is none w/o crcs) but why is there no "data" field added here as well?
Quoted 10 lines
db/attr.c +3
-0{"entries" ,FLDT_ATTR_LEAF_ENTRY ,OI (L3OFF (entries)), attr3_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(N3OFF(__btree)),@@ -543,6 +587,21 @@ const field_t attr3_node_hdr_flds[] = { { NULL } }; +#define RM3OFF (f) bitize(offsetof(struct xfs_attr3_rmt_hdr, rm_ ## f)) +const struct field attr3_remote_crc_flds[] = { + {"magic" ,FLDT_UINT32X ,OI (RM3OFF (magic)),C1 ,0 ,TYP_NONE },
db/attr.c const field_t attr3_node_hdr_flds[] = { · line 602
Quoted 10 lines
db/attr.c +10
-0+ { "offset", FLDT_UINT32D, OI(RM3OFF(offset)), C1, 0, TYP_NONE }, + { "bytes", FLDT_UINT32D, OI(RM3OFF(bytes)), C1, 0, TYP_NONE }, + { "crc", FLDT_CRC, OI(RM3OFF(crc)), C1, 0, TYP_NONE }, + { "uuid", FLDT_UUID, OI(RM3OFF(uuid)), C1, 0, TYP_NONE }, + { "owner", FLDT_INO, OI(RM3OFF(owner)), C1, 0, TYP_NONE }, + { "bno", FLDT_DFSBNO, OI(RM3OFF(blkno)), C1, 0, TYP_BMAPBTD }, + { "lsn", FLDT_UINT64X, OI(RM3OFF(lsn)), C1, 0, TYP_NONE }, + { "data", FLDT_CHARNS, OI(bitize(sizeof(struct xfs_attr3_rmt_hdr))), + attr3_remote_count, FLD_COUNT, TYP_NONE }, + { NULL }
I'm having trouble grokking how the /data/ lands under what seems to be described as the header.
"attr3_remote_hdr" -> attr3_remote_crc_flds -> header /+ data/
I guess I need to just test drive the patch a bit and see if it makes more sense.
Thanks,
-eric
Quoted 49 lines
db/attr.c +2
-0+}; +/* * Special read verifier for attribute buffers. Detect the magic number * appropriately and set the correct verifier and call it. db/attr.h +1
-0@@ -32,6 +32,7 @@ extern const field_t attr3_leaf_hdr_flds[];extern const field_t attr3_node_hdr_flds[];extern const field_t attr3_blkinfo_flds[];extern const field_t attr3_node_hdr_flds[]; +extern const field_t attr3_remote_crc_flds[];extern int attr_leaf_name_size (void *obj,int startoff,int idx);extern int attr_size (void *obj,int startoff,int idx);db/field.c +3
-0@@ -99,6 +99,9 @@ const ftattr_t ftattrtab[] = { {FLDT_ATTR3_NODE_HDR ,"attr3_node_hdr" ,NULL , (char *)attr3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)), 0, NULL, attr3_node_hdr_flds }, + { FLDT_ATTR3_REMOTE_HDR, "attr3_remote_hdr", NULL, + (char *)attr3_remote_crc_flds, attr_size,FTARG_SIZE ,NULL , + attr3_remote_crc_flds }, { FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size, FTARG_SIZE, NULL, bmapbta_flds },db/field.h +1
-1@@ -47,6 +47,7 @@ typedef enum fldt {FLDT_ATTR3_BLKINFO ,FLDT_ATTR3_LEAF_HDR ,FLDT_ATTR3_NODE_HDR , +FLDT_ATTR3_REMOTE_HDR ,FLDT_BMAPBTA , FLDT_BMAPBTA_CRC, --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/7] xfs_db: print attribute remote value blocks
Quoted 8 lines · Eric Sandeen
Quoted 3 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Teach
xfs_dbhow to print the contents of xattr remote value blocks.The
xfs_dbmanpage explains what the various attr fields are (hdr, entries, and nvlist) - should the new fields be added to the manpage?
Yeah.
Quoted 17 lines
Quoted 17 lines
Signed-off-by Darrick J. Wong <[email protected]>--- db/attr.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ db/attr.h | 1 + db/field.c | 3 +++ db/field.h | 1 + 4 files changed, 64 insertions(+)db/attr.c +0
-0@@ -41,6 +41,9 @@ static int attr_leaf_nvlist_offset(void *obj, int startoff, int idx);static int attr_node_btree_count (void *obj,int startoff);static int attr_node_hdr_count (void *obj,int startoff);
Quoted 14 lines
db/attr.c const field_t attr_flds[] = { · line 59
Quoted 11 lines
db/attr.c +4
-0+static int attr_remote_count (void *obj,int startoff); +static int attr3_remote_count (void *obj,int startoff); +const field_t attr_hfld[] = { {"" ,FLDT_ATTR ,OI (0 ),C1 ,0 ,TYP_NONE }, {NULL }@@ -53,6 +56,7 @@ const field_t attr_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR_NODE_HDR ,OI (NOFF (hdr)), attr_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "data", FLDT_CHARNS, OI(0), attr_remote_count, FLD_COUNT, TYP_NONE },I never know how we choose names in
xfs_db. Should this be "value?" Or do you prefer "data" because it may not be the start of, or the full, value?
Correct -- the full attr value is the concatenation of the data fields in each block.
I would add that the disk format reference also refers to the space after the header as the 'data' area, but that's a little disingenuous because I wrote that part of the documentation. :P
Quoted 34 lines
Quoted 21 lines
db/attr.c +14
-0{"entries" ,FLDT_ATTR_LEAF_ENTRY ,OI (LOFF (entries)), attr_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(NOFF(__btree)), attr_node_btree_count,@@ -197,6 +201,33 @@ attr3_leaf_hdr_count(return be16_to_cpu (leaf->hdr.info.hdr.magic) ==XFS_ATTR3_LEAF_MAGIC ; } +static int +attr_remote_count ( +void *obj, +int startoff) +{ +if (attr_leaf_hdr_count (obj, startoff) ==0 && +attr_node_hdr_count (obj, startoff) ==0 ) +return mp->m_sb.sb_blocksize; +return 0 ; +} + +static int +attr3_remote_count( + void *obj,db/attr.c attr3_leaf_hdr_count( · line 227
Quoted 10 lines
db/attr.c +10
-0+ int startoff) +{ +struct xfs_attr3_rmt_hdr *hdr = obj; + +ASSERT (startoff ==0 ); + +if (hdr->rm_magic !=cpu_to_be32 (XFS_ATTR3_RMT_MAGIC )) +return 0 ; +if (be32_to_cpu (hdr->rm_bytes) +sizeof (*hdr) > mp->m_sb.sb_blocksize) +return mp->m_sb.sb_blocksize -sizeof (*hdr);
XFS_ATTR3_RMT_BUF_SPACE()? (h/t bfoster!)
Quoted 7 lines
maybe even:
if (
be32_to_cpu(hdr->rm_bytes)>XFS_ATTR3_RMT_BUF_SPACE
returnXFS_ATTR3_RMT_BUF_SPACEdb/attr.c attr3_leaf_hdr_count( · line 228
Quoted 1 line
db/attr.c +1
-0+return be32_to_cpu (hdr->rm_bytes);
Yes.
Quoted 58 lines
Quoted 24 lines
db/attr.c +13
-0+} +typedef int (*attr_leaf_entry_walk_f )(struct xfs_attr_leafblock *,struct xfs_attr_leaf_entry *,int ); static int@@ -477,6 +508,17 @@ attr3_node_hdr_count(return be16_to_cpu (node->hdr.info.hdr.magic) ==XFS_DA3_NODE_MAGIC ; } +static int +attr3_remote_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_rmt_hdr *node = obj; + +ASSERT (startoff ==0 ); +return be32_to_cpu (node->rm_magic) ==XFS_ATTR3_RMT_MAGIC ; +} + int attr_size( void *obj,db/attr.c const field_t attr3_flds[] = { · line 547
Quoted 5 lines
db/attr.c +2
-0@@ -501,6 +543,8 @@ const field_t attr3_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR3_NODE_HDR ,OI (N3OFF (hdr)), attr3_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "hdr", FLDT_ATTR3_REMOTE_HDR, OI(0), attr3_remote_hdr_count, + FLD_COUNT, TYP_NONE },I'm probably just confused - I get it that
attr_fldshas no remote header type (there is none w/o crcs) but why is there no "data" field added here as well?Quoted 10 lines
db/attr.c +3
-0{"entries" ,FLDT_ATTR_LEAF_ENTRY ,OI (L3OFF (entries)), attr3_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(N3OFF(__btree)),@@ -543,6 +587,21 @@ const field_t attr3_node_hdr_flds[] = { { NULL } }; +#define RM3OFF (f) bitize(offsetof(struct xfs_attr3_rmt_hdr, rm_ ## f)) +const struct field attr3_remote_crc_flds[] = { + {"magic" ,FLDT_UINT32X ,OI (RM3OFF (magic)),C1 ,0 ,TYP_NONE },db/attr.c const field_t attr3_node_hdr_flds[] = { · line 602
Quoted 10 lines
db/attr.c +10
-0+ { "offset", FLDT_UINT32D, OI(RM3OFF(offset)), C1, 0, TYP_NONE }, + { "bytes", FLDT_UINT32D, OI(RM3OFF(bytes)), C1, 0, TYP_NONE }, + { "crc", FLDT_CRC, OI(RM3OFF(crc)), C1, 0, TYP_NONE }, + { "uuid", FLDT_UUID, OI(RM3OFF(uuid)), C1, 0, TYP_NONE }, + { "owner", FLDT_INO, OI(RM3OFF(owner)), C1, 0, TYP_NONE }, + { "bno", FLDT_DFSBNO, OI(RM3OFF(blkno)), C1, 0, TYP_BMAPBTD }, + { "lsn", FLDT_UINT64X, OI(RM3OFF(lsn)), C1, 0, TYP_NONE }, + { "data", FLDT_CHARNS, OI(bitize(sizeof(struct xfs_attr3_rmt_hdr))), + attr3_remote_count, FLD_COUNT, TYP_NONE }, + { NULL }I'm having trouble grokking how the /data/ lands under what seems to be described as the header.
Quoted 1 line
"
attr3_remote_hdr" ->attr3_remote_crc_flds-> header /+ data/
Yes, you're right, the "data" item should be in attr3_flds, not attr3_remote_crc_flds.
--D
Quoted 59 lines
I guess I need to just test drive the patch a bit and see if it makes more sense.
Thanks,
-ericQuoted 45 lines
db/attr.c +2
-0+}; +/* * Special read verifier for attribute buffers. Detect the magic number * appropriately and set the correct verifier and call it. db/attr.h +1
-0@@ -32,6 +32,7 @@ extern const field_t attr3_leaf_hdr_flds[];extern const field_t attr3_node_hdr_flds[];extern const field_t attr3_blkinfo_flds[];extern const field_t attr3_node_hdr_flds[]; +extern const field_t attr3_remote_crc_flds[];extern int attr_leaf_name_size (void *obj,int startoff,int idx);extern int attr_size (void *obj,int startoff,int idx);db/field.c +3
-0@@ -99,6 +99,9 @@ const ftattr_t ftattrtab[] = { {FLDT_ATTR3_NODE_HDR ,"attr3_node_hdr" ,NULL , (char *)attr3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)), 0, NULL, attr3_node_hdr_flds }, + { FLDT_ATTR3_REMOTE_HDR, "attr3_remote_hdr", NULL, + (char *)attr3_remote_crc_flds, attr_size,FTARG_SIZE ,NULL , + attr3_remote_crc_flds }, { FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size, FTARG_SIZE, NULL, bmapbta_flds },db/field.h +1
-1@@ -47,6 +47,7 @@ typedef enum fldt {FLDT_ATTR3_BLKINFO ,FLDT_ATTR3_LEAF_HDR ,FLDT_ATTR3_NODE_HDR , +FLDT_ATTR3_REMOTE_HDR ,FLDT_BMAPBTA , FLDT_BMAPBTA_CRC, --Quoted 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 5/7 xfs_db: print attribute remote value blocks
In reply to Darrick J. WongTeach xfs_db how to print the contents of xattr remote value blocks.
---
v2: update manpage, fix some field placement and function naming problems
--- db/attr.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ db/attr.h | 1 + db/field.c | 3 +++ db/field.h | 1 + man/man8/xfs_db.8 | 38 ++++++++++++++++++++++++++++++-- 5 files changed, 104 insertions(+), 2 deletions(-)
db/attr.c +63 -0
@@ -41,6 +41,10 @@ static int attr_leaf_nvlist_offset(void *obj, int startoff, int idx);static int attr_node_btree_count (void *obj,int startoff);static int attr_node_hdr_count (void *obj,int startoff); +static int attr_remote_data_count (void *obj,int startoff); +static int attr3_remote_hdr_count (void *obj,int startoff); +static int attr3_remote_data_count (void *obj,int startoff); +const field_t attr_hfld[] = { {"" ,FLDT_ATTR ,OI (0 ),C1 ,0 ,TYP_NONE }, {NULL }
@@ -53,6 +57,8 @@ const field_t attr_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR_NODE_HDR ,OI (NOFF (hdr)), attr_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "data", FLDT_CHARNS, OI(0), attr_remote_data_count, FLD_COUNT, + TYP_NONE }, { "entries", FLDT_ATTR_LEAF_ENTRY, OI(LOFF(entries)), attr_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(NOFF(__btree)), attr_node_btree_count,
@@ -197,6 +203,35 @@ attr3_leaf_hdr_count(return be16_to_cpu (leaf->hdr.info.hdr.magic) ==XFS_ATTR3_LEAF_MAGIC ; } +static int +attr_remote_data_count ( +void *obj, +int startoff) +{ +if (attr_leaf_hdr_count (obj, startoff) ==0 && +attr_node_hdr_count (obj, startoff) ==0 ) +return mp->m_sb.sb_blocksize; +return 0 ; +} + +static int +attr3_remote_data_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_rmt_hdr *hdr = obj; +size_t buf_space; + +ASSERT (startoff ==0 ); + +if (hdr->rm_magic !=cpu_to_be32 (XFS_ATTR3_RMT_MAGIC )) +return 0 ; + buf_space =XFS_ATTR3_RMT_BUF_SPACE (mp, mp->m_sb.sb_blocksize); +if (be32_to_cpu (hdr->rm_bytes) > buf_space) +return buf_space; +return be32_to_cpu (hdr->rm_bytes); +} +typedef int (*attr_leaf_entry_walk_f )(struct xfs_attr_leafblock *,struct xfs_attr_leaf_entry *,int ); static int
@@ -477,6 +512,17 @@ attr3_node_hdr_count(return be16_to_cpu (node->hdr.info.hdr.magic) ==XFS_DA3_NODE_MAGIC ; } +static int +attr3_remote_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_rmt_hdr *node = obj; + +ASSERT (startoff ==0 ); +return be32_to_cpu (node->rm_magic) ==XFS_ATTR3_RMT_MAGIC ; +} + int attr_size( void *obj,
@@ -501,6 +547,10 @@ const field_t attr3_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR3_NODE_HDR ,OI (N3OFF (hdr)), attr3_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "hdr", FLDT_ATTR3_REMOTE_HDR, OI(0), attr3_remote_hdr_count, + FLD_COUNT, TYP_NONE }, + { "data", FLDT_CHARNS, OI(bitize(sizeof(struct xfs_attr3_rmt_hdr))), + attr3_remote_data_count, FLD_COUNT, TYP_NONE }, { "entries", FLDT_ATTR_LEAF_ENTRY, OI(L3OFF(entries)), attr3_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(N3OFF(__btree)),
@@ -543,6 +593,19 @@ const field_t attr3_node_hdr_flds[] = { { NULL } }; +#define RM3OFF (f) bitize(offsetof(struct xfs_attr3_rmt_hdr, rm_ ## f)) +const struct field attr3_remote_crc_flds[] = { + {"magic" ,FLDT_UINT32X ,OI (RM3OFF (magic)),C1 ,0 ,TYP_NONE }, + {"offset" ,FLDT_UINT32D ,OI (RM3OFF (offset)),C1 ,0 ,TYP_NONE }, + {"bytes" ,FLDT_UINT32D ,OI (RM3OFF (bytes)),C1 ,0 ,TYP_NONE }, + {"crc" ,FLDT_CRC ,OI (RM3OFF (crc)),C1 ,0 ,TYP_NONE }, + {"uuid" ,FLDT_UUID ,OI (RM3OFF (uuid)),C1 ,0 ,TYP_NONE }, + {"owner" ,FLDT_INO ,OI (RM3OFF (owner)),C1 ,0 ,TYP_NONE }, + {"bno" ,FLDT_DFSBNO ,OI (RM3OFF (blkno)),C1 ,0 ,TYP_BMAPBTD }, + {"lsn" ,FLDT_UINT64X ,OI (RM3OFF (lsn)),C1 ,0 ,TYP_NONE }, + {NULL } +}; +/* * Special read verifier for attribute buffers. Detect the magic number * appropriately and set the correct verifier and call it.
db/attr.h +1 -0
@@ -32,6 +32,7 @@ extern const field_t attr3_leaf_hdr_flds[];extern const field_t attr3_node_hdr_flds[];extern const field_t attr3_blkinfo_flds[];extern const field_t attr3_node_hdr_flds[]; +extern const field_t attr3_remote_crc_flds[];extern int attr_leaf_name_size (void *obj,int startoff,int idx);extern int attr_size (void *obj,int startoff,int idx);
db/field.c +3 -0
@@ -99,6 +99,9 @@ const ftattr_t ftattrtab[] = { {FLDT_ATTR3_NODE_HDR ,"attr3_node_hdr" ,NULL , (char *)attr3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)), 0, NULL, attr3_node_hdr_flds }, + { FLDT_ATTR3_REMOTE_HDR, "attr3_remote_hdr", NULL, + (char *)attr3_remote_crc_flds, attr_size,FTARG_SIZE ,NULL , + attr3_remote_crc_flds }, { FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size, FTARG_SIZE, NULL, bmapbta_flds },
db/field.h +1 -0
@@ -47,6 +47,7 @@ typedef enum fldt {FLDT_ATTR3_BLKINFO ,FLDT_ATTR3_LEAF_HDR ,FLDT_ATTR3_NODE_HDR , +FLDT_ATTR3_REMOTE_HDR ,FLDT_BMAPBTA , FLDT_BMAPBTA_CRC,
man/man8/xfs_db.8 +36 -2
@@ -940,8 +940,7 @@ version 1 and version 2 directories, see type .B dir for a description. Leaf blocks can refer to "local" or "remote" attribute values. Local values are stored directly in the leaf block. -Remote values are stored in an independent block in the attribute fork -(with no structure). Leaf blocks contain the following fields: +Leaf blocks contain the following fields: .RS 1.4i .PD 0 .TP 1.2i
@@ -989,6 +988,41 @@ Fields present for local values: (fork block number of containing the value). .PD .RE +.IP +Remote values are stored in an independent block in the attribute fork. +Prior to v5, value blocks had no structure, but in v5 they acquired a header +structure with the following fields: +.RS 1.4i +.PD 0 +.TP 1.2i +.B magic +attr3 remote block magic number, 0x5841524d ('XARM'). +.TP +.B offset +Byte offset of this data block within the overall attribute value. +.TP +.B bytes +Number of bytes stored in this block. +.TP +.B crc +Checksum of the attribute block contents. +.TP +.B uuid +Filesystem UUID. +.TP +.B owner +Inode that owns this attribute value. +.TP +.B bno +Block offset of this block within the inode's attribute fork. +.TP +.B lsn +Log serial number of the last time this block was logged. +.TP +.B data +The attribute value data. +.PD +.RE .TP .B bmapbt Files with many extents in their data or attribute fork will have the
Re: [PATCH v2 5/7] xfs_db: print attribute remote value blocks
Quoted 6 lines · Darrick J. Wong
Teach
xfs_dbhow to print the contents of xattr remote value blocks.Signed-off-by Darrick J. Wong <[email protected]>---
v2: update manpage, fix some field placement and function naming problems
---
Quoted 214 lines
db/attr.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ db/attr.h | 1 + db/field.c | 3 +++ db/field.h | 1 + man/man8/xfs_db.8 | 38 ++++++++++++++++++++++++++++++-- 5 files changed, 104 insertions(+), 2 deletions(-)db/attr.c +63
-0@@ -41,6 +41,10 @@ static int attr_leaf_nvlist_offset(void *obj, int startoff, int idx);static int attr_node_btree_count (void *obj,int startoff);static int attr_node_hdr_count (void *obj,int startoff); +static int attr_remote_data_count (void *obj,int startoff); +static int attr3_remote_hdr_count (void *obj,int startoff); +static int attr3_remote_data_count (void *obj,int startoff); +const field_t attr_hfld[] = { {"" ,FLDT_ATTR ,OI (0 ),C1 ,0 ,TYP_NONE }, {NULL }@@ -53,6 +57,8 @@ const field_t attr_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR_NODE_HDR ,OI (NOFF (hdr)), attr_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "data", FLDT_CHARNS, OI(0), attr_remote_data_count, FLD_COUNT, + TYP_NONE }, { "entries", FLDT_ATTR_LEAF_ENTRY, OI(LOFF(entries)), attr_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(NOFF(__btree)), attr_node_btree_count,@@ -197,6 +203,35 @@ attr3_leaf_hdr_count(return be16_to_cpu (leaf->hdr.info.hdr.magic) ==XFS_ATTR3_LEAF_MAGIC ; } +static int +attr_remote_data_count ( +void *obj, +int startoff) +{ +if (attr_leaf_hdr_count (obj, startoff) ==0 && +attr_node_hdr_count (obj, startoff) ==0 ) +return mp->m_sb.sb_blocksize; +return 0 ; +} + +static int +attr3_remote_data_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_rmt_hdr *hdr = obj; +size_t buf_space; + +ASSERT (startoff ==0 ); + +if (hdr->rm_magic !=cpu_to_be32 (XFS_ATTR3_RMT_MAGIC )) +return 0 ; + buf_space =XFS_ATTR3_RMT_BUF_SPACE (mp, mp->m_sb.sb_blocksize); +if (be32_to_cpu (hdr->rm_bytes) > buf_space) +return buf_space; +return be32_to_cpu (hdr->rm_bytes); +} +typedef int (*attr_leaf_entry_walk_f )(struct xfs_attr_leafblock *,struct xfs_attr_leaf_entry *,int ); static int@@ -477,6 +512,17 @@ attr3_node_hdr_count(return be16_to_cpu (node->hdr.info.hdr.magic) ==XFS_DA3_NODE_MAGIC ; } +static int +attr3_remote_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_rmt_hdr *node = obj; + +ASSERT (startoff ==0 ); +return be32_to_cpu (node->rm_magic) ==XFS_ATTR3_RMT_MAGIC ; +} + int attr_size( void *obj,@@ -501,6 +547,10 @@ const field_t attr3_flds[] = { FLD_COUNT, TYP_NONE }, {"hdr" ,FLDT_ATTR3_NODE_HDR ,OI (N3OFF (hdr)), attr3_node_hdr_count, FLD_COUNT, TYP_NONE }, + { "hdr", FLDT_ATTR3_REMOTE_HDR, OI(0), attr3_remote_hdr_count, + FLD_COUNT, TYP_NONE }, + { "data", FLDT_CHARNS, OI(bitize(sizeof(struct xfs_attr3_rmt_hdr))), + attr3_remote_data_count, FLD_COUNT, TYP_NONE }, { "entries", FLDT_ATTR_LEAF_ENTRY, OI(L3OFF(entries)), attr3_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "btree", FLDT_ATTR_NODE_ENTRY, OI(N3OFF(__btree)),@@ -543,6 +593,19 @@ const field_t attr3_node_hdr_flds[] = { { NULL } }; +#define RM3OFF (f) bitize(offsetof(struct xfs_attr3_rmt_hdr, rm_ ## f)) +const struct field attr3_remote_crc_flds[] = { + {"magic" ,FLDT_UINT32X ,OI (RM3OFF (magic)),C1 ,0 ,TYP_NONE }, + {"offset" ,FLDT_UINT32D ,OI (RM3OFF (offset)),C1 ,0 ,TYP_NONE }, + {"bytes" ,FLDT_UINT32D ,OI (RM3OFF (bytes)),C1 ,0 ,TYP_NONE }, + {"crc" ,FLDT_CRC ,OI (RM3OFF (crc)),C1 ,0 ,TYP_NONE }, + {"uuid" ,FLDT_UUID ,OI (RM3OFF (uuid)),C1 ,0 ,TYP_NONE }, + {"owner" ,FLDT_INO ,OI (RM3OFF (owner)),C1 ,0 ,TYP_NONE }, + {"bno" ,FLDT_DFSBNO ,OI (RM3OFF (blkno)),C1 ,0 ,TYP_BMAPBTD }, + {"lsn" ,FLDT_UINT64X ,OI (RM3OFF (lsn)),C1 ,0 ,TYP_NONE }, + {NULL } +}; +/* * Special read verifier for attribute buffers. Detect the magic number * appropriately and set the correct verifier and call it. db/attr.h +1
-0@@ -32,6 +32,7 @@ extern const field_t attr3_leaf_hdr_flds[];extern const field_t attr3_node_hdr_flds[];extern const field_t attr3_blkinfo_flds[];extern const field_t attr3_node_hdr_flds[]; +extern const field_t attr3_remote_crc_flds[];extern int attr_leaf_name_size (void *obj,int startoff,int idx);extern int attr_size (void *obj,int startoff,int idx);db/field.c +3
-0@@ -99,6 +99,9 @@ const ftattr_t ftattrtab[] = { {FLDT_ATTR3_NODE_HDR ,"attr3_node_hdr" ,NULL , (char *)attr3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)), 0, NULL, attr3_node_hdr_flds }, + { FLDT_ATTR3_REMOTE_HDR, "attr3_remote_hdr", NULL, + (char *)attr3_remote_crc_flds, attr_size,FTARG_SIZE ,NULL , + attr3_remote_crc_flds }, { FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size, FTARG_SIZE, NULL, bmapbta_flds },db/field.h +1
-0@@ -47,6 +47,7 @@ typedef enum fldt {FLDT_ATTR3_BLKINFO ,FLDT_ATTR3_LEAF_HDR ,FLDT_ATTR3_NODE_HDR , +FLDT_ATTR3_REMOTE_HDR ,FLDT_BMAPBTA , FLDT_BMAPBTA_CRC,man/man8/xfs_db.8 +36
-3@@ -940,8 +940,7 @@ version 1 and version 2 directories, see type .B dir for a description. Leaf blocks can refer to "local" or "remote" attribute values. Local values are stored directly in the leaf block. -Remote values are stored in an independent block in the attribute fork -(with no structure). Leaf blocks contain the following fields: +Leaf blocks contain the following fields: .RS 1.4i .PD 0 .TP 1.2i@@ -989,6 +988,41 @@ Fields present for local values: (fork block number of containing the value). .PD .RE +.IP +Remote values are stored in an independent block in the attribute fork. +Prior to v5, value blocks had no structure, but in v5 they acquired a header +structure with the following fields: +.RS 1.4i +.PD 0 +.TP 1.2i +.B magic +attr3 remote block magic number, 0x5841524d ('XARM'). +.TP +.B offset +Byte offset of this data block within the overall attribute value. +.TP +.B bytes +Number of bytes stored in this block. +.TP +.B crc +Checksum of the attribute block contents. +.TP +.B uuid +Filesystem UUID. +.TP +.B owner +Inode that owns this attribute value. +.TP +.B bno +Block offset of this block within the inode's attribute fork. +.TP +.B lsn +Log serial number of the last time this block was logged. +.TP +.B data +The attribute value data. +.PD +.RE .TP .B bmapbt Files with many extents in their data or attribute fork will have the --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Carlos
PATCH 6/7 xfs_db: write values into dir/attr blocks and recalculate CRCs
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Extend typ_t to (optionally) store a pointer to a function to calculate the CRC of the block, provide functions to do this for the dir3 and attr3 types, and then wire up the write command so that we can modify directory and extended attribute block fields.
--- db/attr.c | 32 ++++++++++++++++++++++++++++++++ db/attr.h | 1 + db/dir2.c | 37 +++++++++++++++++++++++++++++++++++++ db/dir2.h | 1 + db/type.c | 8 ++++---- db/type.h | 2 ++ db/write.c | 3 +++ 7 files changed, 80 insertions(+), 4 deletions(-)
db/attr.c +32 -0
@@ -602,6 +602,38 @@ const struct field attr3_remote_crc_flds[] = { { NULL } }; +/* Set the CRC. */ +void +xfs_attr3_set_crc ( +struct xfs_buf *bp) +{ +__be32 magic32; +__be16 magic16; + + magic32 = *(__be32 *)bp->b_addr; + magic16 = ((struct xfs_da_blkinfo *)bp->b_addr)->magic; + +switch (magic16) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ): +xfs_buf_update_cksum (bp,XFS_ATTR3_LEAF_CRC_OFF ); +return ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DA3_NODE_CRC_OFF ); +return ; +default : +break ; + } + +switch (magic32) { +case cpu_to_be32 (XFS_ATTR3_RMT_MAGIC ): +xfs_buf_update_cksum (bp,XFS_ATTR3_RMT_CRC_OFF ); +return ; +default : +dbprintf (_ ("Unknown attribute buffer type!\n" )); +break ; + } +} +/* * Special read verifier for attribute buffers. Detect the magic number * appropriately and set the correct verifier and call it.
db/attr.h +1 -0
@@ -36,5 +36,6 @@ extern const field_t attr3_remote_crc_flds[];extern int attr_leaf_name_size (void *obj,int startoff,int idx);extern int attr_size (void *obj,int startoff,int idx); +extern void xfs_attr3_set_crc (struct xfs_buf *bp);extern const struct xfs_buf_ops xfs_attr3_db_buf_ops;
db/dir2.c +37 -0
@@ -981,6 +981,43 @@ const field_t da3_node_hdr_flds[] = { { NULL } }; +/* Set the CRC. */ +void +xfs_dir3_set_crc ( +struct xfs_buf *bp) +{ +__be32 magic32; +__be16 magic16; + + magic32 = *(__be32 *)bp->b_addr; + magic16 = ((struct xfs_da_blkinfo *)bp->b_addr)->magic; + +switch (magic32) { +case cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC ): +case cpu_to_be32 (XFS_DIR3_DATA_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DIR3_DATA_CRC_OFF ); +return ; +case cpu_to_be32 (XFS_DIR3_FREE_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DIR3_FREE_CRC_OFF ); +return ; +default : +break ; + } + +switch (magic16) { +case cpu_to_be16 (XFS_DIR3_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DIR3_LEAF_CRC_OFF ); +return ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DA3_NODE_CRC_OFF ); +return ; +default : +dbprintf (_ ("Unknown directory buffer type! %x %x\n" ), magic32, magic16); +break ; + } +} +/* * Special read verifier for directory buffers. Detect the magic number * appropriately and set the correct verifier and call it.
db/dir2.h +1 -0
@@ -60,5 +60,6 @@ static inline uint8_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep)extern int dir2_data_union_size (void *obj,int startoff,int idx);extern int dir2_size (void *obj,int startoff,int idx); +extern void xfs_dir3_set_crc (struct xfs_buf *bp);extern const struct xfs_buf_ops xfs_dir3_db_buf_ops;
db/type.c +4 -4
@@ -87,7 +87,7 @@ static const typ_t __typtab_crc[] = { {TYP_AGI ,"agi" , handle_struct, agi_hfld, &xfs_agi_buf_ops, XFS_AGI_CRC_OFF }, { TYP_ATTR, "attr3", handle_struct, attr3_hfld, - &xfs_attr3_db_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_attr3_db_buf_ops, TYP_F_CRC_FUNC, xfs_attr3_set_crc }, { TYP_BMAPBTA, "bmapbta", handle_struct, bmapbta_crc_hfld, &xfs_bmbt_buf_ops, XFS_BTREE_LBLOCK_CRC_OFF }, { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld,
@@ -102,7 +102,7 @@ static const typ_t __typtab_crc[] = { &xfs_refcountbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_DATA, "data", handle_block, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_DIR2, "dir3", handle_struct, dir3_hfld, - &xfs_dir3_db_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, { TYP_INOBT, "inobt", handle_struct, inobt_crc_hfld,
@@ -131,7 +131,7 @@ static const typ_t __typtab_spcrc[] = { {TYP_AGI ,"agi" , handle_struct, agi_hfld, &xfs_agi_buf_ops , XFS_AGI_CRC_OFF }, { TYP_ATTR, "attr3", handle_struct, attr3_hfld, - &xfs_attr3_db_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_attr3_db_buf_ops, TYP_F_CRC_FUNC, xfs_attr3_set_crc }, { TYP_BMAPBTA, "bmapbta", handle_struct, bmapbta_crc_hfld, &xfs_bmbt_buf_ops, XFS_BTREE_LBLOCK_CRC_OFF }, { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld,
@@ -146,7 +146,7 @@ static const typ_t __typtab_spcrc[] = { &xfs_refcountbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_DATA, "data", handle_block, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_DIR2, "dir3", handle_struct, dir3_hfld, - &xfs_dir3_db_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, { TYP_INOBT, "inobt", handle_struct, inobt_spcrc_hfld,
db/type.h +2 -0
@@ -45,6 +45,8 @@ typedef struct typconst struct xfs_buf_ops *bops;unsigned long crc_off;#define TYP_F_NO_CRC_OFF (-1UL) +#define TYP_F_CRC_FUNC (-2UL) +void (*set_crc)(struct xfs_buf *); } typ_t;extern const typ_t *typtab, *cur_typ;
db/write.c +3 -0
@@ -173,6 +173,9 @@ write_f( }else if (iocur_top->dquot_buf) { local_ops.verify_write = xfs_verify_recalc_dquot_crc;dbprintf (_ ("Allowing write of corrupted dquot with good CRC\n" )); + }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { + local_ops.verify_write = iocur_top->typ->set_crc; +dbprintf (_ ("Allowing write of corrupted data with good CRC\n" )); }else {/* invalid data */ local_ops.verify_write = xfs_verify_recalc_crc;dbprintf (_ ("Allowing write of corrupted data with good CRC\n" ));
Re: [PATCH 6/7] xfs_db: write values into dir/attr blocks and recalculate CRCs
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Extend
typ_tto (optionally) store a pointer to a function to calculate the CRC of the block, provide functions to do this for the dir3 and attr3 types, and then wire up the write command so that we can modify directory and extended attribute block fields.Signed-off-by Darrick J. Wong <[email protected]>
Quoted 196 lines
--- db/attr.c | 32 ++++++++++++++++++++++++++++++++ db/attr.h | 1 + db/dir2.c | 37 +++++++++++++++++++++++++++++++++++++ db/dir2.h | 1 + db/type.c | 8 ++++---- db/type.h | 2 ++ db/write.c | 3 +++ 7 files changed, 80 insertions(+), 4 deletions(-)db/attr.c +32
-0@@ -602,6 +602,38 @@ const struct field attr3_remote_crc_flds[] = { { NULL } }; +/* Set the CRC. */ +void +xfs_attr3_set_crc ( +struct xfs_buf *bp) +{ +__be32 magic32; +__be16 magic16; + + magic32 = *(__be32 *)bp->b_addr; + magic16 = ((struct xfs_da_blkinfo *)bp->b_addr)->magic; + +switch (magic16) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ): +xfs_buf_update_cksum (bp,XFS_ATTR3_LEAF_CRC_OFF ); +return ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DA3_NODE_CRC_OFF ); +return ; +default : +break ; + } + +switch (magic32) { +case cpu_to_be32 (XFS_ATTR3_RMT_MAGIC ): +xfs_buf_update_cksum (bp,XFS_ATTR3_RMT_CRC_OFF ); +return ; +default : +dbprintf (_ ("Unknown attribute buffer type!\n" )); +break ; + } +} +/* * Special read verifier for attribute buffers. Detect the magic number * appropriately and set the correct verifier and call it. db/attr.h +1
-0@@ -36,5 +36,6 @@ extern const field_t attr3_remote_crc_flds[];extern int attr_leaf_name_size (void *obj,int startoff,int idx);extern int attr_size (void *obj,int startoff,int idx); +extern void xfs_attr3_set_crc (struct xfs_buf *bp);extern const struct xfs_buf_ops xfs_attr3_db_buf_ops;db/dir2.c +37
-0@@ -981,6 +981,43 @@ const field_t da3_node_hdr_flds[] = { { NULL } }; +/* Set the CRC. */ +void +xfs_dir3_set_crc ( +struct xfs_buf *bp) +{ +__be32 magic32; +__be16 magic16; + + magic32 = *(__be32 *)bp->b_addr; + magic16 = ((struct xfs_da_blkinfo *)bp->b_addr)->magic; + +switch (magic32) { +case cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC ): +case cpu_to_be32 (XFS_DIR3_DATA_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DIR3_DATA_CRC_OFF ); +return ; +case cpu_to_be32 (XFS_DIR3_FREE_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DIR3_FREE_CRC_OFF ); +return ; +default : +break ; + } + +switch (magic16) { +case cpu_to_be16 (XFS_DIR3_LEAF1_MAGIC ): +case cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DIR3_LEAF_CRC_OFF ); +return ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DA3_NODE_CRC_OFF ); +return ; +default : +dbprintf (_ ("Unknown directory buffer type! %x %x\n" ), magic32, magic16); +break ; + } +} +/* * Special read verifier for directory buffers. Detect the magic number * appropriately and set the correct verifier and call it. db/dir2.h +1
-0@@ -60,5 +60,6 @@ static inline uint8_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep)extern int dir2_data_union_size (void *obj,int startoff,int idx);extern int dir2_size (void *obj,int startoff,int idx); +extern void xfs_dir3_set_crc (struct xfs_buf *bp);extern const struct xfs_buf_ops xfs_dir3_db_buf_ops;db/type.c +4
-4@@ -87,7 +87,7 @@ static const typ_t __typtab_crc[] = { {TYP_AGI ,"agi" , handle_struct, agi_hfld, &xfs_agi_buf_ops, XFS_AGI_CRC_OFF }, { TYP_ATTR, "attr3", handle_struct, attr3_hfld, - &xfs_attr3_db_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_attr3_db_buf_ops, TYP_F_CRC_FUNC, xfs_attr3_set_crc }, { TYP_BMAPBTA, "bmapbta", handle_struct, bmapbta_crc_hfld, &xfs_bmbt_buf_ops, XFS_BTREE_LBLOCK_CRC_OFF }, { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld,@@ -102,7 +102,7 @@ static const typ_t __typtab_crc[] = { &xfs_refcountbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_DATA, "data", handle_block, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_DIR2, "dir3", handle_struct, dir3_hfld, - &xfs_dir3_db_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, { TYP_INOBT, "inobt", handle_struct, inobt_crc_hfld,@@ -131,7 +131,7 @@ static const typ_t __typtab_spcrc[] = { {TYP_AGI ,"agi" , handle_struct, agi_hfld, &xfs_agi_buf_ops , XFS_AGI_CRC_OFF }, { TYP_ATTR, "attr3", handle_struct, attr3_hfld, - &xfs_attr3_db_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_attr3_db_buf_ops, TYP_F_CRC_FUNC, xfs_attr3_set_crc }, { TYP_BMAPBTA, "bmapbta", handle_struct, bmapbta_crc_hfld, &xfs_bmbt_buf_ops, XFS_BTREE_LBLOCK_CRC_OFF }, { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld,@@ -146,7 +146,7 @@ static const typ_t __typtab_spcrc[] = { &xfs_refcountbt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_DATA, "data", handle_block, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_DIR2, "dir3", handle_struct, dir3_hfld, - &xfs_dir3_db_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, { TYP_INOBT, "inobt", handle_struct, inobt_spcrc_hfld,db/type.h +2
-0@@ -45,6 +45,8 @@ typedef struct typconst struct xfs_buf_ops *bops;unsigned long crc_off;#define TYP_F_NO_CRC_OFF (-1UL) +#define TYP_F_CRC_FUNC (-2UL) +void (*set_crc)(struct xfs_buf *); } typ_t;extern const typ_t *typtab, *cur_typ;db/write.c +3
-1@@ -173,6 +173,9 @@ write_f( }else if (iocur_top->dquot_buf) { local_ops.verify_write = xfs_verify_recalc_dquot_crc;dbprintf (_ ("Allowing write of corrupted dquot with good CRC\n" )); + }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { + local_ops.verify_write = iocur_top->typ->set_crc; +dbprintf (_ ("Allowing write of corrupted data with good CRC\n" )); }else {/* invalid data */ local_ops.verify_write = xfs_verify_recalc_crc;dbprintf (_ ("Allowing write of corrupted data with good CRC\n" )); --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Carlos
Re: [PATCH 6/7] xfs_db: write values into dir/attr blocks and recalculate CRCs
In reply to Darrick J. WongQuoted 30 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Extend
typ_tto (optionally) store a pointer to a function to calculate the CRC of the block, provide functions to do this for the dir3 and attr3 types, and then wire up the write command so that we can modify directory and extended attribute block fields.Signed-off-by Darrick J. Wong <[email protected]>--- db/attr.c | 32 ++++++++++++++++++++++++++++++++ db/attr.h | 1 + db/dir2.c | 37 +++++++++++++++++++++++++++++++++++++ db/dir2.h | 1 + db/type.c | 8 ++++---- db/type.h | 2 ++ db/write.c | 3 +++ 7 files changed, 80 insertions(+), 4 deletions(-)db/attr.c +3
-0@@ -602,6 +602,38 @@ const struct field attr3_remote_crc_flds[] = { { NULL } }; +/* Set the CRC. */ +void +xfs_attr3_set_crc(
db/attr.c const struct field attr3_remote_crc_flds[] = { · line 617
Quoted 10 lines
db/attr.c +10
-0+ struct xfs_buf *bp) +{ +__be32 magic32; +__be16 magic16; + + magic32 = *(__be32 *)bp->b_addr; + magic16 = ((struct xfs_da_blkinfo *)bp->b_addr)->magic; + +switch (magic16) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ):
Isn't it more typical to endian-swap magic16 and not have the swap in each case statement? *shrug*
Quoted 8 lines
db/attr.c +8
-0+xfs_buf_update_cksum (bp,XFS_ATTR3_LEAF_CRC_OFF ); +return ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DA3_NODE_CRC_OFF ); +return ; +default : +break ; + }
...
Quoted 6 lines
db/write.c +0
-0
db/write.c write_f( · line 181
Quoted 9 lines
db/write.c +3
-0@@ -173,6 +173,9 @@ write_f( }else if (iocur_top->dquot_buf) { local_ops.verify_write = xfs_verify_recalc_dquot_crc;dbprintf (_ ("Allowing write of corrupted dquot with good CRC\n" )); + }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { + local_ops.verify_write = iocur_top->typ->set_crc; +dbprintf (_ ("Allowing write of corrupted data with good CRC\n" )); }else {/* invalid data */ local_ops.verify_write = xfs_verify_recalc_crc;dbprintf (_ ("Allowing write of corrupted data with good CRC\n" ));
looking at this else if else if else if gunk makes me think that this has grown a bit out of control.
We have other special types that require unique crc setting functions - dquots and inodes. In those cases, we have TYP_F_NO_CRC_OFF but a special indicator that they are of this type (ino_buf, dquot_buf), with a hard-coded recalculation routine (xfs_verify_recalc_dquot_crc, xfs_verify_recalc_inode_crc). Now for /other/ types you've extended typ_t and put the function in there as an op, which makes sense.
It seems to me that it would be logical to move the existing crc recalculation routines for dquots & inodes into this new op as well, and locate & name everything consistently, no?
Thanks,
-Eric
Re: [PATCH 6/7] xfs_db: write values into dir/attr blocks and recalculate CRCs
Quoted 28 lines · Eric Sandeen
Quoted 27 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Extend
typ_tto (optionally) store a pointer to a function to calculate the CRC of the block, provide functions to do this for the dir3 and attr3 types, and then wire up the write command so that we can modify directory and extended attribute block fields.Signed-off-by Darrick J. Wong <[email protected]>--- db/attr.c | 32 ++++++++++++++++++++++++++++++++ db/attr.h | 1 + db/dir2.c | 37 +++++++++++++++++++++++++++++++++++++ db/dir2.h | 1 + db/type.c | 8 ++++---- db/type.h | 2 ++ db/write.c | 3 +++ 7 files changed, 80 insertions(+), 4 deletions(-)db/attr.c +0
-0@@ -602,6 +602,38 @@ const struct field attr3_remote_crc_flds[] = { { NULL } };
Quoted 16 lines
db/attr.c const struct field attr3_remote_crc_flds[] = { · line 617
Quoted 13 lines
db/attr.c +13
-0+/* Set the CRC. */ +void +xfs_attr3_set_crc ( +struct xfs_buf *bp) +{ +__be32 magic32; +__be16 magic16; + + magic32 = *(__be32 *)bp->b_addr; + magic16 = ((struct xfs_da_blkinfo *)bp->b_addr)->magic; + +switch (magic16) { +case cpu_to_be16 (XFS_ATTR3_LEAF_MAGIC ):Isn't it more typical to endian-swap magic16 and not have the swap in each case statement? *shrug*
cpu_to_be*() will do constant folding so we don't have to do any byte swapping at run time.
(I doubt it matters much here, but a fair amount of xfs code follows that paradigm...)
Quoted 37 lines
Quoted 8 lines
db/attr.c +8
-0+xfs_buf_update_cksum (bp,XFS_ATTR3_LEAF_CRC_OFF ); +return ; +case cpu_to_be16 (XFS_DA3_NODE_MAGIC ): +xfs_buf_update_cksum (bp,XFS_DA3_NODE_CRC_OFF ); +return ; +default : +break ; + }...
Quoted 6 lines
db/write.c +0
-0db/write.c write_f( · line 181
Quoted 9 lines
db/write.c +3
-0@@ -173,6 +173,9 @@ write_f( }else if (iocur_top->dquot_buf) { local_ops.verify_write = xfs_verify_recalc_dquot_crc;dbprintf (_ ("Allowing write of corrupted dquot with good CRC\n" )); + }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { + local_ops.verify_write = iocur_top->typ->set_crc; +dbprintf (_ ("Allowing write of corrupted data with good CRC\n" )); }else {/* invalid data */ local_ops.verify_write = xfs_verify_recalc_crc;dbprintf (_ ("Allowing write of corrupted data with good CRC\n" ));looking at this else if else if else if gunk makes me think that this has grown a bit out of control.
We have other special types that require unique crc setting functions - dquots and inodes. In those cases, we have
TYP_F_NO_CRC_OFFbut a special indicator that they are of this type (ino_buf,dquot_buf), with a hard-coded recalculation routine (xfs_verify_recalc_dquot_crc,xfs_verify_recalc_inode_crc). Now for /other/ types you've extendedtyp_tand put the function in there as an op, which makes sense.
Quoted 3 lines
It seems to me that it would be logical to move the existing crc recalculation routines for dquots & inodes into this new op as well, and locate & name everything consistently, no?
Yep. New patch!
--D
Quoted 9 lines
Thanks,
-Eric--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/7 xfs_db: introduce fuzz command
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Introduce a new 'fuzz' command to write creative values into disk structure fields.
--- db/Makefile | 3 db/bit.c | 17 +- db/bit.h | 5 - db/command.c | 2 db/fuzz.c | 467 +++++++++++++++++++++++++++++++++++++++++++++++++++++ db/fuzz.h | 21 ++ db/type.c | 44 ++++- db/type.h | 1 man/man8/xfs_db.8 | 49 ++++++ 9 files changed, 589 insertions(+), 20 deletions(-) create mode 100644 db/fuzz.c create mode 100644 db/fuzz.h
db/Makefile +2 -1
@@ -12,7 +12,8 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \ dir2.h dir2sf.h dquot.h echo.h faddr.h field.h \ flist.h fprint.h frag.h freesp.h hash.h help.h init.h inode.h input.h \ io.h logformat.h malloc.h metadump.h output.h print.h quit.h sb.h \ - sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h + sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h \ + fuzz.h CFILES = $(HFILES:.h=.c) btdump.c LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh
db/bit.c +6 -11
@@ -19,13 +19,8 @@#include "libxfs.h" #include "bit.h" -#undef setbit/* defined in param.h on Linux */ - -static int getbit (char *ptr,int bit); -static void setbit (char *ptr,int bit,int val); - -static int -getbit ( +int +getbit_l (char *ptr,int bit) {
@@ -39,8 +34,8 @@ getbit(return (*ptr & mask) >> shift; } -static void -setbit ( +void +setbit_l (char *ptr,int bit,int val)
@@ -106,7 +101,7 @@ getbitval(for (i =0 , rval =0LL ; i < nbits; i++) { -if (getbit (p, bit + i)) { +if (getbit_l (p, bit + i)) {/* If the last bit is on and we care about sign * bits and we don't have a full 64 bit * container, turn all bits on between the
@@ -162,7 +157,7 @@ setbitval(if (bitoff %NBBY || nbits %NBBY ) {for (bit =0 ; bit < nbits; bit++) -setbit (out, bit + bitoff,getbit (in, bit)); +setbit_l (out, bit + bitoff,getbit_l (in, bit)); }else memcpy (out +byteize (bitoff), in,byteize (nbits)); }
db/bit.h +4 -1
@@ -21,9 +21,12 @@#define bitszof (x,y) bitize(szof(x,y))#define byteize (s) ((s) / NBBY)#define bitoffs (s) ((s) % NBBY) +#define byteize_up (s) (((s) + NBBY - 1) / NBBY)#define BVUNSIGNED 0#define BVSIGNED 1extern int64_t getbitval (void *obj,int bitoff,int nbits,int flags); -extern void setbitval (void *obuf,int bitoff,int nbits,void *ibuf); +extern void setbitval (void *obuf,int bitoff,int nbits,void *ibuf); +extern int getbit_l (char *ptr,int bit); +extern void setbit_l (char *ptr,int bit,int val);
db/command.c +2 -0
@@ -51,6 +51,7 @@#include "dquot.h" #include "fsmap.h" #include "crc.h" +#include "fuzz.h" cmdinfo_t *cmdtab;int ncmds;
@@ -147,4 +148,5 @@ init_commands(void)type_init ();write_init ();dquot_init (); +fuzz_init (); }
db/fuzz.c new file +467 -0
467 lines not on this page · raw message
db/fuzz.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) 2017 Oracle. All Rights Reserved. +* +* Author: Darrick J. Wong <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +extern void fuzz_init (void ); +extern void fuzz_struct (const field_t *fields,int argc,char **argv);
db/type.c +37 -7
79 lines not on this page · raw message
db/type.h +1 -0
@@ -30,6 +30,7 @@ typedef enum typnm TYP_TEXT, TYP_FINOBT, TYP_NONE } typnm_t; +#define DB_FUZZ 2#define DB_WRITE 1#define DB_READ 0
man/man8/xfs_db.8 +49 -0
55 lines not on this page · raw message
Re: [PATCH 7/7] xfs_db: introduce fuzz command
Quoted 6 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Introduce a new 'fuzz' command to write creative values into disk structure fields.
Signed-off-by Darrick J. Wong <[email protected]>
Quoted 14 lines
--- db/Makefile | 3 db/bit.c | 17 +- db/bit.h | 5 - db/command.c | 2 db/fuzz.c | 467 +++++++++++++++++++++++++++++++++++++++++++++++++++++ db/fuzz.h | 21 ++ db/type.c | 44 ++++- db/type.h | 1 man/man8/xfs_db.8 | 49 ++++++ 9 files changed, 589 insertions(+), 20 deletions(-) create mode 100644 db/fuzz.c create mode 100644 db/fuzz.h
Code looks good and tested here.
Quoted 765 lines
db/Makefile +2
-1@@ -12,7 +12,8 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \ dir2.h dir2sf.h dquot.h echo.h faddr.h field.h \ flist.h fprint.h frag.h freesp.h hash.h help.h init.h inode.h input.h \ io.h logformat.h malloc.h metadump.h output.h print.h quit.h sb.h \ - sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h + sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h \ + fuzz.h CFILES = $(HFILES:.h=.c) btdump.c LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.shdb/bit.c +6
-11@@ -19,13 +19,8 @@#include "libxfs.h" #include "bit.h" -#undef setbit/* defined in param.h on Linux */ - -static int getbit (char *ptr,int bit); -static void setbit (char *ptr,int bit,int val); - -static int -getbit ( +int +getbit_l (char *ptr,int bit) {@@ -39,8 +34,8 @@ getbit(return (*ptr & mask) >> shift; } -static void -setbit ( +void +setbit_l (char *ptr,int bit,int val)@@ -106,7 +101,7 @@ getbitval(for (i =0 , rval =0LL ; i < nbits; i++) { -if (getbit (p, bit + i)) { +if (getbit_l (p, bit + i)) {/* If the last bit is on and we care about sign * bits and we don't have a full 64 bit * container, turn all bits on between the @@ -162,7 +157,7 @@ setbitval(if (bitoff %NBBY || nbits %NBBY ) {for (bit =0 ; bit < nbits; bit++) -setbit (out, bit + bitoff,getbit (in, bit)); +setbit_l (out, bit + bitoff,getbit_l (in, bit)); }else memcpy (out +byteize (bitoff), in,byteize (nbits)); }db/bit.h +4
-1@@ -21,9 +21,12 @@#define bitszof (x,y) bitize(szof(x,y))#define byteize (s) ((s) / NBBY)#define bitoffs (s) ((s) % NBBY) +#define byteize_up (s) (((s) + NBBY - 1) / NBBY)#define BVUNSIGNED 0#define BVSIGNED 1extern int64_t getbitval (void *obj,int bitoff,int nbits,int flags); -extern void setbitval (void *obuf,int bitoff,int nbits,void *ibuf); +extern void setbitval (void *obuf,int bitoff,int nbits,void *ibuf); +extern int getbit_l (char *ptr,int bit); +extern void setbit_l (char *ptr,int bit,int val);db/command.c +2
-0@@ -51,6 +51,7 @@#include "dquot.h" #include "fsmap.h" #include "crc.h" +#include "fuzz.h" cmdinfo_t *cmdtab;int ncmds;@@ -147,4 +148,5 @@ init_commands(void)type_init ();write_init ();dquot_init (); +fuzz_init (); }db/fuzz.c new file +467
-0@@ -0,0 +1,467 @@ +/* +* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. +* All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "libxfs.h" +#include <ctype.h> +#include <time.h> +#include "bit.h" +#include "block.h" +#include "command.h" +#include "type.h" +#include "faddr.h" +#include "fprint.h" +#include "field.h" +#include "flist.h" +#include "io.h" +#include "init.h" +#include "output.h" +#include "print.h" +#include "write.h" +#include "malloc.h" + +static int fuzz_f (int argc,char **argv); +static void fuzz_help (void ); + +static const cmdinfo_t fuzz_cmd = + {"fuzz" ,NULL , fuzz_f,0 ,-1 ,0 ,N_ ("[-c] [-d] field fuzzcmd..." ), +N_ ("fuzz values on disk" ), fuzz_help }; + +void +fuzz_init (void ) +{ +if (!expert_mode) +return ; + +add_command (&fuzz_cmd); +srand48 (clock ()); +} + +static void +fuzz_help (void ) +{ +dbprintf (_ ( +"\n" +" The 'fuzz' command fuzzes fields in any on-disk data structure. For\n" +" block fuzzing, see the 'blocktrash' or 'write' commands." +"\n" +" Examples:\n" +" Struct mode: 'fuzz core.uid zeroes' - set an inode uid field to 0.\n" +" 'fuzz crc ones' - set a crc filed to all ones.\n" +" 'fuzz bno[11] firstbit' - set the high bit of a block array.\n" +" 'fuzz keys[5].startblock add' - increase a btree key value.\n" +" 'fuzz uuid random' - randomize the superblock uuid.\n" +"\n" +" In data mode type 'fuzz' by itself for a list of specific commands.\n\n" +" Specifying the -c option will allow writes of invalid (corrupt) data with\n" +" an invalid CRC. Specifying the -d option will allow writes of invalid data,\n" +" but still recalculate the CRC so we are forced to check and detect the\n" +" invalid data appropriately.\n\n" +)); + +} + +static int +fuzz_f ( +int argc, +char **argv) +{ +pfunc_t pf; +extern char *progname; +int c; +bool corrupt = false;/* Allow write of bad data w/ invalid CRC */ +bool invalid_data = false;/* Allow write of bad data w/ valid CRC */ +struct xfs_buf_ops local_ops; +const struct xfs_buf_ops *stashed_ops =NULL ; + +if (x.isreadonly &LIBXFS_ISREADONLY ) { +dbprintf (_ ("%s started in read only mode, fuzzing disabled\n" ), + progname); +return 0 ; + } + +if (cur_typ ==NULL ) { +dbprintf (_ ("no current type\n" )); +return 0 ; + } + + pf = cur_typ->pfunc; +if (pf ==NULL ) { +dbprintf (_ ("no handler function for type %s, fuzz unsupported.\n" ), + cur_typ->name); +return 0 ; + } + +while ((c =getopt (argc, argv,"cd" )) !=EOF ) { +switch (c) { +case 'c' : + corrupt = true; +break ; +case 'd' : + invalid_data = true; +break ; +default : +dbprintf (_ ("bad option for fuzz command\n" )); +return 0 ; + } + } + +if (corrupt && invalid_data) { +dbprintf (_ ("Cannot specify both -c and -d options\n" )); +return 0 ; + } + +if (invalid_data && iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF && + !iocur_top->ino_buf && !iocur_top->dquot_buf) { +dbprintf (_ ("Cannot recalculate CRCs on this type of object\n" )); +return 0 ; + } + + argc -= optind; + argv += optind; + +/* +* If the buffer has no verifier or we are using standard verifier +* paths, then just fuzz it and return +*/ +if (!iocur_top->bp->b_ops || + !(corrupt || invalid_data)) { + (*pf)(DB_FUZZ , cur_typ->fields, argc, argv); +return 0 ; + } + + +/* Temporarily remove write verifier to write bad data */ + stashed_ops = iocur_top->bp->b_ops; + local_ops.verify_read = stashed_ops->verify_read; + iocur_top->bp->b_ops = &local_ops; + +if (corrupt) { + local_ops.verify_write = xfs_dummy_verify; +dbprintf (_ ("Allowing fuzz of corrupted data and bad CRC\n" )); + }else if (iocur_top->ino_buf) { + local_ops.verify_write = xfs_verify_recalc_inode_crc; +dbprintf (_ ("Allowing fuzz of corrupted inode with good CRC\n" )); + }else if (iocur_top->dquot_buf) { + local_ops.verify_write = xfs_verify_recalc_dquot_crc; +dbprintf (_ ("Allowing fuzz of corrupted dquot with good CRC\n" )); + }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { + local_ops.verify_write = iocur_top->typ->set_crc; +dbprintf (_ ("Allowing fuzz of corrupted data with good CRC\n" )); + }else {/* invalid data */ + local_ops.verify_write = xfs_verify_recalc_crc; +dbprintf (_ ("Allowing fuzz of corrupted data with good CRC\n" )); + } + + (*pf)(DB_FUZZ , cur_typ->fields, argc, argv); + + iocur_top->bp->b_ops = stashed_ops; + +return 0 ; +} + +/* Write zeroes to the field */ +static bool +fuzz_zeroes ( +void *buf, +int bitoff, +int nbits) +{ +char *out = buf; +int bit; + +if (bitoff %NBBY || nbits %NBBY ) { +for (bit =0 ; bit < nbits; bit++) +setbit_l (out, bit + bitoff,0 ); + }else +memset (out +byteize (bitoff),0 ,byteize (nbits)); +return true; +} + +/* Write ones to the field */ +static bool +fuzz_ones ( +void *buf, +int bitoff, +int nbits) +{ +char *out = buf; +int bit; + +if (bitoff %NBBY || nbits %NBBY ) { +for (bit =0 ; bit < nbits; bit++) +setbit_l (out, bit + bitoff,1 ); + }else +memset (out +byteize (bitoff),0xFF ,byteize (nbits)); +return true; +} + +/* Flip the high bit in the (presumably big-endian) field */ +static bool +fuzz_firstbit ( +void *buf, +int bitoff, +int nbits) +{ +setbit_l ((char *)buf, bitoff, !getbit_l ((char *)buf, bitoff)); +return true; +} + +/* Flip the low bit in the (presumably big-endian) field */ +static bool +fuzz_lastbit ( +void *buf, +int bitoff, +int nbits) +{ +setbit_l ((char *)buf, bitoff + nbits -1 , + !getbit_l ((char *)buf, bitoff)); +return true; +} + +/* Flip the middle bit in the (presumably big-endian) field */ +static bool +fuzz_middlebit ( +void *buf, +int bitoff, +int nbits) +{ +setbit_l ((char *)buf, bitoff + nbits /2 , + !getbit_l ((char *)buf, bitoff)); +return true; +} + +/* Format and shift a number into a buffer for setbitval. */ +static char * +format_number ( +uint64_t val, +__be64 *out, +int bit_length) +{ +int offset; +char *rbuf = (char *)out; + +/* +* If the length of the field is not a multiple of a byte, push +* the bits up in the field, so the most signicant field bit is +* the most significant bit in the byte: +* +* before: +* val |----|----|----|----|----|--MM|mmmm|llll| +* after +* val |----|----|----|----|----|MMmm|mmll|ll00| +*/ + offset = bit_length %NBBY ; +if (offset) + val <<= (NBBY - offset); + +/* +* convert to big endian and copy into the array +* rbuf |----|----|----|----|----|MMmm|mmll|ll00| +*/ + *out =cpu_to_be64 (val); + +/* +* Align the array to point to the field in the array. +* rbuf = |MMmm|mmll|ll00| +*/ + offset =sizeof (__be64) -1 - ((bit_length -1 ) /sizeof (__be64)); +return rbuf + offset; +} + +/* Increase the value by some small prime number. */ +static bool +fuzz_add ( +void *buf, +int bitoff, +int nbits) +{ +uint64_t val; +__be64 out; +char *b; + +if (nbits >64 ) +return false; + + val =getbitval (buf, bitoff, nbits,BVUNSIGNED ); + val += (nbits >8 ?2017 :137 ); + b =format_number (val, &out, nbits); +setbitval (buf, bitoff, nbits, b); + +return true; +} + +/* Decrease the value by some small prime number. */ +static bool +fuzz_sub ( +void *buf, +int bitoff, +int nbits) +{ +uint64_t val; +__be64 out; +char *b; + +if (nbits >64 ) +return false; + + val =getbitval (buf, bitoff, nbits,BVUNSIGNED ); + val -= (nbits >8 ?2017 :137 ); + b =format_number (val, &out, nbits); +setbitval (buf, bitoff, nbits, b); + +return true; +} + +/* Randomize the field. */ +static bool +fuzz_random ( +void *buf, +int bitoff, +int nbits) +{ +int i, bytes; +char *b, *rbuf; + + bytes =byteize_up (nbits); + rbuf = b =malloc (bytes); +if (!b) { +perror ("fuzz_random" ); +return false; + } + +for (i =0 ; i < bytes; i++) + *b++ = (char )lrand48 (); + +setbitval (buf, bitoff, nbits, rbuf); +free (rbuf); + +return true; +} + +struct fuzzcmd { +const char *verb; +bool (*fn)(void *buf,int bitoff,int nbits); +}; + +/* Keep these verbs in sync with enum fuzzcmds. */ +static struct fuzzcmd fuzzverbs[] = { + {"zeroes" , fuzz_zeroes}, + {"ones" , fuzz_ones}, + {"firstbit" , fuzz_firstbit}, + {"middlebit" , fuzz_middlebit}, + {"lastbit" , fuzz_lastbit}, + {"add" , fuzz_add}, + {"sub" , fuzz_sub}, + {"random" , fuzz_random}, + {NULL ,NULL }, +}; + +/* ARGSUSED */ +void +fuzz_struct ( +const field_t *fields, +int argc, +char **argv) +{ +const ftattr_t *fa; +flist_t *fl; +flist_t *sfl; +int bit_length; +struct fuzzcmd *fc; +bool success; +int parentoffset; + +if (argc !=2 ) { +dbprintf (_ ("Usage: fuzz fieldname verb\n" )); +dbprintf ("Verbs: %s" , fuzzverbs->verb); +for (fc = fuzzverbs +1 ; fc->verb !=NULL ; fc++) +dbprintf (", %s" , fc->verb); +dbprintf (".\n" ); +return ; + } + + fl =flist_scan (argv[0 ]); +if (!fl) { +dbprintf (_ ("unable to parse '%s'.\n" ), argv[0 ]); +return ; + } + +/* Find our fuzz verb */ +for (fc = fuzzverbs; fc->verb !=NULL ; fc++) +if (!strcmp (fc->verb, argv[1 ])) +break ; +if (fc->fn ==NULL ) { +dbprintf (_ ("Unknown fuzz command '%s'.\n" ), argv[1 ]); +return ; + } + +/* if we're a root field type, go down 1 layer to get field list */ +if (fields->name[0 ] =='\0' ) { + fa = &ftattrtab[fields->ftyp]; +ASSERT (fa->ftyp == fields->ftyp); + fields = fa->subfld; + } + +/* run down the field list and set offsets into the data */ +if (!flist_parse (fields, fl, iocur_top->data,0 )) { +flist_free (fl); +dbprintf (_ ("parsing error\n" )); +return ; + } + + sfl = fl; + parentoffset =0 ; +while (sfl->child) { + parentoffset = sfl->offset; + sfl = sfl->child; + } + +/* +* For structures, fsize * fcount tells us the size of the region we are +* modifying, which is usually a single structure member and is pointed +* to by the last child in the list. +* +* However, if the base structure is an array and we have a direct index +* into the array (e.g. write bno[5]) then we are returned a single +* flist object with the offset pointing directly at the location we +* need to modify. The length of the object we are modifying is then +* determined by the size of the individual array entry (fsize) and the +* indexes defined in the object, not the overall size of the array +* (which is what fcount returns). +*/ + bit_length =fsize (sfl->fld, iocur_top->data, parentoffset,0 ); +if (sfl->fld->flags &FLD_ARRAY ) + bit_length *= sfl->high - sfl->low +1 ; +else + bit_length *=fcount (sfl->fld, iocur_top->data, parentoffset); + +/* Fuzz the value */ + success = fc->fn (iocur_top->data, sfl->offset, bit_length); +if (!success) { +dbprintf (_ ("unable to fuzz field '%s'\n" ), argv[0 ]); +flist_free (fl); +return ; + } + +/* Write the fuzzed value back */ +write_cur (); + +flist_print (fl); +print_flist (fl); +flist_free (fl); +}db/fuzz.h new file +21
-0@@ -0,0 +1,21 @@ +/* +* Copyright (C) 2017 Oracle. All Rights Reserved. +* +* Author: Darrick J. Wong <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +extern void fuzz_init (void ); +extern void fuzz_struct (const field_t *fields,int argc,char **argv);db/type.c +37
-7@@ -39,6 +39,7 @@#include "dir2.h" #include "text.h" #include "symlink.h" +#include "fuzz.h" static const typ_t *findtyp (char *name);static int type_f (int argc,char **argv);@@ -254,10 +255,17 @@ handle_struct(int argc, char **argv) { -if (action ==DB_WRITE ) + switch (action) { + case DB_FUZZ: +fuzz_struct (fields ,argc ,argv ); +break ; +case DB_WRITE :write_struct (fields, argc, argv); -else +break ; +case DB_READ :print_struct (fields, argc, argv); +break ; + } }void @@ -267,10 +275,17 @@ handle_string(int argc, char **argv) { -if (action ==DB_WRITE ) + switch (action) { + case DB_WRITE:write_string (fields ,argc ,argv ); -else +break ; +case DB_READ :print_string (fields, argc, argv); +break ; +case DB_FUZZ : +dbprintf (_ ("string fuzzing not supported.\n" )); +break ; + } }void @@ -280,10 +295,17 @@ handle_block(int argc, char **argv) { -if (action ==DB_WRITE ) + switch (action) { + case DB_WRITE:write_block (fields ,argc ,argv ); -else +break ; +case DB_READ :print_block (fields, argc, argv); +break ; +case DB_FUZZ : +dbprintf (_ ("use 'blocktrash' or 'write' to fuzz a block.\n" )); +break ; + } }void @@ -293,6 +315,14 @@ handle_text(int argc, char **argv) { -if (action !=DB_WRITE ) + switch (action) { + case DB_FUZZ: + /* fall through */ + case DB_WRITE: + dbprintf(_("text writing/fuzzing not supported.\n")); +break ; +case DB_READ :print_text (fields, argc, argv); +break ; + } }db/type.h +1
-0@@ -30,6 +30,7 @@ typedef enum typnm TYP_TEXT, TYP_FINOBT, TYP_NONE } typnm_t; +#define DB_FUZZ 2#define DB_WRITE 1#define DB_READ 0man/man8/xfs_db.8 +49
-1@@ -613,6 +613,55 @@ in units of 512-byte blocks, no matter what the filesystem's block size is. .BI "The optional " start " and " end " arguments can be used to constrain the output to a particular range of disk blocks. .TP +.BI "fuzz [\-c] [\-d] " "field action" +Write garbage into a specific structure field on disk. +Expert mode must be enabled to use this command. +The operation happens immediately; there is no buffering. +.IP +The fuzz command can take the following +.IR action "s" +against a field: +.RS 1.0i +.TP 0.4i +.B zeroes +Clears all bits in the field. +.TP 0.4i +.B ones +Sets all bits in the field. +.TP 0.4i +.B firstbit +Flips the first bit in the field. +For a scalar value, this is the highest bit. +.TP 0.4i +.B middlebit +Flips the middle bit in the field. +.TP 0.4i +.B lastbit +Flips the last bit in the field. +For a scalar value, this is the lowest bit. +.TP 0.4i +.B add +Adds a small value to a scalar field. +.TP 0.4i +.B sub +Subtracts a small value from a scalar field. +.TP 0.4i +.B random +Randomizes the contents of the field. +.RE +.IP +The following switches affect the write behavior: +.RS 1.0i +.TP 0.4i +.B \-c +Skip write verifiers and CRC recalculation; allows invalid data to be written +to disk. +.TP 0.4i +.B \-d +Skip write verifiers but perform CRC recalculation; allows invalid data to be +written to disk to test detection of invalid data. +.RE +.TP .BI hash " string Prints the hash value of .I string --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Carlos
[PATCH 8/7] xfs_db: use TYP_F_CRC_FUNC for inodes & dquots
In reply to Darrick J. WongNow that typ_t has a ->set_crc method, use it for inodes & dquots as well, rather than recognizing them as special types and calling their crc functions directly by name.
---
db/dquot.c +11 -0
@@ -171,6 +171,17 @@ dquot_f( }void +xfs_dquot_set_crc ( +struct xfs_buf *bp) +{ +ASSERT ((iocur_top->dquot_buf)); +ASSERT (iocur_top->bp == bp); + +xfs_update_cksum (iocur_top->data,sizeof (struct xfs_dqblk ), +XFS_DQUOT_CRC_OFF ); +} + +void dquot_init (void ) {add_command (&dquot_cmd);
db/dquot.h +1 -0
@@ -20,4 +20,5 @@ extern const struct field disk_dquot_flds[];extern const struct field dqblk_flds[];extern const struct field dqblk_hfld[]; +extern void xfs_dquot_set_crc (struct xfs_buf *);extern void dquot_init (void );
db/fuzz.c +1 -8
@@ -125,8 +125,7 @@ fuzz_f(return 0 ; } -if (invalid_data && iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF && - !iocur_top->ino_buf && !iocur_top->dquot_buf) { +if (invalid_data && iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF ) {dbprintf (_ ("Cannot recalculate CRCs on this type of object\n" ));return 0 ; }
@@ -153,12 +152,6 @@ fuzz_f(if (corrupt) { local_ops.verify_write = xfs_dummy_verify;dbprintf (_ ("Allowing fuzz of corrupted data and bad CRC\n" )); - }else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; -dbprintf (_ ("Allowing fuzz of corrupted inode with good CRC\n" )); - }else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; -dbprintf (_ ("Allowing fuzz of corrupted dquot with good CRC\n" )); }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { local_ops.verify_write = iocur_top->typ->set_crc;dbprintf (_ ("Allowing fuzz of corrupted data with good CRC\n" ));
db/inode.c +11 -0
@@ -711,3 +711,14 @@ _("Metadata CRC error detected for ino %lld\n"),/* track updated info in ring */ ring_add (); } + +void +xfs_inode_set_crc ( +struct xfs_buf *bp) +{ +ASSERT (iocur_top->ino_buf); +ASSERT (iocur_top->bp == bp); + +libxfs_dinode_calc_crc (mp, iocur_top->data); + iocur_top->ino_crc_ok =1 ; +}
db/inode.h +1 -0
@@ -33,4 +33,5 @@ extern void inode_init(void);extern typnm_t inode_next_type (void );extern int inode_size (void *obj,int startoff,int idx);extern int inode_u_size (void *obj,int startoff,int idx); +extern void xfs_inode_set_crc (struct xfs_buf *);extern void set_cur_inode (xfs_ino_t ino);
db/io.c +0 -22
@@ -466,28 +466,6 @@ xfs_dummy_verify( }void -xfs_verify_recalc_inode_crc ( -struct xfs_buf *bp) -{ -ASSERT (iocur_top->ino_buf); -ASSERT (iocur_top->bp == bp); - -libxfs_dinode_calc_crc (mp, iocur_top->data); - iocur_top->ino_crc_ok =1 ; -} - -void -xfs_verify_recalc_dquot_crc ( -struct xfs_buf *bp) -{ -ASSERT ((iocur_top->dquot_buf)); -ASSERT (iocur_top->bp == bp); - -xfs_update_cksum (iocur_top->data,sizeof (struct xfs_dqblk ), -XFS_DQUOT_CRC_OFF ); -} - -void xfs_verify_recalc_crc (struct xfs_buf *bp) {
db/io.h +0 -2
@@ -64,8 +64,6 @@ extern void set_cur(const struct typ *type, xfs_daddr_t blknum,extern void ring_add (void );extern void set_iocur_type (const struct typ *type);extern void xfs_dummy_verify (struct xfs_buf *bp); -extern void xfs_verify_recalc_inode_crc (struct xfs_buf *bp); -extern void xfs_verify_recalc_dquot_crc (struct xfs_buf *bp);extern void xfs_verify_recalc_crc (struct xfs_buf *bp);/*
db/type.c +4 -4
@@ -105,12 +105,12 @@ static const typ_t __typtab_crc[] = { {TYP_DIR2 ,"dir3" , handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_crc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF },
@@ -149,12 +149,12 @@ static const typ_t __typtab_spcrc[] = { {TYP_DIR2 ,"dir3" , handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_spcrc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF },
db/write.c +0 -6
@@ -167,12 +167,6 @@ write_f(if (corrupt) { local_ops.verify_write = xfs_dummy_verify;dbprintf (_ ("Allowing write of corrupted data and bad CRC\n" )); - }else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; -dbprintf (_ ("Allowing write of corrupted inode with good CRC\n" )); - }else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; -dbprintf (_ ("Allowing write of corrupted dquot with good CRC\n" )); }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { local_ops.verify_write = iocur_top->typ->set_crc;dbprintf (_ ("Allowing write of corrupted data with good CRC\n" ));
Darrick J. Wong
Reviewed-byRe: [PATCH 8/7] xfs_db: use TYP_F_CRC_FUNC for inodes & dquots
Quoted 5 lines · Eric Sandeen
Now that
typ_thas a ->set_crc method, use it for inodes & dquots as well, rather than recognizing them as special types and calling their crc functions directly by name.Signed-off-by Eric Sandeen <[email protected]>
Looks fine,
Quoted 193 lines
---
db/dquot.c +11
-0@@ -171,6 +171,17 @@ dquot_f( }void +xfs_dquot_set_crc ( +struct xfs_buf *bp) +{ +ASSERT ((iocur_top->dquot_buf)); +ASSERT (iocur_top->bp == bp); + +xfs_update_cksum (iocur_top->data,sizeof (struct xfs_dqblk ), +XFS_DQUOT_CRC_OFF ); +} + +void dquot_init (void ) {add_command (&dquot_cmd);db/dquot.h +1
-0@@ -20,4 +20,5 @@ extern const struct field disk_dquot_flds[];extern const struct field dqblk_flds[];extern const struct field dqblk_hfld[]; +extern void xfs_dquot_set_crc (struct xfs_buf *);extern void dquot_init (void );db/fuzz.c +1
-8@@ -125,8 +125,7 @@ fuzz_f(return 0 ; } -if (invalid_data && iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF && - !iocur_top->ino_buf && !iocur_top->dquot_buf) { +if (invalid_data && iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF ) {dbprintf (_ ("Cannot recalculate CRCs on this type of object\n" ));return 0 ; }@@ -153,12 +152,6 @@ fuzz_f(if (corrupt) { local_ops.verify_write = xfs_dummy_verify;dbprintf (_ ("Allowing fuzz of corrupted data and bad CRC\n" )); - }else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; -dbprintf (_ ("Allowing fuzz of corrupted inode with good CRC\n" )); - }else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; -dbprintf (_ ("Allowing fuzz of corrupted dquot with good CRC\n" )); }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { local_ops.verify_write = iocur_top->typ->set_crc;dbprintf (_ ("Allowing fuzz of corrupted data with good CRC\n" ));db/inode.c +11
-0@@ -711,3 +711,14 @@ _("Metadata CRC error detected for ino %lld\n"),/* track updated info in ring */ ring_add (); } + +void +xfs_inode_set_crc ( +struct xfs_buf *bp) +{ +ASSERT (iocur_top->ino_buf); +ASSERT (iocur_top->bp == bp); + +libxfs_dinode_calc_crc (mp, iocur_top->data); + iocur_top->ino_crc_ok =1 ; +}db/inode.h +1
-0@@ -33,4 +33,5 @@ extern void inode_init(void);extern typnm_t inode_next_type (void );extern int inode_size (void *obj,int startoff,int idx);extern int inode_u_size (void *obj,int startoff,int idx); +extern void xfs_inode_set_crc (struct xfs_buf *);extern void set_cur_inode (xfs_ino_t ino);db/io.c +0
-22@@ -466,28 +466,6 @@ xfs_dummy_verify( }void -xfs_verify_recalc_inode_crc ( -struct xfs_buf *bp) -{ -ASSERT (iocur_top->ino_buf); -ASSERT (iocur_top->bp == bp); - -libxfs_dinode_calc_crc (mp, iocur_top->data); - iocur_top->ino_crc_ok =1 ; -} - -void -xfs_verify_recalc_dquot_crc ( -struct xfs_buf *bp) -{ -ASSERT ((iocur_top->dquot_buf)); -ASSERT (iocur_top->bp == bp); - -xfs_update_cksum (iocur_top->data,sizeof (struct xfs_dqblk ), -XFS_DQUOT_CRC_OFF ); -} - -void xfs_verify_recalc_crc (struct xfs_buf *bp) {db/io.h +0
-2@@ -64,8 +64,6 @@ extern void set_cur(const struct typ *type, xfs_daddr_t blknum,extern void ring_add (void );extern void set_iocur_type (const struct typ *type);extern void xfs_dummy_verify (struct xfs_buf *bp); -extern void xfs_verify_recalc_inode_crc (struct xfs_buf *bp); -extern void xfs_verify_recalc_dquot_crc (struct xfs_buf *bp);extern void xfs_verify_recalc_crc (struct xfs_buf *bp);/* db/type.c +4
-4@@ -105,12 +105,12 @@ static const typ_t __typtab_crc[] = { {TYP_DIR2 ,"dir3" , handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_crc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF },@@ -149,12 +149,12 @@ static const typ_t __typtab_spcrc[] = { {TYP_DIR2 ,"dir3" , handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_spcrc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF },db/write.c +0
-7@@ -167,12 +167,6 @@ write_f(if (corrupt) { local_ops.verify_write = xfs_dummy_verify;dbprintf (_ ("Allowing write of corrupted data and bad CRC\n" )); - }else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; -dbprintf (_ ("Allowing write of corrupted inode with good CRC\n" )); - }else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; -dbprintf (_ ("Allowing write of corrupted dquot with good CRC\n" )); }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { local_ops.verify_write = iocur_top->typ->set_crc;dbprintf (_ ("Allowing write of corrupted data with good CRC\n" )); --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 8/7 V2] xfs_db: use TYP_F_CRC_FUNC for inodes & dquots
In reply to Eric SandeenNow that typ_t has a ->set_crc method, use it for inodes & dquots as well, rather than recognizing them as special types and calling their crc functions directly by name.
---
V2: Remove one more buf type special case in write_f(), and call crc writer helpers rather than open coded versions in write_cur()
db/dquot.c +11 -0
@@ -171,6 +171,17 @@ dquot_f( }void +xfs_dquot_set_crc ( +struct xfs_buf *bp) +{ +ASSERT ((iocur_top->dquot_buf)); +ASSERT (iocur_top->bp == bp); + +xfs_update_cksum (iocur_top->data,sizeof (struct xfs_dqblk ), +XFS_DQUOT_CRC_OFF ); +} + +void dquot_init (void ) {add_command (&dquot_cmd);
db/dquot.h +1 -0
@@ -20,4 +20,5 @@ extern const struct field disk_dquot_flds[];extern const struct field dqblk_flds[];extern const struct field dqblk_hfld[]; +extern void xfs_dquot_set_crc (struct xfs_buf *);extern void dquot_init (void );
db/fuzz.c +1 -8
@@ -125,8 +125,7 @@ fuzz_f(return 0 ; } -if (invalid_data && iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF && - !iocur_top->ino_buf && !iocur_top->dquot_buf) { +if (invalid_data && iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF ) {dbprintf (_ ("Cannot recalculate CRCs on this type of object\n" ));return 0 ; }
@@ -153,12 +152,6 @@ fuzz_f(if (corrupt) { local_ops.verify_write = xfs_dummy_verify;dbprintf (_ ("Allowing fuzz of corrupted data and bad CRC\n" )); - }else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; -dbprintf (_ ("Allowing fuzz of corrupted inode with good CRC\n" )); - }else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; -dbprintf (_ ("Allowing fuzz of corrupted dquot with good CRC\n" )); }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { local_ops.verify_write = iocur_top->typ->set_crc;dbprintf (_ ("Allowing fuzz of corrupted data with good CRC\n" ));
db/inode.c +11 -0
@@ -711,3 +711,14 @@ _("Metadata CRC error detected for ino %lld\n"),/* track updated info in ring */ ring_add (); } + +void +xfs_inode_set_crc ( +struct xfs_buf *bp) +{ +ASSERT (iocur_top->ino_buf); +ASSERT (iocur_top->bp == bp); + +libxfs_dinode_calc_crc (mp, iocur_top->data); + iocur_top->ino_crc_ok =1 ; +}
db/inode.h +1 -0
@@ -33,4 +33,5 @@ extern void inode_init(void);extern typnm_t inode_next_type (void );extern int inode_size (void *obj,int startoff,int idx);extern int inode_u_size (void *obj,int startoff,int idx); +extern void xfs_inode_set_crc (struct xfs_buf *);extern void set_cur_inode (xfs_ino_t ino);
db/io.c +5 -30
@@ -22,6 +22,7 @@#include "faddr.h" #include "fprint.h" #include "field.h" +#include "dquot.h" #include "inode.h" #include "io.h" #include "output.h"
@@ -466,28 +467,6 @@ xfs_dummy_verify( }void -xfs_verify_recalc_inode_crc ( -struct xfs_buf *bp) -{ -ASSERT (iocur_top->ino_buf); -ASSERT (iocur_top->bp == bp); - -libxfs_dinode_calc_crc (mp, iocur_top->data); - iocur_top->ino_crc_ok =1 ; -} - -void -xfs_verify_recalc_dquot_crc ( -struct xfs_buf *bp) -{ -ASSERT ((iocur_top->dquot_buf)); -ASSERT (iocur_top->bp == bp); - -xfs_update_cksum (iocur_top->data,sizeof (struct xfs_dqblk ), -XFS_DQUOT_CRC_OFF ); -} - -void xfs_verify_recalc_crc (struct xfs_buf *bp) {
@@ -510,14 +489,10 @@ write_cur(void) skip_crc = true;if (!skip_crc) { -if (iocur_top->ino_buf) { -libxfs_dinode_calc_crc (mp, iocur_top->data); - iocur_top->ino_crc_ok =1 ; - }else if (iocur_top->dquot_buf) { -xfs_update_cksum (iocur_top->data, -sizeof (struct xfs_dqblk ), -XFS_DQUOT_CRC_OFF ); - } +if (iocur_top->ino_buf) +xfs_inode_set_crc (iocur_top->bp); +else if (iocur_top->dquot_buf) +xfs_dquot_set_crc (iocur_top->bp); }if (iocur_top->bbmap)write_cur_bbs ();
db/io.h +0 -2
@@ -64,8 +64,6 @@ extern void set_cur(const struct typ *type, xfs_daddr_t blknum,extern void ring_add (void );extern void set_iocur_type (const struct typ *type);extern void xfs_dummy_verify (struct xfs_buf *bp); -extern void xfs_verify_recalc_inode_crc (struct xfs_buf *bp); -extern void xfs_verify_recalc_dquot_crc (struct xfs_buf *bp);extern void xfs_verify_recalc_crc (struct xfs_buf *bp);/*
db/type.c +4 -4
@@ -105,12 +105,12 @@ static const typ_t __typtab_crc[] = { {TYP_DIR2 ,"dir3" , handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_crc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF },
@@ -149,12 +149,12 @@ static const typ_t __typtab_spcrc[] = { {TYP_DIR2 ,"dir3" , handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_spcrc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF },
db/write.c +1 -9
@@ -138,9 +138,7 @@ write_f( }if (invalid_data && - iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF && - !iocur_top->ino_buf && - !iocur_top->dquot_buf) { + iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF ) {dbprintf (_ ("Cannot recalculate CRCs on this type of object\n" ));return 0 ; }
@@ -167,12 +165,6 @@ write_f(if (corrupt) { local_ops.verify_write = xfs_dummy_verify;dbprintf (_ ("Allowing write of corrupted data and bad CRC\n" )); - }else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; -dbprintf (_ ("Allowing write of corrupted inode with good CRC\n" )); - }else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; -dbprintf (_ ("Allowing write of corrupted dquot with good CRC\n" )); }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { local_ops.verify_write = iocur_top->typ->set_crc;dbprintf (_ ("Allowing write of corrupted data with good CRC\n" ));
Darrick J. Wong
Reviewed-byRe: [PATCH 8/7 V2] xfs_db: use TYP_F_CRC_FUNC for inodes & dquots
Quoted 5 lines · Eric Sandeen
Now that
typ_thas a ->set_crc method, use it for inodes & dquots as well, rather than recognizing them as special types and calling their crc functions directly by name.Signed-off-by Eric Sandeen <[email protected]>
Quoted 233 lines
---
V2: Remove one more buf type special case in
write_f(), and call crc writer helpers rather than open coded versions inwrite_cur()db/dquot.c +11
-0@@ -171,6 +171,17 @@ dquot_f( }void +xfs_dquot_set_crc ( +struct xfs_buf *bp) +{ +ASSERT ((iocur_top->dquot_buf)); +ASSERT (iocur_top->bp == bp); + +xfs_update_cksum (iocur_top->data,sizeof (struct xfs_dqblk ), +XFS_DQUOT_CRC_OFF ); +} + +void dquot_init (void ) {add_command (&dquot_cmd);db/dquot.h +1
-0@@ -20,4 +20,5 @@ extern const struct field disk_dquot_flds[];extern const struct field dqblk_flds[];extern const struct field dqblk_hfld[]; +extern void xfs_dquot_set_crc (struct xfs_buf *);extern void dquot_init (void );db/fuzz.c +1
-8@@ -125,8 +125,7 @@ fuzz_f(return 0 ; } -if (invalid_data && iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF && - !iocur_top->ino_buf && !iocur_top->dquot_buf) { +if (invalid_data && iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF ) {dbprintf (_ ("Cannot recalculate CRCs on this type of object\n" ));return 0 ; }@@ -153,12 +152,6 @@ fuzz_f(if (corrupt) { local_ops.verify_write = xfs_dummy_verify;dbprintf (_ ("Allowing fuzz of corrupted data and bad CRC\n" )); - }else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; -dbprintf (_ ("Allowing fuzz of corrupted inode with good CRC\n" )); - }else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; -dbprintf (_ ("Allowing fuzz of corrupted dquot with good CRC\n" )); }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { local_ops.verify_write = iocur_top->typ->set_crc;dbprintf (_ ("Allowing fuzz of corrupted data with good CRC\n" ));db/inode.c +11
-0@@ -711,3 +711,14 @@ _("Metadata CRC error detected for ino %lld\n"),/* track updated info in ring */ ring_add (); } + +void +xfs_inode_set_crc ( +struct xfs_buf *bp) +{ +ASSERT (iocur_top->ino_buf); +ASSERT (iocur_top->bp == bp); + +libxfs_dinode_calc_crc (mp, iocur_top->data); + iocur_top->ino_crc_ok =1 ; +}db/inode.h +1
-0@@ -33,4 +33,5 @@ extern void inode_init(void);extern typnm_t inode_next_type (void );extern int inode_size (void *obj,int startoff,int idx);extern int inode_u_size (void *obj,int startoff,int idx); +extern void xfs_inode_set_crc (struct xfs_buf *);extern void set_cur_inode (xfs_ino_t ino);db/io.c +5
-30@@ -22,6 +22,7 @@#include "faddr.h" #include "fprint.h" #include "field.h" +#include "dquot.h" #include "inode.h" #include "io.h" #include "output.h" @@ -466,28 +467,6 @@ xfs_dummy_verify( }void -xfs_verify_recalc_inode_crc ( -struct xfs_buf *bp) -{ -ASSERT (iocur_top->ino_buf); -ASSERT (iocur_top->bp == bp); - -libxfs_dinode_calc_crc (mp, iocur_top->data); - iocur_top->ino_crc_ok =1 ; -} - -void -xfs_verify_recalc_dquot_crc ( -struct xfs_buf *bp) -{ -ASSERT ((iocur_top->dquot_buf)); -ASSERT (iocur_top->bp == bp); - -xfs_update_cksum (iocur_top->data,sizeof (struct xfs_dqblk ), -XFS_DQUOT_CRC_OFF ); -} - -void xfs_verify_recalc_crc (struct xfs_buf *bp) {@@ -510,14 +489,10 @@ write_cur(void) skip_crc = true;if (!skip_crc) { -if (iocur_top->ino_buf) { -libxfs_dinode_calc_crc (mp, iocur_top->data); - iocur_top->ino_crc_ok =1 ; - }else if (iocur_top->dquot_buf) { -xfs_update_cksum (iocur_top->data, -sizeof (struct xfs_dqblk ), -XFS_DQUOT_CRC_OFF ); - } +if (iocur_top->ino_buf) +xfs_inode_set_crc (iocur_top->bp); +else if (iocur_top->dquot_buf) +xfs_dquot_set_crc (iocur_top->bp); }if (iocur_top->bbmap)write_cur_bbs ();db/io.h +0
-2@@ -64,8 +64,6 @@ extern void set_cur(const struct typ *type, xfs_daddr_t blknum,extern void ring_add (void );extern void set_iocur_type (const struct typ *type);extern void xfs_dummy_verify (struct xfs_buf *bp); -extern void xfs_verify_recalc_inode_crc (struct xfs_buf *bp); -extern void xfs_verify_recalc_dquot_crc (struct xfs_buf *bp);extern void xfs_verify_recalc_crc (struct xfs_buf *bp);/* db/type.c +4
-4@@ -105,12 +105,12 @@ static const typ_t __typtab_crc[] = { {TYP_DIR2 ,"dir3" , handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_crc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF },@@ -149,12 +149,12 @@ static const typ_t __typtab_spcrc[] = { {TYP_DIR2 ,"dir3" , handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_spcrc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF },db/write.c +1
-10@@ -138,9 +138,7 @@ write_f( }if (invalid_data && - iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF && - !iocur_top->ino_buf && - !iocur_top->dquot_buf) { + iocur_top->typ->crc_off ==TYP_F_NO_CRC_OFF ) {dbprintf (_ ("Cannot recalculate CRCs on this type of object\n" ));return 0 ; }@@ -167,12 +165,6 @@ write_f(if (corrupt) { local_ops.verify_write = xfs_dummy_verify;dbprintf (_ ("Allowing write of corrupted data and bad CRC\n" )); - }else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; -dbprintf (_ ("Allowing write of corrupted inode with good CRC\n" )); - }else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; -dbprintf (_ ("Allowing write of corrupted dquot with good CRC\n" )); }else if (iocur_top->typ->crc_off ==TYP_F_CRC_FUNC ) { local_ops.verify_write = iocur_top->typ->set_crc;dbprintf (_ ("Allowing write of corrupted data with good CRC\n" )); --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 9/7] xfs_db: btdump should avoid eval for push and pop of cursor
In reply to Darrick J. WongWe can call the cursor push and pop functions directly from btdump, so skip all the eval overhead.
--- db/btdump.c | 50 +++++++++++++++----------------------------------- db/io.c | 22 ++++++++++++++-------- db/io.h | 1 + 3 files changed, 30 insertions(+), 43 deletions(-)
db/btdump.c +15 -35
@@ -82,11 +82,9 @@ dump_btlevel(xfs_daddr_t orig_daddr = iocur_top->bb;xfs_daddr_t last_daddr;unsigned int nr; -int ret; +int ret =0 ; - ret =eval ("push" ); -if (ret) -return ret; +push_cur_and_set_type (); nr =1 ; do {
@@ -111,10 +109,8 @@ dump_btlevel( nr++; }while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); - ret =eval ("pop" ); -return ret; err: -eval ("pop" ); +pop_cur ();return ret; }
@@ -126,11 +122,9 @@ dump_btree(xfs_daddr_t orig_daddr = iocur_top->bb;xfs_daddr_t last_daddr;int level; -int ret; +int ret =0 ; - ret =eval ("push" ); -if (ret) -return ret; +push_cur_and_set_type (); cur_agno =XFS_FSB_TO_AGNO (mp,XFS_DADDR_TO_FSB (mp, iocur_top->bb)); level =xfs_btree_get_level (iocur_top->data);
@@ -153,10 +147,8 @@ dump_btree( iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); - ret =eval ("pop" ); -return ret; err: -eval ("pop" ); +pop_cur ();return ret; }
@@ -177,7 +169,7 @@ dump_inode( {char *prefix;struct xfs_dinode *dip; -int ret; +int ret =0 ;if (attrfork) prefix ="a.bmbt" ;
@@ -201,9 +193,7 @@ dump_inode( } } - ret =eval ("push" ); -if (ret) -return ret; +push_cur_and_set_type ();if (dump_node_blocks) { ret =eval ("print %s.keys" , prefix);
@@ -222,10 +212,8 @@ dump_inode(if (ret) goto err; - ret =eval ("pop" ); -return ret; err: -eval ("pop" ); +pop_cur ();return ret; }
@@ -397,11 +385,9 @@ dump_dablevel(xfs_daddr_t orig_daddr = iocur_top->bb;xfs_daddr_t last_daddr;unsigned int nr; -int ret; +int ret =0 ; - ret =eval ("push" ); -if (ret) -return ret; +push_cur_and_set_type (); nr =1 ; do {
@@ -421,10 +407,8 @@ dump_dablevel( nr++; }while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); - ret =eval ("pop" ); -return ret; err: -eval ("pop" ); +pop_cur ();return ret; }
@@ -436,11 +420,9 @@ dump_dabtree(xfs_daddr_t orig_daddr = iocur_top->bb;xfs_daddr_t last_daddr;int level; -int ret; +int ret =0 ; - ret =eval ("push" ); -if (ret) -return ret; +push_cur_and_set_type (); cur_agno =XFS_FSB_TO_AGNO (mp,XFS_DADDR_TO_FSB (mp, iocur_top->bb)); level = dbp->level (iocur_top->data);
@@ -468,10 +450,8 @@ dump_dabtree( iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr); - ret =eval ("pop" ); -return ret; err: -eval ("pop" ); +pop_cur ();return ret; }
db/io.c +14 -8
@@ -220,6 +220,19 @@ push_cur(void) cur_typ =NULL ; } +void +push_cur_and_set_type (void ) +{ +/* save current state */ +push_cur (); +if (iocur_top[-1 ].typ && iocur_top[-1 ].typ->typnm ==TYP_INODE ) +set_cur_inode (iocur_top[-1 ].ino); +else +set_cur (iocur_top[-1 ].typ, iocur_top[-1 ].bb, + iocur_top[-1 ].blen,DB_RING_IGN , + iocur_top[-1 ].bbmap); +} + static int push_f( int argc,
@@ -240,14 +253,7 @@ push_f( } } -/* save current state */ -push_cur (); -if (iocur_top[-1 ].typ && iocur_top[-1 ].typ->typnm ==TYP_INODE ) -set_cur_inode (iocur_top[-1 ].ino); -else -set_cur (iocur_top[-1 ].typ, iocur_top[-1 ].bb, - iocur_top[-1 ].blen,DB_RING_IGN , - iocur_top[-1 ].bbmap); +push_cur_and_set_type ();/* run requested command */ if (argc>1 )
db/io.h +1 -0
@@ -57,6 +57,7 @@ extern void off_cur(int off, int len);extern void pop_cur (void );extern void print_iocur (char *tag,iocur_t *ioc);extern void push_cur (void ); +extern void push_cur_and_set_type (void );extern int read_buf (int64_t daddr,int count,void *bufp);extern void write_cur (void ); extern void set_cur(const struct typ *type, xfs_daddr_t blknum,
Eric Sandeen
Reviewed-byRe: [PATCH 9/7] xfs_db: btdump should avoid eval for push and pop of cursor
Quoted 4 lines · Darrick J. Wong
We can call the cursor push and pop functions directly from btdump, so skip all the eval overhead.
Signed-off-by Darrick J. Wong <[email protected]>
Thanks.