cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 03/11] gfs2: Keep track of deletes in inode LVBs
Date: Mon, 20 Jan 2020 10:12:57 +0100	[thread overview]
Message-ID: <20200120091305.24997-4-agruenba@redhat.com> (raw)
In-Reply-To: <20200120091305.24997-1-agruenba@redhat.com>

When deleting an inode, keep track of the generation of the deleted inode in
the inode glock Lock Value Block (LVB).  When trying to delete an inode
remotely, check the last-known inode generation against the deleted inode
generation to skip duplicate remote deletes.  This avoids taking the resource
group glock in order to verify the block type.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/glock.c                  | 19 +++++++++++++++++++
 fs/gfs2/glock.h                  |  3 +++
 fs/gfs2/glops.c                  |  2 +-
 fs/gfs2/super.c                  |  3 +++
 include/uapi/linux/gfs2_ondisk.h |  6 ++++++
 5 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 2aa21bab8e1c..3a9502af895b 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -677,6 +677,25 @@ __acquires(&gl->gl_lockref.lock)
 	return;
 }
 
+void gfs2_inode_remember_delete(struct gfs2_glock *gl, u64 generation)
+{
+	struct gfs2_inode_lvb *ri = (void *)gl->gl_lksb.sb_lvbptr;
+
+	if (ri->ri_magic == 0)
+		ri->ri_magic = cpu_to_be32(GFS2_MAGIC);
+	if (ri->ri_magic == cpu_to_be32(GFS2_MAGIC))
+		ri->ri_generation_deleted = cpu_to_be64(generation);
+}
+
+bool gfs2_inode_already_deleted(struct gfs2_glock *gl, u64 generation)
+{
+	struct gfs2_inode_lvb *ri = (void *)gl->gl_lksb.sb_lvbptr;
+
+	if (ri->ri_magic != cpu_to_be32(GFS2_MAGIC))
+		return false;
+	return generation <= be64_to_cpu(ri->ri_generation_deleted);
+}
+
 static void delete_work_func(struct work_struct *work)
 {
 	struct gfs2_glock *gl = container_of(work, struct gfs2_glock, gl_delete);
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
index dc23cbf6ae7a..63d0486bdbc4 100644
--- a/fs/gfs2/glock.h
+++ b/fs/gfs2/glock.h
@@ -305,4 +305,7 @@ static inline void glock_clear_object(struct gfs2_glock *gl, void *object)
 	spin_unlock(&gl->gl_lockref.lock);
 }
 
+extern void gfs2_inode_remember_delete(struct gfs2_glock *gl, u64 generation);
+extern bool gfs2_inode_already_deleted(struct gfs2_glock *gl, u64 generation);
+
 #endif /* __GLOCK_DOT_H__ */
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 4ede1f18de85..4b4676fb8c3e 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -593,7 +593,7 @@ const struct gfs2_glock_operations gfs2_inode_glops = {
 	.go_lock = inode_go_lock,
 	.go_dump = inode_go_dump,
 	.go_type = LM_TYPE_INODE,
-	.go_flags = GLOF_ASPACE | GLOF_LRU,
+	.go_flags = GLOF_ASPACE | GLOF_LRU | GLOF_LVB,
 };
 
 const struct gfs2_glock_operations gfs2_rgrp_glops = {
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 2621d925812b..b108b6379fb7 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1278,6 +1278,8 @@ static void gfs2_evict_inode(struct inode *inode)
 		goto out;
 	}
 
+	if (gfs2_inode_already_deleted(ip->i_gl, ip->i_no_formal_ino))
+		goto out_truncate;
 	error = gfs2_check_blk_type(sdp, ip->i_no_addr, GFS2_BLKST_UNLINKED);
 	if (error)
 		goto out_truncate;
@@ -1331,6 +1333,7 @@ static void gfs2_evict_inode(struct inode *inode)
 	   that subsequent inode creates don't see an old gl_object. */
 	glock_clear_object(ip->i_gl, ip);
 	error = gfs2_dinode_dealloc(ip);
+	gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino);
 	goto out_unlock;
 
 out_truncate:
diff --git a/include/uapi/linux/gfs2_ondisk.h b/include/uapi/linux/gfs2_ondisk.h
index 2dc10a034de1..07e508e6691b 100644
--- a/include/uapi/linux/gfs2_ondisk.h
+++ b/include/uapi/linux/gfs2_ondisk.h
@@ -171,6 +171,12 @@ struct gfs2_rindex {
 #define GFS2_RGF_NOALLOC	0x00000008
 #define GFS2_RGF_TRIMMED	0x00000010
 
+struct gfs2_inode_lvb {
+	__be32 ri_magic;
+	__be32 __pad;
+	__be64 ri_generation_deleted;
+};
+
 struct gfs2_rgrp_lvb {
 	__be32 rl_magic;
 	__be32 rl_flags;
-- 
2.20.1



  parent reply	other threads:[~2020-01-20  9:12 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 ` Andreas Gruenbacher [this message]
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 ` [Cluster-devel] [PATCH 06/11] gfs2: Try harder to delete inodes locally Andreas Gruenbacher
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-4-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).