Commit 465e2def authored by Dave Chinner's avatar Dave Chinner

Merge branch 'xfs-sb-logging-rework' into for-next

Conflicts:
	fs/xfs/xfs_mount.c
parents 6bcf0939 074e427b
...@@ -403,7 +403,7 @@ xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp) ...@@ -403,7 +403,7 @@ xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
if (!xfs_sb_version_hasattr2(&mp->m_sb)) { if (!xfs_sb_version_hasattr2(&mp->m_sb)) {
xfs_sb_version_addattr2(&mp->m_sb); xfs_sb_version_addattr2(&mp->m_sb);
spin_unlock(&mp->m_sb_lock); spin_unlock(&mp->m_sb_lock);
xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); xfs_log_sb(tp);
} else } else
spin_unlock(&mp->m_sb_lock); spin_unlock(&mp->m_sb_lock);
} }
......
...@@ -1221,22 +1221,20 @@ xfs_bmap_add_attrfork( ...@@ -1221,22 +1221,20 @@ xfs_bmap_add_attrfork(
goto bmap_cancel; goto bmap_cancel;
if (!xfs_sb_version_hasattr(&mp->m_sb) || if (!xfs_sb_version_hasattr(&mp->m_sb) ||
(!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) { (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) {
__int64_t sbfields = 0; bool log_sb = false;
spin_lock(&mp->m_sb_lock); spin_lock(&mp->m_sb_lock);
if (!xfs_sb_version_hasattr(&mp->m_sb)) { if (!xfs_sb_version_hasattr(&mp->m_sb)) {
xfs_sb_version_addattr(&mp->m_sb); xfs_sb_version_addattr(&mp->m_sb);
sbfields |= XFS_SB_VERSIONNUM; log_sb = true;
} }
if (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2) { if (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2) {
xfs_sb_version_addattr2(&mp->m_sb); xfs_sb_version_addattr2(&mp->m_sb);
sbfields |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); log_sb = true;
} }
if (sbfields) { spin_unlock(&mp->m_sb_lock);
spin_unlock(&mp->m_sb_lock); if (log_sb)
xfs_mod_sb(tp, sbfields); xfs_log_sb(tp);
} else
spin_unlock(&mp->m_sb_lock);
} }
error = xfs_bmap_finish(&tp, &flist, &committed); error = xfs_bmap_finish(&tp, &flist, &committed);
......
...@@ -151,10 +151,13 @@ typedef struct xfs_sb { ...@@ -151,10 +151,13 @@ typedef struct xfs_sb {
__uint32_t sb_features2; /* additional feature bits */ __uint32_t sb_features2; /* additional feature bits */
/* /*
* bad features2 field as a result of failing to pad the sb * bad features2 field as a result of failing to pad the sb structure to
* structure to 64 bits. Some machines will be using this field * 64 bits. Some machines will be using this field for features2 bits.
* for features2 bits. Easiest just to mark it bad and not use * Easiest just to mark it bad and not use it for anything else.
* it for anything else. *
* This is not kept up to date in memory; it is always overwritten by
* the value in sb_features2 when formatting the incore superblock to
* the disk buffer.
*/ */
__uint32_t sb_bad_features2; __uint32_t sb_bad_features2;
...@@ -453,13 +456,11 @@ static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) ...@@ -453,13 +456,11 @@ static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp)
{ {
sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT;
sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT;
sbp->sb_bad_features2 |= XFS_SB_VERSION2_ATTR2BIT;
} }
static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp)
{ {
sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT;
sbp->sb_bad_features2 &= ~XFS_SB_VERSION2_ATTR2BIT;
if (!sbp->sb_features2) if (!sbp->sb_features2)
sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT;
} }
...@@ -475,7 +476,6 @@ static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp) ...@@ -475,7 +476,6 @@ static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp)
{ {
sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT;
sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT;
sbp->sb_bad_features2 |= XFS_SB_VERSION2_PROJID32BIT;
} }
/* /*
......
This diff is collapsed.
...@@ -27,11 +27,12 @@ extern struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *, xfs_agnumber_t, ...@@ -27,11 +27,12 @@ extern struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *, xfs_agnumber_t,
extern void xfs_perag_put(struct xfs_perag *pag); extern void xfs_perag_put(struct xfs_perag *pag);
extern int xfs_initialize_perag_data(struct xfs_mount *, xfs_agnumber_t); extern int xfs_initialize_perag_data(struct xfs_mount *, xfs_agnumber_t);
extern void xfs_sb_calc_crc(struct xfs_buf *); extern void xfs_sb_calc_crc(struct xfs_buf *bp);
extern void xfs_mod_sb(struct xfs_trans *, __int64_t); extern void xfs_log_sb(struct xfs_trans *tp);
extern void xfs_sb_mount_common(struct xfs_mount *, struct xfs_sb *); extern int xfs_sync_sb(struct xfs_mount *mp, bool wait);
extern void xfs_sb_from_disk(struct xfs_sb *, struct xfs_dsb *); extern void xfs_sb_mount_common(struct xfs_mount *mp, struct xfs_sb *sbp);
extern void xfs_sb_to_disk(struct xfs_dsb *, struct xfs_sb *, __int64_t); extern void xfs_sb_from_disk(struct xfs_sb *to, struct xfs_dsb *from);
extern void xfs_sb_to_disk(struct xfs_dsb *to, struct xfs_sb *from);
extern void xfs_sb_quota_from_disk(struct xfs_sb *sbp); extern void xfs_sb_quota_from_disk(struct xfs_sb *sbp);
#endif /* __XFS_SB_H__ */ #endif /* __XFS_SB_H__ */
...@@ -82,7 +82,7 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; ...@@ -82,7 +82,7 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops;
#define XFS_TRANS_ATTR_RM 23 #define XFS_TRANS_ATTR_RM 23
#define XFS_TRANS_ATTR_FLAG 24 #define XFS_TRANS_ATTR_FLAG 24
#define XFS_TRANS_CLEAR_AGI_BUCKET 25 #define XFS_TRANS_CLEAR_AGI_BUCKET 25
#define XFS_TRANS_QM_SBCHANGE 26 #define XFS_TRANS_SB_CHANGE 26
/* /*
* Dummy entries since we use the transaction type to index into the * Dummy entries since we use the transaction type to index into the
* trans_type[] in xlog_recover_print_trans_head() * trans_type[] in xlog_recover_print_trans_head()
...@@ -95,17 +95,15 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; ...@@ -95,17 +95,15 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops;
#define XFS_TRANS_QM_DQCLUSTER 32 #define XFS_TRANS_QM_DQCLUSTER 32
#define XFS_TRANS_QM_QINOCREATE 33 #define XFS_TRANS_QM_QINOCREATE 33
#define XFS_TRANS_QM_QUOTAOFF_END 34 #define XFS_TRANS_QM_QUOTAOFF_END 34
#define XFS_TRANS_SB_UNIT 35 #define XFS_TRANS_FSYNC_TS 35
#define XFS_TRANS_FSYNC_TS 36 #define XFS_TRANS_GROWFSRT_ALLOC 36
#define XFS_TRANS_GROWFSRT_ALLOC 37 #define XFS_TRANS_GROWFSRT_ZERO 37
#define XFS_TRANS_GROWFSRT_ZERO 38 #define XFS_TRANS_GROWFSRT_FREE 38
#define XFS_TRANS_GROWFSRT_FREE 39 #define XFS_TRANS_SWAPEXT 39
#define XFS_TRANS_SWAPEXT 40 #define XFS_TRANS_CHECKPOINT 40
#define XFS_TRANS_SB_COUNT 41 #define XFS_TRANS_ICREATE 41
#define XFS_TRANS_CHECKPOINT 42 #define XFS_TRANS_CREATE_TMPFILE 42
#define XFS_TRANS_ICREATE 43 #define XFS_TRANS_TYPE_MAX 43
#define XFS_TRANS_CREATE_TMPFILE 44
#define XFS_TRANS_TYPE_MAX 44
/* new transaction types need to be reflected in xfs_logprint(8) */ /* new transaction types need to be reflected in xfs_logprint(8) */
#define XFS_TRANS_TYPES \ #define XFS_TRANS_TYPES \
...@@ -113,7 +111,6 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; ...@@ -113,7 +111,6 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops;
{ XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \ { XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \
{ XFS_TRANS_INACTIVE, "INACTIVE" }, \ { XFS_TRANS_INACTIVE, "INACTIVE" }, \
{ XFS_TRANS_CREATE, "CREATE" }, \ { XFS_TRANS_CREATE, "CREATE" }, \
{ XFS_TRANS_CREATE_TMPFILE, "CREATE_TMPFILE" }, \
{ XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \ { XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \
{ XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \ { XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \
{ XFS_TRANS_REMOVE, "REMOVE" }, \ { XFS_TRANS_REMOVE, "REMOVE" }, \
...@@ -134,23 +131,23 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; ...@@ -134,23 +131,23 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops;
{ XFS_TRANS_ATTR_RM, "ATTR_RM" }, \ { XFS_TRANS_ATTR_RM, "ATTR_RM" }, \
{ XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \ { XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \
{ XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \ { XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \
{ XFS_TRANS_QM_SBCHANGE, "QM_SBCHANGE" }, \ { XFS_TRANS_SB_CHANGE, "SBCHANGE" }, \
{ XFS_TRANS_DUMMY1, "DUMMY1" }, \
{ XFS_TRANS_DUMMY2, "DUMMY2" }, \
{ XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \ { XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \
{ XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \ { XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \
{ XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \ { XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \
{ XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \ { XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \
{ XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \ { XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \
{ XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \ { XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \
{ XFS_TRANS_SB_UNIT, "SB_UNIT" }, \
{ XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \ { XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \
{ XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \ { XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \
{ XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \ { XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \
{ XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \ { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \
{ XFS_TRANS_SWAPEXT, "SWAPEXT" }, \ { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \
{ XFS_TRANS_SB_COUNT, "SB_COUNT" }, \
{ XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \ { XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \
{ XFS_TRANS_DUMMY1, "DUMMY1" }, \ { XFS_TRANS_ICREATE, "ICREATE" }, \
{ XFS_TRANS_DUMMY2, "DUMMY2" }, \ { XFS_TRANS_CREATE_TMPFILE, "CREATE_TMPFILE" }, \
{ XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" } { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" }
/* /*
......
...@@ -715,17 +715,6 @@ xfs_calc_clear_agi_bucket_reservation( ...@@ -715,17 +715,6 @@ xfs_calc_clear_agi_bucket_reservation(
return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
} }
/*
* Clearing the quotaflags in the superblock.
* the super block for changing quota flags: sector size
*/
STATIC uint
xfs_calc_qm_sbchange_reservation(
struct xfs_mount *mp)
{
return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
}
/* /*
* Adjusting quota limits. * Adjusting quota limits.
* the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot) * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot)
...@@ -864,9 +853,6 @@ xfs_trans_resv_calc( ...@@ -864,9 +853,6 @@ xfs_trans_resv_calc(
* The following transactions are logged in logical format with * The following transactions are logged in logical format with
* a default log count. * a default log count.
*/ */
resp->tr_qm_sbchange.tr_logres = xfs_calc_qm_sbchange_reservation(mp);
resp->tr_qm_sbchange.tr_logcount = XFS_DEFAULT_LOG_COUNT;
resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp); resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp);
resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT; resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT;
......
...@@ -56,7 +56,6 @@ struct xfs_trans_resv { ...@@ -56,7 +56,6 @@ struct xfs_trans_resv {
struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */ struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */
struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */ struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */
struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */
struct xfs_trans_res tr_qm_sbchange; /* change quota flags */
struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */
struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */
struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */ struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */
......
...@@ -541,7 +541,7 @@ xfs_growfs_data_private( ...@@ -541,7 +541,7 @@ xfs_growfs_data_private(
saved_error = error; saved_error = error;
continue; continue;
} }
xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb, XFS_SB_ALL_BITS); xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb);
error = xfs_bwrite(bp); error = xfs_bwrite(bp);
xfs_buf_relse(bp); xfs_buf_relse(bp);
...@@ -756,37 +756,6 @@ xfs_reserve_blocks( ...@@ -756,37 +756,6 @@ xfs_reserve_blocks(
return 0; return 0;
} }
/*
* Dump a transaction into the log that contains no real change. This is needed
* to be able to make the log dirty or stamp the current tail LSN into the log
* during the covering operation.
*
* We cannot use an inode here for this - that will push dirty state back up
* into the VFS and then periodic inode flushing will prevent log covering from
* making progress. Hence we log a field in the superblock instead and use a
* synchronous transaction to ensure the superblock is immediately unpinned
* and can be written back.
*/
int
xfs_fs_log_dummy(
xfs_mount_t *mp)
{
xfs_trans_t *tp;
int error;
tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1, KM_SLEEP);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
if (error) {
xfs_trans_cancel(tp, 0);
return error;
}
/* log the UUID because it is an unchanging field */
xfs_mod_sb(tp, XFS_SB_UUID);
xfs_trans_set_sync(tp);
return xfs_trans_commit(tp, 0);
}
int int
xfs_fs_goingdown( xfs_fs_goingdown(
xfs_mount_t *mp, xfs_mount_t *mp,
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "xfs_fsops.h" #include "xfs_fsops.h"
#include "xfs_cksum.h" #include "xfs_cksum.h"
#include "xfs_sysfs.h" #include "xfs_sysfs.h"
#include "xfs_sb.h"
kmem_zone_t *xfs_log_ticket_zone; kmem_zone_t *xfs_log_ticket_zone;
...@@ -1290,9 +1291,20 @@ xfs_log_worker( ...@@ -1290,9 +1291,20 @@ xfs_log_worker(
struct xfs_mount *mp = log->l_mp; struct xfs_mount *mp = log->l_mp;
/* dgc: errors ignored - not fatal and nowhere to report them */ /* dgc: errors ignored - not fatal and nowhere to report them */
if (xfs_log_need_covered(mp)) if (xfs_log_need_covered(mp)) {
xfs_fs_log_dummy(mp); /*
else * Dump a transaction into the log that contains no real change.
* This is needed to stamp the current tail LSN into the log
* during the covering operation.
*
* We cannot use an inode here for this - that will push dirty
* state back up into the VFS and then periodic inode flushing
* will prevent log covering from making progress. Hence we
* synchronously log the superblock instead to ensure the
* superblock is immediately unpinned and can be written back.
*/
xfs_sync_sb(mp, true);
} else
xfs_log_force(mp, 0); xfs_log_force(mp, 0);
/* start pushing all the metadata that is currently dirty */ /* start pushing all the metadata that is currently dirty */
......
...@@ -408,11 +408,11 @@ xfs_update_alignment(xfs_mount_t *mp) ...@@ -408,11 +408,11 @@ xfs_update_alignment(xfs_mount_t *mp)
if (xfs_sb_version_hasdalign(sbp)) { if (xfs_sb_version_hasdalign(sbp)) {
if (sbp->sb_unit != mp->m_dalign) { if (sbp->sb_unit != mp->m_dalign) {
sbp->sb_unit = mp->m_dalign; sbp->sb_unit = mp->m_dalign;
mp->m_update_flags |= XFS_SB_UNIT; mp->m_update_sb = true;
} }
if (sbp->sb_width != mp->m_swidth) { if (sbp->sb_width != mp->m_swidth) {
sbp->sb_width = mp->m_swidth; sbp->sb_width = mp->m_swidth;
mp->m_update_flags |= XFS_SB_WIDTH; mp->m_update_sb = true;
} }
} else { } else {
xfs_warn(mp, xfs_warn(mp,
...@@ -583,38 +583,19 @@ int ...@@ -583,38 +583,19 @@ int
xfs_mount_reset_sbqflags( xfs_mount_reset_sbqflags(
struct xfs_mount *mp) struct xfs_mount *mp)
{ {
int error;
struct xfs_trans *tp;
mp->m_qflags = 0; mp->m_qflags = 0;
/* /* It is OK to look at sb_qflags in the mount path without m_sb_lock. */
* It is OK to look at sb_qflags here in mount path,
* without m_sb_lock.
*/
if (mp->m_sb.sb_qflags == 0) if (mp->m_sb.sb_qflags == 0)
return 0; return 0;
spin_lock(&mp->m_sb_lock); spin_lock(&mp->m_sb_lock);
mp->m_sb.sb_qflags = 0; mp->m_sb.sb_qflags = 0;
spin_unlock(&mp->m_sb_lock); spin_unlock(&mp->m_sb_lock);
/* if (!xfs_fs_writable(mp, SB_FREEZE_WRITE))
* If the fs is readonly, let the incore superblock run
* with quotas off but don't flush the update out to disk
*/
if (mp->m_flags & XFS_MOUNT_RDONLY)
return 0; return 0;
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); return xfs_sync_sb(mp, false);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_sbchange, 0, 0);
if (error) {
xfs_trans_cancel(tp, 0);
xfs_alert(mp, "%s: Superblock update failed!", __func__);
return error;
}
xfs_mod_sb(tp, XFS_SB_QFLAGS);
return xfs_trans_commit(tp, 0);
} }
__uint64_t __uint64_t
...@@ -659,26 +640,25 @@ xfs_mountfs( ...@@ -659,26 +640,25 @@ xfs_mountfs(
xfs_sb_mount_common(mp, sbp); xfs_sb_mount_common(mp, sbp);
/* /*
* Check for a mismatched features2 values. Older kernels * Check for a mismatched features2 values. Older kernels read & wrote
* read & wrote into the wrong sb offset for sb_features2 * into the wrong sb offset for sb_features2 on some platforms due to
* on some platforms due to xfs_sb_t not being 64bit size aligned * xfs_sb_t not being 64bit size aligned when sb_features2 was added,
* when sb_features2 was added, which made older superblock * which made older superblock reading/writing routines swap it as a
* reading/writing routines swap it as a 64-bit value. * 64-bit value.
* *
* For backwards compatibility, we make both slots equal. * For backwards compatibility, we make both slots equal.
* *
* If we detect a mismatched field, we OR the set bits into the * If we detect a mismatched field, we OR the set bits into the existing
* existing features2 field in case it has already been modified; we * features2 field in case it has already been modified; we don't want
* don't want to lose any features. We then update the bad location * to lose any features. We then update the bad location with the ORed
* with the ORed value so that older kernels will see any features2 * value so that older kernels will see any features2 flags. The
* flags, and mark the two fields as needing updates once the * superblock writeback code ensures the new sb_features2 is copied to
* transaction subsystem is online. * sb_bad_features2 before it is logged or written to disk.
*/ */
if (xfs_sb_has_mismatched_features2(sbp)) { if (xfs_sb_has_mismatched_features2(sbp)) {
xfs_warn(mp, "correcting sb_features alignment problem"); xfs_warn(mp, "correcting sb_features alignment problem");
sbp->sb_features2 |= sbp->sb_bad_features2; sbp->sb_features2 |= sbp->sb_bad_features2;
sbp->sb_bad_features2 = sbp->sb_features2; mp->m_update_sb = true;
mp->m_update_flags |= XFS_SB_FEATURES2;
/* /*
* Re-check for ATTR2 in case it was found in bad_features2 * Re-check for ATTR2 in case it was found in bad_features2
...@@ -692,17 +672,17 @@ xfs_mountfs( ...@@ -692,17 +672,17 @@ xfs_mountfs(
if (xfs_sb_version_hasattr2(&mp->m_sb) && if (xfs_sb_version_hasattr2(&mp->m_sb) &&
(mp->m_flags & XFS_MOUNT_NOATTR2)) { (mp->m_flags & XFS_MOUNT_NOATTR2)) {
xfs_sb_version_removeattr2(&mp->m_sb); xfs_sb_version_removeattr2(&mp->m_sb);
mp->m_update_flags |= XFS_SB_FEATURES2; mp->m_update_sb = true;
/* update sb_versionnum for the clearing of the morebits */ /* update sb_versionnum for the clearing of the morebits */
if (!sbp->sb_features2) if (!sbp->sb_features2)
mp->m_update_flags |= XFS_SB_VERSIONNUM; mp->m_update_sb = true;
} }
/* always use v2 inodes by default now */ /* always use v2 inodes by default now */
if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)) { if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)) {
mp->m_sb.sb_versionnum |= XFS_SB_VERSION_NLINKBIT; mp->m_sb.sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
mp->m_update_flags |= XFS_SB_VERSIONNUM; mp->m_update_sb = true;
} }
/* /*
...@@ -895,8 +875,8 @@ xfs_mountfs( ...@@ -895,8 +875,8 @@ xfs_mountfs(
* the next remount into writeable mode. Otherwise we would never * the next remount into writeable mode. Otherwise we would never
* perform the update e.g. for the root filesystem. * perform the update e.g. for the root filesystem.
*/ */
if (mp->m_update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY)) { if (mp->m_update_sb && !(mp->m_flags & XFS_MOUNT_RDONLY)) {
error = xfs_mount_log_sb(mp, mp->m_update_flags); error = xfs_sync_sb(mp, false);
if (error) { if (error) {
xfs_warn(mp, "failed to write sb changes"); xfs_warn(mp, "failed to write sb changes");
goto out_rtunmount; goto out_rtunmount;
...@@ -1103,9 +1083,6 @@ xfs_fs_writable( ...@@ -1103,9 +1083,6 @@ xfs_fs_writable(
int int
xfs_log_sbcount(xfs_mount_t *mp) xfs_log_sbcount(xfs_mount_t *mp)
{ {
xfs_trans_t *tp;
int error;
/* allow this to proceed during the freeze sequence... */ /* allow this to proceed during the freeze sequence... */
if (!xfs_fs_writable(mp, SB_FREEZE_COMPLETE)) if (!xfs_fs_writable(mp, SB_FREEZE_COMPLETE))
return 0; return 0;
...@@ -1119,17 +1096,7 @@ xfs_log_sbcount(xfs_mount_t *mp) ...@@ -1119,17 +1096,7 @@ xfs_log_sbcount(xfs_mount_t *mp)
if (!xfs_sb_version_haslazysbcount(&mp->m_sb)) if (!xfs_sb_version_haslazysbcount(&mp->m_sb))
return 0; return 0;
tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_COUNT, KM_SLEEP); return xfs_sync_sb(mp, true);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
if (error) {
xfs_trans_cancel(tp, 0);
return error;
}
xfs_mod_sb(tp, XFS_SB_IFREE | XFS_SB_ICOUNT | XFS_SB_FDBLOCKS);
xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp, 0);
return error;
} }
/* /*
...@@ -1422,33 +1389,6 @@ xfs_freesb( ...@@ -1422,33 +1389,6 @@ xfs_freesb(
xfs_buf_relse(bp); xfs_buf_relse(bp);
} }
/*
* Used to log changes to the superblock unit and width fields which could
* be altered by the mount options, as well as any potential sb_features2
* fixup. Only the first superblock is updated.
*/
int
xfs_mount_log_sb(
xfs_mount_t *mp,
__int64_t fields)
{
xfs_trans_t *tp;
int error;
ASSERT(fields & (XFS_SB_UNIT | XFS_SB_WIDTH | XFS_SB_UUID |
XFS_SB_FEATURES2 | XFS_SB_VERSIONNUM));
tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
if (error) {
xfs_trans_cancel(tp, 0);
return error;
}
xfs_mod_sb(tp, fields);
error = xfs_trans_commit(tp, 0);
return error;
}
/* /*
* If the underlying (data/log/rt) device is readonly, there are some * If the underlying (data/log/rt) device is readonly, there are some
* operations that cannot proceed. * operations that cannot proceed.
......
...@@ -162,8 +162,7 @@ typedef struct xfs_mount { ...@@ -162,8 +162,7 @@ typedef struct xfs_mount {
struct delayed_work m_reclaim_work; /* background inode reclaim */ struct delayed_work m_reclaim_work; /* background inode reclaim */
struct delayed_work m_eofblocks_work; /* background eof blocks struct delayed_work m_eofblocks_work; /* background eof blocks
trimming */ trimming */
__int64_t m_update_flags; /* sb flags we need to update bool m_update_sb; /* sb needs update in mount */
on the next remount,rw */
int64_t m_low_space[XFS_LOWSP_MAX]; int64_t m_low_space[XFS_LOWSP_MAX];
/* low free space thresholds */ /* low free space thresholds */
struct xfs_kobj m_kobj; struct xfs_kobj m_kobj;
...@@ -378,7 +377,7 @@ extern void xfs_unmountfs(xfs_mount_t *); ...@@ -378,7 +377,7 @@ extern void xfs_unmountfs(xfs_mount_t *);
extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int64_t, int); extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int64_t, int);
extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *,
uint, int); uint, int);
extern int xfs_mount_log_sb(xfs_mount_t *, __int64_t); extern int xfs_mount_log_sb(xfs_mount_t *);
extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
extern int xfs_readsb(xfs_mount_t *, int); extern int xfs_readsb(xfs_mount_t *, int);
extern void xfs_freesb(xfs_mount_t *); extern void xfs_freesb(xfs_mount_t *);
......
...@@ -714,7 +714,6 @@ STATIC int ...@@ -714,7 +714,6 @@ STATIC int
xfs_qm_qino_alloc( xfs_qm_qino_alloc(
xfs_mount_t *mp, xfs_mount_t *mp,
xfs_inode_t **ip, xfs_inode_t **ip,
__int64_t sbfields,
uint flags) uint flags)
{ {
xfs_trans_t *tp; xfs_trans_t *tp;
...@@ -777,11 +776,6 @@ xfs_qm_qino_alloc( ...@@ -777,11 +776,6 @@ xfs_qm_qino_alloc(
spin_lock(&mp->m_sb_lock); spin_lock(&mp->m_sb_lock);
if (flags & XFS_QMOPT_SBVERSION) { if (flags & XFS_QMOPT_SBVERSION) {
ASSERT(!xfs_sb_version_hasquota(&mp->m_sb)); ASSERT(!xfs_sb_version_hasquota(&mp->m_sb));
ASSERT((sbfields & (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO |
XFS_SB_GQUOTINO | XFS_SB_PQUOTINO | XFS_SB_QFLAGS)) ==
(XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO |
XFS_SB_GQUOTINO | XFS_SB_PQUOTINO |
XFS_SB_QFLAGS));
xfs_sb_version_addquota(&mp->m_sb); xfs_sb_version_addquota(&mp->m_sb);
mp->m_sb.sb_uquotino = NULLFSINO; mp->m_sb.sb_uquotino = NULLFSINO;
...@@ -798,7 +792,7 @@ xfs_qm_qino_alloc( ...@@ -798,7 +792,7 @@ xfs_qm_qino_alloc(
else else
mp->m_sb.sb_pquotino = (*ip)->i_ino; mp->m_sb.sb_pquotino = (*ip)->i_ino;
spin_unlock(&mp->m_sb_lock); spin_unlock(&mp->m_sb_lock);
xfs_mod_sb(tp, sbfields); xfs_log_sb(tp);
if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES))) { if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES))) {
xfs_alert(mp, "%s failed (error %d)!", __func__, error); xfs_alert(mp, "%s failed (error %d)!", __func__, error);
...@@ -1451,7 +1445,7 @@ xfs_qm_mount_quotas( ...@@ -1451,7 +1445,7 @@ xfs_qm_mount_quotas(
spin_unlock(&mp->m_sb_lock); spin_unlock(&mp->m_sb_lock);
if (sbf != (mp->m_qflags & XFS_MOUNT_QUOTA_ALL)) { if (sbf != (mp->m_qflags & XFS_MOUNT_QUOTA_ALL)) {
if (xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS)) { if (xfs_sync_sb(mp, false)) {
/* /*
* We could only have been turning quotas off. * We could only have been turning quotas off.
* We aren't in very good shape actually because * We aren't in very good shape actually because
...@@ -1482,7 +1476,6 @@ xfs_qm_init_quotainos( ...@@ -1482,7 +1476,6 @@ xfs_qm_init_quotainos(
struct xfs_inode *gip = NULL; struct xfs_inode *gip = NULL;
struct xfs_inode *pip = NULL; struct xfs_inode *pip = NULL;
int error; int error;
__int64_t sbflags = 0;
uint flags = 0; uint flags = 0;
ASSERT(mp->m_quotainfo); ASSERT(mp->m_quotainfo);
...@@ -1517,9 +1510,6 @@ xfs_qm_init_quotainos( ...@@ -1517,9 +1510,6 @@ xfs_qm_init_quotainos(
} }
} else { } else {
flags |= XFS_QMOPT_SBVERSION; flags |= XFS_QMOPT_SBVERSION;
sbflags |= (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO |
XFS_SB_GQUOTINO | XFS_SB_PQUOTINO |
XFS_SB_QFLAGS);
} }
/* /*
...@@ -1530,7 +1520,6 @@ xfs_qm_init_quotainos( ...@@ -1530,7 +1520,6 @@ xfs_qm_init_quotainos(
*/ */
if (XFS_IS_UQUOTA_ON(mp) && uip == NULL) { if (XFS_IS_UQUOTA_ON(mp) && uip == NULL) {
error = xfs_qm_qino_alloc(mp, &uip, error = xfs_qm_qino_alloc(mp, &uip,
sbflags | XFS_SB_UQUOTINO,
flags | XFS_QMOPT_UQUOTA); flags | XFS_QMOPT_UQUOTA);
if (error) if (error)
goto error_rele; goto error_rele;
...@@ -1539,7 +1528,6 @@ xfs_qm_init_quotainos( ...@@ -1539,7 +1528,6 @@ xfs_qm_init_quotainos(
} }
if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) { if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) {
error = xfs_qm_qino_alloc(mp, &gip, error = xfs_qm_qino_alloc(mp, &gip,
sbflags | XFS_SB_GQUOTINO,
flags | XFS_QMOPT_GQUOTA); flags | XFS_QMOPT_GQUOTA);
if (error) if (error)
goto error_rele; goto error_rele;
...@@ -1548,7 +1536,6 @@ xfs_qm_init_quotainos( ...@@ -1548,7 +1536,6 @@ xfs_qm_init_quotainos(
} }
if (XFS_IS_PQUOTA_ON(mp) && pip == NULL) { if (XFS_IS_PQUOTA_ON(mp) && pip == NULL) {
error = xfs_qm_qino_alloc(mp, &pip, error = xfs_qm_qino_alloc(mp, &pip,
sbflags | XFS_SB_PQUOTINO,
flags | XFS_QMOPT_PQUOTA); flags | XFS_QMOPT_PQUOTA);
if (error) if (error)
goto error_rele; goto error_rele;
...@@ -1587,32 +1574,6 @@ xfs_qm_dqfree_one( ...@@ -1587,32 +1574,6 @@ xfs_qm_dqfree_one(
xfs_qm_dqdestroy(dqp); xfs_qm_dqdestroy(dqp);
} }
/*
* Start a transaction and write the incore superblock changes to
* disk. flags parameter indicates which fields have changed.
*/
int
xfs_qm_write_sb_changes(
xfs_mount_t *mp,
__int64_t flags)
{
xfs_trans_t *tp;
int error;
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_sbchange, 0, 0);
if (error) {
xfs_trans_cancel(tp, 0);
return error;
}
xfs_mod_sb(tp, flags);
error = xfs_trans_commit(tp, 0);
return error;
}
/* --------------- utility functions for vnodeops ---------------- */ /* --------------- utility functions for vnodeops ---------------- */
......
...@@ -157,7 +157,6 @@ struct xfs_dquot_acct { ...@@ -157,7 +157,6 @@ struct xfs_dquot_acct {
#define XFS_QM_RTBWARNLIMIT 5 #define XFS_QM_RTBWARNLIMIT 5
extern void xfs_qm_destroy_quotainfo(struct xfs_mount *); extern void xfs_qm_destroy_quotainfo(struct xfs_mount *);
extern int xfs_qm_write_sb_changes(struct xfs_mount *, __int64_t);
/* dquot stuff */ /* dquot stuff */
extern void xfs_qm_dqpurge_all(struct xfs_mount *, uint); extern void xfs_qm_dqpurge_all(struct xfs_mount *, uint);
......
...@@ -92,8 +92,7 @@ xfs_qm_scall_quotaoff( ...@@ -92,8 +92,7 @@ xfs_qm_scall_quotaoff(
mutex_unlock(&q->qi_quotaofflock); mutex_unlock(&q->qi_quotaofflock);
/* XXX what to do if error ? Revert back to old vals incore ? */ /* XXX what to do if error ? Revert back to old vals incore ? */
error = xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS); return xfs_sync_sb(mp, false);
return error;
} }
dqtype = 0; dqtype = 0;
...@@ -314,7 +313,6 @@ xfs_qm_scall_quotaon( ...@@ -314,7 +313,6 @@ xfs_qm_scall_quotaon(
{ {
int error; int error;
uint qf; uint qf;
__int64_t sbflags;
flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD); flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
/* /*
...@@ -322,8 +320,6 @@ xfs_qm_scall_quotaon( ...@@ -322,8 +320,6 @@ xfs_qm_scall_quotaon(
*/ */
flags &= ~(XFS_ALL_QUOTA_ACCT); flags &= ~(XFS_ALL_QUOTA_ACCT);
sbflags = 0;
if (flags == 0) { if (flags == 0) {
xfs_debug(mp, "%s: zero flags, m_qflags=%x", xfs_debug(mp, "%s: zero flags, m_qflags=%x",
__func__, mp->m_qflags); __func__, mp->m_qflags);
...@@ -370,11 +366,11 @@ xfs_qm_scall_quotaon( ...@@ -370,11 +366,11 @@ xfs_qm_scall_quotaon(
/* /*
* There's nothing to change if it's the same. * There's nothing to change if it's the same.
*/ */
if ((qf & flags) == flags && sbflags == 0) if ((qf & flags) == flags)
return -EEXIST; return -EEXIST;
sbflags |= XFS_SB_QFLAGS;
if ((error = xfs_qm_write_sb_changes(mp, sbflags))) error = xfs_sync_sb(mp, false);
if (error)
return error; return error;
/* /*
* If we aren't trying to switch on quota enforcement, we are done. * If we aren't trying to switch on quota enforcement, we are done.
...@@ -801,7 +797,7 @@ xfs_qm_log_quotaoff( ...@@ -801,7 +797,7 @@ xfs_qm_log_quotaoff(
mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL;
spin_unlock(&mp->m_sb_lock); spin_unlock(&mp->m_sb_lock);
xfs_mod_sb(tp, XFS_SB_QFLAGS); xfs_log_sb(tp);
/* /*
* We have to make sure that the transaction is secure on disk before we * We have to make sure that the transaction is secure on disk before we
......
...@@ -1257,13 +1257,13 @@ xfs_fs_remount( ...@@ -1257,13 +1257,13 @@ xfs_fs_remount(
* If this is the first remount to writeable state we * If this is the first remount to writeable state we
* might have some superblock changes to update. * might have some superblock changes to update.
*/ */
if (mp->m_update_flags) { if (mp->m_update_sb) {
error = xfs_mount_log_sb(mp, mp->m_update_flags); error = xfs_sync_sb(mp, false);
if (error) { if (error) {
xfs_warn(mp, "failed to write sb changes"); xfs_warn(mp, "failed to write sb changes");
return error; return error;
} }
mp->m_update_flags = 0; mp->m_update_sb = false;
} }
/* /*
...@@ -1293,8 +1293,9 @@ xfs_fs_remount( ...@@ -1293,8 +1293,9 @@ xfs_fs_remount(
/* /*
* Second stage of a freeze. The data is already frozen so we only * Second stage of a freeze. The data is already frozen so we only
* need to take care of the metadata. Once that's done write a dummy * need to take care of the metadata. Once that's done sync the superblock
* record to dirty the log in case of a crash while frozen. * to the log to dirty it in case of a crash while frozen. This ensures that we
* will recover the unlinked inode lists on the next mount.
*/ */
STATIC int STATIC int
xfs_fs_freeze( xfs_fs_freeze(
...@@ -1304,7 +1305,7 @@ xfs_fs_freeze( ...@@ -1304,7 +1305,7 @@ xfs_fs_freeze(
xfs_save_resvblks(mp); xfs_save_resvblks(mp);
xfs_quiesce_attr(mp); xfs_quiesce_attr(mp);
return xfs_fs_log_dummy(mp); return xfs_sync_sb(mp, true);
} }
STATIC int STATIC int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment