Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef __XFS_BMAP_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define	__XFS_BMAP_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) struct getbmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) struct xfs_bmbt_irec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) struct xfs_ifork;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) struct xfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) struct xfs_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) struct xfs_trans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) extern kmem_zone_t	*xfs_bmap_free_item_zone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * Argument structure for xfs_bmap_alloc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) struct xfs_bmalloca {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	struct xfs_trans	*tp;	/* transaction pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	struct xfs_inode	*ip;	/* incore inode pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	struct xfs_bmbt_irec	prev;	/* extent before the new one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct xfs_bmbt_irec	got;	/* extent after, or delayed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	xfs_fileoff_t		offset;	/* offset in file filling in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	xfs_extlen_t		length;	/* i/o length asked/allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	xfs_fsblock_t		blkno;	/* starting block of new extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct xfs_btree_cur	*cur;	/* btree cursor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct xfs_iext_cursor	icur;	/* incore extent cursor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	int			nallocs;/* number of extents alloc'd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	int			logflags;/* flags for transaction logging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	xfs_extlen_t		total;	/* total blocks needed for xaction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	xfs_extlen_t		minlen;	/* minimum allocation size (blocks) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	xfs_extlen_t		minleft; /* amount must be left after alloc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	bool			eof;	/* set if allocating past last extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	bool			wasdel;	/* replacing a delayed allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	bool			aeof;	/* allocated space at eof */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	bool			conv;	/* overwriting unwritten extents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	int			datatype;/* data type being allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	int			flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * List of extents to be free "later".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * The list is kept sorted on xbf_startblock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) struct xfs_extent_free_item
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	xfs_fsblock_t		xefi_startblock;/* starting fs block number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	xfs_extlen_t		xefi_blockcount;/* number of blocks in extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	bool			xefi_skip_discard;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct list_head	xefi_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct xfs_owner_info	xefi_oinfo;	/* extent owner */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define	XFS_BMAP_MAX_NMAP	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * Flags for xfs_bmapi_*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define XFS_BMAPI_ENTIRE	0x001	/* return entire extent, not trimmed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define XFS_BMAPI_METADATA	0x002	/* mapping metadata not user data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define XFS_BMAPI_ATTRFORK	0x004	/* use attribute fork not data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #define XFS_BMAPI_PREALLOC	0x008	/* preallocation op: unwritten space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define XFS_BMAPI_CONTIG	0x020	/* must allocate only one extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * unwritten extent conversion - this needs write cache flushing and no additional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * allocation alignments. When specified with XFS_BMAPI_PREALLOC it converts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * from written to unwritten, otherwise convert from unwritten to written.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #define XFS_BMAPI_CONVERT	0x040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * allocate zeroed extents - this requires all newly allocated user data extents
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * to be initialised to zero. It will be ignored if XFS_BMAPI_METADATA is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * Use in conjunction with XFS_BMAPI_CONVERT to convert unwritten extents found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * during the allocation range to zeroed written extents.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #define XFS_BMAPI_ZERO		0x080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * Map the inode offset to the block given in ap->firstblock.  Primarily
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  * used for reflink.  The range must be in a hole, and this flag cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * turned on with PREALLOC or CONVERT, and cannot be used on the attr fork.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * For bunmapi, this flag unmaps the range without adjusting quota, reducing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  * refcount, or freeing the blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #define XFS_BMAPI_REMAP		0x100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) /* Map something in the CoW fork. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #define XFS_BMAPI_COWFORK	0x200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) /* Skip online discard of freed extents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define XFS_BMAPI_NODISCARD	0x1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* Do not update the rmap btree.  Used for reconstructing bmbt from rmapbt. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define XFS_BMAPI_NORMAP	0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define XFS_BMAPI_FLAGS \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	{ XFS_BMAPI_ENTIRE,	"ENTIRE" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	{ XFS_BMAPI_METADATA,	"METADATA" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	{ XFS_BMAPI_ATTRFORK,	"ATTRFORK" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	{ XFS_BMAPI_PREALLOC,	"PREALLOC" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	{ XFS_BMAPI_CONTIG,	"CONTIG" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	{ XFS_BMAPI_CONVERT,	"CONVERT" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	{ XFS_BMAPI_ZERO,	"ZERO" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	{ XFS_BMAPI_REMAP,	"REMAP" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	{ XFS_BMAPI_COWFORK,	"COWFORK" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	{ XFS_BMAPI_NODISCARD,	"NODISCARD" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	{ XFS_BMAPI_NORMAP,	"NORMAP" }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static inline int xfs_bmapi_aflag(int w)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	return (w == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	       (w == XFS_COW_FORK ? XFS_BMAPI_COWFORK : 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static inline int xfs_bmapi_whichfork(int bmapi_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (bmapi_flags & XFS_BMAPI_COWFORK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return XFS_COW_FORK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	else if (bmapi_flags & XFS_BMAPI_ATTRFORK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		return XFS_ATTR_FORK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	return XFS_DATA_FORK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * Special values for xfs_bmbt_irec_t br_startblock field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define	DELAYSTARTBLOCK		((xfs_fsblock_t)-1LL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define	HOLESTARTBLOCK		((xfs_fsblock_t)-2LL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * Flags for xfs_bmap_add_extent*.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define BMAP_LEFT_CONTIG	(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define BMAP_RIGHT_CONTIG	(1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #define BMAP_LEFT_FILLING	(1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #define BMAP_RIGHT_FILLING	(1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define BMAP_LEFT_DELAY		(1 << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #define BMAP_RIGHT_DELAY	(1 << 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define BMAP_LEFT_VALID		(1 << 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define BMAP_RIGHT_VALID	(1 << 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #define BMAP_ATTRFORK		(1 << 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #define BMAP_COWFORK		(1 << 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #define XFS_BMAP_EXT_FLAGS \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	{ BMAP_LEFT_CONTIG,	"LC" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	{ BMAP_RIGHT_CONTIG,	"RC" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	{ BMAP_LEFT_FILLING,	"LF" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	{ BMAP_RIGHT_FILLING,	"RF" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	{ BMAP_ATTRFORK,	"ATTR" }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	{ BMAP_COWFORK,		"COW" }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /* Return true if the extent is an allocated extent, written or not. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	return irec->br_startblock != HOLESTARTBLOCK &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		irec->br_startblock != DELAYSTARTBLOCK &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		!isnullstartblock(irec->br_startblock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * Return true if the extent is a real, allocated extent, or false if it is  a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * delayed allocation, and unwritten extent or a hole.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static inline bool xfs_bmap_is_written_extent(struct xfs_bmbt_irec *irec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	return xfs_bmap_is_real_extent(irec) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	       irec->br_state != XFS_EXT_UNWRITTEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  * Check the mapping for obviously garbage allocations that could trash the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  * filesystem immediately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #define xfs_valid_startblock(ip, startblock) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	((startblock) != 0 || XFS_IS_REALTIME_INODE(ip))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) void	xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		xfs_filblks_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) int	xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) int	xfs_bmap_set_attrforkoff(struct xfs_inode *ip, int size, int *version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) void	xfs_bmap_local_to_extents_empty(struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		struct xfs_inode *ip, int whichfork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) void	__xfs_bmap_add_free(struct xfs_trans *tp, xfs_fsblock_t bno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		xfs_filblks_t len, const struct xfs_owner_info *oinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		bool skip_discard);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) void	xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) int	xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) int	xfs_bmap_last_before(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		xfs_fileoff_t *last_block, int whichfork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) int	xfs_bmap_last_offset(struct xfs_inode *ip, xfs_fileoff_t *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		int whichfork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) int	xfs_bmap_one_block(struct xfs_inode *ip, int whichfork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) int	xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		xfs_filblks_t len, struct xfs_bmbt_irec *mval,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		int *nmap, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) int	xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		xfs_fileoff_t bno, xfs_filblks_t len, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		xfs_extlen_t total, struct xfs_bmbt_irec *mval, int *nmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) int	__xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		xfs_fileoff_t bno, xfs_filblks_t *rlen, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		xfs_extnum_t nexts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) int	xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		xfs_fileoff_t bno, xfs_filblks_t len, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		xfs_extnum_t nexts, int *done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int	xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		struct xfs_iext_cursor *cur, struct xfs_bmbt_irec *got,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		struct xfs_bmbt_irec *del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) void	xfs_bmap_del_extent_cow(struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		struct xfs_iext_cursor *cur, struct xfs_bmbt_irec *got,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		struct xfs_bmbt_irec *del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) uint	xfs_default_attroffset(struct xfs_inode *ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) int	xfs_bmap_collapse_extents(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		bool *done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) int	xfs_bmap_can_insert_extents(struct xfs_inode *ip, xfs_fileoff_t off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		xfs_fileoff_t shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) int	xfs_bmap_insert_extents(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		bool *done, xfs_fileoff_t stop_fsb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) int	xfs_bmap_split_extent(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		xfs_fileoff_t split_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) int	xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		struct xfs_bmbt_irec *got, struct xfs_iext_cursor *cur,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		int eof);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) int	xfs_bmapi_convert_delalloc(struct xfs_inode *ip, int whichfork,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		xfs_off_t offset, struct iomap *iomap, unsigned int *seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) int	xfs_bmap_add_extent_unwritten_real(struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		struct xfs_inode *ip, int whichfork,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		struct xfs_iext_cursor *icur, struct xfs_btree_cur **curp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		struct xfs_bmbt_irec *new, int *logflagsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) xfs_bmap_add_free(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	struct xfs_trans		*tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	xfs_fsblock_t			bno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	xfs_filblks_t			len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	const struct xfs_owner_info	*oinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	__xfs_bmap_add_free(tp, bno, len, oinfo, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) enum xfs_bmap_intent_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	XFS_BMAP_MAP = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	XFS_BMAP_UNMAP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct xfs_bmap_intent {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	struct list_head			bi_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	enum xfs_bmap_intent_type		bi_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	struct xfs_inode			*bi_owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	int					bi_whichfork;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	struct xfs_bmbt_irec			bi_bmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) int	xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		enum xfs_bmap_intent_type type, int whichfork,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		xfs_fileoff_t startoff, xfs_fsblock_t startblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		xfs_filblks_t *blockcount, xfs_exntst_t state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) void	xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		struct xfs_bmbt_irec *imap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) void	xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		struct xfs_bmbt_irec *imap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) static inline int xfs_bmap_fork_to_state(int whichfork)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	switch (whichfork) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	case XFS_ATTR_FORK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		return BMAP_ATTRFORK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	case XFS_COW_FORK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		return BMAP_COWFORK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_inode *ip, int whichfork,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		struct xfs_bmbt_irec *irec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) int	xfs_bmapi_remap(struct xfs_trans *tp, struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		xfs_fileoff_t bno, xfs_filblks_t len, xfs_fsblock_t startblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) #endif	/* __XFS_BMAP_H__ */