All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Bob Peterson <rpeterso@redhat.com>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Sasha Levin <sashal@kernel.org>,
	cluster-devel@redhat.com
Subject: [PATCH AUTOSEL 5.8 22/42] gfs2: add some much needed cleanup for log flushes that fail
Date: Mon, 31 Aug 2020 11:29:14 -0400	[thread overview]
Message-ID: <20200831152934.1023912-22-sashal@kernel.org> (raw)
In-Reply-To: <20200831152934.1023912-1-sashal@kernel.org>

From: Bob Peterson <rpeterso@redhat.com>

[ Upstream commit 462582b99b6079a6fbcdfc65bac49f5c2a27cfff ]

When a log flush fails due to io errors, it signals the failure but does
not clean up after itself very well. This is because buffers are added to
the transaction tr_buf and tr_databuf queue, but the io error causes
gfs2_log_flush to bypass the "after_commit" functions responsible for
dequeueing the bd elements. If the bd elements are added to the ail list
before the error, function ail_drain takes care of dequeueing them.
But if they haven't gotten that far, the elements are forgotten and
make the transactions unable to be freed.

This patch introduces new function trans_drain which drains the bd
elements from the transaction so they can be freed properly.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/gfs2/log.c   | 31 +++++++++++++++++++++++++++++++
 fs/gfs2/trans.c |  1 +
 2 files changed, 32 insertions(+)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index a76e55bc28ebf..27f467a0f008e 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -901,6 +901,36 @@ static void empty_ail1_list(struct gfs2_sbd *sdp)
 	}
 }
 
