diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-10-27 22:12:40 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-10-27 22:12:40 -0400 |
commit | 56ae19f38f10aad4f27f7e12138a29b295dff07a (patch) | |
tree | 79ada0dacbcf6470b4469c537d3bae02bb81069d /fs/nfs/nfs4proc.c | |
parent | 0c70b50150cfb0b43ff500a8a394a52b4d5f1350 (diff) |
NFSv4: Add directory post-op attributes to the CREATE operations.
Since the directory attributes change every time we CREATE a file,
we might as well pick up the new directory attributes in the same
compound.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r-- | fs/nfs/nfs4proc.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3274f2d354f3..f363fd6c7f4d 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -443,7 +443,11 @@ static int _nfs4_proc_open(struct inode *dir, struct nfs4_state_owner *sp, stru | |||
443 | nfs_increment_open_seqid(status, o_arg->seqid); | 443 | nfs_increment_open_seqid(status, o_arg->seqid); |
444 | if (status != 0) | 444 | if (status != 0) |
445 | goto out; | 445 | goto out; |
446 | update_changeattr(dir, &o_res->cinfo); | 446 | if (o_arg->open_flags & O_CREAT) { |
447 | update_changeattr(dir, &o_res->cinfo); | ||
448 | nfs_post_op_update_inode(dir, o_res->dir_attr); | ||
449 | } else | ||
450 | nfs_refresh_inode(dir, o_res->dir_attr); | ||
447 | if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { | 451 | if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { |
448 | status = _nfs4_proc_open_confirm(server->client, &o_res->fh, | 452 | status = _nfs4_proc_open_confirm(server->client, &o_res->fh, |
449 | sp, &o_res->stateid, o_arg->seqid); | 453 | sp, &o_res->stateid, o_arg->seqid); |
@@ -497,7 +501,7 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st | |||
497 | struct inode *inode = state->inode; | 501 | struct inode *inode = state->inode; |
498 | struct nfs_server *server = NFS_SERVER(dir); | 502 | struct nfs_server *server = NFS_SERVER(dir); |
499 | struct nfs_delegation *delegation = NFS_I(inode)->delegation; | 503 | struct nfs_delegation *delegation = NFS_I(inode)->delegation; |
500 | struct nfs_fattr f_attr; | 504 | struct nfs_fattr f_attr, dir_attr; |
501 | struct nfs_openargs o_arg = { | 505 | struct nfs_openargs o_arg = { |
502 | .fh = NFS_FH(dir), | 506 | .fh = NFS_FH(dir), |
503 | .open_flags = state->state, | 507 | .open_flags = state->state, |
@@ -507,6 +511,7 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st | |||
507 | }; | 511 | }; |
508 | struct nfs_openres o_res = { | 512 | struct nfs_openres o_res = { |
509 | .f_attr = &f_attr, | 513 | .f_attr = &f_attr, |
514 | .dir_attr = &dir_attr, | ||
510 | .server = server, | 515 | .server = server, |
511 | }; | 516 | }; |
512 | int status = 0; | 517 | int status = 0; |
@@ -524,6 +529,7 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st | |||
524 | if (o_arg.seqid == NULL) | 529 | if (o_arg.seqid == NULL) |
525 | goto out; | 530 | goto out; |
526 | nfs_fattr_init(&f_attr); | 531 | nfs_fattr_init(&f_attr); |
532 | nfs_fattr_init(&dir_attr); | ||
527 | status = _nfs4_proc_open(dir, sp, &o_arg, &o_res); | 533 | status = _nfs4_proc_open(dir, sp, &o_arg, &o_res); |
528 | if (status != 0) | 534 | if (status != 0) |
529 | goto out_nodeleg; | 535 | goto out_nodeleg; |
@@ -694,7 +700,7 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st | |||
694 | struct nfs4_client *clp = server->nfs4_state; | 700 | struct nfs4_client *clp = server->nfs4_state; |
695 | struct inode *inode = NULL; | 701 | struct inode *inode = NULL; |
696 | int status; | 702 | int status; |
697 | struct nfs_fattr f_attr; | 703 | struct nfs_fattr f_attr, dir_attr; |
698 | struct nfs_openargs o_arg = { | 704 | struct nfs_openargs o_arg = { |
699 | .fh = NFS_FH(dir), | 705 | .fh = NFS_FH(dir), |
700 | .open_flags = flags, | 706 | .open_flags = flags, |
@@ -705,6 +711,7 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st | |||
705 | }; | 711 | }; |
706 | struct nfs_openres o_res = { | 712 | struct nfs_openres o_res = { |
707 | .f_attr = &f_attr, | 713 | .f_attr = &f_attr, |
714 | .dir_attr = &dir_attr, | ||
708 | .server = server, | 715 | .server = server, |
709 | }; | 716 | }; |
710 | 717 | ||
@@ -727,6 +734,7 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st | |||
727 | if (o_arg.seqid == NULL) | 734 | if (o_arg.seqid == NULL) |
728 | return -ENOMEM; | 735 | return -ENOMEM; |
729 | nfs_fattr_init(&f_attr); | 736 | nfs_fattr_init(&f_attr); |
737 | nfs_fattr_init(&dir_attr); | ||
730 | status = _nfs4_proc_open(dir, sp, &o_arg, &o_res); | 738 | status = _nfs4_proc_open(dir, sp, &o_arg, &o_res); |
731 | if (status != 0) | 739 | if (status != 0) |
732 | goto out_err; | 740 | goto out_err; |
@@ -1746,6 +1754,7 @@ static int _nfs4_proc_symlink(struct inode *dir, struct qstr *name, | |||
1746 | struct nfs_fattr *fattr) | 1754 | struct nfs_fattr *fattr) |
1747 | { | 1755 | { |
1748 | struct nfs_server *server = NFS_SERVER(dir); | 1756 | struct nfs_server *server = NFS_SERVER(dir); |
1757 | struct nfs_fattr dir_fattr; | ||
1749 | struct nfs4_create_arg arg = { | 1758 | struct nfs4_create_arg arg = { |
1750 | .dir_fh = NFS_FH(dir), | 1759 | .dir_fh = NFS_FH(dir), |
1751 | .server = server, | 1760 | .server = server, |
@@ -1758,6 +1767,7 @@ static int _nfs4_proc_symlink(struct inode *dir, struct qstr *name, | |||
1758 | .server = server, | 1767 | .server = server, |
1759 | .fh = fhandle, | 1768 | .fh = fhandle, |
1760 | .fattr = fattr, | 1769 | .fattr = fattr, |
1770 | .dir_fattr = &dir_fattr, | ||
1761 | }; | 1771 | }; |
1762 | struct rpc_message msg = { | 1772 | struct rpc_message msg = { |
1763 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SYMLINK], | 1773 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SYMLINK], |
@@ -1770,10 +1780,12 @@ static int _nfs4_proc_symlink(struct inode *dir, struct qstr *name, | |||
1770 | return -ENAMETOOLONG; | 1780 | return -ENAMETOOLONG; |
1771 | arg.u.symlink = path; | 1781 | arg.u.symlink = path; |
1772 | nfs_fattr_init(fattr); | 1782 | nfs_fattr_init(fattr); |
1783 | nfs_fattr_init(&dir_fattr); | ||
1773 | 1784 | ||
1774 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 1785 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
1775 | if (!status) | 1786 | if (!status) |
1776 | update_changeattr(dir, &res.dir_cinfo); | 1787 | update_changeattr(dir, &res.dir_cinfo); |
1788 | nfs_post_op_update_inode(dir, res.dir_fattr); | ||
1777 | return status; | 1789 | return status; |
1778 | } | 1790 | } |
1779 | 1791 | ||
@@ -1797,7 +1809,7 @@ static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry, | |||
1797 | { | 1809 | { |
1798 | struct nfs_server *server = NFS_SERVER(dir); | 1810 | struct nfs_server *server = NFS_SERVER(dir); |
1799 | struct nfs_fh fhandle; | 1811 | struct nfs_fh fhandle; |
1800 | struct nfs_fattr fattr; | 1812 | struct nfs_fattr fattr, dir_fattr; |
1801 | struct nfs4_create_arg arg = { | 1813 | struct nfs4_create_arg arg = { |
1802 | .dir_fh = NFS_FH(dir), | 1814 | .dir_fh = NFS_FH(dir), |
1803 | .server = server, | 1815 | .server = server, |
@@ -1810,6 +1822,7 @@ static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry, | |||
1810 | .server = server, | 1822 | .server = server, |
1811 | .fh = &fhandle, | 1823 | .fh = &fhandle, |
1812 | .fattr = &fattr, | 1824 | .fattr = &fattr, |
1825 | .dir_fattr = &dir_fattr, | ||
1813 | }; | 1826 | }; |
1814 | struct rpc_message msg = { | 1827 | struct rpc_message msg = { |
1815 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], | 1828 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], |
@@ -1819,10 +1832,12 @@ static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry, | |||
1819 | int status; | 1832 | int status; |
1820 | 1833 | ||
1821 | nfs_fattr_init(&fattr); | 1834 | nfs_fattr_init(&fattr); |
1835 | nfs_fattr_init(&dir_fattr); | ||
1822 | 1836 | ||
1823 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 1837 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
1824 | if (!status) { | 1838 | if (!status) { |
1825 | update_changeattr(dir, &res.dir_cinfo); | 1839 | update_changeattr(dir, &res.dir_cinfo); |
1840 | nfs_post_op_update_inode(dir, res.dir_fattr); | ||
1826 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 1841 | status = nfs_instantiate(dentry, &fhandle, &fattr); |
1827 | } | 1842 | } |
1828 | return status; | 1843 | return status; |
@@ -1895,7 +1910,7 @@ static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry, | |||
1895 | { | 1910 | { |
1896 | struct nfs_server *server = NFS_SERVER(dir); | 1911 | struct nfs_server *server = NFS_SERVER(dir); |
1897 | struct nfs_fh fh; | 1912 | struct nfs_fh fh; |
1898 | struct nfs_fattr fattr; | 1913 | struct nfs_fattr fattr, dir_fattr; |
1899 | struct nfs4_create_arg arg = { | 1914 | struct nfs4_create_arg arg = { |
1900 | .dir_fh = NFS_FH(dir), | 1915 | .dir_fh = NFS_FH(dir), |
1901 | .server = server, | 1916 | .server = server, |
@@ -1907,6 +1922,7 @@ static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry, | |||
1907 | .server = server, | 1922 | .server = server, |
1908 | .fh = &fh, | 1923 | .fh = &fh, |
1909 | .fattr = &fattr, | 1924 | .fattr = &fattr, |
1925 | .dir_fattr = &dir_fattr, | ||
1910 | }; | 1926 | }; |
1911 | struct rpc_message msg = { | 1927 | struct rpc_message msg = { |
1912 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], | 1928 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], |
@@ -1917,6 +1933,7 @@ static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry, | |||
1917 | int mode = sattr->ia_mode; | 1933 | int mode = sattr->ia_mode; |
1918 | 1934 | ||
1919 | nfs_fattr_init(&fattr); | 1935 | nfs_fattr_init(&fattr); |
1936 | nfs_fattr_init(&dir_fattr); | ||
1920 | 1937 | ||
1921 | BUG_ON(!(sattr->ia_valid & ATTR_MODE)); | 1938 | BUG_ON(!(sattr->ia_valid & ATTR_MODE)); |
1922 | BUG_ON(!S_ISFIFO(mode) && !S_ISBLK(mode) && !S_ISCHR(mode) && !S_ISSOCK(mode)); | 1939 | BUG_ON(!S_ISFIFO(mode) && !S_ISBLK(mode) && !S_ISCHR(mode) && !S_ISSOCK(mode)); |
@@ -1938,6 +1955,7 @@ static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry, | |||
1938 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 1955 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
1939 | if (status == 0) { | 1956 | if (status == 0) { |
1940 | update_changeattr(dir, &res.dir_cinfo); | 1957 | update_changeattr(dir, &res.dir_cinfo); |
1958 | nfs_post_op_update_inode(dir, res.dir_fattr); | ||
1941 | status = nfs_instantiate(dentry, &fh, &fattr); | 1959 | status = nfs_instantiate(dentry, &fh, &fattr); |
1942 | } | 1960 | } |
1943 | return status; | 1961 | return status; |