1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
8 #include "xfs_format.h"
9 #include "xfs_log_format.h"
10 #include "xfs_trans_resv.h"
12 #include "xfs_shared.h"
13 #include "xfs_mount.h"
15 #include "xfs_defer.h"
16 #include "xfs_trans.h"
17 #include "xfs_trans_priv.h"
18 #include "xfs_extfree_item.h"
20 #include "xfs_btree.h"
22 #include "xfs_alloc.h"
24 #include "xfs_trace.h"
25 #include "xfs_error.h"
26 #include "xfs_log_priv.h"
27 #include "xfs_log_recover.h"
29 struct kmem_cache *xfs_efi_cache;
30 struct kmem_cache *xfs_efd_cache;
32 static const struct xfs_item_ops xfs_efi_item_ops;
34 static inline struct xfs_efi_log_item *EFI_ITEM(struct xfs_log_item *lip)
36 return container_of(lip, struct xfs_efi_log_item, efi_item);
41 struct xfs_efi_log_item *efip)
43 kmem_free(efip->efi_item.li_lv_shadow);
44 if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS)
47 kmem_cache_free(xfs_efi_cache, efip);
51 * Freeing the efi requires that we remove it from the AIL if it has already
52 * been placed there. However, the EFI may not yet have been placed in the AIL
53 * when called by xfs_efi_release() from EFD processing due to the ordering of
54 * committed vs unpin operations in bulk insert operations. Hence the reference
55 * count to ensure only the last caller frees the EFI.
59 struct xfs_efi_log_item *efip)
61 ASSERT(atomic_read(&efip->efi_refcount) > 0);
62 if (!atomic_dec_and_test(&efip->efi_refcount))
65 xfs_trans_ail_delete(&efip->efi_item, 0);
66 xfs_efi_item_free(efip);
71 struct xfs_log_item *lip,
75 struct xfs_efi_log_item *efip = EFI_ITEM(lip);
78 *nbytes += xfs_efi_log_format_sizeof(efip->efi_format.efi_nextents);
82 * This is called to fill in the vector of log iovecs for the
83 * given efi log item. We use only 1 iovec, and we point that
84 * at the efi_log_format structure embedded in the efi item.
85 * It is at this point that we assert that all of the extent
86 * slots in the efi item have been filled.
90 struct xfs_log_item *lip,
91 struct xfs_log_vec *lv)
93 struct xfs_efi_log_item *efip = EFI_ITEM(lip);
94 struct xfs_log_iovec *vecp = NULL;
96 ASSERT(atomic_read(&efip->efi_next_extent) ==
97 efip->efi_format.efi_nextents);
99 efip->efi_format.efi_type = XFS_LI_EFI;
100 efip->efi_format.efi_size = 1;
102 xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_EFI_FORMAT,
104 xfs_efi_log_format_sizeof(efip->efi_format.efi_nextents));
109 * The unpin operation is the last place an EFI is manipulated in the log. It is
110 * either inserted in the AIL or aborted in the event of a log I/O error. In
111 * either case, the EFI transaction has been successfully committed to make it
112 * this far. Therefore, we expect whoever committed the EFI to either construct
113 * and commit the EFD or drop the EFD's reference in the event of error. Simply
114 * drop the log's EFI reference now that the log is done with it.
118 struct xfs_log_item *lip,
121 struct xfs_efi_log_item *efip = EFI_ITEM(lip);
122 xfs_efi_release(efip);
126 * The EFI has been either committed or aborted if the transaction has been
127 * cancelled. If the transaction was cancelled, an EFD isn't going to be
128 * constructed and thus we free the EFI here directly.
131 xfs_efi_item_release(
132 struct xfs_log_item *lip)
134 xfs_efi_release(EFI_ITEM(lip));
138 * Allocate and initialize an efi item with the given number of extents.
140 STATIC struct xfs_efi_log_item *
142 struct xfs_mount *mp,
146 struct xfs_efi_log_item *efip;
148 ASSERT(nextents > 0);
149 if (nextents > XFS_EFI_MAX_FAST_EXTENTS) {
150 efip = kzalloc(xfs_efi_log_item_sizeof(nextents),
151 GFP_KERNEL | __GFP_NOFAIL);
153 efip = kmem_cache_zalloc(xfs_efi_cache,
154 GFP_KERNEL | __GFP_NOFAIL);
157 xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops);
158 efip->efi_format.efi_nextents = nextents;
159 efip->efi_format.efi_id = (uintptr_t)(void *)efip;
160 atomic_set(&efip->efi_next_extent, 0);
161 atomic_set(&efip->efi_refcount, 2);
167 * Copy an EFI format buffer from the given buf, and into the destination
168 * EFI format structure.
169 * The given buffer can be in 32 bit or 64 bit form (which has different padding),
170 * one of which will be the native format for this kernel.
171 * It will handle the conversion of formats if necessary.
174 xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
176 xfs_efi_log_format_t *src_efi_fmt = buf->i_addr;
178 uint len = xfs_efi_log_format_sizeof(src_efi_fmt->efi_nextents);
179 uint len32 = xfs_efi_log_format32_sizeof(src_efi_fmt->efi_nextents);
180 uint len64 = xfs_efi_log_format64_sizeof(src_efi_fmt->efi_nextents);
182 if (buf->i_len == len) {
183 memcpy(dst_efi_fmt, src_efi_fmt,
184 offsetof(struct xfs_efi_log_format, efi_extents));
185 for (i = 0; i < src_efi_fmt->efi_nextents; i++)
186 memcpy(&dst_efi_fmt->efi_extents[i],
187 &src_efi_fmt->efi_extents[i],
188 sizeof(struct xfs_extent));
190 } else if (buf->i_len == len32) {
191 xfs_efi_log_format_32_t *src_efi_fmt_32 = buf->i_addr;
193 dst_efi_fmt->efi_type = src_efi_fmt_32->efi_type;
194 dst_efi_fmt->efi_size = src_efi_fmt_32->efi_size;
195 dst_efi_fmt->efi_nextents = src_efi_fmt_32->efi_nextents;
196 dst_efi_fmt->efi_id = src_efi_fmt_32->efi_id;
197 for (i = 0; i < dst_efi_fmt->efi_nextents; i++) {
198 dst_efi_fmt->efi_extents[i].ext_start =
199 src_efi_fmt_32->efi_extents[i].ext_start;
200 dst_efi_fmt->efi_extents[i].ext_len =
201 src_efi_fmt_32->efi_extents[i].ext_len;
204 } else if (buf->i_len == len64) {
205 xfs_efi_log_format_64_t *src_efi_fmt_64 = buf->i_addr;
207 dst_efi_fmt->efi_type = src_efi_fmt_64->efi_type;
208 dst_efi_fmt->efi_size = src_efi_fmt_64->efi_size;
209 dst_efi_fmt->efi_nextents = src_efi_fmt_64->efi_nextents;
210 dst_efi_fmt->efi_id = src_efi_fmt_64->efi_id;
211 for (i = 0; i < dst_efi_fmt->efi_nextents; i++) {
212 dst_efi_fmt->efi_extents[i].ext_start =
213 src_efi_fmt_64->efi_extents[i].ext_start;
214 dst_efi_fmt->efi_extents[i].ext_len =
215 src_efi_fmt_64->efi_extents[i].ext_len;
219 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, NULL, buf->i_addr,
221 return -EFSCORRUPTED;
224 static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip)
226 return container_of(lip, struct xfs_efd_log_item, efd_item);
230 xfs_efd_item_free(struct xfs_efd_log_item *efdp)
232 kmem_free(efdp->efd_item.li_lv_shadow);
233 if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS)
236 kmem_cache_free(xfs_efd_cache, efdp);
241 struct xfs_log_item *lip,
245 struct xfs_efd_log_item *efdp = EFD_ITEM(lip);
248 *nbytes += xfs_efd_log_format_sizeof(efdp->efd_format.efd_nextents);
252 * This is called to fill in the vector of log iovecs for the
253 * given efd log item. We use only 1 iovec, and we point that
254 * at the efd_log_format structure embedded in the efd item.
255 * It is at this point that we assert that all of the extent
256 * slots in the efd item have been filled.
260 struct xfs_log_item *lip,
261 struct xfs_log_vec *lv)
263 struct xfs_efd_log_item *efdp = EFD_ITEM(lip);
264 struct xfs_log_iovec *vecp = NULL;
266 ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents);
268 efdp->efd_format.efd_type = XFS_LI_EFD;
269 efdp->efd_format.efd_size = 1;
271 xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_EFD_FORMAT,
273 xfs_efd_log_format_sizeof(efdp->efd_format.efd_nextents));
277 * The EFD is either committed or aborted if the transaction is cancelled. If
278 * the transaction is cancelled, drop our reference to the EFI and free the EFD.
281 xfs_efd_item_release(
282 struct xfs_log_item *lip)
284 struct xfs_efd_log_item *efdp = EFD_ITEM(lip);
286 xfs_efi_release(efdp->efd_efip);
287 xfs_efd_item_free(efdp);
290 static struct xfs_log_item *
292 struct xfs_log_item *lip)
294 return &EFD_ITEM(lip)->efd_efip->efi_item;
297 static const struct xfs_item_ops xfs_efd_item_ops = {
298 .flags = XFS_ITEM_RELEASE_WHEN_COMMITTED |
299 XFS_ITEM_INTENT_DONE,
300 .iop_size = xfs_efd_item_size,
301 .iop_format = xfs_efd_item_format,
302 .iop_release = xfs_efd_item_release,
303 .iop_intent = xfs_efd_item_intent,
307 * Allocate an "extent free done" log item that will hold nextents worth of
308 * extents. The caller must use all nextents extents, because we are not
309 * flexible about this at all.
311 static struct xfs_efd_log_item *
313 struct xfs_trans *tp,
314 struct xfs_efi_log_item *efip,
315 unsigned int nextents)
317 struct xfs_efd_log_item *efdp;
319 ASSERT(nextents > 0);
321 if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
322 efdp = kzalloc(xfs_efd_log_item_sizeof(nextents),
323 GFP_KERNEL | __GFP_NOFAIL);
325 efdp = kmem_cache_zalloc(xfs_efd_cache,
326 GFP_KERNEL | __GFP_NOFAIL);
329 xfs_log_item_init(tp->t_mountp, &efdp->efd_item, XFS_LI_EFD,
331 efdp->efd_efip = efip;
332 efdp->efd_format.efd_nextents = nextents;
333 efdp->efd_format.efd_efi_id = efip->efi_format.efi_id;
335 xfs_trans_add_item(tp, &efdp->efd_item);
340 * Free an extent and log it to the EFD. Note that the transaction is marked
341 * dirty regardless of whether the extent free succeeds or fails to support the
342 * EFI/EFD lifecycle rules.
345 xfs_trans_free_extent(
346 struct xfs_trans *tp,
347 struct xfs_efd_log_item *efdp,
348 xfs_fsblock_t start_block,
349 xfs_extlen_t ext_len,
350 const struct xfs_owner_info *oinfo,
353 struct xfs_mount *mp = tp->t_mountp;
354 struct xfs_extent *extp;
356 xfs_agnumber_t agno = XFS_FSB_TO_AGNO(mp, start_block);
357 xfs_agblock_t agbno = XFS_FSB_TO_AGBNO(mp,
361 trace_xfs_bmap_free_deferred(tp->t_mountp, agno, 0, agbno, ext_len);
363 error = __xfs_free_extent(tp, start_block, ext_len,
364 oinfo, XFS_AG_RESV_NONE, skip_discard);
366 * Mark the transaction dirty, even on error. This ensures the
367 * transaction is aborted, which:
369 * 1.) releases the EFI and frees the EFD
370 * 2.) shuts down the filesystem
372 tp->t_flags |= XFS_TRANS_DIRTY | XFS_TRANS_HAS_INTENT_DONE;
373 set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
375 next_extent = efdp->efd_next_extent;
376 ASSERT(next_extent < efdp->efd_format.efd_nextents);
377 extp = &(efdp->efd_format.efd_extents[next_extent]);
378 extp->ext_start = start_block;
379 extp->ext_len = ext_len;
380 efdp->efd_next_extent++;
385 /* Sort bmap items by AG. */
387 xfs_extent_free_diff_items(
389 const struct list_head *a,
390 const struct list_head *b)
392 struct xfs_mount *mp = priv;
393 struct xfs_extent_free_item *ra;
394 struct xfs_extent_free_item *rb;
396 ra = container_of(a, struct xfs_extent_free_item, xefi_list);
397 rb = container_of(b, struct xfs_extent_free_item, xefi_list);
398 return XFS_FSB_TO_AGNO(mp, ra->xefi_startblock) -
399 XFS_FSB_TO_AGNO(mp, rb->xefi_startblock);
402 /* Log a free extent to the intent item. */
404 xfs_extent_free_log_item(
405 struct xfs_trans *tp,
406 struct xfs_efi_log_item *efip,
407 struct xfs_extent_free_item *free)
410 struct xfs_extent *extp;
412 tp->t_flags |= XFS_TRANS_DIRTY;
413 set_bit(XFS_LI_DIRTY, &efip->efi_item.li_flags);
416 * atomic_inc_return gives us the value after the increment;
417 * we want to use it as an array index so we need to subtract 1 from
420 next_extent = atomic_inc_return(&efip->efi_next_extent) - 1;
421 ASSERT(next_extent < efip->efi_format.efi_nextents);
422 extp = &efip->efi_format.efi_extents[next_extent];
423 extp->ext_start = free->xefi_startblock;
424 extp->ext_len = free->xefi_blockcount;
427 static struct xfs_log_item *
428 xfs_extent_free_create_intent(
429 struct xfs_trans *tp,
430 struct list_head *items,
434 struct xfs_mount *mp = tp->t_mountp;
435 struct xfs_efi_log_item *efip = xfs_efi_init(mp, count);
436 struct xfs_extent_free_item *free;
440 xfs_trans_add_item(tp, &efip->efi_item);
442 list_sort(mp, items, xfs_extent_free_diff_items);
443 list_for_each_entry(free, items, xefi_list)
444 xfs_extent_free_log_item(tp, efip, free);
445 return &efip->efi_item;
448 /* Get an EFD so we can process all the free extents. */
449 static struct xfs_log_item *
450 xfs_extent_free_create_done(
451 struct xfs_trans *tp,
452 struct xfs_log_item *intent,
455 return &xfs_trans_get_efd(tp, EFI_ITEM(intent), count)->efd_item;
458 /* Process a free extent. */
460 xfs_extent_free_finish_item(
461 struct xfs_trans *tp,
462 struct xfs_log_item *done,
463 struct list_head *item,
464 struct xfs_btree_cur **state)
466 struct xfs_owner_info oinfo = { };
467 struct xfs_extent_free_item *free;
470 free = container_of(item, struct xfs_extent_free_item, xefi_list);
471 oinfo.oi_owner = free->xefi_owner;
472 if (free->xefi_flags & XFS_EFI_ATTR_FORK)
473 oinfo.oi_flags |= XFS_OWNER_INFO_ATTR_FORK;
474 if (free->xefi_flags & XFS_EFI_BMBT_BLOCK)
475 oinfo.oi_flags |= XFS_OWNER_INFO_BMBT_BLOCK;
476 error = xfs_trans_free_extent(tp, EFD_ITEM(done),
477 free->xefi_startblock,
478 free->xefi_blockcount,
479 &oinfo, free->xefi_flags & XFS_EFI_SKIP_DISCARD);
480 kmem_cache_free(xfs_extfree_item_cache, free);
484 /* Abort all pending EFIs. */
486 xfs_extent_free_abort_intent(
487 struct xfs_log_item *intent)
489 xfs_efi_release(EFI_ITEM(intent));
492 /* Cancel a free extent. */
494 xfs_extent_free_cancel_item(
495 struct list_head *item)
497 struct xfs_extent_free_item *free;
499 free = container_of(item, struct xfs_extent_free_item, xefi_list);
500 kmem_cache_free(xfs_extfree_item_cache, free);
503 const struct xfs_defer_op_type xfs_extent_free_defer_type = {
504 .max_items = XFS_EFI_MAX_FAST_EXTENTS,
505 .create_intent = xfs_extent_free_create_intent,
506 .abort_intent = xfs_extent_free_abort_intent,
507 .create_done = xfs_extent_free_create_done,
508 .finish_item = xfs_extent_free_finish_item,
509 .cancel_item = xfs_extent_free_cancel_item,
513 * AGFL blocks are accounted differently in the reserve pools and are not
514 * inserted into the busy extent list.
517 xfs_agfl_free_finish_item(
518 struct xfs_trans *tp,
519 struct xfs_log_item *done,
520 struct list_head *item,
521 struct xfs_btree_cur **state)
523 struct xfs_owner_info oinfo = { };
524 struct xfs_mount *mp = tp->t_mountp;
525 struct xfs_efd_log_item *efdp = EFD_ITEM(done);
526 struct xfs_extent_free_item *free;
527 struct xfs_extent *extp;
528 struct xfs_buf *agbp;
533 struct xfs_perag *pag;
535 free = container_of(item, struct xfs_extent_free_item, xefi_list);
536 ASSERT(free->xefi_blockcount == 1);
537 agno = XFS_FSB_TO_AGNO(mp, free->xefi_startblock);
538 agbno = XFS_FSB_TO_AGBNO(mp, free->xefi_startblock);
539 oinfo.oi_owner = free->xefi_owner;
541 trace_xfs_agfl_free_deferred(mp, agno, 0, agbno, free->xefi_blockcount);
543 pag = xfs_perag_get(mp, agno);
544 error = xfs_alloc_read_agf(pag, tp, 0, &agbp);
546 error = xfs_free_agfl_block(tp, agno, agbno, agbp, &oinfo);
550 * Mark the transaction dirty, even on error. This ensures the
551 * transaction is aborted, which:
553 * 1.) releases the EFI and frees the EFD
554 * 2.) shuts down the filesystem
556 tp->t_flags |= XFS_TRANS_DIRTY;
557 set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
559 next_extent = efdp->efd_next_extent;
560 ASSERT(next_extent < efdp->efd_format.efd_nextents);
561 extp = &(efdp->efd_format.efd_extents[next_extent]);
562 extp->ext_start = free->xefi_startblock;
563 extp->ext_len = free->xefi_blockcount;
564 efdp->efd_next_extent++;
566 kmem_cache_free(xfs_extfree_item_cache, free);
570 /* sub-type with special handling for AGFL deferred frees */
571 const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
572 .max_items = XFS_EFI_MAX_FAST_EXTENTS,
573 .create_intent = xfs_extent_free_create_intent,
574 .abort_intent = xfs_extent_free_abort_intent,
575 .create_done = xfs_extent_free_create_done,
576 .finish_item = xfs_agfl_free_finish_item,
577 .cancel_item = xfs_extent_free_cancel_item,
580 /* Is this recovered EFI ok? */
582 xfs_efi_validate_ext(
583 struct xfs_mount *mp,
584 struct xfs_extent *extp)
586 return xfs_verify_fsbext(mp, extp->ext_start, extp->ext_len);
590 * Process an extent free intent item that was recovered from
591 * the log. We need to free the extents that it describes.
594 xfs_efi_item_recover(
595 struct xfs_log_item *lip,
596 struct list_head *capture_list)
598 struct xfs_efi_log_item *efip = EFI_ITEM(lip);
599 struct xfs_mount *mp = lip->li_log->l_mp;
600 struct xfs_efd_log_item *efdp;
601 struct xfs_trans *tp;
602 struct xfs_extent *extp;
607 * First check the validity of the extents described by the
608 * EFI. If any are bad, then assume that all are bad and
611 for (i = 0; i < efip->efi_format.efi_nextents; i++) {
612 if (!xfs_efi_validate_ext(mp,
613 &efip->efi_format.efi_extents[i])) {
614 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
616 sizeof(efip->efi_format));
617 return -EFSCORRUPTED;
621 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
624 efdp = xfs_trans_get_efd(tp, efip, efip->efi_format.efi_nextents);
626 for (i = 0; i < efip->efi_format.efi_nextents; i++) {
627 extp = &efip->efi_format.efi_extents[i];
628 error = xfs_trans_free_extent(tp, efdp, extp->ext_start,
630 &XFS_RMAP_OINFO_ANY_OWNER, false);
631 if (error == -EFSCORRUPTED)
632 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
633 extp, sizeof(*extp));
639 return xfs_defer_ops_capture_and_commit(tp, capture_list);
642 xfs_trans_cancel(tp);
648 struct xfs_log_item *lip,
651 return EFI_ITEM(lip)->efi_format.efi_id == intent_id;
654 /* Relog an intent item to push the log tail forward. */
655 static struct xfs_log_item *
657 struct xfs_log_item *intent,
658 struct xfs_trans *tp)
660 struct xfs_efd_log_item *efdp;
661 struct xfs_efi_log_item *efip;
662 struct xfs_extent *extp;
665 count = EFI_ITEM(intent)->efi_format.efi_nextents;
666 extp = EFI_ITEM(intent)->efi_format.efi_extents;
668 tp->t_flags |= XFS_TRANS_DIRTY;
669 efdp = xfs_trans_get_efd(tp, EFI_ITEM(intent), count);
670 efdp->efd_next_extent = count;
671 memcpy(efdp->efd_format.efd_extents, extp, count * sizeof(*extp));
672 set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
674 efip = xfs_efi_init(tp->t_mountp, count);
675 memcpy(efip->efi_format.efi_extents, extp, count * sizeof(*extp));
676 atomic_set(&efip->efi_next_extent, count);
677 xfs_trans_add_item(tp, &efip->efi_item);
678 set_bit(XFS_LI_DIRTY, &efip->efi_item.li_flags);
679 return &efip->efi_item;
682 static const struct xfs_item_ops xfs_efi_item_ops = {
683 .flags = XFS_ITEM_INTENT,
684 .iop_size = xfs_efi_item_size,
685 .iop_format = xfs_efi_item_format,
686 .iop_unpin = xfs_efi_item_unpin,
687 .iop_release = xfs_efi_item_release,
688 .iop_recover = xfs_efi_item_recover,
689 .iop_match = xfs_efi_item_match,
690 .iop_relog = xfs_efi_item_relog,
694 * This routine is called to create an in-core extent free intent
695 * item from the efi format structure which was logged on disk.
696 * It allocates an in-core efi, copies the extents from the format
697 * structure into it, and adds the efi to the AIL with the given
701 xlog_recover_efi_commit_pass2(
703 struct list_head *buffer_list,
704 struct xlog_recover_item *item,
707 struct xfs_mount *mp = log->l_mp;
708 struct xfs_efi_log_item *efip;
709 struct xfs_efi_log_format *efi_formatp;
712 efi_formatp = item->ri_buf[0].i_addr;
714 if (item->ri_buf[0].i_len < xfs_efi_log_format_sizeof(0)) {
715 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
716 item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
717 return -EFSCORRUPTED;
720 efip = xfs_efi_init(mp, efi_formatp->efi_nextents);
721 error = xfs_efi_copy_format(&item->ri_buf[0], &efip->efi_format);
723 xfs_efi_item_free(efip);
726 atomic_set(&efip->efi_next_extent, efi_formatp->efi_nextents);
728 * Insert the intent into the AIL directly and drop one reference so
729 * that finishing or canceling the work will drop the other.
731 xfs_trans_ail_insert(log->l_ailp, &efip->efi_item, lsn);
732 xfs_efi_release(efip);
736 const struct xlog_recover_item_ops xlog_efi_item_ops = {
737 .item_type = XFS_LI_EFI,
738 .commit_pass2 = xlog_recover_efi_commit_pass2,
742 * This routine is called when an EFD format structure is found in a committed
743 * transaction in the log. Its purpose is to cancel the corresponding EFI if it
744 * was still in the log. To do this it searches the AIL for the EFI with an id
745 * equal to that in the EFD format structure. If we find it we drop the EFD
746 * reference, which removes the EFI from the AIL and frees it.
749 xlog_recover_efd_commit_pass2(
751 struct list_head *buffer_list,
752 struct xlog_recover_item *item,
755 struct xfs_efd_log_format *efd_formatp;
756 int buflen = item->ri_buf[0].i_len;
758 efd_formatp = item->ri_buf[0].i_addr;
760 if (buflen < sizeof(struct xfs_efd_log_format)) {
761 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
762 efd_formatp, buflen);
763 return -EFSCORRUPTED;
766 if (item->ri_buf[0].i_len != xfs_efd_log_format32_sizeof(
767 efd_formatp->efd_nextents) &&
768 item->ri_buf[0].i_len != xfs_efd_log_format64_sizeof(
769 efd_formatp->efd_nextents)) {
770 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
771 efd_formatp, buflen);
772 return -EFSCORRUPTED;
775 xlog_recover_release_intent(log, XFS_LI_EFI, efd_formatp->efd_efi_id);
779 const struct xlog_recover_item_ops xlog_efd_item_ops = {
780 .item_type = XFS_LI_EFD,
781 .commit_pass2 = xlog_recover_efd_commit_pass2,