Commit 5432af15 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher

gfs2: Replace sd_freeze_state with SDF_FROZEN flag

Replace sd_freeze_state with a new SDF_FROZEN flag.

There no longer is a need for indicating that a freeze is in progress
(SDF_STARTING_FREEZE); we are now protecting the critical sections with
the sd_freeze_mutex.
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
parent b77b4a48
...@@ -608,12 +608,7 @@ enum { ...@@ -608,12 +608,7 @@ enum {
withdrawing */ withdrawing */
SDF_DEACTIVATING = 15, SDF_DEACTIVATING = 15,
SDF_EVICTING = 16, SDF_EVICTING = 16,
}; SDF_FROZEN = 17,
enum gfs2_freeze_state {
SFS_UNFROZEN = 0,
SFS_STARTING_FREEZE = 1,
SFS_FROZEN = 2,
}; };
#define GFS2_FSNAME_LEN 256 #define GFS2_FSNAME_LEN 256
...@@ -841,7 +836,6 @@ struct gfs2_sbd { ...@@ -841,7 +836,6 @@ struct gfs2_sbd {
/* For quiescing the filesystem */ /* For quiescing the filesystem */
struct gfs2_holder sd_freeze_gh; struct gfs2_holder sd_freeze_gh;
atomic_t sd_freeze_state;
struct mutex sd_freeze_mutex; struct mutex sd_freeze_mutex;
char sd_fsname[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2]; char sd_fsname[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2];
......
...@@ -914,9 +914,8 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd, ...@@ -914,9 +914,8 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
static void log_write_header(struct gfs2_sbd *sdp, u32 flags) static void log_write_header(struct gfs2_sbd *sdp, u32 flags)
{ {
blk_opf_t op_flags = REQ_PREFLUSH | REQ_FUA | REQ_META | REQ_SYNC; blk_opf_t op_flags = REQ_PREFLUSH | REQ_FUA | REQ_META | REQ_SYNC;
enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state);
gfs2_assert_withdraw(sdp, (state != SFS_FROZEN)); gfs2_assert_withdraw(sdp, !test_bit(SDF_FROZEN, &sdp->sd_flags));
if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) { if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) {
gfs2_ordered_wait(sdp); gfs2_ordered_wait(sdp);
...@@ -1036,7 +1035,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) ...@@ -1036,7 +1035,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
{ {
struct gfs2_trans *tr = NULL; struct gfs2_trans *tr = NULL;
unsigned int reserved_blocks = 0, used_blocks = 0; unsigned int reserved_blocks = 0, used_blocks = 0;
enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state); bool frozen = test_bit(SDF_FROZEN, &sdp->sd_flags);
unsigned int first_log_head; unsigned int first_log_head;
unsigned int reserved_revokes = 0; unsigned int reserved_revokes = 0;
...@@ -1067,7 +1066,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) ...@@ -1067,7 +1066,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
if (tr) { if (tr) {
sdp->sd_log_tr = NULL; sdp->sd_log_tr = NULL;
tr->tr_first = first_log_head; tr->tr_first = first_log_head;
if (unlikely (state == SFS_FROZEN)) { if (unlikely(frozen)) {
if (gfs2_assert_withdraw_delayed(sdp, if (gfs2_assert_withdraw_delayed(sdp,
!tr->tr_num_buf_new && !tr->tr_num_databuf_new)) !tr->tr_num_buf_new && !tr->tr_num_databuf_new))
goto out_withdraw; goto out_withdraw;
...@@ -1092,7 +1091,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) ...@@ -1092,7 +1091,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
if (flags & GFS2_LOG_HEAD_FLUSH_SHUTDOWN) if (flags & GFS2_LOG_HEAD_FLUSH_SHUTDOWN)
clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
if (unlikely(state == SFS_FROZEN)) if (unlikely(frozen))
if (gfs2_assert_withdraw_delayed(sdp, !reserved_revokes)) if (gfs2_assert_withdraw_delayed(sdp, !reserved_revokes))
goto out_withdraw; goto out_withdraw;
......
...@@ -135,7 +135,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) ...@@ -135,7 +135,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
init_rwsem(&sdp->sd_log_flush_lock); init_rwsem(&sdp->sd_log_flush_lock);
atomic_set(&sdp->sd_log_in_flight, 0); atomic_set(&sdp->sd_log_in_flight, 0);
init_waitqueue_head(&sdp->sd_log_flush_wait); init_waitqueue_head(&sdp->sd_log_flush_wait);
atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN);
mutex_init(&sdp->sd_freeze_mutex); mutex_init(&sdp->sd_freeze_mutex);
return sdp; return sdp;
......
...@@ -467,7 +467,7 @@ void gfs2_recover_func(struct work_struct *work) ...@@ -467,7 +467,7 @@ void gfs2_recover_func(struct work_struct *work)
if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) { if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
mutex_lock(&sdp->sd_freeze_mutex); mutex_lock(&sdp->sd_freeze_mutex);
if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN) { if (test_bit(SDF_FROZEN, &sdp->sd_flags)) {
mutex_unlock(&sdp->sd_freeze_mutex); mutex_unlock(&sdp->sd_freeze_mutex);
fs_warn(sdp, "jid=%u: Can't replay: filesystem " fs_warn(sdp, "jid=%u: Can't replay: filesystem "
"is frozen\n", jd->jd_jid); "is frozen\n", jd->jd_jid);
......
...@@ -689,26 +689,19 @@ static int gfs2_freeze_locally(struct gfs2_sbd *sdp) ...@@ -689,26 +689,19 @@ static int gfs2_freeze_locally(struct gfs2_sbd *sdp)
struct super_block *sb = sdp->sd_vfs; struct super_block *sb = sdp->sd_vfs;
int error; int error;
atomic_set(&sdp->sd_freeze_state, SFS_STARTING_FREEZE);
error = freeze_super(sb); error = freeze_super(sb);
if (error) if (error)
goto fail; return error;
if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) { if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_FREEZE | gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_FREEZE |
GFS2_LFC_FREEZE_GO_SYNC); GFS2_LFC_FREEZE_GO_SYNC);
if (gfs2_withdrawn(sdp)) { if (gfs2_withdrawn(sdp)) {
thaw_super(sb); thaw_super(sb);
error = -EIO; return -EIO;
goto fail;
} }
} }
return 0; return 0;
fail:
atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN);
return error;
} }
static int gfs2_do_thaw(struct gfs2_sbd *sdp) static int gfs2_do_thaw(struct gfs2_sbd *sdp)
...@@ -737,7 +730,7 @@ void gfs2_freeze_func(struct work_struct *work) ...@@ -737,7 +730,7 @@ void gfs2_freeze_func(struct work_struct *work)
mutex_lock(&sdp->sd_freeze_mutex); mutex_lock(&sdp->sd_freeze_mutex);
error = -EBUSY; error = -EBUSY;
if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN) if (test_bit(SDF_FROZEN, &sdp->sd_flags))
goto freeze_failed; goto freeze_failed;
error = gfs2_freeze_locally(sdp); error = gfs2_freeze_locally(sdp);
...@@ -745,13 +738,13 @@ void gfs2_freeze_func(struct work_struct *work) ...@@ -745,13 +738,13 @@ void gfs2_freeze_func(struct work_struct *work)
goto freeze_failed; goto freeze_failed;
gfs2_freeze_unlock(&sdp->sd_freeze_gh); gfs2_freeze_unlock(&sdp->sd_freeze_gh);
atomic_set(&sdp->sd_freeze_state, SFS_FROZEN); set_bit(SDF_FROZEN, &sdp->sd_flags);
error = gfs2_do_thaw(sdp); error = gfs2_do_thaw(sdp);
if (error) if (error)
goto out; goto out;
atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN); clear_bit(SDF_FROZEN, &sdp->sd_flags);
goto out; goto out;
freeze_failed: freeze_failed:
...@@ -776,7 +769,7 @@ static int gfs2_freeze_super(struct super_block *sb) ...@@ -776,7 +769,7 @@ static int gfs2_freeze_super(struct super_block *sb)
if (!mutex_trylock(&sdp->sd_freeze_mutex)) if (!mutex_trylock(&sdp->sd_freeze_mutex))
return -EBUSY; return -EBUSY;
error = -EBUSY; error = -EBUSY;
if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN) if (test_bit(SDF_FROZEN, &sdp->sd_flags))
goto out; goto out;
for (;;) { for (;;) {
...@@ -811,7 +804,7 @@ static int gfs2_freeze_super(struct super_block *sb) ...@@ -811,7 +804,7 @@ static int gfs2_freeze_super(struct super_block *sb)
out: out:
if (!error) { if (!error) {
set_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags); set_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags);
atomic_set(&sdp->sd_freeze_state, SFS_FROZEN); set_bit(SDF_FROZEN, &sdp->sd_flags);
} }
mutex_unlock(&sdp->sd_freeze_mutex); mutex_unlock(&sdp->sd_freeze_mutex);
return error; return error;
...@@ -840,7 +833,7 @@ static int gfs2_thaw_super(struct super_block *sb) ...@@ -840,7 +833,7 @@ static int gfs2_thaw_super(struct super_block *sb)
if (!error) { if (!error) {
clear_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags); clear_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags);
atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN); clear_bit(SDF_FROZEN, &sdp->sd_flags);
} }
out: out:
mutex_unlock(&sdp->sd_freeze_mutex); mutex_unlock(&sdp->sd_freeze_mutex);
......
...@@ -82,6 +82,7 @@ static ssize_t status_show(struct gfs2_sbd *sdp, char *buf) ...@@ -82,6 +82,7 @@ static ssize_t status_show(struct gfs2_sbd *sdp, char *buf)
"RO Recovery: %d\n" "RO Recovery: %d\n"
"Skip DLM Unlock: %d\n" "Skip DLM Unlock: %d\n"
"Force AIL Flush: %d\n" "Force AIL Flush: %d\n"
"FS Freeze Initiator: %d\n"
"FS Frozen: %d\n" "FS Frozen: %d\n"
"Withdrawing: %d\n" "Withdrawing: %d\n"
"Withdraw In Prog: %d\n" "Withdraw In Prog: %d\n"
...@@ -112,6 +113,7 @@ static ssize_t status_show(struct gfs2_sbd *sdp, char *buf) ...@@ -112,6 +113,7 @@ static ssize_t status_show(struct gfs2_sbd *sdp, char *buf)
test_bit(SDF_SKIP_DLM_UNLOCK, &f), test_bit(SDF_SKIP_DLM_UNLOCK, &f),
test_bit(SDF_FORCE_AIL_FLUSH, &f), test_bit(SDF_FORCE_AIL_FLUSH, &f),
test_bit(SDF_FREEZE_INITIATOR, &f), test_bit(SDF_FREEZE_INITIATOR, &f),
test_bit(SDF_FROZEN, &f),
test_bit(SDF_WITHDRAWING, &f), test_bit(SDF_WITHDRAWING, &f),
test_bit(SDF_WITHDRAW_IN_PROG, &f), test_bit(SDF_WITHDRAW_IN_PROG, &f),
test_bit(SDF_REMOTE_WITHDRAW, &f), test_bit(SDF_REMOTE_WITHDRAW, &f),
......
...@@ -233,7 +233,6 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) ...@@ -233,7 +233,6 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
struct gfs2_bufdata *bd; struct gfs2_bufdata *bd;
struct gfs2_meta_header *mh; struct gfs2_meta_header *mh;
struct gfs2_trans *tr = current->journal_info; struct gfs2_trans *tr = current->journal_info;
enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state);
lock_buffer(bh); lock_buffer(bh);
if (buffer_pinned(bh)) { if (buffer_pinned(bh)) {
...@@ -267,7 +266,7 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) ...@@ -267,7 +266,7 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
(unsigned long long)bd->bd_bh->b_blocknr); (unsigned long long)bd->bd_bh->b_blocknr);
BUG(); BUG();
} }
if (unlikely(state == SFS_FROZEN)) { if (unlikely(test_bit(SDF_FROZEN, &sdp->sd_flags))) {
fs_info(sdp, "GFS2:adding buf while frozen\n"); fs_info(sdp, "GFS2:adding buf while frozen\n");
gfs2_assert_withdraw(sdp, 0); gfs2_assert_withdraw(sdp, 0);
} }
......
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