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