disable some mediatekl custom warnings
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / xfs / xfs_extfree_item.h
CommitLineData
1da177e4 1/*
7b718769
NS
2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
1da177e4 4 *
7b718769
NS
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
1da177e4
LT
7 * published by the Free Software Foundation.
8 *
7b718769
NS
9 * 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.
1da177e4 13 *
7b718769
NS
14 * 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
1da177e4
LT
17 */
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
6d192a9b
TS
29/*
30 * 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 {
128dabc5
TS
37 __uint64_t ext_start;
38 __uint32_t ext_len;
6d192a9b
TS
39} __attribute__((packed)) xfs_extent_32_t;
40
41typedef struct xfs_extent_64 {
128dabc5
TS
42 __uint64_t ext_start;
43 __uint32_t ext_len;
6d192a9b
TS
44 __uint32_t ext_pad;
45} xfs_extent_64_t;
46
1da177e4
LT
47/*
48 * 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 {
128dabc5
TS
53 __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 */
1da177e4
LT
56 __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
6d192a9b 60typedef struct xfs_efi_log_format_32 {
128dabc5
TS
61 __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 */
6d192a9b
TS
64 __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 {
128dabc5
TS
69 __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 */
6d192a9b
TS
72 __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
1da177e4
LT
76/*
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 {
128dabc5
TS
82 __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 */
1da177e4
LT
85 __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
6d192a9b 89typedef struct xfs_efd_log_format_32 {
128dabc5
TS
90 __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 */
6d192a9b
TS
93 __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 {
128dabc5
TS
98 __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 */
6d192a9b
TS
101 __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
1da177e4
LT
105
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/*
b199c8a4 114 * Define EFI flag bits. Manipulated by set/clear/test_bit operators.
1da177e4 115 */
b199c8a4 116#define XFS_EFI_RECOVERED 1
1da177e4
LT
117
118/*
666d644c
DC
119 * This is the "extent free intention" log item. It is used to log the fact
120 * that some extents need to be free. It is used in conjunction with the
121 * "extent free done" log item described below.
122 *
123 * The EFI is reference counted so that it is not freed prior to both the EFI
124 * and EFD being committed and unpinned. This ensures that when the last
125 * reference goes away the EFI will always be in the AIL as it has been
126 * unpinned, regardless of whether the EFD is processed before or after the EFI.
1da177e4
LT
127 */
128typedef struct xfs_efi_log_item {
129 xfs_log_item_t efi_item;
666d644c 130 atomic_t efi_refcount;
b199c8a4
DC
131 atomic_t efi_next_extent;
132 unsigned long efi_flags; /* misc flags */
1da177e4
LT
133 xfs_efi_log_format_t efi_format;
134} xfs_efi_log_item_t;
135
136/*
137 * This is the "extent free done" log item. It is used to log
138 * the fact that some extents earlier mentioned in an efi item
139 * have been freed.
140 */
141typedef struct xfs_efd_log_item {
142 xfs_log_item_t efd_item;
143 xfs_efi_log_item_t *efd_efip;
144 uint efd_next_extent;
145 xfs_efd_log_format_t efd_format;
146} xfs_efd_log_item_t;
147
148/*
149 * Max number of extents in fast allocation path.
150 */
151#define XFS_EFD_MAX_FAST_EXTENTS 16
152
153extern struct kmem_zone *xfs_efi_zone;
154extern struct kmem_zone *xfs_efd_zone;
155
156xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint);
157xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
158 uint);
6d192a9b
TS
159int xfs_efi_copy_format(xfs_log_iovec_t *buf,
160 xfs_efi_log_format_t *dst_efi_fmt);
7d795ca3
CH
161void xfs_efi_item_free(xfs_efi_log_item_t *);
162
1da177e4
LT
163#endif /* __KERNEL__ */
164
165#endif /* __XFS_EXTFREE_ITEM_H__ */