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