aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs2xdr.c19
-rw-r--r--fs/nfs/nfs3proc.c34
-rw-r--r--fs/nfs/nfs3xdr.c24
-rw-r--r--fs/nfs/nfs4proc.c31
-rw-r--r--fs/nfs/nfs4xdr.c8
-rw-r--r--fs/nfs/proc.c20
6 files changed, 84 insertions, 52 deletions
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index 7fcc78f2aa71..c5fce7567200 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -43,6 +43,7 @@
43#define NFS_entry_sz (NFS_filename_sz+3) 43#define NFS_entry_sz (NFS_filename_sz+3)
44 44
45#define NFS_diropargs_sz (NFS_fhandle_sz+NFS_filename_sz) 45#define NFS_diropargs_sz (NFS_fhandle_sz+NFS_filename_sz)
46#define NFS_removeargs_sz (NFS_fhandle_sz+NFS_filename_sz)
46#define NFS_sattrargs_sz (NFS_fhandle_sz+NFS_sattr_sz) 47#define NFS_sattrargs_sz (NFS_fhandle_sz+NFS_sattr_sz)
47#define NFS_readlinkargs_sz (NFS_fhandle_sz) 48#define NFS_readlinkargs_sz (NFS_fhandle_sz)
48#define NFS_readargs_sz (NFS_fhandle_sz+3) 49#define NFS_readargs_sz (NFS_fhandle_sz+3)
@@ -66,7 +67,7 @@
66 * Common NFS XDR functions as inlines 67 * Common NFS XDR functions as inlines
67 */ 68 */
68static inline __be32 * 69static inline __be32 *
69xdr_encode_fhandle(__be32 *p, struct nfs_fh *fhandle) 70xdr_encode_fhandle(__be32 *p, const struct nfs_fh *fhandle)
70{ 71{
71 memcpy(p, fhandle->data, NFS2_FHSIZE); 72 memcpy(p, fhandle->data, NFS2_FHSIZE);
72 return p + XDR_QUADLEN(NFS2_FHSIZE); 73 return p + XDR_QUADLEN(NFS2_FHSIZE);
@@ -204,7 +205,7 @@ nfs_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs_sattrargs *args)
204 205
205/* 206/*
206 * Encode directory ops argument 207 * Encode directory ops argument
207 * LOOKUP, REMOVE, RMDIR 208 * LOOKUP, RMDIR
208 */ 209 */
209static int 210static int
210nfs_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs_diropargs *args) 211nfs_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)
216} 217}
217 218
218/* 219/*
220 * Encode REMOVE argument
221 */
222static int
223nfs_xdr_removeargs(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args)
224{
225 p = xdr_encode_fhandle(p, args->fh);
226 p = xdr_encode_array(p, args->name.name, args->name.len);
227 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
228 return 0;
229}
230
231/*
219 * Arguments to a READ call. Since we read data directly into the page 232 * Arguments to a READ call. Since we read data directly into the page
220 * cache, we also set up the reply iovec here so that iov[1] points 233 * cache, we also set up the reply iovec here so that iov[1] points
221 * exactly to the page we want to fetch. 234 * exactly to the page we want to fetch.
@@ -705,7 +718,7 @@ struct rpc_procinfo nfs_procedures[] = {
705 PROC(READ, readargs, readres, 3), 718 PROC(READ, readargs, readres, 3),
706 PROC(WRITE, writeargs, writeres, 4), 719 PROC(WRITE, writeargs, writeres, 4),
707 PROC(CREATE, createargs, diropres, 0), 720 PROC(CREATE, createargs, diropres, 0),
708 PROC(REMOVE, diropargs, stat, 0), 721 PROC(REMOVE, removeargs, stat, 0),
709 PROC(RENAME, renameargs, stat, 0), 722 PROC(RENAME, renameargs, stat, 0),
710 PROC(LINK, linkargs, stat, 0), 723 PROC(LINK, linkargs, stat, 0),
711 PROC(SYMLINK, symlinkargs, stat, 0), 724 PROC(SYMLINK, symlinkargs, stat, 0),
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 814d886b6aa4..eac07f2c99dd 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -349,23 +349,23 @@ out:
349static int 349static int
350nfs3_proc_remove(struct inode *dir, struct qstr *name) 350nfs3_proc_remove(struct inode *dir, struct qstr *name)
351{ 351{
352 struct nfs_fattr dir_attr; 352 struct nfs_removeargs arg = {
353 struct nfs3_diropargs arg = { 353 .fh = NFS_FH(dir),
354 .fh = NFS_FH(dir), 354 .name.len = name->len,
355 .name = name->name, 355 .name.name = name->name,
356 .len = name->len
357 }; 356 };
358 struct rpc_message msg = { 357 struct nfs_removeres res;
359 .rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE], 358 struct rpc_message msg = {
360 .rpc_argp = &arg, 359 .rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE],
361 .rpc_resp = &dir_attr, 360 .rpc_argp = &arg,
361 .rpc_resp = &res,
362 }; 362 };
363 int status; 363 int status;
364 364
365 dprintk("NFS call remove %s\n", name->name); 365 dprintk("NFS call remove %s\n", name->name);
366 nfs_fattr_init(&dir_attr); 366 nfs_fattr_init(&res.dir_attr);
367 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 367 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
368 nfs_post_op_update_inode(dir, &dir_attr); 368 nfs_post_op_update_inode(dir, &res.dir_attr);
369 dprintk("NFS reply remove: %d\n", status); 369 dprintk("NFS reply remove: %d\n", status);
370 return status; 370 return status;
371} 371}
@@ -374,17 +374,17 @@ static int
374nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *name) 374nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *name)
375{ 375{
376 struct unlinkxdr { 376 struct unlinkxdr {
377 struct nfs3_diropargs arg; 377 struct nfs_removeargs arg;
378 struct nfs_fattr res; 378 struct nfs_removeres res;
379 } *ptr; 379 } *ptr;
380 380
381 ptr = kmalloc(sizeof(*ptr), GFP_KERNEL); 381 ptr = kmalloc(sizeof(*ptr), GFP_KERNEL);
382 if (!ptr) 382 if (!ptr)
383 return -ENOMEM; 383 return -ENOMEM;
384 ptr->arg.fh = NFS_FH(dir->d_inode); 384 ptr->arg.fh = NFS_FH(dir->d_inode);
385 ptr->arg.name = name->name; 385 ptr->arg.name.name = name->name;
386 ptr->arg.len = name->len; 386 ptr->arg.name.len = name->len;
387 nfs_fattr_init(&ptr->res); 387 nfs_fattr_init(&ptr->res.dir_attr);
388 msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE]; 388 msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE];
389 msg->rpc_argp = &ptr->arg; 389 msg->rpc_argp = &ptr->arg;
390 msg->rpc_resp = &ptr->res; 390 msg->rpc_resp = &ptr->res;
@@ -400,7 +400,7 @@ nfs3_proc_unlink_done(struct dentry *dir, struct rpc_task *task)
400 if (nfs3_async_handle_jukebox(task, dir->d_inode)) 400 if (nfs3_async_handle_jukebox(task, dir->d_inode))
401 return 1; 401 return 1;
402 if (msg->rpc_argp) { 402 if (msg->rpc_argp) {
403 dir_attr = (struct nfs_fattr*)msg->rpc_resp; 403 dir_attr = &((struct nfs_removeres*)msg->rpc_resp)->dir_attr;
404 nfs_post_op_update_inode(dir->d_inode, dir_attr); 404 nfs_post_op_update_inode(dir->d_inode, dir_attr);
405 kfree(msg->rpc_argp); 405 kfree(msg->rpc_argp);
406 } 406 }
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index b4647a22f349..d9e08f0cf2a0 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -50,6 +50,7 @@
50 50
51#define NFS3_sattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3) 51#define NFS3_sattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3)
52#define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz) 52#define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz)
53#define NFS3_removeargs_sz (NFS3_fh_sz+NFS3_filename_sz)
53#define NFS3_accessargs_sz (NFS3_fh_sz+1) 54#define NFS3_accessargs_sz (NFS3_fh_sz+1)
54#define NFS3_readlinkargs_sz (NFS3_fh_sz) 55#define NFS3_readlinkargs_sz (NFS3_fh_sz)
55#define NFS3_readargs_sz (NFS3_fh_sz+3) 56#define NFS3_readargs_sz (NFS3_fh_sz+3)
@@ -65,6 +66,7 @@
65 66
66#define NFS3_attrstat_sz (1+NFS3_fattr_sz) 67#define NFS3_attrstat_sz (1+NFS3_fattr_sz)
67#define NFS3_wccstat_sz (1+NFS3_wcc_data_sz) 68#define NFS3_wccstat_sz (1+NFS3_wcc_data_sz)
69#define NFS3_removeres_sz (NFS3_wccstat_sz)
68#define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz)) 70#define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz))
69#define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1) 71#define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1)
70#define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1) 72#define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1)
@@ -106,7 +108,7 @@ static struct {
106 * Common NFS XDR functions as inlines 108 * Common NFS XDR functions as inlines
107 */ 109 */
108static inline __be32 * 110static inline __be32 *
109xdr_encode_fhandle(__be32 *p, struct nfs_fh *fh) 111xdr_encode_fhandle(__be32 *p, const struct nfs_fh *fh)
110{ 112{
111 return xdr_encode_array(p, fh->data, fh->size); 113 return xdr_encode_array(p, fh->data, fh->size);
112} 114}
@@ -300,6 +302,18 @@ nfs3_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs3_diropargs *args)
300} 302}
301 303
302/* 304/*
305 * Encode REMOVE argument
306 */
307static int
308nfs3_xdr_removeargs(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args)
309{
310 p = xdr_encode_fhandle(p, args->fh);
311 p = xdr_encode_array(p, args->name.name, args->name.len);
312 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
313 return 0;
314}
315
316/*
303 * Encode access() argument 317 * Encode access() argument
304 */ 318 */
305static int 319static int
@@ -736,6 +750,12 @@ nfs3_xdr_wccstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
736 return status; 750 return status;
737} 751}
738 752
753static int
754nfs3_xdr_removeres(struct rpc_rqst *req, __be32 *p, struct nfs_removeres *res)
755{
756 return nfs3_xdr_wccstat(req, p, &res->dir_attr);
757}
758
739/* 759/*
740 * Decode LOOKUP reply 760 * Decode LOOKUP reply
741 */ 761 */
@@ -1126,7 +1146,7 @@ struct rpc_procinfo nfs3_procedures[] = {
1126 PROC(MKDIR, mkdirargs, createres, 0), 1146 PROC(MKDIR, mkdirargs, createres, 0),
1127 PROC(SYMLINK, symlinkargs, createres, 0), 1147 PROC(SYMLINK, symlinkargs, createres, 0),
1128 PROC(MKNOD, mknodargs, createres, 0), 1148 PROC(MKNOD, mknodargs, createres, 0),
1129 PROC(REMOVE, diropargs, wccstat, 0), 1149 PROC(REMOVE, removeargs, removeres, 0),
1130 PROC(RMDIR, diropargs, wccstat, 0), 1150 PROC(RMDIR, diropargs, wccstat, 0),
1131 PROC(RENAME, renameargs, renameres, 0), 1151 PROC(RENAME, renameargs, renameres, 0),
1132 PROC(LINK, linkargs, linkres, 0), 1152 PROC(LINK, linkargs, linkres, 0),
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 7ead63e065ab..23dc25dbc6fa 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1925,28 +1925,27 @@ out:
1925static int _nfs4_proc_remove(struct inode *dir, struct qstr *name) 1925static int _nfs4_proc_remove(struct inode *dir, struct qstr *name)
1926{ 1926{
1927 struct nfs_server *server = NFS_SERVER(dir); 1927 struct nfs_server *server = NFS_SERVER(dir);
1928 struct nfs4_remove_arg args = { 1928 struct nfs_removeargs args = {
1929 .fh = NFS_FH(dir), 1929 .fh = NFS_FH(dir),
1930 .name = name, 1930 .name.len = name->len,
1931 .name.name = name->name,
1931 .bitmask = server->attr_bitmask, 1932 .bitmask = server->attr_bitmask,
1932 }; 1933 };
1933 struct nfs_fattr dir_attr; 1934 struct nfs_removeres res = {
1934 struct nfs4_remove_res res = {
1935 .server = server, 1935 .server = server,
1936 .dir_attr = &dir_attr,
1937 }; 1936 };
1938 struct rpc_message msg = { 1937 struct rpc_message msg = {
1939 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE], 1938 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE],
1940 .rpc_argp = &args, 1939 .rpc_argp = &args,
1941 .rpc_resp = &res, 1940 .rpc_resp = &res,
1942 }; 1941 };
1943 int status; 1942 int status;
1944 1943
1945 nfs_fattr_init(res.dir_attr); 1944 nfs_fattr_init(&res.dir_attr);
1946 status = rpc_call_sync(server->client, &msg, 0); 1945 status = rpc_call_sync(server->client, &msg, 0);
1947 if (status == 0) { 1946 if (status == 0) {
1948 update_changeattr(dir, &res.cinfo); 1947 update_changeattr(dir, &res.cinfo);
1949 nfs_post_op_update_inode(dir, res.dir_attr); 1948 nfs_post_op_update_inode(dir, &res.dir_attr);
1950 } 1949 }
1951 return status; 1950 return status;
1952} 1951}
@@ -1964,9 +1963,8 @@ static int nfs4_proc_remove(struct inode *dir, struct qstr *name)
1964} 1963}
1965 1964
1966struct unlink_desc { 1965struct unlink_desc {
1967 struct nfs4_remove_arg args; 1966 struct nfs_removeargs args;
1968 struct nfs4_remove_res res; 1967 struct nfs_removeres res;
1969 struct nfs_fattr dir_attr;
1970}; 1968};
1971 1969
1972static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, 1970static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir,
@@ -1980,10 +1978,11 @@ static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir,
1980 return -ENOMEM; 1978 return -ENOMEM;
1981 1979
1982 up->args.fh = NFS_FH(dir->d_inode); 1980 up->args.fh = NFS_FH(dir->d_inode);
1983 up->args.name = name; 1981 up->args.name.len = name->len;
1982 up->args.name.name = name->name;
1984 up->args.bitmask = server->attr_bitmask; 1983 up->args.bitmask = server->attr_bitmask;
1985 up->res.server = server; 1984 up->res.server = server;
1986 up->res.dir_attr = &up->dir_attr; 1985 nfs_fattr_init(&up->res.dir_attr);
1987 1986
1988 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE]; 1987 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE];
1989 msg->rpc_argp = &up->args; 1988 msg->rpc_argp = &up->args;
@@ -1999,7 +1998,7 @@ static int nfs4_proc_unlink_done(struct dentry *dir, struct rpc_task *task)
1999 if (msg->rpc_resp != NULL) { 1998 if (msg->rpc_resp != NULL) {
2000 up = container_of(msg->rpc_resp, struct unlink_desc, res); 1999 up = container_of(msg->rpc_resp, struct unlink_desc, res);
2001 update_changeattr(dir->d_inode, &up->res.cinfo); 2000 update_changeattr(dir->d_inode, &up->res.cinfo);
2002 nfs_post_op_update_inode(dir->d_inode, up->res.dir_attr); 2001 nfs_post_op_update_inode(dir->d_inode, &up->res.dir_attr);
2003 kfree(up); 2002 kfree(up);
2004 msg->rpc_resp = NULL; 2003 msg->rpc_resp = NULL;
2005 msg->rpc_argp = NULL; 2004 msg->rpc_argp = NULL;
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 7b73ca8be909..badd73b7ca12 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1435,7 +1435,7 @@ out:
1435/* 1435/*
1436 * Encode REMOVE request 1436 * Encode REMOVE request
1437 */ 1437 */
1438static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs4_remove_arg *args) 1438static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args)
1439{ 1439{
1440 struct xdr_stream xdr; 1440 struct xdr_stream xdr;
1441 struct compound_hdr hdr = { 1441 struct compound_hdr hdr = {
@@ -1447,7 +1447,7 @@ static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs
1447 encode_compound_hdr(&xdr, &hdr); 1447 encode_compound_hdr(&xdr, &hdr);
1448 if ((status = encode_putfh(&xdr, args->fh)) != 0) 1448 if ((status = encode_putfh(&xdr, args->fh)) != 0)
1449 goto out; 1449 goto out;
1450 if ((status = encode_remove(&xdr, args->name)) != 0) 1450 if ((status = encode_remove(&xdr, &args->name)) != 0)
1451 goto out; 1451 goto out;
1452 status = encode_getfattr(&xdr, args->bitmask); 1452 status = encode_getfattr(&xdr, args->bitmask);
1453out: 1453out:
@@ -3835,7 +3835,7 @@ out:
3835/* 3835/*
3836 * Decode REMOVE response 3836 * Decode REMOVE response
3837 */ 3837 */
3838static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_remove_res *res) 3838static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs_removeres *res)
3839{ 3839{
3840 struct xdr_stream xdr; 3840 struct xdr_stream xdr;
3841 struct compound_hdr hdr; 3841 struct compound_hdr hdr;
@@ -3848,7 +3848,7 @@ static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_re
3848 goto out; 3848 goto out;
3849 if ((status = decode_remove(&xdr, &res->cinfo)) != 0) 3849 if ((status = decode_remove(&xdr, &res->cinfo)) != 0)
3850 goto out; 3850 goto out;
3851 decode_getfattr(&xdr, res->dir_attr, res->server); 3851 decode_getfattr(&xdr, &res->dir_attr, res->server);
3852out: 3852out:
3853 return status; 3853 return status;
3854} 3854}
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 7be0ee2782cb..3b3eb692e0f4 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -272,14 +272,14 @@ nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
272static int 272static int
273nfs_proc_remove(struct inode *dir, struct qstr *name) 273nfs_proc_remove(struct inode *dir, struct qstr *name)
274{ 274{
275 struct nfs_diropargs arg = { 275 struct nfs_removeargs arg = {
276 .fh = NFS_FH(dir), 276 .fh = NFS_FH(dir),
277 .name = name->name, 277 .name.len = name->len,
278 .len = name->len 278 .name.name = name->name,
279 }; 279 };
280 struct rpc_message msg = { 280 struct rpc_message msg = {
281 .rpc_proc = &nfs_procedures[NFSPROC_REMOVE], 281 .rpc_proc = &nfs_procedures[NFSPROC_REMOVE],
282 .rpc_argp = &arg, 282 .rpc_argp = &arg,
283 }; 283 };
284 int status; 284 int status;
285 285
@@ -294,14 +294,14 @@ nfs_proc_remove(struct inode *dir, struct qstr *name)
294static int 294static int
295nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *name) 295nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *name)
296{ 296{
297 struct nfs_diropargs *arg; 297 struct nfs_removeargs *arg;
298 298
299 arg = kmalloc(sizeof(*arg), GFP_KERNEL); 299 arg = kmalloc(sizeof(*arg), GFP_KERNEL);
300 if (!arg) 300 if (!arg)
301 return -ENOMEM; 301 return -ENOMEM;
302 arg->fh = NFS_FH(dir->d_inode); 302 arg->fh = NFS_FH(dir->d_inode);
303 arg->name = name->name; 303 arg->name.name = name->name;
304 arg->len = name->len; 304 arg->name.len = name->len;
305 msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE]; 305 msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
306 msg->rpc_argp = arg; 306 msg->rpc_argp = arg;
307 return 0; 307 return 0;