diff options
| -rw-r--r-- | fs/nfs/nfs3proc.c | 23 | ||||
| -rw-r--r-- | fs/nfs/nfs4proc.c | 16 |
2 files changed, 22 insertions, 17 deletions
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 9d5d02f02515..c252fc983a7e 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
| @@ -432,7 +432,6 @@ static int | |||
| 432 | nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, | 432 | nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, |
| 433 | struct inode *new_dir, struct qstr *new_name) | 433 | struct inode *new_dir, struct qstr *new_name) |
| 434 | { | 434 | { |
| 435 | struct nfs_fattr old_dir_attr, new_dir_attr; | ||
| 436 | struct nfs3_renameargs arg = { | 435 | struct nfs3_renameargs arg = { |
| 437 | .fromfh = NFS_FH(old_dir), | 436 | .fromfh = NFS_FH(old_dir), |
| 438 | .fromname = old_name->name, | 437 | .fromname = old_name->name, |
| @@ -441,23 +440,27 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, | |||
| 441 | .toname = new_name->name, | 440 | .toname = new_name->name, |
| 442 | .tolen = new_name->len | 441 | .tolen = new_name->len |
| 443 | }; | 442 | }; |
| 444 | struct nfs3_renameres res = { | 443 | struct nfs3_renameres res; |
| 445 | .fromattr = &old_dir_attr, | ||
| 446 | .toattr = &new_dir_attr | ||
| 447 | }; | ||
| 448 | struct rpc_message msg = { | 444 | struct rpc_message msg = { |
| 449 | .rpc_proc = &nfs3_procedures[NFS3PROC_RENAME], | 445 | .rpc_proc = &nfs3_procedures[NFS3PROC_RENAME], |
| 450 | .rpc_argp = &arg, | 446 | .rpc_argp = &arg, |
| 451 | .rpc_resp = &res, | 447 | .rpc_resp = &res, |
| 452 | }; | 448 | }; |
| 453 | int status; | 449 | int status = -ENOMEM; |
| 454 | 450 | ||
| 455 | dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); | 451 | dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); |
| 456 | nfs_fattr_init(&old_dir_attr); | 452 | |
| 457 | nfs_fattr_init(&new_dir_attr); | 453 | res.fromattr = nfs_alloc_fattr(); |
| 454 | res.toattr = nfs_alloc_fattr(); | ||
| 455 | if (res.fromattr == NULL || res.toattr == NULL) | ||
| 456 | goto out; | ||
| 457 | |||
| 458 | status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0); | 458 | status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0); |
| 459 | nfs_post_op_update_inode(old_dir, &old_dir_attr); | 459 | nfs_post_op_update_inode(old_dir, res.fromattr); |
| 460 | nfs_post_op_update_inode(new_dir, &new_dir_attr); | 460 | nfs_post_op_update_inode(new_dir, res.toattr); |
| 461 | out: | ||
| 462 | nfs_free_fattr(res.toattr); | ||
| 463 | nfs_free_fattr(res.fromattr); | ||
| 461 | dprintk("NFS reply rename: %d\n", status); | 464 | dprintk("NFS reply rename: %d\n", status); |
| 462 | return status; | 465 | return status; |
| 463 | } | 466 | } |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 6591bd852f84..14cde99d8a60 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -2656,29 +2656,31 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, | |||
| 2656 | .new_name = new_name, | 2656 | .new_name = new_name, |
| 2657 | .bitmask = server->attr_bitmask, | 2657 | .bitmask = server->attr_bitmask, |
| 2658 | }; | 2658 | }; |
| 2659 | struct nfs_fattr old_fattr, new_fattr; | ||
| 2660 | struct nfs4_rename_res res = { | 2659 | struct nfs4_rename_res res = { |
| 2661 | .server = server, | 2660 | .server = server, |
| 2662 | .old_fattr = &old_fattr, | ||
| 2663 | .new_fattr = &new_fattr, | ||
| 2664 | }; | 2661 | }; |
| 2665 | struct rpc_message msg = { | 2662 | struct rpc_message msg = { |
| 2666 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME], | 2663 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME], |
| 2667 | .rpc_argp = &arg, | 2664 | .rpc_argp = &arg, |
| 2668 | .rpc_resp = &res, | 2665 | .rpc_resp = &res, |
| 2669 | }; | 2666 | }; |
| 2670 | int status; | 2667 | int status = -ENOMEM; |
| 2671 | 2668 | ||
| 2672 | nfs_fattr_init(res.old_fattr); | 2669 | res.old_fattr = nfs_alloc_fattr(); |
| 2673 | nfs_fattr_init(res.new_fattr); | 2670 | res.new_fattr = nfs_alloc_fattr(); |
| 2674 | status = nfs4_call_sync(server, &msg, &arg, &res, 1); | 2671 | if (res.old_fattr == NULL || res.new_fattr == NULL) |
| 2672 | goto out; | ||
| 2675 | 2673 | ||
| 2674 | status = nfs4_call_sync(server, &msg, &arg, &res, 1); | ||
| 2676 | if (!status) { | 2675 | if (!status) { |
| 2677 | update_changeattr(old_dir, &res.old_cinfo); | 2676 | update_changeattr(old_dir, &res.old_cinfo); |
| 2678 | nfs_post_op_update_inode(old_dir, res.old_fattr); | 2677 | nfs_post_op_update_inode(old_dir, res.old_fattr); |
| 2679 | update_changeattr(new_dir, &res.new_cinfo); | 2678 | update_changeattr(new_dir, &res.new_cinfo); |
| 2680 | nfs_post_op_update_inode(new_dir, res.new_fattr); | 2679 | nfs_post_op_update_inode(new_dir, res.new_fattr); |
| 2681 | } | 2680 | } |
| 2681 | out: | ||
| 2682 | nfs_free_fattr(res.new_fattr); | ||
| 2683 | nfs_free_fattr(res.old_fattr); | ||
| 2682 | return status; | 2684 | return status; |
| 2683 | } | 2685 | } |
| 2684 | 2686 | ||
