1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
4 * Copyright (c) 2008 Dave Chinner
9 #include "xfs_shared.h"
10 #include "xfs_format.h"
11 #include "xfs_log_format.h"
12 #include "xfs_trans_resv.h"
13 #include "xfs_mount.h"
14 #include "xfs_trans.h"
15 #include "xfs_trans_priv.h"
16 #include "xfs_trace.h"
17 #include "xfs_errortag.h"
18 #include "xfs_error.h"
23 * Check that the list is sorted as it should be.
25 * Called with the ail lock held, but we don't want to assert fail with it
26 * held otherwise we'll lock everything up and won't be able to debug the
27 * cause. Hence we sample and check the state under the AIL lock and return if
28 * everything is fine, otherwise we drop the lock and run the ASSERT checks.
29 * Asserts may not be fatal, so pick the lock back up and continue onwards.
34 struct xfs_log_item *lip)
35 __must_hold(&ailp->ail_lock)
37 struct xfs_log_item *prev_lip;
38 struct xfs_log_item *next_lip;
39 xfs_lsn_t prev_lsn = NULLCOMMITLSN;
40 xfs_lsn_t next_lsn = NULLCOMMITLSN;
45 if (list_empty(&ailp->ail_head))
49 * Sample then check the next and previous entries are valid.
51 in_ail = test_bit(XFS_LI_IN_AIL, &lip->li_flags);
52 prev_lip = list_entry(lip->li_ail.prev, struct xfs_log_item, li_ail);
53 if (&prev_lip->li_ail != &ailp->ail_head)
54 prev_lsn = prev_lip->li_lsn;
55 next_lip = list_entry(lip->li_ail.next, struct xfs_log_item, li_ail);
56 if (&next_lip->li_ail != &ailp->ail_head)
57 next_lsn = next_lip->li_lsn;
61 (prev_lsn == NULLCOMMITLSN || XFS_LSN_CMP(prev_lsn, lsn) <= 0) &&
62 (next_lsn == NULLCOMMITLSN || XFS_LSN_CMP(next_lsn, lsn) >= 0))
65 spin_unlock(&ailp->ail_lock);
67 ASSERT(prev_lsn == NULLCOMMITLSN || XFS_LSN_CMP(prev_lsn, lsn) <= 0);
68 ASSERT(next_lsn == NULLCOMMITLSN || XFS_LSN_CMP(next_lsn, lsn) >= 0);
69 spin_lock(&ailp->ail_lock);
72 #define xfs_ail_check(a,l)
76 * Return a pointer to the last item in the AIL. If the AIL is empty, then
79 static struct xfs_log_item *
83 if (list_empty(&ailp->ail_head))
86 return list_entry(ailp->ail_head.prev, struct xfs_log_item, li_ail);
90 * Return a pointer to the item which follows the given item in the AIL. If
91 * the given item is the last item in the list, then return NULL.
93 static struct xfs_log_item *
96 struct xfs_log_item *lip)
98 if (lip->li_ail.next == &ailp->ail_head)
101 return list_first_entry(&lip->li_ail, struct xfs_log_item, li_ail);
105 * This is called by the log manager code to determine the LSN of the tail of
106 * the log. This is exactly the LSN of the first item in the AIL. If the AIL
107 * is empty, then this function returns 0.
109 * We need the AIL lock in order to get a coherent read of the lsn of the last
114 struct xfs_ail *ailp)
116 struct xfs_log_item *lip = xfs_ail_min(ailp);
125 struct xfs_ail *ailp)
129 spin_lock(&ailp->ail_lock);
130 lsn = __xfs_ail_min_lsn(ailp);
131 spin_unlock(&ailp->ail_lock);
137 * Return the maximum lsn held in the AIL, or zero if the AIL is empty.
141 struct xfs_ail *ailp)
144 struct xfs_log_item *lip;
146 spin_lock(&ailp->ail_lock);
147 lip = xfs_ail_max(ailp);
150 spin_unlock(&ailp->ail_lock);
156 * The cursor keeps track of where our current traversal is up to by tracking
157 * the next item in the list for us. However, for this to be safe, removing an
158 * object from the AIL needs to invalidate any cursor that points to it. hence
159 * the traversal cursor needs to be linked to the struct xfs_ail so that
160 * deletion can search all the active cursors for invalidation.
163 xfs_trans_ail_cursor_init(
164 struct xfs_ail *ailp,
165 struct xfs_ail_cursor *cur)
168 list_add_tail(&cur->list, &ailp->ail_cursors);
172 * Get the next item in the traversal and advance the cursor. If the cursor
173 * was invalidated (indicated by a lip of 1), restart the traversal.
175 struct xfs_log_item *
176 xfs_trans_ail_cursor_next(
177 struct xfs_ail *ailp,
178 struct xfs_ail_cursor *cur)
180 struct xfs_log_item *lip = cur->item;
182 if ((uintptr_t)lip & 1)
183 lip = xfs_ail_min(ailp);
185 cur->item = xfs_ail_next(ailp, lip);
190 * When the traversal is complete, we need to remove the cursor from the list
191 * of traversing cursors.
194 xfs_trans_ail_cursor_done(
195 struct xfs_ail_cursor *cur)
198 list_del_init(&cur->list);
202 * Invalidate any cursor that is pointing to this item. This is called when an
203 * item is removed from the AIL. Any cursor pointing to this object is now
204 * invalid and the traversal needs to be terminated so it doesn't reference a
205 * freed object. We set the low bit of the cursor item pointer so we can
206 * distinguish between an invalidation and the end of the list when getting the
207 * next item from the cursor.
210 xfs_trans_ail_cursor_clear(
211 struct xfs_ail *ailp,
212 struct xfs_log_item *lip)
214 struct xfs_ail_cursor *cur;
216 list_for_each_entry(cur, &ailp->ail_cursors, list) {
217 if (cur->item == lip)
218 cur->item = (struct xfs_log_item *)
219 ((uintptr_t)cur->item | 1);
224 * Find the first item in the AIL with the given @lsn by searching in ascending
225 * LSN order and initialise the cursor to point to the next item for a
226 * ascending traversal. Pass a @lsn of zero to initialise the cursor to the
227 * first item in the AIL. Returns NULL if the list is empty.
229 struct xfs_log_item *
230 xfs_trans_ail_cursor_first(
231 struct xfs_ail *ailp,
232 struct xfs_ail_cursor *cur,
235 struct xfs_log_item *lip;
237 xfs_trans_ail_cursor_init(ailp, cur);
240 lip = xfs_ail_min(ailp);
244 list_for_each_entry(lip, &ailp->ail_head, li_ail) {
245 if (XFS_LSN_CMP(lip->li_lsn, lsn) >= 0)
252 cur->item = xfs_ail_next(ailp, lip);
256 static struct xfs_log_item *
257 __xfs_trans_ail_cursor_last(
258 struct xfs_ail *ailp,
261 struct xfs_log_item *lip;
263 list_for_each_entry_reverse(lip, &ailp->ail_head, li_ail) {
264 if (XFS_LSN_CMP(lip->li_lsn, lsn) <= 0)
271 * Find the last item in the AIL with the given @lsn by searching in descending
272 * LSN order and initialise the cursor to point to that item. If there is no
273 * item with the value of @lsn, then it sets the cursor to the last item with an
274 * LSN lower than @lsn. Returns NULL if the list is empty.
276 struct xfs_log_item *
277 xfs_trans_ail_cursor_last(
278 struct xfs_ail *ailp,
279 struct xfs_ail_cursor *cur,
282 xfs_trans_ail_cursor_init(ailp, cur);
283 cur->item = __xfs_trans_ail_cursor_last(ailp, lsn);
288 * Splice the log item list into the AIL at the given LSN. We splice to the
289 * tail of the given LSN to maintain insert order for push traversals. The
290 * cursor is optional, allowing repeated updates to the same LSN to avoid
291 * repeated traversals. This should not be called with an empty list.
295 struct xfs_ail *ailp,
296 struct xfs_ail_cursor *cur,
297 struct list_head *list,
300 struct xfs_log_item *lip;
302 ASSERT(!list_empty(list));
305 * Use the cursor to determine the insertion point if one is
306 * provided. If not, or if the one we got is not valid,
307 * find the place in the AIL where the items belong.
309 lip = cur ? cur->item : NULL;
310 if (!lip || (uintptr_t)lip & 1)
311 lip = __xfs_trans_ail_cursor_last(ailp, lsn);
314 * If a cursor is provided, we know we're processing the AIL
315 * in lsn order, and future items to be spliced in will
316 * follow the last one being inserted now. Update the
317 * cursor to point to that last item, now while we have a
318 * reliable pointer to it.
321 cur->item = list_entry(list->prev, struct xfs_log_item, li_ail);
324 * Finally perform the splice. Unless the AIL was empty,
325 * lip points to the item in the AIL _after_ which the new
326 * items should go. If lip is null the AIL was empty, so
327 * the new items go at the head of the AIL.
330 list_splice(list, &lip->li_ail);
332 list_splice(list, &ailp->ail_head);
336 * Delete the given item from the AIL. Return a pointer to the item.
340 struct xfs_ail *ailp,
341 struct xfs_log_item *lip)
343 xfs_ail_check(ailp, lip);
344 list_del(&lip->li_ail);
345 xfs_trans_ail_cursor_clear(ailp, lip);
349 * Requeue a failed buffer for writeback.
351 * We clear the log item failed state here as well, but we have to be careful
352 * about reference counts because the only active reference counts on the buffer
353 * may be the failed log items. Hence if we clear the log item failed state
354 * before queuing the buffer for IO we can release all active references to
355 * the buffer and free it, leading to use after free problems in
356 * xfs_buf_delwri_queue. It makes no difference to the buffer or log items which
357 * order we process them in - the buffer is locked, and we own the buffer list
358 * so nothing on them is going to change while we are performing this action.
360 * Hence we can safely queue the buffer for IO before we clear the failed log
361 * item state, therefore always having an active reference to the buffer and
362 * avoiding the transient zero-reference state that leads to use-after-free.
365 xfsaild_resubmit_item(
366 struct xfs_log_item *lip,
367 struct list_head *buffer_list)
369 struct xfs_buf *bp = lip->li_buf;
371 if (!xfs_buf_trylock(bp))
372 return XFS_ITEM_LOCKED;
374 if (!xfs_buf_delwri_queue(bp, buffer_list)) {
376 return XFS_ITEM_FLUSHING;
379 /* protected by ail_lock */
380 list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
381 if (bp->b_flags & _XBF_INODES)
382 clear_bit(XFS_LI_FAILED, &lip->li_flags);
384 xfs_clear_li_failed(lip);
388 return XFS_ITEM_SUCCESS;
393 struct xfs_ail *ailp,
394 struct xfs_log_item *lip)
397 * If log item pinning is enabled, skip the push and track the item as
398 * pinned. This can help induce head-behind-tail conditions.
400 if (XFS_TEST_ERROR(false, ailp->ail_mount, XFS_ERRTAG_LOG_ITEM_PIN))
401 return XFS_ITEM_PINNED;
404 * Consider the item pinned if a push callback is not defined so the
405 * caller will force the log. This should only happen for intent items
406 * as they are unpinned once the associated done item is committed to
409 if (!lip->li_ops->iop_push)
410 return XFS_ITEM_PINNED;
411 if (test_bit(XFS_LI_FAILED, &lip->li_flags))
412 return xfsaild_resubmit_item(lip, &ailp->ail_buf_list);
413 return lip->li_ops->iop_push(lip, &ailp->ail_buf_list);
418 struct xfs_ail *ailp)
420 xfs_mount_t *mp = ailp->ail_mount;
421 struct xfs_ail_cursor cur;
422 struct xfs_log_item *lip;
431 * If we encountered pinned items or did not finish writing out all
432 * buffers the last time we ran, force the log first and wait for it
433 * before pushing again.
435 if (ailp->ail_log_flush && ailp->ail_last_pushed_lsn == 0 &&
436 (!list_empty_careful(&ailp->ail_buf_list) ||
437 xfs_ail_min_lsn(ailp))) {
438 ailp->ail_log_flush = 0;
440 XFS_STATS_INC(mp, xs_push_ail_flush);
441 xfs_log_force(mp, XFS_LOG_SYNC);
444 spin_lock(&ailp->ail_lock);
446 /* barrier matches the ail_target update in xfs_ail_push() */
448 target = ailp->ail_target;
449 ailp->ail_target_prev = target;
451 /* we're done if the AIL is empty or our push has reached the end */
452 lip = xfs_trans_ail_cursor_first(ailp, &cur, ailp->ail_last_pushed_lsn);
456 XFS_STATS_INC(mp, xs_push_ail);
459 while ((XFS_LSN_CMP(lip->li_lsn, target) <= 0)) {
463 * Note that iop_push may unlock and reacquire the AIL lock. We
464 * rely on the AIL cursor implementation to be able to deal with
467 lock_result = xfsaild_push_item(ailp, lip);
468 switch (lock_result) {
469 case XFS_ITEM_SUCCESS:
470 XFS_STATS_INC(mp, xs_push_ail_success);
471 trace_xfs_ail_push(lip);
473 ailp->ail_last_pushed_lsn = lsn;
476 case XFS_ITEM_FLUSHING:
478 * The item or its backing buffer is already being
479 * flushed. The typical reason for that is that an
480 * inode buffer is locked because we already pushed the
481 * updates to it as part of inode clustering.
483 * We do not want to stop flushing just because lots
484 * of items are already being flushed, but we need to
485 * re-try the flushing relatively soon if most of the
486 * AIL is being flushed.
488 XFS_STATS_INC(mp, xs_push_ail_flushing);
489 trace_xfs_ail_flushing(lip);
492 ailp->ail_last_pushed_lsn = lsn;
495 case XFS_ITEM_PINNED:
496 XFS_STATS_INC(mp, xs_push_ail_pinned);
497 trace_xfs_ail_pinned(lip);
500 ailp->ail_log_flush++;
502 case XFS_ITEM_LOCKED:
503 XFS_STATS_INC(mp, xs_push_ail_locked);
504 trace_xfs_ail_locked(lip);
516 * Are there too many items we can't do anything with?
518 * If we are skipping too many items because we can't flush
519 * them or they are already being flushed, we back off and
520 * given them time to complete whatever operation is being
521 * done. i.e. remove pressure from the AIL while we can't make
522 * progress so traversals don't slow down further inserts and
523 * removals to/from the AIL.
525 * The value of 100 is an arbitrary magic number based on
531 lip = xfs_trans_ail_cursor_next(ailp, &cur);
538 xfs_trans_ail_cursor_done(&cur);
539 spin_unlock(&ailp->ail_lock);
541 if (xfs_buf_delwri_submit_nowait(&ailp->ail_buf_list))
542 ailp->ail_log_flush++;
544 if (!count || XFS_LSN_CMP(lsn, target) >= 0) {
546 * We reached the target or the AIL is empty, so wait a bit
547 * longer for I/O to complete and remove pushed items from the
548 * AIL before we start the next scan from the start of the AIL.
551 ailp->ail_last_pushed_lsn = 0;
552 } else if (((stuck + flushing) * 100) / count > 90) {
554 * Either there is a lot of contention on the AIL or we are
555 * stuck due to operations in progress. "Stuck" in this case
556 * is defined as >90% of the items we tried to push were stuck.
558 * Backoff a bit more to allow some I/O to complete before
559 * restarting from the start of the AIL. This prevents us from
560 * spinning on the same items, and if they are pinned will all
561 * the restart to issue a log force to unpin the stuck items.
564 ailp->ail_last_pushed_lsn = 0;
567 * Assume we have more work to do in a short while.
579 struct xfs_ail *ailp = data;
580 long tout = 0; /* milliseconds */
581 unsigned int noreclaim_flag;
583 noreclaim_flag = memalloc_noreclaim_save();
587 if (tout && tout <= 20)
588 set_current_state(TASK_KILLABLE);
590 set_current_state(TASK_INTERRUPTIBLE);
593 * Check kthread_should_stop() after we set the task state to
594 * guarantee that we either see the stop bit and exit or the
595 * task state is reset to runnable such that it's not scheduled
596 * out indefinitely and detects the stop bit at next iteration.
597 * A memory barrier is included in above task state set to
598 * serialize again kthread_stop().
600 if (kthread_should_stop()) {
601 __set_current_state(TASK_RUNNING);
604 * The caller forces out the AIL before stopping the
605 * thread in the common case, which means the delwri
606 * queue is drained. In the shutdown case, the queue may
607 * still hold relogged buffers that haven't been
608 * submitted because they were pinned since added to the
611 * Log I/O error processing stales the underlying buffer
612 * and clears the delwri state, expecting the buf to be
613 * removed on the next submission attempt. That won't
614 * happen if we're shutting down, so this is the last
615 * opportunity to release such buffers from the queue.
617 ASSERT(list_empty(&ailp->ail_buf_list) ||
618 XFS_FORCED_SHUTDOWN(ailp->ail_mount));
619 xfs_buf_delwri_cancel(&ailp->ail_buf_list);
623 spin_lock(&ailp->ail_lock);
626 * Idle if the AIL is empty and we are not racing with a target
627 * update. We check the AIL after we set the task to a sleep
628 * state to guarantee that we either catch an ail_target update
629 * or that a wake_up resets the state to TASK_RUNNING.
630 * Otherwise, we run the risk of sleeping indefinitely.
632 * The barrier matches the ail_target update in xfs_ail_push().
635 if (!xfs_ail_min(ailp) &&
636 ailp->ail_target == ailp->ail_target_prev &&
637 list_empty(&ailp->ail_buf_list)) {
638 spin_unlock(&ailp->ail_lock);
639 freezable_schedule();
643 spin_unlock(&ailp->ail_lock);
646 freezable_schedule_timeout(msecs_to_jiffies(tout));
648 __set_current_state(TASK_RUNNING);
652 tout = xfsaild_push(ailp);
655 memalloc_noreclaim_restore(noreclaim_flag);
660 * This routine is called to move the tail of the AIL forward. It does this by
661 * trying to flush items in the AIL whose lsns are below the given
664 * The push is run asynchronously in a workqueue, which means the caller needs
665 * to handle waiting on the async flush for space to become available.
666 * We don't want to interrupt any push that is in progress, hence we only queue
667 * work if we set the pushing bit appropriately.
669 * We do this unlocked - we only need to know whether there is anything in the
670 * AIL at the time we are called. We don't need to access the contents of
671 * any of the objects, so the lock is not needed.
675 struct xfs_ail *ailp,
676 xfs_lsn_t threshold_lsn)
678 struct xfs_log_item *lip;
680 lip = xfs_ail_min(ailp);
681 if (!lip || XFS_FORCED_SHUTDOWN(ailp->ail_mount) ||
682 XFS_LSN_CMP(threshold_lsn, ailp->ail_target) <= 0)
686 * Ensure that the new target is noticed in push code before it clears
687 * the XFS_AIL_PUSHING_BIT.
690 xfs_trans_ail_copy_lsn(ailp, &ailp->ail_target, &threshold_lsn);
693 wake_up_process(ailp->ail_task);
697 * Push out all items in the AIL immediately
701 struct xfs_ail *ailp)
703 xfs_lsn_t threshold_lsn = xfs_ail_max_lsn(ailp);
706 xfs_ail_push(ailp, threshold_lsn);
710 * Push out all items in the AIL immediately and wait until the AIL is empty.
713 xfs_ail_push_all_sync(
714 struct xfs_ail *ailp)
716 struct xfs_log_item *lip;
719 spin_lock(&ailp->ail_lock);
720 while ((lip = xfs_ail_max(ailp)) != NULL) {
721 prepare_to_wait(&ailp->ail_empty, &wait, TASK_UNINTERRUPTIBLE);
722 ailp->ail_target = lip->li_lsn;
723 wake_up_process(ailp->ail_task);
724 spin_unlock(&ailp->ail_lock);
726 spin_lock(&ailp->ail_lock);
728 spin_unlock(&ailp->ail_lock);
730 finish_wait(&ailp->ail_empty, &wait);
734 xfs_ail_update_finish(
735 struct xfs_ail *ailp,
736 xfs_lsn_t old_lsn) __releases(ailp->ail_lock)
738 struct xfs_mount *mp = ailp->ail_mount;
740 /* if the tail lsn hasn't changed, don't do updates or wakeups. */
741 if (!old_lsn || old_lsn == __xfs_ail_min_lsn(ailp)) {
742 spin_unlock(&ailp->ail_lock);
746 if (!XFS_FORCED_SHUTDOWN(mp))
747 xlog_assign_tail_lsn_locked(mp);
749 if (list_empty(&ailp->ail_head))
750 wake_up_all(&ailp->ail_empty);
751 spin_unlock(&ailp->ail_lock);
752 xfs_log_space_wake(mp);
756 * xfs_trans_ail_update - bulk AIL insertion operation.
758 * @xfs_trans_ail_update takes an array of log items that all need to be
759 * positioned at the same LSN in the AIL. If an item is not in the AIL, it will
760 * be added. Otherwise, it will be repositioned by removing it and re-adding
761 * it to the AIL. If we move the first item in the AIL, update the log tail to
762 * match the new minimum LSN in the AIL.
764 * This function takes the AIL lock once to execute the update operations on
765 * all the items in the array, and as such should not be called with the AIL
766 * lock held. As a result, once we have the AIL lock, we need to check each log
767 * item LSN to confirm it needs to be moved forward in the AIL.
769 * To optimise the insert operation, we delete all the items from the AIL in
770 * the first pass, moving them into a temporary list, then splice the temporary
771 * list into the correct position in the AIL. This avoids needing to do an
772 * insert operation on every item.
774 * This function must be called with the AIL lock held. The lock is dropped
778 xfs_trans_ail_update_bulk(
779 struct xfs_ail *ailp,
780 struct xfs_ail_cursor *cur,
781 struct xfs_log_item **log_items,
783 xfs_lsn_t lsn) __releases(ailp->ail_lock)
785 struct xfs_log_item *mlip;
786 xfs_lsn_t tail_lsn = 0;
790 ASSERT(nr_items > 0); /* Not required, but true. */
791 mlip = xfs_ail_min(ailp);
793 for (i = 0; i < nr_items; i++) {
794 struct xfs_log_item *lip = log_items[i];
795 if (test_and_set_bit(XFS_LI_IN_AIL, &lip->li_flags)) {
796 /* check if we really need to move the item */
797 if (XFS_LSN_CMP(lsn, lip->li_lsn) <= 0)
800 trace_xfs_ail_move(lip, lip->li_lsn, lsn);
801 if (mlip == lip && !tail_lsn)
802 tail_lsn = lip->li_lsn;
804 xfs_ail_delete(ailp, lip);
806 trace_xfs_ail_insert(lip, 0, lsn);
809 list_add(&lip->li_ail, &tmp);
812 if (!list_empty(&tmp))
813 xfs_ail_splice(ailp, cur, &tmp, lsn);
815 xfs_ail_update_finish(ailp, tail_lsn);
818 /* Insert a log item into the AIL. */
820 xfs_trans_ail_insert(
821 struct xfs_ail *ailp,
822 struct xfs_log_item *lip,
825 spin_lock(&ailp->ail_lock);
826 xfs_trans_ail_update_bulk(ailp, NULL, &lip, 1, lsn);
830 * Delete one log item from the AIL.
832 * If this item was at the tail of the AIL, return the LSN of the log item so
833 * that we can use it to check if the LSN of the tail of the log has moved
834 * when finishing up the AIL delete process in xfs_ail_update_finish().
838 struct xfs_ail *ailp,
839 struct xfs_log_item *lip)
841 struct xfs_log_item *mlip = xfs_ail_min(ailp);
842 xfs_lsn_t lsn = lip->li_lsn;
844 trace_xfs_ail_delete(lip, mlip->li_lsn, lip->li_lsn);
845 xfs_ail_delete(ailp, lip);
846 clear_bit(XFS_LI_IN_AIL, &lip->li_flags);
855 xfs_trans_ail_delete(
856 struct xfs_log_item *lip,
859 struct xfs_ail *ailp = lip->li_ailp;
860 struct xfs_mount *mp = ailp->ail_mount;
863 spin_lock(&ailp->ail_lock);
864 if (!test_bit(XFS_LI_IN_AIL, &lip->li_flags)) {
865 spin_unlock(&ailp->ail_lock);
866 if (shutdown_type && !XFS_FORCED_SHUTDOWN(mp)) {
867 xfs_alert_tag(mp, XFS_PTAG_AILDELETE,
868 "%s: attempting to delete a log item that is not in the AIL",
870 xfs_force_shutdown(mp, shutdown_type);
875 /* xfs_ail_update_finish() drops the AIL lock */
876 xfs_clear_li_failed(lip);
877 tail_lsn = xfs_ail_delete_one(ailp, lip);
878 xfs_ail_update_finish(ailp, tail_lsn);
885 struct xfs_ail *ailp;
887 ailp = kmem_zalloc(sizeof(struct xfs_ail), KM_MAYFAIL);
891 ailp->ail_mount = mp;
892 INIT_LIST_HEAD(&ailp->ail_head);
893 INIT_LIST_HEAD(&ailp->ail_cursors);
894 spin_lock_init(&ailp->ail_lock);
895 INIT_LIST_HEAD(&ailp->ail_buf_list);
896 init_waitqueue_head(&ailp->ail_empty);
898 ailp->ail_task = kthread_run(xfsaild, ailp, "xfsaild/%s",
899 ailp->ail_mount->m_super->s_id);
900 if (IS_ERR(ailp->ail_task))
912 xfs_trans_ail_destroy(
915 struct xfs_ail *ailp = mp->m_ail;
917 kthread_stop(ailp->ail_task);