~ubuntu-branches/ubuntu/saucy/linux-ti-omap4/saucy-proposed

« back to all changes in this revision

Viewing changes to fs/xfs/xfs_inode_item.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati, Stefan Bader, Upstream Kernel Changes
  • Date: 2012-08-15 17:17:43 UTC
  • Revision ID: package-import@ubuntu.com-20120815171743-h5wnuf51xe7pvdid
Tags: 3.5.0-207.13
[ Paolo Pisati ]

* Start new release

[ Stefan Bader ]

* (config) Enable getabis to use local package copies

[ Upstream Kernel Changes ]

* fixup: gargabe collect iva_seq[0|1] init
* [Config] enable all SND_OMAP_SOC_*s
* fixup: cm2xxx_3xxx.o is needed for omap2_cm_read|write_reg
* fixup: add some snd_soc_dai* helper functions
* fixup: s/snd_soc_dpcm_params/snd_soc_dpcm/g
* fixup: typo, no_host_mode and useless SDP4430 init
* fixup: enable again aess hwmod

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include "xfs.h"
19
19
#include "xfs_fs.h"
20
20
#include "xfs_types.h"
21
 
#include "xfs_bit.h"
22
21
#include "xfs_log.h"
23
 
#include "xfs_inum.h"
24
22
#include "xfs_trans.h"
25
23
#include "xfs_sb.h"
26
24
#include "xfs_ag.h"
480
478
                wake_up_bit(&ip->i_flags, __XFS_IPINNED_BIT);
481
479
}
482
480
 
483
 
/*
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.
487
 
 *
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.
495
 
 */
496
481
STATIC uint
497
 
xfs_inode_item_trylock(
498
 
        struct xfs_log_item     *lip)
 
482
xfs_inode_item_push(
 
483
        struct xfs_log_item     *lip,
 
484
        struct list_head        *buffer_list)
499
485
{
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;
 
490
        int                     error;
502
491
 
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;
508
497
 
 
498
        /*
 
499
         * Re-check the pincount now that we stabilized the value by
 
500
         * taking the ilock.
 
501
         */
 
502
        if (xfs_ipincount(ip) > 0) {
 
503
                rval = XFS_ITEM_PINNED;
 
504
                goto out_unlock;
 
505
        }
 
506
 
 
507
        /*
 
508
         * Stale inode items should force out the iclog.
 
509
         */
 
510
        if (ip->i_flags & XFS_ISTALE) {
 
511
                rval = XFS_ITEM_PINNED;
 
512
                goto out_unlock;
 
513
        }
 
514
 
 
515
        /*
 
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
 
518
         * the AIL.
 
519
         */
509
520
        if (!xfs_iflock_nowait(ip)) {
510
 
                /*
511
 
                 * inode has already been flushed to the backing buffer,
512
 
                 * leave it locked in shared mode, pushbuf routine will
513
 
                 * unlock it.
514
 
                 */
515
 
                return XFS_ITEM_PUSHBUF;
516
 
        }
517
 
 
518
 
        /* Stale items should force out the iclog */
519
 
        if (ip->i_flags & XFS_ISTALE) {
520
 
                xfs_ifunlock(ip);
521
 
                xfs_iunlock(ip, XFS_ILOCK_SHARED);
522
 
                return XFS_ITEM_PINNED;
523
 
        }
524
 
 
525
 
#ifdef DEBUG
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);
530
 
        }
531
 
#endif
532
 
        return XFS_ITEM_SUCCESS;
 
521
                rval = XFS_ITEM_FLUSHING;
 
522
                goto out_unlock;
 
523
        }
 
