提交 b8d4cadd 编写于 作者: T Trond Myklebust

NFSv4: Clean up nfs4_open_revalidate

Remove references to 'struct nameidata' from the low-level open_revalidate
code, and replace them with a struct nfs_open_context which will be
correctly initialised upon success.
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 f46e0bd3
...@@ -1169,6 +1169,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) ...@@ -1169,6 +1169,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
struct dentry *parent = NULL; struct dentry *parent = NULL;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct inode *dir; struct inode *dir;
struct nfs_open_context *ctx;
int openflags, ret = 0; int openflags, ret = 0;
if (!is_atomic_open(nd) || d_mountpoint(dentry)) if (!is_atomic_open(nd) || d_mountpoint(dentry))
...@@ -1194,12 +1195,20 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) ...@@ -1194,12 +1195,20 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
/* We can't create new files, or truncate existing ones here */ /* We can't create new files, or truncate existing ones here */
openflags &= ~(O_CREAT|O_EXCL|O_TRUNC); openflags &= ~(O_CREAT|O_EXCL|O_TRUNC);
ctx = nameidata_to_nfs_open_context(dentry, nd);
ret = PTR_ERR(ctx);
if (IS_ERR(ctx))
goto out;
/* /*
* Note: we're not holding inode->i_mutex and so may be racing with * Note: we're not holding inode->i_mutex and so may be racing with
* operations that change the directory. We therefore save the * operations that change the directory. We therefore save the
* change attribute *before* we do the RPC call. * change attribute *before* we do the RPC call.
*/ */
ret = nfs4_open_revalidate(dir, dentry, openflags, nd); ret = nfs4_open_revalidate(dir, ctx, openflags);
if (ret == 1)
nfs_intent_set_file(nd, ctx);
else
put_nfs_open_context(ctx);
out: out:
dput(parent); dput(parent);
if (!ret) if (!ret)
......
...@@ -243,7 +243,7 @@ extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); ...@@ -243,7 +243,7 @@ extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait); extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait);
extern struct inode *nfs4_atomic_open(struct inode *, struct nfs_open_context *, int, struct iattr *); extern struct inode *nfs4_atomic_open(struct inode *, struct nfs_open_context *, int, struct iattr *);
extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); extern int nfs4_open_revalidate(struct inode *, struct nfs_open_context *, int);
extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
struct nfs4_fs_locations *fs_locations, struct page *page); struct nfs4_fs_locations *fs_locations, struct page *page);
......
...@@ -2038,21 +2038,11 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags ...@@ -2038,21 +2038,11 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags
} }
int int
nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, struct nameidata *nd) nfs4_open_revalidate(struct inode *dir, struct nfs_open_context *ctx, int openflags)
{ {
struct path path = {
.mnt = nd->path.mnt,
.dentry = dentry,
};
struct rpc_cred *cred;
struct nfs4_state *state; struct nfs4_state *state;
fmode_t fmode = openflags & (FMODE_READ | FMODE_WRITE);
cred = rpc_lookup_cred(); state = nfs4_do_open(dir, &ctx->path, ctx->mode, openflags, NULL, ctx->cred);
if (IS_ERR(cred))
return PTR_ERR(cred);
state = nfs4_do_open(dir, &path, fmode, openflags, NULL, cred);
put_rpccred(cred);
if (IS_ERR(state)) { if (IS_ERR(state)) {
switch (PTR_ERR(state)) { switch (PTR_ERR(state)) {
case -EPERM: case -EPERM:
...@@ -2065,14 +2055,13 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st ...@@ -2065,14 +2055,13 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st
goto out_drop; goto out_drop;
} }
} }
if (state->inode == dentry->d_inode) { ctx->state = state;
nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); if (state->inode == ctx->path.dentry->d_inode) {
nfs4_intent_set_file(nd, &path, state, fmode); nfs_set_verifier(ctx->path.dentry, nfs_save_change_attribute(dir));
return 1; return 1;
} }
nfs4_close_sync(&path, state, fmode);
out_drop: out_drop:
d_drop(dentry); d_drop(ctx->path.dentry);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册