diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-09-17 10:56:51 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-09-17 10:56:51 -0400 |
commit | c0204fd2b8fe047b18b67e07e1bf2a03691240cd (patch) | |
tree | d6cf75bc11d08f190c0757ba98b5ae6baef49402 /fs/nfs/nfs4proc.c | |
parent | 535918f14176396646b5547b7d1353c932f24f5e (diff) |
NFS: Clean up nfs4_proc_create()
Remove all remaining references to the struct nameidata from the low level
NFS layers. Again pass down a partially initialised struct nfs_open_context
when we want to do atomic open+create.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r-- | fs/nfs/nfs4proc.c | 56 |
1 files changed, 14 insertions, 42 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 83c5ef6e7cef..617b149ee16d 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -1998,32 +1998,6 @@ out: | |||
1998 | return status; | 1998 | return status; |
1999 | } | 1999 | } |
2000 | 2000 | ||
2001 | static int nfs4_intent_set_file(struct nameidata *nd, struct path *path, struct nfs4_state *state, fmode_t fmode) | ||
2002 | { | ||
2003 | struct file *filp; | ||
2004 | int ret; | ||
2005 | |||
2006 | /* If the open_intent is for execute, we have an extra check to make */ | ||
2007 | if (fmode & FMODE_EXEC) { | ||
2008 | ret = nfs_may_open(state->inode, | ||
2009 | state->owner->so_cred, | ||
2010 | nd->intent.open.flags); | ||
2011 | if (ret < 0) | ||
2012 | goto out_close; | ||
2013 | } | ||
2014 | filp = lookup_instantiate_filp(nd, path->dentry, NULL); | ||
2015 | if (!IS_ERR(filp)) { | ||
2016 | struct nfs_open_context *ctx; | ||
2017 | ctx = nfs_file_open_context(filp); | ||
2018 | ctx->state = state; | ||
2019 | return 0; | ||
2020 | } | ||
2021 | ret = PTR_ERR(filp); | ||
2022 | out_close: | ||
2023 | nfs4_close_sync(path, state, fmode & (FMODE_READ|FMODE_WRITE)); | ||
2024 | return ret; | ||
2025 | } | ||
2026 | |||
2027 | struct inode * | 2001 | struct inode * |
2028 | nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags, struct iattr *attr) | 2002 | nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags, struct iattr *attr) |
2029 | { | 2003 | { |
@@ -2491,36 +2465,34 @@ static int nfs4_proc_readlink(struct inode *inode, struct page *page, | |||
2491 | 2465 | ||
2492 | static int | 2466 | static int |
2493 | nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | 2467 | nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, |
2494 | int flags, struct nameidata *nd) | 2468 | int flags, struct nfs_open_context *ctx) |
2495 | { | 2469 | { |
2496 | struct path path = { | 2470 | struct path my_path = { |
2497 | .mnt = nd->path.mnt, | ||
2498 | .dentry = dentry, | 2471 | .dentry = dentry, |
2499 | }; | 2472 | }; |
2473 | struct path *path = &my_path; | ||
2500 | struct nfs4_state *state; | 2474 | struct nfs4_state *state; |
2501 | struct rpc_cred *cred; | 2475 | struct rpc_cred *cred = NULL; |
2502 | fmode_t fmode = flags & (FMODE_READ | FMODE_WRITE); | 2476 | fmode_t fmode = 0; |
2503 | int status = 0; | 2477 | int status = 0; |
2504 | 2478 | ||
2505 | cred = rpc_lookup_cred(); | 2479 | if (ctx != NULL) { |
2506 | if (IS_ERR(cred)) { | 2480 | cred = ctx->cred; |
2507 | status = PTR_ERR(cred); | 2481 | path = &ctx->path; |
2508 | goto out; | 2482 | fmode = ctx->mode; |
2509 | } | 2483 | } |
2510 | state = nfs4_do_open(dir, &path, fmode, flags, sattr, cred); | 2484 | state = nfs4_do_open(dir, path, fmode, flags, sattr, cred); |
2511 | d_drop(dentry); | 2485 | d_drop(dentry); |
2512 | if (IS_ERR(state)) { | 2486 | if (IS_ERR(state)) { |
2513 | status = PTR_ERR(state); | 2487 | status = PTR_ERR(state); |
2514 | goto out_putcred; | 2488 | goto out; |
2515 | } | 2489 | } |
2516 | d_add(dentry, igrab(state->inode)); | 2490 | d_add(dentry, igrab(state->inode)); |
2517 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 2491 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
2518 | if (status == 0 && (nd->flags & LOOKUP_OPEN) != 0) | 2492 | if (ctx != NULL) |
2519 | status = nfs4_intent_set_file(nd, &path, state, fmode); | 2493 | ctx->state = state; |
2520 | else | 2494 | else |
2521 | nfs4_close_sync(&path, state, fmode); | 2495 | nfs4_close_sync(path, state, fmode); |
2522 | out_putcred: | ||
2523 | put_rpccred(cred); | ||
2524 | out: | 2496 | out: |
2525 | return status; | 2497 | return status; |
2526 | } | 2498 | } |