Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include "xfs.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 19 | #include "xfs_fs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include "xfs_types.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 21 | #include "xfs_bit.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include "xfs_log.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 23 | #include "xfs_inum.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include "xfs_trans.h" |
| 25 | #include "xfs_sb.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 26 | #include "xfs_ag.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include "xfs_dir2.h" |
| 28 | #include "xfs_dmapi.h" |
| 29 | #include "xfs_mount.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 30 | #include "xfs_da_btree.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include "xfs_bmap_btree.h" |
| 32 | #include "xfs_ialloc_btree.h" |
| 33 | #include "xfs_alloc_btree.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 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" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include "xfs_btree.h" |
| 40 | #include "xfs_alloc.h" |
| 41 | #include "xfs_ialloc.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 42 | #include "xfs_quota.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include "xfs_error.h" |
| 44 | #include "xfs_bmap.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include "xfs_rw.h" |
| 46 | #include "xfs_refcache.h" |
| 47 | #include "xfs_buf_item.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 48 | #include "xfs_log_priv.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include "xfs_dir2_trace.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 50 | #include "xfs_extfree_item.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include "xfs_acl.h" |
| 52 | #include "xfs_attr.h" |
| 53 | #include "xfs_clnt.h" |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 54 | #include "xfs_mru_cache.h" |
| 55 | #include "xfs_filestream.h" |
Christoph Hellwig | e13a73f | 2006-01-11 15:30:08 +1100 | [diff] [blame] | 56 | #include "xfs_fsops.h" |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame] | 57 | #include "xfs_vnodeops.h" |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 58 | #include "xfs_vfsops.h" |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame] | 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | int |
| 62 | xfs_init(void) |
| 63 | { |
| 64 | extern kmem_zone_t *xfs_bmap_free_item_zone; |
| 65 | extern kmem_zone_t *xfs_btree_cur_zone; |
| 66 | extern kmem_zone_t *xfs_trans_zone; |
| 67 | extern kmem_zone_t *xfs_buf_item_zone; |
| 68 | extern kmem_zone_t *xfs_dabuf_zone; |
| 69 | #ifdef XFS_DABUF_DEBUG |
| 70 | extern lock_t xfs_dabuf_global_lock; |
| 71 | spinlock_init(&xfs_dabuf_global_lock, "xfsda"); |
| 72 | #endif |
| 73 | |
| 74 | /* |
| 75 | * Initialize all of the zone allocators we use. |
| 76 | */ |
| 77 | xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t), |
| 78 | "xfs_bmap_free_item"); |
| 79 | xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t), |
| 80 | "xfs_btree_cur"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans"); |
| 82 | xfs_da_state_zone = |
| 83 | kmem_zone_init(sizeof(xfs_da_state_t), "xfs_da_state"); |
| 84 | xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf"); |
Nathan Scott | 8758280 | 2006-03-14 13:18:19 +1100 | [diff] [blame] | 85 | xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork"); |
| 86 | xfs_acl_zone_init(xfs_acl_zone, "xfs_acl"); |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 87 | xfs_mru_cache_init(); |
| 88 | xfs_filestream_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
| 90 | /* |
| 91 | * The size of the zone allocated buf log item is the maximum |
| 92 | * size possible under XFS. This wastes a little bit of memory, |
| 93 | * but it is much faster. |
| 94 | */ |
| 95 | xfs_buf_item_zone = |
| 96 | kmem_zone_init((sizeof(xfs_buf_log_item_t) + |
| 97 | (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) / |
| 98 | NBWORD) * sizeof(int))), |
| 99 | "xfs_buf_item"); |
Nathan Scott | 8758280 | 2006-03-14 13:18:19 +1100 | [diff] [blame] | 100 | xfs_efd_zone = |
| 101 | kmem_zone_init((sizeof(xfs_efd_log_item_t) + |
| 102 | ((XFS_EFD_MAX_FAST_EXTENTS - 1) * |
| 103 | sizeof(xfs_extent_t))), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | "xfs_efd_item"); |
Nathan Scott | 8758280 | 2006-03-14 13:18:19 +1100 | [diff] [blame] | 105 | xfs_efi_zone = |
| 106 | kmem_zone_init((sizeof(xfs_efi_log_item_t) + |
| 107 | ((XFS_EFI_MAX_FAST_EXTENTS - 1) * |
| 108 | sizeof(xfs_extent_t))), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | "xfs_efi_item"); |
Nathan Scott | 8758280 | 2006-03-14 13:18:19 +1100 | [diff] [blame] | 110 | |
| 111 | /* |
| 112 | * These zones warrant special memory allocator hints |
| 113 | */ |
| 114 | xfs_inode_zone = |
| 115 | kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode", |
| 116 | KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | |
| 117 | KM_ZONE_SPREAD, NULL); |
| 118 | xfs_ili_zone = |
| 119 | kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili", |
| 120 | KM_ZONE_SPREAD, NULL); |
David Chinner | da353b0 | 2007-08-28 14:00:13 +1000 | [diff] [blame] | 121 | xfs_icluster_zone = |
| 122 | kmem_zone_init_flags(sizeof(xfs_icluster_t), "xfs_icluster", |
Nathan Scott | 8758280 | 2006-03-14 13:18:19 +1100 | [diff] [blame] | 123 | KM_ZONE_SPREAD, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
| 125 | /* |
| 126 | * Allocate global trace buffers. |
| 127 | */ |
| 128 | #ifdef XFS_ALLOC_TRACE |
| 129 | xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_SLEEP); |
| 130 | #endif |
| 131 | #ifdef XFS_BMAP_TRACE |
| 132 | xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_SLEEP); |
| 133 | #endif |
| 134 | #ifdef XFS_BMBT_TRACE |
| 135 | xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_SLEEP); |
| 136 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | #ifdef XFS_ATTR_TRACE |
| 138 | xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_SLEEP); |
| 139 | #endif |
| 140 | #ifdef XFS_DIR2_TRACE |
| 141 | xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_SLEEP); |
| 142 | #endif |
| 143 | |
| 144 | xfs_dir_startup(); |
| 145 | |
| 146 | #if (defined(DEBUG) || defined(INDUCE_IO_ERROR)) |
| 147 | xfs_error_test_init(); |
| 148 | #endif /* DEBUG || INDUCE_IO_ERROR */ |
| 149 | |
| 150 | xfs_init_procfs(); |
| 151 | xfs_sysctl_register(); |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | void |
| 156 | xfs_cleanup(void) |
| 157 | { |
| 158 | extern kmem_zone_t *xfs_bmap_free_item_zone; |
| 159 | extern kmem_zone_t *xfs_btree_cur_zone; |
| 160 | extern kmem_zone_t *xfs_inode_zone; |
| 161 | extern kmem_zone_t *xfs_trans_zone; |
| 162 | extern kmem_zone_t *xfs_da_state_zone; |
| 163 | extern kmem_zone_t *xfs_dabuf_zone; |
| 164 | extern kmem_zone_t *xfs_efd_zone; |
| 165 | extern kmem_zone_t *xfs_efi_zone; |
| 166 | extern kmem_zone_t *xfs_buf_item_zone; |
David Chinner | da353b0 | 2007-08-28 14:00:13 +1000 | [diff] [blame] | 167 | extern kmem_zone_t *xfs_icluster_zone; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
| 169 | xfs_cleanup_procfs(); |
| 170 | xfs_sysctl_unregister(); |
| 171 | xfs_refcache_destroy(); |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 172 | xfs_filestream_uninit(); |
| 173 | xfs_mru_cache_uninit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | xfs_acl_zone_destroy(xfs_acl_zone); |
| 175 | |
| 176 | #ifdef XFS_DIR2_TRACE |
| 177 | ktrace_free(xfs_dir2_trace_buf); |
| 178 | #endif |
| 179 | #ifdef XFS_ATTR_TRACE |
| 180 | ktrace_free(xfs_attr_trace_buf); |
| 181 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | #ifdef XFS_BMBT_TRACE |
| 183 | ktrace_free(xfs_bmbt_trace_buf); |
| 184 | #endif |
| 185 | #ifdef XFS_BMAP_TRACE |
| 186 | ktrace_free(xfs_bmap_trace_buf); |
| 187 | #endif |
| 188 | #ifdef XFS_ALLOC_TRACE |
| 189 | ktrace_free(xfs_alloc_trace_buf); |
| 190 | #endif |
| 191 | |
Nathan Scott | 3758dee | 2006-03-22 12:47:28 +1100 | [diff] [blame] | 192 | kmem_zone_destroy(xfs_bmap_free_item_zone); |
| 193 | kmem_zone_destroy(xfs_btree_cur_zone); |
| 194 | kmem_zone_destroy(xfs_inode_zone); |
| 195 | kmem_zone_destroy(xfs_trans_zone); |
| 196 | kmem_zone_destroy(xfs_da_state_zone); |
| 197 | kmem_zone_destroy(xfs_dabuf_zone); |
| 198 | kmem_zone_destroy(xfs_buf_item_zone); |
| 199 | kmem_zone_destroy(xfs_efd_zone); |
| 200 | kmem_zone_destroy(xfs_efi_zone); |
| 201 | kmem_zone_destroy(xfs_ifork_zone); |
| 202 | kmem_zone_destroy(xfs_ili_zone); |
David Chinner | da353b0 | 2007-08-28 14:00:13 +1000 | [diff] [blame] | 203 | kmem_zone_destroy(xfs_icluster_zone); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | /* |
| 207 | * xfs_start_flags |
| 208 | * |
| 209 | * This function fills in xfs_mount_t fields based on mount args. |
| 210 | * Note: the superblock has _not_ yet been read in. |
| 211 | */ |
| 212 | STATIC int |
| 213 | xfs_start_flags( |
Nathan Scott | b83bd13 | 2006-06-09 16:48:30 +1000 | [diff] [blame] | 214 | struct bhv_vfs *vfs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | struct xfs_mount_args *ap, |
| 216 | struct xfs_mount *mp) |
| 217 | { |
| 218 | /* Values are in BBs */ |
| 219 | if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) { |
| 220 | /* |
| 221 | * At this point the superblock has not been read |
| 222 | * in, therefore we do not know the block size. |
| 223 | * Before the mount call ends we will convert |
| 224 | * these to FSBs. |
| 225 | */ |
| 226 | mp->m_dalign = ap->sunit; |
| 227 | mp->m_swidth = ap->swidth; |
| 228 | } |
| 229 | |
| 230 | if (ap->logbufs != -1 && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | ap->logbufs != 0 && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | (ap->logbufs < XLOG_MIN_ICLOGS || |
| 233 | ap->logbufs > XLOG_MAX_ICLOGS)) { |
| 234 | cmn_err(CE_WARN, |
| 235 | "XFS: invalid logbufs value: %d [not %d-%d]", |
| 236 | ap->logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); |
| 237 | return XFS_ERROR(EINVAL); |
| 238 | } |
| 239 | mp->m_logbufs = ap->logbufs; |
| 240 | if (ap->logbufsize != -1 && |
Nathan Scott | cfcbbbd | 2005-11-02 15:12:04 +1100 | [diff] [blame] | 241 | ap->logbufsize != 0 && |
Eric Sandeen | dcb3b83 | 2007-08-16 16:25:33 +1000 | [diff] [blame] | 242 | (ap->logbufsize < XLOG_MIN_RECORD_BSIZE || |
| 243 | ap->logbufsize > XLOG_MAX_RECORD_BSIZE || |
| 244 | !is_power_of_2(ap->logbufsize))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | cmn_err(CE_WARN, |
| 246 | "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", |
| 247 | ap->logbufsize); |
| 248 | return XFS_ERROR(EINVAL); |
| 249 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | mp->m_logbsize = ap->logbufsize; |
| 251 | mp->m_fsname_len = strlen(ap->fsname) + 1; |
| 252 | mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP); |
| 253 | strcpy(mp->m_fsname, ap->fsname); |
Nathan Scott | fc1f8c1 | 2005-11-02 11:44:33 +1100 | [diff] [blame] | 254 | if (ap->rtname[0]) { |
| 255 | mp->m_rtname = kmem_alloc(strlen(ap->rtname) + 1, KM_SLEEP); |
| 256 | strcpy(mp->m_rtname, ap->rtname); |
| 257 | } |
| 258 | if (ap->logname[0]) { |
| 259 | mp->m_logname = kmem_alloc(strlen(ap->logname) + 1, KM_SLEEP); |
| 260 | strcpy(mp->m_logname, ap->logname); |
| 261 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
| 263 | if (ap->flags & XFSMNT_WSYNC) |
| 264 | mp->m_flags |= XFS_MOUNT_WSYNC; |
| 265 | #if XFS_BIG_INUMS |
| 266 | if (ap->flags & XFSMNT_INO64) { |
| 267 | mp->m_flags |= XFS_MOUNT_INO64; |
| 268 | mp->m_inoadd = XFS_INO64_OFFSET; |
| 269 | } |
| 270 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | if (ap->flags & XFSMNT_RETERR) |
| 272 | mp->m_flags |= XFS_MOUNT_RETERR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | if (ap->flags & XFSMNT_NOALIGN) |
| 274 | mp->m_flags |= XFS_MOUNT_NOALIGN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | if (ap->flags & XFSMNT_SWALLOC) |
| 276 | mp->m_flags |= XFS_MOUNT_SWALLOC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | if (ap->flags & XFSMNT_OSYNCISOSYNC) |
| 278 | mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | if (ap->flags & XFSMNT_32BITINODES) |
Nathan Scott | c11e2c3 | 2005-11-02 15:11:45 +1100 | [diff] [blame] | 280 | mp->m_flags |= XFS_MOUNT_32BITINODES; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | |
| 282 | if (ap->flags & XFSMNT_IOSIZE) { |
| 283 | if (ap->iosizelog > XFS_MAX_IO_LOG || |
| 284 | ap->iosizelog < XFS_MIN_IO_LOG) { |
| 285 | cmn_err(CE_WARN, |
| 286 | "XFS: invalid log iosize: %d [not %d-%d]", |
| 287 | ap->iosizelog, XFS_MIN_IO_LOG, |
| 288 | XFS_MAX_IO_LOG); |
| 289 | return XFS_ERROR(EINVAL); |
| 290 | } |
| 291 | |
| 292 | mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE; |
| 293 | mp->m_readio_log = mp->m_writeio_log = ap->iosizelog; |
| 294 | } |
| 295 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | if (ap->flags & XFSMNT_IDELETE) |
| 297 | mp->m_flags |= XFS_MOUNT_IDELETE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | if (ap->flags & XFSMNT_DIRSYNC) |
| 299 | mp->m_flags |= XFS_MOUNT_DIRSYNC; |
Nathan Scott | 13059ff | 2006-01-11 15:32:01 +1100 | [diff] [blame] | 300 | if (ap->flags & XFSMNT_ATTR2) |
| 301 | mp->m_flags |= XFS_MOUNT_ATTR2; |
David Chinner | e8c8b3a | 2005-11-02 10:33:05 +1100 | [diff] [blame] | 302 | |
Nathan Scott | e718eeb4 | 2005-11-02 15:09:22 +1100 | [diff] [blame] | 303 | if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE) |
| 304 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; |
| 305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | /* |
| 307 | * no recovery flag requires a read-only mount |
| 308 | */ |
| 309 | if (ap->flags & XFSMNT_NORECOVERY) { |
| 310 | if (!(vfs->vfs_flag & VFS_RDONLY)) { |
| 311 | cmn_err(CE_WARN, |
| 312 | "XFS: tried to mount a FS read-write without recovery!"); |
| 313 | return XFS_ERROR(EINVAL); |
| 314 | } |
| 315 | mp->m_flags |= XFS_MOUNT_NORECOVERY; |
| 316 | } |
| 317 | |
| 318 | if (ap->flags & XFSMNT_NOUUID) |
| 319 | mp->m_flags |= XFS_MOUNT_NOUUID; |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 320 | if (ap->flags & XFSMNT_BARRIER) |
| 321 | mp->m_flags |= XFS_MOUNT_BARRIER; |
Christoph Hellwig | 4ef19dd | 2006-01-11 15:27:18 +1100 | [diff] [blame] | 322 | else |
| 323 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 325 | if (ap->flags2 & XFSMNT2_FILESTREAMS) |
| 326 | mp->m_flags |= XFS_MOUNT_FILESTREAMS; |
| 327 | |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 328 | if (ap->flags & XFSMNT_DMAPI) |
| 329 | vfs->vfs_flag |= VFS_DMI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | /* |
| 334 | * This function fills in xfs_mount_t fields based on mount args. |
| 335 | * Note: the superblock _has_ now been read in. |
| 336 | */ |
| 337 | STATIC int |
| 338 | xfs_finish_flags( |
Nathan Scott | b83bd13 | 2006-06-09 16:48:30 +1000 | [diff] [blame] | 339 | struct bhv_vfs *vfs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | struct xfs_mount_args *ap, |
| 341 | struct xfs_mount *mp) |
| 342 | { |
| 343 | int ronly = (vfs->vfs_flag & VFS_RDONLY); |
| 344 | |
| 345 | /* Fail a mount where the logbuf is smaller then the log stripe */ |
| 346 | if (XFS_SB_VERSION_HASLOGV2(&mp->m_sb)) { |
Nathan Scott | c2cd255 | 2006-01-11 15:35:32 +1100 | [diff] [blame] | 347 | if ((ap->logbufsize <= 0) && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | (mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE)) { |
| 349 | mp->m_logbsize = mp->m_sb.sb_logsunit; |
Nathan Scott | c2cd255 | 2006-01-11 15:35:32 +1100 | [diff] [blame] | 350 | } else if (ap->logbufsize > 0 && |
| 351 | ap->logbufsize < mp->m_sb.sb_logsunit) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | cmn_err(CE_WARN, |
| 353 | "XFS: logbuf size must be greater than or equal to log stripe size"); |
| 354 | return XFS_ERROR(EINVAL); |
| 355 | } |
| 356 | } else { |
| 357 | /* Fail a mount if the logbuf is larger than 32K */ |
| 358 | if (ap->logbufsize > XLOG_BIG_RECORD_BSIZE) { |
| 359 | cmn_err(CE_WARN, |
| 360 | "XFS: logbuf size for version 1 logs must be 16K or 32K"); |
| 361 | return XFS_ERROR(EINVAL); |
| 362 | } |
| 363 | } |
| 364 | |
Nathan Scott | 13059ff | 2006-01-11 15:32:01 +1100 | [diff] [blame] | 365 | if (XFS_SB_VERSION_HASATTR2(&mp->m_sb)) { |
| 366 | mp->m_flags |= XFS_MOUNT_ATTR2; |
| 367 | } |
| 368 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | /* |
| 370 | * prohibit r/w mounts of read-only filesystems |
| 371 | */ |
| 372 | if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { |
| 373 | cmn_err(CE_WARN, |
| 374 | "XFS: cannot mount a read-only filesystem as read-write"); |
| 375 | return XFS_ERROR(EROFS); |
| 376 | } |
| 377 | |
| 378 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | * check for shared mount. |
| 380 | */ |
| 381 | if (ap->flags & XFSMNT_SHARED) { |
| 382 | if (!XFS_SB_VERSION_HASSHARED(&mp->m_sb)) |
| 383 | return XFS_ERROR(EINVAL); |
| 384 | |
| 385 | /* |
| 386 | * For IRIX 6.5, shared mounts must have the shared |
| 387 | * version bit set, have the persistent readonly |
| 388 | * field set, must be version 0 and can only be mounted |
| 389 | * read-only. |
| 390 | */ |
| 391 | if (!ronly || !(mp->m_sb.sb_flags & XFS_SBF_READONLY) || |
| 392 | (mp->m_sb.sb_shared_vn != 0)) |
| 393 | return XFS_ERROR(EINVAL); |
| 394 | |
| 395 | mp->m_flags |= XFS_MOUNT_SHARED; |
| 396 | |
| 397 | /* |
| 398 | * Shared XFS V0 can't deal with DMI. Return EINVAL. |
| 399 | */ |
| 400 | if (mp->m_sb.sb_shared_vn == 0 && (ap->flags & XFSMNT_DMAPI)) |
| 401 | return XFS_ERROR(EINVAL); |
| 402 | } |
| 403 | |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 404 | if (ap->flags & XFSMNT_UQUOTA) { |
| 405 | mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE); |
| 406 | if (ap->flags & XFSMNT_UQUOTAENF) |
| 407 | mp->m_qflags |= XFS_UQUOTA_ENFD; |
| 408 | } |
| 409 | |
| 410 | if (ap->flags & XFSMNT_GQUOTA) { |
| 411 | mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); |
| 412 | if (ap->flags & XFSMNT_GQUOTAENF) |
| 413 | mp->m_qflags |= XFS_OQUOTA_ENFD; |
| 414 | } else if (ap->flags & XFSMNT_PQUOTA) { |
| 415 | mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE); |
| 416 | if (ap->flags & XFSMNT_PQUOTAENF) |
| 417 | mp->m_qflags |= XFS_OQUOTA_ENFD; |
| 418 | } |
| 419 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | /* |
| 424 | * xfs_mount |
| 425 | * |
| 426 | * The file system configurations are: |
| 427 | * (1) device (partition) with data and internal log |
| 428 | * (2) logical volume with data and log subvolumes. |
| 429 | * (3) logical volume with data, log, and realtime subvolumes. |
| 430 | * |
| 431 | * We only have to handle opening the log and realtime volumes here if |
| 432 | * they are present. The data subvolume has already been opened by |
| 433 | * get_sb_bdev() and is stored in vfsp->vfs_super->s_bdev. |
| 434 | */ |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 435 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | xfs_mount( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 437 | struct xfs_mount *mp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | struct xfs_mount_args *args, |
| 439 | cred_t *credp) |
| 440 | { |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 441 | struct bhv_vfs *vfsp = XFS_MTOVFS(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | struct block_device *ddev, *logdev, *rtdev; |
| 443 | int flags = 0, error; |
| 444 | |
| 445 | ddev = vfsp->vfs_super->s_bdev; |
| 446 | logdev = rtdev = NULL; |
| 447 | |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 448 | error = xfs_dmops_get(mp, args); |
| 449 | if (error) |
| 450 | return error; |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 451 | error = xfs_qmops_get(mp, args); |
| 452 | if (error) |
| 453 | return error; |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 454 | |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame^] | 455 | mp->m_io_ops = xfs_iocore_xfs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | |
Nathan Scott | 764d1f8 | 2006-03-31 13:04:17 +1000 | [diff] [blame] | 457 | if (args->flags & XFSMNT_QUIET) |
| 458 | flags |= XFS_MFSI_QUIET; |
| 459 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | /* |
| 461 | * Open real time and log devices - order is important. |
| 462 | */ |
| 463 | if (args->logname[0]) { |
| 464 | error = xfs_blkdev_get(mp, args->logname, &logdev); |
| 465 | if (error) |
| 466 | return error; |
| 467 | } |
| 468 | if (args->rtname[0]) { |
| 469 | error = xfs_blkdev_get(mp, args->rtname, &rtdev); |
| 470 | if (error) { |
| 471 | xfs_blkdev_put(logdev); |
| 472 | return error; |
| 473 | } |
| 474 | |
| 475 | if (rtdev == ddev || rtdev == logdev) { |
| 476 | cmn_err(CE_WARN, |
| 477 | "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev."); |
| 478 | xfs_blkdev_put(logdev); |
| 479 | xfs_blkdev_put(rtdev); |
| 480 | return EINVAL; |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | /* |
| 485 | * Setup xfs_mount buffer target pointers |
| 486 | */ |
| 487 | error = ENOMEM; |
| 488 | mp->m_ddev_targp = xfs_alloc_buftarg(ddev, 0); |
| 489 | if (!mp->m_ddev_targp) { |
| 490 | xfs_blkdev_put(logdev); |
| 491 | xfs_blkdev_put(rtdev); |
| 492 | return error; |
| 493 | } |
| 494 | if (rtdev) { |
| 495 | mp->m_rtdev_targp = xfs_alloc_buftarg(rtdev, 1); |
Jesper Juhl | 49ee6c9 | 2007-08-16 16:25:42 +1000 | [diff] [blame] | 496 | if (!mp->m_rtdev_targp) { |
| 497 | xfs_blkdev_put(logdev); |
| 498 | xfs_blkdev_put(rtdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | goto error0; |
Jesper Juhl | 49ee6c9 | 2007-08-16 16:25:42 +1000 | [diff] [blame] | 500 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | } |
| 502 | mp->m_logdev_targp = (logdev && logdev != ddev) ? |
| 503 | xfs_alloc_buftarg(logdev, 1) : mp->m_ddev_targp; |
Jesper Juhl | 49ee6c9 | 2007-08-16 16:25:42 +1000 | [diff] [blame] | 504 | if (!mp->m_logdev_targp) { |
| 505 | xfs_blkdev_put(logdev); |
| 506 | xfs_blkdev_put(rtdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | goto error0; |
Jesper Juhl | 49ee6c9 | 2007-08-16 16:25:42 +1000 | [diff] [blame] | 508 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | |
| 510 | /* |
| 511 | * Setup flags based on mount(2) options and then the superblock |
| 512 | */ |
| 513 | error = xfs_start_flags(vfsp, args, mp); |
| 514 | if (error) |
| 515 | goto error1; |
Nathan Scott | 764d1f8 | 2006-03-31 13:04:17 +1000 | [diff] [blame] | 516 | error = xfs_readsb(mp, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | if (error) |
| 518 | goto error1; |
| 519 | error = xfs_finish_flags(vfsp, args, mp); |
| 520 | if (error) |
| 521 | goto error2; |
| 522 | |
| 523 | /* |
| 524 | * Setup xfs_mount buffer target pointers based on superblock |
| 525 | */ |
| 526 | error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize, |
| 527 | mp->m_sb.sb_sectsize); |
| 528 | if (!error && logdev && logdev != ddev) { |
| 529 | unsigned int log_sector_size = BBSIZE; |
| 530 | |
| 531 | if (XFS_SB_VERSION_HASSECTOR(&mp->m_sb)) |
| 532 | log_sector_size = mp->m_sb.sb_logsectsize; |
| 533 | error = xfs_setsize_buftarg(mp->m_logdev_targp, |
| 534 | mp->m_sb.sb_blocksize, |
| 535 | log_sector_size); |
| 536 | } |
| 537 | if (!error && rtdev) |
| 538 | error = xfs_setsize_buftarg(mp->m_rtdev_targp, |
| 539 | mp->m_sb.sb_blocksize, |
| 540 | mp->m_sb.sb_sectsize); |
| 541 | if (error) |
| 542 | goto error2; |
| 543 | |
Nathan Scott | b2ea401 | 2006-07-28 17:05:13 +1000 | [diff] [blame] | 544 | if (mp->m_flags & XFS_MOUNT_BARRIER) |
Christoph Hellwig | c7d437d | 2006-01-11 15:28:56 +1100 | [diff] [blame] | 545 | xfs_mountfs_check_barriers(mp); |
| 546 | |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 547 | if ((error = xfs_filestream_mount(mp))) |
| 548 | goto error2; |
| 549 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | error = XFS_IOINIT(vfsp, args, flags); |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 551 | if (error) |
| 552 | goto error2; |
| 553 | |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 554 | XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, args->mtpt, args->fsname); |
| 555 | |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 556 | return 0; |
| 557 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | error2: |
| 559 | if (mp->m_sb_bp) |
| 560 | xfs_freesb(mp); |
| 561 | error1: |
| 562 | xfs_binval(mp->m_ddev_targp); |
| 563 | if (logdev && logdev != ddev) |
| 564 | xfs_binval(mp->m_logdev_targp); |
| 565 | if (rtdev) |
| 566 | xfs_binval(mp->m_rtdev_targp); |
| 567 | error0: |
| 568 | xfs_unmountfs_close(mp, credp); |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 569 | xfs_qmops_put(mp); |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 570 | xfs_dmops_put(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | return error; |
| 572 | } |
| 573 | |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 574 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | xfs_unmount( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 576 | xfs_mount_t *mp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | int flags, |
| 578 | cred_t *credp) |
| 579 | { |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 580 | bhv_vfs_t *vfsp = XFS_MTOVFS(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | xfs_inode_t *rip; |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 582 | bhv_vnode_t *rvp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | int unmount_event_wanted = 0; |
| 584 | int unmount_event_flags = 0; |
| 585 | int xfs_unmountfs_needed = 0; |
| 586 | int error; |
| 587 | |
| 588 | rip = mp->m_rootip; |
| 589 | rvp = XFS_ITOV(rip); |
| 590 | |
Eric Sandeen | 948c6d4f | 2007-08-23 16:19:57 +1000 | [diff] [blame] | 591 | #ifdef HAVE_DMAPI |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | if (vfsp->vfs_flag & VFS_DMI) { |
| 593 | error = XFS_SEND_PREUNMOUNT(mp, vfsp, |
| 594 | rvp, DM_RIGHT_NULL, rvp, DM_RIGHT_NULL, |
| 595 | NULL, NULL, 0, 0, |
| 596 | (mp->m_dmevmask & (1<<DM_EVENT_PREUNMOUNT))? |
| 597 | 0:DM_FLAGS_UNWANTED); |
| 598 | if (error) |
| 599 | return XFS_ERROR(error); |
| 600 | unmount_event_wanted = 1; |
| 601 | unmount_event_flags = (mp->m_dmevmask & (1<<DM_EVENT_UNMOUNT))? |
| 602 | 0 : DM_FLAGS_UNWANTED; |
| 603 | } |
Eric Sandeen | 948c6d4f | 2007-08-23 16:19:57 +1000 | [diff] [blame] | 604 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | /* |
| 606 | * First blow any referenced inode from this file system |
| 607 | * out of the reference cache, and delete the timer. |
| 608 | */ |
| 609 | xfs_refcache_purge_mp(mp); |
| 610 | |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 611 | /* |
| 612 | * Blow away any referenced inode in the filestreams cache. |
| 613 | * This can and will cause log traffic as inodes go inactive |
| 614 | * here. |
| 615 | */ |
| 616 | xfs_filestream_unmount(mp); |
| 617 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | XFS_bflush(mp->m_ddev_targp); |
| 619 | error = xfs_unmount_flush(mp, 0); |
| 620 | if (error) |
| 621 | goto out; |
| 622 | |
| 623 | ASSERT(vn_count(rvp) == 1); |
| 624 | |
| 625 | /* |
| 626 | * Drop the reference count |
| 627 | */ |
| 628 | VN_RELE(rvp); |
| 629 | |
| 630 | /* |
| 631 | * If we're forcing a shutdown, typically because of a media error, |
| 632 | * we want to make sure we invalidate dirty pages that belong to |
| 633 | * referenced vnodes as well. |
| 634 | */ |
| 635 | if (XFS_FORCED_SHUTDOWN(mp)) { |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 636 | error = xfs_sync(mp, SYNC_WAIT | SYNC_CLOSE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | ASSERT(error != EFSCORRUPTED); |
| 638 | } |
| 639 | xfs_unmountfs_needed = 1; |
| 640 | |
| 641 | out: |
| 642 | /* Send DMAPI event, if required. |
| 643 | * Then do xfs_unmountfs() if needed. |
| 644 | * Then return error (or zero). |
| 645 | */ |
| 646 | if (unmount_event_wanted) { |
| 647 | /* Note: mp structure must still exist for |
| 648 | * XFS_SEND_UNMOUNT() call. |
| 649 | */ |
| 650 | XFS_SEND_UNMOUNT(mp, vfsp, error == 0 ? rvp : NULL, |
| 651 | DM_RIGHT_NULL, 0, error, unmount_event_flags); |
| 652 | } |
| 653 | if (xfs_unmountfs_needed) { |
| 654 | /* |
| 655 | * Call common unmount function to flush to disk |
| 656 | * and free the super block buffer & mount structures. |
| 657 | */ |
| 658 | xfs_unmountfs(mp, credp); |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 659 | xfs_qmops_put(mp); |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 660 | xfs_dmops_put(mp); |
Christoph Hellwig | f541d27 | 2007-08-29 11:53:22 +1000 | [diff] [blame] | 661 | kmem_free(mp, sizeof(xfs_mount_t)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | return XFS_ERROR(error); |
| 665 | } |
| 666 | |
Christoph Hellwig | f898d6c | 2005-06-21 15:40:48 +1000 | [diff] [blame] | 667 | STATIC int |
| 668 | xfs_quiesce_fs( |
| 669 | xfs_mount_t *mp) |
| 670 | { |
| 671 | int count = 0, pincount; |
Nathan Scott | 3758dee | 2006-03-22 12:47:28 +1100 | [diff] [blame] | 672 | |
Christoph Hellwig | f898d6c | 2005-06-21 15:40:48 +1000 | [diff] [blame] | 673 | xfs_refcache_purge_mp(mp); |
| 674 | xfs_flush_buftarg(mp->m_ddev_targp, 0); |
| 675 | xfs_finish_reclaim_all(mp, 0); |
| 676 | |
| 677 | /* This loop must run at least twice. |
| 678 | * The first instance of the loop will flush |
| 679 | * most meta data but that will generate more |
| 680 | * meta data (typically directory updates). |
| 681 | * Which then must be flushed and logged before |
| 682 | * we can write the unmount record. |
Nathan Scott | 3758dee | 2006-03-22 12:47:28 +1100 | [diff] [blame] | 683 | */ |
Christoph Hellwig | f898d6c | 2005-06-21 15:40:48 +1000 | [diff] [blame] | 684 | do { |
David Chinner | 516b2e7 | 2007-06-18 16:50:48 +1000 | [diff] [blame] | 685 | xfs_syncsub(mp, SYNC_INODE_QUIESCE, NULL); |
Christoph Hellwig | f898d6c | 2005-06-21 15:40:48 +1000 | [diff] [blame] | 686 | pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1); |
| 687 | if (!pincount) { |
| 688 | delay(50); |
| 689 | count++; |
| 690 | } |
| 691 | } while (count < 2); |
| 692 | |
| 693 | return 0; |
| 694 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | |
David Chinner | 516b2e7 | 2007-06-18 16:50:48 +1000 | [diff] [blame] | 696 | /* |
| 697 | * Second stage of a quiesce. The data is already synced, now we have to take |
| 698 | * care of the metadata. New transactions are already blocked, so we need to |
| 699 | * wait for any remaining transactions to drain out before proceding. |
| 700 | */ |
| 701 | STATIC void |
| 702 | xfs_attr_quiesce( |
| 703 | xfs_mount_t *mp) |
| 704 | { |
| 705 | /* wait for all modifications to complete */ |
| 706 | while (atomic_read(&mp->m_active_trans) > 0) |
| 707 | delay(100); |
| 708 | |
| 709 | /* flush inodes and push all remaining buffers out to disk */ |
| 710 | xfs_quiesce_fs(mp); |
| 711 | |
| 712 | ASSERT_ALWAYS(atomic_read(&mp->m_active_trans) == 0); |
| 713 | |
| 714 | /* Push the superblock and write an unmount record */ |
| 715 | xfs_log_sbcount(mp, 1); |
| 716 | xfs_log_unmount_write(mp); |
| 717 | xfs_unmountfs_writesb(mp); |
| 718 | } |
| 719 | |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 720 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | xfs_mntupdate( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 722 | struct xfs_mount *mp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | int *flags, |
| 724 | struct xfs_mount_args *args) |
| 725 | { |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 726 | struct bhv_vfs *vfsp = XFS_MTOVFS(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | |
Nathan Scott | d08d389 | 2006-05-08 19:51:28 +1000 | [diff] [blame] | 728 | if (!(*flags & MS_RDONLY)) { /* rw/ro -> rw */ |
| 729 | if (vfsp->vfs_flag & VFS_RDONLY) |
| 730 | vfsp->vfs_flag &= ~VFS_RDONLY; |
| 731 | if (args->flags & XFSMNT_BARRIER) { |
| 732 | mp->m_flags |= XFS_MOUNT_BARRIER; |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 733 | xfs_mountfs_check_barriers(mp); |
Nathan Scott | d08d389 | 2006-05-08 19:51:28 +1000 | [diff] [blame] | 734 | } else { |
| 735 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
| 736 | } |
| 737 | } else if (!(vfsp->vfs_flag & VFS_RDONLY)) { /* rw -> ro */ |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 738 | xfs_filestream_flush(mp); |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame^] | 739 | xfs_sync(mp, SYNC_DATA_QUIESCE); |
David Chinner | 516b2e7 | 2007-06-18 16:50:48 +1000 | [diff] [blame] | 740 | xfs_attr_quiesce(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | vfsp->vfs_flag |= VFS_RDONLY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | return 0; |
| 744 | } |
| 745 | |
| 746 | /* |
| 747 | * xfs_unmount_flush implements a set of flush operation on special |
| 748 | * inodes, which are needed as a separate set of operations so that |
| 749 | * they can be called as part of relocation process. |
| 750 | */ |
| 751 | int |
| 752 | xfs_unmount_flush( |
| 753 | xfs_mount_t *mp, /* Mount structure we are getting |
| 754 | rid of. */ |
| 755 | int relocation) /* Called from vfs relocation. */ |
| 756 | { |
| 757 | xfs_inode_t *rip = mp->m_rootip; |
| 758 | xfs_inode_t *rbmip; |
| 759 | xfs_inode_t *rsumip = NULL; |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 760 | bhv_vnode_t *rvp = XFS_ITOV(rip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | int error; |
| 762 | |
Lachlan McIlroy | f7c66ce | 2007-05-08 13:50:19 +1000 | [diff] [blame] | 763 | xfs_ilock(rip, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | xfs_iflock(rip); |
| 765 | |
| 766 | /* |
| 767 | * Flush out the real time inodes. |
| 768 | */ |
| 769 | if ((rbmip = mp->m_rbmip) != NULL) { |
| 770 | xfs_ilock(rbmip, XFS_ILOCK_EXCL); |
| 771 | xfs_iflock(rbmip); |
| 772 | error = xfs_iflush(rbmip, XFS_IFLUSH_SYNC); |
| 773 | xfs_iunlock(rbmip, XFS_ILOCK_EXCL); |
| 774 | |
| 775 | if (error == EFSCORRUPTED) |
| 776 | goto fscorrupt_out; |
| 777 | |
| 778 | ASSERT(vn_count(XFS_ITOV(rbmip)) == 1); |
| 779 | |
| 780 | rsumip = mp->m_rsumip; |
| 781 | xfs_ilock(rsumip, XFS_ILOCK_EXCL); |
| 782 | xfs_iflock(rsumip); |
| 783 | error = xfs_iflush(rsumip, XFS_IFLUSH_SYNC); |
| 784 | xfs_iunlock(rsumip, XFS_ILOCK_EXCL); |
| 785 | |
| 786 | if (error == EFSCORRUPTED) |
| 787 | goto fscorrupt_out; |
| 788 | |
| 789 | ASSERT(vn_count(XFS_ITOV(rsumip)) == 1); |
| 790 | } |
| 791 | |
| 792 | /* |
| 793 | * Synchronously flush root inode to disk |
| 794 | */ |
| 795 | error = xfs_iflush(rip, XFS_IFLUSH_SYNC); |
| 796 | if (error == EFSCORRUPTED) |
| 797 | goto fscorrupt_out2; |
| 798 | |
| 799 | if (vn_count(rvp) != 1 && !relocation) { |
| 800 | xfs_iunlock(rip, XFS_ILOCK_EXCL); |
| 801 | return XFS_ERROR(EBUSY); |
| 802 | } |
| 803 | |
| 804 | /* |
| 805 | * Release dquot that rootinode, rbmino and rsumino might be holding, |
| 806 | * flush and purge the quota inodes. |
| 807 | */ |
| 808 | error = XFS_QM_UNMOUNT(mp); |
| 809 | if (error == EFSCORRUPTED) |
| 810 | goto fscorrupt_out2; |
| 811 | |
| 812 | if (rbmip) { |
| 813 | VN_RELE(XFS_ITOV(rbmip)); |
| 814 | VN_RELE(XFS_ITOV(rsumip)); |
| 815 | } |
| 816 | |
| 817 | xfs_iunlock(rip, XFS_ILOCK_EXCL); |
| 818 | return 0; |
| 819 | |
| 820 | fscorrupt_out: |
| 821 | xfs_ifunlock(rip); |
| 822 | |
| 823 | fscorrupt_out2: |
| 824 | xfs_iunlock(rip, XFS_ILOCK_EXCL); |
| 825 | |
| 826 | return XFS_ERROR(EFSCORRUPTED); |
| 827 | } |
| 828 | |
| 829 | /* |
| 830 | * xfs_root extracts the root vnode from a vfs. |
| 831 | * |
| 832 | * vfsp -- the vfs struct for the desired file system |
| 833 | * vpp -- address of the caller's vnode pointer which should be |
| 834 | * set to the desired fs root vnode |
| 835 | */ |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 836 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | xfs_root( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 838 | xfs_mount_t *mp, |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 839 | bhv_vnode_t **vpp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | { |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 841 | bhv_vnode_t *vp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 843 | vp = XFS_ITOV(mp->m_rootip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | VN_HOLD(vp); |
| 845 | *vpp = vp; |
| 846 | return 0; |
| 847 | } |
| 848 | |
| 849 | /* |
| 850 | * xfs_statvfs |
| 851 | * |
| 852 | * Fill in the statvfs structure for the given file system. We use |
| 853 | * the superblock lock in the mount structure to ensure a consistent |
| 854 | * snapshot of the counters returned. |
| 855 | */ |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 856 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | xfs_statvfs( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 858 | xfs_mount_t *mp, |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 859 | bhv_statvfs_t *statp, |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 860 | bhv_vnode_t *vp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | { |
| 862 | __uint64_t fakeinos; |
| 863 | xfs_extlen_t lsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | xfs_sb_t *sbp; |
| 865 | unsigned long s; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | sbp = &(mp->m_sb); |
| 868 | |
| 869 | statp->f_type = XFS_SB_MAGIC; |
| 870 | |
David Chinner | dbcabad | 2007-02-10 18:36:17 +1100 | [diff] [blame] | 871 | xfs_icsb_sync_counters_flags(mp, XFS_ICSB_LAZY_COUNT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | s = XFS_SB_LOCK(mp); |
| 873 | statp->f_bsize = sbp->sb_blocksize; |
| 874 | lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0; |
| 875 | statp->f_blocks = sbp->sb_dblocks - lsize; |
David Chinner | 4be536d | 2006-09-07 14:26:50 +1000 | [diff] [blame] | 876 | statp->f_bfree = statp->f_bavail = |
| 877 | sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | fakeinos = statp->f_bfree << sbp->sb_inopblog; |
| 879 | #if XFS_BIG_INUMS |
| 880 | fakeinos += mp->m_inoadd; |
| 881 | #endif |
| 882 | statp->f_files = |
| 883 | MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER); |
| 884 | if (mp->m_maxicount) |
| 885 | #if XFS_BIG_INUMS |
| 886 | if (!mp->m_inoadd) |
| 887 | #endif |
| 888 | statp->f_files = min_t(typeof(statp->f_files), |
| 889 | statp->f_files, |
| 890 | mp->m_maxicount); |
| 891 | statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree); |
| 892 | XFS_SB_UNLOCK(mp, s); |
| 893 | |
Nathan Scott | cde410a | 2005-09-05 11:47:01 +1000 | [diff] [blame] | 894 | xfs_statvfs_fsid(statp, mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | statp->f_namelen = MAXNAMELEN - 1; |
| 896 | |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 897 | if (vp) |
| 898 | XFS_QM_DQSTATVFS(xfs_vtoi(vp), statp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | return 0; |
| 900 | } |
| 901 | |
| 902 | |
| 903 | /* |
| 904 | * xfs_sync flushes any pending I/O to file system vfsp. |
| 905 | * |
| 906 | * This routine is called by vfs_sync() to make sure that things make it |
| 907 | * out to disk eventually, on sync() system calls to flush out everything, |
| 908 | * and when the file system is unmounted. For the vfs_sync() case, all |
| 909 | * we really need to do is sync out the log to make all of our meta-data |
| 910 | * updates permanent (except for timestamps). For calls from pflushd(), |
| 911 | * dirty pages are kept moving by calling pdflush() on the inodes |
| 912 | * containing them. We also flush the inodes that we can lock without |
| 913 | * sleeping and the superblock if we can lock it without sleeping from |
| 914 | * vfs_sync() so that items at the tail of the log are always moving out. |
| 915 | * |
| 916 | * Flags: |
| 917 | * SYNC_BDFLUSH - We're being called from vfs_sync() so we don't want |
| 918 | * to sleep if we can help it. All we really need |
| 919 | * to do is ensure that the log is synced at least |
| 920 | * periodically. We also push the inodes and |
| 921 | * superblock if we can lock them without sleeping |
| 922 | * and they are not pinned. |
| 923 | * SYNC_ATTR - We need to flush the inodes. If SYNC_BDFLUSH is not |
| 924 | * set, then we really want to lock each inode and flush |
| 925 | * it. |
| 926 | * SYNC_WAIT - All the flushes that take place in this call should |
| 927 | * be synchronous. |
| 928 | * SYNC_DELWRI - This tells us to push dirty pages associated with |
| 929 | * inodes. SYNC_WAIT and SYNC_BDFLUSH are used to |
| 930 | * determine if they should be flushed sync, async, or |
| 931 | * delwri. |
| 932 | * SYNC_CLOSE - This flag is passed when the system is being |
Nathan Scott | c41564b | 2006-03-29 08:55:14 +1000 | [diff] [blame] | 933 | * unmounted. We should sync and invalidate everything. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | * SYNC_FSDATA - This indicates that the caller would like to make |
| 935 | * sure the superblock is safe on disk. We can ensure |
Nathan Scott | c41564b | 2006-03-29 08:55:14 +1000 | [diff] [blame] | 936 | * this by simply making sure the log gets flushed |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | * if SYNC_BDFLUSH is set, and by actually writing it |
| 938 | * out otherwise. |
David Chinner | 3c0dc77 | 2007-02-10 18:37:22 +1100 | [diff] [blame] | 939 | * SYNC_IOWAIT - The caller wants us to wait for all data I/O to complete |
| 940 | * before we return (including direct I/O). Forms the drain |
| 941 | * side of the write barrier needed to safely quiesce the |
| 942 | * filesystem. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | * |
| 944 | */ |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 945 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | xfs_sync( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 947 | xfs_mount_t *mp, |
| 948 | int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | { |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 950 | int error; |
| 951 | |
| 952 | /* |
| 953 | * Get the Quota Manager to flush the dquots. |
| 954 | * |
| 955 | * If XFS quota support is not enabled or this filesystem |
| 956 | * instance does not use quotas XFS_QM_DQSYNC will always |
| 957 | * return zero. |
| 958 | */ |
| 959 | error = XFS_QM_DQSYNC(mp, flags); |
| 960 | if (error) { |
| 961 | /* |
| 962 | * If we got an IO error, we will be shutting down. |
| 963 | * So, there's nothing more for us to do here. |
| 964 | */ |
| 965 | ASSERT(error != EIO || XFS_FORCED_SHUTDOWN(mp)); |
| 966 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 967 | return XFS_ERROR(error); |
| 968 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 970 | if (flags & SYNC_IOWAIT) |
| 971 | xfs_filestream_flush(mp); |
| 972 | |
David Chinner | 2823945 | 2007-02-10 18:36:40 +1100 | [diff] [blame] | 973 | return xfs_syncsub(mp, flags, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | /* |
| 977 | * xfs sync routine for internal use |
| 978 | * |
Nathan Scott | b83bd13 | 2006-06-09 16:48:30 +1000 | [diff] [blame] | 979 | * This routine supports all of the flags defined for the generic vfs_sync |
Lachlan McIlroy | 1f9b3b6 | 2007-02-10 18:35:33 +1100 | [diff] [blame] | 980 | * interface as explained above under xfs_sync. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | * |
| 982 | */ |
Nathan Scott | ee34807 | 2005-11-02 10:32:38 +1100 | [diff] [blame] | 983 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | xfs_sync_inodes( |
| 985 | xfs_mount_t *mp, |
| 986 | int flags, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | int *bypassed) |
| 988 | { |
| 989 | xfs_inode_t *ip = NULL; |
| 990 | xfs_inode_t *ip_next; |
| 991 | xfs_buf_t *bp; |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 992 | bhv_vnode_t *vp = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | int error; |
| 994 | int last_error; |
| 995 | uint64_t fflag; |
| 996 | uint lock_flags; |
| 997 | uint base_lock_flags; |
| 998 | boolean_t mount_locked; |
| 999 | boolean_t vnode_refed; |
| 1000 | int preempt; |
| 1001 | xfs_dinode_t *dip; |
| 1002 | xfs_iptr_t *ipointer; |
| 1003 | #ifdef DEBUG |
| 1004 | boolean_t ipointer_in = B_FALSE; |
| 1005 | |
| 1006 | #define IPOINTER_SET ipointer_in = B_TRUE |
| 1007 | #define IPOINTER_CLR ipointer_in = B_FALSE |
| 1008 | #else |
| 1009 | #define IPOINTER_SET |
| 1010 | #define IPOINTER_CLR |
| 1011 | #endif |
| 1012 | |
| 1013 | |
| 1014 | /* Insert a marker record into the inode list after inode ip. The list |
| 1015 | * must be locked when this is called. After the call the list will no |
| 1016 | * longer be locked. |
| 1017 | */ |
| 1018 | #define IPOINTER_INSERT(ip, mp) { \ |
| 1019 | ASSERT(ipointer_in == B_FALSE); \ |
| 1020 | ipointer->ip_mnext = ip->i_mnext; \ |
| 1021 | ipointer->ip_mprev = ip; \ |
| 1022 | ip->i_mnext = (xfs_inode_t *)ipointer; \ |
| 1023 | ipointer->ip_mnext->i_mprev = (xfs_inode_t *)ipointer; \ |
| 1024 | preempt = 0; \ |
| 1025 | XFS_MOUNT_IUNLOCK(mp); \ |
| 1026 | mount_locked = B_FALSE; \ |
| 1027 | IPOINTER_SET; \ |
| 1028 | } |
| 1029 | |
| 1030 | /* Remove the marker from the inode list. If the marker was the only item |
| 1031 | * in the list then there are no remaining inodes and we should zero out |
| 1032 | * the whole list. If we are the current head of the list then move the head |
| 1033 | * past us. |
| 1034 | */ |
| 1035 | #define IPOINTER_REMOVE(ip, mp) { \ |
| 1036 | ASSERT(ipointer_in == B_TRUE); \ |
| 1037 | if (ipointer->ip_mnext != (xfs_inode_t *)ipointer) { \ |
| 1038 | ip = ipointer->ip_mnext; \ |
| 1039 | ip->i_mprev = ipointer->ip_mprev; \ |
| 1040 | ipointer->ip_mprev->i_mnext = ip; \ |
| 1041 | if (mp->m_inodes == (xfs_inode_t *)ipointer) { \ |
| 1042 | mp->m_inodes = ip; \ |
| 1043 | } \ |
| 1044 | } else { \ |
| 1045 | ASSERT(mp->m_inodes == (xfs_inode_t *)ipointer); \ |
| 1046 | mp->m_inodes = NULL; \ |
| 1047 | ip = NULL; \ |
| 1048 | } \ |
| 1049 | IPOINTER_CLR; \ |
| 1050 | } |
| 1051 | |
| 1052 | #define XFS_PREEMPT_MASK 0x7f |
| 1053 | |
| 1054 | if (bypassed) |
| 1055 | *bypassed = 0; |
| 1056 | if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY) |
| 1057 | return 0; |
| 1058 | error = 0; |
| 1059 | last_error = 0; |
| 1060 | preempt = 0; |
| 1061 | |
| 1062 | /* Allocate a reference marker */ |
| 1063 | ipointer = (xfs_iptr_t *)kmem_zalloc(sizeof(xfs_iptr_t), KM_SLEEP); |
| 1064 | |
| 1065 | fflag = XFS_B_ASYNC; /* default is don't wait */ |
Nathan Scott | ee34807 | 2005-11-02 10:32:38 +1100 | [diff] [blame] | 1066 | if (flags & (SYNC_BDFLUSH | SYNC_DELWRI)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | fflag = XFS_B_DELWRI; |
| 1068 | if (flags & SYNC_WAIT) |
| 1069 | fflag = 0; /* synchronous overrides all */ |
| 1070 | |
| 1071 | base_lock_flags = XFS_ILOCK_SHARED; |
| 1072 | if (flags & (SYNC_DELWRI | SYNC_CLOSE)) { |
| 1073 | /* |
| 1074 | * We need the I/O lock if we're going to call any of |
| 1075 | * the flush/inval routines. |
| 1076 | */ |
| 1077 | base_lock_flags |= XFS_IOLOCK_SHARED; |
| 1078 | } |
| 1079 | |
| 1080 | XFS_MOUNT_ILOCK(mp); |
| 1081 | |
| 1082 | ip = mp->m_inodes; |
| 1083 | |
| 1084 | mount_locked = B_TRUE; |
| 1085 | vnode_refed = B_FALSE; |
| 1086 | |
| 1087 | IPOINTER_CLR; |
| 1088 | |
| 1089 | do { |
| 1090 | ASSERT(ipointer_in == B_FALSE); |
| 1091 | ASSERT(vnode_refed == B_FALSE); |
| 1092 | |
| 1093 | lock_flags = base_lock_flags; |
| 1094 | |
| 1095 | /* |
| 1096 | * There were no inodes in the list, just break out |
| 1097 | * of the loop. |
| 1098 | */ |
| 1099 | if (ip == NULL) { |
| 1100 | break; |
| 1101 | } |
| 1102 | |
| 1103 | /* |
| 1104 | * We found another sync thread marker - skip it |
| 1105 | */ |
| 1106 | if (ip->i_mount == NULL) { |
| 1107 | ip = ip->i_mnext; |
| 1108 | continue; |
| 1109 | } |
| 1110 | |
| 1111 | vp = XFS_ITOV_NULL(ip); |
| 1112 | |
| 1113 | /* |
| 1114 | * If the vnode is gone then this is being torn down, |
| 1115 | * call reclaim if it is flushed, else let regular flush |
| 1116 | * code deal with it later in the loop. |
| 1117 | */ |
| 1118 | |
| 1119 | if (vp == NULL) { |
| 1120 | /* Skip ones already in reclaim */ |
| 1121 | if (ip->i_flags & XFS_IRECLAIM) { |
| 1122 | ip = ip->i_mnext; |
| 1123 | continue; |
| 1124 | } |
| 1125 | if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) { |
| 1126 | ip = ip->i_mnext; |
| 1127 | } else if ((xfs_ipincount(ip) == 0) && |
| 1128 | xfs_iflock_nowait(ip)) { |
| 1129 | IPOINTER_INSERT(ip, mp); |
| 1130 | |
| 1131 | xfs_finish_reclaim(ip, 1, |
| 1132 | XFS_IFLUSH_DELWRI_ELSE_ASYNC); |
| 1133 | |
| 1134 | XFS_MOUNT_ILOCK(mp); |
| 1135 | mount_locked = B_TRUE; |
| 1136 | IPOINTER_REMOVE(ip, mp); |
| 1137 | } else { |
| 1138 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
| 1139 | ip = ip->i_mnext; |
| 1140 | } |
| 1141 | continue; |
| 1142 | } |
| 1143 | |
| 1144 | if (VN_BAD(vp)) { |
| 1145 | ip = ip->i_mnext; |
| 1146 | continue; |
| 1147 | } |
| 1148 | |
| 1149 | if (XFS_FORCED_SHUTDOWN(mp) && !(flags & SYNC_CLOSE)) { |
| 1150 | XFS_MOUNT_IUNLOCK(mp); |
| 1151 | kmem_free(ipointer, sizeof(xfs_iptr_t)); |
| 1152 | return 0; |
| 1153 | } |
| 1154 | |
| 1155 | /* |
| 1156 | * If this is just vfs_sync() or pflushd() calling |
| 1157 | * then we can skip inodes for which it looks like |
| 1158 | * there is nothing to do. Since we don't have the |
Nathan Scott | c41564b | 2006-03-29 08:55:14 +1000 | [diff] [blame] | 1159 | * inode locked this is racy, but these are periodic |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | * calls so it doesn't matter. For the others we want |
| 1161 | * to know for sure, so we at least try to lock them. |
| 1162 | */ |
| 1163 | if (flags & SYNC_BDFLUSH) { |
| 1164 | if (((ip->i_itemp == NULL) || |
| 1165 | !(ip->i_itemp->ili_format.ilf_fields & |
| 1166 | XFS_ILOG_ALL)) && |
| 1167 | (ip->i_update_core == 0)) { |
| 1168 | ip = ip->i_mnext; |
| 1169 | continue; |
| 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | /* |
| 1174 | * Try to lock without sleeping. We're out of order with |
| 1175 | * the inode list lock here, so if we fail we need to drop |
| 1176 | * the mount lock and try again. If we're called from |
| 1177 | * bdflush() here, then don't bother. |
| 1178 | * |
| 1179 | * The inode lock here actually coordinates with the |
| 1180 | * almost spurious inode lock in xfs_ireclaim() to prevent |
| 1181 | * the vnode we handle here without a reference from |
| 1182 | * being freed while we reference it. If we lock the inode |
| 1183 | * while it's on the mount list here, then the spurious inode |
| 1184 | * lock in xfs_ireclaim() after the inode is pulled from |
| 1185 | * the mount list will sleep until we release it here. |
| 1186 | * This keeps the vnode from being freed while we reference |
Christoph Hellwig | cdb6268 | 2005-09-02 16:24:19 +1000 | [diff] [blame] | 1187 | * it. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | */ |
| 1189 | if (xfs_ilock_nowait(ip, lock_flags) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | if ((flags & SYNC_BDFLUSH) || (vp == NULL)) { |
| 1191 | ip = ip->i_mnext; |
| 1192 | continue; |
| 1193 | } |
| 1194 | |
Christoph Hellwig | cdb6268 | 2005-09-02 16:24:19 +1000 | [diff] [blame] | 1195 | vp = vn_grab(vp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | if (vp == NULL) { |
Christoph Hellwig | cdb6268 | 2005-09-02 16:24:19 +1000 | [diff] [blame] | 1197 | ip = ip->i_mnext; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | continue; |
| 1199 | } |
| 1200 | |
Christoph Hellwig | cdb6268 | 2005-09-02 16:24:19 +1000 | [diff] [blame] | 1201 | IPOINTER_INSERT(ip, mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | xfs_ilock(ip, lock_flags); |
| 1203 | |
| 1204 | ASSERT(vp == XFS_ITOV(ip)); |
| 1205 | ASSERT(ip->i_mount == mp); |
| 1206 | |
| 1207 | vnode_refed = B_TRUE; |
| 1208 | } |
| 1209 | |
| 1210 | /* From here on in the loop we may have a marker record |
| 1211 | * in the inode list. |
| 1212 | */ |
| 1213 | |
David Chinner | 40095b6 | 2007-05-14 18:24:09 +1000 | [diff] [blame] | 1214 | /* |
| 1215 | * If we have to flush data or wait for I/O completion |
| 1216 | * we need to drop the ilock that we currently hold. |
| 1217 | * If we need to drop the lock, insert a marker if we |
| 1218 | * have not already done so. |
| 1219 | */ |
| 1220 | if ((flags & (SYNC_CLOSE|SYNC_IOWAIT)) || |
| 1221 | ((flags & SYNC_DELWRI) && VN_DIRTY(vp))) { |
| 1222 | if (mount_locked) { |
| 1223 | IPOINTER_INSERT(ip, mp); |
| 1224 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1225 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
| 1226 | |
David Chinner | 40095b6 | 2007-05-14 18:24:09 +1000 | [diff] [blame] | 1227 | if (flags & SYNC_CLOSE) { |
| 1228 | /* Shutdown case. Flush and invalidate. */ |
| 1229 | if (XFS_FORCED_SHUTDOWN(mp)) |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame] | 1230 | xfs_tosspages(ip, 0, -1, |
| 1231 | FI_REMAPF); |
David Chinner | 40095b6 | 2007-05-14 18:24:09 +1000 | [diff] [blame] | 1232 | else |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame] | 1233 | error = xfs_flushinval_pages(ip, |
| 1234 | 0, -1, FI_REMAPF); |
David Chinner | 40095b6 | 2007-05-14 18:24:09 +1000 | [diff] [blame] | 1235 | } else if ((flags & SYNC_DELWRI) && VN_DIRTY(vp)) { |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame] | 1236 | error = xfs_flush_pages(ip, 0, |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 1237 | -1, fflag, FI_NONE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1238 | } |
| 1239 | |
David Chinner | 40095b6 | 2007-05-14 18:24:09 +1000 | [diff] [blame] | 1240 | /* |
| 1241 | * When freezing, we need to wait ensure all I/O (including direct |
| 1242 | * I/O) is complete to ensure no further data modification can take |
| 1243 | * place after this point |
| 1244 | */ |
| 1245 | if (flags & SYNC_IOWAIT) |
Christoph Hellwig | b677c21 | 2007-08-29 11:46:28 +1000 | [diff] [blame] | 1246 | vn_iowait(ip); |
David Chinner | 40095b6 | 2007-05-14 18:24:09 +1000 | [diff] [blame] | 1247 | |
| 1248 | xfs_ilock(ip, XFS_ILOCK_SHARED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | if (flags & SYNC_BDFLUSH) { |
| 1252 | if ((flags & SYNC_ATTR) && |
| 1253 | ((ip->i_update_core) || |
| 1254 | ((ip->i_itemp != NULL) && |
| 1255 | (ip->i_itemp->ili_format.ilf_fields != 0)))) { |
| 1256 | |
| 1257 | /* Insert marker and drop lock if not already |
| 1258 | * done. |
| 1259 | */ |
| 1260 | if (mount_locked) { |
| 1261 | IPOINTER_INSERT(ip, mp); |
| 1262 | } |
| 1263 | |
| 1264 | /* |
| 1265 | * We don't want the periodic flushing of the |
| 1266 | * inodes by vfs_sync() to interfere with |
| 1267 | * I/O to the file, especially read I/O |
| 1268 | * where it is only the access time stamp |
| 1269 | * that is being flushed out. To prevent |
| 1270 | * long periods where we have both inode |
| 1271 | * locks held shared here while reading the |
| 1272 | * inode's buffer in from disk, we drop the |
| 1273 | * inode lock while reading in the inode |
| 1274 | * buffer. We have to release the buffer |
| 1275 | * and reacquire the inode lock so that they |
| 1276 | * are acquired in the proper order (inode |
| 1277 | * locks first). The buffer will go at the |
| 1278 | * end of the lru chain, though, so we can |
| 1279 | * expect it to still be there when we go |
| 1280 | * for it again in xfs_iflush(). |
| 1281 | */ |
| 1282 | if ((xfs_ipincount(ip) == 0) && |
| 1283 | xfs_iflock_nowait(ip)) { |
| 1284 | |
| 1285 | xfs_ifunlock(ip); |
| 1286 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
| 1287 | |
| 1288 | error = xfs_itobp(mp, NULL, ip, |
Nathan Scott | b12dd34 | 2006-03-17 17:26:04 +1100 | [diff] [blame] | 1289 | &dip, &bp, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1290 | if (!error) { |
| 1291 | xfs_buf_relse(bp); |
| 1292 | } else { |
| 1293 | /* Bailing out, remove the |
| 1294 | * marker and free it. |
| 1295 | */ |
| 1296 | XFS_MOUNT_ILOCK(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | IPOINTER_REMOVE(ip, mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1298 | XFS_MOUNT_IUNLOCK(mp); |
| 1299 | |
| 1300 | ASSERT(!(lock_flags & |
| 1301 | XFS_IOLOCK_SHARED)); |
| 1302 | |
| 1303 | kmem_free(ipointer, |
| 1304 | sizeof(xfs_iptr_t)); |
| 1305 | return (0); |
| 1306 | } |
| 1307 | |
| 1308 | /* |
| 1309 | * Since we dropped the inode lock, |
| 1310 | * the inode may have been reclaimed. |
| 1311 | * Therefore, we reacquire the mount |
| 1312 | * lock and check to see if we were the |
| 1313 | * inode reclaimed. If this happened |
| 1314 | * then the ipointer marker will no |
| 1315 | * longer point back at us. In this |
| 1316 | * case, move ip along to the inode |
| 1317 | * after the marker, remove the marker |
| 1318 | * and continue. |
| 1319 | */ |
| 1320 | XFS_MOUNT_ILOCK(mp); |
| 1321 | mount_locked = B_TRUE; |
| 1322 | |
| 1323 | if (ip != ipointer->ip_mprev) { |
| 1324 | IPOINTER_REMOVE(ip, mp); |
| 1325 | |
| 1326 | ASSERT(!vnode_refed); |
| 1327 | ASSERT(!(lock_flags & |
| 1328 | XFS_IOLOCK_SHARED)); |
| 1329 | continue; |
| 1330 | } |
| 1331 | |
| 1332 | ASSERT(ip->i_mount == mp); |
| 1333 | |
| 1334 | if (xfs_ilock_nowait(ip, |
| 1335 | XFS_ILOCK_SHARED) == 0) { |
| 1336 | ASSERT(ip->i_mount == mp); |
| 1337 | /* |
| 1338 | * We failed to reacquire |
| 1339 | * the inode lock without |
| 1340 | * sleeping, so just skip |
| 1341 | * the inode for now. We |
| 1342 | * clear the ILOCK bit from |
| 1343 | * the lock_flags so that we |
| 1344 | * won't try to drop a lock |
| 1345 | * we don't hold below. |
| 1346 | */ |
| 1347 | lock_flags &= ~XFS_ILOCK_SHARED; |
| 1348 | IPOINTER_REMOVE(ip_next, mp); |
| 1349 | } else if ((xfs_ipincount(ip) == 0) && |
| 1350 | xfs_iflock_nowait(ip)) { |
| 1351 | ASSERT(ip->i_mount == mp); |
| 1352 | /* |
| 1353 | * Since this is vfs_sync() |
| 1354 | * calling we only flush the |
| 1355 | * inode out if we can lock |
| 1356 | * it without sleeping and |
| 1357 | * it is not pinned. Drop |
| 1358 | * the mount lock here so |
| 1359 | * that we don't hold it for |
| 1360 | * too long. We already have |
| 1361 | * a marker in the list here. |
| 1362 | */ |
| 1363 | XFS_MOUNT_IUNLOCK(mp); |
| 1364 | mount_locked = B_FALSE; |
| 1365 | error = xfs_iflush(ip, |
| 1366 | XFS_IFLUSH_DELWRI); |
| 1367 | } else { |
| 1368 | ASSERT(ip->i_mount == mp); |
| 1369 | IPOINTER_REMOVE(ip_next, mp); |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | } |
| 1374 | |
| 1375 | } else { |
| 1376 | if ((flags & SYNC_ATTR) && |
| 1377 | ((ip->i_update_core) || |
| 1378 | ((ip->i_itemp != NULL) && |
| 1379 | (ip->i_itemp->ili_format.ilf_fields != 0)))) { |
| 1380 | if (mount_locked) { |
| 1381 | IPOINTER_INSERT(ip, mp); |
| 1382 | } |
| 1383 | |
| 1384 | if (flags & SYNC_WAIT) { |
| 1385 | xfs_iflock(ip); |
| 1386 | error = xfs_iflush(ip, |
| 1387 | XFS_IFLUSH_SYNC); |
| 1388 | } else { |
| 1389 | /* |
| 1390 | * If we can't acquire the flush |
| 1391 | * lock, then the inode is already |
| 1392 | * being flushed so don't bother |
| 1393 | * waiting. If we can lock it then |
| 1394 | * do a delwri flush so we can |
| 1395 | * combine multiple inode flushes |
| 1396 | * in each disk write. |
| 1397 | */ |
| 1398 | if (xfs_iflock_nowait(ip)) { |
| 1399 | error = xfs_iflush(ip, |
| 1400 | XFS_IFLUSH_DELWRI); |
| 1401 | } |
| 1402 | else if (bypassed) |
| 1403 | (*bypassed)++; |
| 1404 | } |
| 1405 | } |
| 1406 | } |
| 1407 | |
| 1408 | if (lock_flags != 0) { |
| 1409 | xfs_iunlock(ip, lock_flags); |
| 1410 | } |
| 1411 | |
| 1412 | if (vnode_refed) { |
| 1413 | /* |
| 1414 | * If we had to take a reference on the vnode |
| 1415 | * above, then wait until after we've unlocked |
| 1416 | * the inode to release the reference. This is |
| 1417 | * because we can be already holding the inode |
| 1418 | * lock when VN_RELE() calls xfs_inactive(). |
| 1419 | * |
| 1420 | * Make sure to drop the mount lock before calling |
| 1421 | * VN_RELE() so that we don't trip over ourselves if |
| 1422 | * we have to go for the mount lock again in the |
| 1423 | * inactive code. |
| 1424 | */ |
| 1425 | if (mount_locked) { |
| 1426 | IPOINTER_INSERT(ip, mp); |
| 1427 | } |
| 1428 | |
| 1429 | VN_RELE(vp); |
| 1430 | |
| 1431 | vnode_refed = B_FALSE; |
| 1432 | } |
| 1433 | |
| 1434 | if (error) { |
| 1435 | last_error = error; |
| 1436 | } |
| 1437 | |
| 1438 | /* |
| 1439 | * bail out if the filesystem is corrupted. |
| 1440 | */ |
| 1441 | if (error == EFSCORRUPTED) { |
| 1442 | if (!mount_locked) { |
| 1443 | XFS_MOUNT_ILOCK(mp); |
| 1444 | IPOINTER_REMOVE(ip, mp); |
| 1445 | } |
| 1446 | XFS_MOUNT_IUNLOCK(mp); |
| 1447 | ASSERT(ipointer_in == B_FALSE); |
| 1448 | kmem_free(ipointer, sizeof(xfs_iptr_t)); |
| 1449 | return XFS_ERROR(error); |
| 1450 | } |
| 1451 | |
| 1452 | /* Let other threads have a chance at the mount lock |
| 1453 | * if we have looped many times without dropping the |
| 1454 | * lock. |
| 1455 | */ |
| 1456 | if ((++preempt & XFS_PREEMPT_MASK) == 0) { |
| 1457 | if (mount_locked) { |
| 1458 | IPOINTER_INSERT(ip, mp); |
| 1459 | } |
| 1460 | } |
| 1461 | |
| 1462 | if (mount_locked == B_FALSE) { |
| 1463 | XFS_MOUNT_ILOCK(mp); |
| 1464 | mount_locked = B_TRUE; |
| 1465 | IPOINTER_REMOVE(ip, mp); |
| 1466 | continue; |
| 1467 | } |
| 1468 | |
| 1469 | ASSERT(ipointer_in == B_FALSE); |
| 1470 | ip = ip->i_mnext; |
| 1471 | |
| 1472 | } while (ip != mp->m_inodes); |
| 1473 | |
| 1474 | XFS_MOUNT_IUNLOCK(mp); |
| 1475 | |
| 1476 | ASSERT(ipointer_in == B_FALSE); |
| 1477 | |
| 1478 | kmem_free(ipointer, sizeof(xfs_iptr_t)); |
| 1479 | return XFS_ERROR(last_error); |
| 1480 | } |
| 1481 | |
| 1482 | /* |
| 1483 | * xfs sync routine for internal use |
| 1484 | * |
Nathan Scott | b83bd13 | 2006-06-09 16:48:30 +1000 | [diff] [blame] | 1485 | * This routine supports all of the flags defined for the generic vfs_sync |
Lachlan McIlroy | 1f9b3b6 | 2007-02-10 18:35:33 +1100 | [diff] [blame] | 1486 | * interface as explained above under xfs_sync. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1487 | * |
| 1488 | */ |
| 1489 | int |
| 1490 | xfs_syncsub( |
| 1491 | xfs_mount_t *mp, |
| 1492 | int flags, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1493 | int *bypassed) |
| 1494 | { |
| 1495 | int error = 0; |
| 1496 | int last_error = 0; |
| 1497 | uint log_flags = XFS_LOG_FORCE; |
| 1498 | xfs_buf_t *bp; |
| 1499 | xfs_buf_log_item_t *bip; |
| 1500 | |
| 1501 | /* |
| 1502 | * Sync out the log. This ensures that the log is periodically |
| 1503 | * flushed even if there is not enough activity to fill it up. |
| 1504 | */ |
| 1505 | if (flags & SYNC_WAIT) |
| 1506 | log_flags |= XFS_LOG_SYNC; |
| 1507 | |
| 1508 | xfs_log_force(mp, (xfs_lsn_t)0, log_flags); |
| 1509 | |
| 1510 | if (flags & (SYNC_ATTR|SYNC_DELWRI)) { |
| 1511 | if (flags & SYNC_BDFLUSH) |
| 1512 | xfs_finish_reclaim_all(mp, 1); |
| 1513 | else |
Lachlan McIlroy | 1f9b3b6 | 2007-02-10 18:35:33 +1100 | [diff] [blame] | 1514 | error = xfs_sync_inodes(mp, flags, bypassed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1515 | } |
| 1516 | |
| 1517 | /* |
| 1518 | * Flushing out dirty data above probably generated more |
| 1519 | * log activity, so if this isn't vfs_sync() then flush |
| 1520 | * the log again. |
| 1521 | */ |
| 1522 | if (flags & SYNC_DELWRI) { |
| 1523 | xfs_log_force(mp, (xfs_lsn_t)0, log_flags); |
| 1524 | } |
| 1525 | |
| 1526 | if (flags & SYNC_FSDATA) { |
| 1527 | /* |
| 1528 | * If this is vfs_sync() then only sync the superblock |
| 1529 | * if we can lock it without sleeping and it is not pinned. |
| 1530 | */ |
| 1531 | if (flags & SYNC_BDFLUSH) { |
| 1532 | bp = xfs_getsb(mp, XFS_BUF_TRYLOCK); |
| 1533 | if (bp != NULL) { |
| 1534 | bip = XFS_BUF_FSPRIVATE(bp,xfs_buf_log_item_t*); |
| 1535 | if ((bip != NULL) && |
| 1536 | xfs_buf_item_dirty(bip)) { |
| 1537 | if (!(XFS_BUF_ISPINNED(bp))) { |
| 1538 | XFS_BUF_ASYNC(bp); |
| 1539 | error = xfs_bwrite(mp, bp); |
| 1540 | } else { |
| 1541 | xfs_buf_relse(bp); |
| 1542 | } |
| 1543 | } else { |
| 1544 | xfs_buf_relse(bp); |
| 1545 | } |
| 1546 | } |
| 1547 | } else { |
| 1548 | bp = xfs_getsb(mp, 0); |
| 1549 | /* |
| 1550 | * If the buffer is pinned then push on the log so |
| 1551 | * we won't get stuck waiting in the write for |
| 1552 | * someone, maybe ourselves, to flush the log. |
| 1553 | * Even though we just pushed the log above, we |
| 1554 | * did not have the superblock buffer locked at |
| 1555 | * that point so it can become pinned in between |
| 1556 | * there and here. |
| 1557 | */ |
| 1558 | if (XFS_BUF_ISPINNED(bp)) |
| 1559 | xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); |
| 1560 | if (flags & SYNC_WAIT) |
| 1561 | XFS_BUF_UNASYNC(bp); |
| 1562 | else |
| 1563 | XFS_BUF_ASYNC(bp); |
| 1564 | error = xfs_bwrite(mp, bp); |
| 1565 | } |
| 1566 | if (error) { |
| 1567 | last_error = error; |
| 1568 | } |
| 1569 | } |
| 1570 | |
| 1571 | /* |
| 1572 | * If this is the periodic sync, then kick some entries out of |
| 1573 | * the reference cache. This ensures that idle entries are |
| 1574 | * eventually kicked out of the cache. |
| 1575 | */ |
| 1576 | if (flags & SYNC_REFCACHE) { |
Nathan Scott | cde410a | 2005-09-05 11:47:01 +1000 | [diff] [blame] | 1577 | if (flags & SYNC_WAIT) |
| 1578 | xfs_refcache_purge_mp(mp); |
| 1579 | else |
| 1580 | xfs_refcache_purge_some(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1581 | } |
| 1582 | |
| 1583 | /* |
David Chinner | 92821e2 | 2007-05-24 15:26:31 +1000 | [diff] [blame] | 1584 | * If asked, update the disk superblock with incore counter values if we |
| 1585 | * are using non-persistent counters so that they don't get too far out |
| 1586 | * of sync if we crash or get a forced shutdown. We don't want to force |
| 1587 | * this to disk, just get a transaction into the iclogs.... |
| 1588 | */ |
| 1589 | if (flags & SYNC_SUPER) |
| 1590 | xfs_log_sbcount(mp, 0); |
| 1591 | |
| 1592 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1593 | * Now check to see if the log needs a "dummy" transaction. |
| 1594 | */ |
| 1595 | |
| 1596 | if (!(flags & SYNC_REMOUNT) && xfs_log_need_covered(mp)) { |
| 1597 | xfs_trans_t *tp; |
| 1598 | xfs_inode_t *ip; |
| 1599 | |
| 1600 | /* |
| 1601 | * Put a dummy transaction in the log to tell |
| 1602 | * recovery that all others are OK. |
| 1603 | */ |
| 1604 | tp = xfs_trans_alloc(mp, XFS_TRANS_DUMMY1); |
| 1605 | if ((error = xfs_trans_reserve(tp, 0, |
| 1606 | XFS_ICHANGE_LOG_RES(mp), |
| 1607 | 0, 0, 0))) { |
| 1608 | xfs_trans_cancel(tp, 0); |
| 1609 | return error; |
| 1610 | } |
| 1611 | |
| 1612 | ip = mp->m_rootip; |
| 1613 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
| 1614 | |
| 1615 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); |
| 1616 | xfs_trans_ihold(tp, ip); |
| 1617 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
Eric Sandeen | 1c72bf9 | 2007-05-08 13:48:42 +1000 | [diff] [blame] | 1618 | error = xfs_trans_commit(tp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1619 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
| 1620 | xfs_log_force(mp, (xfs_lsn_t)0, log_flags); |
| 1621 | } |
| 1622 | |
| 1623 | /* |
| 1624 | * When shutting down, we need to insure that the AIL is pushed |
| 1625 | * to disk or the filesystem can appear corrupt from the PROM. |
| 1626 | */ |
| 1627 | if ((flags & (SYNC_CLOSE|SYNC_WAIT)) == (SYNC_CLOSE|SYNC_WAIT)) { |
| 1628 | XFS_bflush(mp->m_ddev_targp); |
| 1629 | if (mp->m_rtdev_targp) { |
| 1630 | XFS_bflush(mp->m_rtdev_targp); |
| 1631 | } |
| 1632 | } |
| 1633 | |
| 1634 | return XFS_ERROR(last_error); |
| 1635 | } |
| 1636 | |
| 1637 | /* |
| 1638 | * xfs_vget - called by DMAPI and NFSD to get vnode from file handle |
| 1639 | */ |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 1640 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | xfs_vget( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 1642 | xfs_mount_t *mp, |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 1643 | bhv_vnode_t **vpp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1644 | fid_t *fidp) |
| 1645 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | xfs_fid_t *xfid = (struct xfs_fid *)fidp; |
| 1647 | xfs_inode_t *ip; |
| 1648 | int error; |
| 1649 | xfs_ino_t ino; |
| 1650 | unsigned int igen; |
| 1651 | |
| 1652 | /* |
| 1653 | * Invalid. Since handles can be created in user space and passed in |
| 1654 | * via gethandle(), this is not cause for a panic. |
| 1655 | */ |
| 1656 | if (xfid->xfs_fid_len != sizeof(*xfid) - sizeof(xfid->xfs_fid_len)) |
| 1657 | return XFS_ERROR(EINVAL); |
| 1658 | |
| 1659 | ino = xfid->xfs_fid_ino; |
| 1660 | igen = xfid->xfs_fid_gen; |
| 1661 | |
| 1662 | /* |
| 1663 | * NFS can sometimes send requests for ino 0. Fail them gracefully. |
| 1664 | */ |
| 1665 | if (ino == 0) |
| 1666 | return XFS_ERROR(ESTALE); |
| 1667 | |
| 1668 | error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0); |
| 1669 | if (error) { |
| 1670 | *vpp = NULL; |
| 1671 | return error; |
| 1672 | } |
| 1673 | |
| 1674 | if (ip == NULL) { |
| 1675 | *vpp = NULL; |
| 1676 | return XFS_ERROR(EIO); |
| 1677 | } |
| 1678 | |
| 1679 | if (ip->i_d.di_mode == 0 || ip->i_d.di_gen != igen) { |
| 1680 | xfs_iput_new(ip, XFS_ILOCK_SHARED); |
| 1681 | *vpp = NULL; |
| 1682 | return XFS_ERROR(ENOENT); |
| 1683 | } |
| 1684 | |
| 1685 | *vpp = XFS_ITOV(ip); |
| 1686 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
| 1687 | return 0; |
| 1688 | } |
| 1689 | |
| 1690 | |
| 1691 | #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */ |
| 1692 | #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */ |
| 1693 | #define MNTOPT_LOGDEV "logdev" /* log device */ |
| 1694 | #define MNTOPT_RTDEV "rtdev" /* realtime I/O device */ |
| 1695 | #define MNTOPT_BIOSIZE "biosize" /* log2 of preferred buffered io size */ |
| 1696 | #define MNTOPT_WSYNC "wsync" /* safe-mode nfs compatible mount */ |
| 1697 | #define MNTOPT_INO64 "ino64" /* force inodes into 64-bit range */ |
| 1698 | #define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */ |
| 1699 | #define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */ |
| 1700 | #define MNTOPT_SUNIT "sunit" /* data volume stripe unit */ |
| 1701 | #define MNTOPT_SWIDTH "swidth" /* data volume stripe width */ |
| 1702 | #define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */ |
| 1703 | #define MNTOPT_MTPT "mtpt" /* filesystem mount point */ |
Nathan Scott | e69a333 | 2005-09-02 16:42:26 +1000 | [diff] [blame] | 1704 | #define MNTOPT_GRPID "grpid" /* group-ID from parent directory */ |
| 1705 | #define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */ |
| 1706 | #define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */ |
| 1707 | #define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */ |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1708 | #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1709 | #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */ |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 1710 | #define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 1711 | * unwritten extent conversion */ |
Christoph Hellwig | 4ef19dd | 2006-01-11 15:27:18 +1100 | [diff] [blame] | 1712 | #define MNTOPT_NOBARRIER "nobarrier" /* .. disable */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */ |
| 1714 | #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */ |
| 1715 | #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */ |
| 1716 | #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */ |
David Chinner | e8c8b3a | 2005-11-02 10:33:05 +1100 | [diff] [blame] | 1717 | #define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */ |
| 1718 | #define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes |
| 1719 | * in stat(). */ |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 1720 | #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */ |
| 1721 | #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */ |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 1722 | #define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */ |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 1723 | #define MNTOPT_QUOTA "quota" /* disk quotas (user) */ |
| 1724 | #define MNTOPT_NOQUOTA "noquota" /* no quotas */ |
| 1725 | #define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */ |
| 1726 | #define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */ |
| 1727 | #define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */ |
| 1728 | #define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */ |
| 1729 | #define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */ |
| 1730 | #define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */ |
| 1731 | #define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */ |
| 1732 | #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */ |
| 1733 | #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */ |
| 1734 | #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */ |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 1735 | #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */ |
| 1736 | #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */ |
| 1737 | #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1738 | |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1739 | STATIC unsigned long |
Nathan Scott | b190f11 | 2006-06-09 17:13:15 +1000 | [diff] [blame] | 1740 | suffix_strtoul(char *s, char **endp, unsigned int base) |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1741 | { |
| 1742 | int last, shift_left_factor = 0; |
Nathan Scott | b190f11 | 2006-06-09 17:13:15 +1000 | [diff] [blame] | 1743 | char *value = s; |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1744 | |
| 1745 | last = strlen(value) - 1; |
| 1746 | if (value[last] == 'K' || value[last] == 'k') { |
| 1747 | shift_left_factor = 10; |
| 1748 | value[last] = '\0'; |
| 1749 | } |
| 1750 | if (value[last] == 'M' || value[last] == 'm') { |
| 1751 | shift_left_factor = 20; |
| 1752 | value[last] = '\0'; |
| 1753 | } |
| 1754 | if (value[last] == 'G' || value[last] == 'g') { |
| 1755 | shift_left_factor = 30; |
| 1756 | value[last] = '\0'; |
| 1757 | } |
| 1758 | |
Nathan Scott | b190f11 | 2006-06-09 17:13:15 +1000 | [diff] [blame] | 1759 | return simple_strtoul((const char *)s, endp, base) << shift_left_factor; |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1760 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1761 | |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 1762 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1763 | xfs_parseargs( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 1764 | struct xfs_mount *mp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1765 | char *options, |
| 1766 | struct xfs_mount_args *args, |
| 1767 | int update) |
| 1768 | { |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 1769 | bhv_vfs_t *vfsp = XFS_MTOVFS(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1770 | char *this_char, *value, *eov; |
| 1771 | int dsunit, dswidth, vol_dsunit, vol_dswidth; |
| 1772 | int iosize; |
| 1773 | |
Vlad Apostolov | b93bd20 | 2007-08-28 14:00:28 +1000 | [diff] [blame] | 1774 | /* |
| 1775 | * Applications using DMI filesystems often expect the |
| 1776 | * inode generation number to be monotonically increasing. |
| 1777 | * If we delete inode chunks we break this assumption, so |
| 1778 | * keep unused inode chunks on disk for DMI filesystems |
| 1779 | * until we come up with a better solution. |
| 1780 | * Note that if "ikeep" or "noikeep" mount options are |
| 1781 | * supplied, then they are honored. |
| 1782 | */ |
| 1783 | if (!(args->flags & XFSMNT_DMAPI)) |
| 1784 | args->flags |= XFSMNT_IDELETE; |
| 1785 | |
Nathan Scott | 3bbcc8e | 2006-03-31 13:04:56 +1000 | [diff] [blame] | 1786 | args->flags |= XFSMNT_BARRIER; |
| 1787 | args->flags2 |= XFSMNT2_COMPAT_IOSIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | |
| 1789 | if (!options) |
Nathan Scott | 05db218 | 2005-11-04 09:49:07 +1100 | [diff] [blame] | 1790 | goto done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | |
| 1792 | iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0; |
| 1793 | |
| 1794 | while ((this_char = strsep(&options, ",")) != NULL) { |
| 1795 | if (!*this_char) |
| 1796 | continue; |
| 1797 | if ((value = strchr(this_char, '=')) != NULL) |
| 1798 | *value++ = 0; |
| 1799 | |
| 1800 | if (!strcmp(this_char, MNTOPT_LOGBUFS)) { |
| 1801 | if (!value || !*value) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1802 | cmn_err(CE_WARN, |
| 1803 | "XFS: %s option requires an argument", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1804 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1805 | return EINVAL; |
| 1806 | } |
| 1807 | args->logbufs = simple_strtoul(value, &eov, 10); |
| 1808 | } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1809 | if (!value || !*value) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1810 | cmn_err(CE_WARN, |
| 1811 | "XFS: %s option requires an argument", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1812 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1813 | return EINVAL; |
| 1814 | } |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1815 | args->logbufsize = suffix_strtoul(value, &eov, 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1816 | } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { |
| 1817 | if (!value || !*value) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1818 | cmn_err(CE_WARN, |
| 1819 | "XFS: %s option requires an argument", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1820 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1821 | return EINVAL; |
| 1822 | } |
| 1823 | strncpy(args->logname, value, MAXNAMELEN); |
| 1824 | } else if (!strcmp(this_char, MNTOPT_MTPT)) { |
| 1825 | if (!value || !*value) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1826 | cmn_err(CE_WARN, |
| 1827 | "XFS: %s option requires an argument", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1828 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | return EINVAL; |
| 1830 | } |
| 1831 | strncpy(args->mtpt, value, MAXNAMELEN); |
| 1832 | } else if (!strcmp(this_char, MNTOPT_RTDEV)) { |
| 1833 | if (!value || !*value) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1834 | cmn_err(CE_WARN, |
| 1835 | "XFS: %s option requires an argument", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1836 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1837 | return EINVAL; |
| 1838 | } |
| 1839 | strncpy(args->rtname, value, MAXNAMELEN); |
| 1840 | } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { |
| 1841 | if (!value || !*value) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1842 | cmn_err(CE_WARN, |
| 1843 | "XFS: %s option requires an argument", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1844 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1845 | return EINVAL; |
| 1846 | } |
| 1847 | iosize = simple_strtoul(value, &eov, 10); |
| 1848 | args->flags |= XFSMNT_IOSIZE; |
| 1849 | args->iosizelog = (uint8_t) iosize; |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1850 | } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { |
| 1851 | if (!value || !*value) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1852 | cmn_err(CE_WARN, |
| 1853 | "XFS: %s option requires an argument", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1854 | this_char); |
| 1855 | return EINVAL; |
| 1856 | } |
| 1857 | iosize = suffix_strtoul(value, &eov, 10); |
| 1858 | args->flags |= XFSMNT_IOSIZE; |
| 1859 | args->iosizelog = ffs(iosize) - 1; |
Nathan Scott | e69a333 | 2005-09-02 16:42:26 +1000 | [diff] [blame] | 1860 | } else if (!strcmp(this_char, MNTOPT_GRPID) || |
| 1861 | !strcmp(this_char, MNTOPT_BSDGROUPS)) { |
| 1862 | vfsp->vfs_flag |= VFS_GRPID; |
| 1863 | } else if (!strcmp(this_char, MNTOPT_NOGRPID) || |
| 1864 | !strcmp(this_char, MNTOPT_SYSVGROUPS)) { |
| 1865 | vfsp->vfs_flag &= ~VFS_GRPID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | } else if (!strcmp(this_char, MNTOPT_WSYNC)) { |
| 1867 | args->flags |= XFSMNT_WSYNC; |
| 1868 | } else if (!strcmp(this_char, MNTOPT_OSYNCISOSYNC)) { |
| 1869 | args->flags |= XFSMNT_OSYNCISOSYNC; |
| 1870 | } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) { |
| 1871 | args->flags |= XFSMNT_NORECOVERY; |
| 1872 | } else if (!strcmp(this_char, MNTOPT_INO64)) { |
| 1873 | args->flags |= XFSMNT_INO64; |
| 1874 | #if !XFS_BIG_INUMS |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1875 | cmn_err(CE_WARN, |
| 1876 | "XFS: %s option not allowed on this system", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1877 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1878 | return EINVAL; |
| 1879 | #endif |
| 1880 | } else if (!strcmp(this_char, MNTOPT_NOALIGN)) { |
| 1881 | args->flags |= XFSMNT_NOALIGN; |
| 1882 | } else if (!strcmp(this_char, MNTOPT_SWALLOC)) { |
| 1883 | args->flags |= XFSMNT_SWALLOC; |
| 1884 | } else if (!strcmp(this_char, MNTOPT_SUNIT)) { |
| 1885 | if (!value || !*value) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1886 | cmn_err(CE_WARN, |
| 1887 | "XFS: %s option requires an argument", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1888 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1889 | return EINVAL; |
| 1890 | } |
| 1891 | dsunit = simple_strtoul(value, &eov, 10); |
| 1892 | } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { |
| 1893 | if (!value || !*value) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1894 | cmn_err(CE_WARN, |
| 1895 | "XFS: %s option requires an argument", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1896 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1897 | return EINVAL; |
| 1898 | } |
| 1899 | dswidth = simple_strtoul(value, &eov, 10); |
| 1900 | } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { |
| 1901 | args->flags &= ~XFSMNT_32BITINODES; |
| 1902 | #if !XFS_BIG_INUMS |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1903 | cmn_err(CE_WARN, |
| 1904 | "XFS: %s option not allowed on this system", |
Nathan Scott | 1f443ad | 2005-05-05 13:28:29 -0700 | [diff] [blame] | 1905 | this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1906 | return EINVAL; |
| 1907 | #endif |
| 1908 | } else if (!strcmp(this_char, MNTOPT_NOUUID)) { |
| 1909 | args->flags |= XFSMNT_NOUUID; |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 1910 | } else if (!strcmp(this_char, MNTOPT_BARRIER)) { |
| 1911 | args->flags |= XFSMNT_BARRIER; |
Christoph Hellwig | 4ef19dd | 2006-01-11 15:27:18 +1100 | [diff] [blame] | 1912 | } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) { |
| 1913 | args->flags &= ~XFSMNT_BARRIER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1914 | } else if (!strcmp(this_char, MNTOPT_IKEEP)) { |
| 1915 | args->flags &= ~XFSMNT_IDELETE; |
| 1916 | } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) { |
| 1917 | args->flags |= XFSMNT_IDELETE; |
David Chinner | e8c8b3a | 2005-11-02 10:33:05 +1100 | [diff] [blame] | 1918 | } else if (!strcmp(this_char, MNTOPT_LARGEIO)) { |
Nathan Scott | e718eeb4 | 2005-11-02 15:09:22 +1100 | [diff] [blame] | 1919 | args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE; |
David Chinner | e8c8b3a | 2005-11-02 10:33:05 +1100 | [diff] [blame] | 1920 | } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) { |
Nathan Scott | e718eeb4 | 2005-11-02 15:09:22 +1100 | [diff] [blame] | 1921 | args->flags2 |= XFSMNT2_COMPAT_IOSIZE; |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 1922 | } else if (!strcmp(this_char, MNTOPT_ATTR2)) { |
Nathan Scott | 13059ff | 2006-01-11 15:32:01 +1100 | [diff] [blame] | 1923 | args->flags |= XFSMNT_ATTR2; |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 1924 | } else if (!strcmp(this_char, MNTOPT_NOATTR2)) { |
Nathan Scott | 13059ff | 2006-01-11 15:32:01 +1100 | [diff] [blame] | 1925 | args->flags &= ~XFSMNT_ATTR2; |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 1926 | } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) { |
| 1927 | args->flags2 |= XFSMNT2_FILESTREAMS; |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 1928 | } else if (!strcmp(this_char, MNTOPT_NOQUOTA)) { |
| 1929 | args->flags &= ~(XFSMNT_UQUOTAENF|XFSMNT_UQUOTA); |
| 1930 | args->flags &= ~(XFSMNT_GQUOTAENF|XFSMNT_GQUOTA); |
| 1931 | } else if (!strcmp(this_char, MNTOPT_QUOTA) || |
| 1932 | !strcmp(this_char, MNTOPT_UQUOTA) || |
| 1933 | !strcmp(this_char, MNTOPT_USRQUOTA)) { |
| 1934 | args->flags |= XFSMNT_UQUOTA | XFSMNT_UQUOTAENF; |
| 1935 | } else if (!strcmp(this_char, MNTOPT_QUOTANOENF) || |
| 1936 | !strcmp(this_char, MNTOPT_UQUOTANOENF)) { |
| 1937 | args->flags |= XFSMNT_UQUOTA; |
| 1938 | args->flags &= ~XFSMNT_UQUOTAENF; |
| 1939 | } else if (!strcmp(this_char, MNTOPT_PQUOTA) || |
| 1940 | !strcmp(this_char, MNTOPT_PRJQUOTA)) { |
| 1941 | args->flags |= XFSMNT_PQUOTA | XFSMNT_PQUOTAENF; |
| 1942 | } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) { |
| 1943 | args->flags |= XFSMNT_PQUOTA; |
| 1944 | args->flags &= ~XFSMNT_PQUOTAENF; |
| 1945 | } else if (!strcmp(this_char, MNTOPT_GQUOTA) || |
| 1946 | !strcmp(this_char, MNTOPT_GRPQUOTA)) { |
| 1947 | args->flags |= XFSMNT_GQUOTA | XFSMNT_GQUOTAENF; |
| 1948 | } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) { |
| 1949 | args->flags |= XFSMNT_GQUOTA; |
| 1950 | args->flags &= ~XFSMNT_GQUOTAENF; |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 1951 | } else if (!strcmp(this_char, MNTOPT_DMAPI)) { |
| 1952 | args->flags |= XFSMNT_DMAPI; |
| 1953 | } else if (!strcmp(this_char, MNTOPT_XDSM)) { |
| 1954 | args->flags |= XFSMNT_DMAPI; |
| 1955 | } else if (!strcmp(this_char, MNTOPT_DMI)) { |
| 1956 | args->flags |= XFSMNT_DMAPI; |
David Chinner | da353b0 | 2007-08-28 14:00:13 +1000 | [diff] [blame] | 1957 | } else if (!strcmp(this_char, "ihashsize")) { |
| 1958 | cmn_err(CE_WARN, |
| 1959 | "XFS: ihashsize no longer used, option is deprecated."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1960 | } else if (!strcmp(this_char, "osyncisdsync")) { |
| 1961 | /* no-op, this is now the default */ |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1962 | cmn_err(CE_WARN, |
| 1963 | "XFS: osyncisdsync is now the default, option is deprecated."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1964 | } else if (!strcmp(this_char, "irixsgid")) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1965 | cmn_err(CE_WARN, |
| 1966 | "XFS: irixsgid is now a sysctl(2) variable, option is deprecated."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1967 | } else { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1968 | cmn_err(CE_WARN, |
| 1969 | "XFS: unknown mount option [%s].", this_char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1970 | return EINVAL; |
| 1971 | } |
| 1972 | } |
| 1973 | |
| 1974 | if (args->flags & XFSMNT_NORECOVERY) { |
| 1975 | if ((vfsp->vfs_flag & VFS_RDONLY) == 0) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1976 | cmn_err(CE_WARN, |
| 1977 | "XFS: no-recovery mounts must be read-only."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1978 | return EINVAL; |
| 1979 | } |
| 1980 | } |
| 1981 | |
| 1982 | if ((args->flags & XFSMNT_NOALIGN) && (dsunit || dswidth)) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 1983 | cmn_err(CE_WARN, |
| 1984 | "XFS: sunit and swidth options incompatible with the noalign option"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1985 | return EINVAL; |
| 1986 | } |
| 1987 | |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 1988 | if ((args->flags & XFSMNT_GQUOTA) && (args->flags & XFSMNT_PQUOTA)) { |
| 1989 | cmn_err(CE_WARN, |
| 1990 | "XFS: cannot mount with both project and group quota"); |
| 1991 | return EINVAL; |
| 1992 | } |
| 1993 | |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 1994 | if ((args->flags & XFSMNT_DMAPI) && *args->mtpt == '\0') { |
| 1995 | printk("XFS: %s option needs the mount point option as well\n", |
| 1996 | MNTOPT_DMAPI); |
| 1997 | return EINVAL; |
| 1998 | } |
| 1999 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | if ((dsunit && !dswidth) || (!dsunit && dswidth)) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 2001 | cmn_err(CE_WARN, |
| 2002 | "XFS: sunit and swidth must be specified together"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2003 | return EINVAL; |
| 2004 | } |
| 2005 | |
| 2006 | if (dsunit && (dswidth % dsunit != 0)) { |
Nathan Scott | b657452 | 2006-06-09 15:29:40 +1000 | [diff] [blame] | 2007 | cmn_err(CE_WARN, |
| 2008 | "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2009 | dswidth, dsunit); |
| 2010 | return EINVAL; |
| 2011 | } |
| 2012 | |
| 2013 | if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) { |
| 2014 | if (dsunit) { |
| 2015 | args->sunit = dsunit; |
| 2016 | args->flags |= XFSMNT_RETERR; |
| 2017 | } else { |
| 2018 | args->sunit = vol_dsunit; |
| 2019 | } |
| 2020 | dswidth ? (args->swidth = dswidth) : |
| 2021 | (args->swidth = vol_dswidth); |
| 2022 | } else { |
| 2023 | args->sunit = args->swidth = 0; |
| 2024 | } |
| 2025 | |
Nathan Scott | 05db218 | 2005-11-04 09:49:07 +1100 | [diff] [blame] | 2026 | done: |
Nathan Scott | c11e2c3 | 2005-11-02 15:11:45 +1100 | [diff] [blame] | 2027 | if (args->flags & XFSMNT_32BITINODES) |
| 2028 | vfsp->vfs_flag |= VFS_32BITINODES; |
Nathan Scott | e718eeb4 | 2005-11-02 15:09:22 +1100 | [diff] [blame] | 2029 | if (args->flags2) |
| 2030 | args->flags |= XFSMNT_FLAGS2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2031 | return 0; |
| 2032 | } |
| 2033 | |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 2034 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2035 | xfs_showargs( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 2036 | struct xfs_mount *mp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2037 | struct seq_file *m) |
| 2038 | { |
| 2039 | static struct proc_xfs_info { |
| 2040 | int flag; |
| 2041 | char *str; |
| 2042 | } xfs_info[] = { |
| 2043 | /* the few simple ones we can get from the mount struct */ |
| 2044 | { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC }, |
| 2045 | { XFS_MOUNT_INO64, "," MNTOPT_INO64 }, |
| 2046 | { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN }, |
| 2047 | { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC }, |
| 2048 | { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID }, |
| 2049 | { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY }, |
| 2050 | { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2051 | { 0, NULL } |
| 2052 | }; |
| 2053 | struct proc_xfs_info *xfs_infop; |
Nathan Scott | b83bd13 | 2006-06-09 16:48:30 +1000 | [diff] [blame] | 2054 | struct bhv_vfs *vfsp = XFS_MTOVFS(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | |
| 2056 | for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) { |
| 2057 | if (mp->m_flags & xfs_infop->flag) |
| 2058 | seq_puts(m, xfs_infop->str); |
| 2059 | } |
| 2060 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) |
Nathan Scott | cfcbbbd | 2005-11-02 15:12:04 +1100 | [diff] [blame] | 2062 | seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk", |
| 2063 | (int)(1 << mp->m_writeio_log) >> 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2064 | |
| 2065 | if (mp->m_logbufs > 0) |
| 2066 | seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2067 | if (mp->m_logbsize > 0) |
Nathan Scott | cfcbbbd | 2005-11-02 15:12:04 +1100 | [diff] [blame] | 2068 | seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | |
Nathan Scott | fc1f8c1 | 2005-11-02 11:44:33 +1100 | [diff] [blame] | 2070 | if (mp->m_logname) |
| 2071 | seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname); |
Nathan Scott | fc1f8c1 | 2005-11-02 11:44:33 +1100 | [diff] [blame] | 2072 | if (mp->m_rtname) |
| 2073 | seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | |
| 2075 | if (mp->m_dalign > 0) |
| 2076 | seq_printf(m, "," MNTOPT_SUNIT "=%d", |
| 2077 | (int)XFS_FSB_TO_BB(mp, mp->m_dalign)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | if (mp->m_swidth > 0) |
| 2079 | seq_printf(m, "," MNTOPT_SWIDTH "=%d", |
| 2080 | (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); |
| 2081 | |
Nathan Scott | e15f195 | 2006-03-22 12:47:52 +1100 | [diff] [blame] | 2082 | if (!(mp->m_flags & XFS_MOUNT_IDELETE)) |
| 2083 | seq_printf(m, "," MNTOPT_IKEEP); |
Nathan Scott | fa7e7d7 | 2005-11-02 15:00:48 +1100 | [diff] [blame] | 2084 | if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)) |
| 2085 | seq_printf(m, "," MNTOPT_LARGEIO); |
| 2086 | |
Nathan Scott | c11e2c3 | 2005-11-02 15:11:45 +1100 | [diff] [blame] | 2087 | if (!(vfsp->vfs_flag & VFS_32BITINODES)) |
| 2088 | seq_printf(m, "," MNTOPT_64BITINODE); |
Nathan Scott | e69a333 | 2005-09-02 16:42:26 +1000 | [diff] [blame] | 2089 | if (vfsp->vfs_flag & VFS_GRPID) |
| 2090 | seq_printf(m, "," MNTOPT_GRPID); |
| 2091 | |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 2092 | if (mp->m_qflags & XFS_UQUOTA_ACCT) { |
| 2093 | if (mp->m_qflags & XFS_UQUOTA_ENFD) |
| 2094 | seq_puts(m, "," MNTOPT_USRQUOTA); |
| 2095 | else |
| 2096 | seq_puts(m, "," MNTOPT_UQUOTANOENF); |
| 2097 | } |
| 2098 | |
| 2099 | if (mp->m_qflags & XFS_PQUOTA_ACCT) { |
| 2100 | if (mp->m_qflags & XFS_OQUOTA_ENFD) |
| 2101 | seq_puts(m, "," MNTOPT_PRJQUOTA); |
| 2102 | else |
| 2103 | seq_puts(m, "," MNTOPT_PQUOTANOENF); |
| 2104 | } |
| 2105 | |
| 2106 | if (mp->m_qflags & XFS_GQUOTA_ACCT) { |
| 2107 | if (mp->m_qflags & XFS_OQUOTA_ENFD) |
| 2108 | seq_puts(m, "," MNTOPT_GRPQUOTA); |
| 2109 | else |
| 2110 | seq_puts(m, "," MNTOPT_GQUOTANOENF); |
| 2111 | } |
| 2112 | |
| 2113 | if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT)) |
| 2114 | seq_puts(m, "," MNTOPT_NOQUOTA); |
| 2115 | |
Christoph Hellwig | 293688e | 2007-08-29 11:59:36 +1000 | [diff] [blame] | 2116 | if (vfsp->vfs_flag & VFS_DMI) |
| 2117 | seq_puts(m, "," MNTOPT_DMAPI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2118 | return 0; |
| 2119 | } |
| 2120 | |
David Chinner | 2823945 | 2007-02-10 18:36:40 +1100 | [diff] [blame] | 2121 | /* |
David Chinner | 516b2e7 | 2007-06-18 16:50:48 +1000 | [diff] [blame] | 2122 | * Second stage of a freeze. The data is already frozen so we only |
| 2123 | * need to take care of themetadata. Once that's done write a dummy |
| 2124 | * record to dirty the log in case of a crash while frozen. |
David Chinner | 2823945 | 2007-02-10 18:36:40 +1100 | [diff] [blame] | 2125 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2126 | STATIC void |
| 2127 | xfs_freeze( |
Christoph Hellwig | 48c872a9f | 2007-08-30 17:20:31 +1000 | [diff] [blame] | 2128 | xfs_mount_t *mp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | { |
David Chinner | 516b2e7 | 2007-06-18 16:50:48 +1000 | [diff] [blame] | 2130 | xfs_attr_quiesce(mp); |
Christoph Hellwig | e13a73f | 2006-01-11 15:30:08 +1100 | [diff] [blame] | 2131 | xfs_fs_log_dummy(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | } |