From: Tejun Heo <tj@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, Miklos Szeredi <miklos@szeredi.hu>
Cc: Joshua Miller <joshmiller@fb.com>,
kernel-team@fb.com, Johannes Weiner <hannes@cmpxchg.org>,
Jan Kara <jack@suse.cz>,
stable@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/2] bdi: make sure congestion states are clear on free
Date: Fri, 2 Feb 2018 09:53:28 -0800 [thread overview]
Message-ID: <20180202175328.GL1121507@devbig577.frc2.facebook.com> (raw)
FUSE has a bug where it fails to clear congestion states if a
connection gets aborted while congested, which can leave
nr_wb_congested[] stuck until reboot causing wait_iff_congested() to
wait spuriously.
While the bdi owner, FUSE, is primarily responsible for clearing
congestion states before destroying bdi_writebacks, bdi layer can
ensure that congestion states are not leaked beyond bdi_writeback
lifecycle.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Joshua Miller <joshmiller@fb.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jan Kara <jack@suse.cz>
Cc: stable@vger.kernel.org
---
include/linux/backing-dev.h | 14 +++++++++++++-
mm/backing-dev.c | 2 +-
2 files changed, 14 insertions(+), 2 deletions(-)
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -220,6 +220,18 @@ static inline int bdi_sched_wait(void *w
return 0;
}
+static inline void __wb_congested_free(struct bdi_writeback_congested *congested)
+{
+ /*
+ * Make sure congestion states are cleared before freeing to avoid
+ * nr_wb_congested() corruption which can lead to misbehaving
+ * wait_iff_congested().
+ */
+ clear_wb_congested(congested, BLK_RW_SYNC);
+ clear_wb_congested(congested, BLK_RW_ASYNC);
+ kfree(congested);
+}
+
#ifdef CONFIG_CGROUP_WRITEBACK
struct bdi_writeback_congested *
@@ -409,7 +421,7 @@ wb_congested_get_create(struct backing_d
static inline void wb_congested_put(struct bdi_writeback_congested *congested)
{
if (atomic_dec_and_test(&congested->refcnt))
- kfree(congested);
+ __wb_congested_free(congested);
}
static inline struct bdi_writeback *wb_find_current(struct backing_dev_info *bdi)
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -509,7 +509,7 @@ void wb_congested_put(struct bdi_writeba
}
spin_unlock_irqrestore(&cgwb_lock, flags);
- kfree(congested);
+ __wb_congested_free(congested);
}
static void cgwb_release_workfn(struct work_struct *work)
next reply other threads:[~2018-02-02 17:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 17:53 Tejun Heo [this message]
2018-02-02 17:54 ` [PATCH 2/2] FUSE: fix congested state leak on aborted connections Tejun Heo
2018-02-06 16:25 ` Jan Kara
2018-05-30 14:22 ` Miklos Szeredi
2018-02-05 23:02 ` [PATCH 1/2] bdi: make sure congestion states are clear on free Johannes Weiner
2018-02-06 16:19 ` Jan Kara
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=20180202175328.GL1121507@devbig577.frc2.facebook.com \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=hannes@cmpxchg.org \
--cc=jack@suse.cz \
--cc=joshmiller@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--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 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).