* [Cluster-devel] [PATCH 0/4] gfs2: logd cleanups on for-next
@ 2023-08-24 21:10 Andreas Gruenbacher
2023-08-24 21:10 ` [Cluster-devel] [PATCH 1/4] gfs2: Switch to wait_event in gfs2_logd Andreas Gruenbacher
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andreas Gruenbacher @ 2023-08-24 21:10 UTC (permalink / raw)
To: cluster-devel
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(-)
--
2.40.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 1/4] gfs2: Switch to wait_event in gfs2_logd
2023-08-24 21:10 [Cluster-devel] [PATCH 0/4] gfs2: logd cleanups on for-next Andreas Gruenbacher
@ 2023-08-24 21:10 ` Andreas Gruenbacher
2023-08-24 21:10 ` [Cluster-devel] [PATCH 2/4] gfs2: low-memory forced flush fixes Andreas Gruenbacher
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Gruenbacher @ 2023-08-24 21:10 UTC (permalink / raw)
To: cluster-devel
In gfs2_logd(), switch from an open-coded wait loop to
wait_event_interruptible_timeout().
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/log.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index aa568796207c..d3da259820e3 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -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;
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 2/4] gfs2: low-memory forced flush fixes
2023-08-24 21:10 [Cluster-devel] [PATCH 0/4] gfs2: logd cleanups on for-next Andreas Gruenbacher
2023-08-24 21:10 ` [Cluster-devel] [PATCH 1/4] gfs2: Switch to wait_event in gfs2_logd Andreas Gruenbacher
@ 2023-08-24 21:10 ` Andreas Gruenbacher
2023-08-24 21:11 ` [Cluster-devel] [PATCH 3/4] gfs2: Fix logd wakeup on I/O error Andreas Gruenbacher
2023-08-24 21:11 ` [Cluster-devel] [PATCH 4/4] gfs2: journal flush threshold fixes and cleanup Andreas Gruenbacher
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Gruenbacher @ 2023-08-24 21:10 UTC (permalink / raw)
To: cluster-devel
Function 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.
Fixes: b066a4eebd4f ("gfs2: forcibly flush ail to relieve memory pressure")
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/aops.c | 4 +++-
fs/gfs2/log.c | 8 ++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 5f02542370c4..d15a10a18962 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -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;
}
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index d3da259820e3..aaca22f2aa2d 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -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(),
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 3/4] gfs2: Fix logd wakeup on I/O error
2023-08-24 21:10 [Cluster-devel] [PATCH 0/4] gfs2: logd cleanups on for-next Andreas Gruenbacher
2023-08-24 21:10 ` [Cluster-devel] [PATCH 1/4] gfs2: Switch to wait_event in gfs2_logd Andreas Gruenbacher
2023-08-24 21:10 ` [Cluster-devel] [PATCH 2/4] gfs2: low-memory forced flush fixes Andreas Gruenbacher
@ 2023-08-24 21:11 ` Andreas Gruenbacher
2023-08-24 21:11 ` [Cluster-devel] [PATCH 4/4] gfs2: journal flush threshold fixes and cleanup Andreas Gruenbacher
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Gruenbacher @ 2023-08-24 21:11 UTC (permalink / raw)
To: cluster-devel
When 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.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/log.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index aaca22f2aa2d..abe4397dc59b 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -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);
}
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 4/4] gfs2: journal flush threshold fixes and cleanup
2023-08-24 21:10 [Cluster-devel] [PATCH 0/4] gfs2: logd cleanups on for-next Andreas Gruenbacher
` (2 preceding siblings ...)
2023-08-24 21:11 ` [Cluster-devel] [PATCH 3/4] gfs2: Fix logd wakeup on I/O error Andreas Gruenbacher
@ 2023-08-24 21:11 ` Andreas Gruenbacher
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Gruenbacher @ 2023-08-24 21:11 UTC (permalink / raw)
To: cluster-devel
Commit 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().
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/log.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index abe4397dc59b..addf4ce0bedd 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -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
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-24 21:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-24 21:10 [Cluster-devel] [PATCH 0/4] gfs2: logd cleanups on for-next Andreas Gruenbacher
2023-08-24 21:10 ` [Cluster-devel] [PATCH 1/4] gfs2: Switch to wait_event in gfs2_logd Andreas Gruenbacher
2023-08-24 21:10 ` [Cluster-devel] [PATCH 2/4] gfs2: low-memory forced flush fixes Andreas Gruenbacher
2023-08-24 21:11 ` [Cluster-devel] [PATCH 3/4] gfs2: Fix logd wakeup on I/O error Andreas Gruenbacher
2023-08-24 21:11 ` [Cluster-devel] [PATCH 4/4] gfs2: journal flush threshold fixes and cleanup Andreas Gruenbacher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).