diff options
author | Dave Chinner <david@fromorbit.com> | 2015-01-21 17:20:53 -0500 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-01-21 17:20:53 -0500 |
commit | 465e2def7cb45864da1f82afb973a6acd1046ed8 (patch) | |
tree | d085a45f4575a8ea31d128626c4f1f650cf9d54a /fs/xfs | |
parent | 6bcf0939ff12464c7ea24c056826b8a26def9b06 (diff) | |
parent | 074e427ba7f7398427e4f8e2aec071edcc509673 (diff) |
Merge branch 'xfs-sb-logging-rework' into for-next
Conflicts:
fs/xfs/xfs_mount.c
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/libxfs/xfs_attr_leaf.c | 2 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_bmap.c | 14 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_format.h | 14 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_sb.c | 320 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_sb.h | 11 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_shared.h | 33 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_trans_resv.c | 14 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_trans_resv.h | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_fsops.c | 33 | ||||
-rw-r--r-- | fs/xfs/xfs_log.c | 18 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.c | 106 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.h | 5 | ||||
-rw-r--r-- | fs/xfs/xfs_qm.c | 43 | ||||
-rw-r--r-- | fs/xfs/xfs_qm.h | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_qm_syscalls.c | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_super.c | 13 |
16 files changed, 226 insertions, 416 deletions
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 5d38e8b8a913..15105dbc9e28 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c | |||
@@ -403,7 +403,7 @@ xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp) | |||
403 | if (!xfs_sb_version_hasattr2(&mp->m_sb)) { | 403 | if (!xfs_sb_version_hasattr2(&mp->m_sb)) { |
404 | xfs_sb_version_addattr2(&mp->m_sb); | 404 | xfs_sb_version_addattr2(&mp->m_sb); |
405 | spin_unlock(&mp->m_sb_lock); | 405 | spin_unlock(&mp->m_sb_lock); |
406 | xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); | 406 | xfs_log_sb(tp); |
407 | } else | 407 | } else |
408 | spin_unlock(&mp->m_sb_lock); | 408 | spin_unlock(&mp->m_sb_lock); |
409 | } | 409 | } |
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index b5eb4743f75a..63a5bb9113ee 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c | |||
@@ -1221,22 +1221,20 @@ xfs_bmap_add_attrfork( | |||
1221 | goto bmap_cancel; | 1221 | goto bmap_cancel; |
1222 | if (!xfs_sb_version_hasattr(&mp->m_sb) || | 1222 | if (!xfs_sb_version_hasattr(&mp->m_sb) || |
1223 | (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) { | 1223 | (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) { |
1224 | __int64_t sbfields = 0; | 1224 | bool log_sb = false; |
1225 | 1225 | ||
1226 | spin_lock(&mp->m_sb_lock); | 1226 | spin_lock(&mp->m_sb_lock); |
1227 | if (!xfs_sb_version_hasattr(&mp->m_sb)) { | 1227 | if (!xfs_sb_version_hasattr(&mp->m_sb)) { |
1228 | xfs_sb_version_addattr(&mp->m_sb); | 1228 | xfs_sb_version_addattr(&mp->m_sb); |
1229 | sbfields |= XFS_SB_VERSIONNUM; | 1229 | log_sb = true; |
1230 | } | 1230 | } |
1231 | if (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2) { | 1231 | if (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2) { |
1232 | xfs_sb_version_addattr2(&mp->m_sb); | 1232 | xfs_sb_version_addattr2(&mp->m_sb); |
1233 | sbfields |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); | 1233 | log_sb = true; |
1234 | } | 1234 | } |
1235 | if (sbfields) { | 1235 | spin_unlock(&mp->m_sb_lock); |
1236 | spin_unlock(&mp->m_sb_lock); | 1236 | if (log_sb) |
1237 | xfs_mod_sb(tp, sbfields); | 1237 | xfs_log_sb(tp); |
1238 | } else | ||
1239 | spin_unlock(&mp->m_sb_lock); | ||
1240 | } | 1238 | } |
1241 | 1239 | ||
1242 | error = xfs_bmap_finish(&tp, &flist, &committed); | 1240 | error = xfs_bmap_finish(&tp, &flist, &committed); |
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 476273287aaf..8eb718979383 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h | |||
@@ -151,10 +151,13 @@ typedef struct xfs_sb { | |||
151 | __uint32_t sb_features2; /* additional feature bits */ | 151 | __uint32_t sb_features2; /* additional feature bits */ |
152 | 152 | ||
153 | /* | 153 | /* |
154 | * bad features2 field as a result of failing to pad the sb | 154 | * bad features2 field as a result of failing to pad the sb structure to |
155 | * structure to 64 bits. Some machines will be using this field | 155 | * 64 bits. Some machines will be using this field for features2 bits. |
156 | * for features2 bits. Easiest just to mark it bad and not use | 156 | * Easiest just to mark it bad and not use it for anything else. |
157 | * it for anything else. | 157 | * |
158 | * This is not kept up to date in memory; it is always overwritten by | ||
159 | * the value in sb_features2 when formatting the incore superblock to | ||
160 | * the disk buffer. | ||
158 | */ | 161 | */ |
159 | __uint32_t sb_bad_features2; | 162 | __uint32_t sb_bad_features2; |
160 | 163 | ||
@@ -453,13 +456,11 @@ static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) | |||
453 | { | 456 | { |
454 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; | 457 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; |
455 | sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; | 458 | sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; |
456 | sbp->sb_bad_features2 |= XFS_SB_VERSION2_ATTR2BIT; | ||
457 | } | 459 | } |
458 | 460 | ||
459 | static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) | 461 | static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) |
460 | { | 462 | { |
461 | sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; | 463 | sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; |
462 | sbp->sb_bad_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; | ||
463 | if (!sbp->sb_features2) | 464 | if (!sbp->sb_features2) |
464 | sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; | 465 | sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; |
465 | } | 466 | } |
@@ -475,7 +476,6 @@ static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp) | |||
475 | { | 476 | { |
476 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; | 477 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; |
477 | sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; | 478 | sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; |
478 | sbp->sb_bad_features2 |= XFS_SB_VERSION2_PROJID32BIT; | ||
479 | } | 479 | } |
480 | 480 | ||
481 | /* | 481 | /* |
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 752915fa775a..b0a5fe95a3e2 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c | |||
@@ -40,69 +40,6 @@ | |||
40 | * Physical superblock buffer manipulations. Shared with libxfs in userspace. | 40 | * Physical superblock buffer manipulations. Shared with libxfs in userspace. |
41 | */ | 41 | */ |
42 | 42 | ||
43 | static const struct { | ||
44 | short offset; | ||
45 | short type; /* 0 = integer | ||
46 | * 1 = binary / string (no translation) | ||
47 | */ | ||
48 | } xfs_sb_info[] = { | ||
49 | { offsetof(xfs_sb_t, sb_magicnum), 0 }, | ||
50 | { offsetof(xfs_sb_t, sb_blocksize), 0 }, | ||
51 | { offsetof(xfs_sb_t, sb_dblocks), 0 }, | ||
52 | { offsetof(xfs_sb_t, sb_rblocks), 0 }, | ||
53 | { offsetof(xfs_sb_t, sb_rextents), 0 }, | ||
54 | { offsetof(xfs_sb_t, sb_uuid), 1 }, | ||
55 | { offsetof(xfs_sb_t, sb_logstart), 0 }, | ||
56 | { offsetof(xfs_sb_t, sb_rootino), 0 }, | ||
57 | { offsetof(xfs_sb_t, sb_rbmino), 0 }, | ||
58 | { offsetof(xfs_sb_t, sb_rsumino), 0 }, | ||
59 | { offsetof(xfs_sb_t, sb_rextsize), 0 }, | ||
60 | { offsetof(xfs_sb_t, sb_agblocks), 0 }, | ||
61 | { offsetof(xfs_sb_t, sb_agcount), 0 }, | ||
62 | { offsetof(xfs_sb_t, sb_rbmblocks), 0 }, | ||
63 | { offsetof(xfs_sb_t, sb_logblocks), 0 }, | ||
64 | { offsetof(xfs_sb_t, sb_versionnum), 0 }, | ||
65 | { offsetof(xfs_sb_t, sb_sectsize), 0 }, | ||
66 | { offsetof(xfs_sb_t, sb_inodesize), 0 }, | ||
67 | { offsetof(xfs_sb_t, sb_inopblock), 0 }, | ||
68 | { offsetof(xfs_sb_t, sb_fname[0]), 1 }, | ||
69 | { offsetof(xfs_sb_t, sb_blocklog), 0 }, | ||
70 | { offsetof(xfs_sb_t, sb_sectlog), 0 }, | ||
71 | { offsetof(xfs_sb_t, sb_inodelog), 0 }, | ||
72 | { offsetof(xfs_sb_t, sb_inopblog), 0 }, | ||
73 | { offsetof(xfs_sb_t, sb_agblklog), 0 }, | ||
74 | { offsetof(xfs_sb_t, sb_rextslog), 0 }, | ||
75 | { offsetof(xfs_sb_t, sb_inprogress), 0 }, | ||
76 | { offsetof(xfs_sb_t, sb_imax_pct), 0 }, | ||
77 | { offsetof(xfs_sb_t, sb_icount), 0 }, | ||
78 | { offsetof(xfs_sb_t, sb_ifree), 0 }, | ||
79 | { offsetof(xfs_sb_t, sb_fdblocks), 0 }, | ||
80 | { offsetof(xfs_sb_t, sb_frextents), 0 }, | ||
81 | { offsetof(xfs_sb_t, sb_uquotino), 0 }, | ||
82 | { offsetof(xfs_sb_t, sb_gquotino), 0 }, | ||
83 | { offsetof(xfs_sb_t, sb_qflags), 0 }, | ||
84 | { offsetof(xfs_sb_t, sb_flags), 0 }, | ||
85 | { offsetof(xfs_sb_t, sb_shared_vn), 0 }, | ||
86 | { offsetof(xfs_sb_t, sb_inoalignmt), 0 }, | ||
87 | { offsetof(xfs_sb_t, sb_unit), 0 }, | ||
88 | { offsetof(xfs_sb_t, sb_width), 0 }, | ||
89 | { offsetof(xfs_sb_t, sb_dirblklog), 0 }, | ||
90 | { offsetof(xfs_sb_t, sb_logsectlog), 0 }, | ||
91 | { offsetof(xfs_sb_t, sb_logsectsize), 0 }, | ||
92 | { offsetof(xfs_sb_t, sb_logsunit), 0 }, | ||
93 | { offsetof(xfs_sb_t, sb_features2), 0 }, | ||
94 | { offsetof(xfs_sb_t, sb_bad_features2), 0 }, | ||
95 | { offsetof(xfs_sb_t, sb_features_compat), 0 }, | ||
96 | { offsetof(xfs_sb_t, sb_features_ro_compat), 0 }, | ||
97 | { offsetof(xfs_sb_t, sb_features_incompat), 0 }, | ||
98 | { offsetof(xfs_sb_t, sb_features_log_incompat), 0 }, | ||
99 | { offsetof(xfs_sb_t, sb_crc), 0 }, | ||
100 | { offsetof(xfs_sb_t, sb_pad), 0 }, | ||
101 | { offsetof(xfs_sb_t, sb_pquotino), 0 }, | ||
102 | { offsetof(xfs_sb_t, sb_lsn), 0 }, | ||
103 | { sizeof(xfs_sb_t), 0 } | ||
104 | }; | ||
105 | |||
106 | /* | 43 | /* |
107 | * Reference counting access wrappers to the perag structures. | 44 | * Reference counting access wrappers to the perag structures. |
108 | * Because we never free per-ag structures, the only thing we | 45 | * Because we never free per-ag structures, the only thing we |
@@ -461,58 +398,49 @@ xfs_sb_from_disk( | |||
461 | __xfs_sb_from_disk(to, from, true); | 398 | __xfs_sb_from_disk(to, from, true); |
462 | } | 399 | } |
463 | 400 | ||
464 | static inline void | 401 | static void |
465 | xfs_sb_quota_to_disk( | 402 | xfs_sb_quota_to_disk( |
466 | xfs_dsb_t *to, | 403 | struct xfs_dsb *to, |
467 | xfs_sb_t *from, | 404 | struct xfs_sb *from) |
468 | __int64_t *fields) | ||
469 | { | 405 | { |
470 | __uint16_t qflags = from->sb_qflags; | 406 | __uint16_t qflags = from->sb_qflags; |
471 | 407 | ||
408 | to->sb_uquotino = cpu_to_be64(from->sb_uquotino); | ||
409 | if (xfs_sb_version_has_pquotino(from)) { | ||
410 | to->sb_qflags = cpu_to_be16(from->sb_qflags); | ||
411 | to->sb_gquotino = cpu_to_be64(from->sb_gquotino); | ||
412 | to->sb_pquotino = cpu_to_be64(from->sb_pquotino); | ||
413 | return; | ||
414 | } | ||
415 | |||
472 | /* | 416 | /* |
473 | * We need to do these manipilations only if we are working | 417 | * The in-core version of sb_qflags do not have XFS_OQUOTA_* |
474 | * with an older version of on-disk superblock. | 418 | * flags, whereas the on-disk version does. So, convert incore |
419 | * XFS_{PG}QUOTA_* flags to on-disk XFS_OQUOTA_* flags. | ||
475 | */ | 420 | */ |
476 | if (xfs_sb_version_has_pquotino(from)) | 421 | qflags &= ~(XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD | |
477 | return; | 422 | XFS_GQUOTA_ENFD | XFS_GQUOTA_CHKD); |
478 | 423 | ||
479 | if (*fields & XFS_SB_QFLAGS) { | 424 | if (from->sb_qflags & |
480 | /* | 425 | (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD)) |
481 | * The in-core version of sb_qflags do not have | 426 | qflags |= XFS_OQUOTA_ENFD; |
482 | * XFS_OQUOTA_* flags, whereas the on-disk version | 427 | if (from->sb_qflags & |
483 | * does. So, convert incore XFS_{PG}QUOTA_* flags | 428 | (XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) |
484 | * to on-disk XFS_OQUOTA_* flags. | 429 | qflags |= XFS_OQUOTA_CHKD; |
485 | */ | 430 | to->sb_qflags = cpu_to_be16(qflags); |
486 | qflags &= ~(XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD | | ||
487 | XFS_GQUOTA_ENFD | XFS_GQUOTA_CHKD); | ||
488 | |||
489 | if (from->sb_qflags & | ||
490 | (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD)) | ||
491 | qflags |= XFS_OQUOTA_ENFD; | ||
492 | if (from->sb_qflags & | ||
493 | (XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) | ||
494 | qflags |= XFS_OQUOTA_CHKD; | ||
495 | to->sb_qflags = cpu_to_be16(qflags); | ||
496 | *fields &= ~XFS_SB_QFLAGS; | ||
497 | } | ||
498 | 431 | ||
499 | /* | 432 | /* |
500 | * GQUOTINO and PQUOTINO cannot be used together in versions of | 433 | * GQUOTINO and PQUOTINO cannot be used together in versions |
501 | * superblock that do not have pquotino. from->sb_flags tells us which | 434 | * of superblock that do not have pquotino. from->sb_flags |
502 | * quota is active and should be copied to disk. If neither are active, | 435 | * tells us which quota is active and should be copied to |
503 | * make sure we write NULLFSINO to the sb_gquotino field as a quota | 436 | * disk. If neither are active, we should NULL the inode. |
504 | * inode value of "0" is invalid when the XFS_SB_VERSION_QUOTA feature | ||
505 | * bit is set. | ||
506 | * | 437 | * |
507 | * Note that we don't need to handle the sb_uquotino or sb_pquotino here | 438 | * In all cases, the separate pquotino must remain 0 because it |
508 | * as they do not require any translation. Hence the main sb field loop | 439 | * it beyond the "end" of the valid non-pquotino superblock. |
509 | * will write them appropriately from the in-core superblock. | ||
510 | */ | 440 | */ |
511 | if ((*fields & XFS_SB_GQUOTINO) && | 441 | if (from->sb_qflags & XFS_GQUOTA_ACCT) |
512 | (from->sb_qflags & XFS_GQUOTA_ACCT)) | ||
513 | to->sb_gquotino = cpu_to_be64(from->sb_gquotino); | 442 | to->sb_gquotino = cpu_to_be64(from->sb_gquotino); |
514 | else if ((*fields & XFS_SB_PQUOTINO) && | 443 | else if (from->sb_qflags & XFS_PQUOTA_ACCT) |
515 | (from->sb_qflags & XFS_PQUOTA_ACCT)) | ||
516 | to->sb_gquotino = cpu_to_be64(from->sb_pquotino); | 444 | to->sb_gquotino = cpu_to_be64(from->sb_pquotino); |
517 | else { | 445 | else { |
518 | /* | 446 | /* |
@@ -526,63 +454,78 @@ xfs_sb_quota_to_disk( | |||
526 | to->sb_gquotino = cpu_to_be64(NULLFSINO); | 454 | to->sb_gquotino = cpu_to_be64(NULLFSINO); |
527 | } | 455 | } |
528 | 456 | ||
529 | *fields &= ~(XFS_SB_PQUOTINO | XFS_SB_GQUOTINO); | 457 | to->sb_pquotino = 0; |
530 | } | 458 | } |
531 | 459 | ||
532 | /* | ||
533 | * Copy in core superblock to ondisk one. | ||
534 | * | ||
535 | * The fields argument is mask of superblock fields to copy. | ||
536 | */ | ||
537 | void | 460 | void |
538 | xfs_sb_to_disk( | 461 | xfs_sb_to_disk( |
539 | xfs_dsb_t *to, | 462 | struct xfs_dsb *to, |
540 | xfs_sb_t *from, | 463 | struct xfs_sb *from) |
541 | __int64_t fields) | ||
542 | { | 464 | { |
543 | xfs_caddr_t to_ptr = (xfs_caddr_t)to; | 465 | xfs_sb_quota_to_disk(to, from); |
544 | xfs_caddr_t from_ptr = (xfs_caddr_t)from; | ||
545 | xfs_sb_field_t f; | ||
546 | int first; | ||
547 | int size; | ||
548 | |||
549 | ASSERT(fields); | ||
550 | if (!fields) | ||
551 | return; | ||
552 | 466 | ||
553 | /* We should never write the crc here, it's updated in the IO path */ | 467 | to->sb_magicnum = cpu_to_be32(from->sb_magicnum); |
554 | fields &= ~XFS_SB_CRC; | 468 | to->sb_blocksize = cpu_to_be32(from->sb_blocksize); |
555 | 469 | to->sb_dblocks = cpu_to_be64(from->sb_dblocks); | |
556 | xfs_sb_quota_to_disk(to, from, &fields); | 470 | to->sb_rblocks = cpu_to_be64(from->sb_rblocks); |
557 | while (fields) { | 471 | to->sb_rextents = cpu_to_be64(from->sb_rextents); |
558 | f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields); | 472 | memcpy(&to->sb_uuid, &from->sb_uuid, sizeof(to->sb_uuid)); |
559 | first = xfs_sb_info[f].offset; | 473 | to->sb_logstart = cpu_to_be64(from->sb_logstart); |
560 | size = xfs_sb_info[f + 1].offset - first; | 474 | to->sb_rootino = cpu_to_be64(from->sb_rootino); |
561 | 475 | to->sb_rbmino = cpu_to_be64(from->sb_rbmino); | |
562 | ASSERT(xfs_sb_info[f].type == 0 || xfs_sb_info[f].type == 1); | 476 | to->sb_rsumino = cpu_to_be64(from->sb_rsumino); |
563 | 477 | to->sb_rextsize = cpu_to_be32(from->sb_rextsize); | |
564 | if (size == 1 || xfs_sb_info[f].type == 1) { | 478 | to->sb_agblocks = cpu_to_be32(from->sb_agblocks); |
565 | memcpy(to_ptr + first, from_ptr + first, size); | 479 | to->sb_agcount = cpu_to_be32(from->sb_agcount); |
566 | } else { | 480 | to->sb_rbmblocks = cpu_to_be32(from->sb_rbmblocks); |
567 | switch (size) { | 481 | to->sb_logblocks = cpu_to_be32(from->sb_logblocks); |
568 | case 2: | 482 | to->sb_versionnum = cpu_to_be16(from->sb_versionnum); |
569 | *(__be16 *)(to_ptr + first) = | 483 | to->sb_sectsize = cpu_to_be16(from->sb_sectsize); |
570 | cpu_to_be16(*(__u16 *)(from_ptr + first)); | 484 | to->sb_inodesize = cpu_to_be16(from->sb_inodesize); |
571 | break; | 485 | to->sb_inopblock = cpu_to_be16(from->sb_inopblock); |
572 | case 4: | 486 | memcpy(&to->sb_fname, &from->sb_fname, sizeof(to->sb_fname)); |
573 | *(__be32 *)(to_ptr + first) = | 487 | to->sb_blocklog = from->sb_blocklog; |
574 | cpu_to_be32(*(__u32 *)(from_ptr + first)); | 488 | to->sb_sectlog = from->sb_sectlog; |
575 | break; | 489 | to->sb_inodelog = from->sb_inodelog; |
576 | case 8: | 490 | to->sb_inopblog = from->sb_inopblog; |
577 | *(__be64 *)(to_ptr + first) = | 491 | to->sb_agblklog = from->sb_agblklog; |
578 | cpu_to_be64(*(__u64 *)(from_ptr + first)); | 492 | to->sb_rextslog = from->sb_rextslog; |
579 | break; | 493 | to->sb_inprogress = from->sb_inprogress; |
580 | default: | 494 | to->sb_imax_pct = from->sb_imax_pct; |
581 | ASSERT(0); | 495 | to->sb_icount = cpu_to_be64(from->sb_icount); |
582 | } | 496 | to->sb_ifree = cpu_to_be64(from->sb_ifree); |
583 | } | 497 | to->sb_fdblocks = cpu_to_be64(from->sb_fdblocks); |
498 | to->sb_frextents = cpu_to_be64(from->sb_frextents); | ||
584 | 499 | ||
585 | fields &= ~(1LL << f); | 500 | to->sb_flags = from->sb_flags; |
501 | to->sb_shared_vn = from->sb_shared_vn; | ||
502 | to->sb_inoalignmt = cpu_to_be32(from->sb_inoalignmt); | ||
503 | to->sb_unit = cpu_to_be32(from->sb_unit); | ||
504 | to->sb_width = cpu_to_be32(from->sb_width); | ||
505 | to->sb_dirblklog = from->sb_dirblklog; | ||
506 | to->sb_logsectlog = from->sb_logsectlog; | ||
507 | to->sb_logsectsize = cpu_to_be16(from->sb_logsectsize); | ||
508 | to->sb_logsunit = cpu_to_be32(from->sb_logsunit); | ||
509 | |||
510 | /* | ||
511 | * We need to ensure that bad_features2 always matches features2. | ||
512 | * Hence we enforce that here rather than having to remember to do it | ||
513 | * everywhere else that updates features2. | ||
514 | */ | ||
515 | from->sb_bad_features2 = from->sb_features2; | ||
516 | to->sb_features2 = cpu_to_be32(from->sb_features2); | ||
517 | to->sb_bad_features2 = cpu_to_be32(from->sb_bad_features2); | ||
518 | |||
519 | if (xfs_sb_version_hascrc(from)) { | ||
520 | to->sb_features_compat = cpu_to_be32(from->sb_features_compat); | ||
521 | to->sb_features_ro_compat = | ||
522 | cpu_to_be32(from->sb_features_ro_compat); | ||
523 | to->sb_features_incompat = | ||
524 | cpu_to_be32(from->sb_features_incompat); | ||
525 | to->sb_features_log_incompat = | ||
526 | cpu_to_be32(from->sb_features_log_incompat); | ||
527 | to->sb_pad = 0; | ||
528 | to->sb_lsn = cpu_to_be64(from->sb_lsn); | ||
586 | } | 529 | } |
587 | } | 530 | } |
588 | 531 | ||
@@ -816,42 +759,51 @@ xfs_initialize_perag_data( | |||
816 | } | 759 | } |
817 | 760 | ||
818 | /* | 761 | /* |
819 | * xfs_mod_sb() can be used to copy arbitrary changes to the | 762 | * xfs_log_sb() can be used to copy arbitrary changes to the in-core superblock |
820 | * in-core superblock into the superblock buffer to be logged. | 763 | * into the superblock buffer to be logged. It does not provide the higher |
821 | * It does not provide the higher level of locking that is | 764 | * level of locking that is needed to protect the in-core superblock from |
822 | * needed to protect the in-core superblock from concurrent | 765 | * concurrent access. |
823 | * access. | ||
824 | */ | 766 | */ |
825 | void | 767 | void |
826 | xfs_mod_sb(xfs_trans_t *tp, __int64_t fields) | 768 | xfs_log_sb( |
769 | struct xfs_trans *tp) | ||
827 | { | 770 | { |
828 | xfs_buf_t *bp; | 771 | struct xfs_mount *mp = tp->t_mountp; |
829 | int first; | 772 | struct xfs_buf *bp = xfs_trans_getsb(tp, mp, 0); |
830 | int last; | ||
831 | xfs_mount_t *mp; | ||
832 | xfs_sb_field_t f; | ||
833 | |||
834 | ASSERT(fields); | ||
835 | if (!fields) | ||
836 | return; | ||
837 | mp = tp->t_mountp; | ||
838 | bp = xfs_trans_getsb(tp, mp, 0); | ||
839 | first = sizeof(xfs_sb_t); | ||
840 | last = 0; | ||
841 | |||
842 | /* translate/copy */ | ||
843 | 773 | ||
844 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb, fields); | 774 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb); |
775 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); | ||
776 | xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb)); | ||
777 | } | ||
845 | 778 | ||
846 | /* find modified range */ | 779 | /* |
847 | f = (xfs_sb_field_t)xfs_highbit64((__uint64_t)fields); | 780 | * xfs_sync_sb |
848 | ASSERT((1LL << f) & XFS_SB_MOD_BITS); | 781 | * |
849 | last = xfs_sb_info[f + 1].offset - 1; | 782 | * Sync the superblock to disk. |
783 | * | ||
784 | * Note that the caller is responsible for checking the frozen state of the | ||
785 | * filesystem. This procedure uses the non-blocking transaction allocator and | ||
786 | * thus will allow modifications to a frozen fs. This is required because this | ||
787 | * code can be called during the process of freezing where use of the high-level | ||
788 | * allocator would deadlock. | ||
789 | */ | ||
790 | int | ||
791 | xfs_sync_sb( | ||
792 | struct xfs_mount *mp, | ||
793 | bool wait) | ||
794 | { | ||
795 | struct xfs_trans *tp; | ||
796 | int error; | ||
850 | 797 | ||
851 | f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields); | 798 | tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_CHANGE, KM_SLEEP); |
852 | ASSERT((1LL << f) & XFS_SB_MOD_BITS); | 799 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0); |
853 | first = xfs_sb_info[f].offset; | 800 | if (error) { |
801 | xfs_trans_cancel(tp, 0); | ||
802 | return error; | ||
803 | } | ||
854 | 804 | ||
855 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); | 805 | xfs_log_sb(tp); |
856 | xfs_trans_log_buf(tp, bp, first, last); | 806 | if (wait) |
807 | xfs_trans_set_sync(tp); | ||
808 | return xfs_trans_commit(tp, 0); | ||
857 | } | 809 | } |
diff --git a/fs/xfs/libxfs/xfs_sb.h b/fs/xfs/libxfs/xfs_sb.h index 8eb1c54bafbf..b25bb9a343f3 100644 --- a/fs/xfs/libxfs/xfs_sb.h +++ b/fs/xfs/libxfs/xfs_sb.h | |||
@@ -27,11 +27,12 @@ extern struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *, xfs_agnumber_t, | |||
27 | extern void xfs_perag_put(struct xfs_perag *pag); | 27 | extern void xfs_perag_put(struct xfs_perag *pag); |
28 | extern int xfs_initialize_perag_data(struct xfs_mount *, xfs_agnumber_t); | 28 | extern int xfs_initialize_perag_data(struct xfs_mount *, xfs_agnumber_t); |
29 | 29 | ||
30 | extern void xfs_sb_calc_crc(struct xfs_buf *); | 30 | extern void xfs_sb_calc_crc(struct xfs_buf *bp); |
31 | extern void xfs_mod_sb(struct xfs_trans *, __int64_t); | 31 | extern void xfs_log_sb(struct xfs_trans *tp); |
32 | extern void xfs_sb_mount_common(struct xfs_mount *, struct xfs_sb *); | 32 | extern int xfs_sync_sb(struct xfs_mount *mp, bool wait); |
33 | extern void xfs_sb_from_disk(struct xfs_sb *, struct xfs_dsb *); | 33 | extern void xfs_sb_mount_common(struct xfs_mount *mp, struct xfs_sb *sbp); |
34 | extern void xfs_sb_to_disk(struct xfs_dsb *, struct xfs_sb *, __int64_t); | 34 | extern void xfs_sb_from_disk(struct xfs_sb *to, struct xfs_dsb *from); |
35 | extern void xfs_sb_to_disk(struct xfs_dsb *to, struct xfs_sb *from); | ||
35 | extern void xfs_sb_quota_from_disk(struct xfs_sb *sbp); | 36 | extern void xfs_sb_quota_from_disk(struct xfs_sb *sbp); |
36 | 37 | ||
37 | #endif /* __XFS_SB_H__ */ | 38 | #endif /* __XFS_SB_H__ */ |
diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index 82404da2ca67..8dda4b321343 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h | |||
@@ -82,7 +82,7 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; | |||
82 | #define XFS_TRANS_ATTR_RM 23 | 82 | #define XFS_TRANS_ATTR_RM 23 |
83 | #define XFS_TRANS_ATTR_FLAG 24 | 83 | #define XFS_TRANS_ATTR_FLAG 24 |
84 | #define XFS_TRANS_CLEAR_AGI_BUCKET 25 | 84 | #define XFS_TRANS_CLEAR_AGI_BUCKET 25 |
85 | #define XFS_TRANS_QM_SBCHANGE 26 | 85 | #define XFS_TRANS_SB_CHANGE 26 |
86 | /* | 86 | /* |
87 | * Dummy entries since we use the transaction type to index into the | 87 | * Dummy entries since we use the transaction type to index into the |
88 | * trans_type[] in xlog_recover_print_trans_head() | 88 | * trans_type[] in xlog_recover_print_trans_head() |
@@ -95,17 +95,15 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; | |||
95 | #define XFS_TRANS_QM_DQCLUSTER 32 | 95 | #define XFS_TRANS_QM_DQCLUSTER 32 |
96 | #define XFS_TRANS_QM_QINOCREATE 33 | 96 | #define XFS_TRANS_QM_QINOCREATE 33 |
97 | #define XFS_TRANS_QM_QUOTAOFF_END 34 | 97 | #define XFS_TRANS_QM_QUOTAOFF_END 34 |
98 | #define XFS_TRANS_SB_UNIT 35 | 98 | #define XFS_TRANS_FSYNC_TS 35 |
99 | #define XFS_TRANS_FSYNC_TS 36 | 99 | #define XFS_TRANS_GROWFSRT_ALLOC 36 |
100 | #define XFS_TRANS_GROWFSRT_ALLOC 37 | 100 | #define XFS_TRANS_GROWFSRT_ZERO 37 |
101 | #define XFS_TRANS_GROWFSRT_ZERO 38 | 101 | #define XFS_TRANS_GROWFSRT_FREE 38 |
102 | #define XFS_TRANS_GROWFSRT_FREE 39 | 102 | #define XFS_TRANS_SWAPEXT 39 |
103 | #define XFS_TRANS_SWAPEXT 40 | 103 | #define XFS_TRANS_CHECKPOINT 40 |
104 | #define XFS_TRANS_SB_COUNT 41 | 104 | #define XFS_TRANS_ICREATE 41 |
105 | #define XFS_TRANS_CHECKPOINT 42 | 105 | #define XFS_TRANS_CREATE_TMPFILE 42 |
106 | #define XFS_TRANS_ICREATE 43 | 106 | #define XFS_TRANS_TYPE_MAX 43 |
107 | #define XFS_TRANS_CREATE_TMPFILE 44 | ||
108 | #define XFS_TRANS_TYPE_MAX 44 | ||
109 | /* new transaction types need to be reflected in xfs_logprint(8) */ | 107 | /* new transaction types need to be reflected in xfs_logprint(8) */ |
110 | 108 | ||
111 | #define XFS_TRANS_TYPES \ | 109 | #define XFS_TRANS_TYPES \ |
@@ -113,7 +111,6 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; | |||
113 | { XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \ | 111 | { XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \ |
114 | { XFS_TRANS_INACTIVE, "INACTIVE" }, \ | 112 | { XFS_TRANS_INACTIVE, "INACTIVE" }, \ |
115 | { XFS_TRANS_CREATE, "CREATE" }, \ | 113 | { XFS_TRANS_CREATE, "CREATE" }, \ |
116 | { XFS_TRANS_CREATE_TMPFILE, "CREATE_TMPFILE" }, \ | ||
117 | { XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \ | 114 | { XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \ |
118 | { XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \ | 115 | { XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \ |
119 | { XFS_TRANS_REMOVE, "REMOVE" }, \ | 116 | { XFS_TRANS_REMOVE, "REMOVE" }, \ |
@@ -134,23 +131,23 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; | |||
134 | { XFS_TRANS_ATTR_RM, "ATTR_RM" }, \ | 131 | { XFS_TRANS_ATTR_RM, "ATTR_RM" }, \ |
135 | { XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \ | 132 | { XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \ |
136 | { XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \ | 133 | { XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \ |
137 | { XFS_TRANS_QM_SBCHANGE, "QM_SBCHANGE" }, \ | 134 | { XFS_TRANS_SB_CHANGE, "SBCHANGE" }, \ |
135 | { XFS_TRANS_DUMMY1, "DUMMY1" }, \ | ||
136 | { XFS_TRANS_DUMMY2, "DUMMY2" }, \ | ||
138 | { XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \ | 137 | { XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \ |
139 | { XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \ | 138 | { XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \ |
140 | { XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \ | 139 | { XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \ |
141 | { XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \ | 140 | { XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \ |
142 | { XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \ | 141 | { XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \ |
143 | { XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \ | 142 | { XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \ |
144 | { XFS_TRANS_SB_UNIT, "SB_UNIT" }, \ | ||
145 | { XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \ | 143 | { XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \ |
146 | { XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \ | 144 | { XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \ |
147 | { XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \ | 145 | { XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \ |
148 | { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \ | 146 | { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \ |
149 | { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \ | 147 | { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \ |
150 | { XFS_TRANS_SB_COUNT, "SB_COUNT" }, \ | ||
151 | { XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \ | 148 | { XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \ |
152 | { XFS_TRANS_DUMMY1, "DUMMY1" }, \ | 149 | { XFS_TRANS_ICREATE, "ICREATE" }, \ |
153 | { XFS_TRANS_DUMMY2, "DUMMY2" }, \ | 150 | { XFS_TRANS_CREATE_TMPFILE, "CREATE_TMPFILE" }, \ |
154 | { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" } | 151 | { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" } |
155 | 152 | ||
156 | /* | 153 | /* |
diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index 6c1330f29050..68cb1e7bf2bb 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c | |||
@@ -716,17 +716,6 @@ xfs_calc_clear_agi_bucket_reservation( | |||
716 | } | 716 | } |
717 | 717 | ||
718 | /* | 718 | /* |
719 | * Clearing the quotaflags in the superblock. | ||
720 | * the super block for changing quota flags: sector size | ||
721 | */ | ||
722 | STATIC uint | ||
723 | xfs_calc_qm_sbchange_reservation( | ||
724 | struct xfs_mount *mp) | ||
725 | { | ||
726 | return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); | ||
727 | } | ||
728 | |||
729 | /* | ||
730 | * Adjusting quota limits. | 719 | * Adjusting quota limits. |
731 | * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot) | 720 | * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot) |
732 | */ | 721 | */ |
@@ -864,9 +853,6 @@ xfs_trans_resv_calc( | |||
864 | * The following transactions are logged in logical format with | 853 | * The following transactions are logged in logical format with |
865 | * a default log count. | 854 | * a default log count. |
866 | */ | 855 | */ |
867 | resp->tr_qm_sbchange.tr_logres = xfs_calc_qm_sbchange_reservation(mp); | ||
868 | resp->tr_qm_sbchange.tr_logcount = XFS_DEFAULT_LOG_COUNT; | ||
869 | |||
870 | resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp); | 856 | resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp); |
871 | resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT; | 857 | resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT; |
872 | 858 | ||
diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h index 1097d14cd583..2d5bdfce6d8f 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.h +++ b/fs/xfs/libxfs/xfs_trans_resv.h | |||
@@ -56,7 +56,6 @@ struct xfs_trans_resv { | |||
56 | struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */ | 56 | struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */ |
57 | struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */ | 57 | struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */ |
58 | struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ | 58 | struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ |
59 | struct xfs_trans_res tr_qm_sbchange; /* change quota flags */ | ||
60 | struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ | 59 | struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ |
61 | struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ | 60 | struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ |
62 | struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */ | 61 | struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */ |
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index fdc64220fcb0..f7114527cd2f 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -541,7 +541,7 @@ xfs_growfs_data_private( | |||
541 | saved_error = error; | 541 | saved_error = error; |
542 | continue; | 542 | continue; |
543 | } | 543 | } |
544 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb, XFS_SB_ALL_BITS); | 544 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb); |
545 | 545 | ||
546 | error = xfs_bwrite(bp); | 546 | error = xfs_bwrite(bp); |
547 | xfs_buf_relse(bp); | 547 | xfs_buf_relse(bp); |
@@ -756,37 +756,6 @@ out: | |||
756 | return 0; | 756 | return 0; |
757 | } | 757 | } |
758 | 758 | ||
759 | /* | ||
760 | * Dump a transaction into the log that contains no real change. This is needed | ||
761 | * to be able to make the log dirty or stamp the current tail LSN into the log | ||
762 | * during the covering operation. | ||
763 | * | ||
764 | * We cannot use an inode here for this - that will push dirty state back up | ||
765 | * into the VFS and then periodic inode flushing will prevent log covering from | ||
766 | * making progress. Hence we log a field in the superblock instead and use a | ||
767 | * synchronous transaction to ensure the superblock is immediately unpinned | ||
768 | * and can be written back. | ||
769 | */ | ||
770 | int | ||
771 | xfs_fs_log_dummy( | ||
772 | xfs_mount_t *mp) | ||
773 | { | ||
774 | xfs_trans_t *tp; | ||
775 | int error; | ||
776 | |||
777 | tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1, KM_SLEEP); | ||
778 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0); | ||
779 | if (error) { | ||
780 | xfs_trans_cancel(tp, 0); | ||
781 | return error; | ||
782 | } | ||
783 | |||
784 | /* log the UUID because it is an unchanging field */ | ||
785 | xfs_mod_sb(tp, XFS_SB_UUID); | ||
786 | xfs_trans_set_sync(tp); | ||
787 | return xfs_trans_commit(tp, 0); | ||
788 | } | ||
789 | |||
790 | int | 759 | int |
791 | xfs_fs_goingdown( | 760 | xfs_fs_goingdown( |
792 | xfs_mount_t *mp, | 761 | xfs_mount_t *mp, |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 8fbbfb2d46e1..bcc7cfabb787 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "xfs_fsops.h" | 33 | #include "xfs_fsops.h" |
34 | #include "xfs_cksum.h" | 34 | #include "xfs_cksum.h" |
35 | #include "xfs_sysfs.h" | 35 | #include "xfs_sysfs.h" |
36 | #include "xfs_sb.h" | ||
36 | 37 | ||
37 | kmem_zone_t *xfs_log_ticket_zone; | 38 | kmem_zone_t *xfs_log_ticket_zone; |
38 | 39 | ||
@@ -1290,9 +1291,20 @@ xfs_log_worker( | |||
1290 | struct xfs_mount *mp = log->l_mp; | 1291 | struct xfs_mount *mp = log->l_mp; |
1291 | 1292 | ||
1292 | /* dgc: errors ignored - not fatal and nowhere to report them */ | 1293 | /* dgc: errors ignored - not fatal and nowhere to report them */ |
1293 | if (xfs_log_need_covered(mp)) | 1294 | if (xfs_log_need_covered(mp)) { |
1294 | xfs_fs_log_dummy(mp); | 1295 | /* |
1295 | else | 1296 | * Dump a transaction into the log that contains no real change. |
1297 | * This is needed to stamp the current tail LSN into the log | ||
1298 | * during the covering operation. | ||
1299 | * | ||
1300 | * We cannot use an inode here for this - that will push dirty | ||
1301 | * state back up into the VFS and then periodic inode flushing | ||
1302 | * will prevent log covering from making progress. Hence we | ||
1303 | * synchronously log the superblock instead to ensure the | ||
1304 | * superblock is immediately unpinned and can be written back. | ||
1305 | */ | ||
1306 | xfs_sync_sb(mp, true); | ||
1307 | } else | ||
1296 | xfs_log_force(mp, 0); | 1308 | xfs_log_force(mp, 0); |
1297 | 1309 | ||
1298 | /* start pushing all the metadata that is currently dirty */ | 1310 | /* start pushing all the metadata that is currently dirty */ |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 71d2c97cf58a..4fa80e63eea2 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -408,11 +408,11 @@ xfs_update_alignment(xfs_mount_t *mp) | |||
408 | if (xfs_sb_version_hasdalign(sbp)) { | 408 | if (xfs_sb_version_hasdalign(sbp)) { |
409 | if (sbp->sb_unit != mp->m_dalign) { | 409 | if (sbp->sb_unit != mp->m_dalign) { |
410 | sbp->sb_unit = mp->m_dalign; | 410 | sbp->sb_unit = mp->m_dalign; |
411 | mp->m_update_flags |= XFS_SB_UNIT; | 411 | mp->m_update_sb = true; |
412 | } | 412 | } |
413 | if (sbp->sb_width != mp->m_swidth) { | 413 | if (sbp->sb_width != mp->m_swidth) { |
414 | sbp->sb_width = mp->m_swidth; | 414 | sbp->sb_width = mp->m_swidth; |
415 | mp->m_update_flags |= XFS_SB_WIDTH; | 415 | mp->m_update_sb = true; |
416 | } | 416 | } |
417 | } else { | 417 | } else { |
418 | xfs_warn(mp, | 418 | xfs_warn(mp, |
@@ -583,38 +583,19 @@ int | |||
583 | xfs_mount_reset_sbqflags( | 583 | xfs_mount_reset_sbqflags( |
584 | struct xfs_mount *mp) | 584 | struct xfs_mount *mp) |
585 | { | 585 | { |
586 | int error; | ||
587 | struct xfs_trans *tp; | ||
588 | |||
589 | mp->m_qflags = 0; | 586 | mp->m_qflags = 0; |
590 | 587 | ||
591 | /* | 588 | /* It is OK to look at sb_qflags in the mount path without m_sb_lock. */ |
592 | * It is OK to look at sb_qflags here in mount path, | ||
593 | * without m_sb_lock. | ||
594 | */ | ||
595 | if (mp->m_sb.sb_qflags == 0) | 589 | if (mp->m_sb.sb_qflags == 0) |
596 | return 0; | 590 | return 0; |
597 | spin_lock(&mp->m_sb_lock); | 591 | spin_lock(&mp->m_sb_lock); |
598 | mp->m_sb.sb_qflags = 0; | 592 | mp->m_sb.sb_qflags = 0; |
599 | spin_unlock(&mp->m_sb_lock); | 593 | spin_unlock(&mp->m_sb_lock); |
600 | 594 | ||
601 | /* | 595 | if (!xfs_fs_writable(mp, SB_FREEZE_WRITE)) |
602 | * If the fs is readonly, let the incore superblock run | ||
603 | * with quotas off but don't flush the update out to disk | ||
604 | */ | ||
605 | if (mp->m_flags & XFS_MOUNT_RDONLY) | ||
606 | return 0; | 596 | return 0; |
607 | 597 | ||
608 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); | 598 | return xfs_sync_sb(mp, false); |
609 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_sbchange, 0, 0); | ||
610 | if (error) { | ||
611 | xfs_trans_cancel(tp, 0); | ||
612 | xfs_alert(mp, "%s: Superblock update failed!", __func__); | ||
613 | return error; | ||
614 | } | ||
615 | |||
616 | xfs_mod_sb(tp, XFS_SB_QFLAGS); | ||
617 | return xfs_trans_commit(tp, 0); | ||
618 | } | 599 | } |
619 | 600 | ||
620 | __uint64_t | 601 | __uint64_t |
@@ -659,26 +640,25 @@ xfs_mountfs( | |||
659 | xfs_sb_mount_common(mp, sbp); | 640 | xfs_sb_mount_common(mp, sbp); |
660 | 641 | ||
661 | /* | 642 | /* |
662 | * Check for a mismatched features2 values. Older kernels | 643 | * Check for a mismatched features2 values. Older kernels read & wrote |
663 | * read & wrote into the wrong sb offset for sb_features2 | 644 | * into the wrong sb offset for sb_features2 on some platforms due to |
664 | * on some platforms due to xfs_sb_t not being 64bit size aligned | 645 | * xfs_sb_t not being 64bit size aligned when sb_features2 was added, |
665 | * when sb_features2 was added, which made older superblock | 646 | * which made older superblock reading/writing routines swap it as a |
666 | * reading/writing routines swap it as a 64-bit value. | 647 | * 64-bit value. |
667 | * | 648 | * |
668 | * For backwards compatibility, we make both slots equal. | 649 | * For backwards compatibility, we make both slots equal. |
669 | * | 650 | * |
670 | * If we detect a mismatched field, we OR the set bits into the | 651 | * If we detect a mismatched field, we OR the set bits into the existing |
671 | * existing features2 field in case it has already been modified; we | 652 | * features2 field in case it has already been modified; we don't want |
672 | * don't want to lose any features. We then update the bad location | 653 | * to lose any features. We then update the bad location with the ORed |
673 | * with the ORed value so that older kernels will see any features2 | 654 | * value so that older kernels will see any features2 flags. The |
674 | * flags, and mark the two fields as needing updates once the | 655 | * superblock writeback code ensures the new sb_features2 is copied to |
675 | * transaction subsystem is online. | 656 | * sb_bad_features2 before it is logged or written to disk. |
676 | */ | 657 | */ |
677 | if (xfs_sb_has_mismatched_features2(sbp)) { | 658 | if (xfs_sb_has_mismatched_features2(sbp)) { |
678 | xfs_warn(mp, "correcting sb_features alignment problem"); | 659 | xfs_warn(mp, "correcting sb_features alignment problem"); |
679 | sbp->sb_features2 |= sbp->sb_bad_features2; | 660 | sbp->sb_features2 |= sbp->sb_bad_features2; |
680 | sbp->sb_bad_features2 = sbp->sb_features2; | 661 | mp->m_update_sb = true; |
681 | mp->m_update_flags |= XFS_SB_FEATURES2; | ||
682 | 662 | ||
683 | /* | 663 | /* |
684 | * Re-check for ATTR2 in case it was found in bad_features2 | 664 | * Re-check for ATTR2 in case it was found in bad_features2 |
@@ -692,17 +672,17 @@ xfs_mountfs( | |||
692 | if (xfs_sb_version_hasattr2(&mp->m_sb) && | 672 | if (xfs_sb_version_hasattr2(&mp->m_sb) && |
693 | (mp->m_flags & XFS_MOUNT_NOATTR2)) { | 673 | (mp->m_flags & XFS_MOUNT_NOATTR2)) { |
694 | xfs_sb_version_removeattr2(&mp->m_sb); | 674 | xfs_sb_version_removeattr2(&mp->m_sb); |
695 | mp->m_update_flags |= XFS_SB_FEATURES2; | 675 | mp->m_update_sb = true; |
696 | 676 | ||
697 | /* update sb_versionnum for the clearing of the morebits */ | 677 | /* update sb_versionnum for the clearing of the morebits */ |
698 | if (!sbp->sb_features2) | 678 | if (!sbp->sb_features2) |
699 | mp->m_update_flags |= XFS_SB_VERSIONNUM; | 679 | mp->m_update_sb = true; |
700 | } | 680 | } |
701 | 681 | ||
702 | /* always use v2 inodes by default now */ | 682 | /* always use v2 inodes by default now */ |
703 | if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)) { | 683 | if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)) { |
704 | mp->m_sb.sb_versionnum |= XFS_SB_VERSION_NLINKBIT; | 684 | mp->m_sb.sb_versionnum |= XFS_SB_VERSION_NLINKBIT; |
705 | mp->m_update_flags |= XFS_SB_VERSIONNUM; | 685 | mp->m_update_sb = true; |
706 | } | 686 | } |
707 | 687 | ||
708 | /* | 688 | /* |
@@ -895,8 +875,8 @@ xfs_mountfs( | |||
895 | * the next remount into writeable mode. Otherwise we would never | 875 | * the next remount into writeable mode. Otherwise we would never |
896 | * perform the update e.g. for the root filesystem. | 876 | * perform the update e.g. for the root filesystem. |
897 | */ | 877 | */ |
898 | if (mp->m_update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY)) { | 878 | if (mp->m_update_sb && !(mp->m_flags & XFS_MOUNT_RDONLY)) { |
899 | error = xfs_mount_log_sb(mp, mp->m_update_flags); | 879 | error = xfs_sync_sb(mp, false); |
900 | if (error) { | 880 | if (error) { |
901 | xfs_warn(mp, "failed to write sb changes"); | 881 | xfs_warn(mp, "failed to write sb changes"); |
902 | goto out_rtunmount; | 882 | goto out_rtunmount; |
@@ -1103,9 +1083,6 @@ xfs_fs_writable( | |||
1103 | int | 1083 | int |
1104 | xfs_log_sbcount(xfs_mount_t *mp) | 1084 | xfs_log_sbcount(xfs_mount_t *mp) |
1105 | { | 1085 | { |
1106 | xfs_trans_t *tp; | ||
1107 | int error; | ||
1108 | |||
1109 | /* allow this to proceed during the freeze sequence... */ | 1086 | /* allow this to proceed during the freeze sequence... */ |
1110 | if (!xfs_fs_writable(mp, SB_FREEZE_COMPLETE)) | 1087 | if (!xfs_fs_writable(mp, SB_FREEZE_COMPLETE)) |
1111 | return 0; | 1088 | return 0; |
@@ -1119,17 +1096,7 @@ xfs_log_sbcount(xfs_mount_t *mp) | |||
1119 | if (!xfs_sb_version_haslazysbcount(&mp->m_sb)) | 1096 | if (!xfs_sb_version_haslazysbcount(&mp->m_sb)) |
1120 | return 0; | 1097 | return 0; |
1121 | 1098 | ||
1122 | tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_COUNT, KM_SLEEP); | 1099 | return xfs_sync_sb(mp, true); |
1123 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0); | ||
1124 | if (error) { | ||
1125 | xfs_trans_cancel(tp, 0); | ||
1126 | return error; | ||
1127 | } | ||
1128 | |||
1129 | xfs_mod_sb(tp, XFS_SB_IFREE | XFS_SB_ICOUNT | XFS_SB_FDBLOCKS); | ||
1130 | xfs_trans_set_sync(tp); | ||
1131 | error = xfs_trans_commit(tp, 0); | ||
1132 | return error; | ||
1133 | } | 1100 | } |
1134 | 1101 | ||
1135 | /* | 1102 | /* |
@@ -1423,33 +1390,6 @@ xfs_freesb( | |||
1423 | } | 1390 | } |
1424 | 1391 | ||
1425 | /* | 1392 | /* |
1426 | * Used to log changes to the superblock unit and width fields which could | ||
1427 | * be altered by the mount options, as well as any potential sb_features2 | ||
1428 | * fixup. Only the first superblock is updated. | ||
1429 | */ | ||
1430 | int | ||
1431 | xfs_mount_log_sb( | ||
1432 | xfs_mount_t *mp, | ||
1433 | __int64_t fields) | ||
1434 | { | ||
1435 | xfs_trans_t *tp; | ||
1436 | int error; | ||
1437 | |||
1438 | ASSERT(fields & (XFS_SB_UNIT | XFS_SB_WIDTH | XFS_SB_UUID | | ||
1439 | XFS_SB_FEATURES2 | XFS_SB_VERSIONNUM)); | ||
1440 | |||
1441 | tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT); | ||
1442 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0); | ||
1443 | if (error) { | ||
1444 | xfs_trans_cancel(tp, 0); | ||
1445 | return error; | ||
1446 | } | ||
1447 | xfs_mod_sb(tp, fields); | ||
1448 | error = xfs_trans_commit(tp, 0); | ||
1449 | return error; | ||
1450 | } | ||
1451 | |||
1452 | /* | ||
1453 | * If the underlying (data/log/rt) device is readonly, there are some | 1393 | * If the underlying (data/log/rt) device is readonly, there are some |
1454 | * operations that cannot proceed. | 1394 | * operations that cannot proceed. |
1455 | */ | 1395 | */ |
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 22ccf69d4d3c..a5b2ff822653 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h | |||
@@ -162,8 +162,7 @@ typedef struct xfs_mount { | |||
162 | struct delayed_work m_reclaim_work; /* background inode reclaim */ | 162 | struct delayed_work m_reclaim_work; /* background inode reclaim */ |
163 | struct delayed_work m_eofblocks_work; /* background eof blocks | 163 | struct delayed_work m_eofblocks_work; /* background eof blocks |
164 | trimming */ | 164 | trimming */ |
165 | __int64_t m_update_flags; /* sb flags we need to update | 165 | bool m_update_sb; /* sb needs update in mount */ |
166 | on the next remount,rw */ | ||
167 | int64_t m_low_space[XFS_LOWSP_MAX]; | 166 | int64_t m_low_space[XFS_LOWSP_MAX]; |
168 | /* low free space thresholds */ | 167 | /* low free space thresholds */ |
169 | struct xfs_kobj m_kobj; | 168 | struct xfs_kobj m_kobj; |
@@ -378,7 +377,7 @@ extern void xfs_unmountfs(xfs_mount_t *); | |||
378 | extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int64_t, int); | 377 | extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int64_t, int); |
379 | extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, | 378 | extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, |
380 | uint, int); | 379 | uint, int); |
381 | extern int xfs_mount_log_sb(xfs_mount_t *, __int64_t); | 380 | extern int xfs_mount_log_sb(xfs_mount_t *); |
382 | extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); | 381 | extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); |
383 | extern int xfs_readsb(xfs_mount_t *, int); | 382 | extern int xfs_readsb(xfs_mount_t *, int); |
384 | extern void xfs_freesb(xfs_mount_t *); | 383 | extern void xfs_freesb(xfs_mount_t *); |
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 79fb19dd9c83..3e8186279541 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c | |||
@@ -714,7 +714,6 @@ STATIC int | |||
714 | xfs_qm_qino_alloc( | 714 | xfs_qm_qino_alloc( |
715 | xfs_mount_t *mp, | 715 | xfs_mount_t *mp, |
716 | xfs_inode_t **ip, | 716 | xfs_inode_t **ip, |
717 | __int64_t sbfields, | ||
718 | uint flags) | 717 | uint flags) |
719 | { | 718 | { |
720 | xfs_trans_t *tp; | 719 | xfs_trans_t *tp; |
@@ -777,11 +776,6 @@ xfs_qm_qino_alloc( | |||
777 | spin_lock(&mp->m_sb_lock); | 776 | spin_lock(&mp->m_sb_lock); |
778 | if (flags & XFS_QMOPT_SBVERSION) { | 777 | if (flags & XFS_QMOPT_SBVERSION) { |
779 | ASSERT(!xfs_sb_version_hasquota(&mp->m_sb)); | 778 | ASSERT(!xfs_sb_version_hasquota(&mp->m_sb)); |
780 | ASSERT((sbfields & (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | | ||
781 | XFS_SB_GQUOTINO | XFS_SB_PQUOTINO | XFS_SB_QFLAGS)) == | ||
782 | (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | | ||
783 | XFS_SB_GQUOTINO | XFS_SB_PQUOTINO | | ||
784 | XFS_SB_QFLAGS)); | ||
785 | 779 | ||
786 | xfs_sb_version_addquota(&mp->m_sb); | 780 | xfs_sb_version_addquota(&mp->m_sb); |
787 | mp->m_sb.sb_uquotino = NULLFSINO; | 781 | mp->m_sb.sb_uquotino = NULLFSINO; |
@@ -798,7 +792,7 @@ xfs_qm_qino_alloc( | |||
798 | else | 792 | else |
799 | mp->m_sb.sb_pquotino = (*ip)->i_ino; | 793 | mp->m_sb.sb_pquotino = (*ip)->i_ino; |
800 | spin_unlock(&mp->m_sb_lock); | 794 | spin_unlock(&mp->m_sb_lock); |
801 | xfs_mod_sb(tp, sbfields); | 795 | xfs_log_sb(tp); |
802 | 796 | ||
803 | if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES))) { | 797 | if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES))) { |
804 | xfs_alert(mp, "%s failed (error %d)!", __func__, error); | 798 | xfs_alert(mp, "%s failed (error %d)!", __func__, error); |
@@ -1451,7 +1445,7 @@ xfs_qm_mount_quotas( | |||
1451 | spin_unlock(&mp->m_sb_lock); | 1445 | spin_unlock(&mp->m_sb_lock); |
1452 | 1446 | ||
1453 | if (sbf != (mp->m_qflags & XFS_MOUNT_QUOTA_ALL)) { | 1447 | if (sbf != (mp->m_qflags & XFS_MOUNT_QUOTA_ALL)) { |
1454 | if (xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS)) { | 1448 | if (xfs_sync_sb(mp, false)) { |
1455 | /* | 1449 | /* |
1456 | * We could only have been turning quotas off. | 1450 | * We could only have been turning quotas off. |
1457 | * We aren't in very good shape actually because | 1451 | * We aren't in very good shape actually because |
@@ -1482,7 +1476,6 @@ xfs_qm_init_quotainos( | |||
1482 | struct xfs_inode *gip = NULL; | 1476 | struct xfs_inode *gip = NULL; |
1483 | struct xfs_inode *pip = NULL; | 1477 | struct xfs_inode *pip = NULL; |
1484 | int error; | 1478 | int error; |
1485 | __int64_t sbflags = 0; | ||
1486 | uint flags = 0; | 1479 | uint flags = 0; |
1487 | 1480 | ||
1488 | ASSERT(mp->m_quotainfo); | 1481 | ASSERT(mp->m_quotainfo); |
@@ -1517,9 +1510,6 @@ xfs_qm_init_quotainos( | |||
1517 | } | 1510 | } |
1518 | } else { | 1511 | } else { |
1519 | flags |= XFS_QMOPT_SBVERSION; | 1512 | flags |= XFS_QMOPT_SBVERSION; |
1520 | sbflags |= (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | | ||
1521 | XFS_SB_GQUOTINO | XFS_SB_PQUOTINO | | ||
1522 | XFS_SB_QFLAGS); | ||
1523 | } | 1513 | } |
1524 | 1514 | ||
1525 | /* | 1515 | /* |
@@ -1530,7 +1520,6 @@ xfs_qm_init_quotainos( | |||
1530 | */ | 1520 | */ |
1531 | if (XFS_IS_UQUOTA_ON(mp) && uip == NULL) { | 1521 | if (XFS_IS_UQUOTA_ON(mp) && uip == NULL) { |
1532 | error = xfs_qm_qino_alloc(mp, &uip, | 1522 | error = xfs_qm_qino_alloc(mp, &uip, |
1533 | sbflags | XFS_SB_UQUOTINO, | ||
1534 | flags | XFS_QMOPT_UQUOTA); | 1523 | flags | XFS_QMOPT_UQUOTA); |
1535 | if (error) | 1524 | if (error) |
1536 | goto error_rele; | 1525 | goto error_rele; |
@@ -1539,7 +1528,6 @@ xfs_qm_init_quotainos( | |||
1539 | } | 1528 | } |
1540 | if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) { | 1529 | if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) { |
1541 | error = xfs_qm_qino_alloc(mp, &gip, | 1530 | error = xfs_qm_qino_alloc(mp, &gip, |
1542 | sbflags | XFS_SB_GQUOTINO, | ||
1543 | flags | XFS_QMOPT_GQUOTA); | 1531 | flags | XFS_QMOPT_GQUOTA); |
1544 | if (error) | 1532 | if (error) |
1545 | goto error_rele; | 1533 | goto error_rele; |
@@ -1548,7 +1536,6 @@ xfs_qm_init_quotainos( | |||
1548 | } | 1536 | } |
1549 | if (XFS_IS_PQUOTA_ON(mp) && pip == NULL) { | 1537 | if (XFS_IS_PQUOTA_ON(mp) && pip == NULL) { |
1550 | error = xfs_qm_qino_alloc(mp, &pip, | 1538 | error = xfs_qm_qino_alloc(mp, &pip, |
1551 | sbflags | XFS_SB_PQUOTINO, | ||
1552 | flags | XFS_QMOPT_PQUOTA); | 1539 | flags | XFS_QMOPT_PQUOTA); |
1553 | if (error) | 1540 | if (error) |
1554 | goto error_rele; | 1541 | goto error_rele; |
@@ -1587,32 +1574,6 @@ xfs_qm_dqfree_one( | |||
1587 | xfs_qm_dqdestroy(dqp); | 1574 | xfs_qm_dqdestroy(dqp); |
1588 | } | 1575 | } |
1589 | 1576 | ||
1590 | /* | ||
1591 | * Start a transaction and write the incore superblock changes to | ||
1592 | * disk. flags parameter indicates which fields have changed. | ||
1593 | */ | ||
1594 | int | ||
1595 | xfs_qm_write_sb_changes( | ||
1596 | xfs_mount_t *mp, | ||
1597 | __int64_t flags) | ||
1598 | { | ||
1599 | xfs_trans_t *tp; | ||
1600 | int error; | ||
1601 | |||
1602 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); | ||
1603 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_sbchange, 0, 0); | ||
1604 | if (error) { | ||
1605 | xfs_trans_cancel(tp, 0); | ||
1606 | return error; | ||
1607 | } | ||
1608 | |||
1609 | xfs_mod_sb(tp, flags); | ||
1610 | error = xfs_trans_commit(tp, 0); | ||
1611 | |||
1612 | return error; | ||
1613 | } | ||
1614 | |||
1615 | |||
1616 | /* --------------- utility functions for vnodeops ---------------- */ | 1577 | /* --------------- utility functions for vnodeops ---------------- */ |
1617 | 1578 | ||
1618 | 1579 | ||
diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index 3a07a937e232..d6e4d88094ab 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h | |||
@@ -157,7 +157,6 @@ struct xfs_dquot_acct { | |||
157 | #define XFS_QM_RTBWARNLIMIT 5 | 157 | #define XFS_QM_RTBWARNLIMIT 5 |
158 | 158 | ||
159 | extern void xfs_qm_destroy_quotainfo(struct xfs_mount *); | 159 | extern void xfs_qm_destroy_quotainfo(struct xfs_mount *); |
160 | extern int xfs_qm_write_sb_changes(struct xfs_mount *, __int64_t); | ||
161 | 160 | ||
162 | /* dquot stuff */ | 161 | /* dquot stuff */ |
163 | extern void xfs_qm_dqpurge_all(struct xfs_mount *, uint); | 162 | extern void xfs_qm_dqpurge_all(struct xfs_mount *, uint); |
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index 74fca68e43b6..b8a565edb4ae 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c | |||
@@ -92,8 +92,7 @@ xfs_qm_scall_quotaoff( | |||
92 | mutex_unlock(&q->qi_quotaofflock); | 92 | mutex_unlock(&q->qi_quotaofflock); |
93 | 93 | ||
94 | /* XXX what to do if error ? Revert back to old vals incore ? */ | 94 | /* XXX what to do if error ? Revert back to old vals incore ? */ |
95 | error = xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS); | 95 | return xfs_sync_sb(mp, false); |
96 | return error; | ||
97 | } | 96 | } |
98 | 97 | ||
99 | dqtype = 0; | 98 | dqtype = 0; |
@@ -314,7 +313,6 @@ xfs_qm_scall_quotaon( | |||
314 | { | 313 | { |
315 | int error; | 314 | int error; |
316 | uint qf; | 315 | uint qf; |
317 | __int64_t sbflags; | ||
318 | 316 | ||
319 | flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD); | 317 | flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD); |
320 | /* | 318 | /* |
@@ -322,8 +320,6 @@ xfs_qm_scall_quotaon( | |||
322 | */ | 320 | */ |
323 | flags &= ~(XFS_ALL_QUOTA_ACCT); | 321 | flags &= ~(XFS_ALL_QUOTA_ACCT); |
324 | 322 | ||
325 | sbflags = 0; | ||
326 | |||
327 | if (flags == 0) { | 323 | if (flags == 0) { |
328 | xfs_debug(mp, "%s: zero flags, m_qflags=%x", | 324 | xfs_debug(mp, "%s: zero flags, m_qflags=%x", |
329 | __func__, mp->m_qflags); | 325 | __func__, mp->m_qflags); |
@@ -370,11 +366,11 @@ xfs_qm_scall_quotaon( | |||
370 | /* | 366 | /* |
371 | * There's nothing to change if it's the same. | 367 | * There's nothing to change if it's the same. |
372 | */ | 368 | */ |
373 | if ((qf & flags) == flags && sbflags == 0) | 369 | if ((qf & flags) == flags) |
374 | return -EEXIST; | 370 | return -EEXIST; |
375 | sbflags |= XFS_SB_QFLAGS; | ||
376 | 371 | ||
377 | if ((error = xfs_qm_write_sb_changes(mp, sbflags))) | 372 | error = xfs_sync_sb(mp, false); |
373 | if (error) | ||
378 | return error; | 374 | return error; |
379 | /* | 375 | /* |
380 | * If we aren't trying to switch on quota enforcement, we are done. | 376 | * If we aren't trying to switch on quota enforcement, we are done. |
@@ -801,7 +797,7 @@ xfs_qm_log_quotaoff( | |||
801 | mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; | 797 | mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; |
802 | spin_unlock(&mp->m_sb_lock); | 798 | spin_unlock(&mp->m_sb_lock); |
803 | 799 | ||
804 | xfs_mod_sb(tp, XFS_SB_QFLAGS); | 800 | xfs_log_sb(tp); |
805 | 801 | ||
806 | /* | 802 | /* |
807 | * We have to make sure that the transaction is secure on disk before we | 803 | * We have to make sure that the transaction is secure on disk before we |
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 22e6acaa0320..5ce76d01885d 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -1257,13 +1257,13 @@ xfs_fs_remount( | |||
1257 | * If this is the first remount to writeable state we | 1257 | * If this is the first remount to writeable state we |
1258 | * might have some superblock changes to update. | 1258 | * might have some superblock changes to update. |
1259 | */ | 1259 | */ |
1260 | if (mp->m_update_flags) { | 1260 | if (mp->m_update_sb) { |
1261 | error = xfs_mount_log_sb(mp, mp->m_update_flags); | 1261 | error = xfs_sync_sb(mp, false); |
1262 | if (error) { | 1262 | if (error) { |
1263 | xfs_warn(mp, "failed to write sb changes"); | 1263 | xfs_warn(mp, "failed to write sb changes"); |
1264 | return error; | 1264 | return error; |
1265 | } | 1265 | } |
1266 | mp->m_update_flags = 0; | 1266 | mp->m_update_sb = false; |
1267 | } | 1267 | } |
1268 | 1268 | ||
1269 | /* | 1269 | /* |
@@ -1293,8 +1293,9 @@ xfs_fs_remount( | |||
1293 | 1293 | ||
1294 | /* | 1294 | /* |
1295 | * Second stage of a freeze. The data is already frozen so we only | 1295 | * Second stage of a freeze. The data is already frozen so we only |
1296 | * need to take care of the metadata. Once that's done write a dummy | 1296 | * need to take care of the metadata. Once that's done sync the superblock |
1297 | * record to dirty the log in case of a crash while frozen. | 1297 | * to the log to dirty it in case of a crash while frozen. This ensures that we |
1298 | * will recover the unlinked inode lists on the next mount. | ||
1298 | */ | 1299 | */ |
1299 | STATIC int | 1300 | STATIC int |
1300 | xfs_fs_freeze( | 1301 | xfs_fs_freeze( |
@@ -1304,7 +1305,7 @@ xfs_fs_freeze( | |||
1304 | 1305 | ||
1305 | xfs_save_resvblks(mp); | 1306 | xfs_save_resvblks(mp); |
1306 | xfs_quiesce_attr(mp); | 1307 | xfs_quiesce_attr(mp); |
1307 | return xfs_fs_log_dummy(mp); | 1308 | return xfs_sync_sb(mp, true); |
1308 | } | 1309 | } |
1309 | 1310 | ||
1310 | STATIC int | 1311 | STATIC int |