aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_super.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c572
1 files changed, 549 insertions, 23 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 8cb63c60c048..21dfc9da235e 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -41,6 +41,7 @@
41#include "xfs_rtalloc.h" 41#include "xfs_rtalloc.h"
42#include "xfs_error.h" 42#include "xfs_error.h"
43#include "xfs_itable.h" 43#include "xfs_itable.h"
44#include "xfs_fsops.h"
44#include "xfs_rw.h" 45#include "xfs_rw.h"
45#include "xfs_acl.h" 46#include "xfs_acl.h"
46#include "xfs_attr.h" 47#include "xfs_attr.h"
@@ -49,6 +50,8 @@
49#include "xfs_vnodeops.h" 50#include "xfs_vnodeops.h"
50#include "xfs_vfsops.h" 51#include "xfs_vfsops.h"
51#include "xfs_version.h" 52#include "xfs_version.h"
53#include "xfs_log_priv.h"
54#include "xfs_trans_priv.h"
52 55
53#include <linux/namei.h> 56#include <linux/namei.h>
54#include <linux/init.h> 57#include <linux/init.h>
@@ -87,6 +90,435 @@ xfs_args_allocate(
87 return args; 90 return args;
88} 91}
89 92
93#define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */
94#define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */
95#define MNTOPT_LOGDEV "logdev" /* log device */
96#define MNTOPT_RTDEV "rtdev" /* realtime I/O device */
97#define MNTOPT_BIOSIZE "biosize" /* log2 of preferred buffered io size */
98#define MNTOPT_WSYNC "wsync" /* safe-mode nfs compatible mount */
99#define MNTOPT_INO64 "ino64" /* force inodes into 64-bit range */
100#define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */
101#define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */
102#define MNTOPT_SUNIT "sunit" /* data volume stripe unit */
103#define MNTOPT_SWIDTH "swidth" /* data volume stripe width */
104#define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */
105#define MNTOPT_MTPT "mtpt" /* filesystem mount point */
106#define MNTOPT_GRPID "grpid" /* group-ID from parent directory */
107#define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */
108#define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */
109#define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */
110#define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */
111#define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */
112#define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and
113 * unwritten extent conversion */
114#define MNTOPT_NOBARRIER "nobarrier" /* .. disable */
115#define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */
116#define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */
117#define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */
118#define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */
119#define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */
120#define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes
121 * in stat(). */
122#define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
123#define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
124#define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */
125#define MNTOPT_QUOTA "quota" /* disk quotas (user) */
126#define MNTOPT_NOQUOTA "noquota" /* no quotas */
127#define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */
128#define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */
129#define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */
130#define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */
131#define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */
132#define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */
133#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
134#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
135#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
136#define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
137#define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
138#define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
139#define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
140
141STATIC unsigned long
142suffix_strtoul(char *s, char **endp, unsigned int base)
143{
144 int last, shift_left_factor = 0;
145 char *value = s;
146
147 last = strlen(value) - 1;
148 if (value[last] == 'K' || value[last] == 'k') {
149 shift_left_factor = 10;
150 value[last] = '\0';
151 }
152 if (value[last] == 'M' || value[last] == 'm') {
153 shift_left_factor = 20;
154 value[last] = '\0';
155 }
156 if (value[last] == 'G' || value[last] == 'g') {
157 shift_left_factor = 30;
158 value[last] = '\0';
159 }
160
161 return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
162}
163
164STATIC int
165xfs_parseargs(
166 struct xfs_mount *mp,
167 char *options,
168 struct xfs_mount_args *args,
169 int update)
170{
171 char *this_char, *value, *eov;
172 int dsunit, dswidth, vol_dsunit, vol_dswidth;
173 int iosize;
174 int ikeep = 0;
175
176 args->flags |= XFSMNT_BARRIER;
177 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
178
179 if (!options)
180 goto done;
181
182 iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0;
183
184 while ((this_char = strsep(&options, ",")) != NULL) {
185 if (!*this_char)
186 continue;
187 if ((value = strchr(this_char, '=')) != NULL)
188 *value++ = 0;
189
190 if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
191 if (!value || !*value) {
192 cmn_err(CE_WARN,
193 "XFS: %s option requires an argument",
194 this_char);
195 return EINVAL;
196 }
197 args->logbufs = simple_strtoul(value, &eov, 10);
198 } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
199 if (!value || !*value) {
200 cmn_err(CE_WARN,
201 "XFS: %s option requires an argument",
202 this_char);
203 return EINVAL;
204 }
205 args->logbufsize = suffix_strtoul(value, &eov, 10);
206 } else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
207 if (!value || !*value) {
208 cmn_err(CE_WARN,
209 "XFS: %s option requires an argument",
210 this_char);
211 return EINVAL;
212 }
213 strncpy(args->logname, value, MAXNAMELEN);
214 } else if (!strcmp(this_char, MNTOPT_MTPT)) {
215 if (!value || !*value) {
216 cmn_err(CE_WARN,
217 "XFS: %s option requires an argument",
218 this_char);
219 return EINVAL;
220 }
221 strncpy(args->mtpt, value, MAXNAMELEN);
222 } else if (!strcmp(this_char, MNTOPT_RTDEV)) {
223 if (!value || !*value) {
224 cmn_err(CE_WARN,
225 "XFS: %s option requires an argument",
226 this_char);
227 return EINVAL;
228 }
229 strncpy(args->rtname, value, MAXNAMELEN);
230 } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
231 if (!value || !*value) {
232 cmn_err(CE_WARN,
233 "XFS: %s option requires an argument",
234 this_char);
235 return EINVAL;
236 }
237 iosize = simple_strtoul(value, &eov, 10);
238 args->flags |= XFSMNT_IOSIZE;
239 args->iosizelog = (uint8_t) iosize;
240 } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
241 if (!value || !*value) {
242 cmn_err(CE_WARN,
243 "XFS: %s option requires an argument",
244 this_char);
245 return EINVAL;
246 }
247 iosize = suffix_strtoul(value, &eov, 10);
248 args->flags |= XFSMNT_IOSIZE;
249 args->iosizelog = ffs(iosize) - 1;
250 } else if (!strcmp(this_char, MNTOPT_GRPID) ||
251 !strcmp(this_char, MNTOPT_BSDGROUPS)) {
252 mp->m_flags |= XFS_MOUNT_GRPID;
253 } else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
254 !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
255 mp->m_flags &= ~XFS_MOUNT_GRPID;
256 } else if (!strcmp(this_char, MNTOPT_WSYNC)) {
257 args->flags |= XFSMNT_WSYNC;
258 } else if (!strcmp(this_char, MNTOPT_OSYNCISOSYNC)) {
259 args->flags |= XFSMNT_OSYNCISOSYNC;
260 } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
261 args->flags |= XFSMNT_NORECOVERY;
262 } else if (!strcmp(this_char, MNTOPT_INO64)) {
263 args->flags |= XFSMNT_INO64;
264#if !XFS_BIG_INUMS
265 cmn_err(CE_WARN,
266 "XFS: %s option not allowed on this system",
267 this_char);
268 return EINVAL;
269#endif
270 } else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
271 args->flags |= XFSMNT_NOALIGN;
272 } else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
273 args->flags |= XFSMNT_SWALLOC;
274 } else if (!strcmp(this_char, MNTOPT_SUNIT)) {
275 if (!value || !*value) {
276 cmn_err(CE_WARN,
277 "XFS: %s option requires an argument",
278 this_char);
279 return EINVAL;
280 }
281 dsunit = simple_strtoul(value, &eov, 10);
282 } else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
283 if (!value || !*value) {
284 cmn_err(CE_WARN,
285 "XFS: %s option requires an argument",
286 this_char);
287 return EINVAL;
288 }
289 dswidth = simple_strtoul(value, &eov, 10);
290 } else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
291 args->flags &= ~XFSMNT_32BITINODES;
292#if !XFS_BIG_INUMS
293 cmn_err(CE_WARN,
294 "XFS: %s option not allowed on this system",
295 this_char);
296 return EINVAL;
297#endif
298 } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
299 args->flags |= XFSMNT_NOUUID;
300 } else if (!strcmp(this_char, MNTOPT_BARRIER)) {
301 args->flags |= XFSMNT_BARRIER;
302 } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
303 args->flags &= ~XFSMNT_BARRIER;
304 } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
305 ikeep = 1;
306 args->flags &= ~XFSMNT_IDELETE;
307 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
308 args->flags |= XFSMNT_IDELETE;
309 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
310 args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE;
311 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
312 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
313 } else if (!strcmp(this_char, MNTOPT_ATTR2)) {
314 args->flags |= XFSMNT_ATTR2;
315 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
316 args->flags &= ~XFSMNT_ATTR2;
317 } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
318 args->flags2 |= XFSMNT2_FILESTREAMS;
319 } else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
320 args->flags &= ~(XFSMNT_UQUOTAENF|XFSMNT_UQUOTA);
321 args->flags &= ~(XFSMNT_GQUOTAENF|XFSMNT_GQUOTA);
322 } else if (!strcmp(this_char, MNTOPT_QUOTA) ||
323 !strcmp(this_char, MNTOPT_UQUOTA) ||
324 !strcmp(this_char, MNTOPT_USRQUOTA)) {
325 args->flags |= XFSMNT_UQUOTA | XFSMNT_UQUOTAENF;
326 } else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
327 !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
328 args->flags |= XFSMNT_UQUOTA;
329 args->flags &= ~XFSMNT_UQUOTAENF;
330 } else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
331 !strcmp(this_char, MNTOPT_PRJQUOTA)) {
332 args->flags |= XFSMNT_PQUOTA | XFSMNT_PQUOTAENF;
333 } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
334 args->flags |= XFSMNT_PQUOTA;
335 args->flags &= ~XFSMNT_PQUOTAENF;
336 } else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
337 !strcmp(this_char, MNTOPT_GRPQUOTA)) {
338 args->flags |= XFSMNT_GQUOTA | XFSMNT_GQUOTAENF;
339 } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
340 args->flags |= XFSMNT_GQUOTA;
341 args->flags &= ~XFSMNT_GQUOTAENF;
342 } else if (!strcmp(this_char, MNTOPT_DMAPI)) {
343 args->flags |= XFSMNT_DMAPI;
344 } else if (!strcmp(this_char, MNTOPT_XDSM)) {
345 args->flags |= XFSMNT_DMAPI;
346 } else if (!strcmp(this_char, MNTOPT_DMI)) {
347 args->flags |= XFSMNT_DMAPI;
348 } else if (!strcmp(this_char, "ihashsize")) {
349 cmn_err(CE_WARN,
350 "XFS: ihashsize no longer used, option is deprecated.");
351 } else if (!strcmp(this_char, "osyncisdsync")) {
352 /* no-op, this is now the default */
353 cmn_err(CE_WARN,
354 "XFS: osyncisdsync is now the default, option is deprecated.");
355 } else if (!strcmp(this_char, "irixsgid")) {
356 cmn_err(CE_WARN,
357 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
358 } else {
359 cmn_err(CE_WARN,
360 "XFS: unknown mount option [%s].", this_char);
361 return EINVAL;
362 }
363 }
364
365 if (args->flags & XFSMNT_NORECOVERY) {
366 if ((mp->m_flags & XFS_MOUNT_RDONLY) == 0) {
367 cmn_err(CE_WARN,
368 "XFS: no-recovery mounts must be read-only.");
369 return EINVAL;
370 }
371 }
372
373 if ((args->flags & XFSMNT_NOALIGN) && (dsunit || dswidth)) {
374 cmn_err(CE_WARN,
375 "XFS: sunit and swidth options incompatible with the noalign option");
376 return EINVAL;
377 }
378
379 if ((args->flags & XFSMNT_GQUOTA) && (args->flags & XFSMNT_PQUOTA)) {
380 cmn_err(CE_WARN,
381 "XFS: cannot mount with both project and group quota");
382 return EINVAL;
383 }
384
385 if ((args->flags & XFSMNT_DMAPI) && *args->mtpt == '\0') {
386 printk("XFS: %s option needs the mount point option as well\n",
387 MNTOPT_DMAPI);
388 return EINVAL;
389 }
390
391 if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
392 cmn_err(CE_WARN,
393 "XFS: sunit and swidth must be specified together");
394 return EINVAL;
395 }
396
397 if (dsunit && (dswidth % dsunit != 0)) {
398 cmn_err(CE_WARN,
399 "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)",
400 dswidth, dsunit);
401 return EINVAL;
402 }
403
404 /*
405 * Applications using DMI filesystems often expect the
406 * inode generation number to be monotonically increasing.
407 * If we delete inode chunks we break this assumption, so
408 * keep unused inode chunks on disk for DMI filesystems
409 * until we come up with a better solution.
410 * Note that if "ikeep" or "noikeep" mount options are
411 * supplied, then they are honored.
412 */
413 if (!(args->flags & XFSMNT_DMAPI) && !ikeep)
414 args->flags |= XFSMNT_IDELETE;
415
416 if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
417 if (dsunit) {
418 args->sunit = dsunit;
419 args->flags |= XFSMNT_RETERR;
420 } else {
421 args->sunit = vol_dsunit;
422 }
423 dswidth ? (args->swidth = dswidth) :
424 (args->swidth = vol_dswidth);
425 } else {
426 args->sunit = args->swidth = 0;
427 }
428
429done:
430 if (args->flags & XFSMNT_32BITINODES)
431 mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
432 if (args->flags2)
433 args->flags |= XFSMNT_FLAGS2;
434 return 0;
435}
436
437struct proc_xfs_info {
438 int flag;
439 char *str;
440};
441
442STATIC int
443xfs_showargs(
444 struct xfs_mount *mp,
445 struct seq_file *m)
446{
447 static struct proc_xfs_info xfs_info_set[] = {
448 /* the few simple ones we can get from the mount struct */
449 { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC },
450 { XFS_MOUNT_INO64, "," MNTOPT_INO64 },
451 { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN },
452 { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC },
453 { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID },
454 { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY },
455 { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC },
456 { XFS_MOUNT_ATTR2, "," MNTOPT_ATTR2 },
457 { XFS_MOUNT_FILESTREAMS, "," MNTOPT_FILESTREAM },
458 { XFS_MOUNT_DMAPI, "," MNTOPT_DMAPI },
459 { XFS_MOUNT_GRPID, "," MNTOPT_GRPID },
460 { 0, NULL }
461 };
462 static struct proc_xfs_info xfs_info_unset[] = {
463 /* the few simple ones we can get from the mount struct */
464 { XFS_MOUNT_IDELETE, "," MNTOPT_IKEEP },
465 { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO },
466 { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER },
467 { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE },
468 { 0, NULL }
469 };
470 struct proc_xfs_info *xfs_infop;
471
472 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
473 if (mp->m_flags & xfs_infop->flag)
474 seq_puts(m, xfs_infop->str);
475 }
476 for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
477 if (!(mp->m_flags & xfs_infop->flag))
478 seq_puts(m, xfs_infop->str);
479 }
480
481 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
482 seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
483 (int)(1 << mp->m_writeio_log) >> 10);
484
485 if (mp->m_logbufs > 0)
486 seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
487 if (mp->m_logbsize > 0)
488 seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
489
490 if (mp->m_logname)
491 seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
492 if (mp->m_rtname)
493 seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
494
495 if (mp->m_dalign > 0)
496 seq_printf(m, "," MNTOPT_SUNIT "=%d",
497 (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
498 if (mp->m_swidth > 0)
499 seq_printf(m, "," MNTOPT_SWIDTH "=%d",
500 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
501
502 if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
503 seq_puts(m, "," MNTOPT_USRQUOTA);
504 else if (mp->m_qflags & XFS_UQUOTA_ACCT)
505 seq_puts(m, "," MNTOPT_UQUOTANOENF);
506
507 if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
508 seq_puts(m, "," MNTOPT_PRJQUOTA);
509 else if (mp->m_qflags & XFS_PQUOTA_ACCT)
510 seq_puts(m, "," MNTOPT_PQUOTANOENF);
511
512 if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD))
513 seq_puts(m, "," MNTOPT_GRPQUOTA);
514 else if (mp->m_qflags & XFS_GQUOTA_ACCT)
515 seq_puts(m, "," MNTOPT_GQUOTANOENF);
516
517 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
518 seq_puts(m, "," MNTOPT_NOQUOTA);
519
520 return 0;
521}
90__uint64_t 522__uint64_t
91xfs_max_file_offset( 523xfs_max_file_offset(
92 unsigned int blockshift) 524 unsigned int blockshift)
@@ -137,7 +569,7 @@ xfs_set_inodeops(
137 break; 569 break;
138 case S_IFLNK: 570 case S_IFLNK:
139 inode->i_op = &xfs_symlink_inode_operations; 571 inode->i_op = &xfs_symlink_inode_operations;
140 if (inode->i_blocks) 572 if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
141 inode->i_mapping->a_ops = &xfs_address_space_operations; 573 inode->i_mapping->a_ops = &xfs_address_space_operations;
142 break; 574 break;
143 default: 575 default:
@@ -174,8 +606,6 @@ xfs_revalidate_inode(
174 606
175 inode->i_generation = ip->i_d.di_gen; 607 inode->i_generation = ip->i_d.di_gen;
176 i_size_write(inode, ip->i_d.di_size); 608 i_size_write(inode, ip->i_d.di_size);
177 inode->i_blocks =
178 XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
179 inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; 609 inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec;
180 inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; 610 inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec;
181 inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec; 611 inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec;
@@ -334,6 +764,64 @@ xfs_blkdev_issue_flush(
334 blkdev_issue_flush(buftarg->bt_bdev, NULL); 764 blkdev_issue_flush(buftarg->bt_bdev, NULL);
335} 765}
336 766
767/*
768 * XFS AIL push thread support
769 */
770void
771xfsaild_wakeup(
772 xfs_mount_t *mp,
773 xfs_lsn_t threshold_lsn)
774{
775 mp->m_ail.xa_target = threshold_lsn;
776 wake_up_process(mp->m_ail.xa_task);
777}
778
779int
780xfsaild(
781 void *data)
782{
783 xfs_mount_t *mp = (xfs_mount_t *)data;
784 xfs_lsn_t last_pushed_lsn = 0;
785 long tout = 0;
786
787 while (!kthread_should_stop()) {
788 if (tout)
789 schedule_timeout_interruptible(msecs_to_jiffies(tout));
790 tout = 1000;
791
792 /* swsusp */
793 try_to_freeze();
794
795 ASSERT(mp->m_log);
796 if (XFS_FORCED_SHUTDOWN(mp))
797 continue;
798
799 tout = xfsaild_push(mp, &last_pushed_lsn);
800 }
801
802 return 0;
803} /* xfsaild */
804
805int
806xfsaild_start(
807 xfs_mount_t *mp)
808{
809 mp->m_ail.xa_target = 0;
810 mp->m_ail.xa_task = kthread_run(xfsaild, mp, "xfsaild");
811 if (IS_ERR(mp->m_ail.xa_task))
812 return -PTR_ERR(mp->m_ail.xa_task);
813 return 0;
814}
815
816void
817xfsaild_stop(
818 xfs_mount_t *mp)
819{
820 kthread_stop(mp->m_ail.xa_task);
821}
822
823
824
337STATIC struct inode * 825STATIC struct inode *
338xfs_fs_alloc_inode( 826xfs_fs_alloc_inode(
339 struct super_block *sb) 827 struct super_block *sb)
@@ -361,7 +849,7 @@ xfs_fs_inode_init_once(
361 inode_init_once(vn_to_inode((bhv_vnode_t *)vnode)); 849 inode_init_once(vn_to_inode((bhv_vnode_t *)vnode));
362} 850}
363 851
364STATIC int 852STATIC int __init
365xfs_init_zones(void) 853xfs_init_zones(void)
366{ 854{
367 xfs_vnode_zone = kmem_zone_init_flags(sizeof(bhv_vnode_t), "xfs_vnode", 855 xfs_vnode_zone = kmem_zone_init_flags(sizeof(bhv_vnode_t), "xfs_vnode",
@@ -410,8 +898,7 @@ xfs_fs_write_inode(
410{ 898{
411 int error = 0, flags = FLUSH_INODE; 899 int error = 0, flags = FLUSH_INODE;
412 900
413 vn_trace_entry(XFS_I(inode), __FUNCTION__, 901 xfs_itrace_entry(XFS_I(inode));
414 (inst_t *)__return_address);
415 if (sync) { 902 if (sync) {
416 filemap_fdatawait(inode->i_mapping); 903 filemap_fdatawait(inode->i_mapping);
417 flags |= FLUSH_SYNC; 904 flags |= FLUSH_SYNC;
@@ -438,8 +925,7 @@ xfs_fs_clear_inode(
438 * find an inode with di_mode == 0 but without IGET_CREATE set. 925 * find an inode with di_mode == 0 but without IGET_CREATE set.
439 */ 926 */
440 if (ip) { 927 if (ip) {
441 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 928 xfs_itrace_entry(ip);
442
443 XFS_STATS_INC(vn_rele); 929 XFS_STATS_INC(vn_rele);
444 XFS_STATS_INC(vn_remove); 930 XFS_STATS_INC(vn_remove);
445 XFS_STATS_INC(vn_reclaim); 931 XFS_STATS_INC(vn_reclaim);
@@ -683,8 +1169,44 @@ xfs_fs_statfs(
683 struct dentry *dentry, 1169 struct dentry *dentry,
684 struct kstatfs *statp) 1170 struct kstatfs *statp)
685{ 1171{
686 return -xfs_statvfs(XFS_M(dentry->d_sb), statp, 1172 struct xfs_mount *mp = XFS_M(dentry->d_sb);
687 vn_from_inode(dentry->d_inode)); 1173 xfs_sb_t *sbp = &mp->m_sb;
1174 __uint64_t fakeinos, id;
1175 xfs_extlen_t lsize;
1176
1177 statp->f_type = XFS_SB_MAGIC;
1178 statp->f_namelen = MAXNAMELEN - 1;
1179
1180 id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
1181 statp->f_fsid.val[0] = (u32)id;
1182 statp->f_fsid.val[1] = (u32)(id >> 32);
1183
1184 xfs_icsb_sync_counters_flags(mp, XFS_ICSB_LAZY_COUNT);
1185
1186 spin_lock(&mp->m_sb_lock);
1187 statp->f_bsize = sbp->sb_blocksize;
1188 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
1189 statp->f_blocks = sbp->sb_dblocks - lsize;
1190 statp->f_bfree = statp->f_bavail =
1191 sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
1192 fakeinos = statp->f_bfree << sbp->sb_inopblog;
1193#if XFS_BIG_INUMS
1194 fakeinos += mp->m_inoadd;
1195#endif
1196 statp->f_files =
1197 MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
1198 if (mp->m_maxicount)
1199#if XFS_BIG_INUMS
1200 if (!mp->m_inoadd)
1201#endif
1202 statp->f_files = min_t(typeof(statp->f_files),
1203 statp->f_files,
1204 mp->m_maxicount);
1205 statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
1206 spin_unlock(&mp->m_sb_lock);
1207
1208 XFS_QM_DQSTATVFS(XFS_I(dentry->d_inode), statp);
1209 return 0;
688} 1210}
689 1211
690STATIC int 1212STATIC int
@@ -704,11 +1226,19 @@ xfs_fs_remount(
704 return -error; 1226 return -error;
705} 1227}
706 1228
1229/*
1230 * Second stage of a freeze. The data is already frozen so we only
1231 * need to take care of themetadata. Once that's done write a dummy
1232 * record to dirty the log in case of a crash while frozen.
1233 */
707STATIC void 1234STATIC void
708xfs_fs_lockfs( 1235xfs_fs_lockfs(
709 struct super_block *sb) 1236 struct super_block *sb)
710{ 1237{
711 xfs_freeze(XFS_M(sb)); 1238 struct xfs_mount *mp = XFS_M(sb);
1239
1240 xfs_attr_quiesce(mp);
1241 xfs_fs_log_dummy(mp);
712} 1242}
713 1243
714STATIC int 1244STATIC int
@@ -779,7 +1309,6 @@ xfs_fs_fill_super(
779 struct inode *rootvp; 1309 struct inode *rootvp;
780 struct xfs_mount *mp = NULL; 1310 struct xfs_mount *mp = NULL;
781 struct xfs_mount_args *args = xfs_args_allocate(sb, silent); 1311 struct xfs_mount_args *args = xfs_args_allocate(sb, silent);
782 struct kstatfs statvfs;
783 int error; 1312 int error;
784 1313
785 mp = xfs_mount_init(); 1314 mp = xfs_mount_init();
@@ -807,21 +1336,19 @@ xfs_fs_fill_super(
807 if (error) 1336 if (error)
808 goto fail_vfsop; 1337 goto fail_vfsop;
809 1338
810 error = xfs_statvfs(mp, &statvfs, NULL);
811 if (error)
812 goto fail_unmount;
813
814 sb->s_dirt = 1; 1339 sb->s_dirt = 1;
815 sb->s_magic = statvfs.f_type; 1340 sb->s_magic = XFS_SB_MAGIC;
816 sb->s_blocksize = statvfs.f_bsize; 1341 sb->s_blocksize = mp->m_sb.sb_blocksize;
817 sb->s_blocksize_bits = ffs(statvfs.f_bsize) - 1; 1342 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
818 sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits); 1343 sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
819 sb->s_time_gran = 1; 1344 sb->s_time_gran = 1;
820 set_posix_acl_flag(sb); 1345 set_posix_acl_flag(sb);
821 1346
822 error = xfs_root(mp, &rootvp); 1347 rootvp = igrab(mp->m_rootip->i_vnode);
823 if (error) 1348 if (!rootvp) {
1349 error = ENOENT;
824 goto fail_unmount; 1350 goto fail_unmount;
1351 }
825 1352
826 sb->s_root = d_alloc_root(vn_to_inode(rootvp)); 1353 sb->s_root = d_alloc_root(vn_to_inode(rootvp));
827 if (!sb->s_root) { 1354 if (!sb->s_root) {
@@ -841,8 +1368,7 @@ xfs_fs_fill_super(
841 goto fail_vnrele; 1368 goto fail_vnrele;
842 } 1369 }
843 1370
844 vn_trace_exit(XFS_I(sb->s_root->d_inode), __FUNCTION__, 1371 xfs_itrace_exit(XFS_I(sb->s_root->d_inode));
845 (inst_t *)__return_address);
846 1372
847 kmem_free(args, sizeof(*args)); 1373 kmem_free(args, sizeof(*args));
848 return 0; 1374 return 0;