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