Linux Audio

Check our new training course

Loading...
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * Copyright (c) 2000,2002-2005 Silicon Graphics, Inc.
  4 * All Rights Reserved.
  5 */
  6#ifndef __XFS_BMAP_BTREE_H__
  7#define __XFS_BMAP_BTREE_H__
  8
  9struct xfs_btree_cur;
 10struct xfs_btree_block;
 11struct xfs_mount;
 12struct xfs_inode;
 13struct xfs_trans;
 14
 15/*
 16 * Btree block header size depends on a superblock flag.
 17 */
 18#define XFS_BMBT_BLOCK_LEN(mp) \
 19	(xfs_has_crc(((mp))) ? \
 20		XFS_BTREE_LBLOCK_CRC_LEN : XFS_BTREE_LBLOCK_LEN)
 21
 22#define XFS_BMBT_REC_ADDR(mp, block, index) \
 23	((xfs_bmbt_rec_t *) \
 24		((char *)(block) + \
 25		 XFS_BMBT_BLOCK_LEN(mp) + \
 26		 ((index) - 1) * sizeof(xfs_bmbt_rec_t)))
 27
 28#define XFS_BMBT_KEY_ADDR(mp, block, index) \
 29	((xfs_bmbt_key_t *) \
 30		((char *)(block) + \
 31		 XFS_BMBT_BLOCK_LEN(mp) + \
 32		 ((index) - 1) * sizeof(xfs_bmbt_key_t)))
 33
 34#define XFS_BMBT_PTR_ADDR(mp, block, index, maxrecs) \
 35	((xfs_bmbt_ptr_t *) \
 36		((char *)(block) + \
 37		 XFS_BMBT_BLOCK_LEN(mp) + \
 38		 (maxrecs) * sizeof(xfs_bmbt_key_t) + \
 39		 ((index) - 1) * sizeof(xfs_bmbt_ptr_t)))
 40
 41#define XFS_BMDR_REC_ADDR(block, index) \
 42	((xfs_bmdr_rec_t *) \
 43		((char *)(block) + \
 44		 sizeof(struct xfs_bmdr_block) + \
 45	         ((index) - 1) * sizeof(xfs_bmdr_rec_t)))
 46
 47#define XFS_BMDR_KEY_ADDR(block, index) \
 48	((xfs_bmdr_key_t *) \
 49		((char *)(block) + \
 50		 sizeof(struct xfs_bmdr_block) + \
 51		 ((index) - 1) * sizeof(xfs_bmdr_key_t)))
 52
 53#define XFS_BMDR_PTR_ADDR(block, index, maxrecs) \
 54	((xfs_bmdr_ptr_t *) \
 55		((char *)(block) + \
 56		 sizeof(struct xfs_bmdr_block) + \
 57		 (maxrecs) * sizeof(xfs_bmdr_key_t) + \
 58		 ((index) - 1) * sizeof(xfs_bmdr_ptr_t)))
 59
 60/*
 61 * These are to be used when we know the size of the block and
 62 * we don't have a cursor.
 63 */
 64#define XFS_BMAP_BROOT_PTR_ADDR(mp, bb, i, sz) \
 65	XFS_BMBT_PTR_ADDR(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, 0))
 66
 67#define XFS_BMAP_BROOT_SPACE_CALC(mp, nrecs) \
 68	(int)(XFS_BMBT_BLOCK_LEN(mp) + \
 69	       ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
 70
 71#define XFS_BMAP_BROOT_SPACE(mp, bb) \
 72	(XFS_BMAP_BROOT_SPACE_CALC(mp, be16_to_cpu((bb)->bb_numrecs)))
 73#define XFS_BMDR_SPACE_CALC(nrecs) \
 74	(int)(sizeof(xfs_bmdr_block_t) + \
 75	       ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
 76#define XFS_BMAP_BMDR_SPACE(bb) \
 77	(XFS_BMDR_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs)))
 78
 79/*
 80 * Maximum number of bmap btree levels.
 81 */
 82#define XFS_BM_MAXLEVELS(mp,w)		((mp)->m_bm_maxlevels[(w)])
 83
 84/*
 85 * Prototypes for xfs_bmap.c to call.
 86 */
 87extern void xfs_bmdr_to_bmbt(struct xfs_inode *, xfs_bmdr_block_t *, int,
 88			struct xfs_btree_block *, int);
 89
 90void xfs_bmbt_disk_set_all(struct xfs_bmbt_rec *r, struct xfs_bmbt_irec *s);
 91extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(const struct xfs_bmbt_rec *r);
 92extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(const struct xfs_bmbt_rec *r);
 93void xfs_bmbt_disk_get_all(const struct xfs_bmbt_rec *r,
 94		struct xfs_bmbt_irec *s);
 95
 96extern void xfs_bmbt_to_bmdr(struct xfs_mount *, struct xfs_btree_block *, int,
 97			xfs_bmdr_block_t *, int);
 98
 99extern int xfs_bmbt_get_maxrecs(struct xfs_btree_cur *, int level);
