From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 06/11] gfs2: Try harder to delete inodes locally
Date: Mon, 20 Jan 2020 10:13:00 +0100 [thread overview]
Message-ID: <20200120091305.24997-7-agruenba@redhat.com> (raw)
In-Reply-To: <20200120091305.24997-1-agruenba@redhat.com>
When an inode's link count drops to zero and the inode is cached on
other nodes, the current behavior of gfs2 is to immediately give up and
to rely on the other node(s) to delete the inode if there is iopen glock
contention. This leads to resource group glock bouncing and the loss of
caching. With the previous patches in place, we can fix that by not
giving up immediately.
When the inode is still open on other nodes, those nodes won't be able
to evict the inode and give up the iopen glock. In that case, our lock
conversion request will time out. The unlink system call will block for
the duration of the iopen lock conversion request. We're also holding
the inode glock in EX mode for an extended duration, so other nodes
won't be able to make progress on the inode, either.
This is worse than what we had before, but we can prevent other nodes
from getting stuck by aborting our iopen locking request if there is
contention on the inode glock, and we can also switch to performing the
delete asynchronously in that case. Those will the the subjects of
future patches.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/super.c | 53 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 47 insertions(+), 6 deletions(-)
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 874949b17495..d5b44290da7f 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1222,6 +1222,50 @@ static void gfs2_glock_put_eventually(struct gfs2_glock *gl)
gfs2_glock_put(gl);
}
+static bool gfs2_upgrade_iopen_glock(struct inode *inode)
+{
+ struct gfs2_inode *ip = GFS2_I(inode);
+ struct gfs2_sbd *sdp = GFS2_SB(inode);
+ struct gfs2_holder *gh = &ip->i_iopen_gh;
+ long timeout = 5 * HZ;
+ int error;
+
+ gh->gh_flags |= GL_NOCACHE;
+ gfs2_glock_dq_wait(gh);
+
+ /*
+ * If there are no other lock holders, we'll get the lock immediately.
+ * Otherwise, the other nodes holding the lock will be notified about
+ * our locking request. If they don't have the inode open, they'll
+ * evict the cached inode and release the lock. As a last resort,
+ * we'll eventually time out.
+ *
+ * Note that we're passing the LM_FLAG_TRY_1CB flag to the first
+ * locking request is an optimization to notify lock holders as soon as
+ * possible. Without that flag, they'd be notified implicitly by the
+ * second locking request.
+ */
+
+ gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY | LM_FLAG_TRY_1CB | GL_NOCACHE, gh);
+ error = gfs2_glock_nq(gh);
+ if (error != GLR_TRYFAILED)
+ return !error;
+
+ gfs2_holder_reinit(LM_ST_EXCLUSIVE, GL_ASYNC | GL_NOCACHE, gh);
+ error = gfs2_glock_nq(gh);
+ if (error)
+ return false;
+
+ timeout = wait_event_interruptible_timeout(sdp->sd_async_glock_wait,
+ !test_bit(HIF_WAIT, &gh->gh_iflags),
+ timeout);
+ if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) {
+ gfs2_glock_dq(gh);
+ return false;
+ }
+ return true;
+}
+
/**
* gfs2_evict_inode - Remove an inode from cache
* @inode: The inode to evict
@@ -1303,13 +1347,10 @@ static void gfs2_evict_inode(struct inode *inode)
out_delete:
if (gfs2_holder_initialized(&ip->i_iopen_gh) &&
test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
- ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
- gfs2_glock_dq_wait(&ip->i_iopen_gh);
- gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE,
- &ip->i_iopen_gh);
- error = gfs2_glock_nq(&ip->i_iopen_gh);
- if (error)
+ if (!gfs2_upgrade_iopen_glock(inode)) {
+ gfs2_holder_uninit(&ip->i_iopen_gh);
goto out_truncate;
+ }
}
if (S_ISDIR(inode->i_mode) &&
--
2.20.1
next prev parent reply other threads:[~2020-01-20 9:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-20 9:12 [Cluster-devel] [PATCH 00/11] gfs2: iopen glock locking scheme rework Andreas Gruenbacher
2020-01-20 9:12 ` [Cluster-devel] [PATCH 01/11] gfs2: Allow ASPACE glocks to also have an lvb Andreas Gruenbacher
2020-01-20 9:12 ` [Cluster-devel] [PATCH 02/11] gfs2: Don't add glocks to the LRU while still in use Andreas Gruenbacher
2020-01-20 9:12 ` [Cluster-devel] [PATCH 03/11] gfs2: Keep track of deletes in inode LVBs Andreas Gruenbacher
2020-01-20 9:12 ` [Cluster-devel] [PATCH 04/11] gfs2: Turn gl_delete into a delayed work Andreas Gruenbacher
2020-01-20 9:12 ` [Cluster-devel] [PATCH 05/11] gfs2: Give up the iopen glock on contention Andreas Gruenbacher
2020-01-20 9:13 ` Andreas Gruenbacher [this message]
2020-01-20 9:13 ` [Cluster-devel] [PATCH 07/11] gfs2: Minor gfs2_lookup_by_inum cleanup Andreas Gruenbacher
2020-01-20 9:13 ` [Cluster-devel] [PATCH 08/11] gfs2: Move inode generation number check into gfs2_inode_lookup Andreas Gruenbacher
2020-01-20 9:13 ` [Cluster-devel] [PATCH 09/11] gfs2: Check inode generation number in delete_work_func Andreas Gruenbacher
2020-01-20 9:13 ` [Cluster-devel] [PATCH 10/11] gfs2: Wake up when setting GLF_DEMOTE Andreas Gruenbacher
2020-01-20 9:13 ` [Cluster-devel] [PATCH 11/11] gfs2: Smarter iopen glock waiting Andreas Gruenbacher
2020-01-23 12:41 ` [Cluster-devel] [PATCH 08/11] gfs2: Move inode generation number check into gfs2_inode_lookup Andreas Gruenbacher
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=20200120091305.24997-7-agruenba@redhat.com \
--to=agruenba@redhat.com \
/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).