110
110
#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
111
111
#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
112
112
#define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
113
#define MNTOPT_DELAYLOG "delaylog" /* Delayed loging enabled */
114
#define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */
113
#define MNTOPT_DELAYLOG "delaylog" /* Delayed logging enabled */
114
#define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
115
#define MNTOPT_DISCARD "discard" /* Discard unused blocks */
116
#define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
117
119
* Table driven mount option parser.
173
175
__uint8_t iosizelog = 0;
178
* set up the mount name first so all the errors will refer to the
181
mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL);
184
mp->m_fsname_len = strlen(mp->m_fsname) + 1;
176
187
* Copy binary VFS mount flags we are interested in.
178
189
if (sb->s_flags & MS_RDONLY)
189
200
mp->m_flags |= XFS_MOUNT_BARRIER;
190
201
mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
191
202
mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
203
mp->m_flags |= XFS_MOUNT_DELAYLOG;
194
206
* These can be overridden by the mount option parsing.
208
220
if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
209
221
if (!value || !*value) {
211
"XFS: %s option requires an argument",
222
xfs_warn(mp, "%s option requires an argument",
215
226
mp->m_logbufs = simple_strtoul(value, &eov, 10);
216
227
} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
217
228
if (!value || !*value) {
219
"XFS: %s option requires an argument",
229
xfs_warn(mp, "%s option requires an argument",
223
233
mp->m_logbsize = suffix_strtoul(value, &eov, 10);
224
234
} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
225
235
if (!value || !*value) {
227
"XFS: %s option requires an argument",
236
xfs_warn(mp, "%s option requires an argument",
232
241
if (!mp->m_logname)
234
243
} else if (!strcmp(this_char, MNTOPT_MTPT)) {
236
"XFS: %s option not allowed on this system",
244
xfs_warn(mp, "%s option not allowed on this system",
239
247
} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
240
248
if (!value || !*value) {
242
"XFS: %s option requires an argument",
249
xfs_warn(mp, "%s option requires an argument",
249
256
} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
250
257
if (!value || !*value) {
252
"XFS: %s option requires an argument",
258
xfs_warn(mp, "%s option requires an argument",
257
263
iosizelog = ffs(iosize) - 1;
258
264
} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
259
265
if (!value || !*value) {
261
"XFS: %s option requires an argument",
266
xfs_warn(mp, "%s option requires an argument",
280
285
mp->m_flags |= XFS_MOUNT_SWALLOC;
281
286
} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
282
287
if (!value || !*value) {
284
"XFS: %s option requires an argument",
288
xfs_warn(mp, "%s option requires an argument",
288
292
dsunit = simple_strtoul(value, &eov, 10);
289
293
} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
290
294
if (!value || !*value) {
292
"XFS: %s option requires an argument",
295
xfs_warn(mp, "%s option requires an argument",
297
300
} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
298
301
mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
299
302
#if !XFS_BIG_INUMS
301
"XFS: %s option not allowed on this system",
303
xfs_warn(mp, "%s option not allowed on this system",
355
357
mp->m_flags |= XFS_MOUNT_DELAYLOG;
356
358
} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
357
359
mp->m_flags &= ~XFS_MOUNT_DELAYLOG;
360
} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
361
mp->m_flags |= XFS_MOUNT_DISCARD;
362
} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
363
mp->m_flags &= ~XFS_MOUNT_DISCARD;
358
364
} else if (!strcmp(this_char, "ihashsize")) {
360
"XFS: ihashsize no longer used, option is deprecated.");
366
"ihashsize no longer used, option is deprecated.");
361
367
} else if (!strcmp(this_char, "osyncisdsync")) {
363
"XFS: osyncisdsync has no effect, option is deprecated.");
369
"osyncisdsync has no effect, option is deprecated.");
364
370
} else if (!strcmp(this_char, "osyncisosync")) {
366
"XFS: osyncisosync has no effect, option is deprecated.");
372
"osyncisosync has no effect, option is deprecated.");
367
373
} else if (!strcmp(this_char, "irixsgid")) {
369
"XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
375
"irixsgid is now a sysctl(2) variable, option is deprecated.");
372
"XFS: unknown mount option [%s].", this_char);
377
xfs_warn(mp, "unknown mount option [%s].", this_char);
380
385
if ((mp->m_flags & XFS_MOUNT_NORECOVERY) &&
381
386
!(mp->m_flags & XFS_MOUNT_RDONLY)) {
382
cmn_err(CE_WARN, "XFS: no-recovery mounts must be read-only.");
387
xfs_warn(mp, "no-recovery mounts must be read-only.");
386
391
if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) {
388
"XFS: sunit and swidth options incompatible with the noalign option");
393
"sunit and swidth options incompatible with the noalign option");
397
if ((mp->m_flags & XFS_MOUNT_DISCARD) &&
398
!(mp->m_flags & XFS_MOUNT_DELAYLOG)) {
400
"the discard option is incompatible with the nodelaylog option");
392
404
#ifndef CONFIG_XFS_QUOTA
393
405
if (XFS_IS_QUOTA_RUNNING(mp)) {
395
"XFS: quota support not available in this kernel.");
406
xfs_warn(mp, "quota support not available in this kernel.");
400
411
if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) &&
401
412
(mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) {
403
"XFS: cannot mount with both project and group quota");
413
xfs_warn(mp, "cannot mount with both project and group quota");
407
417
if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
409
"XFS: sunit and swidth must be specified together");
418
xfs_warn(mp, "sunit and swidth must be specified together");
413
422
if (dsunit && (dswidth % dsunit != 0)) {
415
"XFS: stripe width (%d) must be a multiple of the stripe unit (%d)",
424
"stripe width (%d) must be a multiple of the stripe unit (%d)",
416
425
dswidth, dsunit);
438
447
mp->m_logbufs != 0 &&
439
448
(mp->m_logbufs < XLOG_MIN_ICLOGS ||
440
449
mp->m_logbufs > XLOG_MAX_ICLOGS)) {
442
"XFS: invalid logbufs value: %d [not %d-%d]",
450
xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]",
443
451
mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
444
452
return XFS_ERROR(EINVAL);
448
456
(mp->m_logbsize < XLOG_MIN_RECORD_BSIZE ||
449
457
mp->m_logbsize > XLOG_MAX_RECORD_BSIZE ||
450
458
!is_power_of_2(mp->m_logbsize))) {
452
"XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
460
"invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
454
462
return XFS_ERROR(EINVAL);
457
mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL);
460
mp->m_fsname_len = strlen(mp->m_fsname) + 1;
463
466
if (iosizelog > XFS_MAX_IO_LOG ||
464
467
iosizelog < XFS_MIN_IO_LOG) {
466
"XFS: invalid log iosize: %d [not %d-%d]",
468
xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
467
469
iosizelog, XFS_MIN_IO_LOG,
469
471
return XFS_ERROR(EINVAL);
499
501
{ XFS_MOUNT_FILESTREAMS, "," MNTOPT_FILESTREAM },
500
502
{ XFS_MOUNT_GRPID, "," MNTOPT_GRPID },
501
503
{ XFS_MOUNT_DELAYLOG, "," MNTOPT_DELAYLOG },
504
{ XFS_MOUNT_DISCARD, "," MNTOPT_DISCARD },
504
507
static struct proc_xfs_info xfs_info_unset[] = {
611
614
if (IS_ERR(*bdevp)) {
612
615
error = PTR_ERR(*bdevp);
613
printk("XFS: Invalid device [%s], error=%d\n", name, error);
616
xfs_warn(mp, "Invalid device [%s], error=%d\n", name, error);
624
627
blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
628
* Try to write out the superblock using barriers.
634
xfs_buf_t *sbp = xfs_getsb(mp, 0);
639
XFS_BUF_UNDELAYWRITE(sbp);
641
XFS_BUF_UNASYNC(sbp);
642
XFS_BUF_ORDERED(sbp);
645
error = xfs_buf_iowait(sbp);
648
* Clear all the flags we set and possible error state in the
649
* buffer. We only did the write to try out whether barriers
650
* worked and shouldn't leave any traces in the superblock
654
XFS_BUF_ERROR(sbp, 0);
655
XFS_BUF_UNORDERED(sbp);
662
xfs_mountfs_check_barriers(xfs_mount_t *mp)
666
if (mp->m_logdev_targp != mp->m_ddev_targp) {
667
xfs_fs_cmn_err(CE_NOTE, mp,
668
"Disabling barriers, not supported with external log device");
669
mp->m_flags &= ~XFS_MOUNT_BARRIER;
673
if (xfs_readonly_buftarg(mp->m_ddev_targp)) {
674
xfs_fs_cmn_err(CE_NOTE, mp,
675
"Disabling barriers, underlying device is readonly");
676
mp->m_flags &= ~XFS_MOUNT_BARRIER;
680
error = xfs_barrier_test(mp);
682
xfs_fs_cmn_err(CE_NOTE, mp,
683
"Disabling barriers, trial barrier write failed");
684
mp->m_flags &= ~XFS_MOUNT_BARRIER;
690
631
xfs_blkdev_issue_flush(
691
632
xfs_buftarg_t *buftarg)
831
* XFS AIL push thread support
835
struct xfs_ail *ailp,
836
xfs_lsn_t threshold_lsn)
838
/* only ever move the target forwards */
839
if (XFS_LSN_CMP(threshold_lsn, ailp->xa_target) > 0) {
840
ailp->xa_target = threshold_lsn;
841
wake_up_process(ailp->xa_task);
849
struct xfs_ail *ailp = data;
850
xfs_lsn_t last_pushed_lsn = 0;
851
long tout = 0; /* milliseconds */
853
while (!kthread_should_stop()) {
855
* for short sleeps indicating congestion, don't allow us to
856
* get woken early. Otherwise all we do is bang on the AIL lock
857
* without making progress.
859
if (tout && tout <= 20)
860
__set_current_state(TASK_KILLABLE);
862
__set_current_state(TASK_INTERRUPTIBLE);
863
schedule_timeout(tout ?
864
msecs_to_jiffies(tout) : MAX_SCHEDULE_TIMEOUT);
869
ASSERT(ailp->xa_mount->m_log);
870
if (XFS_FORCED_SHUTDOWN(ailp->xa_mount))
873
tout = xfsaild_push(ailp, &last_pushed_lsn);
881
struct xfs_ail *ailp)
884
ailp->xa_task = kthread_run(xfsaild, ailp, "xfsaild/%s",
885
ailp->xa_mount->m_fsname);
886
if (IS_ERR(ailp->xa_task))
887
return -PTR_ERR(ailp->xa_task);
893
struct xfs_ail *ailp)
895
kthread_stop(ailp->xa_task);
899
771
/* Catch misguided souls that try to use this interface on XFS */
900
772
STATIC struct inode *
901
773
xfs_fs_alloc_inode(
1204
1077
if (laptop_mode) {
1205
int prev_sync_seq = mp->m_sync_seq;
1208
1079
* The disk must be active because we're syncing.
1209
1080
* We schedule xfssyncd now (now that the disk is
1210
1081
* active) instead of later (when it might not be).
1212
wake_up_process(mp->m_sync_task);
1214
* We have to wait for the sync iteration to complete.
1215
* If we don't, the disk activity caused by the sync
1216
* will come after the sync is completed, and that
1217
* triggers another sync from laptop mode.
1219
wait_event(mp->m_wait_single_sync_task,
1220
mp->m_sync_seq != prev_sync_seq);
1083
flush_delayed_work_sync(&mp->m_sync_work);
1315
1178
switch (token) {
1316
1179
case Opt_barrier:
1317
1180
mp->m_flags |= XFS_MOUNT_BARRIER;
1320
* Test if barriers are actually working if we can,
1321
* else delay this check until the filesystem is
1324
if (!(mp->m_flags & XFS_MOUNT_RDONLY))
1325
xfs_mountfs_check_barriers(mp);
1327
1182
case Opt_nobarrier:
1328
1183
mp->m_flags &= ~XFS_MOUNT_BARRIER;
1358
1213
if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
1359
1214
mp->m_flags &= ~XFS_MOUNT_RDONLY;
1360
if (mp->m_flags & XFS_MOUNT_BARRIER)
1361
xfs_mountfs_check_barriers(mp);
1364
1217
* If this is the first remount to writeable state we
1367
1220
if (mp->m_update_flags) {
1368
1221
error = xfs_mount_log_sb(mp, mp->m_update_flags);
1371
"XFS: failed to write sb changes");
1223
xfs_warn(mp, "failed to write sb changes");
1374
1226
mp->m_update_flags = 0;
1452
1304
mp->m_logbsize = mp->m_sb.sb_logsunit;
1453
1305
} else if (mp->m_logbsize > 0 &&
1454
1306
mp->m_logbsize < mp->m_sb.sb_logsunit) {
1456
"XFS: logbuf size must be greater than or equal to log stripe size");
1308
"logbuf size must be greater than or equal to log stripe size");
1457
1309
return XFS_ERROR(EINVAL);
1460
1312
/* Fail a mount if the logbuf is larger than 32K */
1461
1313
if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
1463
"XFS: logbuf size for version 1 logs must be 16K or 32K");
1315
"logbuf size for version 1 logs must be 16K or 32K");
1464
1316
return XFS_ERROR(EINVAL);
1477
1329
* prohibit r/w mounts of read-only filesystems
1479
1331
if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
1481
"XFS: cannot mount a read-only filesystem as read-write");
1333
"cannot mount a read-only filesystem as read-write");
1482
1334
return XFS_ERROR(EROFS);
1502
1354
spin_lock_init(&mp->m_sb_lock);
1503
1355
mutex_init(&mp->m_growlock);
1504
1356
atomic_set(&mp->m_active_trans, 0);
1505
INIT_LIST_HEAD(&mp->m_sync_list);
1506
spin_lock_init(&mp->m_sync_lock);
1507
init_waitqueue_head(&mp->m_wait_single_sync_task);
1509
1358
mp->m_super = sb;
1510
1359
sb->s_fs_info = mp;
1813
1659
STATIC int __init
1660
xfs_init_workqueues(void)
1663
* max_active is set to 8 to give enough concurency to allow
1664
* multiple work operations on each CPU to run. This allows multiple
1665
* filesystems to be running sync work concurrently, and scales with
1666
* the number of CPUs in the system.
1668
xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_CPU_INTENSIVE, 8);
1672
xfs_ail_wq = alloc_workqueue("xfsail", WQ_CPU_INTENSIVE, 8);
1674
goto out_destroy_syncd;
1679
destroy_workqueue(xfs_syncd_wq);
1685
xfs_destroy_workqueues(void)
1687
destroy_workqueue(xfs_ail_wq);
1688
destroy_workqueue(xfs_syncd_wq);
1814
1692
init_xfs_fs(void)