+/**
+ * drain_bd - drain the buf and databuf queue for a failed transaction
+ * @tr: the transaction to drain
+ *
+ * When this is called, we're taking an error exit for a log write that failed
+ * but since we bypassed the after_commit functions, we need to remove the
+ * items from the buf and databuf queue.
+ */
+static void trans_drain(struct gfs2_trans *tr)
+{
+	struct gfs2_bufdata *bd;
+	struct list_head *head;
+
+	if (!tr)
+		return;
+
+	head = &tr->tr_buf;
+	while (!list_empty(head)) {
+		bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
+		list_del_init(&bd->bd_list);
+		kmem_cache_free(gfs2_bufdata_cachep, bd);
+	}
+	head = &tr->tr_databuf;
+	while (!list_empty(head)) {
+		bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
+		list_del_init(&bd->bd_list);
+		kmem_cache_free(gfs2_bufdata_cachep, bd);
+	}
+}
+
 /**
  * gfs2_log_flush - flush incore transaction(s)
  * @sdp: the filesystem
@@ -1005,6 +1035,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
 
 out:
 	if (gfs2_withdrawn(sdp)) {
+		trans_drain(tr);
 		/**
 		 * If the tr_list is empty, we're withdrawing during a log
 		 * flush that targets a transaction, but the transaction was
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index a3dfa3aa87ad9..d897dd73c5999 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -52,6 +52,7 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
 		tr->tr_reserved += gfs2_struct2blk(sdp, revokes);
 	INIT_LIST_HEAD(&tr->tr_databuf);
 	INIT_LIST_HEAD(&tr->tr_buf);
+	INIT_LIST_HEAD(&tr->tr_list);
 	INIT_LIST_HEAD(&tr->tr_ail1_list);
 	INIT_LIST_HEAD(&tr->tr_ail2_list);
 
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH AUTOSEL 5.8 22/42] gfs2: add some much needed cleanup for log flushes that fail
Date: Mon, 31 Aug 2020 11:29:14 -0400	[thread overview]
Message-ID: <20200831152934.1023912-22-sashal@kernel.org> (raw)
In-Reply-To: <20200831152934.1023912-1-sashal@kernel.org>

From: Bob Peterson <rpeterso@redhat.com>

[ Upstream commit 462582b99b6079a6fbcdfc65bac49f5c2a27cfff ]

When a log flush fails due to io errors, it signals the failure but does
not clean up after itself very well. This is because buffers are added to
the transaction tr_buf and tr_databuf queue, but the io error causes
gfs2_log_flush to bypass the "after_commit" functions responsible for
dequeueing the bd elements. If the bd elements are added to the ail list
before the error, function ail_drain takes care of dequeueing them.
But if they haven't gotten that far, the elements are forgotten and
make the transactions unable to be freed.

This patch introduces new function trans_drain which drains the bd
elements from the transaction so they can be freed properly.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/gfs2/log.c   | 31 +++++++++++++++++++++++++++++++
 fs/gfs2/trans.c |  1 +
 2 files changed, 32 insertions(+)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index a76e55bc28ebf..27f467a0f008e 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -901,6 +901,36 @@ static void empty_ail1_list(struct gfs2_sbd *sdp)
 	}
 }
 
+/**
+ * drain_bd - drain the buf and databuf queue for a failed transaction
+ * @tr: the transaction to drain
+ *
+ * When this is called, we're taking an error exit for a log write that failed
+ * but since we bypassed the after_commit functions, we need to remove the
+ * items from the buf and databuf queue.
+ */
+static void trans_drain(struct gfs2_trans *tr)
+{
+	struct gfs2_bufdata *bd;
+	struct list_head *head;
+
+	if (!tr)
+		return;
+
+	head = &tr->tr_buf;
+	while (!list_empty(head)) {
+		bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
+		list_del_init(&bd->bd_list);
+		kmem_cache_free(gfs2_bufdata_cachep, bd);
+	}
+	head = &tr->tr_databuf;
+	while (!list_empty(head)) {
+		bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
+		list_del_init(&bd->bd_list);
+		kmem_cache_free(gfs2_bufdata_cachep, bd);
+	}
+}
+
 /**
  * gfs2_log_flush - flush incore transaction(s)
  * @sdp: the filesystem
@@ -1005,6 +1035,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
 
 out:
 	if (gfs2_withdrawn(sdp)) {
+		trans_drain(tr);
 		/**
 		 * If the tr_list is empty, we're withdrawing during a log
 		 * flush that targets a transaction, but the transaction was
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index a3dfa3aa87ad9..d897dd73c5999 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -52,6 +52,7 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
 		tr->tr_reserved += gfs2_struct2blk(sdp, revokes);
 	INIT_LIST_HEAD(&tr->tr_databuf);
 	INIT_LIST_HEAD(&tr->tr_buf);
+	INIT_LIST_HEAD(&tr->tr_list);
 	INIT_LIST_HEAD(&tr->tr_ail1_list);
 	INIT_LIST_HEAD(&tr->tr_ail2_list);
 
-- 
2.25.1




  parent reply	other threads:[~2020-08-31 15:39 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 15:28 [PATCH AUTOSEL 5.8 01/42] hwmon: (pmbus/isl68137) remove READ_TEMPERATURE_1 telemetry for RAA228228 Sasha Levin
2020-08-31 15:28 ` [PATCH AUTOSEL 5.8 02/42] HID: quirks: Always poll three more Lenovo PixArt mice Sasha Levin
2020-08-31 15:28 ` [PATCH AUTOSEL 5.8 03/42] HID: hiddev: Fix slab-out-of-bounds write in hiddev_ioctl_usage() Sasha Levin
2020-08-31 15:28 ` [PATCH AUTOSEL 5.8 04/42] drm/msm/dpu: Fix reservation failures in modeset Sasha Levin
2020-08-31 15:28   ` Sasha Levin
2020-08-31 15:28 ` [PATCH AUTOSEL 5.8 05/42] drm/msm/dpu: Fix scale params in plane validation Sasha Levin
2020-08-31 15:28   ` Sasha Levin
2020-08-31 15:28 ` [PATCH AUTOSEL 5.8 06/42] drm/msm/dpu: fix unitialized variable error Sasha Levin
2020-08-31 15:28   ` Sasha Levin
2020-08-31 15:28 ` [PATCH AUTOSEL 5.8 07/42] speakup: Fix wait_for_xmitr for ttyio case Sasha Levin
2020-08-31 15:28   ` Sasha Levin
2020-08-31 15:33   ` Greg Kroah-Hartman
2020-08-31 15:33     ` Greg Kroah-Hartman
2020-09-05 12:02     ` Sasha Levin
2020-09-05 12:02       ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 08/42] tty: serial: qcom_geni_serial: Drop __init from qcom_geni_console_setup Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 09/42] drm/msm: add shutdown support for display platform_driver Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 10/42] hwmon: (applesmc) check status earlier Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 11/42] nvme: skip noiob for zoned devices Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:38   ` Keith Busch
2020-08-31 15:38     ` Keith Busch
2020-09-05 12:03     ` Sasha Levin
2020-09-05 12:03       ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 12/42] nvmet: Disable keep-alive timer when kato is cleared to 0h Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 13/42] drm/msm: enable vblank during atomic commits Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 14/42] habanalabs: unmap PCI bars upon iATU failure Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 15/42] habanalabs: validate packet id during CB parse Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 16/42] habanalabs: set clock gating according to mask Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 17/42] habanalabs: proper handling of alloc size in coresight Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 18/42] habanalabs: set max power according to card type Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 19/42] habanalabs: validate FW file size Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 20/42] habanalabs: check correct vmalloc return code Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 21/42] drm/msm/a6xx: fix gmu start on newer firmware Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` Sasha Levin [this message]
2020-08-31 15:29   ` [Cluster-devel] [PATCH AUTOSEL 5.8 22/42] gfs2: add some much needed cleanup for log flushes that fail Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 23/42] hv_utils: return error if host timesysnc update is stale Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 24/42] hv_utils: drain the timesync packets on onchannelcallback Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 25/42] ceph: fix inode number handling on arches with 32-bit ino_t Sasha Levin
2020-08-31 16:08   ` Ilya Dryomov
2020-09-05 12:04     ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 26/42] ceph: don't allow setlease on cephfs Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 27/42] i2c: iproc: Fix shifting 31 bits Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 28/42] drm/omap: fix incorrect lock state Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 29/42] irqchip/ingenic: Leave parent IRQ unmasked on suspend Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 30/42] cpuidle: Fixup IRQ state Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 31/42] nbd: restore default timeout when setting it to zero Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 32/42] s390: don't trace preemption in percpu macros Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 33/42] drm/amd/display: should check error using DC_OK Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 34/42] drm/amd/display: Reject overlay plane configurations in multi-display scenarios Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 35/42] drivers: gpu: amd: Initialize amdgpu_dm_backlight_caps object to 0 in amdgpu_dm_update_backlight_caps Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 36/42] drm/amd/display: Revert HDCP disable sequence change Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 37/42] drm/amd/display: Fix passive dongle mistaken as active dongle in EDID emulation Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 38/42] drm/amd/display: Keep current gain when ABM disable immediately Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 39/42] drm/amd/display: Retry AUX write when fail occurs Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 40/42] drm/amd/display: Fix memleak in amdgpu_dm_mode_config_init Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29   ` Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 41/42] xen/xenbus: Fix granting of vmalloc'd memory Sasha Levin
2020-08-31 15:29 ` [PATCH AUTOSEL 5.8 42/42] fsldma: fix very broken 32-bit ppc ioread64 functionality Sasha Levin
2020-08-31 15:29   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200831152934.1023912-22-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=agruenba@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpeterso@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.