524
 
 
525
        ASSERT(iip->ili_fields != 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
 
526
        ASSERT(iip->ili_logged == 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
 
527
 
 
528
        spin_unlock(&lip->li_ailp->xa_lock);
 
529
 
 
530
        error = xfs_iflush(ip, &bp);
 
531
        if (!error) {
 
532
                if (!xfs_buf_delwri_queue(bp, buffer_list))
 
533
                        rval = XFS_ITEM_FLUSHING;
 
534
                xfs_buf_relse(bp);
 
535
        }
 
536
 
 
537
        spin_lock(&lip->li_ailp->xa_lock);
 
538
out_unlock:
 
539
        xfs_iunlock(ip, XFS_ILOCK_SHARED);
 
540
        return rval;
533
541
}
534
542
 
535
543
/*
614
622
}
615
623
 
616
624
/*
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.
622
 
 */
623
 
STATIC bool
624
 
xfs_inode_item_pushbuf(
625
 
        struct xfs_log_item     *lip)
626
 
{
627
 
        struct xfs_inode_log_item *iip = INODE_ITEM(lip);
628
 
        struct xfs_inode        *ip = iip->ili_inode;
629
 
        struct xfs_buf          *bp;
630
 
        bool                    ret = true;
631
 
 
632
 
        ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED));
633
 
 
634
 
        /*
635
 
         * If a flush is not in progress anymore, chances are that the
636
 
         * inode was taken off the AIL. So, just get out.
637
 
         */
638
 
        if (!xfs_isiflocked(ip) ||
639
 
            !(lip->li_flags & XFS_LI_IN_AIL)) {
640
 
                xfs_iunlock(ip, XFS_ILOCK_SHARED);
641
 
                return true;
642
 
        }
643
 
 
644
 
        bp = xfs_incore(ip->i_mount->m_ddev_targp, iip->ili_format.ilf_blkno,
645
 
                        iip->ili_format.ilf_len, XBF_TRYLOCK);
646
 
 
647
 
        xfs_iunlock(ip, XFS_ILOCK_SHARED);
648
 
        if (!bp)
649
 
                return true;
650
 
        if (XFS_BUF_ISDELAYWRITE(bp))
651
 
                xfs_buf_delwri_promote(bp);
652
 
        if (xfs_buf_ispinned(bp))
653
 
                ret = false;
654
 
        xfs_buf_relse(bp);
655
 
        return ret;
656
 
}
657
 
 
658
 
/*
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().
662
 
 */
663
 
STATIC void
664
 
xfs_inode_item_push(
665
 
        struct xfs_log_item     *lip)
666
 
{
667
 
        struct xfs_inode_log_item *iip = INODE_ITEM(lip);
668
 
        struct xfs_inode        *ip = iip->ili_inode;
669
 
 
670
 
        ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED));
671
 
        ASSERT(xfs_isiflocked(ip));
672
 
 
673
 
        /*
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.
681
 
         */
682
 
        ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || iip->ili_fields != 0);
683
 
 
684
 
        /*
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
690
 
         * lock.
691
 
         */
692
 
        (void) xfs_iflush(ip, SYNC_TRYLOCK);
693
 
        xfs_iunlock(ip, XFS_ILOCK_SHARED);
694
 
}
695
 
 
696
 
/*
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.
699
627
 */
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
722
648
};
723
649
 
848
774
                        ASSERT(i <= need_ail);
849
775
                }
850
776
                /* xfs_trans_ail_delete_bulk() drops the AIL lock. */
851
 
                xfs_trans_ail_delete_bulk(ailp, log_items, i);
 
777
                xfs_trans_ail_delete_bulk(ailp, log_items, i,
 
778
                                          SHUTDOWN_CORRUPT_INCORE);
852
779
        }
853
780
 
854
781
 
869
796
}
870
797
 
871
798
/*
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
877
 
 * flush lock.
 
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.
878
803
 */
879
804
void
880
805
xfs_iflush_abort(
881
 
        xfs_inode_t             *ip)
 
806
        xfs_inode_t             *ip,
 
807
        bool                    stale)
882
808
{
883
809
        xfs_inode_log_item_t    *iip = ip->i_itemp;
884
810
 
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,
 
818
                                                stale ?
 
819
                                                     SHUTDOWN_LOG_IO_ERROR :
 
820
                                                     SHUTDOWN_CORRUPT_INCORE);
892
821
                        } else
893
822
                                spin_unlock(&ailp->xa_lock);
894
823
                }
915
844
        struct xfs_buf          *bp,
916
845
        struct xfs_log_item     *lip)
917
846
{
918
 
        xfs_iflush_abort(INODE_ITEM(lip)->ili_inode);
 
847
        xfs_iflush_abort(INODE_ITEM(lip)->ili_inode, true);
919
848
}
920
849
 
921
850
/*