From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH 4/6] gfs2: factor out evict code related to dinodes we are not deleting
Date: Wed, 16 Sep 2020 10:00:18 -0500 [thread overview]
Message-ID: <20200916150020.36582-5-rpeterso@redhat.com> (raw)
In-Reply-To: <20200916150020.36582-1-rpeterso@redhat.com>
Now that we've factored out the delete-dinode case to simplify gfs2_evict_inode
we take it a step further and factor out the other case: where we don't
delete the inode.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
fs/gfs2/super.c | 52 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 18 deletions(-)
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 1e2ff066f8d4..9fc4135a35c0 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1422,6 +1422,39 @@ static enum dinode_demise evict_should_delete(struct inode *inode,
return SHOULD_DELETE_DINODE;
}
+/**
+ * evict_saved_inode - evict an inode whose dinode has not been deleted
+ * @inode: The inode to evict
+ */
+static int evict_saved_inode(struct inode *inode)
+{
+ struct super_block *sb = inode->i_sb;
+ struct gfs2_sbd *sdp = sb->s_fs_info;
+ struct gfs2_inode *ip = GFS2_I(inode);
+ struct address_space *metamapping;
+ int ret;
+
+ gfs2_log_flush(sdp, ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
+ GFS2_LFC_EVICT_INODE);
+ metamapping = gfs2_glock2aspace(ip->i_gl);
+ if (test_bit(GLF_DIRTY, &ip->i_gl->gl_flags)) {
+ filemap_fdatawrite(metamapping);
+ filemap_fdatawait(metamapping);
+ }
+ write_inode_now(inode, 1);
+ gfs2_ail_flush(ip->i_gl, 0);
+
+ ret = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
+ if (ret)
+ return ret;
+
+ /* Needs to be done before glock release & also in a transaction */
+ truncate_inode_pages(&inode->i_data, 0);
+ truncate_inode_pages(metamapping, 0);
+ gfs2_trans_end(sdp);
+ return 0;
+}
+
/**
* gfs2_evict_inode - Remove an inode from cache
* @inode: The inode to evict
@@ -1449,7 +1482,6 @@ static void gfs2_evict_inode(struct inode *inode)
struct gfs2_sbd *sdp = sb->s_fs_info;
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_holder gh;
- struct address_space *metamapping;
int ret;
if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
@@ -1471,23 +1503,7 @@ static void gfs2_evict_inode(struct inode *inode)
goto out_unlock;
out_truncate:
- gfs2_log_flush(sdp, ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
- GFS2_LFC_EVICT_INODE);
- metamapping = gfs2_glock2aspace(ip->i_gl);
- if (test_bit(GLF_DIRTY, &ip->i_gl->gl_flags)) {
- filemap_fdatawrite(metamapping);
- filemap_fdatawait(metamapping);
- }
- write_inode_now(inode, 1);
- gfs2_ail_flush(ip->i_gl, 0);
-
- ret = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
- if (ret)
- goto out_unlock;
- /* Needs to be done before glock release & also in a transaction */
- truncate_inode_pages(&inode->i_data, 0);
- truncate_inode_pages(metamapping, 0);
- gfs2_trans_end(sdp);
+ ret = evict_saved_inode(inode);
out_unlock:
if (gfs2_rs_active(&ip->i_res))
--
2.26.2
next prev parent reply other threads:[~2020-09-16 15:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 15:00 [Cluster-devel] [GFS2 PATCH 0/6] Refactor gfs2_evict_inode (V2) Bob Peterson
2020-09-16 15:00 ` [Cluster-devel] [GFS2 PATCH 1/6] gfs2: switch variable error to ret in gfs2_evict_inode Bob Peterson
2020-09-16 15:00 ` [Cluster-devel] [GFS2 PATCH 2/6] gfs2: factor evict_deleted_inode out of gfs2_evict_inode Bob Peterson
2020-09-16 15:00 ` [Cluster-devel] [GFS2 PATCH 3/6] gfs2: further simplify gfs2_evict_inode with new func evict_should_delete Bob Peterson
2020-09-16 15:00 ` Bob Peterson [this message]
2020-09-16 15:00 ` [Cluster-devel] [GFS2 PATCH 5/6] gfs2: simplify the logic in gfs2_evict_inode Bob Peterson
2020-09-16 15:00 ` [Cluster-devel] [GFS2 PATCH 6/6] gfs2: special evict process for system inodes Bob Peterson
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=20200916150020.36582-5-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).