gfs2: logd cleanups on for-next
Andreas Gruenbacher
maintainercover gfs2: logd cleanups on for-next
The following four patches related to gfs2's logd daemon are currently queued up on our for-next branch, to be submitted upstream in the upcoming merge window.
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/log/?h=for-next
Thanks,
Andreas
Andreas Gruenbacher (4):
gfs2: Switch to wait_event in gfs2_logd
gfs2: low-memory forced flush fixes
gfs2: Fix logd wakeup on I/O error
gfs2: journal flush threshold fixes and cleanup
fs/gfs2/aops.c | 4 +++- fs/gfs2/log.c | 60 ++++++++++++++++++++++---------------------------- 2 files changed, 29 insertions(+), 35 deletions(-)
Signature · 1 line
2.40.1
Andreas Gruenbacher
maintainerPATCH 1/4 gfs2: Switch to wait_event in gfs2_logd
In gfs2_logd(), switch from an open-coded wait loop to wait_event_interruptible_timeout().
--- fs/gfs2/log.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
fs/gfs2/log.c +5 -12
@@ -1301,7 +1301,6 @@ int gfs2_logd(void *data) {struct gfs2_sbd *sdp = data;unsigned long t =1 ; -DEFINE_WAIT (wait);while (!kthread_should_stop ()) {
@@ -1338,17 +1337,11 @@ int gfs2_logd(void *data)try_to_freeze (); -do { -prepare_to_wait (&sdp->sd_logd_waitq, &wait, -TASK_INTERRUPTIBLE ); -if (!gfs2_ail_flush_reqd (sdp) && - !gfs2_jrnl_flush_reqd (sdp) && - !kthread_should_stop ()) - t =schedule_timeout (t); - }while (t && !gfs2_ail_flush_reqd (sdp) && - !gfs2_jrnl_flush_reqd (sdp) && - !kthread_should_stop ()); -finish_wait (&sdp->sd_logd_waitq, &wait); + t =wait_event_interruptible_timeout (sdp->sd_logd_waitq, +gfs2_ail_flush_reqd (sdp) || +gfs2_jrnl_flush_reqd (sdp) || +kthread_should_stop (), + t); }return 0 ;
Signature · 1 line
2.40.1
Andreas Gruenbacher
maintainerPATCH 2/4 gfs2: low-memory forced flush fixes
In reply to Andreas GruenbacherFunction gfs2_ail_flush_reqd checks the SDF_FORCE_AIL_FLUSH flag to determine if an AIL flush should be forced in low-memory situations. However, it also immediately clears the flag, and when called repeatedly as in function gfs2_logd, the flag will be lost. Fix that by pulling the SDF_FORCE_AIL_FLUSH flag check out of gfs2_ail_flush_reqd.
In addition, in gfs2_writepages, logd needs to be woken up after setting the SDF_FORCE_AIL_FLUSH flag.
--- fs/gfs2/aops.c | 4 +++- fs/gfs2/log.c | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-)
fs/gfs2/aops.c +3 -1
@@ -189,8 +189,10 @@ static int gfs2_writepages(struct address_space *mapping,* pages held in the ail that it can't find. */ ret =iomap_writepages (mapping, wbc, &wpc, &gfs2_writeback_ops); -if (ret ==0 ) +if (ret ==0 ) {set_bit (SDF_FORCE_AIL_FLUSH , &sdp->sd_flags); +wake_up (&sdp->sd_logd_waitq); + }return ret; }
fs/gfs2/log.c +4 -4
@@ -1282,9 +1282,6 @@ static inline int gfs2_ail_flush_reqd(struct gfs2_sbd *sdp) {unsigned int used_blocks = sdp->sd_jdesc->jd_blocks -atomic_read (&sdp->sd_log_blks_free); -if (test_and_clear_bit (SDF_FORCE_AIL_FLUSH , &sdp->sd_flags)) -return 1 ; -return used_blocks +atomic_read (&sdp->sd_log_blks_needed) >=atomic_read (&sdp->sd_log_thresh2); }
@@ -1325,7 +1322,9 @@ int gfs2_logd(void *data) GFS2_LFC_LOGD_JFLUSH_REQD); } -if (gfs2_ail_flush_reqd (sdp)) { +if (test_bit (SDF_FORCE_AIL_FLUSH , &sdp->sd_flags) || +gfs2_ail_flush_reqd (sdp)) { +clear_bit (SDF_FORCE_AIL_FLUSH , &sdp->sd_flags);gfs2_ail1_start (sdp);gfs2_ail1_wait (sdp);gfs2_ail1_empty (sdp,0 );
@@ -1338,6 +1337,7 @@ int gfs2_logd(void *data)try_to_freeze (); t = wait_event_interruptible_timeout(sdp->sd_logd_waitq, + test_bit(SDF_FORCE_AIL_FLUSH, &sdp->sd_flags) || gfs2_ail_flush_reqd(sdp) || gfs2_jrnl_flush_reqd(sdp) || kthread_should_stop(),
Signature · 1 line
2.40.1
Andreas Gruenbacher
maintainerPATCH 3/4 gfs2: Fix logd wakeup on I/O error
In reply to Andreas GruenbacherWhen quotad detects an I/O error, it sets sd_log_error and then it wakes up logd to withdraw the filesystem. However, logd doesn't wake up when sd_log_error is set. Fix that.
--- fs/gfs2/log.c | 1 + 1 file changed, 1 insertion(+)
fs/gfs2/log.c +1 -0
@@ -1340,6 +1340,7 @@ int gfs2_logd(void *data)test_bit (SDF_FORCE_AIL_FLUSH , &sdp->sd_flags) ||gfs2_ail_flush_reqd (sdp) ||gfs2_jrnl_flush_reqd (sdp) || + sdp->sd_log_error ||kthread_should_stop (), t); }
Signature · 1 line
2.40.1
Andreas Gruenbacher
maintainerPATCH 4/4 gfs2: journal flush threshold fixes and cleanup
In reply to Andreas GruenbacherCommit f07b35202148 ("GFS2: Made logd daemon take into account log demand") changed gfs2_ail_flush_reqd() and gfs2_jrnl_flush_reqd() to take sd_log_blks_needed into account, but the checks in gfs2_log_commit() were not updated correspondingly.
Once that is fixed, gfs2_jrnl_flush_reqd() and gfs2_ail_flush_reqd() can be used in gfs2_log_commit(). Make those two helpers available to gfs2_log_commit() by defining them above gfs2_log_commit().
--- fs/gfs2/log.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-)
fs/gfs2/log.c +16 -18
@@ -1227,6 +1227,21 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)gfs2_log_unlock (sdp); } +static inline int gfs2_jrnl_flush_reqd (struct gfs2_sbd *sdp) +{ +return atomic_read (&sdp->sd_log_pinned) + +atomic_read (&sdp->sd_log_blks_needed) >= +atomic_read (&sdp->sd_log_thresh1); +} + +static inline int gfs2_ail_flush_reqd (struct gfs2_sbd *sdp) +{ +return sdp->sd_jdesc->jd_blocks - +atomic_read (&sdp->sd_log_blks_free) + +atomic_read (&sdp->sd_log_blks_needed) >= +atomic_read (&sdp->sd_log_thresh2); +} +/** * gfs2_log_commit - Commit a transaction to the log * @sdp: the filesystem
@@ -1246,9 +1261,7 @@ void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) {log_refund (sdp, tr); -if (atomic_read (&sdp->sd_log_pinned) >atomic_read (&sdp->sd_log_thresh1) || - ((sdp->sd_jdesc->jd_blocks -atomic_read (&sdp->sd_log_blks_free)) > -atomic_read (&sdp->sd_log_thresh2))) +if (gfs2_ail_flush_reqd (sdp) ||gfs2_jrnl_flush_reqd (sdp))wake_up (&sdp->sd_logd_waitq); }
@@ -1271,21 +1284,6 @@ static void gfs2_log_shutdown(struct gfs2_sbd *sdp)gfs2_assert_warn (sdp,list_empty (&sdp->sd_ail2_list)); } -static inline int gfs2_jrnl_flush_reqd (struct gfs2_sbd *sdp) -{ -return (atomic_read (&sdp->sd_log_pinned) + -atomic_read (&sdp->sd_log_blks_needed) >= -atomic_read (&sdp->sd_log_thresh1)); -} - -static inline int gfs2_ail_flush_reqd (struct gfs2_sbd *sdp) -{ -unsigned int used_blocks = sdp->sd_jdesc->jd_blocks -atomic_read (&sdp->sd_log_blks_free); - -return used_blocks +atomic_read (&sdp->sd_log_blks_needed) >= -atomic_read (&sdp->sd_log_thresh2); -} -/** * gfs2_logd - Update log tail as Active Items get flushed to in-place blocks * @data: Pointer to GFS2 superblock
Signature · 1 line
2.40.1