100extern int xfs_bmdr_maxrecs(int blocklen, int leaf);
101extern int xfs_bmbt_maxrecs(struct xfs_mount *, int blocklen, int leaf);
102
103extern int xfs_bmbt_change_owner(struct xfs_trans *tp, struct xfs_inode *ip,
104				 int whichfork, xfs_ino_t new_owner,
105				 struct list_head *buffer_list);
106
107extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
108		struct xfs_trans *, struct xfs_inode *, int);
109
110extern unsigned long long xfs_bmbt_calc_size(struct xfs_mount *mp,
111		unsigned long long len);
112
113unsigned int xfs_bmbt_maxlevels_ondisk(void);
114
115int __init xfs_bmbt_init_cur_cache(void);
116void xfs_bmbt_destroy_cur_cache(void);
117
118#endif	/* __XFS_BMAP_BTREE_H__ */
v5.4
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * Copyright (c) 2000,2002-2005 Silicon Graphics, Inc.
  4 * All Rights Reserved.
  5 */
  6#ifndef __XFS_BMAP_BTREE_H__
  7#define __XFS_BMAP_BTREE_H__
  8
  9struct xfs_btree_cur;
 10struct xfs_btree_block;
 11struct xfs_mount;
 12struct xfs_inode;
 13struct xfs_trans;
 14
 15/*
 16 * Btree block header size depends on a superblock flag.
 17 */
 18#define XFS_BMBT_BLOCK_LEN(mp) \
 19	(xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
 20		XFS_BTREE_LBLOCK_CRC_LEN : XFS_BTREE_LBLOCK_LEN)
 21
 22#define XFS_BMBT_REC_ADDR(mp, block, index) \
 23	((xfs_bmbt_rec_t *) \
 24		((char *)(block) + \
 25		 XFS_BMBT_BLOCK_LEN(mp) + \
 26		 ((index) - 1) * sizeof(xfs_bmbt_rec_t)))
 27
 28#define XFS_BMBT_KEY_ADDR(mp, block, index) \
 29	((xfs_bmbt_key_t *) \
 30		((char *)(block) + \
 31		 XFS_BMBT_BLOCK_LEN(mp) + \
 32		 ((index) - 1) * sizeof(xfs_bmbt_key_t)))
 33
 34#define XFS_BMBT_PTR_ADDR(mp, block, index, maxrecs) \
 35	((xfs_bmbt_ptr_t *) \
 36		((char *)(block) + \
 37		 XFS_BMBT_BLOCK_LEN(mp) + \
 38		 (maxrecs) * sizeof(xfs_bmbt_key_t) + \
 39		 ((index) - 1) * sizeof(xfs_bmbt_ptr_t)))
 40
 41#define XFS_BMDR_REC_ADDR(block, index) \
 42	((xfs_bmdr_rec_t *) \
 43		((char *)(block) + \
 44		 sizeof(struct xfs_bmdr_block) + \
 45	         ((index) - 1) * sizeof(xfs_bmdr_rec_t)))
 46
 47#define XFS_BMDR_KEY_ADDR(block, index) \
 48	((xfs_bmdr_key_t *) \
 49		((char *)(block) + \
 50		 sizeof(struct xfs_bmdr_block) + \
 51		 ((index) - 1) * sizeof(xfs_bmdr_key_t)))
 52
 53#define XFS_BMDR_PTR_ADDR(block, index, maxrecs) \
 54	((xfs_bmdr_ptr_t *) \
 55		((char *)(block) + \
 56		 sizeof(struct xfs_bmdr_block) + \
 57		 (maxrecs) * sizeof(xfs_bmdr_key_t) + \
 58		 ((index) - 1) * sizeof(xfs_bmdr_ptr_t)))
 59
 60/*
 61 * These are to be used when we know the size of the block and
 62 * we don't have a cursor.
 63 */
 64#define XFS_BMAP_BROOT_PTR_ADDR(mp, bb, i, sz) \
 65	XFS_BMBT_PTR_ADDR(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, 0))
 66
 67#define XFS_BMAP_BROOT_SPACE_CALC(mp, nrecs) \
 68	(int)(XFS_BMBT_BLOCK_LEN(mp) + \
 69	       ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
 70
 71#define XFS_BMAP_BROOT_SPACE(mp, bb) \
 72	(XFS_BMAP_BROOT_SPACE_CALC(mp, be16_to_cpu((bb)->bb_numrecs)))
 73#define XFS_BMDR_SPACE_CALC(nrecs) \
 74	(int)(sizeof(xfs_bmdr_block_t) + \
 75	       ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
 76#define XFS_BMAP_BMDR_SPACE(bb) \
 77	(XFS_BMDR_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs)))
 78
 79/*
 80 * Maximum number of bmap btree levels.
 81 */
 82#define XFS_BM_MAXLEVELS(mp,w)		((mp)->m_bm_maxlevels[(w)])
 83
 84/*
 85 * Prototypes for xfs_bmap.c to call.
 86 */
 87extern void xfs_bmdr_to_bmbt(struct xfs_inode *, xfs_bmdr_block_t *, int,
 88			struct xfs_btree_block *, int);
 89
 90void xfs_bmbt_disk_set_all(struct xfs_bmbt_rec *r, struct xfs_bmbt_irec *s);
 91extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r);
 92extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(xfs_bmbt_rec_t *r);
 93extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
 
 94
 95extern void xfs_bmbt_to_bmdr(struct xfs_mount *, struct xfs_btree_block *, int,
 96			xfs_bmdr_block_t *, int);
 97
 98extern int xfs_bmbt_get_maxrecs(struct xfs_btree_cur *, int level);
 99extern int xfs_bmdr_maxrecs(int blocklen, int leaf);
100extern int xfs_bmbt_maxrecs(struct xfs_mount *, int blocklen, int leaf);
101
102extern int xfs_bmbt_change_owner(struct xfs_trans *tp, struct xfs_inode *ip,
103				 int whichfork, xfs_ino_t new_owner,
104				 struct list_head *buffer_list);
105
106extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
107		struct xfs_trans *, struct xfs_inode *, int);
108
109extern unsigned long long xfs_bmbt_calc_size(struct xfs_mount *mp,
110		unsigned long long len);
 
 
 
 
 
111
112#endif	/* __XFS_BMAP_BTREE_H__ */