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