diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 14:33:41 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 14:33:41 -0700 |
commit | 3e1f900bff40460d7bbab0ccd1a9efc3c70aee49 (patch) | |
tree | d0e2138ff61bdc9d1bd5b7ae5a1e75267d709afc | |
parent | 12795067cfa595434be0236b102a8eb20d578741 (diff) | |
parent | 0a87cf128f3d3bc6aa7b1040e73109c974ed875a (diff) |
Merge git://git.linux-nfs.org/pub/linux/nfs-2.6
* git://git.linux-nfs.org/pub/linux/nfs-2.6:
NFSv4: handle lack of clientaddr in option string
NFSv4: debug print ntohl(status) in nfs client callback xdr code
SUNRPC: Clean up the sillyrename code
NFS: Introduce struct nfs_removeargs+nfs_removeres
NFS: Use dentry->d_time to store the parent directory verifier.
SUNRPC: move bkl locking and xdr proc invocation into a common helper
NFSv4: Fix the nfsv4 readlink reply buffer alignment
NFSv4: Fix the readdir reply buffer alignment
NFSv4: More NFSv4 xdr cleanups
NFSv4: Try to recover from getfh failures in nfs4_xdr_dec_open
NFSv4: 'constify' lookup arguments.
NFSv4: Don't fail nfs4_xdr_dec_open if decode_restorefh() failed
NFSv4: Fix open state recovery
NFSD/SUNRPC: Fix the automatic selection of RPCSEC_GSS
-rw-r--r-- | fs/Kconfig | 2 | ||||
-rw-r--r-- | fs/nfs/callback_xdr.c | 10 | ||||
-rw-r--r-- | fs/nfs/dir.c | 8 | ||||
-rw-r--r-- | fs/nfs/nfs2xdr.c | 19 | ||||
-rw-r--r-- | fs/nfs/nfs3proc.c | 60 | ||||
-rw-r--r-- | fs/nfs/nfs3xdr.c | 24 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 2 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 122 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 274 | ||||
-rw-r--r-- | fs/nfs/proc.c | 40 | ||||
-rw-r--r-- | fs/nfs/super.c | 7 | ||||
-rw-r--r-- | fs/nfs/unlink.c | 195 | ||||
-rw-r--r-- | include/linux/nfs_fs.h | 4 | ||||
-rw-r--r-- | include/linux/nfs_xdr.h | 32 | ||||
-rw-r--r-- | include/linux/sunrpc/xdr.h | 16 | ||||
-rw-r--r-- | net/sunrpc/auth.c | 13 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 21 |
17 files changed, 442 insertions, 407 deletions
diff --git a/fs/Kconfig b/fs/Kconfig index 6a649902c5a..58a0650293e 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -1674,7 +1674,7 @@ config NFSD_V3_ACL config NFSD_V4 bool "Provide NFSv4 server support (EXPERIMENTAL)" - depends on NFSD_V3 && EXPERIMENTAL + depends on NFSD && NFSD_V3 && EXPERIMENTAL select RPCSEC_GSS_KRB5 help If you would like to include the NFSv4 server as well as the NFSv2 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 849a2029975..058ade7efe7 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c @@ -179,7 +179,7 @@ static __be32 decode_getattr_args(struct svc_rqst *rqstp, struct xdr_stream *xdr args->addr = svc_addr_in(rqstp); status = decode_bitmap(xdr, args->bitmap); out: - dprintk("%s: exit with status = %d\n", __FUNCTION__, status); + dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(status)); return status; } @@ -200,7 +200,7 @@ static __be32 decode_recall_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, args->truncate = ntohl(*p); status = decode_fh(xdr, &args->fh); out: - dprintk("%s: exit with status = %d\n", __FUNCTION__, status); + dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(status)); return status; } @@ -349,7 +349,7 @@ static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr, status = encode_attr_mtime(xdr, res->bitmap, &res->mtime); *savep = htonl((unsigned int)((char *)xdr->p - (char *)(savep+1))); out: - dprintk("%s: exit with status = %d\n", __FUNCTION__, status); + dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(status)); return status; } @@ -392,7 +392,7 @@ static __be32 process_op(struct svc_rqst *rqstp, status = res; if (op->encode_res != NULL && status == 0) status = op->encode_res(rqstp, xdr_out, resp); - dprintk("%s: done, status = %d\n", __FUNCTION__, status); + dprintk("%s: done, status = %d\n", __FUNCTION__, ntohl(status)); return status; } @@ -431,7 +431,7 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *r } *hdr_res.status = status; *hdr_res.nops = htonl(nops); - dprintk("%s: done, status = %u\n", __FUNCTION__, status); + dprintk("%s: done, status = %u\n", __FUNCTION__, ntohl(status)); return rpc_success; } diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 322141f4ab4..ea97408e423 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -654,7 +654,7 @@ static int nfs_check_verifier(struct inode *dir, struct dentry *dentry) if (IS_ROOT(dentry)) return 1; - verf = (unsigned long)dentry->d_fsdata; + verf = dentry->d_time; if (nfs_caches_unstable(dir) || verf != NFS_I(dir)->cache_change_attribute) return 0; @@ -663,7 +663,7 @@ static int nfs_check_verifier(struct inode *dir, struct dentry *dentry) static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf) { - dentry->d_fsdata = (void *)verf; + dentry->d_time = verf; } static void nfs_refresh_verifier(struct dentry * dentry, unsigned long verf) @@ -869,7 +869,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { lock_kernel(); drop_nlink(inode); - nfs_complete_unlink(dentry); + nfs_complete_unlink(dentry, inode); unlock_kernel(); } /* When creating a negative dentry, we want to renew d_time */ @@ -1411,7 +1411,7 @@ static int nfs_sillyrename(struct inode *dir, struct dentry *dentry) nfs_renew_times(dentry); nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); d_move(dentry, sdentry); - error = nfs_async_unlink(dentry); + error = nfs_async_unlink(dir, dentry); /* If we return 0 we don't unlink */ } dput(sdentry); diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c index 7fcc78f2aa7..c5fce756720 100644 --- a/fs/nfs/nfs2xdr.c +++ b/fs/nfs/nfs2xdr.c @@ -43,6 +43,7 @@ #define NFS_entry_sz (NFS_filename_sz+3) #define NFS_diropargs_sz (NFS_fhandle_sz+NFS_filename_sz) +#define NFS_removeargs_sz (NFS_fhandle_sz+NFS_filename_sz) #define NFS_sattrargs_sz (NFS_fhandle_sz+NFS_sattr_sz) #define NFS_readlinkargs_sz (NFS_fhandle_sz) #define NFS_readargs_sz (NFS_fhandle_sz+3) @@ -66,7 +67,7 @@ * Common NFS XDR functions as inlines */ static inline __be32 * -xdr_encode_fhandle(__be32 *p, struct nfs_fh *fhandle) +xdr_encode_fhandle(__be32 *p, const struct nfs_fh *fhandle) { memcpy(p, fhandle->data, NFS2_FHSIZE); return p + XDR_QUADLEN(NFS2_FHSIZE); @@ -204,7 +205,7 @@ nfs_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs_sattrargs *args) /* * Encode directory ops argument - * LOOKUP, REMOVE, RMDIR + * LOOKUP, RMDIR */ static int nfs_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs_diropargs *args) @@ -216,6 +217,18 @@ nfs_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs_diropargs *args) } /* + * Encode REMOVE argument + */ +static int +nfs_xdr_removeargs(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args) +{ + p = xdr_encode_fhandle(p, args->fh); + p = xdr_encode_array(p, args->name.name, args->name.len); + req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); + return 0; +} + +/* * Arguments to a READ call. Since we read data directly into the page * cache, we also set up the reply iovec here so that iov[1] points * exactly to the page we want to fetch. @@ -705,7 +718,7 @@ struct rpc_procinfo nfs_procedures[] = { PROC(READ, readargs, readres, 3), PROC(WRITE, writeargs, writeres, 4), PROC(CREATE, createargs, diropres, 0), - PROC(REMOVE, diropargs, stat, 0), + PROC(REMOVE, removeargs, stat, 0), PROC(RENAME, renameargs, stat, 0), PROC(LINK, linkargs, stat, 0), PROC(SYMLINK, symlinkargs, stat, 0), diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 814d886b6aa..c7ca5d70870 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -349,62 +349,42 @@ out: static int nfs3_proc_remove(struct inode *dir, struct qstr *name) { - struct nfs_fattr dir_attr; - struct nfs3_diropargs arg = { - .fh = NFS_FH(dir), - .name = name->name, - .len = name->len + struct nfs_removeargs arg = { + .fh = NFS_FH(dir), + .name.len = name->len, + .name.name = name->name, }; - struct rpc_message msg = { - .rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE], - .rpc_argp = &arg, - .rpc_resp = &dir_attr, + struct nfs_removeres res; + struct rpc_message msg = { + .rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE], + .rpc_argp = &arg, + .rpc_resp = &res, }; int status; dprintk("NFS call remove %s\n", name->name); - nfs_fattr_init(&dir_attr); + nfs_fattr_init(&res.dir_attr); status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); - nfs_post_op_update_inode(dir, &dir_attr); + nfs_post_op_update_inode(dir, &res.dir_attr); dprintk("NFS reply remove: %d\n", status); return status; } -static int -nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *name) +static void +nfs3_proc_unlink_setup(struct rpc_message *msg, struct inode *dir) { - struct unlinkxdr { - struct nfs3_diropargs arg; - struct nfs_fattr res; - } *ptr; - - ptr = kmalloc(sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return -ENOMEM; - ptr->arg.fh = NFS_FH(dir->d_inode); - ptr->arg.name = name->name; - ptr->arg.len = name->len; - nfs_fattr_init(&ptr->res); msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE]; - msg->rpc_argp = &ptr->arg; - msg->rpc_resp = &ptr->res; - return 0; } static int -nfs3_proc_unlink_done(struct dentry *dir, struct rpc_task *task) +nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir) { - struct rpc_message *msg = &task->tk_msg; - struct nfs_fattr *dir_attr; - - if (nfs3_async_handle_jukebox(task, dir->d_inode)) - return 1; - if (msg->rpc_argp) { - dir_attr = (struct nfs_fattr*)msg->rpc_resp; - nfs_post_op_update_inode(dir->d_inode, dir_attr); - kfree(msg->rpc_argp); - } - return 0; + struct nfs_removeres *res; + if (nfs3_async_handle_jukebox(task, dir)) + return 0; + res = task->tk_msg.rpc_resp; + nfs_post_op_update_inode(dir, &res->dir_attr); + return 1; } static int diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index b4647a22f34..d9e08f0cf2a 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c @@ -50,6 +50,7 @@ #define NFS3_sattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3) #define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz) +#define NFS3_removeargs_sz (NFS3_fh_sz+NFS3_filename_sz) #define NFS3_accessargs_sz (NFS3_fh_sz+1) #define NFS3_readlinkargs_sz (NFS3_fh_sz) #define NFS3_readargs_sz (NFS3_fh_sz+3) @@ -65,6 +66,7 @@ #define NFS3_attrstat_sz (1+NFS3_fattr_sz) #define NFS3_wccstat_sz (1+NFS3_wcc_data_sz) +#define NFS3_removeres_sz (NFS3_wccstat_sz) #define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz)) #define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1) #define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1) @@ -106,7 +108,7 @@ static struct { * Common NFS XDR functions as inlines */ static inline __be32 * -xdr_encode_fhandle(__be32 *p, struct nfs_fh *fh) +xdr_encode_fhandle(__be32 *p, const struct nfs_fh *fh) { return xdr_encode_array(p, fh->data, fh->size); } @@ -300,6 +302,18 @@ nfs3_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs3_diropargs *args) } /* + * Encode REMOVE argument + */ +static int +nfs3_xdr_removeargs(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args) +{ + p = xdr_encode_fhandle(p, args->fh); + p = xdr_encode_array(p, args->name.name, args->name.len); + req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); + return 0; +} + +/* * Encode access() argument */ static int @@ -736,6 +750,12 @@ nfs3_xdr_wccstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr) return status; } +static int +nfs3_xdr_removeres(struct rpc_rqst *req, __be32 *p, struct nfs_removeres *res) +{ + return nfs3_xdr_wccstat(req, p, &res->dir_attr); +} + /* * Decode LOOKUP reply */ @@ -1126,7 +1146,7 @@ struct rpc_procinfo nfs3_procedures[] = { PROC(MKDIR, mkdirargs, createres, 0), PROC(SYMLINK, symlinkargs, createres, 0), PROC(MKNOD, mknodargs, createres, 0), - PROC(REMOVE, diropargs, wccstat, 0), + PROC(REMOVE, removeargs, removeres, 0), PROC(RMDIR, diropargs, wccstat, 0), PROC(RENAME, renameargs, renameres, 0), PROC(LINK, linkargs, linkres, 0), diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 6c028e734fe..d2802b1ca3b 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -182,7 +182,7 @@ extern int nfs4_do_close(struct path *path, struct nfs4_state *state); extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); -extern int nfs4_proc_fs_locations(struct inode *dir, 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); extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops; diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index fee2da856c9..6ca2795ccd9 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -66,6 +66,8 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception); static int nfs4_wait_clnt_recover(struct rpc_clnt *clnt, struct nfs_client *clp); static int _nfs4_do_access(struct inode *inode, struct rpc_cred *cred, int openflags); +static int _nfs4_proc_lookup(struct inode *dir, const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr); +static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr); /* Prevent leaks of NFSv4 errors into userland */ int nfs4_map_errors(int err) @@ -552,6 +554,18 @@ static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state * return ERR_PTR(-ENOENT); } +static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context *ctx, struct nfs4_state *state) +{ + struct nfs4_opendata *opendata; + + opendata = nfs4_opendata_alloc(&ctx->path, state->owner, 0, NULL); + if (opendata == NULL) + return ERR_PTR(-ENOMEM); + opendata->state = state; + atomic_inc(&state->count); + return opendata; +} + static int nfs4_open_recover_helper(struct nfs4_opendata *opendata, mode_t openflags, struct nfs4_state **res) { struct nfs4_state *newstate; @@ -626,12 +640,11 @@ static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state int delegation_type = 0; int status; - opendata = nfs4_opendata_alloc(&ctx->path, state->owner, 0, NULL); - if (opendata == NULL) - return -ENOMEM; + opendata = nfs4_open_recoverdata_alloc(ctx, state); + if (IS_ERR(opendata)) + return PTR_ERR(opendata); opendata->o_arg.claim = NFS4_OPEN_CLAIM_PREVIOUS; opendata->o_arg.fh = NFS_FH(state->inode); - nfs_copy_fh(&opendata->o_res.fh, opendata->o_arg.fh); rcu_read_lock(); delegation = rcu_dereference(NFS_I(state->inode)->delegation); if (delegation != NULL && (delegation->flags & NFS_DELEGATION_NEED_RECLAIM) != 0) @@ -672,13 +685,12 @@ static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *sta static int _nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid) { - struct nfs4_state_owner *sp = state->owner; struct nfs4_opendata *opendata; int ret; - opendata = nfs4_opendata_alloc(&ctx->path, sp, 0, NULL); - if (opendata == NULL) - return -ENOMEM; + opendata = nfs4_open_recoverdata_alloc(ctx, state); + if (IS_ERR(opendata)) + return PTR_ERR(opendata); opendata->o_arg.claim = NFS4_OPEN_CLAIM_DELEGATE_CUR; memcpy(opendata->o_arg.u.delegation.data, stateid->data, sizeof(opendata->o_arg.u.delegation.data)); @@ -823,8 +835,10 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata) /* Update sequence id. */ data->o_arg.id = sp->so_owner_id.id; data->o_arg.clientid = sp->so_client->cl_clientid; - if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) + if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) { msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; + nfs_copy_fh(&data->o_res.fh, data->o_arg.fh); + } data->timestamp = jiffies; rpc_call_setup(task, &msg, 0); return; @@ -918,6 +932,9 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) if (status != 0 || !data->rpc_done) return status; + if (o_res->fh.size == 0) + _nfs4_proc_lookup(dir, o_arg->name, &o_res->fh, o_res->f_attr); + if (o_arg->open_flags & O_CREAT) { update_changeattr(dir, &o_res->cinfo); nfs_post_op_update_inode(dir, o_res->dir_attr); @@ -929,7 +946,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) return status; } if (!(o_res->f_attr->valid & NFS_ATTR_FATTR)) - return server->nfs_client->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr); + _nfs4_proc_getattr(server, &o_res->fh, o_res->f_attr); return 0; } @@ -989,9 +1006,9 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s struct nfs4_opendata *opendata; int ret; - opendata = nfs4_opendata_alloc(&ctx->path, state->owner, 0, NULL); - if (opendata == NULL) - return -ENOMEM; + opendata = nfs4_open_recoverdata_alloc(ctx, state); + if (IS_ERR(opendata)) + return PTR_ERR(opendata); ret = nfs4_open_recover(opendata, state); if (ret == -ESTALE) { /* Invalidate the state owner so we don't ever use it again */ @@ -1553,7 +1570,7 @@ static int nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, * Note that we'll actually follow the referral later when * we detect fsid mismatch in inode revalidation */ -static int nfs4_get_referral(struct inode *dir, struct qstr *name, struct nfs_fattr *fattr, struct nfs_fh *fhandle) +static int nfs4_get_referral(struct inode *dir, const struct qstr *name, struct nfs_fattr *fattr, struct nfs_fh *fhandle) { int status = -ENOMEM; struct page *page = NULL; @@ -1668,8 +1685,8 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, return status; } -static int _nfs4_proc_lookupfh(struct nfs_server *server, struct nfs_fh *dirfh, - struct qstr *name, struct nfs_fh *fhandle, +static int _nfs4_proc_lookupfh(struct nfs_server *server, const struct nfs_fh *dirfh, + const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr) { int status; @@ -1715,7 +1732,7 @@ static int nfs4_proc_lookupfh(struct nfs_server *server, struct nfs_fh *dirfh, return err; } -static int _nfs4_proc_lookup(struct inode *dir, struct qstr *name, +static int _nfs4_proc_lookup(struct inode *dir, const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr) { int status; @@ -1908,28 +1925,27 @@ out: static int _nfs4_proc_remove(struct inode *dir, struct qstr *name) { struct nfs_server *server = NFS_SERVER(dir); - struct nfs4_remove_arg args = { + struct nfs_removeargs args = { .fh = NFS_FH(dir), - .name = name, + .name.len = name->len, + .name.name = name->name, .bitmask = server->attr_bitmask, }; - struct nfs_fattr dir_attr; - struct nfs4_remove_res res = { + struct nfs_removeres res = { .server = server, - .dir_attr = &dir_attr, }; struct rpc_message msg = { - .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE], - .rpc_argp = &args, - .rpc_resp = &res, + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE], + .rpc_argp = &args, + .rpc_resp = &res, }; int status; - nfs_fattr_init(res.dir_attr); + nfs_fattr_init(&res.dir_attr); status = rpc_call_sync(server->client, &msg, 0); if (status == 0) { update_changeattr(dir, &res.cinfo); - nfs_post_op_update_inode(dir, res.dir_attr); + nfs_post_op_update_inode(dir, &res.dir_attr); } return status; } @@ -1946,48 +1962,26 @@ static int nfs4_proc_remove(struct inode *dir, struct qstr *name) return err; } -struct unlink_desc { - struct nfs4_remove_arg args; - struct nfs4_remove_res res; - struct nfs_fattr dir_attr; -}; - -static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, - struct qstr *name) +static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct inode *dir) { - struct nfs_server *server = NFS_SERVER(dir->d_inode); - struct unlink_desc *up; + struct nfs_server *server = NFS_SERVER(dir); + struct nfs_removeargs *args = msg->rpc_argp; + struct nfs_removeres *res = msg->rpc_resp; - up = kmalloc(sizeof(*up), GFP_KERNEL); - if (!up) - return -ENOMEM; - - up->args.fh = NFS_FH(dir->d_inode); - up->args.name = name; - up->args.bitmask = server->attr_bitmask; - up->res.server = server; - up->res.dir_attr = &up->dir_attr; - + args->bitmask = server->attr_bitmask; + res->server = server; msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE]; - msg->rpc_argp = &up->args; - msg->rpc_resp = &up->res; - return 0; } -static int nfs4_proc_unlink_done(struct dentry *dir, struct rpc_task *task) +static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir) { - struct rpc_message *msg = &task->tk_msg; - struct unlink_desc *up; - - if (msg->rpc_resp != NULL) { - up = container_of(msg->rpc_resp, struct unlink_desc, res); - update_changeattr(dir->d_inode, &up->res.cinfo); - nfs_post_op_update_inode(dir->d_inode, up->res.dir_attr); - kfree(up); - msg->rpc_resp = NULL; - msg->rpc_argp = NULL; - } - return 0; + struct nfs_removeres *res = task->tk_msg.rpc_resp; + + if (nfs4_async_handle_error(task, res->server) == -EAGAIN) + return 0; + update_changeattr(dir, &res->cinfo); + nfs_post_op_update_inode(dir, &res->dir_attr); + return 1; } static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, @@ -3672,7 +3666,7 @@ ssize_t nfs4_listxattr(struct dentry *dentry, char *buf, size_t buflen) return len; } -int nfs4_proc_fs_locations(struct inode *dir, struct qstr *name, +int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, struct nfs4_fs_locations *fs_locations, struct page *page) { struct nfs_server *server = NFS_SERVER(dir); diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index c08738441f7..badd73b7ca1 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -72,10 +72,15 @@ static int nfs4_stat_to_errno(int); */ #define open_owner_id_maxsz (1 + 4) #define lock_owner_id_maxsz (1 + 4) +#define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) #define op_encode_hdr_maxsz (1) #define op_decode_hdr_maxsz (2) +#define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) +#define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) +#define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) +#define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ (NFS4_FHSIZE >> 2)) #define decode_putfh_maxsz (op_decode_hdr_maxsz) @@ -96,6 +101,11 @@ static int nfs4_stat_to_errno(int); #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ nfs4_fattr_value_maxsz) #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) +#define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ + 1 + 2 + 1 + \ + nfs4_owner_maxsz + \ + nfs4_group_maxsz + \ + 4 + 4) #define encode_savefh_maxsz (op_encode_hdr_maxsz) #define decode_savefh_maxsz (op_decode_hdr_maxsz) #define encode_restorefh_maxsz (op_encode_hdr_maxsz) @@ -123,7 +133,7 @@ static int nfs4_stat_to_errno(int); #define decode_lookup_maxsz (op_decode_hdr_maxsz) #define encode_share_access_maxsz \ (2) -#define encode_createmode_maxsz (1 + nfs4_fattr_maxsz) +#define encode_createmode_maxsz (1 + encode_attrs_maxsz) #define encode_opentype_maxsz (1 + encode_createmode_maxsz) #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) #define encode_open_maxsz (op_encode_hdr_maxsz + \ @@ -132,14 +142,52 @@ static int nfs4_stat_to_errno(int); encode_opentype_maxsz + \ encode_claim_null_maxsz) #define decode_ace_maxsz (3 + nfs4_owner_maxsz) -#define decode_delegation_maxsz (1 + XDR_QUADLEN(NFS4_STATEID_SIZE) + 1 + \ +#define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ decode_ace_maxsz) #define decode_change_info_maxsz (5) #define decode_open_maxsz (op_decode_hdr_maxsz + \ - XDR_QUADLEN(NFS4_STATEID_SIZE) + \ + decode_stateid_maxsz + \ decode_change_info_maxsz + 1 + \ nfs4_fattr_bitmap_maxsz + \ decode_delegation_maxsz) +#define encode_open_confirm_maxsz \ + (op_encode_hdr_maxsz + \ + encode_stateid_maxsz + 1) +#define decode_open_confirm_maxsz \ + (op_decode_hdr_maxsz + \ + decode_stateid_maxsz) +#define encode_open_downgrade_maxsz \ + (op_encode_hdr_maxsz + \ + encode_stateid_maxsz + 1 + \ + encode_share_access_maxsz) +#define decode_open_downgrade_maxsz \ + (op_decode_hdr_maxsz + \ + decode_stateid_maxsz) +#define encode_close_maxsz (op_encode_hdr_maxsz + \ + 1 + encode_stateid_maxsz) +#define decode_close_maxsz (op_decode_hdr_maxsz + \ + decode_stateid_maxsz) +#define encode_setattr_maxsz (op_encode_hdr_maxsz + \ + encode_stateid_maxsz + \ + encode_attrs_maxsz) +#define decode_setattr_maxsz (op_decode_hdr_maxsz + \ + nfs4_fattr_bitmap_maxsz) +#define encode_read_maxsz (op_encode_hdr_maxsz + \ + encode_stateid_maxsz + 3) +#define decode_read_maxsz (op_decode_hdr_maxsz + 2) +#define encode_readdir_maxsz (op_encode_hdr_maxsz + \ + 2 + encode_verifier_maxsz + 5) +#define decode_readdir_maxsz (op_decode_hdr_maxsz + \ + decode_verifier_maxsz) +#define encode_readlink_maxsz (op_encode_hdr_maxsz) +#define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) +#define encode_write_maxsz (op_encode_hdr_maxsz + \ + encode_stateid_maxsz + 4) +#define decode_write_maxsz (op_decode_hdr_maxsz + \ + 2 + decode_verifier_maxsz) +#define encode_commit_maxsz (op_encode_hdr_maxsz + 3) +#define decode_commit_maxsz (op_decode_hdr_maxsz + \ + decode_verifier_maxsz) #define encode_remove_maxsz (op_encode_hdr_maxsz + \ nfs4_name_maxsz) #define encode_rename_maxsz (op_encode_hdr_maxsz + \ @@ -148,19 +196,44 @@ static int nfs4_stat_to_errno(int); #define encode_link_maxsz (op_encode_hdr_maxsz + \ nfs4_name_maxsz) #define decode_link_maxsz (op_decode_hdr_maxsz + 5) +#define encode_lock_maxsz (op_encode_hdr_maxsz + \ + 7 + \ + 1 + encode_stateid_maxsz + 8) +#define decode_lock_denied_maxsz \ + (8 + decode_lockowner_maxsz) +#define decode_lock_maxsz (op_decode_hdr_maxsz + \ + decode_lock_denied_maxsz) +#define encode_lockt_maxsz (op_encode_hdr_maxsz + 12) +#define decode_lockt_maxsz (op_decode_hdr_maxsz + \ + decode_lock_denied_maxsz) +#define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ + encode_stateid_maxsz + \ + 4) +#define decode_locku_maxsz (op_decode_hdr_maxsz + \ + decode_stateid_maxsz) +#define encode_access_maxsz (op_encode_hdr_maxsz + 1) +#define decode_access_maxsz (op_decode_hdr_maxsz + 2) #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ 1 + nfs4_name_maxsz + \ 1 + \ nfs4_fattr_maxsz) #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) #define encode_create_maxsz (op_encode_hdr_maxsz + \ - 2 + nfs4_name_maxsz + \ - nfs4_fattr_maxsz) + 1 + 2 + nfs4_name_maxsz + \ + encode_attrs_maxsz) #define decode_create_maxsz (op_decode_hdr_maxsz + \ decode_change_info_maxsz + \ nfs4_fattr_bitmap_maxsz) +#define encode_statfs_maxsz (encode_getattr_maxsz) +#define decode_statfs_maxsz (decode_getattr_maxsz) #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) +#define encode_getacl_maxsz (encode_getattr_maxsz) +#define decode_getacl_maxsz (op_decode_hdr_maxsz + \ + nfs4_fattr_bitmap_maxsz + 1) +#define encode_setacl_maxsz (op_encode_hdr_maxsz + \ + encode_stateid_maxsz + 3) +#define decode_setacl_maxsz (decode_setattr_maxsz) #define encode_fs_locations_maxsz \ (encode_getattr_maxsz) #define decode_fs_locations_maxsz \ @@ -169,37 +242,37 @@ static int nfs4_stat_to_errno(int); #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ - op_encode_hdr_maxsz + 7) + encode_read_maxsz) #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ - op_decode_hdr_maxsz + 2) + decode_read_maxsz) #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ - op_encode_hdr_maxsz) + encode_readlink_maxsz) #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ - op_decode_hdr_maxsz) + decode_readlink_maxsz) #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ - op_encode_hdr_maxsz + 9) + encode_readdir_maxsz) #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ - op_decode_hdr_maxsz + 2) + decode_readdir_maxsz) #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ - op_encode_hdr_maxsz + 8 + \ + encode_write_maxsz + \ encode_getattr_maxsz) #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ - op_decode_hdr_maxsz + 4 + \ + decode_write_maxsz + \ decode_getattr_maxsz) #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ - op_encode_hdr_maxsz + 3 + \ + encode_commit_maxsz + \ encode_getattr_maxsz) #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ - op_decode_hdr_maxsz + 2 + \ + decode_commit_maxsz + \ decode_getattr_maxsz) #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ @@ -217,13 +290,14 @@ static int nfs4_stat_to_errno(int); decode_getattr_maxsz + \ decode_restorefh_maxsz + \ decode_getattr_maxsz) -#define NFS4_enc_open_confirm_sz \ - (compound_encode_hdr_maxsz + \ - encode_putfh_maxsz + \ - op_encode_hdr_maxsz + 5) -#define NFS4_dec_open_confirm_sz (compound_decode_hdr_maxsz + \ - decode_putfh_maxsz + \ - op_decode_hdr_maxsz + 4) +#define NFS4_enc_open_confirm_sz \ + (compound_encode_hdr_maxsz + \ + encode_putfh_maxsz + \ + encode_open_confirm_maxsz) +#define NFS4_dec_open_confirm_sz \ + (compound_decode_hdr_maxsz + \ + decode_putfh_maxsz + \ + decode_open_confirm_maxsz) #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ encode_open_maxsz + \ @@ -234,31 +308,30 @@ static int nfs4_stat_to_errno(int); decode_getattr_maxsz) #define NFS4_enc_open_downgrade_sz \ (compound_encode_hdr_maxsz + \ - encode_putfh_maxsz + \ - op_encode_hdr_maxsz + 7 + \ - encode_getattr_maxsz) + encode_putfh_maxsz + \ + encode_open_downgrade_maxsz + \ + encode_getattr_maxsz) #define NFS4_dec_open_downgrade_sz \ (compound_decode_hdr_maxsz + \ - decode_putfh_maxsz + \ - op_decode_hdr_maxsz + 4 + \ - decode_getattr_maxsz) -#define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ - encode_putfh_maxsz + \ - op_encode_hdr_maxsz + 5 + \ - encode_getattr_maxsz) -#define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ - decode_putfh_maxsz + \ - op_decode_hdr_maxsz + 4 + \ - decode_getattr_maxsz) -#define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ - encode_putfh_maxsz + \ - op_encode_hdr_maxsz + 4 + \ - nfs4_fattr_maxsz + \ - encode_getattr_maxsz) -#define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ - decode_putfh_maxsz + \ - op_decode_hdr_maxsz + 3 + \ - nfs4_fattr_maxsz) + decode_putfh_maxsz + \ + decode_open_downgrade_maxsz + \ + decode_getattr_maxsz) +#define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ + encode_putfh_maxsz + \ + encode_close_maxsz + \ + encode_getattr_maxsz) +#define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ + decode_putfh_maxsz + \ + decode_close_maxsz + \ + decode_getattr_maxsz) +#define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ + encode_putfh_maxsz + \ + encode_setattr_maxsz + \ + encode_getattr_maxsz) +#define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ + decode_putfh_maxsz + \ + decode_setattr_maxsz + \ + decode_getattr_maxsz) #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ encode_fsinfo_maxsz) @@ -285,39 +358,28 @@ static int nfs4_stat_to_errno(int); decode_fsinfo_maxsz) #define NFS4_enc_lock_sz ( |