mirror of
https://github.com/torvalds/linux.git
synced 2024-12-13 22:53:20 +00:00
38c26bfd90
Convert the xfs_sb_version_hasfoo() to checks against mp->m_features. Checks of the superblock itself during disk operations (e.g. in the read/write verifiers and the to/from disk formatters) are not converted - they operate purely on the superblock state. Everything else should use the mount features. Large parts of this conversion were done with sed with commands like this: for f in `git grep -l xfs_sb_version_has fs/xfs/*.c`; do sed -i -e 's/xfs_sb_version_has\(.*\)(&\(.*\)->m_sb)/xfs_has_\1(\2)/' $f done With manual cleanups for things like "xfs_has_extflgbit" and other little inconsistencies in naming. The result is ia lot less typing to check features and an XFS binary size reduced by a bit over 3kB: $ size -t fs/xfs/built-in.a text data bss dec hex filenam before 1130866 311352 484 1442702 16038e (TOTALS) after 1127727 311352 484 1439563 15f74b (TOTALS) Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
114 lines
3.5 KiB
C
114 lines
3.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (c) 2000,2002-2005 Silicon Graphics, Inc.
|
|
* All Rights Reserved.
|
|
*/
|
|
#ifndef __XFS_BMAP_BTREE_H__
|
|
#define __XFS_BMAP_BTREE_H__
|
|
|
|
struct xfs_btree_cur;
|
|
struct xfs_btree_block;
|
|
struct xfs_mount;
|
|
struct xfs_inode;
|
|
struct xfs_trans;
|
|
|
|
/*
|
|
* Btree block header size depends on a superblock flag.
|
|
*/
|
|
#define XFS_BMBT_BLOCK_LEN(mp) \
|
|
(xfs_has_crc(((mp))) ? \
|
|
XFS_BTREE_LBLOCK_CRC_LEN : XFS_BTREE_LBLOCK_LEN)
|
|
|
|
#define XFS_BMBT_REC_ADDR(mp, block, index) \
|
|
((xfs_bmbt_rec_t *) \
|
|
((char *)(block) + \
|
|
XFS_BMBT_BLOCK_LEN(mp) + \
|
|
((index) - 1) * sizeof(xfs_bmbt_rec_t)))
|
|
|
|
#define XFS_BMBT_KEY_ADDR(mp, block, index) \
|
|
((xfs_bmbt_key_t *) \
|
|
((char *)(block) + \
|
|
XFS_BMBT_BLOCK_LEN(mp) + \
|
|
((index) - 1) * sizeof(xfs_bmbt_key_t)))
|
|
|
|
#define XFS_BMBT_PTR_ADDR(mp, block, index, maxrecs) \
|
|
((xfs_bmbt_ptr_t *) \
|
|
((char *)(block) + \
|
|
XFS_BMBT_BLOCK_LEN(mp) + \
|
|
(maxrecs) * sizeof(xfs_bmbt_key_t) + \
|
|
((index) - 1) * sizeof(xfs_bmbt_ptr_t)))
|
|
|
|
#define XFS_BMDR_REC_ADDR(block, index) \
|
|
((xfs_bmdr_rec_t *) \
|
|
((char *)(block) + \
|
|
sizeof(struct xfs_bmdr_block) + \
|
|
((index) - 1) * sizeof(xfs_bmdr_rec_t)))
|
|
|
|
#define XFS_BMDR_KEY_ADDR(block, index) \
|
|
((xfs_bmdr_key_t *) \
|
|
((char *)(block) + \
|
|
sizeof(struct xfs_bmdr_block) + \
|
|
((index) - 1) * sizeof(xfs_bmdr_key_t)))
|
|
|
|
#define XFS_BMDR_PTR_ADDR(block, index, maxrecs) \
|
|
((xfs_bmdr_ptr_t *) \
|
|
((char *)(block) + \
|
|
sizeof(struct xfs_bmdr_block) + \
|
|
(maxrecs) * sizeof(xfs_bmdr_key_t) + \
|
|
((index) - 1) * sizeof(xfs_bmdr_ptr_t)))
|
|
|
|
/*
|
|
* These are to be used when we know the size of the block and
|
|
* we don't have a cursor.
|
|
*/
|
|
#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(mp, nrecs) \
|
|
(int)(XFS_BMBT_BLOCK_LEN(mp) + \
|
|
((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
|
|
|
|
#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))))
|
|
#define XFS_BMAP_BMDR_SPACE(bb) \
|
|
(XFS_BMDR_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs)))
|
|
|
|
/*
|
|
* Maximum number of bmap btree levels.
|
|
*/
|
|
#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[(w)])
|
|
|
|
/*
|
|
* Prototypes for xfs_bmap.c to call.
|
|
*/
|
|
extern void xfs_bmdr_to_bmbt(struct xfs_inode *, xfs_bmdr_block_t *, int,
|
|
struct xfs_btree_block *, int);
|
|
|
|
void xfs_bmbt_disk_set_all(struct xfs_bmbt_rec *r, struct xfs_bmbt_irec *s);
|
|
extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(const struct xfs_bmbt_rec *r);
|
|
extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(const struct xfs_bmbt_rec *r);
|
|
void xfs_bmbt_disk_get_all(const struct xfs_bmbt_rec *r,
|
|
struct xfs_bmbt_irec *s);
|
|
|
|
extern void xfs_bmbt_to_bmdr(struct xfs_mount *, struct xfs_btree_block *, int,
|
|
xfs_bmdr_block_t *, int);
|
|
|
|
extern int xfs_bmbt_get_maxrecs(struct xfs_btree_cur *, int level);
|
|
extern int xfs_bmdr_maxrecs(int blocklen, int leaf);
|
|
extern int xfs_bmbt_maxrecs(struct xfs_mount *, int blocklen, int leaf);
|
|
|
|
extern int xfs_bmbt_change_owner(struct xfs_trans *tp, struct xfs_inode *ip,
|
|
int whichfork, xfs_ino_t new_owner,
|
|
struct list_head *buffer_list);
|
|
|
|
extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
|
|
struct xfs_trans *, struct xfs_inode *, int);
|
|
|
|
extern unsigned long long xfs_bmbt_calc_size(struct xfs_mount *mp,
|
|
unsigned long long len);
|
|
|
|
#endif /* __XFS_BMAP_BTREE_H__ */
|