diff options
Diffstat (limited to 'fs/xfs/xfs_extfree_item.c')
-rw-r--r-- | fs/xfs/xfs_extfree_item.c | 278 |
1 files changed, 116 insertions, 162 deletions
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 409fe81585fd..a55e687bf562 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "xfs_buf_item.h" | 24 | #include "xfs_buf_item.h" |
25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
27 | #include "xfs_dmapi.h" | ||
28 | #include "xfs_mount.h" | 27 | #include "xfs_mount.h" |
29 | #include "xfs_trans_priv.h" | 28 | #include "xfs_trans_priv.h" |
30 | #include "xfs_extfree_item.h" | 29 | #include "xfs_extfree_item.h" |
@@ -33,18 +32,19 @@ | |||
33 | kmem_zone_t *xfs_efi_zone; | 32 | kmem_zone_t *xfs_efi_zone; |
34 | kmem_zone_t *xfs_efd_zone; | 33 | kmem_zone_t *xfs_efd_zone; |
35 | 34 | ||
36 | STATIC void xfs_efi_item_unlock(xfs_efi_log_item_t *); | 35 | static inline struct xfs_efi_log_item *EFI_ITEM(struct xfs_log_item *lip) |
36 | { | ||
37 | return container_of(lip, struct xfs_efi_log_item, efi_item); | ||
38 | } | ||
37 | 39 | ||
38 | void | 40 | void |
39 | xfs_efi_item_free(xfs_efi_log_item_t *efip) | 41 | xfs_efi_item_free( |
42 | struct xfs_efi_log_item *efip) | ||
40 | { | 43 | { |
41 | int nexts = efip->efi_format.efi_nextents; | 44 | if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS) |
42 | |||
43 | if (nexts > XFS_EFI_MAX_FAST_EXTENTS) { | ||
44 | kmem_free(efip); | 45 | kmem_free(efip); |
45 | } else { | 46 | else |
46 | kmem_zone_free(xfs_efi_zone, efip); | 47 | kmem_zone_free(xfs_efi_zone, efip); |
47 | } | ||
48 | } | 48 | } |
49 | 49 | ||
50 | /* | 50 | /* |
@@ -52,9 +52,9 @@ xfs_efi_item_free(xfs_efi_log_item_t *efip) | |||
52 | * We only need 1 iovec for an efi item. It just logs the efi_log_format | 52 | * We only need 1 iovec for an efi item. It just logs the efi_log_format |
53 | * structure. | 53 | * structure. |
54 | */ | 54 | */ |
55 | /*ARGSUSED*/ | ||
56 | STATIC uint | 55 | STATIC uint |
57 | xfs_efi_item_size(xfs_efi_log_item_t *efip) | 56 | xfs_efi_item_size( |
57 | struct xfs_log_item *lip) | ||
58 | { | 58 | { |
59 | return 1; | 59 | return 1; |
60 | } | 60 | } |
@@ -67,10 +67,12 @@ xfs_efi_item_size(xfs_efi_log_item_t *efip) | |||
67 | * slots in the efi item have been filled. | 67 | * slots in the efi item have been filled. |
68 | */ | 68 | */ |
69 | STATIC void | 69 | STATIC void |
70 | xfs_efi_item_format(xfs_efi_log_item_t *efip, | 70 | xfs_efi_item_format( |
71 | xfs_log_iovec_t *log_vector) | 71 | struct xfs_log_item *lip, |
72 | struct xfs_log_iovec *log_vector) | ||
72 | { | 73 | { |
73 | uint size; | 74 | struct xfs_efi_log_item *efip = EFI_ITEM(lip); |
75 | uint size; | ||
74 | 76 | ||
75 | ASSERT(efip->efi_next_extent == efip->efi_format.efi_nextents); | 77 | ASSERT(efip->efi_next_extent == efip->efi_format.efi_nextents); |
76 | 78 | ||
@@ -80,7 +82,7 @@ xfs_efi_item_format(xfs_efi_log_item_t *efip, | |||
80 | size += (efip->efi_format.efi_nextents - 1) * sizeof(xfs_extent_t); | 82 | size += (efip->efi_format.efi_nextents - 1) * sizeof(xfs_extent_t); |
81 | efip->efi_format.efi_size = 1; | 83 | efip->efi_format.efi_size = 1; |
82 | 84 | ||
83 | log_vector->i_addr = (xfs_caddr_t)&(efip->efi_format); | 85 | log_vector->i_addr = &efip->efi_format; |
84 | log_vector->i_len = size; | 86 | log_vector->i_len = size; |
85 | log_vector->i_type = XLOG_REG_TYPE_EFI_FORMAT; | 87 | log_vector->i_type = XLOG_REG_TYPE_EFI_FORMAT; |
86 | ASSERT(size >= sizeof(xfs_efi_log_format_t)); | 88 | ASSERT(size >= sizeof(xfs_efi_log_format_t)); |
@@ -90,60 +92,33 @@ xfs_efi_item_format(xfs_efi_log_item_t *efip, | |||
90 | /* | 92 | /* |
91 | * Pinning has no meaning for an efi item, so just return. | 93 | * Pinning has no meaning for an efi item, so just return. |
92 | */ | 94 | */ |
93 | /*ARGSUSED*/ | ||
94 | STATIC void | 95 | STATIC void |
95 | xfs_efi_item_pin(xfs_efi_log_item_t *efip) | 96 | xfs_efi_item_pin( |
97 | struct xfs_log_item *lip) | ||
96 | { | 98 | { |
97 | return; | ||
98 | } | 99 | } |
99 | 100 | ||
100 | |||
101 | /* | 101 | /* |
102 | * While EFIs cannot really be pinned, the unpin operation is the | 102 | * While EFIs cannot really be pinned, the unpin operation is the |
103 | * last place at which the EFI is manipulated during a transaction. | 103 | * last place at which the EFI is manipulated during a transaction. |
104 | * Here we coordinate with xfs_efi_cancel() to determine who gets to | 104 | * Here we coordinate with xfs_efi_cancel() to determine who gets to |
105 | * free the EFI. | 105 | * free the EFI. |
106 | */ | 106 | */ |
107 | /*ARGSUSED*/ | ||
108 | STATIC void | ||
109 | xfs_efi_item_unpin(xfs_efi_log_item_t *efip) | ||
110 | { | ||
111 | struct xfs_ail *ailp = efip->efi_item.li_ailp; | ||
112 | |||
113 | spin_lock(&ailp->xa_lock); | ||
114 | if (efip->efi_flags & XFS_EFI_CANCELED) { | ||
115 | /* xfs_trans_ail_delete() drops the AIL lock. */ | ||
116 | xfs_trans_ail_delete(ailp, (xfs_log_item_t *)efip); | ||
117 | xfs_efi_item_free(efip); | ||
118 | } else { | ||
119 | efip->efi_flags |= XFS_EFI_COMMITTED; | ||
120 | spin_unlock(&ailp->xa_lock); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | /* | ||
125 | * like unpin only we have to also clear the xaction descriptor | ||
126 | * pointing the log item if we free the item. This routine duplicates | ||
127 | * unpin because efi_flags is protected by the AIL lock. Freeing | ||
128 | * the descriptor and then calling unpin would force us to drop the AIL | ||
129 | * lock which would open up a race condition. | ||
130 | */ | ||
131 | STATIC void | 107 | STATIC void |
132 | xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp) | 108 | xfs_efi_item_unpin( |
109 | struct xfs_log_item *lip, | ||
110 | int remove) | ||
133 | { | 111 | { |
134 | struct xfs_ail *ailp = efip->efi_item.li_ailp; | 112 | struct xfs_efi_log_item *efip = EFI_ITEM(lip); |
135 | xfs_log_item_desc_t *lidp; | 113 | struct xfs_ail *ailp = lip->li_ailp; |
136 | 114 | ||
137 | spin_lock(&ailp->xa_lock); | 115 | spin_lock(&ailp->xa_lock); |
138 | if (efip->efi_flags & XFS_EFI_CANCELED) { | 116 | if (efip->efi_flags & XFS_EFI_CANCELED) { |
139 | /* | 117 | if (remove) |
140 | * free the xaction descriptor pointing to this item | 118 | xfs_trans_del_item(lip); |
141 | */ | ||
142 | lidp = xfs_trans_find_item(tp, (xfs_log_item_t *) efip); | ||
143 | xfs_trans_free_item(tp, lidp); | ||
144 | 119 | ||
145 | /* xfs_trans_ail_delete() drops the AIL lock. */ | 120 | /* xfs_trans_ail_delete() drops the AIL lock. */ |
146 | xfs_trans_ail_delete(ailp, (xfs_log_item_t *)efip); | 121 | xfs_trans_ail_delete(ailp, lip); |
147 | xfs_efi_item_free(efip); | 122 | xfs_efi_item_free(efip); |
148 | } else { | 123 | } else { |
149 | efip->efi_flags |= XFS_EFI_COMMITTED; | 124 | efip->efi_flags |= XFS_EFI_COMMITTED; |
@@ -158,9 +133,9 @@ xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp) | |||
158 | * XFS_ITEM_PINNED so that the caller will eventually flush the log. | 133 | * XFS_ITEM_PINNED so that the caller will eventually flush the log. |
159 | * This should help in getting the EFI out of the AIL. | 134 | * This should help in getting the EFI out of the AIL. |
160 | */ | 135 | */ |
161 | /*ARGSUSED*/ | ||
162 | STATIC uint | 136 | STATIC uint |
163 | xfs_efi_item_trylock(xfs_efi_log_item_t *efip) | 137 | xfs_efi_item_trylock( |
138 | struct xfs_log_item *lip) | ||
164 | { | 139 | { |
165 | return XFS_ITEM_PINNED; | 140 | return XFS_ITEM_PINNED; |
166 | } | 141 | } |
@@ -168,13 +143,12 @@ xfs_efi_item_trylock(xfs_efi_log_item_t *efip) | |||
168 | /* | 143 | /* |
169 | * Efi items have no locking, so just return. | 144 | * Efi items have no locking, so just return. |
170 | */ | 145 | */ |
171 | /*ARGSUSED*/ | ||
172 | STATIC void | 146 | STATIC void |
173 | xfs_efi_item_unlock(xfs_efi_log_item_t *efip) | 147 | xfs_efi_item_unlock( |
148 | struct xfs_log_item *lip) | ||
174 | { | 149 | { |
175 | if (efip->efi_item.li_flags & XFS_LI_ABORTED) | 150 | if (lip->li_flags & XFS_LI_ABORTED) |
176 | xfs_efi_item_free(efip); | 151 | xfs_efi_item_free(EFI_ITEM(lip)); |
177 | return; | ||
178 | } | 152 | } |
179 | 153 | ||
180 | /* | 154 | /* |
@@ -183,9 +157,10 @@ xfs_efi_item_unlock(xfs_efi_log_item_t *efip) | |||
183 | * flag is not paid any attention here. Checking for that is delayed | 157 | * flag is not paid any attention here. Checking for that is delayed |
184 | * until the EFI is unpinned. | 158 | * until the EFI is unpinned. |
185 | */ | 159 | */ |
186 | /*ARGSUSED*/ | ||
187 | STATIC xfs_lsn_t | 160 | STATIC xfs_lsn_t |
188 | xfs_efi_item_committed(xfs_efi_log_item_t *efip, xfs_lsn_t lsn) | 161 | xfs_efi_item_committed( |
162 | struct xfs_log_item *lip, | ||
163 | xfs_lsn_t lsn) | ||
189 | { | 164 | { |
190 | return lsn; | 165 | return lsn; |
191 | } | 166 | } |
@@ -195,11 +170,10 @@ xfs_efi_item_committed(xfs_efi_log_item_t *efip, xfs_lsn_t lsn) | |||
195 | * stuck waiting for all of its corresponding efd items to be | 170 | * stuck waiting for all of its corresponding efd items to be |
196 | * committed to disk. | 171 | * committed to disk. |
197 | */ | 172 | */ |
198 | /*ARGSUSED*/ | ||
199 | STATIC void | 173 | STATIC void |
200 | xfs_efi_item_push(xfs_efi_log_item_t *efip) | 174 | xfs_efi_item_push( |
175 | struct xfs_log_item *lip) | ||
201 | { | 176 | { |
202 | return; | ||
203 | } | 177 | } |
204 | 178 | ||
205 | /* | 179 | /* |
@@ -209,61 +183,55 @@ xfs_efi_item_push(xfs_efi_log_item_t *efip) | |||
209 | * example, for inodes, the inode is locked throughout the extent freeing | 183 | * example, for inodes, the inode is locked throughout the extent freeing |
210 | * so the dependency should be recorded there. | 184 | * so the dependency should be recorded there. |
211 | */ | 185 | */ |
212 | /*ARGSUSED*/ | ||
213 | STATIC void | 186 | STATIC void |
214 | xfs_efi_item_committing(xfs_efi_log_item_t *efip, xfs_lsn_t lsn) | 187 | xfs_efi_item_committing( |
188 | struct xfs_log_item *lip, | ||
189 | xfs_lsn_t lsn) | ||
215 | { | 190 | { |
216 | return; | ||
217 | } | 191 | } |
218 | 192 | ||
219 | /* | 193 | /* |
220 | * This is the ops vector shared by all efi log items. | 194 | * This is the ops vector shared by all efi log items. |
221 | */ | 195 | */ |
222 | static struct xfs_item_ops xfs_efi_item_ops = { | 196 | static struct xfs_item_ops xfs_efi_item_ops = { |
223 | .iop_size = (uint(*)(xfs_log_item_t*))xfs_efi_item_size, | 197 | .iop_size = xfs_efi_item_size, |
224 | .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) | 198 | .iop_format = xfs_efi_item_format, |
225 | xfs_efi_item_format, | 199 | .iop_pin = xfs_efi_item_pin, |
226 | .iop_pin = (void(*)(xfs_log_item_t*))xfs_efi_item_pin, | 200 | .iop_unpin = xfs_efi_item_unpin, |
227 | .iop_unpin = (void(*)(xfs_log_item_t*))xfs_efi_item_unpin, | 201 | .iop_trylock = xfs_efi_item_trylock, |
228 | .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t *)) | 202 | .iop_unlock = xfs_efi_item_unlock, |
229 | xfs_efi_item_unpin_remove, | 203 | .iop_committed = xfs_efi_item_committed, |
230 | .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_efi_item_trylock, | 204 | .iop_push = xfs_efi_item_push, |
231 | .iop_unlock = (void(*)(xfs_log_item_t*))xfs_efi_item_unlock, | 205 | .iop_committing = xfs_efi_item_committing |
232 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | ||
233 | xfs_efi_item_committed, | ||
234 | .iop_push = (void(*)(xfs_log_item_t*))xfs_efi_item_push, | ||
235 | .iop_pushbuf = NULL, | ||
236 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | ||
237 | xfs_efi_item_committing | ||
238 | }; | 206 | }; |
239 | 207 | ||
240 | 208 | ||
241 | /* | 209 | /* |
242 | * Allocate and initialize an efi item with the given number of extents. | 210 | * Allocate and initialize an efi item with the given number of extents. |
243 | */ | 211 | */ |
244 | xfs_efi_log_item_t * | 212 | struct xfs_efi_log_item * |
245 | xfs_efi_init(xfs_mount_t *mp, | 213 | xfs_efi_init( |
246 | uint nextents) | 214 | struct xfs_mount *mp, |
215 | uint nextents) | ||
247 | 216 | ||
248 | { | 217 | { |
249 | xfs_efi_log_item_t *efip; | 218 | struct xfs_efi_log_item *efip; |
250 | uint size; | 219 | uint size; |
251 | 220 | ||
252 | ASSERT(nextents > 0); | 221 | ASSERT(nextents > 0); |
253 | if (nextents > XFS_EFI_MAX_FAST_EXTENTS) { | 222 | if (nextents > XFS_EFI_MAX_FAST_EXTENTS) { |
254 | size = (uint)(sizeof(xfs_efi_log_item_t) + | 223 | size = (uint)(sizeof(xfs_efi_log_item_t) + |
255 | ((nextents - 1) * sizeof(xfs_extent_t))); | 224 | ((nextents - 1) * sizeof(xfs_extent_t))); |
256 | efip = (xfs_efi_log_item_t*)kmem_zalloc(size, KM_SLEEP); | 225 | efip = kmem_zalloc(size, KM_SLEEP); |
257 | } else { | 226 | } else { |
258 | efip = (xfs_efi_log_item_t*)kmem_zone_zalloc(xfs_efi_zone, | 227 | efip = kmem_zone_zalloc(xfs_efi_zone, KM_SLEEP); |
259 | KM_SLEEP); | ||
260 | } | 228 | } |
261 | 229 | ||
262 | xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops); | 230 | xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops); |
263 | efip->efi_format.efi_nextents = nextents; | 231 | efip->efi_format.efi_nextents = nextents; |
264 | efip->efi_format.efi_id = (__psint_t)(void*)efip; | 232 | efip->efi_format.efi_id = (__psint_t)(void*)efip; |
265 | 233 | ||
266 | return (efip); | 234 | return efip; |
267 | } | 235 | } |
268 | 236 | ||
269 | /* | 237 | /* |
@@ -276,7 +244,7 @@ xfs_efi_init(xfs_mount_t *mp, | |||
276 | int | 244 | int |
277 | xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt) | 245 | xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt) |
278 | { | 246 | { |
279 | xfs_efi_log_format_t *src_efi_fmt = (xfs_efi_log_format_t *)buf->i_addr; | 247 | xfs_efi_log_format_t *src_efi_fmt = buf->i_addr; |
280 | uint i; | 248 | uint i; |
281 | uint len = sizeof(xfs_efi_log_format_t) + | 249 | uint len = sizeof(xfs_efi_log_format_t) + |
282 | (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_t); | 250 | (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_t); |
@@ -289,8 +257,7 @@ xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt) | |||
289 | memcpy((char *)dst_efi_fmt, (char*)src_efi_fmt, len); | 257 | memcpy((char *)dst_efi_fmt, (char*)src_efi_fmt, len); |
290 | return 0; | 258 | return 0; |
291 | } else if (buf->i_len == len32) { | 259 | } else if (buf->i_len == len32) { |
292 | xfs_efi_log_format_32_t *src_efi_fmt_32 = | 260 | xfs_efi_log_format_32_t *src_efi_fmt_32 = buf->i_addr; |
293 | (xfs_efi_log_format_32_t *)buf->i_addr; | ||
294 | 261 | ||
295 | dst_efi_fmt->efi_type = src_efi_fmt_32->efi_type; | 262 | dst_efi_fmt->efi_type = src_efi_fmt_32->efi_type; |
296 | dst_efi_fmt->efi_size = src_efi_fmt_32->efi_size; | 263 | dst_efi_fmt->efi_size = src_efi_fmt_32->efi_size; |
@@ -304,8 +271,7 @@ xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt) | |||
304 | } | 271 | } |
305 | return 0; | 272 | return 0; |
306 | } else if (buf->i_len == len64) { | 273 | } else if (buf->i_len == len64) { |
307 | xfs_efi_log_format_64_t *src_efi_fmt_64 = | 274 | xfs_efi_log_format_64_t *src_efi_fmt_64 = buf->i_addr; |
308 | (xfs_efi_log_format_64_t *)buf->i_addr; | ||
309 | 275 | ||
310 | dst_efi_fmt->efi_type = src_efi_fmt_64->efi_type; | 276 | dst_efi_fmt->efi_type = src_efi_fmt_64->efi_type; |
311 | dst_efi_fmt->efi_size = src_efi_fmt_64->efi_size; | 277 | dst_efi_fmt->efi_size = src_efi_fmt_64->efi_size; |
@@ -356,16 +322,18 @@ xfs_efi_release(xfs_efi_log_item_t *efip, | |||
356 | } | 322 | } |
357 | } | 323 | } |
358 | 324 | ||
359 | STATIC void | 325 | static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip) |
360 | xfs_efd_item_free(xfs_efd_log_item_t *efdp) | ||
361 | { | 326 | { |
362 | int nexts = efdp->efd_format.efd_nextents; | 327 | return container_of(lip, struct xfs_efd_log_item, efd_item); |
328 | } | ||
363 | 329 | ||
364 | if (nexts > XFS_EFD_MAX_FAST_EXTENTS) { | 330 | STATIC void |
331 | xfs_efd_item_free(struct xfs_efd_log_item *efdp) | ||
332 | { | ||
333 | if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS) | ||
365 | kmem_free(efdp); | 334 | kmem_free(efdp); |
366 | } else { | 335 | else |
367 | kmem_zone_free(xfs_efd_zone, efdp); | 336 | kmem_zone_free(xfs_efd_zone, efdp); |
368 | } | ||
369 | } | 337 | } |
370 | 338 | ||
371 | /* | 339 | /* |
@@ -373,9 +341,9 @@ xfs_efd_item_free(xfs_efd_log_item_t *efdp) | |||
373 | * We only need 1 iovec for an efd item. It just logs the efd_log_format | 341 | * We only need 1 iovec for an efd item. It just logs the efd_log_format |
374 | * structure. | 342 | * structure. |
375 | */ | 343 | */ |
376 | /*ARGSUSED*/ | ||
377 | STATIC uint | 344 | STATIC uint |
378 | xfs_efd_item_size(xfs_efd_log_item_t *efdp) | 345 | xfs_efd_item_size( |
346 | struct xfs_log_item *lip) | ||
379 | { | 347 | { |
380 | return 1; | 348 | return 1; |
381 | } | 349 | } |
@@ -388,10 +356,12 @@ xfs_efd_item_size(xfs_efd_log_item_t *efdp) | |||
388 | * slots in the efd item have been filled. | 356 | * slots in the efd item have been filled. |
389 | */ | 357 | */ |
390 | STATIC void | 358 | STATIC void |
391 | xfs_efd_item_format(xfs_efd_log_item_t *efdp, | 359 | xfs_efd_item_format( |
392 | xfs_log_iovec_t *log_vector) | 360 | struct xfs_log_item *lip, |
361 | struct xfs_log_iovec *log_vector) | ||
393 | { | 362 | { |
394 | uint size; | 363 | struct xfs_efd_log_item *efdp = EFD_ITEM(lip); |
364 | uint size; | ||
395 | 365 | ||
396 | ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents); | 366 | ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents); |
397 | 367 | ||
@@ -401,48 +371,38 @@ xfs_efd_item_format(xfs_efd_log_item_t *efdp, | |||
401 | size += (efdp->efd_format.efd_nextents - 1) * sizeof(xfs_extent_t); | 371 | size += (efdp->efd_format.efd_nextents - 1) * sizeof(xfs_extent_t); |
402 | efdp->efd_format.efd_size = 1; | 372 | efdp->efd_format.efd_size = 1; |
403 | 373 | ||
404 | log_vector->i_addr = (xfs_caddr_t)&(efdp->efd_format); | 374 | log_vector->i_addr = &efdp->efd_format; |
405 | log_vector->i_len = size; | 375 | log_vector->i_len = size; |
406 | log_vector->i_type = XLOG_REG_TYPE_EFD_FORMAT; | 376 | log_vector->i_type = XLOG_REG_TYPE_EFD_FORMAT; |
407 | ASSERT(size >= sizeof(xfs_efd_log_format_t)); | 377 | ASSERT(size >= sizeof(xfs_efd_log_format_t)); |
408 | } | 378 | } |
409 | 379 | ||
410 | |||
411 | /* | 380 | /* |
412 | * Pinning has no meaning for an efd item, so just return. | 381 | * Pinning has no meaning for an efd item, so just return. |
413 | */ | 382 | */ |
414 | /*ARGSUSED*/ | ||
415 | STATIC void | 383 | STATIC void |
416 | xfs_efd_item_pin(xfs_efd_log_item_t *efdp) | 384 | xfs_efd_item_pin( |
385 | struct xfs_log_item *lip) | ||
417 | { | 386 | { |
418 | return; | ||
419 | } | 387 | } |
420 | 388 | ||
421 | |||
422 | /* | 389 | /* |
423 | * Since pinning has no meaning for an efd item, unpinning does | 390 | * Since pinning has no meaning for an efd item, unpinning does |
424 | * not either. | 391 | * not either. |
425 | */ | 392 | */ |
426 | /*ARGSUSED*/ | ||
427 | STATIC void | ||
428 | xfs_efd_item_unpin(xfs_efd_log_item_t *efdp) | ||
429 | { | ||
430 | return; | ||
431 | } | ||
432 | |||
433 | /*ARGSUSED*/ | ||
434 | STATIC void | 393 | STATIC void |
435 | xfs_efd_item_unpin_remove(xfs_efd_log_item_t *efdp, xfs_trans_t *tp) | 394 | xfs_efd_item_unpin( |
395 | struct xfs_log_item *lip, | ||
396 | int remove) | ||
436 | { | 397 | { |
437 | return; | ||
438 | } | 398 | } |
439 | 399 | ||
440 | /* | 400 | /* |
441 | * Efd items have no locking, so just return success. | 401 | * Efd items have no locking, so just return success. |
442 | */ | 402 | */ |
443 | /*ARGSUSED*/ | ||
444 | STATIC uint | 403 | STATIC uint |
445 | xfs_efd_item_trylock(xfs_efd_log_item_t *efdp) | 404 | xfs_efd_item_trylock( |
405 | struct xfs_log_item *lip) | ||
446 | { | 406 | { |
447 | return XFS_ITEM_LOCKED; | 407 | return XFS_ITEM_LOCKED; |
448 | } | 408 | } |
@@ -451,13 +411,12 @@ xfs_efd_item_trylock(xfs_efd_log_item_t *efdp) | |||
451 | * Efd items have no locking or pushing, so return failure | 411 | * Efd items have no locking or pushing, so return failure |
452 | * so that the caller doesn't bother with us. | 412 | * so that the caller doesn't bother with us. |
453 | */ | 413 | */ |
454 | /*ARGSUSED*/ | ||
455 | STATIC void | 414 | STATIC void |
456 | xfs_efd_item_unlock(xfs_efd_log_item_t *efdp) | 415 | xfs_efd_item_unlock( |
416 | struct xfs_log_item *lip) | ||
457 | { | 417 | { |
458 | if (efdp->efd_item.li_flags & XFS_LI_ABORTED) | 418 | if (lip->li_flags & XFS_LI_ABORTED) |
459 | xfs_efd_item_free(efdp); | 419 | xfs_efd_item_free(EFD_ITEM(lip)); |
460 | return; | ||
461 | } | 420 | } |
462 | 421 | ||
463 | /* | 422 | /* |
@@ -467,15 +426,18 @@ xfs_efd_item_unlock(xfs_efd_log_item_t *efdp) | |||
467 | * return -1 to keep the transaction code from further referencing | 426 | * return -1 to keep the transaction code from further referencing |
468 | * this item. | 427 | * this item. |
469 | */ | 428 | */ |
470 | /*ARGSUSED*/ | ||
471 | STATIC xfs_lsn_t | 429 | STATIC xfs_lsn_t |
472 | xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn) | 430 | xfs_efd_item_committed( |
431 | struct xfs_log_item *lip, | ||
432 | xfs_lsn_t lsn) | ||
473 | { | 433 | { |
434 | struct xfs_efd_log_item *efdp = EFD_ITEM(lip); | ||
435 | |||
474 | /* | 436 | /* |
475 | * If we got a log I/O error, it's always the case that the LR with the | 437 | * If we got a log I/O error, it's always the case that the LR with the |
476 | * EFI got unpinned and freed before the EFD got aborted. | 438 | * EFI got unpinned and freed before the EFD got aborted. |
477 | */ | 439 | */ |
478 | if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0) | 440 | if (!(lip->li_flags & XFS_LI_ABORTED)) |
479 | xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents); | 441 | xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents); |
480 | 442 | ||
481 | xfs_efd_item_free(efdp); | 443 | xfs_efd_item_free(efdp); |
@@ -486,11 +448,10 @@ xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn) | |||
486 | * There isn't much you can do to push on an efd item. It is simply | 448 | * There isn't much you can do to push on an efd item. It is simply |
487 | * stuck waiting for the log to be flushed to disk. | 449 | * stuck waiting for the log to be flushed to disk. |
488 | */ | 450 | */ |
489 | /*ARGSUSED*/ | ||
490 | STATIC void | 451 | STATIC void |
491 | xfs_efd_item_push(xfs_efd_log_item_t *efdp) | 452 | xfs_efd_item_push( |
453 | struct xfs_log_item *lip) | ||
492 | { | 454 | { |
493 | return; | ||
494 | } | 455 | } |
495 | 456 | ||
496 | /* | 457 | /* |
@@ -500,55 +461,48 @@ xfs_efd_item_push(xfs_efd_log_item_t *efdp) | |||
500 | * example, for inodes, the inode is locked throughout the extent freeing | 461 | * example, for inodes, the inode is locked throughout the extent freeing |
501 | * so the dependency should be recorded there. | 462 | * so the dependency should be recorded there. |
502 | */ | 463 | */ |
503 | /*ARGSUSED*/ | ||
504 | STATIC void | 464 | STATIC void |
505 | xfs_efd_item_committing(xfs_efd_log_item_t *efip, xfs_lsn_t lsn) | 465 | xfs_efd_item_committing( |
466 | struct xfs_log_item *lip, | ||
467 | xfs_lsn_t lsn) | ||
506 | { | 468 | { |
507 | return; | ||
508 | } | 469 | } |
509 | 470 | ||
510 | /* | 471 | /* |
511 | * This is the ops vector shared by all efd log items. | 472 | * This is the ops vector shared by all efd log items. |
512 | */ | 473 | */ |
513 | static struct xfs_item_ops xfs_efd_item_ops = { | 474 | static struct xfs_item_ops xfs_efd_item_ops = { |
514 | .iop_size = (uint(*)(xfs_log_item_t*))xfs_efd_item_size, | 475 | .iop_size = xfs_efd_item_size, |
515 | .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) | 476 | .iop_format = xfs_efd_item_format, |
516 | xfs_efd_item_format, | 477 | .iop_pin = xfs_efd_item_pin, |
517 | .iop_pin = (void(*)(xfs_log_item_t*))xfs_efd_item_pin, | 478 | .iop_unpin = xfs_efd_item_unpin, |
518 | .iop_unpin = (void(*)(xfs_log_item_t*))xfs_efd_item_unpin, | 479 | .iop_trylock = xfs_efd_item_trylock, |
519 | .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*)) | 480 | .iop_unlock = xfs_efd_item_unlock, |
520 | xfs_efd_item_unpin_remove, | 481 | .iop_committed = xfs_efd_item_committed, |
521 | .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_efd_item_trylock, | 482 | .iop_push = xfs_efd_item_push, |
522 | .iop_unlock = (void(*)(xfs_log_item_t*))xfs_efd_item_unlock, | 483 | .iop_committing = xfs_efd_item_committing |
523 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | ||
524 | xfs_efd_item_committed, | ||
525 | .iop_push = (void(*)(xfs_log_item_t*))xfs_efd_item_push, | ||
526 | .iop_pushbuf = NULL, | ||
527 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | ||
528 | xfs_efd_item_committing | ||
529 | }; | 484 | }; |
530 | 485 | ||
531 | |||
532 | /* | 486 | /* |
533 | * Allocate and initialize an efd item with the given number of extents. | 487 | * Allocate and initialize an efd item with the given number of extents. |
534 | */ | 488 | */ |
535 | xfs_efd_log_item_t * | 489 | struct xfs_efd_log_item * |
536 | xfs_efd_init(xfs_mount_t *mp, | 490 | xfs_efd_init( |
537 | xfs_efi_log_item_t *efip, | 491 | struct xfs_mount *mp, |
538 | uint nextents) | 492 | struct xfs_efi_log_item *efip, |
493 | uint nextents) | ||
539 | 494 | ||
540 | { | 495 | { |
541 | xfs_efd_log_item_t *efdp; | 496 | struct xfs_efd_log_item *efdp; |
542 | uint size; | 497 | uint size; |
543 | 498 | ||
544 | ASSERT(nextents > 0); | 499 | ASSERT(nextents > 0); |
545 | if (nextents > XFS_EFD_MAX_FAST_EXTENTS) { | 500 | if (nextents > XFS_EFD_MAX_FAST_EXTENTS) { |
546 | size = (uint)(sizeof(xfs_efd_log_item_t) + | 501 | size = (uint)(sizeof(xfs_efd_log_item_t) + |
547 | ((nextents - 1) * sizeof(xfs_extent_t))); | 502 | ((nextents - 1) * sizeof(xfs_extent_t))); |
548 | efdp = (xfs_efd_log_item_t*)kmem_zalloc(size, KM_SLEEP); | 503 | efdp = kmem_zalloc(size, KM_SLEEP); |
549 | } else { | 504 | } else { |
550 | efdp = (xfs_efd_log_item_t*)kmem_zone_zalloc(xfs_efd_zone, | 505 | efdp = kmem_zone_zalloc(xfs_efd_zone, KM_SLEEP); |
551 | KM_SLEEP); | ||
552 | } | 506 | } |
553 | 507 | ||
554 | xfs_log_item_init(mp, &efdp->efd_item, XFS_LI_EFD, &xfs_efd_item_ops); | 508 | xfs_log_item_init(mp, &efdp->efd_item, XFS_LI_EFD, &xfs_efd_item_ops); |
@@ -556,5 +510,5 @@ xfs_efd_init(xfs_mount_t *mp, | |||
556 | efdp->efd_format.efd_nextents = nextents; | 510 | efdp->efd_format.efd_nextents = nextents; |
557 | efdp->efd_format.efd_efi_id = efip->efi_format.efi_id; | 511 | efdp->efd_format.efd_efi_id = efip->efi_format.efi_id; |
558 | 512 | ||
559 | return (efdp); | 513 | return efdp; |
560 | } | 514 | } |