All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jianyong Wu <jianyong.wu@arm.com>
To: ericvh@gmail.com, hch@lst.de, dhowells@redhat.com,
	lucho@ionkov.net, asmadeus@codewreck.org
Cc: v9fs-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Kaly.Xin@arm.com,
	justin.he@arm.com, jianyong.wu@arm.com, wei.chen@arm.com
Subject: [RFC PATCH 2/2] 9p: retrieve fid from file if it exists when getattr.
Date: Mon, 20 Jul 2020 09:46:22 +0800	[thread overview]
Message-ID: <20200720014622.37364-3-jianyong.wu@arm.com> (raw)
In-Reply-To: <20200720014622.37364-1-jianyong.wu@arm.com>

fid should be retrieved from file when it is not NULL in getattr.
it denotes that getattr is called by fdstat from userspace when
file is exist, which means we should get info from file context
not dentry to avoid the failure when the dentry has gone.

Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
---
 fs/9p/vfs_inode.c      | 9 +++++++--
 fs/9p/vfs_inode_dotl.c | 9 +++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index c9255d399917..f562f5710eae 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1054,7 +1054,7 @@ v9fs_vfs_getattr(const struct path *path, struct kstat *stat,
 {
 	struct dentry *dentry = path->dentry;
 	struct v9fs_session_info *v9ses;
-	struct p9_fid *fid;
+	struct p9_fid *fid = NULL;
 	struct p9_wstat *st;
 
 	p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry);
@@ -1063,7 +1063,12 @@ v9fs_vfs_getattr(const struct path *path, struct kstat *stat,
 		generic_fillattr(d_inode(dentry), stat);
 		return 0;
 	}
-	fid = v9fs_fid_lookup(dentry);
+	if (stat->filp) {
+		fid = stat->filp->private_data;
+		WARN_ON(!fid);
+	}
+	if (!fid)
+		fid = v9fs_fid_lookup(dentry);
 	if (IS_ERR(fid))
 		return PTR_ERR(fid);
 
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 60328b21c5fb..6b7cbe74b0bb 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -460,7 +460,7 @@ v9fs_vfs_getattr_dotl(const struct path *path, struct kstat *stat,
 {
 	struct dentry *dentry = path->dentry;
 	struct v9fs_session_info *v9ses;
-	struct p9_fid *fid;
+	struct p9_fid *fid = NULL;
 	struct p9_stat_dotl *st;
 
 	p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry);
@@ -469,7 +469,12 @@ v9fs_vfs_getattr_dotl(const struct path *path, struct kstat *stat,
 		generic_fillattr(d_inode(dentry), stat);
 		return 0;
 	}
-	fid = v9fs_fid_lookup(dentry);
+	if (stat->filp) {
+		fid = stat->filp->private_data;
+		WARN_ON(!fid);
+	}
+	if (!fid)
+		fid = v9fs_fid_lookup(dentry);
 	if (IS_ERR(fid))
 		return PTR_ERR(fid);
 
-- 
2.17.1


  parent reply	other threads:[~2020-07-20  1:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20  1:46 [RFC PATCH 0/2] vfs:9p: fix open-unlink-fstat bug Jianyong Wu
2020-07-20  1:46 ` [RFC PATCH 1/2] vfs: pass file down when getattr to avoid losing info Jianyong Wu
2020-07-20 14:53   ` Dominique Martinet
2020-07-21 10:03     ` Jianyong Wu
2020-07-20  1:46 ` Jianyong Wu [this message]
2020-07-20  1:52 ` [RFC PATCH 0/2] vfs:9p: fix open-unlink-fstat bug Al Viro
2020-07-20  1:58   ` Jianyong Wu

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=20200720014622.37364-3-jianyong.wu@arm.com \
    --to=jianyong.wu@arm.com \
    --cc=Kaly.Xin@arm.com \
    --cc=asmadeus@codewreck.org \
    --cc=dhowells@redhat.com \
    --cc=ericvh@gmail.com \
    --cc=hch@lst.de \
    --cc=justin.he@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=v9fs-developer@lists.sourceforge.net \
    --cc=wei.chen@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.