xref: /linux/fs/xfs/xfs_extfree_item.h (revision 6d192a9b82212abf1e0e89da6e3a952afba7e4d6)
11da177e4SLinus Torvalds /*
27b718769SNathan Scott  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
37b718769SNathan Scott  * All Rights Reserved.
41da177e4SLinus Torvalds  *
57b718769SNathan Scott  * This program is free software; you can redistribute it and/or
67b718769SNathan Scott  * modify it under the terms of the GNU General Public License as
71da177e4SLinus Torvalds  * published by the Free Software Foundation.
81da177e4SLinus Torvalds  *
97b718769SNathan Scott  * This program is distributed in the hope that it would be useful,
107b718769SNathan Scott  * but WITHOUT ANY WARRANTY; without even the implied warranty of
117b718769SNathan Scott  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
127b718769SNathan Scott  * GNU General Public License for more details.
131da177e4SLinus Torvalds  *
147b718769SNathan Scott  * You should have received a copy of the GNU General Public License
157b718769SNathan Scott  * along with this program; if not, write the Free Software Foundation,
167b718769SNathan Scott  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
171da177e4SLinus Torvalds  */
181da177e4SLinus Torvalds #ifndef	__XFS_EXTFREE_ITEM_H__
191da177e4SLinus Torvalds #define	__XFS_EXTFREE_ITEM_H__
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds struct xfs_mount;
221da177e4SLinus Torvalds struct kmem_zone;
231da177e4SLinus Torvalds 
241da177e4SLinus Torvalds typedef struct xfs_extent {
251da177e4SLinus Torvalds 	xfs_dfsbno_t	ext_start;
261da177e4SLinus Torvalds 	xfs_extlen_t	ext_len;
271da177e4SLinus Torvalds } xfs_extent_t;
281da177e4SLinus Torvalds 
291da177e4SLinus Torvalds /*
30*6d192a9bSTim Shimmin  * Since an xfs_extent_t has types (start:64, len: 32)
31*6d192a9bSTim Shimmin  * there are different alignments on 32 bit and 64 bit kernels.
32*6d192a9bSTim Shimmin  * So we provide the different variants for use by a
33*6d192a9bSTim Shimmin  * conversion routine.
34*6d192a9bSTim Shimmin  */
35*6d192a9bSTim Shimmin 
36*6d192a9bSTim Shimmin typedef struct xfs_extent_32 {
37*6d192a9bSTim Shimmin 	xfs_dfsbno_t	ext_start;
38*6d192a9bSTim Shimmin 	xfs_extlen_t	ext_len;
39*6d192a9bSTim Shimmin } __attribute__((packed)) xfs_extent_32_t;
40*6d192a9bSTim Shimmin 
41*6d192a9bSTim Shimmin typedef struct xfs_extent_64 {
42*6d192a9bSTim Shimmin 	xfs_dfsbno_t	ext_start;
43*6d192a9bSTim Shimmin 	xfs_extlen_t	ext_len;
44*6d192a9bSTim Shimmin 	__uint32_t	ext_pad;
45*6d192a9bSTim Shimmin } xfs_extent_64_t;
46*6d192a9bSTim Shimmin 
47*6d192a9bSTim Shimmin /*
481da177e4SLinus Torvalds  * This is the structure used to lay out an efi log item in the
491da177e4SLinus Torvalds  * log.  The efi_extents field is a variable size array whose
501da177e4SLinus Torvalds  * size is given by efi_nextents.
511da177e4SLinus Torvalds  */
521da177e4SLinus Torvalds typedef struct xfs_efi_log_format {
531da177e4SLinus Torvalds 	unsigned short		efi_type;	/* efi log item type */
541da177e4SLinus Torvalds 	unsigned short		efi_size;	/* size of this item */
551da177e4SLinus Torvalds 	uint			efi_nextents;	/* # extents to free */
561da177e4SLinus Torvalds 	__uint64_t		efi_id;		/* efi identifier */
571da177e4SLinus Torvalds 	xfs_extent_t		efi_extents[1];	/* array of extents to free */
581da177e4SLinus Torvalds } xfs_efi_log_format_t;
591da177e4SLinus Torvalds 
60*6d192a9bSTim Shimmin typedef struct xfs_efi_log_format_32 {
61*6d192a9bSTim Shimmin 	unsigned short		efi_type;	/* efi log item type */
62*6d192a9bSTim Shimmin 	unsigned short		efi_size;	/* size of this item */
63*6d192a9bSTim Shimmin 	uint			efi_nextents;	/* # extents to free */
64*6d192a9bSTim Shimmin 	__uint64_t		efi_id;		/* efi identifier */
65*6d192a9bSTim Shimmin 	xfs_extent_32_t		efi_extents[1];	/* array of extents to free */
66*6d192a9bSTim Shimmin } __attribute__((packed)) xfs_efi_log_format_32_t;
67*6d192a9bSTim Shimmin 
68*6d192a9bSTim Shimmin typedef struct xfs_efi_log_format_64 {
69*6d192a9bSTim Shimmin 	unsigned short		efi_type;	/* efi log item type */
70*6d192a9bSTim Shimmin 	unsigned short		efi_size;	/* size of this item */
71*6d192a9bSTim Shimmin 	uint			efi_nextents;	/* # extents to free */
72*6d192a9bSTim Shimmin 	__uint64_t		efi_id;		/* efi identifier */
73*6d192a9bSTim Shimmin 	xfs_extent_64_t		efi_extents[1];	/* array of extents to free */
74*6d192a9bSTim Shimmin } xfs_efi_log_format_64_t;
75*6d192a9bSTim Shimmin 
761da177e4SLinus Torvalds /*
771da177e4SLinus Torvalds  * This is the structure used to lay out an efd log item in the
781da177e4SLinus Torvalds  * log.  The efd_extents array is a variable size array whose
791da177e4SLinus Torvalds  * size is given by efd_nextents;
801da177e4SLinus Torvalds  */
811da177e4SLinus Torvalds typedef struct xfs_efd_log_format {
821da177e4SLinus Torvalds 	unsigned short		efd_type;	/* efd log item type */
831da177e4SLinus Torvalds 	unsigned short		efd_size;	/* size of this item */
841da177e4SLinus Torvalds 	uint			efd_nextents;	/* # of extents freed */
851da177e4SLinus Torvalds 	__uint64_t		efd_efi_id;	/* id of corresponding efi */
861da177e4SLinus Torvalds 	xfs_extent_t		efd_extents[1];	/* array of extents freed */
871da177e4SLinus Torvalds } xfs_efd_log_format_t;
881da177e4SLinus Torvalds 
89*6d192a9bSTim Shimmin typedef struct xfs_efd_log_format_32 {
90*6d192a9bSTim Shimmin 	unsigned short		efd_type;	/* efd log item type */
91*6d192a9bSTim Shimmin 	unsigned short		efd_size;	/* size of this item */
92*6d192a9bSTim Shimmin 	uint			efd_nextents;	/* # of extents freed */
93*6d192a9bSTim Shimmin 	__uint64_t		efd_efi_id;	/* id of corresponding efi */
94*6d192a9bSTim Shimmin 	xfs_extent_32_t		efd_extents[1];	/* array of extents freed */
95*6d192a9bSTim Shimmin } __attribute__((packed)) xfs_efd_log_format_32_t;
96*6d192a9bSTim Shimmin 
97*6d192a9bSTim Shimmin typedef struct xfs_efd_log_format_64 {
98*6d192a9bSTim Shimmin 	unsigned short		efd_type;	/* efd log item type */
99*6d192a9bSTim Shimmin 	unsigned short		efd_size;	/* size of this item */
100*6d192a9bSTim Shimmin 	uint			efd_nextents;	/* # of extents freed */
101*6d192a9bSTim Shimmin 	__uint64_t		efd_efi_id;	/* id of corresponding efi */
102*6d192a9bSTim Shimmin 	xfs_extent_64_t		efd_extents[1];	/* array of extents freed */
103*6d192a9bSTim Shimmin } xfs_efd_log_format_64_t;
104*6d192a9bSTim Shimmin 
1051da177e4SLinus Torvalds 
1061da177e4SLinus Torvalds #ifdef __KERNEL__
1071da177e4SLinus Torvalds 
1081da177e4SLinus Torvalds /*
1091da177e4SLinus Torvalds  * Max number of extents in fast allocation path.
1101da177e4SLinus Torvalds  */
1111da177e4SLinus Torvalds #define	XFS_EFI_MAX_FAST_EXTENTS	16
1121da177e4SLinus Torvalds 
1131da177e4SLinus Torvalds /*
1141da177e4SLinus Torvalds  * Define EFI flags.
1151da177e4SLinus Torvalds  */
1161da177e4SLinus Torvalds #define	XFS_EFI_RECOVERED	0x1
1171da177e4SLinus Torvalds #define	XFS_EFI_COMMITTED	0x2
1181da177e4SLinus Torvalds #define	XFS_EFI_CANCELED	0x4
1191da177e4SLinus Torvalds 
1201da177e4SLinus Torvalds /*
1211da177e4SLinus Torvalds  * This is the "extent free intention" log item.  It is used
1221da177e4SLinus Torvalds  * to log the fact that some extents need to be free.  It is
1231da177e4SLinus Torvalds  * used in conjunction with the "extent free done" log item
1241da177e4SLinus Torvalds  * described below.
1251da177e4SLinus Torvalds  */
1261da177e4SLinus Torvalds typedef struct xfs_efi_log_item {
1271da177e4SLinus Torvalds 	xfs_log_item_t		efi_item;
1281da177e4SLinus Torvalds 	uint			efi_flags;	/* misc flags */
1291da177e4SLinus Torvalds 	uint			efi_next_extent;
1301da177e4SLinus Torvalds 	xfs_efi_log_format_t	efi_format;
1311da177e4SLinus Torvalds } xfs_efi_log_item_t;
1321da177e4SLinus Torvalds 
1331da177e4SLinus Torvalds /*
1341da177e4SLinus Torvalds  * This is the "extent free done" log item.  It is used to log
1351da177e4SLinus Torvalds  * the fact that some extents earlier mentioned in an efi item
1361da177e4SLinus Torvalds  * have been freed.
1371da177e4SLinus Torvalds  */
1381da177e4SLinus Torvalds typedef struct xfs_efd_log_item {
1391da177e4SLinus Torvalds 	xfs_log_item_t		efd_item;
1401da177e4SLinus Torvalds 	xfs_efi_log_item_t	*efd_efip;
1411da177e4SLinus Torvalds 	uint			efd_next_extent;
1421da177e4SLinus Torvalds 	xfs_efd_log_format_t	efd_format;
1431da177e4SLinus Torvalds } xfs_efd_log_item_t;
1441da177e4SLinus Torvalds 
1451da177e4SLinus Torvalds /*
1461da177e4SLinus Torvalds  * Max number of extents in fast allocation path.
1471da177e4SLinus Torvalds  */
1481da177e4SLinus Torvalds #define	XFS_EFD_MAX_FAST_EXTENTS	16
1491da177e4SLinus Torvalds 
1501da177e4SLinus Torvalds extern struct kmem_zone	*xfs_efi_zone;
1511da177e4SLinus Torvalds extern struct kmem_zone	*xfs_efd_zone;
1521da177e4SLinus Torvalds 
1531da177e4SLinus Torvalds xfs_efi_log_item_t	*xfs_efi_init(struct xfs_mount *, uint);
1541da177e4SLinus Torvalds xfs_efd_log_item_t	*xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
1551da177e4SLinus Torvalds 				      uint);
156*6d192a9bSTim Shimmin int			xfs_efi_copy_format(xfs_log_iovec_t *buf,
157*6d192a9bSTim Shimmin 					    xfs_efi_log_format_t *dst_efi_fmt);
1587d795ca3SChristoph Hellwig void			xfs_efi_item_free(xfs_efi_log_item_t *);
1597d795ca3SChristoph Hellwig 
1601da177e4SLinus Torvalds #endif	/* __KERNEL__ */
1611da177e4SLinus Torvalds 
1621da177e4SLinus Torvalds #endif	/* __XFS_EXTFREE_ITEM_H__ */
163