From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH 2/5] gfs2: factor delete_evicted_inode out of gfs2_evict_inode
Date: Tue, 15 Sep 2020 09:38:19 -0500 [thread overview]
Message-ID: <20200915143822.16485-3-rpeterso@redhat.com> (raw)
In-Reply-To: <20200915143822.16485-1-rpeterso@redhat.com>
Function gfs2_evict_inode is way too big, complex and unreadable. This is a
first baby step toward breaking it apart to be more readable. It factors out
the portion that deletes the online bits for a dinode that is unlinked and
needs to be deleted. A future patch will factor out more. (If I factor
out too much, the patch itself becomes unreadable).
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
fs/gfs2/super.c | 67 +++++++++++++++++++++++++++++--------------------
1 file changed, 40 insertions(+), 27 deletions(-)
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index ab08b9a1102c..6f9e394d2a2e 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1310,6 +1310,45 @@ static bool gfs2_upgrade_iopen_glock(struct inode *inode)
return true;
}
+/**
+ * delete_evicted_inode - delete the pieces of an unlinked evicted inode
+ * @inode: The inode to evict
+ */
+static int delete_evicted_inode(struct inode *inode)
+{
+ struct gfs2_inode *ip = GFS2_I(inode);
+ int ret;
+
+ if (S_ISDIR(inode->i_mode) &&
+ (ip->i_diskflags & GFS2_DIF_EXHASH)) {
+ ret = gfs2_dir_exhash_dealloc(ip);
+ if (ret)
+ goto out;
+ }
+
+ if (ip->i_eattr) {
+ ret = gfs2_ea_dealloc(ip);
+ if (ret)
+ goto out;
+ }
+
+ if (!gfs2_is_stuffed(ip)) {
+ ret = gfs2_file_dealloc(ip);
+ if (ret)
+ goto out;
+ }
+
+ /* We're about to clear the bitmap for the dinode, but as soon as we
+ do, gfs2_create_inode can create another inode at the same block
+ location and try to set gl_object again. We clear gl_object here so
+ that subsequent inode creates don't see an old gl_object. */
+ glock_clear_object(ip->i_gl, ip);
+ ret = gfs2_dinode_dealloc(ip);
+ gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino);
+out:
+ return ret;
+}
+
/**
* gfs2_evict_inode - Remove an inode from cache
* @inode: The inode to evict
@@ -1396,33 +1435,7 @@ static void gfs2_evict_inode(struct inode *inode)
goto out_truncate;
}
}
-
- if (S_ISDIR(inode->i_mode) &&
- (ip->i_diskflags & GFS2_DIF_EXHASH)) {
- ret = gfs2_dir_exhash_dealloc(ip);
- if (ret)
- goto out_unlock;
- }
-
- if (ip->i_eattr) {
- ret = gfs2_ea_dealloc(ip);
- if (ret)
- goto out_unlock;
- }
-
- if (!gfs2_is_stuffed(ip)) {
- ret = gfs2_file_dealloc(ip);
- if (ret)
- goto out_unlock;
- }
-
- /* We're about to clear the bitmap for the dinode, but as soon as we
- do, gfs2_create_inode can create another inode at the same block
- location and try to set gl_object again. We clear gl_object here so
- that subsequent inode creates don't see an old gl_object. */
- glock_clear_object(ip->i_gl, ip);
- ret = gfs2_dinode_dealloc(ip);
- gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino);
+ ret = delete_evicted_inode(inode);
goto out_unlock;
out_truncate:
--
2.26.2
next prev parent reply other threads:[~2020-09-15 14:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 14:38 [Cluster-devel] [GFS2 PATCH 0/5] Refactor gfs2_evict_inode Bob Peterson
2020-09-15 14:38 ` [Cluster-devel] [GFS2 PATCH 1/5] gfs2: switch variable error to ret in gfs2_evict_inode Bob Peterson
2020-09-15 14:38 ` Bob Peterson [this message]
2020-09-15 19:08 ` [Cluster-devel] [GFS2 PATCH 2/5] gfs2: factor delete_evicted_inode out of gfs2_evict_inode Andreas Gruenbacher
2020-09-15 14:38 ` [Cluster-devel] [GFS2 PATCH 3/5] gfs2: further simplify gfs2_evict_inode with new func may_delete_evicted Bob Peterson
2020-09-15 19:09 ` Andreas Gruenbacher
2020-09-15 14:38 ` [Cluster-devel] [GFS2 PATCH 4/5] gfs2: factor out evict code related to dinodes we are not deleting Bob Peterson
2020-09-15 19:09 ` Andreas Gruenbacher
2020-09-15 14:38 ` [Cluster-devel] [GFS2 PATCH 5/5] gfs2: simplify the logic in gfs2_evict_inode Bob Peterson
2020-09-15 19:08 ` [Cluster-devel] [GFS2 PATCH 0/5] Refactor gfs2_evict_inode 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=20200915143822.16485-3-rpeterso@redhat.com \
--to=rpeterso@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).