gfs2: Minor gfs2_ail1_empty cleanup
Andreas Gruenbacher
maintainerPATCH 1/4 gfs2: Minor gfs2_ail1_empty cleanup
Change gfs2_ail1_empty() to return %true when the ail1 list is empty.
Based on that, make the loop in empty_ail1_list() more obvious.
--- fs/gfs2/log.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
fs/gfs2/log.c +9 -8
@@ -352,14 +352,15 @@ static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,* @sdp: The superblock * @max_revokes: If non-zero, add revokes where appropriate * -* Tries to empty the ail1 lists, starting with the oldest first +* Tries to empty the ail1 lists, starting with the oldest first. +* Returns %true if the ail1 list is now empty. */ -static int gfs2_ail1_empty (struct gfs2_sbd *sdp,int max_revokes) +static bool gfs2_ail1_empty (struct gfs2_sbd *sdp,int max_revokes) {struct gfs2_trans *tr, *s;int oldest_tr =1 ; -int ret; +bool empty;spin_lock (&sdp->sd_ail_lock);list_for_each_entry_safe_reverse (tr, s, &sdp->sd_ail1_list, tr_list) {
@@ -369,7 +370,7 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes) oldest_tr =0 ; }gfs2_log_update_flush_tail (sdp); - ret =list_empty (&sdp->sd_ail1_list); + empty =list_empty (&sdp->sd_ail1_list);spin_unlock (&sdp->sd_ail_lock);if (test_bit (SDF_WITHDRAWING , &sdp->sd_flags)) {
@@ -377,7 +378,7 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)gfs2_withdraw (sdp); } -return ret; +return empty; }static void gfs2_ail1_wait (struct gfs2_sbd *sdp)
@@ -974,8 +975,9 @@ void gfs2_ail_drain(struct gfs2_sbd *sdp)static void empty_ail1_list (struct gfs2_sbd *sdp) {unsigned long start = jiffies; +bool empty = false; -for (;;) { +while (!empty) {if (time_after (jiffies, start + (HZ *600 ))) {fs_err (sdp,"Error: In %s for 10 minutes! t=%d\n" , __func__, current->journal_info ?1 :0 );
@@ -984,8 +986,7 @@ static void empty_ail1_list(struct gfs2_sbd *sdp) }gfs2_ail1_start (sdp);gfs2_ail1_wait (sdp); -if (gfs2_ail1_empty (sdp,0 )) -return ; + empty =gfs2_ail1_empty (sdp,0 ); } }
Signature · 1 line
2.43.0
Andreas Gruenbacher
maintainerPATCH 2/4 gfs2: Mark withdraws as unlikely
Mark the gfs2_withdrawn(), gfs2_withdrawing(), and gfs2_withdraw_in_prog() inline functions as likely to return %false. This allows to get rid of likely() and unlikely() annotations at the call sites of those functions.
--- fs/gfs2/aops.c | 2 +- fs/gfs2/file.c | 2 +- fs/gfs2/glock.c | 4 ++-- fs/gfs2/meta_io.c | 6 +++--- fs/gfs2/ops_fstype.c | 2 +- fs/gfs2/super.c | 2 +- fs/gfs2/trans.c | 2 +- fs/gfs2/util.h | 10 +++++----- 8 files changed, 15 insertions(+), 15 deletions(-)
fs/gfs2/aops.c +1 -1
@@ -462,7 +462,7 @@ static int gfs2_read_folio(struct file *file, struct folio *folio) error =mpage_read_folio (folio, gfs2_block_map); } -if (unlikely (gfs2_withdrawn (sdp))) +if (gfs2_withdrawn (sdp))return -EIO ;return error;
fs/gfs2/file.c +1 -1
@@ -1442,7 +1442,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)if (!(fl->fl_flags &FL_POSIX ))return -ENOLCK ; -if (unlikely (gfs2_withdrawn (sdp))) { +if (gfs2_withdrawn (sdp)) {if (fl->fl_type ==F_UNLCK )locks_lock_file_wait (file, fl);return -EIO ;
fs/gfs2/glock.c +2 -2
@@ -156,7 +156,7 @@ static bool glock_blocked_by_withdraw(struct gfs2_glock *gl) {struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; -if (likely (!gfs2_withdrawn (sdp))) +if (!gfs2_withdrawn (sdp))return false;if (gl->gl_ops->go_flags &GLOF_NONDISK )return false;
@@ -774,7 +774,7 @@ __acquires(&gl->gl_lockref.lock)* gfs2_gl_hash_clear calls clear_glock) and recovery is complete * then it's okay to tell dlm to unlock it. */ -if (unlikely (sdp->sd_log_error && !gfs2_withdrawn (sdp))) +if (unlikely (sdp->sd_log_error) && !gfs2_withdrawn (sdp))gfs2_withdraw_delayed (sdp); if (glock_blocked_by_withdraw(gl) && (target != LM_ST_UNLOCKED ||
fs/gfs2/meta_io.c +3 -3
@@ -252,7 +252,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,struct buffer_head *bh, *bhs[2 ];int num =0 ; -if (unlikely (gfs2_withdrawn (sdp)) && !gfs2_withdraw_in_prog (sdp)) { +if (gfs2_withdrawn (sdp) && !gfs2_withdraw_in_prog (sdp)) { *bhp =NULL ;return -EIO ; }
@@ -310,7 +310,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 (gfs2_withdrawn (sdp)) && !gfs2_withdraw_in_prog (sdp)) +if (gfs2_withdrawn (sdp) && !gfs2_withdraw_in_prog (sdp))return -EIO ;wait_on_buffer (bh);
@@ -321,7 +321,7 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh)gfs2_io_error_bh_wd (sdp, bh);return -EIO ; } -if (unlikely (gfs2_withdrawn (sdp)) && !gfs2_withdraw_in_prog (sdp)) +if (gfs2_withdrawn (sdp) && !gfs2_withdraw_in_prog (sdp))return -EIO ;return 0 ;
fs/gfs2/ops_fstype.c +1 -1
@@ -1073,7 +1073,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 (!gfs2_withdrawn (sdp)) && lm->lm_unmount) +if (!gfs2_withdrawn (sdp) && lm->lm_unmount) lm->lm_unmount (sdp); }
fs/gfs2/super.c +1 -1
@@ -499,7 +499,7 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)return ; } -if (unlikely (gfs2_withdrawn (sdp))) +if (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);
fs/gfs2/trans.c +1 -1
@@ -268,7 +268,7 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) (unsigned long long)bd->bd_bh->b_blocknr);BUG (); } -if (unlikely (gfs2_withdrawn (sdp))) { +if (gfs2_withdrawn (sdp)) {fs_info (sdp,"GFS2:adding buf while withdrawn! 0x%llx\n" , (unsigned long long )bd->bd_bh->b_blocknr); goto out_unlock;
fs/gfs2/util.h +5 -5
@@ -203,8 +203,8 @@ static inline void gfs2_withdraw_delayed(struct gfs2_sbd *sdp)*/ static inline bool gfs2_withdrawn (struct gfs2_sbd *sdp) { -return test_bit (SDF_WITHDRAWN , &sdp->sd_flags) || -test_bit (SDF_WITHDRAWING , &sdp->sd_flags); +return unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags) || +test_bit (SDF_WITHDRAWING , &sdp->sd_flags)); }/**
@@ -213,13 +213,13 @@ static inline bool gfs2_withdrawn(struct gfs2_sbd *sdp)*/ static inline bool gfs2_withdrawing (struct gfs2_sbd *sdp) { -return test_bit (SDF_WITHDRAWING , &sdp->sd_flags) && - !test_bit (SDF_WITHDRAWN , &sdp->sd_flags); +return unlikely (test_bit (SDF_WITHDRAWING , &sdp->sd_flags) && + !test_bit (SDF_WITHDRAWN , &sdp->sd_flags)); }static inline bool gfs2_withdraw_in_prog (struct gfs2_sbd *sdp) { -return test_bit (SDF_WITHDRAW_IN_PROG , &sdp->sd_flags); +return unlikely (test_bit (SDF_WITHDRAW_IN_PROG , &sdp->sd_flags)); }#define gfs2_tune_get (sdp, field) \
Signature · 1 line
2.43.0
Andreas Gruenbacher
maintainerPATCH 3/4 gfs2: Rename gfs2_withdrawn to gfs2_withdrawing_or_withdrawn
In reply to Andreas GruenbacherThis function checks whether the filesystem has been been marked to be withdrawn eventually or has been withdrawn already. Rename this function to avoid confusing code like checking for gfs2_withdrawing() when gfs2_withdrawn() has already returned true.
--- fs/gfs2/aops.c | 2 +- fs/gfs2/file.c | 2 +- fs/gfs2/glock.c | 8 ++++---- fs/gfs2/glops.c | 2 +- fs/gfs2/lock_dlm.c | 8 ++++---- fs/gfs2/log.c | 21 +++++++++++---------- fs/gfs2/meta_io.c | 9 ++++++--- fs/gfs2/ops_fstype.c | 2 +- fs/gfs2/quota.c | 8 ++++---- fs/gfs2/recovery.c | 2 +- fs/gfs2/super.c | 10 +++++----- fs/gfs2/sys.c | 2 +- fs/gfs2/trans.c | 2 +- fs/gfs2/util.c | 4 ++-- fs/gfs2/util.h | 5 +++-- 15 files changed, 46 insertions(+), 41 deletions(-)
fs/gfs2/aops.c +1 -1
@@ -462,7 +462,7 @@ static int gfs2_read_folio(struct file *file, struct folio *folio) error =mpage_read_folio (folio, gfs2_block_map); } -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp))return -EIO ;return error;
fs/gfs2/file.c +1 -1
@@ -1442,7 +1442,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)if (!(fl->fl_flags &FL_POSIX ))return -ENOLCK ; -if (gfs2_withdrawn (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp)) {if (fl->fl_type ==F_UNLCK )locks_lock_file_wait (file, fl);return -EIO ;
fs/gfs2/glock.c +4 -4
@@ -156,7 +156,7 @@ static bool glock_blocked_by_withdraw(struct gfs2_glock *gl) {struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; -if (!gfs2_withdrawn (sdp)) +if (!gfs2_withdrawing_or_withdrawn (sdp))return false;if (gl->gl_ops->go_flags &GLOF_NONDISK )return false;
@@ -278,7 +278,7 @@ static void __gfs2_glock_put(struct gfs2_glock *gl)GLOCK_BUG_ON (gl, !list_empty (&gl->gl_holders));if (mapping) {truncate_inode_pages_final (mapping); -if (!gfs2_withdrawn (sdp)) +if (!gfs2_withdrawing_or_withdrawn (sdp))GLOCK_BUG_ON (gl, !mapping_empty (mapping)); }trace_gfs2_glock_put (gl);
@@ -774,7 +774,7 @@ __acquires(&gl->gl_lockref.lock)* gfs2_gl_hash_clear calls clear_glock) and recovery is complete * then it's okay to tell dlm to unlock it. */ -if (unlikely (sdp->sd_log_error) && !gfs2_withdrawn (sdp)) +if (unlikely (sdp->sd_log_error) && !gfs2_withdrawing_or_withdrawn (sdp))gfs2_withdraw_delayed (sdp); if (glock_blocked_by_withdraw(gl) && (target != LM_ST_UNLOCKED ||
@@ -811,7 +811,7 @@ __acquires(&gl->gl_lockref.lock)gfs2_glock_queue_work (gl,0 ); }else if (ret) {fs_err (sdp,"lm_lock ret %d\n" , ret); -GLOCK_BUG_ON (gl, !gfs2_withdrawn (sdp)); +GLOCK_BUG_ON (gl, !gfs2_withdrawing_or_withdrawn (sdp)); } }else {/* lock_nolock */ finish_xmote (gl, target);
fs/gfs2/glops.c +1 -1
@@ -174,7 +174,7 @@ static int gfs2_rgrp_metasync(struct gfs2_glock *gl)filemap_fdatawrite_range (metamapping, start, end); error =filemap_fdatawait_range (metamapping, start, end); -WARN_ON_ONCE (error && !gfs2_withdrawn (sdp)); +WARN_ON_ONCE (error && !gfs2_withdrawing_or_withdrawn (sdp));mapping_set_error (metamapping, error);if (error)gfs2_io_error (sdp);
fs/gfs2/lock_dlm.c +4 -4
@@ -1122,7 +1122,7 @@ static void gdlm_recover_prep(void *arg)struct gfs2_sbd *sdp = arg;struct lm_lockstruct *ls = &sdp->sd_lockstruct; -if (gfs2_withdrawn (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp)) {fs_err (sdp,"recover_prep ignored due to withdraw.\n" );return ; }
@@ -1148,7 +1148,7 @@ static void gdlm_recover_slot(void *arg, struct dlm_slot *slot)struct lm_lockstruct *ls = &sdp->sd_lockstruct;int jid = slot->slot -1 ; -if (gfs2_withdrawn (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp)) {fs_err (sdp,"recover_slot jid %d ignored due to withdraw.\n" , jid);return ;
@@ -1177,7 +1177,7 @@ static void gdlm_recover_done(void *arg, struct dlm_slot *slots, int num_slots,struct gfs2_sbd *sdp = arg;struct lm_lockstruct *ls = &sdp->sd_lockstruct; -if (gfs2_withdrawn (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp)) {fs_err (sdp,"recover_done ignored due to withdraw.\n" );return ; }
@@ -1208,7 +1208,7 @@ static void gdlm_recovery_result(struct gfs2_sbd *sdp, unsigned int jid, {struct lm_lockstruct *ls = &sdp->sd_lockstruct; -if (gfs2_withdrawn (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp)) {fs_err (sdp,"recovery_result jid %d ignored due to withdraw.\n" , jid);return ;
fs/gfs2/log.c +11 -10
@@ -126,7 +126,7 @@ __acquires(&sdp->sd_ail_lock) } } -if (gfs2_withdrawn (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp)) {gfs2_remove_from_ail (bd);continue ; }
@@ -842,7 +842,7 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,struct super_block *sb = sdp->sd_vfs;u64 dblock; -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp))return ; page =mempool_alloc (gfs2_page_pool,GFP_NOIO );
@@ -1048,7 +1048,8 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)* Do this check while holding the log_flush_lock to prevent new * buffers from being added to the ail via gfs2_pin() */ -if (gfs2_withdrawn (sdp) || !test_bit (SDF_JOURNAL_LIVE , &sdp->sd_flags)) +if (gfs2_withdrawing_or_withdrawn (sdp) || + !test_bit (SDF_JOURNAL_LIVE , &sdp->sd_flags)) goto out;/* Log might have been flushed while we waited for the flush lock */
@@ -1097,13 +1098,13 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) goto out_withdraw;gfs2_ordered_write (sdp); -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp)) goto out_withdraw;lops_before_commit (sdp, tr); -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp)) goto out_withdraw;gfs2_log_submit_bio (&sdp->sd_jdesc->jd_log_bio,REQ_OP_WRITE ); -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp)) goto out_withdraw;if (sdp->sd_log_head != sdp->sd_log_flush_head) {
@@ -1111,7 +1112,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) }else if (sdp->sd_log_tail != sdp->sd_log_flush_tail && !sdp->sd_log_idle) {log_write_header (sdp, flags); } -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp)) goto out_withdraw;lops_after_commit (sdp, tr);
@@ -1129,7 +1130,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)if (!(flags &GFS2_LOG_HEAD_FLUSH_NORMAL )) {if (!sdp->sd_log_idle) {empty_ail1_list (sdp); -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp)) goto out_withdraw;log_write_header (sdp, flags); }
@@ -1299,7 +1300,7 @@ int gfs2_logd(void *data)unsigned long t =1 ;while (!kthread_should_stop ()) { -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp))break ;/* Check for errors writing to the journal */
@@ -1338,7 +1339,7 @@ int gfs2_logd(void *data)gfs2_ail_flush_reqd (sdp) ||gfs2_jrnl_flush_reqd (sdp) || sdp->sd_log_error || -gfs2_withdrawn (sdp) || +gfs2_withdrawing_or_withdrawn (sdp) ||kthread_should_stop (), t); }
fs/gfs2/meta_io.c +6 -3
@@ -252,7 +252,8 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,struct buffer_head *bh, *bhs[2 ];int num =0 ; -if (gfs2_withdrawn (sdp) && !gfs2_withdraw_in_prog (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp) && + !gfs2_withdraw_in_prog (sdp)) { *bhp =NULL ;return -EIO ; }
@@ -310,7 +311,8 @@ 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 (gfs2_withdrawn (sdp) && !gfs2_withdraw_in_prog (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp) && + !gfs2_withdraw_in_prog (sdp))return -EIO ;wait_on_buffer (bh);
@@ -321,7 +323,8 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh)gfs2_io_error_bh_wd (sdp, bh);return -EIO ; } -if (gfs2_withdrawn (sdp) && !gfs2_withdraw_in_prog (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp) && + !gfs2_withdraw_in_prog (sdp))return -EIO ;return 0 ;
fs/gfs2/ops_fstype.c +1 -1
@@ -1073,7 +1073,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 (!gfs2_withdrawn (sdp) && lm->lm_unmount) +if (!gfs2_withdrawing_or_withdrawn (sdp) && lm->lm_unmount) lm->lm_unmount (sdp); }
fs/gfs2/quota.c +4 -4
@@ -128,7 +128,7 @@ static void gfs2_qd_dispose(struct gfs2_quota_data *qd)hlist_bl_del_rcu (&qd->qd_hlist);spin_unlock_bucket (qd->qd_hash); -if (!gfs2_withdrawn (sdp)) { +if (!gfs2_withdrawing_or_withdrawn (sdp)) {gfs2_assert_warn (sdp, !qd->qd_change);gfs2_assert_warn (sdp, !qd->qd_slot_ref);gfs2_assert_warn (sdp, !qd->qd_bh_count);
@@ -1540,7 +1540,7 @@ static void quotad_error(struct gfs2_sbd *sdp, const char *msg, int error) {if (error ==0 || error == -EROFS )return ; -if (!gfs2_withdrawn (sdp)) { +if (!gfs2_withdrawing_or_withdrawn (sdp)) {if (!cmpxchg (&sdp->sd_log_error,0 , error))fs_err (sdp,"gfs2_quotad: %s error %d\n" , msg, error);wake_up (&sdp->sd_logd_waitq);
@@ -1584,7 +1584,7 @@ int gfs2_quotad(void *data)unsigned long t =0 ;while (!kthread_should_stop ()) { -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp))break ;/* Update the master statfs file */
@@ -1608,7 +1608,7 @@ int gfs2_quotad(void *data) t =wait_event_interruptible_timeout (sdp->sd_quota_wait, sdp->sd_statfs_force_sync || -gfs2_withdrawn (sdp) || +gfs2_withdrawing_or_withdrawn (sdp) ||kthread_should_stop (), t);
fs/gfs2/recovery.c +1 -1
@@ -411,7 +411,7 @@ void gfs2_recover_func(struct work_struct *work)int error =0 ;int jlocked =0 ; -if (gfs2_withdrawn (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp)) {fs_err (sdp,"jid=%u: Recovery not attempted due to withdraw.\n" , jd->jd_jid); goto fail;
fs/gfs2/super.c +5 -5
@@ -134,7 +134,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)int error; j_gl->gl_ops->go_inval (j_gl,DIO_METADATA ); -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp))return -EIO ; error =gfs2_find_jhead (sdp->sd_jdesc, &head, false);
@@ -153,7 +153,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)gfs2_log_pointers_init (sdp, head.lh_blkno); error =gfs2_quota_init (sdp); -if (!error &&gfs2_withdrawn (sdp)) +if (!error &&gfs2_withdrawing_or_withdrawn (sdp)) error = -EIO ;if (!error)set_bit (SDF_JOURNAL_LIVE , &sdp->sd_flags);
@@ -499,7 +499,7 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)return ; } -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_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);
@@ -605,7 +605,7 @@ static void gfs2_put_super(struct super_block *sb)if (!sb_rdonly (sb))gfs2_make_fs_ro (sdp);else { -if (gfs2_withdrawn (sdp)) +if (gfs2_withdrawing_or_withdrawn (sdp))gfs2_destroy_threads (sdp);gfs2_quota_cleanup (sdp);
@@ -685,7 +685,7 @@ static int gfs2_freeze_locally(struct gfs2_sbd *sdp)if (test_bit (SDF_JOURNAL_LIVE , &sdp->sd_flags)) {gfs2_log_flush (sdp,NULL ,GFS2_LOG_HEAD_FLUSH_FREEZE |GFS2_LFC_FREEZE_GO_SYNC ); -if (gfs2_withdrawn (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp)) { error =thaw_super (sb,FREEZE_HOLDER_USERSPACE );if (error)return error;
fs/gfs2/sys.c +1 -1
@@ -193,7 +193,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 =gfs2_withdrawn (sdp); +unsigned int b =gfs2_withdrawing_or_withdrawn (sdp);return snprintf (buf,PAGE_SIZE ,"%u\n" , b); }
fs/gfs2/trans.c +1 -1
@@ -268,7 +268,7 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) (unsigned long long)bd->bd_bh->b_blocknr);BUG (); } -if (gfs2_withdrawn (sdp)) { +if (gfs2_withdrawing_or_withdrawn (sdp)) {fs_info (sdp,"GFS2:adding buf while withdrawn! 0x%llx\n" , (unsigned long long )bd->bd_bh->b_blocknr); goto out_unlock;
fs/gfs2/util.c +2 -2
@@ -372,7 +372,7 @@ void gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion, const char *function, char *file, unsigned int line, bool delayed) { - if (gfs2_withdrawn(sdp)) + if (gfs2_withdrawing_or_withdrawn(sdp)) return; fs_err(sdp,
@@ -548,7 +548,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 (gfs2_withdrawn(sdp)) + if (gfs2_withdrawing_or_withdrawn(sdp)) return; fs_err(sdp, "fatal: I/O error\n"
fs/gfs2/util.h +3 -2
@@ -198,10 +198,11 @@ static inline void gfs2_withdraw_delayed(struct gfs2_sbd *sdp) }/** -* gfs2_withdrawn - test whether the file system is withdrawing or withdrawn +* gfs2_withdrawing_or_withdrawn - test whether the file system is withdrawing +* or withdrawn * @sdp: the superblock */ -static inline bool gfs2_withdrawn (struct gfs2_sbd *sdp) +static inline bool gfs2_withdrawing_or_withdrawn (struct gfs2_sbd *sdp) {return unlikely (test_bit (SDF_WITHDRAWN , &sdp->sd_flags) ||test_bit (SDF_WITHDRAWING , &sdp->sd_flags));
Signature · 1 line
2.43.0
Andreas Gruenbacher
maintainerPATCH 4/4 gfs2: Lift withdraw check out of gfs2_ail1_empty
In reply to Andreas GruenbacherLift the check for the SDF_WITHDRAWING flag out of gfs2_ail1_empty() and into its callers. This is needed so that gfs2_flush_revokes() can drop the sd_log_lock spinlock before triggering a withdraw if necessary.
Instead of checking for the SDF_WITHDRAWING flag, use gfs2_withdrawing(). Also, the low-level code triggering the delayed withdraw reports when there is a problem, so there is no need to report that again.
--- fs/gfs2/log.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
fs/gfs2/log.c +12 -5
@@ -373,11 +373,6 @@ static bool gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes) empty =list_empty (&sdp->sd_ail1_list);spin_unlock (&sdp->sd_ail_lock); -if (test_bit (SDF_WITHDRAWING , &sdp->sd_flags)) { -gfs2_lm (sdp,"fatal: I/O error(s)\n" ); -gfs2_withdraw (sdp); - } -return empty; }
@@ -815,6 +810,9 @@ void gfs2_flush_revokes(struct gfs2_sbd *sdp)gfs2_log_lock (sdp);gfs2_ail1_empty (sdp, max_revokes);gfs2_log_unlock (sdp); + +if (gfs2_withdrawing (sdp)) +gfs2_withdraw (sdp); }/**
@@ -987,7 +985,13 @@ static void empty_ail1_list(struct gfs2_sbd *sdp)gfs2_ail1_start (sdp);gfs2_ail1_wait (sdp); empty =gfs2_ail1_empty (sdp,0 ); + +if (gfs2_withdrawing_or_withdrawn (sdp)) +break ; } + +if (gfs2_withdrawing (sdp)) +gfs2_withdraw (sdp); }/**
@@ -1344,6 +1348,9 @@ int gfs2_logd(void *data) t); } +if (gfs2_withdrawing (sdp)) +gfs2_withdraw (sdp); +return 0 ; }
Signature · 1 line
2.43.0