xfsprogs: Initial CRC support
cover xfsprogs: Initial CRC support
Hi Folks,
This is the first real "works ok" CRC patchset for xfsprogs. It provides full support for mkfs.xfs and xfs_repair, and partial read-only support for xfs_db.
For mkfs.xfs, it does everything properly, and filesystems that are freshly made also run cleanly through xfs_repair and mount and run just fine.
For xfs_repair, it reads and writes all metadata with CRC checks, calculations and validation just like the kernel code does, but it currently silently ignores the validation done in the IO layer. Enabling that is future work - it involves adding buffer error checking to every libxfs_readbuf() call that is made, and we do none of that right now. It does, however, fully validate all the non-CRC format metadata just as it does for non-CRC filesystems, and so the coverage it has is the same for both CRC and non-CRC filesystems.
For xfs_db, there is read-only support for looking at the filesystem as the xfs_db IO stack does not support CRCs at all. We need to convert xfs_db to use the libxfs infrastructure to enable that. Apart from that, xfs_db has partial support for the extended metadata fields - the directory/attribute blocks don't have extended support yet, but everything else does.
xfs_check is made special. It currently detects a version 5 superblock, and immediately exits with success. Hence it always says CRC enabled filesystems are OK. This is a temporary change that enables running xfstests without full support in xfs_db for all the new metadata structures (like headers in remote symlink and attribute blocks). Depending on if we want to keep xfs-check useful for xfstests, we can revisit this bypass hack once xfs_db has been converted to use the libxfs IO engine.
Overall, xfstests is now running enough to start to find bugs in the kernel CRC code - I'm mainly hitting remote attribute block bugs right now (generic/117!) but there's certainly less problems being reported than I expected.
Oh, and I've tested it with external log devices and real time devices, too.
Comments, thoughts, flames, and testing all welcome!
Cheers,
Dave.
$ git diff --minimal --stat --summary 8e78288.. copy/xfs_copy.c | 4 +- db/agf.c | 3 + db/agfl.c | 16 + db/agfl.h | 2 + db/agi.c | 3 + db/attr.c | 20 +- db/btblock.c | 145 +++++ db/btblock.h | 10 + db/check.c | 34 +- db/dir2.c | 10 +- db/dir2sf.c | 9 +- db/field.c | 16 + db/field.h | 8 + db/freesp.c | 13 +- db/init.c | 19 + db/inode.c | 27 + db/inode.h | 3 + db/metadump.c | 4 +- db/sb.c | 54 +- db/type.c | 34 +- db/type.h | 3 +- include/Makefile | 4 +- include/libxfs.h | 118 ++-- include/libxlog.h | 2 +- include/xfs_ag.h | 54 +- include/xfs_alloc_btree.h | 13 +- include/xfs_attr_leaf.h | 124 +++- include/xfs_attr_remote.h | 52 ++ include/xfs_bmap_btree.h | 20 +- include/xfs_btree.h | 63 +- include/xfs_buf_item.h | 64 +- include/xfs_da_btree.h | 130 +++- include/xfs_dinode.h | 37 +- include/xfs_dir2.h | 7 + include/xfs_dir2_format.h | 293 ++++++++- include/xfs_ialloc_btree.h | 10 +- include/xfs_inode.h | 26 + include/xfs_mount.h | 1 + include/xfs_quota.h | 11 +- include/xfs_sb.h | 166 ++++- include/xfs_symlink.h | 45 ++ libxfs/Makefile | 4 +- libxfs/init.c | 84 ++- libxfs/logitem.c | 4 +- libxfs/rdwr.c | 236 ++++--- libxfs/trans.c | 17 +- libxfs/util.c | 29 +- libxfs/xfs.h | 37 +- libxfs/xfs_alloc.c | 202 ++++-- libxfs/xfs_alloc_btree.c | 99 ++- libxfs/xfs_attr.c | 386 ++---------- libxfs/xfs_attr_leaf.c | 1553 ++++++++++++++++++++++++++-------------------- libxfs/xfs_attr_remote.c | 527 ++++++++++++++++ libxfs/xfs_bmap.c | 49 +- libxfs/xfs_bmap_btree.c | 107 +++- libxfs/xfs_btree.c | 255 ++++++-- libxfs/xfs_da_btree.c | 1499 +++++++++++++++++++++++++++----------------- libxfs/xfs_dir2_block.c | 171 +++-- libxfs/xfs_dir2_data.c | 266 +++++--- libxfs/xfs_dir2_leaf.c | 880 ++++++++++++++++---------- libxfs/xfs_dir2_node.c | 1007 +++++++++++++++++++----------- libxfs/xfs_dir2_priv.h | 46 +- libxfs/xfs_dir2_sf.c | 8 +- libxfs/xfs_ialloc.c | 78 ++- libxfs/xfs_ialloc_btree.c | 80 ++- libxfs/xfs_inode.c | 124 +++- libxfs/xfs_mount.c | 137 +++- libxfs/xfs_symlink.c | 154 +++++ logprint/log_misc.c | 51 +- logprint/log_print_all.c | 3 +- logprint/log_print_trans.c | 18 + logprint/logprint.c | 4 +- mdrestore/Makefile | 2 +- mkfs/maxtrres.c | 4 +- mkfs/proto.c | 6 +- mkfs/xfs_mkfs.c | 170 +++-- mkfs/xfs_mkfs.h | 12 +- repair/agheader.c | 36 +- repair/attr_repair.c | 173 +++--- repair/dino_chunks.c | 13 +- repair/dinode.c | 200 +++--- repair/dir2.c | 167 ++--- repair/dir2.h | 6 +- repair/phase2.c | 8 +- repair/phase3.c | 2 +- repair/phase5.c | 156 +++-- repair/phase6.c | 172 +++-- repair/prefetch.c | 9 +- repair/rt.c | 4 +- repair/scan.c | 169 ++--- repair/scan.h | 12 +- repair/versions.c | 2 +- repair/xfs_repair.c | 8 +- 93 files changed, 7559 insertions(+), 3564 deletions(-) create mode 100644 include/xfs_attr_remote.h create mode 100644 include/xfs_symlink.h create mode 100644 libxfs/xfs_attr_remote.c create mode 100644 libxfs/xfs_symlink.c
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/30 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
Re: [PATCH 01/30] mkfs: fix realtime device initialisation
Quoted 8 lines · Dave Chinner
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.Signed-off-by Dave Chinner <[email protected]>
Applied to the master branch.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/30 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
PATCH 3/30 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
PATCH 4/30 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
PATCH 5/30 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
PATCH 6/30 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
PATCH 7/30 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
PATCH 8/30 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
PATCH 9/30 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
PATCH 10/30 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
PATCH 11/30 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
PATCH 12/30 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
PATCH 13/30 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
PATCH 14/30 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.
PATCH 15/30 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.
PATCH 16/30 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
PATCH 17/30 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
PATCH 18/30 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
PATCH 19/30 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
PATCH 20/30 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
PATCH 21/30 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
PATCH 22/30 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
PATCH 23/30 patch xfsprogs-mkfs-crc-support-2
In reply to Dave Chinner--- 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
PATCH 24/30 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
PATCH 25/30 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
PATCH 26/30 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
PATCH 27/30 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
PATCH 28/30 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
PATCH 29/30 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
PATCH 30/30 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
Quoted 40 lines · Dave Chinner
Hi Folks,
This is the first real "works ok" CRC patchset for xfsprogs. It provides full support for mkfs.xfs and
xfs_repair, and partial read-only support forxfs_db.For mkfs.xfs, it does everything properly, and filesystems that are freshly made also run cleanly through
xfs_repairand mount and run just fine.For
xfs_repair, it reads and writes all metadata with CRC checks, calculations and validation just like the kernel code does, but it currently silently ignores the validation done in the IO layer. Enabling that is future work - it involves adding buffer error checking to everylibxfs_readbuf()call that is made, and we do none of that right now. It does, however, fully validate all the non-CRC format metadata just as it does for non-CRC filesystems, and so the coverage it has is the same for both CRC and non-CRC filesystems.For
xfs_db, there is read-only support for looking at the filesystem as thexfs_dbIO stack does not support CRCs at all. We need to convertxfs_dbto use the libxfs infrastructure to enable that. Apart from that,xfs_dbhas partial support for the extended metadata fields - the directory/attribute blocks don't have extended support yet, but everything else does.
xfs_checkis made special. It currently detects a version 5 superblock, and immediately exits with success. Hence it always says CRC enabled filesystems are OK. This is a temporary change that enables running xfstests without full support inxfs_dbfor all the new metadata structures (like headers in remote symlink and attribute blocks). Depending on if we want to keep xfs-check useful for xfstests, we can revisit this bypass hack oncexfs_dbhas been converted to use the libxfs IO engine.Overall, xfstests is now running enough to start to find bugs in the kernel CRC code - I'm mainly hitting remote attribute block bugs right now (generic/117!) but there's certainly less problems being reported than I expected.
Quoted 8 lines
Oh, and I've tested it with external log devices and real time devices, too.
Comments, thoughts, flames, and testing all welcome!
Cheers,
Dave.
OK. The basics look good so far. The patchset applied without need for additional work with vi and patch. Whitespace errors were reported for Patches 8, 14, 16, 17, 24, 25, and 27. xfsprogs built with no additional errors over a normal xfsprogs build.
That all stated, the tar -xvf qt-source.tar.xz still fails on a CRC-enabled filesystem. Worse, until I return home, I won't be able to do serial-console capture of hard oopses. However, the initial oops I got was a soft one, so it is included after my closing. The kernel is this...
last night's kernel git
last night's xfs-oss/master
some of your recent patches (didn't apply your 6_5 patch yet)
J. Liu's most recent patchset + 2 older bitness patches
Chandra's v8 pquota/gquota patchset + one E-mail fix
Shaggy's JFS patch to make it through the old xfstests #068 on JFS
an NILFS2 patch to address broken bmap handling, lurked from the NILFS2 mailing list
one local removed assert to make it through the old xfstests #111
maybe one or two XFS patches beyond this
...all on a 32-bit Pentium 4.
What I'm trying to state is that a lot is in there, but the PC is spinning like a top, and xfstests results are really good right now. However, if I feel the need to provide a fresh environment, patch management is taking some time.
Great job on a fine patchset so far, and good luck!
Michael
[ 6188.126012] XFS: Assertion failed: first <= last && last < BBTOB(bp->b_length), file: fs/xfs/xfs_trans_buf.c, line: 569 [ 6188.137663] ------------[ cut here ]------------ [ 6188.143109] kernel BUG at fs/xfs/xfs_message.c:108! [ 6188.147632] invalid opcode: 0000 [#1] [ 6188.147632] CPU: 0 PID: 12676 Comm: tar Not tainted 3.10.0-rc1+ #25 [ 6188.147632] Hardware name: Dell Computer Corporation Dimension 2350/07W080, BIOS A01 12/17/2002 [ 6188.147632] task: e0ef53e0 ti: ea330000 task.ti: ea330000 [ 6188.147632] EIP: 0060:[<c1170664>] EFLAGS: 00010282 CPU: 0 [ 6188.147632] EIP is at assfail+0x26/0x28 [ 6188.147632] EAX: 0000006b EBX: ea042630 ECX: 00000000 EDX: c1689820 [ 6188.147632] ESI: d94a3900 EDI: ea347aa8 EBP: ea331bf0 ESP: ea331bdc [ 6188.147632] DS: 007b ES: 007b FS: 0000 GS: 00e0 SS: 0068 [ 6188.147632] CR0: 8005003b CR2: b74f0000 CR3: 1964e000 CR4: 000007d0 [ 6188.147632] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000 [ 6188.147632] DR6: ffff0ff0 DR7: 00000400 [ 6188.147632] Stack: [ 6188.147632] 00000000 c160a688 c1613b74 c15fe01d 00000239 ea331c08 c11c6d67 00001ff6 [ 6188.147632] d94a5ffc d94a5000 d94a3900 ea331c24 c11a0653 00001ff7 ea347aa8 d94a5ffc [ 6188.147632] 00000ffc d94a5000 ea331c54 c11a0e45 d94a3900 ea347aa8 01ff0034 d94a5030 [ 6188.147632] Call Trace: [ 6188.147632] [<c11c6d67>] xfs_trans_log_buf+0x64/0x11b [ 6188.147632] [<c11a0653>] xfs_dir2_data_log_unused+0x7b/0x83 [ 6188.147632] [<c11a0e45>] xfs_dir2_data_use_free+0x1bf/0x41a [ 6188.147632] [<c11a308b>] xfs_dir2_leaf_addname+0x307/0x6f2 [ 6188.147632] [<c119d32f>] xfs_dir_createname+0x113/0x129 [ 6188.147632] [<c1174633>] xfs_create+0x3e0/0x4fb [ 6188.147632] [<c116e555>] xfs_vn_mknod+0x8f/0x15a [ 6188.147632] [<c116e620>] ? xfs_vn_mknod+0x15a/0x15a [ 6188.147632] [<c116e635>] xfs_vn_create+0x15/0x17 [ 6188.147632] [<c109eb31>] vfs_create+0x68/0xeb [ 6188.147632] [<c109f410>] do_last+0x85c/0xc45 [ 6188.147632] [<c109cf53>] ? inode_permission+0x11/0x3e [ 6188.147632] [<c109d955>] ? link_path_walk+0x4f/0x67f [ 6188.147632] [<c109f898>] path_openat+0x9f/0x38d [ 6188.147632] [<c109fbac>] do_filp_open+0x26/0x6b [ 6188.147632] [<c12ad0c6>] ? tty_write_unlock+0x2d/0x33 [ 6188.147632] [<c109cc94>] ? getname_flags+0x86/0x118 [ 6188.147632] [<c1095157>] do_sys_open+0xf0/0x1ae [ 6188.147632] [<c109524f>] SyS_openat+0x1b/0x1d [ 6188.147632] [<c14d5d4c>] syscall_call+0x7/0xb [ 6188.147632] [<c14d0000>] ? spurious_fault+0xbf/0xc2 [ 6188.147632] Code: 56 eb ff c9 c3 55 89 e5 83 ec 14 89 4c 24 10 89 54 24 0c 89 44 24 08 c7 44 24 04 88 a6 60 c1 c7 04 24 00 00 00 00 e8 e4 fd ff ff <0f> 0b 55 89 e5 83 ec 14 c7 44 24 10 01 00 00 00 89 54 24 0c 89 [ 6188.147632] EIP: [<c1170664>] assfail+0x26/0x28 SS:ESP 0068:ea331bdc [ 6188.415714] ---[ end trace c213c626812e5949 ]--- [ 6211.447695] XFS (sdb5): Version 5 superblock detected. This kernel has EXPERIMENTAL support enabled! [ 6211.447695] Use of these features in this kernel is at your own risk!
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 46 lines · Michael L. Semon
Quoted 45 lines · Dave Chinner
Hi Folks,
This is the first real "works ok" CRC patchset for xfsprogs. It provides full support for mkfs.xfs and
xfs_repair, and partial read-only support forxfs_db.For mkfs.xfs, it does everything properly, and filesystems that are freshly made also run cleanly through
xfs_repairand mount and run just fine.For
xfs_repair, it reads and writes all metadata with CRC checks, calculations and validation just like the kernel code does, but it currently silently ignores the validation done in the IO layer. Enabling that is future work - it involves adding buffer error checking to everylibxfs_readbuf()call that is made, and we do none of that right now. It does, however, fully validate all the non-CRC format metadata just as it does for non-CRC filesystems, and so the coverage it has is the same for both CRC and non-CRC filesystems.For
xfs_db, there is read-only support for looking at the filesystem as thexfs_dbIO stack does not support CRCs at all. We need to convertxfs_dbto use the libxfs infrastructure to enable that. Apart from that,xfs_dbhas partial support for the extended metadata fields - the directory/attribute blocks don't have extended support yet, but everything else does.
xfs_checkis made special. It currently detects a version 5 superblock, and immediately exits with success. Hence it always says CRC enabled filesystems are OK. This is a temporary change that enables running xfstests without full support inxfs_dbfor all the new metadata structures (like headers in remote symlink and attribute blocks). Depending on if we want to keep xfs-check useful for xfstests, we can revisit this bypass hack oncexfs_dbhas been converted to use the libxfs IO engine.Overall, xfstests is now running enough to start to find bugs in the kernel CRC code - I'm mainly hitting remote attribute block bugs right now (generic/117!) but there's certainly less problems being reported than I expected.
Oh, and I've tested it with external log devices and real time devices, too.
Comments, thoughts, flames, and testing all welcome!
Quoted 8 lines
Quoted 3 lines
Cheers,
Dave.
OK. The basics look good so far. The patchset applied without need for additional work with vi and patch. Whitespace errors were reported for Patches 8, 14, 16, 17, 24, 25, and 27. xfsprogs built with no additional errors over a normal xfsprogs build.
Can you send me the output indicating where the whitespace errors are? I don't get any warnings from guilt about them when I apply the patchset here...
Quoted 2 lines
That all stated, the
tar -xvf qt-source.tar.xzstill fails on a CRC-enabled filesystem.
Not surprising - I haven't got a crc enabled filesystem all the way through xfstests yet. remote attributes are the current piece I'm working on getting fixed.
Quoted 17 lines
Worse, until I return home, I won't be able
to do serial-console capture of hard oopses. However, the initial oops I got was a soft one, so it is included after my closing. The kernel is this...last night's kernel git
last night's xfs-oss/master
some of your recent patches (didn't apply your 6_5 patch yet)
J. Liu's most recent patchset + 2 older bitness patches
Chandra's v8 pquota/gquota patchset + one E-mail fix
Shaggy's JFS patch to make it through the old xfstests #068 on JFS
Quoted 8 lines
an NILFS2 patch to address broken bmap handling, lurked from the NILFS2 mailing list
one local removed assert to make it through the old xfstests #111
maybe one or two XFS patches beyond this
...all on a 32-bit Pentium 4.
And reporting bugs :)
Quoted 4 lines
What I'm trying to state is that a lot is in there, but the PC is spinning like a top, and xfstests results are really good right now. However, if I feel the need to provide a fresh environment, patch management is taking some time.
How are you managing patches right now? When taking in a new patchset from a mailing list, I save them all in a mbox file, then use git-am to apply them to a temporary git branch. I then move to my real working branch, and do a 'guilt import-commit x..y' to convert the commits in the temporary branch to a set of guilt patches, and then go from there....
The worst step for me is, by far, the git-am step. Resolving patch conflicts is painful because you have to manually apply the patch, then remember to git add all the files modified by the patch, etc.
It'd be really cool if guilt could do the import directly from the mbox file without applying the patches, so the normal guilt force-push-fix-and-refresh method of solving patch conflicts could be used instead of git-am.
/me wonders if #jeffpc is listening here....
Quoted 1 line
Great job on a fine patchset so far, and good luck!
Keep the bug reports rolling in, Michael. ;)
Quoted 5 lines
Michael
[ 6188.126012] XFS: Assertion failed: first <= last && last <
BBTOB(bp->b_length), file:fs/xfs/xfs_trans_buf.c, line: 569
Hmmm - that seems familiar - I thought I'd already fixed a bug like that previously...
Quoted 6 lines
[ 6188.147632] [<c11c6d67>] xfs_trans_log_buf+0x64/0x11b [ 6188.147632] [<c11a0653>] xfs_dir2_data_log_unused+0x7b/0x83 [ 6188.147632] [<c11a0e45>] xfs_dir2_data_use_free+0x1bf/0x41a [ 6188.147632] [<c11a308b>] xfs_dir2_leaf_addname+0x307/0x6f2 [ 6188.147632] [<c119d32f>] xfs_dir_createname+0x113/0x129 [ 6188.147632] [<c1174633>] xfs_create+0x3e0/0x4fb
I'll look into that further - it's a different problem to what I'm stuck on at the moment...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 111 lines · Dave Chinner
Quoted 46 lines · Michael L. Semon
Quoted 45 lines · Dave Chinner
Hi Folks,
This is the first real "works ok" CRC patchset for xfsprogs. It provides full support for mkfs.xfs and
xfs_repair, and partial read-only support forxfs_db.For mkfs.xfs, it does everything properly, and filesystems that are freshly made also run cleanly through
xfs_repairand mount and run just fine.For
xfs_repair, it reads and writes all metadata with CRC checks, calculations and validation just like the kernel code does, but it currently silently ignores the validation done in the IO layer. Enabling that is future work - it involves adding buffer error checking to everylibxfs_readbuf()call that is made, and we do none of that right now. It does, however, fully validate all the non-CRC format metadata just as it does for non-CRC filesystems, and so the coverage it has is the same for both CRC and non-CRC filesystems.For
xfs_db, there is read-only support for looking at the filesystem as thexfs_dbIO stack does not support CRCs at all. We need to convertxfs_dbto use the libxfs infrastructure to enable that. Apart from that,xfs_dbhas partial support for the extended metadata fields - the directory/attribute blocks don't have extended support yet, but everything else does.
xfs_checkis made special. It currently detects a version 5 superblock, and immediately exits with success. Hence it always says CRC enabled filesystems are OK. This is a temporary change that enables running xfstests without full support inxfs_dbfor all the new metadata structures (like headers in remote symlink and attribute blocks). Depending on if we want to keep xfs-check useful for xfstests, we can revisit this bypass hack oncexfs_dbhas been converted to use the libxfs IO engine.Overall, xfstests is now running enough to start to find bugs in the kernel CRC code - I'm mainly hitting remote attribute block bugs right now (generic/117!) but there's certainly less problems being reported than I expected.
Oh, and I've tested it with external log devices and real time devices, too.
Comments, thoughts, flames, and testing all welcome!
Quoted 8 lines
Quoted 3 lines
Cheers,
Dave.
OK. The basics look good so far. The patchset applied without need for additional work with vi and patch. Whitespace errors were reported for Patches 8, 14, 16, 17, 24, 25, and 27. xfsprogs built with no additional errors over a normal xfsprogs build.
Can you send me the output indicating where the whitespace errors are? I don't get any warnings from guilt about them when I apply the patchset here...
Quoted 2 lines
That all stated, the
tar -xvf qt-source.tar.xzstill fails on a CRC-enabled filesystem.Not surprising - I haven't got a crc enabled filesystem all the way through xfstests yet. remote attributes are the current piece I'm working on getting fixed.
Quoted 17 lines
Worse, until I return home, I won't be able
to do serial-console capture of hard oopses. However, the initial oops I got was a soft one, so it is included after my closing. The kernel is this...last night's kernel git
last night's xfs-oss/master
some of your recent patches (didn't apply your 6_5 patch yet)
J. Liu's most recent patchset + 2 older bitness patches
Chandra's v8 pquota/gquota patchset + one E-mail fix
Shaggy's JFS patch to make it through the old xfstests #068 on JFS
Quoted 8 lines
an NILFS2 patch to address broken bmap handling, lurked from the NILFS2 mailing list
one local removed assert to make it through the old xfstests #111
maybe one or two XFS patches beyond this
...all on a 32-bit Pentium 4.
And reporting bugs :)
Quoted 4 lines
What I'm trying to state is that a lot is in there, but the PC is spinning like a top, and xfstests results are really good right now. However, if I feel the need to provide a fresh environment, patch management is taking some time.
How are you managing patches right now? When taking in a new patchset from a mailing list, I save them all in a mbox file, then use git-am to apply them to a temporary git branch. I then move to my real working branch, and do a 'guilt import-commit x..y' to convert the commits in the temporary branch to a set of guilt patches, and then go from there....
The worst step for me is, by far, the git-am step. Resolving patch conflicts is painful because you have to manually apply the patch, then remember to git add all the files modified by the patch, etc.
Quoted 6 lines
It'd be really cool if guilt could do the import directly from the mbox file without applying the patches, so the normal guilt force-push-fix-and-refresh method of solving patch conflicts could be used instead of git-am.
/me wonders if #jeffpc is listening here....
Ah? #jeffpc == me ? #jeffpc is up and listening... : just ignore;
Looks our test for 32-bit system is insufficient. There has another bug reports regarding 32-bit yesterday:
http://oss.sgi.com/archives/xfs/2013-05/msg00494.html
So I'm going to setup a 32-bit test environment for such tests together with Michael.
Thanks,
-Jeff
Quoted 21 lines
Quoted 2 lines
Great job on a fine patchset so far, and good luck!
Keep the bug reports rolling in, Michael. ;)
Quoted 5 lines
Michael
[ 6188.126012] XFS: Assertion failed: first <= last && last <
BBTOB(bp->b_length), file:fs/xfs/xfs_trans_buf.c, line: 569Hmmm - that seems familiar - I thought I'd already fixed a bug like that previously...
Quoted 6 lines
[ 6188.147632] [<c11c6d67>] xfs_trans_log_buf+0x64/0x11b [ 6188.147632] [<c11a0653>] xfs_dir2_data_log_unused+0x7b/0x83 [ 6188.147632] [<c11a0e45>] xfs_dir2_data_use_free+0x1bf/0x41a [ 6188.147632] [<c11a308b>] xfs_dir2_leaf_addname+0x307/0x6f2 [ 6188.147632] [<c119d32f>] xfs_dir_createname+0x113/0x129 [ 6188.147632] [<c1174633>] xfs_create+0x3e0/0x4fb
Quoted 7 lines
I'll look into that further - it's a different problem to what I'm stuck on at the moment...
Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 112 lines · Jeff Liu
Quoted 111 lines · Dave Chinner
Quoted 46 lines · Michael L. Semon
Quoted 45 lines · Dave Chinner
Hi Folks,
This is the first real "works ok" CRC patchset for xfsprogs. It provides full support for mkfs.xfs and
xfs_repair, and partial read-only support forxfs_db.For mkfs.xfs, it does everything properly, and filesystems that are freshly made also run cleanly through
xfs_repairand mount and run just fine.For
xfs_repair, it reads and writes all metadata with CRC checks, calculations and validation just like the kernel code does, but it currently silently ignores the validation done in the IO layer. Enabling that is future work - it involves adding buffer error checking to everylibxfs_readbuf()call that is made, and we do none of that right now. It does, however, fully validate all the non-CRC format metadata just as it does for non-CRC filesystems, and so the coverage it has is the same for both CRC and non-CRC filesystems.For
xfs_db, there is read-only support for looking at the filesystem as thexfs_dbIO stack does not support CRCs at all. We need to convertxfs_dbto use the libxfs infrastructure to enable that. Apart from that,xfs_dbhas partial support for the extended metadata fields - the directory/attribute blocks don't have extended support yet, but everything else does.
xfs_checkis made special. It currently detects a version 5 superblock, and immediately exits with success. Hence it always says CRC enabled filesystems are OK. This is a temporary change that enables running xfstests without full support inxfs_dbfor all the new metadata structures (like headers in remote symlink and attribute blocks). Depending on if we want to keep xfs-check useful for xfstests, we can revisit this bypass hack oncexfs_dbhas been converted to use the libxfs IO engine.Overall, xfstests is now running enough to start to find bugs in the kernel CRC code - I'm mainly hitting remote attribute block bugs right now (generic/117!) but there's certainly less problems being reported than I expected.
Oh, and I've tested it with external log devices and real time devices, too.
Comments, thoughts, flames, and testing all welcome!
Quoted 8 lines
Quoted 3 lines
Cheers,
Dave.
OK. The basics look good so far. The patchset applied without need for additional work with vi and patch. Whitespace errors were reported for Patches 8, 14, 16, 17, 24, 25, and 27. xfsprogs built with no additional errors over a normal xfsprogs build.
Can you send me the output indicating where the whitespace errors are? I don't get any warnings from guilt about them when I apply the patchset here...
Quoted 2 lines
That all stated, the
tar -xvf qt-source.tar.xzstill fails on a CRC-enabled filesystem.Not surprising - I haven't got a crc enabled filesystem all the way through xfstests yet. remote attributes are the current piece I'm working on getting fixed.
Quoted 17 lines
Worse, until I return home, I won't be able
to do serial-console capture of hard oopses. However, the initial oops I got was a soft one, so it is included after my closing. The kernel is this...last night's kernel git
last night's xfs-oss/master
some of your recent patches (didn't apply your 6_5 patch yet)
J. Liu's most recent patchset + 2 older bitness patches
Chandra's v8 pquota/gquota patchset + one E-mail fix
Shaggy's JFS patch to make it through the old xfstests #068 on JFS
Quoted 8 lines
an NILFS2 patch to address broken bmap handling, lurked from the NILFS2 mailing list
one local removed assert to make it through the old xfstests #111
maybe one or two XFS patches beyond this
...all on a 32-bit Pentium 4.
And reporting bugs :)
Quoted 4 lines
What I'm trying to state is that a lot is in there, but the PC is spinning like a top, and xfstests results are really good right now. However, if I feel the need to provide a fresh environment, patch management is taking some time.
How are you managing patches right now? When taking in a new patchset from a mailing list, I save them all in a mbox file, then use git-am to apply them to a temporary git branch. I then move to my real working branch, and do a 'guilt import-commit x..y' to convert the commits in the temporary branch to a set of guilt patches, and then go from there....
The worst step for me is, by far, the git-am step. Resolving patch conflicts is painful because you have to manually apply the patch, then remember to git add all the files modified by the patch, etc.
Quoted 7 lines
Quoted 6 lines
It'd be really cool if guilt could do the import directly from the mbox file without applying the patches, so the normal guilt force-push-fix-and-refresh method of solving patch conflicts could be used instead of git-am.
/me wonders if #jeffpc is listening here....
Ah? #jeffpc == me ? #jeffpc is up and listening... : just ignore;
No, #jeffpc is Josef Sipek. Author of guilt and many other useful things.
Quoted 6 lines
Looks our test for 32-bit system is insufficient. There has another bug reports regarding 32-bit yesterday:
http://oss.sgi.com/archives/xfs/2013-05/msg00494.htmlSo I'm going to setup a 32-bit test environment for such tests together with Michael.
Sounds good to me ;)
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 3 lines · Jeff Liu
Looks our test for 32-bit system is insufficient. There has another bug reports regarding 32-bit yesterday:
http://oss.sgi.com/archives/xfs/2013-05/msg00494.html
I read this and did not chime in because I don't know about the "no space left on device" error.
The first issue the customer had, though, was one I had on a 2.8GHz Pentium 4. The idea of using a tunable to increase vmalloc space made me think, "What, am I using FreeBSD or something? Why didn't Linux auto-tune this?" so I dug deeper. [Disclaimer: I use FreeBSD and find value in it, but it requires at least some sysctl tuning for things that Linux will tune automatically.]
Basically, I had vmalloc space to have an environment set up perfectly in 768 MB of RAM. Then I added another 512 MB, and Linux saw only 896 MB for lack of highmem support. At that point I enabled highmem support, Linux decided to auto-tune my vmalloc space down to 128 MB, which was not enough to handle an xfsdump of a 30 GB device-mapper crypt partition. The PC, when left alone, could develop those same oops-y messages while doing incremental xfsdumps overnight, and if left alone for days, even simple cp commands could cause issues. My resolution was to use the CONFIG_VMSPLIT_2G kernel option and reduce the things reported by /proc/vmallocinfo that are vmalloc items. Some ioremap items in /proc/vmallocinfo were removed where convenient. Despite warnings on the Internet like "this breaks ELF" and "this breaks binary modules," I've had no issues with it in the nine months in which the kernel has operated this way. [Note: I don't use binary modules. For that matter, only that PC uses modules at all.] Ultimately, I got rid of the crypts as well, but not before verifying that the above setup did indeed solve the problem at hand.
It's only my two cents, one person trying to balance Internet research against what actually works in testing on one PC. If the solution is sane sane to you, feel free to forward this story to your customer to see if anything in it will help.
Quoted 2 lines
So I'm going to setup a 32-bit test environment for such tests together with Michael.
Excellent! Let me know a little about your test environment and whether it's a VM or bare metal.
Michael
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 39 lines · Michael L. Semon
Quoted 3 lines · Jeff Liu
Looks our test for 32-bit system is insufficient. There has another bug reports regarding 32-bit yesterday:
http://oss.sgi.com/archives/xfs/2013-05/msg00494.htmlI read this and did not chime in because I don't know about the "no space left on device" error.
The first issue the customer had, though, was one I had on a 2.8GHz Pentium 4. The idea of using a tunable to increase vmalloc space made me think, "What, am I using FreeBSD or something? Why didn't Linux auto-tune this?" so I dug deeper. [Disclaimer: I use FreeBSD and find value in it, but it requires at least some sysctl tuning for things that Linux will tune automatically.]
Basically, I had vmalloc space to have an environment set up perfectly in 768 MB of RAM. Then I added another 512 MB, and Linux saw only 896 MB for lack of highmem support. At that point I enabled highmem support, Linux decided to auto-tune my vmalloc space down to 128 MB, which was not enough to handle an xfsdump of a 30 GB device-mapper crypt partition. The PC, when left alone, could develop those same oops-y messages while doing incremental xfsdumps overnight, and if left alone for days, even simple cp commands could cause issues. My resolution was to use the
CONFIG_VMSPLIT_2Gkernel option and reduce the things reported by/proc/vmallocinfothat are vmalloc items. Some ioremap items in/proc/vmallocinfowere removed where convenient. Despite warnings on the Internet like "this breaks ELF" and "this breaks binary modules," I've had no issues with it in the nine months in which the kernel has operated this way. [Note: I don't use binary modules. For that matter, only that PC uses modules at all.] Ultimately, I got rid of the crypts as well, but not before verifying that the above setup did indeed solve the problem at hand.It's only my two cents, one person trying to balance Internet research against what actually works in testing on one PC. If the solution is sane sane to you, feel free to forward this story to your customer to see if anything in it will help.
Quoted 5 lines
Quoted 2 lines
So I'm going to setup a 32-bit test environment for such tests together with Michael.
Excellent! Let me know a little about your test environment and whether it's a VM or bare metal.
VM running via virtual box.
The kernel is based on the updated xfs-next tree.
root@linux32bit:/home/jeff# uname -a Linux linux32bit 3.10.0-rc1+ #1 SMP Sat May 18 15:30:11 CST 2013 i686 i686 i386 GNU/Linux
Thanks,
-Jeff
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 51 lines · Dave Chinner
Quoted 50 lines · Michael L. Semon
Quoted 48 lines · Dave Chinner
Hi Folks,
This is the first real "works ok" CRC patchset for xfsprogs. It provides full support for mkfs.xfs and
xfs_repair, and partial read-only support forxfs_db.For mkfs.xfs, it does everything properly, and filesystems that are freshly made also run cleanly through
xfs_repairand mount and run just fine.For
xfs_repair, it reads and writes all metadata with CRC checks, calculations and validation just like the kernel code does, but it currently silently ignores the validation done in the IO layer. Enabling that is future work - it involves adding buffer error checking to everylibxfs_readbuf()call that is made, and we do none of that right now. It does, however, fully validate all the non-CRC format metadata just as it does for non-CRC filesystems, and so the coverage it has is the same for both CRC and non-CRC filesystems.For
xfs_db, there is read-only support for looking at the filesystem as thexfs_dbIO stack does not support CRCs at all. We need to convertxfs_dbto use the libxfs infrastructure to enable that. Apart from that,xfs_dbhas partial support for the extended metadata fields - the directory/attribute blocks don't have extended support yet, but everything else does.
xfs_checkis made special. It currently detects a version 5 superblock, and immediately exits with success. Hence it always says CRC enabled filesystems are OK. This is a temporary change that enables running xfstests without full support inxfs_dbfor all the new metadata structures (like headers in remote symlink and attribute blocks). Depending on if we want to keep xfs-check useful for xfstests, we can revisit this bypass hack oncexfs_dbhas been converted to use the libxfs IO engine.Overall, xfstests is now running enough to start to find bugs in the kernel CRC code - I'm mainly hitting remote attribute block bugs right now (generic/117!) but there's certainly less problems being reported than I expected.
Oh, and I've tested it with external log devices and real time devices, too.
Comments, thoughts, flames, and testing all welcome!
Cheers,
Dave.
Quoted 8 lines
Quoted 4 lines
OK. The basics look good so far. The patchset applied without need for additional work with vi and patch. Whitespace errors were reported for Patches 8, 14, 16, 17, 24, 25, and 27. xfsprogs built with no additional errors over a normal xfsprogs build.
Can you send me the output indicating where the whitespace errors are? I don't get any warnings from guilt about them when I apply the patchset here...
If it makes any difference at all, I'm saving these patches using Thunderbird...
The pre-patchset xfsprogs has been saved as a tarball, so I can provide a non-git patch session if necessary. Sorry so vague last time: I was overjoyed that everything went through git so cleanly.
This is the result of the patches about which git am complained:
PATCH 08:
Applying: libxfs: add support for crc headers on remote symlinks /usr/src/xfs/xfsprogs/.git/rebase-apply/patch:282: new blank line at EOF. +
PATCH 14:
Applying: xfs: add CRCs to dir2/da node blocks /usr/src/xfs/xfsprogs/.git/rebase-apply/patch:61: trailing whitespace.
nodehdr.level, id->ino,
warning: 1 line adds whitespace errors.
PATCH 16:
Applying: xfs: split remote attribute code out /usr/src/xfs/xfsprogs/.git/rebase-apply/patch:722: new blank line at EOF. +
warning: 1 line adds whitespace errors.
PATCH 17:
Applying: xfs: add CRC protection to remote attributes /usr/src/xfs/xfsprogs/.git/rebase-apply/patch:340: trailing whitespace.
* allocating the blocks below.
warning: 1 line adds whitespace errors.
PATCH 24:
Applying: xfsprogs: add crc format support to repair /usr/src/xfs/xfsprogs/.git/rebase-apply/patch:574: trailing whitespace.
if (scan_lbtree(be64_to_cpu(pp[i]), level, scan_bmapbt,
type,
warning: 1 line adds whitespace errors.
PATCH 25:
Applying: xfs_repair: update for dir/attr crc format changes. /usr/src/xfs/xfsprogs/.git/rebase-apply/patch:128: trailing whitespace.
if ((leafhdr.holes == 0 &&
/usr/src/xfs/xfsprogs/.git/rebase-apply/patch:130: space before tab in indent.
leafhdr.firstused > firstb) {/usr/src/xfs/xfsprogs/.git/rebase-apply/patch:136: trailing whitespace.
leafhdr.firstused,/usr/src/xfs/xfsprogs/.git/rebase-apply/patch:146: trailing whitespace.
leafhdr.firstused,/usr/src/xfs/xfsprogs/.git/rebase-apply/patch:158: trailing whitespace.
leafhdr.usedbytes,
warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.
PATCH 27:
Applying: xfs_db: disable modification for CRC enabled filessytems. /usr/src/xfs/xfsprogs/.git/rebase-apply/patch:20: trailing whitespace.
fprintf(stderr,
warning: 1 line adds whitespace errors.
Quoted 40 lines
Quoted 2 lines
That all stated, the
tar -xvf qt-source.tar.xzstill fails on a CRC-enabled filesystem.Not surprising - I haven't got a crc enabled filesystem all the way through xfstests yet. remote attributes are the current piece I'm working on getting fixed.
Quoted 17 lines
Worse, until I return home, I won't be able
to do serial-console capture of hard oopses. However, the initial oops I got was a soft one, so it is included after my closing. The kernel is this...last night's kernel git
last night's xfs-oss/master
some of your recent patches (didn't apply your 6_5 patch yet)
J. Liu's most recent patchset + 2 older bitness patches
Chandra's v8 pquota/gquota patchset + one E-mail fix
Shaggy's JFS patch to make it through the old xfstests #068 on JFS
Quoted 8 lines
an NILFS2 patch to address broken bmap handling, lurked from the NILFS2 mailing list
one local removed assert to make it through the old xfstests #111
maybe one or two XFS patches beyond this
...all on a 32-bit Pentium 4.
And reporting bugs :)
Quoted 4 lines
What I'm trying to state is that a lot is in there, but the PC is spinning like a top, and xfstests results are really good right now. However, if I feel the need to provide a fresh environment, patch management is taking some time.
Quoted 6 lines
How are you managing patches right now? When taking in a new patchset from a mailing list, I save them all in a mbox file, then use git-am to apply them to a temporary git branch. I then move to my real working branch, and do a 'guilt import-commit x..y' to convert the commits in the temporary branch to a set of guilt patches, and then go from there....
The patches themselves are stored as individual files, in case they need to be applied again. Separate git branches are used for kernel patches, but for the XFS suite, I keep backup tarballs and work directly off of master.
A new branch is started at strategic points. If you mention "this is based on 3.9.2 + xfsdev", kernel 3.9.2 is checked out into a new branch, xfs-oss/master is updated and merged, and the patches are reapplied. It takes time but is the best way, until I can find the git --backout-this-patch-cleanly --i-really-mean-it-this-time --do-not-bother-to-suggest-git-am-resolved-if-it-cannot-be-done command.
The trick is to remember which patches to apply, so I might have a directory that has five great patches and one that no longer applies.
Quoted 3 lines
The worst step for me is, by far, the git-am step. Resolving patch conflicts is painful because you have to manually apply the patch, then remember to git add all the files modified by the patch, etc.
I don't know how to use git to properly back out a patch that was made at some time in the past. Disaster management in particular has left me to backup at strategic points. On these older PCs, restore operations can be much faster than git recovery attempts.
git am is hard because that diagnostic "Patch does not apply" is not helpful, and the --ignore-whitespace option can cause trouble very quickly.
Any patches that don't apply by git am are reduced from E-mail to ordinary diffs and sent through git apply. If that doesn't work, they go through patch; vimdiff is used to help splice the patches in by hand.
git add is then used to add the files.
Quoted 10 lines
It'd be really cool if guilt could do the import directly from the mbox file without applying the patches, so the normal guilt force-push-fix-and-refresh method of solving patch conflicts could be used instead of git-am.
/me wonders if #jeffpc is listening here....
Quoted 1 line
Great job on a fine patchset so far, and good luck!
Keep the bug reports rolling in, Michael. ;)
Thanks! It's all good fun :-)
Quoted 8 lines
Quoted 5 lines
Michael
[ 6188.126012] XFS: Assertion failed: first <= last && last <
BBTOB(bp->b_length), file:fs/xfs/xfs_trans_buf.c, line: 569Hmmm - that seems familiar - I thought I'd already fixed a bug like that previously...
You may have fixed it already. If there's a patch, either I don't have it, or it's stuck on my main xfstests PC at home. Was this the issue that was triggered easily by xfstests xfs/017?
Quoted 7 lines
Quoted 6 lines
[ 6188.147632] [<c11c6d67>] xfs_trans_log_buf+0x64/0x11b [ 6188.147632] [<c11a0653>] xfs_dir2_data_log_unused+0x7b/0x83 [ 6188.147632] [<c11a0e45>] xfs_dir2_data_use_free+0x1bf/0x41a [ 6188.147632] [<c11a308b>] xfs_dir2_leaf_addname+0x307/0x6f2 [ 6188.147632] [<c119d32f>] xfs_dir_createname+0x113/0x129 [ 6188.147632] [<c1174633>] xfs_create+0x3e0/0x4fb
Quoted 7 lines
I'll look into that further - it's a different problem to what I'm stuck on at the moment...
Cheers,
Dave.
No worries. It will take a while to compile an initial xfstests report with CRC-enabled filesystems.
Thanks again!
Michael
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 8 lines · Michael L. Semon
Quoted 7 lines · Dave Chinner
Quoted 6 lines · Michael L. Semon
Quoted 5 lines · Dave Chinner
Hi Folks,
This is the first real "works ok" CRC patchset for xfsprogs. It provides full support for mkfs.xfs and
xfs_repair, and partial read-only support forxfs_db.
....
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
OK. The basics look good so far. The patchset applied without need for additional work with vi and patch. Whitespace errors were reported for Patches 8, 14, 16, 17, 24, 25, and 27. xfsprogs built with no additional errors over a normal xfsprogs build.
Can you send me the output indicating where the whitespace errors are? I don't get any warnings from guilt about them when I apply the patchset here...
If it makes any difference at all, I'm saving these patches using Thunderbird...
It shouldn't.
Quoted 7 lines
The pre-patchset xfsprogs has been saved as a tarball, so I can provide a non-git patch session if necessary. Sorry so vague last
time: I was overjoyed that everything went through git so cleanly.This is the result of the patches about which
git amcomplained:PATCH 08:
....
Thanks, i'll have a look at them on monday...
Quoted 17 lines
Quoted 11 lines
Quoted 4 lines
What I'm trying to state is that a lot is in there, but the PC is spinning like a top, and xfstests results are really good right now. However, if I feel the need to provide a fresh environment, patch management is taking some time.
How are you managing patches right now? When taking in a new patchset from a mailing list, I save them all in a mbox file, then use git-am to apply them to a temporary git branch. I then move to my real working branch, and do a 'guilt import-commit x..y' to convert the commits in the temporary branch to a set of guilt patches, and then go from there....
The patches themselves are stored as individual files, in case they need to be applied again. Separate git branches are used for kernel patches, but for the XFS suite, I keep backup tarballs and work directly off of master.
Quoted 7 lines
A new branch is started at strategic points. If you mention "this is based on 3.9.2 + xfsdev", kernel 3.9.2 is checked out into a new branch, xfs-oss/master is updated and merged, and the patches are reapplied. It takes time but is the best way, until I can find the
git --backout-this-patch-cleanly --i-really-mean-it-this-time --do-not-bother-to-suggest-git-am-resolved-if-it-cannot-be-donecommand.
Being able to add and remove patches and reorder them easily is exactly why I use guilt. The raw git workflow is, well, less than optimal IMO.
Quoted 4 lines
The trick is to remember which patches to apply, so I might have a directory that has five great patches and one that no longer applies.
Quoted 8 lines
Quoted 3 lines
The worst step for me is, by far, the git-am step. Resolving patch conflicts is painful because you have to manually apply the patch, then remember to git add all the files modified by the patch, etc.
I don't know how to use git to properly back out a patch that was made at some time in the past. Disaster management in particular has left me to backup at strategic points. On these older PCs, restore operations can be much faster than git recovery attempts.
So, once I've have a patch series imported into git as a guilt stack, it's managed as a series of patches rather than as individual patches or commits. The order is kept in a series file. So, updating the underlying release for a specific patch set is effectively:
$ guilt checkout working # go to base tree branch $ guilt pop -a # remove all patches in the branch $ git reset --hard v3.10-rc1 # reset branch to known clean state $ git remote update $ git merge origin/master # linus tree $ git merge xfs-oss/master # xfs tree $ guilt push -a # push all local patches back into branch
At this point I have an up-to-date linus + xfs + local patches branch.
Say now I want add a new patchset in from the list. I save it as an mbox file "saved-patches". Then I create a new branch from the xfs tree so I know that it will apply cleanly:
$ git checkout -b imports xfs-oss/master # create a new branch from the xfs tree $ git am saved-patches .....
Now all patches are applied to the imports branch. Get all the commit ids, switch back to the working branch, and import them into guilt to track them as patches:
$ git log --oneline -n <number of patches in the seriesi + 2> yyyy last commit .... xxxx commit prior to first in new series $ git checkout working $ guilt import-commit xxxx..yyyy # import the commits onto the tail # of the current patch series $ guilt push -a # apply the patchset to the current branch $ git branch -D imports # remove the temp import branch.
At this point, all the patches in the series you just pulled down from the list are applied to your tree. You can now push and pop them out of the tree, reorder them, etc as though you are just managing a series of patches....
If any of the patches in the inew series fail to apply, then guilt won't apply it. If you force apply it, guilt outputs the result of applying the patch, same as if you ran patch. The difference is that for all the modified files and the files that need to be editted to fix conflicts, you don't need to git add them. just "guilt refresh" and you're ready to push the next patch in the series onto the stack...
Quoted 3 lines
git amis hard because that diagnostic "Patch does not apply" is not helpful, and the --ignore-whitespace option can cause trouble very quickly.
Right, so you have to go to .git/rebase-apply/patchNNNN to find the patch that didn't apply, and run:
$ patch --dry-run -p1 < .git/rebase-apply/patchNNNN
to find out why it didn't apply.
Quoted 4 lines
Any patches that don't apply by
git amare reduced from E-mail to ordinary diffs and sent throughgit apply. If that doesn't work, they go through patch; vimdiff is used to help splice the patches in by hand.git addis then used to add the files.
Yes, it's painful, isn't it? That's why I try to apply the patches to an otherwise unmodified tree so I can avoid this pain and use guilt to resolve any conflicts.
However, if you do have git-am failures, skipping straight to the above patch that git has already stripped from the email will make it a bit faster for you. It's still annoying having to manually use git add, though.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
[ 6188.126012] XFS: Assertion failed: first <= last && last <
BBTOB(bp->b_length), file:fs/xfs/xfs_trans_buf.c, line: 569Hmmm - that seems familiar - I thought I'd already fixed a bug like that previously...
You may have fixed it already. If there's a patch, either I don't have it, or it's stuck on my main xfstests PC at home. Was this the issue that was triggered easily by xfstests xfs/017?
Might have been. It was a while back. If it's still there once I've got it through xfstests here and you've applied the patches I send out to get that far then I'll need to look deeper...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 66 lines · Dave Chinner
Quoted 3 lines · Michael L. Semon
Quoted 2 lines · Dave Chinner
Quoted 1 line · Michael L. Semon
On 05/17/2013 07:12 AM, Dave Chinner wrote:
Being able to add and remove patches and reorder them easily is exactly why I use guilt. The raw git workflow is, well, less than optimal IMO.
Quoted 4 lines
The trick is to remember which patches to apply, so I might have a directory that has five great patches and one that no longer applies.
Quoted 8 lines
Quoted 3 lines
The worst step for me is, by far, the git-am step. Resolving patch conflicts is painful because you have to manually apply the patch, then remember to git add all the files modified by the patch, etc.
I don't know how to use git to properly back out a patch that was made at some time in the past. Disaster management in particular has left me to backup at strategic points. On these older PCs, restore operations can be much faster than git recovery attempts.
So, once I've have a patch series imported into git as a guilt stack, it's managed as a series of patches rather than as individual patches or commits. The order is kept in a series file. So, updating the underlying release for a specific patch set is effectively:
$ guilt checkout working # go to base tree branch $ guilt pop -a # remove all patches in the branch $ git reset --hard v3.10-rc1 # reset branch to known clean state $ git remote update $ git merge origin/master # linus tree $ git merge xfs-oss/master # xfs tree $ guilt push -a # push all local patches back into branchAt this point I have an up-to-date linus + xfs + local patches branch.
Say now I want add a new patchset in from the list. I save it as an mbox file "saved-patches". Then I create a new branch from the xfs tree so I know that it will apply cleanly:
$ git checkout -b imports xfs-oss/master # create a new branch from the xfs tree $ git am saved-patches .....Now all patches are applied to the imports branch. Get all the commit ids, switch back to the working branch, and import them into guilt to track them as patches:
$ git log --oneline -n <number of patches in the seriesi + 2> yyyy last commit .... xxxx commit prior to first in new series $ git checkout working $ guilt import-commit xxxx..yyyy # import the commits onto the tail # of the current patch series $ guilt push -a # apply the patchset to the current branch $ git branch -D imports # remove the temp import branch.At this point, all the patches in the series you just pulled down from the list are applied to your tree. You can now push and pop them out of the tree, reorder them, etc as though you are just managing a series of patches....
Quoted 7 lines
If any of the patches in the inew series fail to apply, then guilt won't apply it. If you force apply it, guilt outputs the result of applying the patch, same as if you ran patch. The difference is that for all the modified files and the files that need to be editted to fix conflicts, you don't need to git add them. just "guilt refresh" and you're ready to push the next patch in the series onto the stack...
Ah, excellent explanation! guilt sounds awesome. Not finding anything that looked like an official site for guilt that worked, I grabbed the guilt source from the wheezy section at packages.debian.org. At the next opportunity, I will learn it, live it, love it.
Michael
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 9 lines · Dave Chinner
Hi Folks,
This is the first real "works ok" CRC patchset for xfsprogs. It provides full support for mkfs.xfs and
xfs_repair, and partial read-only support forxfs_db.For mkfs.xfs, it does everything properly, and filesystems that are freshly made also run cleanly through
xfs_repairand mount and run just fine.
This seemed to be worthy of early note:
xfs/031 30s ...[ 587.843478] XFS (sdb6): Version 5 superblock detected. This kernel has EXPERIMENTAL support enabled!
[ 587.843478] Use of these features in this kernel is at your own risk!
*** Error in `/sbin/mkfs.xfs': malloc(): smallbin double linked list corrupted: 0x0907f7d0 ***
The test doesn't seem to finish, but Ctrl-c ends the test cleanly. No dmesg stuff is added, and strace doesn't show anything between the mount message and the error message. I'll need to re-enable tracers to provide a trace...and as traces can be huge, I'll wait on your advice.
[BTW, the "30s" reference time is from the non-CRC run of your patched xfsprogs. The non-CRC run looked good.]
Thanks!
Michael
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
cover xfsprogs: more CRC support patches
In reply to Dave Chinner[ well, really patches 31..36 :) ]
Hi folks,
More work on top of the original series of 30 patches, including xfs_db support for parsing the v3 directory format.
Note that there are also two patches in here that convert both xfs_db and xfs_repair to use the libxfs directory block type definitions. While it may have once been convenient for them to have a basic definition, it does not lend itself to making the code support the v3 format quickly and concisely. Reusing the libxfs/kernel structure definitions and abstraction means that the code quickly becomes v3 aware and has just works.
Right now this patchset and the current kernel patchset (all the attr fixes) runs through xfstests quite far on a 4k block size filesystem - all the generic tests pass, and most of the XFS specific tests that don't rely on write or attr output support in xfs_db also pass.
I'll get the attr db support done tomorrow.....
Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/6 xfs_repair: always use incore header for directory block checks
From: 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
PATCH 2/6 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
PATCH 3/6 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
PATCH 4/6 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 | 14 ++- db/type.h | 2 +- 6 files changed, 336 insertions(+), 67 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 +9 -5
@@ -59,6 +59,7 @@ static const typ_t __typtab[] = { { TYP_CNTBT, "cntbt", handle_struct, cntbt_hfld }, { TYP_DATA, "data", handle_block, NULL }, { TYP_DIR2, "dir2", handle_struct, dir2_hfld }, + { TYP_DIR3, NULL, NULL, NULL }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld }, { TYP_INOBT, "inobt", handle_struct, inobt_hfld }, { TYP_INODATA, "inodata", NULL, NULL },
@@ -82,7 +83,8 @@ 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, NULL, NULL, NULL }, + { TYP_DIR3, "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 +112,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 +135,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); } }
db/type.h +1 -1
@@ -25,7 +25,7 @@ typedef enum typnm {TYP_AGF ,TYP_AGFL ,TYP_AGI ,TYP_ATTR ,TYP_BMAPBTA ,TYP_BMAPBTD ,TYP_BNOBT ,TYP_CNTBT ,TYP_DATA , -TYP_DIR2 ,TYP_DQBLK ,TYP_INOBT ,TYP_INODATA ,TYP_INODE , +TYP_DIR2 ,TYP_DIR3 ,TYP_DQBLK ,TYP_INOBT ,TYP_INODATA ,TYP_INODE ,TYP_LOG ,TYP_RTBITMAP ,TYP_RTSUMMARY ,TYP_SB ,TYP_SYMLINK , TYP_TEXT, TYP_NONE } typnm_t;
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 5/6 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
PATCH 6/6 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 0/6] xfsprogs: more CRC support patches
In reply to Dave ChinnerQuoted 21 lines · Dave Chinner
[ well, really patches 31..36 :) ]
Hi folks,
More work on top of the original series of 30 patches, including
xfs_dbsupport for parsing the v3 directory format.Note that there are also two patches in here that convert both
xfs_dbandxfs_repairto use the libxfs directory block type definitions. While it may have once been convenient for them to have a basic definition, it does not lend itself to making the code support the v3 format quickly and concisely. Reusing the libxfs/kernel structure definitions and abstraction means that the code quickly becomes v3 aware and has just works.Right now this patchset and the current kernel patchset (all the attr fixes) runs through xfstests quite far on a 4k block size filesystem - all the generic tests pass, and most of the XFS specific tests that don't rely on write or attr output support in
xfs_dbalso pass.
Quoted 5 lines
I'll get the attr db support done tomorrow.....
Cheers,
Dave.
This makes some improvement to the setup here: xfs/041 no longer triggers a sure-fire "args->op_flags & XFS_DA_OP_OKNOENT" assertion. This will take a re-review on my part of the xfs/[0-9][0-9][0-9] test set.
Here's how the git am session went, syntax removed because Ctrl-w word removal in bash makes the script output unworkable:
# PATCH 1
Applying: xfs_repair: always use incore header for directory block checks # PATCH 2
Applying: xfs_db: convert directory parsing to use libxfs structure /usr/src/xfs/xfsprogs/.git/rebase-apply/patch:94: trailing whitespace.
if (be32_to_cpu(data->magic) == XFS_DIR2_BLOCK_MAGIC &&
warning: 1 line adds whitespace errors.
# PATCH 3
Applying: xfs_db: factor some common dir2 field parsing code. # PATCH 4
Applying: xfs_db: update field printing for dir crc format changes. # PATCH 5
Applying: xfs_repair: convert directory parsing to use libxfs structure # PATCH 6
Applying: xfs_repair: make directory freespace table CRC format aware.
Nice job!
Michael
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
cover xfsprogs: yet more CRC support patches
In reply to Dave ChinnerJust a couple for xfs_db - dquot and attribute structure printing. These go on top of the previous two patches that this one is threaded to.
-Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/2 xfs_db: add CRC information to dquot output
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.
--- 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
PATCH 2/2 xfs_db: add CRC support for attribute fork structures.
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- db/attr.c | 393 ++++++++++++++++++++++++++++++++++++------------------------ db/attr.h | 4 + db/field.c | 13 ++ db/field.h | 8 ++ db/type.c | 4 +- db/type.h | 2 +- 6 files changed, 268 insertions(+), 156 deletions(-)
db/attr.c +239 -154
@@ -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 (bitoffs (startoff) ==0 ); - off =byteize (startoff); - block = obj; -if (be16_to_cpu (block->hdr.info.magic) !=XFS_ATTR_LEAF_MAGIC ) +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 (startoff ==0 ); +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 (node->hdr.__count); +} + +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 (block->hdr.__count); +return be16_to_cpu (node->hdr.__count); } -/*ARGSUSED*/ +static int attr_node_hdr_count (void *obj,int startoff) { -xfs_da_intnode_t *block; +struct xfs_da_intnode *node = obj; + +ASSERT (startoff ==0 ); +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 ); - block = obj; -return be16_to_cpu (block->hdr.info.magic) ==XFS_DA_NODE_MAGIC ; +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 +4 -0
@@ -26,5 +26,9 @@ 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_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, "attr", NULL, (char *)attr3_flds, attr_size, FTARG_SIZE, + NULL, attr3_flds }, + { FLDT_ATTR3_LEAF_HDR, "attr_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, "attr_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 +3 -1
@@ -53,6 +53,7 @@ static const typ_t __typtab[] = { { TYP_AGFL, "agfl", handle_struct, agfl_hfld }, { TYP_AGI, "agi", handle_struct, agi_hfld }, { TYP_ATTR, "attr", handle_struct, attr_hfld }, + { TYP_ATTR3, NULL, NULL, NULL }, { TYP_BMAPBTA, "bmapbta", handle_struct, bmapbta_hfld }, { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_hfld }, { TYP_BNOBT, "bnobt", handle_struct, bnobt_hfld },
@@ -77,7 +78,8 @@ 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, NULL, NULL, NULL }, + { TYP_ATTR3, "attr3", 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 },
db/type.h +1 -1
@@ -23,7 +23,7 @@ struct field; typedef enum typnm { - TYP_AGF, TYP_AGFL, TYP_AGI, TYP_ATTR, TYP_BMAPBTA, + TYP_AGF, TYP_AGFL, TYP_AGI, TYP_ATTR, TYP_ATTR3, TYP_BMAPBTA, TYP_BMAPBTD, TYP_BNOBT, TYP_CNTBT, TYP_DATA, TYP_DIR2, TYP_DIR3, TYP_DQBLK, TYP_INOBT, TYP_INODATA, TYP_INODE, TYP_LOG, TYP_RTBITMAP, TYP_RTSUMMARY, TYP_SB, TYP_SYMLINK,
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
cover xfsprogs: more CRC patches
In reply to Dave ChinnerA few more patches. The first enforced the fixed config bits for CRC enabled filesystems at mkfs time. The second adds "-m crc=?" output to xfs-info, the last two effectively disable metadump/restore functionality on CRC enabled filesystems until xfs_db supports CRC calculations properly.
-Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/4 mkfs.xfs: validate options for CRCs up front.
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.
--- mkfs/xfs_mkfs.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
mkfs/xfs_mkfs.c +52 -0
@@ -1476,6 +1476,7 @@ main(if (c <0 || c >1 )illegal (value,"m crc" ); crcs_enabled = c; + projid32bit =1 ;break ;default :unknown ('m' , value);
@@ -1754,6 +1755,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 (projid32bit !=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 ) {
Signature · 6 lines
1.7.10.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/4 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.
--- growfs/xfs_growfs.c | 9 +++++++-- include/xfs_fs.h | 1 + mkfs/xfs_mkfs.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-)
growfs/xfs_growfs.c +7 -2
@@ -53,11 +53,13 @@ report_info( int dirversion, int logversion, int attrversion, + int crcs_enabled, int cimode) { printf(_("meta-data=%-22s isize=%-6u agcount=%u, agsize=%u blks\n" " =%-22s sectsz=%-5u attr=%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"
@@ -67,6 +69,7 @@ report_info( mntpoint, geo.inodesize, geo.agcount, geo.agblocks,"" , geo.sectsize, attrversion, +"" , crcs_enabled,"" , geo.blocksize, (unsigned long long )geo.datablocks, geo.imaxpct, "", geo.sunit, geo.swidth,
@@ -115,6 +118,7 @@ main(int argc, char **argv)char *rtdev;/* RT device name */ fs_path_t *fs;/* mount point information */ libxfs_init_t xi;/* libxfs structure */ +int crcs_enabled; progname =basename (argv[0 ]);setlocale (LC_ALL ,"" );
@@ -234,10 +238,11 @@ 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 ; + 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, crcs_enabled, ci);exit (0 ); }
@@ -274,7 +279,7 @@ main(int argc, char **argv)report_info (geo, datadev, isint, logdev, rtdev, lazycount, dirversion, logversion, - attrversion, ci); + attrversion, 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
@@ -2425,7 +2425,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
PATCH 3/4 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
PATCH 4/4 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