2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "xfs_types.h"
24 #include "xfs_trans.h"
28 #include "xfs_dmapi.h"
29 #include "xfs_mount.h"
30 #include "xfs_da_btree.h"
31 #include "xfs_bmap_btree.h"
32 #include "xfs_ialloc_btree.h"
33 #include "xfs_alloc_btree.h"
34 #include "xfs_dir2_sf.h"
35 #include "xfs_attr_sf.h"
36 #include "xfs_dinode.h"
37 #include "xfs_inode.h"
38 #include "xfs_inode_item.h"
39 #include "xfs_btree.h"
40 #include "xfs_alloc.h"
41 #include "xfs_ialloc.h"
42 #include "xfs_quota.h"
43 #include "xfs_error.h"
46 #include "xfs_buf_item.h"
47 #include "xfs_log_priv.h"
48 #include "xfs_dir2_trace.h"
49 #include "xfs_extfree_item.h"
53 #include "xfs_mru_cache.h"
54 #include "xfs_filestream.h"
55 #include "xfs_fsops.h"
56 #include "xfs_vnodeops.h"
57 #include "xfs_vfsops.h"
58 #include "xfs_utils.h"
64 #ifdef XFS_DABUF_DEBUG
65 extern spinlock_t xfs_dabuf_global_lock
;
66 spin_lock_init(&xfs_dabuf_global_lock
);
70 * Initialize all of the zone allocators we use.
72 xfs_log_ticket_zone
= kmem_zone_init(sizeof(xlog_ticket_t
),
74 xfs_bmap_free_item_zone
= kmem_zone_init(sizeof(xfs_bmap_free_item_t
),
75 "xfs_bmap_free_item");
76 xfs_btree_cur_zone
= kmem_zone_init(sizeof(xfs_btree_cur_t
),
78 xfs_da_state_zone
= kmem_zone_init(sizeof(xfs_da_state_t
),
80 xfs_dabuf_zone
= kmem_zone_init(sizeof(xfs_dabuf_t
), "xfs_dabuf");
81 xfs_ifork_zone
= kmem_zone_init(sizeof(xfs_ifork_t
), "xfs_ifork");
82 xfs_trans_zone
= kmem_zone_init(sizeof(xfs_trans_t
), "xfs_trans");
83 xfs_acl_zone_init(xfs_acl_zone
, "xfs_acl");
85 xfs_filestream_init();
88 * The size of the zone allocated buf log item is the maximum
89 * size possible under XFS. This wastes a little bit of memory,
90 * but it is much faster.
93 kmem_zone_init((sizeof(xfs_buf_log_item_t
) +
94 (((XFS_MAX_BLOCKSIZE
/ XFS_BLI_CHUNK
) /
95 NBWORD
) * sizeof(int))),
98 kmem_zone_init((sizeof(xfs_efd_log_item_t
) +
99 ((XFS_EFD_MAX_FAST_EXTENTS
- 1) *
100 sizeof(xfs_extent_t
))),
103 kmem_zone_init((sizeof(xfs_efi_log_item_t
) +
104 ((XFS_EFI_MAX_FAST_EXTENTS
- 1) *
105 sizeof(xfs_extent_t
))),
109 * These zones warrant special memory allocator hints
112 kmem_zone_init_flags(sizeof(xfs_inode_t
), "xfs_inode",
113 KM_ZONE_HWALIGN
| KM_ZONE_RECLAIM
|
114 KM_ZONE_SPREAD
, NULL
);
116 kmem_zone_init_flags(sizeof(xfs_inode_log_item_t
), "xfs_ili",
117 KM_ZONE_SPREAD
, NULL
);
120 * Allocate global trace buffers.
122 #ifdef XFS_ALLOC_TRACE
123 xfs_alloc_trace_buf
= ktrace_alloc(XFS_ALLOC_TRACE_SIZE
, KM_SLEEP
);
125 #ifdef XFS_BMAP_TRACE
126 xfs_bmap_trace_buf
= ktrace_alloc(XFS_BMAP_TRACE_SIZE
, KM_SLEEP
);
128 #ifdef XFS_BMBT_TRACE
129 xfs_bmbt_trace_buf
= ktrace_alloc(XFS_BMBT_TRACE_SIZE
, KM_SLEEP
);
131 #ifdef XFS_ATTR_TRACE
132 xfs_attr_trace_buf
= ktrace_alloc(XFS_ATTR_TRACE_SIZE
, KM_SLEEP
);
134 #ifdef XFS_DIR2_TRACE
135 xfs_dir2_trace_buf
= ktrace_alloc(XFS_DIR2_GTRACE_SIZE
, KM_SLEEP
);
140 #if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
141 xfs_error_test_init();
142 #endif /* DEBUG || INDUCE_IO_ERROR */
145 xfs_sysctl_register();
152 extern kmem_zone_t
*xfs_inode_zone
;
153 extern kmem_zone_t
*xfs_efd_zone
;
154 extern kmem_zone_t
*xfs_efi_zone
;
156 xfs_cleanup_procfs();
157 xfs_sysctl_unregister();
158 xfs_filestream_uninit();
159 xfs_mru_cache_uninit();
160 xfs_acl_zone_destroy(xfs_acl_zone
);
162 #ifdef XFS_DIR2_TRACE
163 ktrace_free(xfs_dir2_trace_buf
);
165 #ifdef XFS_ATTR_TRACE
166 ktrace_free(xfs_attr_trace_buf
);
168 #ifdef XFS_BMBT_TRACE
169 ktrace_free(xfs_bmbt_trace_buf
);
171 #ifdef XFS_BMAP_TRACE
172 ktrace_free(xfs_bmap_trace_buf
);
174 #ifdef XFS_ALLOC_TRACE
175 ktrace_free(xfs_alloc_trace_buf
);
178 kmem_zone_destroy(xfs_bmap_free_item_zone
);
179 kmem_zone_destroy(xfs_btree_cur_zone
);
180 kmem_zone_destroy(xfs_inode_zone
);
181 kmem_zone_destroy(xfs_trans_zone
);
182 kmem_zone_destroy(xfs_da_state_zone
);
183 kmem_zone_destroy(xfs_dabuf_zone
);
184 kmem_zone_destroy(xfs_buf_item_zone
);
185 kmem_zone_destroy(xfs_efd_zone
);
186 kmem_zone_destroy(xfs_efi_zone
);
187 kmem_zone_destroy(xfs_ifork_zone
);
188 kmem_zone_destroy(xfs_ili_zone
);
189 kmem_zone_destroy(xfs_log_ticket_zone
);
196 int count
= 0, pincount
;
198 xfs_flush_buftarg(mp
->m_ddev_targp
, 0);
199 xfs_finish_reclaim_all(mp
, 0);
201 /* This loop must run at least twice.
202 * The first instance of the loop will flush
203 * most meta data but that will generate more
204 * meta data (typically directory updates).
205 * Which then must be flushed and logged before
206 * we can write the unmount record.
209 xfs_syncsub(mp
, SYNC_INODE_QUIESCE
, NULL
);
210 pincount
= xfs_flush_buftarg(mp
->m_ddev_targp
, 1);
219 * Second stage of a quiesce. The data is already synced, now we have to take
220 * care of the metadata. New transactions are already blocked, so we need to
221 * wait for any remaining transactions to drain out before proceding.
229 /* wait for all modifications to complete */
230 while (atomic_read(&mp
->m_active_trans
) > 0)
233 /* flush inodes and push all remaining buffers out to disk */
236 ASSERT_ALWAYS(atomic_read(&mp
->m_active_trans
) == 0);
238 /* Push the superblock and write an unmount record */
239 error
= xfs_log_sbcount(mp
, 1);
241 xfs_fs_cmn_err(CE_WARN
, mp
,
242 "xfs_attr_quiesce: failed to log sb changes. "
243 "Frozen image may not be consistent.");
244 xfs_log_unmount_write(mp
);
245 xfs_unmountfs_writesb(mp
);
249 * xfs_unmount_flush implements a set of flush operation on special
250 * inodes, which are needed as a separate set of operations so that
251 * they can be called as part of relocation process.
255 xfs_mount_t
*mp
, /* Mount structure we are getting
257 int relocation
) /* Called from vfs relocation. */
259 xfs_inode_t
*rip
= mp
->m_rootip
;
261 xfs_inode_t
*rsumip
= NULL
;
262 bhv_vnode_t
*rvp
= XFS_ITOV(rip
);
265 xfs_ilock(rip
, XFS_ILOCK_EXCL
| XFS_ILOCK_PARENT
);
269 * Flush out the real time inodes.
271 if ((rbmip
= mp
->m_rbmip
) != NULL
) {
272 xfs_ilock(rbmip
, XFS_ILOCK_EXCL
);
274 error
= xfs_iflush(rbmip
, XFS_IFLUSH_SYNC
);
275 xfs_iunlock(rbmip
, XFS_ILOCK_EXCL
);
277 if (error
== EFSCORRUPTED
)
280 ASSERT(vn_count(XFS_ITOV(rbmip
)) == 1);
282 rsumip
= mp
->m_rsumip
;
283 xfs_ilock(rsumip
, XFS_ILOCK_EXCL
);
285 error
= xfs_iflush(rsumip
, XFS_IFLUSH_SYNC
);
286 xfs_iunlock(rsumip
, XFS_ILOCK_EXCL
);
288 if (error
== EFSCORRUPTED
)
291 ASSERT(vn_count(XFS_ITOV(rsumip
)) == 1);
295 * Synchronously flush root inode to disk
297 error
= xfs_iflush(rip
, XFS_IFLUSH_SYNC
);
298 if (error
== EFSCORRUPTED
)
301 if (vn_count(rvp
) != 1 && !relocation
) {
302 xfs_iunlock(rip
, XFS_ILOCK_EXCL
);
303 return XFS_ERROR(EBUSY
);
307 * Release dquot that rootinode, rbmino and rsumino might be holding,
308 * flush and purge the quota inodes.
310 error
= XFS_QM_UNMOUNT(mp
);
311 if (error
== EFSCORRUPTED
)
319 xfs_iunlock(rip
, XFS_ILOCK_EXCL
);
326 xfs_iunlock(rip
, XFS_ILOCK_EXCL
);
328 return XFS_ERROR(EFSCORRUPTED
);
332 * xfs_sync flushes any pending I/O to file system vfsp.
334 * This routine is called by vfs_sync() to make sure that things make it
335 * out to disk eventually, on sync() system calls to flush out everything,
336 * and when the file system is unmounted. For the vfs_sync() case, all
337 * we really need to do is sync out the log to make all of our meta-data
338 * updates permanent (except for timestamps). For calls from pflushd(),
339 * dirty pages are kept moving by calling pdflush() on the inodes
340 * containing them. We also flush the inodes that we can lock without
341 * sleeping and the superblock if we can lock it without sleeping from
342 * vfs_sync() so that items at the tail of the log are always moving out.
345 * SYNC_BDFLUSH - We're being called from vfs_sync() so we don't want
346 * to sleep if we can help it. All we really need
347 * to do is ensure that the log is synced at least
348 * periodically. We also push the inodes and
349 * superblock if we can lock them without sleeping
350 * and they are not pinned.
351 * SYNC_ATTR - We need to flush the inodes. If SYNC_BDFLUSH is not
352 * set, then we really want to lock each inode and flush
354 * SYNC_WAIT - All the flushes that take place in this call should
356 * SYNC_DELWRI - This tells us to push dirty pages associated with
357 * inodes. SYNC_WAIT and SYNC_BDFLUSH are used to
358 * determine if they should be flushed sync, async, or
360 * SYNC_CLOSE - This flag is passed when the system is being
361 * unmounted. We should sync and invalidate everything.
362 * SYNC_FSDATA - This indicates that the caller would like to make
363 * sure the superblock is safe on disk. We can ensure
364 * this by simply making sure the log gets flushed
365 * if SYNC_BDFLUSH is set, and by actually writing it
367 * SYNC_IOWAIT - The caller wants us to wait for all data I/O to complete
368 * before we return (including direct I/O). Forms the drain
369 * side of the write barrier needed to safely quiesce the
381 * Get the Quota Manager to flush the dquots.
383 * If XFS quota support is not enabled or this filesystem
384 * instance does not use quotas XFS_QM_DQSYNC will always
387 error
= XFS_QM_DQSYNC(mp
, flags
);
390 * If we got an IO error, we will be shutting down.
391 * So, there's nothing more for us to do here.
393 ASSERT(error
!= EIO
|| XFS_FORCED_SHUTDOWN(mp
));
394 if (XFS_FORCED_SHUTDOWN(mp
))
395 return XFS_ERROR(error
);
398 if (flags
& SYNC_IOWAIT
)
399 xfs_filestream_flush(mp
);
401 return xfs_syncsub(mp
, flags
, NULL
);
405 * xfs sync routine for internal use
407 * This routine supports all of the flags defined for the generic vfs_sync
408 * interface as explained above under xfs_sync.
417 xfs_inode_t
*ip
= NULL
;
418 bhv_vnode_t
*vp
= NULL
;
423 uint base_lock_flags
;
424 boolean_t mount_locked
;
425 boolean_t vnode_refed
;
427 xfs_iptr_t
*ipointer
;
429 boolean_t ipointer_in
= B_FALSE
;
431 #define IPOINTER_SET ipointer_in = B_TRUE
432 #define IPOINTER_CLR ipointer_in = B_FALSE
439 /* Insert a marker record into the inode list after inode ip. The list
440 * must be locked when this is called. After the call the list will no
443 #define IPOINTER_INSERT(ip, mp) { \
444 ASSERT(ipointer_in == B_FALSE); \
445 ipointer->ip_mnext = ip->i_mnext; \
446 ipointer->ip_mprev = ip; \
447 ip->i_mnext = (xfs_inode_t *)ipointer; \
448 ipointer->ip_mnext->i_mprev = (xfs_inode_t *)ipointer; \
450 XFS_MOUNT_IUNLOCK(mp); \
451 mount_locked = B_FALSE; \
455 /* Remove the marker from the inode list. If the marker was the only item
456 * in the list then there are no remaining inodes and we should zero out
457 * the whole list. If we are the current head of the list then move the head
460 #define IPOINTER_REMOVE(ip, mp) { \
461 ASSERT(ipointer_in == B_TRUE); \
462 if (ipointer->ip_mnext != (xfs_inode_t *)ipointer) { \
463 ip = ipointer->ip_mnext; \
464 ip->i_mprev = ipointer->ip_mprev; \
465 ipointer->ip_mprev->i_mnext = ip; \
466 if (mp->m_inodes == (xfs_inode_t *)ipointer) { \
470 ASSERT(mp->m_inodes == (xfs_inode_t *)ipointer); \
471 mp->m_inodes = NULL; \
477 #define XFS_PREEMPT_MASK 0x7f
479 ASSERT(!(flags
& SYNC_BDFLUSH
));
483 if (mp
->m_flags
& XFS_MOUNT_RDONLY
)
489 /* Allocate a reference marker */
490 ipointer
= (xfs_iptr_t
*)kmem_zalloc(sizeof(xfs_iptr_t
), KM_SLEEP
);
492 fflag
= XFS_B_ASYNC
; /* default is don't wait */
493 if (flags
& SYNC_DELWRI
)
494 fflag
= XFS_B_DELWRI
;
495 if (flags
& SYNC_WAIT
)
496 fflag
= 0; /* synchronous overrides all */
498 base_lock_flags
= XFS_ILOCK_SHARED
;
499 if (flags
& (SYNC_DELWRI
| SYNC_CLOSE
)) {
501 * We need the I/O lock if we're going to call any of
502 * the flush/inval routines.
504 base_lock_flags
|= XFS_IOLOCK_SHARED
;
511 mount_locked
= B_TRUE
;
512 vnode_refed
= B_FALSE
;
517 ASSERT(ipointer_in
== B_FALSE
);
518 ASSERT(vnode_refed
== B_FALSE
);
520 lock_flags
= base_lock_flags
;
523 * There were no inodes in the list, just break out
531 * We found another sync thread marker - skip it
533 if (ip
->i_mount
== NULL
) {
538 vp
= XFS_ITOV_NULL(ip
);
541 * If the vnode is gone then this is being torn down,
542 * call reclaim if it is flushed, else let regular flush
543 * code deal with it later in the loop.
547 /* Skip ones already in reclaim */
548 if (ip
->i_flags
& XFS_IRECLAIM
) {
552 if (xfs_ilock_nowait(ip
, XFS_ILOCK_EXCL
) == 0) {
554 } else if ((xfs_ipincount(ip
) == 0) &&
555 xfs_iflock_nowait(ip
)) {
556 IPOINTER_INSERT(ip
, mp
);
558 xfs_finish_reclaim(ip
, 1,
559 XFS_IFLUSH_DELWRI_ELSE_ASYNC
);
562 mount_locked
= B_TRUE
;
563 IPOINTER_REMOVE(ip
, mp
);
565 xfs_iunlock(ip
, XFS_ILOCK_EXCL
);
576 if (XFS_FORCED_SHUTDOWN(mp
) && !(flags
& SYNC_CLOSE
)) {
577 XFS_MOUNT_IUNLOCK(mp
);
583 * Try to lock without sleeping. We're out of order with
584 * the inode list lock here, so if we fail we need to drop
585 * the mount lock and try again. If we're called from
586 * bdflush() here, then don't bother.
588 * The inode lock here actually coordinates with the
589 * almost spurious inode lock in xfs_ireclaim() to prevent
590 * the vnode we handle here without a reference from
591 * being freed while we reference it. If we lock the inode
592 * while it's on the mount list here, then the spurious inode
593 * lock in xfs_ireclaim() after the inode is pulled from
594 * the mount list will sleep until we release it here.
595 * This keeps the vnode from being freed while we reference
598 if (xfs_ilock_nowait(ip
, lock_flags
) == 0) {
610 IPOINTER_INSERT(ip
, mp
);
611 xfs_ilock(ip
, lock_flags
);
613 ASSERT(vp
== XFS_ITOV(ip
));
614 ASSERT(ip
->i_mount
== mp
);
616 vnode_refed
= B_TRUE
;
619 /* From here on in the loop we may have a marker record
624 * If we have to flush data or wait for I/O completion
625 * we need to drop the ilock that we currently hold.
626 * If we need to drop the lock, insert a marker if we
627 * have not already done so.
629 if ((flags
& (SYNC_CLOSE
|SYNC_IOWAIT
)) ||
630 ((flags
& SYNC_DELWRI
) && VN_DIRTY(vp
))) {
632 IPOINTER_INSERT(ip
, mp
);
634 xfs_iunlock(ip
, XFS_ILOCK_SHARED
);
636 if (flags
& SYNC_CLOSE
) {
637 /* Shutdown case. Flush and invalidate. */
638 if (XFS_FORCED_SHUTDOWN(mp
))
639 xfs_tosspages(ip
, 0, -1,
642 error
= xfs_flushinval_pages(ip
,
644 } else if ((flags
& SYNC_DELWRI
) && VN_DIRTY(vp
)) {
645 error
= xfs_flush_pages(ip
, 0,
650 * When freezing, we need to wait ensure all I/O (including direct
651 * I/O) is complete to ensure no further data modification can take
652 * place after this point
654 if (flags
& SYNC_IOWAIT
)
657 xfs_ilock(ip
, XFS_ILOCK_SHARED
);
660 if ((flags
& SYNC_ATTR
) &&
661 (ip
->i_update_core
||
662 (ip
->i_itemp
&& ip
->i_itemp
->ili_format
.ilf_fields
))) {
664 IPOINTER_INSERT(ip
, mp
);
666 if (flags
& SYNC_WAIT
) {
668 error
= xfs_iflush(ip
, XFS_IFLUSH_SYNC
);
671 * If we can't acquire the flush lock, then the inode
672 * is already being flushed so don't bother waiting.
674 * If we can lock it then do a delwri flush so we can
675 * combine multiple inode flushes in each disk write.
677 } else if (xfs_iflock_nowait(ip
)) {
678 error
= xfs_iflush(ip
, XFS_IFLUSH_DELWRI
);
679 } else if (bypassed
) {
684 if (lock_flags
!= 0) {
685 xfs_iunlock(ip
, lock_flags
);
690 * If we had to take a reference on the vnode
691 * above, then wait until after we've unlocked
692 * the inode to release the reference. This is
693 * because we can be already holding the inode
694 * lock when IRELE() calls xfs_inactive().
696 * Make sure to drop the mount lock before calling
697 * IRELE() so that we don't trip over ourselves if
698 * we have to go for the mount lock again in the
702 IPOINTER_INSERT(ip
, mp
);
707 vnode_refed
= B_FALSE
;
715 * bail out if the filesystem is corrupted.
717 if (error
== EFSCORRUPTED
) {
720 IPOINTER_REMOVE(ip
, mp
);
722 XFS_MOUNT_IUNLOCK(mp
);
723 ASSERT(ipointer_in
== B_FALSE
);
725 return XFS_ERROR(error
);
728 /* Let other threads have a chance at the mount lock
729 * if we have looped many times without dropping the
732 if ((++preempt
& XFS_PREEMPT_MASK
) == 0) {
734 IPOINTER_INSERT(ip
, mp
);
738 if (mount_locked
== B_FALSE
) {
740 mount_locked
= B_TRUE
;
741 IPOINTER_REMOVE(ip
, mp
);
745 ASSERT(ipointer_in
== B_FALSE
);
748 } while (ip
!= mp
->m_inodes
);
750 XFS_MOUNT_IUNLOCK(mp
);
752 ASSERT(ipointer_in
== B_FALSE
);
755 return XFS_ERROR(last_error
);
759 * xfs sync routine for internal use
761 * This routine supports all of the flags defined for the generic vfs_sync
762 * interface as explained above under xfs_sync.
773 uint log_flags
= XFS_LOG_FORCE
;
775 xfs_buf_log_item_t
*bip
;
778 * Sync out the log. This ensures that the log is periodically
779 * flushed even if there is not enough activity to fill it up.
781 if (flags
& SYNC_WAIT
)
782 log_flags
|= XFS_LOG_SYNC
;
784 xfs_log_force(mp
, (xfs_lsn_t
)0, log_flags
);
786 if (flags
& (SYNC_ATTR
|SYNC_DELWRI
)) {
787 if (flags
& SYNC_BDFLUSH
)
788 xfs_finish_reclaim_all(mp
, 1);
790 error
= xfs_sync_inodes(mp
, flags
, bypassed
);
794 * Flushing out dirty data above probably generated more
795 * log activity, so if this isn't vfs_sync() then flush
798 if (flags
& SYNC_DELWRI
) {
799 xfs_log_force(mp
, (xfs_lsn_t
)0, log_flags
);
802 if (flags
& SYNC_FSDATA
) {
804 * If this is vfs_sync() then only sync the superblock
805 * if we can lock it without sleeping and it is not pinned.
807 if (flags
& SYNC_BDFLUSH
) {
808 bp
= xfs_getsb(mp
, XFS_BUF_TRYLOCK
);
810 bip
= XFS_BUF_FSPRIVATE(bp
,xfs_buf_log_item_t
*);
812 xfs_buf_item_dirty(bip
)) {
813 if (!(XFS_BUF_ISPINNED(bp
))) {
815 error
= xfs_bwrite(mp
, bp
);
824 bp
= xfs_getsb(mp
, 0);
826 * If the buffer is pinned then push on the log so
827 * we won't get stuck waiting in the write for
828 * someone, maybe ourselves, to flush the log.
829 * Even though we just pushed the log above, we
830 * did not have the superblock buffer locked at
831 * that point so it can become pinned in between
834 if (XFS_BUF_ISPINNED(bp
))
835 xfs_log_force(mp
, (xfs_lsn_t
)0, XFS_LOG_FORCE
);
836 if (flags
& SYNC_WAIT
)
840 error
= xfs_bwrite(mp
, bp
);
848 * Now check to see if the log needs a "dummy" transaction.
850 if (!(flags
& SYNC_REMOUNT
) && xfs_log_need_covered(mp
)) {
855 * Put a dummy transaction in the log to tell
856 * recovery that all others are OK.
858 tp
= xfs_trans_alloc(mp
, XFS_TRANS_DUMMY1
);
859 if ((error
= xfs_trans_reserve(tp
, 0,
860 XFS_ICHANGE_LOG_RES(mp
),
862 xfs_trans_cancel(tp
, 0);
867 xfs_ilock(ip
, XFS_ILOCK_EXCL
);
869 xfs_trans_ijoin(tp
, ip
, XFS_ILOCK_EXCL
);
870 xfs_trans_ihold(tp
, ip
);
871 xfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
872 error
= xfs_trans_commit(tp
, 0);
873 xfs_iunlock(ip
, XFS_ILOCK_EXCL
);
874 xfs_log_force(mp
, (xfs_lsn_t
)0, log_flags
);
878 * When shutting down, we need to insure that the AIL is pushed
879 * to disk or the filesystem can appear corrupt from the PROM.
881 if ((flags
& (SYNC_CLOSE
|SYNC_WAIT
)) == (SYNC_CLOSE
|SYNC_WAIT
)) {
882 XFS_bflush(mp
->m_ddev_targp
);
883 if (mp
->m_rtdev_targp
) {
884 XFS_bflush(mp
->m_rtdev_targp
);
888 return XFS_ERROR(last_error
);