aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_btree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_btree.h')
-rw-r--r--fs/xfs/xfs_btree.h120
1 files changed, 14 insertions, 106 deletions
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 09b4e1532a35..30ee83712c79 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -113,12 +113,7 @@ typedef struct xfs_btree_block
113/* 113/*
114 * Boolean to select which form of xfs_btree_block_t.bb_u to use. 114 * Boolean to select which form of xfs_btree_block_t.bb_u to use.
115 */ 115 */
116#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BTREE_LONG_PTRS)
117int xfs_btree_long_ptrs(xfs_btnum_t btnum);
118#define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP) 116#define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP)
119#else
120#define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP)
121#endif
122 117
123/* 118/*
124 * Magic numbers for btree blocks. 119 * Magic numbers for btree blocks.
@@ -205,24 +200,10 @@ typedef struct xfs_btree_cur
205/* 200/*
206 * Convert from buffer to btree block header. 201 * Convert from buffer to btree block header.
207 */ 202 */
208#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_BLOCK) 203#define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)XFS_BUF_PTR(bp))
209xfs_btree_block_t *xfs_buf_to_block(struct xfs_buf *bp); 204#define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)XFS_BUF_PTR(bp))
210#define XFS_BUF_TO_BLOCK(bp) xfs_buf_to_block(bp) 205#define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)XFS_BUF_PTR(bp))
211#else 206
212#define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)(XFS_BUF_PTR(bp)))
213#endif
214#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_LBLOCK)
215xfs_btree_lblock_t *xfs_buf_to_lblock(struct xfs_buf *bp);
216#define XFS_BUF_TO_LBLOCK(bp) xfs_buf_to_lblock(bp)
217#else
218#define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)(XFS_BUF_PTR(bp)))
219#endif
220#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_SBLOCK)
221xfs_btree_sblock_t *xfs_buf_to_sblock(struct xfs_buf *bp);
222#define XFS_BUF_TO_SBLOCK(bp) xfs_buf_to_sblock(bp)
223#else
224#define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)(XFS_BUF_PTR(bp)))
225#endif
226 207
227#ifdef __KERNEL__ 208#ifdef __KERNEL__
228 209
@@ -477,106 +458,33 @@ xfs_btree_setbuf(
477/* 458/*
478 * Min and max functions for extlen, agblock, fileoff, and filblks types. 459 * Min and max functions for extlen, agblock, fileoff, and filblks types.
479 */ 460 */
480#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTLEN_MIN)
481xfs_extlen_t xfs_extlen_min(xfs_extlen_t a, xfs_extlen_t b);
482#define XFS_EXTLEN_MIN(a,b) xfs_extlen_min(a,b)
483#else
484#define XFS_EXTLEN_MIN(a,b) \ 461#define XFS_EXTLEN_MIN(a,b) \
485 ((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \ 462 ((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \
486 (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) 463 (xfs_extlen_t)(a) : (xfs_extlen_t)(b))
487#endif
488#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTLEN_MAX)
489xfs_extlen_t xfs_extlen_max(xfs_extlen_t a, xfs_extlen_t b);
490#define XFS_EXTLEN_MAX(a,b) xfs_extlen_max(a,b)
491#else
492#define XFS_EXTLEN_MAX(a,b) \ 464#define XFS_EXTLEN_MAX(a,b) \
493 ((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \ 465 ((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \
494 (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) 466 (xfs_extlen_t)(a) : (xfs_extlen_t)(b))
495#endif
496
497#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGBLOCK_MIN)
498xfs_agblock_t xfs_agblock_min(xfs_agblock_t a, xfs_agblock_t b);
499#define XFS_AGBLOCK_MIN(a,b) xfs_agblock_min(a,b)
500#else
501#define XFS_AGBLOCK_MIN(a,b) \ 467#define XFS_AGBLOCK_MIN(a,b) \
502 ((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \ 468 ((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \
503 (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) 469 (xfs_agblock_t)(a) : (xfs_agblock_t)(b))
504#endif
505#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGBLOCK_MAX)
506xfs_agblock_t xfs_agblock_max(xfs_agblock_t a, xfs_agblock_t b);
507#define XFS_AGBLOCK_MAX(a,b) xfs_agblock_max(a,b)
508#else
509#define XFS_AGBLOCK_MAX(a,b) \ 470#define XFS_AGBLOCK_MAX(a,b) \
510 ((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \ 471 ((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \
511 (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) 472 (xfs_agblock_t)(a) : (xfs_agblock_t)(b))
512#endif
513
514#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILEOFF_MIN)
515xfs_fileoff_t xfs_fileoff_min(xfs_fileoff_t a, xfs_fileoff_t b);
516#define XFS_FILEOFF_MIN(a,b) xfs_fileoff_min(a,b)
517#else
518#define XFS_FILEOFF_MIN(a,b) \ 473#define XFS_FILEOFF_MIN(a,b) \
519 ((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \ 474 ((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \
520 (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) 475 (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b))
521#endif
522#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILEOFF_MAX)
523xfs_fileoff_t xfs_fileoff_max(xfs_fileoff_t a, xfs_fileoff_t b);
524#define XFS_FILEOFF_MAX(a,b) xfs_fileoff_max(a,b)
525#else
526#define XFS_FILEOFF_MAX(a,b) \ 476#define XFS_FILEOFF_MAX(a,b) \
527 ((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \ 477 ((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \
528 (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) 478 (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b))
529#endif
530
531#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILBLKS_MIN)
532xfs_filblks_t xfs_filblks_min(xfs_filblks_t a, xfs_filblks_t b);
533#define XFS_FILBLKS_MIN(a,b) xfs_filblks_min(a,b)
534#else
535#define XFS_FILBLKS_MIN(a,b) \ 479#define XFS_FILBLKS_MIN(a,b) \
536 ((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \ 480 ((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \
537 (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) 481 (xfs_filblks_t)(a) : (xfs_filblks_t)(b))
538#endif
539#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILBLKS_MAX)
540xfs_filblks_t xfs_filblks_max(xfs_filblks_t a, xfs_filblks_t b);
541#define XFS_FILBLKS_MAX(a,b) xfs_filblks_max(a,b)
542#else
543#define XFS_FILBLKS_MAX(a,b) \ 482#define XFS_FILBLKS_MAX(a,b) \
544 ((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \ 483 ((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \
545 (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) 484 (xfs_filblks_t)(a) : (xfs_filblks_t)(b))
546#endif 485
547#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_SANITY_CHECK)
548int xfs_fsb_sanity_check(struct xfs_mount *mp, xfs_fsblock_t fsb);
549#define XFS_FSB_SANITY_CHECK(mp,fsb) xfs_fsb_sanity_check(mp,fsb)
550#else
551#define XFS_FSB_SANITY_CHECK(mp,fsb) \ 486#define XFS_FSB_SANITY_CHECK(mp,fsb) \
552 (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \ 487 (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
553 XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks) 488 XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks)
554#endif
555
556/*
557 * Macros to set EFSCORRUPTED & return/branch.
558 */
559#define XFS_WANT_CORRUPTED_GOTO(x,l) \
560 { \
561 int fs_is_ok = (x); \
562 ASSERT(fs_is_ok); \
563 if (unlikely(!fs_is_ok)) { \
564 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
565 XFS_ERRLEVEL_LOW, NULL); \
566 error = XFS_ERROR(EFSCORRUPTED); \
567 goto l; \
568 } \
569 }
570
571#define XFS_WANT_CORRUPTED_RETURN(x) \
572 { \
573 int fs_is_ok = (x); \
574 ASSERT(fs_is_ok); \
575 if (unlikely(!fs_is_ok)) { \
576 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
577 XFS_ERRLEVEL_LOW, NULL); \
578 return XFS_ERROR(EFSCORRUPTED); \
579 } \
580 }
581 489
582#endif /* __XFS_BTREE_H__ */ 490#endif /* __XFS_BTREE_H__ */