2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 #include "xfs_macros.h"
35 #include "xfs_types.h"
38 #include "xfs_trans.h"
43 #include "xfs_dmapi.h"
44 #include "xfs_mount.h"
45 #include "xfs_alloc_btree.h"
46 #include "xfs_bmap_btree.h"
47 #include "xfs_ialloc_btree.h"
48 #include "xfs_btree.h"
49 #include "xfs_ialloc.h"
50 #include "xfs_attr_sf.h"
51 #include "xfs_dir_sf.h"
52 #include "xfs_dir2_sf.h"
53 #include "xfs_dinode.h"
54 #include "xfs_inode.h"
55 #include "xfs_alloc.h"
56 #include "xfs_rtalloc.h"
58 #include "xfs_error.h"
61 #include "xfs_quota.h"
62 #include "xfs_fsops.h"
64 STATIC void xfs_mount_log_sbunit(xfs_mount_t *, __int64_t);
65 STATIC int xfs_uuid_mount(xfs_mount_t *);
66 STATIC void xfs_uuid_unmount(xfs_mount_t *mp);
70 short type; /* 0 = integer
71 * 1 = binary / string (no translation)
74 { offsetof(xfs_sb_t, sb_magicnum), 0 },
75 { offsetof(xfs_sb_t, sb_blocksize), 0 },
76 { offsetof(xfs_sb_t, sb_dblocks), 0 },
77 { offsetof(xfs_sb_t, sb_rblocks), 0 },
78 { offsetof(xfs_sb_t, sb_rextents), 0 },
79 { offsetof(xfs_sb_t, sb_uuid), 1 },
80 { offsetof(xfs_sb_t, sb_logstart), 0 },
81 { offsetof(xfs_sb_t, sb_rootino), 0 },
82 { offsetof(xfs_sb_t, sb_rbmino), 0 },
83 { offsetof(xfs_sb_t, sb_rsumino), 0 },
84 { offsetof(xfs_sb_t, sb_rextsize), 0 },
85 { offsetof(xfs_sb_t, sb_agblocks), 0 },
86 { offsetof(xfs_sb_t, sb_agcount), 0 },
87 { offsetof(xfs_sb_t, sb_rbmblocks), 0 },
88 { offsetof(xfs_sb_t, sb_logblocks), 0 },
89 { offsetof(xfs_sb_t, sb_versionnum), 0 },
90 { offsetof(xfs_sb_t, sb_sectsize), 0 },
91 { offsetof(xfs_sb_t, sb_inodesize), 0 },
92 { offsetof(xfs_sb_t, sb_inopblock), 0 },
93 { offsetof(xfs_sb_t, sb_fname[0]), 1 },
94 { offsetof(xfs_sb_t, sb_blocklog), 0 },
95 { offsetof(xfs_sb_t, sb_sectlog), 0 },
96 { offsetof(xfs_sb_t, sb_inodelog), 0 },
97 { offsetof(xfs_sb_t, sb_inopblog), 0 },
98 { offsetof(xfs_sb_t, sb_agblklog), 0 },
99 { offsetof(xfs_sb_t, sb_rextslog), 0 },
100 { offsetof(xfs_sb_t, sb_inprogress), 0 },
101 { offsetof(xfs_sb_t, sb_imax_pct), 0 },
102 { offsetof(xfs_sb_t, sb_icount), 0 },
103 { offsetof(xfs_sb_t, sb_ifree), 0 },
104 { offsetof(xfs_sb_t, sb_fdblocks), 0 },
105 { offsetof(xfs_sb_t, sb_frextents), 0 },
106 { offsetof(xfs_sb_t, sb_uquotino), 0 },
107 { offsetof(xfs_sb_t, sb_gquotino), 0 },
108 { offsetof(xfs_sb_t, sb_qflags), 0 },
109 { offsetof(xfs_sb_t, sb_flags), 0 },
110 { offsetof(xfs_sb_t, sb_shared_vn), 0 },
111 { offsetof(xfs_sb_t, sb_inoalignmt), 0 },
112 { offsetof(xfs_sb_t, sb_unit), 0 },
113 { offsetof(xfs_sb_t, sb_width), 0 },
114 { offsetof(xfs_sb_t, sb_dirblklog), 0 },
115 { offsetof(xfs_sb_t, sb_logsectlog), 0 },
116 { offsetof(xfs_sb_t, sb_logsectsize),0 },
117 { offsetof(xfs_sb_t, sb_logsunit), 0 },
118 { offsetof(xfs_sb_t, sb_features2), 0 },
119 { sizeof(xfs_sb_t), 0 }
123 * Return a pointer to an initialized xfs_mount structure.
130 mp = kmem_zalloc(sizeof(*mp), KM_SLEEP);
132 AIL_LOCKINIT(&mp->m_ail_lock, "xfs_ail");
133 spinlock_init(&mp->m_sb_lock, "xfs_sb");
134 mutex_init(&mp->m_ilock, MUTEX_DEFAULT, "xfs_ilock");
135 initnsema(&mp->m_growlock, 1, "xfs_grow");
137 * Initialize the AIL.
139 xfs_trans_ail_init(mp);
141 atomic_set(&mp->m_active_trans, 0);
147 * Free up the resources associated with a mount structure. Assume that
148 * the structure was initially zeroed, so we can tell which fields got
164 for (agno = 0; agno < mp->m_maxagi; agno++)
165 if (mp->m_perag[agno].pagb_list)
166 kmem_free(mp->m_perag[agno].pagb_list,
167 sizeof(xfs_perag_busy_t) *
169 kmem_free(mp->m_perag,
170 sizeof(xfs_perag_t) * mp->m_sb.sb_agcount);
173 AIL_LOCK_DESTROY(&mp->m_ail_lock);
174 spinlock_destroy(&mp->m_sb_lock);
175 mutex_destroy(&mp->m_ilock);
176 freesema(&mp->m_growlock);
180 if (mp->m_fsname != NULL)
181 kmem_free(mp->m_fsname, mp->m_fsname_len);
184 struct vfs *vfsp = XFS_MTOVFS(mp);
186 bhv_remove_all_vfsops(vfsp, 0);
187 VFS_REMOVEBHV(vfsp, &mp->m_bhv);
190 kmem_free(mp, sizeof(xfs_mount_t));
195 * Check the validity of the SB found.
198 xfs_mount_validate_sb(
203 * If the log device and data device have the
204 * same device number, the log is internal.
205 * Consequently, the sb_logstart should be non-zero. If
206 * we have a zero sb_logstart in this case, we may be trying to mount
207 * a volume filesystem in a non-volume manner.
209 if (sbp->sb_magicnum != XFS_SB_MAGIC) {
210 cmn_err(CE_WARN, "XFS: bad magic number");
211 return XFS_ERROR(EWRONGFS);
214 if (!XFS_SB_GOOD_VERSION(sbp)) {
215 cmn_err(CE_WARN, "XFS: bad version");
216 return XFS_ERROR(EWRONGFS);
220 sbp->sb_logstart == 0 && mp->m_logdev_targp == mp->m_ddev_targp)) {
222 "XFS: filesystem is marked as having an external log; "
223 "specify logdev on the\nmount command line.");
224 XFS_CORRUPTION_ERROR("xfs_mount_validate_sb(1)",
225 XFS_ERRLEVEL_HIGH, mp, sbp);
226 return XFS_ERROR(EFSCORRUPTED);
230 sbp->sb_logstart != 0 && mp->m_logdev_targp != mp->m_ddev_targp)) {
232 "XFS: filesystem is marked as having an internal log; "
233 "don't specify logdev on\nthe mount command line.");
234 XFS_CORRUPTION_ERROR("xfs_mount_validate_sb(2)",
235 XFS_ERRLEVEL_HIGH, mp, sbp);
236 return XFS_ERROR(EFSCORRUPTED);
240 * More sanity checking. These were stolen directly from
244 sbp->sb_agcount <= 0 ||
245 sbp->sb_sectsize < XFS_MIN_SECTORSIZE ||
246 sbp->sb_sectsize > XFS_MAX_SECTORSIZE ||
247 sbp->sb_sectlog < XFS_MIN_SECTORSIZE_LOG ||
248 sbp->sb_sectlog > XFS_MAX_SECTORSIZE_LOG ||
249 sbp->sb_blocksize < XFS_MIN_BLOCKSIZE ||
250 sbp->sb_blocksize > XFS_MAX_BLOCKSIZE ||
251 sbp->sb_blocklog < XFS_MIN_BLOCKSIZE_LOG ||
252 sbp->sb_blocklog > XFS_MAX_BLOCKSIZE_LOG ||
253 sbp->sb_inodesize < XFS_DINODE_MIN_SIZE ||
254 sbp->sb_inodesize > XFS_DINODE_MAX_SIZE ||
255 (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) ||
256 (sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) ||
257 sbp->sb_imax_pct > 100)) {
258 cmn_err(CE_WARN, "XFS: SB sanity check 1 failed");
259 XFS_CORRUPTION_ERROR("xfs_mount_validate_sb(3)",
260 XFS_ERRLEVEL_LOW, mp, sbp);
261 return XFS_ERROR(EFSCORRUPTED);
265 * Sanity check AG count, size fields against data size field
268 sbp->sb_dblocks == 0 ||
270 (xfs_drfsbno_t)sbp->sb_agcount * sbp->sb_agblocks ||
271 sbp->sb_dblocks < (xfs_drfsbno_t)(sbp->sb_agcount - 1) *
272 sbp->sb_agblocks + XFS_MIN_AG_BLOCKS)) {
273 cmn_err(CE_WARN, "XFS: SB sanity check 2 failed");
274 XFS_ERROR_REPORT("xfs_mount_validate_sb(4)",
275 XFS_ERRLEVEL_LOW, mp);
276 return XFS_ERROR(EFSCORRUPTED);
279 ASSERT(PAGE_SHIFT >= sbp->sb_blocklog);
280 ASSERT(sbp->sb_blocklog >= BBSHIFT);
282 #if XFS_BIG_BLKNOS /* Limited by ULONG_MAX of page cache index */
284 (sbp->sb_dblocks >> (PAGE_SHIFT - sbp->sb_blocklog)) > ULONG_MAX ||
285 (sbp->sb_rblocks >> (PAGE_SHIFT - sbp->sb_blocklog)) > ULONG_MAX)) {
286 #else /* Limited by UINT_MAX of sectors */
288 (sbp->sb_dblocks << (sbp->sb_blocklog - BBSHIFT)) > UINT_MAX ||
289 (sbp->sb_rblocks << (sbp->sb_blocklog - BBSHIFT)) > UINT_MAX)) {
292 "XFS: File system is too large to be mounted on this system.");
293 return XFS_ERROR(E2BIG);
296 if (unlikely(sbp->sb_inprogress)) {
297 cmn_err(CE_WARN, "XFS: file system busy");
298 XFS_ERROR_REPORT("xfs_mount_validate_sb(5)",
299 XFS_ERRLEVEL_LOW, mp);
300 return XFS_ERROR(EFSCORRUPTED);
304 * Until this is fixed only page-sized or smaller data blocks work.
306 if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) {
308 "XFS: Attempted to mount file system with blocksize %d bytes",
311 "XFS: Only page-sized (%d) or less blocksizes currently work.",
313 return XFS_ERROR(ENOSYS);
320 xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount)
322 xfs_agnumber_t index, max_metadata;
326 xfs_sb_t *sbp = &mp->m_sb;
327 xfs_ino_t max_inum = XFS_MAXINUMBER_32;
329 /* Check to see if the filesystem can overflow 32 bit inodes */
330 agino = XFS_OFFBNO_TO_AGINO(mp, sbp->sb_agblocks - 1, 0);
331 ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino);
333 /* Clear the mount flag if no inode can overflow 32 bits
334 * on this filesystem, or if specifically requested..
336 if ((mp->m_flags & XFS_MOUNT_32BITINOOPT) && ino > max_inum) {
337 mp->m_flags |= XFS_MOUNT_32BITINODES;
339 mp->m_flags &= ~XFS_MOUNT_32BITINODES;
342 /* If we can overflow then setup the ag headers accordingly */
343 if (mp->m_flags & XFS_MOUNT_32BITINODES) {
344 /* Calculate how much should be reserved for inodes to
345 * meet the max inode percentage.
347 if (mp->m_maxicount) {
350 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
352 icount += sbp->sb_agblocks - 1;
353 do_div(icount, mp->m_ialloc_blks);
354 max_metadata = icount;
356 max_metadata = agcount;
358 for (index = 0; index < agcount; index++) {
359 ino = XFS_AGINO_TO_INO(mp, index, agino);
360 if (ino > max_inum) {
365 /* This ag is prefered for inodes */
366 pag = &mp->m_perag[index];
367 pag->pagi_inodeok = 1;
368 if (index < max_metadata)
369 pag->pagf_metadata = 1;
372 /* Setup default behavior for smaller filesystems */
373 for (index = 0; index < agcount; index++) {
374 pag = &mp->m_perag[index];
375 pag->pagi_inodeok = 1;
384 * data - on disk version of sb
386 * dir - conversion direction: <0 - convert sb to buf
387 * >0 - convert buf to sb
388 * fields - which fields to copy (bitmask)
409 buf_ptr = (xfs_caddr_t)data;
410 mem_ptr = (xfs_caddr_t)sb;
413 f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields);
414 first = xfs_sb_info[f].offset;
415 size = xfs_sb_info[f + 1].offset - first;
417 ASSERT(xfs_sb_info[f].type == 0 || xfs_sb_info[f].type == 1);
419 if (size == 1 || xfs_sb_info[f].type == 1) {
421 memcpy(mem_ptr + first, buf_ptr + first, size);
423 memcpy(buf_ptr + first, mem_ptr + first, size);
428 INT_XLATE(*(__uint16_t*)(buf_ptr+first),
429 *(__uint16_t*)(mem_ptr+first),
433 INT_XLATE(*(__uint32_t*)(buf_ptr+first),
434 *(__uint32_t*)(mem_ptr+first),
438 INT_XLATE(*(__uint64_t*)(buf_ptr+first),
439 *(__uint64_t*)(mem_ptr+first), dir, ARCH_CONVERT);
446 fields &= ~(1LL << f);
453 * Does the initial read of the superblock.
456 xfs_readsb(xfs_mount_t *mp)
458 unsigned int sector_size;
459 unsigned int extra_flags;
464 ASSERT(mp->m_sb_bp == NULL);
465 ASSERT(mp->m_ddev_targp != NULL);
468 * Allocate a (locked) buffer to hold the superblock.
469 * This will be kept around at all times to optimize
470 * access to the superblock.
472 sector_size = xfs_getsize_buftarg(mp->m_ddev_targp);
473 extra_flags = XFS_BUF_LOCK | XFS_BUF_MANAGE | XFS_BUF_MAPPED;
475 bp = xfs_buf_read_flags(mp->m_ddev_targp, XFS_SB_DADDR,
476 BTOBB(sector_size), extra_flags);
477 if (!bp || XFS_BUF_ISERROR(bp)) {
478 cmn_err(CE_WARN, "XFS: SB read failed");
479 error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM;
482 ASSERT(XFS_BUF_ISBUSY(bp));
483 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
486 * Initialize the mount structure from the superblock.
487 * But first do some basic consistency checking.
489 sbp = XFS_BUF_TO_SBP(bp);
490 xfs_xlatesb(XFS_BUF_PTR(bp), &(mp->m_sb), 1, XFS_SB_ALL_BITS);
492 error = xfs_mount_validate_sb(mp, &(mp->m_sb));
494 cmn_err(CE_WARN, "XFS: SB validate failed");
499 * We must be able to do sector-sized and sector-aligned IO.
501 if (sector_size > mp->m_sb.sb_sectsize) {
503 "XFS: device supports only %u byte sectors (not %u)",
504 sector_size, mp->m_sb.sb_sectsize);
510 * If device sector size is smaller than the superblock size,
511 * re-read the superblock so the buffer is correctly sized.
513 if (sector_size < mp->m_sb.sb_sectsize) {
514 XFS_BUF_UNMANAGE(bp);
516 sector_size = mp->m_sb.sb_sectsize;
517 bp = xfs_buf_read_flags(mp->m_ddev_targp, XFS_SB_DADDR,
518 BTOBB(sector_size), extra_flags);
519 if (!bp || XFS_BUF_ISERROR(bp)) {
520 cmn_err(CE_WARN, "XFS: SB re-read failed");
521 error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM;
524 ASSERT(XFS_BUF_ISBUSY(bp));
525 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
530 ASSERT(XFS_BUF_VALUSEMA(bp) > 0);
535 XFS_BUF_UNMANAGE(bp);
545 * Mount initialization code establishing various mount
546 * fields from the superblock associated with the given
550 xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp)
554 mp->m_agfrotor = mp->m_agirotor = 0;
555 spinlock_init(&mp->m_agirotor_lock, "m_agirotor_lock");
556 mp->m_maxagi = mp->m_sb.sb_agcount;
557 mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG;
558 mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;
559 mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT;
560 mp->m_agno_log = xfs_highbit32(sbp->sb_agcount - 1) + 1;
561 mp->m_agino_log = sbp->sb_inopblog + sbp->sb_agblklog;
562 mp->m_litino = sbp->sb_inodesize -
563 ((uint)sizeof(xfs_dinode_core_t) + (uint)sizeof(xfs_agino_t));
564 mp->m_blockmask = sbp->sb_blocksize - 1;
565 mp->m_blockwsize = sbp->sb_blocksize >> XFS_WORDLOG;
566 mp->m_blockwmask = mp->m_blockwsize - 1;
567 INIT_LIST_HEAD(&mp->m_del_inodes);
570 * Setup for attributes, in case they get created.
571 * This value is for inodes getting attributes for the first time,
572 * the per-inode value is for old attribute values.
574 ASSERT(sbp->sb_inodesize >= 256 && sbp->sb_inodesize <= 2048);
575 switch (sbp->sb_inodesize) {
577 mp->m_attroffset = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(2);
582 mp->m_attroffset = XFS_BMDR_SPACE_CALC(12);
587 ASSERT(mp->m_attroffset < XFS_LITINO(mp));
589 for (i = 0; i < 2; i++) {
590 mp->m_alloc_mxr[i] = XFS_BTREE_BLOCK_MAXRECS(sbp->sb_blocksize,
592 mp->m_alloc_mnr[i] = XFS_BTREE_BLOCK_MINRECS(sbp->sb_blocksize,
595 for (i = 0; i < 2; i++) {
596 mp->m_bmap_dmxr[i] = XFS_BTREE_BLOCK_MAXRECS(sbp->sb_blocksize,
598 mp->m_bmap_dmnr[i] = XFS_BTREE_BLOCK_MINRECS(sbp->sb_blocksize,
601 for (i = 0; i < 2; i++) {
602 mp->m_inobt_mxr[i] = XFS_BTREE_BLOCK_MAXRECS(sbp->sb_blocksize,
604 mp->m_inobt_mnr[i] = XFS_BTREE_BLOCK_MINRECS(sbp->sb_blocksize,
608 mp->m_bsize = XFS_FSB_TO_BB(mp, 1);
609 mp->m_ialloc_inos = (int)MAX((__uint16_t)XFS_INODES_PER_CHUNK,
611 mp->m_ialloc_blks = mp->m_ialloc_inos >> sbp->sb_inopblog;
616 * This function does the following on an initial mount of a file system:
617 * - reads the superblock from disk and init the mount struct
618 * - if we're a 32-bit kernel, do a size check on the superblock
619 * so we don't mount terabyte filesystems
620 * - init mount struct realtime fields
621 * - allocate inode hash table for fs
622 * - init directory manager
623 * - perform recovery and init the log manager
632 xfs_sb_t *sbp = &(mp->m_sb);
635 int readio_log, writeio_log;
638 __int64_t update_flags;
639 uint quotamount, quotaflags;
641 int uuid_mounted = 0;
644 if (mp->m_sb_bp == NULL) {
645 if ((error = xfs_readsb(mp))) {
649 xfs_mount_common(mp, sbp);
652 * Check if sb_agblocks is aligned at stripe boundary
653 * If sb_agblocks is NOT aligned turn off m_dalign since
654 * allocator alignment is within an ag, therefore ag has
655 * to be aligned at stripe boundary.
658 if (mp->m_dalign && !(mfsi_flags & XFS_MFSI_SECOND)) {
660 * If stripe unit and stripe width are not multiples
661 * of the fs blocksize turn off alignment.
663 if ((BBTOB(mp->m_dalign) & mp->m_blockmask) ||
664 (BBTOB(mp->m_swidth) & mp->m_blockmask)) {
665 if (mp->m_flags & XFS_MOUNT_RETERR) {
667 "XFS: alignment check 1 failed");
668 error = XFS_ERROR(EINVAL);
671 mp->m_dalign = mp->m_swidth = 0;
674 * Convert the stripe unit and width to FSBs.
676 mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign);
677 if (mp->m_dalign && (sbp->sb_agblocks % mp->m_dalign)) {
678 if (mp->m_flags & XFS_MOUNT_RETERR) {
679 error = XFS_ERROR(EINVAL);
682 xfs_fs_cmn_err(CE_WARN, mp,
683 "stripe alignment turned off: sunit(%d)/swidth(%d) incompatible with agsize(%d)",
684 mp->m_dalign, mp->m_swidth,
689 } else if (mp->m_dalign) {
690 mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth);
692 if (mp->m_flags & XFS_MOUNT_RETERR) {
693 xfs_fs_cmn_err(CE_WARN, mp,
694 "stripe alignment turned off: sunit(%d) less than bsize(%d)",
697 error = XFS_ERROR(EINVAL);
705 * Update superblock with new values
708 if (XFS_SB_VERSION_HASDALIGN(sbp)) {
709 if (sbp->sb_unit != mp->m_dalign) {
710 sbp->sb_unit = mp->m_dalign;
711 update_flags |= XFS_SB_UNIT;
713 if (sbp->sb_width != mp->m_swidth) {
714 sbp->sb_width = mp->m_swidth;
715 update_flags |= XFS_SB_WIDTH;
718 } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN &&
719 XFS_SB_VERSION_HASDALIGN(&mp->m_sb)) {
720 mp->m_dalign = sbp->sb_unit;
721 mp->m_swidth = sbp->sb_width;
724 xfs_alloc_compute_maxlevels(mp);
725 xfs_bmap_compute_maxlevels(mp, XFS_DATA_FORK);
726 xfs_bmap_compute_maxlevels(mp, XFS_ATTR_FORK);
727 xfs_ialloc_compute_maxlevels(mp);
729 if (sbp->sb_imax_pct) {
732 /* Make sure the maximum inode count is a multiple of the
733 * units we allocate inodes in.
736 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
738 do_div(icount, mp->m_ialloc_blks);
739 mp->m_maxicount = (icount * mp->m_ialloc_blks) <<
744 mp->m_maxioffset = xfs_max_file_offset(sbp->sb_blocklog);
747 * XFS uses the uuid from the superblock as the unique
748 * identifier for fsid. We can not use the uuid from the volume
749 * since a single partition filesystem is identical to a single
750 * partition volume/filesystem.
752 if ((mfsi_flags & XFS_MFSI_SECOND) == 0 &&
753 (mp->m_flags & XFS_MOUNT_NOUUID) == 0) {
754 if (xfs_uuid_mount(mp)) {
755 error = XFS_ERROR(EINVAL);
759 ret64 = uuid_hash64(&sbp->sb_uuid);
760 memcpy(&vfsp->vfs_fsid, &ret64, sizeof(ret64));
764 * Set the default minimum read and write sizes unless
765 * already specified in a mount option.
766 * We use smaller I/O sizes when the file system
767 * is being used for NFS service (wsync mount option).
769 if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)) {
770 if (mp->m_flags & XFS_MOUNT_WSYNC) {
771 readio_log = XFS_WSYNC_READIO_LOG;
772 writeio_log = XFS_WSYNC_WRITEIO_LOG;
774 readio_log = XFS_READIO_LOG_LARGE;
775 writeio_log = XFS_WRITEIO_LOG_LARGE;
778 readio_log = mp->m_readio_log;
779 writeio_log = mp->m_writeio_log;
783 * Set the number of readahead buffers to use based on
784 * physical memory size.
786 if (xfs_physmem <= 4096) /* <= 16MB */
787 mp->m_nreadaheads = XFS_RW_NREADAHEAD_16MB;
788 else if (xfs_physmem <= 8192) /* <= 32MB */
789 mp->m_nreadaheads = XFS_RW_NREADAHEAD_32MB;
791 mp->m_nreadaheads = XFS_RW_NREADAHEAD_K32;
792 if (sbp->sb_blocklog > readio_log) {
793 mp->m_readio_log = sbp->sb_blocklog;
795 mp->m_readio_log = readio_log;
797 mp->m_readio_blocks = 1 << (mp->m_readio_log - sbp->sb_blocklog);
798 if (sbp->sb_blocklog > writeio_log) {
799 mp->m_writeio_log = sbp->sb_blocklog;
801 mp->m_writeio_log = writeio_log;
803 mp->m_writeio_blocks = 1 << (mp->m_writeio_log - sbp->sb_blocklog);
806 * Set the inode cluster size based on the physical memory
807 * size. This may still be overridden by the file system
808 * block size if it is larger than the chosen cluster size.
810 if (xfs_physmem <= btoc(32 * 1024 * 1024)) { /* <= 32 MB */
811 mp->m_inode_cluster_size = XFS_INODE_SMALL_CLUSTER_SIZE;
813 mp->m_inode_cluster_size = XFS_INODE_BIG_CLUSTER_SIZE;
816 * Set whether we're using inode alignment.
818 if (XFS_SB_VERSION_HASALIGN(&mp->m_sb) &&
819 mp->m_sb.sb_inoalignmt >=
820 XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size))
821 mp->m_inoalign_mask = mp->m_sb.sb_inoalignmt - 1;
823 mp->m_inoalign_mask = 0;
825 * If we are using stripe alignment, check whether
826 * the stripe unit is a multiple of the inode alignment
828 if (mp->m_dalign && mp->m_inoalign_mask &&
829 !(mp->m_dalign & mp->m_inoalign_mask))
830 mp->m_sinoalign = mp->m_dalign;
834 * Check that the data (and log if separate) are an ok size.
836 d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks);
837 if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) {
838 cmn_err(CE_WARN, "XFS: size check 1 failed");
839 error = XFS_ERROR(E2BIG);
842 error = xfs_read_buf(mp, mp->m_ddev_targp,
843 d - XFS_FSS_TO_BB(mp, 1),
844 XFS_FSS_TO_BB(mp, 1), 0, &bp);
848 cmn_err(CE_WARN, "XFS: size check 2 failed");
849 if (error == ENOSPC) {
850 error = XFS_ERROR(E2BIG);
855 if (((mfsi_flags & XFS_MFSI_CLIENT) == 0) &&
856 mp->m_logdev_targp != mp->m_ddev_targp) {
857 d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks);
858 if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) {
859 cmn_err(CE_WARN, "XFS: size check 3 failed");
860 error = XFS_ERROR(E2BIG);
863 error = xfs_read_buf(mp, mp->m_logdev_targp,
864 d - XFS_FSB_TO_BB(mp, 1),
865 XFS_FSB_TO_BB(mp, 1), 0, &bp);
869 cmn_err(CE_WARN, "XFS: size check 3 failed");
870 if (error == ENOSPC) {
871 error = XFS_ERROR(E2BIG);
878 * Initialize realtime fields in the mount structure
880 if ((error = xfs_rtmount_init(mp))) {
881 cmn_err(CE_WARN, "XFS: RT mount failed");
886 * For client case we are done now
888 if (mfsi_flags & XFS_MFSI_CLIENT) {
893 * Copies the low order bits of the timestamp and the randomly
894 * set "sequence" number out of a UUID.
896 uuid_getnodeuniq(&sbp->sb_uuid, mp->m_fixedfsid);
899 * The vfs structure needs to have a file system independent
900 * way of checking for the invariant file system ID. Since it
901 * can't look at mount structures it has a pointer to the data
902 * in the mount structure.
904 * File systems that don't support user level file handles (i.e.
905 * all of them except for XFS) will leave vfs_altfsid as NULL.
907 vfsp->vfs_altfsid = (xfs_fsid_t *)mp->m_fixedfsid;
908 mp->m_dmevmask = 0; /* not persistent; set after each mount */
911 * Select the right directory manager.
914 XFS_SB_VERSION_HASDIRV2(&mp->m_sb) ?
919 * Initialize directory manager's entries.
924 * Initialize the attribute manager's entries.
926 mp->m_attr_magicpct = (mp->m_sb.sb_blocksize * 37) / 100;
929 * Initialize the precomputed transaction reservations values.
934 * Allocate and initialize the inode hash table for this
941 * Allocate and initialize the per-ag data.
943 init_rwsem(&mp->m_peraglock);
945 kmem_zalloc(sbp->sb_agcount * sizeof(xfs_perag_t), KM_SLEEP);
947 mp->m_maxagi = xfs_initialize_perag(mp, sbp->sb_agcount);
950 * log's mount-time initialization. Perform 1st part recovery if needed
952 if (likely(sbp->sb_logblocks > 0)) { /* check for volume case */
953 error = xfs_log_mount(mp, mp->m_logdev_targp,
954 XFS_FSB_TO_DADDR(mp, sbp->sb_logstart),
955 XFS_FSB_TO_BB(mp, sbp->sb_logblocks));
957 cmn_err(CE_WARN, "XFS: log mount failed");
960 } else { /* No log has been defined */
961 cmn_err(CE_WARN, "XFS: no log defined");
962 XFS_ERROR_REPORT("xfs_mountfs_int(1)", XFS_ERRLEVEL_LOW, mp);
963 error = XFS_ERROR(EFSCORRUPTED);
968 * Get and sanity-check the root inode.
969 * Save the pointer to it in the mount structure.
971 error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip, 0);
973 cmn_err(CE_WARN, "XFS: failed to read root inode");
980 if (unlikely((rip->i_d.di_mode & S_IFMT) != S_IFDIR)) {
981 cmn_err(CE_WARN, "XFS: corrupted root inode");
982 prdev("Root inode %llu is not a directory",
983 mp->m_ddev_targp, (unsigned long long)rip->i_ino);
984 xfs_iunlock(rip, XFS_ILOCK_EXCL);
985 XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW,
987 error = XFS_ERROR(EFSCORRUPTED);
990 mp->m_rootip = rip; /* save it */
992 xfs_iunlock(rip, XFS_ILOCK_EXCL);
995 * Initialize realtime inode pointers in the mount structure
997 if ((error = xfs_rtmount_inodes(mp))) {
999 * Free up the root inode.
1001 cmn_err(CE_WARN, "XFS: failed to read RT inodes");
1006 * If fs is not mounted readonly, then update the superblock
1007 * unit and width changes.
1009 if (update_flags && !(vfsp->vfs_flag & VFS_RDONLY))
1010 xfs_mount_log_sbunit(mp, update_flags);
1013 * Initialise the XFS quota management subsystem for this mount
1015 if ((error = XFS_QM_INIT(mp, "amount, "aflags)))
1019 * Finish recovering the file system. This part needed to be
1020 * delayed until after the root and real-time bitmap inodes
1021 * were consistently read in.
1023 error = xfs_log_mount_finish(mp, mfsi_flags);
1025 cmn_err(CE_WARN, "XFS: log mount finish failed");
1030 * Complete the quota initialisation, post-log-replay component.
1032 if ((error = XFS_QM_MOUNT(mp, quotamount, quotaflags, mfsi_flags)))
1039 * Free up the root inode.
1043 xfs_log_unmount_dealloc(mp);
1047 for (agno = 0; agno < sbp->sb_agcount; agno++)
1048 if (mp->m_perag[agno].pagb_list)
1049 kmem_free(mp->m_perag[agno].pagb_list,
1050 sizeof(xfs_perag_busy_t) * XFS_PAGB_NUM_SLOTS);
1051 kmem_free(mp->m_perag, sbp->sb_agcount * sizeof(xfs_perag_t));
1056 xfs_uuid_unmount(mp);
1064 * This flushes out the inodes,dquots and the superblock, unmounts the
1065 * log and makes sure that incore structures are freed.
1068 xfs_unmountfs(xfs_mount_t *mp, struct cred *cr)
1070 struct vfs *vfsp = XFS_MTOVFS(mp);
1071 #if defined(DEBUG) || defined(INDUCE_IO_ERROR)
1075 xfs_iflush_all(mp, XFS_FLUSH_ALL);
1077 XFS_QM_DQPURGEALL(mp,
1078 XFS_QMOPT_UQUOTA | XFS_QMOPT_GQUOTA | XFS_QMOPT_UMOUNTING);
1081 * Flush out the log synchronously so that we know for sure
1082 * that nothing is pinned. This is important because bflush()
1083 * will skip pinned buffers.
1085 xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE | XFS_LOG_SYNC);
1087 xfs_binval(mp->m_ddev_targp);
1088 if (mp->m_rtdev_targp) {
1089 xfs_binval(mp->m_rtdev_targp);
1092 xfs_unmountfs_writesb(mp);
1094 xfs_unmountfs_wait(mp); /* wait for async bufs */
1096 xfs_log_unmount(mp); /* Done! No more fs ops. */
1101 * All inodes from this mount point should be freed.
1103 ASSERT(mp->m_inodes == NULL);
1106 * We may have bufs that are in the process of getting written still.
1107 * We must wait for the I/O completion of those. The sync flag here
1108 * does a two pass iteration thru the bufcache.
1110 if (XFS_FORCED_SHUTDOWN(mp)) {
1111 xfs_incore_relse(mp->m_ddev_targp, 0, 1); /* synchronous */
1114 xfs_unmountfs_close(mp, cr);
1115 if ((mp->m_flags & XFS_MOUNT_NOUUID) == 0)
1116 xfs_uuid_unmount(mp);
1118 #if defined(DEBUG) || defined(INDUCE_IO_ERROR)
1120 * clear all error tags on this filesystem
1122 memcpy(&fsid, &vfsp->vfs_fsid, sizeof(int64_t));
1123 xfs_errortag_clearall_umount(fsid, mp->m_fsname, 0);
1126 xfs_mount_free(mp, 1);
1131 xfs_unmountfs_close(xfs_mount_t *mp, struct cred *cr)
1133 if (mp->m_logdev_targp != mp->m_ddev_targp)
1134 xfs_free_buftarg(mp->m_logdev_targp, 1);
1135 if (mp->m_rtdev_targp)
1136 xfs_free_buftarg(mp->m_rtdev_targp, 1);
1137 xfs_free_buftarg(mp->m_ddev_targp, 0);
1141 xfs_unmountfs_wait(xfs_mount_t *mp)
1143 if (mp->m_logdev_targp != mp->m_ddev_targp)
1144 xfs_wait_buftarg(mp->m_logdev_targp);
1145 if (mp->m_rtdev_targp)
1146 xfs_wait_buftarg(mp->m_rtdev_targp);
1147 xfs_wait_buftarg(mp->m_ddev_targp);
1151 xfs_unmountfs_writesb(xfs_mount_t *mp)
1158 * skip superblock write if fs is read-only, or
1159 * if we are doing a forced umount.
1161 sbp = xfs_getsb(mp, 0);
1162 if (!(XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY ||
1163 XFS_FORCED_SHUTDOWN(mp))) {
1165 * mark shared-readonly if desired
1167 sb = XFS_BUF_TO_SBP(sbp);
1168 if (mp->m_mk_sharedro) {
1169 if (!(sb->sb_flags & XFS_SBF_READONLY))
1170 sb->sb_flags |= XFS_SBF_READONLY;
1171 if (!XFS_SB_VERSION_HASSHARED(sb))
1172 XFS_SB_VERSION_ADDSHARED(sb);
1173 xfs_fs_cmn_err(CE_NOTE, mp,
1174 "Unmounting, marking shared read-only");
1176 XFS_BUF_UNDONE(sbp);
1177 XFS_BUF_UNREAD(sbp);
1178 XFS_BUF_UNDELAYWRITE(sbp);
1180 XFS_BUF_UNASYNC(sbp);
1181 ASSERT(XFS_BUF_TARGET(sbp) == mp->m_ddev_targp);
1182 xfsbdstrat(mp, sbp);
1183 /* Nevermind errors we might get here. */
1184 error = xfs_iowait(sbp);
1186 xfs_ioerror_alert("xfs_unmountfs_writesb",
1187 mp, sbp, XFS_BUF_ADDR(sbp));
1188 if (error && mp->m_mk_sharedro)
1189 xfs_fs_cmn_err(CE_ALERT, mp, "Superblock write error detected while unmounting. Filesystem may not be marked shared readonly");
1196 * xfs_mod_sb() can be used to copy arbitrary changes to the
1197 * in-core superblock into the superblock buffer to be logged.
1198 * It does not provide the higher level of locking that is
1199 * needed to protect the in-core superblock from concurrent
1203 xfs_mod_sb(xfs_trans_t *tp, __int64_t fields)
1216 bp = xfs_trans_getsb(tp, mp, 0);
1217 sbp = XFS_BUF_TO_SBP(bp);
1218 first = sizeof(xfs_sb_t);
1221 /* translate/copy */
1223 xfs_xlatesb(XFS_BUF_PTR(bp), &(mp->m_sb), -1, fields);
1225 /* find modified range */
1227 f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields);
1228 ASSERT((1LL << f) & XFS_SB_MOD_BITS);
1229 first = xfs_sb_info[f].offset;
1231 f = (xfs_sb_field_t)xfs_highbit64((__uint64_t)fields);
1232 ASSERT((1LL << f) & XFS_SB_MOD_BITS);
1233 last = xfs_sb_info[f + 1].offset - 1;
1235 xfs_trans_log_buf(tp, bp, first, last);
1239 * xfs_mod_incore_sb_unlocked() is a utility routine common used to apply
1240 * a delta to a specified field in the in-core superblock. Simply
1241 * switch on the field indicated and apply the delta to that field.
1242 * Fields are not allowed to dip below zero, so if the delta would
1243 * do this do not apply it and return EINVAL.
1245 * The SB_LOCK must be held when this routine is called.
1248 xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field,
1249 int delta, int rsvd)
1251 int scounter; /* short counter for 32 bit fields */
1252 long long lcounter; /* long counter for 64 bit fields */
1253 long long res_used, rem;
1256 * With the in-core superblock spin lock held, switch
1257 * on the indicated field. Apply the delta to the
1258 * proper field. If the fields value would dip below
1259 * 0, then do not apply the delta and return EINVAL.
1262 case XFS_SBS_ICOUNT:
1263 lcounter = (long long)mp->m_sb.sb_icount;
1267 return (XFS_ERROR(EINVAL));
1269 mp->m_sb.sb_icount = lcounter;
1272 lcounter = (long long)mp->m_sb.sb_ifree;
1276 return (XFS_ERROR(EINVAL));
1278 mp->m_sb.sb_ifree = lcounter;
1280 case XFS_SBS_FDBLOCKS:
1282 lcounter = (long long)mp->m_sb.sb_fdblocks;
1283 res_used = (long long)(mp->m_resblks - mp->m_resblks_avail);
1285 if (delta > 0) { /* Putting blocks back */
1286 if (res_used > delta) {
1287 mp->m_resblks_avail += delta;
1289 rem = delta - res_used;
1290 mp->m_resblks_avail = mp->m_resblks;
1293 } else { /* Taking blocks away */
1298 * If were out of blocks, use any available reserved blocks if
1304 lcounter = (long long)mp->m_resblks_avail + delta;
1306 return (XFS_ERROR(ENOSPC));
1308 mp->m_resblks_avail = lcounter;
1310 } else { /* not reserved */
1311 return (XFS_ERROR(ENOSPC));
1316 mp->m_sb.sb_fdblocks = lcounter;
1318 case XFS_SBS_FREXTENTS:
1319 lcounter = (long long)mp->m_sb.sb_frextents;
1322 return (XFS_ERROR(ENOSPC));
1324 mp->m_sb.sb_frextents = lcounter;
1326 case XFS_SBS_DBLOCKS:
1327 lcounter = (long long)mp->m_sb.sb_dblocks;
1331 return (XFS_ERROR(EINVAL));
1333 mp->m_sb.sb_dblocks = lcounter;
1335 case XFS_SBS_AGCOUNT:
1336 scounter = mp->m_sb.sb_agcount;
1340 return (XFS_ERROR(EINVAL));
1342 mp->m_sb.sb_agcount = scounter;
1344 case XFS_SBS_IMAX_PCT:
1345 scounter = mp->m_sb.sb_imax_pct;
1349 return (XFS_ERROR(EINVAL));
1351 mp->m_sb.sb_imax_pct = scounter;
1353 case XFS_SBS_REXTSIZE:
1354 scounter = mp->m_sb.sb_rextsize;
1358 return (XFS_ERROR(EINVAL));
1360 mp->m_sb.sb_rextsize = scounter;
1362 case XFS_SBS_RBMBLOCKS:
1363 scounter = mp->m_sb.sb_rbmblocks;
1367 return (XFS_ERROR(EINVAL));
1369 mp->m_sb.sb_rbmblocks = scounter;
1371 case XFS_SBS_RBLOCKS:
1372 lcounter = (long long)mp->m_sb.sb_rblocks;
1376 return (XFS_ERROR(EINVAL));
1378 mp->m_sb.sb_rblocks = lcounter;
1380 case XFS_SBS_REXTENTS:
1381 lcounter = (long long)mp->m_sb.sb_rextents;
1385 return (XFS_ERROR(EINVAL));
1387 mp->m_sb.sb_rextents = lcounter;
1389 case XFS_SBS_REXTSLOG:
1390 scounter = mp->m_sb.sb_rextslog;
1394 return (XFS_ERROR(EINVAL));
1396 mp->m_sb.sb_rextslog = scounter;
1400 return (XFS_ERROR(EINVAL));
1405 * xfs_mod_incore_sb() is used to change a field in the in-core
1406 * superblock structure by the specified delta. This modification
1407 * is protected by the SB_LOCK. Just use the xfs_mod_incore_sb_unlocked()
1408 * routine to do the work.
1411 xfs_mod_incore_sb(xfs_mount_t *mp, xfs_sb_field_t field, int delta, int rsvd)
1416 s = XFS_SB_LOCK(mp);
1417 status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd);
1418 XFS_SB_UNLOCK(mp, s);
1423 * xfs_mod_incore_sb_batch() is used to change more than one field
1424 * in the in-core superblock structure at a time. This modification
1425 * is protected by a lock internal to this module. The fields and
1426 * changes to those fields are specified in the array of xfs_mod_sb
1427 * structures passed in.
1429 * Either all of the specified deltas will be applied or none of
1430 * them will. If any modified field dips below 0, then all modifications
1431 * will be backed out and EINVAL will be returned.
1434 xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd)
1441 * Loop through the array of mod structures and apply each
1442 * individually. If any fail, then back out all those
1443 * which have already been applied. Do all of this within
1444 * the scope of the SB_LOCK so that all of the changes will
1447 s = XFS_SB_LOCK(mp);
1449 for (msbp = &msbp[0]; msbp < (msb + nmsb); msbp++) {
1451 * Apply the delta at index n. If it fails, break
1452 * from the loop so we'll fall into the undo loop
1455 status = xfs_mod_incore_sb_unlocked(mp, msbp->msb_field,
1456 msbp->msb_delta, rsvd);
1463 * If we didn't complete the loop above, then back out
1464 * any changes made to the superblock. If you add code
1465 * between the loop above and here, make sure that you
1466 * preserve the value of status. Loop back until
1467 * we step below the beginning of the array. Make sure
1468 * we don't touch anything back there.
1472 while (msbp >= msb) {
1473 status = xfs_mod_incore_sb_unlocked(mp,
1474 msbp->msb_field, -(msbp->msb_delta), rsvd);
1475 ASSERT(status == 0);
1479 XFS_SB_UNLOCK(mp, s);
1484 * xfs_getsb() is called to obtain the buffer for the superblock.
1485 * The buffer is returned locked and read in from disk.
1486 * The buffer should be released with a call to xfs_brelse().
1488 * If the flags parameter is BUF_TRYLOCK, then we'll only return
1489 * the superblock buffer if it can be locked without sleeping.
1490 * If it can't then we'll return NULL.
1499 ASSERT(mp->m_sb_bp != NULL);
1501 if (flags & XFS_BUF_TRYLOCK) {
1502 if (!XFS_BUF_CPSEMA(bp)) {
1506 XFS_BUF_PSEMA(bp, PRIBIO);
1509 ASSERT(XFS_BUF_ISDONE(bp));
1514 * Used to free the superblock along various error paths.
1523 * Use xfs_getsb() so that the buffer will be locked
1524 * when we call xfs_buf_relse().
1526 bp = xfs_getsb(mp, 0);
1527 XFS_BUF_UNMANAGE(bp);
1533 * See if the UUID is unique among mounted XFS filesystems.
1534 * Mount fails if UUID is nil or a FS with the same UUID is already mounted.
1540 if (uuid_is_nil(&mp->m_sb.sb_uuid)) {
1542 "XFS: Filesystem %s has nil UUID - can't mount",
1546 if (!uuid_table_insert(&mp->m_sb.sb_uuid)) {
1548 "XFS: Filesystem %s has duplicate UUID - can't mount",
1556 * Remove filesystem from the UUID table.
1562 uuid_table_remove(&mp->m_sb.sb_uuid);
1566 * Used to log changes to the superblock unit and width fields which could
1567 * be altered by the mount options. Only the first superblock is updated.
1570 xfs_mount_log_sbunit(
1576 ASSERT(fields & (XFS_SB_UNIT|XFS_SB_WIDTH|XFS_SB_UUID));
1578 tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT);
1579 if (xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
1580 XFS_DEFAULT_LOG_COUNT)) {
1581 xfs_trans_cancel(tp, 0);
1584 xfs_mod_sb(tp, fields);
1585 xfs_trans_commit(tp, 0, NULL);