blob: 0d22c56fdf64247f6f208ef0ed2f2a72a7b64e22 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_EXTFREE_ITEM_H__
19#define __XFS_EXTFREE_ITEM_H__
20
21struct xfs_mount;
22struct kmem_zone;
23
24typedef struct xfs_extent {
25 xfs_dfsbno_t ext_start;
26 xfs_extlen_t ext_len;
27} xfs_extent_t;
28
29/*
Tim Shimmin6d192a92006-06-09 14:55:38 +100030 * Since an xfs_extent_t has types (start:64, len: 32)
31 * there are different alignments on 32 bit and 64 bit kernels.
32 * So we provide the different variants for use by a
33 * conversion routine.
34 */
35
36typedef struct xfs_extent_32 {
Tim Shimmin128dabc2006-09-28 10:55:43 +100037 __uint64_t ext_start;
38 __uint32_t ext_len;
Tim Shimmin6d192a92006-06-09 14:55:38 +100039} __attribute__((packed)) xfs_extent_32_t;
40
41typedef struct xfs_extent_64 {
Tim Shimmin128dabc2006-09-28 10:55:43 +100042 __uint64_t ext_start;
43 __uint32_t ext_len;
Tim Shimmin6d192a92006-06-09 14:55:38 +100044 __uint32_t ext_pad;
45} xfs_extent_64_t;
46
47/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 * This is the structure used to lay out an efi log item in the
49 * log. The efi_extents field is a variable size array whose
50 * size is given by efi_nextents.
51 */
52typedef struct xfs_efi_log_format {
Tim Shimmin128dabc2006-09-28 10:55:43 +100053 __uint16_t efi_type; /* efi log item type */
54 __uint16_t efi_size; /* size of this item */
55 __uint32_t efi_nextents; /* # extents to free */
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 __uint64_t efi_id; /* efi identifier */
57 xfs_extent_t efi_extents[1]; /* array of extents to free */
58} xfs_efi_log_format_t;
59
Tim Shimmin6d192a92006-06-09 14:55:38 +100060typedef struct xfs_efi_log_format_32 {
Tim Shimmin128dabc2006-09-28 10:55:43 +100061 __uint16_t efi_type; /* efi log item type */
62 __uint16_t efi_size; /* size of this item */
63 __uint32_t efi_nextents; /* # extents to free */
Tim Shimmin6d192a92006-06-09 14:55:38 +100064 __uint64_t efi_id; /* efi identifier */
65 xfs_extent_32_t efi_extents[1]; /* array of extents to free */
66} __attribute__((packed)) xfs_efi_log_format_32_t;
67
68typedef struct xfs_efi_log_format_64 {
Tim Shimmin128dabc2006-09-28 10:55:43 +100069 __uint16_t efi_type; /* efi log item type */
70 __uint16_t efi_size; /* size of this item */
71 __uint32_t efi_nextents; /* # extents to free */
Tim Shimmin6d192a92006-06-09 14:55:38 +100072 __uint64_t efi_id; /* efi identifier */
73 xfs_extent_64_t efi_extents[1]; /* array of extents to free */
74} xfs_efi_log_format_64_t;
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076/*
77 * This is the structure used to lay out an efd log item in the
78 * log. The efd_extents array is a variable size array whose
79 * size is given by efd_nextents;
80 */
81typedef struct xfs_efd_log_format {
Tim Shimmin128dabc2006-09-28 10:55:43 +100082 __uint16_t efd_type; /* efd log item type */
83 __uint16_t efd_size; /* size of this item */
84 __uint32_t efd_nextents; /* # of extents freed */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 __uint64_t efd_efi_id; /* id of corresponding efi */
86 xfs_extent_t efd_extents[1]; /* array of extents freed */
87} xfs_efd_log_format_t;
88
Tim Shimmin6d192a92006-06-09 14:55:38 +100089typedef struct xfs_efd_log_format_32 {
Tim Shimmin128dabc2006-09-28 10:55:43 +100090 __uint16_t efd_type; /* efd log item type */
91 __uint16_t efd_size; /* size of this item */
92 __uint32_t efd_nextents; /* # of extents freed */
Tim Shimmin6d192a92006-06-09 14:55:38 +100093 __uint64_t efd_efi_id; /* id of corresponding efi */
94 xfs_extent_32_t efd_extents[1]; /* array of extents freed */
95} __attribute__((packed)) xfs_efd_log_format_32_t;
96
97typedef struct xfs_efd_log_format_64 {
Tim Shimmin128dabc2006-09-28 10:55:43 +100098 __uint16_t efd_type; /* efd log item type */
99 __uint16_t efd_size; /* size of this item */
100 __uint32_t efd_nextents; /* # of extents freed */
Tim Shimmin6d192a92006-06-09 14:55:38 +1000101 __uint64_t efd_efi_id; /* id of corresponding efi */
102 xfs_extent_64_t efd_extents[1]; /* array of extents freed */
103} xfs_efd_log_format_64_t;
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106#ifdef __KERNEL__
107
108/*
109 * Max number of extents in fast allocation path.
110 */
111#define XFS_EFI_MAX_FAST_EXTENTS 16
112
113/*
114 * Define EFI flags.
115 */
116#define XFS_EFI_RECOVERED 0x1
117#define XFS_EFI_COMMITTED 0x2
118#define XFS_EFI_CANCELED 0x4
119
120/*
121 * This is the "extent free intention" log item. It is used
122 * to log the fact that some extents need to be free. It is
123 * used in conjunction with the "extent free done" log item
124 * described below.
125 */
126typedef struct xfs_efi_log_item {
127 xfs_log_item_t efi_item;
128 uint efi_flags; /* misc flags */
129 uint efi_next_extent;
130 xfs_efi_log_format_t efi_format;
131} xfs_efi_log_item_t;
132
133/*
134 * This is the "extent free done" log item. It is used to log
135 * the fact that some extents earlier mentioned in an efi item
136 * have been freed.
137 */
138typedef struct xfs_efd_log_item {
139 xfs_log_item_t efd_item;
140 xfs_efi_log_item_t *efd_efip;
141 uint efd_next_extent;
142 xfs_efd_log_format_t efd_format;
143} xfs_efd_log_item_t;
144
145/*
146 * Max number of extents in fast allocation path.
147 */
148#define XFS_EFD_MAX_FAST_EXTENTS 16
149
150extern struct kmem_zone *xfs_efi_zone;
151extern struct kmem_zone *xfs_efd_zone;
152
153xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint);
154xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
155 uint);
Tim Shimmin6d192a92006-06-09 14:55:38 +1000156int xfs_efi_copy_format(xfs_log_iovec_t *buf,
157 xfs_efi_log_format_t *dst_efi_fmt);
Christoph Hellwig7d795ca2005-06-21 15:41:19 +1000158void xfs_efi_item_free(xfs_efi_log_item_t *);
159
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160#endif /* __KERNEL__ */
161
162#endif /* __XFS_EXTFREE_ITEM_H__ */