diff options
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
-rw-r--r-- | fs/xfs/xfs_vnodeops.c | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index ddd2c5d1b854..9d376be0ea38 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -584,113 +584,6 @@ xfs_readlink( | |||
584 | } | 584 | } |
585 | 585 | ||
586 | /* | 586 | /* |
587 | * xfs_fsync | ||
588 | * | ||
589 | * This is called to sync the inode and its data out to disk. We need to hold | ||
590 | * the I/O lock while flushing the data, and the inode lock while flushing the | ||
591 | * inode. The inode lock CANNOT be held while flushing the data, so acquire | ||
592 | * after we're done with that. | ||
593 | */ | ||
594 | int | ||
595 | xfs_fsync( | ||
596 | xfs_inode_t *ip) | ||
597 | { | ||
598 | xfs_trans_t *tp; | ||
599 | int error = 0; | ||
600 | int log_flushed = 0; | ||
601 | |||
602 | xfs_itrace_entry(ip); | ||
603 | |||
604 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) | ||
605 | return XFS_ERROR(EIO); | ||
606 | |||
607 | /* | ||
608 | * We always need to make sure that the required inode state is safe on | ||
609 | * disk. The inode might be clean but we still might need to force the | ||
610 | * log because of committed transactions that haven't hit the disk yet. | ||
611 | * Likewise, there could be unflushed non-transactional changes to the | ||
612 | * inode core that have to go to disk and this requires us to issue | ||
613 | * a synchronous transaction to capture these changes correctly. | ||
614 | * | ||
615 | * This code relies on the assumption that if the update_* fields | ||
616 | * of the inode are clear and the inode is unpinned then it is clean | ||
617 | * and no action is required. | ||
618 | */ | ||
619 | xfs_ilock(ip, XFS_ILOCK_SHARED); | ||
620 | |||
621 | if (!ip->i_update_core) { | ||
622 | /* | ||
623 | * Timestamps/size haven't changed since last inode flush or | ||
624 | * inode transaction commit. That means either nothing got | ||
625 | * written or a transaction committed which caught the updates. | ||
626 | * If the latter happened and the transaction hasn't hit the | ||
627 | * disk yet, the inode will be still be pinned. If it is, | ||
628 | * force the log. | ||
629 | */ | ||
630 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | ||
631 | if (xfs_ipincount(ip)) { | ||
632 | if (ip->i_itemp->ili_last_lsn) { | ||
633 | error = _xfs_log_force_lsn(ip->i_mount, | ||
634 | ip->i_itemp->ili_last_lsn, | ||
635 | XFS_LOG_SYNC, &log_flushed); | ||
636 | } else { | ||
637 | error = _xfs_log_force(ip->i_mount, | ||
638 | XFS_LOG_SYNC, &log_flushed); | ||
639 | } | ||
640 | } | ||
641 | } else { | ||
642 | /* | ||
643 | * Kick off a transaction to log the inode core to get the | ||
644 | * updates. The sync transaction will also force the log. | ||
645 | */ | ||
646 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | ||
647 | tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_FSYNC_TS); | ||
648 | error = xfs_trans_reserve(tp, 0, | ||
649 | XFS_FSYNC_TS_LOG_RES(ip->i_mount), 0, 0, 0); | ||
650 | if (error) { | ||
651 | xfs_trans_cancel(tp, 0); | ||
652 | return error; | ||
653 | } | ||
654 | xfs_ilock(ip, XFS_ILOCK_EXCL); | ||
655 | |||
656 | /* | ||
657 | * Note - it's possible that we might have pushed ourselves out | ||
658 | * of the way during trans_reserve which would flush the inode. | ||
659 | * But there's no guarantee that the inode buffer has actually | ||
660 | * gone out yet (it's delwri). Plus the buffer could be pinned | ||
661 | * anyway if it's part of an inode in another recent | ||
662 | * transaction. So we play it safe and fire off the | ||
663 | * transaction anyway. | ||
664 | */ | ||
665 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | ||
666 | xfs_trans_ihold(tp, ip); | ||
667 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | ||
668 | xfs_trans_set_sync(tp); | ||
669 | error = _xfs_trans_commit(tp, 0, &log_flushed); | ||
670 | |||
671 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | ||
672 | } | ||
673 | |||
674 | if (ip->i_mount->m_flags & XFS_MOUNT_BARRIER) { | ||
675 | /* | ||
676 | * If the log write didn't issue an ordered tag we need | ||
677 | * to flush the disk cache for the data device now. | ||
678 | */ | ||
679 | if (!log_flushed) | ||
680 | xfs_blkdev_issue_flush(ip->i_mount->m_ddev_targp); | ||
681 | |||
682 | /* | ||
683 | * If this inode is on the RT dev we need to flush that | ||
684 | * cache as well. | ||
685 | */ | ||
686 | if (XFS_IS_REALTIME_INODE(ip)) | ||
687 | xfs_blkdev_issue_flush(ip->i_mount->m_rtdev_targp); | ||
688 | } | ||
689 | |||
690 | return error; | ||
691 | } | ||
692 | |||
693 | /* | ||
694 | * Flags for xfs_free_eofblocks | 587 | * Flags for xfs_free_eofblocks |
695 | */ | 588 | */ |
696 | #define XFS_FREE_EOF_TRYLOCK (1<<0) | 589 | #define XFS_FREE_EOF_TRYLOCK (1<<0) |