mpc5200_wdt: __user annotations
[linux-2.6.git] / fs / xfs / xfs_vfsops.c
blob11f5ea29a0388e62abc4a69507171db69214183c
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"
58 STATIC int xfs_sync(bhv_desc_t *, int, cred_t *);
60 int
61 xfs_init(void)
63 extern kmem_zone_t *xfs_bmap_free_item_zone;
64 extern kmem_zone_t *xfs_btree_cur_zone;
65 extern kmem_zone_t *xfs_trans_zone;
66 extern kmem_zone_t *xfs_buf_item_zone;
67 extern kmem_zone_t *xfs_dabuf_zone;
68 #ifdef XFS_DABUF_DEBUG
69 extern lock_t xfs_dabuf_global_lock;
70 spinlock_init(&xfs_dabuf_global_lock, "xfsda");
71 #endif
74 * Initialize all of the zone allocators we use.
76 xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
77 "xfs_bmap_free_item");
78 xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
79 "xfs_btree_cur");
80 xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
81 xfs_da_state_zone =
82 kmem_zone_init(sizeof(xfs_da_state_t), "xfs_da_state");
83 xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
84 xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
85 xfs_acl_zone_init(xfs_acl_zone, "xfs_acl");
86 xfs_mru_cache_init();
87 xfs_filestream_init();
90 * The size of the zone allocated buf log item is the maximum
91 * size possible under XFS. This wastes a little bit of memory,
92 * but it is much faster.
94 xfs_buf_item_zone =
95 kmem_zone_init((sizeof(xfs_buf_log_item_t) +
96 (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
97 NBWORD) * sizeof(int))),
98 "xfs_buf_item");
99 xfs_efd_zone =
100 kmem_zone_init((sizeof(xfs_efd_log_item_t) +
101 ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
102 sizeof(xfs_extent_t))),
103 "xfs_efd_item");
104 xfs_efi_zone =
105 kmem_zone_init((sizeof(xfs_efi_log_item_t) +
106 ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
107 sizeof(xfs_extent_t))),
108 "xfs_efi_item");
111 * These zones warrant special memory allocator hints
113 xfs_inode_zone =
114 kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
115 KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
116 KM_ZONE_SPREAD, NULL);
117 xfs_ili_zone =
118 kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
119 KM_ZONE_SPREAD, NULL);
120 xfs_chashlist_zone =
121 kmem_zone_init_flags(sizeof(xfs_chashlist_t), "xfs_chashlist",
122 KM_ZONE_SPREAD, NULL);
125 * Allocate global trace buffers.
127 #ifdef XFS_ALLOC_TRACE
128 xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_SLEEP);
129 #endif
130 #ifdef XFS_BMAP_TRACE
131 xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_SLEEP);
132 #endif
133 #ifdef XFS_BMBT_TRACE
134 xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_SLEEP);
135 #endif
136 #ifdef XFS_ATTR_TRACE
137 xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_SLEEP);
138 #endif
139 #ifdef XFS_DIR2_TRACE
140 xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_SLEEP);
141 #endif
143 xfs_dir_startup();
145 #if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
146 xfs_error_test_init();
147 #endif /* DEBUG || INDUCE_IO_ERROR */
149 xfs_init_procfs();
150 xfs_sysctl_register();
151 return 0;
154 void
155 xfs_cleanup(void)
157 extern kmem_zone_t *xfs_bmap_free_item_zone;
158 extern kmem_zone_t *xfs_btree_cur_zone;
159 extern kmem_zone_t *xfs_inode_zone;
160 extern kmem_zone_t *xfs_trans_zone;
161 extern kmem_zone_t *xfs_da_state_zone;
162 extern kmem_zone_t *xfs_dabuf_zone;
163 extern kmem_zone_t *xfs_efd_zone;
164 extern kmem_zone_t *xfs_efi_zone;
165 extern kmem_zone_t *xfs_buf_item_zone;
166 extern kmem_zone_t *xfs_chashlist_zone;
168 xfs_cleanup_procfs();
169 xfs_sysctl_unregister();
170 xfs_refcache_destroy();
171 xfs_filestream_uninit();
172 xfs_mru_cache_uninit();
173 xfs_acl_zone_destroy(xfs_acl_zone);
175 #ifdef XFS_DIR2_TRACE
176 ktrace_free(xfs_dir2_trace_buf);
177 #endif
178 #ifdef XFS_ATTR_TRACE
179 ktrace_free(xfs_attr_trace_buf);
180 #endif
181 #ifdef XFS_BMBT_TRACE
182 ktrace_free(xfs_bmbt_trace_buf);
183 #endif
184 #ifdef XFS_BMAP_TRACE
185 ktrace_free(xfs_bmap_trace_buf);
186 #endif
187 #ifdef XFS_ALLOC_TRACE
188 ktrace_free(xfs_alloc_trace_buf);
189 #endif
191 kmem_zone_destroy(xfs_bmap_free_item_zone);
192 kmem_zone_destroy(xfs_btree_cur_zone);
193 kmem_zone_destroy(xfs_inode_zone);
194 kmem_zone_destroy(xfs_trans_zone);
195 kmem_zone_destroy(xfs_da_state_zone);
196 kmem_zone_destroy(xfs_dabuf_zone);
197 kmem_zone_destroy(xfs_buf_item_zone);
198 kmem_zone_destroy(xfs_efd_zone);
199 kmem_zone_destroy(xfs_efi_zone);
200 kmem_zone_destroy(xfs_ifork_zone);
201 kmem_zone_destroy(xfs_ili_zone);
202 kmem_zone_destroy(xfs_chashlist_zone);
206 * xfs_start_flags
208 * This function fills in xfs_mount_t fields based on mount args.
209 * Note: the superblock has _not_ yet been read in.
211 STATIC int
212 xfs_start_flags(
213 struct bhv_vfs *vfs,
214 struct xfs_mount_args *ap,
215 struct xfs_mount *mp)
217 /* Values are in BBs */
218 if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
220 * At this point the superblock has not been read
221 * in, therefore we do not know the block size.
222 * Before the mount call ends we will convert
223 * these to FSBs.
225 mp->m_dalign = ap->sunit;
226 mp->m_swidth = ap->swidth;
229 if (ap->logbufs != -1 &&
230 ap->logbufs != 0 &&
231 (ap->logbufs < XLOG_MIN_ICLOGS ||
232 ap->logbufs > XLOG_MAX_ICLOGS)) {
233 cmn_err(CE_WARN,
234 "XFS: invalid logbufs value: %d [not %d-%d]",
235 ap->logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
236 return XFS_ERROR(EINVAL);
238 mp->m_logbufs = ap->logbufs;
239 if (ap->logbufsize != -1 &&
240 ap->logbufsize != 0 &&
241 ap->logbufsize != 16 * 1024 &&
242 ap->logbufsize != 32 * 1024 &&
243 ap->logbufsize != 64 * 1024 &&
244 ap->logbufsize != 128 * 1024 &&
245 ap->logbufsize != 256 * 1024) {
246 cmn_err(CE_WARN,
247 "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
248 ap->logbufsize);
249 return XFS_ERROR(EINVAL);
251 mp->m_ihsize = ap->ihashsize;
252 mp->m_logbsize = ap->logbufsize;
253 mp->m_fsname_len = strlen(ap->fsname) + 1;
254 mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP);
255 strcpy(mp->m_fsname, ap->fsname);
256 if (ap->rtname[0]) {
257 mp->m_rtname = kmem_alloc(strlen(ap->rtname) + 1, KM_SLEEP);
258 strcpy(mp->m_rtname, ap->rtname);
260 if (ap->logname[0]) {
261 mp->m_logname = kmem_alloc(strlen(ap->logname) + 1, KM_SLEEP);
262 strcpy(mp->m_logname, ap->logname);
265 if (ap->flags & XFSMNT_WSYNC)
266 mp->m_flags |= XFS_MOUNT_WSYNC;
267 #if XFS_BIG_INUMS
268 if (ap->flags & XFSMNT_INO64) {
269 mp->m_flags |= XFS_MOUNT_INO64;
270 mp->m_inoadd = XFS_INO64_OFFSET;
272 #endif
273 if (ap->flags & XFSMNT_RETERR)
274 mp->m_flags |= XFS_MOUNT_RETERR;
275 if (ap->flags & XFSMNT_NOALIGN)
276 mp->m_flags |= XFS_MOUNT_NOALIGN;
277 if (ap->flags & XFSMNT_SWALLOC)
278 mp->m_flags |= XFS_MOUNT_SWALLOC;
279 if (ap->flags & XFSMNT_OSYNCISOSYNC)
280 mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
281 if (ap->flags & XFSMNT_32BITINODES)
282 mp->m_flags |= XFS_MOUNT_32BITINODES;
284 if (ap->flags & XFSMNT_IOSIZE) {
285 if (ap->iosizelog > XFS_MAX_IO_LOG ||
286 ap->iosizelog < XFS_MIN_IO_LOG) {
287 cmn_err(CE_WARN,
288 "XFS: invalid log iosize: %d [not %d-%d]",
289 ap->iosizelog, XFS_MIN_IO_LOG,
290 XFS_MAX_IO_LOG);
291 return XFS_ERROR(EINVAL);
294 mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
295 mp->m_readio_log = mp->m_writeio_log = ap->iosizelog;
298 if (ap->flags & XFSMNT_IHASHSIZE)
299 mp->m_flags |= XFS_MOUNT_IHASHSIZE;
300 if (ap->flags & XFSMNT_IDELETE)
301 mp->m_flags |= XFS_MOUNT_IDELETE;
302 if (ap->flags & XFSMNT_DIRSYNC)
303 mp->m_flags |= XFS_MOUNT_DIRSYNC;
304 if (ap->flags & XFSMNT_ATTR2)
305 mp->m_flags |= XFS_MOUNT_ATTR2;
307 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
308 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
311 * no recovery flag requires a read-only mount
313 if (ap->flags & XFSMNT_NORECOVERY) {
314 if (!(vfs->vfs_flag & VFS_RDONLY)) {
315 cmn_err(CE_WARN,
316 "XFS: tried to mount a FS read-write without recovery!");
317 return XFS_ERROR(EINVAL);
319 mp->m_flags |= XFS_MOUNT_NORECOVERY;
322 if (ap->flags & XFSMNT_NOUUID)
323 mp->m_flags |= XFS_MOUNT_NOUUID;
324 if (ap->flags & XFSMNT_BARRIER)
325 mp->m_flags |= XFS_MOUNT_BARRIER;
326 else
327 mp->m_flags &= ~XFS_MOUNT_BARRIER;
329 if (ap->flags2 & XFSMNT2_FILESTREAMS)
330 mp->m_flags |= XFS_MOUNT_FILESTREAMS;
332 return 0;
336 * This function fills in xfs_mount_t fields based on mount args.
337 * Note: the superblock _has_ now been read in.
339 STATIC int
340 xfs_finish_flags(
341 struct bhv_vfs *vfs,
342 struct xfs_mount_args *ap,
343 struct xfs_mount *mp)
345 int ronly = (vfs->vfs_flag & VFS_RDONLY);
347 /* Fail a mount where the logbuf is smaller then the log stripe */
348 if (XFS_SB_VERSION_HASLOGV2(&mp->m_sb)) {
349 if ((ap->logbufsize <= 0) &&
350 (mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE)) {
351 mp->m_logbsize = mp->m_sb.sb_logsunit;
352 } else if (ap->logbufsize > 0 &&
353 ap->logbufsize < mp->m_sb.sb_logsunit) {
354 cmn_err(CE_WARN,
355 "XFS: logbuf size must be greater than or equal to log stripe size");
356 return XFS_ERROR(EINVAL);
358 } else {
359 /* Fail a mount if the logbuf is larger than 32K */
360 if (ap->logbufsize > XLOG_BIG_RECORD_BSIZE) {
361 cmn_err(CE_WARN,
362 "XFS: logbuf size for version 1 logs must be 16K or 32K");
363 return XFS_ERROR(EINVAL);
367 if (XFS_SB_VERSION_HASATTR2(&mp->m_sb)) {
368 mp->m_flags |= XFS_MOUNT_ATTR2;
372 * prohibit r/w mounts of read-only filesystems
374 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
375 cmn_err(CE_WARN,
376 "XFS: cannot mount a read-only filesystem as read-write");
377 return XFS_ERROR(EROFS);
381 * check for shared mount.
383 if (ap->flags & XFSMNT_SHARED) {
384 if (!XFS_SB_VERSION_HASSHARED(&mp->m_sb))
385 return XFS_ERROR(EINVAL);
388 * For IRIX 6.5, shared mounts must have the shared
389 * version bit set, have the persistent readonly
390 * field set, must be version 0 and can only be mounted
391 * read-only.
393 if (!ronly || !(mp->m_sb.sb_flags & XFS_SBF_READONLY) ||
394 (mp->m_sb.sb_shared_vn != 0))
395 return XFS_ERROR(EINVAL);
397 mp->m_flags |= XFS_MOUNT_SHARED;
400 * Shared XFS V0 can't deal with DMI. Return EINVAL.
402 if (mp->m_sb.sb_shared_vn == 0 && (ap->flags & XFSMNT_DMAPI))
403 return XFS_ERROR(EINVAL);
406 return 0;
410 * xfs_mount
412 * The file system configurations are:
413 * (1) device (partition) with data and internal log
414 * (2) logical volume with data and log subvolumes.
415 * (3) logical volume with data, log, and realtime subvolumes.
417 * We only have to handle opening the log and realtime volumes here if
418 * they are present. The data subvolume has already been opened by
419 * get_sb_bdev() and is stored in vfsp->vfs_super->s_bdev.
421 STATIC int
422 xfs_mount(
423 struct bhv_desc *bhvp,
424 struct xfs_mount_args *args,
425 cred_t *credp)
427 struct bhv_vfs *vfsp = bhvtovfs(bhvp);
428 struct bhv_desc *p;
429 struct xfs_mount *mp = XFS_BHVTOM(bhvp);
430 struct block_device *ddev, *logdev, *rtdev;
431 int flags = 0, error;
433 ddev = vfsp->vfs_super->s_bdev;
434 logdev = rtdev = NULL;
437 * Setup xfs_mount function vectors from available behaviors
439 p = vfs_bhv_lookup(vfsp, VFS_POSITION_DM);
440 mp->m_dm_ops = p ? *(xfs_dmops_t *) vfs_bhv_custom(p) : xfs_dmcore_stub;
441 p = vfs_bhv_lookup(vfsp, VFS_POSITION_QM);
442 mp->m_qm_ops = p ? *(xfs_qmops_t *) vfs_bhv_custom(p) : xfs_qmcore_stub;
443 p = vfs_bhv_lookup(vfsp, VFS_POSITION_IO);
444 mp->m_io_ops = p ? *(xfs_ioops_t *) vfs_bhv_custom(p) : xfs_iocore_xfs;
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 goto error0;
488 mp->m_logdev_targp = (logdev && logdev != ddev) ?
489 xfs_alloc_buftarg(logdev, 1) : mp->m_ddev_targp;
490 if (!mp->m_logdev_targp)
491 goto error0;
494 * Setup flags based on mount(2) options and then the superblock
496 error = xfs_start_flags(vfsp, args, mp);
497 if (error)
498 goto error1;
499 error = xfs_readsb(mp, flags);
500 if (error)
501 goto error1;
502 error = xfs_finish_flags(vfsp, args, mp);
503 if (error)
504 goto error2;
507 * Setup xfs_mount buffer target pointers based on superblock
509 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize,
510 mp->m_sb.sb_sectsize);
511 if (!error && logdev && logdev != ddev) {
512 unsigned int log_sector_size = BBSIZE;
514 if (XFS_SB_VERSION_HASSECTOR(&mp->m_sb))
515 log_sector_size = mp->m_sb.sb_logsectsize;
516 error = xfs_setsize_buftarg(mp->m_logdev_targp,
517 mp->m_sb.sb_blocksize,
518 log_sector_size);
520 if (!error && rtdev)
521 error = xfs_setsize_buftarg(mp->m_rtdev_targp,
522 mp->m_sb.sb_blocksize,
523 mp->m_sb.sb_sectsize);
524 if (error)
525 goto error2;
527 if (mp->m_flags & XFS_MOUNT_BARRIER)
528 xfs_mountfs_check_barriers(mp);
530 if ((error = xfs_filestream_mount(mp)))
531 goto error2;
533 error = XFS_IOINIT(vfsp, args, flags);
534 if (error)
535 goto error2;
537 return 0;
539 error2:
540 if (mp->m_sb_bp)
541 xfs_freesb(mp);
542 error1:
543 xfs_binval(mp->m_ddev_targp);
544 if (logdev && logdev != ddev)
545 xfs_binval(mp->m_logdev_targp);
546 if (rtdev)
547 xfs_binval(mp->m_rtdev_targp);
548 error0:
549 xfs_unmountfs_close(mp, credp);
550 return error;
553 STATIC int
554 xfs_unmount(
555 bhv_desc_t *bdp,
556 int flags,
557 cred_t *credp)
559 bhv_vfs_t *vfsp = bhvtovfs(bdp);
560 xfs_mount_t *mp = XFS_BHVTOM(bdp);
561 xfs_inode_t *rip;
562 bhv_vnode_t *rvp;
563 int unmount_event_wanted = 0;
564 int unmount_event_flags = 0;
565 int xfs_unmountfs_needed = 0;
566 int error;
568 rip = mp->m_rootip;
569 rvp = XFS_ITOV(rip);
571 if (vfsp->vfs_flag & VFS_DMI) {
572 error = XFS_SEND_PREUNMOUNT(mp, vfsp,
573 rvp, DM_RIGHT_NULL, rvp, DM_RIGHT_NULL,
574 NULL, NULL, 0, 0,
575 (mp->m_dmevmask & (1<<DM_EVENT_PREUNMOUNT))?
576 0:DM_FLAGS_UNWANTED);
577 if (error)
578 return XFS_ERROR(error);
579 unmount_event_wanted = 1;
580 unmount_event_flags = (mp->m_dmevmask & (1<<DM_EVENT_UNMOUNT))?
581 0 : DM_FLAGS_UNWANTED;
585 * First blow any referenced inode from this file system
586 * out of the reference cache, and delete the timer.
588 xfs_refcache_purge_mp(mp);
591 * Blow away any referenced inode in the filestreams cache.
592 * This can and will cause log traffic as inodes go inactive
593 * here.
595 xfs_filestream_unmount(mp);
597 XFS_bflush(mp->m_ddev_targp);
598 error = xfs_unmount_flush(mp, 0);
599 if (error)
600 goto out;
602 ASSERT(vn_count(rvp) == 1);
605 * Drop the reference count
607 VN_RELE(rvp);
610 * If we're forcing a shutdown, typically because of a media error,
611 * we want to make sure we invalidate dirty pages that belong to
612 * referenced vnodes as well.
614 if (XFS_FORCED_SHUTDOWN(mp)) {
615 error = xfs_sync(&mp->m_bhv,
616 (SYNC_WAIT | SYNC_CLOSE), credp);
617 ASSERT(error != EFSCORRUPTED);
619 xfs_unmountfs_needed = 1;
621 out:
622 /* Send DMAPI event, if required.
623 * Then do xfs_unmountfs() if needed.
624 * Then return error (or zero).
626 if (unmount_event_wanted) {
627 /* Note: mp structure must still exist for
628 * XFS_SEND_UNMOUNT() call.
630 XFS_SEND_UNMOUNT(mp, vfsp, error == 0 ? rvp : NULL,
631 DM_RIGHT_NULL, 0, error, unmount_event_flags);
633 if (xfs_unmountfs_needed) {
635 * Call common unmount function to flush to disk
636 * and free the super block buffer & mount structures.
638 xfs_unmountfs(mp, credp);
641 return XFS_ERROR(error);
644 STATIC int
645 xfs_quiesce_fs(
646 xfs_mount_t *mp)
648 int count = 0, pincount;
650 xfs_refcache_purge_mp(mp);
651 xfs_flush_buftarg(mp->m_ddev_targp, 0);
652 xfs_finish_reclaim_all(mp, 0);
654 /* This loop must run at least twice.
655 * The first instance of the loop will flush
656 * most meta data but that will generate more
657 * meta data (typically directory updates).
658 * Which then must be flushed and logged before
659 * we can write the unmount record.
661 do {
662 xfs_syncsub(mp, SYNC_INODE_QUIESCE, NULL);
663 pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
664 if (!pincount) {
665 delay(50);
666 count++;
668 } while (count < 2);
670 return 0;
674 * Second stage of a quiesce. The data is already synced, now we have to take
675 * care of the metadata. New transactions are already blocked, so we need to
676 * wait for any remaining transactions to drain out before proceding.
678 STATIC void
679 xfs_attr_quiesce(
680 xfs_mount_t *mp)
682 /* wait for all modifications to complete */
683 while (atomic_read(&mp->m_active_trans) > 0)
684 delay(100);
686 /* flush inodes and push all remaining buffers out to disk */
687 xfs_quiesce_fs(mp);
689 ASSERT_ALWAYS(atomic_read(&mp->m_active_trans) == 0);
691 /* Push the superblock and write an unmount record */
692 xfs_log_sbcount(mp, 1);
693 xfs_log_unmount_write(mp);
694 xfs_unmountfs_writesb(mp);
697 STATIC int
698 xfs_mntupdate(
699 bhv_desc_t *bdp,
700 int *flags,
701 struct xfs_mount_args *args)
703 bhv_vfs_t *vfsp = bhvtovfs(bdp);
704 xfs_mount_t *mp = XFS_BHVTOM(bdp);
706 if (!(*flags & MS_RDONLY)) { /* rw/ro -> rw */
707 if (vfsp->vfs_flag & VFS_RDONLY)
708 vfsp->vfs_flag &= ~VFS_RDONLY;
709 if (args->flags & XFSMNT_BARRIER) {
710 mp->m_flags |= XFS_MOUNT_BARRIER;
711 xfs_mountfs_check_barriers(mp);
712 } else {
713 mp->m_flags &= ~XFS_MOUNT_BARRIER;
715 } else if (!(vfsp->vfs_flag & VFS_RDONLY)) { /* rw -> ro */
716 xfs_filestream_flush(mp);
717 bhv_vfs_sync(vfsp, SYNC_DATA_QUIESCE, NULL);
718 xfs_attr_quiesce(mp);
719 vfsp->vfs_flag |= VFS_RDONLY;
721 return 0;
725 * xfs_unmount_flush implements a set of flush operation on special
726 * inodes, which are needed as a separate set of operations so that
727 * they can be called as part of relocation process.
730 xfs_unmount_flush(
731 xfs_mount_t *mp, /* Mount structure we are getting
732 rid of. */
733 int relocation) /* Called from vfs relocation. */
735 xfs_inode_t *rip = mp->m_rootip;
736 xfs_inode_t *rbmip;
737 xfs_inode_t *rsumip = NULL;
738 bhv_vnode_t *rvp = XFS_ITOV(rip);
739 int error;
741 xfs_ilock(rip, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
742 xfs_iflock(rip);
745 * Flush out the real time inodes.
747 if ((rbmip = mp->m_rbmip) != NULL) {
748 xfs_ilock(rbmip, XFS_ILOCK_EXCL);
749 xfs_iflock(rbmip);
750 error = xfs_iflush(rbmip, XFS_IFLUSH_SYNC);
751 xfs_iunlock(rbmip, XFS_ILOCK_EXCL);
753 if (error == EFSCORRUPTED)
754 goto fscorrupt_out;
756 ASSERT(vn_count(XFS_ITOV(rbmip)) == 1);
758 rsumip = mp->m_rsumip;
759 xfs_ilock(rsumip, XFS_ILOCK_EXCL);
760 xfs_iflock(rsumip);
761 error = xfs_iflush(rsumip, XFS_IFLUSH_SYNC);
762 xfs_iunlock(rsumip, XFS_ILOCK_EXCL);
764 if (error == EFSCORRUPTED)
765 goto fscorrupt_out;
767 ASSERT(vn_count(XFS_ITOV(rsumip)) == 1);
771 * Synchronously flush root inode to disk
773 error = xfs_iflush(rip, XFS_IFLUSH_SYNC);
774 if (error == EFSCORRUPTED)
775 goto fscorrupt_out2;
777 if (vn_count(rvp) != 1 && !relocation) {
778 xfs_iunlock(rip, XFS_ILOCK_EXCL);
779 return XFS_ERROR(EBUSY);
783 * Release dquot that rootinode, rbmino and rsumino might be holding,
784 * flush and purge the quota inodes.
786 error = XFS_QM_UNMOUNT(mp);
787 if (error == EFSCORRUPTED)
788 goto fscorrupt_out2;
790 if (rbmip) {
791 VN_RELE(XFS_ITOV(rbmip));
792 VN_RELE(XFS_ITOV(rsumip));
795 xfs_iunlock(rip, XFS_ILOCK_EXCL);
796 return 0;
798 fscorrupt_out:
799 xfs_ifunlock(rip);
801 fscorrupt_out2:
802 xfs_iunlock(rip, XFS_ILOCK_EXCL);
804 return XFS_ERROR(EFSCORRUPTED);
808 * xfs_root extracts the root vnode from a vfs.
810 * vfsp -- the vfs struct for the desired file system
811 * vpp -- address of the caller's vnode pointer which should be
812 * set to the desired fs root vnode
814 STATIC int
815 xfs_root(
816 bhv_desc_t *bdp,
817 bhv_vnode_t **vpp)
819 bhv_vnode_t *vp;
821 vp = XFS_ITOV((XFS_BHVTOM(bdp))->m_rootip);
822 VN_HOLD(vp);
823 *vpp = vp;
824 return 0;
828 * xfs_statvfs
830 * Fill in the statvfs structure for the given file system. We use
831 * the superblock lock in the mount structure to ensure a consistent
832 * snapshot of the counters returned.
834 STATIC int
835 xfs_statvfs(
836 bhv_desc_t *bdp,
837 bhv_statvfs_t *statp,
838 bhv_vnode_t *vp)
840 __uint64_t fakeinos;
841 xfs_extlen_t lsize;
842 xfs_mount_t *mp;
843 xfs_sb_t *sbp;
844 unsigned long s;
846 mp = XFS_BHVTOM(bdp);
847 sbp = &(mp->m_sb);
849 statp->f_type = XFS_SB_MAGIC;
851 xfs_icsb_sync_counters_flags(mp, XFS_ICSB_LAZY_COUNT);
852 s = XFS_SB_LOCK(mp);
853 statp->f_bsize = sbp->sb_blocksize;
854 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
855 statp->f_blocks = sbp->sb_dblocks - lsize;
856 statp->f_bfree = statp->f_bavail =
857 sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
858 fakeinos = statp->f_bfree << sbp->sb_inopblog;
859 #if XFS_BIG_INUMS
860 fakeinos += mp->m_inoadd;
861 #endif
862 statp->f_files =
863 MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
864 if (mp->m_maxicount)
865 #if XFS_BIG_INUMS
866 if (!mp->m_inoadd)
867 #endif
868 statp->f_files = min_t(typeof(statp->f_files),
869 statp->f_files,
870 mp->m_maxicount);
871 statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
872 XFS_SB_UNLOCK(mp, s);
874 xfs_statvfs_fsid(statp, mp);
875 statp->f_namelen = MAXNAMELEN - 1;
877 return 0;
882 * xfs_sync flushes any pending I/O to file system vfsp.
884 * This routine is called by vfs_sync() to make sure that things make it
885 * out to disk eventually, on sync() system calls to flush out everything,
886 * and when the file system is unmounted. For the vfs_sync() case, all
887 * we really need to do is sync out the log to make all of our meta-data
888 * updates permanent (except for timestamps). For calls from pflushd(),
889 * dirty pages are kept moving by calling pdflush() on the inodes
890 * containing them. We also flush the inodes that we can lock without
891 * sleeping and the superblock if we can lock it without sleeping from
892 * vfs_sync() so that items at the tail of the log are always moving out.
894 * Flags:
895 * SYNC_BDFLUSH - We're being called from vfs_sync() so we don't want
896 * to sleep if we can help it. All we really need
897 * to do is ensure that the log is synced at least
898 * periodically. We also push the inodes and
899 * superblock if we can lock them without sleeping
900 * and they are not pinned.
901 * SYNC_ATTR - We need to flush the inodes. If SYNC_BDFLUSH is not
902 * set, then we really want to lock each inode and flush
903 * it.
904 * SYNC_WAIT - All the flushes that take place in this call should
905 * be synchronous.
906 * SYNC_DELWRI - This tells us to push dirty pages associated with
907 * inodes. SYNC_WAIT and SYNC_BDFLUSH are used to
908 * determine if they should be flushed sync, async, or
909 * delwri.
910 * SYNC_CLOSE - This flag is passed when the system is being
911 * unmounted. We should sync and invalidate everything.
912 * SYNC_FSDATA - This indicates that the caller would like to make
913 * sure the superblock is safe on disk. We can ensure
914 * this by simply making sure the log gets flushed
915 * if SYNC_BDFLUSH is set, and by actually writing it
916 * out otherwise.
917 * SYNC_IOWAIT - The caller wants us to wait for all data I/O to complete
918 * before we return (including direct I/O). Forms the drain
919 * side of the write barrier needed to safely quiesce the
920 * filesystem.
923 /*ARGSUSED*/
924 STATIC int
925 xfs_sync(
926 bhv_desc_t *bdp,
927 int flags,
928 cred_t *credp)
930 xfs_mount_t *mp = XFS_BHVTOM(bdp);
932 if (flags & SYNC_IOWAIT)
933 xfs_filestream_flush(mp);
935 return xfs_syncsub(mp, flags, NULL);
939 * xfs sync routine for internal use
941 * This routine supports all of the flags defined for the generic vfs_sync
942 * interface as explained above under xfs_sync.
946 xfs_sync_inodes(
947 xfs_mount_t *mp,
948 int flags,
949 int *bypassed)
951 xfs_inode_t *ip = NULL;
952 xfs_inode_t *ip_next;
953 xfs_buf_t *bp;
954 bhv_vnode_t *vp = NULL;
955 int error;
956 int last_error;
957 uint64_t fflag;
958 uint lock_flags;
959 uint base_lock_flags;
960 boolean_t mount_locked;
961 boolean_t vnode_refed;
962 int preempt;
963 xfs_dinode_t *dip;
964 xfs_iptr_t *ipointer;
965 #ifdef DEBUG
966 boolean_t ipointer_in = B_FALSE;
968 #define IPOINTER_SET ipointer_in = B_TRUE
969 #define IPOINTER_CLR ipointer_in = B_FALSE
970 #else
971 #define IPOINTER_SET
972 #define IPOINTER_CLR
973 #endif
976 /* Insert a marker record into the inode list after inode ip. The list
977 * must be locked when this is called. After the call the list will no
978 * longer be locked.
980 #define IPOINTER_INSERT(ip, mp) { \
981 ASSERT(ipointer_in == B_FALSE); \
982 ipointer->ip_mnext = ip->i_mnext; \
983 ipointer->ip_mprev = ip; \
984 ip->i_mnext = (xfs_inode_t *)ipointer; \
985 ipointer->ip_mnext->i_mprev = (xfs_inode_t *)ipointer; \
986 preempt = 0; \
987 XFS_MOUNT_IUNLOCK(mp); \
988 mount_locked = B_FALSE; \
989 IPOINTER_SET; \
992 /* Remove the marker from the inode list. If the marker was the only item
993 * in the list then there are no remaining inodes and we should zero out
994 * the whole list. If we are the current head of the list then move the head
995 * past us.
997 #define IPOINTER_REMOVE(ip, mp) { \
998 ASSERT(ipointer_in == B_TRUE); \
999 if (ipointer->ip_mnext != (xfs_inode_t *)ipointer) { \
1000 ip = ipointer->ip_mnext; \
1001 ip->i_mprev = ipointer->ip_mprev; \
1002 ipointer->ip_mprev->i_mnext = ip; \
1003 if (mp->m_inodes == (xfs_inode_t *)ipointer) { \
1004 mp->m_inodes = ip; \
1006 } else { \
1007 ASSERT(mp->m_inodes == (xfs_inode_t *)ipointer); \
1008 mp->m_inodes = NULL; \
1009 ip = NULL; \
1011 IPOINTER_CLR; \
1014 #define XFS_PREEMPT_MASK 0x7f
1016 if (bypassed)
1017 *bypassed = 0;
1018 if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY)
1019 return 0;
1020 error = 0;
1021 last_error = 0;
1022 preempt = 0;
1024 /* Allocate a reference marker */
1025 ipointer = (xfs_iptr_t *)kmem_zalloc(sizeof(xfs_iptr_t), KM_SLEEP);
1027 fflag = XFS_B_ASYNC; /* default is don't wait */
1028 if (flags & (SYNC_BDFLUSH | SYNC_DELWRI))
1029 fflag = XFS_B_DELWRI;
1030 if (flags & SYNC_WAIT)
1031 fflag = 0; /* synchronous overrides all */
1033 base_lock_flags = XFS_ILOCK_SHARED;
1034 if (flags & (SYNC_DELWRI | SYNC_CLOSE)) {
1036 * We need the I/O lock if we're going to call any of
1037 * the flush/inval routines.
1039 base_lock_flags |= XFS_IOLOCK_SHARED;
1042 XFS_MOUNT_ILOCK(mp);
1044 ip = mp->m_inodes;
1046 mount_locked = B_TRUE;
1047 vnode_refed = B_FALSE;
1049 IPOINTER_CLR;
1051 do {
1052 ASSERT(ipointer_in == B_FALSE);
1053 ASSERT(vnode_refed == B_FALSE);
1055 lock_flags = base_lock_flags;
1058 * There were no inodes in the list, just break out
1059 * of the loop.
1061 if (ip == NULL) {
1062 break;
1066 * We found another sync thread marker - skip it
1068 if (ip->i_mount == NULL) {
1069 ip = ip->i_mnext;
1070 continue;
1073 vp = XFS_ITOV_NULL(ip);
1076 * If the vnode is gone then this is being torn down,
1077 * call reclaim if it is flushed, else let regular flush
1078 * code deal with it later in the loop.
1081 if (vp == NULL) {
1082 /* Skip ones already in reclaim */
1083 if (ip->i_flags & XFS_IRECLAIM) {
1084 ip = ip->i_mnext;
1085 continue;
1087 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) {
1088 ip = ip->i_mnext;
1089 } else if ((xfs_ipincount(ip) == 0) &&
1090 xfs_iflock_nowait(ip)) {
1091 IPOINTER_INSERT(ip, mp);
1093 xfs_finish_reclaim(ip, 1,
1094 XFS_IFLUSH_DELWRI_ELSE_ASYNC);
1096 XFS_MOUNT_ILOCK(mp);
1097 mount_locked = B_TRUE;
1098 IPOINTER_REMOVE(ip, mp);
1099 } else {
1100 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1101 ip = ip->i_mnext;
1103 continue;
1106 if (VN_BAD(vp)) {
1107 ip = ip->i_mnext;
1108 continue;
1111 if (XFS_FORCED_SHUTDOWN(mp) && !(flags & SYNC_CLOSE)) {
1112 XFS_MOUNT_IUNLOCK(mp);
1113 kmem_free(ipointer, sizeof(xfs_iptr_t));
1114 return 0;
1118 * If this is just vfs_sync() or pflushd() calling
1119 * then we can skip inodes for which it looks like
1120 * there is nothing to do. Since we don't have the
1121 * inode locked this is racy, but these are periodic
1122 * calls so it doesn't matter. For the others we want
1123 * to know for sure, so we at least try to lock them.
1125 if (flags & SYNC_BDFLUSH) {
1126 if (((ip->i_itemp == NULL) ||
1127 !(ip->i_itemp->ili_format.ilf_fields &
1128 XFS_ILOG_ALL)) &&
1129 (ip->i_update_core == 0)) {
1130 ip = ip->i_mnext;
1131 continue;
1136 * Try to lock without sleeping. We're out of order with
1137 * the inode list lock here, so if we fail we need to drop
1138 * the mount lock and try again. If we're called from
1139 * bdflush() here, then don't bother.
1141 * The inode lock here actually coordinates with the
1142 * almost spurious inode lock in xfs_ireclaim() to prevent
1143 * the vnode we handle here without a reference from
1144 * being freed while we reference it. If we lock the inode
1145 * while it's on the mount list here, then the spurious inode
1146 * lock in xfs_ireclaim() after the inode is pulled from
1147 * the mount list will sleep until we release it here.
1148 * This keeps the vnode from being freed while we reference
1149 * it.
1151 if (xfs_ilock_nowait(ip, lock_flags) == 0) {
1152 if ((flags & SYNC_BDFLUSH) || (vp == NULL)) {
1153 ip = ip->i_mnext;
1154 continue;
1157 vp = vn_grab(vp);
1158 if (vp == NULL) {
1159 ip = ip->i_mnext;
1160 continue;
1163 IPOINTER_INSERT(ip, mp);
1164 xfs_ilock(ip, lock_flags);
1166 ASSERT(vp == XFS_ITOV(ip));
1167 ASSERT(ip->i_mount == mp);
1169 vnode_refed = B_TRUE;
1172 /* From here on in the loop we may have a marker record
1173 * in the inode list.
1177 * If we have to flush data or wait for I/O completion
1178 * we need to drop the ilock that we currently hold.
1179 * If we need to drop the lock, insert a marker if we
1180 * have not already done so.
1182 if ((flags & (SYNC_CLOSE|SYNC_IOWAIT)) ||
1183 ((flags & SYNC_DELWRI) && VN_DIRTY(vp))) {
1184 if (mount_locked) {
1185 IPOINTER_INSERT(ip, mp);
1187 xfs_iunlock(ip, XFS_ILOCK_SHARED);
1189 if (flags & SYNC_CLOSE) {
1190 /* Shutdown case. Flush and invalidate. */
1191 if (XFS_FORCED_SHUTDOWN(mp))
1192 bhv_vop_toss_pages(vp, 0, -1, FI_REMAPF);
1193 else
1194 error = bhv_vop_flushinval_pages(vp, 0,
1195 -1, FI_REMAPF);
1196 } else if ((flags & SYNC_DELWRI) && VN_DIRTY(vp)) {
1197 error = bhv_vop_flush_pages(vp, (xfs_off_t)0,
1198 -1, fflag, FI_NONE);
1202 * When freezing, we need to wait ensure all I/O (including direct
1203 * I/O) is complete to ensure no further data modification can take
1204 * place after this point
1206 if (flags & SYNC_IOWAIT)
1207 vn_iowait(vp);
1209 xfs_ilock(ip, XFS_ILOCK_SHARED);
1212 if (flags & SYNC_BDFLUSH) {
1213 if ((flags & SYNC_ATTR) &&
1214 ((ip->i_update_core) ||
1215 ((ip->i_itemp != NULL) &&
1216 (ip->i_itemp->ili_format.ilf_fields != 0)))) {
1218 /* Insert marker and drop lock if not already
1219 * done.
1221 if (mount_locked) {
1222 IPOINTER_INSERT(ip, mp);
1226 * We don't want the periodic flushing of the
1227 * inodes by vfs_sync() to interfere with
1228 * I/O to the file, especially read I/O
1229 * where it is only the access time stamp
1230 * that is being flushed out. To prevent
1231 * long periods where we have both inode
1232 * locks held shared here while reading the
1233 * inode's buffer in from disk, we drop the
1234 * inode lock while reading in the inode
1235 * buffer. We have to release the buffer
1236 * and reacquire the inode lock so that they
1237 * are acquired in the proper order (inode
1238 * locks first). The buffer will go at the
1239 * end of the lru chain, though, so we can
1240 * expect it to still be there when we go
1241 * for it again in xfs_iflush().
1243 if ((xfs_ipincount(ip) == 0) &&
1244 xfs_iflock_nowait(ip)) {
1246 xfs_ifunlock(ip);
1247 xfs_iunlock(ip, XFS_ILOCK_SHARED);
1249 error = xfs_itobp(mp, NULL, ip,
1250 &dip, &bp, 0, 0);
1251 if (!error) {
1252 xfs_buf_relse(bp);
1253 } else {
1254 /* Bailing out, remove the
1255 * marker and free it.
1257 XFS_MOUNT_ILOCK(mp);
1258 IPOINTER_REMOVE(ip, mp);
1259 XFS_MOUNT_IUNLOCK(mp);
1261 ASSERT(!(lock_flags &
1262 XFS_IOLOCK_SHARED));
1264 kmem_free(ipointer,
1265 sizeof(xfs_iptr_t));
1266 return (0);
1270 * Since we dropped the inode lock,
1271 * the inode may have been reclaimed.
1272 * Therefore, we reacquire the mount
1273 * lock and check to see if we were the
1274 * inode reclaimed. If this happened
1275 * then the ipointer marker will no
1276 * longer point back at us. In this
1277 * case, move ip along to the inode
1278 * after the marker, remove the marker
1279 * and continue.
1281 XFS_MOUNT_ILOCK(mp);
1282 mount_locked = B_TRUE;
1284 if (ip != ipointer->ip_mprev) {
1285 IPOINTER_REMOVE(ip, mp);
1287 ASSERT(!vnode_refed);
1288 ASSERT(!(lock_flags &
1289 XFS_IOLOCK_SHARED));
1290 continue;
1293 ASSERT(ip->i_mount == mp);
1295 if (xfs_ilock_nowait(ip,
1296 XFS_ILOCK_SHARED) == 0) {
1297 ASSERT(ip->i_mount == mp);
1299 * We failed to reacquire
1300 * the inode lock without
1301 * sleeping, so just skip
1302 * the inode for now. We
1303 * clear the ILOCK bit from
1304 * the lock_flags so that we
1305 * won't try to drop a lock
1306 * we don't hold below.
1308 lock_flags &= ~XFS_ILOCK_SHARED;
1309 IPOINTER_REMOVE(ip_next, mp);
1310 } else if ((xfs_ipincount(ip) == 0) &&
1311 xfs_iflock_nowait(ip)) {
1312 ASSERT(ip->i_mount == mp);
1314 * Since this is vfs_sync()
1315 * calling we only flush the
1316 * inode out if we can lock
1317 * it without sleeping and
1318 * it is not pinned. Drop
1319 * the mount lock here so
1320 * that we don't hold it for
1321 * too long. We already have
1322 * a marker in the list here.
1324 XFS_MOUNT_IUNLOCK(mp);
1325 mount_locked = B_FALSE;
1326 error = xfs_iflush(ip,
1327 XFS_IFLUSH_DELWRI);
1328 } else {
1329 ASSERT(ip->i_mount == mp);
1330 IPOINTER_REMOVE(ip_next, mp);
1336 } else {
1337 if ((flags & SYNC_ATTR) &&
1338 ((ip->i_update_core) ||
1339 ((ip->i_itemp != NULL) &&
1340 (ip->i_itemp->ili_format.ilf_fields != 0)))) {
1341 if (mount_locked) {
1342 IPOINTER_INSERT(ip, mp);
1345 if (flags & SYNC_WAIT) {
1346 xfs_iflock(ip);
1347 error = xfs_iflush(ip,
1348 XFS_IFLUSH_SYNC);
1349 } else {
1351 * If we can't acquire the flush
1352 * lock, then the inode is already
1353 * being flushed so don't bother
1354 * waiting. If we can lock it then
1355 * do a delwri flush so we can
1356 * combine multiple inode flushes
1357 * in each disk write.
1359 if (xfs_iflock_nowait(ip)) {
1360 error = xfs_iflush(ip,
1361 XFS_IFLUSH_DELWRI);
1363 else if (bypassed)
1364 (*bypassed)++;
1369 if (lock_flags != 0) {
1370 xfs_iunlock(ip, lock_flags);
1373 if (vnode_refed) {
1375 * If we had to take a reference on the vnode
1376 * above, then wait until after we've unlocked
1377 * the inode to release the reference. This is
1378 * because we can be already holding the inode
1379 * lock when VN_RELE() calls xfs_inactive().
1381 * Make sure to drop the mount lock before calling
1382 * VN_RELE() so that we don't trip over ourselves if
1383 * we have to go for the mount lock again in the
1384 * inactive code.
1386 if (mount_locked) {
1387 IPOINTER_INSERT(ip, mp);
1390 VN_RELE(vp);
1392 vnode_refed = B_FALSE;
1395 if (error) {
1396 last_error = error;
1400 * bail out if the filesystem is corrupted.
1402 if (error == EFSCORRUPTED) {
1403 if (!mount_locked) {
1404 XFS_MOUNT_ILOCK(mp);
1405 IPOINTER_REMOVE(ip, mp);
1407 XFS_MOUNT_IUNLOCK(mp);
1408 ASSERT(ipointer_in == B_FALSE);
1409 kmem_free(ipointer, sizeof(xfs_iptr_t));
1410 return XFS_ERROR(error);
1413 /* Let other threads have a chance at the mount lock
1414 * if we have looped many times without dropping the
1415 * lock.
1417 if ((++preempt & XFS_PREEMPT_MASK) == 0) {
1418 if (mount_locked) {
1419 IPOINTER_INSERT(ip, mp);
1423 if (mount_locked == B_FALSE) {
1424 XFS_MOUNT_ILOCK(mp);
1425 mount_locked = B_TRUE;
1426 IPOINTER_REMOVE(ip, mp);
1427 continue;
1430 ASSERT(ipointer_in == B_FALSE);
1431 ip = ip->i_mnext;
1433 } while (ip != mp->m_inodes);
1435 XFS_MOUNT_IUNLOCK(mp);
1437 ASSERT(ipointer_in == B_FALSE);
1439 kmem_free(ipointer, sizeof(xfs_iptr_t));
1440 return XFS_ERROR(last_error);
1444 * xfs sync routine for internal use
1446 * This routine supports all of the flags defined for the generic vfs_sync
1447 * interface as explained above under xfs_sync.
1451 xfs_syncsub(
1452 xfs_mount_t *mp,
1453 int flags,
1454 int *bypassed)
1456 int error = 0;
1457 int last_error = 0;
1458 uint log_flags = XFS_LOG_FORCE;
1459 xfs_buf_t *bp;
1460 xfs_buf_log_item_t *bip;
1463 * Sync out the log. This ensures that the log is periodically
1464 * flushed even if there is not enough activity to fill it up.
1466 if (flags & SYNC_WAIT)
1467 log_flags |= XFS_LOG_SYNC;
1469 xfs_log_force(mp, (xfs_lsn_t)0, log_flags);
1471 if (flags & (SYNC_ATTR|SYNC_DELWRI)) {
1472 if (flags & SYNC_BDFLUSH)
1473 xfs_finish_reclaim_all(mp, 1);
1474 else
1475 error = xfs_sync_inodes(mp, flags, bypassed);
1479 * Flushing out dirty data above probably generated more
1480 * log activity, so if this isn't vfs_sync() then flush
1481 * the log again.
1483 if (flags & SYNC_DELWRI) {
1484 xfs_log_force(mp, (xfs_lsn_t)0, log_flags);
1487 if (flags & SYNC_FSDATA) {
1489 * If this is vfs_sync() then only sync the superblock
1490 * if we can lock it without sleeping and it is not pinned.
1492 if (flags & SYNC_BDFLUSH) {
1493 bp = xfs_getsb(mp, XFS_BUF_TRYLOCK);
1494 if (bp != NULL) {
1495 bip = XFS_BUF_FSPRIVATE(bp,xfs_buf_log_item_t*);
1496 if ((bip != NULL) &&
1497 xfs_buf_item_dirty(bip)) {
1498 if (!(XFS_BUF_ISPINNED(bp))) {
1499 XFS_BUF_ASYNC(bp);
1500 error = xfs_bwrite(mp, bp);
1501 } else {
1502 xfs_buf_relse(bp);
1504 } else {
1505 xfs_buf_relse(bp);
1508 } else {
1509 bp = xfs_getsb(mp, 0);
1511 * If the buffer is pinned then push on the log so
1512 * we won't get stuck waiting in the write for
1513 * someone, maybe ourselves, to flush the log.
1514 * Even though we just pushed the log above, we
1515 * did not have the superblock buffer locked at
1516 * that point so it can become pinned in between
1517 * there and here.
1519 if (XFS_BUF_ISPINNED(bp))
1520 xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE);
1521 if (flags & SYNC_WAIT)
1522 XFS_BUF_UNASYNC(bp);
1523 else
1524 XFS_BUF_ASYNC(bp);
1525 error = xfs_bwrite(mp, bp);
1527 if (error) {
1528 last_error = error;
1533 * If this is the periodic sync, then kick some entries out of
1534 * the reference cache. This ensures that idle entries are
1535 * eventually kicked out of the cache.
1537 if (flags & SYNC_REFCACHE) {
1538 if (flags & SYNC_WAIT)
1539 xfs_refcache_purge_mp(mp);
1540 else
1541 xfs_refcache_purge_some(mp);
1545 * If asked, update the disk superblock with incore counter values if we
1546 * are using non-persistent counters so that they don't get too far out
1547 * of sync if we crash or get a forced shutdown. We don't want to force
1548 * this to disk, just get a transaction into the iclogs....
1550 if (flags & SYNC_SUPER)
1551 xfs_log_sbcount(mp, 0);
1554 * Now check to see if the log needs a "dummy" transaction.
1557 if (!(flags & SYNC_REMOUNT) && xfs_log_need_covered(mp)) {
1558 xfs_trans_t *tp;
1559 xfs_inode_t *ip;
1562 * Put a dummy transaction in the log to tell
1563 * recovery that all others are OK.
1565 tp = xfs_trans_alloc(mp, XFS_TRANS_DUMMY1);
1566 if ((error = xfs_trans_reserve(tp, 0,
1567 XFS_ICHANGE_LOG_RES(mp),
1568 0, 0, 0))) {
1569 xfs_trans_cancel(tp, 0);
1570 return error;
1573 ip = mp->m_rootip;
1574 xfs_ilock(ip, XFS_ILOCK_EXCL);
1576 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
1577 xfs_trans_ihold(tp, ip);
1578 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
1579 error = xfs_trans_commit(tp, 0);
1580 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1581 xfs_log_force(mp, (xfs_lsn_t)0, log_flags);
1585 * When shutting down, we need to insure that the AIL is pushed
1586 * to disk or the filesystem can appear corrupt from the PROM.
1588 if ((flags & (SYNC_CLOSE|SYNC_WAIT)) == (SYNC_CLOSE|SYNC_WAIT)) {
1589 XFS_bflush(mp->m_ddev_targp);
1590 if (mp->m_rtdev_targp) {
1591 XFS_bflush(mp->m_rtdev_targp);
1595 return XFS_ERROR(last_error);
1599 * xfs_vget - called by DMAPI and NFSD to get vnode from file handle
1601 STATIC int
1602 xfs_vget(
1603 bhv_desc_t *bdp,
1604 bhv_vnode_t **vpp,
1605 fid_t *fidp)
1607 xfs_mount_t *mp = XFS_BHVTOM(bdp);
1608 xfs_fid_t *xfid = (struct xfs_fid *)fidp;
1609 xfs_inode_t *ip;
1610 int error;
1611 xfs_ino_t ino;
1612 unsigned int igen;
1615 * Invalid. Since handles can be created in user space and passed in
1616 * via gethandle(), this is not cause for a panic.
1618 if (xfid->xfs_fid_len != sizeof(*xfid) - sizeof(xfid->xfs_fid_len))
1619 return XFS_ERROR(EINVAL);
1621 ino = xfid->xfs_fid_ino;
1622 igen = xfid->xfs_fid_gen;
1625 * NFS can sometimes send requests for ino 0. Fail them gracefully.
1627 if (ino == 0)
1628 return XFS_ERROR(ESTALE);
1630 error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0);
1631 if (error) {
1632 *vpp = NULL;
1633 return error;
1636 if (ip == NULL) {
1637 *vpp = NULL;
1638 return XFS_ERROR(EIO);
1641 if (ip->i_d.di_mode == 0 || ip->i_d.di_gen != igen) {
1642 xfs_iput_new(ip, XFS_ILOCK_SHARED);
1643 *vpp = NULL;
1644 return XFS_ERROR(ENOENT);
1647 *vpp = XFS_ITOV(ip);
1648 xfs_iunlock(ip, XFS_ILOCK_SHARED);
1649 return 0;
1653 #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */
1654 #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */
1655 #define MNTOPT_LOGDEV "logdev" /* log device */
1656 #define MNTOPT_RTDEV "rtdev" /* realtime I/O device */
1657 #define MNTOPT_BIOSIZE "biosize" /* log2 of preferred buffered io size */
1658 #define MNTOPT_WSYNC "wsync" /* safe-mode nfs compatible mount */
1659 #define MNTOPT_INO64 "ino64" /* force inodes into 64-bit range */
1660 #define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */
1661 #define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */
1662 #define MNTOPT_SUNIT "sunit" /* data volume stripe unit */
1663 #define MNTOPT_SWIDTH "swidth" /* data volume stripe width */
1664 #define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */
1665 #define MNTOPT_MTPT "mtpt" /* filesystem mount point */
1666 #define MNTOPT_GRPID "grpid" /* group-ID from parent directory */
1667 #define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */
1668 #define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */
1669 #define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */
1670 #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */
1671 #define MNTOPT_IHASHSIZE "ihashsize" /* size of inode hash table */
1672 #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */
1673 #define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and
1674 * unwritten extent conversion */
1675 #define MNTOPT_NOBARRIER "nobarrier" /* .. disable */
1676 #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */
1677 #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */
1678 #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */
1679 #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */
1680 #define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */
1681 #define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes
1682 * in stat(). */
1683 #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
1684 #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
1685 #define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */
1687 STATIC unsigned long
1688 suffix_strtoul(char *s, char **endp, unsigned int base)
1690 int last, shift_left_factor = 0;
1691 char *value = s;
1693 last = strlen(value) - 1;
1694 if (value[last] == 'K' || value[last] == 'k') {
1695 shift_left_factor = 10;
1696 value[last] = '\0';
1698 if (value[last] == 'M' || value[last] == 'm') {
1699 shift_left_factor = 20;
1700 value[last] = '\0';
1702 if (value[last] == 'G' || value[last] == 'g') {
1703 shift_left_factor = 30;
1704 value[last] = '\0';
1707 return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
1710 STATIC int
1711 xfs_parseargs(
1712 struct bhv_desc *bhv,
1713 char *options,
1714 struct xfs_mount_args *args,
1715 int update)
1717 bhv_vfs_t *vfsp = bhvtovfs(bhv);
1718 char *this_char, *value, *eov;
1719 int dsunit, dswidth, vol_dsunit, vol_dswidth;
1720 int iosize;
1722 args->flags |= XFSMNT_IDELETE;
1723 args->flags |= XFSMNT_BARRIER;
1724 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
1726 if (!options)
1727 goto done;
1729 iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0;
1731 while ((this_char = strsep(&options, ",")) != NULL) {
1732 if (!*this_char)
1733 continue;
1734 if ((value = strchr(this_char, '=')) != NULL)
1735 *value++ = 0;
1737 if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
1738 if (!value || !*value) {
1739 cmn_err(CE_WARN,
1740 "XFS: %s option requires an argument",
1741 this_char);
1742 return EINVAL;
1744 args->logbufs = simple_strtoul(value, &eov, 10);
1745 } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
1746 if (!value || !*value) {
1747 cmn_err(CE_WARN,
1748 "XFS: %s option requires an argument",
1749 this_char);
1750 return EINVAL;
1752 args->logbufsize = suffix_strtoul(value, &eov, 10);
1753 } else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
1754 if (!value || !*value) {
1755 cmn_err(CE_WARN,
1756 "XFS: %s option requires an argument",
1757 this_char);
1758 return EINVAL;
1760 strncpy(args->logname, value, MAXNAMELEN);
1761 } else if (!strcmp(this_char, MNTOPT_MTPT)) {
1762 if (!value || !*value) {
1763 cmn_err(CE_WARN,
1764 "XFS: %s option requires an argument",
1765 this_char);
1766 return EINVAL;
1768 strncpy(args->mtpt, value, MAXNAMELEN);
1769 } else if (!strcmp(this_char, MNTOPT_RTDEV)) {
1770 if (!value || !*value) {
1771 cmn_err(CE_WARN,
1772 "XFS: %s option requires an argument",
1773 this_char);
1774 return EINVAL;
1776 strncpy(args->rtname, value, MAXNAMELEN);
1777 } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
1778 if (!value || !*value) {
1779 cmn_err(CE_WARN,
1780 "XFS: %s option requires an argument",
1781 this_char);
1782 return EINVAL;
1784 iosize = simple_strtoul(value, &eov, 10);
1785 args->flags |= XFSMNT_IOSIZE;
1786 args->iosizelog = (uint8_t) iosize;
1787 } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
1788 if (!value || !*value) {
1789 cmn_err(CE_WARN,
1790 "XFS: %s option requires an argument",
1791 this_char);
1792 return EINVAL;
1794 iosize = suffix_strtoul(value, &eov, 10);
1795 args->flags |= XFSMNT_IOSIZE;
1796 args->iosizelog = ffs(iosize) - 1;
1797 } else if (!strcmp(this_char, MNTOPT_IHASHSIZE)) {
1798 if (!value || !*value) {
1799 cmn_err(CE_WARN,
1800 "XFS: %s option requires an argument",
1801 this_char);
1802 return EINVAL;
1804 args->flags |= XFSMNT_IHASHSIZE;
1805 args->ihashsize = simple_strtoul(value, &eov, 10);
1806 } else if (!strcmp(this_char, MNTOPT_GRPID) ||
1807 !strcmp(this_char, MNTOPT_BSDGROUPS)) {
1808 vfsp->vfs_flag |= VFS_GRPID;
1809 } else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
1810 !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
1811 vfsp->vfs_flag &= ~VFS_GRPID;
1812 } else if (!strcmp(this_char, MNTOPT_WSYNC)) {
1813 args->flags |= XFSMNT_WSYNC;
1814 } else if (!strcmp(this_char, MNTOPT_OSYNCISOSYNC)) {
1815 args->flags |= XFSMNT_OSYNCISOSYNC;
1816 } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
1817 args->flags |= XFSMNT_NORECOVERY;
1818 } else if (!strcmp(this_char, MNTOPT_INO64)) {
1819 args->flags |= XFSMNT_INO64;
1820 #if !XFS_BIG_INUMS
1821 cmn_err(CE_WARN,
1822 "XFS: %s option not allowed on this system",
1823 this_char);
1824 return EINVAL;
1825 #endif
1826 } else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
1827 args->flags |= XFSMNT_NOALIGN;
1828 } else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
1829 args->flags |= XFSMNT_SWALLOC;
1830 } else if (!strcmp(this_char, MNTOPT_SUNIT)) {
1831 if (!value || !*value) {
1832 cmn_err(CE_WARN,
1833 "XFS: %s option requires an argument",
1834 this_char);
1835 return EINVAL;
1837 dsunit = simple_strtoul(value, &eov, 10);
1838 } else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
1839 if (!value || !*value) {
1840 cmn_err(CE_WARN,
1841 "XFS: %s option requires an argument",
1842 this_char);
1843 return EINVAL;
1845 dswidth = simple_strtoul(value, &eov, 10);
1846 } else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
1847 args->flags &= ~XFSMNT_32BITINODES;
1848 #if !XFS_BIG_INUMS
1849 cmn_err(CE_WARN,
1850 "XFS: %s option not allowed on this system",
1851 this_char);
1852 return EINVAL;
1853 #endif
1854 } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
1855 args->flags |= XFSMNT_NOUUID;
1856 } else if (!strcmp(this_char, MNTOPT_BARRIER)) {
1857 args->flags |= XFSMNT_BARRIER;
1858 } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
1859 args->flags &= ~XFSMNT_BARRIER;
1860 } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
1861 args->flags &= ~XFSMNT_IDELETE;
1862 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
1863 args->flags |= XFSMNT_IDELETE;
1864 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
1865 args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE;
1866 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
1867 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
1868 } else if (!strcmp(this_char, MNTOPT_ATTR2)) {
1869 args->flags |= XFSMNT_ATTR2;
1870 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
1871 args->flags &= ~XFSMNT_ATTR2;
1872 } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
1873 args->flags2 |= XFSMNT2_FILESTREAMS;
1874 } else if (!strcmp(this_char, "osyncisdsync")) {
1875 /* no-op, this is now the default */
1876 cmn_err(CE_WARN,
1877 "XFS: osyncisdsync is now the default, option is deprecated.");
1878 } else if (!strcmp(this_char, "irixsgid")) {
1879 cmn_err(CE_WARN,
1880 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
1881 } else {
1882 cmn_err(CE_WARN,
1883 "XFS: unknown mount option [%s].", this_char);
1884 return EINVAL;
1888 if (args->flags & XFSMNT_NORECOVERY) {
1889 if ((vfsp->vfs_flag & VFS_RDONLY) == 0) {
1890 cmn_err(CE_WARN,
1891 "XFS: no-recovery mounts must be read-only.");
1892 return EINVAL;
1896 if ((args->flags & XFSMNT_NOALIGN) && (dsunit || dswidth)) {
1897 cmn_err(CE_WARN,
1898 "XFS: sunit and swidth options incompatible with the noalign option");
1899 return EINVAL;
1902 if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
1903 cmn_err(CE_WARN,
1904 "XFS: sunit and swidth must be specified together");
1905 return EINVAL;
1908 if (dsunit && (dswidth % dsunit != 0)) {
1909 cmn_err(CE_WARN,
1910 "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)",
1911 dswidth, dsunit);
1912 return EINVAL;
1915 if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
1916 if (dsunit) {
1917 args->sunit = dsunit;
1918 args->flags |= XFSMNT_RETERR;
1919 } else {
1920 args->sunit = vol_dsunit;
1922 dswidth ? (args->swidth = dswidth) :
1923 (args->swidth = vol_dswidth);
1924 } else {
1925 args->sunit = args->swidth = 0;
1928 done:
1929 if (args->flags & XFSMNT_32BITINODES)
1930 vfsp->vfs_flag |= VFS_32BITINODES;
1931 if (args->flags2)
1932 args->flags |= XFSMNT_FLAGS2;
1933 return 0;
1936 STATIC int
1937 xfs_showargs(
1938 struct bhv_desc *bhv,
1939 struct seq_file *m)
1941 static struct proc_xfs_info {
1942 int flag;
1943 char *str;
1944 } xfs_info[] = {
1945 /* the few simple ones we can get from the mount struct */
1946 { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC },
1947 { XFS_MOUNT_INO64, "," MNTOPT_INO64 },
1948 { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN },
1949 { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC },
1950 { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID },
1951 { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY },
1952 { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC },
1953 { 0, NULL }
1955 struct proc_xfs_info *xfs_infop;
1956 struct xfs_mount *mp = XFS_BHVTOM(bhv);
1957 struct bhv_vfs *vfsp = XFS_MTOVFS(mp);
1959 for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) {
1960 if (mp->m_flags & xfs_infop->flag)
1961 seq_puts(m, xfs_infop->str);
1964 if (mp->m_flags & XFS_MOUNT_IHASHSIZE)
1965 seq_printf(m, "," MNTOPT_IHASHSIZE "=%d", (int)mp->m_ihsize);
1967 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
1968 seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
1969 (int)(1 << mp->m_writeio_log) >> 10);
1971 if (mp->m_logbufs > 0)
1972 seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
1973 if (mp->m_logbsize > 0)
1974 seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
1976 if (mp->m_logname)
1977 seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
1978 if (mp->m_rtname)
1979 seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
1981 if (mp->m_dalign > 0)
1982 seq_printf(m, "," MNTOPT_SUNIT "=%d",
1983 (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
1984 if (mp->m_swidth > 0)
1985 seq_printf(m, "," MNTOPT_SWIDTH "=%d",
1986 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
1988 if (!(mp->m_flags & XFS_MOUNT_IDELETE))
1989 seq_printf(m, "," MNTOPT_IKEEP);
1990 if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE))
1991 seq_printf(m, "," MNTOPT_LARGEIO);
1993 if (!(vfsp->vfs_flag & VFS_32BITINODES))
1994 seq_printf(m, "," MNTOPT_64BITINODE);
1995 if (vfsp->vfs_flag & VFS_GRPID)
1996 seq_printf(m, "," MNTOPT_GRPID);
1998 return 0;
2002 * Second stage of a freeze. The data is already frozen so we only
2003 * need to take care of themetadata. Once that's done write a dummy
2004 * record to dirty the log in case of a crash while frozen.
2006 STATIC void
2007 xfs_freeze(
2008 bhv_desc_t *bdp)
2010 xfs_mount_t *mp = XFS_BHVTOM(bdp);
2012 xfs_attr_quiesce(mp);
2013 xfs_fs_log_dummy(mp);
2017 bhv_vfsops_t xfs_vfsops = {
2018 BHV_IDENTITY_INIT(VFS_BHV_XFS,VFS_POSITION_XFS),
2019 .vfs_parseargs = xfs_parseargs,
2020 .vfs_showargs = xfs_showargs,
2021 .vfs_mount = xfs_mount,
2022 .vfs_unmount = xfs_unmount,
2023 .vfs_mntupdate = xfs_mntupdate,
2024 .vfs_root = xfs_root,
2025 .vfs_statvfs = xfs_statvfs,
2026 .vfs_sync = xfs_sync,
2027 .vfs_vget = xfs_vget,
2028 .vfs_dmapiops = (vfs_dmapiops_t)fs_nosys,
2029 .vfs_quotactl = (vfs_quotactl_t)fs_nosys,
2030 .vfs_init_vnode = xfs_initialize_vnode,
2031 .vfs_force_shutdown = xfs_do_force_shutdown,
2032 .vfs_freeze = xfs_freeze,