Commit eb43e660 authored by Bob Peterson's avatar Bob Peterson Committed by Andreas Gruenbacher

gfs2: Introduce function gfs2_withdrawn

Add function gfs2_withdrawn and replace all checks for the SDF_WITHDRAWN
bit to call it. This does not change the logic or function of gfs2, and
it facilitates later improvements to the withdraw sequence.
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
parent fe5e7ba1
...@@ -497,7 +497,7 @@ static int __gfs2_readpage(void *file, struct page *page) ...@@ -497,7 +497,7 @@ static int __gfs2_readpage(void *file, struct page *page)
error = mpage_readpage(page, gfs2_block_map); error = mpage_readpage(page, gfs2_block_map);
} }
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) if (unlikely(gfs2_withdrawn(sdp)))
return -EIO; return -EIO;
return error; return error;
...@@ -614,7 +614,7 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping, ...@@ -614,7 +614,7 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping,
gfs2_glock_dq(&gh); gfs2_glock_dq(&gh);
out_uninit: out_uninit:
gfs2_holder_uninit(&gh); gfs2_holder_uninit(&gh);
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) if (unlikely(gfs2_withdrawn(sdp)))
ret = -EIO; ret = -EIO;
return ret; return ret;
} }
......
...@@ -1194,7 +1194,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) ...@@ -1194,7 +1194,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
cmd = F_SETLK; cmd = F_SETLK;
fl->fl_type = F_UNLCK; fl->fl_type = F_UNLCK;
} }
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) { if (unlikely(gfs2_withdrawn(sdp))) {
if (fl->fl_type == F_UNLCK) if (fl->fl_type == F_UNLCK)
locks_lock_file_wait(file, fl); locks_lock_file_wait(file, fl);
return -EIO; return -EIO;
......
...@@ -549,7 +549,7 @@ __acquires(&gl->gl_lockref.lock) ...@@ -549,7 +549,7 @@ __acquires(&gl->gl_lockref.lock)
unsigned int lck_flags = (unsigned int)(gh ? gh->gh_flags : 0); unsigned int lck_flags = (unsigned int)(gh ? gh->gh_flags : 0);
int ret; int ret;
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) && if (unlikely(gfs2_withdrawn(sdp)) &&
target != LM_ST_UNLOCKED) target != LM_ST_UNLOCKED)
return; return;
lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP | lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP |
...@@ -586,8 +586,7 @@ __acquires(&gl->gl_lockref.lock) ...@@ -586,8 +586,7 @@ __acquires(&gl->gl_lockref.lock)
} }
else if (ret) { else if (ret) {
fs_err(sdp, "lm_lock ret %d\n", ret); fs_err(sdp, "lm_lock ret %d\n", ret);
GLOCK_BUG_ON(gl, !test_bit(SDF_WITHDRAWN, GLOCK_BUG_ON(gl, !gfs2_withdrawn(sdp));
&sdp->sd_flags));
} }
} else { /* lock_nolock */ } else { /* lock_nolock */
finish_xmote(gl, target); finish_xmote(gl, target);
...@@ -1191,7 +1190,7 @@ int gfs2_glock_nq(struct gfs2_holder *gh) ...@@ -1191,7 +1190,7 @@ int gfs2_glock_nq(struct gfs2_holder *gh)
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
int error = 0; int error = 0;
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) if (unlikely(gfs2_withdrawn(sdp)))
return -EIO; return -EIO;
if (test_bit(GLF_LRU, &gl->gl_flags)) if (test_bit(GLF_LRU, &gl->gl_flags))
......
...@@ -540,7 +540,7 @@ static int freeze_go_xmote_bh(struct gfs2_glock *gl, struct gfs2_holder *gh) ...@@ -540,7 +540,7 @@ static int freeze_go_xmote_bh(struct gfs2_glock *gl, struct gfs2_holder *gh)
gfs2_consist(sdp); gfs2_consist(sdp);
/* Initialize some head of the log stuff */ /* Initialize some head of the log stuff */
if (!test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) { if (!gfs2_withdrawn(sdp)) {
sdp->sd_log_sequence = head.lh_sequence + 1; sdp->sd_log_sequence = head.lh_sequence + 1;
gfs2_log_pointers_init(sdp, head.lh_blkno); gfs2_log_pointers_init(sdp, head.lh_blkno);
} }
......
...@@ -251,7 +251,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, ...@@ -251,7 +251,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
struct buffer_head *bh, *bhs[2]; struct buffer_head *bh, *bhs[2];
int num = 0; int num = 0;
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) { if (unlikely(gfs2_withdrawn(sdp))) {
*bhp = NULL; *bhp = NULL;
return -EIO; return -EIO;
} }
...@@ -309,7 +309,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, ...@@ -309,7 +309,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh) int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh)
{ {
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) if (unlikely(gfs2_withdrawn(sdp)))
return -EIO; return -EIO;
wait_on_buffer(bh); wait_on_buffer(bh);
...@@ -320,7 +320,7 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh) ...@@ -320,7 +320,7 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh)
gfs2_io_error_bh_wd(sdp, bh); gfs2_io_error_bh_wd(sdp, bh);
return -EIO; return -EIO;
} }
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) if (unlikely(gfs2_withdrawn(sdp)))
return -EIO; return -EIO;
return 0; return 0;
......
...@@ -1006,8 +1006,7 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) ...@@ -1006,8 +1006,7 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)
void gfs2_lm_unmount(struct gfs2_sbd *sdp) void gfs2_lm_unmount(struct gfs2_sbd *sdp)
{ {
const struct lm_lockops *lm = sdp->sd_lockstruct.ls_ops; const struct lm_lockops *lm = sdp->sd_lockstruct.ls_ops;
if (likely(!test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) && if (likely(!gfs2_withdrawn(sdp)) && lm->lm_unmount)
lm->lm_unmount)
lm->lm_unmount(sdp); lm->lm_unmount(sdp);
} }
......
...@@ -1475,7 +1475,7 @@ static void quotad_error(struct gfs2_sbd *sdp, const char *msg, int error) ...@@ -1475,7 +1475,7 @@ static void quotad_error(struct gfs2_sbd *sdp, const char *msg, int error)
{ {
if (error == 0 || error == -EROFS) if (error == 0 || error == -EROFS)
return; return;
if (!test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) { if (!gfs2_withdrawn(sdp)) {
fs_err(sdp, "gfs2_quotad: %s error %d\n", msg, error); fs_err(sdp, "gfs2_quotad: %s error %d\n", msg, error);
sdp->sd_log_error = error; sdp->sd_log_error = error;
wake_up(&sdp->sd_logd_waitq); wake_up(&sdp->sd_logd_waitq);
......
...@@ -553,7 +553,7 @@ static void gfs2_dirty_inode(struct inode *inode, int flags) ...@@ -553,7 +553,7 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)
if (!(flags & I_DIRTY_INODE)) if (!(flags & I_DIRTY_INODE))
return; return;
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) if (unlikely(gfs2_withdrawn(sdp)))
return; return;
if (!gfs2_glock_is_locked_by_me(ip->i_gl)) { if (!gfs2_glock_is_locked_by_me(ip->i_gl)) {
ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
...@@ -602,7 +602,7 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp) ...@@ -602,7 +602,7 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED, GL_NOCACHE, error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED, GL_NOCACHE,
&freeze_gh); &freeze_gh);
if (error && !test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) if (error && !gfs2_withdrawn(sdp))
return error; return error;
flush_workqueue(gfs2_delete_workqueue); flush_workqueue(gfs2_delete_workqueue);
...@@ -761,7 +761,7 @@ static int gfs2_freeze(struct super_block *sb) ...@@ -761,7 +761,7 @@ static int gfs2_freeze(struct super_block *sb)
if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN) if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN)
goto out; goto out;
if (test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) { if (gfs2_withdrawn(sdp)) {
error = -EINVAL; error = -EINVAL;
goto out; goto out;
} }
......
...@@ -118,7 +118,7 @@ static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len) ...@@ -118,7 +118,7 @@ static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf) static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)
{ {
unsigned int b = test_bit(SDF_WITHDRAWN, &sdp->sd_flags); unsigned int b = gfs2_withdrawn(sdp);
return snprintf(buf, PAGE_SIZE, "%u\n", b); return snprintf(buf, PAGE_SIZE, "%u\n", b);
} }
......
...@@ -258,7 +258,7 @@ void gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh, ...@@ -258,7 +258,7 @@ void gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
const char *function, char *file, unsigned int line, const char *function, char *file, unsigned int line,
bool withdraw) bool withdraw)
{ {
if (!test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) if (!gfs2_withdrawn(sdp))
fs_err(sdp, fs_err(sdp,
"fatal: I/O error\n" "fatal: I/O error\n"
" block = %llu\n" " block = %llu\n"
......
...@@ -164,6 +164,15 @@ static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt, ...@@ -164,6 +164,15 @@ static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
return x; return x;
} }
/**
* gfs2_withdrawn - test whether the file system is withdrawing or withdrawn
* @sdp: the superblock
*/
static inline bool gfs2_withdrawn(struct gfs2_sbd *sdp)
{
return test_bit(SDF_WITHDRAWN, &sdp->sd_flags);
}
#define gfs2_tune_get(sdp, field) \ #define gfs2_tune_get(sdp, field) \
gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field) gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
......
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