gfs2: Introduce function gfs2_withdrawn
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 gfs2: Introduce function gfs2_withdrawn
Hi,
This patch adds function gfs2_withdrawn and replaces 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.
--- fs/gfs2/aops.c | 4 ++-- fs/gfs2/file.c | 2 +- fs/gfs2/glock.c | 7 +++---- fs/gfs2/glops.c | 2 +- fs/gfs2/meta_io.c | 6 +++--- fs/gfs2/ops_fstype.c | 3 +-- fs/gfs2/quota.c | 2 +- fs/gfs2/super.c | 6 +++--- fs/gfs2/sys.c | 2 +- fs/gfs2/util.c | 2 +- fs/gfs2/util.h | 11 +++++++++++ 11 files changed, 28 insertions(+), 19 deletions(-)
fs/gfs2/aops.c +2 -2
@@ -497,7 +497,7 @@ static int __gfs2_readpage(void *file, struct page *page) error =mpage_readpage (page, gfs2_block_map); } -if (unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags))) +if (unlikely (gfs2_withdrawn (sdp)))return -EIO ;return error;
@@ -614,7 +614,7 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping,gfs2_glock_dq (&gh); out_uninit:gfs2_holder_uninit (&gh); -if (unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags))) +if (unlikely (gfs2_withdrawn (sdp))) ret = -EIO ;return ret; }
fs/gfs2/file.c +1 -1
@@ -1194,7 +1194,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) cmd =F_SETLK ; 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 )locks_lock_file_wait (file, fl);return -EIO ;
fs/gfs2/glock.c +3 -4
@@ -549,7 +549,7 @@ __acquires(&gl->gl_lockref.lock)unsigned int lck_flags = (unsigned int )(gh ? gh->gh_flags :0 );int ret; -if (unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags)) && +if (unlikely (gfs2_withdrawn (sdp)) && target !=LM_ST_UNLOCKED )return ; lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP |
@@ -586,8 +586,7 @@ __acquires(&gl->gl_lockref.lock) }else if (ret) {fs_err (sdp,"lm_lock ret %d\n" , ret); -GLOCK_BUG_ON (gl, !test_bit (SDF_WITHDRAWN , - &sdp->sd_flags)); +GLOCK_BUG_ON (gl, !gfs2_withdrawn (sdp)); } }else {/* lock_nolock */ finish_xmote (gl, target);
@@ -1191,7 +1190,7 @@ int gfs2_glock_nq(struct gfs2_holder *gh)struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;int error =0 ; -if (unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags))) +if (unlikely (gfs2_withdrawn (sdp)))return -EIO ;if (test_bit (GLF_LRU , &gl->gl_flags))
fs/gfs2/glops.c +1 -1
@@ -540,7 +540,7 @@ static int freeze_go_xmote_bh(struct gfs2_glock *gl, struct gfs2_holder *gh)gfs2_consist (sdp);/* 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 ;gfs2_log_pointers_init (sdp, head.lh_blkno); }
fs/gfs2/meta_io.c +3 -3
@@ -251,7 +251,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,struct buffer_head *bh, *bhs[2 ];int num =0 ; -if (unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags))) { +if (unlikely (gfs2_withdrawn (sdp))) { *bhp =NULL ;return -EIO ; }
@@ -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) { -if (unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags))) +if (unlikely (gfs2_withdrawn (sdp)))return -EIO ;wait_on_buffer (bh);
@@ -320,7 +320,7 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh)gfs2_io_error_bh_wd (sdp, bh);return -EIO ; } -if (unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags))) +if (unlikely (gfs2_withdrawn (sdp)))return -EIO ;return 0 ;
fs/gfs2/ops_fstype.c +1 -2
@@ -1006,8 +1006,7 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)void gfs2_lm_unmount (struct gfs2_sbd *sdp) {const struct lm_lockops *lm = sdp->sd_lockstruct.ls_ops; -if (likely (!test_bit (SDF_WITHDRAWN , &sdp->sd_flags)) && - lm->lm_unmount) +if (likely (!gfs2_withdrawn (sdp)) && lm->lm_unmount) lm->lm_unmount (sdp); }
fs/gfs2/quota.c +1 -1
@@ -1475,7 +1475,7 @@ static void quotad_error(struct gfs2_sbd *sdp, const char *msg, int error) {if (error ==0 || error == -EROFS )return ; -if (!test_bit (SDF_WITHDRAWN , &sdp->sd_flags)) { +if (!gfs2_withdrawn (sdp)) {fs_err (sdp,"gfs2_quotad: %s error %d\n" , msg, error); sdp->sd_log_error = error;wake_up (&sdp->sd_logd_waitq);
fs/gfs2/super.c +3 -3
@@ -553,7 +553,7 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)if (!(flags &I_DIRTY_INODE ))return ; -if (unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags))) +if (unlikely (gfs2_withdrawn (sdp)))return ;if (!gfs2_glock_is_locked_by_me (ip->i_gl)) { 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) error =gfs2_glock_nq_init (sdp->sd_freeze_gl,LM_ST_SHARED ,GL_NOCACHE , &freeze_gh); -if (error && !test_bit (SDF_WITHDRAWN , &sdp->sd_flags)) +if (error && !gfs2_withdrawn (sdp))return error;flush_workqueue (gfs2_delete_workqueue);
@@ -761,7 +761,7 @@ static int gfs2_freeze(struct super_block *sb)if (atomic_read (&sdp->sd_freeze_state) !=SFS_UNFROZEN ) goto out; -if (test_bit (SDF_WITHDRAWN , &sdp->sd_flags)) { +if (gfs2_withdrawn (sdp)) { error = -EINVAL ; goto out; }
fs/gfs2/sys.c +1 -1
@@ -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) { -unsigned int b =test_bit (SDF_WITHDRAWN , &sdp->sd_flags); +unsigned int b =gfs2_withdrawn (sdp);return snprintf (buf,PAGE_SIZE ,"%u\n" , b); }
fs/gfs2/util.c +1 -1
@@ -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, bool withdraw) { - if (!test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) + if (!gfs2_withdrawn(sdp)) fs_err(sdp, "fatal: I/O error\n" " block = %llu\n"
fs/gfs2/util.h +11 -0
@@ -164,6 +164,17 @@ static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,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) +{ +if (test_bit (SDF_WITHDRAWN , &sdp->sd_flags)) +return true; +return false; +} +#define gfs2_tune_get (sdp, field) \ gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
Andreas Gruenbacher
maintainerPATCH 1/1 gfs2: Introduce function gfs2_withdrawn
Quoted 4 lines · Bob Peterson
This patch adds function
gfs2_withdrawnand replaces all checks for theSDF_WITHDRAWNbit to call it. This does not change the logic or function of gfs2, and it facilitates later improvements to the withdraw sequence.
This looks mostly okay, but:
fs/gfs2/util.h static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt, · line 175
Quoted 9 lines
fs/gfs2/util.h +9
-0+/** +* gfs2_withdrawn - test whether the file system is withdrawing or withdrawn +* @sdp: the superblock +*/ +static inline bool gfs2_withdrawn (struct gfs2_sbd *sdp) +{ +if (test_bit (SDF_WITHDRAWN , &sdp->sd_flags)) +return true; +return false;
return test_bit(SDF_WITHDRAWN, &sdp->sd_flags)
Quoted 1 line
+}
Thanks,
Andreas
PATCH 1/1 gfs2: Introduce function gfs2_withdrawn
----- Original Message -----
Quoted 21 lines · Bob Peterson
Quoted 4 lines
This patch adds function
gfs2_withdrawnand replaces all checks for theSDF_WITHDRAWNbit to call it. This does not change the logic or function of gfs2, and it facilitates later improvements to the withdraw sequence.This looks mostly okay, but:
fs/gfs2/util.h static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt, · line 175
Quoted 10 lines
+/**
+ *gfs2_withdrawn- test whether the file system is withdrawing or withdrawn
+ * @sdp: the superblock
+ */fs/gfs2/util.h +5
-0+static inline bool gfs2_withdrawn (struct gfs2_sbd *sdp) +{ +if (test_bit (SDF_WITHDRAWN , &sdp->sd_flags)) +return true; +return false;return test_bit(SDF_WITHDRAWN, &sdp->sd_flags)
Quoted 4 lines
Quoted 1 line
+}
Thanks,
Andreas
Well, I can certainly do that, but this patch is a predecessor to another that checks two bits instead of one. I could or them, of course.
Andreas Gruenbacher
maintainerPATCH 1/1 gfs2: Introduce function gfs2_withdrawn
Quoted 2 lines · Bob Peterson
Well, I can certainly do that, but this patch is a predecessor to another that checks two bits instead of one. I could or them, of course.
Yes, what's wrong with return A || B?
Thanks,
Andreas