From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 08/11] gfs2: Move inode generation number check into gfs2_inode_lookup
Date: Mon, 20 Jan 2020 10:13:02 +0100 [thread overview]
Message-ID: <20200120091305.24997-9-agruenba@redhat.com> (raw)
In-Reply-To: <20200120091305.24997-1-agruenba@redhat.com>
Move the inode generation number check from gfs2_lookup_by_inum into
gfs2_inode_lookup: gfs2_inode_lookup may be able to decide that an inode with
the given inode generation number cannot exist without having to verify the
block type or reading the inode from disk.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/inode.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 41fc23710529..e12e694a1bbb 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -114,6 +114,10 @@ static void gfs2_set_iop(struct inode *inode)
* placeholder because it doesn't otherwise make sense), the on-disk block type
* is verified to be @blktype.
*
+ * When @no_formal_ino is non-zero, this function will return ERR_PTR(-ESTALE)
+ * if it detects that @no_formal_ino doesn't match the actual inode generation
+ * number. However, it doesn't always know unless @type is DT_UNKNOWN.
+ *
* Returns: A VFS inode, or an error
*/
@@ -158,6 +162,11 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
if (error)
goto fail_put;
+ error = -ESTALE;
+ if (no_formal_ino &&
+ gfs2_inode_already_deleted(ip->i_gl, no_formal_ino))
+ goto fail_put;
+
if (blktype != GFS2_BLKST_FREE) {
error = gfs2_check_blk_type(sdp, no_addr,
blktype);
@@ -189,9 +198,15 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
/* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
inode->i_atime.tv_sec = 1LL << (8 * sizeof(inode->i_atime.tv_sec) - 1);
inode->i_atime.tv_nsec = 0;
+ }
+ error = -ESTALE;
+ if (no_formal_ino && ip->i_no_formal_ino &&
+ no_formal_ino != ip->i_no_formal_ino)
+ goto fail_refresh;
+
+ if (inode->i_state & I_NEW)
unlock_new_inode(inode);
- }
if (gfs2_holder_initialized(&i_gh))
gfs2_glock_dq_uninit(&i_gh);
@@ -226,16 +241,12 @@ struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
struct inode *inode;
int error;
- inode = gfs2_inode_lookup(sb, DT_UNKNOWN, no_addr, 0, blktype);
+ inode = gfs2_inode_lookup(sb, DT_UNKNOWN, no_addr, no_formal_ino,
+ blktype);
if (IS_ERR(inode))
return inode;
- /* Two extra checks for NFS only */
if (no_formal_ino) {
- error = -ESTALE;
- if (GFS2_I(inode)->i_no_formal_ino != no_formal_ino)
- goto fail_iput;
-
error = -EIO;
if (GFS2_I(inode)->i_diskflags & GFS2_DIF_SYSTEM)
goto fail_iput;
--
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 ` [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 ` Andreas Gruenbacher [this message]
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-9-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).