xfsprogs: CRC support
cover xfsprogs: CRC support
Hi folks,
This is the latest update of the series of patches tht introduces CRC support into xfsprogs. Of note, for CRC enabled filesystems;
- write support for xfs-db is disabled
- obfuscation for metadump is disabled
- xfs_check does nothing ("always succeed") so that xfstests can run without needing this
- all structures shoul dbe supported for printing in xfs_db
- xfs_repair should be able to fully validate the structure of a CRC enabled filesystem.
- xfs_repair still ignores CRC validation errors when reading metadata
- mkfs.xfs enforces limitations on the format of CRC enabled filesystems (inode size, attr format, projid32bit, etc).
- whenever a v5 superblock is parsed on read by any utility, it outputs a wanring about it being an experimental format.
Bug reports, patches, comments, reviews, etc all welcome.
Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/48 mkfs: fix realtime device initialisation
From: Dave Chinner <[email protected]>
The method that libxfs uses for logging inodes is not followed by rtinit(). It fails to join the realtime bitmap inode to the final extent free transactions, and so mkfs.xfs dies when trying to log changes to the bitmap inode. Fix it.
--- mkfs/proto.c | 2 ++ 1 file changed, 2 insertions(+)
mkfs/proto.c +2 -0
@@ -733,6 +733,8 @@ rtinit( tp =libxfs_trans_alloc (mp,0 );if ((i =libxfs_trans_reserve (tp,0 ,0 ,0 ,0 ,0 )))res_failed (i); +libxfs_trans_ijoin (tp, rbmip,0 ); +libxfs_trans_ihold (tp, rbmip);xfs_bmap_init (&flist, &first); ebno =XFS_RTMIN (mp->m_sb.sb_rextents, bno +NBBY * mp->m_sb.sb_blocksize);
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/48 logprint: fix wrapped log dump issue.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
When running xfs/295 on a 512 byte block size filesystem, logprint fails during checking with a "Bad log record header" error. This is due to the fact that the log has wrapped and there is partial record a the start of the log.
logprint doesn't check for this condition, and simply assumes that the first block in the log contains a log header, and hence aborts when this case occurs. So we now have a spurious test failure due to logprint displaying how right this comment is:
/*
* This code is gross and needs to be rewritten.
*/
--- logprint/log_misc.c | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-)
logprint/log_misc.c +32 -17
@@ -833,7 +833,8 @@ xlog_print_record(int fd,int *read_type, xfs_caddr_t *partial_buf, xlog_rec_header_t *rhead, - xlog_rec_ext_header_t *xhdrs) + xlog_rec_ext_header_t *xhdrs, + int bad_hdr_warn) { xfs_caddr_t buf, ptr;int read_len, skip;
@@ -1006,11 +1007,17 @@ xlog_print_record(int fd,break ; }default : { -fprintf (stderr,_ ("%s: unknown log operation type (%x)\n" ), - progname, *(unsigned short *)ptr); -if (print_exit) { -free (buf); -return BAD_HEADER ; +if (bad_hdr_warn) { +fprintf (stderr, +_ ("%s: unknown log operation type (%x)\n" ), + progname, *(unsigned short *)ptr); +if (print_exit) { +free (buf); +return BAD_HEADER ; + } + }else { +printf ( +_ ("Left over region from split log item\n" )); } skip =0 ; ptr +=be32_to_cpu (op_head->oh_len);
@@ -1028,7 +1035,7 @@ xlog_print_record(int fd,int -xlog_print_rec_head (xlog_rec_header_t *head,int *len) +xlog_print_rec_head (xlog_rec_header_t *head,int *len,int bad_hdr_warn) {int i;char uub[64 ];
@@ -1041,9 +1048,10 @@ xlog_print_rec_head(xlog_rec_header_t *head, int *len)return ZEROED_LOG ;if (be32_to_cpu (head->h_magicno) !=XLOG_HEADER_MAGIC_NUM ) { -printf (_ ("Header 0x%x wanted 0x%x\n" ), -be32_to_cpu (head->h_magicno), -XLOG_HEADER_MAGIC_NUM ); +if (bad_hdr_warn) +printf (_ ("Header 0x%x wanted 0x%x\n" ), +be32_to_cpu (head->h_magicno), +XLOG_HEADER_MAGIC_NUM );return BAD_HEADER ; }
@@ -1269,8 +1277,9 @@ void xfs_log_print(struct xlog *log,xfs_daddr_t zeroed_blkno =0 , cleared_blkno =0 ;int read_type =FULL_READ ;xfs_caddr_t partial_buf; -int zeroed =0 ; -int cleared =0 ; +int zeroed =0 ; +int cleared =0 ; +int first_hdr_found =0 ; logBBsize = log->l_logBBsize;
@@ -1302,7 +1311,7 @@ void xfs_log_print(struct xlog *log, blkno++; goto loop; } - num_ops =xlog_print_rec_head (hdr, &len); + num_ops =xlog_print_rec_head (hdr, &len, first_hdr_found); blkno++;if (zeroed && num_ops !=ZEROED_LOG ) {
@@ -1328,7 +1337,10 @@ void xfs_log_print(struct xlog *log, cleared_blkno = blkno-1 ; cleared++; }else { -print_xlog_bad_header (blkno-1 , hbuf); +if (!first_hdr_found) + block_start = blkno; +else +print_xlog_bad_header (blkno-1 , hbuf); } goto loop;
@@ -1339,7 +1351,9 @@ void xfs_log_print(struct xlog *log,break ; } - error =xlog_print_record (fd, num_ops, len, &read_type, &partial_buf, hdr, xhdrs); + error =xlog_print_record (fd, num_ops, len, &read_type, &partial_buf, + hdr, xhdrs, first_hdr_found); + first_hdr_found++;switch (error) {case 0 : { blkno +=BTOBB (len);
@@ -1415,7 +1429,7 @@ loop: blkno++; goto loop2; } - num_ops =xlog_print_rec_head (hdr, &len); + num_ops =xlog_print_rec_head (hdr, &len, first_hdr_found); blkno++; if (num_ops == ZEROED_LOG ||
@@ -1444,7 +1458,8 @@ partial_log_read: &read_type, &partial_buf, (xlog_rec_header_t *)hbuf, - xhdrs); + xhdrs, + first_hdr_found);if (read_type !=FULL_READ ) len -= read_type; read_type =FULL_READ ;
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 02/48] logprint: fix wrapped log dump issue.
Quoted 36 lines · Dave Chinner
From: Dave Chinner <[email protected]>
When running xfs/295 on a 512 byte block size filesystem, logprint fails during checking with a "Bad log record header" error. This is due to the fact that the log has wrapped and there is partial record a the start of the log.
logprint doesn't check for this condition, and simply assumes that the first block in the log contains a log header, and hence aborts when this case occurs. So we now have a spurious test failure due to logprint displaying how right this comment is:
/*
* This code is gross and needs to be rewritten.
*/Signed-off-by Dave Chinner <[email protected]>--- logprint/log_misc.c | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-)logprint/log_misc.c +2
-1@@ -833,7 +833,8 @@ xlog_print_record(int fd,int *read_type, xfs_caddr_t *partial_buf, xlog_rec_header_t *rhead, - xlog_rec_ext_header_t *xhdrs) + xlog_rec_ext_header_t *xhdrs, + int bad_hdr_warn) { xfs_caddr_t buf, ptr;int read_len, skip;
logprint/log_misc.c xlog_print_record(int fd, · line 1010
Quoted 9 lines
logprint/log_misc.c +1
-5@@ -1006,11 +1007,17 @@ xlog_print_record(int fd,break ; }default : { -fprintf (stderr,_ ("%s: unknown log operation type (%x)\n" ), - progname, *(unsigned short *)ptr); -if (print_exit) { -free (buf); -return BAD_HEADER ; +if (bad_hdr_warn) {
^ Added a space.
Applied to the master branch.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/48 libxfs: add crc format changes to generic btrees
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- include/libxfs.h | 15 +-- include/xfs_alloc_btree.h | 13 ++- include/xfs_bmap_btree.h | 20 ++-- include/xfs_btree.h | 60 +++++++++-- include/xfs_buf_item.h | 24 ++++- include/xfs_dinode.h | 4 +- include/xfs_ialloc_btree.h | 10 +- include/xfs_trans.h | 2 + libxfs/rdwr.c | 24 ++--- libxfs/xfs.h | 4 + libxfs/xfs_alloc_btree.c | 99 +++++++++++------ libxfs/xfs_attr_leaf.c | 2 +- libxfs/xfs_bmap.c | 49 ++++++--- libxfs/xfs_bmap_btree.c | 107 ++++++++++++------ libxfs/xfs_btree.c | 257 ++++++++++++++++++++++++++++++++++++-------- libxfs/xfs_ialloc_btree.c | 80 +++++++++----- libxfs/xfs_inode.c | 33 +++--- libxfs/xfs_mount.c | 2 +- mdrestore/Makefile | 2 +- 19 files changed, 587 insertions(+), 220 deletions(-)
include/libxfs.h +9 -6
@@ -240,14 +240,14 @@ struct xfs_buf_ops { typedef struct xfs_buf { struct cache_node b_node; unsigned int b_flags; - xfs_daddr_t b_blkno; + xfs_daddr_t b_bn; unsigned b_bcount; unsigned int b_length; dev_t b_dev; pthread_mutex_t b_lock; pthread_t b_holder; unsigned int b_recur; - void *b_fsprivate; + void *b_fspriv; void *b_fsprivate2; void *b_fsprivate3; void *b_addr;
@@ -273,9 +273,11 @@ enum xfs_buf_flags_t { /* b_flags bits */ LIBXFS_B_DISCONTIG = 0x0010, /* discontiguous buffer */ }; +#define XFS_BUF_DADDR_NULL ((xfs_daddr_t) (-1LL)) +#define XFS_BUF_PTR (bp) ((char *)(bp)->b_addr)#define xfs_buf_offset (bp, offset) (XFS_BUF_PTR(bp) + (offset)) -#define XFS_BUF_ADDR (bp) ((bp)->b_blkno) +#define XFS_BUF_ADDR (bp) ((bp)->b_bn)#define XFS_BUF_SIZE (bp) ((bp)->b_bcount)#define XFS_BUF_COUNT (bp) ((bp)->b_bcount)#define XFS_BUF_TARGET (bp) ((bp)->b_dev)
@@ -284,11 +286,11 @@ enum xfs_buf_flags_t { /* b_flags bits */XFS_BUF_SET_COUNT (bp,cnt); \ }) -#define XFS_BUF_SET_ADDR (bp,blk) ((bp)->b_blkno = (blk)) +#define XFS_BUF_SET_ADDR (bp,blk) ((bp)->b_bn = (blk))#define XFS_BUF_SET_COUNT (bp,cnt) ((bp)->b_bcount = (cnt)) -#define XFS_BUF_FSPRIVATE (bp,type) ((type)(bp)->b_fsprivate) -#define XFS_BUF_SET_FSPRIVATE (bp,val) (bp)->b_fsprivate = (void *)(val) +#define XFS_BUF_FSPRIVATE (bp,type) ((type)(bp)->b_fspriv) +#define XFS_BUF_SET_FSPRIVATE (bp,val) (bp)->b_fspriv = (void *)(val)#define XFS_BUF_FSPRIVATE2 (bp,type) ((type)(bp)->b_fsprivate2)#define XFS_BUF_SET_FSPRIVATE2 (bp,val) (bp)->b_fsprivate2 = (void *)(val)#define XFS_BUF_FSPRIVATE3 (bp,type) ((type)(bp)->b_fsprivate3)
@@ -392,6 +394,7 @@ typedef struct xfs_log_item {struct xfs_log_item_desc *li_desc;/* ptr to current desc*/ struct xfs_mount *li_mountp;/* ptr to fs mount */ uint li_type;/* item type */ +xfs_lsn_t li_lsn; } xfs_log_item_t; typedef struct xfs_inode_log_item {
include/xfs_alloc_btree.h +8 -5
@@ -31,8 +31,10 @@ struct xfs_mount;* by blockcount and blockno. All blocks look the same to make the code * simpler; if we have time later, we'll make the optimizations. */ -#define XFS_ABTB_MAGIC 0x41425442/* 'ABTB' for bno tree */ -#define XFS_ABTC_MAGIC 0x41425443/* 'ABTC' for cnt tree */ +#define XFS_ABTB_MAGIC 0x41425442/* 'ABTB' for bno tree */ +#define XFS_ABTB_CRC_MAGIC 0x41423342/* 'AB3B' */ +#define XFS_ABTC_MAGIC 0x41425443/* 'ABTC' for cnt tree */ +#define XFS_ABTC_CRC_MAGIC 0x41423343/* 'AB3C' */ /* * Data record/key structure
@@ -59,10 +61,11 @@ typedef __be32 xfs_alloc_ptr_t;/* * Btree block header size depends on a superblock flag. -* -* (not quite yet, but soon) */ -#define XFS_ALLOC_BLOCK_LEN (mp) XFS_BTREE_SBLOCK_LEN +#define XFS_ALLOC_BLOCK_LEN (mp) \ + (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ + XFS_BTREE_SBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD : \ + XFS_BTREE_SBLOCK_LEN)/* * Record, key, and pointer address macros for btree blocks.
include/xfs_bmap_btree.h +11 -9
@@ -18,7 +18,8 @@#ifndef __XFS_BMAP_BTREE_H__#define __XFS_BMAP_BTREE_H__ -#define XFS_BMAP_MAGIC 0x424d4150/* 'BMAP' */ +#define XFS_BMAP_MAGIC 0x424d4150/* 'BMAP' */ +#define XFS_BMAP_CRC_MAGIC 0x424d4133/* 'BMA3' */ struct xfs_btree_cur ;struct xfs_btree_block ;
@@ -136,10 +137,11 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t;/* * Btree block header size depends on a superblock flag. -* -* (not quite yet, but soon) */ -#define XFS_BMBT_BLOCK_LEN (mp) XFS_BTREE_LBLOCK_LEN +#define XFS_BMBT_BLOCK_LEN (mp) \ + (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ + XFS_BTREE_LBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD : \ + XFS_BTREE_LBLOCK_LEN)#define XFS_BMBT_REC_ADDR (mp, block, index) \ ((xfs_bmbt_rec_t *) \
@@ -186,12 +188,12 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t;#define XFS_BMAP_BROOT_PTR_ADDR (mp, bb, i, sz) \ XFS_BMBT_PTR_ADDR(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, 0)) -#define XFS_BMAP_BROOT_SPACE_CALC (nrecs) \ - (int)(XFS_BTREE_LBLOCK_LEN + \ +#define XFS_BMAP_BROOT_SPACE_CALC (mp, nrecs) \ + (int)(XFS_BMBT_BLOCK_LEN(mp) + \ ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))) -#define XFS_BMAP_BROOT_SPACE (bb) \ - (XFS_BMAP_BROOT_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs))) +#define XFS_BMAP_BROOT_SPACE (mp, bb) \ + (XFS_BMAP_BROOT_SPACE_CALC(mp, be16_to_cpu((bb)->bb_numrecs)))#define XFS_BMDR_SPACE_CALC (nrecs) \ (int)(sizeof(xfs_bmdr_block_t) + \ ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
@@ -204,7 +206,7 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t;/* * Prototypes for xfs_bmap.c to call. */ -extern void xfs_bmdr_to_bmbt (struct xfs_mount *,xfs_bmdr_block_t *,int , +extern void xfs_bmdr_to_bmbt (struct xfs_inode *,xfs_bmdr_block_t *,int ,struct xfs_btree_block *,int );extern void xfs_bmbt_get_all (xfs_bmbt_rec_host_t *r,xfs_bmbt_irec_t *s);extern xfs_filblks_t xfs_bmbt_get_blockcount (xfs_bmbt_rec_host_t *r);
include/xfs_btree.h +51 -9
111 lines not on this page · raw message
include/xfs_buf_item.h +19 -5
@@ -24,19 +24,33 @@ extern kmem_zone_t *xfs_buf_item_zone;* This flag indicates that the buffer contains on disk inodes * and requires special recovery handling. */ -#define XFS_BLF_INODE_BUF 0x1 +#define XFS_BLF_INODE_BUF (1<<0)/* * This flag indicates that the buffer should not be replayed * during recovery because its blocks are being freed. */ -#define XFS_BLF_CANCEL 0x2 +#define XFS_BLF_CANCEL (1<<1) +/* * This flag indicates that the buffer contains on disk * user or group dquots and may require special recovery handling. */ -#define XFS_BLF_UDQUOT_BUF 0x4 -#define XFS_BLF_PDQUOT_BUF 0x8 -#define XFS_BLF_GDQUOT_BUF 0x10 +#define XFS_BLF_UDQUOT_BUF (1<<2) +#define XFS_BLF_PDQUOT_BUF (1<<3) +#define XFS_BLF_GDQUOT_BUF (1<<4) + +/* +* all buffers now need flags to tell recovery where the magic number +* is so that it can verify and calculate the CRCs on the buffer correctly +* once the changes have been replayed into the buffer. +*/ +#define XFS_BLF_BTREE_BUF (1<<5) + +#define XFS_BLF_TYPE_MASK \ + (XFS_BLF_UDQUOT_BUF | \ + XFS_BLF_PDQUOT_BUF | \ + XFS_BLF_GDQUOT_BUF | \ + XFS_BLF_BTREE_BUF)#define XFS_BLF_CHUNK 128#define XFS_BLF_SHIFT 7
include/xfs_dinode.h +2 -2
@@ -107,8 +107,8 @@ typedef enum xfs_dinode_fmt {#define XFS_LITINO (mp, version) \ ((int)(((mp)->m_sb.sb_inodesize) - sizeof(struct xfs_dinode))) -#define XFS_BROOT_SIZE_ADJ \ - (XFS_BTREE_LBLOCK_LEN - sizeof(xfs_bmdr_block_t)) +#define XFS_BROOT_SIZE_ADJ (ip) \ + (XFS_BMBT_BLOCK_LEN((ip)->i_mount) - sizeof(xfs_bmdr_block_t))/* * Inode data & attribute fork sizes, per inode.
include/xfs_ialloc_btree.h +6 -4
@@ -29,7 +29,8 @@ struct xfs_mount;/* * There is a btree for the inode map per allocation group. */ -#define XFS_IBT_MAGIC 0x49414254/* 'IABT' */ +#define XFS_IBT_MAGIC 0x49414254/* 'IABT' */ +#define XFS_IBT_CRC_MAGIC 0x49414233/* 'IAB3' */ typedef __uint64_t xfs_inofree_t ;#define XFS_INODES_PER_CHUNK (NBBY * sizeof(xfs_inofree_t))
@@ -76,10 +77,11 @@ typedef __be32 xfs_inobt_ptr_t;/* * Btree block header size depends on a superblock flag. -* -* (not quite yet, but soon) */ -#define XFS_INOBT_BLOCK_LEN (mp) XFS_BTREE_SBLOCK_LEN +#define XFS_INOBT_BLOCK_LEN (mp) \ + (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ + XFS_BTREE_SBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD : \ + XFS_BTREE_SBLOCK_LEN)/* * Record, key, and pointer address macros for btree blocks.
include/xfs_trans.h +2 -0
@@ -500,6 +500,8 @@ void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *);void xfs_trans_stale_inode_buf (xfs_trans_t *,struct xfs_buf *);void xfs_trans_dquot_buf (xfs_trans_t *,struct xfs_buf *,uint );void xfs_trans_inode_alloc_buf (xfs_trans_t *,struct xfs_buf *); +void xfs_trans_buf_set_type (struct xfs_trans *,struct xfs_buf *, +uint );void xfs_trans_ichgtime (struct xfs_trans *,struct xfs_inode *,int );void xfs_trans_ijoin (struct xfs_trans *,struct xfs_inode *,uint );void xfs_trans_log_buf (xfs_trans_t *,struct xfs_buf *,uint ,uint );
libxfs/rdwr.c +12 -12
@@ -323,17 +323,17 @@ libxfs_bcompare(struct cache_node *node, cache_key_t key)#ifdef IO_BCOMPARE_CHECK if (bp->b_dev == bkey->device && - bp->b_blkno == bkey->blkno && + bp->b_bn == bkey->blkno && bp->b_bcount !=BBTOB (bkey->bblen))fprintf (stderr,"%lx: Badness in key lookup (length)\n" "bp=(bno 0x%llx, len %u bytes) key=(bno 0x%llx, len %u bytes)\n" ,pthread_self (), - (unsigned long long )bp->b_blkno, (int )bp->b_bcount, + (unsigned long long )bp->b_bn, (int )bp->b_bcount, (unsigned long long )bkey->blkno,BBTOB (bkey->bblen));#endif return (bp->b_dev == bkey->device && - bp->b_blkno == bkey->blkno && + bp->b_bn == bkey->blkno && bp->b_bcount ==BBTOB (bkey->bblen)); }
@@ -341,7 +341,7 @@ void libxfs_bprint(xfs_buf_t *bp) {fprintf (stderr,"Buffer 0x%p blkno=%llu bytes=%u flags=0x%x count=%u\n" , - bp, (unsigned long long )bp->b_blkno, (unsigned )bp->b_bcount, + bp, (unsigned long long )bp->b_bn, (unsigned )bp->b_bcount, bp->b_flags, bp->b_node.cn_count); }
@@ -349,7 +349,7 @@ static void __initbuf(xfs_buf_t *bp, dev_t device, xfs_daddr_t bno, unsigned int bytes) { bp->b_flags =0 ; - bp->b_blkno = bno; + bp->b_bn = bno; bp->b_bcount = bytes; bp->b_length =BTOBB (bytes); bp->b_dev = device;
@@ -613,7 +613,7 @@ libxfs_purgebuf(xfs_buf_t *bp)struct xfs_bufkey key = {0 }; key.device = bp->b_dev; - key.blkno = bp->b_blkno; + key.blkno = bp->b_bn; key.bblen = bp->b_bcount >>BBSHIFT ;cache_node_purge (libxfs_bcache, &key, (struct cache_node *)bp);
@@ -669,7 +669,7 @@ libxfs_readbufr(dev_t dev, xfs_daddr_t blkno, xfs_buf_t *bp, int len, int flags) error =__read_buf (fd, bp->b_addr, bytes,LIBXFS_BBTOOFF64 (blkno), flags);if (!error && bp->b_dev == dev && - bp->b_blkno == blkno && + bp->b_bn == blkno && bp->b_bcount == bytes) bp->b_flags |=LIBXFS_B_UPTODATE ;#ifdef IO_DEBUG
@@ -736,7 +736,7 @@ libxfs_readbuf_map(dev_t dev, struct xfs_buf_map *map, int nmaps, int flags)#ifdef IO_DEBUG printf ("%lx: %s: read %lu bytes, error %d, blkno=%llu(%llu), %p\n" ,pthread_self (), __FUNCTION__, buf - (char *)bp->b_addr, error, - (long long )LIBXFS_BBTOOFF64 (bp->b_blkno), (long long )bp->b_blkno, bp); + (long long )LIBXFS_BBTOOFF64 (bp->b_bn), (long long )bp->b_bn, bp);#endif return bp; }
@@ -772,7 +772,7 @@ libxfs_writebufr(xfs_buf_t *bp)if (!(bp->b_flags &LIBXFS_B_DISCONTIG )) { error =__write_buf (fd, bp->b_addr, bp->b_bcount, -LIBXFS_BBTOOFF64 (bp->b_blkno), bp->b_flags); +LIBXFS_BBTOOFF64 (bp->b_bn), bp->b_flags); }else {int i;char *buf = bp->b_addr;
@@ -794,8 +794,8 @@ libxfs_writebufr(xfs_buf_t *bp)#ifdef IO_DEBUG printf ("%lx: %s: wrote %u bytes, blkno=%llu(%llu), %p\n" ,pthread_self (), __FUNCTION__, bp->b_bcount, - (long long )LIBXFS_BBTOOFF64 (bp->b_blkno), - (long long )bp->b_blkno, bp); + (long long )LIBXFS_BBTOOFF64 (bp->b_bn), + (long long )bp->b_bn, bp);#endif if (!error) { bp->b_flags |=LIBXFS_B_UPTODATE ;
@@ -826,7 +826,7 @@ libxfs_iomove(xfs_buf_t *bp, uint boff, int len, void *data, int flags)if (boff + len > bp->b_bcount) {printf ("Badness, iomove out of range!\n" "bp=(bno 0x%llx, bytes %u) range=(boff %u, bytes %u)\n" , - (long long )bp->b_blkno, bp->b_bcount, boff, len); + (long long )bp->b_bn, bp->b_bcount, boff, len);abort (); }#endif
libxfs/xfs.h +4 -0
@@ -249,6 +249,7 @@ roundup_pow_of_two(uint v)#define xfs_trans_agblocks_delta (tp, d)#define xfs_trans_agflist_delta (tp, d)#define xfs_trans_agbtree_delta (tp, d) +#define xfs_trans_buf_set_type (tp, bp, t)#define xfs_buf_readahead (a,b,c,ops) ((void) 0)/* no readahead */ #define xfs_buf_readahead_map (a,b,c,ops) ((void) 0)/* no readahead */
@@ -314,6 +315,9 @@ do { \#define xfs_trans_unreserve_quota_nblks (t,i,b,n,f) ((void) 0)#define xfs_qm_dqattach (i,f) (0) +#define uuid_copy (s,d) platform_uuid_copy((s),(d)) +#define uuid_equal (s,d) (platform_uuid_compare((s),(d)) == 0) +/* * Prototypes for kernel static functions that are aren't in their * associated header files
libxfs/xfs_alloc_btree.c +67 -32
146 lines not on this page · raw message
libxfs/xfs_attr_leaf.c +1 -1
@@ -201,7 +201,7 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)return 0 ;return dp->i_d.di_forkoff; } - dsize =XFS_BMAP_BROOT_SPACE (dp->i_df.if_broot); + dsize =XFS_BMAP_BROOT_SPACE (mp, dp->i_df.if_broot);break ; }
libxfs/xfs_bmap.c +32 -17
121 lines not on this page · raw message
libxfs/xfs_bmap_btree.c +76 -31
171 lines not on this page · raw message
libxfs/xfs_btree.c +212 -45
404 lines not on this page · raw message
libxfs/xfs_ialloc_btree.c +56 -24
114 lines not on this page · raw message
libxfs/xfs_inode.c +17 -16
@@ -492,6 +492,7 @@ xfs_iformat_btree( xfs_dinode_t *dip, int whichfork) { +struct xfs_mount *mp = ip->i_mount;xfs_bmdr_block_t *dfp;xfs_ifork_t *ifp;/* REFERENCED */
@@ -500,7 +501,7 @@ xfs_iformat_btree( ifp =XFS_IFORK_PTR (ip, whichfork); dfp = (xfs_bmdr_block_t *)XFS_DFORK_PTR (dip, whichfork); - size =XFS_BMAP_BROOT_SPACE (dfp); + size =XFS_BMAP_BROOT_SPACE (mp, dfp); nrecs =be16_to_cpu (dfp->bb_numrecs);/*
@@ -511,14 +512,14 @@ xfs_iformat_btree(* blocks. */ if (unlikely (XFS_IFORK_NEXTENTS (ip, whichfork) <= -XFS_IFORK_MAXEXT (ip, whichfork) || +XFS_IFORK_MAXEXT (ip, whichfork) ||XFS_BMDR_SPACE_CALC (nrecs) > -XFS_DFORK_SIZE (dip, ip->i_mount, whichfork) || +XFS_DFORK_SIZE (dip, mp, whichfork) ||XFS_IFORK_NEXTENTS (ip, whichfork) > ip->i_d.di_nblocks)) { -xfs_warn (ip->i_mount,"corrupt inode %Lu (btree)." , - (unsigned long long ) ip->i_ino); +xfs_warn (mp,"corrupt inode %Lu (btree)." , + (unsigned long long ) ip->i_ino);XFS_CORRUPTION_ERROR ("xfs_iformat_btree" ,XFS_ERRLEVEL_LOW , - ip->i_mount, dip); + mp, dip);return XFS_ERROR (EFSCORRUPTED ); }
@@ -529,8 +530,7 @@ xfs_iformat_btree(* Copy and convert from the on-disk structure * to the in-memory structure. */ -xfs_bmdr_to_bmbt (ip->i_mount, dfp, -XFS_DFORK_SIZE (dip, ip->i_mount, whichfork), +xfs_bmdr_to_bmbt (ip, dfp,XFS_DFORK_SIZE (dip, ip->i_mount, whichfork), ifp->if_broot, size); ifp->if_flags &= ~XFS_IFEXTENTS ; ifp->if_flags |=XFS_IFBROOT ;
@@ -813,7 +813,7 @@ xfs_iroot_realloc(* allocate it now and get out. */ if (ifp->if_broot_bytes ==0 ) { - new_size = (size_t )XFS_BMAP_BROOT_SPACE_CALC (rec_diff); + new_size =XFS_BMAP_BROOT_SPACE_CALC (mp, rec_diff); ifp->if_broot =kmem_alloc (new_size,KM_SLEEP |KM_NOFS ); ifp->if_broot_bytes = (int )new_size;return ;
@@ -827,9 +827,9 @@ xfs_iroot_realloc(*/ cur_max =xfs_bmbt_maxrecs (mp, ifp->if_broot_bytes,0 ); new_max = cur_max + rec_diff; - new_size = (size_t )XFS_BMAP_BROOT_SPACE_CALC (new_max); + new_size =XFS_BMAP_BROOT_SPACE_CALC (mp, new_max); ifp->if_broot =kmem_realloc (ifp->if_broot, new_size, - (size_t )XFS_BMAP_BROOT_SPACE_CALC (cur_max),/* old size */ +XFS_BMAP_BROOT_SPACE_CALC (mp, cur_max),KM_SLEEP |KM_NOFS ); op = (char *)XFS_BMAP_BROOT_PTR_ADDR (mp, ifp->if_broot,1 , ifp->if_broot_bytes);
@@ -837,7 +837,7 @@ xfs_iroot_realloc( (int)new_size); ifp->if_broot_bytes = (int )new_size;ASSERT (ifp->if_broot_bytes <= -XFS_IFORK_SIZE (ip, whichfork) +XFS_BROOT_SIZE_ADJ ); +XFS_IFORK_SIZE (ip, whichfork) +XFS_BROOT_SIZE_ADJ (ip));memmove (np, op, cur_max * (uint )sizeof (xfs_dfsbno_t));return ; }
@@ -852,7 +852,7 @@ xfs_iroot_realloc( new_max = cur_max + rec_diff;ASSERT (new_max >=0 );if (new_max >0 ) - new_size = (size_t )XFS_BMAP_BROOT_SPACE_CALC (new_max); + new_size =XFS_BMAP_BROOT_SPACE_CALC (mp, new_max);else new_size =0 ;if (new_size >0 ) {
@@ -860,7 +860,8 @@ xfs_iroot_realloc(/* * First copy over the btree block header. */ -memcpy (new_broot, ifp->if_broot,XFS_BTREE_LBLOCK_LEN ); +memcpy (new_broot, ifp->if_broot, +XFS_BMBT_BLOCK_LEN (ip->i_mount)); }else { new_broot =NULL ; ifp->if_flags &= ~XFS_IFBROOT ;
@@ -890,7 +891,7 @@ xfs_iroot_realloc( ifp->if_broot = new_broot; ifp->if_broot_bytes = (int )new_size;ASSERT (ifp->if_broot_bytes <= -XFS_IFORK_SIZE (ip, whichfork) +XFS_BROOT_SIZE_ADJ ); +XFS_IFORK_SIZE (ip, whichfork) +XFS_BROOT_SIZE_ADJ (ip));return ; }
@@ -1161,7 +1162,7 @@ xfs_iflush_fork(ASSERT (ifp->if_broot !=NULL );ASSERT (ifp->if_broot_bytes <= (XFS_IFORK_SIZE (ip, whichfork) + -XFS_BROOT_SIZE_ADJ )); +XFS_BROOT_SIZE_ADJ (ip)));xfs_bmbt_to_bmdr (mp, ifp->if_broot, ifp->if_broot_bytes, (xfs_bmdr_block_t *)cp,XFS_DFORK_SIZE (dip, mp, whichfork));
libxfs/xfs_mount.c +1 -1
@@ -333,7 +333,7 @@ xfs_sb_verify(* Only check the in progress field for the primary superblock as * mkfs.xfs doesn't clear it from secondary superblocks. */ - error =xfs_mount_validate_sb (mp, &sb, bp->b_blkno ==XFS_SB_DADDR ); + error =xfs_mount_validate_sb (mp, &sb, bp->b_bn ==XFS_SB_DADDR );if (error)xfs_buf_ioerror (bp, error); }
mdrestore/Makefile +1 -1
@@ -8,7 +8,7 @@ include $(TOPDIR)/include/builddefs LTCOMMAND = xfs_mdrestore CFILES = xfs_mdrestore.c -LLDLIBS = $(LIBXFS) $(LIBRT) $(LIBPTHREAD) +LLDLIBS = $(LIBXFS) $(LIBRT) $(LIBPTHREAD) $(LIBUUID) LTDEPENDENCIES = $(LIBXFS) LLDFLAGS = -static
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 03/48] libxfs: add crc format changes to generic btrees
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
This patch mostly corresponds to commit ee1a47ab0e, and in some areas it is equivalent but slightly different. There are some other things in here too:
* Addition of XFS_BUF_DADDR_NULL
* rename of b_blkno to b_bn in struct xfs_buf
* rename of b_fsprivate to b_fspriv in struct xfs_buf
* addition of uuid_copy and uuid_equal, and libuuid to build
It all looks fine to me, except as below:
libxfs/xfs_bmap_btree.c xfs_bmbt_read_verify( · line 762
Quoted 5 lines
static void
libxfs/xfs_bmap_btree.c +0
-0@@ -733,13 +760,29 @@ xfs_bmbt_read_verify( struct xfs_buf *bp) {xfs_bmbt_verify (bp);
^^^^^^^^^^^^^^^^^^^^
In commit ee1a47ab0e we removed this call.
Quoted 5 lines
libxfs/xfs_bmap_btree.c +5
-0+if (!(xfs_btree_lblock_verify_crc (bp) && +xfs_bmbt_verify (bp))) { +trace_xfs_btree_corrupt (bp, _RET_IP_); +XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , + bp->b_target->bt_mount, bp->b_addr);
libxfs/xfs_bmap_btree.c xfs_bmbt_read_verify( · line 742
Quoted 10 lines
libxfs/xfs_bmap_btree.c +3
-1+xfs_buf_ioerror (bp,EFSCORRUPTED ); + } + }static void xfs_bmbt_write_verify (struct xfs_buf *bp) { -xfs_bmbt_verify (bp);
^^^^^^^^^^^^^^^^^^^^
As we did here
libxfs/xfs_bmap_btree.c xfs_bmbt_read_verify( · line 785
Quoted 9 lines
libxfs/xfs_bmap_btree.c +9
-0+if (!xfs_bmbt_verify (bp)) { +xfs_warn (bp->b_target->bt_mount,"bmbt daddr 0x%llx failed" , bp->b_bn); +trace_xfs_btree_corrupt (bp, _RET_IP_); +XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , + bp->b_target->bt_mount, bp->b_addr); +xfs_buf_ioerror (bp,EFSCORRUPTED ); +return ; + } +xfs_btree_lblock_calc_crc (bp);
Is that addressed later in the series?
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 03/48] libxfs: add crc format changes to generic btrees
Quoted 8 lines · Ben Myers
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>This patch mostly corresponds to commit
ee1a47ab0e, and in some areas it is equivalent but slightly different. There are some other things in here too:
Quoted 6 lines
* Addition of
XFS_BUF_DADDR_NULL
* rename ofb_blknotob_bnin structxfs_buf
* rename ofb_fsprivatetob_fsprivin structxfs_buf
* addition ofuuid_copyanduuid_equal, and libuuid to buildIt all looks fine to me, except as below:
I think you'll find they are fixed up in later patches in the series.
Indeed, I think it's a little late to asking for these patches to be changed, considering that making significant changes to these first few patches will mean that I have to rebase a 100 or so subsequent patches.
For issues that aren't fixed in later patches, I'll add new patches to the end of the current series to fix them.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 03/48] libxfs: add crc format changes to generic btrees
Dave,
Quoted 16 lines · Dave Chinner
Quoted 8 lines · Ben Myers
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>This patch mostly corresponds to commit
ee1a47ab0e, and in some areas it is equivalent but slightly different. There are some other things in here too:Quoted 6 lines
* Addition of
XFS_BUF_DADDR_NULL
* rename ofb_blknotob_bnin structxfs_buf
* rename ofb_fsprivatetob_fsprivin structxfs_buf
* addition ofuuid_copyanduuid_equal, and libuuid to buildIt all looks fine to me, except as below:
Quoted 7 lines
I think you'll find they are fixed up in later patches in the series.
Indeed, I think it's a little late to asking for these patches to be changed, considering that making significant changes to these first few patches will mean that I have to rebase a 100 or so subsequent patches.
You are mistaken...
Quoted 2 lines
For issues that aren't fixed in later patches, I'll add new patches to the end of the current series to fix them.
...but I have no objection to taking this approach, so long as my concerns are addressed.
-Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 03/48] libxfs: add crc format changes to generic btrees
Quoted 22 lines · Ben Myers
Dave,
Quoted 19 lines · Dave Chinner
Quoted 8 lines · Ben Myers
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>This patch mostly corresponds to commit
ee1a47ab0e, and in some areas it is equivalent but slightly different. There are some other things in here too:Quoted 6 lines
* Addition of
XFS_BUF_DADDR_NULL
* rename ofb_blknotob_bnin structxfs_buf
* rename ofb_fsprivatetob_fsprivin structxfs_buf
* addition ofuuid_copyanduuid_equal, and libuuid to buildIt all looks fine to me, except as below:
I think you'll find they are fixed up in later patches in the series.
Quoted 6 lines
Quoted 4 lines
Indeed, I think it's a little late to asking for these patches to be changed, considering that making significant changes to these first few patches will mean that I have to rebase a 100 or so subsequent patches.
You are mistaken...
Mistaken about what, exactly? That a rebase will take days to do and retest, while an additional patch will take minutes?
I don't even have this series set up with guilt anymore - it's been so long since it was committed to the crc-dev branch that I moved over to working on that branch and adding patches on top of it to fix issues. I've simply assumed that this patchset is fixed in concrete and any problems will be layered on top.
People are already using this code, so we've already got a significant amount of test exposure to it. Going back and modifying and completely rebasing it invalidates all that test coverage. Rebasing is not a risk-free operation, and when that is combined with the amount of time needed for a rebase of such a series, I'd much prefer that code that is in the crc-dev tree remains untouched and we layer fixes on top of it...
Quoted 5 lines
Quoted 2 lines
For issues that aren't fixed in later patches, I'll add new patches to the end of the current series to fix them.
...but I have no objection to taking this approach, so long as my concerns are addressed.
Which, for this patch, have already been addressed in subsequent patches....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 03/48] libxfs: add crc format changes to generic btrees
Dave,
Quoted 21 lines · Dave Chinner
Quoted 20 lines · Ben Myers
Quoted 19 lines · Dave Chinner
Quoted 8 lines · Ben Myers
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>This patch mostly corresponds to commit
ee1a47ab0e, and in some areas it is equivalent but slightly different. There are some other things in here too:Quoted 6 lines
* Addition of
XFS_BUF_DADDR_NULL
* rename ofb_blknotob_bnin structxfs_buf
* rename ofb_fsprivatetob_fsprivin structxfs_buf
* addition ofuuid_copyanduuid_equal, and libuuid to buildIt all looks fine to me, except as below:
I think you'll find they are fixed up in later patches in the series.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Indeed, I think it's a little late to asking for these patches to be changed, considering that making significant changes to these first few patches will mean that I have to rebase a 100 or so subsequent patches.
You are mistaken...
Mistaken about what, exactly?
You are mistaken to assume that I will not require changes be made to patches at the beginning of your series regardless of the quantity of work you have on top. Pulling these into crc-dev without review did not imply that these patches are set in concrete.
Having said that, I'm not doing these reviews to make your life difficult. Unless we find something egregious (such as the mismatched commit message in patch 7), I have no objection to taking the approach that minor issues can be fixed at the end of the series.
-Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/1 xfs: don't verify bmbt reads twice
In reply to Ben MyersQuoted 15 lines · Ben Myers
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>This patch mostly corresponds to commit
ee1a47ab0e, and in some areas it is equivalent but slightly different. There are some other things in here too:* Addition of
XFS_BUF_DADDR_NULL
* rename ofb_blknotob_bnin structxfs_buf
* rename ofb_fsprivatetob_fsprivin structxfs_buf
* addition ofuuid_copyanduuid_equal, and libuuid to buildIt all looks fine to me, except as below:
Quoted 7 lines
Review xfs_bmbt_read_verify( · line 762
Quoted 5 lines
static void
(quoted diff) +0
-0@@ -733,13 +760,29 @@ xfs_bmbt_read_verify( struct xfs_buf *bp) { xfs_bmbt_verify(bp);^^^^^^^^^^^^^^^^^^^^In commit
ee1a47ab0ewe removed this call.
From: Ben Myers <[email protected]>
xfs: don't verify bmbt reads twice
xfs_bmbt_read_verify is calling xfs_bmbt_verify twice in a row. commit ee1a47ab0e in the kernel removed the first xfs_bmbt_verify but this was not carried over when it was implemented in userspace.
--- libxfs/xfs_bmap_btree.c | 2 -- 1 file changed, 2 deletions(-)
libxfs/xfs_bmap_btree.c +0 -2
@@ -759,7 +759,6 @@ static voidxfs_bmbt_read_verify ( struct xfs_buf *bp) { -xfs_bmbt_verify (bp);if (!(xfs_btree_lblock_verify_crc (bp) &&xfs_bmbt_verify (bp))) {trace_xfs_btree_corrupt (bp, _RET_IP_);
@@ -767,7 +766,6 @@ xfs_bmbt_read_verify( bp->b_target->bt_mount, bp->b_addr);xfs_buf_ioerror (bp,EFSCORRUPTED ); } - } static void
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 4/48 xfsprogs: add crc format chagnes to ag headers
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- include/xfs_ag.h | 54 ++++++++++++- include/xfs_buf_item.h | 8 +- libxfs/xfs_alloc.c | 197 ++++++++++++++++++++++++++++++++---------------- libxfs/xfs_ialloc.c | 55 ++++++++++---- 4 files changed, 231 insertions(+), 83 deletions(-)
include/xfs_ag.h +51 -3
@@ -30,6 +30,7 @@ struct xfs_trans;#define XFS_AGF_MAGIC 0x58414746/* 'XAGF' */ #define XFS_AGI_MAGIC 0x58414749/* 'XAGI' */ +#define XFS_AGFL_MAGIC 0x5841464c/* 'XAFL' */ #define XFS_AGF_VERSION 1#define XFS_AGI_VERSION 1
@@ -63,12 +64,29 @@ typedef struct xfs_agf {__be32 agf_spare0;/* spare field */ __be32 agf_levels[XFS_BTNUM_AGF ];/* btree levels */ __be32 agf_spare1;/* spare field */ +__be32 agf_flfirst;/* first freelist block's index */ __be32 agf_fllast;/* last freelist block's index */ __be32 agf_flcount;/* count of blocks in freelist */ __be32 agf_freeblks;/* total free blocks */ +__be32 agf_longest;/* longest free space */ __be32 agf_btreeblks;/* # of blocks held in AGF btrees */ +uuid_t agf_uuid;/* uuid of filesystem */ + +/* +* reserve some contiguous space for future logged fields before we add +* the unlogged fields. This makes the range logging via flags and +* structure offsets much simpler. +*/ +__be64 agf_spare64[16 ]; + +/* unlogged fields, written during buffer writeback. */ +__be64 agf_lsn;/* last write sequence */ +__be32 agf_crc;/* crc of agf sector */ +__be32 agf_spare2; + +/* structure must be padded to 64 bit alignment */ } xfs_agf_t;#define XFS_AGF_MAGICNUM 0x00000001
@@ -83,6 +101,7 @@ typedef struct xfs_agf {#define XFS_AGF_FREEBLKS 0x00000200#define XFS_AGF_LONGEST 0x00000400#define XFS_AGF_BTREEBLKS 0x00000800 +#define XFS_AGF_UUID 0x00001000#define XFS_AGF_NUM_BITS 12#define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1)
@@ -98,7 +117,8 @@ typedef struct xfs_agf { { XFS_AGF_FLCOUNT, "FLCOUNT" }, \ { XFS_AGF_FREEBLKS, "FREEBLKS" }, \ { XFS_AGF_LONGEST, "LONGEST" }, \ - { XFS_AGF_BTREEBLKS, "BTREEBLKS" } + { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ + { XFS_AGF_UUID, "UUID" } /* disk block (xfs_daddr_t) in the AG */ #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
@@ -132,6 +152,7 @@ typedef struct xfs_agi {__be32 agi_root;/* root of inode btree */ __be32 agi_level;/* levels in inode btree */ __be32 agi_freecount;/* number of free inodes */ +__be32 agi_newino;/* new inode just allocated */ __be32 agi_dirino;/* last directory inode chunk */ /*
@@ -139,6 +160,13 @@ typedef struct xfs_agi {* still being referenced. */ __be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS ]; + +uuid_t agi_uuid;/* uuid of filesystem */ +__be32 agi_crc;/* crc of agi sector */ +__be32 agi_pad32; +__be64 agi_lsn;/* last write sequence */ + +/* structure must be padded to 64 bit alignment */ } xfs_agi_t;#define XFS_AGI_MAGICNUM 0x00000001
@@ -171,11 +199,31 @@ extern const struct xfs_buf_ops xfs_agi_buf_ops;*/ #define XFS_AGFL_DADDR (mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log))#define XFS_AGFL_BLOCK (mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) -#define XFS_AGFL_SIZE (mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t))#define XFS_BUF_TO_AGFL (bp) ((xfs_agfl_t *)((bp)->b_addr)) +#define XFS_BUF_TO_AGFL_BNO (mp, bp) \ + (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ + &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \ + (__be32 *)(bp)->b_addr) + +/* +* Size of the AGFL. For CRC-enabled filesystes we steal a couple of +* slots in the beginning of the block for a proper header with the +* location information and CRC. +*/ +#define XFS_AGFL_SIZE (mp) \ + (((mp)->m_sb.sb_sectsize - \ + (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ + sizeof(struct xfs_agfl) : 0)) / \ + sizeof(xfs_agblock_t)) +typedef struct xfs_agfl { -__be32 agfl_bno[1 ];/* actually XFS_AGFL_SIZE(mp) */ +__be32 agfl_magicnum; +__be32 agfl_seqno; +uuid_t agfl_uuid; +__be64 agfl_lsn; +__be32 agfl_crc; +__be32 agfl_bno[];/* actually XFS_AGFL_SIZE(mp) */ }xfs_agfl_t ;/*
include/xfs_buf_item.h +7 -1
@@ -45,12 +45,18 @@ extern kmem_zone_t *xfs_buf_item_zone;* once the changes have been replayed into the buffer. */ #define XFS_BLF_BTREE_BUF (1<<5) +#define XFS_BLF_AGF_BUF (1<<6) +#define XFS_BLF_AGFL_BUF (1<<7) +#define XFS_BLF_AGI_BUF (1<<8)#define XFS_BLF_TYPE_MASK \ (XFS_BLF_UDQUOT_BUF | \ XFS_BLF_PDQUOT_BUF | \ XFS_BLF_GDQUOT_BUF | \ - XFS_BLF_BTREE_BUF) + XFS_BLF_BTREE_BUF | \ + XFS_BLF_AGF_BUF | \ + XFS_BLF_AGFL_BUF | \ + XFS_BLF_AGI_BUF)#define XFS_BLF_CHUNK 128#define XFS_BLF_SHIFT 7
libxfs/xfs_alloc.c +132 -65
313 lines not on this page · raw message
libxfs/xfs_ialloc.c +41 -14
96 lines not on this page · raw message
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/48] xfsprogs: add crc format chagnes to ag headers
Quoted 1 line · Dave Chinner
From: Dave Chinner <[email protected]>
This corresponds with commits 4e0e6040c405, 77c95bba013, and 983d09ffe3.
Quoted 4 lines
include/xfs_ag.h +0
-0
...
include/xfs_ag.h typedef struct xfs_agf { · line 105
Quoted 6 lines
include/xfs_ag.h +1
-0@@ -83,6 +101,7 @@ typedef struct xfs_agf {#define XFS_AGF_FREEBLKS 0x00000200#define XFS_AGF_LONGEST 0x00000400#define XFS_AGF_BTREEBLKS 0x00000800 +#define XFS_AGF_UUID 0x00001000#define XFS_AGF_NUM_BITS 12
^^ Should be 13 now.
s/chagnes/changes in the subject line.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/48] xfsprogs: add crc format chagnes to ag headers
Quoted 12 lines · Ben Myers
Quoted 1 line · Dave Chinner
From: Dave Chinner <[email protected]>
This corresponds with commits
4e0e6040c405,77c95bba013, and983d09ffe3.Quoted 4 lines
include/xfs_ag.h +0
-0...
Quoted 9 lines
include/xfs_ag.h typedef struct xfs_agf { · line 105
Quoted 6 lines
include/xfs_ag.h +1
-0@@ -83,6 +101,7 @@ typedef struct xfs_agf {#define XFS_AGF_FREEBLKS 0x00000200#define XFS_AGF_LONGEST 0x00000400#define XFS_AGF_BTREEBLKS 0x00000800 +#define XFS_AGF_UUID 0x00001000#define XFS_AGF_NUM_BITS 12^^ Should be 13 now.
Looks like this synced over in patch 33 of the subsequent series.
From: Ben Myers <[email protected]>
Subject: xfsprogs XFS_AGF_NUM_BITS should be 13
commit 4e0e6040c4052aff15a494ac05778f4086d24c33 changed XFS_AGF_NUM_BITS to be 13, however when this commit was applied to userspace the change was not pulled over.
--- include/xfs_ag.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/xfs_ag.h +1 -1
@@ -102,7 +102,7 @@ typedef struct xfs_agf {#define XFS_AGF_LONGEST 0x00000400#define XFS_AGF_BTREEBLKS 0x00000800#define XFS_AGF_UUID 0x00001000 -#define XFS_AGF_NUM_BITS 12 +#define XFS_AGF_NUM_BITS 13#define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1)#define XFS_AGF_FLAGS \
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 5/48 xfsprogs: Support new AGFL format
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
With the addition of CRCs to the filesystem format, the AGFL has a new format structure definition. Existing code that pulls freelist blocks out via dereferencing agfl->agfl_bno no longer works as the location of the free list is now variable depending on the disk format in use.
Hence all the users of agfl_bno need ot be converted to extract the location of the first free list entry from the AGFL and grab entries relative to that first entry. It's a simple change, but needs to be made in several places as there is very little code reuse within and between the different utilities in xfsprogs.
--- db/check.c | 6 +++++- db/freesp.c | 7 ++++++- repair/phase5.c | 6 ++++-- repair/scan.c | 6 +++--- 4 files changed, 18 insertions(+), 7 deletions(-)
db/check.c +5 -1
@@ -3806,6 +3806,7 @@ scan_freelist(xfs_agblock_t bno;uint count;int i; +__be32 *freelist; if (XFS_SB_BLOCK(mp) != XFS_AGFL_BLOCK(mp) && XFS_AGF_BLOCK(mp) != XFS_AGFL_BLOCK(mp) &&
@@ -3835,9 +3836,12 @@ scan_freelist(return ; } +/* open coded XFS_BUF_TO_AGFL_BNO */ + freelist =xfs_sb_version_hascrc (&((mp)->m_sb)) ? &agfl->agfl_bno[0 ] + : (__be32 *)agfl; count =0 ;for (;;) { - bno =be32_to_cpu (agfl->agfl_bno[i]); + bno =be32_to_cpu (freelist[i]);set_dbmap (seqno, bno,1 ,DBM_FREELIST , seqno,XFS_AGFL_BLOCK (mp)); count++;
db/freesp.c +6 -1
@@ -231,6 +231,7 @@ scan_freelist(xfs_agfl_t *agfl;xfs_agblock_t bno;int i; +__be32 *agfl_bno;if (be32_to_cpu (agf->agf_flcount) ==0 )return ;
@@ -240,6 +241,10 @@ scan_freelist( agfl = iocur_top->data; i =be32_to_cpu (agf->agf_flfirst); +/* open coded XFS_BUF_TO_AGFL_BNO */ + agfl_bno =xfs_sb_version_hascrc (&mp->m_sb) ? &agfl->agfl_bno[0 ] + : (__be32 *)agfl; +/* verify agf values before proceeding */ if (be32_to_cpu (agf->agf_flfirst) >=XFS_AGFL_SIZE (mp) ||be32_to_cpu (agf->agf_fllast) >=XFS_AGFL_SIZE (mp)) {
@@ -250,7 +255,7 @@ scan_freelist( }for (;;) { - bno =be32_to_cpu (agfl->agfl_bno[i]); + bno =be32_to_cpu (agfl_bno[i]);addtohist (seqno, bno,1 );if (i ==be32_to_cpu (agf->agf_fllast))break ;
repair/phase5.c +4 -2
@@ -1208,6 +1208,7 @@ build_agf_agfl(xfs_mount_t *mp,int j;xfs_agfl_t *agfl;xfs_agf_t *agf; +__be32 *freelist; agf_buf = libxfs_getbuf(mp->m_dev, XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
@@ -1277,19 +1278,20 @@ build_agf_agfl(xfs_mount_t *mp,XFS_AG_DADDR (mp, agno,XFS_AGFL_DADDR (mp)), mp->m_sb.sb_sectsize/BBSIZE); agfl =XFS_BUF_TO_AGFL (agfl_buf); + freelist =XFS_BUF_TO_AGFL_BNO (mp, agfl_buf);memset (agfl,0 , mp->m_sb.sb_sectsize);/* * ok, now grab as many blocks as we can */ i = j =0 ;while (bno_bt->num_free_blocks >0 && i <XFS_AGFL_SIZE (mp)) { - agfl->agfl_bno[i] =cpu_to_be32 ( + freelist[i] =cpu_to_be32 (get_next_blockaddr (agno,0 , bno_bt)); i++; }while (bcnt_bt->num_free_blocks >0 && i <XFS_AGFL_SIZE (mp)) { - agfl->agfl_bno[i] =cpu_to_be32 ( + freelist[i] =cpu_to_be32 (get_next_blockaddr (agno,0 , bcnt_bt)); i++; }
repair/scan.c +3 -3
@@ -1041,12 +1041,12 @@ scan_freelist(xfs_agf_t *agf, struct aghdr_cnts *agcnts) { - xfs_agfl_t *agfl; xfs_buf_t *agflbuf;xfs_agnumber_t agno;xfs_agblock_t bno;int count;int i; +__be32 *freelist; agno =be32_to_cpu (agf->agf_seqno);
@@ -1065,7 +1065,7 @@ scan_freelist(do_abort (_ ("can't read agfl block for ag %d\n" ), agno);return ; } - agfl =XFS_BUF_TO_AGFL (agflbuf); + freelist =XFS_BUF_TO_AGFL_BNO (mp, agflbuf); i =be32_to_cpu (agf->agf_flfirst);if (no_modify) {
@@ -1080,7 +1080,7 @@ scan_freelist( count =0 ;for (;;) { - bno =be32_to_cpu (agfl->agfl_bno[i]); + bno =be32_to_cpu (freelist[i]);if (verify_agbno (mp, agno, bno))set_bmap (agno, bno,XR_E_FREE );else
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 05/48] xfsprogs: Support new AGFL format
Quoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
With the addition of CRCs to the filesystem format, the AGFL has a new format structure definition. Existing code that pulls freelist blocks out via dereferencing
agfl->agfl_bnono longer works as the location of the free list is now variable depending on the disk format in use.
Quoted 5 lines
Hence all the users of
agfl_bnoneed ot be converted to extract the location of the first free list entry from the AGFL and grab entries relative to that first entry. It's a simple change, but needs to be made in several places as there is very little code reuse within and between the different utilities in xfsprogs.
Looks fine.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 6/48 libxfs: change quota buffer formats
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- include/xfs_quota.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
include/xfs_quota.h +10 -1
@@ -77,7 +77,14 @@ typedef struct xfs_disk_dquot {*/ typedef struct xfs_dqblk {xfs_disk_dquot_t dd_diskdq;/* portion that lives incore as well */ -char dd_fill[32 ];/* filling for posterity */ +char dd_fill[4 ];/* filling for posterity */ + +/* +* These two are only present on filesystems with the CRC bits set. +*/ +__be32 dd_crc;/* checksum */ +__be64 dd_lsn;/* last modification in log */ +uuid_t dd_uuid;/* location information */ }xfs_dqblk_t ;/*
@@ -380,5 +387,7 @@ extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *);extern int xfs_mount_reset_sbqflags (struct xfs_mount *); +extern const struct xfs_buf_ops xfs_dquot_buf_ops; +#endif /* __KERNEL__ */ #endif /* __XFS_QUOTA_H__ */
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 06/48] libxfs: change quota buffer formats
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
Corresponds to commit 3fe58f30b4f
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 7/48 libxfs: add version 3 inode support
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Header from folded patch 'debug':
xfs_quota: fix report command parsing
The report command line needs to be parsed as a whole not as individual elements - report_f() is set up to do this correctly. When treated as non-global command line, the report function is called once for each command line arg, resulting in reports being issued multiple times.
Set the command to be a global command so that it is only called once.
--- db/dir2sf.c | 9 +++-- include/xfs_buf_item.h | 4 +- include/xfs_dinode.h | 33 +++++++++++++++-- include/xfs_inode.h | 26 +++++++++++++ libxfs/trans.c | 1 + libxfs/util.c | 30 ++++++++++++++- libxfs/xfs_ialloc.c | 23 +++++++++++- libxfs/xfs_inode.c | 91 ++++++++++++++++++++++++++++++++++++++++------ logprint/log_misc.c | 2 +- logprint/log_print_all.c | 3 +- repair/phase6.c | 63 +++++++++++++++++++++++++++++--- 11 files changed, 255 insertions(+), 30 deletions(-)
db/dir2sf.c +6 -3
@@ -74,10 +74,11 @@ dir2_inou_i4_count( void *obj, int startoff) { +struct xfs_dinode *dip = obj;xfs_dir2_sf_t *sf;ASSERT (bitoffs (startoff) ==0 ); - sf = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (obj); + sf = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (dip);return sf->hdr.i8count ==0 ; }
@@ -87,10 +88,11 @@ dir2_inou_i8_count( void *obj, int startoff) { +struct xfs_dinode *dip = obj;xfs_dir2_sf_t *sf;ASSERT (bitoffs (startoff) ==0 ); - sf = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (obj); + sf = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (dip);return sf->hdr.i8count !=0 ; }
@@ -101,11 +103,12 @@ dir2_inou_size( int startoff, int idx) { +struct xfs_dinode *dip = obj;xfs_dir2_sf_t *sf;ASSERT (bitoffs (startoff) ==0 );ASSERT (idx ==0 ); - sf = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (obj); + sf = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (dip);return bitize (sf->hdr.i8count ? (uint )sizeof (xfs_dir2_ino8_t) : (uint )sizeof (xfs_dir2_ino4_t));
include/xfs_buf_item.h +3 -1
@@ -48,6 +48,7 @@ extern kmem_zone_t *xfs_buf_item_zone;#define XFS_BLF_AGF_BUF (1<<6)#define XFS_BLF_AGFL_BUF (1<<7)#define XFS_BLF_AGI_BUF (1<<8) +#define XFS_BLF_DINO_BUF (1<<9)#define XFS_BLF_TYPE_MASK \ (XFS_BLF_UDQUOT_BUF | \
@@ -56,7 +57,8 @@ extern kmem_zone_t *xfs_buf_item_zone; XFS_BLF_BTREE_BUF | \ XFS_BLF_AGF_BUF | \ XFS_BLF_AGFL_BUF | \ - XFS_BLF_AGI_BUF) + XFS_BLF_AGI_BUF | \ + XFS_BLF_DINO_BUF)#define XFS_BLF_CHUNK 128#define XFS_BLF_SHIFT 7
include/xfs_dinode.h +29 -4
@@ -19,7 +19,7 @@#define __XFS_DINODE_H__#define XFS_DINODE_MAGIC 0x494e/* 'IN' */ -#define XFS_DINODE_GOOD_VERSION (v) (((v) == 1 || (v) == 2)) +#define XFS_DINODE_GOOD_VERSION (v) ((v) >= 1 && (v) <= 3) typedef struct xfs_timestamp { __be32 t_sec; /* timestamp seconds */
@@ -70,11 +70,36 @@ typedef struct xfs_dinode {/* di_next_unlinked is the only non-core field in the old dinode */ __be32 di_next_unlinked;/* agi unlinked list ptr */ -} __attribute__((packed)) xfs_dinode_t; + +/* start of the extended dinode, writable fields */ +__le32 di_crc;/* CRC of the inode */ +__be64 di_changecount;/* number of attribute changes */ +__be64 di_lsn;/* flush sequence */ +__be64 di_flags2;/* more random flags */ +__u8 di_pad2[16 ];/* more padding for future expansion */ + +/* fields only written to during inode creation */ +xfs_timestamp_t di_crtime;/* time created */ +__be64 di_ino;/* inode number */ +uuid_t di_uuid;/* UUID of the filesystem */ + +/* structure must be padded to 64 bit alignment */ +} xfs_dinode_t;#define DI_MAX_FLUSH 0xffff/* +* Size of the core inode on disk. Version 1 and 2 inodes have +* the same size, but version 3 has grown a few additional fields. +*/ +static inline uint xfs_dinode_size (int version) +{ +if (version ==3 ) +return sizeof (struct xfs_dinode ); +return offsetof(struct xfs_dinode , di_crc); +} + +/* * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. * Since the pathconf interface is signed, we use 2^31 - 1 instead. * The old inode format had a 16 bit link count, so its maximum is USHRT_MAX.
@@ -105,7 +130,7 @@ typedef enum xfs_dinode_fmt {* Inode size for given fs. */ #define XFS_LITINO (mp, version) \ - ((int)(((mp)->m_sb.sb_inodesize) - sizeof(struct xfs_dinode))) + ((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version)))#define XFS_BROOT_SIZE_ADJ (ip) \ (XFS_BMBT_BLOCK_LEN((ip)->i_mount) - sizeof(xfs_bmdr_block_t))
@@ -133,7 +158,7 @@ typedef enum xfs_dinode_fmt {* Return pointers to the data or attribute forks. */ #define XFS_DFORK_DPTR (dip) \ - ((char *)(dip) + sizeof(struct xfs_dinode)) + ((char *)dip + xfs_dinode_size(dip->di_version))#define XFS_DFORK_APTR (dip) \ (XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip))#define XFS_DFORK_PTR (dip,w) \
include/xfs_inode.h +26 -0
@@ -150,13 +150,38 @@ typedef struct xfs_icdinode {__uint16_t di_dmstate;/* DMIG state info */ __uint16_t di_flags;/* random flags, XFS_DIFLAG_... */ __uint32_t di_gen;/* generation number */ + +/* di_next_unlinked is the only non-core field in the old dinode */ +__be32 di_next_unlinked;/* agi unlinked list ptr */ + +/* start of the extended dinode, writable fields */ +__uint32_t di_crc;/* CRC of the inode */ +__uint64_t di_changecount;/* number of attribute changes */ +xfs_lsn_t di_lsn;/* flush sequence */ +__uint64_t di_flags2;/* more random flags */ +__uint8_t di_pad2[16 ];/* more padding for future expansion */ + +/* fields only written to during inode creation */ +xfs_ictimestamp_t di_crtime;/* time created */ +xfs_ino_t di_ino;/* inode number */ +uuid_t di_uuid;/* UUID of the filesystem */ + +/* structure must be padded to 64 bit alignment */ } xfs_icdinode_t; +static inline uint xfs_icdinode_size (struct xfs_icdinode *dicp) +{ +if (dicp->di_version ==3 ) +return sizeof (struct xfs_icdinode ); +return offsetof(struct xfs_icdinode , di_next_unlinked); +} +/* * Flags for xfs_ichgtime(). */ #define XFS_ICHGTIME_MOD 0x1/* data fork modification timestamp */ #define XFS_ICHGTIME_CHG 0x2/* inode field change timestamp */ +#define XFS_ICHGTIME_CREATE 0x4/* inode create timestamp */ /* * Per-fork incore inode flags.
@@ -556,6 +581,7 @@ int xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *, struct xfs_buf **, uint, uint);int xfs_iread (struct xfs_mount *,struct xfs_trans *,struct xfs_inode *,uint ); +void xfs_dinode_calc_crc (struct xfs_mount *,struct xfs_dinode *);void xfs_dinode_to_disk (struct xfs_dinode *,struct xfs_icdinode *);void xfs_idestroy_fork (struct xfs_inode *,int );
libxfs/trans.c +1 -0
@@ -218,6 +218,7 @@ libxfs_trans_inode_alloc_buf( ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); bip->bli_flags |=XFS_BLI_INODE_ALLOC_BUF ; +xfs_trans_buf_set_type (tp, bp,XFS_BLF_DINO_BUF ); }/*
libxfs/util.c +29 -1
@@ -47,6 +47,10 @@ libxfs_trans_ichgtime( ip->i_d.di_ctime.t_sec = (__int32_t )tv.tv_sec; ip->i_d.di_ctime.t_nsec = (__int32_t )tv.tv_nsec; } +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; + } }/*
@@ -75,6 +79,7 @@ libxfs_ialloc(xfs_inode_t *ip;uint flags;int error; +int times;/* * Call the space management code to pick
@@ -103,6 +108,7 @@ libxfs_ialloc( ip->i_d.di_gid = cr->cr_gid;xfs_set_projid (&ip->i_d, pip ?0 : fsx->fsx_projid);memset (&(ip->i_d.di_pad[0 ]),0 ,sizeof (ip->i_d.di_pad)); +xfs_trans_ichgtime (tp, ip,XFS_ICHGTIME_CHG |XFS_ICHGTIME_MOD );/* * If the superblock version is up to where we support new format
@@ -128,7 +134,6 @@ libxfs_ialloc( ip->i_d.di_size =0 ; ip->i_d.di_nextents =0 ;ASSERT (ip->i_d.di_nblocks ==0 ); -xfs_trans_ichgtime (tp, ip,XFS_ICHGTIME_CHG |XFS_ICHGTIME_MOD );/* * di_gen will have been taken care of in xfs_iread. */
@@ -136,6 +141,18 @@ libxfs_ialloc( ip->i_d.di_dmevmask =0 ; ip->i_d.di_dmstate =0 ; ip->i_d.di_flags = pip ?0 : fsx->fsx_xflags; + +if (ip->i_d.di_version ==3 ) { +ASSERT (ip->i_d.di_ino == ino); +ASSERT (uuid_equal (&ip->i_d.di_uuid, &mp->m_sb.sb_uuid)); + ip->i_d.di_crc =0 ; + ip->i_d.di_changecount =1 ; + ip->i_d.di_lsn =0 ; + ip->i_d.di_flags2 =0 ; +memset (&(ip->i_d.di_pad2[0 ]),0 ,sizeof (ip->i_d.di_pad2)); + ip->i_d.di_crtime = ip->i_d.di_mtime; + } + flags =XFS_ILOG_CORE ;switch (mode &S_IFMT ) {case S_IFIFO :
@@ -295,6 +312,10 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)ASSERT (ip->i_d.di_nextents+ip->i_d.di_anextents <= ip->i_d.di_nblocks);ASSERT (ip->i_d.di_forkoff <= mp->m_sb.sb_inodesize); +/* bump the change count on v3 inodes */ +if (ip->i_d.di_version ==3 ) + ip->i_d.di_changecount++; +/* * Copy the dirty parts of the inode into the on-disk * inode. We always copy out the core of the inode,
@@ -338,6 +359,13 @@ libxfs_iflush_int(xfs_inode_t *ip, xfs_buf_t *bp)if (XFS_IFORK_Q (ip))xfs_iflush_fork (ip, dip, iip,XFS_ATTR_FORK , bp); +/* update the lsn in the on disk inode if required */ +if (ip->i_d.di_version ==3 ) + dip->di_lsn =cpu_to_be64 (iip->ili_item.li_lsn); + +/* generate the checksum. */ +xfs_dinode_calc_crc (mp, dip); +return 0 ; }
libxfs/xfs_ialloc.c +21 -2
@@ -146,6 +146,7 @@ xfs_ialloc_inode_init(int version;int i, j;xfs_daddr_t d; +xfs_ino_t ino =0 ;/* * Loop over the new block(s), filling in the inodes.
@@ -169,8 +170,18 @@ xfs_ialloc_inode_init(* the new inode format, then use the new inode version. Otherwise * use the old version so that old kernels will continue to be * able to use the file system. +* +* For v3 inodes, we also need to write the inode number into the inode, +* so calculate the first inode number of the chunk here as +* XFS_OFFBNO_TO_AGINO() only works on filesystem block boundaries, not +* cluster boundaries and so cannot be used in the cluster buffer loop +* below. */ -if (xfs_sb_version_hasnlink (&mp->m_sb)) +if (xfs_sb_version_hascrc (&mp->m_sb)) { + version =3 ; + ino =XFS_AGINO_TO_INO (mp, agno, +XFS_OFFBNO_TO_AGINO (mp, agbno,0 )); + }else if (xfs_sb_version_hasnlink (&mp->m_sb)) version =2 ;else version =1 ;
@@ -196,13 +207,21 @@ xfs_ialloc_inode_init(xfs_buf_zero (fbuf,0 , ninodes << mp->m_sb.sb_inodelog);for (i =0 ; i < ninodes; i++) {int ioffset = i << mp->m_sb.sb_inodelog; -uint isize =sizeof (struct xfs_dinode ); +uint isize =xfs_dinode_size (version); free =xfs_make_iptr (mp, fbuf, i); free->di_magic =cpu_to_be16 (XFS_DINODE_MAGIC ); free->di_version = version; free->di_gen =cpu_to_be32 (gen); free->di_next_unlinked =cpu_to_be32 (NULLAGINO ); + +if (version ==3 ) { + free->di_ino =cpu_to_be64 (ino); + ino++; +uuid_copy (&free->di_uuid, &mp->m_sb.sb_uuid); +xfs_dinode_calc_crc (mp, free); + } +xfs_trans_log_buf (tp, fbuf, ioffset, ioffset + isize -1 ); }xfs_trans_inode_alloc_buf (tp, fbuf);
libxfs/xfs_inode.c +80 -11
119 lines not on this page · raw message
logprint/log_misc.c +1 -1
@@ -655,7 +655,7 @@ xlog_print_trans_inode(xfs_caddr_t *ptr, mode = dino.di_mode &S_IFMT ; size = (int )dino.di_size;xlog_print_trans_inode_core (&dino); - *ptr +=sizeof (xfs_icdinode_t); + *ptr +=xfs_icdinode_size (&dino);if (*i == num_ops-1 && f->ilf_size ==3 ) {return 1 ;
logprint/log_print_all.c +2 -1
@@ -295,7 +295,8 @@ xlog_recover_print_inode( f->ilf_dsize);/* core inode comes 2nd */ -ASSERT (item->ri_buf[1 ].i_len ==sizeof (xfs_icdinode_t)); +ASSERT (item->ri_buf[1 ].i_len ==xfs_icdinode_size ((xfs_icdinode_t *) + item->ri_buf[1 ].i_addr));xlog_recover_print_inode_core ((xfs_icdinode_t *) item->ri_buf[1 ].i_addr);
repair/phase6.c +57 -6
123 lines not on this page · raw message
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 07/48] libxfs: add version 3 inode support
Dave,
Quoted 15 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>Header from folded patch 'debug':
xfs_quota: fix report command parsingThe report command line needs to be parsed as a whole not as individual elements -
report_f()is set up to do this correctly. When treated as non-global command line, the report function is called once for each command line arg, resulting in reports being issued multiple times.
Quoted 4 lines
Set the command to be a global command so that it is only called once.
Signed-off-by Dave Chinner <[email protected]>
This header looks like it came from an unrelated patch.
Looks like this patch mostly corresponds to commit 93848a999cf. There is also:
* changes to printing i4_count, i8_count, and size fields for shortform directories
* changes to start filling in v3 inode specific fields
* make logprint stop asserting on v3 inodes
* add support for creating v3 realtime bitmap, realtime summary, and root_dir inodes
There are a couple of issues below:
Quoted 33 lines
libxfs/xfs_ialloc.c +12
-1@@ -146,6 +146,7 @@ xfs_ialloc_inode_init(int version;int i, j;xfs_daddr_t d; +xfs_ino_t ino =0 ;/* * Loop over the new block(s), filling in the inodes. @@ -169,8 +170,18 @@ xfs_ialloc_inode_init(* the new inode format, then use the new inode version. Otherwise * use the old version so that old kernels will continue to be * able to use the file system. +* +* For v3 inodes, we also need to write the inode number into the inode, +* so calculate the first inode number of the chunk here as +* XFS_OFFBNO_TO_AGINO() only works on filesystem block boundaries, not +* cluster boundaries and so cannot be used in the cluster buffer loop +* below. */ -if (xfs_sb_version_hasnlink (&mp->m_sb)) +if (xfs_sb_version_hascrc (&mp->m_sb)) { + version =3 ; + ino =XFS_AGINO_TO_INO (mp, agno, +XFS_OFFBNO_TO_AGINO (mp, agbno,0 )); + }else if (xfs_sb_version_hasnlink (&mp->m_sb)) version =2 ;else version =1 ;
libxfs/xfs_ialloc.c xfs_ialloc_inode_init( · line 207
Quoted 1 line
libxfs/xfs_ialloc.c +0
-0@@ -196,13 +207,21 @@ xfs_ialloc_inode_init(xfs_buf_zero (fbuf,0 , ninodes << mp->m_sb.sb_inodelog);
There is a section in commit 93848a999cf where the above line is modified to this:
xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length));
I suggest you pull that in here too.
Quoted 8 lines
libxfs/xfs_inode.c +0
-0@@ -572,6 +572,17 @@ xfs_dinode_from_disk( to->di_dmstate =be16_to_cpu (from->di_dmstate); to->di_flags =be16_to_cpu (from->di_flags); to->di_gen =be32_to_cpu (from->di_gen);
libxfs/xfs_inode.c xfs_dinode_from_disk( · line 584
Quoted 10 lines
libxfs/xfs_inode.c +10
-0+ +if (to->di_version ==3 ) { + to->di_changecount =be64_to_cpu (from->di_changecount); + to->di_crtime.t_sec =be32_to_cpu (from->di_crtime.t_sec); + to->di_crtime.t_nsec =be32_to_cpu (from->di_crtime.t_nsec); + to->di_flags2 =be64_to_cpu (from->di_flags2); + to->di_ino =be64_to_cpu (from->di_ino); + to->di_lsn =be64_to_cpu (from->di_lsn); +memcpy (to->di_pad2, from->di_pad2,sizeof (to->di_pad2)); +platform_uuid_copy (&to->di_uuid, &from->di_uuid);
You added a #define for uuid_copy in an earlier patch. I suggest you use it if you can. There are several occurances.
Other than that this looks fine.
-Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 07/48] libxfs: add version 3 inode support
Quoted 18 lines · Ben Myers
Dave,
Quoted 15 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>Header from folded patch 'debug':
xfs_quota: fix report command parsingThe report command line needs to be parsed as a whole not as individual elements -
report_f()is set up to do this correctly. When treated as non-global command line, the report function is called once for each command line arg, resulting in reports being issued multiple times.
Quoted 6 lines
Quoted 4 lines
Set the command to be a global command so that it is only called once.
Signed-off-by Dave Chinner <[email protected]>This header looks like it came from an unrelated patch.
So remove it ;)
Quoted 48 lines
Looks like this patch mostly corresponds to commit
93848a999cf. There is also:* changes to printing
i4_count,i8_count, and size fields for shortform directories
* changes to start filling in v3 inode specific fields
* make logprint stop asserting on v3 inodes
* add support for creating v3 realtime bitmap, realtime summary, androot_dirinodesThere are a couple of issues below:
Quoted 33 lines
libxfs/xfs_ialloc.c +12
-1@@ -146,6 +146,7 @@ xfs_ialloc_inode_init(int version;int i, j;xfs_daddr_t d; +xfs_ino_t ino =0 ;/* * Loop over the new block(s), filling in the inodes. @@ -169,8 +170,18 @@ xfs_ialloc_inode_init(* the new inode format, then use the new inode version. Otherwise * use the old version so that old kernels will continue to be * able to use the file system. +* +* For v3 inodes, we also need to write the inode number into the inode, +* so calculate the first inode number of the chunk here as +* XFS_OFFBNO_TO_AGINO() only works on filesystem block boundaries, not +* cluster boundaries and so cannot be used in the cluster buffer loop +* below. */ -if (xfs_sb_version_hasnlink (&mp->m_sb)) +if (xfs_sb_version_hascrc (&mp->m_sb)) { + version =3 ; + ino =XFS_AGINO_TO_INO (mp, agno, +XFS_OFFBNO_TO_AGINO (mp, agbno,0 )); + }else if (xfs_sb_version_hasnlink (&mp->m_sb)) version =2 ;else version =1 ;libxfs/xfs_ialloc.c xfs_ialloc_inode_init( · line 207
Quoted 1 line
libxfs/xfs_ialloc.c +0
-0@@ -196,13 +207,21 @@ xfs_ialloc_inode_init(xfs_buf_zero (fbuf,0 , ninodes << mp->m_sb.sb_inodelog);There is a section in commit
93848a999cfwhere the above line is modified to this:
Quoted 3 lines
xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length));I suggest you pull that in here too.
It's correct in the current TOT, so I'm not going to change it here.
Quoted 2 lines
You added a #define for
uuid_copyin an earlier patch. I suggest you use it if you can. There are several occurances.
There's only two calls to platform_uuid_copy() left in the current patchset, and they were introduced in the current patchset. SO I'm not going to go back and fix it here, either.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 07/48] libxfs: add version 3 inode support
In reply to Ben MyersQuoted 73 lines · Ben Myers
Dave,
Quoted 15 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>Header from folded patch 'debug':
xfs_quota: fix report command parsingThe report command line needs to be parsed as a whole not as individual elements -
report_f()is set up to do this correctly. When treated as non-global command line, the report function is called once for each command line arg, resulting in reports being issued multiple times.Quoted 4 lines
Set the command to be a global command so that it is only called once.
Signed-off-by Dave Chinner <[email protected]>This header looks like it came from an unrelated patch.
Looks like this patch mostly corresponds to commit
93848a999cf. There is also:* changes to printing
i4_count,i8_count, and size fields for shortform directories
* changes to start filling in v3 inode specific fields
* make logprint stop asserting on v3 inodes
* add support for creating v3 realtime bitmap, realtime summary, androot_dirinodesThere are a couple of issues below:
Quoted 33 lines
libxfs/xfs_ialloc.c +12
-1@@ -146,6 +146,7 @@ xfs_ialloc_inode_init(int version;int i, j;xfs_daddr_t d; +xfs_ino_t ino =0 ;/* * Loop over the new block(s), filling in the inodes. @@ -169,8 +170,18 @@ xfs_ialloc_inode_init(* the new inode format, then use the new inode version. Otherwise * use the old version so that old kernels will continue to be * able to use the file system. +* +* For v3 inodes, we also need to write the inode number into the inode, +* so calculate the first inode number of the chunk here as +* XFS_OFFBNO_TO_AGINO() only works on filesystem block boundaries, not +* cluster boundaries and so cannot be used in the cluster buffer loop +* below. */ -if (xfs_sb_version_hasnlink (&mp->m_sb)) +if (xfs_sb_version_hascrc (&mp->m_sb)) { + version =3 ; + ino =XFS_AGINO_TO_INO (mp, agno, +XFS_OFFBNO_TO_AGINO (mp, agbno,0 )); + }else if (xfs_sb_version_hasnlink (&mp->m_sb)) version =2 ;else version =1 ;libxfs/xfs_ialloc.c xfs_ialloc_inode_init( · line 207
Quoted 1 line
libxfs/xfs_ialloc.c +0
-0@@ -196,13 +207,21 @@ xfs_ialloc_inode_init(xfs_buf_zero (fbuf,0 , ninodes << mp->m_sb.sb_inodelog);There is a section in commit
93848a999cfwhere the above line is modified to this:
Quoted 3 lines
xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length));I suggest you pull that in here too.
Looks like you grabbed it in patch 2 of the next series.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 8/48 libxfs: add support for crc headers on remote symlinks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- include/Makefile | 4 +- include/libxfs.h | 1 + include/xfs_buf_item.h | 4 +- include/xfs_symlink.h | 43 ++++++++++++++ libxfs/Makefile | 2 +- libxfs/xfs_symlink.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 204 insertions(+), 4 deletions(-) create mode 100644 include/xfs_symlink.h create mode 100644 libxfs/xfs_symlink.c
include/Makefile +2 -2
@@ -28,8 +28,8 @@ QAHFILES = libxfs.h libxlog.h \ xfs_extfree_item.h xfs_ialloc.h xfs_ialloc_btree.h \ xfs_inode.h xfs_inode_item.h xfs_inum.h \ xfs_log.h xfs_log_priv.h xfs_log_recover.h xfs_metadump.h \ - xfs_mount.h xfs_quota.h xfs_rtalloc.h xfs_sb.h xfs_trace.h \ - xfs_trans.h xfs_trans_space.h xfs_dfrag.h + xfs_mount.h xfs_quota.h xfs_rtalloc.h xfs_sb.h xfs_symlink.h \ + xfs_trace.h xfs_trans.h xfs_trans_space.h xfs_dfrag.h HFILES = handle.h jdm.h xqm.h xfs.h xfs_fs.h xfs_types.h HFILES += $(PKG_PLATFORM).h
include/libxfs.h +1 -0
@@ -56,6 +56,7 @@#include <xfs/xfs_btree_trace.h> #include <xfs/xfs_bmap.h> #include <xfs/xfs_trace.h> +#include <xfs/xfs_symlink.h> #ifndef ARRAY_SIZE #define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))
include/xfs_buf_item.h +3 -1
@@ -49,6 +49,7 @@ extern kmem_zone_t *xfs_buf_item_zone;#define XFS_BLF_AGFL_BUF (1<<7)#define XFS_BLF_AGI_BUF (1<<8)#define XFS_BLF_DINO_BUF (1<<9) +#define XFS_BLF_SYMLINK_BUF (1<<10)#define XFS_BLF_TYPE_MASK \ (XFS_BLF_UDQUOT_BUF | \
@@ -58,7 +59,8 @@ extern kmem_zone_t *xfs_buf_item_zone; XFS_BLF_AGF_BUF | \ XFS_BLF_AGFL_BUF | \ XFS_BLF_AGI_BUF | \ - XFS_BLF_DINO_BUF) + XFS_BLF_DINO_BUF | \ + XFS_BLF_SYMLINK_BUF)#define XFS_BLF_CHUNK 128#define XFS_BLF_SHIFT 7
include/xfs_symlink.h new file +43 -0
43 lines not on this page · raw message
libxfs/Makefile +1 -1
@@ -17,7 +17,7 @@ CFILES = cache.c init.c kmem.c logitem.c radix-tree.c rdwr.c trans.c util.c \ xfs_dir2.c xfs_dir2_leaf.c xfs_attr_leaf.c xfs_dir2_block.c \ xfs_dir2_node.c xfs_dir2_data.c xfs_dir2_sf.c xfs_bmap.c \ xfs_mount.c xfs_rtalloc.c xfs_trans.c xfs_attr.c \ - crc32.c + crc32.c xfs_symlink.c CFILES += $(PKG_PLATFORM).c PCFILES = darwin.c freebsd.c irix.c linux.c
libxfs/xfs_symlink.c new file +154 -0
154 lines not on this page · raw message
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 08/48] libxfs: add support for crc headers on remote symlinks
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
Ok, so this corresponds with commit f948dd76d and commit 19de7351a....
include/xfs_symlink.h line 3
Quoted 9 lines
include/xfs_symlink.h new file +3
-0@@ -0,0 +1,43 @@ +/* +* Copyright (c) 2012 Red Hat, Inc. All rights reserved. +*/
Please add the gpl header as you did in the kernel.
Quoted 19 lines
libxfs/Makefile +1
-1@@ -17,7 +17,7 @@ CFILES = cache.c init.c kmem.c logitem.c radix-tree.c rdwr.c trans.c util.c \ xfs_dir2.c xfs_dir2_leaf.c xfs_attr_leaf.c xfs_dir2_block.c \ xfs_dir2_node.c xfs_dir2_data.c xfs_dir2_sf.c xfs_bmap.c \ xfs_mount.c xfs_rtalloc.c xfs_trans.c xfs_attr.c \ - crc32.c + crc32.c xfs_symlink.c CFILES += $(PKG_PLATFORM).c PCFILES = darwin.c freebsd.c irix.c linux.clibxfs/xfs_symlink.c new file +0
-0
libxfs/xfs_symlink.c line 4
Quoted 4 lines
libxfs/xfs_symlink.c new file +4
-0@@ -0,0 +1,154 @@ +/* +* Copyright 2013 Red Hat, Inc. +* All rights reserved. +*/
Here too.
Else, this looks fine.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 9/48 xfs: add CRC checks to block format directory blocks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Now that directory buffers are made from a single struct xfs_buf, we can add CRC calculation and checking callbacks. While there, add all the fields to the on disk structures for future functionality such as d_type support, uuids, block numbers, owner inode, etc.
To distinguish between the different on disk formats, change the magic numbers for the new format directory blocks.
--- include/xfs_dir2_format.h | 155 +++++++++++++++++++++++++++++++++++++++++-- libxfs/xfs_dir2_block.c | 126 +++++++++++++++++++++++++---------- libxfs/xfs_dir2_data.c | 160 ++++++++++++++++++++++++++++----------------- libxfs/xfs_dir2_leaf.c | 6 +- libxfs/xfs_dir2_node.c | 2 +- libxfs/xfs_dir2_priv.h | 4 +- libxfs/xfs_dir2_sf.c | 2 +- 7 files changed, 346 insertions(+), 109 deletions(-)
include/xfs_dir2_format.h +149 -6
@@ -1,5 +1,6 @@/* * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. +* Copyright (c) 2013 Red Hat, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or
@@ -36,6 +37,37 @@#define XFS_DIR2_FREE_MAGIC 0x58443246/* XD2F: free index blocks */ /* +* Directory Version 3 With CRCs. +* +* The tree formats are the same as for version 2 directories. The difference +* is in the block header and dirent formats. In many cases the v3 structures +* use v2 definitions as they are no different and this makes code sharing much +* easier. +* +* Also, the xfs_dir3_*() functions handle both v2 and v3 formats - if the +* format is v2 then they switch to the existing v2 code, or the format is v3 +* they implement the v3 functionality. This means the existing dir2 is a mix of +* xfs_dir2/xfs_dir3 calls and functions. The xfs_dir3 functions are called +* where there is a difference in the formats, otherwise the code is unchanged. +* +* Where it is possible, the code decides what to do based on the magic numbers +* in the blocks rather than feature bits in the superblock. This means the code +* is as independent of the external XFS code as possible as doesn't require +* passing struct xfs_mount pointers into places where it isn't really +* necessary. +* +* Version 3 includes: +* +* - a larger block header for CRC and identification purposes and so the +* offsets of all the structures inside the blocks are different. +* +* - new magic numbers to be able to detect the v2/v3 types on the fly. +*/ + +#define XFS_DIR3_BLOCK_MAGIC 0x58444233/* XDB3: single block dirs */ +#define XFS_DIR3_DATA_MAGIC 0x58444433/* XDD3: multiblock dirs */ + +/* * Byte offset in data block and shortform entry. */ typedef __uint16_t xfs_dir2_data_off_t ;
@@ -111,19 +143,19 @@ static inline int xfs_dir2_sf_hdr_size(int i8count) (sizeof (xfs_dir2_ino8_t) -sizeof (xfs_dir2_ino4_t)); } -static inline xfs_dir2_data_aoff_t +static inline xfs_dir2_data_aoff_t xfs_dir2_sf_get_offset (xfs_dir2_sf_entry_t *sfep) {return get_unaligned_be16 (&sfep->offset.i); } -static inline void +static inline void xfs_dir2_sf_put_offset (xfs_dir2_sf_entry_t *sfep,xfs_dir2_data_aoff_t off) {put_unaligned_be16 (off, &sfep->offset.i); } -static inline int +static inline int xfs_dir2_sf_entsize (struct xfs_dir2_sf_hdr *hdr,int len) { return sizeof(struct xfs_dir2_sf_entry) + /* namelen + offset */
@@ -133,14 +165,14 @@ xfs_dir2_sf_entsize(struct xfs_dir2_sf_hdr *hdr, int len) sizeof(xfs_dir2_ino4_t)); } -static inline struct xfs_dir2_sf_entry * +static inline struct xfs_dir2_sf_entry *xfs_dir2_sf_firstentry (struct xfs_dir2_sf_hdr *hdr) {return (struct xfs_dir2_sf_entry *) ((char *)hdr +xfs_dir2_sf_hdr_size (hdr->i8count)); } -static inline struct xfs_dir2_sf_entry * +static inline struct xfs_dir2_sf_entry *xfs_dir2_sf_nextentry (struct xfs_dir2_sf_hdr *hdr,struct xfs_dir2_sf_entry *sfep) {
@@ -215,11 +247,43 @@ typedef struct xfs_dir2_data_free {*/ typedef struct xfs_dir2_data_hdr {__be32 magic;/* XFS_DIR2_DATA_MAGIC or */ -/* XFS_DIR2_BLOCK_MAGIC */ +/* XFS_DIR2_BLOCK_MAGIC */ xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT ]; }xfs_dir2_data_hdr_t ;/* +* define a structure for all the verification fields we are adding to the +* directory block structures. This will be used in several structures. +* The magic number must be the first entry to align with all the dir2 +* structures so we determine how to decode them just by the magic number. +*/ +struct xfs_dir3_blk_hdr { +__be32 magic;/* magic number */ +__be32 crc;/* CRC of block */ +__be64 blkno;/* first block of the buffer */ +__be64 lsn;/* sequence number of last write */ +uuid_t uuid;/* filesystem we belong to */ +__be64 owner;/* inode that owns the block */ +}; + +struct xfs_dir3_data_hdr { +struct xfs_dir3_blk_hdr hdr; +xfs_dir2_data_free_t best_free[XFS_DIR2_DATA_FD_COUNT ]; +}; + +#define XFS_DIR3_DATA_CRC_OFF offsetof(struct xfs_dir3_data_hdr, hdr.crc) + +static inline struct xfs_dir2_data_free * +xfs_dir3_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) +{ +if (hdr->magic ==cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC )) { +struct xfs_dir3_data_hdr *hdr3 = (struct xfs_dir3_data_hdr *)hdr; +return hdr3->best_free; + } +return hdr->bestfree; +} + +/* * Active entry in a data block. * * Aligned to 8 bytes. After the variable length name field there is a
@@ -274,6 +338,85 @@ xfs_dir2_data_unused_tag_p(struct xfs_dir2_data_unused *dup) be16_to_cpu(dup->length) - sizeof(__be16)); } +static inline struct xfs_dir2_data_unused * +xfs_dir3_data_unused_p (struct xfs_dir2_data_hdr *hdr) +{ +if (hdr->magic ==cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC )) { +return (struct xfs_dir2_data_unused *) + ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); + } +return (struct xfs_dir2_data_unused *) + ((char *)hdr +sizeof (struct xfs_dir2_data_hdr )); +} + +static inline size_t +xfs_dir3_data_hdr_size (bool dir3) +{ +if (dir3) +return sizeof (struct xfs_dir3_data_hdr ); +return sizeof (struct xfs_dir2_data_hdr ); +} + +static inline size_t +xfs_dir3_data_entry_offset (struct xfs_dir2_data_hdr *hdr) +{ +bool dir3 = hdr->magic ==cpu_to_be32 (XFS_DIR3_DATA_MAGIC ) || + hdr->magic ==cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC ); +return xfs_dir3_data_hdr_size (dir3); +} + +static inline struct xfs_dir2_data_entry * +xfs_dir3_data_entry_p (struct xfs_dir2_data_hdr *hdr) +{ +return (struct xfs_dir2_data_entry *) + ((char *)hdr +xfs_dir3_data_entry_offset (hdr)); +} + +/* +* Offsets of . and .. in data space (always block 0) +*/ +static inline xfs_dir2_data_aoff_t +xfs_dir3_data_dot_offset (struct xfs_dir2_data_hdr *hdr) +{ +return xfs_dir3_data_entry_offset (hdr); +} + +static inline xfs_dir2_data_aoff_t +xfs_dir3_data_dotdot_offset (struct xfs_dir2_data_hdr *hdr) +{ +return xfs_dir3_data_dot_offset (hdr) +xfs_dir2_data_entsize (1 ); +} + +static inline xfs_dir2_data_aoff_t +xfs_dir3_data_first_offset (struct xfs_dir2_data_hdr *hdr) +{ +return xfs_dir3_data_dotdot_offset (hdr) +xfs_dir2_data_entsize (2 ); +} + +/* +* location of . and .. in data space (always block 0) +*/ +static inline struct xfs_dir2_data_entry * +xfs_dir3_data_dot_entry_p (struct xfs_dir2_data_hdr *hdr) +{ +return (struct xfs_dir2_data_entry *) + ((char *)hdr +xfs_dir3_data_dot_offset (hdr)); +} + +static inline struct xfs_dir2_data_entry * +xfs_dir3_data_dotdot_entry_p (struct xfs_dir2_data_hdr *hdr) +{ +return (struct xfs_dir2_data_entry *) + ((char *)hdr +xfs_dir3_data_dotdot_offset (hdr)); +} + +static inline struct xfs_dir2_data_entry * +xfs_dir3_data_first_entry_p (struct xfs_dir2_data_hdr *hdr) +{ +return (struct xfs_dir2_data_entry *) + ((char *)hdr +xfs_dir3_data_first_offset (hdr)); +} +/* * Leaf block structures. *
libxfs/xfs_dir2_block.c +90 -36
230 lines not on this page · raw message
libxfs/xfs_dir2_data.c +99 -61
410 lines not on this page · raw message
libxfs/xfs_dir2_leaf.c +4 -2
@@ -133,6 +133,7 @@ xfs_dir2_block_to_leaf(int needlog;/* need to log block header */ int needscan;/* need to rescan bestfree */ xfs_trans_t *tp;/* transaction pointer */ +struct xfs_dir2_data_free *bf;trace_xfs_dir2_block_to_leaf (args);
@@ -161,6 +162,7 @@ xfs_dir2_block_to_leaf(xfs_dir2_data_check (dp, dbp); btp =xfs_dir2_block_tail_p (mp, hdr); blp =xfs_dir2_block_leaf_p (btp); + bf =xfs_dir3_data_bestfree_p (hdr);/* * Set the counts in the leaf header. */
@@ -196,7 +198,7 @@ xfs_dir2_block_to_leaf( ltp =xfs_dir2_leaf_tail_p (mp, leaf); ltp->bestcount =cpu_to_be32 (1 ); bestsp =xfs_dir2_leaf_bests_p (ltp); - bestsp[0 ] = hdr->bestfree[0 ].length; + bestsp[0 ] = bf[0 ].length;/* * Log the data header and leaf bests table. */
@@ -528,7 +530,7 @@ xfs_dir2_leaf_addname(/* * Initialize the block. */ -if ((error =xfs_dir2_data_init (args, use_block, &dbp))) { +if ((error =xfs_dir3_data_init (args, use_block, &dbp))) {xfs_trans_brelse (tp, lbp);return error; }
libxfs/xfs_dir2_node.c +1 -1
@@ -1573,7 +1573,7 @@ xfs_dir2_node_addname_int(if (unlikely ((error =xfs_dir2_grow_inode (args,XFS_DIR2_DATA_SPACE , &dbno)) || - (error =xfs_dir2_data_init (args, dbno, &dbp)))) + (error =xfs_dir3_data_init (args, dbno, &dbp))))return error;/*
libxfs/xfs_dir2_priv.h +2 -2
@@ -30,7 +30,7 @@ extern int xfs_dir_cilookup_result(struct xfs_da_args *args, const unsigned char *name, int len);/* xfs_dir2_block.c */ -extern const struct xfs_buf_ops xfs_dir2_block_buf_ops; +extern const struct xfs_buf_ops xfs_dir3_block_buf_ops;extern int xfs_dir2_block_addname (struct xfs_da_args *args); extern int xfs_dir2_block_getdents(struct xfs_inode *dp, void *dirent,
@@ -61,7 +61,7 @@ xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_unused *dup, int *loghead);extern void xfs_dir2_data_freescan (struct xfs_mount *mp,struct xfs_dir2_data_hdr *hdr,int *loghead); -extern int xfs_dir2_data_init (struct xfs_da_args *args,xfs_dir2_db_t blkno, +extern int xfs_dir3_data_init (struct xfs_da_args *args,xfs_dir2_db_t blkno,struct xfs_buf **bpp);extern void xfs_dir2_data_log_entry (struct xfs_trans *tp,struct xfs_buf *bp,struct xfs_dir2_data_entry *dep);
libxfs/xfs_dir2_sf.c +1 -1
@@ -262,7 +262,7 @@ xfs_dir2_block_to_sf(* Set up to loop over the block's entries. */ btp =xfs_dir2_block_tail_p (mp, hdr); - ptr = (char *)(hdr +1 ); + ptr = (char *)xfs_dir3_data_entry_p (hdr); endptr = (char *)xfs_dir2_block_leaf_p (btp); sfep =xfs_dir2_sf_firstentry (sfp);/*
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 09/48] xfs: add CRC checks to block format directory blocks
Quoted 11 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Now that directory buffers are made from a single struct
xfs_buf, we can add CRC calculation and checking callbacks. While there, add all the fields to the on disk structures for future functionality such asd_typesupport, uuids, block numbers, owner inode, etc.To distinguish between the different on disk formats, change the magic numbers for the new format directory blocks.
Signed-off-by Dave Chinner <[email protected]>
corresponds to commit f5f3d9b016
Quoted 14 lines
--- include/xfs_dir2_format.h | 155 +++++++++++++++++++++++++++++++++++++++++-- libxfs/xfs_dir2_block.c | 126 +++++++++++++++++++++++++---------- libxfs/xfs_dir2_data.c | 160 ++++++++++++++++++++++++++++----------------- libxfs/xfs_dir2_leaf.c | 6 +- libxfs/xfs_dir2_node.c | 2 +- libxfs/xfs_dir2_priv.h | 4 +- libxfs/xfs_dir2_sf.c | 2 +- 7 files changed, 346 insertions(+), 109 deletions(-)include/xfs_dir2_format.h +0
-0
...
include/xfs_dir2_format.h typedef struct xfs_dir2_data_free { · line 250
Quoted 6 lines
include/xfs_dir2_format.h +1
-1@@ -215,11 +247,43 @@ typedef struct xfs_dir2_data_free {*/ typedef struct xfs_dir2_data_hdr { __be32 magic; /* XFS_DIR2_DATA_MAGIC or */ - /* XFS_DIR2_BLOCK_MAGIC */ + /* XFS_DIR2_BLOCK_MAGIC */
This change to remove some tabs does not match the kernel code. Suggest you remove it. Maybe you have done that in one of the syncs later.
include/xfs_dir2_format.h xfs_dir2_block_lookup_int(
Quoted 10 lines
include/xfs_dir2_format.h +1
-1@@ -287,7 +340,7 @@ xfs_dir2_block_addname( mp = dp->i_mount;/* Read the (one and only) directory block into bp. */ - error =xfs_dir2_block_read (tp, dp, &bp); + error =xfs_dir3_block_read (tp, dp, &bp);if (error)return error;@@ -597,7 +650,7 @@ xfs_dir2_block_lookup_int(
It looks like there are a couple changes to xfs_dir2_block_getdents() that are in the corresponding kernel commit but not reflected here. Seems like this function isn't called in the userspace code, so maybe it doesn't matter.
Quoted 9 lines
include/xfs_dir2_format.h +1
-1tp = args->trans; mp = dp->i_mount; - error =xfs_dir2_block_read (tp, dp, &bp); + error =xfs_dir3_block_read (tp, dp, &bp);if (error)return error;@@ -860,9 +913,12 @@ xfs_dir2_leaf_to_block(
...
Quoted 13 lines
libxfs/xfs_dir2_data.c +1
-0@@ -1,5 +1,6 @@/* * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. +* Copyright (c) 2013 Red Hat, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or @@ -49,11 +50,12 @@ __xfs_dir2_data_check(
libxfs/xfs_dir2_data.c __xfs_dir2_data_check( · line 58
Quoted 10 lines
libxfs/xfs_dir2_data.c +3
-2mp = bp->b_target->bt_mount; hdr = bp->b_addr; - bf = hdr->bestfree; - p = (char *)(hdr +1 ); + bf =xfs_dir3_data_bestfree_p (hdr); + p = (char *)xfs_dir3_data_entry_p (hdr);switch (be32_to_cpu (hdr->magic)) {case XFS_DIR2_BLOCK_MAGIC : +case XFS_DIR3_BLOCK_MAGIC :
^^^^^
In the kernel the endian flip is done here, not in the switch parens.
Quoted 24 lines
libxfs/xfs_dir2_data.c +4
-2btp =xfs_dir2_block_tail_p (mp, hdr); lep =xfs_dir2_block_leaf_p (btp); endp = (char *)lep;@@ -132,7 +134,8 @@ __xfs_dir2_data_check( (char *)dep - (char *)hdr); count++; lastfree =0 ; -if (hdr->magic ==cpu_to_be32 (XFS_DIR2_BLOCK_MAGIC )) { +if (hdr->magic ==cpu_to_be32 (XFS_DIR2_BLOCK_MAGIC ) || + hdr->magic ==cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC )) { addr =xfs_dir2_db_off_to_dataptr (mp, mp->m_dirdatablk, (xfs_dir2_data_aoff_t) ((char *)dep - (char *)hdr));@@ -152,7 +155,8 @@ __xfs_dir2_data_check(* Need to have seen all the entries and all the bestfree slots. */ XFS_WANT_CORRUPTED_RETURN (freeseen ==7 ); -if (hdr->magic ==cpu_to_be32 (XFS_DIR2_BLOCK_MAGIC )) { +if (hdr->magic ==cpu_to_be32 (XFS_DIR2_BLOCK_MAGIC ) || + hdr->magic ==cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC )) {for (i = stale =0 ; i <be32_to_cpu (btp->count); i++) {if (lep[i].address ==cpu_to_be32 (XFS_DIR2_NULL_DATAPTR ))
libxfs/xfs_dir2_data.c xfs_dir2_data_reada_verify( · line 207
Quoted 5 lines
libxfs/xfs_dir2_data.c +1
-1@@ -200,7 +204,8 @@ xfs_dir2_data_reada_verify(switch (be32_to_cpu (hdr->magic)) {case XFS_DIR2_BLOCK_MAGIC : - bp->b_ops = &xfs_dir2_block_buf_ops; +case XFS_DIR3_BLOCK_MAGIC :
Also here the endian switch was done differently in the kernel.
Other than those nits this looks fine.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 09/48] xfs: add CRC checks to block format directory blocks
Quoted 32 lines · Ben Myers
Quoted 11 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Now that directory buffers are made from a single struct
xfs_buf, we can add CRC calculation and checking callbacks. While there, add all the fields to the on disk structures for future functionality such asd_typesupport, uuids, block numbers, owner inode, etc.To distinguish between the different on disk formats, change the magic numbers for the new format directory blocks.
Signed-off-by Dave Chinner <[email protected]>corresponds to commit
f5f3d9b016Quoted 14 lines
--- include/xfs_dir2_format.h | 155 +++++++++++++++++++++++++++++++++++++++++-- libxfs/xfs_dir2_block.c | 126 +++++++++++++++++++++++++---------- libxfs/xfs_dir2_data.c | 160 ++++++++++++++++++++++++++++----------------- libxfs/xfs_dir2_leaf.c | 6 +- libxfs/xfs_dir2_node.c | 2 +- libxfs/xfs_dir2_priv.h | 4 +- libxfs/xfs_dir2_sf.c | 2 +- 7 files changed, 346 insertions(+), 109 deletions(-)include/xfs_dir2_format.h +0
-0...
Quoted 9 lines
include/xfs_dir2_format.h typedef struct xfs_dir2_data_free { · line 250
Quoted 6 lines
include/xfs_dir2_format.h +1
-1@@ -215,11 +247,43 @@ typedef struct xfs_dir2_data_free {*/ typedef struct xfs_dir2_data_hdr { __be32 magic; /* XFS_DIR2_DATA_MAGIC or */ - /* XFS_DIR2_BLOCK_MAGIC */ + /* XFS_DIR2_BLOCK_MAGIC */This change to remove some tabs does not match the kernel code. Suggest you remove it. Maybe you have done that in one of the syncs later.
All this has been done in later syncs. I'd suggest that you need to check the current code, as what was committed to the crc-dev branch didn't *exactly* match what was in the kernel code.
Why do you think I spent so much time trying to unify them after this?
Quoted 9 lines
include/xfs_dir2_format.h typedef struct xfs_dir2_data_free { · line 256
Quoted 6 lines
include/xfs_dir2_format.h +3
-0+ bf =xfs_dir3_data_bestfree_p (hdr); + p = (char *)xfs_dir3_data_entry_p (hdr);switch (be32_to_cpu (hdr->magic)) {case XFS_DIR2_BLOCK_MAGIC : +case XFS_DIR3_BLOCK_MAGIC :^^^^^In the kernel the endian flip is done here, not in the switch parens.
See later patches. It's done that way here because the kernel method causes compilation failure. i.e. this patch:
[PATCH 06/49] libxfs: fix byte swapping on constants
modifies the xfsprogs infrastructure to allow the kernel method to be used in userspace, and it swaps all the libxfs code around.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 10/48 xfs: add CRC checking to dir2 free blocks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
This addition follows the same pattern as the dir2 block CRCs, but with a few differences. The main difference is that the free block header is different between the v2 and v3 formats, so an "in-core" free block header has been added and _todisk/_from_disk functions used to abstract the differences in structure format from the code. This is similar to the on-disk superblock versus the in-core superblock setup. The in-core strucutre is populated when the buffer is read from disk, all the in memory checks and modifications are done on the in-core version of the structure which is written back to the buffer before the buffer is logged.
--- db/check.c | 2 +- include/xfs_dir2_format.h | 55 +++++- libxfs/xfs_dir2_leaf.c | 15 +- libxfs/xfs_dir2_node.c | 474 ++++++++++++++++++++++++++++++--------------- repair/phase6.c | 2 +- 5 files changed, 384 insertions(+), 164 deletions(-)
db/check.c +1 -1
@@ -3005,7 +3005,7 @@ process_leaf_node_dir_v2_free( error++;return ; } - maxent =xfs_dir2_free_max_bests (mp); + maxent =xfs_dir3_free_max_bests (mp);if (be32_to_cpu (free->hdr.firstdb) !=xfs_dir2_da_to_db (mp, dabno - mp->m_dirfreeblk) * maxent) {if (!sflag || v)
include/xfs_dir2_format.h +51 -4
83 lines not on this page · raw message
libxfs/xfs_dir2_leaf.c +8 -7
@@ -1477,6 +1477,7 @@ xfs_dir2_node_to_leaf(xfs_mount_t *mp;/* filesystem mount point */ int rval;/* successful free trim? */ xfs_trans_t *tp;/* transaction pointer */ +struct xfs_dir3_icfree_hdr freehdr;/* * There's more than a leaf level in the btree, so there must
@@ -1534,15 +1535,15 @@ xfs_dir2_node_to_leaf(if (error)return error; free = fbp->b_addr; -ASSERT (free->hdr.magic ==cpu_to_be32 (XFS_DIR2_FREE_MAGIC )); -ASSERT (!free->hdr.firstdb); +xfs_dir3_free_hdr_from_disk (&freehdr, free); + +ASSERT (!freehdr.firstdb);/* * Now see if the leafn and free data will fit in a leaf1. * If not, release the buffer and give up. */ -if (xfs_dir2_leaf_size (&leaf->hdr,be32_to_cpu (free->hdr.nvalid)) > - mp->m_dirblksize) { +if (xfs_dir2_leaf_size (&leaf->hdr, freehdr.nvalid) > mp->m_dirblksize) {xfs_trans_brelse (tp, fbp);return 0 ; }
@@ -1563,12 +1564,12 @@ xfs_dir2_node_to_leaf(* Set up the leaf tail from the freespace block. */ ltp =xfs_dir2_leaf_tail_p (mp, leaf); - ltp->bestcount = free->hdr.nvalid; + ltp->bestcount =cpu_to_be32 (freehdr.nvalid);/* * Set up the leaf bests table. */ -memcpy (xfs_dir2_leaf_bests_p (ltp), free->bests, -be32_to_cpu (ltp->bestcount) *sizeof (xfs_dir2_data_off_t)); +memcpy (xfs_dir2_leaf_bests_p (ltp),xfs_dir3_free_bests_p (mp, free), + freehdr.nvalid *sizeof (xfs_dir2_data_off_t));xfs_dir2_leaf_log_bests (tp, lbp,0 ,be32_to_cpu (ltp->bestcount) -1 );xfs_dir2_leaf_log_tail (tp, lbp);xfs_dir2_leaf_check (dp, lbp);
libxfs/xfs_dir2_node.c +323 -151
752 lines not on this page · raw message
repair/phase6.c +1 -1
@@ -1960,7 +1960,7 @@ longform_dir2_check_node(if (be32_to_cpu (free->hdr.magic) !=XFS_DIR2_FREE_MAGIC ||be32_to_cpu (free->hdr.firstdb) != (fdb -XFS_DIR2_FREE_FIRSTDB (mp)) * -xfs_dir2_free_max_bests (mp) || +xfs_dir3_free_max_bests (mp) ||be32_to_cpu (free->hdr.nvalid) <be32_to_cpu (free->hdr.nused)) { do_warn(
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 10/48] xfs: add CRC checking to dir2 free blocks
Quoted 13 lines · Dave Chinner
From: Dave Chinner <[email protected]>
This addition follows the same pattern as the dir2 block CRCs, but with a few differences. The main difference is that the free block header is different between the v2 and v3 formats, so an "in-core" free block header has been added and _todisk/_from_disk functions used to abstract the differences in structure format from the code. This is similar to the on-disk superblock versus the in-core superblock setup. The in-core strucutre is populated when the buffer is read from disk, all the in memory checks and modifications are done on the in-core version of the structure which is written back to the buffer before the buffer is logged.
Quoted 1 line
Signed-off-by Dave Chinner <[email protected]>
Corresponds to cbc8adf8972
Quoted 4 lines
include/xfs_dir2_format.h +0
-0
...
Quoted 8 lines
include/xfs_dir2_format.h +8
-0+static int +xfs_dir3_free_get_buf ( +struct xfs_trans *tp, +struct xfs_inode *dp, +xfs_dir2_db_t fbno, +struct xfs_buf **bpp) +{ +struct xfs_mount *mp = dp->i_mount;
include/xfs_dir2_format.h
Quoted 10 lines
include/xfs_dir2_format.h +10
-0+struct xfs_buf *bp; +int error; +struct xfs_dir3_icfree_hdr hdr; + + error =xfs_da_get_buf (tp, dp,xfs_dir2_db_to_da (mp, fbno), +-1 , &bp,XFS_DATA_FORK ); +if (error) +return error; + + bp->b_ops = &xfs_dir3_free_buf_ops;;
Extra ;
Quoted 7 lines
include/xfs_dir2_format.h +7
-0+ +/* +* Initialize the new block to be empty, and remember +* its first slot as our empty slot. +*/ + hdr.magic =XFS_DIR2_FREE_MAGIC ; + hdr.firstdb =0 ;
include/xfs_dir2_format.h
Quoted 10 lines
include/xfs_dir2_format.h +10
-0+ hdr.nused =0 ; + hdr.nvalid =0 ; +if (xfs_sb_version_hascrc (&mp->m_sb)) { +struct xfs_dir3_free_hdr *hdr3 = bp->b_addr; + + hdr.magic =XFS_DIR3_FREE_MAGIC ; + hdr3->hdr.blkno =cpu_to_be64 (bp->b_bn); + hdr3->hdr.owner =cpu_to_be64 (dp->i_ino); +uuid_copy (&hdr3->hdr.uuid, &mp->m_sb.sb_uuid); +
Extra line.
include/xfs_dir2_format.h xfs_dir2_leafn_rebalance( · line 1034
Quoted 6 lines
include/xfs_dir2_format.h +1
-1@@ -883,7 +1031,7 @@ xfs_dir2_leafn_rebalance( }static int -xfs_dir2_data_block_free( +xfs_dir3_data_block_free(
There were some differences in comments and whitespace between this version and the one in the kernel. I took a look and didn't see any functional changes though.
Quoted 97 lines
include/xfs_dir2_format.h +46
-38@@ -894,59 +1042,68 @@ xfs_dir2_data_block_free( {struct xfs_trans *tp = args->trans;int logfree =0 ; +__be16 *bests; +struct xfs_dir3_icfree_hdr freehdr; -if (!hdr) { -/* One less used entry in the free table. */ -be32_add_cpu (&free->hdr.nused,-1 ); -xfs_dir2_free_log_header (tp, fbp); -/* -* If this was the last entry in the table, we can trim the -* table size back. There might be other entries at the end -* referring to non-existent data blocks, get those too. -*/ -if (findex ==be32_to_cpu (free->hdr.nvalid) -1 ) { -int i;/* free entry index */ +xfs_dir3_free_hdr_from_disk (&freehdr, free); -for (i = findex -1 ; i >=0 ; i--) { -if (free->bests[i] !=cpu_to_be16 (NULLDATAOFF )) -break ; - } - free->hdr.nvalid =cpu_to_be32 (i +1 ); - logfree =0 ; - }else { -/* Not the last entry, just punch it out. */ - free->bests[findex] =cpu_to_be16 (NULLDATAOFF ); - logfree =1 ; - } + bests =xfs_dir3_free_bests_p (tp->t_mountp, free); +if (hdr) {/* -* If there are no useful entries left in the block, -* get rid of the block if we can. +* Data block is not empty, just set the free entry to the new +* value. */ -if (!free->hdr.nused) { -int error; + bests[findex] =cpu_to_be16 (longest); +xfs_dir2_free_log_bests (tp, fbp, findex, findex); +return 0 ; + } - error =xfs_dir2_shrink_inode (args, fdb, fbp); -if (error ==0 ) { - fbp =NULL ; - logfree =0 ; - }else if (error !=ENOSPC || args->total !=0 ) -return error; -/* -* It's possible to get ENOSPC if there is no -* space reservation. In this case some one -* else will eventually get rid of this block. -*/ +/* +* One less used entry in the free table. Unused is not converted +* because we only need to know if it zero +*/ + freehdr.nused--; + +if (findex == freehdr.nvalid -1 ) { +int i;/* free entry index */ + +for (i = findex -1 ; i >=0 ; i--) { +if (bests[i] !=cpu_to_be16 (NULLDATAOFF )) +break ; } + freehdr.nvalid = i +1 ; + logfree =0 ; }else { +/* Not the last entry, just punch it out. */ + bests[findex] =cpu_to_be16 (NULLDATAOFF ); + logfree =1 ; + } + +xfs_dir3_free_hdr_to_disk (free, &freehdr); +xfs_dir2_free_log_header (tp, fbp); + +/* +* If there are no useful entries left in the block, get rid of the +* block if we can. +*/ +if (!freehdr.nused) { +int error; + + error =xfs_dir2_shrink_inode (args, fdb, fbp); +if (error ==0 ) { + fbp =NULL ; + logfree =0 ; + }else if (error !=ENOSPC || args->total !=0 ) +return error;/* -* Data block is not empty, just set the free entry to the new
include/xfs_dir2_format.h xfs_dir2_data_block_free( · line 1106
Quoted 10 lines
include/xfs_dir2_format.h +4
-3-* value. +* It's possible to get ENOSPC if there is no +* space reservation. In this case some one +* else will eventually get rid of this block. */ - free->bests[findex] =cpu_to_be16 (longest); - logfree =1 ; } +
Extra line
include/xfs_dir2_format.h xfs_dir2_node_addname_int( · line 1705
Quoted 11 lines
include/xfs_dir2_format.h +2
-1@@ -1532,20 +1697,26 @@ xfs_dir2_node_addname_int(if (!fbp)continue ; free = fbp->b_addr; -ASSERT (free->hdr.magic ==cpu_to_be32 (XFS_DIR2_FREE_MAGIC )); findex =0 ; }/* * Look at the current free entry. Is it good enough? +* +* The bests initialisation should be wher eteh bufer is read in
where the
include/xfs_dir2_format.h xfs_dir2_node_addname_int( · line 1707
Quoted 2 lines
include/xfs_dir2_format.h +2
-0+* the above branch. But gcc is too stupid to realise that bests +* iand the freehdr are actually initialised if they are placed
and
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 11/48 xfs: add CRC checking to dir2 data blocks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
This addition follows the same pattern as the dir2 block CRCs.
--- include/xfs_dir2_format.h | 21 +++++----- libxfs/xfs_dir2_block.c | 20 ++++----- libxfs/xfs_dir2_data.c | 98 +++++++++++++++++++++++++++++++-------------- libxfs/xfs_dir2_leaf.c | 59 ++++++++++++++++----------- libxfs/xfs_dir2_node.c | 39 ++++++++++-------- libxfs/xfs_dir2_priv.h | 12 +++--- 6 files changed, 152 insertions(+), 97 deletions(-)
include/xfs_dir2_format.h +9 -12
@@ -277,7 +277,8 @@ struct xfs_dir3_data_hdr {static inline struct xfs_dir2_data_free *xfs_dir3_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) { -if (hdr->magic ==cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC )) { +if (hdr->magic ==cpu_to_be32 (XFS_DIR3_DATA_MAGIC ) || + hdr->magic ==cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC )) {struct xfs_dir3_data_hdr *hdr3 = (struct xfs_dir3_data_hdr *)hdr;return hdr3->best_free; }
@@ -339,17 +340,6 @@ xfs_dir2_data_unused_tag_p(struct xfs_dir2_data_unused *dup) be16_to_cpu(dup->length) - sizeof(__be16)); } -static inline struct xfs_dir2_data_unused * -xfs_dir3_data_unused_p (struct xfs_dir2_data_hdr *hdr) -{ -if (hdr->magic ==cpu_to_be32 (XFS_DIR3_BLOCK_MAGIC )) { -return (struct xfs_dir2_data_unused *) - ((char *)hdr +sizeof (struct xfs_dir3_data_hdr )); - } -return (struct xfs_dir2_data_unused *) - ((char *)hdr +sizeof (struct xfs_dir2_data_hdr )); -} -static inline size_t xfs_dir3_data_hdr_size (bool dir3) {
@@ -373,6 +363,13 @@ xfs_dir3_data_entry_p(struct xfs_dir2_data_hdr *hdr) ((char *)hdr +xfs_dir3_data_entry_offset (hdr)); } +static inline struct xfs_dir2_data_unused * +xfs_dir3_data_unused_p (struct xfs_dir2_data_hdr *hdr) +{ +return (struct xfs_dir2_data_unused *) + ((char *)hdr +xfs_dir3_data_entry_offset (hdr)); +} +/* * Offsets of . and .. in data space (always block 0) */
libxfs/xfs_dir2_block.c +11 -9
@@ -59,7 +59,7 @@ xfs_dir3_block_verify(if (hdr3->magic !=cpu_to_be32 (XFS_DIR2_BLOCK_MAGIC ))return false; } -if (__xfs_dir2_data_check (NULL , bp)) +if (__xfs_dir3_data_check (NULL , bp))return false;return true; }
@@ -535,7 +535,7 @@ xfs_dir2_block_addname(xfs_dir2_data_log_header (tp, bp);xfs_dir2_block_log_tail (tp, bp);xfs_dir2_data_log_entry (tp, bp, dep); -xfs_dir2_data_check (dp, bp); +xfs_dir3_data_check (dp, bp);return 0 ; }
@@ -604,7 +604,7 @@ xfs_dir2_block_lookup( dp = args->dp; mp = dp->i_mount; hdr = bp->b_addr; -xfs_dir2_data_check (dp, bp); +xfs_dir3_data_check (dp, bp); btp =xfs_dir2_block_tail_p (mp, hdr); blp =xfs_dir2_block_leaf_p (btp);/*
@@ -655,7 +655,7 @@ xfs_dir2_block_lookup_int(return error; hdr = bp->b_addr; -xfs_dir2_data_check (dp, bp); +xfs_dir3_data_check (dp, bp); btp =xfs_dir2_block_tail_p (mp, hdr); blp =xfs_dir2_block_leaf_p (btp);/*
@@ -792,7 +792,7 @@ xfs_dir2_block_removename(xfs_dir2_data_freescan (mp, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (tp, bp); -xfs_dir2_data_check (dp, bp); +xfs_dir3_data_check (dp, bp);/* * See if the size as a shortform is good enough. */
@@ -849,7 +849,7 @@ xfs_dir2_block_replace(*/ dep->inumber =cpu_to_be64 (args->inumber);xfs_dir2_data_log_entry (args->trans, bp, dep); -xfs_dir2_data_check (dp, bp); +xfs_dir3_data_check (dp, bp);return 0 ; }
@@ -930,12 +930,14 @@ xfs_dir2_leaf_to_block(* Read the data block if we don't already have it, give up if it fails. */ if (!dbp) { - error =xfs_dir2_data_read (tp, dp, mp->m_dirdatablk,-1 , &dbp); + error =xfs_dir3_data_read (tp, dp, mp->m_dirdatablk,-1 , &dbp);if (error)return error; } hdr = dbp->b_addr; -ASSERT (hdr->magic ==cpu_to_be32 (XFS_DIR2_DATA_MAGIC )); +ASSERT (hdr->magic ==cpu_to_be32 (XFS_DIR2_DATA_MAGIC ) || + hdr->magic ==cpu_to_be32 (XFS_DIR3_DATA_MAGIC )); +/* * Size of the "leaf" area in the block. */
@@ -1213,6 +1215,6 @@ xfs_dir2_sf_to_block(ASSERT (needscan ==0 );xfs_dir2_block_log_leaf (tp, bp,0 ,be32_to_cpu (btp->count) -1 );xfs_dir2_block_log_tail (tp, bp); -xfs_dir2_data_check (dp, bp); +xfs_dir3_data_check (dp, bp);return 0 ; }
libxfs/xfs_dir2_data.c +68 -30
222 lines not on this page · raw message
libxfs/xfs_dir2_leaf.c +35 -24
179 lines not on this page · raw message
libxfs/xfs_dir2_node.c +23 -16
@@ -737,13 +737,13 @@ xfs_dir2_leafn_lookup_for_entry(ASSERT (state->extravalid); curbp = state->extrablk.bp; }else { - error =xfs_dir2_data_read (tp, dp, + error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (mp, newdb),-1 , &curbp);if (error)return error; } -xfs_dir2_data_check (dp, curbp); +xfs_dir3_data_check (dp, curbp); curdb = newdb; }/*
@@ -771,7 +771,7 @@ xfs_dir2_leafn_lookup_for_entry( state->extrablk.index = (int )((char *)dep - (char *)curbp->b_addr); state->extrablk.magic =XFS_DIR2_DATA_MAGIC ; - curbp->b_ops = &xfs_dir2_data_buf_ops; + curbp->b_ops = &xfs_dir3_data_buf_ops;if (cmp ==XFS_CMP_EXACT )return XFS_ERROR (EEXIST ); }
@@ -786,7 +786,7 @@ xfs_dir2_leafn_lookup_for_entry( state->extrablk.index =-1 ; state->extrablk.blkno = curdb; state->extrablk.magic =XFS_DIR2_DATA_MAGIC ; - curbp->b_ops = &xfs_dir2_data_buf_ops; + curbp->b_ops = &xfs_dir3_data_buf_ops; }else {/* If the curbp is not the CI match block, drop it */ if (state->extrablk.bp != curbp)
@@ -1136,6 +1136,7 @@ xfs_dir2_leafn_remove(int needlog;/* need to log data header */ int needscan;/* need to rescan data frees */ xfs_trans_t *tp;/* transaction pointer */ +struct xfs_dir2_data_free *bf;/* bestfree table */ trace_xfs_dir2_leafn_remove (args, index);
@@ -1170,7 +1171,8 @@ xfs_dir2_leafn_remove( dbp = dblk->bp; hdr = dbp->b_addr; dep = (xfs_dir2_data_entry_t *)((char *)hdr + off); - longest =be16_to_cpu (hdr->bestfree[0 ].length); + bf =xfs_dir3_data_bestfree_p (hdr); + longest =be16_to_cpu (bf[0 ].length); needlog = needscan =0 ;xfs_dir2_data_make_free (tp, dbp, off,xfs_dir2_data_entsize (dep->namelen), &needlog, &needscan);
@@ -1182,12 +1184,12 @@ xfs_dir2_leafn_remove(xfs_dir2_data_freescan (mp, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (tp, dbp); -xfs_dir2_data_check (dp, dbp); +xfs_dir3_data_check (dp, dbp);/* * If the longest data block freespace changes, need to update * the corresponding freeblock entry. */ -if (longest <be16_to_cpu (hdr->bestfree[0 ].length)) { +if (longest <be16_to_cpu (bf[0 ].length)) {int error;/* error return value */ struct xfs_buf *fbp;/* freeblock buffer */ xfs_dir2_db_t fdb;/* freeblock block number */
@@ -1217,12 +1219,13 @@ xfs_dir2_leafn_remove(* Calculate which entry we need to fix. */ findex =xfs_dir2_db_to_fdindex (mp, db); - longest =be16_to_cpu (hdr->bestfree[0 ].length); + longest =be16_to_cpu (bf[0 ].length);/* * If the data block is now empty we can get rid of it * (usually). */ -if (longest == mp->m_dirblksize - (uint )sizeof (*hdr)) { +if (longest == mp->m_dirblksize - +xfs_dir3_data_entry_offset (hdr)) {/* * Try to punch out the data block. */
@@ -1596,6 +1599,7 @@ xfs_dir2_node_addname_int(xfs_trans_t *tp;/* transaction pointer */ __be16 *bests;struct xfs_dir3_icfree_hdr freehdr; +struct xfs_dir2_data_free *bf; dp = args->dp; mp = dp->i_mount;
@@ -1853,7 +1857,8 @@ xfs_dir2_node_addname_int(* change again. */ hdr = dbp->b_addr; - bests[findex] = hdr->bestfree[0 ].length; + bf =xfs_dir3_data_bestfree_p (hdr); + bests[findex] = bf[0 ].length; logfree =1 ; }/*
@@ -1869,19 +1874,20 @@ xfs_dir2_node_addname_int(/* * Read the data block in. */ - error =xfs_dir2_data_read (tp, dp,xfs_dir2_db_to_da (mp, dbno), + error =xfs_dir3_data_read (tp, dp,xfs_dir2_db_to_da (mp, dbno),-1 , &dbp);if (error)return error; hdr = dbp->b_addr; + bf =xfs_dir3_data_bestfree_p (hdr); logfree =0 ; } -ASSERT (be16_to_cpu (hdr->bestfree[0 ].length) >= length); +ASSERT (be16_to_cpu (bf[0 ].length) >= length);/* * Point to the existing unused space. */ dup = (xfs_dir2_data_unused_t *) - ((char *)hdr +be16_to_cpu (hdr->bestfree[0 ].offset)); + ((char *)hdr +be16_to_cpu (bf[0 ].offset)); needscan = needlog =0 ;/* * Mark the first part of the unused space, inuse for us.
@@ -1913,8 +1919,8 @@ xfs_dir2_node_addname_int(* If the freespace entry is now wrong, update it. */ bests =xfs_dir3_free_bests_p (mp, free);/* gcc is so stupid */ -if (be16_to_cpu (bests[findex]) !=be16_to_cpu (hdr->bestfree[0 ].length)) { - bests[findex] = hdr->bestfree[0 ].length; +if (be16_to_cpu (bests[findex]) !=be16_to_cpu (bf[0 ].length)) { + bests[findex] = bf[0 ].length; logfree =1 ; }/*
@@ -2104,7 +2110,8 @@ xfs_dir2_node_replace(* Point to the data entry. */ hdr = state->extrablk.bp->b_addr; -ASSERT (hdr->magic ==cpu_to_be32 (XFS_DIR2_DATA_MAGIC )); +ASSERT (hdr->magic ==cpu_to_be32 (XFS_DIR2_DATA_MAGIC ) || + hdr->magic ==cpu_to_be32 (XFS_DIR3_DATA_MAGIC )); dep = (xfs_dir2_data_entry_t *) ((char *)hdr +xfs_dir2_dataptr_to_off (state->mp,be32_to_cpu (lep->address)));
libxfs/xfs_dir2_priv.h +6 -6
@@ -43,17 +43,17 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,/* xfs_dir2_data.c */ #ifdef DEBUG -#define xfs_dir2_data_check (dp,bp) __xfs_dir2_data_check(dp, bp); +#define xfs_dir3_data_check (dp,bp) __xfs_dir3_data_check(dp, bp);#else -#define xfs_dir2_data_check (dp,bp) +#define xfs_dir3_data_check (dp,bp)#endif -extern const struct xfs_buf_ops xfs_dir2_data_buf_ops; +extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; -extern int __xfs_dir2_data_check (struct xfs_inode *dp,struct xfs_buf *bp); -extern int xfs_dir2_data_read (struct xfs_trans *tp,struct xfs_inode *dp, +extern int __xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp); +extern int xfs_dir3_data_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t bno,xfs_daddr_t mapped_bno,struct xfs_buf **bpp); -extern int xfs_dir2_data_readahead (struct xfs_trans *tp,struct xfs_inode *dp, +extern int xfs_dir3_data_readahead (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t bno,xfs_daddr_t mapped_bno); extern struct xfs_dir2_data_free *
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 11/48] xfs: add CRC checking to dir2 data blocks
Quoted 4 lines · Dave Chinner
From: Dave Chinner <[email protected]>
This addition follows the same pattern as the dir2 block CRCs.
Corresponds to 33363feed16.
Quoted 1 line
Signed-off-by Dave Chinner <[email protected]>
...
Quoted 14 lines
libxfs/xfs_dir2_block.c +1
-1@@ -59,7 +59,7 @@ xfs_dir3_block_verify(if (hdr3->magic !=cpu_to_be32 (XFS_DIR2_BLOCK_MAGIC ))return false; } -if (__xfs_dir2_data_check (NULL , bp)) +if (__xfs_dir3_data_check (NULL , bp))return false;return true; }
libxfs/xfs_dir2_block.c xfs_dir2_block_addname( · line 540
Quoted 7 lines
libxfs/xfs_dir2_block.c +1
-1@@ -535,7 +535,7 @@ xfs_dir2_block_addname(xfs_dir2_data_log_header (tp, bp);xfs_dir2_block_log_tail (tp, bp);xfs_dir2_data_log_entry (tp, bp, dep); -xfs_dir2_data_check (dp, bp); +xfs_dir3_data_check (dp, bp);return 0 ; }
Changes to xfs_dir2_block_getdents in the kernel are not included here. Again, it seems that we don't have this function in userspace.
Quoted 14 lines
libxfs/xfs_dir2_data.c +1
-1@@ -25,7 +25,7 @@* Return 0 is the buffer is good, otherwise an error. */ int -__xfs_dir2_data_check ( +__xfs_dir3_data_check (struct xfs_inode *dp,/* incore inode pointer */ struct xfs_buf *bp)/* data block's buffer */ {
libxfs/xfs_dir2_data.c __xfs_dir2_data_check( · line 64
Quoted 4 lines
libxfs/xfs_dir2_data.c +1
-0@@ -61,6 +61,7 @@ __xfs_dir2_data_check( endp = (char *)lep;break ;case XFS_DIR2_DATA_MAGIC : +case XFS_DIR3_DATA_MAGIC :
The endian swap was done in the switch parens in the kernel
Quoted 10 lines
libxfs/xfs_dir2_data.c +1
-1@@ -196,7 +203,7 @@ xfs_dir2_data_verify(* format buffer or a data format buffer on readahead. */ static void -xfs_dir2_data_reada_verify ( +xfs_dir3_data_reada_verify (struct xfs_buf *bp) {struct xfs_mount *mp = bp->b_target->bt_mount;
libxfs/xfs_dir2_data.c xfs_dir2_data_reada_verify( · line 220
Quoted 6 lines
libxfs/xfs_dir2_data.c +2
-1@@ -209,7 +216,8 @@ xfs_dir2_data_reada_verify( bp->b_ops->verify_read (bp);return ;case XFS_DIR2_DATA_MAGIC : -xfs_dir2_data_verify (bp); +case XFS_DIR3_DATA_MAGIC : +xfs_dir3_data_verify (bp);
Also here the endian swap was done differently in the kernel.
libxfs/xfs_dir2_leaf.c xfs_dir2_leaf_addname( · line 378
Quoted 11 lines
libxfs/xfs_dir2_leaf.c +1
-0@@ -369,6 +373,7 @@ xfs_dir2_leaf_addname(__be16 *tagp;/* end of data entry */ xfs_trans_t *tp;/* transaction pointer */ xfs_dir2_db_t use_block;/* data block number */ +struct xfs_dir2_data_free *bf;/* bestfree table */ trace_xfs_dir2_leaf_addname (args);
Seem to be missing changes to xfs_dir2_leaf_readbuf, which we don't have in userspace...
Looks fine.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 12/48 xfs: add CRC checking to dir2 leaf blocks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
This addition follows the same pattern as the dir2 block CRCs. Seeing as both LEAF1 and LEAFN types need to changed at the same time, this is a pretty large amount of change. leaf block headers need to be abstracted away from the on-disk structures (struct xfs_dir3_icleaf_hdr), as do the base leaf entry locations.
This header abstract allows the in-core header and leaf entry location to be passed around instead of the leaf block itself. This saves a lot of converting individual variables from on-disk format to host format where they are used, so there's a good chance that the compiler will be able to produce much more optimal code as it's not having to byteswap variables all over the place.
--- db/check.c | 2 +- db/dir2.c | 2 +- include/xfs_da_btree.h | 23 ++ include/xfs_dir2_format.h | 60 +++- libxfs/xfs_da_btree.c | 45 ++- libxfs/xfs_dir2_block.c | 19 +- libxfs/xfs_dir2_leaf.c | 786 ++++++++++++++++++++++++++++----------------- libxfs/xfs_dir2_node.c | 475 +++++++++++++++------------ libxfs/xfs_dir2_priv.h | 32 +- repair/dir2.c | 12 +- repair/phase6.c | 14 +- 11 files changed, 938 insertions(+), 532 deletions(-)
db/check.c +1 -1
@@ -3140,7 +3140,7 @@ process_leaf_node_dir_v2_int( error++;return ; } - lep = leaf->ents; + lep =xfs_dir3_leaf_ents_p (leaf);for (i = stale =0 ; i <be16_to_cpu (leaf->hdr.count); i++) {if (be32_to_cpu (lep[i].address) ==XFS_DIR2_NULL_DATAPTR ) stale++;
db/dir2.c +1 -1
@@ -80,7 +80,7 @@ const field_t dir2_flds[] = { FLD_COUNT, TYP_NONE }, {"lbests" ,FLDT_DIR2_DATA_OFF , dir2_leaf_bests_offset, dir2_leaf_bests_count, FLD_ARRAY|FLD_OFFSET|FLD_COUNT, TYP_NONE }, - { "lents", FLDT_DIR2_LEAF_ENTRY, OI(LOFF(ents)), dir2_leaf_ents_count, + { "lents", FLDT_DIR2_LEAF_ENTRY, OI(LOFF(__ents)), dir2_leaf_ents_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "ltail", FLDT_DIR2_LEAF_TAIL, dir2_leaf_tail_offset, dir2_leaf_tail_count, FLD_OFFSET|FLD_COUNT, TYP_NONE },
include/xfs_da_btree.h +23 -0
@@ -47,6 +47,29 @@ typedef struct xfs_da_blkinfo { } xfs_da_blkinfo_t;/* +* CRC enabled directory structure types +* +* The headers change size for the additional verification information, but +* otherwise the tree layouts and contents are unchanged. +*/ +#define XFS_DIR3_LEAF1_MAGIC 0x3df1/* magic number: v2 dirlf single blks */ +#define XFS_DIR3_LEAFN_MAGIC 0x3dff/* magic number: v2 dirlf multi blks */ + +struct xfs_da3_blkinfo { +/* +* the node link manipulation code relies on the fact that the first +* element of this structure is the struct xfs_da_blkinfo so it can +* ignore the differences in the rest of the structures. +*/ +struct xfs_da_blkinfo hdr; +__be32 crc;/* CRC of block */ +__be64 blkno;/* first block of the buffer */ +__be64 lsn;/* sequence number of last write */ +uuid_t uuid;/* filesystem we belong to */ +__be64 owner;/* inode that owns the block */ +}; + +/* * This is the structure of the root and intermediate nodes in the Btree. * The leaf nodes are defined above. *
include/xfs_dir2_format.h +53 -7
88 lines not on this page · raw message
libxfs/xfs_da_btree.c +35 -10
104 lines not on this page · raw message
libxfs/xfs_dir2_block.c +12 -7
@@ -897,6 +897,8 @@ xfs_dir2_leaf_to_block(__be16 *tagp;/* end of entry (tag) */ int to;/* block/leaf to index */ xfs_trans_t *tp;/* transaction pointer */ +struct xfs_dir2_leaf_entry *ents; +struct xfs_dir3_icleaf_hdr leafhdr;trace_xfs_dir2_leaf_to_block (args);
@@ -904,8 +906,12 @@ xfs_dir2_leaf_to_block( tp = args->trans; mp = dp->i_mount; leaf = lbp->b_addr; -ASSERT (leaf->hdr.info.magic ==cpu_to_be16 (XFS_DIR2_LEAF1_MAGIC )); +xfs_dir3_leaf_hdr_from_disk (&leafhdr, leaf); + ents =xfs_dir3_leaf_ents_p (leaf); ltp =xfs_dir2_leaf_tail_p (mp, leaf); + +ASSERT (leafhdr.magic ==XFS_DIR2_LEAF1_MAGIC || + leafhdr.magic ==XFS_DIR3_LEAF1_MAGIC );/* * If there are data blocks other than the first one, take this * opportunity to remove trailing empty data blocks that may have
@@ -942,7 +948,7 @@ xfs_dir2_leaf_to_block(* Size of the "leaf" area in the block. */ size = (uint )sizeof (xfs_dir2_block_tail_t) + - (uint )sizeof (*lep) * (be16_to_cpu (leaf->hdr.count) -be16_to_cpu (leaf->hdr.stale)); + (uint )sizeof (*lep) * (leafhdr.count - leafhdr.stale);/* * Look at the last data entry. */
@@ -971,18 +977,17 @@ xfs_dir2_leaf_to_block(* Initialize the block tail. */ btp =xfs_dir2_block_tail_p (mp, hdr); - btp->count =cpu_to_be32 (be16_to_cpu (leaf->hdr.count) -be16_to_cpu (leaf->hdr.stale)); + btp->count =cpu_to_be32 (leafhdr.count - leafhdr.stale); btp->stale =0 ;xfs_dir2_block_log_tail (tp, dbp);/* * Initialize the block leaf area. We compact out stale entries. */ lep =xfs_dir2_block_leaf_p (btp); -for (from = to =0 ; from <be16_to_cpu (leaf->hdr.count); from++) { -if (leaf->ents[from].address == -cpu_to_be32 (XFS_DIR2_NULL_DATAPTR )) +for (from = to =0 ; from < leafhdr.count; from++) { +if (ents[from].address ==cpu_to_be32 (XFS_DIR2_NULL_DATAPTR ))continue ; - lep[to++] = leaf->ents[from]; + lep[to++] = ents[from]; }ASSERT (to ==be32_to_cpu (btp->count));xfs_dir2_block_log_leaf (tp, dbp,0 ,be32_to_cpu (btp->count) -1 );
libxfs/xfs_dir2_leaf.c +500 -286
1,353 lines not on this page · raw message
libxfs/xfs_dir2_node.c +277 -198
796 lines not on this page · raw message
libxfs/xfs_dir2_priv.h +20 -12
@@ -77,24 +77,25 @@ extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp, xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);/* xfs_dir2_leaf.c */ -extern const struct xfs_buf_ops xfs_dir2_leafn_buf_ops; +extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops; -extern int xfs_dir2_leafn_read (struct xfs_trans *tp,struct xfs_inode *dp, +extern int xfs_dir3_leafn_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t fbno,xfs_daddr_t mappedbno,struct xfs_buf **bpp);extern int xfs_dir2_block_to_leaf (struct xfs_da_args *args,struct xfs_buf *dbp);extern int xfs_dir2_leaf_addname (struct xfs_da_args *args); -extern void xfs_dir2_leaf_compact (struct xfs_da_args *args, -struct xfs_buf *bp); -extern void xfs_dir2_leaf_compact_x1 (struct xfs_buf *bp,int *indexp, +extern void xfs_dir3_leaf_compact (struct xfs_da_args *args, +struct xfs_dir3_icleaf_hdr *leafhdr,struct xfs_buf *bp); +extern void xfs_dir3_leaf_compact_x1 (struct xfs_dir3_icleaf_hdr *leafhdr, +struct xfs_dir2_leaf_entry *ents,int *indexp,int *lowstalep,int *highstalep,int *lowlogp,int *highlogp);extern int xfs_dir2_leaf_getdents (struct xfs_inode *dp,void *dirent,size_t bufsize,xfs_off_t *offset,filldir_t filldir); -extern int xfs_dir2_leaf_init (struct xfs_da_args *args,xfs_dir2_db_t bno, -struct xfs_buf **bpp,int magic); -extern void xfs_dir2_leaf_log_ents (struct xfs_trans *tp,struct xfs_buf *bp, +extern int xfs_dir3_leaf_get_buf (struct xfs_da_args *args,xfs_dir2_db_t bno, +struct xfs_buf **bpp,__uint16_t magic); +extern void xfs_dir3_leaf_log_ents (struct xfs_trans *tp,struct xfs_buf *bp,int first,int last); -extern void xfs_dir2_leaf_log_header (struct xfs_trans *tp, +extern void xfs_dir3_leaf_log_header (struct xfs_trans *tp,struct xfs_buf *bp);extern int xfs_dir2_leaf_lookup (struct xfs_da_args *args);extern int xfs_dir2_leaf_removename (struct xfs_da_args *args);
@@ -104,11 +105,18 @@ extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,extern int xfs_dir2_leaf_trim_data (struct xfs_da_args *args,struct xfs_buf *lbp,xfs_dir2_db_t db);extern struct xfs_dir2_leaf_entry * -xfs_dir2_leaf_find_entry (struct xfs_dir2_leaf *leaf,int index,int compact, -int lowstale,int highstale, -int *lfloglow,int *lfloghigh); +xfs_dir3_leaf_find_entry (struct xfs_dir3_icleaf_hdr *leafhdr, +struct xfs_dir2_leaf_entry *ents,int index,int compact, +int lowstale,int highstale,int *lfloglow,int *lfloghigh);extern int xfs_dir2_node_to_leaf (struct xfs_da_state *state); +extern void xfs_dir3_leaf_hdr_from_disk (struct xfs_dir3_icleaf_hdr *to, +struct xfs_dir2_leaf *from); +extern void xfs_dir3_leaf_hdr_to_disk (struct xfs_dir2_leaf *to, +struct xfs_dir3_icleaf_hdr *from); +extern bool xfs_dir3_leaf_check_int (struct xfs_mount *mp, +struct xfs_dir3_icleaf_hdr *hdr,struct xfs_dir2_leaf *leaf); +/* xfs_dir2_node.c */ extern int xfs_dir2_leaf_to_node (struct xfs_da_args *args,struct xfs_buf *lbp);
repair/dir2.c +7 -5
@@ -1627,24 +1627,26 @@ process_leaf_block_dir2( {int i;int stale; +struct xfs_dir2_leaf_entry *ents; + + ents =xfs_dir3_leaf_ents_p (leaf);for (i = stale =0 ; i <be16_to_cpu (leaf->hdr.count); i++) { -if ((char *)&leaf->ents[i] >= (char *)leaf + mp->m_dirblksize) { +if ((char *)&ents[i] >= (char *)leaf + mp->m_dirblksize) {do_warn (_ ("bad entry count in block %u of directory inode %" PRIu64"\n" ), da_bno, ino);return 1 ; } -if (be32_to_cpu (leaf->ents[i].address) ==XFS_DIR2_NULL_DATAPTR ) +if (be32_to_cpu (ents[i].address) ==XFS_DIR2_NULL_DATAPTR ) stale++; -else if (be32_to_cpu (leaf->ents[i].hashval) < last_hashval) { +else if (be32_to_cpu (ents[i].hashval) < last_hashval) {do_warn (_ ("bad hash ordering in block %u of directory inode %" PRIu64"\n" ), da_bno, ino);return 1 ; } - *next_hashval = last_hashval = -be32_to_cpu (leaf->ents[i].hashval); + *next_hashval = last_hashval =be32_to_cpu (ents[i].hashval); }if (stale !=be16_to_cpu (leaf->hdr.stale)) { do_warn(
repair/phase6.c +9 -5
@@ -1826,6 +1826,7 @@ longform_dir2_check_leaf(xfs_dir2_leaf_t *leaf;xfs_dir2_leaf_tail_t *ltp;int seeval; +struct xfs_dir2_leaf_entry *ents; da_bno = mp->m_dirleafblk;if (libxfs_da_read_buf (NULL , ip, da_bno,-1 , &bp,XFS_DATA_FORK ,NULL )) {
@@ -1835,6 +1836,7 @@ longform_dir2_check_leaf(/* NOTREACHED */ } leaf = bp->b_addr; + ents =xfs_dir3_leaf_ents_p (leaf); ltp =xfs_dir2_leaf_tail_p (mp, leaf); bestsp =xfs_dir2_leaf_bests_p (ltp); if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR2_LEAF1_MAGIC ||
@@ -1843,8 +1845,8 @@ longform_dir2_check_leaf( be16_to_cpu(leaf->hdr.count) < be16_to_cpu(leaf->hdr.stale) || be16_to_cpu(leaf->hdr.count) > - xfs_dir2_max_leaf_ents(mp) || - (char *)&leaf->ents[be16_to_cpu( + xfs_dir3_max_leaf_ents(mp, leaf) || + (char *)&ents[be16_to_cpu( leaf->hdr.count)] > (char *)bestsp) { do_warn( _("leaf block %u for directory inode %" PRIu64 " bad header\n"),
@@ -1852,7 +1854,7 @@ longform_dir2_check_leaf(libxfs_putbuf (bp);return 1 ; } - seeval =dir_hash_see_all (hashtab, leaf->ents, + seeval =dir_hash_see_all (hashtab, ents,be16_to_cpu (leaf->hdr.count),be16_to_cpu (leaf->hdr.stale));if (dir_hash_check (hashtab, ip, seeval)) {
@@ -1895,6 +1897,7 @@ longform_dir2_check_node(xfs_fileoff_t next_da_bno;int seeval =0 ;int used; +struct xfs_dir2_leaf_entry *ents; for (da_bno = mp->m_dirleafblk, next_da_bno = 0; next_da_bno != NULLFILEOFF && da_bno < mp->m_dirfreeblk;
@@ -1910,6 +1913,7 @@ longform_dir2_check_node(return 1 ; } leaf = bp->b_addr; + ents =xfs_dir3_leaf_ents_p (leaf);if (be16_to_cpu (leaf->hdr.info.magic) !=XFS_DIR2_LEAFN_MAGIC ) {if (be16_to_cpu (leaf->hdr.info.magic) ==XFS_DA_NODE_MAGIC ) {
@@ -1923,7 +1927,7 @@ longform_dir2_check_node(libxfs_putbuf (bp);return 1 ; } -if (be16_to_cpu (leaf->hdr.count) >xfs_dir2_max_leaf_ents (mp) || +if (be16_to_cpu (leaf->hdr.count) >xfs_dir3_max_leaf_ents (mp, leaf) ||be16_to_cpu (leaf->hdr.count) <be16_to_cpu (leaf->hdr.stale)) { do_warn(
@@ -1932,7 +1936,7 @@ longform_dir2_check_node(libxfs_putbuf (bp);return 1 ; } - seeval =dir_hash_see_all (hashtab, leaf->ents, + seeval =dir_hash_see_all (hashtab, ents,be16_to_cpu (leaf->hdr.count),be16_to_cpu (leaf->hdr.stale));libxfs_putbuf (bp);
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 12/48] xfs: add CRC checking to dir2 leaf blocks
Quoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
This addition follows the same pattern as the dir2 block CRCs. Seeing as both LEAF1 and LEAFN types need to changed at the same time, this is a pretty large amount of change. leaf block headers need to be abstracted away from the on-disk structures (struct
xfs_dir3_icleaf_hdr), as do the base leaf entry locations.
Quoted 8 lines
This header abstract allows the in-core header and leaf entry location to be passed around instead of the leaf block itself. This saves a lot of converting individual variables from on-disk format to host format where they are used, so there's a good chance that the compiler will be able to produce much more optimal code as it's not having to byteswap variables all over the place.
Signed-off-by Dave Chinner <[email protected]>
Looks good. Note that xfs_dir3_leafn_read_verify and xfs_dir3_leafn_write_verify are static in the kernel but not in userspace.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 12/48] xfs: add CRC checking to dir2 leaf blocks
Quoted 16 lines · Ben Myers
Quoted 15 lines · Dave Chinner
From: Dave Chinner <[email protected]>
This addition follows the same pattern as the dir2 block CRCs. Seeing as both LEAF1 and LEAFN types need to changed at the same time, this is a pretty large amount of change. leaf block headers need to be abstracted away from the on-disk structures (struct
xfs_dir3_icleaf_hdr), as do the base leaf entry locations.This header abstract allows the in-core header and leaf entry location to be passed around instead of the leaf block itself. This saves a lot of converting individual variables from on-disk format to host format where they are used, so there's a good chance that the compiler will be able to produce much more optimal code as it's not having to byteswap variables all over the place.
Quoted 6 lines
Quoted 1 line
Signed-off-by Dave Chinner <[email protected]>Looks good. Note that
xfs_dir3_leafn_read_verifyandxfs_dir3_leafn_write_verifyare static in the kernel but not in userspace.Reviewed-by Ben Myers <[email protected]>
corresponds to commit 24df33b45ecf5.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 13/48 xfs: shortform directory offsets change for dir3 format
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Because the header size for the CRC enabled directory blocks is larger, the offset of the first entry into a directory block is different to the dir2 format. The shortform directory stores the dirent's offset so that it doesn't change when moving from shortform to block form and back again, and hence it needs to take into account the different header sizes to maintain the correct offsets.
--- db/check.c | 2 +- include/xfs_dir2_format.h | 25 ++++++++++++++----------- libxfs/xfs_dir2_sf.c | 6 +++--- repair/dir2.c | 7 ++++--- 4 files changed, 22 insertions(+), 18 deletions(-)
db/check.c +1 -1
@@ -3418,7 +3418,7 @@ process_sf_dir_v2(dbprintf (_ ("dir %lld entry . %lld\n" ), id->ino, id->ino); (*dot)++; sfe =xfs_dir2_sf_firstentry (&sf->hdr); - offset =XFS_DIR2_DATA_FIRST_OFFSET ; + offset =XFS_DIR3_DATA_FIRST_OFFSET (mp);for (i = sf->hdr.count -1 , i8 =0 ; i >=0 ; i--) {if ((__psint_t )sfe +xfs_dir2_sf_entsize (&sf->hdr,sfe->namelen) - (__psint_t )sf >be64_to_cpu (dip->di_size)) {
include/xfs_dir2_format.h +14 -11
@@ -222,16 +222,6 @@ xfs_dir2_sf_nextentry(struct xfs_dir2_sf_hdr *hdr,xfs_dir2_byte_to_db (mp,XFS_DIR2_DATA_OFFSET )/* -* Offsets of . and .. in data space (always block 0) - */ -#define XFS_DIR2_DATA_DOT_OFFSET \ - ((xfs_dir2_data_aoff_t)sizeof(struct xfs_dir2_data_hdr)) -#define XFS_DIR2_DATA_DOTDOT_OFFSET \ - (XFS_DIR2_DATA_DOT_OFFSET + xfs_dir2_data_entsize(1)) -#define XFS_DIR2_DATA_FIRST_OFFSET \ - (XFS_DIR2_DATA_DOTDOT_OFFSET + xfs_dir2_data_entsize(2)) - -/* * Describe a free area in the data block. * * The freespace will be formatted as a xfs_dir2_data_unused_t.
@@ -372,7 +362,20 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)/* * Offsets of . and .. in data space (always block 0) -*/ +* +* The macros are used for shortform directories as they have no headers to read +* the magic number out of. Shortform directories need to know the size of the +* data block header because the sfe embeds the block offset of the entry into +* it so that it doesn't change when format conversion occurs. Bad Things Happen +* if we don't follow this rule. +*/ +#define XFS_DIR3_DATA_DOT_OFFSET (mp) \ + xfs_dir3_data_hdr_size(xfs_sb_version_hascrc(&(mp)->m_sb)) +#define XFS_DIR3_DATA_DOTDOT_OFFSET (mp) \ + (XFS_DIR3_DATA_DOT_OFFSET(mp) + xfs_dir2_data_entsize(1)) +#define XFS_DIR3_DATA_FIRST_OFFSET (mp) \ + (XFS_DIR3_DATA_DOTDOT_OFFSET(mp) + xfs_dir2_data_entsize(2)) +static inline xfs_dir2_data_aoff_t xfs_dir3_data_dot_offset (struct xfs_dir2_data_hdr *hdr) {
libxfs/xfs_dir2_sf.c +3 -3
@@ -519,7 +519,7 @@ xfs_dir2_sf_addname_hard(* to insert the new entry. * If it's going to end up at the end then oldsfep will point there. */ - for (offset = XFS_DIR2_DATA_FIRST_OFFSET, + for (offset = XFS_DIR3_DATA_FIRST_OFFSET(dp->i_mount), oldsfep = xfs_dir2_sf_firstentry(oldsfp), add_datasize = xfs_dir2_data_entsize(args->namelen), eof = (char *)oldsfep == &buf[old_isize];
@@ -601,7 +601,7 @@ xfs_dir2_sf_addname_pick( sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; size =xfs_dir2_data_entsize (args->namelen); - offset =XFS_DIR2_DATA_FIRST_OFFSET ; + offset =XFS_DIR3_DATA_FIRST_OFFSET (mp); sfep =xfs_dir2_sf_firstentry (sfp); holefit =0 ;/*
@@ -672,7 +672,7 @@ xfs_dir2_sf_check( dp = args->dp; sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - offset =XFS_DIR2_DATA_FIRST_OFFSET ; + offset =XFS_DIR3_DATA_FIRST_OFFSET (dp->i_mount); ino =xfs_dir2_sf_get_parent_ino (sfp); i8count = ino >XFS_DIR2_MAX_SHORT_INUM ;
repair/dir2.c +4 -3
@@ -682,6 +682,7 @@ process_sf_dir2_fixi8(*/ static void process_sf_dir2_fixoff ( +xfs_mount_t *mp,xfs_dinode_t *dip) {int i;
@@ -691,7 +692,7 @@ process_sf_dir2_fixoff( sfp = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (dip); sfep =xfs_dir2_sf_firstentry (&sfp->hdr); - offset =XFS_DIR2_DATA_FIRST_OFFSET ; + offset =XFS_DIR3_DATA_FIRST_OFFSET (mp);for (i =0 ; i < sfp->hdr.count; i++) {xfs_dir2_sf_put_offset (sfep, offset);
@@ -745,7 +746,7 @@ process_sf_dir2( max_size =XFS_DFORK_DSIZE (dip, mp); num_entries = sfp->hdr.count; ino_dir_size =be64_to_cpu (dip->di_size); - offset =XFS_DIR2_DATA_FIRST_OFFSET ; + offset =XFS_DIR3_DATA_FIRST_OFFSET (mp); bad_offset = *repair =0 ;ASSERT (ino_dir_size <= max_size);
@@ -1102,7 +1103,7 @@ _("would have corrected entry offsets in directory %" PRIu64 "\n"),do_warn (_ ("corrected entry offsets in directory %" PRIu64"\n" ), ino); -process_sf_dir2_fixoff (dip); +process_sf_dir2_fixoff (mp, dip); *dino_dirty =1 ; *repair =1 ; }
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 13/48] xfs: shortform directory offsets change for dir3 format
Quoted 10 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Because the header size for the CRC enabled directory blocks is larger, the offset of the first entry into a directory block is different to the dir2 format. The shortform directory stores the dirent's offset so that it doesn't change when moving from shortform to block form and back again, and hence it needs to take into account the different header sizes to maintain the correct offsets.
Signed-off-by Dave Chinner <[email protected]>
corresponds to commit 6b2647a12a0
xfs_dir2_sf_getdents which is changed in the kernel commit doesn't exist in userspace.
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 14/48 xfs: add CRCs to dir2/da node blocks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- db/attr.c | 4 +- db/check.c | 8 +- db/dir2.c | 4 +- include/xfs_da_btree.h | 106 +++- libxfs/xfs_attr.c | 24 +- libxfs/xfs_attr_leaf.c | 17 +- libxfs/xfs_da_btree.c | 1393 +++++++++++++++++++++++++++++------------------- libxfs/xfs_dir2_node.c | 26 +- repair/attr_repair.c | 88 +-- repair/dir2.c | 96 ++-- 10 files changed, 1066 insertions(+), 700 deletions(-)
db/attr.c +2 -2
@@ -54,7 +54,7 @@ const field_t attr_flds[] = { 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, + { "btree", FLDT_ATTR_NODE_ENTRY, OI(NOFF(__btree)), attr_node_btree_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "nvlist", FLDT_ATTR_LEAF_NAME, attr_leaf_nvlist_offset, attr_leaf_nvlist_count, FLD_ARRAY|FLD_OFFSET|FLD_COUNT, TYP_NONE },
@@ -144,7 +144,7 @@ const field_t attr_node_entry_flds[] = {const field_t attr_node_hdr_flds[] = { {"info" ,FLDT_ATTR_BLKINFO ,OI (HOFF (info)),C1 ,0 ,TYP_NONE }, {"count" ,FLDT_UINT16D ,OI (HOFF (count)),C1 ,0 ,TYP_NONE }, - {"level" ,FLDT_UINT16D ,OI (HOFF (level)),C1 ,0 ,TYP_NONE }, + {"level" ,FLDT_UINT16D ,OI (HOFF (__level)),C1 ,0 ,TYP_NONE }, {NULL } };
db/check.c +4 -4
@@ -3072,6 +3072,7 @@ process_leaf_node_dir_v2_int(xfs_dir2_leaf_tail_t *ltp;xfs_da_intnode_t *node;int stale; +struct xfs_da3_icnode_hdr nodehdr; leaf = iocur_top->data;switch (be16_to_cpu (leaf->hdr.info.magic)) {
@@ -3120,13 +3121,12 @@ process_leaf_node_dir_v2_int(break ;case XFS_DA_NODE_MAGIC : node = iocur_top->data; -if (be16_to_cpu (node->hdr.level) <1 || -be16_to_cpu (node->hdr.level) > -XFS_DA_NODE_MAXDEPTH ) { +xfs_da3_node_hdr_from_disk (&nodehdr, node); +if (nodehdr.level <1 || nodehdr.level >XFS_DA_NODE_MAXDEPTH ) {if (!sflag || v)dbprintf (_ ("bad node block level %d for dir ino " "%lld block %d\n" ), -be16_to_cpu (node->hdr.level), id->ino, + nodehdr.level, id->ino, dabno); error++; }
db/dir2.c +2 -2
@@ -86,7 +86,7 @@ const field_t dir2_flds[] = { dir2_leaf_tail_count, FLD_OFFSET|FLD_COUNT, TYP_NONE }, {"nhdr" ,FLDT_DA_NODE_HDR ,OI (NOFF (hdr)), dir2_node_hdr_count, FLD_COUNT, TYP_NONE }, - { "nbtree", FLDT_DA_NODE_ENTRY, OI(NOFF(btree)), dir2_node_btree_count, + { "nbtree", FLDT_DA_NODE_ENTRY, OI(NOFF(__btree)), dir2_node_btree_count, FLD_ARRAY|FLD_COUNT, TYP_NONE }, { "fhdr", FLDT_DIR2_FREE_HDR, OI(FOFF(hdr)), dir2_free_hdr_count, FLD_COUNT, TYP_NONE },
@@ -185,7 +185,7 @@ const field_t da_node_entry_flds[] = {const field_t da_node_hdr_flds[] = { {"info" ,FLDT_DA_BLKINFO ,OI (HOFF (info)),C1 ,0 ,TYP_NONE }, {"count" ,FLDT_UINT16D ,OI (HOFF (count)),C1 ,0 ,TYP_NONE }, - {"level" ,FLDT_UINT16D ,OI (HOFF (level)),C1 ,0 ,TYP_NONE }, + {"level" ,FLDT_UINT16D ,OI (HOFF (__level)),C1 ,0 ,TYP_NONE }, {NULL } };
include/xfs_da_btree.h +83 -23
151 lines not on this page · raw message
libxfs/xfs_attr.c +12 -12
@@ -967,7 +967,7 @@ restart:* Search to see if name already exists, and get back a pointer * to where it should go. */ - error =xfs_da_node_lookup_int (state, &retval); + error =xfs_da3_node_lookup_int (state, &retval);if (error) goto out; blk = &state->path.blk[ state->path.active-1 ];
@@ -1038,7 +1038,7 @@ restart:* in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields. */ xfs_bmap_init (args->flist, args->firstblock); - error =xfs_da_split (state); + error =xfs_da3_split (state);if (!error) { error =xfs_bmap_finish (&args->trans, args->flist, &committed);
@@ -1060,7 +1060,7 @@ restart:/* * Addition succeeded, update Btree hashvals. */ -xfs_da_fixhashpath (state, &state->path); +xfs_da3_fixhashpath (state, &state->path); }/*
@@ -1131,7 +1131,7 @@ restart: state->blocksize = state->mp->m_sb.sb_blocksize; state->node_ents = state->mp->m_attr_node_ents; state->inleaf =0 ; - error =xfs_da_node_lookup_int (state, &retval); + error =xfs_da3_node_lookup_int (state, &retval);if (error) goto out;
@@ -1141,14 +1141,14 @@ restart: blk = &state->path.blk[ state->path.active-1 ];ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); error =xfs_attr_leaf_remove (blk->bp, args); -xfs_da_fixhashpath (state, &state->path); +xfs_da3_fixhashpath (state, &state->path);/* * Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active >1 )) {xfs_bmap_init (args->flist, args->firstblock); - error =xfs_da_join (state); + error =xfs_da3_join (state);if (!error) { error = xfs_bmap_finish(&args->trans, args->flist,
@@ -1226,7 +1226,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)/* * Search to see if name exists, and get back a pointer to it. */ - error =xfs_da_node_lookup_int (state, &retval); + error =xfs_da3_node_lookup_int (state, &retval);if (error || (retval !=EEXIST )) {if (error ==0 ) error = retval;
@@ -1277,14 +1277,14 @@ xfs_attr_node_removename(xfs_da_args_t *args) blk = &state->path.blk[ state->path.active-1 ];ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); retval =xfs_attr_leaf_remove (blk->bp, args); -xfs_da_fixhashpath (state, &state->path); +xfs_da3_fixhashpath (state, &state->path);/* * Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active >1 )) {xfs_bmap_init (args->flist, args->firstblock); - error =xfs_da_join (state); + error =xfs_da3_join (state);if (!error) { error =xfs_bmap_finish (&args->trans, args->flist, &committed);
@@ -1430,7 +1430,7 @@ xfs_attr_refillstate(xfs_da_state_t *state)ASSERT ((path->active >=0 ) && (path->active <XFS_DA_NODE_MAXDEPTH ));for (blk = path->blk, level =0 ; level < path->active; blk++, level++) {if (blk->disk_blkno) { - error =xfs_da_node_read (state->args->trans, + error =xfs_da3_node_read (state->args->trans, state->args->dp, blk->blkno, blk->disk_blkno, &blk->bp,XFS_ATTR_FORK );
@@ -1449,7 +1449,7 @@ xfs_attr_refillstate(xfs_da_state_t *state)ASSERT ((path->active >=0 ) && (path->active <XFS_DA_NODE_MAXDEPTH ));for (blk = path->blk, level =0 ; level < path->active; blk++, level++) {if (blk->disk_blkno) { - error =xfs_da_node_read (state->args->trans, + error =xfs_da3_node_read (state->args->trans, state->args->dp, blk->blkno, blk->disk_blkno, &blk->bp,XFS_ATTR_FORK );
@@ -1489,7 +1489,7 @@ xfs_attr_node_get(xfs_da_args_t *args)/* * Search to see if name exists, and get back a pointer to it. */ - error =xfs_da_node_lookup_int (state, &retval); + error =xfs_da3_node_lookup_int (state, &retval);if (error) { retval = error; }else if (retval ==EEXIST ) {
libxfs/xfs_attr_leaf.c +9 -8
@@ -703,6 +703,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)struct xfs_buf *bp1, *bp2;xfs_dablk_t blkno;int error; +struct xfs_da_node_entry *btree;trace_xfs_attr_leaf_to_node (args);
@@ -728,16 +729,16 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)/* * Set up the new root node. */ - error =xfs_da_node_create (args,0 ,1 , &bp1,XFS_ATTR_FORK ); + error =xfs_da3_node_create (args,0 ,1 , &bp1,XFS_ATTR_FORK );if (error) goto out; node = bp1->b_addr; leaf = bp2->b_addr;ASSERT (leaf->hdr.info.magic ==cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ));/* both on-disk, don't endian-flip twice */ - node->btree[0 ].hashval = - leaf->entries[be16_to_cpu (leaf->hdr.count)-1 ].hashval; - node->btree[0 ].before =cpu_to_be32 (blkno); + btree =xfs_da3_node_tree_p (node); + btree[0 ].hashval = leaf->entries[be16_to_cpu (leaf->hdr.count)-1 ].hashval; + btree[0 ].before =cpu_to_be32 (blkno); node->hdr.count =cpu_to_be16 (1 );xfs_trans_log_buf (args->trans, bp1,0 ,XFS_LBSIZE (dp->i_mount) -1 ); error =0 ;
@@ -825,7 +826,7 @@ xfs_attr_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,* NOTE: rebalance() currently depends on the 2nd block being empty. */ xfs_attr_leaf_rebalance (state, oldblk, newblk); - error =xfs_da_blk_link (state, oldblk, newblk); + error =xfs_da3_blk_link (state, oldblk, newblk);if (error)return (error);
@@ -1453,7 +1454,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)*/ forward = (info->forw !=0 );memcpy (&state->altpath, &state->path,sizeof (state->path)); - error =xfs_da_path_shift (state, &state->altpath, forward, + error =xfs_da3_path_shift (state, &state->altpath, forward,0 , &retval);if (error)return (error);
@@ -1510,10 +1511,10 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)*/ memcpy (&state->altpath, &state->path,sizeof (state->path));if (blkno < blk->blkno) { - error =xfs_da_path_shift (state, &state->altpath, forward, + error =xfs_da3_path_shift (state, &state->altpath, forward,0 , &retval); }else { - error =xfs_da_path_shift (state, &state->path, forward, + error =xfs_da3_path_shift (state, &state->path, forward,0 , &retval); }if (error)
libxfs/xfs_da_btree.c +840 -553
2,158 lines not on this page · raw message
libxfs/xfs_dir2_node.c +13 -13
@@ -1356,7 +1356,7 @@ xfs_dir2_leafn_split(* block into the leaves. */ xfs_dir2_leafn_rebalance (state, oldblk, newblk); - error =xfs_da_blk_link (state, oldblk, newblk); + error =xfs_da3_blk_link (state, oldblk, newblk);if (error) {return error; }
@@ -1437,7 +1437,7 @@ xfs_dir2_leafn_toosmall(*/ forward = (leafhdr.forw !=0 );memcpy (&state->altpath, &state->path,sizeof (state->path)); - error =xfs_da_path_shift (state, &state->altpath, forward,0 , + error =xfs_da3_path_shift (state, &state->altpath, forward,0 , &rval);if (error)return error;
@@ -1499,10 +1499,10 @@ xfs_dir2_leafn_toosmall(*/ memcpy (&state->altpath, &state->path,sizeof (state->path));if (blkno < blk->blkno) - error =xfs_da_path_shift (state, &state->altpath, forward,0 , + error =xfs_da3_path_shift (state, &state->altpath, forward,0 , &rval);else - error =xfs_da_path_shift (state, &state->path, forward,0 , + error =xfs_da3_path_shift (state, &state->path, forward,0 , &rval);if (error) {return error;
@@ -1599,7 +1599,7 @@ xfs_dir2_node_addname(* Look up the name. We're not supposed to find it, but * this gives us the insertion point. */ - error =xfs_da_node_lookup_int (state, &rval); + error =xfs_da3_node_lookup_int (state, &rval);if (error) rval = error;if (rval !=ENOENT ) {
@@ -1625,7 +1625,7 @@ xfs_dir2_node_addname(* It worked, fix the hash values up the btree. */ if (!(args->op_flags &XFS_DA_OP_JUSTCHECK )) -xfs_da_fixhashpath (state, &state->path); +xfs_da3_fixhashpath (state, &state->path); }else {/* * It didn't work, we need to split the leaf block.
@@ -1637,7 +1637,7 @@ xfs_dir2_node_addname(/* * Split the leaf block and insert the new entry. */ - rval =xfs_da_split (state); + rval =xfs_da3_split (state); } done:xfs_da_state_free (state);
@@ -2015,7 +2015,7 @@ xfs_dir2_node_addname_int(/* * Lookup an entry in a node-format directory. -* All the real work happens in xfs_da_node_lookup_int. +* All the real work happens in xfs_da3_node_lookup_int. * The only real output is the inode number of the entry. */ int /* error */
@@ -2040,7 +2040,7 @@ xfs_dir2_node_lookup(/* * Fill in the path to the entry in the cursor. */ - error =xfs_da_node_lookup_int (state, &rval); + error =xfs_da3_node_lookup_int (state, &rval);if (error) rval = error;else if (rval ==ENOENT && args->cmpresult ==XFS_CMP_CASE ) {
@@ -2095,7 +2095,7 @@ xfs_dir2_node_removename(/* * Look up the entry we're deleting, set up the cursor. */ - error =xfs_da_node_lookup_int (state, &rval); + error =xfs_da3_node_lookup_int (state, &rval);if (error) rval = error;/*
@@ -2119,12 +2119,12 @@ xfs_dir2_node_removename(/* * Fix the hash values up the btree. */ -xfs_da_fixhashpath (state, &state->path); +xfs_da3_fixhashpath (state, &state->path);/* * If we need to join leaf blocks, do it. */ if (rval && state->path.active >1 ) - error =xfs_da_join (state); + error =xfs_da3_join (state);/* * If no errors so far, try conversion to leaf format. */
@@ -2166,7 +2166,7 @@ xfs_dir2_node_replace(/* * Lookup the entry to change in the btree. */ - error =xfs_da_node_lookup_int (state, &rval); + error =xfs_da3_node_lookup_int (state, &rval);if (error) { rval = error; }
repair/attr_repair.c +49 -39
271 lines not on this page · raw message
repair/dir2.c +52 -44
116 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Part of the diff is not shown here. View the raw message.
Re: [PATCH 14/48] xfs: add CRCs to dir2/da node blocks
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
Corresponds with commit f5ea110044f.
Note we don't have xfs_attr_node_list, xfs_attr_root_inactive, xfs_attr_node_inactive in userspace.
The check and repair changes look good.
libxfs/xfs_da_btree.c xfs_da_split(xfs_da_state_t *state) · line 456
Quoted 7 lines
libxfs/xfs_da_btree.c +3
-0@@ -299,8 +451,10 @@ xfs_da_split(xfs_da_state_t *state)* just got bumped because of the addition of a new root node. * There might be three blocks involved if a double split occurred, * and the original block 0 could be at any position in the list. +* +* Note: the info structures being modified here for both v2 and v3 da +* headers, so we can do this linkage just using the v2 structures.
The kernel code had additional comments here. Probably this is synced up in a subsequent patch.
Quoted 8 lines
libxfs/xfs_da_btree.c +4
-2STATIC void -xfs_da_node_unbalance (xfs_da_state_t *state,xfs_da_state_blk_t *drop_blk, -xfs_da_state_blk_t *save_blk) +xfs_da3_node_unbalance ( +struct xfs_da_state *state, +struct xfs_da_state_blk *drop_blk, +struct xfs_da_state_blk *save_blk) {
libxfs/xfs_da_btree.c xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path) · line 1344
Quoted 10 lines
libxfs/xfs_da_btree.c +6
-4-xfs_da_intnode_t *drop_node, *save_node; -xfs_da_node_entry_t *btree; -int tmp; -xfs_trans_t *tp; +struct xfs_da_intnode *drop_node; +struct xfs_da_intnode *save_node; +struct xfs_da_node_entry *dbtree; +struct xfs_da_node_entry *sbtree; +struct xfs_da3_icnode_hdr dhdr; +struct xfs_da3_icnode_hdr shdr;
drop and save are named differently in the kernel, probably another one resolved later in the series.
Quoted 24 lines
libxfs/xfs_da_btree.c +7
-6+struct xfs_trans *tp; +int sindex; +int tmp;trace_xfs_da_node_unbalance (state->args); drop_node = drop_blk->bp->b_addr; save_node = save_blk->bp->b_addr; -ASSERT (drop_node->hdr.info.magic ==cpu_to_be16 (XFS_DA_NODE_MAGIC )); -ASSERT (save_node->hdr.info.magic ==cpu_to_be16 (XFS_DA_NODE_MAGIC )); +xfs_da3_node_hdr_from_disk (&dhdr, drop_node); +xfs_da3_node_hdr_from_disk (&shdr, save_node); + dbtree =xfs_da3_node_tree_p (drop_node); + sbtree =xfs_da3_node_tree_p (save_node); tp = state->args->trans;/* * If the dying block has lower hashvals, then move all the * elements in the remaining block up to make a hole. */ -if ((be32_to_cpu (drop_node->btree[0 ].hashval) <be32_to_cpu (save_node->btree[0 ].hashval)) || - (be32_to_cpu (drop_node->btree[be16_to_cpu (drop_node->hdr.count)-1 ].hashval) < -be32_to_cpu (save_node->btree[be16_to_cpu (save_node->hdr.count)-1 ].hashval))) - {
libxfs/xfs_da_btree.c xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path) · line 1368
Quoted 10 lines
libxfs/xfs_da_btree.c +6
-4- btree = &save_node->btree[be16_to_cpu (drop_node->hdr.count)]; - tmp =be16_to_cpu (save_node->hdr.count) * (uint )sizeof (xfs_da_node_entry_t); -memmove (btree, &save_node->btree[0 ], tmp); - btree = &save_node->btree[0 ]; +if ((be32_to_cpu (dbtree[0 ].hashval) <be32_to_cpu (sbtree[0 ].hashval)) || + (be32_to_cpu (dbtree[dhdr.count -1 ].hashval) < +be32_to_cpu (sbtree[shdr.count -1 ].hashval))) { +/* XXX: check this - is memmove dst correct? */ + tmp = shdr.count * (uint )sizeof (xfs_da_node_entry_t); +memmove (&sbtree[dhdr.count], &sbtree[0 ], tmp);
Mmm. I don't remember how things came out regarding the question of this memmove.
libxfs/xfs_da_btree.c xfs_da_swap_lastblock( · line 2159
Quoted 9 lines
libxfs/xfs_da_btree.c +4
-1@@ -1835,17 +2153,22 @@ xfs_da_swap_lastblock( dead_level =0 ; dead_hash =be32_to_cpu (ents[leafhdr.count -1 ].hashval); }else { -ASSERT (dead_info->magic ==cpu_to_be16 (XFS_DA_NODE_MAGIC )); +struct xfs_da3_icnode_hdr deadhdr; + +ASSERT (dead_info->magic ==cpu_to_be16 (XFS_DA_NODE_MAGIC ) || + dead_info->magic ==cpu_to_be16 (XFS_DA3_NODE_MAGIC ));
This assert was removed in the kernel. Not sure if we want to keep it here...
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 15/48 xfs: add CRCs to attr leaf blocks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- db/attr.c | 16 +- db/dir2.c | 4 +- db/metadump.c | 4 +- include/xfs_attr_leaf.h | 122 +++- include/xfs_da_btree.h | 5 +- libxfs/xfs_attr.c | 66 +- libxfs/xfs_attr_leaf.c | 1529 +++++++++++++++++++++++++++-------------------- libxfs/xfs_da_btree.c | 35 +- repair/attr_repair.c | 4 +- 9 files changed, 1034 insertions(+), 751 deletions(-)
db/attr.c +8 -8
@@ -143,7 +143,7 @@ const field_t attr_node_entry_flds[] = {#define HOFF (f) bitize(offsetof(xfs_da_node_hdr_t, f))const field_t attr_node_hdr_flds[] = { {"info" ,FLDT_ATTR_BLKINFO ,OI (HOFF (info)),C1 ,0 ,TYP_NONE }, - {"count" ,FLDT_UINT16D ,OI (HOFF (count)),C1 ,0 ,TYP_NONE }, + {"count" ,FLDT_UINT16D ,OI (HOFF (__count)),C1 ,0 ,TYP_NONE }, {"level" ,FLDT_UINT16D ,OI (HOFF (__level)),C1 ,0 ,TYP_NONE }, {NULL } };
@@ -219,7 +219,7 @@ attr_leaf_name_local_name_count( e = &block->entries[i];if (be16_to_cpu (e->nameidx) == off) {if (e->flags &XFS_ATTR_LOCAL ) { - l =xfs_attr_leaf_name_local (block, i); + l =xfs_attr3_leaf_name_local (block, i);return l->namelen; }else return 0 ;
@@ -248,7 +248,7 @@ attr_leaf_name_local_value_count( e = &block->entries[i];if (be16_to_cpu (e->nameidx) == off) {if (e->flags &XFS_ATTR_LOCAL ) { - l =xfs_attr_leaf_name_local (block, i); + l =xfs_attr3_leaf_name_local (block, i);return be16_to_cpu (l->valuelen); }else return 0 ;
@@ -285,7 +285,7 @@ attr_leaf_name_local_value_offset(if (i >=be16_to_cpu (block->hdr.count))return 0 ; - l =xfs_attr_leaf_name_local (block, i); + l =xfs_attr3_leaf_name_local (block, i); vp = (char *)&l->nameval[l->namelen];return (int )bitize (vp - (char *)l); }
@@ -333,7 +333,7 @@ attr_leaf_name_remote_name_count( e = &block->entries[i];if (be16_to_cpu (e->nameidx) == off) {if (!(e->flags &XFS_ATTR_LOCAL )) { - r =xfs_attr_leaf_name_remote (block, i); + r =xfs_attr3_leaf_name_remote (block, i);return r->namelen; }else return 0 ;
@@ -360,11 +360,11 @@ attr_leaf_name_size(return 0 ; e = &block->entries[idx];if (e->flags &XFS_ATTR_LOCAL ) { - l =xfs_attr_leaf_name_local (block, idx); + l =xfs_attr3_leaf_name_local (block, idx);return (int )bitize (xfs_attr_leaf_entsize_local (l->namelen,be16_to_cpu (l->valuelen))); }else { - r =xfs_attr_leaf_name_remote (block, idx); + r =xfs_attr3_leaf_name_remote (block, idx);return (int )bitize (xfs_attr_leaf_entsize_remote (r->namelen)); } }
@@ -412,7 +412,7 @@ attr_node_btree_count( block = obj;if (be16_to_cpu (block->hdr.info.magic) !=XFS_DA_NODE_MAGIC )return 0 ; -return be16_to_cpu (block->hdr.count); +return be16_to_cpu (block->hdr.__count); }/*ARGSUSED*/
db/dir2.c +2 -2
@@ -184,7 +184,7 @@ const field_t da_node_entry_flds[] = {#define HOFF (f) bitize(offsetof(xfs_da_node_hdr_t, f))const field_t da_node_hdr_flds[] = { {"info" ,FLDT_DA_BLKINFO ,OI (HOFF (info)),C1 ,0 ,TYP_NONE }, - {"count" ,FLDT_UINT16D ,OI (HOFF (count)),C1 ,0 ,TYP_NONE }, + {"count" ,FLDT_UINT16D ,OI (HOFF (__count)),C1 ,0 ,TYP_NONE }, {"level" ,FLDT_UINT16D ,OI (HOFF (__level)),C1 ,0 ,TYP_NONE }, {NULL } };
@@ -707,7 +707,7 @@ dir2_node_btree_count( node = obj;if (be16_to_cpu (node->hdr.info.magic) !=XFS_DA_NODE_MAGIC )return 0 ; -return be16_to_cpu (node->hdr.count); +return be16_to_cpu (node->hdr.__count); }/*ARGSUSED*/
db/metadump.c +2 -2
@@ -1282,7 +1282,7 @@ obfuscate_attr_blocks(break ; }if (entry->flags &XFS_ATTR_LOCAL ) { - local =xfs_attr_leaf_name_local (leaf, i); + local =xfs_attr3_leaf_name_local (leaf, i);if (local->namelen ==0 ) {if (show_warnings) print_warning("zero length for "
@@ -1295,7 +1295,7 @@ obfuscate_attr_blocks(memset (&local->nameval[local->namelen],0 ,be16_to_cpu (local->valuelen)); }else { - remote =xfs_attr_leaf_name_remote (leaf, i); + remote =xfs_attr3_leaf_name_remote (leaf, i);if (remote->namelen ==0 || remote->valueblk ==0 ) {if (show_warnings)
include/xfs_attr_leaf.h +95 -27
186 lines not on this page · raw message
include/xfs_da_btree.h +3 -2
@@ -55,6 +55,7 @@ typedef struct xfs_da_blkinfo {* magic numbers without modification for both v2 and v3 nodes. */ #define XFS_DA3_NODE_MAGIC 0x3ebe/* magic number: non-leaf blocks */ +#define XFS_ATTR3_LEAF_MAGIC 0x3bee/* magic number: attribute leaf blks */ #define XFS_DIR3_LEAF1_MAGIC 0x3df1/* magic number: v2 dirlf single blks */ #define XFS_DIR3_LEAFN_MAGIC 0x3dff/* magic number: v2 dirlf multi blks */
@@ -85,13 +86,13 @@ struct xfs_da3_blkinfo {typedef struct xfs_da_node_hdr {struct xfs_da_blkinfo info;/* block type, links, etc. */ -__be16 count;/* count of active entries */ +__be16 __count;/* count of active entries */ __be16 __level;/* level above leaves (leaf == 0) */ }xfs_da_node_hdr_t ;struct xfs_da3_node_hdr {struct xfs_da3_blkinfo info;/* block type, links, etc. */ -__be16 count;/* count of active entries */ +__be16 __count;/* count of active entries */ __be16 __level;/* level above leaves (leaf == 0) */ __be32 __pad32; };
libxfs/xfs_attr.c +33 -33
231 lines not on this page · raw message
libxfs/xfs_attr_leaf.c +868 -661
2,410 lines not on this page · raw message
libxfs/xfs_da_btree.c +21 -14
@@ -120,14 +120,14 @@ xfs_da3_node_hdr_from_disk( to->forw =be32_to_cpu (hdr3->info.hdr.forw); to->back =be32_to_cpu (hdr3->info.hdr.back); to->magic =be16_to_cpu (hdr3->info.hdr.magic); - to->count =be16_to_cpu (hdr3->count); + to->count =be16_to_cpu (hdr3->__count); to->level =be16_to_cpu (hdr3->__level);return ; } to->forw =be32_to_cpu (from->hdr.info.forw); to->back =be32_to_cpu (from->hdr.info.back); to->magic =be16_to_cpu (from->hdr.info.magic); - to->count =be16_to_cpu (from->hdr.count); + to->count =be16_to_cpu (from->hdr.__count); to->level =be16_to_cpu (from->hdr.__level); }
@@ -145,14 +145,14 @@ xfs_da3_node_hdr_to_disk( hdr3->info.hdr.forw =cpu_to_be32 (from->forw); hdr3->info.hdr.back =cpu_to_be32 (from->back); hdr3->info.hdr.magic =cpu_to_be16 (from->magic); - hdr3->count =cpu_to_be16 (from->count); + hdr3->__count =cpu_to_be16 (from->count); hdr3->__level =cpu_to_be16 (from->level);return ; } to->hdr.info.forw =cpu_to_be32 (from->forw); to->hdr.info.back =cpu_to_be32 (from->back); to->hdr.info.magic =cpu_to_be16 (from->magic); - to->hdr.count =cpu_to_be16 (from->count); + to->hdr.__count =cpu_to_be16 (from->count); to->hdr.__level =cpu_to_be16 (from->level); }
@@ -247,7 +247,8 @@ xfs_da3_node_read_verify(break ;return ;case XFS_ATTR_LEAF_MAGIC : - bp->b_ops = &xfs_attr_leaf_buf_ops; +case XFS_ATTR3_LEAF_MAGIC : + bp->b_ops = &xfs_attr3_leaf_buf_ops; bp->b_ops->verify_read (bp);return ;case XFS_DIR2_LEAFN_MAGIC :
@@ -378,7 +379,7 @@ xfs_da3_split(*/ switch (oldblk->magic) {case XFS_ATTR_LEAF_MAGIC : - error =xfs_attr_leaf_split (state, oldblk, newblk); + error =xfs_attr3_leaf_split (state, oldblk, newblk);if ((error !=0 ) && (error !=ENOSPC )) {return (error);/* GROT: attr is inconsistent */ }
@@ -393,12 +394,12 @@ xfs_da3_split(if (state->inleaf) { state->extraafter =0 ;/* before newblk */ trace_xfs_attr_leaf_split_before (state->args); - error =xfs_attr_leaf_split (state, oldblk, + error =xfs_attr3_leaf_split (state, oldblk, &state->extrablk); }else { state->extraafter =1 ;/* after newblk */ trace_xfs_attr_leaf_split_after (state->args);
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Part of the diff is not shown here. View the raw message.
Re: [PATCH 15/48] xfs: add CRCs to attr leaf blocks
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
This one corresponds to commit 517c22207b04.
The xfs_db, metadump, and repair changes look good.
Note don't have xfs_attr_inactive, xfs_attr_leaf_list, xfs_attr_node_list, xfs_attr_node_inactive, xfs_attr_leaf_inactive, xfs_attr_leaf_freextent, xfs_attr_root_inactive, and xfs_attr_leaf_list_int in userspace.
Quoted 4 lines
libxfs/xfs_attr.c +0
-0@@ -854,24 +854,24 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)*/ dp = args->dp; args->blkno =0 ;
libxfs/xfs_attr.c xfs_attr_leaf_removename(xfs_da_args_t *args) · line 864
Quoted 10 lines
libxfs/xfs_attr.c +2
-2- error =xfs_attr_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp); + error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp);if (error)return error; - error =xfs_attr_leaf_lookup_int (bp, args); + error =xfs_attr3_leaf_lookup_int (bp, args);if (error ==ENOATTR ) {xfs_trans_brelse (args->trans, bp);return (error);
In the kernel patch the parens are removed:
return error;
Again, this is probably fixed in a subsequent patch.
Quoted 14 lines
libxfs/xfs_attr_leaf.c +5
-7STATIC int -xfs_attr_leaf_add_work ( -struct xfs_buf *bp, -xfs_da_args_t *args, -int mapindex) +xfs_attr3_leaf_add_work ( +struct xfs_buf *bp, +struct xfs_attr3_icleaf_hdr *ichdr, +struct xfs_da_args *args, +int mapindex) { -xfs_attr_leafblock_t *leaf; -xfs_attr_leaf_hdr_t *hdr; -xfs_attr_leaf_entry_t *entry;
libxfs/xfs_attr_leaf.c xfs_attr_leaf_add( · line 1114
Quoted 10 lines
libxfs/xfs_attr_leaf.c +5
-5-xfs_attr_leaf_name_local_t *name_loc; -xfs_attr_leaf_name_remote_t *name_rmt; -xfs_attr_leaf_map_t *map; -xfs_mount_t *mp; -int tmp, i; +struct xfs_attr_leafblock *leaf; +struct xfs_attr_leaf_entry *entry; +struct xfs_attr_leaf_name_local *name_loc; +struct xfs_attr_leaf_name_remote *name_rmt; +struct xfs_attr_leaf_map *map;
The kernel commit removed map. Probably fixed in a subsequent patch.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 16/48 xfs: split remote attribute code out
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Adding CRC support to remote attributes adds a significant amount of remote attribute specific code. Split the existing remote attribute code out into it's own file so that all the relevant remote attribute code is in a single, easy to find place.
--- include/libxfs.h | 1 + include/xfs_attr_remote.h | 31 +++++ libxfs/Makefile | 2 +- libxfs/xfs.h | 9 +- libxfs/xfs_attr.c | 296 ------------------------------------------- libxfs/xfs_attr_remote.c | 306 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 346 insertions(+), 299 deletions(-) create mode 100644 include/xfs_attr_remote.h create mode 100644 libxfs/xfs_attr_remote.c
include/libxfs.h +1 -0
@@ -589,6 +589,7 @@ extern unsigned long libxfs_physmem(void); /* in kilobytes */#include <xfs/xfs_rtalloc.h> #include <xfs/xfs_attr_leaf.h> +#include <xfs/xfs_attr_remote.h> #include <xfs/xfs_quota.h> #include <xfs/xfs_trans_space.h> #include <xfs/xfs_log.h>
include/xfs_attr_remote.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (c) 2013 Red Hat, Inc. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2.1 of the GNU Lesser 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. +* +* Further, this software is distributed without any warranty that it is +* free of the rightful claim of any third person regarding infringement +* or the like. Any license provided herein, whether implied or +* otherwise, applies only to this software file. Patent licenses, if +* any, provided herein do not apply to combinations of this program with +* other software, or any other product whatsoever. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, +* USA. +*/ +#ifndef __XFS_ATTR_REMOTE_H__ +#define __XFS_ATTR_REMOTE_H__ + +int xfs_attr_rmtval_get (struct xfs_da_args *args); +int xfs_attr_rmtval_set (struct xfs_da_args *args); +int xfs_attr_rmtval_remove (struct xfs_da_args *args); + +#endif /* __XFS_ATTR_REMOTE_H__ */
libxfs/Makefile +1 -1
@@ -16,7 +16,7 @@ CFILES = cache.c init.c kmem.c logitem.c radix-tree.c rdwr.c trans.c util.c \ xfs_ialloc_btree.c xfs_bmap_btree.c xfs_da_btree.c \ xfs_dir2.c xfs_dir2_leaf.c xfs_attr_leaf.c xfs_dir2_block.c \ xfs_dir2_node.c xfs_dir2_data.c xfs_dir2_sf.c xfs_bmap.c \ - xfs_mount.c xfs_rtalloc.c xfs_trans.c xfs_attr.c \ + xfs_mount.c xfs_rtalloc.c xfs_trans.c xfs_attr.c xfs_attr_remote.c \ crc32.c xfs_symlink.c CFILES += $(PKG_PLATFORM).c
libxfs/xfs.h +7 -2
@@ -180,14 +180,19 @@ roundup_pow_of_two(uint v)#define XFS_BUF_SET_VTYPE_REF (a,b,c) ((void) 0)#define XFS_BUF_SET_BDSTRAT_FUNC (a,b) ((void) 0) -#define xfs_incore (bt,blkno,len,lockit) 0 +/* avoid gcc warning */ +#define xfs_incore (bt,blkno,len,lockit) ({ \ + typeof(blkno) __foo = (blkno); \ + (blkno) = __foo; \ + NULL; \ +})#define xfs_buf_relse (bp) libxfs_putbuf(bp)#define xfs_read_buf (mp,devp,blkno,len,f,bpp) \ (*(bpp) = libxfs_readbuf((devp), \ (blkno), (len), 1), 0)#define xfs_buf_get (devp,blkno,len,f) \ (libxfs_getbuf((devp), (blkno), (len))) -#define xfs_bwrite (mp,bp) libxfs_writebuf((bp), 0) +#define xfs_bwrite (bp) libxfs_writebuf((bp), 0)#define XBRW_READ LIBXFS_BREAD#define XBRW_WRITE LIBXFS_BWRITE
libxfs/xfs_attr.c +0 -296
305 lines not on this page · raw message
libxfs/xfs_attr_remote.c new file +306 -0
306 lines not on this page · raw message
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 16/48] xfs: split remote attribute code out
Quoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Adding CRC support to remote attributes adds a significant amount of remote attribute specific code. Split the existing remote attribute code out into it's own file so that all the relevant remote attribute code is in a single, easy to find place.
Signed-off-by Dave Chinner <[email protected]>
Corresponds to commit 95920cd6ce1
Quoted 19 lines
include/xfs_attr_remote.h new file +13
-0@@ -0,0 +1,31 @@ +/* +* Copyright (c) 2013 Red Hat, Inc. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2.1 of the GNU Lesser 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. +* +* Further, this software is distributed without any warranty that it is +* free of the rightful claim of any third person regarding infringement
include/xfs_attr_remote.h line 23
Quoted 10 lines
include/xfs_attr_remote.h new file +10
-0+* or the like. Any license provided herein, whether implied or +* otherwise, applies only to this software file. Patent licenses, if +* any, provided herein do not apply to combinations of this program with +* other software, or any other product whatsoever. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, +* USA. +*/
This gpl header is different than the one in the kernel. Probably fixed later in the series.
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 17/48 xfs: add CRC protection to remote attributes
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
There are two ways of doing this - the first is to add a CRC to the remote attribute entry in the attribute block. The second is to treat them similar to the remote symlink, where each fragment has it's own header and identifies fragment location in the attribute.
The problem with the CRC in the remote attr entry is that we cannot identify the owner of the metadata from the metadata blocks themselves, or where the blocks fit into the remote attribute. The down side to this approach is that we never know when the attribute has been read from disk or not and so we have to verify it every time it is read, and we must calculate it during the create transaction and log it. We do not log CRCs for any other metadata, and so this creates a unique set of coherency problems that, in general, are best avoided.
Adding an identifying header to each allocated block allows us to identify each fragment and where in the attribute it is located. It enables us to rebuild the remote attribute from just the raw blocks containing the attribute. It also provides us to do per-block CRCs verification at IO time rather than during the transaction context that creates it or every time it is read into a user buffer. Hence it avoids all the problems that an external, logged CRC has, and provides all the benefits of self identifying metadata.
The only complexity is that we have to add a header per fragment, and we don't know how many fragments will be needed prior to allocations. If we take the symlink example, the header is 56 bytes and hence for a 4k block size filesystem, in the worst case 16 headers requires 1 extra block for the 64k attribute data. For 512 byte filesystems the worst case is an extra block for every 9 fragments (i.e. 16 extra blocks in the worse case). This will be very rare and so it's not really a major concern.
Because allocation is done in two steps - the first finds a hole large enough in the attribute file, the second does the allocation - we only need to find a hole big enough for a worst case allocation. We only need to allocate enough extra blocks for number of headers required by the fragments, and we can calculate that as we go....
Hence it really only makes sense to use the same model as for symlinks - it doesn't add that much complexity, does not require an attribute tree format change, and does not require logging calculated CRC values.
--- include/xfs_attr_remote.h | 19 +++ libxfs/xfs_attr_remote.c | 321 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 290 insertions(+), 50 deletions(-)
include/xfs_attr_remote.h +19 -0
@@ -24,6 +24,25 @@#ifndef __XFS_ATTR_REMOTE_H__#define __XFS_ATTR_REMOTE_H__ +#define XFS_ATTR3_RMT_MAGIC 0x5841524d/* XARM */ + +struct xfs_attr3_rmt_hdr { +__be32 rm_magic; +__be32 rm_offset; +__be32 rm_bytes; +__be32 rm_crc; +uuid_t rm_uuid; +__be64 rm_owner; +__be64 rm_blkno; +__be64 rm_lsn; +}; + +#define XFS_ATTR3_RMT_CRC_OFF offsetof(struct xfs_attr3_rmt_hdr, rm_crc) + +#define XFS_ATTR3_RMT_BUF_SPACE (mp, bufsize) \ + ((bufsize) - (xfs_sb_version_hascrc(&(mp)->m_sb) ? \ + sizeof(struct xfs_attr3_rmt_hdr) : 0)) +int xfs_attr_rmtval_get (struct xfs_da_args *args);int xfs_attr_rmtval_set (struct xfs_da_args *args);int xfs_attr_rmtval_remove (struct xfs_da_args *args);
libxfs/xfs_attr_remote.c +271 -50
419 lines not on this page · raw message
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 17/48] xfs: add CRC protection to remote attributes
Quoted 41 lines · Dave Chinner
From: Dave Chinner <[email protected]>
There are two ways of doing this - the first is to add a CRC to the remote attribute entry in the attribute block. The second is to treat them similar to the remote symlink, where each fragment has it's own header and identifies fragment location in the attribute.
The problem with the CRC in the remote attr entry is that we cannot identify the owner of the metadata from the metadata blocks themselves, or where the blocks fit into the remote attribute. The down side to this approach is that we never know when the attribute has been read from disk or not and so we have to verify it every time it is read, and we must calculate it during the create transaction and log it. We do not log CRCs for any other metadata, and so this creates a unique set of coherency problems that, in general, are best avoided.
Adding an identifying header to each allocated block allows us to identify each fragment and where in the attribute it is located. It enables us to rebuild the remote attribute from just the raw blocks containing the attribute. It also provides us to do per-block CRCs verification at IO time rather than during the transaction context that creates it or every time it is read into a user buffer. Hence it avoids all the problems that an external, logged CRC has, and provides all the benefits of self identifying metadata.
The only complexity is that we have to add a header per fragment, and we don't know how many fragments will be needed prior to allocations. If we take the symlink example, the header is 56 bytes and hence for a 4k block size filesystem, in the worst case 16 headers requires 1 extra block for the 64k attribute data. For 512 byte filesystems the worst case is an extra block for every 9 fragments (i.e. 16 extra blocks in the worse case). This will be very rare and so it's not really a major concern.
Because allocation is done in two steps - the first finds a hole large enough in the attribute file, the second does the allocation - we only need to find a hole big enough for a worst case allocation. We only need to allocate enough extra blocks for number of headers required by the fragments, and we can calculate that as we go....
Quoted 6 lines
Hence it really only makes sense to use the same model as for symlinks - it doesn't add that much complexity, does not require an attribute tree format change, and does not require logging calculated CRC values.
Signed-off-by Dave Chinner <[email protected]>
Corresponds to commit d2e448d5fde
I see the rework of the remote attribute code later in the series...
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 18/48 xfs: add buffer types to directory and attribute buffers
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Add buffer types to the buffer log items so that log recovery can validate the buffers and calculate CRCs correctly after the buffers are recovered.
--- include/xfs_attr_remote.h | 2 ++ include/xfs_buf_item.h | 18 +++++++++++++++++- include/xfs_da_btree.h | 2 ++ include/xfs_trans.h | 2 ++ libxfs/xfs.h | 1 + libxfs/xfs_attr_leaf.c | 9 ++++++++- libxfs/xfs_da_btree.c | 46 ++++++++++++++++++++++++++++++++++++++++++--- libxfs/xfs_dir2_block.c | 12 +++++++++--- libxfs/xfs_dir2_data.c | 8 +++++++- libxfs/xfs_dir2_leaf.c | 24 +++++++++++++++++++---- libxfs/xfs_dir2_node.c | 17 ++++++++++++++--- libxfs/xfs_dir2_priv.h | 2 ++ 12 files changed, 127 insertions(+), 16 deletions(-)
include/xfs_attr_remote.h +2 -0
@@ -43,6 +43,8 @@ struct xfs_attr3_rmt_hdr { ((bufsize) - (xfs_sb_version_hascrc (&(mp)->m_sb) ? \ sizeof(struct xfs_attr3_rmt_hdr) : 0)) +extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops; +int xfs_attr_rmtval_get (struct xfs_da_args *args);int xfs_attr_rmtval_set (struct xfs_da_args *args);int xfs_attr_rmtval_remove (struct xfs_da_args *args);
include/xfs_buf_item.h +17 -1
@@ -50,6 +50,14 @@ extern kmem_zone_t *xfs_buf_item_zone;#define XFS_BLF_AGI_BUF (1<<8)#define XFS_BLF_DINO_BUF (1<<9)#define XFS_BLF_SYMLINK_BUF (1<<10) +#define XFS_BLF_DIR_BLOCK_BUF (1<<11) +#define XFS_BLF_DIR_DATA_BUF (1<<12) +#define XFS_BLF_DIR_FREE_BUF (1<<13) +#define XFS_BLF_DIR_LEAF1_BUF (1<<14) +#define XFS_BLF_DIR_LEAFN_BUF (1<<15) +#define XFS_BLF_DA_NODE_BUF (1<<16) +#define XFS_BLF_ATTR_LEAF_BUF (1<<17) +#define XFS_BLF_ATTR_RMT_BUF (1<<18)#define XFS_BLF_TYPE_MASK \ (XFS_BLF_UDQUOT_BUF | \
@@ -60,7 +68,15 @@ extern kmem_zone_t *xfs_buf_item_zone; XFS_BLF_AGFL_BUF | \ XFS_BLF_AGI_BUF | \ XFS_BLF_DINO_BUF | \ - XFS_BLF_SYMLINK_BUF) + XFS_BLF_SYMLINK_BUF | \ + XFS_BLF_DIR_BLOCK_BUF | \ + XFS_BLF_DIR_DATA_BUF | \ + XFS_BLF_DIR_FREE_BUF | \ + XFS_BLF_DIR_LEAF1_BUF | \ + XFS_BLF_DIR_LEAFN_BUF | \ + XFS_BLF_DA_NODE_BUF | \ + XFS_BLF_ATTR_LEAF_BUF | \ + XFS_BLF_ATTR_RMT_BUF)#define XFS_BLF_CHUNK 128#define XFS_BLF_SHIFT 7
include/xfs_da_btree.h +2 -0
@@ -301,6 +301,8 @@ int xfs_da3_node_read(struct xfs_trans *tp, struct xfs_inode *dp, xfs_dablk_t bno, xfs_daddr_t mappedbno, struct xfs_buf **bpp, int which_fork); +extern const struct xfs_buf_ops xfs_da3_node_buf_ops; +/* * Utility routines. */
include/xfs_trans.h +2 -0
@@ -502,6 +502,8 @@ void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint);void xfs_trans_inode_alloc_buf (xfs_trans_t *,struct xfs_buf *);void xfs_trans_buf_set_type (struct xfs_trans *,struct xfs_buf *,uint ); +void xfs_trans_buf_copy_type (struct xfs_buf *dst_bp, +struct xfs_buf *src_bp);void xfs_trans_ichgtime (struct xfs_trans *,struct xfs_inode *,int );void xfs_trans_ijoin (struct xfs_trans *,struct xfs_inode *,uint );void xfs_trans_log_buf (xfs_trans_t *,struct xfs_buf *,uint ,uint );
libxfs/xfs.h +1 -0
@@ -255,6 +255,7 @@ roundup_pow_of_two(uint v)#define xfs_trans_agflist_delta (tp, d)#define xfs_trans_agbtree_delta (tp, d)#define xfs_trans_buf_set_type (tp, bp, t) +#define xfs_trans_buf_copy_type (dbp, sbp)#define xfs_buf_readahead (a,b,c,ops) ((void) 0)/* no readahead */ #define xfs_buf_readahead_map (a,b,c,ops) ((void) 0)/* no readahead */
libxfs/xfs_attr_leaf.c +8 -1
@@ -236,8 +236,13 @@ xfs_attr3_leaf_read(xfs_daddr_t mappedbno, struct xfs_buf **bpp) { - return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp, + int err; + + err =xfs_da_read_buf (tp, dp, bno, mappedbno, bpp,XFS_ATTR_FORK , &xfs_attr3_leaf_buf_ops); +if (!err && tp) +xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_ATTR_LEAF_BUF ); +return err; }/*========================================================================
@@ -867,6 +872,7 @@ xfs_attr3_leaf_to_node( goto out;/* copy leaf to new buffer, update identifiers */ +xfs_trans_buf_set_type (args->trans, bp2,XFS_BLF_ATTR_LEAF_BUF ); bp2->b_ops = bp1->b_ops;memcpy (bp2->b_addr, bp1->b_addr,XFS_LBSIZE (mp));if (xfs_sb_version_hascrc (&mp->m_sb)) {
@@ -929,6 +935,7 @@ xfs_attr3_leaf_create(if (error)return error; bp->b_ops = &xfs_attr3_leaf_buf_ops; +xfs_trans_buf_set_type (args->trans, bp,XFS_BLF_ATTR_LEAF_BUF ); leaf = bp->b_addr;memset (leaf,0 ,XFS_LBSIZE (mp));
libxfs/xfs_da_btree.c +43 -3
89 lines not on this page · raw message
libxfs/xfs_dir2_block.c +9 -3
@@ -114,20 +114,26 @@ xfs_dir3_block_read( struct xfs_buf **bpp) {struct xfs_mount *mp = dp->i_mount; +int err; -return xfs_da_read_buf (tp, dp, mp->m_dirdatablk,-1 , bpp, + err =xfs_da_read_buf (tp, dp, mp->m_dirdatablk,-1 , bpp,XFS_DATA_FORK , &xfs_dir3_block_buf_ops); +if (!err && tp) +xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_BLOCK_BUF ); +return err; }static void xfs_dir3_block_init (struct xfs_mount *mp, +struct xfs_trans *tp,struct xfs_buf *bp,struct xfs_inode *dp) {struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; bp->b_ops = &xfs_dir3_block_buf_ops; +xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_BLOCK_BUF );if (xfs_sb_version_hascrc (&mp->m_sb)) {memset (hdr3,0 ,sizeof (*hdr3));
@@ -964,7 +970,7 @@ xfs_dir2_leaf_to_block(/* * Start converting it to block form. */ -xfs_dir3_block_init (mp, dbp, dp); +xfs_dir3_block_init (mp, tp, dbp, dp); needlog =1 ; needscan =0 ;
@@ -1093,7 +1099,7 @@ xfs_dir2_sf_to_block(kmem_free (sfp);return error; } -xfs_dir3_block_init (mp, bp, dp); +xfs_dir3_block_init (mp, tp, bp, dp); hdr = bp->b_addr;/*
libxfs/xfs_dir2_data.c +7 -1
@@ -283,8 +283,13 @@ xfs_dir3_data_read(xfs_daddr_t mapped_bno, struct xfs_buf **bpp) { - return xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp, + int err; + + err =xfs_da_read_buf (tp, dp, bno, mapped_bno, bpp,XFS_DATA_FORK , &xfs_dir3_data_buf_ops); +if (!err && tp) +xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_DATA_BUF ); +return err; }int
@@ -553,6 +558,7 @@ xfs_dir3_data_init(if (error)return error; bp->b_ops = &xfs_dir3_data_buf_ops; +xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_DATA_BUF );/* * Initialize the header.
libxfs/xfs_dir2_leaf.c +20 -4
@@ -279,8 +279,13 @@ xfs_dir3_leaf_read(xfs_daddr_t mappedbno, struct xfs_buf **bpp) { - return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, + int err; + + err =xfs_da_read_buf (tp, dp, fbno, mappedbno, bpp,XFS_DATA_FORK , &xfs_dir3_leaf1_buf_ops); +if (!err && tp) +xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_LEAF1_BUF ); +return err; }int
@@ -291,8 +296,13 @@ xfs_dir3_leafn_read(xfs_daddr_t mappedbno, struct xfs_buf **bpp) { - return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, + int err; + + err =xfs_da_read_buf (tp, dp, fbno, mappedbno, bpp,XFS_DATA_FORK , &xfs_dir3_leafn_buf_ops); +if (!err && tp) +xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_LEAFN_BUF ); +return err; }/*
@@ -301,6 +311,7 @@ xfs_dir3_leafn_read(static void xfs_dir3_leaf_init (struct xfs_mount *mp, +struct xfs_trans *tp,struct xfs_buf *bp,xfs_ino_t owner,__uint16_t type)
@@ -335,8 +346,11 @@ xfs_dir3_leaf_init( ltp =xfs_dir2_leaf_tail_p (mp, leaf); ltp->bestcount =0 ; bp->b_ops = &xfs_dir3_leaf1_buf_ops; - }else +xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_LEAF1_BUF ); + }else { bp->b_ops = &xfs_dir3_leafn_buf_ops; +xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_LEAFN_BUF ); + } }int
@@ -361,7 +375,7 @@ xfs_dir3_leaf_get_buf(if (error)return error; -xfs_dir3_leaf_init (mp, bp, dp->i_ino, magic); +xfs_dir3_leaf_init (mp, tp, bp, dp->i_ino, magic);xfs_dir3_leaf_log_header (tp, bp);if (magic ==XFS_DIR2_LEAF1_MAGIC )xfs_dir3_leaf_log_tail (tp, bp);
@@ -456,6 +470,7 @@ xfs_dir2_block_to_leaf(* Fix up the block header, make it a data block. */ dbp->b_ops = &xfs_dir3_data_buf_ops; +xfs_trans_buf_set_type (tp, dbp,XFS_BLF_DIR_DATA_BUF );if (hdr->magic ==cpu_to_be32 (XFS_DIR2_BLOCK_MAGIC )) hdr->magic =cpu_to_be32 (XFS_DIR2_DATA_MAGIC );else
@@ -1776,6 +1791,7 @@ xfs_dir2_node_to_leaf(xfs_dir3_leaf_compact (args, &leafhdr, lbp); lbp->b_ops = &xfs_dir3_leaf1_buf_ops; +xfs_trans_buf_set_type (tp, lbp,XFS_BLF_DIR_LEAF1_BUF ); leafhdr.magic = (leafhdr.magic ==XFS_DIR2_LEAFN_MAGIC ) ?XFS_DIR2_LEAF1_MAGIC :XFS_DIR3_LEAF1_MAGIC ;
libxfs/xfs_dir2_node.c +14 -3
@@ -130,7 +130,7 @@ xfs_dir3_free_write_verify(xfs_update_cksum (bp->b_addr,BBTOB (bp->b_length),XFS_DIR3_FREE_CRC_OFF ); } -static const struct xfs_buf_ops xfs_dir3_free_buf_ops = { +const struct xfs_buf_ops xfs_dir3_free_buf_ops = { .verify_read = xfs_dir3_free_read_verify, .verify_write = xfs_dir3_free_write_verify, };
@@ -144,8 +144,15 @@ __xfs_dir3_free_read(xfs_daddr_t mappedbno, struct xfs_buf **bpp) { - return xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, + int err; + + err =xfs_da_read_buf (tp, dp, fbno, mappedbno, bpp,XFS_DATA_FORK , &xfs_dir3_free_buf_ops); + +/* try read returns without an error or *bpp if it lands in a hole */ +if (!err && tp && *bpp) +xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_FREE_BUF ); +return err; }int
@@ -232,7 +239,8 @@ xfs_dir3_free_get_buf(if (error)return error; - bp->b_ops = &xfs_dir3_free_buf_ops;; +xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_FREE_BUF ); + bp->b_ops = &xfs_dir3_free_buf_ops;/* * Initialize the new block to be empty, and remember
@@ -380,6 +388,7 @@ xfs_dir2_leaf_to_node(else leaf->hdr.info.magic =cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ); lbp->b_ops = &xfs_dir3_leafn_buf_ops; +xfs_trans_buf_set_type (tp, lbp,XFS_BLF_DIR_LEAFN_BUF );xfs_dir3_leaf_log_header (tp, lbp);xfs_dir3_leaf_check (mp, lbp);return 0 ;
@@ -795,6 +804,7 @@ xfs_dir2_leafn_lookup_for_entry( (char *)curbp->b_addr); state->extrablk.magic =XFS_DIR2_DATA_MAGIC ; curbp->b_ops = &xfs_dir3_data_buf_ops; +xfs_trans_buf_set_type (tp, curbp,XFS_BLF_DIR_DATA_BUF );if (cmp ==XFS_CMP_EXACT )return XFS_ERROR (EEXIST ); }
@@ -809,6 +819,7 @@ xfs_dir2_leafn_lookup_for_entry( state->extrablk.blkno = curdb; state->extrablk.magic =XFS_DIR2_DATA_MAGIC ; curbp->b_ops = &xfs_dir3_data_buf_ops; +xfs_trans_buf_set_type (tp, curbp,XFS_BLF_DIR_DATA_BUF ); }else {/* If the curbp is not the CI match block, drop it */ if (state->extrablk.bp != curbp)
libxfs/xfs_dir2_priv.h +2 -0
@@ -49,6 +49,7 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,#endif extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; +extern const struct xfs_buf_ops xfs_dir3_free_buf_ops;extern int __xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp); extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
@@ -77,6 +78,7 @@ extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp, xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);/* xfs_dir2_leaf.c */ +extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops;extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops; extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 18/48] xfs: add buffer types to directory and attribute buffers
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Add buffer types to the buffer log items so that log recovery can validate the buffers and calculate CRCs correctly after the buffers are recovered.
Signed-off-by Dave Chinner <[email protected]>
Corresponds to commit d75afeb3d3020.
libxfs/xfs.h roundup_pow_of_two(uint v) · line 258
Quoted 9 lines
libxfs/xfs.h +1
-0@@ -255,6 +255,7 @@ roundup_pow_of_two(uint v)#define xfs_trans_agflist_delta (tp, d)#define xfs_trans_agbtree_delta (tp, d)#define xfs_trans_buf_set_type (tp, bp, t) +#define xfs_trans_buf_copy_type (dbp, sbp)
Looks like he's not called but needs to be defined to compile.
libxfs/xfs_dir2_leaf.c
Quoted 4 lines
libxfs/xfs_dir2_leaf.c +0
-0
There is probably a change later in the series that makes xfs_dir3_leaf1_buf_ops not static.
libxfs/xfs_dir2_leaf.c xfs_dir3_free_get_buf( · line 235
Quoted 5 lines
libxfs/xfs_dir2_leaf.c +0
-1@@ -232,7 +239,8 @@ xfs_dir3_free_get_buf(if (error)return error; - bp->b_ops = &xfs_dir3_free_buf_ops;;
Oh good. Got rid of the extra ;
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 19/48 xfs: buffer type overruns blf_flags field
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
The buffer type passed to log recvoery in the buffer log item overruns the blf_flags field. I had assumed that flags field was a 32 bit value, and it turns out it is a unisgned short. Therefore having 19 flags doesn't really work.
Convert the buffer type field to numeric value, and use the top 5 bits of the flags field for it. We currently have 17 types of buffers, so using 5 bits gives us plenty of room for expansion in future....
--- include/xfs_buf_item.h | 92 +++++++++++++++++++++++++++-------------------- include/xfs_trans.h | 4 --- libxfs/trans.c | 2 +- libxfs/xfs_alloc.c | 4 +-- libxfs/xfs_attr_leaf.c | 6 ++-- libxfs/xfs_bmap.c | 2 +- libxfs/xfs_btree.c | 8 ++--- libxfs/xfs_da_btree.c | 12 +++---- libxfs/xfs_dir2_block.c | 4 +-- libxfs/xfs_dir2_data.c | 4 +-- libxfs/xfs_dir2_leaf.c | 12 +++---- libxfs/xfs_dir2_node.c | 10 +++--- libxfs/xfs_ialloc.c | 2 +- 13 files changed, 86 insertions(+), 76 deletions(-)
include/xfs_buf_item.h +53 -39
@@ -39,45 +39,6 @@ extern kmem_zone_t *xfs_buf_item_zone;#define XFS_BLF_PDQUOT_BUF (1<<3)#define XFS_BLF_GDQUOT_BUF (1<<4) -/* -* all buffers now need flags to tell recovery where the magic number -* is so that it can verify and calculate the CRCs on the buffer correctly -* once the changes have been replayed into the buffer. -*/ -#define XFS_BLF_BTREE_BUF (1<<5) -#define XFS_BLF_AGF_BUF (1<<6) -#define XFS_BLF_AGFL_BUF (1<<7) -#define XFS_BLF_AGI_BUF (1<<8) -#define XFS_BLF_DINO_BUF (1<<9) -#define XFS_BLF_SYMLINK_BUF (1<<10) -#define XFS_BLF_DIR_BLOCK_BUF (1<<11) -#define XFS_BLF_DIR_DATA_BUF (1<<12) -#define XFS_BLF_DIR_FREE_BUF (1<<13) -#define XFS_BLF_DIR_LEAF1_BUF (1<<14) -#define XFS_BLF_DIR_LEAFN_BUF (1<<15) -#define XFS_BLF_DA_NODE_BUF (1<<16) -#define XFS_BLF_ATTR_LEAF_BUF (1<<17) -#define XFS_BLF_ATTR_RMT_BUF (1<<18) - -#define XFS_BLF_TYPE_MASK \ - (XFS_BLF_UDQUOT_BUF | \ - XFS_BLF_PDQUOT_BUF | \ - XFS_BLF_GDQUOT_BUF | \ - XFS_BLF_BTREE_BUF | \ - XFS_BLF_AGF_BUF | \ - XFS_BLF_AGFL_BUF | \ - XFS_BLF_AGI_BUF | \ - XFS_BLF_DINO_BUF | \ - XFS_BLF_SYMLINK_BUF | \ - XFS_BLF_DIR_BLOCK_BUF | \ - XFS_BLF_DIR_DATA_BUF | \ - XFS_BLF_DIR_FREE_BUF | \ - XFS_BLF_DIR_LEAF1_BUF | \ - XFS_BLF_DIR_LEAFN_BUF | \ - XFS_BLF_DA_NODE_BUF | \ - XFS_BLF_ATTR_LEAF_BUF | \ - XFS_BLF_ATTR_RMT_BUF) -#define XFS_BLF_CHUNK 128#define XFS_BLF_SHIFT 7#define BIT_TO_WORD_SHIFT 5
@@ -101,6 +62,55 @@ typedef struct xfs_buf_log_format { } xfs_buf_log_format_t;/* +* All buffers now need to tell recovery where the magic number +* is so that it can verify and calculate the CRCs on the buffer correctly +* once the changes have been replayed into the buffer. +* +* The type value is held in the upper 5 bits of the blf_flags field, which is +* an unsigned 16 bit field. Hence we need to shift it 11 bits up and down. +*/ +#define XFS_BLFT_BITS 5 +#define XFS_BLFT_SHIFT 11 +#define XFS_BLFT_MASK (((1 << XFS_BLFT_BITS) - 1) << XFS_BLFT_SHIFT) + +enum xfs_blft { +XFS_BLFT_UNKNOWN_BUF =0 , +XFS_BLFT_UDQUOT_BUF , +XFS_BLFT_PDQUOT_BUF , +XFS_BLFT_GDQUOT_BUF , +XFS_BLFT_BTREE_BUF , +XFS_BLFT_AGF_BUF , +XFS_BLFT_AGFL_BUF , +XFS_BLFT_AGI_BUF , +XFS_BLFT_DINO_BUF , +XFS_BLFT_SYMLINK_BUF , +XFS_BLFT_DIR_BLOCK_BUF , +XFS_BLFT_DIR_DATA_BUF , +XFS_BLFT_DIR_FREE_BUF , +XFS_BLFT_DIR_LEAF1_BUF , +XFS_BLFT_DIR_LEAFN_BUF , +XFS_BLFT_DA_NODE_BUF , +XFS_BLFT_ATTR_LEAF_BUF , +XFS_BLFT_ATTR_RMT_BUF , +XFS_BLFT_SB_BUF , +XFS_BLFT_MAX_BUF = (1 <<XFS_BLFT_BITS ), +}; + +static inline void +xfs_blft_to_flags (struct xfs_buf_log_format *blf,enum xfs_blft type) +{ +ASSERT (type >XFS_BLFT_UNKNOWN_BUF && type <XFS_BLFT_MAX_BUF ); + blf->blf_flags &= ~XFS_BLFT_MASK ; + blf->blf_flags |= ((type <<XFS_BLFT_SHIFT ) &XFS_BLFT_MASK ); +} + +static inline __uint16_t +xfs_blft_from_flags (struct xfs_buf_log_format *blf) +{ +return (blf->blf_flags &XFS_BLFT_MASK ) >>XFS_BLFT_SHIFT ; +} + +/* * buf log item flags */ #define XFS_BLI_HOLD 0x01
@@ -153,6 +163,10 @@ void xfs_buf_attach_iodone(struct xfs_buf *,void xfs_buf_iodone_callbacks (struct xfs_buf *);void xfs_buf_iodone (struct xfs_buf *,struct xfs_log_item *); +void xfs_trans_buf_set_type (struct xfs_trans *,struct xfs_buf *, +enum xfs_blft ); +void xfs_trans_buf_copy_type (struct xfs_buf *dst_bp,struct xfs_buf *src_bp); +#endif /* __KERNEL__ */ #endif /* __XFS_BUF_ITEM_H__ */
include/xfs_trans.h +0 -4
@@ -500,10 +500,6 @@ void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *);void xfs_trans_stale_inode_buf (xfs_trans_t *,struct xfs_buf *);void xfs_trans_dquot_buf (xfs_trans_t *,struct xfs_buf *,uint );void xfs_trans_inode_alloc_buf (xfs_trans_t *,struct xfs_buf *); -void xfs_trans_buf_set_type (struct xfs_trans *,struct xfs_buf *, -uint ); -void xfs_trans_buf_copy_type (struct xfs_buf *dst_bp, -struct xfs_buf *src_bp);void xfs_trans_ichgtime (struct xfs_trans *,struct xfs_inode *,int );void xfs_trans_ijoin (struct xfs_trans *,struct xfs_inode *,uint );void xfs_trans_log_buf (xfs_trans_t *,struct xfs_buf *,uint ,uint );
libxfs/trans.c +1 -1
@@ -218,7 +218,7 @@ libxfs_trans_inode_alloc_buf( ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); bip->bli_flags |=XFS_BLI_INODE_ALLOC_BUF ; -xfs_trans_buf_set_type (tp, bp,XFS_BLF_DINO_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DINO_BUF ); }/*
libxfs/xfs_alloc.c +2 -2
@@ -2079,7 +2079,7 @@ xfs_alloc_log_agf(trace_xfs_agf (tp->t_mountp,XFS_BUF_TO_AGF (bp), fields, _RET_IP_); -xfs_trans_buf_set_type (tp, bp,XFS_BLF_AGF_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_AGF_BUF );xfs_btree_offsets (fields, offsets,XFS_AGF_NUM_BITS , &first, &last);xfs_trans_log_buf (tp, bp, (uint )first, (uint )last);
@@ -2159,7 +2159,7 @@ xfs_alloc_put_freelist(xfs_alloc_log_agf (tp, agbp, logflags); -xfs_trans_buf_set_type (tp, agflbp,XFS_BLF_AGFL_BUF ); +xfs_trans_buf_set_type (tp, agflbp,XFS_BLFT_AGFL_BUF );xfs_trans_log_buf (tp, agflbp, startoff, startoff +sizeof (xfs_agblock_t) -1 );return 0 ;
libxfs/xfs_attr_leaf.c +3 -3
@@ -241,7 +241,7 @@ xfs_attr3_leaf_read( err =xfs_da_read_buf (tp, dp, bno, mappedbno, bpp,XFS_ATTR_FORK , &xfs_attr3_leaf_buf_ops);if (!err && tp) -xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_ATTR_LEAF_BUF ); +xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_ATTR_LEAF_BUF );return err; }
@@ -872,7 +872,7 @@ xfs_attr3_leaf_to_node( goto out;/* copy leaf to new buffer, update identifiers */ -xfs_trans_buf_set_type (args->trans, bp2,XFS_BLF_ATTR_LEAF_BUF ); +xfs_trans_buf_set_type (args->trans, bp2,XFS_BLFT_ATTR_LEAF_BUF ); bp2->b_ops = bp1->b_ops;memcpy (bp2->b_addr, bp1->b_addr,XFS_LBSIZE (mp));if (xfs_sb_version_hascrc (&mp->m_sb)) {
@@ -935,7 +935,7 @@ xfs_attr3_leaf_create(if (error)return error; bp->b_ops = &xfs_attr3_leaf_buf_ops; -xfs_trans_buf_set_type (args->trans, bp,XFS_BLF_ATTR_LEAF_BUF ); +xfs_trans_buf_set_type (args->trans, bp,XFS_BLFT_ATTR_LEAF_BUF ); leaf = bp->b_addr;memset (leaf,0 ,XFS_LBSIZE (mp));
libxfs/xfs_bmap.c +1 -1
@@ -1217,7 +1217,7 @@ xfs_bmap_local_to_extents_init_fn( { bp->b_ops = &xfs_bmbt_buf_ops;memcpy (bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); -xfs_trans_buf_set_type (tp, bp,XFS_BLF_BTREE_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_BTREE_BUF ); }STATIC void
libxfs/xfs_btree.c +4 -4
@@ -1227,7 +1227,7 @@ xfs_btree_log_keys(XFS_BTREE_TRACE_ARGBII (cur, bp, first, last);if (bp) { -xfs_trans_buf_set_type (cur->bc_tp, bp,XFS_BLF_BTREE_BUF ); +xfs_trans_buf_set_type (cur->bc_tp, bp,XFS_BLFT_BTREE_BUF );xfs_trans_log_buf (cur->bc_tp, bp,xfs_btree_key_offset (cur, first),xfs_btree_key_offset (cur, last +1 ) -1 );
@@ -1252,7 +1252,7 @@ xfs_btree_log_recs(XFS_BTREE_TRACE_CURSOR (cur,XBT_ENTRY );XFS_BTREE_TRACE_ARGBII (cur, bp, first, last); -xfs_trans_buf_set_type (cur->bc_tp, bp,XFS_BLF_BTREE_BUF ); +xfs_trans_buf_set_type (cur->bc_tp, bp,XFS_BLFT_BTREE_BUF );xfs_trans_log_buf (cur->bc_tp, bp,xfs_btree_rec_offset (cur, first),xfs_btree_rec_offset (cur, last +1 ) -1 );
@@ -1277,7 +1277,7 @@ xfs_btree_log_ptrs(struct xfs_btree_block *block =XFS_BUF_TO_BLOCK (bp);int level =xfs_btree_get_level (block); -xfs_trans_buf_set_type (cur->bc_tp, bp,XFS_BLF_BTREE_BUF ); +xfs_trans_buf_set_type (cur->bc_tp, bp,XFS_BLFT_BTREE_BUF );xfs_trans_log_buf (cur->bc_tp, bp,xfs_btree_ptr_offset (cur, first, level),xfs_btree_ptr_offset (cur, last +1 , level) -1 );
@@ -1352,7 +1352,7 @@ xfs_btree_log_block( (cur->bc_flags &XFS_BTREE_LONG_PTRS ) ? loffsets : soffsets, nbits, &first, &last); -xfs_trans_buf_set_type (cur->bc_tp, bp,XFS_BLF_BTREE_BUF ); +xfs_trans_buf_set_type (cur->bc_tp, bp,XFS_BLFT_BTREE_BUF );xfs_trans_log_buf (cur->bc_tp, bp, first, last); }else { xfs_trans_log_inode(cur->bc_tp, cur->bc_private.b.ip,
libxfs/xfs_da_btree.c +6 -6
@@ -290,15 +290,15 @@ xfs_da3_node_read(switch (be16_to_cpu (info->magic)) {case XFS_DA3_NODE_MAGIC :case XFS_DA_NODE_MAGIC : - type =XFS_BLF_DA_NODE_BUF ; + type =XFS_BLFT_DA_NODE_BUF ;break ;case XFS_ATTR_LEAF_MAGIC :case XFS_ATTR3_LEAF_MAGIC : - type =XFS_BLF_ATTR_LEAF_BUF ; + type =XFS_BLFT_ATTR_LEAF_BUF ;break ;case XFS_DIR2_LEAFN_MAGIC :case XFS_DIR3_LEAFN_MAGIC : - type =XFS_BLF_DIR_LEAFN_BUF ; + type =XFS_BLFT_DIR_LEAFN_BUF ;break ;default : type =0 ;
@@ -339,7 +339,7 @@ xfs_da3_node_create(if (error)return (error); bp->b_ops = &xfs_da3_node_buf_ops; -xfs_trans_buf_set_type (tp, bp,XFS_BLF_DA_NODE_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DA_NODE_BUF ); node = bp->b_addr;if (xfs_sb_version_hascrc (&mp->m_sb)) {
@@ -573,7 +573,7 @@ xfs_da3_root_split(* we are about to copy oldroot to bp, so set up the type * of bp while we know exactly what it will be. */ -xfs_trans_buf_set_type (tp, bp,XFS_BLF_DA_NODE_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DA_NODE_BUF ); }else {struct xfs_dir3_icleaf_hdr leafhdr;struct xfs_dir2_leaf_entry *ents;
@@ -591,7 +591,7 @@ xfs_da3_root_split(* we are about to copy oldroot to bp, so set up the type * of bp while we know exactly what it will be. */ -xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_LEAFN_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DIR_LEAFN_BUF ); }/*
libxfs/xfs_dir2_block.c +2 -2
@@ -119,7 +119,7 @@ xfs_dir3_block_read( err =xfs_da_read_buf (tp, dp, mp->m_dirdatablk,-1 , bpp,XFS_DATA_FORK , &xfs_dir3_block_buf_ops);if (!err && tp) -xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_BLOCK_BUF ); +xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_BLOCK_BUF );return err; }
@@ -133,7 +133,7 @@ xfs_dir3_block_init(struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; bp->b_ops = &xfs_dir3_block_buf_ops; -xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_BLOCK_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DIR_BLOCK_BUF );if (xfs_sb_version_hascrc (&mp->m_sb)) {memset (hdr3,0 ,sizeof (*hdr3));
libxfs/xfs_dir2_data.c +2 -2
@@ -288,7 +288,7 @@ xfs_dir3_data_read( err =xfs_da_read_buf (tp, dp, bno, mapped_bno, bpp,XFS_DATA_FORK , &xfs_dir3_data_buf_ops);if (!err && tp) -xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_DATA_BUF ); +xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_DATA_BUF );return err; }
@@ -558,7 +558,7 @@ xfs_dir3_data_init(if (error)return error; bp->b_ops = &xfs_dir3_data_buf_ops; -xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_DATA_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DIR_DATA_BUF );/* * Initialize the header.
libxfs/xfs_dir2_leaf.c +6 -6
@@ -284,7 +284,7 @@ xfs_dir3_leaf_read( err =xfs_da_read_buf (tp, dp, fbno, mappedbno, bpp,XFS_DATA_FORK , &xfs_dir3_leaf1_buf_ops);if (!err && tp) -xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_LEAF1_BUF ); +xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_LEAF1_BUF );return err; }
@@ -301,7 +301,7 @@ xfs_dir3_leafn_read( err =xfs_da_read_buf (tp, dp, fbno, mappedbno, bpp,XFS_DATA_FORK , &xfs_dir3_leafn_buf_ops);if (!err && tp) -xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_LEAFN_BUF ); +xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_LEAFN_BUF );return err; }
@@ -346,10 +346,10 @@ xfs_dir3_leaf_init( ltp =xfs_dir2_leaf_tail_p (mp, leaf); ltp->bestcount =0 ; bp->b_ops = &xfs_dir3_leaf1_buf_ops; -xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_LEAF1_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DIR_LEAF1_BUF ); }else { bp->b_ops = &xfs_dir3_leafn_buf_ops; -xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_LEAFN_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DIR_LEAFN_BUF ); } }
@@ -470,7 +470,7 @@ xfs_dir2_block_to_leaf(* Fix up the block header, make it a data block. */ dbp->b_ops = &xfs_dir3_data_buf_ops; -xfs_trans_buf_set_type (tp, dbp,XFS_BLF_DIR_DATA_BUF ); +xfs_trans_buf_set_type (tp, dbp,XFS_BLFT_DIR_DATA_BUF );if (hdr->magic ==cpu_to_be32 (XFS_DIR2_BLOCK_MAGIC )) hdr->magic =cpu_to_be32 (XFS_DIR2_DATA_MAGIC );else
@@ -1791,7 +1791,7 @@ xfs_dir2_node_to_leaf(xfs_dir3_leaf_compact (args, &leafhdr, lbp); lbp->b_ops = &xfs_dir3_leaf1_buf_ops; -xfs_trans_buf_set_type (tp, lbp,XFS_BLF_DIR_LEAF1_BUF ); +xfs_trans_buf_set_type (tp, lbp,XFS_BLFT_DIR_LEAF1_BUF ); leafhdr.magic = (leafhdr.magic ==XFS_DIR2_LEAFN_MAGIC ) ?XFS_DIR2_LEAF1_MAGIC :XFS_DIR3_LEAF1_MAGIC ;
libxfs/xfs_dir2_node.c +5 -5
@@ -151,7 +151,7 @@ __xfs_dir3_free_read(/* try read returns without an error or *bpp if it lands in a hole */ if (!err && tp && *bpp) -xfs_trans_buf_set_type (tp, *bpp,XFS_BLF_DIR_FREE_BUF ); +xfs_trans_buf_set_type (tp, *bpp,XFS_BLFT_DIR_FREE_BUF );return err; }
@@ -239,7 +239,7 @@ xfs_dir3_free_get_buf(if (error)return error; -xfs_trans_buf_set_type (tp, bp,XFS_BLF_DIR_FREE_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DIR_FREE_BUF ); bp->b_ops = &xfs_dir3_free_buf_ops;/*
@@ -388,7 +388,7 @@ xfs_dir2_leaf_to_node(else leaf->hdr.info.magic =cpu_to_be16 (XFS_DIR3_LEAFN_MAGIC ); lbp->b_ops = &xfs_dir3_leafn_buf_ops; -xfs_trans_buf_set_type (tp, lbp,XFS_BLF_DIR_LEAFN_BUF ); +xfs_trans_buf_set_type (tp, lbp,XFS_BLFT_DIR_LEAFN_BUF );xfs_dir3_leaf_log_header (tp, lbp);xfs_dir3_leaf_check (mp, lbp);return 0 ;
@@ -804,7 +804,7 @@ xfs_dir2_leafn_lookup_for_entry( (char *)curbp->b_addr); state->extrablk.magic =XFS_DIR2_DATA_MAGIC ; curbp->b_ops = &xfs_dir3_data_buf_ops; -xfs_trans_buf_set_type (tp, curbp,XFS_BLF_DIR_DATA_BUF ); +xfs_trans_buf_set_type (tp, curbp,XFS_BLFT_DIR_DATA_BUF );if (cmp ==XFS_CMP_EXACT )return XFS_ERROR (EEXIST ); }
@@ -819,7 +819,7 @@ xfs_dir2_leafn_lookup_for_entry( state->extrablk.blkno = curdb; state->extrablk.magic =XFS_DIR2_DATA_MAGIC ; curbp->b_ops = &xfs_dir3_data_buf_ops; -xfs_trans_buf_set_type (tp, curbp,XFS_BLF_DIR_DATA_BUF ); +xfs_trans_buf_set_type (tp, curbp,XFS_BLFT_DIR_DATA_BUF ); }else {/* If the curbp is not the CI match block, drop it */ if (state->extrablk.bp != curbp)
libxfs/xfs_ialloc.c +1 -1
@@ -1286,7 +1286,7 @@ xfs_ialloc_log_agi(/* * Log the allocation group inode header buffer. */ -xfs_trans_buf_set_type (tp, bp,XFS_BLF_AGI_BUF ); +xfs_trans_buf_set_type (tp, bp,XFS_BLFT_AGI_BUF );xfs_trans_log_buf (tp, bp, first, last); }
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 19/48] xfs: buffer type overruns blf_flags field
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The buffer type passed to log recvoery in the buffer log item overruns the
blf_flagsfield. I had assumed that flags field was a 32 bit value, and it turns out it is a unisgned short. Therefore having 19 flags doesn't really work.
Quoted 6 lines
Convert the buffer type field to numeric value, and use the top 5 bits of the flags field for it. We currently have 17 types of buffers, so using 5 bits gives us plenty of room for expansion in future....
Signed-off-by Dave Chinner <[email protected]>
This corresponds to commit 61fe135c1dde1.
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 20/48 xfs: add CRC checks to the superblock
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
With the addition of CRCs, there is such a wide and varied change to the on disk format that it makes sense to bump the superblock version number rather than try to use feature bits for all the new functionality.
This commit introduces all the new superblock fields needed for all the new functionality: feature masks similar to ext4, separate project quota inodes, a LSN field for recovery and the CRC field.
This commit does not bump the superblock version number, however. That will be done as a separate commit at the end of the series after all the new functionality is present so we switch it all on in one commit. This means that we can slowly introduce the changes without them being active and hence maintain bisectability of the tree.
This patch is based on a patch originally written by myself back from SGI days, which was subsequently modified by Christoph Hellwig. There is relatively little of that patch remaining, but the history of the patch still should be acknowledged here.
--- include/xfs_mount.h | 1 + include/xfs_sb.h | 100 ++++++++++++++++++++++++++++++++++++--------------- libxfs/xfs_mount.c | 92 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 153 insertions(+), 40 deletions(-)
include/xfs_mount.h +1 -0
@@ -391,6 +391,7 @@ struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *mp, xfs_agnumber_t agno, int tag);void xfs_perag_put (struct xfs_perag *pag); +extern void xfs_sb_calc_crc (struct xfs_buf *);extern void xfs_mod_sb (struct xfs_trans *,__int64_t );extern int xfs_initialize_perag (struct xfs_mount *,xfs_agnumber_t ,xfs_agnumber_t *);
include/xfs_sb.h +71 -29
231 lines not on this page · raw message
libxfs/xfs_mount.c +81 -11
158 lines not on this page · raw message
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 20/48] xfs: add CRC checks to the superblock
Quoted 18 lines · Dave Chinner
From: Dave Chinner <[email protected]>
With the addition of CRCs, there is such a wide and varied change to the on disk format that it makes sense to bump the superblock version number rather than try to use feature bits for all the new functionality.
This commit introduces all the new superblock fields needed for all the new functionality: feature masks similar to ext4, separate project quota inodes, a LSN field for recovery and the CRC field.
This commit does not bump the superblock version number, however. That will be done as a separate commit at the end of the series after all the new functionality is present so we switch it all on in one commit. This means that we can slowly introduce the changes without them being active and hence maintain bisectability of the tree.
Quoted 6 lines
This patch is based on a patch originally written by myself back from SGI days, which was subsequently modified by Christoph Hellwig. There is relatively little of that patch remaining, but the history of the patch still should be acknowledged here.
Signed-off-by Dave Chinner <[email protected]>
corresponds to commit 04a1e6c5b222b
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 21/48 xfs: implement extended feature masks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
The version 5 superblock has extended feature masks for compatible, incompatible and read-only compatible feature sets. Implement the masking and mount-time checking for these feature masks.
--- include/xfs_sb.h | 70 ++++++++++++++++++++++++++++++++++++++++++-- libxfs/xfs_mount.c | 53 ++++++++++++++++++++++++--------- logprint/log_print_trans.c | 18 ++++++++++++ 3 files changed, 125 insertions(+), 16 deletions(-)
include/xfs_sb.h +68 -2
@@ -168,8 +168,10 @@ typedef struct xfs_sb {__uint32_t sb_features_compat;__uint32_t sb_features_ro_compat;__uint32_t sb_features_incompat; +__uint32_t sb_features_log_incompat;__uint32_t sb_crc;/* superblock crc */ +__uint32_t sb_pad;xfs_ino_t sb_pquotino;/* project quota inode */ xfs_lsn_t sb_lsn;/* last write sequence */
@@ -250,8 +252,10 @@ typedef struct xfs_dsb {__be32 sb_features_compat;__be32 sb_features_ro_compat;__be32 sb_features_incompat; +__be32 sb_features_log_incompat;__le32 sb_crc;/* superblock crc */ +__be32 sb_pad;__be64 sb_pquotino;/* project quota inode */ __be64 sb_lsn;/* last write sequence */
@@ -276,7 +280,8 @@ typedef enum {XFS_SBS_INOALIGNMT ,XFS_SBS_UNIT ,XFS_SBS_WIDTH ,XFS_SBS_DIRBLKLOG ,XFS_SBS_LOGSECTLOG ,XFS_SBS_LOGSECTSIZE ,XFS_SBS_LOGSUNIT ,XFS_SBS_FEATURES2 ,XFS_SBS_BAD_FEATURES2 ,XFS_SBS_FEATURES_COMPAT , -XFS_SBS_FEATURES_RO_COMPAT ,XFS_SBS_FEATURES_INCOMPAT ,XFS_SBS_CRC , +XFS_SBS_FEATURES_RO_COMPAT ,XFS_SBS_FEATURES_INCOMPAT , +XFS_SBS_FEATURES_LOG_INCOMPAT ,XFS_SBS_CRC ,XFS_SBS_PAD ,XFS_SBS_PQUOTINO ,XFS_SBS_LSN , XFS_SBS_FIELDCOUNT } xfs_sb_field_t;
@@ -306,6 +311,7 @@ typedef enum {#define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT)#define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT)#define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) +#define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT)#define XFS_SB_CRC XFS_SB_MVAL(CRC)#define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO)#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
@@ -316,7 +322,8 @@ typedef enum {XFS_SB_QFLAGS |XFS_SB_SHARED_VN |XFS_SB_UNIT |XFS_SB_WIDTH | \XFS_SB_ICOUNT |XFS_SB_IFREE |XFS_SB_FDBLOCKS |XFS_SB_FEATURES2 | \XFS_SB_BAD_FEATURES2 |XFS_SB_FEATURES_COMPAT | \ - XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | XFS_SB_PQUOTINO) +XFS_SB_FEATURES_RO_COMPAT |XFS_SB_FEATURES_INCOMPAT | \ + XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO)/*
@@ -559,6 +566,65 @@ static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp)return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; } + +/* +* Extended v5 superblock feature masks. These are to be used for new v5 +* superblock features only. +* +* Compat features are new features that old kernels will not notice or affect +* and so can mount read-write without issues. +* +* RO-Compat (read only) are features that old kernels can read but will break +* if they write. Hence only read-only mounts of such filesystems are allowed on +* kernels that don't support the feature bit. +* +* InCompat features are features which old kernels will not understand and so +* must not mount. +* +* Log-InCompat features are for changes to log formats or new transactions that +* can't be replayed on older kernels. The fields are set when the filesystem is +* mounted, and a clean unmount clears the fields. +*/ +#define XFS_SB_FEAT_COMPAT_ALL 0 +#define XFS_SB_FEAT_COMPAT_UNKNOWN ~XFS_SB_FEAT_COMPAT_ALL +static inline bool +xfs_sb_has_compat_feature ( +struct xfs_sb *sbp, +__uint32_t feature) +{ +return (sbp->sb_features_compat & feature) !=0 ; +} + +#define XFS_SB_FEAT_RO_COMPAT_ALL 0 +#define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL +static inline bool +xfs_sb_has_ro_compat_feature ( +struct xfs_sb *sbp, +__uint32_t feature) +{ +return (sbp->sb_features_ro_compat & feature) !=0 ; +} + +#define XFS_SB_FEAT_INCOMPAT_ALL 0 +#define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL +static inline bool +xfs_sb_has_incompat_feature ( +struct xfs_sb *sbp, +__uint32_t feature) +{ +return (sbp->sb_features_incompat & feature) !=0 ; +} + +#define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 +#define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL +static inline bool +xfs_sb_has_incompat_log_feature ( +struct xfs_sb *sbp, +__uint32_t feature) +{ +return (sbp->sb_features_log_incompat & feature) !=0 ; +} +/* * end of superblock version macros */
libxfs/xfs_mount.c +39 -14
89 lines not on this page · raw message
logprint/log_print_trans.c +18 -0
@@ -68,6 +68,24 @@ xfs_log_print_trans(if (head_blk == tail_blk)return ; + +/* +* Version 5 superblock log feature mask validation. We know the +* log is dirty so check if there are any unknown log features +* in what we need to recover. If there are unknown features +* (e.g. unsupported transactions) then warn about it. +*/ +if (XFS_SB_VERSION_NUM (&log->l_mp->m_sb) ==XFS_SB_VERSION_5 && +xfs_sb_has_incompat_log_feature (&log->l_mp->m_sb, +XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN )) { +printf (_ ( +"Superblock has unknown incompatible log features (0x%x) enabled.\n" +"Output may be incomplete or inaccurate. It is recommended that you\n" +"upgrade your xfsprogs installation to match the filesystem features.\n" ), + (log->l_mp->m_sb.sb_features_log_incompat & +XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN )); + } +if ((error =xlog_do_recovery_pass (log, head_blk, tail_blk,XLOG_RECOVER_PASS1 ))) {fprintf (stderr,_ ("%s: failed in xfs_do_recovery_pass, error: %d\n" ), progname, error);
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 21/48] xfs: implement extended feature masks
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The version 5 superblock has extended feature masks for compatible, incompatible and read-only compatible feature sets. Implement the masking and mount-time checking for these feature masks.
Signed-off-by Dave Chinner <[email protected]>
corresponds to commit e721f504cf46a
libxfs/xfs_mount.c xfs_mount_validate_sb( · line 222
Quoted 10 lines
libxfs/xfs_mount.c +0
-6@@ -214,12 +242,6 @@ xfs_mount_validate_sb(return XFS_ERROR (ENOSYS ); } - -if (check_inprogress && sbp->sb_inprogress) { -xfs_warn (mp,"Offline file system operation in progress!" ); -return XFS_ERROR (EFSCORRUPTED ); - } -
Why did this need to be removed?
Other than that this looks fine.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 21/48] xfs: implement extended feature masks
Quoted 15 lines · Ben Myers
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The version 5 superblock has extended feature masks for compatible, incompatible and read-only compatible feature sets. Implement the masking and mount-time checking for these feature masks.
Signed-off-by Dave Chinner <[email protected]>corresponds to commit
e721f504cf46aQuoted 4 lines
libxfs/xfs_mount.c +0
-0@@ -214,12 +242,6 @@ xfs_mount_validate_sb(return XFS_ERROR (ENOSYS ); }
Quoted 8 lines
libxfs/xfs_mount.c xfs_mount_validate_sb( · line 222
Quoted 6 lines
libxfs/xfs_mount.c +0
-6- -if (check_inprogress && sbp->sb_inprogress) { -xfs_warn (mp,"Offline file system operation in progress!" ); -return XFS_ERROR (EFSCORRUPTED ); - } -Why did this need to be removed?
Think about it for a minute - it's not valid in userspace. i.e. it's a kernel-side check to determine if userspace is modifying the filesystem at the current time.
e.g. mkfs.xfs sets it in the primary superblock to prevent the kernel mounting the filesystem before mkfs completes. If we leave it in the userspace code, then mkfs will abort when it rereads the superblock from disk because it's detected that mkfs is running....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 22/48 xfsprogs: Add verifiers to libxfs buffer interfaces.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Verifiers need to be used everywhere to enable calculation of CRCs during writeback of modified metadata. Add then to the libxfs buffer interfaces conver the internal use of devices to be buftarg aware.
Verifiers also require that the buffer has a back pointer to the struct xfs_mount. To make this source level comaptible between kernel and userspace, convert userspace to pass struct xfs_buftargs around rather than a "device".
--- copy/xfs_copy.c | 4 +- db/sb.c | 8 +- include/libxfs.h | 96 ++++++++++++++---------- include/libxlog.h | 2 +- include/xfs_dir2.h | 7 ++ libxfs/init.c | 84 ++++++++++++++++++--- libxfs/logitem.c | 4 +- libxfs/rdwr.c | 195 ++++++++++++++++++++++++++++++++---------------- libxfs/trans.c | 16 ++-- libxfs/xfs.h | 11 +-- libxfs/xfs_dir2_priv.h | 8 -- logprint/logprint.c | 4 +- mkfs/proto.c | 4 +- mkfs/xfs_mkfs.c | 56 ++++++++------ repair/attr_repair.c | 10 +-- repair/dino_chunks.c | 8 +- repair/dinode.c | 10 ++- repair/dir2.c | 15 ++-- repair/phase2.c | 7 +- repair/phase3.c | 2 +- repair/phase6.c | 13 ++-- repair/prefetch.c | 4 +- repair/rt.c | 4 +- repair/scan.c | 15 ++-- repair/xfs_repair.c | 6 +- 25 files changed, 381 insertions(+), 212 deletions(-)
copy/xfs_copy.c +3 -1
@@ -674,8 +674,10 @@ main(int argc, char **argv)/* prepare the mount structure */ - sbp =libxfs_readbuf (xargs.ddev,XFS_SB_DADDR ,1 ,0 );memset (&mbuf,0 ,sizeof (xfs_mount_t)); +libxfs_buftarg_init (&mbuf, xargs.ddev, xargs.logdev, xargs.rtdev); + sbp =libxfs_readbuf (mbuf.m_ddev_targp,XFS_SB_DADDR ,1 ,0 , + &xfs_sb_buf_ops); sb = &mbuf.m_sb;libxfs_sb_from_disk (sb,XFS_BUF_TO_SBP (sbp));
db/sb.c +3 -5
@@ -231,15 +231,14 @@ sb_logcheck(void) }memset (&log,0 ,sizeof (log)); -if (!x.logdev) - x.logdev = x.ddev; +libxfs_buftarg_init (mp, x.ddev, x.logdev, x.rtdev); x.logBBsize =XFS_FSB_TO_BB (mp, mp->m_sb.sb_logblocks); x.logBBstart =XFS_FSB_TO_DADDR (mp, mp->m_sb.sb_logstart); x.lbsize =BBSIZE ;if (xfs_sb_version_hassector (&mp->m_sb)) x.lbsize <<= (mp->m_sb.sb_logsectlog -BBSHIFT ); - log.l_dev = (mp->m_sb.sb_logstart ==0 ) ? x.logdev : x.ddev; + log.l_dev = mp->m_logdev_targp; log.l_logsize =BBTOB (log.l_logBBsize); log.l_logBBsize = x.logBBsize; log.l_logBBstart = x.logBBstart;
@@ -271,8 +270,7 @@ sb_logzero(uuid_t *uuidp)dbprintf (_ ("Clearing log and setting UUID\n" )); - if (libxfs_log_clear( - (mp->m_sb.sb_logstart == 0) ? x.logdev : x.ddev, + if (libxfs_log_clear(mp->m_logdev_targp, XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), (xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks), uuidp,
include/libxfs.h +58 -38
211 lines not on this page · raw message
include/libxlog.h +1 -1
@@ -28,7 +28,7 @@ struct xlog {xfs_lsn_t l_tail_lsn;/* lsn of 1st LR w/ unflush buffers */ xfs_lsn_t l_last_sync_lsn;/* lsn of last LR on disk */ xfs_mount_t *l_mp;/* mount point */ -dev_t l_dev;/* dev_t of log */ +struct xfs_buftarg *l_dev;/* dev_t of log */ xfs_daddr_t l_logBBstart;/* start block of log */ int l_logsize;/* size of log in bytes */ int l_logBBsize;/* size of log in 512 byte chunks */
include/xfs_dir2.h +7 -0
@@ -104,4 +104,11 @@ extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp,extern struct xfs_dir2_data_free *xfs_dir2_data_freefind (struct xfs_dir2_data_hdr *hdr,struct xfs_dir2_data_unused *dup); +extern const struct xfs_buf_ops xfs_dir3_block_buf_ops; +extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops; +extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops; +extern const struct xfs_buf_ops xfs_dir3_free_buf_ops; +extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; + +#endif /* __XFS_DIR2_H__ */
libxfs/init.c +75 -9
124 lines not on this page · raw message
libxfs/logitem.c +2 -2
@@ -32,7 +32,7 @@ kmem_zone_t *xfs_ili_zone; /* inode log item zone */xfs_buf_t *xfs_trans_buf_item_match (xfs_trans_t *tp, -dev_t dev, +struct xfs_buftarg *btp,struct xfs_buf_map *map,int nmaps) {
@@ -47,7 +47,7 @@ xfs_trans_buf_item_match(list_for_each_entry (lidp, &tp->t_items, lid_trans) { blip = (struct xfs_buf_log_item *)lidp->lid_item;if (blip->bli_item.li_type ==XFS_LI_BUF && - blip->bli_buf->b_dev == dev && + blip->bli_buf->b_target->dev == btp->dev &&XFS_BUF_ADDR (blip->bli_buf) == map[0 ].bm_bn && blip->bli_buf->b_bcount ==BBTOB (len)) {ASSERT (blip->bli_buf->b_map_count == nmaps);
libxfs/rdwr.c +132 -63
437 lines not on this page · raw message
libxfs/trans.c +8 -8
@@ -386,7 +386,7 @@ libxfs_trans_bhold(xfs_buf_t *libxfs_trans_get_buf_map (xfs_trans_t *tp, -dev_t dev, +struct xfs_buftarg *btp,struct xfs_buf_map *map,int nmaps,uint f)
@@ -395,9 +395,9 @@ libxfs_trans_get_buf_map(xfs_buf_log_item_t *bip;if (tp ==NULL ) -return libxfs_getbuf_map (dev, map, nmaps); +return libxfs_getbuf_map (btp, map, nmaps); - bp =xfs_trans_buf_item_match (tp, dev, map, nmaps); + bp =xfs_trans_buf_item_match (tp, btp, map, nmaps);if (bp !=NULL ) { ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
@@ -406,7 +406,7 @@ libxfs_trans_get_buf_map(return bp; } - bp =libxfs_getbuf_map (dev, map, nmaps); + bp =libxfs_getbuf_map (btp, map, nmaps);if (bp ==NULL )return NULL ;#ifdef XACT_DEBUG
@@ -465,7 +465,7 @@ int libxfs_trans_read_buf_map( xfs_mount_t *mp, xfs_trans_t *tp, - dev_t dev, + struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps, uint flags,
@@ -479,7 +479,7 @@ libxfs_trans_read_buf_map( *bpp =NULL ;if (tp ==NULL ) { - bp =libxfs_readbuf_map (dev, map, nmaps, flags); + bp =libxfs_readbuf_map (btp, map, nmaps, flags, ops);if (!bp) {return (flags &XBF_TRYLOCK ) ?EAGAIN :XFS_ERROR (ENOMEM );
@@ -489,7 +489,7 @@ libxfs_trans_read_buf_map( goto done; } - bp =xfs_trans_buf_item_match (tp, dev, map, nmaps); + bp =xfs_trans_buf_item_match (tp, btp, map, nmaps);if (bp !=NULL ) { ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
@@ -498,7 +498,7 @@ libxfs_trans_read_buf_map( goto done; } - bp =libxfs_readbuf_map (dev, map, nmaps, flags); + bp =libxfs_readbuf_map (btp, map, nmaps, flags, ops);if (!bp) {return (flags &XBF_TRYLOCK ) ?EAGAIN :XFS_ERROR (ENOMEM );
libxfs/xfs.h +2 -9
@@ -55,9 +55,6 @@ typedef __uint32_t inst_t; /* an instruction */#define EWRONGFS EINVAL#endif -#define m_ddev_targp m_dev -#define m_logdev_targp m_logdev -#define m_rtdev_targp m_rtdev#define xfs_error_level 0#define STATIC static
@@ -187,11 +184,7 @@ roundup_pow_of_two(uint v)NULL ; \ })#define xfs_buf_relse (bp) libxfs_putbuf(bp) -#define xfs_read_buf (mp,devp,blkno,len,f,bpp) \ - (*(bpp) = libxfs_readbuf((devp), \ - (blkno), (len), 1), 0) -#define xfs_buf_get (devp,blkno,len,f) \ - (libxfs_getbuf((devp), (blkno), (len))) +#define xfs_buf_get (devp,blkno,len,f) (libxfs_getbuf((devp), (blkno), (len)))#define xfs_bwrite (bp) libxfs_writebuf((bp), 0)#define XBRW_READ LIBXFS_BREAD
@@ -372,7 +365,7 @@ void xfs_buf_item_init (xfs_buf_t *, xfs_mount_t *);void xfs_buf_item_log (xfs_buf_log_item_t *,uint ,uint );/* xfs_trans_buf.c */ -xfs_buf_t *xfs_trans_buf_item_match (xfs_trans_t *,dev_t , +xfs_buf_t *xfs_trans_buf_item_match (xfs_trans_t *,struct xfs_buftarg *,struct xfs_buf_map *,int );/* local source files */
libxfs/xfs_dir2_priv.h +0 -8
@@ -30,8 +30,6 @@ extern int xfs_dir_cilookup_result(struct xfs_da_args *args, const unsigned char *name, int len);/* xfs_dir2_block.c */ -extern const struct xfs_buf_ops xfs_dir3_block_buf_ops; -extern int xfs_dir2_block_addname (struct xfs_da_args *args);extern int xfs_dir2_block_getdents (struct xfs_inode *dp,void *dirent,xfs_off_t *offset,filldir_t filldir);
@@ -48,9 +46,6 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,#define xfs_dir3_data_check (dp,bp)#endif -extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; -extern const struct xfs_buf_ops xfs_dir3_free_buf_ops; -extern int __xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp);extern int xfs_dir3_data_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t bno,xfs_daddr_t mapped_bno,struct xfs_buf **bpp);
@@ -78,9 +73,6 @@ extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp, xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);/* xfs_dir2_leaf.c */ -extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops; -extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops; -extern int xfs_dir3_leafn_read (struct xfs_trans *tp,struct xfs_inode *dp,xfs_dablk_t fbno,xfs_daddr_t mappedbno,struct xfs_buf **bpp); extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
logprint/logprint.c +3 -1
@@ -140,6 +140,7 @@ main(int argc, char **argv)setlocale (LC_ALL ,"" );bindtextdomain (PACKAGE ,LOCALEDIR );textdomain (PACKAGE ); +memset (&mount,0 ,sizeof (mount)); progname =basename (argv[0 ]);while ((c =getopt (argc, argv,"bC:cdefl:iqnors:tDVv" )) !=EOF ) {
@@ -220,6 +221,7 @@ main(int argc, char **argv)exit (1 );logstat (&mount); +libxfs_buftarg_init (&mount, x.ddev, x.logdev, x.rtdev); logfd = (x.logfd <0 ) ? x.dfd : x.logfd;
@@ -236,7 +238,7 @@ main(int argc, char **argv)ASSERT (x.logBBsize <=INT_MAX ); - log.l_dev = x.logdev; + log.l_dev = mount.m_logdev_targp; log.l_logsize =BBTOB (x.logBBsize); log.l_logBBstart = x.logBBstart; log.l_logBBsize = x.logBBsize;
mkfs/proto.c +2 -2
@@ -676,7 +676,7 @@ rtinit( error); }for (i =0 , ep = map; i < nmap; i++, ep++) { -libxfs_device_zero (mp->m_dev, +libxfs_device_zero (mp->m_ddev_targp,XFS_FSB_TO_DADDR (mp, ep->br_startblock),XFS_FSB_TO_BB (mp, ep->br_blockcount)); bno += ep->br_blockcount;
@@ -713,7 +713,7 @@ rtinit( error); }for (i =0 , ep = map; i < nmap; i++, ep++) { -libxfs_device_zero (mp->m_dev, +libxfs_device_zero (mp->m_ddev_targp,XFS_FSB_TO_DADDR (mp, ep->br_startblock),XFS_FSB_TO_BB (mp, ep->br_blockcount)); bno += ep->br_blockcount;
mkfs/xfs_mkfs.c +34 -22
159 lines not on this page · raw message
repair/attr_repair.c +5 -5
@@ -170,7 +170,7 @@ traverse_int_dablock(xfs_mount_t *mp, goto error_out; bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, fsbno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 , &xfs_da3_node_buf_ops);if (!bp) {if (whichfork ==XFS_DATA_FORK ) do_warn(
@@ -552,7 +552,7 @@ verify_da_path(xfs_mount_t *mp, } bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, fsbno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 , &xfs_da3_node_buf_ops);if (!bp) { do_warn( _("can't read block %u (%" PRIu64 ") for directory inode %" PRIu64 "\n"),
@@ -986,7 +986,7 @@ rmtval_get(xfs_mount_t *mp, xfs_ino_t ino, blkmap_t *blkmap,break ; } bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, bno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 ,NULL );if (!bp) {do_warn (_ ("can't read remote block for attributes of inode %" PRIu64"\n" ), ino);
@@ -1315,7 +1315,7 @@ process_leaf_attr_level(xfs_mount_t *mp, } bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, dev_bno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 ,NULL );if (!bp) { do_warn( _("can't read file block %u (fsbno %" PRIu64 ") for attribute fork of inode %" PRIu64 "\n"),
@@ -1497,7 +1497,7 @@ process_longform_attr( } bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, bno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 ,NULL );if (!bp) { do_warn( _("can't read block 0 of inode %" PRIu64 " attribute fork\n"),
repair/dino_chunks.c +6 -2
@@ -52,7 +52,7 @@ check_aginode_block(xfs_mount_t *mp,* so no one else will overlap them. */ bp =libxfs_readbuf (mp->m_dev,XFS_AGB_TO_DADDR (mp, agno, agbno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 ,NULL );if (!bp) {do_warn (_ ("cannot read agbno (%u/%u), disk block %" PRId64"\n" ), agno, agbno,XFS_AGB_TO_DADDR (mp, agno, agbno));
@@ -65,6 +65,8 @@ check_aginode_block(xfs_mount_t *mp, XFS_OFFBNO_TO_AGINO(mp, agbno, i))) cnt++; } +if (cnt) + bp->b_ops = &xfs_inode_buf_ops;libxfs_putbuf (bp);return (cnt);
@@ -625,7 +627,8 @@ process_inode_chunk( bplist[bp_index] =libxfs_readbuf (mp->m_dev,XFS_AGB_TO_DADDR (mp, agno, agbno), -XFS_FSB_TO_BB (mp, blks_per_cluster),0 ); +XFS_FSB_TO_BB (mp, blks_per_cluster),0 , +NULL );if (!bplist[bp_index]) { do_warn(_("cannot read inode %" PRIu64 ", disk block %" PRId64 ", cnt %d\n"), XFS_AGINO_TO_INO(mp, agno, first_irec->ino_startnum),
@@ -639,6 +642,7 @@ process_inode_chunk(return (1 ); } agbno += blks_per_cluster; + bplist[bp_index]->b_ops = &xfs_inode_buf_ops; pftrace("readbuf %p (%llu, %d) in AG %d", bplist[bp_index], (long long)XFS_BUF_ADDR(bplist[bp_index]),
repair/dinode.c +6 -4
@@ -836,7 +836,8 @@ get_agino_buf(xfs_mount_t *mp, size =XFS_FSB_TO_BB (mp,MAX (1 ,XFS_INODES_PER_CHUNK /inodes_per_block)); bp =libxfs_readbuf (mp->m_dev,XFS_AGB_TO_DADDR (mp, agno, -XFS_AGINO_TO_AGBNO (mp, irec->ino_startnum)), size,0 ); +XFS_AGINO_TO_AGBNO (mp, irec->ino_startnum)), size,0 , + &xfs_inode_buf_ops);if (!bp) { do_warn(_("cannot read inode (%u/%u), disk block %" PRIu64 "\n"), agno, irec->ino_startnum,
@@ -947,7 +948,7 @@ getfunc_btree(xfs_mount_t *mp,ASSERT (verify_dfsbno (mp, fsbno)); bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, fsbno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 ,NULL );if (!bp) {do_error (_ ("cannot read bmap block %" PRIu64"\n" ), fsbno);return (NULLDFSBNO );
@@ -1004,7 +1005,7 @@ _("- # of bmap records in inode %" PRIu64 " less than minimum (%u, min - %u), pr*/ libxfs_putbuf (bp); bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, fsbno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 ,NULL );if (!bp) {do_error (_ ("cannot read bmap block %" PRIu64"\n" ), fsbno);
@@ -1510,7 +1511,8 @@ process_symlink(if (fsbno !=NULLDFSBNO ) bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, fsbno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 , + &xfs_symlink_buf_ops);if (!bp || fsbno ==NULLDFSBNO ) { do_warn( _("cannot read inode %" PRIu64 ", file block %d, disk block %" PRIu64 "\n"),
repair/dir2.c +8 -7
@@ -103,7 +103,8 @@ static struct xfs_buf *da_read_buf ( xfs_mount_t *mp, int nex, - bmap_ext_t *bmp) + bmap_ext_t *bmp, + const struct xfs_buf_ops *ops) {#define MAP_ARRAY_SZ 4struct xfs_buf_map map_array[MAP_ARRAY_SZ ];
@@ -125,7 +126,7 @@ da_read_buf( map[i].bm_bn =XFS_FSB_TO_DADDR (mp, bmp[i].startblock); map[i].bm_len =XFS_FSB_TO_BB (mp, bmp[i].blockcount); } - bp =libxfs_readbuf_map (mp->m_dev, map, nex,0 ); + bp =libxfs_readbuf_map (mp->m_dev, map, nex,0 , ops);if (map != map_array)free (map);return bp;
@@ -172,7 +173,7 @@ traverse_int_dir2block(xfs_mount_t *mp,if (nex ==0 ) goto error_out; - bp =da_read_buf (mp, nex, bmp); + bp =da_read_buf (mp, nex, bmp, &xfs_da3_node_buf_ops);if (bmp != &lbmp)free (bmp);if (bp ==NULL ) {
@@ -536,7 +537,7 @@ _("can't get map info for block %u of directory inode %" PRIu64 "\n"),return (1 ); } - bp =da_read_buf (mp, nex, bmp); + bp =da_read_buf (mp, nex, bmp, &xfs_da3_node_buf_ops);if (bmp != &lbmp)free (bmp);
@@ -1581,7 +1582,7 @@ _("block %u for directory inode %" PRIu64 " is missing\n"), mp->m_dirdatablk, ino);return 1 ; } - bp =da_read_buf (mp, nex, bmp); + bp =da_read_buf (mp, nex, bmp, &xfs_dir3_block_buf_ops);if (bmp != &lbmp)free (bmp);if (bp ==NULL ) {
@@ -1711,7 +1712,7 @@ _("can't map block %u for directory inode %" PRIu64 "\n"), da_bno, ino); goto error_out; } - bp =da_read_buf (mp, nex, bmp); + bp =da_read_buf (mp, nex, bmp, &xfs_dir3_leafn_buf_ops);if (bmp != &lbmp)free (bmp); bmp =NULL ;
@@ -1897,7 +1898,7 @@ _("block %" PRIu64 " for directory inode %" PRIu64 " is missing\n"), dbno, ino);continue ; } - bp =da_read_buf (mp, nex, bmp); + bp =da_read_buf (mp, nex, bmp, &xfs_dir3_data_buf_ops);if (bmp != &lbmp)free (bmp);if (bp ==NULL ) {
repair/phase2.c +2 -5
@@ -40,18 +40,15 @@ zero_log(xfs_mount_t *mp)int error;struct xlog log;xfs_daddr_t head_blk, tail_blk; -dev_t logdev = (mp->m_sb.sb_logstart ==0 ) ? x.logdev : x.ddev;memset (&log,0 ,sizeof (log)); -if (!x.logdev) - x.logdev = x.ddev; x.logBBsize =XFS_FSB_TO_BB (mp, mp->m_sb.sb_logblocks); x.logBBstart =XFS_FSB_TO_DADDR (mp, mp->m_sb.sb_logstart); x.lbsize =BBSIZE ;if (xfs_sb_version_hassector (&mp->m_sb)) x.lbsize <<= (mp->m_sb.sb_logsectlog -BBSHIFT ); - log.l_dev = logdev; + log.l_dev = mp->m_logdev_targp; log.l_logsize =BBTOB (x.logBBsize); log.l_logBBsize = x.logBBsize; log.l_logBBstart = x.logBBstart;
@@ -96,7 +93,7 @@ zero_log(xfs_mount_t *mp) } } - libxfs_log_clear(logdev, + libxfs_log_clear(log.l_dev, XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), (xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks), &mp->m_sb.sb_uuid,
repair/phase3.c +1 -1
@@ -40,7 +40,7 @@ process_agi_unlinked( bp =libxfs_readbuf (mp->m_dev,XFS_AG_DADDR (mp, agno,XFS_AGI_DADDR (mp)), - mp->m_sb.sb_sectsize/BBSIZE ,0 ); + mp->m_sb.sb_sectsize/BBSIZE ,0 , &xfs_agi_buf_ops);if (!bp)do_error (_ ("cannot read agi block %" PRId64" for ag %u\n" ),XFS_AG_DADDR (mp, agno,XFS_AGI_DADDR (mp)), agno);
repair/phase6.c +7 -6
@@ -510,7 +510,7 @@ mk_rbmino(xfs_mount_t *mp) error); }for (i =0 , ep = map; i < nmap; i++, ep++) { -libxfs_device_zero (mp->m_dev, +libxfs_device_zero (mp->m_ddev_targp,XFS_FSB_TO_DADDR (mp, ep->br_startblock),XFS_FSB_TO_BB (mp, ep->br_blockcount)); bno += ep->br_blockcount;
@@ -765,7 +765,7 @@ mk_rsumino(xfs_mount_t *mp) error); }for (i =0 , ep = map; i < nmap; i++, ep++) { -libxfs_device_zero (mp->m_dev, +libxfs_device_zero (mp->m_ddev_targp,XFS_FSB_TO_DADDR (mp, ep->br_startblock),XFS_FSB_TO_BB (mp, ep->br_blockcount)); bno += ep->br_blockcount;
@@ -1829,7 +1829,8 @@ longform_dir2_check_leaf(struct xfs_dir2_leaf_entry *ents; da_bno = mp->m_dirleafblk; -if (libxfs_da_read_buf (NULL , ip, da_bno,-1 , &bp,XFS_DATA_FORK ,NULL )) { +if (libxfs_da_read_buf (NULL , ip, da_bno,-1 , &bp,XFS_DATA_FORK , + &xfs_dir3_leaf1_buf_ops)) {do_error (_ ("can't read block %u for directory inode %" PRIu64"\n" ), da_bno, ip->i_ino);
@@ -1906,7 +1907,7 @@ longform_dir2_check_node(if (bmap_next_offset (NULL , ip, &next_da_bno,XFS_DATA_FORK ))break ;if (libxfs_da_read_buf (NULL , ip, da_bno,-1 , &bp, -XFS_DATA_FORK ,NULL )) { +XFS_DATA_FORK , &xfs_dir3_leafn_buf_ops)) {do_warn (_ ("can't read leaf block %u for directory inode %" PRIu64"\n" ), da_bno, ip->i_ino);
@@ -1953,7 +1954,7 @@ longform_dir2_check_node(if (bmap_next_offset (NULL , ip, &next_da_bno,XFS_DATA_FORK ))break ;if (libxfs_da_read_buf (NULL , ip, da_bno,-1 , &bp, -XFS_DATA_FORK ,NULL )) { +XFS_DATA_FORK , &xfs_dir3_free_buf_ops)) {do_warn (_ ("can't read freespace block %u for directory inode %" PRIu64"\n" ), da_bno, ip->i_ino);
@@ -2075,7 +2076,7 @@ longform_dir2_entry_check(xfs_mount_t *mp, num_bps * sizeof(struct xfs_buf*)); }if (libxfs_da_read_buf (NULL , ip, da_bno,-1 , &bplist[db], -XFS_DATA_FORK ,NULL )) { +XFS_DATA_FORK , &xfs_dir3_data_buf_ops)) {do_warn (_ ("can't read data block %u for directory inode %" PRIu64"\n" ), da_bno, ino);
repair/prefetch.c +2 -2
@@ -221,7 +221,7 @@ pf_scan_lbtree(int rc; bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, dbno), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 ,NULL );if (!bp)return 0 ;
@@ -720,7 +720,7 @@ init_prefetch( xfs_mount_t *pmp) { mp = pmp; - mp_fd =libxfs_device_to_fd (mp->m_dev); + mp_fd =libxfs_device_to_fd (mp->m_ddev_targp->dev); pf_max_bytes =sysconf (_SC_PAGE_SIZE) <<7 ; pf_max_bbs = pf_max_bytes >>BBSHIFT ; pf_max_fsbs = pf_max_bytes >> mp->m_sb.sb_blocklog;
repair/rt.c +2 -2
@@ -206,7 +206,7 @@ process_rtbitmap(xfs_mount_t *mp,continue ; } bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, bno), -XFS_FSB_TO_BB (mp,1 )); +XFS_FSB_TO_BB (mp,1 ),NULL );if (!bp) {do_warn (_ ("can't read block %d for rtbitmap inode\n" ), bmbno);
@@ -268,7 +268,7 @@ process_rtsummary(xfs_mount_t *mp,continue ; } bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, bno), -XFS_FSB_TO_BB (mp,1 )); +XFS_FSB_TO_BB (mp,1 ),NULL );if (!bp) {do_warn (_ ("can't read block %d for rtsummary inode\n" ), sumbno);
repair/scan.c +8 -7
@@ -85,7 +85,7 @@ scan_sbtree(xfs_buf_t *bp; bp =libxfs_readbuf (mp->m_dev,XFS_AGB_TO_DADDR (mp, agno, root), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 ,NULL );if (!bp) {do_error (_ ("can't read btree block %d/%d\n" ), agno, root);return ;
@@ -130,7 +130,7 @@ scan_lbtree(int dirty =0 ; bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, root), -XFS_FSB_TO_BB (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 ,NULL );if (!bp) { do_error(_("can't read btree block %d/%d\n"), XFS_FSB_TO_AGNO(mp, root),
@@ -1060,7 +1060,7 @@ scan_freelist( agflbuf =libxfs_readbuf (mp->m_dev,XFS_AG_DADDR (mp, agno,XFS_AGFL_DADDR (mp)), -XFS_FSS_TO_BB (mp,1 ),0 ); +XFS_FSS_TO_BB (mp,1 ),0 , &xfs_agfl_buf_ops);if (!agflbuf) {do_abort (_ ("can't read agfl block for ag %d\n" ), agno);return ;
@@ -1207,7 +1207,7 @@ scan_ag(int status; sbbuf =libxfs_readbuf (mp->m_dev,XFS_AG_DADDR (mp, agno,XFS_SB_DADDR ), -XFS_FSS_TO_BB (mp,1 ),0 ); +XFS_FSS_TO_BB (mp,1 ),0 , &xfs_sb_buf_ops);if (!sbbuf) {do_error (_ ("can't get root superblock for ag %d\n" ), agno);return ;
@@ -1223,7 +1223,7 @@ scan_ag( agfbuf =libxfs_readbuf (mp->m_dev,XFS_AG_DADDR (mp, agno,XFS_AGF_DADDR (mp)), -XFS_FSS_TO_BB (mp,1 ),0 ); +XFS_FSS_TO_BB (mp,1 ),0 , &xfs_agf_buf_ops);if (!agfbuf) {do_error (_ ("can't read agf block for ag %d\n" ), agno);libxfs_putbuf (sbbuf);
@@ -1234,7 +1234,7 @@ scan_ag( agibuf =libxfs_readbuf (mp->m_dev,XFS_AG_DADDR (mp, agno,XFS_AGI_DADDR (mp)), -XFS_FSS_TO_BB (mp,1 ),0 ); +XFS_FSS_TO_BB (mp,1 ),0 , &xfs_agi_buf_ops);if (!agibuf) {do_error (_ ("can't read agi block for ag %d\n" ), agno);libxfs_putbuf (agfbuf);
@@ -1353,7 +1353,8 @@ scan_ags( }memset (agcnts,0 , mp->m_sb.sb_agcount *sizeof (*agcnts)); -create_work_queue (&wq, mp, scan_threads); +create_work_queue (&wq, mp,1 ); +//create_work_queue(&wq, mp, scan_threads); for (i =0 ; i < mp->m_sb.sb_agcount; i++)queue_work (&wq, scan_ag, i, &agcnts[i]);
repair/xfs_repair.c +4 -2
@@ -558,9 +558,11 @@ main(int argc, char **argv) }/* prepare the mount structure */ - sbp =libxfs_readbuf (x.ddev,XFS_SB_DADDR , -1 << (XFS_MAX_SECTORSIZE_LOG -BBSHIFT ),0 );memset (&xfs_m,0 ,sizeof (xfs_mount_t)); +libxfs_buftarg_init (&xfs_m, x.ddev, x.logdev, x.rtdev); + sbp =libxfs_readbuf (xfs_m.m_ddev_targp,XFS_SB_DADDR , +1 << (XFS_MAX_SECTORSIZE_LOG -BBSHIFT ),0 , + &xfs_sb_buf_ops);libxfs_sb_from_disk (&xfs_m.m_sb,XFS_BUF_TO_SBP (sbp));/*
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 22/48] xfsprogs: Add verifiers to libxfs buffer interfaces.
Dave,
Quoted 15 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Verifiers need to be used everywhere to enable calculation of CRCs during writeback of modified metadata. Add then to the libxfs buffer interfaces conver the internal use of devices to be buftarg aware.
Verifiers also require that the buffer has a back pointer to the struct
xfs_mount. To make this source level comaptible between kernel and userspace, convert userspace to pass structxfs_buftargsaround rather than a "device".Signed-off-by Dave Chinner <[email protected]>
include/libxfs.h typedef struct xfs_inode { · line 530
Quoted 5 lines
include/libxfs.h +1
-1@@ -507,7 +527,7 @@ typedef struct xfs_inode {xfs_mount_t *i_mount;/* fs mount struct ptr */ xfs_ino_t i_ino;/* inode number (agno/agino) */ struct xfs_imap i_imap;/* location for xfs_imap() */ -dev_t i_dev;/* dev for this inode */ +struct xfs_buftarg i_dev;/* dev for this inode */
Got a little jumpy with the tabs there...
libxfs/rdwr.c libxfs_log_header( · line 204
Quoted 12 lines
libxfs/rdwr.c +2
-2@@ -200,12 +200,15 @@ libxfs_log_header(#undef libxfs_getbuf_flags#undef libxfs_putbuf -xfs_buf_t *libxfs_readbuf (dev_t ,xfs_daddr_t ,int ,int ); -xfs_buf_t *libxfs_readbuf_map (dev_t ,struct xfs_buf_map *,int ,int ); +xfs_buf_t *libxfs_readbuf (struct xfs_buftarg *,xfs_daddr_t ,int ,int , +const struct xfs_buf_map *);
const struct xfs_buf_ops *);
libxfs/rdwr.c libxfs_log_header( · line 206
Quoted 2 lines
libxfs/rdwr.c +2
-0+xfs_buf_t *libxfs_readbuf_map (struct xfs_buftarg *,struct xfs_buf_map *, +int ,int ,const struct xfs_buf_map *);
const struct xfs_buf_ops *);
libxfs/rdwr.c libxfs_purgebuf(xfs_buf_t *bp) · line 627
Quoted 9 lines
libxfs/rdwr.c +2
-2@@ -612,9 +622,9 @@ libxfs_purgebuf(xfs_buf_t *bp) {struct xfs_bufkey key = {0 }; - key.device = bp->b_dev; + key.buftarg = bp->b_target; key.blkno = bp->b_bn; - key.bblen = bp->b_bcount >>BBSHIFT ; + key.bblen = bp->b_length;
Why was this change necessary? b_bcount to b_length? It doesn't seem to be related to the rest of the patch.
Quoted 8 lines
libxfs/rdwr.c +1
-1@@ -767,9 +803,42 @@ __write_buf(int fd, void *buf, int len, off64_t offset, int flags)int libxfs_writebufr (xfs_buf_t *bp) { -int fd =libxfs_device_to_fd (bp->b_dev); +int fd =libxfs_device_to_fd (bp->b_target->dev);int error =0 ;
libxfs/rdwr.c __write_buf(int fd, void *buf, int len, off64_t offset, int flags) · line 818
Quoted 10 lines
libxfs/rdwr.c +10
-0+/* +* we never write buffers that are marked stale. This indicates they +* contain data that has been invalidated, and even if the buffer is +* dirty it must *never* be written. Verifiers are wonderful for finding +* bugs like this. Make sure the error is obvious as to the cause. +*/ +if (bp->b_flags &LIBXFS_B_STALE ) { + bp->b_error =ESTALE ; +return bp->b_error; + }
What led to this?
Quoted 13 lines
libxfs/rdwr.c +13
-0+ +/* +* clear any pre-existing error status on the buffer. This can occur if +* the buffer is corrupt on disk and the repair process doesn't clear +* the error before fixing and writing it back. +*/ + bp->b_error =0 ; +if (bp->b_ops) { + bp->b_ops->verify_write (bp); +if (bp->b_error) { +fprintf (stderr, +_ ("%s: write verifer failed on bno 0x%llx/0x%x\n" ), + __func__, (long long )bp->b_bn, bp->b_bcount);
libxfs/rdwr.c __write_buf(int fd, void *buf, int len, off64_t offset, int flags) · line 841
Quoted 10 lines
libxfs/rdwr.c +10
-0+return bp->b_error; + } + } + +if (bp->b_ops) { + bp->b_ops->verify_write (bp); +if (bp->b_error) +return bp->b_error; + } +
Calling the verifier twice? Maybe I'm seeing double again...
libxfs/rdwr.c roundup_pow_of_two(uint v) · line 192
Quoted 7 lines
libxfs/rdwr.c +0
-3@@ -187,11 +184,7 @@ roundup_pow_of_two(uint v)NULL ; \ })#define xfs_buf_relse (bp) libxfs_putbuf(bp) -#define xfs_read_buf (mp,devp,blkno,len,f,bpp) \ - (*(bpp) = libxfs_readbuf((devp), \ - (blkno), (len), 1), 0)
Yeah, nobody is using this macro anymore.
Quoted 5 lines
mkfs/xfs_mkfs.c +0
-0
mkfs/xfs_mkfs.c an AG size that is one stripe unit smaller, for example %llu.\n"), · line 2496
Quoted 9 lines
mkfs/xfs_mkfs.c +5
-0@@ -2487,13 +2488,19 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),exit (1 ); } +/* +* XXX: this code is effectively shared with the kernel growfs code. +* These initialisations should be pulled into libxfs to keep the +* kernel/userspace header initialisation code the same. +*/ for (agno =0 ; agno < agcount; agno++) {
Nice idea.
Quoted 11 lines
mkfs/xfs_mkfs.c +2
-1/* * Superblock. */ - buf =libxfs_getbuf (xi.ddev, + buf =libxfs_getbuf (mp->m_ddev_targp,XFS_AG_DADDR (mp, agno,XFS_SB_DADDR ),XFS_FSS_TO_BB (mp,1 )); + buf->b_ops = &xfs_sb_buf_ops;memset (XFS_BUF_PTR (buf),0 , sectorsize);libxfs_sb_to_disk ((void *)XFS_BUF_PTR (buf), sbp,XFS_SB_ALL_BITS );libxfs_writebuf (buf,LIBXFS_EXIT_ON_FAILURE );
...
mkfs/xfs_mkfs.c scan_ags( · line 1357
Quoted 7 lines
mkfs/xfs_mkfs.c +2
-1@@ -1353,7 +1353,8 @@ scan_ags( }memset (agcnts,0 , mp->m_sb.sb_agcount *sizeof (*agcnts)); -create_work_queue (&wq, mp, scan_threads); +create_work_queue (&wq, mp,1 ); +//create_work_queue(&wq, mp, scan_threads);
What's this all about? Were you having trouble with a multithreaded scan?
Looks fine for the most part... I did get a little uncomfortable with using verifiers on reads in repair. Not sure whether setting b_error = EFSCORRUPTED would have ill effect later.
Regards,
Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 22/48] xfsprogs: Add verifiers to libxfs buffer interfaces.
Quoted 41 lines · Ben Myers
Dave,
Quoted 15 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Verifiers need to be used everywhere to enable calculation of CRCs during writeback of modified metadata. Add then to the libxfs buffer interfaces conver the internal use of devices to be buftarg aware.
Verifiers also require that the buffer has a back pointer to the struct
xfs_mount. To make this source level comaptible between kernel and userspace, convert userspace to pass structxfs_buftargsaround rather than a "device".Signed-off-by Dave Chinner <[email protected]>include/libxfs.h typedef struct xfs_inode { · line 530
Quoted 5 lines
include/libxfs.h +1
-1@@ -507,7 +527,7 @@ typedef struct xfs_inode {xfs_mount_t *i_mount;/* fs mount struct ptr */ xfs_ino_t i_ino;/* inode number (agno/agino) */ struct xfs_imap i_imap;/* location for xfs_imap() */ -dev_t i_dev;/* dev for this inode */ +struct xfs_buftarg i_dev;/* dev for this inode */ Got a little jumpy with the tabs there...
libxfs/rdwr.c libxfs_log_header( · line 204
Quoted 12 lines
libxfs/rdwr.c +2
-2@@ -200,12 +200,15 @@ libxfs_log_header(#undef libxfs_getbuf_flags#undef libxfs_putbuf -xfs_buf_t *libxfs_readbuf (dev_t ,xfs_daddr_t ,int ,int ); -xfs_buf_t *libxfs_readbuf_map (dev_t ,struct xfs_buf_map *,int ,int ); +xfs_buf_t *libxfs_readbuf (struct xfs_buftarg *,xfs_daddr_t ,int ,int , +const struct xfs_buf_map *);const struct xfs_buf_ops *);
Quoted 4 lines
libxfs/rdwr.c libxfs_log_header( · line 206
Quoted 2 lines
libxfs/rdwr.c +2
-0+xfs_buf_t *libxfs_readbuf_map (struct xfs_buftarg *,struct xfs_buf_map *, +int ,int ,const struct xfs_buf_map *);const struct xfs_buf_ops *);
Oh, in not-compiled debug code.
Quoted 5 lines
Quoted 5 lines
libxfs/rdwr.c +0
-0@@ -612,9 +622,9 @@ libxfs_purgebuf(xfs_buf_t *bp) {struct xfs_bufkey key = {0 };
Quoted 8 lines
libxfs/rdwr.c libxfs_purgebuf(xfs_buf_t *bp) · line 627
Quoted 5 lines
libxfs/rdwr.c +2
-2- key.device = bp->b_dev; + key.buftarg = bp->b_target; key.blkno = bp->b_bn; - key.bblen = bp->b_bcount >>BBSHIFT ; + key.bblen = bp->b_length;Why was this change necessary?
b_bcounttob_length? It doesn't seem to be related to the rest of the patch.
Sure it is - I added a length in basic blocks to the struct xfs_buf, and the key uses length in basic blocks. I converted everything to use basic blocks where possible, because that matches what the kernel uses for all it's buffer interfaces.
Quoted 8 lines
Quoted 8 lines
libxfs/rdwr.c +1
-1@@ -767,9 +803,42 @@ __write_buf(int fd, void *buf, int len, off64_t offset, int flags)int libxfs_writebufr (xfs_buf_t *bp) { -int fd =libxfs_device_to_fd (bp->b_dev); +int fd =libxfs_device_to_fd (bp->b_target->dev);int error =0 ;
Quoted 12 lines
libxfs/rdwr.c __write_buf(int fd, void *buf, int len, off64_t offset, int flags) · line 818
Quoted 10 lines
libxfs/rdwr.c +10
-0+/* +* we never write buffers that are marked stale. This indicates they +* contain data that has been invalidated, and even if the buffer is +* dirty it must *never* be written. Verifiers are wonderful for finding +* bugs like this. Make sure the error is obvious as to the cause. +*/ +if (bp->b_flags &LIBXFS_B_STALE ) { + bp->b_error =ESTALE ; +return bp->b_error; + }What led to this?
Exactly what the comment says - write verifiers were failing because stale blocks often have invalid contents. And, of course, stale buffers should never be written to disk as they could be overwriting otherwise valid data.
Quoted 17 lines
Quoted 17 lines
libxfs/rdwr.c +17
-0+ +/* +* clear any pre-existing error status on the buffer. This can occur if +* the buffer is corrupt on disk and the repair process doesn't clear +* the error before fixing and writing it back. +*/ + bp->b_error =0 ; +if (bp->b_ops) { + bp->b_ops->verify_write (bp); +if (bp->b_error) { +fprintf (stderr, +_ ("%s: write verifer failed on bno 0x%llx/0x%x\n" ), + __func__, (long long )bp->b_bn, bp->b_bcount); +return bp->b_error; + } + } +
Quoted 8 lines
libxfs/rdwr.c __write_buf(int fd, void *buf, int len, off64_t offset, int flags) · line 841
Quoted 6 lines
libxfs/rdwr.c +6
-0+if (bp->b_ops) { + bp->b_ops->verify_write (bp); +if (bp->b_error) +return bp->b_error; + } +Calling the verifier twice? Maybe I'm seeing double again...
Probably a rebase error - a patch that should have conflicted and got a merge error didn't. Indeed, that doesn't match what is actually in the current code base - it repeats that entire block from comment to the end of the if statement twice - so it's pretty obvious there's been rebase/merge issues here...
Quoted 9 lines
libxfs/rdwr.c scan_ags( · line 1357
Quoted 7 lines
libxfs/rdwr.c +2
-1@@ -1353,7 +1353,8 @@ scan_ags( }memset (agcnts,0 , mp->m_sb.sb_agcount *sizeof (*agcnts)); -create_work_queue (&wq, mp, scan_threads); +create_work_queue (&wq, mp,1 ); +//create_work_queue(&wq, mp, scan_threads); What's this all about? Were you having trouble with a multithreaded scan?
Debug code I forgot to remove - multithreaded code can be a pain to debug in gdb. I thought I'd re-enabled it, but obviously not.
Quoted 3 lines
Looks fine for the most part... I did get a little uncomfortable with using verifiers on reads in repair. Not sure whether setting
b_error= EFSCORRUPTED would have ill effect later.
That's why bp->b_error is zeroed before we do any IO on the buffer again - so previous errors aren't propagated. Righ tnow the EFSCORRUPTED error from the verifiers is ignored, but I have patches to start having repair treat them a broken blocks (e.g. because the CRC failed) needing repair. i.e. for repair to actually correctly verify the filesystem is error free, it has to verify allt eh CRCs are in tact. it doesn't currently do that....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 23/48 xfsprogs: introduce CRC support into mkfs.xfs
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- libxfs/xfs_mount.c | 10 +++-- libxfs/xfs_symlink.c | 4 +- mkfs/maxtrres.c | 4 +- mkfs/xfs_mkfs.c | 114 ++++++++++++++++++++++++++++++++++++++++---------- mkfs/xfs_mkfs.h | 12 +++--- 5 files changed, 111 insertions(+), 33 deletions(-)
libxfs/xfs_mount.c +6 -4
@@ -369,7 +369,8 @@ xfs_sb_to_disk(static int xfs_sb_verify ( -struct xfs_buf *bp) +struct xfs_buf *bp, +bool verbose) {struct xfs_mount *mp = bp->b_target->bt_mount;struct xfs_sb sb;
@@ -380,7 +381,8 @@ xfs_sb_verify(* Only check the in progress field for the primary superblock as * mkfs.xfs doesn't clear it from secondary superblocks. */ -return xfs_mount_validate_sb (mp, &sb, bp->b_bn ==XFS_SB_DADDR ); +return xfs_mount_validate_sb (mp, &sb, + verbose && bp->b_bn ==XFS_SB_DADDR ); }/*
@@ -413,7 +415,7 @@ xfs_sb_read_verify( goto out_error; } } - error =xfs_sb_verify (bp); + error =xfs_sb_verify (bp, true); out_error:if (error) {
@@ -452,7 +454,7 @@ xfs_sb_write_verify(struct xfs_buf_log_item *bip = bp->b_fspriv;int error; - error =xfs_sb_verify (bp); + error =xfs_sb_verify (bp, false);if (error) {XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , mp, bp->b_addr);xfs_buf_ioerror (bp, error);
libxfs/xfs_symlink.c +2 -2
@@ -27,9 +27,9 @@ xfs_symlink_blocks( }/* -* XXX: this need to be used by mkfs/proto.c to create symlinks. +* This is used by mkfs/proto.c to create symlinks. */ -static int +int xfs_symlink_hdr_set( struct xfs_mount *mp, xfs_ino_t ino,
mkfs/maxtrres.c +3 -1
@@ -67,6 +67,7 @@ max_trans_res_by_mount( int max_trans_res( + int crcs_enabled, int dirversion, int sectorlog, int blocklog,
@@ -90,7 +91,8 @@ max_trans_res( sbp->sb_inodesize =1 << inodelog; sbp->sb_inopblock =1 << (blocklog - inodelog); sbp->sb_dirblklog = dirblocklog - blocklog; - sbp->sb_versionnum =XFS_SB_VERSION_4 | + sbp->sb_versionnum = + (crcs_enabled ?XFS_SB_VERSION_5 :XFS_SB_VERSION_4 ) | (dirversion ==2 ?XFS_SB_VERSION_DIRV2BIT :0 );libxfs_mount (&mount, sbp,0 ,0 ,0 ,0 );
mkfs/xfs_mkfs.c +93 -21
231 lines not on this page · raw message
mkfs/xfs_mkfs.h +7 -5
@@ -23,9 +23,9 @@ XFS_SB_VERSION_EXTFLGBIT | \ XFS_SB_VERSION_DIRV2BIT) -#define XFS_SB_VERSION_MKFS (ia,dia,log2,attr1,sflag,ci,more) (\ - ((ia)||(dia)||(log2)||(attr1)||(sflag)||(ci)||(more)) ? \ - ( XFS_SB_VERSION_4 | \ +#define XFS_SB_VERSION_MKFS (crc,ia,dia,log2,attr1,sflag,ci,more) (\ + ((crc)||(ia)||(dia)||(log2)||(attr1)||(sflag)||(ci)||(more)) ? \ + (((crc) ? XFS_SB_VERSION_5 : XFS_SB_VERSION_4) | \ ((ia) ? XFS_SB_VERSION_ALIGNBIT : 0) | \ ((dia) ? XFS_SB_VERSION_DALIGNBIT : 0) | \ ((log2) ? XFS_SB_VERSION_LOGV2BIT : 0) | \
@@ -36,15 +36,17 @@ XFS_DFL_SB_VERSION_BITS | \ 0 ) : XFS_SB_VERSION_1 ) -#define XFS_SB_VERSION2_MKFS (lazycount, attr2, projid32bit, parent) (\ +#define XFS_SB_VERSION2_MKFS (crc, lazycount, attr2, projid32bit, parent) (\ ((lazycount) ? XFS_SB_VERSION2_LAZYSBCOUNTBIT : 0) | \ ((attr2) ? XFS_SB_VERSION2_ATTR2BIT : 0) | \ ((projid32bit) ? XFS_SB_VERSION2_PROJID32BIT : 0) | \ ((parent) ? XFS_SB_VERSION2_PARENTBIT : 0) | \ + ((crc) ? XFS_SB_VERSION2_CRCBIT : 0) | \ 0 )#define XFS_DFL_BLOCKSIZE_LOG 12/* 4096 byte blocks */ #define XFS_DINODE_DFL_LOG 8/* 256 byte inodes */ +#define XFS_DINODE_DFL_CRC_LOG 9/* 512 byte inodes for CRCs */ #define XFS_MIN_DATA_BLOCKS 100#define XFS_MIN_INODE_PERBLOCK 2/* min inodes per block */ #define XFS_DFL_IMAXIMUM_PCT 25/* max % of space for inodes */
@@ -79,7 +81,7 @@ extern void parse_proto (xfs_mount_t *mp, struct fsxattr *fsx, char **pp);extern void res_failed (int err);/* maxtrres.c */ -extern int max_trans_res (int dirversion, +extern int max_trans_res (int crcs_enabled,int dirversion,int sectorlog,int blocklog,int inodelog,int dirblocklog);#endif /* __XFS_MKFS_H__ */
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 23/48] xfsprogs: introduce CRC support into mkfs.xfs
Quoted 16 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>--- libxfs/xfs_mount.c | 10 +++-- libxfs/xfs_symlink.c | 4 +- mkfs/maxtrres.c | 4 +- mkfs/xfs_mkfs.c | 114 ++++++++++++++++++++++++++++++++++++++++---------- mkfs/xfs_mkfs.h | 12 +++--- 5 files changed, 111 insertions(+), 33 deletions(-)libxfs/xfs_mount.c +0
-0
libxfs/xfs_mount.c xfs_sb_to_disk( · line 373
Quoted 6 lines
libxfs/xfs_mount.c +2
-1@@ -369,7 +369,8 @@ xfs_sb_to_disk(static int xfs_sb_verify ( -struct xfs_buf *bp) +struct xfs_buf *bp, +bool verbose)
xfs_sb_verify in userspace and xfs_sb_verify in the kernel both have a boolean arg but they mean different things. Could get confusing.
Anyway, looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 24/48 xfsprogs: add crc format support to repair
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- include/libxfs.h | 5 ++ include/xfs_alloc_btree.h | 2 +- include/xfs_bmap_btree.h | 2 +- include/xfs_btree.h | 5 +- include/xfs_ialloc_btree.h | 2 +- include/xfs_symlink.h | 2 + libxfs/rdwr.c | 19 ++++- libxfs/xfs.h | 12 ++- libxfs/xfs_alloc.c | 7 +- libxfs/xfs_btree.c | 20 +++-- repair/agheader.c | 36 ++++++++- repair/dino_chunks.c | 7 +- repair/dinode.c | 190 ++++++++++++++++++++++++++------------------ repair/phase2.c | 1 + repair/phase5.c | 152 ++++++++++++++++++++++++++--------- repair/prefetch.c | 7 +- repair/scan.c | 152 +++++++++++++++++++---------------- repair/scan.h | 12 ++- repair/versions.c | 2 +- repair/xfs_repair.c | 2 +- 20 files changed, 422 insertions(+), 215 deletions(-)
include/libxfs.h +5 -0
@@ -682,6 +682,7 @@ void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);#define libxfs_dinode_to_disk xfs_dinode_to_diskvoid xfs_dinode_from_disk (struct xfs_icdinode *,struct xfs_dinode *); +#define libxfs_dinode_calc_crc xfs_dinode_calc_crc#define libxfs_idata_realloc xfs_idata_realloc#define libxfs_idestroy_fork xfs_idestroy_fork
@@ -690,6 +691,10 @@ void xfs_dinode_from_disk(struct xfs_icdinode *,#define libxfs_sb_from_disk xfs_sb_from_disk#define libxfs_sb_to_disk xfs_sb_to_disk +/* xfs_symlink.h */ +#define libxfs_symlink_blocks xfs_symlink_blocks +#define libxfs_symlink_hdr_ok xfs_symlink_hdr_ok +/* xfs_rtalloc.c */ int libxfs_rtfree_extent (struct xfs_trans *,xfs_rtblock_t ,xfs_extlen_t );
include/xfs_alloc_btree.h +1 -1
@@ -64,7 +64,7 @@ typedef __be32 xfs_alloc_ptr_t;*/ #define XFS_ALLOC_BLOCK_LEN (mp) \ (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ - XFS_BTREE_SBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD : \ + XFS_BTREE_SBLOCK_CRC_LEN : \ XFS_BTREE_SBLOCK_LEN)/*
include/xfs_bmap_btree.h +1 -1
@@ -140,7 +140,7 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t;*/ #define XFS_BMBT_BLOCK_LEN (mp) \ (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ - XFS_BTREE_LBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD : \ + XFS_BTREE_LBLOCK_CRC_LEN : \ XFS_BTREE_LBLOCK_LEN)#define XFS_BMBT_REC_ADDR (mp, block, index) \
include/xfs_btree.h +4 -1
@@ -83,7 +83,10 @@ struct xfs_btree_block {#define XFS_BTREE_SBLOCK_LEN 16/* size of a short form block */ #define XFS_BTREE_LBLOCK_LEN 24/* size of a long form block */ -#define XFS_BTREE_CRCBLOCK_ADD 32/* size of blkno + crc + uuid */ + +/* sizes of CRC enabled btree blocks */ +#define XFS_BTREE_SBLOCK_CRC_LEN (XFS_BTREE_SBLOCK_LEN + 40) +#define XFS_BTREE_LBLOCK_CRC_LEN (XFS_BTREE_LBLOCK_LEN + 48)#define XFS_BTREE_SBLOCK_CRC_OFF \ offsetof(struct xfs_btree_block, bb_u.s.bb_crc)
include/xfs_ialloc_btree.h +1 -1
@@ -80,7 +80,7 @@ typedef __be32 xfs_inobt_ptr_t;*/ #define XFS_INOBT_BLOCK_LEN (mp) \ (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ - XFS_BTREE_SBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD : \ + XFS_BTREE_SBLOCK_CRC_LEN : \ XFS_BTREE_SBLOCK_LEN)/*
include/xfs_symlink.h +2 -0
@@ -29,6 +29,8 @@ struct xfs_dsymlink_hdr { sizeof(struct xfs_dsymlink_hdr) : 0))int xfs_symlink_blocks (struct xfs_mount *mp,int pathlen); +bool xfs_symlink_hdr_ok (struct xfs_mount *mp,xfs_ino_t ino,uint32_t offset, +uint32_t size,struct xfs_buf *bp);extern const struct xfs_buf_ops xfs_symlink_buf_ops;
libxfs/rdwr.c +18 -1
@@ -445,6 +445,7 @@ __libxfs_getbufr(int blen) }else bp =kmem_zone_zalloc (xfs_buf_zone,0 );pthread_mutex_unlock (&xfs_buf_freelist.cm_mutex); + bp->b_ops =NULL ;return bp; }
@@ -833,10 +834,20 @@ libxfs_writebufr(xfs_buf_t *bp) } } +/* +* clear any pre-existing error status on the buffer. This can occur if +* the buffer is corrupt on disk and the repair process doesn't clear +* the error before fixing and writing it back. +*/ + bp->b_error =0 ;if (bp->b_ops) { bp->b_ops->verify_write (bp); -if (bp->b_error) +if (bp->b_error) { +fprintf (stderr, +_ ("%s: write verifer failed on bno 0x%llx/0x%x\n" ), + __func__, (long long )bp->b_bn, bp->b_bcount);return bp->b_error; + } }if (!(bp->b_flags &LIBXFS_B_DISCONTIG )) {
@@ -883,6 +894,12 @@ libxfs_writebuf_int(xfs_buf_t *bp, int flags)int libxfs_writebuf (xfs_buf_t *bp,int flags) { +#ifdef IO_DEBUG +printf ("%lx: %s: dirty blkno=%llu(%llu)\n" , +pthread_self (), __FUNCTION__, + (long long )LIBXFS_BBTOOFF64 (bp->b_bn), + (long long )bp->b_bn); +#endif bp->b_flags |= (LIBXFS_B_DIRTY | flags);libxfs_putbuf (bp);return 0 ;
libxfs/xfs.h +10 -2
@@ -69,8 +69,16 @@ typedef __uint32_t inst_t; /* an instruction */#define IHOLD (ip) ((void) 0)/* stop unused var warnings by assigning mp to itself */ -#define XFS_CORRUPTION_ERROR (e,l,mp,m) do { (mp) = (mp); } while (0) -#define XFS_ERROR_REPORT (e,l,mp) do { (mp) = (mp); } while (0) +#define XFS_CORRUPTION_ERROR (e,l,mp,m) do { \ + (mp) = (mp); \ + cmn_err(CE_ALERT, "%s: XFS_CORRUPTION_ERROR", (e)); \ +} while (0) + +#define XFS_ERROR_REPORT (e,l,mp) do { \ + (mp) = (mp); \ + cmn_err(CE_ALERT, "%s: XFS_ERROR_REPORT", (e)); \ +} while (0) +#define XFS_QM_DQATTACH (mp,ip,flags) 0#define XFS_ERROR (e) (e)#define XFS_ERRLEVEL_LOW 1
libxfs/xfs_alloc.c +6 -1
@@ -2173,8 +2173,13 @@ xfs_agf_verify(struct xfs_agf *agf =XFS_BUF_TO_AGF (bp);if (xfs_sb_version_hascrc (&mp->m_sb) && - !uuid_equal (&agf->agf_uuid, &mp->m_sb.sb_uuid)) + !uuid_equal (&agf->agf_uuid, &mp->m_sb.sb_uuid)) { +char uu[64 ], uu2[64 ]; +platform_uuid_unparse (&agf->agf_uuid, uu); +platform_uuid_unparse (&mp->m_sb.sb_uuid, uu2); +return false; + } if (!(agf->agf_magicnum == cpu_to_be32(XFS_AGF_MAGIC) && XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) &&
libxfs/xfs_btree.c +9 -11
@@ -391,17 +391,15 @@ xfs_btree_dup_cursor(*/ static inline size_t xfs_btree_block_len (struct xfs_btree_cur *cur) { -size_t len; - -if (cur->bc_flags &XFS_BTREE_LONG_PTRS ) - len =XFS_BTREE_LBLOCK_LEN ; -else - len =XFS_BTREE_SBLOCK_LEN ; +if (cur->bc_flags &XFS_BTREE_LONG_PTRS ) { +if (cur->bc_flags &XFS_BTREE_CRC_BLOCKS ) +return XFS_BTREE_LBLOCK_CRC_LEN ; +return XFS_BTREE_LBLOCK_LEN ; + }if (cur->bc_flags &XFS_BTREE_CRC_BLOCKS ) - len +=XFS_BTREE_CRCBLOCK_ADD ; - -return len; +return XFS_BTREE_SBLOCK_CRC_LEN ; +return XFS_BTREE_SBLOCK_LEN ; }/*
@@ -1311,7 +1309,7 @@ xfs_btree_log_block( offsetof(struct xfs_btree_block, bb_u.s.bb_uuid), offsetof(struct xfs_btree_block, bb_u.s.bb_owner), offsetof(struct xfs_btree_block, bb_u.s.bb_crc), - XFS_BTREE_SBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD + XFS_BTREE_SBLOCK_CRC_LEN };static const short loffsets[] = {/* table of offsets (long) */ offsetof(struct xfs_btree_block , bb_magic),
@@ -1325,7 +1323,7 @@ xfs_btree_log_block( offsetof(struct xfs_btree_block, bb_u.l.bb_owner), offsetof(struct xfs_btree_block, bb_u.l.bb_crc), offsetof(struct xfs_btree_block, bb_u.l.bb_pad), - XFS_BTREE_LBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD + XFS_BTREE_LBLOCK_CRC_LEN };XFS_BTREE_TRACE_CURSOR (cur,XBT_ENTRY );
repair/agheader.c +34 -2
@@ -22,6 +22,11 @@#include "protos.h" #include "err_protos.h" +/* +* XXX (dgc): WTF is the point of all the check and repair here when phase 5 +* recreates the AGF/AGI/AGFL completely from scratch? +*/ +static int verify_set_agf (xfs_mount_t *mp,xfs_agf_t *agf,xfs_agnumber_t i) {
@@ -104,7 +109,20 @@ verify_set_agf(xfs_mount_t *mp, xfs_agf_t *agf, xfs_agnumber_t i)/* don't check freespace btrees -- will be checked by caller */ -return (retval); +if (!xfs_sb_version_hascrc (&mp->m_sb)) +return retval; + +if (platform_uuid_compare (&agf->agf_uuid, &mp->m_sb.sb_uuid)) { +char uu[64 ]; + + retval =XR_AG_AGF ; +platform_uuid_unparse (&agf->agf_uuid, uu); +do_warn (_ ("bad uuid %s for agf %d\n" ), uu, i); + +if (!no_modify) +platform_uuid_copy (&agf->agf_uuid, &mp->m_sb.sb_uuid); + } +return retval; } static int
@@ -169,7 +187,21 @@ verify_set_agi(xfs_mount_t *mp, xfs_agi_t *agi, xfs_agnumber_t agno)/* don't check inode btree -- will be checked by caller */ -return (retval); +if (!xfs_sb_version_hascrc (&mp->m_sb)) +return retval; + +if (platform_uuid_compare (&agi->agi_uuid, &mp->m_sb.sb_uuid)) { +char uu[64 ]; + + retval =XR_AG_AGI ; +platform_uuid_unparse (&agi->agi_uuid, uu); +do_warn (_ ("bad uuid %s for agi %d\n" ), uu, agno); + +if (!no_modify) +platform_uuid_copy (&agi->agi_uuid, &mp->m_sb.sb_uuid); + } + +return retval; }/*
repair/dino_chunks.c +5 -2
@@ -628,7 +628,7 @@ process_inode_chunk( bplist[bp_index] =libxfs_readbuf (mp->m_dev,XFS_AGB_TO_DADDR (mp, agno, agbno),XFS_FSB_TO_BB (mp, blks_per_cluster),0 , -NULL ); + &xfs_inode_buf_ops);if (!bplist[bp_index]) { do_warn(_("cannot read inode %" PRIu64 ", disk block %" PRId64 ", cnt %d\n"), XFS_AGINO_TO_INO(mp, agno, first_irec->ino_startnum),
@@ -775,8 +775,11 @@ process_inode_chunk( extra_attr_check, &isa_dir, &parent);ASSERT (is_used !=3 ); -if (ino_dirty) +if (ino_dirty) { dirty =1 ; +libxfs_dinode_calc_crc (mp, dino); + } +/* * XXX - if we want to try and keep * track of whether we need to bang on
repair/dinode.c +111 -79
307 lines not on this page · raw message
repair/phase2.c +1 -0
@@ -64,6 +64,7 @@ zero_log(xfs_mount_t *mp)ASSERT (mp->m_sb.sb_logsectlog >=BBSHIFT ); } log.l_sectbb_mask = (1 << log.l_sectbb_log) -1 ; + log.l_sectBBsize =1 << mp->m_sb.sb_logsectlog;if ((error =xlog_find_tail (&log, &head_blk, &tail_blk))) { do_warn(_("zero_log: cannot find log head/tail "
repair/phase5.c +114 -38
287 lines not on this page · raw message
repair/prefetch.c +6 -1
@@ -221,7 +221,7 @@ pf_scan_lbtree(int rc; bp =libxfs_readbuf (mp->m_dev,XFS_FSB_TO_DADDR (mp, dbno), -XFS_FSB_TO_BB (mp,1 ),0 ,NULL ); +XFS_FSB_TO_BB (mp,1 ),0 , &xfs_bmbt_buf_ops);if (!bp)return 0 ;
@@ -337,6 +337,11 @@ pf_read_inode_dirs(int hasdir =0 ;int isadir; + bp->b_ops = &xfs_inode_buf_ops; + bp->b_ops->verify_read (bp); +if (bp->b_error) +return ; +for (icnt =0 ; icnt < (XFS_BUF_COUNT (bp) >> mp->m_sb.sb_inodelog); icnt++) { dino =xfs_make_iptr (mp, bp, icnt);
repair/scan.c +84 -68
318 lines not on this page · raw message
repair/scan.h +8 -4
@@ -35,7 +35,8 @@ int scan_lbtree(bmap_cursor_t *bm_cursor, int isroot, int check_dups, - int *dirty), + int *dirty, + __uint64_t magic), int type, int whichfork, xfs_ino_t ino,
@@ -44,9 +45,11 @@ int scan_lbtree(struct blkmap **blkmapp, bmap_cursor_t *bm_cursor, int isroot, - int check_dups); + int check_dups, + __uint64_t magic, + const struct xfs_buf_ops *ops); -int scanfunc_bmap( +int scan_bmapbt( struct xfs_btree_block *block, int level, int type,
@@ -59,7 +62,8 @@ int scanfunc_bmap(bmap_cursor_t *bm_cursor, int isroot, int check_dups, - int *dirty); + int *dirty, + __uint64_t magic);void scan_ags(
repair/versions.c +1 -1
@@ -165,7 +165,7 @@ _("This filesystem contains features not understood by this program.\n"));return (1 ); } -if (XFS_SB_VERSION_NUM (sb) ==XFS_SB_VERSION_4 ) { +if (XFS_SB_VERSION_NUM (sb) >=XFS_SB_VERSION_4 ) {if (!fs_sb_feature_bits_allowed) {if (!no_modify) { do_warn(
repair/xfs_repair.c +1 -1
@@ -611,7 +611,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 =howmany (MAXPATHLEN -1 , mp->m_sb.sb_blocksize); + max_symlink_blocks =libxfs_symlink_blocks (mp,MAXPATHLEN ); inodes_per_cluster =MAX (mp->m_sb.sb_inopblock,XFS_INODE_CLUSTER_SIZE (mp) >> mp->m_sb.sb_inodelog);
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 24/48] xfsprogs: add crc format support to repair
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
...
include/xfs_alloc_btree.h typedef __be32 xfs_alloc_ptr_t; · line 68
Quoted 11 lines
include/xfs_alloc_btree.h +1
-1@@ -64,7 +64,7 @@ typedef __be32 xfs_alloc_ptr_t;*/ #define XFS_ALLOC_BLOCK_LEN (mp) \ (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ - XFS_BTREE_SBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD : \ + XFS_BTREE_SBLOCK_CRC_LEN : \ XFS_BTREE_SBLOCK_LEN)
Good. This addresses my observation that this was done differently in userspace than in the kernel.
include/xfs_bmap_btree.h typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; · line 144
Quoted 13 lines
include/xfs_alloc_btree.h +0
-0/* include/xfs_bmap_btree.h +1
-1@@ -140,7 +140,7 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t;*/ #define XFS_BMBT_BLOCK_LEN (mp) \ (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ - XFS_BTREE_LBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD : \ + XFS_BTREE_LBLOCK_CRC_LEN : \ XFS_BTREE_LBLOCK_LEN)
Here too.
Quoted 23 lines
include/xfs_bmap_btree.h +0
-0#define XFS_BMBT_REC_ADDR (mp, block, index) \include/xfs_btree.h +4
-1@@ -83,7 +83,10 @@ struct xfs_btree_block {#define XFS_BTREE_SBLOCK_LEN 16/* size of a short form block */ #define XFS_BTREE_LBLOCK_LEN 24/* size of a long form block */ -#define XFS_BTREE_CRCBLOCK_ADD 32/* size of blkno + crc + uuid */ + +/* sizes of CRC enabled btree blocks */ +#define XFS_BTREE_SBLOCK_CRC_LEN (XFS_BTREE_SBLOCK_LEN + 40) +#define XFS_BTREE_LBLOCK_CRC_LEN (XFS_BTREE_LBLOCK_LEN + 48)#define XFS_BTREE_SBLOCK_CRC_OFF \ offsetof(struct xfs_btree_block, bb_u.s.bb_crc)include/xfs_ialloc_btree.h +0
-0
include/xfs_ialloc_btree.h typedef __be32 xfs_inobt_ptr_t; · line 84
Quoted 6 lines
include/xfs_ialloc_btree.h +1
-1@@ -80,7 +80,7 @@ typedef __be32 xfs_inobt_ptr_t;*/ #define XFS_INOBT_BLOCK_LEN (mp) \ (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ - XFS_BTREE_SBLOCK_LEN + XFS_BTREE_CRCBLOCK_ADD : \ + XFS_BTREE_SBLOCK_CRC_LEN : \ XFS_BTREE_SBLOCK_LEN)
And here.
Quoted 28 lines
include/xfs_ialloc_btree.h +0
-0/* include/xfs_symlink.h +2
-0@@ -29,6 +29,8 @@ struct xfs_dsymlink_hdr { sizeof(struct xfs_dsymlink_hdr) : 0))int xfs_symlink_blocks (struct xfs_mount *mp,int pathlen); +bool xfs_symlink_hdr_ok (struct xfs_mount *mp,xfs_ino_t ino,uint32_t offset, +uint32_t size,struct xfs_buf *bp);extern const struct xfs_buf_ops xfs_symlink_buf_ops;libxfs/rdwr.c +1
-0@@ -445,6 +445,7 @@ __libxfs_getbufr(int blen) }else bp =kmem_zone_zalloc (xfs_buf_zone,0 );pthread_mutex_unlock (&xfs_buf_freelist.cm_mutex); + bp->b_ops =NULL ;return bp; }
libxfs/rdwr.c libxfs_writebufr(xfs_buf_t *bp) · line 842
Quoted 9 lines
libxfs/rdwr.c +6
-0@@ -833,10 +834,20 @@ libxfs_writebufr(xfs_buf_t *bp) } } +/* +* clear any pre-existing error status on the buffer. This can occur if +* the buffer is corrupt on disk and the repair process doesn't clear +* the error before fixing and writing it back. +*/ + bp->b_error =0 ;
And here we're clearing b_error, which I think addresses my concern from the last patch.
Quoted 5 lines
libxfs/xfs_alloc.c +0
-0
libxfs/xfs_alloc.c xfs_agf_verify( · line 2180
Quoted 9 lines
libxfs/xfs_alloc.c +5
-1@@ -2173,8 +2173,13 @@ xfs_agf_verify(struct xfs_agf *agf =XFS_BUF_TO_AGF (bp);if (xfs_sb_version_hascrc (&mp->m_sb) && - !uuid_equal (&agf->agf_uuid, &mp->m_sb.sb_uuid)) + !uuid_equal (&agf->agf_uuid, &mp->m_sb.sb_uuid)) { +char uu[64 ], uu2[64 ]; +platform_uuid_unparse (&agf->agf_uuid, uu); +platform_uuid_unparse (&mp->m_sb.sb_uuid, uu2); +
Here it looks like we unparse the uuids into strings, and then do nothing with them?
repair/agheader.c line 26
Quoted 10 lines
repair/agheader.c +2
-0@@ -22,6 +22,11 @@#include "protos.h" #include "err_protos.h" +/* +* XXX (dgc): WTF is the point of all the check and repair here when phase 5
Don't cuss into the codebase. People work here.
Quoted 4 lines
repair/dinode.c +0
-0
...
repair/dinode.c _("would have cleared inode %" PRIu64 " attributes\n"), ino_num); · line 190
Quoted 11 lines
repair/dinode.c +11
-0+if (platform_uuid_compare (&dinoc->di_uuid, &mp->m_sb.sb_uuid)) { +__dirty_no_modify_ret (dirty); +platform_uuid_copy (&dinoc->di_uuid, &mp->m_sb.sb_uuid); + } + +for (i =0 ; i <16 ; i++) { +if (dinoc->di_pad[i] !=0 ) { +__dirty_no_modify_ret (dirty); +memset (dinoc->di_pad,0 ,16 ); +break ; + }
This looks incorrect. di_pad is 6 bytes long. Maybe you are after di_pad2, but even then there is no need to zero it up to 16 times, afaict.
Quoted 23 lines
repair/dinode.c +5
-2@@ -1137,6 +1126,9 @@ process_btinode(else forkname =_ ("attr" ); + magic =xfs_sb_version_hascrc (&mp->m_sb) ?XFS_BMAP_CRC_MAGIC + :XFS_BMAP_MAGIC ; + level =be16_to_cpu (dib->bb_level); numrecs =be16_to_cpu (dib->bb_numrecs);@@ -1190,9 +1182,9 @@ _("bad numrecs 0 in inode %" PRIu64 " bmap btree root block\n"),return (1 ); } -if (scan_lbtree (be64_to_cpu (pp[i]), level, scanfunc_bmap, type, +if (scan_lbtree (be64_to_cpu (pp[i]), level, scan_bmapbt, type, whichfork, lino, tot, nex, blkmapp, &cursor, -1 , check_dups)) +1 , check_dups, magic, &xfs_bmbt_buf_ops))return (1 );/* * fix key (offset) mismatches between the keys in root
repair/dinode.c _("cannot read inode %" PRIu64 ", file block %d, disk block %" PRIu64 "\n"), · line 1515
Quoted 4 lines
repair/dinode.c +1
-0@@ -1520,9 +1512,21 @@ _("cannot read inode %" PRIu64 ", file block %d, disk block %" PRIu64 "\n"),return (1 ); } +
Extra line.
repair/phase2.c zero_log(xfs_mount_t *mp) · line 67
Quoted 9 lines
repair/phase2.c +1
-0@@ -64,6 +64,7 @@ zero_log(xfs_mount_t *mp)ASSERT (mp->m_sb.sb_logsectlog >=BBSHIFT ); } log.l_sectbb_mask = (1 << log.l_sectbb_log) -1 ; + log.l_sectBBsize =1 << mp->m_sb.sb_logsectlog;
I'm not seeing how this change is connected with the patch. Is it something we didn't use and needs to be initialized now?
repair/phase5.c build_agf_agfl(xfs_mount_t *mp, · line 1403
Quoted 11 lines
repair/phase5.c +3
-0@@ -1342,6 +1398,26 @@ build_agf_agfl(xfs_mount_t *mp,libxfs_writebuf (agf_buf,0 ); +/* +* now fix up the free list appropriately +* XXX: code lifted from mkfs, shoul dbe shared.
should be
Quoted 16 lines
repair/scan.c +4
-4@@ -709,10 +702,20 @@ _("%s freespace btree block claimed (state %d), agno %d, bno %d, suspect %d\n"),* as possible. */ if (bno !=0 &&verify_agbno (mp, agno, bno)) { -scan_sbtree (bno, level, agno, suspect, - (magic ==XFS_ABTB_MAGIC ) ? - scanfunc_bno : scanfunc_cnt,0 , - (void *)agcnts); +switch (magic) { +case XFS_ABTB_CRC_MAGIC : +case XFS_ABTB_MAGIC : + scan_sbtree(bno, level, agno, suspect,
repair/scan.c _("%s freespace btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), · line 718
Quoted 10 lines
repair/scan.c +10
-0+ scan_allocbt,0 , magic, priv, + &xfs_allocbt_buf_ops); +break ; +case XFS_ABTC_CRC_MAGIC : +case XFS_ABTC_MAGIC : +scan_sbtree (bno, level, agno, suspect, + scan_allocbt,0 , magic, priv, + &xfs_allocbt_buf_ops); +break ; + }
This looks ok but appears that it could be collapsed.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 25/48 xfs_repair: update for dir/attr crc format changes.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- include/xfs_attr_leaf.h | 2 + include/xfs_dir2_format.h | 3 ++ libxfs/xfs_dir2_priv.h | 2 - repair/attr_repair.c | 77 +++++++++++++++++++++++---------------- repair/dir2.c | 43 +++++++++++++--------- repair/dir2.h | 6 +-- repair/phase6.c | 89 ++++++++++++++++++++++++--------------------- 7 files changed, 126 insertions(+), 96 deletions(-)
include/xfs_attr_leaf.h +2 -0
@@ -332,6 +332,8 @@ int xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_buf **bpp);void xfs_attr3_leaf_hdr_from_disk (struct xfs_attr3_icleaf_hdr *to,struct xfs_attr_leafblock *from); +void xfs_attr3_leaf_hdr_to_disk (struct xfs_attr_leafblock *to, +struct xfs_attr3_icleaf_hdr *from);extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
include/xfs_dir2_format.h +3 -0
@@ -512,6 +512,9 @@ struct xfs_dir3_leaf {#define XFS_DIR3_LEAF_CRC_OFF offsetof(struct xfs_dir3_leaf_hdr, info.crc) +extern void xfs_dir3_leaf_hdr_from_disk (struct xfs_dir3_icleaf_hdr *to, +struct xfs_dir2_leaf *from); +static inline int xfs_dir3_leaf_hdr_size (struct xfs_dir2_leaf *lp) {
libxfs/xfs_dir2_priv.h +0 -2
@@ -104,8 +104,6 @@ xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr, int lowstale, int highstale, int *lfloglow, int *lfloghigh);extern int xfs_dir2_node_to_leaf (struct xfs_da_state *state); -extern void xfs_dir3_leaf_hdr_from_disk (struct xfs_dir3_icleaf_hdr *to, -struct xfs_dir2_leaf *from);extern void xfs_dir3_leaf_hdr_to_disk (struct xfs_dir2_leaf *to,struct xfs_dir3_icleaf_hdr *from); extern bool xfs_dir3_leaf_check_int(struct xfs_mount *mp,
repair/attr_repair.c +45 -32
221 lines not on this page · raw message
repair/dir2.c +25 -18
131 lines not on this page · raw message
repair/dir2.h +3 -3
@@ -33,13 +33,13 @@ typedef union {typedef struct xfs_dir2_data {xfs_dir2_data_hdr_t hdr;/* magic XFS_DIR2_DATA_MAGIC */ -xfs_dir2_data_union_t u[1 ]; +xfs_dir2_data_union_t __u[1 ]; }xfs_dir2_data_t ;typedef struct xfs_dir2_block {xfs_dir2_data_hdr_t hdr;/* magic XFS_DIR2_BLOCK_MAGIC */ -xfs_dir2_data_union_t u[1 ]; -xfs_dir2_leaf_entry_t leaf[1 ]; +xfs_dir2_data_union_t __u[1 ]; +xfs_dir2_leaf_entry_t __leaf[1 ];xfs_dir2_block_tail_t tail; }xfs_dir2_block_t ;
repair/phase6.c +48 -41
192 lines not on this page · raw message
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 25/48] xfs_repair: update for dir/attr crc format changes.
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 26/48 xfsprogs: disable xfs_check for CRC enabled filesystems
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Until xfs_db has full metadata CRC support, xfs_check will not be able to fully verify filesystems in this format. Don't even bother trying right now, and to make it simple to test full xfsprogs installs with xfstests, just silently succeed.
--- db/check.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
db/check.c +14 -0
@@ -788,6 +788,20 @@ blockget_f(dbprintf (_ ("already have block usage information\n" ));return 0 ; } + +/* +* XXX: check does not support CRC enabled filesystems. Return +* immediately, silently, with success but without doing anything here +* initially so that xfstests can run without modification on metadata +* enabled filesystems. +* +* XXX: ultimately we need to dump an error message here that xfstests +* filters out, or we need to actually do the work to make check support +* crc enabled filesystems. +*/ +if (xfs_sb_version_hascrc (&mp->m_sb)) +return 0 ; +if (!init (argc, argv)) {if (serious_error) exitcode =3 ;
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 26/48] xfsprogs: disable xfs_check for CRC enabled filesystems
Quoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Until
xfs_dbhas full metadata CRC support,xfs_checkwill not be able to fully verify filesystems in this format. Don't even bother trying right now, and to make it simple to test full xfsprogs installs with xfstests, just silently succeed.Signed-off-by Dave Chinner <[email protected]>
Huh. I guess we can do this since it's deprecated...
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 27/48 xfs_db: disable modification for CRC enabled filessytems.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
xfs_db does not have the IO infrastructure to calculate metadata CRCs after modifying metadata. Hence xfs_db can only run in read-only mode on filesystems with version 5 superblocks.
To fix this, xfs_db needs to have it's IO engine converted to use the buffer based IO provided by libxfs rather than rolling it's own IO routines. That is future work, so until this conversion is done, only allow xfs_db to run in read-only mode on v5 filesystems.
--- db/init.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
db/init.c +15 -0
@@ -132,6 +132,21 @@ init(exit (EXIT_FAILURE ); } +/* +* Don't allow modifications to CRC enabled filesystems until we support +* CRC recalculation in the IO path. Unless, of course, the user is in +* the process of hitting us with a big hammer. +*/ +if (XFS_SB_VERSION_NUM (sbp) >=XFS_SB_VERSION_5 && + !(x.isreadonly &LIBXFS_ISREADONLY )) { +fprintf (stderr, +_ ("%s: modifications to %s are not supported in thi version.\n" +"Use \"-r\" to run %s in read-only mode on this filesystem .\n" ), + progname, fsdevice, progname); +if (!force) +exit (EXIT_FAILURE ); + } + mp =libxfs_mount (&xmount, sbp, x.ddev, x.logdev, x.rtdev,LIBXFS_MOUNT_ROOTINOS |LIBXFS_MOUNT_DEBUGGER );if (!mp) {
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 27/48] xfs_db: disable modification for CRC enabled filessytems.
Quoted 6 lines · Dave Chinner
From: Dave Chinner <[email protected]>
xfs_dbdoes not have the IO infrastructure to calculate metadata CRCs after modifying metadata. Hencexfs_dbcan only run in read-only mode on filesystems with version 5 superblocks.
Quoted 6 lines
To fix this,
xfs_dbneeds to have it's IO engine converted to use the buffer based IO provided by libxfs rather than rolling it's own IO routines. That is future work, so until this conversion is done, only allowxfs_dbto run in read-only mode on v5 filesystems.Signed-off-by Dave Chinner <[email protected]>
Another one for the TODO list.
Quoted 11 lines
--- db/init.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)db/init.c +0
-0@@ -132,6 +132,21 @@ init(exit (EXIT_FAILURE ); }
db/init.c init( · line 143
Quoted 10 lines
db/init.c +9
-0+/* +* Don't allow modifications to CRC enabled filesystems until we support +* CRC recalculation in the IO path. Unless, of course, the user is in +* the process of hitting us with a big hammer. +*/ +if (XFS_SB_VERSION_NUM (sbp) >=XFS_SB_VERSION_5 && + !(x.isreadonly &LIBXFS_ISREADONLY )) { + fprintf(stderr, + _("%s: modifications to %s are not supported in thi version.\n"
this
db/init.c init( · line 144
Quoted 1 line
db/init.c +1
-0+ "Use \"-r\" to run %s in read-only mode on this filesystem .\n"),
^ extra space
Quoted 15 lines
db/init.c +5
-0+ progname, fsdevice, progname); +if (!force) +exit (EXIT_FAILURE ); + } + mp =libxfs_mount (&xmount, sbp, x.ddev, x.logdev, x.rtdev,LIBXFS_MOUNT_ROOTINOS |LIBXFS_MOUNT_DEBUGGER );if (!mp) {Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 28/48 libxfs: determine inode size from version number, not struct xfs_dinode
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
xfs_db does not use the same structure types as libxfs when checking inodes, and so cannot determine the size of the inode core by passing a struct xfs_dinode to a function. We do, however, know the raw version number, so we can pass that instead. Convert the code to passing the inode version rather than a structure.
Note that this should probably be converted in the kernel code as well.
--- include/xfs_inode.h | 4 ++-- logprint/log_misc.c | 2 +- logprint/log_print_all.c | 4 ++-- repair/phase6.c | 9 +++------ 4 files changed, 8 insertions(+), 11 deletions(-)
include/xfs_inode.h +2 -2
@@ -169,9 +169,9 @@ typedef struct xfs_icdinode {/* structure must be padded to 64 bit alignment */ } xfs_icdinode_t; -static inline uint xfs_icdinode_size (struct xfs_icdinode *dicp) +static inline uint xfs_icdinode_size (int version) { -if (dicp->di_version ==3 ) +if (version ==3 )return sizeof (struct xfs_icdinode );return offsetof(struct xfs_icdinode , di_next_unlinked); }
logprint/log_misc.c +1 -1
@@ -655,7 +655,7 @@ xlog_print_trans_inode(xfs_caddr_t *ptr, mode = dino.di_mode &S_IFMT ; size = (int )dino.di_size;xlog_print_trans_inode_core (&dino); - *ptr +=xfs_icdinode_size (&dino); + *ptr +=xfs_icdinode_size (dino.di_version);if (*i == num_ops-1 && f->ilf_size ==3 ) {return 1 ;
logprint/log_print_all.c +2 -2
@@ -295,8 +295,8 @@ xlog_recover_print_inode( f->ilf_dsize);/* core inode comes 2nd */ -ASSERT (item->ri_buf[1 ].i_len ==xfs_icdinode_size ((xfs_icdinode_t *) - item->ri_buf[1 ].i_addr)); +ASSERT (item->ri_buf[1 ].i_len ==xfs_icdinode_size (1 ) || + item->ri_buf[1 ].i_len ==xfs_icdinode_size (3 ));xlog_recover_print_inode_core ((xfs_icdinode_t *) item->ri_buf[1 ].i_addr);
repair/phase6.c +3 -6
@@ -446,8 +446,7 @@ mk_rbmino(xfs_mount_t *mp) } vers =xfs_sb_version_hascrc (&mp->m_sb) ?3 :1 ; - ip->i_d.di_version = vers; -memset (&ip->i_d,0 ,xfs_icdinode_size (&ip->i_d)); +memset (&ip->i_d,0 ,xfs_icdinode_size (vers)); ip->i_d.di_magic =XFS_DINODE_MAGIC ; ip->i_d.di_mode =S_IFREG ;
@@ -696,8 +695,7 @@ mk_rsumino(xfs_mount_t *mp) } vers =xfs_sb_version_hascrc (&mp->m_sb) ?3 :1 ; - ip->i_d.di_version = vers; -memset (&ip->i_d,0 ,xfs_icdinode_size (&ip->i_d)); +memset (&ip->i_d,0 ,xfs_icdinode_size (vers)); ip->i_d.di_magic =XFS_DINODE_MAGIC ; ip->i_d.di_mode =S_IFREG ;
@@ -813,8 +811,7 @@ mk_root_dir(xfs_mount_t *mp)* take care of the core -- initialization from xfs_ialloc() */ vers =xfs_sb_version_hascrc (&mp->m_sb) ?3 :1 ; - ip->i_d.di_version = vers; -memset (&ip->i_d,0 ,xfs_icdinode_size (&ip->i_d)); +memset (&ip->i_d,0 ,xfs_icdinode_size (vers)); ip->i_d.di_magic =XFS_DINODE_MAGIC ; ip->i_d.di_mode = (__uint16_t ) mode|S_IFDIR ;
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 28/48] libxfs: determine inode size from version number, not struct xfs_dinode
Quoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
xfs_dbdoes not use the same structure types as libxfs when checking inodes, and so cannot determine the size of the inode core by passing a structxfs_dinodeto a function. We do, however, know the raw version number, so we can pass that instead. Convert the code to passing the inode version rather than a structure.
Quoted 4 lines
Note that this should probably be converted in the kernel code as well.
Signed-off-by Dave Chinner <[email protected]>
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 29/48 xfsdb: support version 5 superblock in versionnum command
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
While there, add visibility of the new superblock fields in the "sb" command.
--- db/sb.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-)
db/sb.c +41 -5
@@ -108,7 +108,19 @@ const field_t sb_flds[] = { { "logsectsize", FLDT_UINT16D, OI(OFF(logsectsize)), C1, 0, TYP_NONE }, { "logsunit", FLDT_UINT32D, OI(OFF(logsunit)), C1, 0, TYP_NONE }, { "features2", FLDT_UINT32X, OI(OFF(features2)), C1, 0, TYP_NONE }, - { "bad_features2", FLDT_UINT32X, OI(OFF(bad_features2)), C1, 0, TYP_NONE }, + { "bad_features2", FLDT_UINT32X, OI(OFF(bad_features2)), + C1, 0, TYP_NONE }, + { "features_compat", FLDT_UINT32X, OI(OFF(features_compat)), + C1, 0, TYP_NONE }, + { "features_ro_compat", FLDT_UINT32X, OI(OFF(features_ro_compat)), + C1, 0, TYP_NONE }, + { "features_incompat", FLDT_UINT32X, OI(OFF(features_incompat)), + C1, 0, TYP_NONE }, + { "features_log_incompat", FLDT_UINT32X, OI(OFF(features_log_incompat)), + C1, 0, TYP_NONE }, + { "crc", FLDT_UINT32X, OI(OFF(crc)), C1, 0, TYP_NONE }, + { "pquotino", FLDT_INO, OI(OFF(pquotino)), C1, 0, TYP_INODE }, + { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, { NULL } };
@@ -597,6 +609,8 @@ version_string(strcpy (s,"V3" ); else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) strcpy(s, "V4"); + else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) + strcpy(s, "V5"); if (xfs_sb_version_hasattr(sbp)) strcat(s, ",ATTR");
@@ -628,9 +642,17 @@ version_string(strcat (s,",LAZYSBCOUNT" );if (xfs_sb_version_hasprojid32bit (sbp))strcat (s,",PROJID32BIT" ); +if (xfs_sb_version_hascrc (sbp)) +strcat (s,",CRC" );return s; } +/* +* XXX: this only supports reading and writing to version 4 superblock fields. +* V5 superblocks always define certain V4 feature bits - they are blocked from +* being changed if a V5 sb is detected, but otherwise v5 superblock features +* are not handled here. +*/ static int version_f( int argc,
@@ -662,12 +684,16 @@ version_f(break ;case XFS_SB_VERSION_4 :if (xfs_sb_version_hasextflgbit (&mp->m_sb)) -dbprintf (_ ("unwritten extents flag" -" is already enabled\n" )); +dbprintf ( +_ ("unwritten extents flag is already enabled\n" ));else version = mp->m_sb.sb_versionnum |XFS_SB_VERSION_EXTFLGBIT ;break ; +case XFS_SB_VERSION_5 : +dbprintf ( +_ ("unwritten extents always enabled for v5 superblocks.\n" )); +break ; } }else if (!strcasecmp (argv[1 ],"log2" )) {switch (XFS_SB_VERSION_NUM (&mp->m_sb)) {
@@ -682,14 +708,24 @@ version_f(break ;case XFS_SB_VERSION_4 :if (xfs_sb_version_haslogv2 (&mp->m_sb)) -dbprintf (_ ("version 2 log format" -" is already in use\n" )); +dbprintf ( +_ ("version 2 log format is already in use\n" ));else version = mp->m_sb.sb_versionnum |XFS_SB_VERSION_LOGV2BIT ;break ; +case XFS_SB_VERSION_5 : +dbprintf ( +_ ("Version 2 logs always enabled for v5 superblocks.\n" )); +break ; } + }else if (XFS_SB_VERSION_NUM (&mp->m_sb) ==XFS_SB_VERSION_5 ) { +dbprintf ( +_ ("%s: Cannot change %s on v5 superblocks.\n" ), + progname, argv[1 ]); +return 0 ; }else if (!strcasecmp (argv[1 ],"attr1" )) { +if (xfs_sb_version_hasattr2 (&mp->m_sb)) {if (!(mp->m_sb.sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT ))
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 29/48] xfsdb: support version 5 superblock in versionnum command
Quoted 6 lines · Dave Chinner
From: Dave Chinner <[email protected]>
While there, add visibility of the new superblock fields in the "sb" command.
Signed-off-by Dave Chinner <[email protected]>
Looks good.
s/xfsdb/xfs_db
in the subject.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 30/48 xfsprogs: add crc format support to db
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- db/agf.c | 3 ++ db/agfl.c | 16 +++++++ db/agfl.h | 2 + db/agi.c | 3 ++ db/btblock.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ db/btblock.h | 10 ++++ db/field.c | 16 +++++++ db/field.h | 8 ++++ db/freesp.c | 6 ++- db/init.c | 4 ++ db/inode.c | 27 +++++++++++ db/inode.h | 3 ++ db/type.c | 34 +++++++++++++- db/type.h | 3 +- libxfs/util.c | 1 - 15 files changed, 276 insertions(+), 5 deletions(-)
db/agf.c +3 -0
@@ -69,6 +69,9 @@ const field_t agf_flds[] = { { "freeblks", FLDT_EXTLEN, OI(OFF(freeblks)), C1, 0, TYP_NONE }, { "longest", FLDT_EXTLEN, OI(OFF(longest)), C1, 0, TYP_NONE }, { "btreeblks", FLDT_UINT32D, OI(OFF(btreeblks)), C1, 0, TYP_NONE }, + { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, + { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, + { "crc", FLDT_UINT32X, OI(OFF(crc)), C1, 0, TYP_NONE }, { NULL } };
db/agfl.c +16 -0
@@ -41,8 +41,24 @@ const field_t agfl_hfld[] = { { { NULL } }; +const field_t agfl_crc_hfld[] = { { +"" ,FLDT_AGFL_CRC ,OI (0 ),C1 ,0 ,TYP_NONE , }, + {NULL } +}; +#define OFF (f) bitize(offsetof(xfs_agfl_t, agfl_ ## f))const field_t agfl_flds[] = { + {"bno" ,FLDT_AGBLOCKNZ ,OI (OFF (magicnum)), agfl_bno_size, +FLD_ARRAY |FLD_COUNT ,TYP_DATA }, + {NULL } +}; + +const field_t agfl_crc_flds[] = { + {"magicnum" ,FLDT_UINT32X ,OI (OFF (magicnum)),C1 ,0 ,TYP_NONE }, + {"seqno" ,FLDT_AGNUMBER ,OI (OFF (seqno)),C1 ,0 ,TYP_NONE }, + {"uuid" ,FLDT_UUID ,OI (OFF (uuid)),C1 ,0 ,TYP_NONE }, + {"lsn" ,FLDT_UINT64X ,OI (OFF (lsn)),C1 ,0 ,TYP_NONE }, + {"crc" ,FLDT_UINT32X ,OI (OFF (crc)),C1 ,0 ,TYP_NONE }, {"bno" ,FLDT_AGBLOCKNZ ,OI (OFF (bno)), agfl_bno_size,FLD_ARRAY |FLD_COUNT ,TYP_DATA }, {NULL }
db/agfl.h +2 -0
@@ -18,6 +18,8 @@extern const struct field agfl_flds[];extern const struct field agfl_hfld[]; +extern const struct field agfl_crc_flds[]; +extern const struct field agfl_crc_hfld[];extern void agfl_init (void );extern int agfl_size (void *obj,int startoff,int idx);
db/agi.c +3 -0
@@ -54,6 +54,9 @@ const field_t agi_flds[] = { { "dirino", FLDT_AGINO, OI(OFF(dirino)), C1, 0, TYP_INODE }, { "unlinked", FLDT_AGINONN, OI(OFF(unlinked)), CI(XFS_AGI_UNLINKED_BUCKETS), FLD_ARRAY, TYP_NONE }, + { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, + { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, + { "crc", FLDT_UINT32X, OI(OFF(crc)), C1, 0, TYP_NONE }, { NULL } };
db/btblock.c +145 -0
199 lines not on this page · raw message
db/btblock.h +10 -0
@@ -18,26 +18,36 @@extern const struct field bmapbta_flds[];extern const struct field bmapbta_hfld[]; +extern const struct field bmapbta_crc_flds[]; +extern const struct field bmapbta_crc_hfld[];extern const struct field bmapbta_key_flds[];extern const struct field bmapbta_rec_flds[];extern const struct field bmapbtd_flds[];extern const struct field bmapbtd_hfld[]; +extern const struct field bmapbtd_crc_flds[]; +extern const struct field bmapbtd_crc_hfld[];extern const struct field bmapbtd_key_flds[];extern const struct field bmapbtd_rec_flds[];extern const struct field inobt_flds[];extern const struct field inobt_hfld[]; +extern const struct field inobt_crc_flds[]; +extern const struct field inobt_crc_hfld[];extern const struct field inobt_key_flds[];extern const struct field inobt_rec_flds[];extern const struct field bnobt_flds[];extern const struct field bnobt_hfld[]; +extern const struct field bnobt_crc_flds[]; +extern const struct field bnobt_crc_hfld[];extern const struct field bnobt_key_flds[];extern const struct field bnobt_rec_flds[];extern const struct field cntbt_flds[];extern const struct field cntbt_hfld[]; +extern const struct field cntbt_crc_flds[]; +extern const struct field cntbt_crc_hfld[];extern const struct field cntbt_key_flds[];extern const struct field cntbt_rec_flds[];
db/field.c +16 -0
@@ -46,6 +46,8 @@ const ftattr_t ftattrtab[] = { agf_flds }, {FLDT_AGFL ,"agfl" ,NULL , (char *)agfl_flds, agfl_size,FTARG_SIZE , NULL, agfl_flds }, + { FLDT_AGFL_CRC, "agfl", NULL, (char *)agfl_crc_flds, agfl_size, + FTARG_SIZE, NULL, agfl_crc_flds }, { FLDT_AGI, "agi", NULL, (char *)agi_flds, agi_size, FTARG_SIZE, NULL, agi_flds }, { FLDT_AGINO, "agino", fp_num, "%u", SI(bitsz(xfs_agino_t)),
@@ -84,6 +86,8 @@ const ftattr_t ftattrtab[] = { attrshort_size, FTARG_SIZE, NULL, attr_shortform_flds }, { FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size, FTARG_SIZE, NULL, bmapbta_flds }, + { FLDT_BMAPBTA_CRC, "bmapbta", NULL, (char *)bmapbta_crc_flds, + btblock_size, FTARG_SIZE, NULL, bmapbta_crc_flds }, { FLDT_BMAPBTAKEY, "bmapbtakey", fp_sarray, (char *)bmapbta_key_flds, SI(bitsz(xfs_bmbt_key_t)), 0, NULL, bmapbta_key_flds }, { FLDT_BMAPBTAPTR, "bmapbtaptr", fp_num, "%llu",
@@ -92,6 +96,8 @@ const ftattr_t ftattrtab[] = { SI(bitsz(xfs_bmbt_rec_t)), 0, NULL, bmapbta_rec_flds }, { FLDT_BMAPBTD, "bmapbtd", NULL, (char *)bmapbtd_flds, btblock_size, FTARG_SIZE, NULL, bmapbtd_flds }, + { FLDT_BMAPBTD_CRC, "bmapbtd", NULL, (char *)bmapbtd_crc_flds, + btblock_size, FTARG_SIZE, NULL, bmapbtd_crc_flds }, { FLDT_BMAPBTDKEY, "bmapbtdkey", fp_sarray, (char *)bmapbtd_key_flds, SI(bitsz(xfs_bmbt_key_t)), 0, NULL, bmapbtd_key_flds }, { FLDT_BMAPBTDPTR, "bmapbtdptr", fp_num, "%llu",
@@ -112,6 +118,8 @@ const ftattr_t ftattrtab[] = { SI(bitsz(xfs_bmdr_ptr_t)), 0, fa_dfsbno, NULL }, { FLDT_BNOBT, "bnobt", NULL, (char *)bnobt_flds, btblock_size, FTARG_SIZE, NULL, bnobt_flds }, + { FLDT_BNOBT_CRC, "bnobt", NULL, (char *)bnobt_crc_flds, btblock_size, + FTARG_SIZE, NULL, bnobt_crc_flds }, { FLDT_BNOBTKEY, "bnobtkey", fp_sarray, (char *)bnobt_key_flds, SI(bitsz(xfs_alloc_key_t)), 0, NULL, bnobt_key_flds }, { FLDT_BNOBTPTR, "bnobtptr", fp_num, "%u", SI(bitsz(xfs_alloc_ptr_t)),
@@ -133,6 +141,8 @@ const ftattr_t ftattrtab[] = { { FLDT_CHARS, "chars", fp_num, "%c", SI(bitsz(char)), 0, NULL, NULL }, { FLDT_CNTBT, "cntbt", NULL, (char *)cntbt_flds, btblock_size, FTARG_SIZE, NULL, cntbt_flds }, + { FLDT_CNTBT_CRC, "cntbt", NULL, (char *)cntbt_crc_flds, btblock_size, + FTARG_SIZE, NULL, cntbt_crc_flds }, { FLDT_CNTBTKEY, "cntbtkey", fp_sarray, (char *)cntbt_key_flds, SI(bitsz(xfs_alloc_key_t)), 0, NULL, cntbt_key_flds }, { FLDT_CNTBTPTR, "cntbtptr", fp_num, "%u", SI(bitsz(xfs_alloc_ptr_t)),
@@ -154,6 +164,8 @@ const ftattr_t ftattrtab[] = { SI(bitsz(__int8_t)), 0, NULL, NULL }, { FLDT_DINODE_U, "dinode_u", NULL, (char *)inode_u_flds, inode_u_size, FTARG_SIZE|FTARG_OKEMPTY, NULL, inode_u_flds }, + { FLDT_DINODE_V3, "dinode_v3", NULL, (char *)inode_v3_flds, + SI(bitsz(xfs_dinode_t)), 0, NULL, inode_v3_flds }, { FLDT_DIR2, "dir2", NULL, (char *)dir2_flds, dir2_size, FTARG_SIZE, NULL, dir2_flds }, { FLDT_DIR2_BLOCK_TAIL, "dir2_block_tail", NULL,
@@ -224,6 +236,8 @@ const ftattr_t ftattrtab[] = { fa_ino, NULL }, { FLDT_INOBT, "inobt", NULL, (char *)inobt_flds, btblock_size, FTARG_SIZE, NULL, inobt_flds }, + { FLDT_INOBT_CRC, "inobt", NULL, (char *)inobt_crc_flds, btblock_size, + FTARG_SIZE, NULL, inobt_crc_flds }, { FLDT_INOBTKEY, "inobtkey", fp_sarray, (char *)inobt_key_flds, SI(bitsz(xfs_inobt_key_t)), 0, NULL, inobt_key_flds }, { FLDT_INOBTPTR, "inobtptr", fp_num, "%u", SI(bitsz(xfs_inobt_ptr_t)),
@@ -232,6 +246,8 @@ const ftattr_t ftattrtab[] = { SI(bitsz(xfs_inobt_rec_t)), 0, NULL, inobt_rec_flds }, { FLDT_INODE, "inode", NULL, (char *)inode_flds, inode_size, FTARG_SIZE, NULL, inode_flds }, + { FLDT_INODE_CRC, "inode", NULL, (char *)inode_crc_flds, inode_size, + FTARG_SIZE, NULL, inode_crc_flds }, { FLDT_INOFREE, "inofree", fp_num, "%#llx", SI(bitsz(xfs_inofree_t)), 0, NULL, NULL }, { FLDT_INT16D, "int16d", fp_num, "%d", SI(bitsz(__int16_t)),
db/field.h +8 -0
@@ -22,6 +22,7 @@ typedef enum fldt {FLDT_AGBLOCKNZ ,FLDT_AGF ,FLDT_AGFL , +FLDT_AGFL_CRC ,FLDT_AGI ,FLDT_AGINO , FLDT_AGINONN,
@@ -39,10 +40,12 @@ typedef enum fldt {FLDT_ATTRBLOCK ,FLDT_ATTRSHORT ,FLDT_BMAPBTA , +FLDT_BMAPBTA_CRC ,FLDT_BMAPBTAKEY ,FLDT_BMAPBTAPTR ,FLDT_BMAPBTAREC ,FLDT_BMAPBTD , +FLDT_BMAPBTD_CRC ,FLDT_BMAPBTDKEY ,FLDT_BMAPBTDPTR , FLDT_BMAPBTDREC,
@@ -53,6 +56,7 @@ typedef enum fldt {FLDT_BMROOTDKEY ,FLDT_BMROOTDPTR ,FLDT_BNOBT , +FLDT_BNOBT_CRC ,FLDT_BNOBTKEY ,FLDT_BNOBTPTR , FLDT_BNOBTREC,
@@ -64,6 +68,7 @@ typedef enum fldt {FLDT_CHARNS ,FLDT_CHARS ,FLDT_CNTBT , +FLDT_CNTBT_CRC ,FLDT_CNTBTKEY ,FLDT_CNTBTPTR , FLDT_CNTBTREC,
@@ -75,6 +80,7 @@ typedef enum fldt {FLDT_DINODE_CORE ,FLDT_DINODE_FMT ,FLDT_DINODE_U , +FLDT_DINODE_V3 ,FLDT_DIR2 ,FLDT_DIR2_BLOCK_TAIL , FLDT_DIR2_DATA_FREE,
@@ -107,10 +113,12 @@ typedef enum fldt {FLDT_FSIZE ,FLDT_INO ,FLDT_INOBT , +FLDT_INOBT_CRC ,FLDT_INOBTKEY ,FLDT_INOBTPTR ,FLDT_INOBTREC ,FLDT_INODE , +FLDT_INODE_CRC ,FLDT_INOFREE ,FLDT_INT16D , FLDT_INT32D,
db/freesp.c +4 -2
@@ -301,7 +301,8 @@ scanfunc_bno(xfs_alloc_ptr_t *pp;xfs_alloc_rec_t *rp; -if (be32_to_cpu (block->bb_magic) !=XFS_ABTB_MAGIC ) +if (!(be32_to_cpu (block->bb_magic) ==XFS_ABTB_MAGIC || +be32_to_cpu (block->bb_magic) ==XFS_ABTB_CRC_MAGIC ))return ;if (level ==0 ) {
@@ -328,7 +329,8 @@ scanfunc_cnt(xfs_alloc_ptr_t *pp;xfs_alloc_rec_t *rp; -if (be32_to_cpu (block->bb_magic) !=XFS_ABTC_MAGIC ) +if (!(be32_to_cpu (block->bb_magic) ==XFS_ABTC_MAGIC || +be32_to_cpu (block->bb_magic) ==XFS_ABTC_CRC_MAGIC ))return ;if (level ==0 ) {
db/init.c +4 -0
@@ -26,6 +26,7 @@#include "sig.h" #include "output.h" #include "malloc.h" +#include "type.h" static char **cmdline;static int ncmdline;
@@ -160,6 +161,9 @@ init( } blkbb =1 << mp->m_blkbb_log; +if (xfs_sb_version_hascrc (&mp->m_sb)) +type_set_tab_crc (); +push_cur ();init_commands ();init_sig ();
db/inode.c +27 -0
@@ -57,6 +57,10 @@ const field_t inode_hfld[] = { { "", FLDT_INODE, OI(0), C1, 0, TYP_NONE }, { NULL } }; +const field_t inode_crc_hfld[] = { + {"" ,FLDT_INODE_CRC ,OI (0 ),C1 ,0 ,TYP_NONE }, + {NULL } +};/* XXX: fix this up! */ #define OFF (f) bitize(offsetof(xfs_dinode_t, di_ ## f))
@@ -69,6 +73,17 @@ const field_t inode_flds[] = { FLD_COUNT|FLD_OFFSET, TYP_NONE }, { NULL } }; +const field_t inode_crc_flds[] = { + {"core" ,FLDT_DINODE_CORE ,OI (OFF (magic)),C1 ,0 ,TYP_NONE }, + {"next_unlinked" ,FLDT_AGINO ,OI (OFF (next_unlinked)),C1 ,0 , +TYP_INODE }, + {"v3" ,FLDT_DINODE_V3 ,OI (OFF (magic)),C1 ,0 ,TYP_NONE }, + {"u" ,FLDT_DINODE_U , inode_u_offset,C1 ,FLD_OFFSET ,TYP_NONE }, + {"a" ,FLDT_DINODE_A , inode_a_offset, inode_a_count, +FLD_COUNT |FLD_OFFSET ,TYP_NONE }, + {NULL } +}; +#define COFF (f) bitize(offsetof(xfs_dinode_t, di_ ## f))const field_t inode_core_flds[] = {
@@ -151,6 +166,18 @@ const field_t inode_core_flds[] = { { NULL } }; +const field_t inode_v3_flds[] = { + {"crc" ,FLDT_UINT32X ,OI (COFF (crc)),C1 ,0 ,TYP_NONE }, + {"change_count" ,FLDT_UINT64D ,OI (COFF (changecount)),C1 ,0 ,TYP_NONE }, + {"lsn" ,FLDT_UINT64X ,OI (COFF (lsn)),C1 ,0 ,TYP_NONE }, + {"flags2" ,FLDT_UINT64X ,OI (COFF (flags2)),C1 ,0 ,TYP_NONE }, + {"crtime" ,FLDT_TIMESTAMP ,OI (COFF (crtime)),C1 ,0 ,TYP_NONE }, + {"inumber" ,FLDT_INO ,OI (COFF (ino)),C1 ,0 ,TYP_NONE }, + {"uuid" ,FLDT_UUID ,OI (COFF (uuid)),C1 ,0 ,TYP_NONE }, + {NULL } +}; + +#define TOFF (f) bitize(offsetof(xfs_timestamp_t, t_ ## f))const field_t timestamp_flds[] = { {"sec" ,FLDT_TIME ,OI (TOFF (sec)),C1 ,0 ,TYP_NONE },
db/inode.h +3 -0
@@ -18,8 +18,11 @@extern const struct field inode_a_flds[];extern const struct field inode_core_flds[]; +extern const struct field inode_v3_flds[];extern const struct field inode_flds[]; +extern const struct field inode_crc_flds[];extern const struct field inode_hfld[]; +extern const struct field inode_crc_hfld[];extern const struct field inode_u_flds[];extern const struct field timestamp_flds[];
db/type.c +33 -1
@@ -48,7 +48,7 @@ static const cmdinfo_t type_cmd = {"type" ,NULL , type_f,0 ,1 ,1 ,N_ ("[newtype]" ), N_("set/show current data type"), NULL }; -const typ_t typtab[] = { +static const typ_t __typtab[] = { {TYP_AGF ,"agf" , handle_struct, agf_hfld }, {TYP_AGFL ,"agfl" , handle_struct, agfl_hfld }, { TYP_AGI, "agi", handle_struct, agi_hfld },
@@ -72,6 +72,38 @@ const typ_t typtab[] = { { TYP_NONE, NULL } }; +static const typ_t __typtab_crc[] = { + {TYP_AGF ,"agf" , handle_struct, agf_hfld }, + {TYP_AGFL ,"agfl" , handle_struct, agfl_crc_hfld }, + {TYP_AGI ,"agi" , handle_struct, agi_hfld }, + {TYP_ATTR ,"attr" , handle_struct, attr_hfld }, + {TYP_BMAPBTA ,"bmapbta" , handle_struct, bmapbta_crc_hfld }, + {TYP_BMAPBTD ,"bmapbtd" , handle_struct, bmapbtd_crc_hfld }, + {TYP_BNOBT ,"bnobt" , handle_struct, bnobt_crc_hfld }, + {TYP_CNTBT ,"cntbt" , handle_struct, cntbt_crc_hfld }, + {TYP_DATA ,"data" , handle_block,NULL }, + {TYP_DIR2 ,"dir2" , handle_struct, dir2_hfld }, + {TYP_DQBLK ,"dqblk" , handle_struct, dqblk_hfld }, + {TYP_INOBT ,"inobt" , handle_struct, inobt_crc_hfld }, + {TYP_INODATA ,"inodata" ,NULL ,NULL }, + {TYP_INODE ,"inode" , handle_struct, inode_crc_hfld }, + {TYP_LOG ,"log" ,NULL ,NULL }, + {TYP_RTBITMAP ,"rtbitmap" ,NULL ,NULL }, + {TYP_RTSUMMARY ,"rtsummary" ,NULL ,NULL }, + {TYP_SB ,"sb" , handle_struct, sb_hfld }, + {TYP_SYMLINK ,"symlink" , handle_string,NULL }, + {TYP_TEXT ,"text" , handle_text,NULL }, + {TYP_NONE ,NULL } +}; + +const typ_t *typtab = __typtab; + +void +type_set_tab_crc (void ) +{ + typtab = __typtab_crc; +} +static const typ_t *findtyp (char *name)
db/type.h +2 -1
@@ -43,9 +43,10 @@ typedef struct typpfunc_t pfunc;const struct field *fields; } typ_t; -extern const typ_t typtab[], *cur_typ; +extern const typ_t *typtab, *cur_typ;extern void type_init (void ); +extern void type_set_tab_crc (void );extern void handle_block (int action,const struct field *fields,int argc,char **argv); extern void handle_string(int action, const struct field *fields, int argc,
libxfs/util.c +0 -1
@@ -79,7 +79,6 @@ libxfs_ialloc(xfs_inode_t *ip;uint flags;int error; -int times;/* * Call the space management code to pick
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 30/48] xfsprogs: add crc format support to db
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 31/48 xfs_repair: always use incore header for directory block checks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Otherwise we get failures to validate the block on CRC enabled filesystems.
--- repair/phase6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
repair/phase6.c +1 -1
@@ -1849,7 +1849,7 @@ longform_dir2_check_leaf(if (!(leafhdr.magic ==XFS_DIR2_LEAF1_MAGIC || leafhdr.magic ==XFS_DIR3_LEAF1_MAGIC ) || leafhdr.forw || leafhdr.back || - leafhdr.count < leaf->hdr.stale || + leafhdr.count < leafhdr.stale || leafhdr.count >xfs_dir3_max_leaf_ents (mp, leaf) || (char *)&ents[leafhdr.count] > (char *)bestsp) {
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 31/48] xfs_repair: always use incore header for directory block checks
Quoted 6 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Otherwise we get failures to validate the block on CRC enabled filesystems.
Signed-off-by Dave Chinner <[email protected]>
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 32/48 xfs_db: convert directory parsing to use libxfs structure
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
xfs_db rolls it's own "opaque" directory types for the different block formats. All it cares about is where the headers end and the data starts, and none of the other details in the structures. Rather than duplicate this for the dir3 format, we already have perfectly good headers and abstraction functions for finding this information in libxfs. Using these means that the dir2 code used for printing fields, metadump and check need to be modified to use libxfs definitions.
--- db/check.c | 70 +++++++++++++++--------------- db/dir2.c | 133 ++++++++++++++++++++++++++++----------------------------- db/dir2.h | 25 ----------- db/dir2sf.c | 62 +++++++++++++-------------- db/metadump.c | 31 +++++++------- 5 files changed, 148 insertions(+), 173 deletions(-)
db/check.c +35 -35
@@ -278,9 +278,9 @@ static xfs_ino_t process_data_dir_v2(int *dot, int *dotdot, inodata_t *id, int v, xfs_dablk_t dabno, freetab_t **freetabp); -static xfs_dir2_data_free_t - *process_data_dir_v2_freefind (xfs_dir2_data_t *data, -xfs_dir2_data_unused_t *dup); +static xfs_dir2_data_free_t *process_data_dir_v2_freefind ( +struct xfs_dir2_data_hdr *data, +struct xfs_dir2_data_unused *dup);static void process_dir (xfs_dinode_t *dip,blkmap_t *blkmap,inodata_t *id); static int process_dir_v2(xfs_dinode_t *dip, blkmap_t *blkmap,
@@ -2188,11 +2188,11 @@ process_data_dir_v2(xfs_dir2_dataptr_t addr;xfs_dir2_data_free_t *bf;int bf_err; -xfs_dir2_block_t *block; +struct xfs_dir2_data_hdr *block;xfs_dir2_block_tail_t *btp =NULL ;inodata_t *cid;int count; -xfs_dir2_data_t *data; +struct xfs_dir2_data_hdr *data;xfs_dir2_db_t db;xfs_dir2_data_entry_t *dep;xfs_dir2_data_free_t *dfp;
@@ -2214,20 +2214,20 @@ process_data_dir_v2( data = iocur_top->data; block = iocur_top->data; -if (be32_to_cpu (block->hdr.magic) !=XFS_DIR2_BLOCK_MAGIC && -be32_to_cpu (data->hdr.magic) !=XFS_DIR2_DATA_MAGIC ) { +if (be32_to_cpu (block->magic) !=XFS_DIR2_BLOCK_MAGIC && +be32_to_cpu (data->magic) !=XFS_DIR2_DATA_MAGIC ) {if (!sflag || v)dbprintf (_ ("bad directory data magic # %#x for dir ino " "%lld block %d\n" ), -be32_to_cpu (data->hdr.magic), id->ino, dabno); +be32_to_cpu (data->magic), id->ino, dabno); error++;return NULLFSINO ; } db =xfs_dir2_da_to_db (mp, dabno); - bf = data->hdr.bestfree; - ptr = (char *)data->u; -if (be32_to_cpu (block->hdr.magic) ==XFS_DIR2_BLOCK_MAGIC ) { - btp =xfs_dir2_block_tail_p (mp, &block->hdr); + bf =xfs_dir3_data_bestfree_p (data); + ptr = (char *)xfs_dir3_data_unused_p (data); +if (be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC ) { + btp =xfs_dir2_block_tail_p (mp, block); lep =xfs_dir2_block_leaf_p (btp); endptr = (char *)lep;if (endptr <= ptr || endptr > (char *)btp) {
@@ -2372,7 +2372,7 @@ process_data_dir_v2( (*dot)++; } } -if (be32_to_cpu (data->hdr.magic) ==XFS_DIR2_BLOCK_MAGIC ) { +if (be32_to_cpu (data->magic) ==XFS_DIR2_BLOCK_MAGIC ) { endptr = (char *)data + mp->m_dirblksize;for (i = stale =0 ; lep && i <be32_to_cpu (btp->count); i++) {if ((char *)&lep[i] >= endptr) {
@@ -2404,9 +2404,8 @@ process_data_dir_v2( id->ino, dabno); error++; } -if (be32_to_cpu (data->hdr.magic) ==XFS_DIR2_BLOCK_MAGIC && - count !=be32_to_cpu (btp->count) - -be32_to_cpu (btp->stale)) { +if (be32_to_cpu (data->magic) ==XFS_DIR2_BLOCK_MAGIC && + count !=be32_to_cpu (btp->count) -be32_to_cpu (btp->stale)) {if (!sflag || v) dbprintf(_("dir %lld block %d bad block tail count %d " "(stale %d)\n"),
@@ -2414,7 +2413,7 @@ process_data_dir_v2( be32_to_cpu(btp->stale)); error++; } -if (be32_to_cpu (data->hdr.magic) ==XFS_DIR2_BLOCK_MAGIC && +if (be32_to_cpu (data->magic) ==XFS_DIR2_BLOCK_MAGIC && stale !=be32_to_cpu (btp->stale)) {if (!sflag || v) dbprintf(_("dir %lld block %d bad stale tail count %d\n"),
@@ -2439,18 +2438,19 @@ process_data_dir_v2(static xfs_dir2_data_free_t *process_data_dir_v2_freefind ( -xfs_dir2_data_t *data, +struct xfs_dir2_data_hdr *data,xfs_dir2_data_unused_t *dup) { -xfs_dir2_data_free_t *dfp; +struct xfs_dir2_data_free *bf; +struct xfs_dir2_data_free *dfp;xfs_dir2_data_aoff_t off; off = (xfs_dir2_data_aoff_t)((char *)dup - (char *)data); -if (be16_to_cpu (dup->length) <be16_to_cpu (data->hdr. - bestfree[XFS_DIR2_DATA_FD_COUNT -1 ].length)) + bf =xfs_dir3_data_bestfree_p (data); +if (be16_to_cpu (dup->length) < +be16_to_cpu (bf[XFS_DIR2_DATA_FD_COUNT -1 ].length))return NULL ; -for (dfp = &data->hdr.bestfree[0 ]; dfp < &data->hdr. - bestfree[XFS_DIR2_DATA_FD_COUNT ]; dfp++) { +for (dfp = bf; dfp < &bf[XFS_DIR2_DATA_FD_COUNT ]; dfp++) {if (be16_to_cpu (dfp->offset) ==0 )return NULL ;if (be16_to_cpu (dfp->offset) == off)
@@ -3421,20 +3421,20 @@ process_sf_dir_v2(int i8;xfs_ino_t lino;int offset; -xfs_dir2_sf_t *sf; +struct xfs_dir2_sf_hdr *sf;xfs_dir2_sf_entry_t *sfe;int v; - sf = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (dip); + sf = (struct xfs_dir2_sf_hdr *)XFS_DFORK_DPTR (dip);addlink_inode (id); v = verbose || id->ilist;if (v)dbprintf (_ ("dir %lld entry . %lld\n" ), id->ino, id->ino); (*dot)++; - sfe =xfs_dir2_sf_firstentry (&sf->hdr); + sfe =xfs_dir2_sf_firstentry (sf); offset =XFS_DIR3_DATA_FIRST_OFFSET (mp); -for (i = sf->hdr.count -1 , i8 =0 ; i >=0 ; i--) { -if ((__psint_t )sfe +xfs_dir2_sf_entsize (&sf->hdr,sfe->namelen) - +for (i = sf->count -1 , i8 =0 ; i >=0 ; i--) { +if ((__psint_t )sfe +xfs_dir2_sf_entsize (sf, sfe->namelen) - (__psint_t )sf >be64_to_cpu (dip->di_size)) {if (!sflag) dbprintf(_("dir %llu bad size in entry at %d\n"),
@@ -3443,7 +3443,7 @@ process_sf_dir_v2( error++;break ; } - lino =xfs_dir2_sfe_get_ino (&sf->hdr, sfe); + lino =xfs_dir2_sfe_get_ino (sf, sfe);if (lino >XFS_DIR2_MAX_SHORT_INUM ) i8++; cid =find_inode (lino,1 );
@@ -3473,8 +3473,8 @@ process_sf_dir_v2( } offset =xfs_dir2_sf_get_offset (sfe) + -xfs_dir2_sf_entsize (&sf->hdr, sfe->namelen); - sfe =xfs_dir2_sf_nextentry (&sf->hdr, sfe); +xfs_dir2_sf_entsize (sf, sfe->namelen); + sfe =xfs_dir2_sf_nextentry (sf, sfe); }if (i <0 && (__psint_t )sfe - (__psint_t )sf !=be64_to_cpu (dip->di_size)) {
@@ -3484,13 +3484,13 @@ process_sf_dir_v2( (uint)((char *)sfe - (char *)sf)); error++; } -if (offset + (sf->hdr.count +2 ) *sizeof (xfs_dir2_leaf_entry_t) + +if (offset + (sf->count +2 ) *sizeof (xfs_dir2_leaf_entry_t) +sizeof (xfs_dir2_block_tail_t) > mp->m_dirblksize) {if (!sflag)dbprintf (_ ("dir %llu offsets too high\n" ), id->ino); error++; } - lino =xfs_dir2_sf_get_parent_ino (&sf->hdr); + lino =xfs_dir2_sf_get_parent_ino (sf);if (lino >XFS_DIR2_MAX_SHORT_INUM ) i8++; cid =find_inode (lino,1 );
@@ -3504,11 +3504,11 @@ process_sf_dir_v2( }if (v)dbprintf (_ ("dir %lld entry .. %lld\n" ), id->ino, lino); -if (i8 != sf->hdr.i8count) { +if (i8 != sf->i8count) {if (!sflag)dbprintf (_ ("dir %lld i8count mismatch is %d should be " "%d\n" ), - id->ino, sf->hdr.i8count, i8); + id->ino, sf->i8count, i8); error++; } (*dotdot)++;
db/dir2.c +66 -67
327 lines not on this page · raw message
db/dir2.h +0 -25
@@ -31,31 +31,6 @@ extern const field_t da_blkinfo_flds[];extern const field_t da_node_entry_flds[];extern const field_t da_node_hdr_flds[]; -/* -* generic dir2 structures used by xfs_db -*/ -typedef union { -xfs_dir2_data_entry_t entry; -xfs_dir2_data_unused_t unused; -}xfs_dir2_data_union_t ; - -typedef struct xfs_dir2_data { -xfs_dir2_data_hdr_t hdr;/* magic XFS_DIR2_DATA_MAGIC */ -xfs_dir2_data_union_t u[1 ]; -}xfs_dir2_data_t ; - -typedef struct xfs_dir2_block { -xfs_dir2_data_hdr_t hdr;/* magic XFS_DIR2_BLOCK_MAGIC */ -xfs_dir2_data_union_t u[1 ]; -xfs_dir2_leaf_entry_t leaf[1 ]; -xfs_dir2_block_tail_t tail; -}xfs_dir2_block_t ; - -typedef struct xfs_dir2_sf { -xfs_dir2_sf_hdr_t hdr;/* shortform header */ -xfs_dir2_sf_entry_t list[1 ];/* shortform entries */ -}xfs_dir2_sf_t ; -static inline xfs_dir2_inou_t *xfs_dir2_sf_inumberp (xfs_dir2_sf_entry_t *sfep) {return (xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen];
db/dir2sf.c +31 -31
137 lines not on this page · raw message
db/metadump.c +16 -15
@@ -906,12 +906,12 @@ static voidobfuscate_sf_dir ( xfs_dinode_t *dip) { -xfs_dir2_sf_t *sfp; +struct xfs_dir2_sf_hdr *sfp;xfs_dir2_sf_entry_t *sfep;__uint64_t ino_dir_size;int i; - sfp = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (dip); + sfp = (struct xfs_dir2_sf_hdr *)XFS_DFORK_DPTR (dip); ino_dir_size =be64_to_cpu (dip->di_size);if (ino_dir_size >XFS_DFORK_DSIZE (dip, mp)) { ino_dir_size =XFS_DFORK_DSIZE (dip, mp);
@@ -920,8 +920,8 @@ obfuscate_sf_dir( (long long)cur_ino); } - sfep =xfs_dir2_sf_firstentry (&sfp->hdr); -for (i =0 ; (i < sfp->hdr.count) && + sfep =xfs_dir2_sf_firstentry (sfp); +for (i =0 ; (i < sfp->count) && ((char *)sfep - (char *)sfp < ino_dir_size); i++) {/*
@@ -934,27 +934,27 @@ obfuscate_sf_dir(if (show_warnings)print_warning ("zero length entry in dir inode " "%llu" , (long long )cur_ino); -if (i != sfp->hdr.count -1 ) +if (i != sfp->count -1 )break ; namelen = ino_dir_size - ((char *)&sfep->name[0 ] - (char *)sfp); }else if ((char *)sfep - (char *)sfp + -xfs_dir2_sf_entsize (&sfp->hdr, sfep->namelen) > +xfs_dir2_sf_entsize (sfp, sfep->namelen) > ino_dir_size) {if (show_warnings)print_warning ("entry length in dir inode %llu " "overflows space" , (long long )cur_ino); -if (i != sfp->hdr.count -1 ) +if (i != sfp->count -1 )break ; namelen = ino_dir_size - ((char *)&sfep->name[0 ] - (char *)sfp); } -generate_obfuscated_name (xfs_dir2_sfe_get_ino (&sfp->hdr, sfep), +generate_obfuscated_name (xfs_dir2_sfe_get_ino (sfp, sfep), namelen, &sfep->name[0 ]); sfep = (xfs_dir2_sf_entry_t *)((char *)sfep + -xfs_dir2_sf_entsize (&sfp->hdr, namelen)); +xfs_dir2_sf_entsize (sfp, namelen)); } }
@@ -1101,6 +1101,9 @@ obfuscate_dir_data_blocks(if (dir_data.block_index ==0 ) {int wantmagic; +struct xfs_dir2_data_hdr *datahdr; + + datahdr = (struct xfs_dir2_data_hdr *)block;if (offset % mp->m_dirblkfsbs !=0 )return ;/* corrupted, leave it alone */
@@ -1110,10 +1113,8 @@ obfuscate_dir_data_blocks(if (is_block_format) {xfs_dir2_leaf_entry_t *blp;xfs_dir2_block_tail_t *btp; -xfs_dir2_block_t *blk; - blk = (xfs_dir2_block_t *)block; - btp =xfs_dir2_block_tail_p (mp, &blk->hdr); + btp =xfs_dir2_block_tail_p (mp, datahdr); blp =xfs_dir2_block_leaf_p (btp);if ((char *)blp > (char *)btp) blp = (xfs_dir2_leaf_entry_t *)btp;
@@ -1125,10 +1126,10 @@ obfuscate_dir_data_blocks( mp->m_sb.sb_blocklog; wantmagic =XFS_DIR2_DATA_MAGIC ; } - dir_data.offset_to_entry = offsetof(xfs_dir2_data_t , u); + dir_data.offset_to_entry = +xfs_dir3_data_entry_offset (datahdr); -if (be32_to_cpu (((xfs_dir2_data_hdr_t *)block)->magic) != - wantmagic) { +if (be32_to_cpu (datahdr->magic) != wantmagic) {if (show_warnings) print_warning("invalid magic in dir " "inode %llu block %ld",
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 32/48] xfs_db: convert directory parsing to use libxfs structure
Quoted 11 lines · Dave Chinner
From: Dave Chinner <[email protected]>
xfs_dbrolls it's own "opaque" directory types for the different block formats. All it cares about is where the headers end and the data starts, and none of the other details in the structures. Rather than duplicate this for the dir3 format, we already have perfectly good headers and abstraction functions for finding this information in libxfs. Using these means that the dir2 code used for printing fields, metadump and check need to be modified to use libxfs definitions.
Quoted 1 line
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 33/48 xfs_db: factor some common dir2 field parsing code.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Why duplicate it?
--- db/dir2.c | 172 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 84 insertions(+), 88 deletions(-)
db/dir2.c +84 -88
@@ -189,6 +189,72 @@ const field_t da_node_hdr_flds[] = { { NULL } }; +/* +* Worker functions shared between either dir2/dir3 or block/data formats +*/ +static int +__dir2_block_tail_offset ( +struct xfs_dir2_data_hdr *block, +int startoff, +int idx) +{ +struct xfs_dir2_block_tail *btp; + +ASSERT (startoff ==0 ); +ASSERT (idx ==0 ); + btp =xfs_dir2_block_tail_p (mp, block); +return bitize ((int )((char *)btp - (char *)block)); +} + +static int +__dir2_data_entries_count ( +char *ptr, +char *endptr) +{ +int i; + +for (i =0 ; ptr < endptr; i++) { +struct xfs_dir2_data_entry *dep; +struct xfs_dir2_data_unused *dup; + + dup = (xfs_dir2_data_unused_t *)ptr; +if (be16_to_cpu (dup->freetag) ==XFS_DIR2_DATA_FREE_TAG ) + ptr +=be16_to_cpu (dup->length); +else { + dep = (xfs_dir2_data_entry_t *)ptr; + ptr +=xfs_dir2_data_entsize (dep->namelen); + } + } +return i; +} + +static char * +__dir2_data_entry_offset ( +char *ptr, +char *endptr, +int idx) +{ +int i; + +for (i =0 ; i < idx; i++) { +struct xfs_dir2_data_entry *dep; +struct xfs_dir2_data_unused *dup; + +ASSERT (ptr < endptr); + dup = (xfs_dir2_data_unused_t *)ptr; +if (be16_to_cpu (dup->freetag) ==XFS_DIR2_DATA_FREE_TAG ) + ptr +=be16_to_cpu (dup->length); +else { + dep = (xfs_dir2_data_entry_t *)ptr; + ptr +=xfs_dir2_data_entsize (dep->namelen); + } + } +return ptr; +} + +/* +* Block format functions +*/ static int dir2_block_hdr_count( void *obj,
@@ -254,86 +320,50 @@ dir2_block_tail_offset( int startoff, int idx) { -struct xfs_dir2_data_hdr *block; -struct xfs_dir2_block_tail *btp; +struct xfs_dir2_data_hdr *block = obj; -ASSERT (startoff ==0 ); -ASSERT (idx ==0 ); - block = obj;ASSERT (be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC ); - btp =xfs_dir2_block_tail_p (mp, block); -return bitize ((int )((char *)btp - (char *)block)); +return __dir2_block_tail_offset (block, startoff, idx); } -/*ARGSUSED*/ static int dir2_block_u_count (void *obj,int startoff) { -struct xfs_dir2_data_hdr *block; +struct xfs_dir2_data_hdr *block = obj;struct xfs_dir2_block_tail *btp; -char *endptr; -int i; -char *ptr;ASSERT (startoff ==0 ); - block = obj;if (be32_to_cpu (block->magic) !=XFS_DIR2_BLOCK_MAGIC )return 0 ; - btp =xfs_dir2_block_tail_p (mp, block); - ptr = (char *)xfs_dir3_data_unused_p (block); - endptr = (char *)xfs_dir2_block_leaf_p (btp); -for (i =0 ; ptr < endptr; i++) { -struct xfs_dir2_data_entry *dep; -struct xfs_dir2_data_unused *dup; - dup = (xfs_dir2_data_unused_t *)ptr; -if (be16_to_cpu (dup->freetag) ==XFS_DIR2_DATA_FREE_TAG ) - ptr +=be16_to_cpu (dup->length); -else { - dep = (xfs_dir2_data_entry_t *)ptr; - ptr +=xfs_dir2_data_entsize (dep->namelen); - } - } -return i; + btp =xfs_dir2_block_tail_p (mp, block); +return __dir2_data_entries_count ((char *)xfs_dir3_data_unused_p (block), + (char *)xfs_dir2_block_leaf_p (btp)); } -/*ARGSUSED*/ static int dir2_block_u_offset (void *obj,int startoff,int idx) { -struct xfs_dir2_data_hdr *block; +struct xfs_dir2_data_hdr *block = obj;struct xfs_dir2_block_tail *btp; -char *endptr; -int i;char *ptr;ASSERT (startoff ==0 ); - block = obj;ASSERT (be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC ); btp =xfs_dir2_block_tail_p (mp, block); - ptr = (char *)xfs_dir3_data_unused_p (block); - endptr = (char *)xfs_dir2_block_leaf_p (btp); -for (i =0 ; i < idx; i++) { -struct xfs_dir2_data_entry *dep; -struct xfs_dir2_data_unused *dup; - -ASSERT (ptr < endptr); - dup = (xfs_dir2_data_unused_t *)ptr; -if (be16_to_cpu (dup->freetag) ==XFS_DIR2_DATA_FREE_TAG ) - ptr +=be16_to_cpu (dup->length); -else { - dep = (xfs_dir2_data_entry_t *)ptr; - ptr +=xfs_dir2_data_entsize (dep->namelen); - } - } + ptr =__dir2_data_entry_offset ((char *)xfs_dir3_data_unused_p (block), + (char *)xfs_dir2_block_leaf_p (btp), idx);return bitize ((int )(ptr - (char *)block)); } +/* +* Data block format functions +*/ static int dir2_data_union_freetag_count( void *obj,
@@ -489,66 +519,32 @@ dir2_data_u_count( void *obj, int startoff) { -struct xfs_dir2_data_hdr *data; -char *endptr; -int i; -char *ptr; +struct xfs_dir2_data_hdr *data = obj;ASSERT (startoff ==0 ); - data = obj;if (be32_to_cpu (data->magic) !=XFS_DIR2_DATA_MAGIC )return 0 ; - ptr = (char *)xfs_dir3_data_unused_p (data); - endptr = (char *)data + mp->m_dirblksize; -for (i =0 ; ptr < endptr; i++) { -struct xfs_dir2_data_entry *dep; -struct xfs_dir2_data_unused *dup; - dup = (xfs_dir2_data_unused_t *)ptr; -if (be16_to_cpu (dup->freetag) ==XFS_DIR2_DATA_FREE_TAG ) - ptr +=be16_to_cpu (dup->length); -else { - dep = (xfs_dir2_data_entry_t *)ptr; - ptr +=xfs_dir2_data_entsize (dep->namelen); - } - } -return i; +return __dir2_data_entries_count ((char *)xfs_dir3_data_unused_p (data), + (char *)data + mp->m_dirblksize); } -/*ARGSUSED*/ static int dir2_data_u_offset (void *obj,int startoff,int idx) { -struct xfs_dir2_data_hdr *data; -char *endptr; -int i; +struct xfs_dir2_data_hdr *data = obj;char *ptr;ASSERT (startoff ==0 ); - data = obj;ASSERT (be32_to_cpu (data->magic) ==XFS_DIR2_DATA_MAGIC ); - ptr = (char *)xfs_dir3_data_unused_p (data); - endptr = (char *)data + mp->m_dirblksize; -for (i =0 ; i < idx; i++) { -struct xfs_dir2_data_entry *dep; -struct xfs_dir2_data_unused *dup; - -ASSERT (ptr < endptr); - dup = (xfs_dir2_data_unused_t *)ptr; -if (be16_to_cpu (dup->freetag) ==XFS_DIR2_DATA_FREE_TAG ) - ptr +=be16_to_cpu (dup->length); -else { - dep = (xfs_dir2_data_entry_t *)ptr; - ptr +=xfs_dir2_data_entsize (dep->namelen); - } - } + ptr =__dir2_data_entry_offset ((char *)xfs_dir3_data_unused_p (data), + (char *)data + mp->m_dirblksize, idx);return bitize ((int )(ptr - (char *)data)); } -/*ARGSUSED*/ int dir2_data_union_size( void *obj,
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 33/48] xfs_db: factor some common dir2 field parsing code.
Quoted 5 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Why duplicate it?
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 34/48 xfs_db: update field printing for dir crc format changes.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Note that this also requires changing the type parsing to only allow dir3 data block parsing on CRC enabled filesystems. This is slighly more complex than it needs to be because of the way the type table is walked and the assumption that all the entries are in type number order.
--- db/dir2.c | 319 +++++++++++++++++++++++++++++++++++++++++++++++++----------- db/dir2.h | 33 +++++-- db/field.c | 21 ++++ db/field.h | 14 +++ db/type.c | 12 ++- 5 files changed, 333 insertions(+), 66 deletions(-)
db/dir2.c +264 -55
@@ -260,24 +260,34 @@ dir2_block_hdr_count( void *obj, int startoff) { -struct xfs_dir2_data_hdr *block; +struct xfs_dir2_data_hdr *block = obj;ASSERT (startoff ==0 ); - block = obj;return be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC ; }static int +dir3_block_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_dir2_data_hdr *block = obj; + +ASSERT (startoff ==0 ); +return be32_to_cpu (block->magic) ==XFS_DIR3_BLOCK_MAGIC ; +} + +static int dir2_block_leaf_count (void *obj,int startoff) { -struct xfs_dir2_data_hdr *block; +struct xfs_dir2_data_hdr *block = obj;struct xfs_dir2_block_tail *btp;ASSERT (startoff ==0 ); - block = obj; -if (be32_to_cpu (block->magic) !=XFS_DIR2_BLOCK_MAGIC ) +if (be32_to_cpu (block->magic) !=XFS_DIR2_BLOCK_MAGIC && +be32_to_cpu (block->magic) !=XFS_DIR3_BLOCK_MAGIC )return 0 ; btp =xfs_dir2_block_tail_p (mp, block);return be32_to_cpu (btp->count);
@@ -289,13 +299,13 @@ dir2_block_leaf_offset( int startoff, int idx) { -struct xfs_dir2_data_hdr *block; +struct xfs_dir2_data_hdr *block = obj;struct xfs_dir2_block_tail *btp;struct xfs_dir2_leaf_entry *lep;ASSERT (startoff ==0 ); - block = obj; -ASSERT (be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC ); +ASSERT (be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC || +be32_to_cpu (block->magic) ==XFS_DIR3_BLOCK_MAGIC ); btp =xfs_dir2_block_tail_p (mp, block); lep =xfs_dir2_block_leaf_p (btp) + idx;return bitize ((int )((char *)lep - (char *)block));
@@ -306,14 +316,23 @@ dir2_block_tail_count( void *obj, int startoff) { -struct xfs_dir2_data_hdr *block; +struct xfs_dir2_data_hdr *block = obj;ASSERT (startoff ==0 ); - block = obj;return be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC ; } -/*ARGSUSED*/ +static int +dir3_block_tail_count ( +void *obj, +int startoff) +{ +struct xfs_dir2_data_hdr *block = obj; + +ASSERT (startoff ==0 ); +return be32_to_cpu (block->magic) ==XFS_DIR3_BLOCK_MAGIC ; +} + static int dir2_block_tail_offset( void *obj,
@@ -322,7 +341,8 @@ dir2_block_tail_offset( {struct xfs_dir2_data_hdr *block = obj; -ASSERT (be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC ); +ASSERT (be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC || +be32_to_cpu (block->magic) ==XFS_DIR3_BLOCK_MAGIC );return __dir2_block_tail_offset (block, startoff, idx); }
@@ -335,7 +355,8 @@ dir2_block_u_count(struct xfs_dir2_block_tail *btp;ASSERT (startoff ==0 ); -if (be32_to_cpu (block->magic) !=XFS_DIR2_BLOCK_MAGIC ) +if (be32_to_cpu (block->magic) !=XFS_DIR2_BLOCK_MAGIC && +be32_to_cpu (block->magic) !=XFS_DIR3_BLOCK_MAGIC )return 0 ; btp =xfs_dir2_block_tail_p (mp, block);
@@ -354,7 +375,8 @@ dir2_block_u_offset(char *ptr;ASSERT (startoff ==0 ); -ASSERT (be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC ); +ASSERT (be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC || +be32_to_cpu (block->magic) ==XFS_DIR3_BLOCK_MAGIC ); btp =xfs_dir2_block_tail_p (mp, block); ptr =__dir2_data_entry_offset ((char *)xfs_dir3_data_unused_p (block), (char *)xfs_dir2_block_leaf_p (btp), idx);
@@ -479,7 +501,6 @@ dir2_data_union_tag_count(return end <= (char *)obj + mp->m_dirblksize; } -/*ARGSUSED*/ static int dir2_data_union_tag_offset( void *obj,
@@ -500,20 +521,28 @@ dir2_data_union_tag_offset( (char *)dep)); } -/*ARGSUSED*/ static int dir2_data_hdr_count (void *obj,int startoff) { -struct xfs_dir2_data_hdr *data; +struct xfs_dir2_data_hdr *data = obj;ASSERT (startoff ==0 ); - data = obj;return be32_to_cpu (data->magic) ==XFS_DIR2_DATA_MAGIC ; } -/*ARGSUSED*/ +static int +dir3_data_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_dir2_data_hdr *data = obj; + +ASSERT (startoff ==0 ); +return be32_to_cpu (data->magic) ==XFS_DIR3_DATA_MAGIC ; +} + static int dir2_data_u_count( void *obj,
@@ -522,7 +551,8 @@ dir2_data_u_count(struct xfs_dir2_data_hdr *data = obj;ASSERT (startoff ==0 ); -if (be32_to_cpu (data->magic) !=XFS_DIR2_DATA_MAGIC ) +if (be32_to_cpu (data->magic) !=XFS_DIR2_DATA_MAGIC && +be32_to_cpu (data->magic) !=XFS_DIR3_DATA_MAGIC )return 0 ; return __dir2_data_entries_count((char *)xfs_dir3_data_unused_p(data),
@@ -539,7 +569,8 @@ dir2_data_u_offset(char *ptr;ASSERT (startoff ==0 ); -ASSERT (be32_to_cpu (data->magic) ==XFS_DIR2_DATA_MAGIC ); +ASSERT (be32_to_cpu (data->magic) ==XFS_DIR2_DATA_MAGIC || +be32_to_cpu (data->magic) ==XFS_DIR3_DATA_MAGIC ); ptr =__dir2_data_entry_offset ((char *)xfs_dir3_data_unused_p (data), (char *)data + mp->m_dirblksize, idx);return bitize ((int )(ptr - (char *)data));
@@ -565,160 +596,236 @@ dir2_data_union_size( } } -/*ARGSUSED*/ +/* +* Free block functions +*/ static int dir2_free_bests_count (void *obj,int startoff) { -struct xfs_dir2_free *free; +struct xfs_dir2_free *free = obj;ASSERT (startoff ==0 ); - free = obj;if (be32_to_cpu (free->hdr.magic) !=XFS_DIR2_FREE_MAGIC )return 0 ;return be32_to_cpu (free->hdr.nvalid); } -/*ARGSUSED*/ +static int +dir3_free_bests_count ( +void *obj, +int startoff) +{ +struct xfs_dir3_free *free = obj; + +ASSERT (startoff ==0 ); +if (be32_to_cpu (free->hdr.hdr.magic) !=XFS_DIR3_FREE_MAGIC ) +return 0 ; +return be32_to_cpu (free->hdr.nvalid); +} +static int dir2_free_hdr_count (void *obj,int startoff) { -struct xfs_dir2_free *free; +struct xfs_dir2_free *free = obj;ASSERT (startoff ==0 ); - free = obj;return be32_to_cpu (free->hdr.magic) ==XFS_DIR2_FREE_MAGIC ; } -/*ARGSUSED*/ +static int +dir3_free_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_dir3_free *free = obj; + +ASSERT (startoff ==0 ); +return be32_to_cpu (free->hdr.hdr.magic) ==XFS_DIR3_FREE_MAGIC ; +} + +/* +* Leaf block functions +*/ static int dir2_leaf_bests_count (void *obj,int startoff) { -struct xfs_dir2_leaf *leaf; +struct xfs_dir2_leaf *leaf = obj;struct xfs_dir2_leaf_tail *ltp;ASSERT (startoff ==0 ); - leaf = obj; -if (be16_to_cpu (leaf->hdr.info.magic) !=XFS_DIR2_LEAF1_MAGIC ) +if (be16_to_cpu (leaf->hdr.info.magic) !=XFS_DIR2_LEAF1_MAGIC && +be16_to_cpu (leaf->hdr.info.magic) !=XFS_DIR3_LEAF1_MAGIC )return 0 ; ltp =xfs_dir2_leaf_tail_p (mp, leaf);return be32_to_cpu (ltp->bestcount); } -/*ARGSUSED*/ static int dir2_leaf_bests_offset (void *obj,int startoff,int idx) { -struct xfs_dir2_leaf *leaf; +struct xfs_dir2_leaf *leaf = obj;struct xfs_dir2_leaf_tail *ltp;__be16 *lbp;ASSERT (startoff ==0 ); - leaf = obj; -ASSERT (be16_to_cpu (leaf->hdr.info.magic) ==XFS_DIR2_LEAF1_MAGIC ); +ASSERT (be16_to_cpu (leaf->hdr.info.magic) ==XFS_DIR2_LEAF1_MAGIC || +be16_to_cpu (leaf->hdr.info.magic) ==XFS_DIR3_LEAF1_MAGIC ); ltp =xfs_dir2_leaf_tail_p (mp, leaf); lbp =xfs_dir2_leaf_bests_p (ltp) + idx;return bitize ((int )((char *)lbp - (char *)leaf)); } -/*ARGSUSED*/ static int dir2_leaf_ents_count (void *obj,int startoff) { -struct xfs_dir2_leaf *leaf; +struct xfs_dir2_leaf *leaf = obj;ASSERT (startoff ==0 ); - leaf = obj;if (be16_to_cpu (leaf->hdr.info.magic) !=XFS_DIR2_LEAF1_MAGIC &&be16_to_cpu (leaf->hdr.info.magic) !=XFS_DIR2_LEAFN_MAGIC )return 0 ;return be16_to_cpu (leaf->hdr.count); } -/*ARGSUSED*/ +static int +dir3_leaf_ents_count ( +void *obj, +int startoff) +{ +struct xfs_dir3_leaf *leaf = obj; + +ASSERT (startoff ==0 ); +if (be16_to_cpu (leaf->hdr.info.hdr.magic) !=XFS_DIR3_LEAF1_MAGIC && +be16_to_cpu (leaf->hdr.info.hdr.magic) !=XFS_DIR3_LEAFN_MAGIC ) +return 0 ; +return be16_to_cpu (leaf->hdr.count); +} +static int dir2_leaf_hdr_count (void *obj,int startoff) { -struct xfs_dir2_leaf *leaf; +struct xfs_dir2_leaf *leaf = obj;ASSERT (startoff ==0 ); - leaf = obj;return be16_to_cpu (leaf->hdr.info.magic) ==XFS_DIR2_LEAF1_MAGIC ||be16_to_cpu (leaf->hdr.info.magic) ==XFS_DIR2_LEAFN_MAGIC ; } -/*ARGSUSED*/ +static int +dir3_leaf_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_dir3_leaf *leaf = obj; + +ASSERT (startoff ==0 ); +return be16_to_cpu (leaf->hdr.info.hdr.magic) ==XFS_DIR3_LEAF1_MAGIC || +be16_to_cpu (leaf->hdr.info.hdr.magic) ==XFS_DIR3_LEAFN_MAGIC ; +} +static int dir2_leaf_tail_count (void *obj,int startoff) { -struct xfs_dir2_leaf *leaf; +struct xfs_dir2_leaf *leaf = obj;ASSERT (startoff ==0 ); - leaf = obj;return be16_to_cpu (leaf->hdr.info.magic) ==XFS_DIR2_LEAF1_MAGIC ; } -/*ARGSUSED*/ +static int +dir3_leaf_tail_count ( +void *obj, +int startoff) +{ +struct xfs_dir3_leaf *leaf = obj; + +ASSERT (startoff ==0 ); +return be16_to_cpu (leaf->hdr.info.hdr.magic) ==XFS_DIR3_LEAF1_MAGIC ; +} +static int dir2_leaf_tail_offset (void *obj,int startoff,int idx) { -struct xfs_dir2_leaf *leaf; +struct xfs_dir2_leaf *leaf = obj;struct xfs_dir2_leaf_tail *ltp;ASSERT (startoff ==0 );ASSERT (idx ==0 ); - leaf = obj; -ASSERT (be16_to_cpu (leaf->hdr.info.magic) ==XFS_DIR2_LEAF1_MAGIC ); +ASSERT (be16_to_cpu (leaf->hdr.info.magic) ==XFS_DIR2_LEAF1_MAGIC || +be16_to_cpu (leaf->hdr.info.magic) ==XFS_DIR3_LEAF1_MAGIC ); ltp =xfs_dir2_leaf_tail_p (mp, leaf);return bitize ((int )((char *)ltp - (char *)leaf)); } -/*ARGSUSED*/ +/* +* Node format functions +*/ static int dir2_node_btree_count (void *obj,int startoff) { -xfs_da_intnode_t *node; +xfs_da_intnode_t *node = obj;ASSERT (startoff ==0 ); - node = obj;if (be16_to_cpu (node->hdr.info.magic) !=XFS_DA_NODE_MAGIC )return 0 ;return be16_to_cpu (node->hdr.__count); } -/*ARGSUSED*/ +static int +dir3_node_btree_count ( +void *obj, +int startoff) +{ +struct xfs_da3_intnode *node = obj; + +ASSERT (startoff ==0 ); +if (be16_to_cpu (node->hdr.info.hdr.magic) !=XFS_DA3_NODE_MAGIC ) +return 0 ; +return be16_to_cpu (node->hdr.__count); +} +static int dir2_node_hdr_count (void *obj,int startoff) { -struct xfs_da_intnode *node; +struct xfs_da_intnode *node = obj;ASSERT (startoff ==0 ); - node = obj;return be16_to_cpu (node->hdr.info.magic) ==XFS_DA_NODE_MAGIC ; } -/*ARGSUSED*/ +static int +dir3_node_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_da3_intnode *node = obj; + +ASSERT (startoff ==0 ); +return be16_to_cpu (node->hdr.info.hdr.magic) ==XFS_DA3_NODE_MAGIC ; +} + int dir2_size( void *obj,
@@ -727,3 +834,105 @@ dir2_size( {return bitize (mp->m_dirblksize); } + +/* +* CRC enabled structure definitions +*/ +const field_t dir3_hfld[] = { + {"" ,FLDT_DIR3 ,OI (0 ),C1 ,0 ,TYP_NONE }, + {NULL } +}; + +#define B3OFF (f) bitize(offsetof(struct xfs_dir3_data_hdr, f)) +#define D3OFF (f) bitize(offsetof(struct xfs_dir3_data_hdr, f)) +#define F3OFF (f) bitize(offsetof(struct xfs_dir3_free, f)) +#define L3OFF (f) bitize(offsetof(struct xfs_dir3_leaf, f)) +#define N3OFF (f) bitize(offsetof(struct xfs_da3_intnode, f)) +const field_t dir3_flds[] = { + {"bhdr" ,FLDT_DIR3_DATA_HDR ,OI (B3OFF (hdr)), dir3_block_hdr_count, +FLD_COUNT ,TYP_NONE }, + {"bu" ,FLDT_DIR2_DATA_UNION , dir2_block_u_offset, dir2_block_u_count, +FLD_ARRAY |FLD_OFFSET |FLD_COUNT ,TYP_NONE }, + {"bleaf" ,FLDT_DIR2_LEAF_ENTRY , dir2_block_leaf_offset, + dir2_block_leaf_count,FLD_ARRAY |FLD_OFFSET |FLD_COUNT ,TYP_NONE }, + {"btail" ,FLDT_DIR2_BLOCK_TAIL , dir2_block_tail_offset, + dir3_block_tail_count,FLD_OFFSET |FLD_COUNT ,TYP_NONE }, + {"dhdr" ,FLDT_DIR3_DATA_HDR ,OI (D3OFF (hdr)), dir3_data_hdr_count, +FLD_COUNT ,TYP_NONE }, + {"du" ,FLDT_DIR2_DATA_UNION , dir2_data_u_offset, dir2_data_u_count, +FLD_ARRAY |FLD_OFFSET |FLD_COUNT ,TYP_NONE }, + {"lhdr" ,FLDT_DIR3_LEAF_HDR ,OI (L3OFF (hdr)), dir3_leaf_hdr_count, +FLD_COUNT ,TYP_NONE }, + {"lbests" ,FLDT_DIR2_DATA_OFF , dir2_leaf_bests_offset, + dir2_leaf_bests_count,FLD_ARRAY |FLD_OFFSET |FLD_COUNT ,TYP_NONE }, + {"lents" ,FLDT_DIR2_LEAF_ENTRY ,OI (L3OFF (__ents)), dir3_leaf_ents_count, +FLD_ARRAY |FLD_COUNT ,TYP_NONE }, + {"ltail" ,FLDT_DIR2_LEAF_TAIL , dir2_leaf_tail_offset, + dir3_leaf_tail_count,FLD_OFFSET |FLD_COUNT ,TYP_NONE }, + {"nhdr" ,FLDT_DA3_NODE_HDR ,OI (N3OFF (hdr)), dir3_node_hdr_count, +FLD_COUNT ,TYP_NONE }, + {"nbtree" ,FLDT_DA_NODE_ENTRY ,OI (N3OFF (__btree)), dir3_node_btree_count, +FLD_ARRAY |FLD_COUNT ,TYP_NONE }, + {"fhdr" ,FLDT_DIR3_FREE_HDR ,OI (F3OFF (hdr)), dir3_free_hdr_count, +FLD_COUNT ,TYP_NONE }, + {"fbests" ,FLDT_DIR2_DATA_OFFNZ ,OI (F3OFF (bests)), + dir3_free_bests_count,FLD_ARRAY |FLD_COUNT ,TYP_NONE }, + {NULL } +}; + +#define DBH3OFF (f) bitize(offsetof(struct xfs_dir3_blk_hdr, f)) +const field_t dir3_blkhdr_flds[] = { + {"magic" ,FLDT_UINT32X ,OI (DBH3OFF (magic)),C1 ,0 ,TYP_NONE }, + {"crc" ,FLDT_UINT32X ,OI (DBH3OFF (crc)),C1 ,0 ,TYP_NONE }, + {"bno" ,FLDT_DFSBNO ,OI (DBH3OFF (blkno)),C1 ,0 ,TYP_BMAPBTD }, + {"lsn" ,FLDT_UINT64X ,OI (DBH3OFF (lsn)),C1 ,0 ,TYP_NONE }, + {"uuid" ,FLDT_UUID ,OI (DBH3OFF (uuid)),C1 ,0 ,TYP_NONE }, + {"owner" ,FLDT_INO ,OI (DBH3OFF (owner)),C1 ,0 ,TYP_NONE }, + {NULL } +}; + +#define DH3OFF (f) bitize(offsetof(struct xfs_dir3_data_hdr, f)) +const field_t dir3_data_hdr_flds[] = { + {"hdr" ,FLDT_DIR3_BLKHDR ,OI (DH3OFF (hdr)),C1 ,0 ,TYP_NONE }, + {"bestfree" ,FLDT_DIR2_DATA_FREE ,OI (DH3OFF (best_free)), +CI (XFS_DIR2_DATA_FD_COUNT ),FLD_ARRAY ,TYP_NONE }, + {NULL } +}; + +#define LH3OFF (f) bitize(offsetof(struct xfs_dir3_leaf_hdr, f)) +const field_t dir3_leaf_hdr_flds[] = { + {"info" ,FLDT_DA3_BLKINFO ,OI (LH3OFF (info)),C1 ,0 ,TYP_NONE }, + {"count" ,FLDT_UINT16D ,OI (LH3OFF (count)),C1 ,0 ,TYP_NONE }, + {"stale" ,FLDT_UINT16D ,OI (LH3OFF (stale)),C1 ,0 ,TYP_NONE }, + {NULL } +}; + +#define FH3OFF (f) bitize(offsetof(struct xfs_dir3_free_hdr, f)) +const field_t dir3_free_hdr_flds[] = { + {"hdr" ,FLDT_DIR3_BLKHDR ,OI (FH3OFF (hdr)),C1 ,0 ,TYP_NONE }, + {"firstdb" ,FLDT_INT32D ,OI (FH3OFF (firstdb)),C1 ,0 ,TYP_NONE }, + {"nvalid" ,FLDT_INT32D ,OI (FH3OFF (nvalid)),C1 ,0 ,TYP_NONE }, + {"nused" ,FLDT_INT32D ,OI (FH3OFF (nused)),C1 ,0 ,TYP_NONE }, + {NULL } +}; + + +#define DB3OFF (f) bitize(offsetof(struct xfs_da3_blkinfo, f)) +const field_t da3_blkinfo_flds[] = { + {"hdr" ,FLDT_DA_BLKINFO ,OI (DB3OFF (hdr)),C1 ,0 ,TYP_NONE }, + {"crc" ,FLDT_UINT32X ,OI (DB3OFF (crc)),C1 ,0 ,TYP_NONE }, + {"bno" ,FLDT_DFSBNO ,OI (DB3OFF (blkno)),C1 ,0 ,TYP_BMAPBTD }, + {"lsn" ,FLDT_UINT64X ,OI (DB3OFF (lsn)),C1 ,0 ,TYP_NONE }, + {"uuid" ,FLDT_UUID ,OI (DB3OFF (uuid)),C1 ,0 ,TYP_NONE }, + {"owner" ,FLDT_INO ,OI (DB3OFF (owner)),C1 ,0 ,TYP_NONE }, + {NULL } +}; + +#define H3OFF (f) bitize(offsetof(struct xfs_da3_node_hdr, f)) +const field_t da3_node_hdr_flds[] = { + {"info" ,FLDT_DA3_BLKINFO ,OI (H3OFF (info)),C1 ,0 ,TYP_NONE }, + {"count" ,FLDT_UINT16D ,OI (H3OFF (__count)),C1 ,0 ,TYP_NONE }, + {"level" ,FLDT_UINT16D ,OI (H3OFF (__level)),C1 ,0 ,TYP_NONE }, + {"pad" ,FLDT_UINT32D ,OI (H3OFF (__pad32)),C1 ,0 ,TYP_NONE }, + {NULL } +};
db/dir2.h +27 -6
@@ -16,21 +16,42 @@* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -extern const field_t dir2_flds[]; -extern const field_t dir2_hfld[]; +/* +* common types across directory formats +*/ extern const field_t dir2_block_tail_flds[];extern const field_t dir2_data_free_flds[]; -extern const field_t dir2_data_hdr_flds[];extern const field_t dir2_data_union_flds[]; -extern const field_t dir2_free_hdr_flds[]; +extern const field_t dir2_leaf_tail_flds[];extern const field_t dir2_leaf_entry_flds[]; + +extern const field_t da_node_entry_flds[]; + +/* +* dirv2 specific types +*/ +extern const field_t dir2_flds[]; +extern const field_t dir2_hfld[]; +extern const field_t dir2_data_hdr_flds[]; +extern const field_t dir2_free_hdr_flds[];extern const field_t dir2_leaf_hdr_flds[]; -extern const field_t dir2_leaf_tail_flds[];extern const field_t da_blkinfo_flds[]; -extern const field_t da_node_entry_flds[];extern const field_t da_node_hdr_flds[]; +/* +* dirv3 specific types +*/ +extern const field_t dir3_flds[]; +extern const field_t dir3_hfld[]; +extern const field_t dir3_blkhdr_flds[]; +extern const field_t dir3_data_hdr_flds[]; +extern const field_t dir3_free_hdr_flds[]; +extern const field_t dir3_leaf_hdr_flds[]; + +extern const field_t da3_blkinfo_flds[]; +extern const field_t da3_node_hdr_flds[]; +static inline xfs_dir2_inou_t *xfs_dir2_sf_inumberp (xfs_dir2_sf_entry_t *sfep) {return (xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen];
db/field.c +21 -0
@@ -166,6 +166,8 @@ const ftattr_t ftattrtab[] = { FTARG_SIZE|FTARG_OKEMPTY, NULL, inode_u_flds }, {FLDT_DINODE_V3 ,"dinode_v3" ,NULL , (char *)inode_v3_flds, SI(bitsz(xfs_dinode_t)), 0, NULL, inode_v3_flds }, + +/* dir v2 fields */ { FLDT_DIR2, "dir2", NULL, (char *)dir2_flds, dir2_size, FTARG_SIZE, NULL, dir2_flds }, { FLDT_DIR2_BLOCK_TAIL, "dir2_block_tail", NULL,
@@ -207,6 +209,20 @@ const ftattr_t ftattrtab[] = { SI(bitsz(xfs_dir2_sf_off_t)), 0, NULL, NULL }, { FLDT_DIR2SF, "dir2sf", NULL, (char *)dir2sf_flds, dir2sf_size, FTARG_SIZE, NULL, dir2sf_flds }, + +/* dir v3 fields */ + { FLDT_DIR3, "dir3", NULL, (char *)dir3_flds, dir2_size, FTARG_SIZE, + NULL, dir3_flds }, + { FLDT_DIR3_BLKHDR, "dir3_blk_hdr", NULL, (char *)dir3_blkhdr_flds, + SI(bitsz(struct xfs_dir3_blk_hdr)), 0, NULL, dir3_blkhdr_flds }, + { FLDT_DIR3_DATA_HDR, "dir3_data_hdr", NULL, (char *)dir3_data_hdr_flds, + SI(bitsz(struct xfs_dir3_data_hdr)), 0, NULL, dir3_data_hdr_flds }, + { FLDT_DIR3_FREE_HDR, "dir3_free_hdr", NULL, (char *)dir3_free_hdr_flds, + SI(bitsz(struct xfs_dir3_free_hdr)), 0, NULL, dir3_free_hdr_flds }, + { FLDT_DIR3_LEAF_HDR, "dir3_leaf_hdr", NULL, (char *)dir3_leaf_hdr_flds, + SI(bitsz(struct xfs_dir3_leaf_hdr)), 0, NULL, dir3_leaf_hdr_flds }, + +/* dir v2/3 node fields */ { FLDT_DA_BLKINFO, "dir_blkinfo", NULL, (char *)da_blkinfo_flds, SI(bitsz(struct xfs_da_blkinfo)), 0, NULL, da_blkinfo_flds }, { FLDT_DA_NODE_ENTRY, "dir_node_entry", fp_sarray,
@@ -214,6 +230,11 @@ const ftattr_t ftattrtab[] = { NULL, da_node_entry_flds }, {FLDT_DA_NODE_HDR ,"dir_node_hdr" ,NULL , (char *)da_node_hdr_flds, SI(bitsz(struct xfs_da_node_hdr)), 0, NULL, da_node_hdr_flds }, + { FLDT_DA3_BLKINFO, "dir_blkinfo", NULL, (char *)da3_blkinfo_flds, + SI(bitsz(struct xfs_da3_blkinfo)), 0, NULL, da3_blkinfo_flds }, + { FLDT_DA3_NODE_HDR, "dir_node_hdr", NULL, (char *)da3_node_hdr_flds, + SI(bitsz(struct xfs_da3_node_hdr)), 0, NULL, da3_node_hdr_flds }, + { FLDT_DIRBLOCK, "dirblock", fp_num, "%u", SI(bitsz(__uint32_t)), 0, fa_dirblock, NULL }, { FLDT_DISK_DQUOT, "disk_dquot", NULL, (char *)disk_dquot_flds,
db/field.h +14 -0
@@ -81,6 +81,8 @@ typedef enum fldt {FLDT_DINODE_FMT ,FLDT_DINODE_U ,FLDT_DINODE_V3 , + +/* dir v2 fields */ FLDT_DIR2 ,FLDT_DIR2_BLOCK_TAIL , FLDT_DIR2_DATA_FREE,
@@ -99,9 +101,21 @@ typedef enum fldt {FLDT_DIR2_SF_HDR ,FLDT_DIR2_SF_OFF ,FLDT_DIR2SF , + +/* dir v3 fields */ +FLDT_DIR3 , +FLDT_DIR3_BLKHDR , +FLDT_DIR3_DATA_HDR , +FLDT_DIR3_FREE_HDR , +FLDT_DIR3_LEAF_HDR , + +/* dir v2/3 node fields */ FLDT_DA_BLKINFO ,FLDT_DA_NODE_ENTRY ,FLDT_DA_NODE_HDR , +FLDT_DA3_BLKINFO , +FLDT_DA3_NODE_HDR , +FLDT_DIRBLOCK ,FLDT_DISK_DQUOT , FLDT_DQBLK,
db/type.c +7 -5
@@ -82,7 +82,7 @@ static const typ_t __typtab_crc[] = { { TYP_BNOBT, "bnobt", handle_struct, bnobt_crc_hfld }, { TYP_CNTBT, "cntbt", handle_struct, cntbt_crc_hfld }, { TYP_DATA, "data", handle_block, NULL }, - { TYP_DIR2, "dir2", handle_struct, dir2_hfld }, + { TYP_DIR2, "dir3", handle_struct, dir3_hfld }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld }, { TYP_INOBT, "inobt", handle_struct, inobt_crc_hfld }, { TYP_INODATA, "inodata", NULL, NULL },
@@ -110,9 +110,9 @@ findtyp( {const typ_t *tt; -for (tt = typtab; tt->name !=NULL ; tt++) { +for (tt = typtab; tt->typnm !=TYP_NONE ; tt++) {ASSERT (tt->typnm == (typnm_t)(tt - typtab)); -if (strcmp (tt->name, name) ==0 ) +if (tt->name &&strcmp (tt->name, name) ==0 )return tt; }return NULL ;
@@ -133,12 +133,14 @@ type_f(dbprintf (_ ("current type is \"%s\"\n" ), cur_typ->name);dbprintf (_ ("\n supported types are:\n " )); -for (tt = typtab, count =0 ; tt->name !=NULL ; tt++) { +for (tt = typtab, count =0 ; tt->typnm !=TYP_NONE ; tt++) { +if (tt->name ==NULL ) +continue ;if ((tt+1 )->name !=NULL ) {dbprintf ("%s, " , tt->name);if ((++count %8 ) ==0 )dbprintf ("\n " ); - }else { + }else if ((tt+1 )->typnm ==TYP_NONE ) {dbprintf ("%s\n" , tt->name); } }
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 34/48] xfs_db: update field printing for dir crc format changes.
Quoted 9 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Note that this also requires changing the type parsing to only allow dir3 data block parsing on CRC enabled filesystems. This is slighly more complex than it needs to be because of the way the type table is walked and the assumption that all the entries are in type number order.
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 35/48 xfs_repair: convert directory parsing to use libxfs structure
In reply to Dave ChinnerIt turns out that xfs_repair copies xfs_db in rollin git's own opaque directory types for the different block formats. It has a little comment about how they are "shared" with xfs_db. Shared by copy and pasting, rather than a common header, it would appear.
Anyway, same problems, need to use format aware definitionsi and abstractions from libxfs so that everything is parsed properly.
--- repair/dir2.c | 116 +++++++++++++++++++++++++++---------------------------- repair/dir2.h | 28 +------------- repair/phase6.c | 60 ++++++++++++++-------------- 3 files changed, 89 insertions(+), 115 deletions(-)
repair/dir2.c +58 -58
@@ -651,13 +651,13 @@ _("would correct bad hashval in interior dir block\n"*/ void process_sf_dir2_fixi8 ( -xfs_dir2_sf_t *sfp, +struct xfs_dir2_sf_hdr *sfp,xfs_dir2_sf_entry_t **next_sfep) {xfs_ino_t ino; -xfs_dir2_sf_t *newsfp; +struct xfs_dir2_sf_hdr *newsfp;xfs_dir2_sf_entry_t *newsfep; -xfs_dir2_sf_t *oldsfp; +struct xfs_dir2_sf_hdr *oldsfp;xfs_dir2_sf_entry_t *oldsfep;int oldsize;
@@ -669,21 +669,21 @@ process_sf_dir2_fixi8(exit (1 ); }memmove (oldsfp, newsfp, oldsize); - newsfp->hdr.count = oldsfp->hdr.count; - newsfp->hdr.i8count =0 ; - ino =xfs_dir2_sf_get_parent_ino (&sfp->hdr); -xfs_dir2_sf_put_parent_ino (&newsfp->hdr, ino); - oldsfep =xfs_dir2_sf_firstentry (&oldsfp->hdr); - newsfep =xfs_dir2_sf_firstentry (&newsfp->hdr); + newsfp->count = oldsfp->count; + newsfp->i8count =0 ; + ino =xfs_dir2_sf_get_parent_ino (sfp); +xfs_dir2_sf_put_parent_ino (newsfp, ino); + oldsfep =xfs_dir2_sf_firstentry (oldsfp); + newsfep =xfs_dir2_sf_firstentry (newsfp);while ((int )((char *)oldsfep - (char *)oldsfp) < oldsize) { newsfep->namelen = oldsfep->namelen;xfs_dir2_sf_put_offset (newsfep,xfs_dir2_sf_get_offset (oldsfep));memmove (newsfep->name, oldsfep->name, newsfep->namelen); - ino =xfs_dir2_sfe_get_ino (&oldsfp->hdr, oldsfep); -xfs_dir2_sfe_put_ino (&newsfp->hdr, newsfep, ino); - oldsfep =xfs_dir2_sf_nextentry (&oldsfp->hdr, oldsfep); - newsfep =xfs_dir2_sf_nextentry (&newsfp->hdr, newsfep); + ino =xfs_dir2_sfe_get_ino (oldsfp, oldsfep); +xfs_dir2_sfe_put_ino (newsfp, newsfep, ino); + oldsfep =xfs_dir2_sf_nextentry (oldsfp, oldsfep); + newsfep =xfs_dir2_sf_nextentry (newsfp, newsfep); } *next_sfep = newsfep;free (oldsfp);
@@ -700,16 +700,16 @@ process_sf_dir2_fixoff(int i;int offset;xfs_dir2_sf_entry_t *sfep; -xfs_dir2_sf_t *sfp; +struct xfs_dir2_sf_hdr *sfp; - sfp = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (dip); - sfep =xfs_dir2_sf_firstentry (&sfp->hdr); + sfp = (struct xfs_dir2_sf_hdr *)XFS_DFORK_DPTR (dip); + sfep =xfs_dir2_sf_firstentry (sfp); offset =XFS_DIR3_DATA_FIRST_OFFSET (mp); -for (i =0 ; i < sfp->hdr.count; i++) { +for (i =0 ; i < sfp->count; i++) {xfs_dir2_sf_put_offset (sfep, offset); offset +=xfs_dir2_data_entsize (sfep->namelen); - sfep =xfs_dir2_sf_nextentry (&sfp->hdr, sfep); + sfep =xfs_dir2_sf_nextentry (sfp, sfep); } }
@@ -747,16 +747,16 @@ process_sf_dir2(xfs_dir2_sf_entry_t *next_sfep;int num_entries;int offset; -xfs_dir2_sf_t *sfp; +struct xfs_dir2_sf_hdr *sfp;xfs_dir2_sf_entry_t *sfep;int tmp_elen;int tmp_len;xfs_dir2_sf_entry_t *tmp_sfep;xfs_ino_t zero =0 ; - sfp = (xfs_dir2_sf_t *)XFS_DFORK_DPTR (dip); + sfp = (struct xfs_dir2_sf_hdr *)XFS_DFORK_DPTR (dip); max_size =XFS_DFORK_DSIZE (dip, mp); - num_entries = sfp->hdr.count; + num_entries = sfp->count; ino_dir_size =be64_to_cpu (dip->di_size); offset =XFS_DIR3_DATA_FIRST_OFFSET (mp); bad_offset = *repair =0 ;
@@ -766,12 +766,12 @@ process_sf_dir2(/* * Initialize i8 based on size of parent inode number. */ - i8 = (xfs_dir2_sf_get_parent_ino (&sfp->hdr) >XFS_DIR2_MAX_SHORT_INUM ); + i8 = (xfs_dir2_sf_get_parent_ino (sfp) >XFS_DIR2_MAX_SHORT_INUM );/* * check for bad entry count */ -if (num_entries *xfs_dir2_sf_entsize (&sfp->hdr,1 ) + +if (num_entries *xfs_dir2_sf_entsize (sfp,1 ) +xfs_dir2_sf_hdr_size (0 ) > max_size || num_entries ==0 ) num_entries =0xFF ;
@@ -779,7 +779,7 @@ process_sf_dir2(* run through entries, stop at first bad entry, don't need * to check for .. since that's encoded in its own field */ - sfep = next_sfep =xfs_dir2_sf_firstentry (&sfp->hdr); + sfep = next_sfep =xfs_dir2_sf_firstentry (sfp);for (i =0 ; i < num_entries && ino_dir_size > (char *)next_sfep - (char *)sfp; i++) {
@@ -787,7 +787,7 @@ process_sf_dir2( sfep = next_sfep; junkit =0 ; bad_sfnamelen =0 ; - lino =xfs_dir2_sfe_get_ino (&sfp->hdr, sfep); + lino =xfs_dir2_sfe_get_ino (sfp, sfep);/* * if entry points to self, junk it since only '.' or '..' * should do that and shortform dirs don't contain either
@@ -901,7 +901,7 @@ _("zero length entry in shortform dir %" PRIu64 ""),break ; } }else if ((__psint_t ) sfep - (__psint_t ) sfp + -xfs_dir2_sf_entsize (&sfp->hdr, sfep->namelen) +xfs_dir2_sf_entsize (sfp, sfep->namelen) > ino_dir_size) { bad_sfnamelen =1 ;
@@ -989,7 +989,7 @@ _("entry contains offset out of order in shortform dir %" PRIu64 "\n"), name[namelen] ='\0' ;if (!no_modify) { - tmp_elen =xfs_dir2_sf_entsize (&sfp->hdr, + tmp_elen =xfs_dir2_sf_entsize (sfp, sfep->namelen);be64_add_cpu (&dip->di_size, -tmp_elen); ino_dir_size -= tmp_elen;
@@ -1001,7 +1001,7 @@ _("entry contains offset out of order in shortform dir %" PRIu64 "\n"),memmove (sfep, tmp_sfep, tmp_len); - sfp->hdr.count -=1 ; + sfp->count -=1 ; num_entries--;memset ((void *) ((__psint_t ) sfep + tmp_len),0 , tmp_elen);
@@ -1043,41 +1043,41 @@ _("would have junked entry \"%s\" in directory inode %" PRIu64 "\n"), next_sfep = (tmp_sfep ==NULL ) ? (xfs_dir2_sf_entry_t *) ((__psint_t ) sfep + ((!bad_sfnamelen) - ?xfs_dir2_sf_entsize (&sfp->hdr, sfep->namelen) - :xfs_dir2_sf_entsize (&sfp->hdr, namelen))) + ?xfs_dir2_sf_entsize (sfp, sfep->namelen) + :xfs_dir2_sf_entsize (sfp, namelen))) : tmp_sfep; }/* sync up sizes and entry counts */ -if (sfp->hdr.count != i) { +if (sfp->count != i) {if (no_modify) {do_warn (_ ("would have corrected entry count in directory %" PRIu64" from %d to %d\n" ), - ino, sfp->hdr.count, i); + ino, sfp->count, i); }else {do_warn (_ ("corrected entry count in directory %" PRIu64", was %d, now %d\n" ), - ino, sfp->hdr.count, i); - sfp->hdr.count = i; + ino, sfp->count, i); + sfp->count = i; *dino_dirty =1 ; *repair =1 ; } } -if (sfp->hdr.i8count != i8) { +if (sfp->i8count != i8) {if (no_modify) {do_warn (_ ("would have corrected i8 count in directory %" PRIu64" from %d to %d\n" ), - ino, sfp->hdr.i8count, i8); + ino, sfp->i8count, i8); }else {do_warn (_ ("corrected i8 count in directory %" PRIu64", was %d, now %d\n" ), - ino, sfp->hdr.i8count, i8); + ino, sfp->i8count, i8);if (i8 ==0 )process_sf_dir2_fixi8 (sfp, &next_sfep);else - sfp->hdr.i8count = i8; + sfp->i8count = i8; *dino_dirty =1 ; *repair =1 ; }
@@ -1101,7 +1101,7 @@ _("corrected directory %" PRIu64 " size, was %" PRId64 ", now %" PRIdPTR "\n"), *repair =1 ; } } -if (offset + (sfp->hdr.count +2 ) *sizeof (xfs_dir2_leaf_entry_t) + +if (offset + (sfp->count +2 ) *sizeof (xfs_dir2_leaf_entry_t) +sizeof (xfs_dir2_block_tail_t) > mp->m_dirblksize) {do_warn (_ ("directory %" PRIu64" offsets too high\n" ), ino); bad_offset =1 ;
@@ -1124,7 +1124,7 @@ _("corrected entry offsets in directory %" PRIu64 "\n"),/* * check parent (..) entry */ - *parent =xfs_dir2_sf_get_parent_ino (&sfp->hdr); + *parent =xfs_dir2_sf_get_parent_ino (sfp);/* * if parent entry is bogus, null it out. we'll fix it later .
@@ -1138,7 +1138,7 @@ _("bogus .. inode number (%" PRIu64 ") in directory inode %" PRIu64 ", "),if (!no_modify) {do_warn (_ ("clearing inode number\n" )); -xfs_dir2_sf_put_parent_ino (&sfp->hdr, zero); +xfs_dir2_sf_put_parent_ino (sfp, zero); *dino_dirty =1 ; *repair =1 ; }else {
@@ -1153,7 +1153,7 @@ _("bogus .. inode number (%" PRIu64 ") in directory inode %" PRIu64 ", "),_ ("corrected root directory %" PRIu64" .. entry, was %" PRIu64", now %" PRIu64"\n" ), ino, *parent, ino); *parent = ino; -xfs_dir2_sf_put_parent_ino (&sfp->hdr, ino); +xfs_dir2_sf_put_parent_ino (sfp, ino); *dino_dirty =1 ; *repair =1 ; }else {
@@ -1173,7 +1173,7 @@ _("bad .. entry in directory inode %" PRIu64 ", points to self, "),if (!no_modify) {do_warn (_ ("clearing inode number\n" )); -xfs_dir2_sf_put_parent_ino (&sfp->hdr, zero); +xfs_dir2_sf_put_parent_ino (sfp, zero); *dino_dirty =1 ; *repair =1 ; }else {
@@ -1207,7 +1207,7 @@ process_dir2_data(xfs_dir2_data_free_t *bf;int clearino;char *clearreason =NULL ; -xfs_dir2_data_t *d; +struct xfs_dir2_data_hdr *d;xfs_dir2_data_entry_t *dep;xfs_dir2_data_free_t *dfp;xfs_dir2_data_unused_t *dup;
@@ -1222,8 +1222,8 @@ process_dir2_data(xfs_ino_t ent_ino; d = bp->b_addr; - bf =xfs_dir3_data_bestfree_p (&d->hdr); - ptr = (char *)xfs_dir3_data_entry_p (&d->hdr); + bf =xfs_dir3_data_bestfree_p (d); + ptr = (char *)xfs_dir3_data_entry_p (d); badbest = lastfree = freeseen =0 ;if (be16_to_cpu (bf[0 ].length) ==0 ) { badbest |=be16_to_cpu (bf[0 ].offset) !=0 ;
@@ -1255,7 +1255,7 @@ process_dir2_data( (char *)dup - (char *)d)break ; badbest |= lastfree !=0 ; - dfp =xfs_dir2_data_freefind (&d->hdr, dup); + dfp =xfs_dir2_data_freefind (d, dup);if (dfp) { i = dfp - bf; badbest |= (freeseen & (1 << i)) !=0 ;
@@ -1289,7 +1289,7 @@ process_dir2_data(do_warn (_ ("\twould junk block\n" ));return 1 ; } - ptr = (char *)xfs_dir3_data_entry_p (&d->hdr); + ptr = (char *)xfs_dir3_data_entry_p (d);/* * Process the entries now. */
@@ -1539,7 +1539,7 @@ _("bad bestfree table in block %u in directory inode %" PRIu64 ": "), da_bno, ino);if (!no_modify) {do_warn (_ ("repairing table\n" )); -libxfs_dir2_data_freescan (mp, &d->hdr, &i); +libxfs_dir2_data_freescan (mp, d, &i); *dirty =1 ; }else {do_warn (_ ("would repair table\n" ));
@@ -1566,7 +1566,7 @@ process_block_dir2(int *dotdot,/* out - 1 if there's a dotdot, else 0 */ int *repair) /* out - 1 if something was fixed */ { - xfs_dir2_block_t *block; + struct xfs_dir2_data_hdr *block;xfs_dir2_leaf_entry_t *blp;bmap_ext_t *bmp;struct xfs_buf *bp;
@@ -1598,16 +1598,16 @@ _("can't read block %u for directory inode %" PRIu64 "\n"),* Verify the block */ block = bp->b_addr; -if (!(be32_to_cpu (block->hdr.magic) ==XFS_DIR2_BLOCK_MAGIC || -be32_to_cpu (block->hdr.magic) ==XFS_DIR3_BLOCK_MAGIC )) +if (!(be32_to_cpu (block->magic) ==XFS_DIR2_BLOCK_MAGIC || +be32_to_cpu (block->magic) ==XFS_DIR3_BLOCK_MAGIC ))do_warn (_ ("bad directory block magic # %#x in block %u for directory inode %" PRIu64"\n" ), -be32_to_cpu (block->hdr.magic), mp->m_dirdatablk, ino); +be32_to_cpu (block->magic), mp->m_dirdatablk, ino);/* * process the data area * this also checks & fixes the bestfree */ - btp =xfs_dir2_block_tail_p (mp, &block->hdr); + btp =xfs_dir2_block_tail_p (mp, block); blp =xfs_dir2_block_leaf_p (btp);/* * Don't let this go past the end of the block.
@@ -1878,7 +1878,7 @@ process_leaf_node_dir2( {bmap_ext_t *bmp;struct xfs_buf *bp; -xfs_dir2_data_t *data; +struct xfs_dir2_data_hdr *data;xfs_dfiloff_t dbno;int good;int i;
@@ -1914,11 +1914,11 @@ _("can't read block %" PRIu64 " for directory inode %" PRIu64 "\n"),continue ; } data = bp->b_addr; -if (!(be32_to_cpu (data->hdr.magic) ==XFS_DIR2_DATA_MAGIC || -be32_to_cpu (data->hdr.magic) ==XFS_DIR3_DATA_MAGIC )) +if (!(be32_to_cpu (data->magic) ==XFS_DIR2_DATA_MAGIC || +be32_to_cpu (data->magic) ==XFS_DIR3_DATA_MAGIC ))do_warn (_ ("bad directory block magic # %#x in block %" PRIu64" for directory inode %" PRIu64"\n" ), -be32_to_cpu (data->hdr.magic), dbno, ino); +be32_to_cpu (data->magic), dbno, ino); i =process_dir2_data (mp, ino, dip, ino_discovery, dirname, parent, bp, dot, dotdot, (xfs_dablk_t )dbno, (char *)data + mp->m_dirblksize, &dirty);
repair/dir2.h +1 -27
@@ -23,32 +23,6 @@ struct blkmap;struct bmap_ext ;/* -* generic dir2 structures used by xfs_repair. -* XXX: shared with xfsdb -*/ -typedef union { -xfs_dir2_data_entry_t entry; -xfs_dir2_data_unused_t unused; -}xfs_dir2_data_union_t ; - -typedef struct xfs_dir2_data { -xfs_dir2_data_hdr_t hdr;/* magic XFS_DIR2_DATA_MAGIC */ -xfs_dir2_data_union_t __u[1 ]; -}xfs_dir2_data_t ; - -typedef struct xfs_dir2_block { -xfs_dir2_data_hdr_t hdr;/* magic XFS_DIR2_BLOCK_MAGIC */ -xfs_dir2_data_union_t __u[1 ]; -xfs_dir2_leaf_entry_t __leaf[1 ]; -xfs_dir2_block_tail_t tail; -}xfs_dir2_block_t ; - -typedef struct xfs_dir2_sf { -xfs_dir2_sf_hdr_t hdr;/* shortform header */ -xfs_dir2_sf_entry_t list[1 ];/* shortform entries */ -}xfs_dir2_sf_t ; - -/* * the cursor gets passed up and down the da btree processing * routines. The interior block processing routines use the * cursor to determine if the pointers to and from the preceding
@@ -98,7 +72,7 @@ process_dir2(void process_sf_dir2_fixi8 ( -xfs_dir2_sf_t *sfp, +struct xfs_dir2_sf_hdr *sfp,xfs_dir2_sf_entry_t **next_sfep);int
repair/phase6.c +30 -30
216 lines not on this page · raw message
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 35/48] xfs_repair: convert directory parsing to use libxfs structure
Quoted 1 line · Dave Chinner
It turns out that
xfs_repaircopiesxfs_dbin rollin git's own
rolling it's
Quoted 5 lines
opaque directory types for the different block formats. It has a little comment about how they are "shared" with
xfs_db. Shared by copy and pasting, rather than a common header, it would appear.Anyway, same problems, need to use format aware definitionsi and
definitions
Quoted 3 lines
abstractions from libxfs so that everything is parsed properly.
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 36/48 xfs_repair: make directory freespace table CRC format aware.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
We fail to take into account the format of the directory block when reading the best free space form a directory data block for free space block verification. This causes occasionaly failures in xfstests.
--- repair/phase6.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
repair/phase6.c +5 -1
@@ -1395,6 +1395,7 @@ longform_dir2_entry_check_data(xfs_dir2_db_t db;xfs_dir2_data_entry_t *dep;xfs_dir2_data_unused_t *dup; +struct xfs_dir2_data_free *bf;char *endptr;int error;xfs_fsblock_t firstblock;
@@ -1808,7 +1809,10 @@ _("entry \"%s\" in dir inode %" PRIu64 " inconsistent with .. value (%" PRIu64 "libxfs_dir2_data_log_header (tp, bp);libxfs_bmap_finish (&tp, &flist, &committed);libxfs_trans_commit (tp,0 ); - freetab->ents[db].v =be16_to_cpu (d->bestfree[0 ].length); + +/* record the largest free space in the freetab for later checking */ + bf =xfs_dir3_data_bestfree_p (d); + freetab->ents[db].v =be16_to_cpu (bf[0 ].length); freetab->ents[db].s =0 ; }
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 36/48] xfs_repair: make directory freespace table CRC format aware.
Quoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
We fail to take into account the format of the directory block when reading the best free space form a directory data block for free space block verification. This causes occasionaly failures in xfstests.
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 37/48 xfs_db: add CRC information to dquot output
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
When dumping a dqblk, also output the CRC related fields. For non-CRC filesystems, these fields should always be zero.
--- db/dquot.c | 3 +++ 1 file changed, 3 insertions(+)
db/dquot.c +3 -0
@@ -48,6 +48,9 @@ const field_t dqblk_flds[] = { { "diskdq", FLDT_DISK_DQUOT, OI(DDOFF(diskdq)), C1, 0, TYP_NONE }, { "fill", FLDT_CHARS, OI(DDOFF(fill)), CI(DDSZC(fill)), FLD_SKIPALL, TYP_NONE }, + { "crc", FLDT_UINT32X, OI(DDOFF(crc)), C1, 0, TYP_NONE }, + { "lsn", FLDT_UINT64X, OI(DDOFF(lsn)), C1, 0, TYP_NONE }, + { "uuid", FLDT_UUID, OI(DDOFF(uuid)), C1, 0, TYP_NONE }, { NULL } };
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 37/48] xfs_db: add CRC information to dquot output
Quoted 6 lines · Dave Chinner
From: Dave Chinner <[email protected]>
When dumping a dqblk, also output the CRC related fields. For non-CRC filesystems, these fields should always be zero.
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 38/48 xfs_db: add CRC support for attribute fork structures.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- db/attr.c | 391 ++++++++++++++++++++++++++++++++++++------------------------ db/attr.h | 5 + db/field.c | 13 ++ db/field.h | 8 ++ db/type.c | 2 +- 5 files changed, 265 insertions(+), 154 deletions(-)
db/attr.c +238 -153
@@ -148,84 +148,141 @@ const field_t attr_node_hdr_flds[] = { { NULL } }; -/*ARGSUSED*/ static int attr_leaf_entries_count (void *obj,int startoff) { -xfs_attr_leafblock_t *block; +struct xfs_attr_leafblock *leaf = obj;ASSERT (startoff ==0 ); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) +if (be16_to_cpu (leaf->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC )return 0 ; -return be16_to_cpu (block->hdr.count); +return be16_to_cpu (leaf->hdr.count); +} + +static int +attr3_leaf_entries_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_leafblock *leaf = obj; + +ASSERT (startoff ==0 ); +if (be16_to_cpu (leaf->hdr.info.hdr.magic) !=XFS_ATTR_LEAF_MAGIC ) +return 0 ; +return be16_to_cpu (leaf->hdr.count); } -/*ARGSUSED*/ static int attr_leaf_hdr_count (void *obj,int startoff) { -xfs_attr_leafblock_t *block; +struct xfs_attr_leafblock *leaf = obj;ASSERT (startoff ==0 ); - block = obj; -return be16_to_cpu (block->hdr.info.magic) ==XFS_ATTR_LEAF_MAGIC ; +return be16_to_cpu (leaf->hdr.info.magic) ==XFS_ATTR_LEAF_MAGIC ; }static int -attr_leaf_name_local_count ( +attr3_leaf_hdr_count (void *obj,int startoff) { -xfs_attr_leafblock_t *block; -xfs_attr_leaf_entry_t *e; -int i; -int off; +struct xfs_attr3_leafblock *leaf = obj; + +ASSERT (startoff ==0 ); +return be16_to_cpu (leaf->hdr.info.hdr.magic) ==XFS_ATTR3_LEAF_MAGIC ; +} + +typedef int (*attr_leaf_entry_walk_f )(struct xfs_attr_leafblock *, +struct xfs_attr_leaf_entry *,int ); +static int +attr_leaf_entry_walk ( +void *obj, +int startoff, +attr_leaf_entry_walk_f func) +{ +struct xfs_attr_leafblock *leaf = obj; +struct xfs_attr3_icleaf_hdr leafhdr; +struct xfs_attr_leaf_entry *entries; +struct xfs_attr_leaf_entry *e; +int i; +int off;ASSERT (bitoffs (startoff) ==0 ); - off =byteize (startoff); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) +if (be16_to_cpu (leaf->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC && +be16_to_cpu (leaf->hdr.info.magic) !=XFS_ATTR3_LEAF_MAGIC )return 0 ; -for (i =0 ; i <be16_to_cpu (block->hdr.count); i++) { - e = &block->entries[i]; + + off =byteize (startoff); +xfs_attr3_leaf_hdr_from_disk (&leafhdr, leaf); + entries =xfs_attr3_leaf_entryp (leaf); + +for (i =0 ; i < leafhdr.count; i++) { + e = &entries[i];if (be16_to_cpu (e->nameidx) == off) -return (e->flags &XFS_ATTR_LOCAL ) !=0 ; +return func (leaf, e, i); }return 0 ; }static int +__attr_leaf_name_local_count ( +struct xfs_attr_leafblock *leaf, +struct xfs_attr_leaf_entry *e, +int i) +{ +return (e->flags &XFS_ATTR_LOCAL ) !=0 ; +} + +static int +attr_leaf_name_local_count ( +void *obj, +int startoff) +{ +return attr_leaf_entry_walk (obj, startoff, + __attr_leaf_name_local_count); +} + +static int +__attr_leaf_name_local_name_count ( +struct xfs_attr_leafblock *leaf, +struct xfs_attr_leaf_entry *e, +int i) +{ +struct xfs_attr_leaf_name_local *l; + +if (!(e->flags &XFS_ATTR_LOCAL )) +return 0 ; + + l =xfs_attr3_leaf_name_local (leaf, i); +return l->namelen; +} + +static int attr_leaf_name_local_name_count (void *obj,int startoff) { -xfs_attr_leafblock_t *block; -xfs_attr_leaf_entry_t *e; -int i; -xfs_attr_leaf_name_local_t *l; -int off; +return attr_leaf_entry_walk (obj, startoff, + __attr_leaf_name_local_name_count); +} -ASSERT (bitoffs (startoff) ==0 ); - off =byteize (startoff); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) +static int +__attr_leaf_name_local_value_count ( +struct xfs_attr_leafblock *leaf, +struct xfs_attr_leaf_entry *e, +int i) +{ +struct xfs_attr_leaf_name_local *l; + +if (!(e->flags &XFS_ATTR_LOCAL ))return 0 ; -for (i =0 ; i <be16_to_cpu (block->hdr.count); i++) { - e = &block->entries[i]; -if (be16_to_cpu (e->nameidx) == off) { -if (e->flags &XFS_ATTR_LOCAL ) { - l =xfs_attr3_leaf_name_local (block, i); -return l->namelen; - }else -return 0 ; - } - } -return 0 ; + + l =xfs_attr3_leaf_name_local (leaf, i); +return be16_to_cpu (l->valuelen); } static int
@@ -233,84 +290,66 @@ attr_leaf_name_local_value_count( void *obj, int startoff) { -xfs_attr_leafblock_t *block; -xfs_attr_leaf_entry_t *e; -int i; -xfs_attr_leaf_name_local_t *l; -int off; +return attr_leaf_entry_walk (obj, startoff, + __attr_leaf_name_local_value_count); +} -ASSERT (bitoffs (startoff) ==0 ); - off =byteize (startoff); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) -return 0 ; -for (i =0 ; i <be16_to_cpu (block->hdr.count); i++) { - e = &block->entries[i]; -if (be16_to_cpu (e->nameidx) == off) { -if (e->flags &XFS_ATTR_LOCAL ) { - l =xfs_attr3_leaf_name_local (block, i); -return be16_to_cpu (l->valuelen); - }else -return 0 ; - } - } -return 0 ; +static int +__attr_leaf_name_local_value_offset ( +struct xfs_attr_leafblock *leaf, +struct xfs_attr_leaf_entry *e, +int i) +{ +struct xfs_attr_leaf_name_local *l; +char *vp; + + l =xfs_attr3_leaf_name_local (leaf, i); + vp = (char *)&l->nameval[l->namelen]; + +return (int )bitize (vp - (char *)l); } -/*ARGSUSED*/ static int attr_leaf_name_local_value_offset (void *obj,int startoff,int idx) { -xfs_attr_leafblock_t *block; -xfs_attr_leaf_name_local_t *l; -char *vp; -int off; -xfs_attr_leaf_entry_t *e; -int i; - -ASSERT (bitoffs (startoff) ==0 ); - off =byteize (startoff); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) -return 0 ; - -for (i =0 ; i <be16_to_cpu (block->hdr.count); i++) { - e = &block->entries[i]; -if (be16_to_cpu (e->nameidx) == off) -break ; - } -if (i >=be16_to_cpu (block->hdr.count)) -return 0 ; +return attr_leaf_entry_walk (obj, startoff, + __attr_leaf_name_local_value_offset); +} - l =xfs_attr3_leaf_name_local (block, i); - vp = (char *)&l->nameval[l->namelen]; -return (int )bitize (vp - (char *)l); +static int +__attr_leaf_name_remote_count ( +struct xfs_attr_leafblock *leaf, +struct xfs_attr_leaf_entry *e, +int i) +{ +return (e->flags &XFS_ATTR_LOCAL ) ==0 ; }static int attr_leaf_name_remote_count ( -void *obj, -int startoff) +void *obj, +int startoff) { -xfs_attr_leafblock_t *block; -xfs_attr_leaf_entry_t *e; -int i; -int off; +return attr_leaf_entry_walk (obj, startoff, + __attr_leaf_name_remote_count); +} -ASSERT (bitoffs (startoff) ==0 ); - off =byteize (startoff); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) +static int +__attr_leaf_name_remote_name_count ( +struct xfs_attr_leafblock *leaf, +struct xfs_attr_leaf_entry *e, +int i) +{ +struct xfs_attr_leaf_name_remote *r; + +if (e->flags &XFS_ATTR_LOCAL )return 0 ; -for (i =0 ; i <be16_to_cpu (block->hdr.count); i++) { - e = &block->entries[i]; -if (be16_to_cpu (e->nameidx) == off) -return (e->flags &XFS_ATTR_LOCAL ) ==0 ; - } -return 0 ; + + r =xfs_attr3_leaf_name_remote (leaf, i); +return r->namelen; } static int
@@ -318,117 +357,125 @@ attr_leaf_name_remote_name_count( void *obj, int startoff) { -xfs_attr_leafblock_t *block; -xfs_attr_leaf_entry_t *e; -int i; -int off; -xfs_attr_leaf_name_remote_t *r; - -ASSERT (bitoffs (startoff) ==0 ); - off =byteize (startoff); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) -return 0 ; -for (i =0 ; i <be16_to_cpu (block->hdr.count); i++) { - e = &block->entries[i]; -if (be16_to_cpu (e->nameidx) == off) { -if (!(e->flags &XFS_ATTR_LOCAL )) { - r =xfs_attr3_leaf_name_remote (block, i); -return r->namelen; - }else -return 0 ; - } - } -return 0 ; +return attr_leaf_entry_walk (obj, startoff, + __attr_leaf_name_remote_name_count); } -/*ARGSUSED*/ int attr_leaf_name_size (void *obj,int startoff,int idx) { -xfs_attr_leafblock_t *block; -xfs_attr_leaf_entry_t *e; -xfs_attr_leaf_name_local_t *l; -xfs_attr_leaf_name_remote_t *r; +struct xfs_attr_leafblock *leaf = obj; +struct xfs_attr_leaf_entry *e; +struct xfs_attr_leaf_name_local *l; +struct xfs_attr_leaf_name_remote *r;ASSERT (startoff ==0 ); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) +if (be16_to_cpu (leaf->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC && +be16_to_cpu (leaf->hdr.info.magic) !=XFS_ATTR3_LEAF_MAGIC )return 0 ; - e = &block->entries[idx]; + e = &xfs_attr3_leaf_entryp (leaf)[idx];if (e->flags &XFS_ATTR_LOCAL ) { - l =xfs_attr3_leaf_name_local (block, idx); + l =xfs_attr3_leaf_name_local (leaf, idx);return (int )bitize (xfs_attr_leaf_entsize_local (l->namelen,be16_to_cpu (l->valuelen))); }else { - r =xfs_attr3_leaf_name_remote (block, idx); + r =xfs_attr3_leaf_name_remote (leaf, idx);return (int )bitize (xfs_attr_leaf_entsize_remote (r->namelen)); } } -/*ARGSUSED*/ static int attr_leaf_nvlist_count (void *obj,int startoff) { -xfs_attr_leafblock_t *block; +struct xfs_attr_leafblock *leaf = obj; + +ASSERT (startoff ==0 ); +if (be16_to_cpu (leaf->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) +return 0 ; +return be16_to_cpu (leaf->hdr.count); +} + +static int +attr3_leaf_nvlist_count ( +void *obj, +int startoff) +{ +struct xfs_attr3_leafblock *leaf = obj;ASSERT (startoff ==0 ); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) +if (be16_to_cpu (leaf->hdr.info.hdr.magic) !=XFS_ATTR3_LEAF_MAGIC )return 0 ; -return be16_to_cpu (block->hdr.count); +return be16_to_cpu (leaf->hdr.count); } -/*ARGSUSED*/ static int attr_leaf_nvlist_offset (void *obj,int startoff,int idx) { -xfs_attr_leafblock_t *block; -xfs_attr_leaf_entry_t *e; +struct xfs_attr_leafblock *leaf = obj; +struct xfs_attr_leaf_entry *e;ASSERT (startoff ==0 ); - block = obj; - e = &block->entries[idx]; + e = &xfs_attr3_leaf_entryp (leaf)[idx];return bitize (be16_to_cpu (e->nameidx)); } -/*ARGSUSED*/ static int attr_node_btree_count (void *obj,int startoff) { -xfs_da_intnode_t *block; +struct xfs_da_intnode *node = obj;ASSERT (startoff ==0 );/* this is a base structure */ - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_DA_NODE_MAGIC ) +if (be16_to_cpu (node->hdr.info.magic) !=XFS_DA_NODE_MAGIC )return 0 ; -return be16_to_cpu (block->hdr.__count); +return be16_to_cpu (node->hdr.__count); } -/*ARGSUSED*/ +static int +attr3_node_btree_count ( +void *obj, +int startoff) +{ +struct xfs_da3_intnode *node = obj; + +ASSERT (startoff ==0 ); +if (be16_to_cpu (node->hdr.info.hdr.magic) !=XFS_DA3_NODE_MAGIC ) +return 0 ; +return be16_to_cpu (node->hdr.__count); +} + +static int attr_node_hdr_count (void *obj,int startoff) { -xfs_da_intnode_t *block; +struct xfs_da_intnode *node = obj;ASSERT (startoff ==0 ); - block = obj; -return be16_to_cpu (block->hdr.info.magic) ==XFS_DA_NODE_MAGIC ; +return be16_to_cpu (node->hdr.info.magic) ==XFS_DA_NODE_MAGIC ; +} + +static int +attr3_node_hdr_count ( +void *obj, +int startoff) +{ +struct xfs_da3_intnode *node = obj; + +ASSERT (startoff ==0 ); +return be16_to_cpu (node->hdr.info.hdr.magic) ==XFS_DA3_NODE_MAGIC ; } -/*ARGSUSED*/ int attr_size( void *obj,
@@ -437,3 +484,41 @@ attr_size( {return bitize (mp->m_sb.sb_blocksize); } + +/* +* CRC enabled attribute block field definitions +*/ +const field_t attr3_hfld[] = { + {"" ,FLDT_ATTR3 ,OI (0 ),C1 ,0 ,TYP_NONE }, + {NULL } +}; + +#define L3OFF (f) bitize(offsetof(struct xfs_attr3_leafblock, f)) +#define N3OFF (f) bitize(offsetof(struct xfs_da3_intnode, f)) +const field_t attr3_flds[] = { + {"hdr" ,FLDT_ATTR3_LEAF_HDR ,OI (L3OFF (hdr)), attr3_leaf_hdr_count, +FLD_COUNT ,TYP_NONE }, + {"hdr" ,FLDT_DA3_NODE_HDR ,OI (N3OFF (hdr)), attr3_node_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)), + attr3_node_btree_count,FLD_ARRAY |FLD_COUNT ,TYP_NONE }, + {"nvlist" ,FLDT_ATTR_LEAF_NAME , attr_leaf_nvlist_offset, + attr3_leaf_nvlist_count,FLD_ARRAY |FLD_OFFSET |FLD_COUNT ,TYP_NONE }, + {NULL } +}; + +#define LH3OFF (f) bitize(offsetof(struct xfs_attr3_leaf_hdr, f)) +const field_t attr3_leaf_hdr_flds[] = { + {"info" ,FLDT_DA3_BLKINFO ,OI (LH3OFF (info)),C1 ,0 ,TYP_NONE }, + {"count" ,FLDT_UINT16D ,OI (LH3OFF (count)),C1 ,0 ,TYP_NONE }, + {"usedbytes" ,FLDT_UINT16D ,OI (LH3OFF (usedbytes)),C1 ,0 ,TYP_NONE }, + {"firstused" ,FLDT_UINT16D ,OI (LH3OFF (firstused)),C1 ,0 ,TYP_NONE }, + {"holes" ,FLDT_UINT8D ,OI (LH3OFF (holes)),C1 ,0 ,TYP_NONE }, + {"pad1" ,FLDT_UINT8X ,OI (LH3OFF (pad1)),C1 ,FLD_SKIPALL ,TYP_NONE }, + {"freemap" ,FLDT_ATTR_LEAF_MAP ,OI (LH3OFF (freemap)), +CI (XFS_ATTR_LEAF_MAPSIZE ),FLD_ARRAY ,TYP_NONE }, + {NULL } +}; +
db/attr.h +5 -0
@@ -26,5 +26,10 @@ extern const field_t attr_leaf_name_flds[];extern const field_t attr_node_entry_flds[];extern const field_t attr_node_hdr_flds[]; +extern const field_t attr3_flds[]; +extern const field_t attr3_hfld[]; +extern const field_t attr3_leaf_hdr_flds[]; +extern const field_t attr3_node_hdr_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 +13 -0
@@ -56,6 +56,8 @@ const ftattr_t ftattrtab[] = { FTARG_SKIPNULL, fa_agino, NULL }, { FLDT_AGNUMBER, "agnumber", fp_num, "%u", SI(bitsz(xfs_agnumber_t)), FTARG_DONULL, NULL, NULL }, + +/* attr fields */ { FLDT_ATTR, "attr", NULL, (char *)attr_flds, attr_size, FTARG_SIZE, NULL, attr_flds }, { FLDT_ATTR_BLKINFO, "attr_blkinfo", NULL, (char *)attr_blkinfo_flds,
@@ -84,6 +86,17 @@ const ftattr_t ftattrtab[] = { fa_attrblock, NULL }, { FLDT_ATTRSHORT, "attrshort", NULL, (char *)attr_shortform_flds, attrshort_size, FTARG_SIZE, NULL, attr_shortform_flds }, + +/* attr3 specific fields */ + { FLDT_ATTR3, "attr3", NULL, (char *)attr3_flds, attr_size, FTARG_SIZE, + NULL, attr3_flds }, + { FLDT_ATTR3_LEAF_HDR, "attr3_leaf_hdr", NULL, + (char *)attr3_leaf_hdr_flds, SI(bitsz(struct xfs_attr3_leaf_hdr)), + 0, NULL, attr3_leaf_hdr_flds }, + { FLDT_ATTR3_NODE_HDR, "attr3_node_hdr", NULL, + (char *)da3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)), + 0, NULL, da3_node_hdr_flds }, + { FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size, FTARG_SIZE, NULL, bmapbta_flds }, { FLDT_BMAPBTA_CRC, "bmapbta", NULL, (char *)bmapbta_crc_flds,
db/field.h +8 -0
@@ -27,6 +27,8 @@ typedef enum fldt {FLDT_AGINO ,FLDT_AGINONN ,FLDT_AGNUMBER , + +/* attr fields */ FLDT_ATTR ,FLDT_ATTR_BLKINFO , FLDT_ATTR_LEAF_ENTRY,
@@ -39,6 +41,12 @@ typedef enum fldt {FLDT_ATTR_SF_HDR ,FLDT_ATTRBLOCK ,FLDT_ATTRSHORT , + +/* attr 3 specific fields */ +FLDT_ATTR3 , +FLDT_ATTR3_LEAF_HDR , +FLDT_ATTR3_NODE_HDR , +FLDT_BMAPBTA ,FLDT_BMAPBTA_CRC , FLDT_BMAPBTAKEY,
db/type.c +1 -1
@@ -76,7 +76,7 @@ static const typ_t __typtab_crc[] = { { TYP_AGF, "agf", handle_struct, agf_hfld }, { TYP_AGFL, "agfl", handle_struct, agfl_crc_hfld }, { TYP_AGI, "agi", handle_struct, agi_hfld }, - { TYP_ATTR, "attr", handle_struct, attr_hfld }, + { TYP_ATTR, "attr3", handle_struct, attr3_hfld }, { TYP_BMAPBTA, "bmapbta", handle_struct, bmapbta_crc_hfld }, { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld }, { TYP_BNOBT, "bnobt", handle_struct, bnobt_crc_hfld },
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 38/48] xfs_db: add CRC support for attribute fork structures.
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 39/48 mkfs.xfs: validate options for CRCs up front.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
With CRC enabled filesystems, certain options are now not optional and so are always enabled. Validate these options up front and abort if options are specified that cannot be set.
--- mkfs/xfs_mkfs.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 5 deletions(-)
mkfs/xfs_mkfs.c +56 -5
@@ -870,7 +870,7 @@ main(__uint64_t agsize;xfs_alloc_rec_t *arec;int attrversion; -int projid32bit; +int projid16bit;struct xfs_btree_block *block;int blflag;int blocklog;
@@ -966,7 +966,7 @@ main(textdomain (PACKAGE ); attrversion =2 ; - projid32bit =0 ; + projid16bit =0 ; blflag = bsflag = slflag = ssflag = lslflag = lssflag =0 ; blocklog = blocksize =0 ; sectorlog = lsectorlog =XFS_MIN_SECTORSIZE_LOG ;
@@ -1310,7 +1310,7 @@ main( c =atoi (value);if (c <0 || c >1 )illegal (value,"i projid32bit" ); - projid32bit = c; + projid16bit = c ?0 :1 ;break ;default :unknown ('i' , value);
@@ -1754,6 +1754,57 @@ _("block size %d cannot be smaller than logical sector size %d\n"), logversion =2 ; } +/* +* Now we have blocks and sector sizes set up, check parameters that are +* no longer optional for CRC enabled filesystems. Catch them up front +* here before doing anything else. +*/ +if (crcs_enabled) { +/* minimum inode size is 512 bytes, ipflag checked later */ +if ((isflag || ilflag) && inodelog <XFS_DINODE_DFL_CRC_LOG ) { +fprintf (stderr, +_ ("Minimum inode size for CRCs is %d bytes\n" ), +1 <<XFS_DINODE_DFL_CRC_LOG ); +usage (); + } + +/* inodes always aligned */ +if (iaflag !=1 ) { +fprintf (stderr, +_ ("Inodes always aligned for CRC enabled filesytems\n" )); +usage (); + } + +/* lazy sb counters always on */ +if (lazy_sb_counters !=1 ) { +fprintf (stderr, +_ ("Lazy superblock counted always enabled for CRC enabled filesytems\n" )); +usage (); + } + +/* version 2 logs always on */ +if (logversion !=2 ) { +fprintf (stderr, +_ ("V2 logs always enabled for CRC enabled filesytems\n" )); +usage (); + } + +/* attr2 always on */ +if (attrversion !=2 ) { +fprintf (stderr, +_ ("V2 attribute format always enabled on CRC enabled filesytems\n" )); +usage (); + } + +/* 32 bit project quota always on */ +/* attr2 always on */ +if (projid16bit ==1 ) { +fprintf (stderr, +_ ("32 bit Project IDs always enabled on CRC enabled filesytems\n" )); +usage (); + } + } +if (nsflag || nlflag) {if (dirblocksize < blocksize || dirblocksize >XFS_MAX_BLOCKSIZE ) {
@@ -2381,7 +2432,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n")," =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n" "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"), dfile, isize, (long long )agcount, (long long )agsize, -"" , sectorsize, attrversion, projid32bit, +"" , sectorsize, attrversion, !projid16bit,"" , crcs_enabled,"" , blocksize, (long long )dblocks, imaxpct, "", dsunit, dswidth,
@@ -2449,7 +2500,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n"), sbp->sb_logsectsize =0 ; } sbp->sb_features2 =XFS_SB_VERSION2_MKFS (crcs_enabled, lazy_sb_counters, - attrversion ==2 , projid32bit ==1 ,0 ); + attrversion ==2 , !projid16bit,0 ); sbp->sb_versionnum = XFS_SB_VERSION_MKFS(crcs_enabled, iaflag, dsunit != 0, logversion == 2, attrversion == 1,
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 39/48] mkfs.xfs: validate options for CRCs up front.
On Fri, Jun 07, 2013 at 10:26:02AM +1000, Dave Chinner wrote:
| From: Dave Chinner <[email protected]> | | With CRC enabled filesystems, certain options are now not optional | and so are always enabled. Validate these options up front and | abort if options are specified that cannot be set. | | Signed-off-by: Dave Chinner <[email protected]> | --- | mkfs/xfs_mkfs.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++----- | 1 file changed, 56 insertions(+), 5 deletions(-) | | diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c | index 291bab4..9987dde 100644 | --- a/mkfs/xfs_mkfs.c | +++ b/mkfs/xfs_mkfs.c ... | @@ -1754,6 +1754,57 @@ _("block size %d cannot be smaller than logical sector size %d\n"), | logversion = 2; | } | | + /* | + * Now we have blocks and sector sizes set up, check parameters that are | + * no longer optional for CRC enabled filesystems. Catch them up front | + * here before doing anything else. | + */ | + if (crcs_enabled) { | + /* minimum inode size is 512 bytes, ipflag checked later */ | + if ((isflag || ilflag) && inodelog < XFS_DINODE_DFL_CRC_LOG) { | + fprintf(stderr, | +_("Minimum inode size for CRCs is %d bytes\n"), | + 1 << XFS_DINODE_DFL_CRC_LOG); | + usage(); | + }
I am not satisfied with the explanation for not allowing 256 byte inodes with CRCs, and I am requesting that this limitation not be implemented. I have no issue with making the default inode size 512 bytes, but removing the option for 256 byte inodes is an issue, especially with the initial implementation. Making the minimum inode size 256 is fine.
Signature · 6 lines
Geoffrey Wehrman 651-683-5496 [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 39/48] mkfs.xfs: validate options for CRCs up front.
Quoted 35 lines · Geoffrey Wehrman
On Fri, Jun 07, 2013 at 10:26:02AM +1000, Dave Chinner wrote:
| From: Dave Chinner <[email protected]> | | With CRC enabled filesystems, certain options are now not optional | and so are always enabled. Validate these options up front and | abort if options are specified that cannot be set. | | Signed-off-by: Dave Chinner <[email protected]> | --- | mkfs/xfs_mkfs.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++----- | 1 file changed, 56 insertions(+), 5 deletions(-) | | diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c | index 291bab4..9987dde 100644 | --- a/mkfs/xfs_mkfs.c | +++ b/mkfs/xfs_mkfs.c ... | @@ -1754,6 +1754,57 @@ _("block size %d cannot be smaller than logical sector size %d\n"), | logversion = 2; | } | | + /* | + * Now we have blocks and sector sizes set up, check parameters that are | + * no longer optional for CRC enabled filesystems. Catch them up front | + * here before doing anything else. | + */ | + if (crcs_enabled) { | + /* minimum inode size is 512 bytes, ipflag checked later */ | + if ((isflag || ilflag) && inodelog < XFS_DINODE_DFL_CRC_LOG) { | + fprintf(stderr, | +_("Minimum inode size for CRCs is %d bytes\n"), | + 1 << XFS_DINODE_DFL_CRC_LOG); | + usage(); | + }
Quoted 5 lines
I am not satisfied with the explanation for not allowing 256 byte inodes with CRCs, and I am requesting that this limitation not be implemented. I have no issue with making the default inode size 512 bytes, but removing the option for 256 byte inodes is an issue, especially with the initial implementation. Making the minimum inode size 256 is fine.
As I said on the call, it makes no sense to support 256 byte inodes for CRC enabled filesystems for either a performance or a support point of view. For the purpose of this discussion on the list, I'll redo the calculations from first principles as the inode core size has grown since these checks were originally done way back in 2008- 2009 so everyone can see why it doesn't make sense.
To start with, the inode core size for version 1/2 inodes (i.e. without CRCs) is 100 bytes (including the di_next_unlinked field). With the 8 byte alignment rounding that the forks need, that gives us a literal area size of 152 bytes.
Back in 2008-2009, the new v3 inode format did not have all the self describing metadata, and so the core size increased to about 140 bytes. This left roughly 112 bytes of literal space available.
With the addition of the extra self describing metadata, the new v3 inode has grown to it's current size of 176 bytes, bring the literal area down to 80 bytes. That's smaller than I realised it was....
The minimum physical inode fork sizes are defined in xfs_types.h:
/*
* Min numbers of data/attr fork btree root pointers. */
#define MINDBTPTRS 3
#define MINABTPTRS 2
And their sizes are defined in xfs_bmap_btree.h:
#define XFS_BMDR_SPACE_CALC(nrecs) \
(int)(sizeof(xfs_bmdr_block_t) + \
((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))So:
minimum data fork size = XFS_BMDR_SPACE_CALC(3) = 4 + 3 * (8 + 8) = 52 bytes minimum attr fork size = XFS_BMDR_SPACE_CALC(2) = 36 bytes
And when we align these to 8 byte, we have minimum sizes of 56 bytes and 40 bytes for the data and attr forks respectively. That means we need at least 96 bytes of literal space available in the inode
So, we have:
literal space
required available
inode size v2 old v3 final v3
256 96 156 112 80
512 96 408 368 336
And so for the final v3 inode format there is only be 80 bytes of literal space available, which is not enough to fit minimally sized data and attr forks simultaneously with a 256 byte inode size. i.e. it's not a physically valid configuration.
IOWs, there's nothing to debate - 256 byte inodes in v3 format is not physically possible with the current on-disk format definitions...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 39/48] mkfs.xfs: validate options for CRCs up front.
On Fri, Jun 21, 2013 at 09:05:34AM +1000, Dave Chinner wrote:
| On Thu, Jun 20, 2013 at 04:17:47PM -0500, Geoffrey Wehrman wrote: | > On Fri, Jun 07, 2013 at 10:26:02AM +1000, Dave Chinner wrote: | > | From: Dave Chinner <[email protected]> | > | | > | With CRC enabled filesystems, certain options are now not optional | > | and so are always enabled. Validate these options up front and | > | abort if options are specified that cannot be set. | > | | > | Signed-off-by: Dave Chinner <[email protected]> | > | --- | > | mkfs/xfs_mkfs.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++----- | > | 1 file changed, 56 insertions(+), 5 deletions(-) | > | | > | diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c | > | index 291bab4..9987dde 100644 | > | --- a/mkfs/xfs_mkfs.c | > | +++ b/mkfs/xfs_mkfs.c | > ... | > | @@ -1754,6 +1754,57 @@ _("block size %d cannot be smaller than logical sector size %d\n"), | > | logversion = 2; | > | } | > | | > | + /* | > | + * Now we have blocks and sector sizes set up, check parameters that are | > | + * no longer optional for CRC enabled filesystems. Catch them up front | > | + * here before doing anything else. | > | + */ | > | + if (crcs_enabled) { | > | + /* minimum inode size is 512 bytes, ipflag checked later */ | > | + if ((isflag || ilflag) && inodelog < XFS_DINODE_DFL_CRC_LOG) { | > | + fprintf(stderr, | > | +_("Minimum inode size for CRCs is %d bytes\n"), | > | + 1 << XFS_DINODE_DFL_CRC_LOG); | > | + usage(); | > | + } | > | > I am not satisfied with the explanation for not allowing 256 byte inodes | > with CRCs, and I am requesting that this limitation not be implemented. | > I have no issue with making the default inode size 512 bytes, but | > removing the option for 256 byte inodes is an issue, especially with the | > initial implementation. Making the minimum inode size 256 is fine. | | IOWs, there's nothing to debate - 256 byte inodes in v3 format is | not physically possible with the current on-disk format | definitions...
I should have done the math. I didn't realize how bloated v4 inodes are.
Signature · 6 lines
Geoffrey Wehrman 651-683-5496 [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 39/48] mkfs.xfs: validate options for CRCs up front.
In reply to Dave ChinnerQuoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
With CRC enabled filesystems, certain options are now not optional and so are always enabled. Validate these options up front and abort if options are specified that cannot be set.
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 40/48 xfsprogs: support CRC enabled filesystem detection
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Add the XFS_FSOP_GEOM_FLAGS_V5SB flag to the XFS_IOC_FSGEOMETRY ioctl to allow utilities like xfs_info to detect that the filesystem is CRC enabled.
While touching xfs_info, add projid32bit output as well.
--- growfs/xfs_growfs.c | 16 ++++++++++++---- include/xfs_fs.h | 1 + mkfs/xfs_mkfs.c | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-)
growfs/xfs_growfs.c +12 -4
@@ -53,11 +53,14 @@ report_info( int dirversion, int logversion, int attrversion, + int projid32bit, + int crcs_enabled, int cimode) { printf(_("meta-data=%-22s isize=%-6u agcount=%u, agsize=%u blks\n" -" =%-22s sectsz=%-5u attr=%u\n" +" =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n" +" =%-22s crc=%u\n" "data =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n" " =%-22s sunit=%-6u swidth=%u blks\n" "naming =version %-14u bsize=%-6u ascii-ci=%d\n"
@@ -66,7 +69,8 @@ report_info( "realtime =%-22s extsz=%-6u blocks=%llu, rtextents=%llu\n"), mntpoint, geo.inodesize, geo.agcount, geo.agblocks, -"" , geo.sectsize, attrversion, +"" , geo.sectsize, attrversion, projid32bit, +"" , crcs_enabled,"" , geo.blocksize, (unsigned long long )geo.datablocks, geo.imaxpct, "", geo.sunit, geo.swidth,
@@ -115,6 +119,8 @@ main(int argc, char **argv)char *rtdev;/* RT device name */ fs_path_t *fs;/* mount point information */ libxfs_init_t xi;/* libxfs structure */ +int projid32bit; +int crcs_enabled; progname =basename (argv[0 ]);setlocale (LC_ALL ,"" );
@@ -234,10 +240,12 @@ main(int argc, char **argv) attrversion = geo.flags &XFS_FSOP_GEOM_FLAGS_ATTR2 ?2 : \ (geo.flags &XFS_FSOP_GEOM_FLAGS_ATTR ?1 :0 ); ci = geo.flags &XFS_FSOP_GEOM_FLAGS_DIRV2CI ?1 :0 ; + projid32bit = geo.flags &XFS_FSOP_GEOM_FLAGS_PROJID32 ?1 :0 ; + crcs_enabled = geo.flags &XFS_FSOP_GEOM_FLAGS_V5SB ?1 :0 ;if (nflag) {report_info (geo, datadev, isint, logdev, rtdev, lazycount, dirversion, logversion, - attrversion, ci); + attrversion, projid32bit, crcs_enabled, ci);exit (0 ); }
@@ -274,7 +282,7 @@ main(int argc, char **argv)report_info (geo, datadev, isint, logdev, rtdev, lazycount, dirversion, logversion, - attrversion, ci); + attrversion, projid32bit, crcs_enabled, ci); ddsize = xi.dsize; dlsize = ( xi.logBBsize? xi.logBBsize :
include/xfs_fs.h +1 -0
@@ -236,6 +236,7 @@ typedef struct xfs_fsop_resblks {#define XFS_FSOP_GEOM_FLAGS_PROJID32 0x0800/* 32-bit project IDs */ #define XFS_FSOP_GEOM_FLAGS_DIRV2CI 0x1000/* ASCII only CI names */ #define XFS_FSOP_GEOM_FLAGS_LAZYSB 0x4000/* lazy superblock counters */ +#define XFS_FSOP_GEOM_FLAGS_V5SB 0x8000/* version 5 superblock */ /*
mkfs/xfs_mkfs.c +1 -1
@@ -2424,7 +2424,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n"), printf(_( "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n" " =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n" - " =%-22s crc=%-5u\n" + " =%-22s crc=%u\n" "data =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n" " =%-22s sunit=%-6u swidth=%u blks\n" "naming =version %-14u bsize=%-6u ascii-ci=%d\n"
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 40/48] xfsprogs: support CRC enabled filesystem detection
Quoted 94 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Add the
XFS_FSOP_GEOM_FLAGS_V5SBflag to theXFS_IOC_FSGEOMETRYioctl to allow utilities likexfs_infoto detect that the filesystem is CRC enabled.While touching
xfs_info, add projid32bit output as well.Signed-off-by Dave Chinner <[email protected]>--- growfs/xfs_growfs.c | 16 ++++++++++++---- include/xfs_fs.h | 1 + mkfs/xfs_mkfs.c | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-)growfs/xfs_growfs.c +12
-4@@ -53,11 +53,14 @@ report_info( int dirversion, int logversion, int attrversion, + int projid32bit, + int crcs_enabled, int cimode) { printf(_("meta-data=%-22s isize=%-6u agcount=%u, agsize=%u blks\n" -" =%-22s sectsz=%-5u attr=%u\n" +" =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n" +" =%-22s crc=%u\n" "data =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n" " =%-22s sunit=%-6u swidth=%u blks\n" "naming =version %-14u bsize=%-6u ascii-ci=%d\n" @@ -66,7 +69,8 @@ report_info( "realtime =%-22s extsz=%-6u blocks=%llu, rtextents=%llu\n"), mntpoint, geo.inodesize, geo.agcount, geo.agblocks, -"" , geo.sectsize, attrversion, +"" , geo.sectsize, attrversion, projid32bit, +"" , crcs_enabled,"" , geo.blocksize, (unsigned long long )geo.datablocks, geo.imaxpct, "", geo.sunit, geo.swidth,@@ -115,6 +119,8 @@ main(int argc, char **argv)char *rtdev;/* RT device name */ fs_path_t *fs;/* mount point information */ libxfs_init_t xi;/* libxfs structure */ +int projid32bit; +int crcs_enabled; progname =basename (argv[0 ]);setlocale (LC_ALL ,"" );@@ -234,10 +240,12 @@ main(int argc, char **argv) attrversion = geo.flags &XFS_FSOP_GEOM_FLAGS_ATTR2 ?2 : \ (geo.flags &XFS_FSOP_GEOM_FLAGS_ATTR ?1 :0 ); ci = geo.flags &XFS_FSOP_GEOM_FLAGS_DIRV2CI ?1 :0 ; + projid32bit = geo.flags &XFS_FSOP_GEOM_FLAGS_PROJID32 ?1 :0 ; + crcs_enabled = geo.flags &XFS_FSOP_GEOM_FLAGS_V5SB ?1 :0 ;if (nflag) {report_info (geo, datadev, isint, logdev, rtdev, lazycount, dirversion, logversion, - attrversion, ci); + attrversion, projid32bit, crcs_enabled, ci);exit (0 ); }@@ -274,7 +282,7 @@ main(int argc, char **argv)report_info (geo, datadev, isint, logdev, rtdev, lazycount, dirversion, logversion, - attrversion, ci); + attrversion, projid32bit, crcs_enabled, ci); ddsize = xi.dsize; dlsize = ( xi.logBBsize? xi.logBBsize :include/xfs_fs.h +1
-0@@ -236,6 +236,7 @@ typedef struct xfs_fsop_resblks {#define XFS_FSOP_GEOM_FLAGS_PROJID32 0x0800/* 32-bit project IDs */ #define XFS_FSOP_GEOM_FLAGS_DIRV2CI 0x1000/* ASCII only CI names */ #define XFS_FSOP_GEOM_FLAGS_LAZYSB 0x4000/* lazy superblock counters */ +#define XFS_FSOP_GEOM_FLAGS_V5SB 0x8000/* version 5 superblock */ /* mkfs/xfs_mkfs.c +0
-0
mkfs/xfs_mkfs.c an AG size that is one stripe unit smaller, for example %llu.\n"), · line 2430
Quoted 8 lines
mkfs/xfs_mkfs.c +1
-1@@ -2424,7 +2424,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n"), printf(_( "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n" " =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n" - " =%-22s crc=%-5u\n" + " =%-22s crc=%u\n" "data =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n" " =%-22s sunit=%-6u swidth=%u blks\n" "naming =version %-14u bsize=%-6u ascii-ci=%d\n"
D'oh. Looks like I missed that in the previous patch, where the additional args are added to the print, but not the format string.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 41/48 xfs_mdrestore: recalculate sb CRC before writing
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
xfs_mdrestore writes the superblock after modifying it, and so the CRC is not necessarily correct. make sure the CRC is correct before we write the superblock back.
--- mdrestore/xfs_mdrestore.c | 5 +++++ 1 file changed, 5 insertions(+)
mdrestore/xfs_mdrestore.c +5 -0
@@ -169,6 +169,11 @@ perform_restore(memset (block_buffer,0 , sb.sb_sectsize); sb.sb_inprogress =0 ;libxfs_sb_to_disk ((xfs_dsb_t *)block_buffer, &sb,XFS_SB_ALL_BITS ); +if (xfs_sb_version_hascrc (&sb)) { +xfs_update_cksum (block_buffer, sb.sb_sectsize, + offsetof(struct xfs_sb , sb_crc)); + } +if (pwrite (dst_fd, block_buffer, sb.sb_sectsize,0 ) <0 )fatal ("error writing primary superblock: %s\n" ,strerror (errno));
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 41/48] xfs_mdrestore: recalculate sb CRC before writing
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
xfs_mdrestorewrites the superblock after modifying it, and so the CRC is not necessarily correct. make sure the CRC is correct before we write the superblock back.Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 42/48 xfs_metadump: requires some object CRC recalculation
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
And we can't do that right now through xfs_db, so disable metadump and restore for CRC enabled filesystems until the issues have been sorted out.
--- db/metadump.c | 5 +++++ mdrestore/xfs_mdrestore.c | 3 +++ 2 files changed, 8 insertions(+)
db/metadump.c +5 -0
@@ -2050,6 +2050,11 @@ metadump_f(return 0 ; } +if (xfs_sb_version_hascrc (&mp->m_sb) && dont_obfuscate ==0 ) { +print_warning ("Can't obfuscate CRC enabled filesystems yet." ); +return 0 ; + } + metablock = (xfs_metablock_t *)calloc (BBSIZE +1 ,BBSIZE );if (metablock ==NULL ) {print_warning ("memory allocation failure" );
mdrestore/xfs_mdrestore.c +3 -0
@@ -109,6 +109,9 @@ perform_restore(if (sb.sb_magicnum !=XFS_SB_MAGIC )fatal ("bad magic number for primary superblock\n" ); +if (xfs_sb_version_hascrc (&sb)) +fatal ("Can't restore CRC enabled filesystems yet.\n" ); + ((xfs_dsb_t *)block_buffer)->sb_inprogress =1 ;if (is_target_file) {
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 42/48] xfs_metadump: requires some object CRC recalculation
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
And we can't do that right now through
xfs_db, so disable metadump and restore for CRC enabled filesystems until the issues have been sorted out.Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 43/48 xfs_repair: drop buffer reference on symlink error
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Failing to drop the buffer when the header is bad results in a deadlock in a later phase when we try to read the remote symlink again.
--- repair/dinode.c | 1 + 1 file changed, 1 insertion(+)
repair/dinode.c +1 -0
@@ -1523,6 +1523,7 @@ _("cannot read inode %" PRIu64 ", file block %d, disk block %" PRIu64 "\n"),do_warn (_ ("bad symlink header ino %" PRIu64", file block %d, disk block %" PRIu64"\n" ), lino, i, fsbno); +libxfs_putbuf (bp);return (1 ); } buf_data +=sizeof (struct xfs_dsymlink_hdr );
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 43/48] xfs_repair: drop buffer reference on symlink error
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Failing to drop the buffer when the header is bad results in a deadlock in a later phase when we try to read the remote symlink again.
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 44/48 xfs_db: add support for CRC format remote symlinks
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- db/Makefile | 2 +- db/field.c | 6 +++++ db/field.h | 4 +++ db/symlink.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ db/symlink.h | 26 +++++++++++++++++++ db/type.c | 3 ++- 6 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 db/symlink.c create mode 100644 db/symlink.h
db/Makefile +1 -1
@@ -12,7 +12,7 @@ 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 malloc.h metadump.h output.h print.h quit.h sb.h sig.h strvec.h \ - text.h type.h write.h attrset.h + text.h type.h write.h attrset.h symlink.h CFILES = $(HFILES:.h=.c) LSRCFILES = xfs_admin.sh xfs_check.sh xfs_ncheck.sh xfs_metadump.sh
db/field.c +6 -0
@@ -34,6 +34,7 @@#include "dquot.h" #include "dir2.h" #include "dir2sf.h" +#include "symlink.h" const ftattr_t ftattrtab[] = { {FLDT_AEXTNUM ,"aextnum" , fp_num,"%d" ,SI (bitsz (xfs_aextnum_t)),
@@ -300,6 +301,11 @@ const ftattr_t ftattrtab[] = { NULL, NULL }, {FLDT_SB ,"sb" ,NULL , (char *)sb_flds, sb_size,FTARG_SIZE ,NULL , sb_flds }, + +/* CRC enabled symlink */ + { FLDT_SYMLINK_CRC, "symlink", NULL, (char *)symlink_crc_flds, + symlink_size, FTARG_SIZE, NULL, symlink_crc_flds }, + { FLDT_TIME, "time", fp_time, NULL, SI(bitsz(__int32_t)), FTARG_SIGNED, NULL, NULL }, { FLDT_TIMESTAMP, "timestamp", NULL, (char *)timestamp_flds,
db/field.h +4 -0
@@ -150,6 +150,10 @@ typedef enum fldt {FLDT_QCNT ,FLDT_QWARNCNT ,FLDT_SB , + +/* CRC enabled symlink */ +FLDT_SYMLINK_CRC , +FLDT_TIME ,FLDT_TIMESTAMP , FLDT_UINT1,
db/symlink.c new file +81 -0
81 lines not on this page · raw message
db/symlink.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (c) 2013 Red Hat, 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 +*/ +#ifndef __XFS_DB_SYMLINK_H +#define __XFS_DB_SYMLINK_H + +extern const struct field symlink_crc_hfld[]; +extern const struct field symlink_crc_flds[]; + +extern int symlink_size (void *obj,int startoff,int idx); + +#endif /* __XFS_DB_SYMLINK_H */
db/type.c +2 -1
@@ -38,6 +38,7 @@#include "dquot.h" #include "dir2.h" #include "text.h" +#include "symlink.h" static const typ_t *findtyp (char *name);static int type_f (int argc,char **argv);
@@ -91,7 +92,7 @@ static const typ_t __typtab_crc[] = { { TYP_RTBITMAP, "rtbitmap", NULL, NULL }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL }, { TYP_SB, "sb", handle_struct, sb_hfld }, - { TYP_SYMLINK, "symlink", handle_string, NULL }, + { TYP_SYMLINK, "symlink", handle_struct, symlink_crc_hfld }, { TYP_TEXT, "text", handle_text, NULL }, { TYP_NONE, NULL } };
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 44/48] xfs_db: add support for CRC format remote symlinks
Quoted 3 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Signed-off-by Dave Chinner <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs