480
478
wake_up_bit(&ip->i_flags, __XFS_IPINNED_BIT);
484
* This is called to attempt to lock the inode associated with this
485
* inode log item, in preparation for the push routine which does the actual
486
* iflush. Don't sleep on the inode lock or the flush lock.
488
* If the flush lock is already held, indicating that the inode has
489
* been or is in the process of being flushed, then (ideally) we'd like to
490
* see if the inode's buffer is still incore, and if so give it a nudge.
491
* We delay doing so until the pushbuf routine, though, to avoid holding
492
* the AIL lock across a call to the blackhole which is the buffer cache.
493
* Also we don't want to sleep in any device strategy routines, which can happen
494
* if we do the subsequent bawrite in here.
497
xfs_inode_item_trylock(
498
struct xfs_log_item *lip)
483
struct xfs_log_item *lip,
484
struct list_head *buffer_list)
500
486
struct xfs_inode_log_item *iip = INODE_ITEM(lip);
501
487
struct xfs_inode *ip = iip->ili_inode;
488
struct xfs_buf *bp = NULL;
489
uint rval = XFS_ITEM_SUCCESS;
503
492
if (xfs_ipincount(ip) > 0)
504
493
return XFS_ITEM_PINNED;
506
495
if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED))
507
496
return XFS_ITEM_LOCKED;
499
* Re-check the pincount now that we stabilized the value by
502
if (xfs_ipincount(ip) > 0) {
503
rval = XFS_ITEM_PINNED;
508
* Stale inode items should force out the iclog.
510
if (ip->i_flags & XFS_ISTALE) {
511
rval = XFS_ITEM_PINNED;
516
* Someone else is already flushing the inode. Nothing we can do
517
* here but wait for the flush to finish and remove the item from
509
520
if (!xfs_iflock_nowait(ip)) {
511
* inode has already been flushed to the backing buffer,
512
* leave it locked in shared mode, pushbuf routine will
515
return XFS_ITEM_PUSHBUF;
518
/* Stale items should force out the iclog */
519
if (ip->i_flags & XFS_ISTALE) {
521
xfs_iunlock(ip, XFS_ILOCK_SHARED);
522
return XFS_ITEM_PINNED;
526
if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {
527
ASSERT(iip->ili_fields != 0);
528
ASSERT(iip->ili_logged == 0);
529
ASSERT(lip->li_flags & XFS_LI_IN_AIL);
532
return XFS_ITEM_SUCCESS;
521
rval = XFS_ITEM_FLUSHING;
525
ASSERT(iip->ili_fields != 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
526
ASSERT(iip->ili_logged == 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
528
spin_unlock(&lip->li_ailp->xa_lock);
530
error = xfs_iflush(ip, &bp);
532
if (!xfs_buf_delwri_queue(bp, buffer_list))
533
rval = XFS_ITEM_FLUSHING;
537
spin_lock(&lip->li_ailp->xa_lock);
539
xfs_iunlock(ip, XFS_ILOCK_SHARED);
617
* This gets called by xfs_trans_push_ail(), when IOP_TRYLOCK
618
* failed to get the inode flush lock but did get the inode locked SHARED.
619
* Here we're trying to see if the inode buffer is incore, and if so whether it's
620
* marked delayed write. If that's the case, we'll promote it and that will
621
* allow the caller to write the buffer by triggering the xfsbufd to run.
624
xfs_inode_item_pushbuf(
625
struct xfs_log_item *lip)
627
struct xfs_inode_log_item *iip = INODE_ITEM(lip);
628
struct xfs_inode *ip = iip->ili_inode;
632
ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED));
635
* If a flush is not in progress anymore, chances are that the
636
* inode was taken off the AIL. So, just get out.
638
if (!xfs_isiflocked(ip) ||
639
!(lip->li_flags & XFS_LI_IN_AIL)) {
640
xfs_iunlock(ip, XFS_ILOCK_SHARED);
644
bp = xfs_incore(ip->i_mount->m_ddev_targp, iip->ili_format.ilf_blkno,
645
iip->ili_format.ilf_len, XBF_TRYLOCK);
647
xfs_iunlock(ip, XFS_ILOCK_SHARED);
650
if (XFS_BUF_ISDELAYWRITE(bp))
651
xfs_buf_delwri_promote(bp);
652
if (xfs_buf_ispinned(bp))
659
* This is called to asynchronously write the inode associated with this
660
* inode log item out to disk. The inode will already have been locked by
661
* a successful call to xfs_inode_item_trylock().
665
struct xfs_log_item *lip)
667
struct xfs_inode_log_item *iip = INODE_ITEM(lip);
668
struct xfs_inode *ip = iip->ili_inode;
670
ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED));
671
ASSERT(xfs_isiflocked(ip));
674
* Since we were able to lock the inode's flush lock and
675
* we found it on the AIL, the inode must be dirty. This
676
* is because the inode is removed from the AIL while still
677
* holding the flush lock in xfs_iflush_done(). Thus, if
678
* we found it in the AIL and were able to obtain the flush
679
* lock without sleeping, then there must not have been
680
* anyone in the process of flushing the inode.
682
ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || iip->ili_fields != 0);
685
* Push the inode to it's backing buffer. This will not remove the
686
* inode from the AIL - a further push will be required to trigger a
687
* buffer push. However, this allows all the dirty inodes to be pushed
688
* to the buffer before it is pushed to disk. The buffer IO completion
689
* will pull the inode from the AIL, mark it clean and unlock the flush
692
(void) xfs_iflush(ip, SYNC_TRYLOCK);
693
xfs_iunlock(ip, XFS_ILOCK_SHARED);
697
625
* XXX rcc - this one really has to do something. Probably needs
698
626
* to stamp in a new field in the incore inode.
713
641
.iop_format = xfs_inode_item_format,
714
642
.iop_pin = xfs_inode_item_pin,
715
643
.iop_unpin = xfs_inode_item_unpin,
716
.iop_trylock = xfs_inode_item_trylock,
717
644
.iop_unlock = xfs_inode_item_unlock,
718
645
.iop_committed = xfs_inode_item_committed,
719
646
.iop_push = xfs_inode_item_push,
720
.iop_pushbuf = xfs_inode_item_pushbuf,
721
647
.iop_committing = xfs_inode_item_committing
872
* This is the inode flushing abort routine. It is called
873
* from xfs_iflush when the filesystem is shutting down to clean
874
* up the inode state.
875
* It is responsible for removing the inode item
876
* from the AIL if it has not been re-logged, and unlocking the inode's
799
* This is the inode flushing abort routine. It is called from xfs_iflush when
800
* the filesystem is shutting down to clean up the inode state. It is
801
* responsible for removing the inode item from the AIL if it has not been
802
* re-logged, and unlocking the inode's flush lock.
880
805
xfs_iflush_abort(
883
809
xfs_inode_log_item_t *iip = ip->i_itemp;
888
814
spin_lock(&ailp->xa_lock);
889
815
if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
890
816
/* xfs_trans_ail_delete() drops the AIL lock. */
891
xfs_trans_ail_delete(ailp, (xfs_log_item_t *)iip);
817
xfs_trans_ail_delete(ailp, &iip->ili_item,
819
SHUTDOWN_LOG_IO_ERROR :
820
SHUTDOWN_CORRUPT_INCORE);
893
822
spin_unlock(&ailp->xa_lock);