aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_sb.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/libxfs/xfs_sb.c')
-rw-r--r--fs/xfs/libxfs/xfs_sb.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 115a7cd3a6fb..63f814872dfb 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -753,14 +753,13 @@ xfs_initialize_perag_data(
753} 753}
754 754
755/* 755/*
756 * xfs_mod_sb() can be used to copy arbitrary changes to the 756 * xfs_log_sb() can be used to copy arbitrary changes to the in-core superblock
757 * in-core superblock into the superblock buffer to be logged. 757 * into the superblock buffer to be logged. It does not provide the higher
758 * It does not provide the higher level of locking that is 758 * level of locking that is needed to protect the in-core superblock from
759 * needed to protect the in-core superblock from concurrent 759 * concurrent access.
760 * access.
761 */ 760 */
762void 761void
763xfs_mod_sb( 762xfs_log_sb(
764 struct xfs_trans *tp) 763 struct xfs_trans *tp)
765{ 764{
766 struct xfs_mount *mp = tp->t_mountp; 765 struct xfs_mount *mp = tp->t_mountp;
@@ -770,3 +769,35 @@ xfs_mod_sb(
770 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); 769 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF);
771 xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb)); 770 xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb));
772} 771}
772
773/*
774 * xfs_sync_sb
775 *
776 * Sync the superblock to disk.
777 *
778 * Note that the caller is responsible for checking the frozen state of the
779 * filesystem. This procedure uses the non-blocking transaction allocator and
780 * thus will allow modifications to a frozen fs. This is required because this
781 * code can be called during the process of freezing where use of the high-level
782 * allocator would deadlock.
783 */
784int
785xfs_sync_sb(
786 struct xfs_mount *mp,
787 bool wait)
788{
789 struct xfs_trans *tp;
790 int error;
791
792 tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_CHANGE, KM_SLEEP);
793 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
794 if (error) {
795 xfs_trans_cancel(tp, 0);
796 return error;
797 }
798
799 xfs_log_sb(tp);
800 if (wait)
801 xfs_trans_set_sync(tp);
802 return xfs_trans_commit(tp, 0);
803}