aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_format.h
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-04-11 17:30:21 -0400
committerBen Myers <bpm@sgi.com>2013-04-27 13:19:53 -0400
commit24df33b45ecf5ca413ef1530e0aca5506d9be2cc (patch)
treec4f3ca2bfdd25b09706ad3d4ccd4f45fff6710a9 /fs/xfs/xfs_dir2_format.h
parent33363feed1614def83d0a6870051f0a7828cd61b (diff)
xfs: add CRC checking to dir2 leaf blocks
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. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Ben Myers <bpm@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_format.h')
-rw-r--r--fs/xfs/xfs_dir2_format.h60
1 files changed, 53 insertions, 7 deletions
diff --git a/fs/xfs/xfs_dir2_format.h b/fs/xfs/xfs_dir2_format.h
index 0ac09502b830..7b986d334b33 100644
--- a/fs/xfs/xfs_dir2_format.h
+++ b/fs/xfs/xfs_dir2_format.h
@@ -470,6 +470,21 @@ typedef struct xfs_dir2_leaf_hdr {
470 __be16 stale; /* count of stale entries */ 470 __be16 stale; /* count of stale entries */
471} xfs_dir2_leaf_hdr_t; 471} xfs_dir2_leaf_hdr_t;
472 472
473struct xfs_dir3_leaf_hdr {
474 struct xfs_da3_blkinfo info; /* header for da routines */
475 __be16 count; /* count of entries */
476 __be16 stale; /* count of stale entries */
477 __be32 pad;
478};
479
480struct xfs_dir3_icleaf_hdr {
481 __uint32_t forw;
482 __uint32_t back;
483 __uint16_t magic;
484 __uint16_t count;
485 __uint16_t stale;
486};
487
473/* 488/*
474 * Leaf block entry. 489 * Leaf block entry.
475 */ 490 */
@@ -489,23 +504,50 @@ typedef struct xfs_dir2_leaf_tail {
489 * Leaf block. 504 * Leaf block.
490 */ 505 */
491typedef struct xfs_dir2_leaf { 506typedef struct xfs_dir2_leaf {
492 xfs_dir2_leaf_hdr_t hdr; /* leaf header */ 507 xfs_dir2_leaf_hdr_t hdr; /* leaf header */
493 xfs_dir2_leaf_entry_t ents[]; /* entries */ 508 xfs_dir2_leaf_entry_t __ents[]; /* entries */
494} xfs_dir2_leaf_t; 509} xfs_dir2_leaf_t;
495 510
496/* 511struct xfs_dir3_leaf {
497 * DB blocks here are logical directory block numbers, not filesystem blocks. 512 struct xfs_dir3_leaf_hdr hdr; /* leaf header */
498 */ 513 struct xfs_dir2_leaf_entry __ents[]; /* entries */
514};
515
516#define XFS_DIR3_LEAF_CRC_OFF offsetof(struct xfs_dir3_leaf_hdr, info.crc)
517
518static inline int
519xfs_dir3_leaf_hdr_size(struct xfs_dir2_leaf *lp)
520{
521 if (lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) ||
522 lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC))
523 return sizeof(struct xfs_dir3_leaf_hdr);
524 return sizeof(struct xfs_dir2_leaf_hdr);
525}
499 526
500static inline int xfs_dir2_max_leaf_ents(struct xfs_mount *mp) 527static inline int
528xfs_dir3_max_leaf_ents(struct xfs_mount *mp, struct xfs_dir2_leaf *lp)
501{ 529{
502 return (mp->m_dirblksize - (uint)sizeof(struct xfs_dir2_leaf_hdr)) / 530 return (mp->m_dirblksize - xfs_dir3_leaf_hdr_size(lp)) /
503 (uint)sizeof(struct xfs_dir2_leaf_entry); 531 (uint)sizeof(struct xfs_dir2_leaf_entry);
504} 532}
505 533
506/* 534/*
507 * Get address of the bestcount field in the single-leaf block. 535 * Get address of the bestcount field in the single-leaf block.
508 */ 536 */
537static inline struct xfs_dir2_leaf_entry *
538xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp)
539{
540 if (lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) ||
541 lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) {
542 struct xfs_dir3_leaf *lp3 = (struct xfs_dir3_leaf *)lp;
543 return lp3->__ents;
544 }
545 return lp->__ents;
546}
547
548/*
549 * Get address of the bestcount field in the single-leaf block.
550 */
509static inline struct xfs_dir2_leaf_tail * 551static inline struct xfs_dir2_leaf_tail *
510xfs_dir2_leaf_tail_p(struct xfs_mount *mp, struct xfs_dir2_leaf *lp) 552xfs_dir2_leaf_tail_p(struct xfs_mount *mp, struct xfs_dir2_leaf *lp)
511{ 553{
@@ -524,6 +566,10 @@ xfs_dir2_leaf_bests_p(struct xfs_dir2_leaf_tail *ltp)
524} 566}
525 567
526/* 568/*
569 * DB blocks here are logical directory block numbers, not filesystem blocks.
570 */
571
572/*
527 * Convert dataptr to byte in file space 573 * Convert dataptr to byte in file space
528 */ 574 */
529static inline xfs_dir2_off_t 575static inline xfs_dir2_off_t