]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
7b718769 NS |
2 | * Copyright (c) 2000-2001,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 | 17 | */ |
1da177e4 | 18 | #include "xfs.h" |
a844f451 | 19 | #include "xfs_fs.h" |
1da177e4 | 20 | #include "xfs_types.h" |
1da177e4 | 21 | #include "xfs_log.h" |
a844f451 | 22 | #include "xfs_inum.h" |
1da177e4 LT |
23 | #include "xfs_trans.h" |
24 | #include "xfs_buf_item.h" | |
25 | #include "xfs_sb.h" | |
da353b0d | 26 | #include "xfs_ag.h" |
1da177e4 LT |
27 | #include "xfs_mount.h" |
28 | #include "xfs_trans_priv.h" | |
29 | #include "xfs_extfree_item.h" | |
30 | ||
31 | ||
32 | kmem_zone_t *xfs_efi_zone; | |
33 | kmem_zone_t *xfs_efd_zone; | |
34 | ||
7bfa31d8 CH |
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 | } | |
1da177e4 | 39 | |
7d795ca3 | 40 | void |
7bfa31d8 CH |
41 | xfs_efi_item_free( |
42 | struct xfs_efi_log_item *efip) | |
7d795ca3 | 43 | { |
7bfa31d8 | 44 | if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS) |
f0e2d93c | 45 | kmem_free(efip); |
7bfa31d8 | 46 | else |
7d795ca3 | 47 | kmem_zone_free(xfs_efi_zone, efip); |
7d795ca3 | 48 | } |
1da177e4 LT |
49 | |
50 | /* | |
51 | * This returns the number of iovecs needed to log the given efi item. | |
52 | * We only need 1 iovec for an efi item. It just logs the efi_log_format | |
53 | * structure. | |
54 | */ | |
1da177e4 | 55 | STATIC uint |
7bfa31d8 CH |
56 | xfs_efi_item_size( |
57 | struct xfs_log_item *lip) | |
1da177e4 LT |
58 | { |
59 | return 1; | |
60 | } | |
61 | ||
62 | /* | |
63 | * This is called to fill in the vector of log iovecs for the | |
64 | * given efi log item. We use only 1 iovec, and we point that | |
65 | * at the efi_log_format structure embedded in the efi item. | |
66 | * It is at this point that we assert that all of the extent | |
67 | * slots in the efi item have been filled. | |
68 | */ | |
69 | STATIC void | |
7bfa31d8 CH |
70 | xfs_efi_item_format( |
71 | struct xfs_log_item *lip, | |
72 | struct xfs_log_iovec *log_vector) | |
1da177e4 | 73 | { |
7bfa31d8 CH |
74 | struct xfs_efi_log_item *efip = EFI_ITEM(lip); |
75 | uint size; | |
1da177e4 LT |
76 | |
77 | ASSERT(efip->efi_next_extent == efip->efi_format.efi_nextents); | |
78 | ||
79 | efip->efi_format.efi_type = XFS_LI_EFI; | |
80 | ||
81 | size = sizeof(xfs_efi_log_format_t); | |
82 | size += (efip->efi_format.efi_nextents - 1) * sizeof(xfs_extent_t); | |
83 | efip->efi_format.efi_size = 1; | |
84 | ||
7bfa31d8 | 85 | log_vector->i_addr = (xfs_caddr_t)&efip->efi_format; |
1da177e4 | 86 | log_vector->i_len = size; |
4139b3b3 | 87 | log_vector->i_type = XLOG_REG_TYPE_EFI_FORMAT; |
1da177e4 LT |
88 | ASSERT(size >= sizeof(xfs_efi_log_format_t)); |
89 | } | |
90 | ||
91 | ||
92 | /* | |
93 | * Pinning has no meaning for an efi item, so just return. | |
94 | */ | |
1da177e4 | 95 | STATIC void |
7bfa31d8 CH |
96 | xfs_efi_item_pin( |
97 | struct xfs_log_item *lip) | |
1da177e4 | 98 | { |
1da177e4 LT |
99 | } |
100 | ||
1da177e4 LT |
101 | /* |
102 | * While EFIs cannot really be pinned, the unpin operation is the | |
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 | |
105 | * free the EFI. | |
106 | */ | |
1da177e4 | 107 | STATIC void |
7bfa31d8 CH |
108 | xfs_efi_item_unpin( |
109 | struct xfs_log_item *lip, | |
110 | int remove) | |
1da177e4 | 111 | { |
7bfa31d8 CH |
112 | struct xfs_efi_log_item *efip = EFI_ITEM(lip); |
113 | struct xfs_ail *ailp = lip->li_ailp; | |
1da177e4 | 114 | |
fc1829f3 | 115 | spin_lock(&ailp->xa_lock); |
1da177e4 | 116 | if (efip->efi_flags & XFS_EFI_CANCELED) { |
9412e318 CH |
117 | if (remove) |
118 | xfs_trans_del_item(lip); | |
783a2f65 DC |
119 | |
120 | /* xfs_trans_ail_delete() drops the AIL lock. */ | |
e98c414f | 121 | xfs_trans_ail_delete(ailp, lip); |
7d795ca3 | 122 | xfs_efi_item_free(efip); |
1da177e4 LT |
123 | } else { |
124 | efip->efi_flags |= XFS_EFI_COMMITTED; | |
fc1829f3 | 125 | spin_unlock(&ailp->xa_lock); |
1da177e4 | 126 | } |
1da177e4 LT |
127 | } |
128 | ||
129 | /* | |
130 | * Efi items have no locking or pushing. However, since EFIs are | |
131 | * pulled from the AIL when their corresponding EFDs are committed | |
132 | * to disk, their situation is very similar to being pinned. Return | |
133 | * XFS_ITEM_PINNED so that the caller will eventually flush the log. | |
134 | * This should help in getting the EFI out of the AIL. | |
135 | */ | |
1da177e4 | 136 | STATIC uint |
7bfa31d8 CH |
137 | xfs_efi_item_trylock( |
138 | struct xfs_log_item *lip) | |
1da177e4 LT |
139 | { |
140 | return XFS_ITEM_PINNED; | |
141 | } | |
142 | ||
143 | /* | |
144 | * Efi items have no locking, so just return. | |
145 | */ | |
1da177e4 | 146 | STATIC void |
7bfa31d8 CH |
147 | xfs_efi_item_unlock( |
148 | struct xfs_log_item *lip) | |
1da177e4 | 149 | { |
7bfa31d8 CH |
150 | if (lip->li_flags & XFS_LI_ABORTED) |
151 | xfs_efi_item_free(EFI_ITEM(lip)); | |
1da177e4 LT |
152 | } |
153 | ||
154 | /* | |
155 | * The EFI is logged only once and cannot be moved in the log, so | |
156 | * simply return the lsn at which it's been logged. The canceled | |
157 | * flag is not paid any attention here. Checking for that is delayed | |
158 | * until the EFI is unpinned. | |
159 | */ | |
1da177e4 | 160 | STATIC xfs_lsn_t |
7bfa31d8 CH |
161 | xfs_efi_item_committed( |
162 | struct xfs_log_item *lip, | |
163 | xfs_lsn_t lsn) | |
1da177e4 LT |
164 | { |
165 | return lsn; | |
166 | } | |
167 | ||
1da177e4 LT |
168 | /* |
169 | * There isn't much you can do to push on an efi item. It is simply | |
170 | * stuck waiting for all of its corresponding efd items to be | |
171 | * committed to disk. | |
172 | */ | |
1da177e4 | 173 | STATIC void |
7bfa31d8 CH |
174 | xfs_efi_item_push( |
175 | struct xfs_log_item *lip) | |
1da177e4 | 176 | { |
1da177e4 LT |
177 | } |
178 | ||
179 | /* | |
180 | * The EFI dependency tracking op doesn't do squat. It can't because | |
181 | * it doesn't know where the free extent is coming from. The dependency | |
182 | * tracking has to be handled by the "enclosing" metadata object. For | |
183 | * example, for inodes, the inode is locked throughout the extent freeing | |
184 | * so the dependency should be recorded there. | |
185 | */ | |
1da177e4 | 186 | STATIC void |
7bfa31d8 CH |
187 | xfs_efi_item_committing( |
188 | struct xfs_log_item *lip, | |
189 | xfs_lsn_t lsn) | |
1da177e4 | 190 | { |
1da177e4 LT |
191 | } |
192 | ||
193 | /* | |
194 | * This is the ops vector shared by all efi log items. | |
195 | */ | |
7989cb8e | 196 | static struct xfs_item_ops xfs_efi_item_ops = { |
7bfa31d8 CH |
197 | .iop_size = xfs_efi_item_size, |
198 | .iop_format = xfs_efi_item_format, | |
199 | .iop_pin = xfs_efi_item_pin, | |
200 | .iop_unpin = xfs_efi_item_unpin, | |
201 | .iop_trylock = xfs_efi_item_trylock, | |
202 | .iop_unlock = xfs_efi_item_unlock, | |
203 | .iop_committed = xfs_efi_item_committed, | |
204 | .iop_push = xfs_efi_item_push, | |
205 | .iop_committing = xfs_efi_item_committing | |
1da177e4 LT |
206 | }; |
207 | ||
208 | ||
209 | /* | |
210 | * Allocate and initialize an efi item with the given number of extents. | |
211 | */ | |
7bfa31d8 CH |
212 | struct xfs_efi_log_item * |
213 | xfs_efi_init( | |
214 | struct xfs_mount *mp, | |
215 | uint nextents) | |
1da177e4 LT |
216 | |
217 | { | |
7bfa31d8 | 218 | struct xfs_efi_log_item *efip; |
1da177e4 LT |
219 | uint size; |
220 | ||
221 | ASSERT(nextents > 0); | |
222 | if (nextents > XFS_EFI_MAX_FAST_EXTENTS) { | |
223 | size = (uint)(sizeof(xfs_efi_log_item_t) + | |
224 | ((nextents - 1) * sizeof(xfs_extent_t))); | |
7bfa31d8 | 225 | efip = kmem_zalloc(size, KM_SLEEP); |
1da177e4 | 226 | } else { |
7bfa31d8 | 227 | efip = kmem_zone_zalloc(xfs_efi_zone, KM_SLEEP); |
1da177e4 LT |
228 | } |
229 | ||
43f5efc5 | 230 | xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops); |
1da177e4 LT |
231 | efip->efi_format.efi_nextents = nextents; |
232 | efip->efi_format.efi_id = (__psint_t)(void*)efip; | |
233 | ||
7bfa31d8 | 234 | return efip; |
1da177e4 LT |
235 | } |
236 | ||
6d192a9b TS |
237 | /* |
238 | * Copy an EFI format buffer from the given buf, and into the destination | |
239 | * EFI format structure. | |
240 | * The given buffer can be in 32 bit or 64 bit form (which has different padding), | |
241 | * one of which will be the native format for this kernel. | |
242 | * It will handle the conversion of formats if necessary. | |
243 | */ | |
244 | int | |
245 | xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt) | |
246 | { | |
247 | xfs_efi_log_format_t *src_efi_fmt = (xfs_efi_log_format_t *)buf->i_addr; | |
248 | uint i; | |
249 | uint len = sizeof(xfs_efi_log_format_t) + | |
250 | (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_t); | |
251 | uint len32 = sizeof(xfs_efi_log_format_32_t) + | |
252 | (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_32_t); | |
253 | uint len64 = sizeof(xfs_efi_log_format_64_t) + | |
254 | (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_64_t); | |
255 | ||
256 | if (buf->i_len == len) { | |
257 | memcpy((char *)dst_efi_fmt, (char*)src_efi_fmt, len); | |
258 | return 0; | |
259 | } else if (buf->i_len == len32) { | |
260 | xfs_efi_log_format_32_t *src_efi_fmt_32 = | |
261 | (xfs_efi_log_format_32_t *)buf->i_addr; | |
262 | ||
263 | dst_efi_fmt->efi_type = src_efi_fmt_32->efi_type; | |
264 | dst_efi_fmt->efi_size = src_efi_fmt_32->efi_size; | |
265 | dst_efi_fmt->efi_nextents = src_efi_fmt_32->efi_nextents; | |
266 | dst_efi_fmt->efi_id = src_efi_fmt_32->efi_id; | |
267 | for (i = 0; i < dst_efi_fmt->efi_nextents; i++) { | |
268 | dst_efi_fmt->efi_extents[i].ext_start = | |
269 | src_efi_fmt_32->efi_extents[i].ext_start; | |
270 | dst_efi_fmt->efi_extents[i].ext_len = | |
271 | src_efi_fmt_32->efi_extents[i].ext_len; | |
272 | } | |
273 | return 0; | |
274 | } else if (buf->i_len == len64) { | |
275 | xfs_efi_log_format_64_t *src_efi_fmt_64 = | |
276 | (xfs_efi_log_format_64_t *)buf->i_addr; | |
277 | ||
278 | dst_efi_fmt->efi_type = src_efi_fmt_64->efi_type; | |
279 | dst_efi_fmt->efi_size = src_efi_fmt_64->efi_size; | |
280 | dst_efi_fmt->efi_nextents = src_efi_fmt_64->efi_nextents; | |
281 | dst_efi_fmt->efi_id = src_efi_fmt_64->efi_id; | |
282 | for (i = 0; i < dst_efi_fmt->efi_nextents; i++) { | |
283 | dst_efi_fmt->efi_extents[i].ext_start = | |
284 | src_efi_fmt_64->efi_extents[i].ext_start; | |
285 | dst_efi_fmt->efi_extents[i].ext_len = | |
286 | src_efi_fmt_64->efi_extents[i].ext_len; | |
287 | } | |
288 | return 0; | |
289 | } | |
290 | return EFSCORRUPTED; | |
291 | } | |
292 | ||
1da177e4 LT |
293 | /* |
294 | * This is called by the efd item code below to release references to | |
295 | * the given efi item. Each efd calls this with the number of | |
296 | * extents that it has logged, and when the sum of these reaches | |
297 | * the total number of extents logged by this efi item we can free | |
298 | * the efi item. | |
299 | * | |
300 | * Freeing the efi item requires that we remove it from the AIL. | |
301 | * We'll use the AIL lock to protect our counters as well as | |
302 | * the removal from the AIL. | |
303 | */ | |
304 | void | |
305 | xfs_efi_release(xfs_efi_log_item_t *efip, | |
306 | uint nextents) | |
307 | { | |
783a2f65 | 308 | struct xfs_ail *ailp = efip->efi_item.li_ailp; |
fc1829f3 | 309 | int extents_left; |
1da177e4 | 310 | |
1da177e4 LT |
311 | ASSERT(efip->efi_next_extent > 0); |
312 | ASSERT(efip->efi_flags & XFS_EFI_COMMITTED); | |
313 | ||
fc1829f3 | 314 | spin_lock(&ailp->xa_lock); |
1da177e4 LT |
315 | ASSERT(efip->efi_next_extent >= nextents); |
316 | efip->efi_next_extent -= nextents; | |
317 | extents_left = efip->efi_next_extent; | |
318 | if (extents_left == 0) { | |
783a2f65 DC |
319 | /* xfs_trans_ail_delete() drops the AIL lock. */ |
320 | xfs_trans_ail_delete(ailp, (xfs_log_item_t *)efip); | |
7d795ca3 | 321 | xfs_efi_item_free(efip); |
1da177e4 | 322 | } else { |
fc1829f3 | 323 | spin_unlock(&ailp->xa_lock); |
1da177e4 | 324 | } |
1da177e4 LT |
325 | } |
326 | ||
7bfa31d8 | 327 | static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip) |
7d795ca3 | 328 | { |
7bfa31d8 CH |
329 | return container_of(lip, struct xfs_efd_log_item, efd_item); |
330 | } | |
1da177e4 | 331 | |
7bfa31d8 CH |
332 | STATIC void |
333 | xfs_efd_item_free(struct xfs_efd_log_item *efdp) | |
334 | { | |
335 | if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS) | |
f0e2d93c | 336 | kmem_free(efdp); |
7bfa31d8 | 337 | else |
7d795ca3 | 338 | kmem_zone_free(xfs_efd_zone, efdp); |
7d795ca3 | 339 | } |
1da177e4 LT |
340 | |
341 | /* | |
342 | * This returns the number of iovecs needed to log the given efd item. | |
343 | * We only need 1 iovec for an efd item. It just logs the efd_log_format | |
344 | * structure. | |
345 | */ | |
1da177e4 | 346 | STATIC uint |
7bfa31d8 CH |
347 | xfs_efd_item_size( |
348 | struct xfs_log_item *lip) | |
1da177e4 LT |
349 | { |
350 | return 1; | |
351 | } | |
352 | ||
353 | /* | |
354 | * This is called to fill in the vector of log iovecs for the | |
355 | * given efd log item. We use only 1 iovec, and we point that | |
356 | * at the efd_log_format structure embedded in the efd item. | |
357 | * It is at this point that we assert that all of the extent | |
358 | * slots in the efd item have been filled. | |
359 | */ | |
360 | STATIC void | |
7bfa31d8 CH |
361 | xfs_efd_item_format( |
362 | struct xfs_log_item *lip, | |
363 | struct xfs_log_iovec *log_vector) | |
1da177e4 | 364 | { |
7bfa31d8 CH |
365 | struct xfs_efd_log_item *efdp = EFD_ITEM(lip); |
366 | uint size; | |
1da177e4 LT |
367 | |
368 | ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents); | |
369 | ||
370 | efdp->efd_format.efd_type = XFS_LI_EFD; | |
371 | ||
372 | size = sizeof(xfs_efd_log_format_t); | |
373 | size += (efdp->efd_format.efd_nextents - 1) * sizeof(xfs_extent_t); | |
374 | efdp->efd_format.efd_size = 1; | |
375 | ||
7bfa31d8 | 376 | log_vector->i_addr = (xfs_caddr_t)&efdp->efd_format; |
1da177e4 | 377 | log_vector->i_len = size; |
4139b3b3 | 378 | log_vector->i_type = XLOG_REG_TYPE_EFD_FORMAT; |
1da177e4 LT |
379 | ASSERT(size >= sizeof(xfs_efd_log_format_t)); |
380 | } | |
381 | ||
1da177e4 LT |
382 | /* |
383 | * Pinning has no meaning for an efd item, so just return. | |
384 | */ | |
1da177e4 | 385 | STATIC void |
7bfa31d8 CH |
386 | xfs_efd_item_pin( |
387 | struct xfs_log_item *lip) | |
1da177e4 | 388 | { |
1da177e4 LT |
389 | } |
390 | ||
1da177e4 LT |
391 | /* |
392 | * Since pinning has no meaning for an efd item, unpinning does | |
393 | * not either. | |
394 | */ | |
1da177e4 | 395 | STATIC void |
7bfa31d8 CH |
396 | xfs_efd_item_unpin( |
397 | struct xfs_log_item *lip, | |
398 | int remove) | |
1da177e4 | 399 | { |
1da177e4 LT |
400 | } |
401 | ||
402 | /* | |
403 | * Efd items have no locking, so just return success. | |
404 | */ | |
1da177e4 | 405 | STATIC uint |
7bfa31d8 CH |
406 | xfs_efd_item_trylock( |
407 | struct xfs_log_item *lip) | |
1da177e4 LT |
408 | { |
409 | return XFS_ITEM_LOCKED; | |
410 | } | |
411 | ||
412 | /* | |
413 | * Efd items have no locking or pushing, so return failure | |
414 | * so that the caller doesn't bother with us. | |
415 | */ | |
1da177e4 | 416 | STATIC void |
7bfa31d8 CH |
417 | xfs_efd_item_unlock( |
418 | struct xfs_log_item *lip) | |
1da177e4 | 419 | { |
7bfa31d8 CH |
420 | if (lip->li_flags & XFS_LI_ABORTED) |
421 | xfs_efd_item_free(EFD_ITEM(lip)); | |
1da177e4 LT |
422 | } |
423 | ||
424 | /* | |
425 | * When the efd item is committed to disk, all we need to do | |
426 | * is delete our reference to our partner efi item and then | |
427 | * free ourselves. Since we're freeing ourselves we must | |
428 | * return -1 to keep the transaction code from further referencing | |
429 | * this item. | |
430 | */ | |
1da177e4 | 431 | STATIC xfs_lsn_t |
7bfa31d8 CH |
432 | xfs_efd_item_committed( |
433 | struct xfs_log_item *lip, | |
434 | xfs_lsn_t lsn) | |
1da177e4 | 435 | { |
7bfa31d8 CH |
436 | struct xfs_efd_log_item *efdp = EFD_ITEM(lip); |
437 | ||
1da177e4 LT |
438 | /* |
439 | * If we got a log I/O error, it's always the case that the LR with the | |
440 | * EFI got unpinned and freed before the EFD got aborted. | |
441 | */ | |
7bfa31d8 | 442 | if (!(lip->li_flags & XFS_LI_ABORTED)) |
1da177e4 LT |
443 | xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents); |
444 | ||
7d795ca3 | 445 | xfs_efd_item_free(efdp); |
1da177e4 LT |
446 | return (xfs_lsn_t)-1; |
447 | } | |
448 | ||
1da177e4 LT |
449 | /* |
450 | * There isn't much you can do to push on an efd item. It is simply | |
451 | * stuck waiting for the log to be flushed to disk. | |
452 | */ | |
1da177e4 | 453 | STATIC void |
7bfa31d8 CH |
454 | xfs_efd_item_push( |
455 | struct xfs_log_item *lip) | |
1da177e4 | 456 | { |
1da177e4 LT |
457 | } |
458 | ||
459 | /* | |
460 | * The EFD dependency tracking op doesn't do squat. It can't because | |
461 | * it doesn't know where the free extent is coming from. The dependency | |
462 | * tracking has to be handled by the "enclosing" metadata object. For | |
463 | * example, for inodes, the inode is locked throughout the extent freeing | |
464 | * so the dependency should be recorded there. | |
465 | */ | |
1da177e4 | 466 | STATIC void |
7bfa31d8 CH |
467 | xfs_efd_item_committing( |
468 | struct xfs_log_item *lip, | |
469 | xfs_lsn_t lsn) | |
1da177e4 | 470 | { |
1da177e4 LT |
471 | } |
472 | ||
473 | /* | |
474 | * This is the ops vector shared by all efd log items. | |
475 | */ | |
7989cb8e | 476 | static struct xfs_item_ops xfs_efd_item_ops = { |
7bfa31d8 CH |
477 | .iop_size = xfs_efd_item_size, |
478 | .iop_format = xfs_efd_item_format, | |
479 | .iop_pin = xfs_efd_item_pin, | |
480 | .iop_unpin = xfs_efd_item_unpin, | |
481 | .iop_trylock = xfs_efd_item_trylock, | |
482 | .iop_unlock = xfs_efd_item_unlock, | |
483 | .iop_committed = xfs_efd_item_committed, | |
484 | .iop_push = xfs_efd_item_push, | |
485 | .iop_committing = xfs_efd_item_committing | |
1da177e4 LT |
486 | }; |
487 | ||
1da177e4 LT |
488 | /* |
489 | * Allocate and initialize an efd item with the given number of extents. | |
490 | */ | |
7bfa31d8 CH |
491 | struct xfs_efd_log_item * |
492 | xfs_efd_init( | |
493 | struct xfs_mount *mp, | |
494 | struct xfs_efi_log_item *efip, | |
495 | uint nextents) | |
1da177e4 LT |
496 | |
497 | { | |
7bfa31d8 | 498 | struct xfs_efd_log_item *efdp; |
1da177e4 LT |
499 | uint size; |
500 | ||
501 | ASSERT(nextents > 0); | |
502 | if (nextents > XFS_EFD_MAX_FAST_EXTENTS) { | |
503 | size = (uint)(sizeof(xfs_efd_log_item_t) + | |
504 | ((nextents - 1) * sizeof(xfs_extent_t))); | |
7bfa31d8 | 505 | efdp = kmem_zalloc(size, KM_SLEEP); |
1da177e4 | 506 | } else { |
7bfa31d8 | 507 | efdp = kmem_zone_zalloc(xfs_efd_zone, KM_SLEEP); |
1da177e4 LT |
508 | } |
509 | ||
43f5efc5 | 510 | xfs_log_item_init(mp, &efdp->efd_item, XFS_LI_EFD, &xfs_efd_item_ops); |
1da177e4 LT |
511 | efdp->efd_efip = efip; |
512 | efdp->efd_format.efd_nextents = nextents; | |
513 | efdp->efd_format.efd_efi_id = efip->efi_format.efi_id; | |
514 | ||
7bfa31d8 | 515 | return efdp; |
1da177e4 | 516 | } |