Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / fs / xfs / xfs_vfsops.c
blobaf03b904437d5b8582874fbf2e88309f1cc3b1b7
1 /*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
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
18 #include "xfs.h"
19 #include "xfs_fs.h"
20 #include "xfs_types.h"
21 #include "xfs_bit.h"
22 #include "xfs_log.h"
23 #include "xfs_inum.h"
24 #include "xfs_trans.h"
25 #include "xfs_sb.h"
26 #include "xfs_ag.h"
27 #include "xfs_dir2.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"
44 #include "xfs_bmap.h"
45 #include "xfs_rw.h"
46 #include "xfs_refcache.h"
47 #include "xfs_buf_item.h"
48 #include "xfs_log_priv.h"
49 #include "xfs_dir2_trace.h"
50 #include "xfs_extfree_item.h"
51 #include "xfs_acl.h"
52 #include "xfs_attr.h"
53 #include "xfs_clnt.h"
54 #include "xfs_mru_cache.h"
55 #include "xfs_filestream.h"
56 #include "xfs_fsops.h"
57 #include "xfs_vnodeops.h"
58 #include "xfs_vfsops.h"
61 int __init
62 xfs_init(void)
64 #ifdef XFS_DABUF_DEBUG
65 extern spinlock_t xfs_dabuf_global_lock;
66 spin_lock_init(&xfs_dabuf_global_lock);
67 #endif
70 * Initialize all of the zone allocators we use.
72 xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
73 "xfs_bmap_free_item");
74 xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
75 "xfs_btree_cur");
76 xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
77 xfs_da_state_zone =
78 kmem_zone_init(sizeof(xfs_da_state_t), "xfs_da_state");
79 xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
80 xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
81 xfs_acl_zone_init(xfs_acl_zone, "xfs_acl");
82 xfs_mru_cache_init();
83 xfs_filestream_init();
86 * The size of the zone allocated buf log item is the maximum
87 * size possible under XFS. This wastes a little bit of memory,
88 * but it is much faster.
90 xfs_buf_item_zone =
91 kmem_zone_init((sizeof(xfs_buf_log_item_t) +
92 (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
93 NBWORD) * sizeof(int))),
94 "xfs_buf_item");
95 xfs_efd_zone =
96 kmem_zone_init((sizeof(xfs_efd_log_item_t) +
97 ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
98 sizeof(xfs_extent_t))),
99 "xfs_efd_item");
100 xfs_efi_zone =
101 kmem_zone_init((sizeof(xfs_efi_log_item_t) +
102 ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
103 sizeof(xfs_extent_t))),
104 "xfs_efi_item");
107 * These zones warrant special memory allocator hints
109 xfs_inode_zone =
110 kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
111 KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
112 KM_ZONE_SPREAD, NULL);
113 xfs_ili_zone =
114 kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
115 KM_ZONE_SPREAD, NULL);
116 xfs_icluster_zone =
117 kmem_zone_init_flags(sizeof(xfs_icluster_t), "xfs_icluster",
118 KM_ZONE_SPREAD, NULL);
121 * Allocate global trace buffers.
123 #ifdef XFS_ALLOC_TRACE
124 xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_SLEEP);
125 #endif
126 #ifdef XFS_BMAP_TRACE
127 xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_SLEEP);
128 #endif
129 #ifdef XFS_BMBT_TRACE
130 xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_SLEEP);
131 #endif
132 #ifdef XFS_ATTR_TRACE
133 xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_SLEEP);
134 #endif
135 #ifdef XFS_DIR2_TRACE
136 xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_SLEEP);
137 #endif
139 xfs_dir_startup();
141 #if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
142 xfs_error_test_init();
143 #endif /* DEBUG || INDUCE_IO_ERROR */
145 xfs_init_procfs();
146 xfs_sysctl_register();
147 return 0;
150 void __exit
151 xfs_cleanup(void)
153 extern kmem_zone_t *xfs_inode_zone;
154 extern kmem_zone_t *xfs_efd_zone;
155 extern kmem_zone_t *xfs_efi_zone;
156 extern kmem_zone_t *xfs_icluster_zone;
158 xfs_cleanup_procfs();
159 xfs_sysctl_unregister();
160 xfs_refcache_destroy();
161 xfs_filestream_uninit();
162 xfs_mru_cache_uninit();
163 xfs_acl_zone_destroy(xfs_acl_zone);
165 #ifdef XFS_DIR2_TRACE
166 ktrace_free(xfs_dir2_trace_buf);
167 #endif
168 #ifdef XFS_ATTR_TRACE
169 ktrace_free(xfs_attr_trace_buf);
170 #endif
171 #ifdef XFS_BMBT_TRACE
172 ktrace_free(xfs_bmbt_trace_buf);
173 #endif
174 #ifdef XFS_BMAP_TRACE
175 ktrace_free(xfs_bmap_trace_buf);
176 #endif
177 #ifdef XFS_ALLOC_TRACE
178 ktrace_free(xfs_alloc_trace_buf);
179 #endif
181 kmem_zone_destroy(xfs_bmap_free_item_zone);
182 kmem_zone_destroy(xfs_btree_cur_zone);
183 kmem_zone_destroy(xfs_inode_zone);
184 kmem_zone_destroy(xfs_trans_zone);
185 kmem_zone_destroy(xfs_da_state_zone);
186 kmem_zone_destroy(xfs_dabuf_zone);
187 kmem_zone_destroy(xfs_buf_item_zone);
188 kmem_zone_destroy(xfs_efd_zone);
189 kmem_zone_destroy(xfs_efi_zone);
190 kmem_zone_destroy(xfs_ifork_zone);
191 kmem_zone_destroy(xfs_ili_zone);
192 kmem_zone_destroy(xfs_icluster_zone);
196 * xfs_start_flags
198 * This function fills in xfs_mount_t fields based on mount args.
199 * Note: the superblock has _not_ yet been read in.
201 STATIC int
202 xfs_start_flags(
203 struct xfs_mount_args *ap,
204 struct xfs_mount *mp)
206 /* Values are in BBs */
207 if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
209 * At this point the superblock has not been read
210 * in, therefore we do not know the block size.
211 * Before the mount call ends we will convert
212 * these to FSBs.
214 mp->m_dalign = ap->sunit;
215 mp->m_swidth = ap->swidth;
218 if (ap->logbufs != -1 &&
219 ap->logbufs != 0 &&
220 (ap->logbufs < XLOG_MIN_ICLOGS ||
221 ap->logbufs > XLOG_MAX_ICLOGS)) {
222 cmn_err(CE_WARN,
223 "XFS: invalid logbufs value: %d [not %d-%d]",
224 ap->logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
225 return XFS_ERROR(EINVAL);
227 mp->m_logbufs = ap->logbufs;
228 if (ap->logbufsize != -1 &&
229 ap->logbufsize != 0 &&
230 (ap->logbufsize < XLOG_MIN_RECORD_BSIZE ||
231 ap->logbufsize > XLOG_MAX_RECORD_BSIZE ||
232 !is_power_of_2(ap->logbufsize))) {
233 cmn_err(CE_WARN,
234 "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
235 ap->logbufsize);
236 return XFS_ERROR(EINVAL);
238 mp->m_logbsize = ap->logbufsize;
239 mp->m_fsname_len = strlen(ap->fsname) + 1;
240 mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP);
241 strcpy(mp->m_fsname, ap->fsname);
242 if (ap->rtname[0]) {
243 mp->m_rtname = kmem_alloc(strlen(ap->rtname) + 1, KM_SLEEP);
244 strcpy(mp->m_rtname, ap->rtname);
246 if (ap->logname[0]) {
247 mp->m_logname = kmem_alloc(strlen(ap->logname) + 1, KM_SLEEP);
248 strcpy(mp->m_logname, ap->logname);
251 if (ap->flags & XFSMNT_WSYNC)
252 mp->m_flags |= XFS_MOUNT_WSYNC;
253 #if XFS_BIG_INUMS
254 if (ap->flags & XFSMNT_INO64) {
255 mp->m_flags |= XFS_MOUNT_INO64;
256 mp->m_inoadd = XFS_INO64_OFFSET;
258 #endif
259 if (ap->flags & XFSMNT_RETERR)
260 mp->m_flags |= XFS_MOUNT_RETERR;
261 if (ap->flags & XFSMNT_NOALIGN)
262 mp->m_flags |= XFS_MOUNT_NOALIGN;
263 if (ap->flags & XFSMNT_SWALLOC)
264 mp->m_flags |= XFS_MOUNT_SWALLOC;
265 if (ap->flags & XFSMNT_OSYNCISOSYNC)
266 mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
267 if (ap->flags & XFSMNT_32BITINODES)
268 mp->m_flags |= XFS_MOUNT_32BITINODES;
270 if (ap->flags & XFSMNT_IOSIZE) {
271 if (ap->iosizelog > XFS_MAX_IO_LOG ||
272 ap->iosizelog < XFS_MIN_IO_LOG) {
273 cmn_err(CE_WARN,
274 "XFS: invalid log iosize: %d [not %d-%d]",
275 ap->iosizelog, XFS_MIN_IO_LOG,
276 XFS_MAX_IO_LOG);
277 return XFS_ERROR(EINVAL);
280 mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
281 mp->m_readio_log = mp->m_writeio_log = ap->iosizelog;
284 <<<<<<< HEAD:fs/xfs/xfs_vfsops.c
285 if (ap->flags & XFSMNT_IDELETE)
286 mp->m_flags |= XFS_MOUNT_IDELETE;
287 =======
288 if (ap->flags & XFSMNT_IKEEP)
289 mp->m_flags |= XFS_MOUNT_IKEEP;
290 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:fs/xfs/xfs_vfsops.c
291 if (ap->flags & XFSMNT_DIRSYNC)
292 mp->m_flags |= XFS_MOUNT_DIRSYNC;
293 if (ap->flags & XFSMNT_ATTR2)
294 mp->m_flags |= XFS_MOUNT_ATTR2;
296 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
297 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
300 * no recovery flag requires a read-only mount
302 if (ap->flags & XFSMNT_NORECOVERY) {
303 if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
304 cmn_err(CE_WARN,
305 "XFS: tried to mount a FS read-write without recovery!");
306 return XFS_ERROR(EINVAL);
308 mp->m_flags |= XFS_MOUNT_NORECOVERY;
311 if (ap->flags & XFSMNT_NOUUID)
312 mp->m_flags |= XFS_MOUNT_NOUUID;
313 if (ap->flags & XFSMNT_BARRIER)
314 mp->m_flags |= XFS_MOUNT_BARRIER;
315 else
316 mp->m_flags &= ~XFS_MOUNT_BARRIER;
318 if (ap->flags2 & XFSMNT2_FILESTREAMS)
319 mp->m_flags |= XFS_MOUNT_FILESTREAMS;
321 if (ap->flags & XFSMNT_DMAPI)
322 mp->m_flags |= XFS_MOUNT_DMAPI;
323 return 0;
327 * This function fills in xfs_mount_t fields based on mount args.
328 * Note: the superblock _has_ now been read in.
330 STATIC int
331 xfs_finish_flags(
332 struct xfs_mount_args *ap,
333 struct xfs_mount *mp)
335 int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
337 /* Fail a mount where the logbuf is smaller then the log stripe */
338 if (XFS_SB_VERSION_HASLOGV2(&mp->m_sb)) {
339 if ((ap->logbufsize <= 0) &&
340 (mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE)) {
341 mp->m_logbsize = mp->m_sb.sb_logsunit;
342 } else if (ap->logbufsize > 0 &&
343 ap->logbufsize < mp->m_sb.sb_logsunit) {
344 cmn_err(CE_WARN,
345 "XFS: logbuf size must be greater than or equal to log stripe size");
346 return XFS_ERROR(EINVAL);
348 } else {
349 /* Fail a mount if the logbuf is larger than 32K */
350 if (ap->logbufsize > XLOG_BIG_RECORD_BSIZE) {
351 cmn_err(CE_WARN,
352 "XFS: logbuf size for version 1 logs must be 16K or 32K");
353 return XFS_ERROR(EINVAL);
357 if (XFS_SB_VERSION_HASATTR2(&mp->m_sb)) {
358 mp->m_flags |= XFS_MOUNT_ATTR2;
362 * prohibit r/w mounts of read-only filesystems
364 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
365 cmn_err(CE_WARN,
366 "XFS: cannot mount a read-only filesystem as read-write");
367 return XFS_ERROR(EROFS);
371 * check for shared mount.
373 if (ap->flags & XFSMNT_SHARED) {
374 if (!XFS_SB_VERSION_HASSHARED(&mp->m_sb))
375 return XFS_ERROR(EINVAL);
378 * For IRIX 6.5, shared mounts must have the shared
379 * version bit set, have the persistent readonly
380 * field set, must be version 0 and can only be mounted
381 * read-only.
383 if (!ronly || !(mp->m_sb.sb_flags & XFS_SBF_READONLY) ||
384 (mp->m_sb.sb_shared_vn != 0))
385 return XFS_ERROR(EINVAL);
387 mp->m_flags |= XFS_MOUNT_SHARED;
390 * Shared XFS V0 can't deal with DMI. Return EINVAL.
392 if (mp->m_sb.sb_shared_vn == 0 && (ap->flags & XFSMNT_DMAPI))
393 return XFS_ERROR(EINVAL);
396 if (ap->flags & XFSMNT_UQUOTA) {
397 mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
398 if (ap->flags & XFSMNT_UQUOTAENF)
399 mp->m_qflags |= XFS_UQUOTA_ENFD;
402 if (ap->flags & XFSMNT_GQUOTA) {
403 mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
404 if (ap->flags & XFSMNT_GQUOTAENF)
405 mp->m_qflags |= XFS_OQUOTA_ENFD;
406 } else if (ap->flags & XFSMNT_PQUOTA) {
407 mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
408 if (ap->flags & XFSMNT_PQUOTAENF)
409 mp->m_qflags |= XFS_OQUOTA_ENFD;
412 return 0;
416 * xfs_mount
418 * The file system configurations are:
419 * (1) device (partition) with data and internal log
420 * (2) logical volume with data and log subvolumes.
421 * (3) logical volume with data, log, and realtime subvolumes.
423 * We only have to handle opening the log and realtime volumes here if
424 * they are present. The data subvolume has already been opened by
425 * get_sb_bdev() and is stored in vfsp->vfs_super->s_bdev.
428 xfs_mount(
429 struct xfs_mount *mp,
430 struct xfs_mount_args *args,
431 cred_t *credp)
433 struct block_device *ddev, *logdev, *rtdev;
434 int flags = 0, error;
436 ddev = mp->m_super->s_bdev;
437 logdev = rtdev = NULL;
439 error = xfs_dmops_get(mp, args);
440 if (error)
441 return error;
442 error = xfs_qmops_get(mp, args);
443 if (error)
444 return error;
446 if (args->flags & XFSMNT_QUIET)
447 flags |= XFS_MFSI_QUIET;
450 * Open real time and log devices - order is important.
452 if (args->logname[0]) {
453 error = xfs_blkdev_get(mp, args->logname, &logdev);
454 if (error)
455 return error;
457 if (args->rtname[0]) {
458 error = xfs_blkdev_get(mp, args->rtname, &rtdev);
459 if (error) {
460 xfs_blkdev_put(logdev);
461 return error;
464 if (rtdev == ddev || rtdev == logdev) {
465 cmn_err(CE_WARN,
466 "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev.");
467 xfs_blkdev_put(logdev);
468 xfs_blkdev_put(rtdev);
469 return EINVAL;
474 * Setup xfs_mount buffer target pointers
476 error = ENOMEM;
477 mp->m_ddev_targp = xfs_alloc_buftarg(ddev, 0);
478 if (!mp->m_ddev_targp) {
479 xfs_blkdev_put(logdev);
480 xfs_blkdev_put(rtdev);
481 return error;
483 if (rtdev) {
484 mp->m_rtdev_targp = xfs_alloc_buftarg(rtdev, 1);
485 if (!mp->m_rtdev_targp) {
486 xfs_blkdev_put(logdev);
487 xfs_blkdev_put(rtdev);
488 goto error0;
491 mp->m_logdev_targp = (logdev && logdev != ddev) ?
492 xfs_alloc_buftarg(logdev, 1) : mp->m_ddev_targp;
493 if (!mp->m_logdev_targp) {
494 xfs_blkdev_put(logdev);
495 xfs_blkdev_put(rtdev);
496 goto error0;
500 * Setup flags based on mount(2) options and then the superblock
502 error = xfs_start_flags(args, mp);
503 if (error)
504 goto error1;
505 error = xfs_readsb(mp, flags);
506 if (error)
507 goto error1;
508 error = xfs_finish_flags(args, mp);
509 if (error)
510 goto error2;
513 * Setup xfs_mount buffer target pointers based on superblock
515 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize,
516 mp->m_sb.sb_sectsize);
517 if (!error && logdev && logdev != ddev) {
518 unsigned int log_sector_size = BBSIZE;
520 if (XFS_SB_VERSION_HASSECTOR(&mp->m_sb))
521 log_sector_size = mp->m_sb.sb_logsectsize;
522 error = xfs_setsize_buftarg(mp->m_logdev_targp,
523 mp->m_sb.sb_blocksize,
524 log_sector_size);
526 if (!error && rtdev)
527 error = xfs_setsize_buftarg(mp->m_rtdev_targp,
528 mp->m_sb.sb_blocksize,
529 mp->m_sb.sb_sectsize);
530 if (error)
531 goto error2;
533 if (mp->m_flags & XFS_MOUNT_BARRIER)
534 xfs_mountfs_check_barriers(mp);
536 if ((error = xfs_filestream_mount(mp)))
537 goto error2;
539 error = xfs_mountfs(mp, flags);
540 if (error)
541 goto error2;
543 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, args->mtpt, args->fsname);
545 return 0;
547 error2:
548 if (mp->m_sb_bp)
549 xfs_freesb(mp);
550 error1:
551 xfs_binval(mp->m_ddev_targp);
552 if (logdev && logdev != ddev)
553 xfs_binval(mp->m_logdev_targp);
554 if (rtdev)
555 xfs_binval(mp->m_rtdev_targp);
556 error0:
557 xfs_unmountfs_close(mp, credp);
558 xfs_qmops_put(mp);
559 xfs_dmops_put(mp);
560 return error;
564 xfs_unmount(
565 xfs_mount_t *mp,
566 int flags,
567 cred_t *credp)
569 xfs_inode_t *rip;
570 bhv_vnode_t *rvp;
571 int unmount_event_wanted = 0;
572 int unmount_event_flags = 0;
573 int xfs_unmountfs_needed = 0;
574 int error;
576 rip = mp->m_rootip;
577 rvp = XFS_ITOV(rip);
579 #ifdef HAVE_DMAPI
580 if (mp->m_flags & XFS_MOUNT_DMAPI) {
581 error = XFS_SEND_PREUNMOUNT(mp,
582 rvp, DM_RIGHT_NULL, rvp, DM_RIGHT_NULL,
583 NULL, NULL, 0, 0,
584 (mp->m_dmevmask & (1<<DM_EVENT_PREUNMOUNT))?
585 0:DM_FLAGS_UNWANTED);
586 if (error)
587 return XFS_ERROR(error);
588 unmount_event_wanted = 1;
589 unmount_event_flags = (mp->m_dmevmask & (1<<DM_EVENT_UNMOUNT))?
590 0 : DM_FLAGS_UNWANTED;
592 #endif
594 * First blow any referenced inode from this file system
595 * out of the reference cache, and delete the timer.
597 xfs_refcache_purge_mp(mp);
600 * Blow away any referenced inode in the filestreams cache.
601 * This can and will cause log traffic as inodes go inactive
602 * here.
604 xfs_filestream_unmount(mp);
606 XFS_bflush(mp->m_ddev_targp);
607 error = xfs_unmount_flush(mp, 0);
608 if (error)
609 goto out;
611 ASSERT(vn_count(rvp) == 1);
614 * Drop the reference count
616 VN_RELE(rvp);
619 * If we're forcing a shutdown, typically because of a media error,
620 * we want to make sure we invalidate dirty pages that belong to
621 * referenced vnodes as well.
623 if (XFS_FORCED_SHUTDOWN(mp)) {
624 error = xfs_sync(mp, SYNC_WAIT | SYNC_CLOSE);
625 ASSERT(error != EFSCORRUPTED);
627 xfs_unmountfs_needed = 1;
629 out:
630 /* Send DMAPI event, if required.
631 * Then do xfs_unmountfs() if needed.
632 * Then return error (or zero).
634 if (unmount_event_wanted) {
635 /* Note: mp structure must still exist for
636 * XFS_SEND_UNMOUNT() call.
638 XFS_SEND_UNMOUNT(mp, error == 0 ? rvp : NULL,
639 DM_RIGHT_NULL, 0, error, unmount_event_flags);
641 if (xfs_unmountfs_needed) {
643 * Call common unmount function to flush to disk
644 * and free the super block buffer & mount structures.
646 xfs_unmountfs(mp, credp);
647 xfs_qmops_put(mp);
648 xfs_dmops_put(mp);
649 kmem_free(mp, sizeof(xfs_mount_t));
652 return XFS_ERROR(error);
655 STATIC int
656 xfs_quiesce_fs(
657 xfs_mount_t *mp)
659 int count = 0, pincount;
661 xfs_refcache_purge_mp(mp);
662 xfs_flush_buftarg(mp->m_ddev_targp, 0);
663 xfs_finish_reclaim_all(mp, 0);
665 /* This loop must run at least twice.
666 * The first instance of the loop will flush
667 * most meta data but that will generate more
668 * meta data (typically directory updates).
669 * Which then must be flushed and logged before
670 * we can write the unmount record.
672 do {
673 xfs_syncsub(mp, SYNC_INODE_QUIESCE, NULL);
674 pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
675 if (!pincount) {
676 delay(50);
677 count++;
679 } while (count < 2);
681 return 0;
685 * Second stage of a quiesce. The data is already synced, now we have to take
686 * care of the metadata. New transactions are already blocked, so we need to
687 * wait for any remaining transactions to drain out before proceding.
689 void
690 xfs_attr_quiesce(
691 xfs_mount_t *mp)
693 /* wait for all modifications to complete */
694 while (atomic_read(&mp->m_active_trans) > 0)
695 delay(100);
697 /* flush inodes and push all remaining buffers out to disk */
698 xfs_quiesce_fs(mp);
700 ASSERT_ALWAYS(atomic_read(&mp->m_active_trans) == 0);
702 /* Push the superblock and write an unmount record */
703 xfs_log_sbcount(mp, 1);
704 xfs_log_unmount_write(mp);
705 xfs_unmountfs_writesb(mp);
709 xfs_mntupdate(
710 struct xfs_mount *mp,
711 int *flags,
712 struct xfs_mount_args *args)
714 if (!(*flags & MS_RDONLY)) { /* rw/ro -> rw */
715 if (mp->m_flags & XFS_MOUNT_RDONLY)
716 mp->m_flags &= ~XFS_MOUNT_RDONLY;
717 if (args->flags & XFSMNT_BARRIER) {
718 mp->m_flags |= XFS_MOUNT_BARRIER;
719 xfs_mountfs_check_barriers(mp);
720 } else {
721 mp->m_flags &= ~XFS_MOUNT_BARRIER;
723 } else if (!(mp->m_flags & XFS_MOUNT_RDONLY)) { /* rw -> ro */
724 xfs_filestream_flush(mp);
725 xfs_sync(mp, SYNC_DATA_QUIESCE);
726 xfs_attr_quiesce(mp);
727 mp->m_flags |= XFS_MOUNT_RDONLY;
729 return 0;
733 * xfs_unmount_flush implements a set of flush operation on special
734 * inodes, which are needed as a separate set of operations so that
735 * they can be called as part of relocation process.
738 xfs_unmount_flush(
739 xfs_mount_t *mp, /* Mount structure we are getting
740 rid of. */
741 int relocation) /* Called from vfs relocation. */
743 xfs_inode_t *rip = mp->m_rootip;
744 xfs_inode_t *rbmip;
745 xfs_inode_t *rsumip = NULL;
746 bhv_vnode_t *rvp = XFS_ITOV(rip);
747 int error;
749 xfs_ilock(rip, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
750 xfs_iflock(rip);
753 * Flush out the real time inodes.
755 if ((rbmip = mp->m_rbmip) != NULL) {
756 xfs_ilock(rbmip, XFS_ILOCK_EXCL);
757 xfs_iflock(rbmip);
758 error = xfs_iflush(rbmip, XFS_IFLUSH_SYNC);
759 xfs_iunlock(rbmip, XFS_ILOCK_EXCL);
761 if (error == EFSCORRUPTED)
762 goto fscorrupt_out;
764 ASSERT(vn_count(XFS_ITOV(rbmip)) == 1);
766 rsumip = mp->m_rsumip;
767 xfs_ilock(rsumip, XFS_ILOCK_EXCL);
768 xfs_iflock(rsumip);
769 error = xfs_iflush(rsumip, XFS_IFLUSH_SYNC);
770 xfs_iunlock(rsumip, XFS_ILOCK_EXCL);
772 if (error == EFSCORRUPTED)
773 goto fscorrupt_out;
775 ASSERT(vn_count(XFS_ITOV(rsumip)) == 1);
779 * Synchronously flush root inode to disk
781 error = xfs_iflush(rip, XFS_IFLUSH_SYNC);
782 if (error == EFSCORRUPTED)
783 goto fscorrupt_out2;
785 if (vn_count(rvp) != 1 && !relocation) {
786 xfs_iunlock(rip, XFS_ILOCK_EXCL);
787 return XFS_ERROR(EBUSY);
791 * Release dquot that rootinode, rbmino and rsumino might be holding,
792 * flush and purge the quota inodes.
794 error = XFS_QM_UNMOUNT(mp);
795 if (error == EFSCORRUPTED)
796 goto fscorrupt_out2;
798 if (rbmip) {
799 VN_RELE(XFS_ITOV(rbmip));
800 VN_RELE(XFS_ITOV(rsumip));
803 xfs_iunlock(rip, XFS_ILOCK_EXCL);
804 return 0;
806 fscorrupt_out:
807 xfs_ifunlock(rip);
809 fscorrupt_out2:
810 xfs_iunlock(rip, XFS_ILOCK_EXCL);
812 return XFS_ERROR(EFSCORRUPTED);
816 * xfs_sync flushes any pending I/O to file system vfsp.
818 * This routine is called by vfs_sync() to make sure that things make it
819 * out to disk eventually, on sync() system calls to flush out everything,
820 * and when the file system is unmounted. For the vfs_sync() case, all
821 * we really need to do is sync out the log to make all of our meta-data
822 * updates permanent (except for timestamps). For calls from pflushd(),
823 * dirty pages are kept moving by calling pdflush() on the inodes
824 * containing them. We also flush the inodes that we can lock without
825 * sleeping and the superblock if we can lock it without sleeping from
826 * vfs_sync() so that items at the tail of the log are always moving out.
828 * Flags:
829 * SYNC_BDFLUSH - We're being called from vfs_sync() so we don't want
830 * to sleep if we can help it. All we really need
831 * to do is ensure that the log is synced at least
832 * periodically. We also push the inodes and
833 * superblock if we can lock them without sleeping
834 * and they are not pinned.
835 * SYNC_ATTR - We need to flush the inodes. If SYNC_BDFLUSH is not
836 * set, then we really want to lock each inode and flush
837 * it.
838 * SYNC_WAIT - All the flushes that take place in this call should
839 * be synchronous.
840 * SYNC_DELWRI - This tells us to push dirty pages associated with
841 * inodes. SYNC_WAIT and SYNC_BDFLUSH are used to
842 * determine if they should be flushed sync, async, or
843 * delwri.
844 * SYNC_CLOSE - This flag is passed when the system is being
845 * unmounted. We should sync and invalidate everything.
846 * SYNC_FSDATA - This indicates that the caller would like to make
847 * sure the superblock is safe on disk. We can ensure
848 * this by simply making sure the log gets flushed
849 * if SYNC_BDFLUSH is set, and by actually writing it
850 * out otherwise.
851 * SYNC_IOWAIT - The caller wants us to wait for all data I/O to complete
852 * before we return (including direct I/O). Forms the drain
853 * side of the write barrier needed to safely quiesce the
854 * filesystem.
858 xfs_sync(
859 xfs_mount_t *mp,
860 int flags)
862 int error;
865 * Get the Quota Manager to flush the dquots.
867 * If XFS quota support is not enabled or this filesystem
868 * instance does not use quotas XFS_QM_DQSYNC will always
869 * return zero.
871 error = XFS_QM_DQSYNC(mp, flags);
872 if (error) {
874 * If we got an IO error, we will be shutting down.
875 * So, there's nothing more for us to do here.
877 ASSERT(error != EIO || XFS_FORCED_SHUTDOWN(mp));
878 if (XFS_FORCED_SHUTDOWN(mp))
879 return XFS_ERROR(error);
882 if (flags & SYNC_IOWAIT)
883 xfs_filestream_flush(mp);
885 return xfs_syncsub(mp, flags, NULL);
889 * xfs sync routine for internal use
891 * This routine supports all of the flags defined for the generic vfs_sync
892 * interface as explained above under xfs_sync.
896 xfs_sync_inodes(
897 xfs_mount_t *mp,
898 int flags,
899 int *bypassed)
901 xfs_inode_t *ip = NULL;
902 bhv_vnode_t *vp = NULL;
903 int error;
904 int last_error;
905 uint64_t fflag;
906 uint lock_flags;
907 uint base_lock_flags;
908 boolean_t mount_locked;
909 boolean_t vnode_refed;
910 int preempt;
911 xfs_iptr_t *ipointer;
912 #ifdef DEBUG
913 boolean_t ipointer_in = B_FALSE;
915 #define IPOINTER_SET ipointer_in = B_TRUE
916 #define IPOINTER_CLR ipointer_in = B_FALSE
917 #else
918 #define IPOINTER_SET
919 #define IPOINTER_CLR
920 #endif
923 /* Insert a marker record into the inode list after inode ip. The list
924 * must be locked when this is called. After the call the list will no
925 * longer be locked.
927 #define IPOINTER_INSERT(ip, mp) { \
928 ASSERT(ipointer_in == B_FALSE); \
929 ipointer->ip_mnext = ip->i_mnext; \
930 ipointer->ip_mprev = ip; \
931 ip->i_mnext = (xfs_inode_t *)ipointer; \
932 ipointer->ip_mnext->i_mprev = (xfs_inode_t *)ipointer; \
933 preempt = 0; \
934 XFS_MOUNT_IUNLOCK(mp); \
935 mount_locked = B_FALSE; \
936 IPOINTER_SET; \
939 /* Remove the marker from the inode list. If the marker was the only item
940 * in the list then there are no remaining inodes and we should zero out
941 * the whole list. If we are the current head of the list then move the head
942 * past us.
944 #define IPOINTER_REMOVE(ip, mp) { \
945 ASSERT(ipointer_in == B_TRUE); \
946 if (ipointer->ip_mnext != (xfs_inode_t *)ipointer) { \
947 ip = ipointer->ip_mnext; \
948 ip->i_mprev = ipointer->ip_mprev; \
949 ipointer->ip_mprev->i_mnext = ip; \
950 if (mp->m_inodes == (xfs_inode_t *)ipointer) { \
951 mp->m_inodes = ip; \
953 } else { \
954 ASSERT(mp->m_inodes == (xfs_inode_t *)ipointer); \
955 mp->m_inodes = NULL; \
956 ip = NULL; \
958 IPOINTER_CLR; \
961 #define XFS_PREEMPT_MASK 0x7f
963 ASSERT(!(flags & SYNC_BDFLUSH));
965 if (bypassed)
966 *bypassed = 0;
967 if (mp->m_flags & XFS_MOUNT_RDONLY)
968 return 0;
969 error = 0;
970 last_error = 0;
971 preempt = 0;
973 /* Allocate a reference marker */
974 ipointer = (xfs_iptr_t *)kmem_zalloc(sizeof(xfs_iptr_t), KM_SLEEP);
976 fflag = XFS_B_ASYNC; /* default is don't wait */
977 if (flags & SYNC_DELWRI)
978 fflag = XFS_B_DELWRI;
979 if (flags & SYNC_WAIT)
980 fflag = 0; /* synchronous overrides all */
982 base_lock_flags = XFS_ILOCK_SHARED;
983 if (flags & (SYNC_DELWRI | SYNC_CLOSE)) {
985 * We need the I/O lock if we're going to call any of
986 * the flush/inval routines.
988 base_lock_flags |= XFS_IOLOCK_SHARED;
991 XFS_MOUNT_ILOCK(mp);
993 ip = mp->m_inodes;
995 mount_locked = B_TRUE;
996 vnode_refed = B_FALSE;
998 IPOINTER_CLR;
1000 do {
1001 ASSERT(ipointer_in == B_FALSE);
1002 ASSERT(vnode_refed == B_FALSE);
1004 lock_flags = base_lock_flags;
1007 * There were no inodes in the list, just break out
1008 * of the loop.
1010 if (ip == NULL) {
1011 break;
1015 * We found another sync thread marker - skip it
1017 if (ip->i_mount == NULL) {
1018 ip = ip->i_mnext;
1019 continue;
1022 vp = XFS_ITOV_NULL(ip);
1025 * If the vnode is gone then this is being torn down,
1026 * call reclaim if it is flushed, else let regular flush
1027 * code deal with it later in the loop.
1030 if (vp == NULL) {
1031 /* Skip ones already in reclaim */
1032 if (ip->i_flags & XFS_IRECLAIM) {
1033 ip = ip->i_mnext;
1034 continue;
1036 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) {
1037 ip = ip->i_mnext;
1038 } else if ((xfs_ipincount(ip) == 0) &&
1039 xfs_iflock_nowait(ip)) {
1040 IPOINTER_INSERT(ip, mp);
1042 xfs_finish_reclaim(ip, 1,
1043 XFS_IFLUSH_DELWRI_ELSE_ASYNC);
1045 XFS_MOUNT_ILOCK(mp);
1046 mount_locked = B_TRUE;
1047 IPOINTER_REMOVE(ip, mp);
1048 } else {
1049 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1050 ip = ip->i_mnext;
1052 continue;
1055 if (VN_BAD(vp)) {
1056 ip = ip->i_mnext;
1057 continue;
1060 if (XFS_FORCED_SHUTDOWN(mp) && !(flags & SYNC_CLOSE)) {
1061 XFS_MOUNT_IUNLOCK(mp);
1062 kmem_free(ipointer, sizeof(xfs_iptr_t));
1063 return 0;
1067 * Try to lock without sleeping. We're out of order with
1068 * the inode list lock here, so if we fail we need to drop
1069 * the mount lock and try again. If we're called from
1070 * bdflush() here, then don't bother.
1072 * The inode lock here actually coordinates with the
1073 * almost spurious inode lock in xfs_ireclaim() to prevent
1074 * the vnode we handle here without a reference from
1075 * being freed while we reference it. If we lock the inode
1076 * while it's on the mount list here, then the spurious inode
1077 * lock in xfs_ireclaim() after the inode is pulled from
1078 * the mount list will sleep until we release it here.
1079 * This keeps the vnode from being freed while we reference
1080 * it.
1082 if (xfs_ilock_nowait(ip, lock_flags) == 0) {
1083 if (vp == NULL) {
1084 ip = ip->i_mnext;
1085 continue;
1088 vp = vn_grab(vp);
1089 if (vp == NULL) {
1090 ip = ip->i_mnext;
1091 continue;
1094 IPOINTER_INSERT(ip, mp);
1095 xfs_ilock(ip, lock_flags);
1097 ASSERT(vp == XFS_ITOV(ip));
1098 ASSERT(ip->i_mount == mp);
1100 vnode_refed = B_TRUE;
1103 /* From here on in the loop we may have a marker record
1104 * in the inode list.
1108 * If we have to flush data or wait for I/O completion
1109 * we need to drop the ilock that we currently hold.
1110 * If we need to drop the lock, insert a marker if we
1111 * have not already done so.
1113 if ((flags & (SYNC_CLOSE|SYNC_IOWAIT)) ||
1114 ((flags & SYNC_DELWRI) && VN_DIRTY(vp))) {
1115 if (mount_locked) {
1116 IPOINTER_INSERT(ip, mp);
1118 xfs_iunlock(ip, XFS_ILOCK_SHARED);
1120 if (flags & SYNC_CLOSE) {
1121 /* Shutdown case. Flush and invalidate. */
1122 if (XFS_FORCED_SHUTDOWN(mp))
1123 xfs_tosspages(ip, 0, -1,
1124 FI_REMAPF);
1125 else
1126 error = xfs_flushinval_pages(ip,
1127 0, -1, FI_REMAPF);
1128 } else if ((flags & SYNC_DELWRI) && VN_DIRTY(vp)) {
1129 error = xfs_flush_pages(ip, 0,
1130 -1, fflag, FI_NONE);
1134 * When freezing, we need to wait ensure all I/O (including direct
1135 * I/O) is complete to ensure no further data modification can take
1136 * place after this point
1138 if (flags & SYNC_IOWAIT)
1139 vn_iowait(ip);
1141 xfs_ilock(ip, XFS_ILOCK_SHARED);
1144 if ((flags & SYNC_ATTR) &&
1145 (ip->i_update_core ||
1146 (ip->i_itemp && ip->i_itemp->ili_format.ilf_fields))) {
1147 if (mount_locked)
1148 IPOINTER_INSERT(ip, mp);
1150 if (flags & SYNC_WAIT) {
1151 xfs_iflock(ip);
1152 error = xfs_iflush(ip, XFS_IFLUSH_SYNC);
1155 * If we can't acquire the flush lock, then the inode
1156 * is already being flushed so don't bother waiting.
1158 * If we can lock it then do a delwri flush so we can
1159 * combine multiple inode flushes in each disk write.
1161 } else if (xfs_iflock_nowait(ip)) {
1162 error = xfs_iflush(ip, XFS_IFLUSH_DELWRI);
1163 } else if (bypassed) {
1164 (*bypassed)++;
1168 if (lock_flags != 0) {
1169 xfs_iunlock(ip, lock_flags);
1172 if (vnode_refed) {
1174 * If we had to take a reference on the vnode
1175 * above, then wait until after we've unlocked
1176 * the inode to release the reference. This is
1177 * because we can be already holding the inode
1178 * lock when VN_RELE() calls xfs_inactive().
1180 * Make sure to drop the mount lock before calling
1181 * VN_RELE() so that we don't trip over ourselves if
1182 * we have to go for the mount lock again in the
1183 * inactive code.
1185 if (mount_locked) {
1186 IPOINTER_INSERT(ip, mp);
1189 VN_RELE(vp);
1191 vnode_refed = B_FALSE;
1194 if (error) {
1195 last_error = error;
1199 * bail out if the filesystem is corrupted.
1201 if (error == EFSCORRUPTED) {
1202 if (!mount_locked) {
1203 XFS_MOUNT_ILOCK(mp);
1204 IPOINTER_REMOVE(ip, mp);
1206 XFS_MOUNT_IUNLOCK(mp);
1207 ASSERT(ipointer_in == B_FALSE);
1208 kmem_free(ipointer, sizeof(xfs_iptr_t));
1209 return XFS_ERROR(error);
1212 /* Let other threads have a chance at the mount lock
1213 * if we have looped many times without dropping the
1214 * lock.
1216 if ((++preempt & XFS_PREEMPT_MASK) == 0) {
1217 if (mount_locked) {
1218 IPOINTER_INSERT(ip, mp);
1222 if (mount_locked == B_FALSE) {
1223 XFS_MOUNT_ILOCK(mp);
1224 mount_locked = B_TRUE;
1225 IPOINTER_REMOVE(ip, mp);
1226 continue;
1229 ASSERT(ipointer_in == B_FALSE);
1230 ip = ip->i_mnext;
1232 } while (ip != mp->m_inodes);
1234 XFS_MOUNT_IUNLOCK(mp);
1236 ASSERT(ipointer_in == B_FALSE);
1238 kmem_free(ipointer, sizeof(xfs_iptr_t));
1239 return XFS_ERROR(last_error);
1243 * xfs sync routine for internal use
1245 * This routine supports all of the flags defined for the generic vfs_sync
1246 * interface as explained above under xfs_sync.
1250 xfs_syncsub(
1251 xfs_mount_t *mp,
1252 int flags,
1253 int *bypassed)
1255 int error = 0;
1256 int last_error = 0;
1257 uint log_flags = XFS_LOG_FORCE;
1258 xfs_buf_t *bp;
1259 xfs_buf_log_item_t *bip;
1262 * Sync out the log. This ensures that the log is periodically
1263 * flushed even if there is not enough activity to fill it up.
1265 if (flags & SYNC_WAIT)
1266 log_flags |= XFS_LOG_SYNC;
1268 xfs_log_force(mp, (xfs_lsn_t)0, log_flags);
1270 if (flags & (SYNC_ATTR|SYNC_DELWRI)) {
1271 if (flags & SYNC_BDFLUSH)
1272 xfs_finish_reclaim_all(mp, 1);
1273 else
1274 error = xfs_sync_inodes(mp, flags, bypassed);
1278 * Flushing out dirty data above probably generated more
1279 * log activity, so if this isn't vfs_sync() then flush
1280 * the log again.
1282 if (flags & SYNC_DELWRI) {
1283 xfs_log_force(mp, (xfs_lsn_t)0, log_flags);
1286 if (flags & SYNC_FSDATA) {
1288 * If this is vfs_sync() then only sync the superblock
1289 * if we can lock it without sleeping and it is not pinned.
1291 if (flags & SYNC_BDFLUSH) {
1292 bp = xfs_getsb(mp, XFS_BUF_TRYLOCK);
1293 if (bp != NULL) {
1294 bip = XFS_BUF_FSPRIVATE(bp,xfs_buf_log_item_t*);
1295 if ((bip != NULL) &&
1296 xfs_buf_item_dirty(bip)) {
1297 if (!(XFS_BUF_ISPINNED(bp))) {
1298 XFS_BUF_ASYNC(bp);
1299 error = xfs_bwrite(mp, bp);
1300 } else {
1301 xfs_buf_relse(bp);
1303 } else {
1304 xfs_buf_relse(bp);
1307 } else {
1308 bp = xfs_getsb(mp, 0);
1310 * If the buffer is pinned then push on the log so
1311 * we won't get stuck waiting in the write for
1312 * someone, maybe ourselves, to flush the log.
1313 * Even though we just pushed the log above, we
1314 * did not have the superblock buffer locked at
1315 * that point so it can become pinned in between
1316 * there and here.
1318 if (XFS_BUF_ISPINNED(bp))
1319 xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE);
1320 if (flags & SYNC_WAIT)
1321 XFS_BUF_UNASYNC(bp);
1322 else
1323 XFS_BUF_ASYNC(bp);
1324 error = xfs_bwrite(mp, bp);
1326 if (error) {
1327 last_error = error;
1332 * If this is the periodic sync, then kick some entries out of
1333 * the reference cache. This ensures that idle entries are
1334 * eventually kicked out of the cache.
1336 if (flags & SYNC_REFCACHE) {
1337 if (flags & SYNC_WAIT)
1338 xfs_refcache_purge_mp(mp);
1339 else
1340 xfs_refcache_purge_some(mp);
1344 * If asked, update the disk superblock with incore counter values if we
1345 * are using non-persistent counters so that they don't get too far out
1346 * of sync if we crash or get a forced shutdown. We don't want to force
1347 * this to disk, just get a transaction into the iclogs....
1349 if (flags & SYNC_SUPER)
1350 xfs_log_sbcount(mp, 0);
1353 * Now check to see if the log needs a "dummy" transaction.
1356 if (!(flags & SYNC_REMOUNT) && xfs_log_need_covered(mp)) {
1357 xfs_trans_t *tp;
1358 xfs_inode_t *ip;
1361 * Put a dummy transaction in the log to tell
1362 * recovery that all others are OK.
1364 tp = xfs_trans_alloc(mp, XFS_TRANS_DUMMY1);
1365 if ((error = xfs_trans_reserve(tp, 0,
1366 XFS_ICHANGE_LOG_RES(mp),
1367 0, 0, 0))) {
1368 xfs_trans_cancel(tp, 0);
1369 return error;
1372 ip = mp->m_rootip;
1373 xfs_ilock(ip, XFS_ILOCK_EXCL);
1375 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
1376 xfs_trans_ihold(tp, ip);
1377 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
1378 error = xfs_trans_commit(tp, 0);
1379 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1380 xfs_log_force(mp, (xfs_lsn_t)0, log_flags);
1384 * When shutting down, we need to insure that the AIL is pushed
1385 * to disk or the filesystem can appear corrupt from the PROM.
1387 if ((flags & (SYNC_CLOSE|SYNC_WAIT)) == (SYNC_CLOSE|SYNC_WAIT)) {
1388 XFS_bflush(mp->m_ddev_targp);
1389 if (mp->m_rtdev_targp) {
1390 XFS_bflush(mp->m_rtdev_targp);
1394 return XFS_ERROR(last_error);