Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | a805bad | 2006-06-19 08:40:27 +1000 | [diff] [blame] | 2 | * Copyright (c) 2000-2006 Silicon Graphics, Inc. |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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_bit.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include "xfs_log.h" |
| 21 | #include "xfs_clnt.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 22 | #include "xfs_inum.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include "xfs_trans.h" |
| 24 | #include "xfs_sb.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 25 | #include "xfs_ag.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include "xfs_dir2.h" |
| 27 | #include "xfs_alloc.h" |
| 28 | #include "xfs_dmapi.h" |
| 29 | #include "xfs_quota.h" |
| 30 | #include "xfs_mount.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include "xfs_bmap_btree.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 32 | #include "xfs_alloc_btree.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include "xfs_ialloc_btree.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include "xfs_dir2_sf.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 35 | #include "xfs_attr_sf.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include "xfs_dinode.h" |
| 37 | #include "xfs_inode.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 38 | #include "xfs_btree.h" |
Christoph Hellwig | 8c4ed63 | 2008-10-30 16:55:13 +1100 | [diff] [blame] | 39 | #include "xfs_btree_trace.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 40 | #include "xfs_ialloc.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include "xfs_bmap.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include "xfs_rtalloc.h" |
| 43 | #include "xfs_error.h" |
| 44 | #include "xfs_itable.h" |
Christoph Hellwig | 9909c4a | 2007-10-11 18:11:14 +1000 | [diff] [blame] | 45 | #include "xfs_fsops.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include "xfs_rw.h" |
| 47 | #include "xfs_acl.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include "xfs_attr.h" |
| 49 | #include "xfs_buf_item.h" |
| 50 | #include "xfs_utils.h" |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame] | 51 | #include "xfs_vnodeops.h" |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame] | 52 | #include "xfs_vfsops.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | #include "xfs_version.h" |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 54 | #include "xfs_log_priv.h" |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 55 | #include "xfs_trans_priv.h" |
Christoph Hellwig | 48b62a1 | 2008-05-20 11:30:39 +1000 | [diff] [blame] | 56 | #include "xfs_filestream.h" |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 57 | #include "xfs_da_btree.h" |
| 58 | #include "xfs_dir2_trace.h" |
| 59 | #include "xfs_extfree_item.h" |
| 60 | #include "xfs_mru_cache.h" |
| 61 | #include "xfs_inode_item.h" |
David Chinner | fe4fa4b | 2008-10-30 17:06:08 +1100 | [diff] [blame] | 62 | #include "xfs_sync.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | #include <linux/namei.h> |
| 65 | #include <linux/init.h> |
| 66 | #include <linux/mount.h> |
Christoph Hellwig | 0829c36 | 2005-09-02 16:58:49 +1000 | [diff] [blame] | 67 | #include <linux/mempool.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #include <linux/writeback.h> |
Christoph Hellwig | 4df08c5 | 2005-09-05 08:34:18 +1000 | [diff] [blame] | 69 | #include <linux/kthread.h> |
Nigel Cunningham | 7dfb710 | 2006-12-06 20:34:23 -0800 | [diff] [blame] | 70 | #include <linux/freezer.h> |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 71 | #include <linux/parser.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 73 | static struct quotactl_ops xfs_quotactl_operations; |
| 74 | static struct super_operations xfs_super_operations; |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 75 | static kmem_zone_t *xfs_ioend_zone; |
Christoph Hellwig | 0829c36 | 2005-09-02 16:58:49 +1000 | [diff] [blame] | 76 | mempool_t *xfs_ioend_pool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | STATIC struct xfs_mount_args * |
| 79 | xfs_args_allocate( |
Nathan Scott | 764d1f8 | 2006-03-31 13:04:17 +1000 | [diff] [blame] | 80 | struct super_block *sb, |
| 81 | int silent) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | { |
| 83 | struct xfs_mount_args *args; |
| 84 | |
Christoph Hellwig | bdd907b | 2008-05-20 15:10:44 +1000 | [diff] [blame] | 85 | args = kzalloc(sizeof(struct xfs_mount_args), GFP_KERNEL); |
| 86 | if (!args) |
| 87 | return NULL; |
| 88 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | args->logbufs = args->logbufsize = -1; |
| 90 | strncpy(args->fsname, sb->s_id, MAXNAMELEN); |
| 91 | |
| 92 | /* Copy the already-parsed mount(2) flags we're interested in */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | if (sb->s_flags & MS_DIRSYNC) |
| 94 | args->flags |= XFSMNT_DIRSYNC; |
| 95 | if (sb->s_flags & MS_SYNCHRONOUS) |
| 96 | args->flags |= XFSMNT_WSYNC; |
Nathan Scott | 764d1f8 | 2006-03-31 13:04:17 +1000 | [diff] [blame] | 97 | if (silent) |
| 98 | args->flags |= XFSMNT_QUIET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | args->flags |= XFSMNT_32BITINODES; |
| 100 | |
| 101 | return args; |
| 102 | } |
| 103 | |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 104 | #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */ |
| 105 | #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */ |
| 106 | #define MNTOPT_LOGDEV "logdev" /* log device */ |
| 107 | #define MNTOPT_RTDEV "rtdev" /* realtime I/O device */ |
| 108 | #define MNTOPT_BIOSIZE "biosize" /* log2 of preferred buffered io size */ |
| 109 | #define MNTOPT_WSYNC "wsync" /* safe-mode nfs compatible mount */ |
| 110 | #define MNTOPT_INO64 "ino64" /* force inodes into 64-bit range */ |
| 111 | #define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */ |
| 112 | #define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */ |
| 113 | #define MNTOPT_SUNIT "sunit" /* data volume stripe unit */ |
| 114 | #define MNTOPT_SWIDTH "swidth" /* data volume stripe width */ |
| 115 | #define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */ |
| 116 | #define MNTOPT_MTPT "mtpt" /* filesystem mount point */ |
| 117 | #define MNTOPT_GRPID "grpid" /* group-ID from parent directory */ |
| 118 | #define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */ |
| 119 | #define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */ |
| 120 | #define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */ |
| 121 | #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */ |
| 122 | #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */ |
| 123 | #define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and |
| 124 | * unwritten extent conversion */ |
| 125 | #define MNTOPT_NOBARRIER "nobarrier" /* .. disable */ |
| 126 | #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */ |
| 127 | #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */ |
| 128 | #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */ |
| 129 | #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */ |
| 130 | #define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */ |
| 131 | #define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes |
| 132 | * in stat(). */ |
| 133 | #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */ |
| 134 | #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */ |
| 135 | #define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */ |
| 136 | #define MNTOPT_QUOTA "quota" /* disk quotas (user) */ |
| 137 | #define MNTOPT_NOQUOTA "noquota" /* no quotas */ |
| 138 | #define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */ |
| 139 | #define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */ |
| 140 | #define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */ |
| 141 | #define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */ |
| 142 | #define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */ |
| 143 | #define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */ |
| 144 | #define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */ |
| 145 | #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */ |
| 146 | #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */ |
| 147 | #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */ |
| 148 | #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */ |
| 149 | #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */ |
| 150 | #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */ |
| 151 | |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 152 | /* |
| 153 | * Table driven mount option parser. |
| 154 | * |
| 155 | * Currently only used for remount, but it will be used for mount |
| 156 | * in the future, too. |
| 157 | */ |
| 158 | enum { |
| 159 | Opt_barrier, Opt_nobarrier, Opt_err |
| 160 | }; |
| 161 | |
Steven Whitehouse | a447c09 | 2008-10-13 10:46:57 +0100 | [diff] [blame] | 162 | static const match_table_t tokens = { |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 163 | {Opt_barrier, "barrier"}, |
| 164 | {Opt_nobarrier, "nobarrier"}, |
| 165 | {Opt_err, NULL} |
| 166 | }; |
| 167 | |
| 168 | |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 169 | STATIC unsigned long |
| 170 | suffix_strtoul(char *s, char **endp, unsigned int base) |
| 171 | { |
| 172 | int last, shift_left_factor = 0; |
| 173 | char *value = s; |
| 174 | |
| 175 | last = strlen(value) - 1; |
| 176 | if (value[last] == 'K' || value[last] == 'k') { |
| 177 | shift_left_factor = 10; |
| 178 | value[last] = '\0'; |
| 179 | } |
| 180 | if (value[last] == 'M' || value[last] == 'm') { |
| 181 | shift_left_factor = 20; |
| 182 | value[last] = '\0'; |
| 183 | } |
| 184 | if (value[last] == 'G' || value[last] == 'g') { |
| 185 | shift_left_factor = 30; |
| 186 | value[last] = '\0'; |
| 187 | } |
| 188 | |
| 189 | return simple_strtoul((const char *)s, endp, base) << shift_left_factor; |
| 190 | } |
| 191 | |
| 192 | STATIC int |
| 193 | xfs_parseargs( |
| 194 | struct xfs_mount *mp, |
| 195 | char *options, |
| 196 | struct xfs_mount_args *args, |
| 197 | int update) |
| 198 | { |
| 199 | char *this_char, *value, *eov; |
| 200 | int dsunit, dswidth, vol_dsunit, vol_dswidth; |
| 201 | int iosize; |
Josef Jeff Sipek | 1bd960e | 2008-02-29 13:58:40 +1100 | [diff] [blame] | 202 | int dmapi_implies_ikeep = 1; |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 203 | |
| 204 | args->flags |= XFSMNT_BARRIER; |
| 205 | args->flags2 |= XFSMNT2_COMPAT_IOSIZE; |
| 206 | |
| 207 | if (!options) |
| 208 | goto done; |
| 209 | |
| 210 | iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0; |
| 211 | |
| 212 | while ((this_char = strsep(&options, ",")) != NULL) { |
| 213 | if (!*this_char) |
| 214 | continue; |
| 215 | if ((value = strchr(this_char, '=')) != NULL) |
| 216 | *value++ = 0; |
| 217 | |
| 218 | if (!strcmp(this_char, MNTOPT_LOGBUFS)) { |
| 219 | if (!value || !*value) { |
| 220 | cmn_err(CE_WARN, |
| 221 | "XFS: %s option requires an argument", |
| 222 | this_char); |
| 223 | return EINVAL; |
| 224 | } |
| 225 | args->logbufs = simple_strtoul(value, &eov, 10); |
| 226 | } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { |
| 227 | if (!value || !*value) { |
| 228 | cmn_err(CE_WARN, |
| 229 | "XFS: %s option requires an argument", |
| 230 | this_char); |
| 231 | return EINVAL; |
| 232 | } |
| 233 | args->logbufsize = suffix_strtoul(value, &eov, 10); |
| 234 | } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { |
| 235 | if (!value || !*value) { |
| 236 | cmn_err(CE_WARN, |
| 237 | "XFS: %s option requires an argument", |
| 238 | this_char); |
| 239 | return EINVAL; |
| 240 | } |
| 241 | strncpy(args->logname, value, MAXNAMELEN); |
| 242 | } else if (!strcmp(this_char, MNTOPT_MTPT)) { |
| 243 | if (!value || !*value) { |
| 244 | cmn_err(CE_WARN, |
| 245 | "XFS: %s option requires an argument", |
| 246 | this_char); |
| 247 | return EINVAL; |
| 248 | } |
| 249 | strncpy(args->mtpt, value, MAXNAMELEN); |
| 250 | } else if (!strcmp(this_char, MNTOPT_RTDEV)) { |
| 251 | if (!value || !*value) { |
| 252 | cmn_err(CE_WARN, |
| 253 | "XFS: %s option requires an argument", |
| 254 | this_char); |
| 255 | return EINVAL; |
| 256 | } |
| 257 | strncpy(args->rtname, value, MAXNAMELEN); |
| 258 | } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { |
| 259 | if (!value || !*value) { |
| 260 | cmn_err(CE_WARN, |
| 261 | "XFS: %s option requires an argument", |
| 262 | this_char); |
| 263 | return EINVAL; |
| 264 | } |
| 265 | iosize = simple_strtoul(value, &eov, 10); |
| 266 | args->flags |= XFSMNT_IOSIZE; |
| 267 | args->iosizelog = (uint8_t) iosize; |
| 268 | } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { |
| 269 | if (!value || !*value) { |
| 270 | cmn_err(CE_WARN, |
| 271 | "XFS: %s option requires an argument", |
| 272 | this_char); |
| 273 | return EINVAL; |
| 274 | } |
| 275 | iosize = suffix_strtoul(value, &eov, 10); |
| 276 | args->flags |= XFSMNT_IOSIZE; |
| 277 | args->iosizelog = ffs(iosize) - 1; |
| 278 | } else if (!strcmp(this_char, MNTOPT_GRPID) || |
| 279 | !strcmp(this_char, MNTOPT_BSDGROUPS)) { |
| 280 | mp->m_flags |= XFS_MOUNT_GRPID; |
| 281 | } else if (!strcmp(this_char, MNTOPT_NOGRPID) || |
| 282 | !strcmp(this_char, MNTOPT_SYSVGROUPS)) { |
| 283 | mp->m_flags &= ~XFS_MOUNT_GRPID; |
| 284 | } else if (!strcmp(this_char, MNTOPT_WSYNC)) { |
| 285 | args->flags |= XFSMNT_WSYNC; |
| 286 | } else if (!strcmp(this_char, MNTOPT_OSYNCISOSYNC)) { |
| 287 | args->flags |= XFSMNT_OSYNCISOSYNC; |
| 288 | } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) { |
| 289 | args->flags |= XFSMNT_NORECOVERY; |
| 290 | } else if (!strcmp(this_char, MNTOPT_INO64)) { |
| 291 | args->flags |= XFSMNT_INO64; |
| 292 | #if !XFS_BIG_INUMS |
| 293 | cmn_err(CE_WARN, |
| 294 | "XFS: %s option not allowed on this system", |
| 295 | this_char); |
| 296 | return EINVAL; |
| 297 | #endif |
| 298 | } else if (!strcmp(this_char, MNTOPT_NOALIGN)) { |
| 299 | args->flags |= XFSMNT_NOALIGN; |
| 300 | } else if (!strcmp(this_char, MNTOPT_SWALLOC)) { |
| 301 | args->flags |= XFSMNT_SWALLOC; |
| 302 | } else if (!strcmp(this_char, MNTOPT_SUNIT)) { |
| 303 | if (!value || !*value) { |
| 304 | cmn_err(CE_WARN, |
| 305 | "XFS: %s option requires an argument", |
| 306 | this_char); |
| 307 | return EINVAL; |
| 308 | } |
| 309 | dsunit = simple_strtoul(value, &eov, 10); |
| 310 | } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { |
| 311 | if (!value || !*value) { |
| 312 | cmn_err(CE_WARN, |
| 313 | "XFS: %s option requires an argument", |
| 314 | this_char); |
| 315 | return EINVAL; |
| 316 | } |
| 317 | dswidth = simple_strtoul(value, &eov, 10); |
| 318 | } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { |
| 319 | args->flags &= ~XFSMNT_32BITINODES; |
| 320 | #if !XFS_BIG_INUMS |
| 321 | cmn_err(CE_WARN, |
| 322 | "XFS: %s option not allowed on this system", |
| 323 | this_char); |
| 324 | return EINVAL; |
| 325 | #endif |
| 326 | } else if (!strcmp(this_char, MNTOPT_NOUUID)) { |
| 327 | args->flags |= XFSMNT_NOUUID; |
| 328 | } else if (!strcmp(this_char, MNTOPT_BARRIER)) { |
| 329 | args->flags |= XFSMNT_BARRIER; |
| 330 | } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) { |
| 331 | args->flags &= ~XFSMNT_BARRIER; |
| 332 | } else if (!strcmp(this_char, MNTOPT_IKEEP)) { |
Josef Jeff Sipek | 1bd960e | 2008-02-29 13:58:40 +1100 | [diff] [blame] | 333 | args->flags |= XFSMNT_IKEEP; |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 334 | } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) { |
Josef Jeff Sipek | 1bd960e | 2008-02-29 13:58:40 +1100 | [diff] [blame] | 335 | dmapi_implies_ikeep = 0; |
| 336 | args->flags &= ~XFSMNT_IKEEP; |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 337 | } else if (!strcmp(this_char, MNTOPT_LARGEIO)) { |
| 338 | args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE; |
| 339 | } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) { |
| 340 | args->flags2 |= XFSMNT2_COMPAT_IOSIZE; |
| 341 | } else if (!strcmp(this_char, MNTOPT_ATTR2)) { |
| 342 | args->flags |= XFSMNT_ATTR2; |
| 343 | } else if (!strcmp(this_char, MNTOPT_NOATTR2)) { |
| 344 | args->flags &= ~XFSMNT_ATTR2; |
Tim Shimmin | 7c12f29 | 2008-04-30 18:15:28 +1000 | [diff] [blame] | 345 | args->flags |= XFSMNT_NOATTR2; |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 346 | } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) { |
| 347 | args->flags2 |= XFSMNT2_FILESTREAMS; |
| 348 | } else if (!strcmp(this_char, MNTOPT_NOQUOTA)) { |
| 349 | args->flags &= ~(XFSMNT_UQUOTAENF|XFSMNT_UQUOTA); |
| 350 | args->flags &= ~(XFSMNT_GQUOTAENF|XFSMNT_GQUOTA); |
| 351 | } else if (!strcmp(this_char, MNTOPT_QUOTA) || |
| 352 | !strcmp(this_char, MNTOPT_UQUOTA) || |
| 353 | !strcmp(this_char, MNTOPT_USRQUOTA)) { |
| 354 | args->flags |= XFSMNT_UQUOTA | XFSMNT_UQUOTAENF; |
| 355 | } else if (!strcmp(this_char, MNTOPT_QUOTANOENF) || |
| 356 | !strcmp(this_char, MNTOPT_UQUOTANOENF)) { |
| 357 | args->flags |= XFSMNT_UQUOTA; |
| 358 | args->flags &= ~XFSMNT_UQUOTAENF; |
| 359 | } else if (!strcmp(this_char, MNTOPT_PQUOTA) || |
| 360 | !strcmp(this_char, MNTOPT_PRJQUOTA)) { |
| 361 | args->flags |= XFSMNT_PQUOTA | XFSMNT_PQUOTAENF; |
| 362 | } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) { |
| 363 | args->flags |= XFSMNT_PQUOTA; |
| 364 | args->flags &= ~XFSMNT_PQUOTAENF; |
| 365 | } else if (!strcmp(this_char, MNTOPT_GQUOTA) || |
| 366 | !strcmp(this_char, MNTOPT_GRPQUOTA)) { |
| 367 | args->flags |= XFSMNT_GQUOTA | XFSMNT_GQUOTAENF; |
| 368 | } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) { |
| 369 | args->flags |= XFSMNT_GQUOTA; |
| 370 | args->flags &= ~XFSMNT_GQUOTAENF; |
| 371 | } else if (!strcmp(this_char, MNTOPT_DMAPI)) { |
| 372 | args->flags |= XFSMNT_DMAPI; |
| 373 | } else if (!strcmp(this_char, MNTOPT_XDSM)) { |
| 374 | args->flags |= XFSMNT_DMAPI; |
| 375 | } else if (!strcmp(this_char, MNTOPT_DMI)) { |
| 376 | args->flags |= XFSMNT_DMAPI; |
| 377 | } else if (!strcmp(this_char, "ihashsize")) { |
| 378 | cmn_err(CE_WARN, |
| 379 | "XFS: ihashsize no longer used, option is deprecated."); |
| 380 | } else if (!strcmp(this_char, "osyncisdsync")) { |
| 381 | /* no-op, this is now the default */ |
| 382 | cmn_err(CE_WARN, |
| 383 | "XFS: osyncisdsync is now the default, option is deprecated."); |
| 384 | } else if (!strcmp(this_char, "irixsgid")) { |
| 385 | cmn_err(CE_WARN, |
| 386 | "XFS: irixsgid is now a sysctl(2) variable, option is deprecated."); |
| 387 | } else { |
| 388 | cmn_err(CE_WARN, |
| 389 | "XFS: unknown mount option [%s].", this_char); |
| 390 | return EINVAL; |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | if (args->flags & XFSMNT_NORECOVERY) { |
| 395 | if ((mp->m_flags & XFS_MOUNT_RDONLY) == 0) { |
| 396 | cmn_err(CE_WARN, |
| 397 | "XFS: no-recovery mounts must be read-only."); |
| 398 | return EINVAL; |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | if ((args->flags & XFSMNT_NOALIGN) && (dsunit || dswidth)) { |
| 403 | cmn_err(CE_WARN, |
| 404 | "XFS: sunit and swidth options incompatible with the noalign option"); |
| 405 | return EINVAL; |
| 406 | } |
| 407 | |
| 408 | if ((args->flags & XFSMNT_GQUOTA) && (args->flags & XFSMNT_PQUOTA)) { |
| 409 | cmn_err(CE_WARN, |
| 410 | "XFS: cannot mount with both project and group quota"); |
| 411 | return EINVAL; |
| 412 | } |
| 413 | |
| 414 | if ((args->flags & XFSMNT_DMAPI) && *args->mtpt == '\0') { |
| 415 | printk("XFS: %s option needs the mount point option as well\n", |
| 416 | MNTOPT_DMAPI); |
| 417 | return EINVAL; |
| 418 | } |
| 419 | |
| 420 | if ((dsunit && !dswidth) || (!dsunit && dswidth)) { |
| 421 | cmn_err(CE_WARN, |
| 422 | "XFS: sunit and swidth must be specified together"); |
| 423 | return EINVAL; |
| 424 | } |
| 425 | |
| 426 | if (dsunit && (dswidth % dsunit != 0)) { |
| 427 | cmn_err(CE_WARN, |
| 428 | "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)", |
| 429 | dswidth, dsunit); |
| 430 | return EINVAL; |
| 431 | } |
| 432 | |
| 433 | /* |
| 434 | * Applications using DMI filesystems often expect the |
| 435 | * inode generation number to be monotonically increasing. |
| 436 | * If we delete inode chunks we break this assumption, so |
| 437 | * keep unused inode chunks on disk for DMI filesystems |
| 438 | * until we come up with a better solution. |
| 439 | * Note that if "ikeep" or "noikeep" mount options are |
| 440 | * supplied, then they are honored. |
| 441 | */ |
Josef Jeff Sipek | 1bd960e | 2008-02-29 13:58:40 +1100 | [diff] [blame] | 442 | if ((args->flags & XFSMNT_DMAPI) && dmapi_implies_ikeep) |
| 443 | args->flags |= XFSMNT_IKEEP; |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 444 | |
| 445 | if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) { |
| 446 | if (dsunit) { |
| 447 | args->sunit = dsunit; |
| 448 | args->flags |= XFSMNT_RETERR; |
| 449 | } else { |
| 450 | args->sunit = vol_dsunit; |
| 451 | } |
| 452 | dswidth ? (args->swidth = dswidth) : |
| 453 | (args->swidth = vol_dswidth); |
| 454 | } else { |
| 455 | args->sunit = args->swidth = 0; |
| 456 | } |
| 457 | |
| 458 | done: |
| 459 | if (args->flags & XFSMNT_32BITINODES) |
| 460 | mp->m_flags |= XFS_MOUNT_SMALL_INUMS; |
| 461 | if (args->flags2) |
| 462 | args->flags |= XFSMNT_FLAGS2; |
| 463 | return 0; |
| 464 | } |
| 465 | |
| 466 | struct proc_xfs_info { |
| 467 | int flag; |
| 468 | char *str; |
| 469 | }; |
| 470 | |
| 471 | STATIC int |
| 472 | xfs_showargs( |
| 473 | struct xfs_mount *mp, |
| 474 | struct seq_file *m) |
| 475 | { |
| 476 | static struct proc_xfs_info xfs_info_set[] = { |
| 477 | /* the few simple ones we can get from the mount struct */ |
Josef Jeff Sipek | 1bd960e | 2008-02-29 13:58:40 +1100 | [diff] [blame] | 478 | { XFS_MOUNT_IKEEP, "," MNTOPT_IKEEP }, |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 479 | { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC }, |
| 480 | { XFS_MOUNT_INO64, "," MNTOPT_INO64 }, |
| 481 | { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN }, |
| 482 | { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC }, |
| 483 | { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID }, |
| 484 | { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY }, |
| 485 | { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC }, |
| 486 | { XFS_MOUNT_ATTR2, "," MNTOPT_ATTR2 }, |
| 487 | { XFS_MOUNT_FILESTREAMS, "," MNTOPT_FILESTREAM }, |
| 488 | { XFS_MOUNT_DMAPI, "," MNTOPT_DMAPI }, |
| 489 | { XFS_MOUNT_GRPID, "," MNTOPT_GRPID }, |
| 490 | { 0, NULL } |
| 491 | }; |
| 492 | static struct proc_xfs_info xfs_info_unset[] = { |
| 493 | /* the few simple ones we can get from the mount struct */ |
David Chinner | a67d7c5 | 2007-11-23 16:29:32 +1100 | [diff] [blame] | 494 | { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO }, |
| 495 | { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER }, |
| 496 | { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE }, |
| 497 | { 0, NULL } |
| 498 | }; |
| 499 | struct proc_xfs_info *xfs_infop; |
| 500 | |
| 501 | for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) { |
| 502 | if (mp->m_flags & xfs_infop->flag) |
| 503 | seq_puts(m, xfs_infop->str); |
| 504 | } |
| 505 | for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) { |
| 506 | if (!(mp->m_flags & xfs_infop->flag)) |
| 507 | seq_puts(m, xfs_infop->str); |
| 508 | } |
| 509 | |
| 510 | if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) |
| 511 | seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk", |
| 512 | (int)(1 << mp->m_writeio_log) >> 10); |
| 513 | |
| 514 | if (mp->m_logbufs > 0) |
| 515 | seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs); |
| 516 | if (mp->m_logbsize > 0) |
| 517 | seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10); |
| 518 | |
| 519 | if (mp->m_logname) |
| 520 | seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname); |
| 521 | if (mp->m_rtname) |
| 522 | seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname); |
| 523 | |
| 524 | if (mp->m_dalign > 0) |
| 525 | seq_printf(m, "," MNTOPT_SUNIT "=%d", |
| 526 | (int)XFS_FSB_TO_BB(mp, mp->m_dalign)); |
| 527 | if (mp->m_swidth > 0) |
| 528 | seq_printf(m, "," MNTOPT_SWIDTH "=%d", |
| 529 | (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); |
| 530 | |
| 531 | if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD)) |
| 532 | seq_puts(m, "," MNTOPT_USRQUOTA); |
| 533 | else if (mp->m_qflags & XFS_UQUOTA_ACCT) |
| 534 | seq_puts(m, "," MNTOPT_UQUOTANOENF); |
| 535 | |
| 536 | if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD)) |
| 537 | seq_puts(m, "," MNTOPT_PRJQUOTA); |
| 538 | else if (mp->m_qflags & XFS_PQUOTA_ACCT) |
| 539 | seq_puts(m, "," MNTOPT_PQUOTANOENF); |
| 540 | |
| 541 | if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD)) |
| 542 | seq_puts(m, "," MNTOPT_GRPQUOTA); |
| 543 | else if (mp->m_qflags & XFS_GQUOTA_ACCT) |
| 544 | seq_puts(m, "," MNTOPT_GQUOTANOENF); |
| 545 | |
| 546 | if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT)) |
| 547 | seq_puts(m, "," MNTOPT_NOQUOTA); |
| 548 | |
| 549 | return 0; |
| 550 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | __uint64_t |
| 552 | xfs_max_file_offset( |
| 553 | unsigned int blockshift) |
| 554 | { |
| 555 | unsigned int pagefactor = 1; |
| 556 | unsigned int bitshift = BITS_PER_LONG - 1; |
| 557 | |
| 558 | /* Figure out maximum filesize, on Linux this can depend on |
| 559 | * the filesystem blocksize (on 32 bit platforms). |
| 560 | * __block_prepare_write does this in an [unsigned] long... |
| 561 | * page->index << (PAGE_CACHE_SHIFT - bbits) |
| 562 | * So, for page sized blocks (4K on 32 bit platforms), |
| 563 | * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is |
| 564 | * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) |
| 565 | * but for smaller blocksizes it is less (bbits = log2 bsize). |
| 566 | * Note1: get_block_t takes a long (implicit cast from above) |
| 567 | * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch |
| 568 | * can optionally convert the [unsigned] long from above into |
| 569 | * an [unsigned] long long. |
| 570 | */ |
| 571 | |
| 572 | #if BITS_PER_LONG == 32 |
| 573 | # if defined(CONFIG_LBD) |
| 574 | ASSERT(sizeof(sector_t) == 8); |
| 575 | pagefactor = PAGE_CACHE_SIZE; |
| 576 | bitshift = BITS_PER_LONG; |
| 577 | # else |
| 578 | pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift); |
| 579 | # endif |
| 580 | #endif |
| 581 | |
| 582 | return (((__uint64_t)pagefactor) << bitshift) - 1; |
| 583 | } |
| 584 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | int |
| 586 | xfs_blkdev_get( |
| 587 | xfs_mount_t *mp, |
| 588 | const char *name, |
| 589 | struct block_device **bdevp) |
| 590 | { |
| 591 | int error = 0; |
| 592 | |
Al Viro | 30c40d2 | 2008-02-22 19:50:45 -0500 | [diff] [blame] | 593 | *bdevp = open_bdev_exclusive(name, FMODE_READ|FMODE_WRITE, mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | if (IS_ERR(*bdevp)) { |
| 595 | error = PTR_ERR(*bdevp); |
| 596 | printk("XFS: Invalid device [%s], error=%d\n", name, error); |
| 597 | } |
| 598 | |
| 599 | return -error; |
| 600 | } |
| 601 | |
| 602 | void |
| 603 | xfs_blkdev_put( |
| 604 | struct block_device *bdev) |
| 605 | { |
| 606 | if (bdev) |
Al Viro | 30c40d2 | 2008-02-22 19:50:45 -0500 | [diff] [blame] | 607 | close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | } |
| 609 | |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 610 | /* |
| 611 | * Try to write out the superblock using barriers. |
| 612 | */ |
| 613 | STATIC int |
| 614 | xfs_barrier_test( |
| 615 | xfs_mount_t *mp) |
| 616 | { |
| 617 | xfs_buf_t *sbp = xfs_getsb(mp, 0); |
| 618 | int error; |
| 619 | |
| 620 | XFS_BUF_UNDONE(sbp); |
| 621 | XFS_BUF_UNREAD(sbp); |
| 622 | XFS_BUF_UNDELAYWRITE(sbp); |
| 623 | XFS_BUF_WRITE(sbp); |
| 624 | XFS_BUF_UNASYNC(sbp); |
| 625 | XFS_BUF_ORDERED(sbp); |
| 626 | |
| 627 | xfsbdstrat(mp, sbp); |
| 628 | error = xfs_iowait(sbp); |
| 629 | |
| 630 | /* |
| 631 | * Clear all the flags we set and possible error state in the |
| 632 | * buffer. We only did the write to try out whether barriers |
| 633 | * worked and shouldn't leave any traces in the superblock |
| 634 | * buffer. |
| 635 | */ |
| 636 | XFS_BUF_DONE(sbp); |
| 637 | XFS_BUF_ERROR(sbp, 0); |
| 638 | XFS_BUF_UNORDERED(sbp); |
| 639 | |
| 640 | xfs_buf_relse(sbp); |
| 641 | return error; |
| 642 | } |
| 643 | |
| 644 | void |
| 645 | xfs_mountfs_check_barriers(xfs_mount_t *mp) |
| 646 | { |
| 647 | int error; |
| 648 | |
| 649 | if (mp->m_logdev_targp != mp->m_ddev_targp) { |
| 650 | xfs_fs_cmn_err(CE_NOTE, mp, |
| 651 | "Disabling barriers, not supported with external log device"); |
| 652 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
Christoph Hellwig | 4ef19dd | 2006-01-11 15:27:18 +1100 | [diff] [blame] | 653 | return; |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 654 | } |
| 655 | |
Nathan Scott | b2ea401 | 2006-07-28 17:05:13 +1000 | [diff] [blame] | 656 | if (xfs_readonly_buftarg(mp->m_ddev_targp)) { |
| 657 | xfs_fs_cmn_err(CE_NOTE, mp, |
| 658 | "Disabling barriers, underlying device is readonly"); |
| 659 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
| 660 | return; |
| 661 | } |
| 662 | |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 663 | error = xfs_barrier_test(mp); |
| 664 | if (error) { |
| 665 | xfs_fs_cmn_err(CE_NOTE, mp, |
| 666 | "Disabling barriers, trial barrier write failed"); |
| 667 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
Christoph Hellwig | 4ef19dd | 2006-01-11 15:27:18 +1100 | [diff] [blame] | 668 | return; |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 669 | } |
| 670 | } |
| 671 | |
| 672 | void |
| 673 | xfs_blkdev_issue_flush( |
| 674 | xfs_buftarg_t *buftarg) |
| 675 | { |
Nathan Scott | ce8e922 | 2006-01-11 15:39:08 +1100 | [diff] [blame] | 676 | blkdev_issue_flush(buftarg->bt_bdev, NULL); |
Christoph Hellwig | f538d4d | 2005-11-02 10:26:59 +1100 | [diff] [blame] | 677 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 679 | STATIC void |
| 680 | xfs_close_devices( |
| 681 | struct xfs_mount *mp) |
| 682 | { |
| 683 | if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { |
Lachlan McIlroy | c032bfc | 2008-07-18 17:13:12 +1000 | [diff] [blame] | 684 | struct block_device *logdev = mp->m_logdev_targp->bt_bdev; |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 685 | xfs_free_buftarg(mp->m_logdev_targp); |
Lachlan McIlroy | c032bfc | 2008-07-18 17:13:12 +1000 | [diff] [blame] | 686 | xfs_blkdev_put(logdev); |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 687 | } |
| 688 | if (mp->m_rtdev_targp) { |
Lachlan McIlroy | c032bfc | 2008-07-18 17:13:12 +1000 | [diff] [blame] | 689 | struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev; |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 690 | xfs_free_buftarg(mp->m_rtdev_targp); |
Lachlan McIlroy | c032bfc | 2008-07-18 17:13:12 +1000 | [diff] [blame] | 691 | xfs_blkdev_put(rtdev); |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 692 | } |
| 693 | xfs_free_buftarg(mp->m_ddev_targp); |
| 694 | } |
| 695 | |
| 696 | /* |
| 697 | * The file system configurations are: |
| 698 | * (1) device (partition) with data and internal log |
| 699 | * (2) logical volume with data and log subvolumes. |
| 700 | * (3) logical volume with data, log, and realtime subvolumes. |
| 701 | * |
| 702 | * We only have to handle opening the log and realtime volumes here if |
| 703 | * they are present. The data subvolume has already been opened by |
| 704 | * get_sb_bdev() and is stored in sb->s_bdev. |
| 705 | */ |
| 706 | STATIC int |
| 707 | xfs_open_devices( |
| 708 | struct xfs_mount *mp, |
| 709 | struct xfs_mount_args *args) |
| 710 | { |
| 711 | struct block_device *ddev = mp->m_super->s_bdev; |
| 712 | struct block_device *logdev = NULL, *rtdev = NULL; |
| 713 | int error; |
| 714 | |
| 715 | /* |
| 716 | * Open real time and log devices - order is important. |
| 717 | */ |
| 718 | if (args->logname[0]) { |
| 719 | error = xfs_blkdev_get(mp, args->logname, &logdev); |
| 720 | if (error) |
| 721 | goto out; |
| 722 | } |
| 723 | |
| 724 | if (args->rtname[0]) { |
| 725 | error = xfs_blkdev_get(mp, args->rtname, &rtdev); |
| 726 | if (error) |
| 727 | goto out_close_logdev; |
| 728 | |
| 729 | if (rtdev == ddev || rtdev == logdev) { |
| 730 | cmn_err(CE_WARN, |
| 731 | "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev."); |
| 732 | error = EINVAL; |
| 733 | goto out_close_rtdev; |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | /* |
| 738 | * Setup xfs_mount buffer target pointers |
| 739 | */ |
| 740 | error = ENOMEM; |
| 741 | mp->m_ddev_targp = xfs_alloc_buftarg(ddev, 0); |
| 742 | if (!mp->m_ddev_targp) |
| 743 | goto out_close_rtdev; |
| 744 | |
| 745 | if (rtdev) { |
| 746 | mp->m_rtdev_targp = xfs_alloc_buftarg(rtdev, 1); |
| 747 | if (!mp->m_rtdev_targp) |
| 748 | goto out_free_ddev_targ; |
| 749 | } |
| 750 | |
| 751 | if (logdev && logdev != ddev) { |
| 752 | mp->m_logdev_targp = xfs_alloc_buftarg(logdev, 1); |
| 753 | if (!mp->m_logdev_targp) |
| 754 | goto out_free_rtdev_targ; |
| 755 | } else { |
| 756 | mp->m_logdev_targp = mp->m_ddev_targp; |
| 757 | } |
| 758 | |
| 759 | return 0; |
| 760 | |
| 761 | out_free_rtdev_targ: |
| 762 | if (mp->m_rtdev_targp) |
| 763 | xfs_free_buftarg(mp->m_rtdev_targp); |
| 764 | out_free_ddev_targ: |
| 765 | xfs_free_buftarg(mp->m_ddev_targp); |
| 766 | out_close_rtdev: |
| 767 | if (rtdev) |
| 768 | xfs_blkdev_put(rtdev); |
| 769 | out_close_logdev: |
| 770 | if (logdev && logdev != ddev) |
| 771 | xfs_blkdev_put(logdev); |
| 772 | out: |
| 773 | return error; |
| 774 | } |
| 775 | |
Christoph Hellwig | e34b562 | 2008-05-20 15:10:36 +1000 | [diff] [blame] | 776 | /* |
| 777 | * Setup xfs_mount buffer target pointers based on superblock |
| 778 | */ |
| 779 | STATIC int |
| 780 | xfs_setup_devices( |
| 781 | struct xfs_mount *mp) |
| 782 | { |
| 783 | int error; |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 784 | |
Christoph Hellwig | e34b562 | 2008-05-20 15:10:36 +1000 | [diff] [blame] | 785 | error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize, |
| 786 | mp->m_sb.sb_sectsize); |
| 787 | if (error) |
| 788 | return error; |
| 789 | |
| 790 | if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { |
| 791 | unsigned int log_sector_size = BBSIZE; |
| 792 | |
| 793 | if (xfs_sb_version_hassector(&mp->m_sb)) |
| 794 | log_sector_size = mp->m_sb.sb_logsectsize; |
| 795 | error = xfs_setsize_buftarg(mp->m_logdev_targp, |
| 796 | mp->m_sb.sb_blocksize, |
| 797 | log_sector_size); |
| 798 | if (error) |
| 799 | return error; |
| 800 | } |
| 801 | if (mp->m_rtdev_targp) { |
| 802 | error = xfs_setsize_buftarg(mp->m_rtdev_targp, |
| 803 | mp->m_sb.sb_blocksize, |
| 804 | mp->m_sb.sb_sectsize); |
| 805 | if (error) |
| 806 | return error; |
| 807 | } |
| 808 | |
| 809 | return 0; |
| 810 | } |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 811 | |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 812 | /* |
| 813 | * XFS AIL push thread support |
| 814 | */ |
| 815 | void |
| 816 | xfsaild_wakeup( |
David Chinner | 82fa901 | 2008-10-30 17:38:26 +1100 | [diff] [blame^] | 817 | struct xfs_ail *ailp, |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 818 | xfs_lsn_t threshold_lsn) |
| 819 | { |
David Chinner | 82fa901 | 2008-10-30 17:38:26 +1100 | [diff] [blame^] | 820 | ailp->xa_target = threshold_lsn; |
| 821 | wake_up_process(ailp->xa_task); |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | int |
| 825 | xfsaild( |
| 826 | void *data) |
| 827 | { |
David Chinner | 82fa901 | 2008-10-30 17:38:26 +1100 | [diff] [blame^] | 828 | struct xfs_ail *ailp = data; |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 829 | xfs_lsn_t last_pushed_lsn = 0; |
| 830 | long tout = 0; |
| 831 | |
| 832 | while (!kthread_should_stop()) { |
| 833 | if (tout) |
| 834 | schedule_timeout_interruptible(msecs_to_jiffies(tout)); |
| 835 | tout = 1000; |
| 836 | |
| 837 | /* swsusp */ |
| 838 | try_to_freeze(); |
| 839 | |
David Chinner | 82fa901 | 2008-10-30 17:38:26 +1100 | [diff] [blame^] | 840 | ASSERT(ailp->xa_mount->m_log); |
| 841 | if (XFS_FORCED_SHUTDOWN(ailp->xa_mount)) |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 842 | continue; |
| 843 | |
David Chinner | 82fa901 | 2008-10-30 17:38:26 +1100 | [diff] [blame^] | 844 | tout = xfsaild_push(ailp, &last_pushed_lsn); |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | return 0; |
| 848 | } /* xfsaild */ |
| 849 | |
| 850 | int |
| 851 | xfsaild_start( |
David Chinner | 82fa901 | 2008-10-30 17:38:26 +1100 | [diff] [blame^] | 852 | struct xfs_ail *ailp) |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 853 | { |
David Chinner | 82fa901 | 2008-10-30 17:38:26 +1100 | [diff] [blame^] | 854 | ailp->xa_target = 0; |
| 855 | ailp->xa_task = kthread_run(xfsaild, ailp, "xfsaild"); |
| 856 | if (IS_ERR(ailp->xa_task)) |
| 857 | return -PTR_ERR(ailp->xa_task); |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 858 | return 0; |
| 859 | } |
| 860 | |
| 861 | void |
| 862 | xfsaild_stop( |
David Chinner | 82fa901 | 2008-10-30 17:38:26 +1100 | [diff] [blame^] | 863 | struct xfs_ail *ailp) |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 864 | { |
David Chinner | 82fa901 | 2008-10-30 17:38:26 +1100 | [diff] [blame^] | 865 | kthread_stop(ailp->xa_task); |
David Chinner | 249a8c1 | 2008-02-05 12:13:32 +1100 | [diff] [blame] | 866 | } |
| 867 | |
| 868 | |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 869 | /* Catch misguided souls that try to use this interface on XFS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | STATIC struct inode * |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 871 | xfs_fs_alloc_inode( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | struct super_block *sb) |
| 873 | { |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 874 | BUG(); |
Lachlan McIlroy | 493dca6 | 2008-10-30 17:36:52 +1100 | [diff] [blame] | 875 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | } |
| 877 | |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 878 | /* |
David Chinner | 99fa8cb | 2008-10-30 17:36:40 +1100 | [diff] [blame] | 879 | * Now that the generic code is guaranteed not to be accessing |
| 880 | * the linux inode, we can reclaim the inode. |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 881 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | STATIC void |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 883 | xfs_fs_destroy_inode( |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 884 | struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | { |
David Chinner | 99fa8cb | 2008-10-30 17:36:40 +1100 | [diff] [blame] | 886 | xfs_inode_t *ip = XFS_I(inode); |
| 887 | |
| 888 | XFS_STATS_INC(vn_reclaim); |
| 889 | if (xfs_reclaim(ip)) |
| 890 | panic("%s: cannot reclaim 0x%p\n", __func__, inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | } |
| 892 | |
David Chinner | 07c8f67 | 2008-10-30 16:11:59 +1100 | [diff] [blame] | 893 | /* |
| 894 | * Slab object creation initialisation for the XFS inode. |
| 895 | * This covers only the idempotent fields in the XFS inode; |
| 896 | * all other fields need to be initialised on allocation |
| 897 | * from the slab. This avoids the need to repeatedly intialise |
| 898 | * fields in the xfs inode that left in the initialise state |
| 899 | * when freeing the inode. |
| 900 | */ |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 901 | STATIC void |
| 902 | xfs_fs_inode_init_once( |
David Chinner | 07c8f67 | 2008-10-30 16:11:59 +1100 | [diff] [blame] | 903 | void *inode) |
| 904 | { |
| 905 | struct xfs_inode *ip = inode; |
| 906 | |
| 907 | memset(ip, 0, sizeof(struct xfs_inode)); |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 908 | |
| 909 | /* vfs inode */ |
| 910 | inode_init_once(VFS_I(ip)); |
| 911 | |
| 912 | /* xfs inode */ |
David Chinner | 07c8f67 | 2008-10-30 16:11:59 +1100 | [diff] [blame] | 913 | atomic_set(&ip->i_iocount, 0); |
| 914 | atomic_set(&ip->i_pincount, 0); |
| 915 | spin_lock_init(&ip->i_flags_lock); |
David Chinner | 07c8f67 | 2008-10-30 16:11:59 +1100 | [diff] [blame] | 916 | init_waitqueue_head(&ip->i_ipin_wait); |
| 917 | /* |
| 918 | * Because we want to use a counting completion, complete |
| 919 | * the flush completion once to allow a single access to |
| 920 | * the flush completion without blocking. |
| 921 | */ |
| 922 | init_completion(&ip->i_flush); |
| 923 | complete(&ip->i_flush); |
| 924 | |
| 925 | mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER, |
| 926 | "xfsino", ip->i_ino); |
| 927 | mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino); |
| 928 | } |
| 929 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | /* |
| 931 | * Attempt to flush the inode, this will actually fail |
| 932 | * if the inode is pinned, but we dirty the inode again |
| 933 | * at the point when it is unpinned after a log write, |
Nathan Scott | 8758280 | 2006-03-14 13:18:19 +1100 | [diff] [blame] | 934 | * since this is when the inode itself becomes flushable. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | */ |
| 936 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 937 | xfs_fs_write_inode( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | struct inode *inode, |
| 939 | int sync) |
| 940 | { |
David Chinner | a3f74ff | 2008-03-06 13:43:42 +1100 | [diff] [blame] | 941 | int error = 0; |
| 942 | int flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | |
Lachlan McIlroy | cf441ee | 2008-02-07 16:42:19 +1100 | [diff] [blame] | 944 | xfs_itrace_entry(XFS_I(inode)); |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame] | 945 | if (sync) { |
| 946 | filemap_fdatawait(inode->i_mapping); |
| 947 | flags |= FLUSH_SYNC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 948 | } |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame] | 949 | error = xfs_inode_flush(XFS_I(inode), flags); |
Lachlan McIlroy | e893bff | 2007-10-12 11:13:35 +1000 | [diff] [blame] | 950 | /* |
| 951 | * if we failed to write out the inode then mark |
| 952 | * it dirty again so we'll try again later. |
| 953 | */ |
| 954 | if (error) |
David Chinner | 94b97e3 | 2008-10-30 17:21:30 +1100 | [diff] [blame] | 955 | xfs_mark_inode_dirty_sync(XFS_I(inode)); |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame] | 956 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | return -error; |
| 958 | } |
| 959 | |
| 960 | STATIC void |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 961 | xfs_fs_clear_inode( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | struct inode *inode) |
| 963 | { |
Christoph Hellwig | 1543d79 | 2007-08-29 11:46:47 +1000 | [diff] [blame] | 964 | xfs_inode_t *ip = XFS_I(inode); |
Christoph Hellwig | 56d433e | 2005-09-05 08:23:54 +1000 | [diff] [blame] | 965 | |
David Chinner | 99fa8cb | 2008-10-30 17:36:40 +1100 | [diff] [blame] | 966 | xfs_itrace_entry(ip); |
| 967 | XFS_STATS_INC(vn_rele); |
| 968 | XFS_STATS_INC(vn_remove); |
| 969 | XFS_STATS_DEC(vn_active); |
Christoph Hellwig | 56d433e | 2005-09-05 08:23:54 +1000 | [diff] [blame] | 970 | |
David Chinner | 99fa8cb | 2008-10-30 17:36:40 +1100 | [diff] [blame] | 971 | xfs_inactive(ip); |
| 972 | xfs_iflags_clear(ip, XFS_IMODIFIED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | } |
| 974 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | STATIC void |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 976 | xfs_free_fsname( |
| 977 | struct xfs_mount *mp) |
| 978 | { |
| 979 | kfree(mp->m_fsname); |
| 980 | kfree(mp->m_rtname); |
| 981 | kfree(mp->m_logname); |
| 982 | } |
| 983 | |
| 984 | STATIC void |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 985 | xfs_fs_put_super( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | struct super_block *sb) |
| 987 | { |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame] | 988 | struct xfs_mount *mp = XFS_M(sb); |
Christoph Hellwig | e48ad31 | 2008-05-20 11:30:52 +1000 | [diff] [blame] | 989 | struct xfs_inode *rip = mp->m_rootip; |
| 990 | int unmount_event_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 991 | int error; |
| 992 | |
David Chinner | a167b17 | 2008-10-30 17:06:18 +1100 | [diff] [blame] | 993 | xfs_syncd_stop(mp); |
David Chinner | be97d9d | 2008-10-30 17:15:38 +1100 | [diff] [blame] | 994 | xfs_sync_inodes(mp, SYNC_ATTR|SYNC_DELWRI); |
Christoph Hellwig | e48ad31 | 2008-05-20 11:30:52 +1000 | [diff] [blame] | 995 | |
| 996 | #ifdef HAVE_DMAPI |
| 997 | if (mp->m_flags & XFS_MOUNT_DMAPI) { |
| 998 | unmount_event_flags = |
| 999 | (mp->m_dmevmask & (1 << DM_EVENT_UNMOUNT)) ? |
| 1000 | 0 : DM_FLAGS_UNWANTED; |
| 1001 | /* |
| 1002 | * Ignore error from dmapi here, first unmount is not allowed |
| 1003 | * to fail anyway, and second we wouldn't want to fail a |
| 1004 | * unmount because of dmapi. |
| 1005 | */ |
| 1006 | XFS_SEND_PREUNMOUNT(mp, rip, DM_RIGHT_NULL, rip, DM_RIGHT_NULL, |
| 1007 | NULL, NULL, 0, 0, unmount_event_flags); |
| 1008 | } |
| 1009 | #endif |
| 1010 | |
| 1011 | /* |
| 1012 | * Blow away any referenced inode in the filestreams cache. |
| 1013 | * This can and will cause log traffic as inodes go inactive |
| 1014 | * here. |
| 1015 | */ |
| 1016 | xfs_filestream_unmount(mp); |
| 1017 | |
| 1018 | XFS_bflush(mp->m_ddev_targp); |
| 1019 | error = xfs_unmount_flush(mp, 0); |
| 1020 | WARN_ON(error); |
| 1021 | |
Christoph Hellwig | e48ad31 | 2008-05-20 11:30:52 +1000 | [diff] [blame] | 1022 | if (mp->m_flags & XFS_MOUNT_DMAPI) { |
| 1023 | XFS_SEND_UNMOUNT(mp, rip, DM_RIGHT_NULL, 0, 0, |
| 1024 | unmount_event_flags); |
| 1025 | } |
| 1026 | |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 1027 | xfs_unmountfs(mp); |
Christoph Hellwig | 6203300 | 2008-08-13 16:50:21 +1000 | [diff] [blame] | 1028 | xfs_freesb(mp); |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1029 | xfs_icsb_destroy_counters(mp); |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 1030 | xfs_close_devices(mp); |
Christoph Hellwig | e48ad31 | 2008-05-20 11:30:52 +1000 | [diff] [blame] | 1031 | xfs_qmops_put(mp); |
| 1032 | xfs_dmops_put(mp); |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1033 | xfs_free_fsname(mp); |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1034 | kfree(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | STATIC void |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1038 | xfs_fs_write_super( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | struct super_block *sb) |
| 1040 | { |
Nathan Scott | b83bd13 | 2006-06-09 16:48:30 +1000 | [diff] [blame] | 1041 | if (!(sb->s_flags & MS_RDONLY)) |
David Chinner | e9f1c6e | 2008-10-30 17:15:50 +1100 | [diff] [blame] | 1042 | xfs_sync_fsdata(XFS_M(sb), 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | sb->s_dirt = 0; |
| 1044 | } |
| 1045 | |
| 1046 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1047 | xfs_fs_sync_super( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | struct super_block *sb, |
| 1049 | int wait) |
| 1050 | { |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame] | 1051 | struct xfs_mount *mp = XFS_M(sb); |
Nathan Scott | b83bd13 | 2006-06-09 16:48:30 +1000 | [diff] [blame] | 1052 | int error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | |
Lachlan McIlroy | e893bff | 2007-10-12 11:13:35 +1000 | [diff] [blame] | 1054 | /* |
| 1055 | * Treat a sync operation like a freeze. This is to work |
| 1056 | * around a race in sync_inodes() which works in two phases |
| 1057 | * - an asynchronous flush, which can write out an inode |
| 1058 | * without waiting for file size updates to complete, and a |
| 1059 | * synchronous flush, which wont do anything because the |
| 1060 | * async flush removed the inode's dirty flag. Also |
| 1061 | * sync_inodes() will not see any files that just have |
| 1062 | * outstanding transactions to be flushed because we don't |
| 1063 | * dirty the Linux inode until after the transaction I/O |
| 1064 | * completes. |
| 1065 | */ |
David Chinner | e9f1c6e | 2008-10-30 17:15:50 +1100 | [diff] [blame] | 1066 | if (wait || unlikely(sb->s_frozen == SB_FREEZE_WRITE)) |
| 1067 | error = xfs_quiesce_data(mp); |
| 1068 | else |
| 1069 | error = xfs_sync_fsdata(mp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | sb->s_dirt = 0; |
| 1071 | |
| 1072 | if (unlikely(laptop_mode)) { |
Christoph Hellwig | 7439449 | 2007-08-30 17:21:22 +1000 | [diff] [blame] | 1073 | int prev_sync_seq = mp->m_sync_seq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | |
| 1075 | /* |
| 1076 | * The disk must be active because we're syncing. |
| 1077 | * We schedule xfssyncd now (now that the disk is |
| 1078 | * active) instead of later (when it might not be). |
| 1079 | */ |
Christoph Hellwig | 7439449 | 2007-08-30 17:21:22 +1000 | [diff] [blame] | 1080 | wake_up_process(mp->m_sync_task); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | /* |
| 1082 | * We have to wait for the sync iteration to complete. |
| 1083 | * If we don't, the disk activity caused by the sync |
| 1084 | * will come after the sync is completed, and that |
| 1085 | * triggers another sync from laptop mode. |
| 1086 | */ |
Christoph Hellwig | 7439449 | 2007-08-30 17:21:22 +1000 | [diff] [blame] | 1087 | wait_event(mp->m_wait_single_sync_task, |
| 1088 | mp->m_sync_seq != prev_sync_seq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1089 | } |
| 1090 | |
| 1091 | return -error; |
| 1092 | } |
| 1093 | |
| 1094 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1095 | xfs_fs_statfs( |
David Howells | 726c334 | 2006-06-23 02:02:58 -0700 | [diff] [blame] | 1096 | struct dentry *dentry, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1097 | struct kstatfs *statp) |
| 1098 | { |
Christoph Hellwig | 4ca488e | 2007-10-11 18:09:40 +1000 | [diff] [blame] | 1099 | struct xfs_mount *mp = XFS_M(dentry->d_sb); |
| 1100 | xfs_sb_t *sbp = &mp->m_sb; |
| 1101 | __uint64_t fakeinos, id; |
| 1102 | xfs_extlen_t lsize; |
| 1103 | |
| 1104 | statp->f_type = XFS_SB_MAGIC; |
| 1105 | statp->f_namelen = MAXNAMELEN - 1; |
| 1106 | |
| 1107 | id = huge_encode_dev(mp->m_ddev_targp->bt_dev); |
| 1108 | statp->f_fsid.val[0] = (u32)id; |
| 1109 | statp->f_fsid.val[1] = (u32)(id >> 32); |
| 1110 | |
Christoph Hellwig | d4d90b5 | 2008-04-22 17:34:37 +1000 | [diff] [blame] | 1111 | xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT); |
Christoph Hellwig | 4ca488e | 2007-10-11 18:09:40 +1000 | [diff] [blame] | 1112 | |
| 1113 | spin_lock(&mp->m_sb_lock); |
| 1114 | statp->f_bsize = sbp->sb_blocksize; |
| 1115 | lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0; |
| 1116 | statp->f_blocks = sbp->sb_dblocks - lsize; |
| 1117 | statp->f_bfree = statp->f_bavail = |
| 1118 | sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp); |
| 1119 | fakeinos = statp->f_bfree << sbp->sb_inopblog; |
| 1120 | #if XFS_BIG_INUMS |
| 1121 | fakeinos += mp->m_inoadd; |
| 1122 | #endif |
| 1123 | statp->f_files = |
| 1124 | MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER); |
| 1125 | if (mp->m_maxicount) |
| 1126 | #if XFS_BIG_INUMS |
| 1127 | if (!mp->m_inoadd) |
| 1128 | #endif |
| 1129 | statp->f_files = min_t(typeof(statp->f_files), |
| 1130 | statp->f_files, |
| 1131 | mp->m_maxicount); |
| 1132 | statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree); |
| 1133 | spin_unlock(&mp->m_sb_lock); |
| 1134 | |
| 1135 | XFS_QM_DQSTATVFS(XFS_I(dentry->d_inode), statp); |
| 1136 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1140 | xfs_fs_remount( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | struct super_block *sb, |
| 1142 | int *flags, |
| 1143 | char *options) |
| 1144 | { |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame] | 1145 | struct xfs_mount *mp = XFS_M(sb); |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 1146 | substring_t args[MAX_OPT_ARGS]; |
| 1147 | char *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 1149 | while ((p = strsep(&options, ",")) != NULL) { |
| 1150 | int token; |
Christoph Hellwig | bdd907b | 2008-05-20 15:10:44 +1000 | [diff] [blame] | 1151 | |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 1152 | if (!*p) |
| 1153 | continue; |
Christoph Hellwig | 48b62a1 | 2008-05-20 11:30:39 +1000 | [diff] [blame] | 1154 | |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 1155 | token = match_token(p, tokens, args); |
| 1156 | switch (token) { |
| 1157 | case Opt_barrier: |
Christoph Hellwig | 48b62a1 | 2008-05-20 11:30:39 +1000 | [diff] [blame] | 1158 | mp->m_flags |= XFS_MOUNT_BARRIER; |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 1159 | |
| 1160 | /* |
| 1161 | * Test if barriers are actually working if we can, |
| 1162 | * else delay this check until the filesystem is |
| 1163 | * marked writeable. |
| 1164 | */ |
| 1165 | if (!(mp->m_flags & XFS_MOUNT_RDONLY)) |
| 1166 | xfs_mountfs_check_barriers(mp); |
| 1167 | break; |
| 1168 | case Opt_nobarrier: |
Christoph Hellwig | 48b62a1 | 2008-05-20 11:30:39 +1000 | [diff] [blame] | 1169 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 1170 | break; |
| 1171 | default: |
Christoph Hellwig | 6efdf28 | 2008-09-17 16:49:33 +1000 | [diff] [blame] | 1172 | /* |
| 1173 | * Logically we would return an error here to prevent |
| 1174 | * users from believing they might have changed |
| 1175 | * mount options using remount which can't be changed. |
| 1176 | * |
| 1177 | * But unfortunately mount(8) adds all options from |
| 1178 | * mtab and fstab to the mount arguments in some cases |
| 1179 | * so we can't blindly reject options, but have to |
| 1180 | * check for each specified option if it actually |
| 1181 | * differs from the currently set option and only |
| 1182 | * reject it if that's the case. |
| 1183 | * |
| 1184 | * Until that is implemented we return success for |
| 1185 | * every remount request, and silently ignore all |
| 1186 | * options that we can't actually change. |
| 1187 | */ |
| 1188 | #if 0 |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 1189 | printk(KERN_INFO |
| 1190 | "XFS: mount option \"%s\" not supported for remount\n", p); |
| 1191 | return -EINVAL; |
Christoph Hellwig | 6efdf28 | 2008-09-17 16:49:33 +1000 | [diff] [blame] | 1192 | #else |
Christoph Hellwig | 6c5e51d | 2008-10-12 14:30:44 +0200 | [diff] [blame] | 1193 | break; |
Christoph Hellwig | 6efdf28 | 2008-09-17 16:49:33 +1000 | [diff] [blame] | 1194 | #endif |
Christoph Hellwig | 48b62a1 | 2008-05-20 11:30:39 +1000 | [diff] [blame] | 1195 | } |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 1196 | } |
| 1197 | |
| 1198 | /* rw/ro -> rw */ |
| 1199 | if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) { |
| 1200 | mp->m_flags &= ~XFS_MOUNT_RDONLY; |
| 1201 | if (mp->m_flags & XFS_MOUNT_BARRIER) |
| 1202 | xfs_mountfs_check_barriers(mp); |
| 1203 | } |
| 1204 | |
| 1205 | /* rw -> ro */ |
| 1206 | if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) { |
David Chinner | e9f1c6e | 2008-10-30 17:15:50 +1100 | [diff] [blame] | 1207 | xfs_quiesce_data(mp); |
David Chinner | 76bf105 | 2008-10-30 17:16:21 +1100 | [diff] [blame] | 1208 | xfs_quiesce_attr(mp); |
Christoph Hellwig | 48b62a1 | 2008-05-20 11:30:39 +1000 | [diff] [blame] | 1209 | mp->m_flags |= XFS_MOUNT_RDONLY; |
| 1210 | } |
| 1211 | |
Christoph Hellwig | 62a877e | 2008-07-18 17:12:36 +1000 | [diff] [blame] | 1212 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1213 | } |
| 1214 | |
Christoph Hellwig | 9909c4a | 2007-10-11 18:11:14 +1000 | [diff] [blame] | 1215 | /* |
| 1216 | * Second stage of a freeze. The data is already frozen so we only |
David Chinner | 76bf105 | 2008-10-30 17:16:21 +1100 | [diff] [blame] | 1217 | * need to take care of the metadata. Once that's done write a dummy |
Christoph Hellwig | 9909c4a | 2007-10-11 18:11:14 +1000 | [diff] [blame] | 1218 | * record to dirty the log in case of a crash while frozen. |
| 1219 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | STATIC void |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1221 | xfs_fs_lockfs( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | struct super_block *sb) |
| 1223 | { |
Christoph Hellwig | 9909c4a | 2007-10-11 18:11:14 +1000 | [diff] [blame] | 1224 | struct xfs_mount *mp = XFS_M(sb); |
| 1225 | |
David Chinner | 76bf105 | 2008-10-30 17:16:21 +1100 | [diff] [blame] | 1226 | xfs_quiesce_attr(mp); |
Christoph Hellwig | 9909c4a | 2007-10-11 18:11:14 +1000 | [diff] [blame] | 1227 | xfs_fs_log_dummy(mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1231 | xfs_fs_show_options( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | struct seq_file *m, |
| 1233 | struct vfsmount *mnt) |
| 1234 | { |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame] | 1235 | return -xfs_showargs(XFS_M(mnt->mnt_sb), m); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1236 | } |
| 1237 | |
| 1238 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1239 | xfs_fs_quotasync( |
Nathan Scott | ee34807 | 2005-11-02 10:32:38 +1100 | [diff] [blame] | 1240 | struct super_block *sb, |
| 1241 | int type) |
| 1242 | { |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 1243 | return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XQUOTASYNC, 0, NULL); |
Nathan Scott | ee34807 | 2005-11-02 10:32:38 +1100 | [diff] [blame] | 1244 | } |
| 1245 | |
| 1246 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1247 | xfs_fs_getxstate( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | struct super_block *sb, |
| 1249 | struct fs_quota_stat *fqs) |
| 1250 | { |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 1251 | return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XGETQSTAT, 0, (caddr_t)fqs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | } |
| 1253 | |
| 1254 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1255 | xfs_fs_setxstate( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | struct super_block *sb, |
| 1257 | unsigned int flags, |
| 1258 | int op) |
| 1259 | { |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 1260 | return -XFS_QM_QUOTACTL(XFS_M(sb), op, 0, (caddr_t)&flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1261 | } |
| 1262 | |
| 1263 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1264 | xfs_fs_getxquota( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | struct super_block *sb, |
| 1266 | int type, |
| 1267 | qid_t id, |
| 1268 | struct fs_disk_quota *fdq) |
| 1269 | { |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 1270 | return -XFS_QM_QUOTACTL(XFS_M(sb), |
Nathan Scott | b83bd13 | 2006-06-09 16:48:30 +1000 | [diff] [blame] | 1271 | (type == USRQUOTA) ? Q_XGETQUOTA : |
| 1272 | ((type == GRPQUOTA) ? Q_XGETGQUOTA : |
| 1273 | Q_XGETPQUOTA), id, (caddr_t)fdq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | } |
| 1275 | |
| 1276 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1277 | xfs_fs_setxquota( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1278 | struct super_block *sb, |
| 1279 | int type, |
| 1280 | qid_t id, |
| 1281 | struct fs_disk_quota *fdq) |
| 1282 | { |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 1283 | return -XFS_QM_QUOTACTL(XFS_M(sb), |
Nathan Scott | b83bd13 | 2006-06-09 16:48:30 +1000 | [diff] [blame] | 1284 | (type == USRQUOTA) ? Q_XSETQLIM : |
| 1285 | ((type == GRPQUOTA) ? Q_XSETGQLIM : |
| 1286 | Q_XSETPQLIM), id, (caddr_t)fdq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | } |
| 1288 | |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1289 | /* |
| 1290 | * This function fills in xfs_mount_t fields based on mount args. |
| 1291 | * Note: the superblock has _not_ yet been read in. |
| 1292 | */ |
| 1293 | STATIC int |
| 1294 | xfs_start_flags( |
| 1295 | struct xfs_mount_args *ap, |
| 1296 | struct xfs_mount *mp) |
| 1297 | { |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1298 | int error; |
| 1299 | |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1300 | /* Values are in BBs */ |
| 1301 | if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) { |
| 1302 | /* |
| 1303 | * At this point the superblock has not been read |
| 1304 | * in, therefore we do not know the block size. |
| 1305 | * Before the mount call ends we will convert |
| 1306 | * these to FSBs. |
| 1307 | */ |
| 1308 | mp->m_dalign = ap->sunit; |
| 1309 | mp->m_swidth = ap->swidth; |
| 1310 | } |
| 1311 | |
| 1312 | if (ap->logbufs != -1 && |
| 1313 | ap->logbufs != 0 && |
| 1314 | (ap->logbufs < XLOG_MIN_ICLOGS || |
| 1315 | ap->logbufs > XLOG_MAX_ICLOGS)) { |
| 1316 | cmn_err(CE_WARN, |
| 1317 | "XFS: invalid logbufs value: %d [not %d-%d]", |
| 1318 | ap->logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); |
| 1319 | return XFS_ERROR(EINVAL); |
| 1320 | } |
| 1321 | mp->m_logbufs = ap->logbufs; |
| 1322 | if (ap->logbufsize != -1 && |
| 1323 | ap->logbufsize != 0 && |
| 1324 | (ap->logbufsize < XLOG_MIN_RECORD_BSIZE || |
| 1325 | ap->logbufsize > XLOG_MAX_RECORD_BSIZE || |
| 1326 | !is_power_of_2(ap->logbufsize))) { |
| 1327 | cmn_err(CE_WARN, |
| 1328 | "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", |
| 1329 | ap->logbufsize); |
| 1330 | return XFS_ERROR(EINVAL); |
| 1331 | } |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1332 | |
| 1333 | error = ENOMEM; |
| 1334 | |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1335 | mp->m_logbsize = ap->logbufsize; |
| 1336 | mp->m_fsname_len = strlen(ap->fsname) + 1; |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1337 | |
| 1338 | mp->m_fsname = kstrdup(ap->fsname, GFP_KERNEL); |
| 1339 | if (!mp->m_fsname) |
| 1340 | goto out; |
| 1341 | |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1342 | if (ap->rtname[0]) { |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1343 | mp->m_rtname = kstrdup(ap->rtname, GFP_KERNEL); |
| 1344 | if (!mp->m_rtname) |
| 1345 | goto out_free_fsname; |
| 1346 | |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1347 | } |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1348 | |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1349 | if (ap->logname[0]) { |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1350 | mp->m_logname = kstrdup(ap->logname, GFP_KERNEL); |
| 1351 | if (!mp->m_logname) |
| 1352 | goto out_free_rtname; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1353 | } |
| 1354 | |
| 1355 | if (ap->flags & XFSMNT_WSYNC) |
| 1356 | mp->m_flags |= XFS_MOUNT_WSYNC; |
| 1357 | #if XFS_BIG_INUMS |
| 1358 | if (ap->flags & XFSMNT_INO64) { |
| 1359 | mp->m_flags |= XFS_MOUNT_INO64; |
| 1360 | mp->m_inoadd = XFS_INO64_OFFSET; |
| 1361 | } |
| 1362 | #endif |
| 1363 | if (ap->flags & XFSMNT_RETERR) |
| 1364 | mp->m_flags |= XFS_MOUNT_RETERR; |
| 1365 | if (ap->flags & XFSMNT_NOALIGN) |
| 1366 | mp->m_flags |= XFS_MOUNT_NOALIGN; |
| 1367 | if (ap->flags & XFSMNT_SWALLOC) |
| 1368 | mp->m_flags |= XFS_MOUNT_SWALLOC; |
| 1369 | if (ap->flags & XFSMNT_OSYNCISOSYNC) |
| 1370 | mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC; |
| 1371 | if (ap->flags & XFSMNT_32BITINODES) |
| 1372 | mp->m_flags |= XFS_MOUNT_32BITINODES; |
| 1373 | |
| 1374 | if (ap->flags & XFSMNT_IOSIZE) { |
| 1375 | if (ap->iosizelog > XFS_MAX_IO_LOG || |
| 1376 | ap->iosizelog < XFS_MIN_IO_LOG) { |
| 1377 | cmn_err(CE_WARN, |
| 1378 | "XFS: invalid log iosize: %d [not %d-%d]", |
| 1379 | ap->iosizelog, XFS_MIN_IO_LOG, |
| 1380 | XFS_MAX_IO_LOG); |
| 1381 | return XFS_ERROR(EINVAL); |
| 1382 | } |
| 1383 | |
| 1384 | mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE; |
| 1385 | mp->m_readio_log = mp->m_writeio_log = ap->iosizelog; |
| 1386 | } |
| 1387 | |
| 1388 | if (ap->flags & XFSMNT_IKEEP) |
| 1389 | mp->m_flags |= XFS_MOUNT_IKEEP; |
| 1390 | if (ap->flags & XFSMNT_DIRSYNC) |
| 1391 | mp->m_flags |= XFS_MOUNT_DIRSYNC; |
| 1392 | if (ap->flags & XFSMNT_ATTR2) |
| 1393 | mp->m_flags |= XFS_MOUNT_ATTR2; |
| 1394 | if (ap->flags & XFSMNT_NOATTR2) |
| 1395 | mp->m_flags |= XFS_MOUNT_NOATTR2; |
| 1396 | |
| 1397 | if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE) |
| 1398 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; |
| 1399 | |
| 1400 | /* |
| 1401 | * no recovery flag requires a read-only mount |
| 1402 | */ |
| 1403 | if (ap->flags & XFSMNT_NORECOVERY) { |
| 1404 | if (!(mp->m_flags & XFS_MOUNT_RDONLY)) { |
| 1405 | cmn_err(CE_WARN, |
| 1406 | "XFS: tried to mount a FS read-write without recovery!"); |
| 1407 | return XFS_ERROR(EINVAL); |
| 1408 | } |
| 1409 | mp->m_flags |= XFS_MOUNT_NORECOVERY; |
| 1410 | } |
| 1411 | |
| 1412 | if (ap->flags & XFSMNT_NOUUID) |
| 1413 | mp->m_flags |= XFS_MOUNT_NOUUID; |
| 1414 | if (ap->flags & XFSMNT_BARRIER) |
| 1415 | mp->m_flags |= XFS_MOUNT_BARRIER; |
| 1416 | else |
| 1417 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
| 1418 | |
| 1419 | if (ap->flags2 & XFSMNT2_FILESTREAMS) |
| 1420 | mp->m_flags |= XFS_MOUNT_FILESTREAMS; |
| 1421 | |
| 1422 | if (ap->flags & XFSMNT_DMAPI) |
| 1423 | mp->m_flags |= XFS_MOUNT_DMAPI; |
| 1424 | return 0; |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1425 | |
| 1426 | |
| 1427 | out_free_rtname: |
| 1428 | kfree(mp->m_rtname); |
| 1429 | out_free_fsname: |
| 1430 | kfree(mp->m_fsname); |
| 1431 | out: |
| 1432 | return error; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | /* |
| 1436 | * This function fills in xfs_mount_t fields based on mount args. |
| 1437 | * Note: the superblock _has_ now been read in. |
| 1438 | */ |
| 1439 | STATIC int |
| 1440 | xfs_finish_flags( |
| 1441 | struct xfs_mount_args *ap, |
| 1442 | struct xfs_mount *mp) |
| 1443 | { |
| 1444 | int ronly = (mp->m_flags & XFS_MOUNT_RDONLY); |
| 1445 | |
| 1446 | /* Fail a mount where the logbuf is smaller then the log stripe */ |
| 1447 | if (xfs_sb_version_haslogv2(&mp->m_sb)) { |
| 1448 | if ((ap->logbufsize <= 0) && |
| 1449 | (mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE)) { |
| 1450 | mp->m_logbsize = mp->m_sb.sb_logsunit; |
| 1451 | } else if (ap->logbufsize > 0 && |
| 1452 | ap->logbufsize < mp->m_sb.sb_logsunit) { |
| 1453 | cmn_err(CE_WARN, |
| 1454 | "XFS: logbuf size must be greater than or equal to log stripe size"); |
| 1455 | return XFS_ERROR(EINVAL); |
| 1456 | } |
| 1457 | } else { |
| 1458 | /* Fail a mount if the logbuf is larger than 32K */ |
| 1459 | if (ap->logbufsize > XLOG_BIG_RECORD_BSIZE) { |
| 1460 | cmn_err(CE_WARN, |
| 1461 | "XFS: logbuf size for version 1 logs must be 16K or 32K"); |
| 1462 | return XFS_ERROR(EINVAL); |
| 1463 | } |
| 1464 | } |
| 1465 | |
| 1466 | /* |
| 1467 | * mkfs'ed attr2 will turn on attr2 mount unless explicitly |
| 1468 | * told by noattr2 to turn it off |
| 1469 | */ |
| 1470 | if (xfs_sb_version_hasattr2(&mp->m_sb) && |
| 1471 | !(ap->flags & XFSMNT_NOATTR2)) |
| 1472 | mp->m_flags |= XFS_MOUNT_ATTR2; |
| 1473 | |
| 1474 | /* |
| 1475 | * prohibit r/w mounts of read-only filesystems |
| 1476 | */ |
| 1477 | if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { |
| 1478 | cmn_err(CE_WARN, |
| 1479 | "XFS: cannot mount a read-only filesystem as read-write"); |
| 1480 | return XFS_ERROR(EROFS); |
| 1481 | } |
| 1482 | |
| 1483 | /* |
| 1484 | * check for shared mount. |
| 1485 | */ |
| 1486 | if (ap->flags & XFSMNT_SHARED) { |
| 1487 | if (!xfs_sb_version_hasshared(&mp->m_sb)) |
| 1488 | return XFS_ERROR(EINVAL); |
| 1489 | |
| 1490 | /* |
| 1491 | * For IRIX 6.5, shared mounts must have the shared |
| 1492 | * version bit set, have the persistent readonly |
| 1493 | * field set, must be version 0 and can only be mounted |
| 1494 | * read-only. |
| 1495 | */ |
| 1496 | if (!ronly || !(mp->m_sb.sb_flags & XFS_SBF_READONLY) || |
| 1497 | (mp->m_sb.sb_shared_vn != 0)) |
| 1498 | return XFS_ERROR(EINVAL); |
| 1499 | |
| 1500 | mp->m_flags |= XFS_MOUNT_SHARED; |
| 1501 | |
| 1502 | /* |
| 1503 | * Shared XFS V0 can't deal with DMI. Return EINVAL. |
| 1504 | */ |
| 1505 | if (mp->m_sb.sb_shared_vn == 0 && (ap->flags & XFSMNT_DMAPI)) |
| 1506 | return XFS_ERROR(EINVAL); |
| 1507 | } |
| 1508 | |
| 1509 | if (ap->flags & XFSMNT_UQUOTA) { |
| 1510 | mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE); |
| 1511 | if (ap->flags & XFSMNT_UQUOTAENF) |
| 1512 | mp->m_qflags |= XFS_UQUOTA_ENFD; |
| 1513 | } |
| 1514 | |
| 1515 | if (ap->flags & XFSMNT_GQUOTA) { |
| 1516 | mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); |
| 1517 | if (ap->flags & XFSMNT_GQUOTAENF) |
| 1518 | mp->m_qflags |= XFS_OQUOTA_ENFD; |
| 1519 | } else if (ap->flags & XFSMNT_PQUOTA) { |
| 1520 | mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE); |
| 1521 | if (ap->flags & XFSMNT_PQUOTAENF) |
| 1522 | mp->m_qflags |= XFS_OQUOTA_ENFD; |
| 1523 | } |
| 1524 | |
| 1525 | return 0; |
| 1526 | } |
| 1527 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1529 | xfs_fs_fill_super( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | struct super_block *sb, |
| 1531 | void *data, |
| 1532 | int silent) |
| 1533 | { |
Christoph Hellwig | f3dcc13 | 2008-03-27 18:00:54 +1100 | [diff] [blame] | 1534 | struct inode *root; |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame] | 1535 | struct xfs_mount *mp = NULL; |
Christoph Hellwig | bdd907b | 2008-05-20 15:10:44 +1000 | [diff] [blame] | 1536 | struct xfs_mount_args *args; |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1537 | int flags = 0, error = ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1538 | |
Christoph Hellwig | bdd907b | 2008-05-20 15:10:44 +1000 | [diff] [blame] | 1539 | args = xfs_args_allocate(sb, silent); |
| 1540 | if (!args) |
| 1541 | return -ENOMEM; |
| 1542 | |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1543 | mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL); |
| 1544 | if (!mp) |
| 1545 | goto out_free_args; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1546 | |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1547 | spin_lock_init(&mp->m_sb_lock); |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1548 | mutex_init(&mp->m_growlock); |
| 1549 | atomic_set(&mp->m_active_trans, 0); |
Christoph Hellwig | 7439449 | 2007-08-30 17:21:22 +1000 | [diff] [blame] | 1550 | INIT_LIST_HEAD(&mp->m_sync_list); |
| 1551 | spin_lock_init(&mp->m_sync_lock); |
| 1552 | init_waitqueue_head(&mp->m_wait_single_sync_task); |
| 1553 | |
Christoph Hellwig | b267ce9 | 2007-08-30 17:21:30 +1000 | [diff] [blame] | 1554 | mp->m_super = sb; |
| 1555 | sb->s_fs_info = mp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | |
Christoph Hellwig | bd186aa | 2007-08-30 17:21:12 +1000 | [diff] [blame] | 1557 | if (sb->s_flags & MS_RDONLY) |
| 1558 | mp->m_flags |= XFS_MOUNT_RDONLY; |
| 1559 | |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame] | 1560 | error = xfs_parseargs(mp, (char *)data, args, 0); |
| 1561 | if (error) |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1562 | goto out_free_mp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | |
| 1564 | sb_min_blocksize(sb, BBSIZE); |
Lachlan McIlroy | 0ec5851 | 2008-06-23 13:23:01 +1000 | [diff] [blame] | 1565 | sb->s_xattr = xfs_xattr_handlers; |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1566 | sb->s_export_op = &xfs_export_operations; |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1567 | sb->s_qcop = &xfs_quotactl_operations; |
| 1568 | sb->s_op = &xfs_super_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1570 | error = xfs_dmops_get(mp, args); |
Christoph Hellwig | 745f691 | 2007-08-30 17:20:39 +1000 | [diff] [blame] | 1571 | if (error) |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1572 | goto out_free_mp; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1573 | error = xfs_qmops_get(mp, args); |
| 1574 | if (error) |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 1575 | goto out_put_dmops; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1576 | |
| 1577 | if (args->flags & XFSMNT_QUIET) |
| 1578 | flags |= XFS_MFSI_QUIET; |
| 1579 | |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 1580 | error = xfs_open_devices(mp, args); |
| 1581 | if (error) |
| 1582 | goto out_put_qmops; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1583 | |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1584 | if (xfs_icsb_init_counters(mp)) |
| 1585 | mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB; |
| 1586 | |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1587 | /* |
| 1588 | * Setup flags based on mount(2) options and then the superblock |
| 1589 | */ |
| 1590 | error = xfs_start_flags(args, mp); |
| 1591 | if (error) |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1592 | goto out_free_fsname; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1593 | error = xfs_readsb(mp, flags); |
| 1594 | if (error) |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1595 | goto out_free_fsname; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1596 | error = xfs_finish_flags(args, mp); |
| 1597 | if (error) |
Christoph Hellwig | effa2ed | 2008-05-20 15:11:05 +1000 | [diff] [blame] | 1598 | goto out_free_sb; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1599 | |
Christoph Hellwig | e34b562 | 2008-05-20 15:10:36 +1000 | [diff] [blame] | 1600 | error = xfs_setup_devices(mp); |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 1601 | if (error) |
Christoph Hellwig | effa2ed | 2008-05-20 15:11:05 +1000 | [diff] [blame] | 1602 | goto out_free_sb; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1603 | |
| 1604 | if (mp->m_flags & XFS_MOUNT_BARRIER) |
| 1605 | xfs_mountfs_check_barriers(mp); |
| 1606 | |
| 1607 | error = xfs_filestream_mount(mp); |
| 1608 | if (error) |
Christoph Hellwig | effa2ed | 2008-05-20 15:11:05 +1000 | [diff] [blame] | 1609 | goto out_free_sb; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1610 | |
Christoph Hellwig | 4249023 | 2008-08-13 16:49:32 +1000 | [diff] [blame] | 1611 | error = xfs_mountfs(mp); |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1612 | if (error) |
Christoph Hellwig | 120226c | 2008-05-20 15:11:11 +1000 | [diff] [blame] | 1613 | goto out_filestream_unmount; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1614 | |
| 1615 | XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, args->mtpt, args->fsname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1616 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | sb->s_dirt = 1; |
Christoph Hellwig | 4ca488e | 2007-10-11 18:09:40 +1000 | [diff] [blame] | 1618 | sb->s_magic = XFS_SB_MAGIC; |
| 1619 | sb->s_blocksize = mp->m_sb.sb_blocksize; |
| 1620 | sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits); |
| 1622 | sb->s_time_gran = 1; |
| 1623 | set_posix_acl_flag(sb); |
| 1624 | |
David Chinner | 0165164 | 2008-08-13 15:45:15 +1000 | [diff] [blame] | 1625 | root = igrab(VFS_I(mp->m_rootip)); |
Christoph Hellwig | f3dcc13 | 2008-03-27 18:00:54 +1100 | [diff] [blame] | 1626 | if (!root) { |
Christoph Hellwig | cbc89dc | 2008-02-05 12:14:01 +1100 | [diff] [blame] | 1627 | error = ENOENT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1628 | goto fail_unmount; |
Christoph Hellwig | cbc89dc | 2008-02-05 12:14:01 +1100 | [diff] [blame] | 1629 | } |
Christoph Hellwig | f3dcc13 | 2008-03-27 18:00:54 +1100 | [diff] [blame] | 1630 | if (is_bad_inode(root)) { |
| 1631 | error = EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | goto fail_vnrele; |
| 1633 | } |
Christoph Hellwig | f3dcc13 | 2008-03-27 18:00:54 +1100 | [diff] [blame] | 1634 | sb->s_root = d_alloc_root(root); |
| 1635 | if (!sb->s_root) { |
| 1636 | error = ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1637 | goto fail_vnrele; |
| 1638 | } |
Christoph Hellwig | 7439449 | 2007-08-30 17:21:22 +1000 | [diff] [blame] | 1639 | |
David Chinner | a167b17 | 2008-10-30 17:06:18 +1100 | [diff] [blame] | 1640 | error = xfs_syncd_init(mp); |
| 1641 | if (error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1642 | goto fail_vnrele; |
Christoph Hellwig | 7439449 | 2007-08-30 17:21:22 +1000 | [diff] [blame] | 1643 | |
Lachlan McIlroy | cf441ee | 2008-02-07 16:42:19 +1100 | [diff] [blame] | 1644 | xfs_itrace_exit(XFS_I(sb->s_root->d_inode)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1645 | |
Christoph Hellwig | bdd907b | 2008-05-20 15:10:44 +1000 | [diff] [blame] | 1646 | kfree(args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1647 | return 0; |
| 1648 | |
Christoph Hellwig | 120226c | 2008-05-20 15:11:11 +1000 | [diff] [blame] | 1649 | out_filestream_unmount: |
| 1650 | xfs_filestream_unmount(mp); |
Christoph Hellwig | effa2ed | 2008-05-20 15:11:05 +1000 | [diff] [blame] | 1651 | out_free_sb: |
| 1652 | xfs_freesb(mp); |
Christoph Hellwig | a738159 | 2008-08-13 16:04:05 +1000 | [diff] [blame] | 1653 | out_free_fsname: |
| 1654 | xfs_free_fsname(mp); |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1655 | xfs_icsb_destroy_counters(mp); |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 1656 | xfs_close_devices(mp); |
| 1657 | out_put_qmops: |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1658 | xfs_qmops_put(mp); |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 1659 | out_put_dmops: |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1660 | xfs_dmops_put(mp); |
Christoph Hellwig | c962fb7 | 2008-05-20 15:10:52 +1000 | [diff] [blame] | 1661 | out_free_mp: |
| 1662 | kfree(mp); |
| 1663 | out_free_args: |
| 1664 | kfree(args); |
| 1665 | return -error; |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1666 | |
| 1667 | fail_vnrele: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | if (sb->s_root) { |
| 1669 | dput(sb->s_root); |
| 1670 | sb->s_root = NULL; |
| 1671 | } else { |
Christoph Hellwig | f3dcc13 | 2008-03-27 18:00:54 +1100 | [diff] [blame] | 1672 | iput(root); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1673 | } |
| 1674 | |
Christoph Hellwig | f8f15e4 | 2008-05-20 11:30:59 +1000 | [diff] [blame] | 1675 | fail_unmount: |
Christoph Hellwig | e48ad31 | 2008-05-20 11:30:52 +1000 | [diff] [blame] | 1676 | /* |
| 1677 | * Blow away any referenced inode in the filestreams cache. |
| 1678 | * This can and will cause log traffic as inodes go inactive |
| 1679 | * here. |
| 1680 | */ |
| 1681 | xfs_filestream_unmount(mp); |
| 1682 | |
| 1683 | XFS_bflush(mp->m_ddev_targp); |
| 1684 | error = xfs_unmount_flush(mp, 0); |
| 1685 | WARN_ON(error); |
| 1686 | |
Christoph Hellwig | 19f354d | 2008-05-20 11:31:13 +1000 | [diff] [blame] | 1687 | xfs_unmountfs(mp); |
Christoph Hellwig | 6203300 | 2008-08-13 16:50:21 +1000 | [diff] [blame] | 1688 | goto out_free_sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1689 | } |
| 1690 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1691 | STATIC int |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1692 | xfs_fs_get_sb( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | struct file_system_type *fs_type, |
| 1694 | int flags, |
| 1695 | const char *dev_name, |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1696 | void *data, |
| 1697 | struct vfsmount *mnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1698 | { |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1699 | return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super, |
| 1700 | mnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | } |
| 1702 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 1703 | static struct super_operations xfs_super_operations = { |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1704 | .alloc_inode = xfs_fs_alloc_inode, |
| 1705 | .destroy_inode = xfs_fs_destroy_inode, |
| 1706 | .write_inode = xfs_fs_write_inode, |
| 1707 | .clear_inode = xfs_fs_clear_inode, |
| 1708 | .put_super = xfs_fs_put_super, |
| 1709 | .write_super = xfs_fs_write_super, |
| 1710 | .sync_fs = xfs_fs_sync_super, |
| 1711 | .write_super_lockfs = xfs_fs_lockfs, |
| 1712 | .statfs = xfs_fs_statfs, |
| 1713 | .remount_fs = xfs_fs_remount, |
| 1714 | .show_options = xfs_fs_show_options, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1715 | }; |
| 1716 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 1717 | static struct quotactl_ops xfs_quotactl_operations = { |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1718 | .quota_sync = xfs_fs_quotasync, |
| 1719 | .get_xstate = xfs_fs_getxstate, |
| 1720 | .set_xstate = xfs_fs_setxstate, |
| 1721 | .get_xquota = xfs_fs_getxquota, |
| 1722 | .set_xquota = xfs_fs_setxquota, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1723 | }; |
| 1724 | |
Andrew Morton | 5085b60 | 2007-02-20 13:57:47 -0800 | [diff] [blame] | 1725 | static struct file_system_type xfs_fs_type = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1726 | .owner = THIS_MODULE, |
| 1727 | .name = "xfs", |
Nathan Scott | a50cd26 | 2006-03-14 14:06:18 +1100 | [diff] [blame] | 1728 | .get_sb = xfs_fs_get_sb, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1729 | .kill_sb = kill_block_super, |
| 1730 | .fs_flags = FS_REQUIRES_DEV, |
| 1731 | }; |
| 1732 | |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1733 | STATIC int __init |
| 1734 | xfs_alloc_trace_bufs(void) |
| 1735 | { |
| 1736 | #ifdef XFS_ALLOC_TRACE |
| 1737 | xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_MAYFAIL); |
| 1738 | if (!xfs_alloc_trace_buf) |
| 1739 | goto out; |
| 1740 | #endif |
| 1741 | #ifdef XFS_BMAP_TRACE |
| 1742 | xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_MAYFAIL); |
| 1743 | if (!xfs_bmap_trace_buf) |
| 1744 | goto out_free_alloc_trace; |
| 1745 | #endif |
Christoph Hellwig | 8c4ed63 | 2008-10-30 16:55:13 +1100 | [diff] [blame] | 1746 | #ifdef XFS_BTREE_TRACE |
| 1747 | xfs_allocbt_trace_buf = ktrace_alloc(XFS_ALLOCBT_TRACE_SIZE, |
| 1748 | KM_MAYFAIL); |
| 1749 | if (!xfs_allocbt_trace_buf) |
| 1750 | goto out_free_bmap_trace; |
| 1751 | |
| 1752 | xfs_inobt_trace_buf = ktrace_alloc(XFS_INOBT_TRACE_SIZE, KM_MAYFAIL); |
| 1753 | if (!xfs_inobt_trace_buf) |
| 1754 | goto out_free_allocbt_trace; |
| 1755 | |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1756 | xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL); |
| 1757 | if (!xfs_bmbt_trace_buf) |
Christoph Hellwig | 8c4ed63 | 2008-10-30 16:55:13 +1100 | [diff] [blame] | 1758 | goto out_free_inobt_trace; |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1759 | #endif |
| 1760 | #ifdef XFS_ATTR_TRACE |
| 1761 | xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL); |
| 1762 | if (!xfs_attr_trace_buf) |
| 1763 | goto out_free_bmbt_trace; |
| 1764 | #endif |
| 1765 | #ifdef XFS_DIR2_TRACE |
| 1766 | xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_MAYFAIL); |
| 1767 | if (!xfs_dir2_trace_buf) |
| 1768 | goto out_free_attr_trace; |
| 1769 | #endif |
| 1770 | |
| 1771 | return 0; |
| 1772 | |
| 1773 | #ifdef XFS_DIR2_TRACE |
| 1774 | out_free_attr_trace: |
| 1775 | #endif |
| 1776 | #ifdef XFS_ATTR_TRACE |
| 1777 | ktrace_free(xfs_attr_trace_buf); |
| 1778 | out_free_bmbt_trace: |
| 1779 | #endif |
Christoph Hellwig | 8c4ed63 | 2008-10-30 16:55:13 +1100 | [diff] [blame] | 1780 | #ifdef XFS_BTREE_TRACE |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1781 | ktrace_free(xfs_bmbt_trace_buf); |
Christoph Hellwig | 8c4ed63 | 2008-10-30 16:55:13 +1100 | [diff] [blame] | 1782 | out_free_inobt_trace: |
| 1783 | ktrace_free(xfs_inobt_trace_buf); |
| 1784 | out_free_allocbt_trace: |
| 1785 | ktrace_free(xfs_allocbt_trace_buf); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1786 | out_free_bmap_trace: |
| 1787 | #endif |
| 1788 | #ifdef XFS_BMAP_TRACE |
| 1789 | ktrace_free(xfs_bmap_trace_buf); |
| 1790 | out_free_alloc_trace: |
| 1791 | #endif |
| 1792 | #ifdef XFS_ALLOC_TRACE |
| 1793 | ktrace_free(xfs_alloc_trace_buf); |
| 1794 | out: |
| 1795 | #endif |
| 1796 | return -ENOMEM; |
| 1797 | } |
| 1798 | |
| 1799 | STATIC void |
| 1800 | xfs_free_trace_bufs(void) |
| 1801 | { |
| 1802 | #ifdef XFS_DIR2_TRACE |
| 1803 | ktrace_free(xfs_dir2_trace_buf); |
| 1804 | #endif |
| 1805 | #ifdef XFS_ATTR_TRACE |
| 1806 | ktrace_free(xfs_attr_trace_buf); |
| 1807 | #endif |
Christoph Hellwig | 8c4ed63 | 2008-10-30 16:55:13 +1100 | [diff] [blame] | 1808 | #ifdef XFS_BTREE_TRACE |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1809 | ktrace_free(xfs_bmbt_trace_buf); |
Christoph Hellwig | 8c4ed63 | 2008-10-30 16:55:13 +1100 | [diff] [blame] | 1810 | ktrace_free(xfs_inobt_trace_buf); |
| 1811 | ktrace_free(xfs_allocbt_trace_buf); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1812 | #endif |
| 1813 | #ifdef XFS_BMAP_TRACE |
| 1814 | ktrace_free(xfs_bmap_trace_buf); |
| 1815 | #endif |
| 1816 | #ifdef XFS_ALLOC_TRACE |
| 1817 | ktrace_free(xfs_alloc_trace_buf); |
| 1818 | #endif |
| 1819 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1820 | |
| 1821 | STATIC int __init |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1822 | xfs_init_zones(void) |
| 1823 | { |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1824 | |
| 1825 | xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend"); |
| 1826 | if (!xfs_ioend_zone) |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 1827 | goto out; |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1828 | |
| 1829 | xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE, |
| 1830 | xfs_ioend_zone); |
| 1831 | if (!xfs_ioend_pool) |
| 1832 | goto out_destroy_ioend_zone; |
| 1833 | |
| 1834 | xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t), |
| 1835 | "xfs_log_ticket"); |
| 1836 | if (!xfs_log_ticket_zone) |
| 1837 | goto out_destroy_ioend_pool; |
| 1838 | |
| 1839 | xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t), |
| 1840 | "xfs_bmap_free_item"); |
| 1841 | if (!xfs_bmap_free_item_zone) |
| 1842 | goto out_destroy_log_ticket_zone; |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 1843 | |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1844 | xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t), |
| 1845 | "xfs_btree_cur"); |
| 1846 | if (!xfs_btree_cur_zone) |
| 1847 | goto out_destroy_bmap_free_item_zone; |
| 1848 | |
| 1849 | xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t), |
| 1850 | "xfs_da_state"); |
| 1851 | if (!xfs_da_state_zone) |
| 1852 | goto out_destroy_btree_cur_zone; |
| 1853 | |
| 1854 | xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf"); |
| 1855 | if (!xfs_dabuf_zone) |
| 1856 | goto out_destroy_da_state_zone; |
| 1857 | |
| 1858 | xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork"); |
| 1859 | if (!xfs_ifork_zone) |
| 1860 | goto out_destroy_dabuf_zone; |
| 1861 | |
| 1862 | xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans"); |
| 1863 | if (!xfs_trans_zone) |
| 1864 | goto out_destroy_ifork_zone; |
| 1865 | |
| 1866 | /* |
| 1867 | * The size of the zone allocated buf log item is the maximum |
| 1868 | * size possible under XFS. This wastes a little bit of memory, |
| 1869 | * but it is much faster. |
| 1870 | */ |
| 1871 | xfs_buf_item_zone = kmem_zone_init((sizeof(xfs_buf_log_item_t) + |
| 1872 | (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) / |
| 1873 | NBWORD) * sizeof(int))), "xfs_buf_item"); |
| 1874 | if (!xfs_buf_item_zone) |
| 1875 | goto out_destroy_trans_zone; |
| 1876 | |
| 1877 | xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) + |
| 1878 | ((XFS_EFD_MAX_FAST_EXTENTS - 1) * |
| 1879 | sizeof(xfs_extent_t))), "xfs_efd_item"); |
| 1880 | if (!xfs_efd_zone) |
| 1881 | goto out_destroy_buf_item_zone; |
| 1882 | |
| 1883 | xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) + |
| 1884 | ((XFS_EFI_MAX_FAST_EXTENTS - 1) * |
| 1885 | sizeof(xfs_extent_t))), "xfs_efi_item"); |
| 1886 | if (!xfs_efi_zone) |
| 1887 | goto out_destroy_efd_zone; |
| 1888 | |
| 1889 | xfs_inode_zone = |
| 1890 | kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode", |
David Chinner | bf90424 | 2008-10-30 17:36:14 +1100 | [diff] [blame] | 1891 | KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD, |
| 1892 | xfs_fs_inode_init_once); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1893 | if (!xfs_inode_zone) |
| 1894 | goto out_destroy_efi_zone; |
| 1895 | |
| 1896 | xfs_ili_zone = |
| 1897 | kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili", |
| 1898 | KM_ZONE_SPREAD, NULL); |
| 1899 | if (!xfs_ili_zone) |
| 1900 | goto out_destroy_inode_zone; |
| 1901 | |
| 1902 | #ifdef CONFIG_XFS_POSIX_ACL |
| 1903 | xfs_acl_zone = kmem_zone_init(sizeof(xfs_acl_t), "xfs_acl"); |
| 1904 | if (!xfs_acl_zone) |
| 1905 | goto out_destroy_ili_zone; |
| 1906 | #endif |
| 1907 | |
| 1908 | return 0; |
| 1909 | |
| 1910 | #ifdef CONFIG_XFS_POSIX_ACL |
| 1911 | out_destroy_ili_zone: |
| 1912 | #endif |
| 1913 | kmem_zone_destroy(xfs_ili_zone); |
| 1914 | out_destroy_inode_zone: |
| 1915 | kmem_zone_destroy(xfs_inode_zone); |
| 1916 | out_destroy_efi_zone: |
| 1917 | kmem_zone_destroy(xfs_efi_zone); |
| 1918 | out_destroy_efd_zone: |
| 1919 | kmem_zone_destroy(xfs_efd_zone); |
| 1920 | out_destroy_buf_item_zone: |
| 1921 | kmem_zone_destroy(xfs_buf_item_zone); |
| 1922 | out_destroy_trans_zone: |
| 1923 | kmem_zone_destroy(xfs_trans_zone); |
| 1924 | out_destroy_ifork_zone: |
| 1925 | kmem_zone_destroy(xfs_ifork_zone); |
| 1926 | out_destroy_dabuf_zone: |
| 1927 | kmem_zone_destroy(xfs_dabuf_zone); |
| 1928 | out_destroy_da_state_zone: |
| 1929 | kmem_zone_destroy(xfs_da_state_zone); |
| 1930 | out_destroy_btree_cur_zone: |
| 1931 | kmem_zone_destroy(xfs_btree_cur_zone); |
| 1932 | out_destroy_bmap_free_item_zone: |
| 1933 | kmem_zone_destroy(xfs_bmap_free_item_zone); |
| 1934 | out_destroy_log_ticket_zone: |
| 1935 | kmem_zone_destroy(xfs_log_ticket_zone); |
| 1936 | out_destroy_ioend_pool: |
| 1937 | mempool_destroy(xfs_ioend_pool); |
| 1938 | out_destroy_ioend_zone: |
| 1939 | kmem_zone_destroy(xfs_ioend_zone); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1940 | out: |
| 1941 | return -ENOMEM; |
| 1942 | } |
| 1943 | |
| 1944 | STATIC void |
| 1945 | xfs_destroy_zones(void) |
| 1946 | { |
| 1947 | #ifdef CONFIG_XFS_POSIX_ACL |
| 1948 | kmem_zone_destroy(xfs_acl_zone); |
| 1949 | #endif |
| 1950 | kmem_zone_destroy(xfs_ili_zone); |
| 1951 | kmem_zone_destroy(xfs_inode_zone); |
| 1952 | kmem_zone_destroy(xfs_efi_zone); |
| 1953 | kmem_zone_destroy(xfs_efd_zone); |
| 1954 | kmem_zone_destroy(xfs_buf_item_zone); |
| 1955 | kmem_zone_destroy(xfs_trans_zone); |
| 1956 | kmem_zone_destroy(xfs_ifork_zone); |
| 1957 | kmem_zone_destroy(xfs_dabuf_zone); |
| 1958 | kmem_zone_destroy(xfs_da_state_zone); |
| 1959 | kmem_zone_destroy(xfs_btree_cur_zone); |
| 1960 | kmem_zone_destroy(xfs_bmap_free_item_zone); |
| 1961 | kmem_zone_destroy(xfs_log_ticket_zone); |
| 1962 | mempool_destroy(xfs_ioend_pool); |
| 1963 | kmem_zone_destroy(xfs_ioend_zone); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1964 | |
| 1965 | } |
| 1966 | |
| 1967 | STATIC int __init |
| 1968 | init_xfs_fs(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1969 | { |
| 1970 | int error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1971 | static char message[] __initdata = KERN_INFO \ |
| 1972 | XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n"; |
| 1973 | |
| 1974 | printk(message); |
| 1975 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1976 | ktrace_init(64); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1977 | vn_init(); |
| 1978 | xfs_dir_startup(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1979 | |
Nathan Scott | 8758280 | 2006-03-14 13:18:19 +1100 | [diff] [blame] | 1980 | error = xfs_init_zones(); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1981 | if (error) |
| 1982 | goto out; |
| 1983 | |
| 1984 | error = xfs_alloc_trace_bufs(); |
| 1985 | if (error) |
| 1986 | goto out_destroy_zones; |
| 1987 | |
| 1988 | error = xfs_mru_cache_init(); |
| 1989 | if (error) |
| 1990 | goto out_free_trace_buffers; |
| 1991 | |
| 1992 | error = xfs_filestream_init(); |
| 1993 | if (error) |
| 1994 | goto out_mru_cache_uninit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | |
Nathan Scott | ce8e922 | 2006-01-11 15:39:08 +1100 | [diff] [blame] | 1996 | error = xfs_buf_init(); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 1997 | if (error) |
| 1998 | goto out_filestream_uninit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1999 | |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 2000 | error = xfs_init_procfs(); |
| 2001 | if (error) |
| 2002 | goto out_buf_terminate; |
| 2003 | |
| 2004 | error = xfs_sysctl_register(); |
| 2005 | if (error) |
| 2006 | goto out_cleanup_procfs; |
| 2007 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2008 | vfs_initquota(); |
| 2009 | |
| 2010 | error = register_filesystem(&xfs_fs_type); |
| 2011 | if (error) |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 2012 | goto out_sysctl_unregister; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2013 | return 0; |
| 2014 | |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 2015 | out_sysctl_unregister: |
| 2016 | xfs_sysctl_unregister(); |
| 2017 | out_cleanup_procfs: |
| 2018 | xfs_cleanup_procfs(); |
| 2019 | out_buf_terminate: |
Nathan Scott | ce8e922 | 2006-01-11 15:39:08 +1100 | [diff] [blame] | 2020 | xfs_buf_terminate(); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 2021 | out_filestream_uninit: |
| 2022 | xfs_filestream_uninit(); |
| 2023 | out_mru_cache_uninit: |
| 2024 | xfs_mru_cache_uninit(); |
| 2025 | out_free_trace_buffers: |
| 2026 | xfs_free_trace_bufs(); |
| 2027 | out_destroy_zones: |
Nathan Scott | 8758280 | 2006-03-14 13:18:19 +1100 | [diff] [blame] | 2028 | xfs_destroy_zones(); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 2029 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | return error; |
| 2031 | } |
| 2032 | |
| 2033 | STATIC void __exit |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 2034 | exit_xfs_fs(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2035 | { |
| 2036 | vfs_exitquota(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2037 | unregister_filesystem(&xfs_fs_type); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 2038 | xfs_sysctl_unregister(); |
| 2039 | xfs_cleanup_procfs(); |
Nathan Scott | ce8e922 | 2006-01-11 15:39:08 +1100 | [diff] [blame] | 2040 | xfs_buf_terminate(); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 2041 | xfs_filestream_uninit(); |
| 2042 | xfs_mru_cache_uninit(); |
| 2043 | xfs_free_trace_bufs(); |
Nathan Scott | 8758280 | 2006-03-14 13:18:19 +1100 | [diff] [blame] | 2044 | xfs_destroy_zones(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2045 | ktrace_uninit(); |
| 2046 | } |
| 2047 | |
| 2048 | module_init(init_xfs_fs); |
| 2049 | module_exit(exit_xfs_fs); |
| 2050 | |
| 2051 | MODULE_AUTHOR("Silicon Graphics, Inc."); |
| 2052 | MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled"); |
| 2053 | MODULE_LICENSE("GPL"); |