diff options
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/callback.c | 34 | ||||
-rw-r--r-- | fs/nfs/client.c | 13 | ||||
-rw-r--r-- | fs/nfs/dir.c | 90 | ||||
-rw-r--r-- | fs/nfs/direct.c | 4 | ||||
-rw-r--r-- | fs/nfs/file.c | 161 | ||||
-rw-r--r-- | fs/nfs/inode.c | 79 | ||||
-rw-r--r-- | fs/nfs/internal.h | 1 | ||||
-rw-r--r-- | fs/nfs/iostat.h | 119 | ||||
-rw-r--r-- | fs/nfs/nfs3acl.c | 9 | ||||
-rw-r--r-- | fs/nfs/nfs3proc.c | 275 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 265 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 2 | ||||
-rw-r--r-- | fs/nfs/nfsroot.c | 10 | ||||
-rw-r--r-- | fs/nfs/proc.c | 28 | ||||
-rw-r--r-- | fs/nfs/super.c | 882 | ||||
-rw-r--r-- | fs/nfs/write.c | 322 |
16 files changed, 1326 insertions, 968 deletions
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index c1e7c8300629..f447f4b4476c 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | struct nfs_callback_data { | 28 | struct nfs_callback_data { |
29 | unsigned int users; | 29 | unsigned int users; |
30 | struct svc_serv *serv; | 30 | struct svc_rqst *rqst; |
31 | struct task_struct *task; | 31 | struct task_struct *task; |
32 | }; | 32 | }; |
33 | 33 | ||
@@ -91,21 +91,17 @@ nfs_callback_svc(void *vrqstp) | |||
91 | svc_process(rqstp); | 91 | svc_process(rqstp); |
92 | } | 92 | } |
93 | unlock_kernel(); | 93 | unlock_kernel(); |
94 | nfs_callback_info.task = NULL; | ||
95 | svc_exit_thread(rqstp); | ||
96 | return 0; | 94 | return 0; |
97 | } | 95 | } |
98 | 96 | ||
99 | /* | 97 | /* |
100 | * Bring up the server process if it is not already up. | 98 | * Bring up the callback thread if it is not already up. |
101 | */ | 99 | */ |
102 | int nfs_callback_up(void) | 100 | int nfs_callback_up(void) |
103 | { | 101 | { |
104 | struct svc_serv *serv = NULL; | 102 | struct svc_serv *serv = NULL; |
105 | struct svc_rqst *rqstp; | ||
106 | int ret = 0; | 103 | int ret = 0; |
107 | 104 | ||
108 | lock_kernel(); | ||
109 | mutex_lock(&nfs_callback_mutex); | 105 | mutex_lock(&nfs_callback_mutex); |
110 | if (nfs_callback_info.users++ || nfs_callback_info.task != NULL) | 106 | if (nfs_callback_info.users++ || nfs_callback_info.task != NULL) |
111 | goto out; | 107 | goto out; |
@@ -121,22 +117,23 @@ int nfs_callback_up(void) | |||
121 | nfs_callback_tcpport = ret; | 117 | nfs_callback_tcpport = ret; |
122 | dprintk("Callback port = 0x%x\n", nfs_callback_tcpport); | 118 | dprintk("Callback port = 0x%x\n", nfs_callback_tcpport); |
123 | 119 | ||
124 | rqstp = svc_prepare_thread(serv, &serv->sv_pools[0]); | 120 | nfs_callback_info.rqst = svc_prepare_thread(serv, &serv->sv_pools[0]); |
125 | if (IS_ERR(rqstp)) { | 121 | if (IS_ERR(nfs_callback_info.rqst)) { |
126 | ret = PTR_ERR(rqstp); | 122 | ret = PTR_ERR(nfs_callback_info.rqst); |
123 | nfs_callback_info.rqst = NULL; | ||
127 | goto out_err; | 124 | goto out_err; |
128 | } | 125 | } |
129 | 126 | ||
130 | svc_sock_update_bufs(serv); | 127 | svc_sock_update_bufs(serv); |
131 | nfs_callback_info.serv = serv; | ||
132 | 128 | ||
133 | nfs_callback_info.task = kthread_run(nfs_callback_svc, rqstp, | 129 | nfs_callback_info.task = kthread_run(nfs_callback_svc, |
130 | nfs_callback_info.rqst, | ||
134 | "nfsv4-svc"); | 131 | "nfsv4-svc"); |
135 | if (IS_ERR(nfs_callback_info.task)) { | 132 | if (IS_ERR(nfs_callback_info.task)) { |
136 | ret = PTR_ERR(nfs_callback_info.task); | 133 | ret = PTR_ERR(nfs_callback_info.task); |
137 | nfs_callback_info.serv = NULL; | 134 | svc_exit_thread(nfs_callback_info.rqst); |
135 | nfs_callback_info.rqst = NULL; | ||
138 | nfs_callback_info.task = NULL; | 136 | nfs_callback_info.task = NULL; |
139 | svc_exit_thread(rqstp); | ||
140 | goto out_err; | 137 | goto out_err; |
141 | } | 138 | } |
142 | out: | 139 | out: |
@@ -149,7 +146,6 @@ out: | |||
149 | if (serv) | 146 | if (serv) |
150 | svc_destroy(serv); | 147 | svc_destroy(serv); |
151 | mutex_unlock(&nfs_callback_mutex); | 148 | mutex_unlock(&nfs_callback_mutex); |
152 | unlock_kernel(); | ||
153 | return ret; | 149 | return ret; |
154 | out_err: | 150 | out_err: |
155 | dprintk("Couldn't create callback socket or server thread; err = %d\n", | 151 | dprintk("Couldn't create callback socket or server thread; err = %d\n", |
@@ -159,17 +155,19 @@ out_err: | |||
159 | } | 155 | } |
160 | 156 | ||
161 | /* | 157 | /* |
162 | * Kill the server process if it is not already down. | 158 | * Kill the callback thread if it's no longer being used. |
163 | */ | 159 | */ |
164 | void nfs_callback_down(void) | 160 | void nfs_callback_down(void) |
165 | { | 161 | { |
166 | lock_kernel(); | ||
167 | mutex_lock(&nfs_callback_mutex); | 162 | mutex_lock(&nfs_callback_mutex); |
168 | nfs_callback_info.users--; | 163 | nfs_callback_info.users--; |
169 | if (nfs_callback_info.users == 0 && nfs_callback_info.task != NULL) | 164 | if (nfs_callback_info.users == 0 && nfs_callback_info.task != NULL) { |
170 | kthread_stop(nfs_callback_info.task); | 165 | kthread_stop(nfs_callback_info.task); |
166 | svc_exit_thread(nfs_callback_info.rqst); | ||
167 | nfs_callback_info.rqst = NULL; | ||
168 | nfs_callback_info.task = NULL; | ||
169 | } | ||
171 | mutex_unlock(&nfs_callback_mutex); | 170 | mutex_unlock(&nfs_callback_mutex); |
172 | unlock_kernel(); | ||
173 | } | 171 | } |
174 | 172 | ||
175 | static int nfs_callback_authenticate(struct svc_rqst *rqstp) | 173 | static int nfs_callback_authenticate(struct svc_rqst *rqstp) |
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index f2a092ca69b5..5ee23e7058b3 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -431,14 +431,14 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | |||
431 | { | 431 | { |
432 | to->to_initval = timeo * HZ / 10; | 432 | to->to_initval = timeo * HZ / 10; |
433 | to->to_retries = retrans; | 433 | to->to_retries = retrans; |
434 | if (!to->to_retries) | ||
435 | to->to_retries = 2; | ||
436 | 434 | ||
437 | switch (proto) { | 435 | switch (proto) { |
438 | case XPRT_TRANSPORT_TCP: | 436 | case XPRT_TRANSPORT_TCP: |
439 | case XPRT_TRANSPORT_RDMA: | 437 | case XPRT_TRANSPORT_RDMA: |
438 | if (to->to_retries == 0) | ||
439 | to->to_retries = NFS_DEF_TCP_RETRANS; | ||
440 | if (to->to_initval == 0) | 440 | if (to->to_initval == 0) |
441 | to->to_initval = 60 * HZ; | 441 | to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10; |
442 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) | 442 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) |
443 | to->to_initval = NFS_MAX_TCP_TIMEOUT; | 443 | to->to_initval = NFS_MAX_TCP_TIMEOUT; |
444 | to->to_increment = to->to_initval; | 444 | to->to_increment = to->to_initval; |
@@ -450,14 +450,17 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | |||
450 | to->to_exponential = 0; | 450 | to->to_exponential = 0; |
451 | break; | 451 | break; |
452 | case XPRT_TRANSPORT_UDP: | 452 | case XPRT_TRANSPORT_UDP: |
453 | default: | 453 | if (to->to_retries == 0) |
454 | to->to_retries = NFS_DEF_UDP_RETRANS; | ||
454 | if (!to->to_initval) | 455 | if (!to->to_initval) |
455 | to->to_initval = 11 * HZ / 10; | 456 | to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10; |
456 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) | 457 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) |
457 | to->to_initval = NFS_MAX_UDP_TIMEOUT; | 458 | to->to_initval = NFS_MAX_UDP_TIMEOUT; |
458 | to->to_maxval = NFS_MAX_UDP_TIMEOUT; | 459 | to->to_maxval = NFS_MAX_UDP_TIMEOUT; |
459 | to->to_exponential = 1; | 460 | to->to_exponential = 1; |
460 | break; | 461 | break; |
462 | default: | ||
463 | BUG(); | ||
461 | } | 464 | } |
462 | } | 465 | } |
463 | 466 | ||
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 58d43daec084..28a238dab23a 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -133,13 +133,14 @@ nfs_opendir(struct inode *inode, struct file *filp) | |||
133 | { | 133 | { |
134 | int res; | 134 | int res; |
135 | 135 | ||
136 | dfprintk(VFS, "NFS: opendir(%s/%ld)\n", | 136 | dfprintk(FILE, "NFS: open dir(%s/%s)\n", |
137 | inode->i_sb->s_id, inode->i_ino); | 137 | filp->f_path.dentry->d_parent->d_name.name, |
138 | filp->f_path.dentry->d_name.name); | ||
139 | |||
140 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); | ||
138 | 141 | ||
139 | lock_kernel(); | ||
140 | /* Call generic open code in order to cache credentials */ | 142 | /* Call generic open code in order to cache credentials */ |
141 | res = nfs_open(inode, filp); | 143 | res = nfs_open(inode, filp); |
142 | unlock_kernel(); | ||
143 | return res; | 144 | return res; |
144 | } | 145 | } |
145 | 146 | ||
@@ -204,7 +205,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page) | |||
204 | * Note: assumes we have exclusive access to this mapping either | 205 | * Note: assumes we have exclusive access to this mapping either |
205 | * through inode->i_mutex or some other mechanism. | 206 | * through inode->i_mutex or some other mechanism. |
206 | */ | 207 | */ |
207 | if (page->index == 0 && invalidate_inode_pages2_range(inode->i_mapping, PAGE_CACHE_SIZE, -1) < 0) { | 208 | if (invalidate_inode_pages2_range(inode->i_mapping, page->index + 1, -1) < 0) { |
208 | /* Should never happen */ | 209 | /* Should never happen */ |
209 | nfs_zap_mapping(inode, inode->i_mapping); | 210 | nfs_zap_mapping(inode, inode->i_mapping); |
210 | } | 211 | } |
@@ -528,13 +529,11 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
528 | struct nfs_fattr fattr; | 529 | struct nfs_fattr fattr; |
529 | long res; | 530 | long res; |
530 | 531 | ||
531 | dfprintk(VFS, "NFS: readdir(%s/%s) starting at cookie %Lu\n", | 532 | dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n", |
532 | dentry->d_parent->d_name.name, dentry->d_name.name, | 533 | dentry->d_parent->d_name.name, dentry->d_name.name, |
533 | (long long)filp->f_pos); | 534 | (long long)filp->f_pos); |
534 | nfs_inc_stats(inode, NFSIOS_VFSGETDENTS); | 535 | nfs_inc_stats(inode, NFSIOS_VFSGETDENTS); |
535 | 536 | ||
536 | lock_kernel(); | ||
537 | |||
538 | /* | 537 | /* |
539 | * filp->f_pos points to the dirent entry number. | 538 | * filp->f_pos points to the dirent entry number. |
540 | * *desc->dir_cookie has the cookie for the next entry. We have | 539 | * *desc->dir_cookie has the cookie for the next entry. We have |
@@ -592,10 +591,9 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
592 | } | 591 | } |
593 | out: | 592 | out: |
594 | nfs_unblock_sillyrename(dentry); | 593 | nfs_unblock_sillyrename(dentry); |
595 | unlock_kernel(); | ||
596 | if (res > 0) | 594 | if (res > 0) |
597 | res = 0; | 595 | res = 0; |
598 | dfprintk(VFS, "NFS: readdir(%s/%s) returns %ld\n", | 596 | dfprintk(FILE, "NFS: readdir(%s/%s) returns %ld\n", |
599 | dentry->d_parent->d_name.name, dentry->d_name.name, | 597 | dentry->d_parent->d_name.name, dentry->d_name.name, |
600 | res); | 598 | res); |
601 | return res; | 599 | return res; |
@@ -603,7 +601,15 @@ out: | |||
603 | 601 | ||
604 | static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) | 602 | static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) |
605 | { | 603 | { |
606 | mutex_lock(&filp->f_path.dentry->d_inode->i_mutex); | 604 | struct dentry *dentry = filp->f_path.dentry; |
605 | struct inode *inode = dentry->d_inode; | ||
606 | |||
607 | dfprintk(FILE, "NFS: llseek dir(%s/%s, %lld, %d)\n", | ||
608 | dentry->d_parent->d_name.name, | ||
609 | dentry->d_name.name, | ||
610 | offset, origin); | ||
611 | |||
612 | mutex_lock(&inode->i_mutex); | ||
607 | switch (origin) { | 613 | switch (origin) { |
608 | case 1: | 614 | case 1: |
609 | offset += filp->f_pos; | 615 | offset += filp->f_pos; |
@@ -619,7 +625,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) | |||
619 | nfs_file_open_context(filp)->dir_cookie = 0; | 625 | nfs_file_open_context(filp)->dir_cookie = 0; |
620 | } | 626 | } |
621 | out: | 627 | out: |
622 | mutex_unlock(&filp->f_path.dentry->d_inode->i_mutex); | 628 | mutex_unlock(&inode->i_mutex); |
623 | return offset; | 629 | return offset; |
624 | } | 630 | } |
625 | 631 | ||
@@ -629,10 +635,11 @@ out: | |||
629 | */ | 635 | */ |
630 | static int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync) | 636 | static int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync) |
631 | { | 637 | { |
632 | dfprintk(VFS, "NFS: fsync_dir(%s/%s) datasync %d\n", | 638 | dfprintk(FILE, "NFS: fsync dir(%s/%s) datasync %d\n", |
633 | dentry->d_parent->d_name.name, dentry->d_name.name, | 639 | dentry->d_parent->d_name.name, dentry->d_name.name, |
634 | datasync); | 640 | datasync); |
635 | 641 | ||
642 | nfs_inc_stats(dentry->d_inode, NFSIOS_VFSFSYNC); | ||
636 | return 0; | 643 | return 0; |
637 | } | 644 | } |
638 | 645 | ||
@@ -767,7 +774,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
767 | struct nfs_fattr fattr; | 774 | struct nfs_fattr fattr; |
768 | 775 | ||
769 | parent = dget_parent(dentry); | 776 | parent = dget_parent(dentry); |
770 | lock_kernel(); | ||
771 | dir = parent->d_inode; | 777 | dir = parent->d_inode; |
772 | nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE); | 778 | nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE); |
773 | inode = dentry->d_inode; | 779 | inode = dentry->d_inode; |
@@ -805,7 +811,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
805 | 811 | ||
806 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 812 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
807 | out_valid: | 813 | out_valid: |
808 | unlock_kernel(); | ||
809 | dput(parent); | 814 | dput(parent); |
810 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n", | 815 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n", |
811 | __func__, dentry->d_parent->d_name.name, | 816 | __func__, dentry->d_parent->d_name.name, |
@@ -824,7 +829,6 @@ out_zap_parent: | |||
824 | shrink_dcache_parent(dentry); | 829 | shrink_dcache_parent(dentry); |
825 | } | 830 | } |
826 | d_drop(dentry); | 831 | d_drop(dentry); |
827 | unlock_kernel(); | ||
828 | dput(parent); | 832 | dput(parent); |
829 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n", | 833 | dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n", |
830 | __func__, dentry->d_parent->d_name.name, | 834 | __func__, dentry->d_parent->d_name.name, |
@@ -858,6 +862,14 @@ static int nfs_dentry_delete(struct dentry *dentry) | |||
858 | 862 | ||
859 | } | 863 | } |
860 | 864 | ||
865 | static void nfs_drop_nlink(struct inode *inode) | ||
866 | { | ||
867 | spin_lock(&inode->i_lock); | ||
868 | if (inode->i_nlink > 0) | ||
869 | drop_nlink(inode); | ||
870 | spin_unlock(&inode->i_lock); | ||
871 | } | ||
872 | |||
861 | /* | 873 | /* |
862 | * Called when the dentry loses inode. | 874 | * Called when the dentry loses inode. |
863 | * We use it to clean up silly-renamed files. | 875 | * We use it to clean up silly-renamed files. |
@@ -869,10 +881,8 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) | |||
869 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA; | 881 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA; |
870 | 882 | ||
871 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { | 883 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { |
872 | lock_kernel(); | ||
873 | drop_nlink(inode); | 884 | drop_nlink(inode); |
874 | nfs_complete_unlink(dentry, inode); | 885 | nfs_complete_unlink(dentry, inode); |
875 | unlock_kernel(); | ||
876 | } | 886 | } |
877 | iput(inode); | 887 | iput(inode); |
878 | } | 888 | } |
@@ -903,8 +913,6 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
903 | res = ERR_PTR(-ENOMEM); | 913 | res = ERR_PTR(-ENOMEM); |
904 | dentry->d_op = NFS_PROTO(dir)->dentry_ops; | 914 | dentry->d_op = NFS_PROTO(dir)->dentry_ops; |
905 | 915 | ||
906 | lock_kernel(); | ||
907 | |||
908 | /* | 916 | /* |
909 | * If we're doing an exclusive create, optimize away the lookup | 917 | * If we're doing an exclusive create, optimize away the lookup |
910 | * but don't hash the dentry. | 918 | * but don't hash the dentry. |
@@ -912,7 +920,7 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
912 | if (nfs_is_exclusive_create(dir, nd)) { | 920 | if (nfs_is_exclusive_create(dir, nd)) { |
913 | d_instantiate(dentry, NULL); | 921 | d_instantiate(dentry, NULL); |
914 | res = NULL; | 922 | res = NULL; |
915 | goto out_unlock; | 923 | goto out; |
916 | } | 924 | } |
917 | 925 | ||
918 | parent = dentry->d_parent; | 926 | parent = dentry->d_parent; |
@@ -940,8 +948,6 @@ no_entry: | |||
940 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 948 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
941 | out_unblock_sillyrename: | 949 | out_unblock_sillyrename: |
942 | nfs_unblock_sillyrename(parent); | 950 | nfs_unblock_sillyrename(parent); |
943 | out_unlock: | ||
944 | unlock_kernel(); | ||
945 | out: | 951 | out: |
946 | return res; | 952 | return res; |
947 | } | 953 | } |
@@ -999,9 +1005,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry | |||
999 | } | 1005 | } |
1000 | 1006 | ||
1001 | /* Open the file on the server */ | 1007 | /* Open the file on the server */ |
1002 | lock_kernel(); | ||
1003 | res = nfs4_atomic_open(dir, dentry, nd); | 1008 | res = nfs4_atomic_open(dir, dentry, nd); |
1004 | unlock_kernel(); | ||
1005 | if (IS_ERR(res)) { | 1009 | if (IS_ERR(res)) { |
1006 | error = PTR_ERR(res); | 1010 | error = PTR_ERR(res); |
1007 | switch (error) { | 1011 | switch (error) { |
@@ -1063,9 +1067,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1063 | * operations that change the directory. We therefore save the | 1067 | * operations that change the directory. We therefore save the |
1064 | * change attribute *before* we do the RPC call. | 1068 | * change attribute *before* we do the RPC call. |
1065 | */ | 1069 | */ |
1066 | lock_kernel(); | ||
1067 | ret = nfs4_open_revalidate(dir, dentry, openflags, nd); | 1070 | ret = nfs4_open_revalidate(dir, dentry, openflags, nd); |
1068 | unlock_kernel(); | ||
1069 | out: | 1071 | out: |
1070 | dput(parent); | 1072 | dput(parent); |
1071 | if (!ret) | 1073 | if (!ret) |
@@ -1218,14 +1220,11 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1218 | if ((nd->flags & LOOKUP_CREATE) != 0) | 1220 | if ((nd->flags & LOOKUP_CREATE) != 0) |
1219 | open_flags = nd->intent.open.flags; | 1221 | open_flags = nd->intent.open.flags; |
1220 | 1222 | ||
1221 | lock_kernel(); | ||
1222 | error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd); | 1223 | error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd); |
1223 | if (error != 0) | 1224 | if (error != 0) |
1224 | goto out_err; | 1225 | goto out_err; |
1225 | unlock_kernel(); | ||
1226 | return 0; | 1226 | return 0; |
1227 | out_err: | 1227 | out_err: |
1228 | unlock_kernel(); | ||
1229 | d_drop(dentry); | 1228 | d_drop(dentry); |
1230 | return error; | 1229 | return error; |
1231 | } | 1230 | } |
@@ -1248,14 +1247,11 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | |||
1248 | attr.ia_mode = mode; | 1247 | attr.ia_mode = mode; |
1249 | attr.ia_valid = ATTR_MODE; | 1248 | attr.ia_valid = ATTR_MODE; |
1250 | 1249 | ||
1251 | lock_kernel(); | ||
1252 | status = NFS_PROTO(dir)->mknod(dir, dentry, &attr, rdev); | 1250 | status = NFS_PROTO(dir)->mknod(dir, dentry, &attr, rdev); |
1253 | if (status != 0) | 1251 | if (status != 0) |
1254 | goto out_err; | 1252 | goto out_err; |
1255 | unlock_kernel(); | ||
1256 | return 0; | 1253 | return 0; |
1257 | out_err: | 1254 | out_err: |
1258 | unlock_kernel(); | ||
1259 | d_drop(dentry); | 1255 | d_drop(dentry); |
1260 | return status; | 1256 | return status; |
1261 | } | 1257 | } |
@@ -1274,15 +1270,12 @@ static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1274 | attr.ia_valid = ATTR_MODE; | 1270 | attr.ia_valid = ATTR_MODE; |
1275 | attr.ia_mode = mode | S_IFDIR; | 1271 | attr.ia_mode = mode | S_IFDIR; |
1276 | 1272 | ||
1277 | lock_kernel(); | ||
1278 | error = NFS_PROTO(dir)->mkdir(dir, dentry, &attr); | 1273 | error = NFS_PROTO(dir)->mkdir(dir, dentry, &attr); |
1279 | if (error != 0) | 1274 | if (error != 0) |
1280 | goto out_err; | 1275 | goto out_err; |
1281 | unlock_kernel(); | ||
1282 | return 0; | 1276 | return 0; |
1283 | out_err: | 1277 | out_err: |
1284 | d_drop(dentry); | 1278 | d_drop(dentry); |
1285 | unlock_kernel(); | ||
1286 | return error; | 1279 | return error; |
1287 | } | 1280 | } |
1288 | 1281 | ||
@@ -1299,14 +1292,12 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1299 | dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n", | 1292 | dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n", |
1300 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); | 1293 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); |
1301 | 1294 | ||
1302 | lock_kernel(); | ||
1303 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); | 1295 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); |
1304 | /* Ensure the VFS deletes this inode */ | 1296 | /* Ensure the VFS deletes this inode */ |
1305 | if (error == 0 && dentry->d_inode != NULL) | 1297 | if (error == 0 && dentry->d_inode != NULL) |
1306 | clear_nlink(dentry->d_inode); | 1298 | clear_nlink(dentry->d_inode); |
1307 | else if (error == -ENOENT) | 1299 | else if (error == -ENOENT) |
1308 | nfs_dentry_handle_enoent(dentry); | 1300 | nfs_dentry_handle_enoent(dentry); |
1309 | unlock_kernel(); | ||
1310 | 1301 | ||
1311 | return error; | 1302 | return error; |
1312 | } | 1303 | } |
@@ -1408,7 +1399,7 @@ static int nfs_safe_remove(struct dentry *dentry) | |||
1408 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); | 1399 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); |
1409 | /* The VFS may want to delete this inode */ | 1400 | /* The VFS may want to delete this inode */ |
1410 | if (error == 0) | 1401 | if (error == 0) |
1411 | drop_nlink(inode); | 1402 | nfs_drop_nlink(inode); |
1412 | nfs_mark_for_revalidate(inode); | 1403 | nfs_mark_for_revalidate(inode); |
1413 | } else | 1404 | } else |
1414 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); | 1405 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); |
@@ -1431,7 +1422,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry) | |||
1431 | dfprintk(VFS, "NFS: unlink(%s/%ld, %s)\n", dir->i_sb->s_id, | 1422 | dfprintk(VFS, "NFS: unlink(%s/%ld, %s)\n", dir->i_sb->s_id, |
1432 | dir->i_ino, dentry->d_name.name); | 1423 | dir->i_ino, dentry->d_name.name); |
1433 | 1424 | ||
1434 | lock_kernel(); | ||
1435 | spin_lock(&dcache_lock); | 1425 | spin_lock(&dcache_lock); |
1436 | spin_lock(&dentry->d_lock); | 1426 | spin_lock(&dentry->d_lock); |
1437 | if (atomic_read(&dentry->d_count) > 1) { | 1427 | if (atomic_read(&dentry->d_count) > 1) { |
@@ -1440,7 +1430,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry) | |||
1440 | /* Start asynchronous writeout of the inode */ | 1430 | /* Start asynchronous writeout of the inode */ |
1441 | write_inode_now(dentry->d_inode, 0); | 1431 | write_inode_now(dentry->d_inode, 0); |
1442 | error = nfs_sillyrename(dir, dentry); | 1432 | error = nfs_sillyrename(dir, dentry); |
1443 | unlock_kernel(); | ||
1444 | return error; | 1433 | return error; |
1445 | } | 1434 | } |
1446 | if (!d_unhashed(dentry)) { | 1435 | if (!d_unhashed(dentry)) { |
@@ -1454,7 +1443,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry) | |||
1454 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 1443 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
1455 | } else if (need_rehash) | 1444 | } else if (need_rehash) |
1456 | d_rehash(dentry); | 1445 | d_rehash(dentry); |
1457 | unlock_kernel(); | ||
1458 | return error; | 1446 | return error; |
1459 | } | 1447 | } |
1460 | 1448 | ||
@@ -1491,13 +1479,9 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym | |||
1491 | attr.ia_mode = S_IFLNK | S_IRWXUGO; | 1479 | attr.ia_mode = S_IFLNK | S_IRWXUGO; |
1492 | attr.ia_valid = ATTR_MODE; | 1480 | attr.ia_valid = ATTR_MODE; |
1493 | 1481 | ||
1494 | lock_kernel(); | ||
1495 | |||
1496 | page = alloc_page(GFP_HIGHUSER); | 1482 | page = alloc_page(GFP_HIGHUSER); |
1497 | if (!page) { | 1483 | if (!page) |
1498 | unlock_kernel(); | ||
1499 | return -ENOMEM; | 1484 | return -ENOMEM; |
1500 | } | ||
1501 | 1485 | ||
1502 | kaddr = kmap_atomic(page, KM_USER0); | 1486 | kaddr = kmap_atomic(page, KM_USER0); |
1503 | memcpy(kaddr, symname, pathlen); | 1487 | memcpy(kaddr, symname, pathlen); |
@@ -1512,7 +1496,6 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym | |||
1512 | dentry->d_name.name, symname, error); | 1496 | dentry->d_name.name, symname, error); |
1513 | d_drop(dentry); | 1497 | d_drop(dentry); |
1514 | __free_page(page); | 1498 | __free_page(page); |
1515 | unlock_kernel(); | ||
1516 | return error; | 1499 | return error; |
1517 | } | 1500 | } |
1518 | 1501 | ||
@@ -1530,7 +1513,6 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym | |||
1530 | } else | 1513 | } else |
1531 | __free_page(page); | 1514 | __free_page(page); |
1532 | 1515 | ||
1533 | unlock_kernel(); | ||
1534 | return 0; | 1516 | return 0; |
1535 | } | 1517 | } |
1536 | 1518 | ||
@@ -1544,14 +1526,12 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) | |||
1544 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, | 1526 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, |
1545 | dentry->d_parent->d_name.name, dentry->d_name.name); | 1527 | dentry->d_parent->d_name.name, dentry->d_name.name); |
1546 | 1528 | ||
1547 | lock_kernel(); | ||
1548 | d_drop(dentry); | 1529 | d_drop(dentry); |
1549 | error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); | 1530 | error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); |
1550 | if (error == 0) { | 1531 | if (error == 0) { |
1551 | atomic_inc(&inode->i_count); | 1532 | atomic_inc(&inode->i_count); |
1552 | d_add(dentry, inode); | 1533 | d_add(dentry, inode); |
1553 | } | 1534 | } |
1554 | unlock_kernel(); | ||
1555 | return error; | 1535 | return error; |
1556 | } | 1536 | } |
1557 | 1537 | ||
@@ -1591,7 +1571,6 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1591 | * To prevent any new references to the target during the rename, | 1571 | * To prevent any new references to the target during the rename, |
1592 | * we unhash the dentry and free the inode in advance. | 1572 | * we unhash the dentry and free the inode in advance. |
1593 | */ | 1573 | */ |
1594 | lock_kernel(); | ||
1595 | if (!d_unhashed(new_dentry)) { | 1574 | if (!d_unhashed(new_dentry)) { |
1596 | d_drop(new_dentry); | 1575 | d_drop(new_dentry); |
1597 | rehash = new_dentry; | 1576 | rehash = new_dentry; |
@@ -1635,7 +1614,7 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1635 | /* dentry still busy? */ | 1614 | /* dentry still busy? */ |
1636 | goto out; | 1615 | goto out; |
1637 | } else | 1616 | } else |
1638 | drop_nlink(new_inode); | 1617 | nfs_drop_nlink(new_inode); |
1639 | 1618 | ||
1640 | go_ahead: | 1619 | go_ahead: |
1641 | /* | 1620 | /* |
@@ -1669,7 +1648,6 @@ out: | |||
1669 | /* new dentry created? */ | 1648 | /* new dentry created? */ |
1670 | if (dentry) | 1649 | if (dentry) |
1671 | dput(dentry); | 1650 | dput(dentry); |
1672 | unlock_kernel(); | ||
1673 | return error; | 1651 | return error; |
1674 | } | 1652 | } |
1675 | 1653 | ||
@@ -1962,8 +1940,6 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) | |||
1962 | } | 1940 | } |
1963 | 1941 | ||
1964 | force_lookup: | 1942 | force_lookup: |
1965 | lock_kernel(); | ||
1966 | |||
1967 | if (!NFS_PROTO(inode)->access) | 1943 | if (!NFS_PROTO(inode)->access) |
1968 | goto out_notsup; | 1944 | goto out_notsup; |
1969 | 1945 | ||
@@ -1973,7 +1949,6 @@ force_lookup: | |||
1973 | put_rpccred(cred); | 1949 | put_rpccred(cred); |
1974 | } else | 1950 | } else |
1975 | res = PTR_ERR(cred); | 1951 | res = PTR_ERR(cred); |
1976 | unlock_kernel(); | ||
1977 | out: | 1952 | out: |
1978 | dfprintk(VFS, "NFS: permission(%s/%ld), mask=0x%x, res=%d\n", | 1953 | dfprintk(VFS, "NFS: permission(%s/%ld), mask=0x%x, res=%d\n", |
1979 | inode->i_sb->s_id, inode->i_ino, mask, res); | 1954 | inode->i_sb->s_id, inode->i_ino, mask, res); |
@@ -1982,7 +1957,6 @@ out_notsup: | |||
1982 | res = nfs_revalidate_inode(NFS_SERVER(inode), inode); | 1957 | res = nfs_revalidate_inode(NFS_SERVER(inode), inode); |
1983 | if (res == 0) | 1958 | if (res == 0) |
1984 | res = generic_permission(inode, mask, NULL); | 1959 | res = generic_permission(inode, mask, NULL); |
1985 | unlock_kernel(); | ||
1986 | goto out; | 1960 | goto out; |
1987 | } | 1961 | } |
1988 | 1962 | ||
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 4757a2b326a1..08f6b040d289 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -890,7 +890,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov, | |||
890 | count = iov_length(iov, nr_segs); | 890 | count = iov_length(iov, nr_segs); |
891 | nfs_add_stats(mapping->host, NFSIOS_DIRECTREADBYTES, count); | 891 | nfs_add_stats(mapping->host, NFSIOS_DIRECTREADBYTES, count); |
892 | 892 | ||
893 | dprintk("nfs: direct read(%s/%s, %zd@%Ld)\n", | 893 | dfprintk(FILE, "NFS: direct read(%s/%s, %zd@%Ld)\n", |
894 | file->f_path.dentry->d_parent->d_name.name, | 894 | file->f_path.dentry->d_parent->d_name.name, |
895 | file->f_path.dentry->d_name.name, | 895 | file->f_path.dentry->d_name.name, |
896 | count, (long long) pos); | 896 | count, (long long) pos); |
@@ -947,7 +947,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov, | |||
947 | count = iov_length(iov, nr_segs); | 947 | count = iov_length(iov, nr_segs); |
948 | nfs_add_stats(mapping->host, NFSIOS_DIRECTWRITTENBYTES, count); | 948 | nfs_add_stats(mapping->host, NFSIOS_DIRECTWRITTENBYTES, count); |
949 | 949 | ||
950 | dfprintk(VFS, "nfs: direct write(%s/%s, %zd@%Ld)\n", | 950 | dfprintk(FILE, "NFS: direct write(%s/%s, %zd@%Ld)\n", |
951 | file->f_path.dentry->d_parent->d_name.name, | 951 | file->f_path.dentry->d_parent->d_name.name, |
952 | file->f_path.dentry->d_name.name, | 952 | file->f_path.dentry->d_name.name, |
953 | count, (long long) pos); | 953 | count, (long long) pos); |
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index d84a3d8f32af..78460657f5cb 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -50,7 +50,7 @@ static ssize_t nfs_file_read(struct kiocb *, const struct iovec *iov, | |||
50 | static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov, | 50 | static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov, |
51 | unsigned long nr_segs, loff_t pos); | 51 | unsigned long nr_segs, loff_t pos); |
52 | static int nfs_file_flush(struct file *, fl_owner_t id); | 52 | static int nfs_file_flush(struct file *, fl_owner_t id); |
53 | static int nfs_fsync(struct file *, struct dentry *dentry, int datasync); | 53 | static int nfs_file_fsync(struct file *, struct dentry *dentry, int datasync); |
54 | static int nfs_check_flags(int flags); | 54 | static int nfs_check_flags(int flags); |
55 | static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl); | 55 | static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl); |
56 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl); | 56 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl); |
@@ -72,7 +72,7 @@ const struct file_operations nfs_file_operations = { | |||
72 | .open = nfs_file_open, | 72 | .open = nfs_file_open, |
73 | .flush = nfs_file_flush, | 73 | .flush = nfs_file_flush, |
74 | .release = nfs_file_release, | 74 | .release = nfs_file_release, |
75 | .fsync = nfs_fsync, | 75 | .fsync = nfs_file_fsync, |
76 | .lock = nfs_lock, | 76 | .lock = nfs_lock, |
77 | .flock = nfs_flock, | 77 | .flock = nfs_flock, |
78 | .splice_read = nfs_file_splice_read, | 78 | .splice_read = nfs_file_splice_read, |
@@ -119,25 +119,33 @@ nfs_file_open(struct inode *inode, struct file *filp) | |||
119 | { | 119 | { |
120 | int res; | 120 | int res; |
121 | 121 | ||
122 | dprintk("NFS: open file(%s/%s)\n", | ||
123 | filp->f_path.dentry->d_parent->d_name.name, | ||
124 | filp->f_path.dentry->d_name.name); | ||
125 | |||
122 | res = nfs_check_flags(filp->f_flags); | 126 | res = nfs_check_flags(filp->f_flags); |
123 | if (res) | 127 | if (res) |
124 | return res; | 128 | return res; |
125 | 129 | ||
126 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); | 130 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); |
127 | lock_kernel(); | 131 | res = nfs_open(inode, filp); |
128 | res = NFS_PROTO(inode)->file_open(inode, filp); | ||
129 | unlock_kernel(); | ||
130 | return res; | 132 | return res; |
131 | } | 133 | } |
132 | 134 | ||
133 | static int | 135 | static int |
134 | nfs_file_release(struct inode *inode, struct file *filp) | 136 | nfs_file_release(struct inode *inode, struct file *filp) |
135 | { | 137 | { |
138 | struct dentry *dentry = filp->f_path.dentry; | ||
139 | |||
140 | dprintk("NFS: release(%s/%s)\n", | ||
141 | dentry->d_parent->d_name.name, | ||
142 | dentry->d_name.name); | ||
143 | |||
136 | /* Ensure that dirty pages are flushed out with the right creds */ | 144 | /* Ensure that dirty pages are flushed out with the right creds */ |
137 | if (filp->f_mode & FMODE_WRITE) | 145 | if (filp->f_mode & FMODE_WRITE) |
138 | nfs_wb_all(filp->f_path.dentry->d_inode); | 146 | nfs_wb_all(dentry->d_inode); |
139 | nfs_inc_stats(inode, NFSIOS_VFSRELEASE); | 147 | nfs_inc_stats(inode, NFSIOS_VFSRELEASE); |
140 | return NFS_PROTO(inode)->file_release(inode, filp); | 148 | return nfs_release(inode, filp); |
141 | } | 149 | } |
142 | 150 | ||
143 | /** | 151 | /** |
@@ -170,6 +178,13 @@ force_reval: | |||
170 | 178 | ||
171 | static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) | 179 | static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) |
172 | { | 180 | { |
181 | loff_t loff; | ||
182 | |||
183 | dprintk("NFS: llseek file(%s/%s, %lld, %d)\n", | ||
184 | filp->f_path.dentry->d_parent->d_name.name, | ||
185 | filp->f_path.dentry->d_name.name, | ||
186 | offset, origin); | ||
187 | |||
173 | /* origin == SEEK_END => we must revalidate the cached file length */ | 188 | /* origin == SEEK_END => we must revalidate the cached file length */ |
174 | if (origin == SEEK_END) { | 189 | if (origin == SEEK_END) { |
175 | struct inode *inode = filp->f_mapping->host; | 190 | struct inode *inode = filp->f_mapping->host; |
@@ -177,11 +192,14 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) | |||
177 | if (retval < 0) | 192 | if (retval < 0) |
178 | return (loff_t)retval; | 193 | return (loff_t)retval; |
179 | } | 194 | } |
180 | return remote_llseek(filp, offset, origin); | 195 | lock_kernel(); /* BKL needed? */ |
196 | loff = generic_file_llseek_unlocked(filp, offset, origin); | ||
197 | unlock_kernel(); | ||
198 | return loff; | ||
181 | } | 199 | } |
182 | 200 | ||
183 | /* | 201 | /* |
184 | * Helper for nfs_file_flush() and nfs_fsync() | 202 | * Helper for nfs_file_flush() and nfs_file_fsync() |
185 | * | 203 | * |
186 | * Notice that it clears the NFS_CONTEXT_ERROR_WRITE before synching to | 204 | * Notice that it clears the NFS_CONTEXT_ERROR_WRITE before synching to |
187 | * disk, but it retrieves and clears ctx->error after synching, despite | 205 | * disk, but it retrieves and clears ctx->error after synching, despite |
@@ -207,16 +225,18 @@ static int nfs_do_fsync(struct nfs_open_context *ctx, struct inode *inode) | |||
207 | 225 | ||
208 | /* | 226 | /* |
209 | * Flush all dirty pages, and check for write errors. | 227 | * Flush all dirty pages, and check for write errors. |
210 | * | ||
211 | */ | 228 | */ |
212 | static int | 229 | static int |
213 | nfs_file_flush(struct file *file, fl_owner_t id) | 230 | nfs_file_flush(struct file *file, fl_owner_t id) |
214 | { | 231 | { |
215 | struct nfs_open_context *ctx = nfs_file_open_context(file); | 232 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
216 | struct inode *inode = file->f_path.dentry->d_inode; | 233 | struct dentry *dentry = file->f_path.dentry; |
234 | struct inode *inode = dentry->d_inode; | ||
217 | int status; | 235 | int status; |
218 | 236 | ||
219 | dfprintk(VFS, "nfs: flush(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); | 237 | dprintk("NFS: flush(%s/%s)\n", |
238 | dentry->d_parent->d_name.name, | ||
239 | dentry->d_name.name); | ||
220 | 240 | ||
221 | if ((file->f_mode & FMODE_WRITE) == 0) | 241 | if ((file->f_mode & FMODE_WRITE) == 0) |
222 | return 0; | 242 | return 0; |
@@ -241,7 +261,7 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov, | |||
241 | if (iocb->ki_filp->f_flags & O_DIRECT) | 261 | if (iocb->ki_filp->f_flags & O_DIRECT) |
242 | return nfs_file_direct_read(iocb, iov, nr_segs, pos); | 262 | return nfs_file_direct_read(iocb, iov, nr_segs, pos); |
243 | 263 | ||
244 | dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n", | 264 | dprintk("NFS: read(%s/%s, %lu@%lu)\n", |
245 | dentry->d_parent->d_name.name, dentry->d_name.name, | 265 | dentry->d_parent->d_name.name, dentry->d_name.name, |
246 | (unsigned long) count, (unsigned long) pos); | 266 | (unsigned long) count, (unsigned long) pos); |
247 | 267 | ||
@@ -261,7 +281,7 @@ nfs_file_splice_read(struct file *filp, loff_t *ppos, | |||
261 | struct inode *inode = dentry->d_inode; | 281 | struct inode *inode = dentry->d_inode; |
262 | ssize_t res; | 282 | ssize_t res; |
263 | 283 | ||
264 | dfprintk(VFS, "nfs: splice_read(%s/%s, %lu@%Lu)\n", | 284 | dprintk("NFS: splice_read(%s/%s, %lu@%Lu)\n", |
265 | dentry->d_parent->d_name.name, dentry->d_name.name, | 285 | dentry->d_parent->d_name.name, dentry->d_name.name, |
266 | (unsigned long) count, (unsigned long long) *ppos); | 286 | (unsigned long) count, (unsigned long long) *ppos); |
267 | 287 | ||
@@ -278,7 +298,7 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma) | |||
278 | struct inode *inode = dentry->d_inode; | 298 | struct inode *inode = dentry->d_inode; |
279 | int status; | 299 | int status; |
280 | 300 | ||
281 | dfprintk(VFS, "nfs: mmap(%s/%s)\n", | 301 | dprintk("NFS: mmap(%s/%s)\n", |
282 | dentry->d_parent->d_name.name, dentry->d_name.name); | 302 | dentry->d_parent->d_name.name, dentry->d_name.name); |
283 | 303 | ||
284 | status = nfs_revalidate_mapping(inode, file->f_mapping); | 304 | status = nfs_revalidate_mapping(inode, file->f_mapping); |
@@ -296,12 +316,14 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma) | |||
296 | * whether any write errors occurred for this process. | 316 | * whether any write errors occurred for this process. |
297 | */ | 317 | */ |
298 | static int | 318 | static int |
299 | nfs_fsync(struct file *file, struct dentry *dentry, int datasync) | 319 | nfs_file_fsync(struct file *file, struct dentry *dentry, int datasync) |
300 | { | 320 | { |
301 | struct nfs_open_context *ctx = nfs_file_open_context(file); | 321 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
302 | struct inode *inode = dentry->d_inode; | 322 | struct inode *inode = dentry->d_inode; |
303 | 323 | ||
304 | dfprintk(VFS, "nfs: fsync(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); | 324 | dprintk("NFS: fsync file(%s/%s) datasync %d\n", |
325 | dentry->d_parent->d_name.name, dentry->d_name.name, | ||
326 | datasync); | ||
305 | 327 | ||
306 | nfs_inc_stats(inode, NFSIOS_VFSFSYNC); | 328 | nfs_inc_stats(inode, NFSIOS_VFSFSYNC); |
307 | return nfs_do_fsync(ctx, inode); | 329 | return nfs_do_fsync(ctx, inode); |
@@ -324,6 +346,11 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping, | |||
324 | struct page *page; | 346 | struct page *page; |
325 | index = pos >> PAGE_CACHE_SHIFT; | 347 | index = pos >> PAGE_CACHE_SHIFT; |
326 | 348 | ||
349 | dfprintk(PAGECACHE, "NFS: write_begin(%s/%s(%ld), %u@%lld)\n", | ||
350 | file->f_path.dentry->d_parent->d_name.name, | ||
351 | file->f_path.dentry->d_name.name, | ||
352 | mapping->host->i_ino, len, (long long) pos); | ||
353 | |||
327 | page = __grab_cache_page(mapping, index); | 354 | page = __grab_cache_page(mapping, index); |
328 | if (!page) | 355 | if (!page) |
329 | return -ENOMEM; | 356 | return -ENOMEM; |
@@ -344,9 +371,32 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, | |||
344 | unsigned offset = pos & (PAGE_CACHE_SIZE - 1); | 371 | unsigned offset = pos & (PAGE_CACHE_SIZE - 1); |
345 | int status; | 372 | int status; |
346 | 373 | ||
347 | lock_kernel(); | 374 | dfprintk(PAGECACHE, "NFS: write_end(%s/%s(%ld), %u@%lld)\n", |
375 | file->f_path.dentry->d_parent->d_name.name, | ||
376 | file->f_path.dentry->d_name.name, | ||
377 | mapping->host->i_ino, len, (long long) pos); | ||
378 | |||
379 | /* | ||
380 | * Zero any uninitialised parts of the page, and then mark the page | ||
381 | * as up to date if it turns out that we're extending the file. | ||
382 | */ | ||
383 | if (!PageUptodate(page)) { | ||
384 | unsigned pglen = nfs_page_length(page); | ||
385 | unsigned end = offset + len; | ||
386 | |||
387 | if (pglen == 0) { | ||
388 | zero_user_segments(page, 0, offset, | ||
389 | end, PAGE_CACHE_SIZE); | ||
390 | SetPageUptodate(page); | ||
391 | } else if (end >= pglen) { | ||
392 | zero_user_segment(page, end, PAGE_CACHE_SIZE); | ||
393 | if (offset == 0) | ||
394 | SetPageUptodate(page); | ||
395 | } else | ||
396 | zero_user_segment(page, pglen, PAGE_CACHE_SIZE); | ||
397 | } | ||
398 | |||
348 | status = nfs_updatepage(file, page, offset, copied); | 399 | status = nfs_updatepage(file, page, offset, copied); |
349 | unlock_kernel(); | ||
350 | 400 | ||
351 | unlock_page(page); | 401 | unlock_page(page); |
352 | page_cache_release(page); | 402 | page_cache_release(page); |
@@ -358,6 +408,8 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, | |||
358 | 408 | ||
359 | static void nfs_invalidate_page(struct page *page, unsigned long offset) | 409 | static void nfs_invalidate_page(struct page *page, unsigned long offset) |
360 | { | 410 | { |
411 | dfprintk(PAGECACHE, "NFS: invalidate_page(%p, %lu)\n", page, offset); | ||
412 | |||
361 | if (offset != 0) | 413 | if (offset != 0) |
362 | return; | 414 | return; |
363 | /* Cancel any unstarted writes on this page */ | 415 | /* Cancel any unstarted writes on this page */ |
@@ -366,13 +418,20 @@ static void nfs_invalidate_page(struct page *page, unsigned long offset) | |||
366 | 418 | ||
367 | static int nfs_release_page(struct page *page, gfp_t gfp) | 419 | static int nfs_release_page(struct page *page, gfp_t gfp) |
368 | { | 420 | { |
421 | dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page); | ||
422 | |||
369 | /* If PagePrivate() is set, then the page is not freeable */ | 423 | /* If PagePrivate() is set, then the page is not freeable */ |
370 | return 0; | 424 | return 0; |
371 | } | 425 | } |
372 | 426 | ||
373 | static int nfs_launder_page(struct page *page) | 427 | static int nfs_launder_page(struct page *page) |
374 | { | 428 | { |
375 | return nfs_wb_page(page->mapping->host, page); | 429 | struct inode *inode = page->mapping->host; |
430 | |||
431 | dfprintk(PAGECACHE, "NFS: launder_page(%ld, %llu)\n", | ||
432 | inode->i_ino, (long long)page_offset(page)); | ||
433 | |||
434 | return nfs_wb_page(inode, page); | ||
376 | } | 435 | } |
377 | 436 | ||
378 | const struct address_space_operations nfs_file_aops = { | 437 | const struct address_space_operations nfs_file_aops = { |
@@ -392,13 +451,19 @@ const struct address_space_operations nfs_file_aops = { | |||
392 | static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct page *page) | 451 | static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct page *page) |
393 | { | 452 | { |
394 | struct file *filp = vma->vm_file; | 453 | struct file *filp = vma->vm_file; |
454 | struct dentry *dentry = filp->f_path.dentry; | ||
395 | unsigned pagelen; | 455 | unsigned pagelen; |
396 | int ret = -EINVAL; | 456 | int ret = -EINVAL; |
397 | struct address_space *mapping; | 457 | struct address_space *mapping; |
398 | 458 | ||
459 | dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%s/%s(%ld), offset %lld)\n", | ||
460 | dentry->d_parent->d_name.name, dentry->d_name.name, | ||
461 | filp->f_mapping->host->i_ino, | ||
462 | (long long)page_offset(page)); | ||
463 | |||
399 | lock_page(page); | 464 | lock_page(page); |
400 | mapping = page->mapping; | 465 | mapping = page->mapping; |
401 | if (mapping != vma->vm_file->f_path.dentry->d_inode->i_mapping) | 466 | if (mapping != dentry->d_inode->i_mapping) |
402 | goto out_unlock; | 467 | goto out_unlock; |
403 | 468 | ||
404 | ret = 0; | 469 | ret = 0; |
@@ -446,9 +511,9 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
446 | if (iocb->ki_filp->f_flags & O_DIRECT) | 511 | if (iocb->ki_filp->f_flags & O_DIRECT) |
447 | return nfs_file_direct_write(iocb, iov, nr_segs, pos); | 512 | return nfs_file_direct_write(iocb, iov, nr_segs, pos); |
448 | 513 | ||
449 | dfprintk(VFS, "nfs: write(%s/%s(%ld), %lu@%Ld)\n", | 514 | dprintk("NFS: write(%s/%s, %lu@%Ld)\n", |
450 | dentry->d_parent->d_name.name, dentry->d_name.name, | 515 | dentry->d_parent->d_name.name, dentry->d_name.name, |
451 | inode->i_ino, (unsigned long) count, (long long) pos); | 516 | (unsigned long) count, (long long) pos); |
452 | 517 | ||
453 | result = -EBUSY; | 518 | result = -EBUSY; |
454 | if (IS_SWAPFILE(inode)) | 519 | if (IS_SWAPFILE(inode)) |
@@ -582,7 +647,8 @@ static int do_setlk(struct file *filp, int cmd, struct file_lock *fl) | |||
582 | * This makes locking act as a cache coherency point. | 647 | * This makes locking act as a cache coherency point. |
583 | */ | 648 | */ |
584 | nfs_sync_mapping(filp->f_mapping); | 649 | nfs_sync_mapping(filp->f_mapping); |
585 | nfs_zap_caches(inode); | 650 | if (!nfs_have_delegation(inode, FMODE_READ)) |
651 | nfs_zap_caches(inode); | ||
586 | out: | 652 | out: |
587 | return status; | 653 | return status; |
588 | } | 654 | } |
@@ -592,23 +658,35 @@ out: | |||
592 | */ | 658 | */ |
593 | static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) | 659 | static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) |
594 | { | 660 | { |
595 | struct inode * inode = filp->f_mapping->host; | 661 | struct inode *inode = filp->f_mapping->host; |
662 | int ret = -ENOLCK; | ||
596 | 663 | ||
597 | dprintk("NFS: nfs_lock(f=%s/%ld, t=%x, fl=%x, r=%Ld:%Ld)\n", | 664 | dprintk("NFS: lock(%s/%s, t=%x, fl=%x, r=%lld:%lld)\n", |
598 | inode->i_sb->s_id, inode->i_ino, | 665 | filp->f_path.dentry->d_parent->d_name.name, |
666 | filp->f_path.dentry->d_name.name, | ||
599 | fl->fl_type, fl->fl_flags, | 667 | fl->fl_type, fl->fl_flags, |
600 | (long long)fl->fl_start, (long long)fl->fl_end); | 668 | (long long)fl->fl_start, (long long)fl->fl_end); |
669 | |||
601 | nfs_inc_stats(inode, NFSIOS_VFSLOCK); | 670 | nfs_inc_stats(inode, NFSIOS_VFSLOCK); |
602 | 671 | ||
603 | /* No mandatory locks over NFS */ | 672 | /* No mandatory locks over NFS */ |
604 | if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK) | 673 | if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK) |
605 | return -ENOLCK; | 674 | goto out_err; |
675 | |||
676 | if (NFS_PROTO(inode)->lock_check_bounds != NULL) { | ||
677 | ret = NFS_PROTO(inode)->lock_check_bounds(fl); | ||
678 | if (ret < 0) | ||
679 | goto out_err; | ||
680 | } | ||
606 | 681 | ||
607 | if (IS_GETLK(cmd)) | 682 | if (IS_GETLK(cmd)) |
608 | return do_getlk(filp, cmd, fl); | 683 | ret = do_getlk(filp, cmd, fl); |
609 | if (fl->fl_type == F_UNLCK) | 684 | else if (fl->fl_type == F_UNLCK) |
610 | return do_unlk(filp, cmd, fl); | 685 | ret = do_unlk(filp, cmd, fl); |
611 | return do_setlk(filp, cmd, fl); | 686 | else |
687 | ret = do_setlk(filp, cmd, fl); | ||
688 | out_err: | ||
689 | return ret; | ||
612 | } | 690 | } |
613 | 691 | ||
614 | /* | 692 | /* |
@@ -616,9 +694,9 @@ static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) | |||
616 | */ | 694 | */ |
617 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) | 695 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) |
618 | { | 696 | { |
619 | dprintk("NFS: nfs_flock(f=%s/%ld, t=%x, fl=%x)\n", | 697 | dprintk("NFS: flock(%s/%s, t=%x, fl=%x)\n", |
620 | filp->f_path.dentry->d_inode->i_sb->s_id, | 698 | filp->f_path.dentry->d_parent->d_name.name, |
621 | filp->f_path.dentry->d_inode->i_ino, | 699 | filp->f_path.dentry->d_name.name, |
622 | fl->fl_type, fl->fl_flags); | 700 | fl->fl_type, fl->fl_flags); |
623 | 701 | ||
624 | /* | 702 | /* |
@@ -641,12 +719,15 @@ static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) | |||
641 | return do_setlk(filp, cmd, fl); | 719 | return do_setlk(filp, cmd, fl); |
642 | } | 720 | } |
643 | 721 | ||
722 | /* | ||
723 | * There is no protocol support for leases, so we have no way to implement | ||
724 | * them correctly in the face of opens by other clients. | ||
725 | */ | ||
644 | static int nfs_setlease(struct file *file, long arg, struct file_lock **fl) | 726 | static int nfs_setlease(struct file *file, long arg, struct file_lock **fl) |
645 | { | 727 | { |
646 | /* | 728 | dprintk("NFS: setlease(%s/%s, arg=%ld)\n", |
647 | * There is no protocol support for leases, so we have no way | 729 | file->f_path.dentry->d_parent->d_name.name, |
648 | * to implement them correctly in the face of opens by other | 730 | file->f_path.dentry->d_name.name, arg); |
649 | * clients. | 731 | |
650 | */ | ||
651 | return -EINVAL; | 732 | return -EINVAL; |
652 | } | 733 | } |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 596c5d8e86f4..df23f987da6b 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -57,8 +57,6 @@ static int enable_ino64 = NFS_64_BIT_INODE_NUMBERS_ENABLED; | |||
57 | static void nfs_invalidate_inode(struct inode *); | 57 | static void nfs_invalidate_inode(struct inode *); |
58 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); | 58 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); |
59 | 59 | ||
60 | static void nfs_zap_acl_cache(struct inode *); | ||
61 | |||
62 | static struct kmem_cache * nfs_inode_cachep; | 60 | static struct kmem_cache * nfs_inode_cachep; |
63 | 61 | ||
64 | static inline unsigned long | 62 | static inline unsigned long |
@@ -167,7 +165,7 @@ void nfs_zap_mapping(struct inode *inode, struct address_space *mapping) | |||
167 | } | 165 | } |
168 | } | 166 | } |
169 | 167 | ||
170 | static void nfs_zap_acl_cache(struct inode *inode) | 168 | void nfs_zap_acl_cache(struct inode *inode) |
171 | { | 169 | { |
172 | void (*clear_acl_cache)(struct inode *); | 170 | void (*clear_acl_cache)(struct inode *); |
173 | 171 | ||
@@ -347,7 +345,7 @@ out_no_inode: | |||
347 | goto out; | 345 | goto out; |
348 | } | 346 | } |
349 | 347 | ||
350 | #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET) | 348 | #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE) |
351 | 349 | ||
352 | int | 350 | int |
353 | nfs_setattr(struct dentry *dentry, struct iattr *attr) | 351 | nfs_setattr(struct dentry *dentry, struct iattr *attr) |
@@ -369,10 +367,9 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
369 | 367 | ||
370 | /* Optimization: if the end result is no change, don't RPC */ | 368 | /* Optimization: if the end result is no change, don't RPC */ |
371 | attr->ia_valid &= NFS_VALID_ATTRS; | 369 | attr->ia_valid &= NFS_VALID_ATTRS; |
372 | if (attr->ia_valid == 0) | 370 | if ((attr->ia_valid & ~ATTR_FILE) == 0) |
373 | return 0; | 371 | return 0; |
374 | 372 | ||
375 | lock_kernel(); | ||
376 | /* Write all dirty data */ | 373 | /* Write all dirty data */ |
377 | if (S_ISREG(inode->i_mode)) { | 374 | if (S_ISREG(inode->i_mode)) { |
378 | filemap_write_and_wait(inode->i_mapping); | 375 | filemap_write_and_wait(inode->i_mapping); |
@@ -386,11 +383,66 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
386 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); | 383 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); |
387 | if (error == 0) | 384 | if (error == 0) |
388 | nfs_refresh_inode(inode, &fattr); | 385 | nfs_refresh_inode(inode, &fattr); |
389 | unlock_kernel(); | ||
390 | return error; | 386 | return error; |
391 | } | 387 | } |
392 | 388 | ||
393 | /** | 389 | /** |
390 | * nfs_vmtruncate - unmap mappings "freed" by truncate() syscall | ||
391 | * @inode: inode of the file used | ||
392 | * @offset: file offset to start truncating | ||
393 | * | ||
394 | * This is a copy of the common vmtruncate, but with the locking | ||
395 | * corrected to take into account the fact that NFS requires | ||
396 | * inode->i_size to be updated under the inode->i_lock. | ||
397 | */ | ||
398 | static int nfs_vmtruncate(struct inode * inode, loff_t offset) | ||
399 | { | ||
400 | if (i_size_read(inode) < offset) { | ||
401 | unsigned long limit; | ||
402 | |||
403 | limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; | ||
404 | if (limit != RLIM_INFINITY && offset > limit) | ||
405 | goto out_sig; | ||
406 | if (offset > inode->i_sb->s_maxbytes) | ||
407 | goto out_big; | ||
408 | spin_lock(&inode->i_lock); | ||
409 | i_size_write(inode, offset); | ||
410 | spin_unlock(&inode->i_lock); | ||
411 | } else { | ||
412 | struct address_space *mapping = inode->i_mapping; | ||
413 | |||
414 | /* | ||
415 | * truncation of in-use swapfiles is disallowed - it would | ||
416 | * cause subsequent swapout to scribble on the now-freed | ||
417 | * blocks. | ||
418 | */ | ||
419 | if (IS_SWAPFILE(inode)) | ||
420 | return -ETXTBSY; | ||
421 | spin_lock(&inode->i_lock); | ||
422 | i_size_write(inode, offset); | ||
423 | spin_unlock(&inode->i_lock); | ||
424 | |||
425 | /* | ||
426 | * unmap_mapping_range is called twice, first simply for | ||
427 | * efficiency so that truncate_inode_pages does fewer | ||
428 | * single-page unmaps. However after this first call, and | ||
429 | * before truncate_inode_pages finishes, it is possible for | ||
430 | * private pages to be COWed, which remain after | ||
431 | * truncate_inode_pages finishes, hence the second | ||
432 | * unmap_mapping_range call must be made for correctness. | ||
433 | */ | ||
434 | unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); | ||
435 | truncate_inode_pages(mapping, offset); | ||
436 | unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); | ||
437 | } | ||
438 | return 0; | ||
439 | out_sig: | ||
440 | send_sig(SIGXFSZ, current, 0); | ||
441 | out_big: | ||
442 | return -EFBIG; | ||
443 | } | ||
444 | |||
445 | /** | ||
394 | * nfs_setattr_update_inode - Update inode metadata after a setattr call. | 446 | * nfs_setattr_update_inode - Update inode metadata after a setattr call. |
395 | * @inode: pointer to struct inode | 447 | * @inode: pointer to struct inode |
396 | * @attr: pointer to struct iattr | 448 | * @attr: pointer to struct iattr |
@@ -416,8 +468,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr) | |||
416 | } | 468 | } |
417 | if ((attr->ia_valid & ATTR_SIZE) != 0) { | 469 | if ((attr->ia_valid & ATTR_SIZE) != 0) { |
418 | nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); | 470 | nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); |
419 | inode->i_size = attr->ia_size; | 471 | nfs_vmtruncate(inode, attr->ia_size); |
420 | vmtruncate(inode, attr->ia_size); | ||
421 | } | 472 | } |
422 | } | 473 | } |
423 | 474 | ||
@@ -647,7 +698,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
647 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); | 698 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); |
648 | 699 | ||
649 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); | 700 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); |
650 | lock_kernel(); | ||
651 | if (is_bad_inode(inode)) | 701 | if (is_bad_inode(inode)) |
652 | goto out_nowait; | 702 | goto out_nowait; |
653 | if (NFS_STALE(inode)) | 703 | if (NFS_STALE(inode)) |
@@ -696,7 +746,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
696 | nfs_wake_up_inode(inode); | 746 | nfs_wake_up_inode(inode); |
697 | 747 | ||
698 | out_nowait: | 748 | out_nowait: |
699 | unlock_kernel(); | ||
700 | return status; | 749 | return status; |
701 | } | 750 | } |
702 | 751 | ||
@@ -831,9 +880,9 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
831 | if (S_ISDIR(inode->i_mode)) | 880 | if (S_ISDIR(inode->i_mode)) |
832 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | 881 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
833 | } | 882 | } |
834 | if (inode->i_size == nfs_size_to_loff_t(fattr->pre_size) && | 883 | if (i_size_read(inode) == nfs_size_to_loff_t(fattr->pre_size) && |
835 | nfsi->npages == 0) | 884 | nfsi->npages == 0) |
836 | inode->i_size = nfs_size_to_loff_t(fattr->size); | 885 | i_size_write(inode, nfs_size_to_loff_t(fattr->size)); |
837 | } | 886 | } |
838 | } | 887 | } |
839 | 888 | ||
@@ -974,7 +1023,7 @@ int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fa | |||
974 | (fattr->valid & NFS_ATTR_WCC) == 0) { | 1023 | (fattr->valid & NFS_ATTR_WCC) == 0) { |
975 | memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime)); | 1024 | memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime)); |
976 | memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime)); | 1025 | memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime)); |
977 | fattr->pre_size = inode->i_size; | 1026 | fattr->pre_size = i_size_read(inode); |
978 | fattr->valid |= NFS_ATTR_WCC; | 1027 | fattr->valid |= NFS_ATTR_WCC; |
979 | } | 1028 | } |
980 | return nfs_post_op_update_inode(inode, fattr); | 1029 | return nfs_post_op_update_inode(inode, fattr); |
@@ -1059,7 +1108,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1059 | /* Do we perhaps have any outstanding writes, or has | 1108 | /* Do we perhaps have any outstanding writes, or has |
1060 | * the file grown beyond our last write? */ | 1109 | * the file grown beyond our last write? */ |
1061 | if (nfsi->npages == 0 || new_isize > cur_isize) { | 1110 | if (nfsi->npages == 0 || new_isize > cur_isize) { |
1062 | inode->i_size = new_isize; | 1111 | i_size_write(inode, new_isize); |
1063 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; | 1112 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; |
1064 | } | 1113 | } |
1065 | dprintk("NFS: isize change on server for file %s/%ld\n", | 1114 | dprintk("NFS: isize change on server for file %s/%ld\n", |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 04ae867dddba..24241fcbb98d 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -150,6 +150,7 @@ extern void nfs_clear_inode(struct inode *); | |||
150 | #ifdef CONFIG_NFS_V4 | 150 | #ifdef CONFIG_NFS_V4 |
151 | extern void nfs4_clear_inode(struct inode *); | 151 | extern void nfs4_clear_inode(struct inode *); |
152 | #endif | 152 | #endif |
153 | void nfs_zap_acl_cache(struct inode *inode); | ||
153 | 154 | ||
154 | /* super.c */ | 155 | /* super.c */ |
155 | extern struct file_system_type nfs_xdev_fs_type; | 156 | extern struct file_system_type nfs_xdev_fs_type; |
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h index 6350ecbde589..a36952810032 100644 --- a/fs/nfs/iostat.h +++ b/fs/nfs/iostat.h | |||
@@ -5,135 +5,41 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com> | 6 | * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com> |
7 | * | 7 | * |
8 | * NFS client per-mount statistics provide information about the health of | ||
9 | * the NFS client and the health of each NFS mount point. Generally these | ||
10 | * are not for detailed problem diagnosis, but simply to indicate that there | ||
11 | * is a problem. | ||
12 | * | ||
13 | * These counters are not meant to be human-readable, but are meant to be | ||
14 | * integrated into system monitoring tools such as "sar" and "iostat". As | ||
15 | * such, the counters are sampled by the tools over time, and are never | ||
16 | * zeroed after a file system is mounted. Moving averages can be computed | ||
17 | * by the tools by taking the difference between two instantaneous samples | ||
18 | * and dividing that by the time between the samples. | ||
19 | */ | 8 | */ |
20 | 9 | ||
21 | #ifndef _NFS_IOSTAT | 10 | #ifndef _NFS_IOSTAT |
22 | #define _NFS_IOSTAT | 11 | #define _NFS_IOSTAT |
23 | 12 | ||
24 | #define NFS_IOSTAT_VERS "1.0" | ||
25 | |||
26 | /* | ||
27 | * NFS byte counters | ||
28 | * | ||
29 | * 1. SERVER - the number of payload bytes read from or written to the | ||
30 | * server by the NFS client via an NFS READ or WRITE request. | ||
31 | * | ||
32 | * 2. NORMAL - the number of bytes read or written by applications via | ||
33 | * the read(2) and write(2) system call interfaces. | ||
34 | * | ||
35 | * 3. DIRECT - the number of bytes read or written from files opened | ||
36 | * with the O_DIRECT flag. | ||
37 | * | ||
38 | * These counters give a view of the data throughput into and out of the NFS | ||
39 | * client. Comparing the number of bytes requested by an application with the | ||
40 | * number of bytes the client requests from the server can provide an | ||
41 | * indication of client efficiency (per-op, cache hits, etc). | ||
42 | * | ||
43 | * These counters can also help characterize which access methods are in | ||
44 | * use. DIRECT by itself shows whether there is any O_DIRECT traffic. | ||
45 | * NORMAL + DIRECT shows how much data is going through the system call | ||
46 | * interface. A large amount of SERVER traffic without much NORMAL or | ||
47 | * DIRECT traffic shows that applications are using mapped files. | ||
48 | * | ||
49 | * NFS page counters | ||
50 | * | ||
51 | * These count the number of pages read or written via nfs_readpage(), | ||
52 | * nfs_readpages(), or their write equivalents. | ||
53 | */ | ||
54 | enum nfs_stat_bytecounters { | ||
55 | NFSIOS_NORMALREADBYTES = 0, | ||
56 | NFSIOS_NORMALWRITTENBYTES, | ||
57 | NFSIOS_DIRECTREADBYTES, | ||
58 | NFSIOS_DIRECTWRITTENBYTES, | ||
59 | NFSIOS_SERVERREADBYTES, | ||
60 | NFSIOS_SERVERWRITTENBYTES, | ||
61 | NFSIOS_READPAGES, | ||
62 | NFSIOS_WRITEPAGES, | ||
63 | __NFSIOS_BYTESMAX, | ||
64 | }; | ||
65 | |||
66 | /* | ||
67 | * NFS event counters | ||
68 | * | ||
69 | * These counters provide a low-overhead way of monitoring client activity | ||
70 | * without enabling NFS trace debugging. The counters show the rate at | ||
71 | * which VFS requests are made, and how often the client invalidates its | ||
72 | * data and attribute caches. This allows system administrators to monitor | ||
73 | * such things as how close-to-open is working, and answer questions such | ||
74 | * as "why are there so many GETATTR requests on the wire?" | ||
75 | * | ||
76 | * They also count anamolous events such as short reads and writes, silly | ||
77 | * renames due to close-after-delete, and operations that change the size | ||
78 | * of a file (such operations can often be the source of data corruption | ||
79 | * if applications aren't using file locking properly). | ||
80 | */ | ||
81 | enum nfs_stat_eventcounters { | ||
82 | NFSIOS_INODEREVALIDATE = 0, | ||
83 | NFSIOS_DENTRYREVALIDATE, | ||
84 | NFSIOS_DATAINVALIDATE, | ||
85 | NFSIOS_ATTRINVALIDATE, | ||
86 | NFSIOS_VFSOPEN, | ||
87 | NFSIOS_VFSLOOKUP, | ||
88 | NFSIOS_VFSACCESS, | ||
89 | NFSIOS_VFSUPDATEPAGE, | ||
90 | NFSIOS_VFSREADPAGE, | ||
91 | NFSIOS_VFSREADPAGES, | ||
92 | NFSIOS_VFSWRITEPAGE, | ||
93 | NFSIOS_VFSWRITEPAGES, | ||
94 | NFSIOS_VFSGETDENTS, | ||
95 | NFSIOS_VFSSETATTR, | ||
96 | NFSIOS_VFSFLUSH, | ||
97 | NFSIOS_VFSFSYNC, | ||
98 | NFSIOS_VFSLOCK, | ||
99 | NFSIOS_VFSRELEASE, | ||
100 | NFSIOS_CONGESTIONWAIT, | ||
101 | NFSIOS_SETATTRTRUNC, | ||
102 | NFSIOS_EXTENDWRITE, | ||
103 | NFSIOS_SILLYRENAME, | ||
104 | NFSIOS_SHORTREAD, | ||
105 | NFSIOS_SHORTWRITE, | ||
106 | NFSIOS_DELAY, | ||
107 | __NFSIOS_COUNTSMAX, | ||
108 | }; | ||
109 | |||
110 | #ifdef __KERNEL__ | ||
111 | |||
112 | #include <linux/percpu.h> | 13 | #include <linux/percpu.h> |
113 | #include <linux/cache.h> | 14 | #include <linux/cache.h> |
15 | #include <linux/nfs_iostat.h> | ||
114 | 16 | ||
115 | struct nfs_iostats { | 17 | struct nfs_iostats { |
116 | unsigned long long bytes[__NFSIOS_BYTESMAX]; | 18 | unsigned long long bytes[__NFSIOS_BYTESMAX]; |
117 | unsigned long events[__NFSIOS_COUNTSMAX]; | 19 | unsigned long events[__NFSIOS_COUNTSMAX]; |
118 | } ____cacheline_aligned; | 20 | } ____cacheline_aligned; |
119 | 21 | ||
120 | static inline void nfs_inc_server_stats(struct nfs_server *server, enum nfs_stat_eventcounters stat) | 22 | static inline void nfs_inc_server_stats(const struct nfs_server *server, |
23 | enum nfs_stat_eventcounters stat) | ||
121 | { | 24 | { |
122 | struct nfs_iostats *iostats; | 25 | struct nfs_iostats *iostats; |
123 | int cpu; | 26 | int cpu; |
124 | 27 | ||
125 | cpu = get_cpu(); | 28 | cpu = get_cpu(); |
126 | iostats = per_cpu_ptr(server->io_stats, cpu); | 29 | iostats = per_cpu_ptr(server->io_stats, cpu); |
127 | iostats->events[stat] ++; | 30 | iostats->events[stat]++; |
128 | put_cpu_no_resched(); | 31 | put_cpu_no_resched(); |
129 | } | 32 | } |
130 | 33 | ||
131 | static inline void nfs_inc_stats(struct inode *inode, enum nfs_stat_eventcounters stat) | 34 | static inline void nfs_inc_stats(const struct inode *inode, |
35 | enum nfs_stat_eventcounters stat) | ||
132 | { | 36 | { |
133 | nfs_inc_server_stats(NFS_SERVER(inode), stat); | 37 | nfs_inc_server_stats(NFS_SERVER(inode), stat); |
134 | } | 38 | } |
135 | 39 | ||
136 | static inline void nfs_add_server_stats(struct nfs_server *server, enum nfs_stat_bytecounters stat, unsigned long addend) | 40 | static inline void nfs_add_server_stats(const struct nfs_server *server, |
41 | enum nfs_stat_bytecounters stat, | ||
42 | unsigned long addend) | ||
137 | { | 43 | { |
138 | struct nfs_iostats *iostats; | 44 | struct nfs_iostats *iostats; |
139 | int cpu; | 45 | int cpu; |
@@ -144,7 +50,9 @@ static inline void nfs_add_server_stats(struct nfs_server *server, enum nfs_stat | |||
144 | put_cpu_no_resched(); | 50 | put_cpu_no_resched(); |
145 | } | 51 | } |
146 | 52 | ||
147 | static inline void nfs_add_stats(struct inode *inode, enum nfs_stat_bytecounters stat, unsigned long addend) | 53 | static inline void nfs_add_stats(const struct inode *inode, |
54 | enum nfs_stat_bytecounters stat, | ||
55 | unsigned long addend) | ||
148 | { | 56 | { |
149 | nfs_add_server_stats(NFS_SERVER(inode), stat, addend); | 57 | nfs_add_server_stats(NFS_SERVER(inode), stat, addend); |
150 | } | 58 | } |
@@ -160,5 +68,4 @@ static inline void nfs_free_iostats(struct nfs_iostats *stats) | |||
160 | free_percpu(stats); | 68 | free_percpu(stats); |
161 | } | 69 | } |
162 | 70 | ||
163 | #endif | 71 | #endif /* _NFS_IOSTAT */ |
164 | #endif | ||
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c index 9b7362565c0c..423842f51ac9 100644 --- a/fs/nfs/nfs3acl.c +++ b/fs/nfs/nfs3acl.c | |||
@@ -5,6 +5,8 @@ | |||
5 | #include <linux/posix_acl_xattr.h> | 5 | #include <linux/posix_acl_xattr.h> |
6 | #include <linux/nfsacl.h> | 6 | #include <linux/nfsacl.h> |
7 | 7 | ||
8 | #include "internal.h" | ||
9 | |||
8 | #define NFSDBG_FACILITY NFSDBG_PROC | 10 | #define NFSDBG_FACILITY NFSDBG_PROC |
9 | 11 | ||
10 | ssize_t nfs3_listxattr(struct dentry *dentry, char *buffer, size_t size) | 12 | ssize_t nfs3_listxattr(struct dentry *dentry, char *buffer, size_t size) |
@@ -205,6 +207,8 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) | |||
205 | status = nfs_revalidate_inode(server, inode); | 207 | status = nfs_revalidate_inode(server, inode); |
206 | if (status < 0) | 208 | if (status < 0) |
207 | return ERR_PTR(status); | 209 | return ERR_PTR(status); |
210 | if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL) | ||
211 | nfs_zap_acl_cache(inode); | ||
208 | acl = nfs3_get_cached_acl(inode, type); | 212 | acl = nfs3_get_cached_acl(inode, type); |
209 | if (acl != ERR_PTR(-EAGAIN)) | 213 | if (acl != ERR_PTR(-EAGAIN)) |
210 | return acl; | 214 | return acl; |
@@ -319,9 +323,8 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, | |||
319 | dprintk("NFS call setacl\n"); | 323 | dprintk("NFS call setacl\n"); |
320 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL]; | 324 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL]; |
321 | status = rpc_call_sync(server->client_acl, &msg, 0); | 325 | status = rpc_call_sync(server->client_acl, &msg, 0); |
322 | spin_lock(&inode->i_lock); | 326 | nfs_access_zap_cache(inode); |
323 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS; | 327 | nfs_zap_acl_cache(inode); |
324 | spin_unlock(&inode->i_lock); | ||
325 | dprintk("NFS reply setacl: %d\n", status); | 328 | dprintk("NFS reply setacl: %d\n", status); |
326 | 329 | ||
327 | /* pages may have been allocated at the xdr layer. */ | 330 | /* pages may have been allocated at the xdr layer. */ |
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index c3523ad03ed1..1e750e4574a9 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -129,6 +129,8 @@ nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
129 | int status; | 129 | int status; |
130 | 130 | ||
131 | dprintk("NFS call setattr\n"); | 131 | dprintk("NFS call setattr\n"); |
132 | if (sattr->ia_valid & ATTR_FILE) | ||
133 | msg.rpc_cred = nfs_file_cred(sattr->ia_file); | ||
132 | nfs_fattr_init(fattr); | 134 | nfs_fattr_init(fattr); |
133 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 135 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
134 | if (status == 0) | 136 | if (status == 0) |
@@ -248,6 +250,53 @@ static int nfs3_proc_readlink(struct inode *inode, struct page *page, | |||
248 | return status; | 250 | return status; |
249 | } | 251 | } |
250 | 252 | ||
253 | struct nfs3_createdata { | ||
254 | struct rpc_message msg; | ||
255 | union { | ||
256 | struct nfs3_createargs create; | ||
257 | struct nfs3_mkdirargs mkdir; | ||
258 | struct nfs3_symlinkargs symlink; | ||
259 | struct nfs3_mknodargs mknod; | ||
260 | } arg; | ||
261 | struct nfs3_diropres res; | ||
262 | struct nfs_fh fh; | ||
263 | struct nfs_fattr fattr; | ||
264 | struct nfs_fattr dir_attr; | ||
265 | }; | ||
266 | |||
267 | static struct nfs3_createdata *nfs3_alloc_createdata(void) | ||
268 | { | ||
269 | struct nfs3_createdata *data; | ||
270 | |||
271 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
272 | if (data != NULL) { | ||
273 | data->msg.rpc_argp = &data->arg; | ||
274 | data->msg.rpc_resp = &data->res; | ||
275 | data->res.fh = &data->fh; | ||
276 | data->res.fattr = &data->fattr; | ||
277 | data->res.dir_attr = &data->dir_attr; | ||
278 | nfs_fattr_init(data->res.fattr); | ||
279 | nfs_fattr_init(data->res.dir_attr); | ||
280 | } | ||
281 | return data; | ||
282 | } | ||
283 | |||
284 | static int nfs3_do_create(struct inode *dir, struct dentry *dentry, struct nfs3_createdata *data) | ||
285 | { | ||
286 | int status; | ||
287 | |||
288 | status = rpc_call_sync(NFS_CLIENT(dir), &data->msg, 0); | ||
289 | nfs_post_op_update_inode(dir, data->res.dir_attr); | ||
290 | if (status == 0) | ||
291 | status = nfs_instantiate(dentry, data->res.fh, data->res.fattr); | ||
292 | return status; | ||
293 | } | ||
294 | |||
295 | static void nfs3_free_createdata(struct nfs3_createdata *data) | ||
296 | { | ||
297 | kfree(data); | ||
298 | } | ||
299 | |||
251 | /* | 300 | /* |
252 | * Create a regular file. | 301 | * Create a regular file. |
253 | * For now, we don't implement O_EXCL. | 302 | * For now, we don't implement O_EXCL. |
@@ -256,70 +305,60 @@ static int | |||
256 | nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | 305 | nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, |
257 | int flags, struct nameidata *nd) | 306 | int flags, struct nameidata *nd) |
258 | { | 307 | { |
259 | struct nfs_fh fhandle; | 308 | struct nfs3_createdata *data; |
260 | struct nfs_fattr fattr; | ||
261 | struct nfs_fattr dir_attr; | ||
262 | struct nfs3_createargs arg = { | ||
263 | .fh = NFS_FH(dir), | ||
264 | .name = dentry->d_name.name, | ||
265 | .len = dentry->d_name.len, | ||
266 | .sattr = sattr, | ||
267 | }; | ||
268 | struct nfs3_diropres res = { | ||
269 | .dir_attr = &dir_attr, | ||
270 | .fh = &fhandle, | ||
271 | .fattr = &fattr | ||
272 | }; | ||
273 | struct rpc_message msg = { | ||
274 | .rpc_proc = &nfs3_procedures[NFS3PROC_CREATE], | ||
275 | .rpc_argp = &arg, | ||
276 | .rpc_resp = &res, | ||
277 | }; | ||
278 | mode_t mode = sattr->ia_mode; | 309 | mode_t mode = sattr->ia_mode; |
279 | int status; | 310 | int status = -ENOMEM; |
280 | 311 | ||
281 | dprintk("NFS call create %s\n", dentry->d_name.name); | 312 | dprintk("NFS call create %s\n", dentry->d_name.name); |
282 | arg.createmode = NFS3_CREATE_UNCHECKED; | 313 | |
314 | data = nfs3_alloc_createdata(); | ||
315 | if (data == NULL) | ||
316 | goto out; | ||
317 | |||
318 | data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_CREATE]; | ||
319 | data->arg.create.fh = NFS_FH(dir); | ||
320 | data->arg.create.name = dentry->d_name.name; | ||
321 | data->arg.create.len = dentry->d_name.len; | ||
322 | data->arg.create.sattr = sattr; | ||
323 | |||
324 | data->arg.create.createmode = NFS3_CREATE_UNCHECKED; | ||
283 | if (flags & O_EXCL) { | 325 | if (flags & O_EXCL) { |
284 | arg.createmode = NFS3_CREATE_EXCLUSIVE; | 326 | data->arg.create.createmode = NFS3_CREATE_EXCLUSIVE; |
285 | arg.verifier[0] = jiffies; | 327 | data->arg.create.verifier[0] = jiffies; |
286 | arg.verifier[1] = current->pid; | 328 | data->arg.create.verifier[1] = current->pid; |
287 | } | 329 | } |
288 | 330 | ||
289 | sattr->ia_mode &= ~current->fs->umask; | 331 | sattr->ia_mode &= ~current->fs->umask; |
290 | 332 | ||
291 | again: | 333 | for (;;) { |
292 | nfs_fattr_init(&dir_attr); | 334 | status = nfs3_do_create(dir, dentry, data); |
293 | nfs_fattr_init(&fattr); | ||
294 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | ||
295 | nfs_refresh_inode(dir, &dir_attr); | ||
296 | 335 | ||
297 | /* If the server doesn't support the exclusive creation semantics, | 336 | if (status != -ENOTSUPP) |
298 | * try again with simple 'guarded' mode. */ | 337 | break; |
299 | if (status == -ENOTSUPP) { | 338 | /* If the server doesn't support the exclusive creation |
300 | switch (arg.createmode) { | 339 | * semantics, try again with simple 'guarded' mode. */ |
340 | switch (data->arg.create.createmode) { | ||
301 | case NFS3_CREATE_EXCLUSIVE: | 341 | case NFS3_CREATE_EXCLUSIVE: |
302 | arg.createmode = NFS3_CREATE_GUARDED; | 342 | data->arg.create.createmode = NFS3_CREATE_GUARDED; |
303 | break; | 343 | break; |
304 | 344 | ||
305 | case NFS3_CREATE_GUARDED: | 345 | case NFS3_CREATE_GUARDED: |
306 | arg.createmode = NFS3_CREATE_UNCHECKED; | 346 | data->arg.create.createmode = NFS3_CREATE_UNCHECKED; |
307 | break; | 347 | break; |
308 | 348 | ||
309 | case NFS3_CREATE_UNCHECKED: | 349 | case NFS3_CREATE_UNCHECKED: |
310 | goto out; | 350 | goto out; |
311 | } | 351 | } |
312 | goto again; | 352 | nfs_fattr_init(data->res.dir_attr); |
353 | nfs_fattr_init(data->res.fattr); | ||
313 | } | 354 | } |
314 | 355 | ||
315 | if (status == 0) | ||
316 | status = nfs_instantiate(dentry, &fhandle, &fattr); | ||
317 | if (status != 0) | 356 | if (status != 0) |
318 | goto out; | 357 | goto out; |
319 | 358 | ||
320 | /* When we created the file with exclusive semantics, make | 359 | /* When we created the file with exclusive semantics, make |
321 | * sure we set the attributes afterwards. */ | 360 | * sure we set the attributes afterwards. */ |
322 | if (arg.createmode == NFS3_CREATE_EXCLUSIVE) { | 361 | if (data->arg.create.createmode == NFS3_CREATE_EXCLUSIVE) { |
323 | dprintk("NFS call setattr (post-create)\n"); | 362 | dprintk("NFS call setattr (post-create)\n"); |
324 | 363 | ||
325 | if (!(sattr->ia_valid & ATTR_ATIME_SET)) | 364 | if (!(sattr->ia_valid & ATTR_ATIME_SET)) |
@@ -330,14 +369,15 @@ again: | |||
330 | /* Note: we could use a guarded setattr here, but I'm | 369 | /* Note: we could use a guarded setattr here, but I'm |
331 | * not sure this buys us anything (and I'd have | 370 | * not sure this buys us anything (and I'd have |
332 | * to revamp the NFSv3 XDR code) */ | 371 | * to revamp the NFSv3 XDR code) */ |
333 | status = nfs3_proc_setattr(dentry, &fattr, sattr); | 372 | status = nfs3_proc_setattr(dentry, data->res.fattr, sattr); |
334 | nfs_post_op_update_inode(dentry->d_inode, &fattr); | 373 | nfs_post_op_update_inode(dentry->d_inode, data->res.fattr); |
335 | dprintk("NFS reply setattr (post-create): %d\n", status); | 374 | dprintk("NFS reply setattr (post-create): %d\n", status); |
375 | if (status != 0) | ||
376 | goto out; | ||
336 | } | 377 | } |
337 | if (status != 0) | ||
338 | goto out; | ||
339 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); | 378 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); |
340 | out: | 379 | out: |
380 | nfs3_free_createdata(data); | ||
341 | dprintk("NFS reply create: %d\n", status); | 381 | dprintk("NFS reply create: %d\n", status); |
342 | return status; | 382 | return status; |
343 | } | 383 | } |
@@ -452,40 +492,28 @@ static int | |||
452 | nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, | 492 | nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, |
453 | unsigned int len, struct iattr *sattr) | 493 | unsigned int len, struct iattr *sattr) |
454 | { | 494 | { |
455 | struct nfs_fh fhandle; | 495 | struct nfs3_createdata *data; |
456 | struct nfs_fattr fattr, dir_attr; | 496 | int status = -ENOMEM; |
457 | struct nfs3_symlinkargs arg = { | ||
458 | .fromfh = NFS_FH(dir), | ||
459 | .fromname = dentry->d_name.name, | ||
460 | .fromlen = dentry->d_name.len, | ||
461 | .pages = &page, | ||
462 | .pathlen = len, | ||
463 | .sattr = sattr | ||
464 | }; | ||
465 | struct nfs3_diropres res = { | ||
466 | .dir_attr = &dir_attr, | ||
467 | .fh = &fhandle, | ||
468 | .fattr = &fattr | ||
469 | }; | ||
470 | struct rpc_message msg = { | ||
471 | .rpc_proc = &nfs3_procedures[NFS3PROC_SYMLINK], | ||
472 | .rpc_argp = &arg, | ||
473 | .rpc_resp = &res, | ||
474 | }; | ||
475 | int status; | ||
476 | 497 | ||
477 | if (len > NFS3_MAXPATHLEN) | 498 | if (len > NFS3_MAXPATHLEN) |
478 | return -ENAMETOOLONG; | 499 | return -ENAMETOOLONG; |
479 | 500 | ||
480 | dprintk("NFS call symlink %s\n", dentry->d_name.name); | 501 | dprintk("NFS call symlink %s\n", dentry->d_name.name); |
481 | 502 | ||
482 | nfs_fattr_init(&dir_attr); | 503 | data = nfs3_alloc_createdata(); |
483 | nfs_fattr_init(&fattr); | 504 | if (data == NULL) |
484 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | ||
485 | nfs_post_op_update_inode(dir, &dir_attr); | ||
486 | if (status != 0) | ||
487 | goto out; | 505 | goto out; |
488 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 506 | data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_SYMLINK]; |
507 | data->arg.symlink.fromfh = NFS_FH(dir); | ||
508 | data->arg.symlink.fromname = dentry->d_name.name; | ||
509 | data->arg.symlink.fromlen = dentry->d_name.len; | ||
510 | data->arg.symlink.pages = &page; | ||
511 | data->arg.symlink.pathlen = len; | ||
512 | data->arg.symlink.sattr = sattr; | ||
513 | |||
514 | status = nfs3_do_create(dir, dentry, data); | ||
515 | |||
516 | nfs3_free_createdata(data); | ||
489 | out: | 517 | out: |
490 | dprintk("NFS reply symlink: %d\n", status); | 518 | dprintk("NFS reply symlink: %d\n", status); |
491 | return status; | 519 | return status; |
@@ -494,42 +522,31 @@ out: | |||
494 | static int | 522 | static int |
495 | nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) | 523 | nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) |
496 | { | 524 | { |
497 | struct nfs_fh fhandle; | 525 | struct nfs3_createdata *data; |
498 | struct nfs_fattr fattr, dir_attr; | ||
499 | struct nfs3_mkdirargs arg = { | ||
500 | .fh = NFS_FH(dir), | ||
501 | .name = dentry->d_name.name, | ||
502 | .len = dentry->d_name.len, | ||
503 | .sattr = sattr | ||
504 | }; | ||
505 | struct nfs3_diropres res = { | ||
506 | .dir_attr = &dir_attr, | ||
507 | .fh = &fhandle, | ||
508 | .fattr = &fattr | ||
509 | }; | ||
510 | struct rpc_message msg = { | ||
511 | .rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR], | ||
512 | .rpc_argp = &arg, | ||
513 | .rpc_resp = &res, | ||
514 | }; | ||
515 | int mode = sattr->ia_mode; | 526 | int mode = sattr->ia_mode; |
516 | int status; | 527 | int status = -ENOMEM; |
517 | 528 | ||
518 | dprintk("NFS call mkdir %s\n", dentry->d_name.name); | 529 | dprintk("NFS call mkdir %s\n", dentry->d_name.name); |
519 | 530 | ||
520 | sattr->ia_mode &= ~current->fs->umask; | 531 | sattr->ia_mode &= ~current->fs->umask; |
521 | 532 | ||
522 | nfs_fattr_init(&dir_attr); | 533 | data = nfs3_alloc_createdata(); |
523 | nfs_fattr_init(&fattr); | 534 | if (data == NULL) |
524 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | ||
525 | nfs_post_op_update_inode(dir, &dir_attr); | ||
526 | if (status != 0) | ||
527 | goto out; | 535 | goto out; |
528 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 536 | |
537 | data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR]; | ||
538 | data->arg.mkdir.fh = NFS_FH(dir); | ||
539 | data->arg.mkdir.name = dentry->d_name.name; | ||
540 | data->arg.mkdir.len = dentry->d_name.len; | ||
541 | data->arg.mkdir.sattr = sattr; | ||
542 | |||
543 | status = nfs3_do_create(dir, dentry, data); | ||
529 | if (status != 0) | 544 | if (status != 0) |
530 | goto out; | 545 | goto out; |
546 | |||
531 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); | 547 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); |
532 | out: | 548 | out: |
549 | nfs3_free_createdata(data); | ||
533 | dprintk("NFS reply mkdir: %d\n", status); | 550 | dprintk("NFS reply mkdir: %d\n", status); |
534 | return status; | 551 | return status; |
535 | } | 552 | } |
@@ -615,52 +632,50 @@ static int | |||
615 | nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | 632 | nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, |
616 | dev_t rdev) | 633 | dev_t rdev) |
617 | { | 634 | { |
618 | struct nfs_fh fh; | 635 | struct nfs3_createdata *data; |
619 | struct nfs_fattr fattr, dir_attr; | ||
620 | struct nfs3_mknodargs arg = { | ||
621 | .fh = NFS_FH(dir), | ||
622 | .name = dentry->d_name.name, | ||
623 | .len = dentry->d_name.len, | ||
624 | .sattr = sattr, | ||
625 | .rdev = rdev | ||
626 | }; | ||
627 | struct nfs3_diropres res = { | ||
628 | .dir_attr = &dir_attr, | ||
629 | .fh = &fh, | ||
630 | .fattr = &fattr | ||
631 | }; | ||
632 | struct rpc_message msg = { | ||
633 | .rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD], | ||
634 | .rpc_argp = &arg, | ||
635 | .rpc_resp = &res, | ||
636 | }; | ||
637 | mode_t mode = sattr->ia_mode; | 636 | mode_t mode = sattr->ia_mode; |
638 | int status; | 637 | int status = -ENOMEM; |
639 | |||
640 | switch (sattr->ia_mode & S_IFMT) { | ||
641 | case S_IFBLK: arg.type = NF3BLK; break; | ||
642 | case S_IFCHR: arg.type = NF3CHR; break; | ||
643 | case S_IFIFO: arg.type = NF3FIFO; break; | ||
644 | case S_IFSOCK: arg.type = NF3SOCK; break; | ||
645 | default: return -EINVAL; | ||
646 | } | ||
647 | 638 | ||
648 | dprintk("NFS call mknod %s %u:%u\n", dentry->d_name.name, | 639 | dprintk("NFS call mknod %s %u:%u\n", dentry->d_name.name, |
649 | MAJOR(rdev), MINOR(rdev)); | 640 | MAJOR(rdev), MINOR(rdev)); |
650 | 641 | ||
651 | sattr->ia_mode &= ~current->fs->umask; | 642 | sattr->ia_mode &= ~current->fs->umask; |
652 | 643 | ||
653 | nfs_fattr_init(&dir_attr); | 644 | data = nfs3_alloc_createdata(); |
654 | nfs_fattr_init(&fattr); | 645 | if (data == NULL) |
655 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | ||
656 | nfs_post_op_update_inode(dir, &dir_attr); | ||
657 | if (status != 0) | ||
658 | goto out; | 646 | goto out; |
659 | status = nfs_instantiate(dentry, &fh, &fattr); | 647 | |
648 | data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD]; | ||
649 | data->arg.mknod.fh = NFS_FH(dir); | ||
650 | data->arg.mknod.name = dentry->d_name.name; | ||
651 | data->arg.mknod.len = dentry->d_name.len; | ||
652 | data->arg.mknod.sattr = sattr; | ||
653 | data->arg.mknod.rdev = rdev; | ||
654 | |||
655 | switch (sattr->ia_mode & S_IFMT) { | ||
656 | case S_IFBLK: | ||
657 | data->arg.mknod.type = NF3BLK; | ||
658 | break; | ||
659 | case S_IFCHR: | ||
660 | data->arg.mknod.type = NF3CHR; | ||
661 | break; | ||
662 | case S_IFIFO: | ||
663 | data->arg.mknod.type = NF3FIFO; | ||
664 | break; | ||
665 | case S_IFSOCK: | ||
666 | data->arg.mknod.type = NF3SOCK; | ||
667 | break; | ||
668 | default: | ||
669 | status = -EINVAL; | ||
670 | goto out; | ||
671 | } | ||
672 | |||
673 | status = nfs3_do_create(dir, dentry, data); | ||
660 | if (status != 0) | 674 | if (status != 0) |
661 | goto out; | 675 | goto out; |
662 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); | 676 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); |
663 | out: | 677 | out: |
678 | nfs3_free_createdata(data); | ||
664 | dprintk("NFS reply mknod: %d\n", status); | 679 | dprintk("NFS reply mknod: %d\n", status); |
665 | return status; | 680 | return status; |
666 | } | 681 | } |
@@ -801,8 +816,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = { | |||
801 | .write_done = nfs3_write_done, | 816 | .write_done = nfs3_write_done, |
802 | .commit_setup = nfs3_proc_commit_setup, | 817 | .commit_setup = nfs3_proc_commit_setup, |
803 | .commit_done = nfs3_commit_done, | 818 | .commit_done = nfs3_commit_done, |
804 | .file_open = nfs_open, | ||
805 | .file_release = nfs_release, | ||
806 | .lock = nfs3_proc_lock, | 819 | .lock = nfs3_proc_lock, |
807 | .clear_acl_cache = nfs3_forget_cached_acls, | 820 | .clear_acl_cache = nfs3_forget_cached_acls, |
808 | }; | 821 | }; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 1293e0acd82b..c910413eaeca 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -451,9 +451,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) | |||
451 | /* Save the delegation */ | 451 | /* Save the delegation */ |
452 | memcpy(stateid.data, delegation->stateid.data, sizeof(stateid.data)); | 452 | memcpy(stateid.data, delegation->stateid.data, sizeof(stateid.data)); |
453 | rcu_read_unlock(); | 453 | rcu_read_unlock(); |
454 | lock_kernel(); | ||
455 | ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); | 454 | ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); |
456 | unlock_kernel(); | ||
457 | if (ret != 0) | 455 | if (ret != 0) |
458 | goto out; | 456 | goto out; |
459 | ret = -EAGAIN; | 457 | ret = -EAGAIN; |
@@ -1139,8 +1137,9 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir, struct path *path, int | |||
1139 | return res; | 1137 | return res; |
1140 | } | 1138 | } |
1141 | 1139 | ||
1142 | static int _nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | 1140 | static int _nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, |
1143 | struct iattr *sattr, struct nfs4_state *state) | 1141 | struct nfs_fattr *fattr, struct iattr *sattr, |
1142 | struct nfs4_state *state) | ||
1144 | { | 1143 | { |
1145 | struct nfs_server *server = NFS_SERVER(inode); | 1144 | struct nfs_server *server = NFS_SERVER(inode); |
1146 | struct nfs_setattrargs arg = { | 1145 | struct nfs_setattrargs arg = { |
@@ -1154,9 +1153,10 @@ static int _nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | |||
1154 | .server = server, | 1153 | .server = server, |
1155 | }; | 1154 | }; |
1156 | struct rpc_message msg = { | 1155 | struct rpc_message msg = { |
1157 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR], | 1156 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR], |
1158 | .rpc_argp = &arg, | 1157 | .rpc_argp = &arg, |
1159 | .rpc_resp = &res, | 1158 | .rpc_resp = &res, |
1159 | .rpc_cred = cred, | ||
1160 | }; | 1160 | }; |
1161 | unsigned long timestamp = jiffies; | 1161 | unsigned long timestamp = jiffies; |
1162 | int status; | 1162 | int status; |
@@ -1166,7 +1166,6 @@ static int _nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | |||
1166 | if (nfs4_copy_delegation_stateid(&arg.stateid, inode)) { | 1166 | if (nfs4_copy_delegation_stateid(&arg.stateid, inode)) { |
1167 | /* Use that stateid */ | 1167 | /* Use that stateid */ |
1168 | } else if (state != NULL) { | 1168 | } else if (state != NULL) { |
1169 | msg.rpc_cred = state->owner->so_cred; | ||
1170 | nfs4_copy_stateid(&arg.stateid, state, current->files); | 1169 | nfs4_copy_stateid(&arg.stateid, state, current->files); |
1171 | } else | 1170 | } else |
1172 | memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid)); | 1171 | memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid)); |
@@ -1177,15 +1176,16 @@ static int _nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | |||
1177 | return status; | 1176 | return status; |
1178 | } | 1177 | } |
1179 | 1178 | ||
1180 | static int nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | 1179 | static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, |
1181 | struct iattr *sattr, struct nfs4_state *state) | 1180 | struct nfs_fattr *fattr, struct iattr *sattr, |
1181 | struct nfs4_state *state) | ||
1182 | { | 1182 | { |
1183 | struct nfs_server *server = NFS_SERVER(inode); | 1183 | struct nfs_server *server = NFS_SERVER(inode); |
1184 | struct nfs4_exception exception = { }; | 1184 | struct nfs4_exception exception = { }; |
1185 | int err; | 1185 | int err; |
1186 | do { | 1186 | do { |
1187 | err = nfs4_handle_exception(server, | 1187 | err = nfs4_handle_exception(server, |
1188 | _nfs4_do_setattr(inode, fattr, sattr, state), | 1188 | _nfs4_do_setattr(inode, cred, fattr, sattr, state), |
1189 | &exception); | 1189 | &exception); |
1190 | } while (exception.retry); | 1190 | } while (exception.retry); |
1191 | return err; | 1191 | return err; |
@@ -1647,29 +1647,25 @@ static int | |||
1647 | nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | 1647 | nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, |
1648 | struct iattr *sattr) | 1648 | struct iattr *sattr) |
1649 | { | 1649 | { |
1650 | struct rpc_cred *cred; | ||
1651 | struct inode *inode = dentry->d_inode; | 1650 | struct inode *inode = dentry->d_inode; |
1652 | struct nfs_open_context *ctx; | 1651 | struct rpc_cred *cred = NULL; |
1653 | struct nfs4_state *state = NULL; | 1652 | struct nfs4_state *state = NULL; |
1654 | int status; | 1653 | int status; |
1655 | 1654 | ||
1656 | nfs_fattr_init(fattr); | 1655 | nfs_fattr_init(fattr); |
1657 | 1656 | ||
1658 | cred = rpc_lookup_cred(); | ||
1659 | if (IS_ERR(cred)) | ||
1660 | return PTR_ERR(cred); | ||
1661 | |||
1662 | /* Search for an existing open(O_WRITE) file */ | 1657 | /* Search for an existing open(O_WRITE) file */ |
1663 | ctx = nfs_find_open_context(inode, cred, FMODE_WRITE); | 1658 | if (sattr->ia_valid & ATTR_FILE) { |
1664 | if (ctx != NULL) | 1659 | struct nfs_open_context *ctx; |
1660 | |||
1661 | ctx = nfs_file_open_context(sattr->ia_file); | ||
1662 | cred = ctx->cred; | ||
1665 | state = ctx->state; | 1663 | state = ctx->state; |
1664 | } | ||
1666 | 1665 | ||
1667 | status = nfs4_do_setattr(inode, fattr, sattr, state); | 1666 | status = nfs4_do_setattr(inode, cred, fattr, sattr, state); |
1668 | if (status == 0) | 1667 | if (status == 0) |
1669 | nfs_setattr_update_inode(inode, sattr); | 1668 | nfs_setattr_update_inode(inode, sattr); |
1670 | if (ctx != NULL) | ||
1671 | put_nfs_open_context(ctx); | ||
1672 | put_rpccred(cred); | ||
1673 | return status; | 1669 | return status; |
1674 | } | 1670 | } |
1675 | 1671 | ||
@@ -1897,17 +1893,16 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
1897 | goto out; | 1893 | goto out; |
1898 | } | 1894 | } |
1899 | state = nfs4_do_open(dir, &path, flags, sattr, cred); | 1895 | state = nfs4_do_open(dir, &path, flags, sattr, cred); |
1900 | put_rpccred(cred); | ||
1901 | d_drop(dentry); | 1896 | d_drop(dentry); |
1902 | if (IS_ERR(state)) { | 1897 | if (IS_ERR(state)) { |
1903 | status = PTR_ERR(state); | 1898 | status = PTR_ERR(state); |
1904 | goto out; | 1899 | goto out_putcred; |
1905 | } | 1900 | } |
1906 | d_add(dentry, igrab(state->inode)); | 1901 | d_add(dentry, igrab(state->inode)); |
1907 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 1902 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
1908 | if (flags & O_EXCL) { | 1903 | if (flags & O_EXCL) { |
1909 | struct nfs_fattr fattr; | 1904 | struct nfs_fattr fattr; |
1910 | status = nfs4_do_setattr(state->inode, &fattr, sattr, state); | 1905 | status = nfs4_do_setattr(state->inode, cred, &fattr, sattr, state); |
1911 | if (status == 0) | 1906 | if (status == 0) |
1912 | nfs_setattr_update_inode(state->inode, sattr); | 1907 | nfs_setattr_update_inode(state->inode, sattr); |
1913 | nfs_post_op_update_inode(state->inode, &fattr); | 1908 | nfs_post_op_update_inode(state->inode, &fattr); |
@@ -1916,6 +1911,8 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
1916 | status = nfs4_intent_set_file(nd, &path, state); | 1911 | status = nfs4_intent_set_file(nd, &path, state); |
1917 | else | 1912 | else |
1918 | nfs4_close_sync(&path, state, flags); | 1913 | nfs4_close_sync(&path, state, flags); |
1914 | out_putcred: | ||
1915 | put_rpccred(cred); | ||
1919 | out: | 1916 | out: |
1920 | return status; | 1917 | return status; |
1921 | } | 1918 | } |
@@ -2079,47 +2076,81 @@ static int nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr *n | |||
2079 | return err; | 2076 | return err; |
2080 | } | 2077 | } |
2081 | 2078 | ||
2079 | struct nfs4_createdata { | ||
2080 | struct rpc_message msg; | ||
2081 | struct nfs4_create_arg arg; | ||
2082 | struct nfs4_create_res res; | ||
2083 | struct nfs_fh fh; | ||
2084 | struct nfs_fattr fattr; | ||
2085 | struct nfs_fattr dir_fattr; | ||
2086 | }; | ||
2087 | |||
2088 | static struct nfs4_createdata *nfs4_alloc_createdata(struct inode *dir, | ||
2089 | struct qstr *name, struct iattr *sattr, u32 ftype) | ||
2090 | { | ||
2091 | struct nfs4_createdata *data; | ||
2092 | |||
2093 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
2094 | if (data != NULL) { | ||
2095 | struct nfs_server *server = NFS_SERVER(dir); | ||
2096 | |||
2097 | data->msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE]; | ||
2098 | data->msg.rpc_argp = &data->arg; | ||
2099 | data->msg.rpc_resp = &data->res; | ||
2100 | data->arg.dir_fh = NFS_FH(dir); | ||
2101 | data->arg.server = server; | ||
2102 | data->arg.name = name; | ||
2103 | data->arg.attrs = sattr; | ||
2104 | data->arg.ftype = ftype; | ||
2105 | data->arg.bitmask = server->attr_bitmask; | ||
2106 | data->res.server = server; | ||
2107 | data->res.fh = &data->fh; | ||
2108 | data->res.fattr = &data->fattr; | ||
2109 | data->res.dir_fattr = &data->dir_fattr; | ||
2110 | nfs_fattr_init(data->res.fattr); | ||
2111 | nfs_fattr_init(data->res.dir_fattr); | ||
2112 | } | ||
2113 | return data; | ||
2114 | } | ||
2115 | |||
2116 | static int nfs4_do_create(struct inode *dir, struct dentry *dentry, struct nfs4_createdata *data) | ||
2117 | { | ||
2118 | int status = rpc_call_sync(NFS_CLIENT(dir), &data->msg, 0); | ||
2119 | if (status == 0) { | ||
2120 | update_changeattr(dir, &data->res.dir_cinfo); | ||
2121 | nfs_post_op_update_inode(dir, data->res.dir_fattr); | ||
2122 | status = nfs_instantiate(dentry, data->res.fh, data->res.fattr); | ||
2123 | } | ||
2124 | return status; | ||
2125 | } | ||
2126 | |||
2127 | static void nfs4_free_createdata(struct nfs4_createdata *data) | ||
2128 | { | ||
2129 | kfree(data); | ||
2130 | } | ||
2131 | |||
2082 | static int _nfs4_proc_symlink(struct inode *dir, struct dentry *dentry, | 2132 | static int _nfs4_proc_symlink(struct inode *dir, struct dentry *dentry, |
2083 | struct page *page, unsigned int len, struct iattr *sattr) | 2133 | struct page *page, unsigned int len, struct iattr *sattr) |
2084 | { | 2134 | { |
2085 | struct nfs_server *server = NFS_SERVER(dir); | 2135 | struct nfs4_createdata *data; |
2086 | struct nfs_fh fhandle; | 2136 | int status = -ENAMETOOLONG; |
2087 | struct nfs_fattr fattr, dir_fattr; | ||
2088 | struct nfs4_create_arg arg = { | ||
2089 | .dir_fh = NFS_FH(dir), | ||
2090 | .server = server, | ||
2091 | .name = &dentry->d_name, | ||
2092 | .attrs = sattr, | ||
2093 | .ftype = NF4LNK, | ||
2094 | .bitmask = server->attr_bitmask, | ||
2095 | }; | ||
2096 | struct nfs4_create_res res = { | ||
2097 | .server = server, | ||
2098 | .fh = &fhandle, | ||
2099 | .fattr = &fattr, | ||
2100 | .dir_fattr = &dir_fattr, | ||
2101 | }; | ||
2102 | struct rpc_message msg = { | ||
2103 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SYMLINK], | ||
2104 | .rpc_argp = &arg, | ||
2105 | .rpc_resp = &res, | ||
2106 | }; | ||
2107 | int status; | ||
2108 | 2137 | ||
2109 | if (len > NFS4_MAXPATHLEN) | 2138 | if (len > NFS4_MAXPATHLEN) |
2110 | return -ENAMETOOLONG; | 2139 | goto out; |
2111 | 2140 | ||
2112 | arg.u.symlink.pages = &page; | 2141 | status = -ENOMEM; |
2113 | arg.u.symlink.len = len; | 2142 | data = nfs4_alloc_createdata(dir, &dentry->d_name, sattr, NF4LNK); |
2114 | nfs_fattr_init(&fattr); | 2143 | if (data == NULL) |
2115 | nfs_fattr_init(&dir_fattr); | 2144 | goto out; |
2145 | |||
2146 | data->msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SYMLINK]; | ||
2147 | data->arg.u.symlink.pages = &page; | ||
2148 | data->arg.u.symlink.len = len; | ||
2116 | 2149 | ||
2117 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 2150 | status = nfs4_do_create(dir, dentry, data); |
2118 | if (!status) { | 2151 | |
2119 | update_changeattr(dir, &res.dir_cinfo); | 2152 | nfs4_free_createdata(data); |
2120 | nfs_post_op_update_inode(dir, res.dir_fattr); | 2153 | out: |
2121 | status = nfs_instantiate(dentry, &fhandle, &fattr); | ||
2122 | } | ||
2123 | return status; | 2154 | return status; |
2124 | } | 2155 | } |
2125 | 2156 | ||
@@ -2140,39 +2171,17 @@ static int nfs4_proc_symlink(struct inode *dir, struct dentry *dentry, | |||
2140 | static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry, | 2171 | static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry, |
2141 | struct iattr *sattr) | 2172 | struct iattr *sattr) |
2142 | { | 2173 | { |
2143 | struct nfs_server *server = NFS_SERVER(dir); | 2174 | struct nfs4_createdata *data; |
2144 | struct nfs_fh fhandle; | 2175 | int status = -ENOMEM; |
2145 | struct nfs_fattr fattr, dir_fattr; | ||
2146 | struct nfs4_create_arg arg = { | ||
2147 | .dir_fh = NFS_FH(dir), | ||
2148 | .server = server, | ||
2149 | .name = &dentry->d_name, | ||
2150 | .attrs = sattr, | ||
2151 | .ftype = NF4DIR, | ||
2152 | .bitmask = server->attr_bitmask, | ||
2153 | }; | ||
2154 | struct nfs4_create_res res = { | ||
2155 | .server = server, | ||
2156 | .fh = &fhandle, | ||
2157 | .fattr = &fattr, | ||
2158 | .dir_fattr = &dir_fattr, | ||
2159 | }; | ||
2160 | struct rpc_message msg = { | ||
2161 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], | ||
2162 | .rpc_argp = &arg, | ||
2163 | .rpc_resp = &res, | ||
2164 | }; | ||
2165 | int status; | ||
2166 | 2176 | ||
2167 | nfs_fattr_init(&fattr); | 2177 | data = nfs4_alloc_createdata(dir, &dentry->d_name, sattr, NF4DIR); |
2168 | nfs_fattr_init(&dir_fattr); | 2178 | if (data == NULL) |
2169 | 2179 | goto out; | |
2170 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 2180 | |
2171 | if (!status) { | 2181 | status = nfs4_do_create(dir, dentry, data); |
2172 | update_changeattr(dir, &res.dir_cinfo); | 2182 | |
2173 | nfs_post_op_update_inode(dir, res.dir_fattr); | 2183 | nfs4_free_createdata(data); |
2174 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 2184 | out: |
2175 | } | ||
2176 | return status; | 2185 | return status; |
2177 | } | 2186 | } |
2178 | 2187 | ||
@@ -2242,56 +2251,34 @@ static int nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
2242 | static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry, | 2251 | static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry, |
2243 | struct iattr *sattr, dev_t rdev) | 2252 | struct iattr *sattr, dev_t rdev) |
2244 | { | 2253 | { |
2245 | struct nfs_server *server = NFS_SERVER(dir); | 2254 | struct nfs4_createdata *data; |
2246 | struct nfs_fh fh; | 2255 | int mode = sattr->ia_mode; |
2247 | struct nfs_fattr fattr, dir_fattr; | 2256 | int status = -ENOMEM; |
2248 | struct nfs4_create_arg arg = { | ||
2249 | .dir_fh = NFS_FH(dir), | ||
2250 | .server = server, | ||
2251 | .name = &dentry->d_name, | ||
2252 | .attrs = sattr, | ||
2253 | .bitmask = server->attr_bitmask, | ||
2254 | }; | ||
2255 | struct nfs4_create_res res = { | ||
2256 | .server = server, | ||
2257 | .fh = &fh, | ||
2258 | .fattr = &fattr, | ||
2259 | .dir_fattr = &dir_fattr, | ||
2260 | }; | ||
2261 | struct rpc_message msg = { | ||
2262 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], | ||
2263 | .rpc_argp = &arg, | ||
2264 | .rpc_resp = &res, | ||
2265 | }; | ||
2266 | int status; | ||
2267 | int mode = sattr->ia_mode; | ||
2268 | |||
2269 | nfs_fattr_init(&fattr); | ||
2270 | nfs_fattr_init(&dir_fattr); | ||
2271 | 2257 | ||
2272 | BUG_ON(!(sattr->ia_valid & ATTR_MODE)); | 2258 | BUG_ON(!(sattr->ia_valid & ATTR_MODE)); |
2273 | BUG_ON(!S_ISFIFO(mode) && !S_ISBLK(mode) && !S_ISCHR(mode) && !S_ISSOCK(mode)); | 2259 | BUG_ON(!S_ISFIFO(mode) && !S_ISBLK(mode) && !S_ISCHR(mode) && !S_ISSOCK(mode)); |
2260 | |||
2261 | data = nfs4_alloc_createdata(dir, &dentry->d_name, sattr, NF4SOCK); | ||
2262 | if (data == NULL) | ||
2263 | goto out; | ||
2264 | |||
2274 | if (S_ISFIFO(mode)) | 2265 | if (S_ISFIFO(mode)) |
2275 | arg.ftype = NF4FIFO; | 2266 | data->arg.ftype = NF4FIFO; |
2276 | else if (S_ISBLK(mode)) { | 2267 | else if (S_ISBLK(mode)) { |
2277 | arg.ftype = NF4BLK; | 2268 | data->arg.ftype = NF4BLK; |
2278 | arg.u.device.specdata1 = MAJOR(rdev); | 2269 | data->arg.u.device.specdata1 = MAJOR(rdev); |
2279 | arg.u.device.specdata2 = MINOR(rdev); | 2270 | data->arg.u.device.specdata2 = MINOR(rdev); |
2280 | } | 2271 | } |
2281 | else if (S_ISCHR(mode)) { | 2272 | else if (S_ISCHR(mode)) { |
2282 | arg.ftype = NF4CHR; | 2273 | data->arg.ftype = NF4CHR; |
2283 | arg.u.device.specdata1 = MAJOR(rdev); | 2274 | data->arg.u.device.specdata1 = MAJOR(rdev); |
2284 | arg.u.device.specdata2 = MINOR(rdev); | 2275 | data->arg.u.device.specdata2 = MINOR(rdev); |
2285 | } | 2276 | } |
2286 | else | ||
2287 | arg.ftype = NF4SOCK; | ||
2288 | 2277 | ||
2289 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 2278 | status = nfs4_do_create(dir, dentry, data); |
2290 | if (status == 0) { | 2279 | |
2291 | update_changeattr(dir, &res.dir_cinfo); | 2280 | nfs4_free_createdata(data); |
2292 | nfs_post_op_update_inode(dir, res.dir_fattr); | 2281 | out: |
2293 | status = nfs_instantiate(dentry, &fh, &fattr); | ||
2294 | } | ||
2295 | return status; | 2282 | return status; |
2296 | } | 2283 | } |
2297 | 2284 | ||
@@ -2706,6 +2693,8 @@ static ssize_t nfs4_proc_get_acl(struct inode *inode, void *buf, size_t buflen) | |||
2706 | ret = nfs_revalidate_inode(server, inode); | 2693 | ret = nfs_revalidate_inode(server, inode); |
2707 | if (ret < 0) | 2694 | if (ret < 0) |
2708 | return ret; | 2695 | return ret; |
2696 | if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL) | ||
2697 | nfs_zap_acl_cache(inode); | ||
2709 | ret = nfs4_read_cached_acl(inode, buf, buflen); | 2698 | ret = nfs4_read_cached_acl(inode, buf, buflen); |
2710 | if (ret != -ENOENT) | 2699 | if (ret != -ENOENT) |
2711 | return ret; | 2700 | return ret; |
@@ -2733,7 +2722,8 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl | |||
2733 | nfs_inode_return_delegation(inode); | 2722 | nfs_inode_return_delegation(inode); |
2734 | buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase); | 2723 | buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase); |
2735 | ret = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 2724 | ret = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
2736 | nfs_zap_caches(inode); | 2725 | nfs_access_zap_cache(inode); |
2726 | nfs_zap_acl_cache(inode); | ||
2737 | return ret; | 2727 | return ret; |
2738 | } | 2728 | } |
2739 | 2729 | ||
@@ -2767,8 +2757,7 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server) | |||
2767 | task->tk_status = 0; | 2757 | task->tk_status = 0; |
2768 | return -EAGAIN; | 2758 | return -EAGAIN; |
2769 | case -NFS4ERR_DELAY: | 2759 | case -NFS4ERR_DELAY: |
2770 | nfs_inc_server_stats((struct nfs_server *) server, | 2760 | nfs_inc_server_stats(server, NFSIOS_DELAY); |
2771 | NFSIOS_DELAY); | ||
2772 | case -NFS4ERR_GRACE: | 2761 | case -NFS4ERR_GRACE: |
2773 | rpc_delay(task, NFS4_POLL_RETRY_MAX); | 2762 | rpc_delay(task, NFS4_POLL_RETRY_MAX); |
2774 | task->tk_status = 0; | 2763 | task->tk_status = 0; |
@@ -2933,7 +2922,7 @@ static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cre | |||
2933 | 2922 | ||
2934 | int nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) | 2923 | int nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) |
2935 | { | 2924 | { |
2936 | long timeout; | 2925 | long timeout = 0; |
2937 | int err; | 2926 | int err; |
2938 | do { | 2927 | do { |
2939 | err = _nfs4_proc_setclientid_confirm(clp, cred); | 2928 | err = _nfs4_proc_setclientid_confirm(clp, cred); |
@@ -3725,8 +3714,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = { | |||
3725 | .write_done = nfs4_write_done, | 3714 | .write_done = nfs4_write_done, |
3726 | .commit_setup = nfs4_proc_commit_setup, | 3715 | .commit_setup = nfs4_proc_commit_setup, |
3727 | .commit_done = nfs4_commit_done, | 3716 | .commit_done = nfs4_commit_done, |
3728 | .file_open = nfs_open, | ||
3729 | .file_release = nfs_release, | ||
3730 | .lock = nfs4_proc_lock, | 3717 | .lock = nfs4_proc_lock, |
3731 | .clear_acl_cache = nfs4_zap_acl_attr, | 3718 | .clear_acl_cache = nfs4_zap_acl_attr, |
3732 | }; | 3719 | }; |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 856a8934f610..401ef8b28f97 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -940,7 +940,6 @@ static int reclaimer(void *ptr) | |||
940 | allow_signal(SIGKILL); | 940 | allow_signal(SIGKILL); |
941 | 941 | ||
942 | /* Ensure exclusive access to NFSv4 state */ | 942 | /* Ensure exclusive access to NFSv4 state */ |
943 | lock_kernel(); | ||
944 | down_write(&clp->cl_sem); | 943 | down_write(&clp->cl_sem); |
945 | /* Are there any NFS mounts out there? */ | 944 | /* Are there any NFS mounts out there? */ |
946 | if (list_empty(&clp->cl_superblocks)) | 945 | if (list_empty(&clp->cl_superblocks)) |
@@ -1000,7 +999,6 @@ restart_loop: | |||
1000 | nfs_delegation_reap_unclaimed(clp); | 999 | nfs_delegation_reap_unclaimed(clp); |
1001 | out: | 1000 | out: |
1002 | up_write(&clp->cl_sem); | 1001 | up_write(&clp->cl_sem); |
1003 | unlock_kernel(); | ||
1004 | if (status == -NFS4ERR_CB_PATH_DOWN) | 1002 | if (status == -NFS4ERR_CB_PATH_DOWN) |
1005 | nfs_handle_cb_pathdown(clp); | 1003 | nfs_handle_cb_pathdown(clp); |
1006 | nfs4_clear_recover_bit(clp); | 1004 | nfs4_clear_recover_bit(clp); |
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index 531379d36823..46763d1cd397 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: nfsroot.c,v 1.45 1998/03/07 10:44:46 mj Exp $ | ||
3 | * | ||
4 | * Copyright (C) 1995, 1996 Gero Kuhlmann <gero@gkminix.han.de> | 2 | * Copyright (C) 1995, 1996 Gero Kuhlmann <gero@gkminix.han.de> |
5 | * | 3 | * |
6 | * Allow an NFS filesystem to be mounted as root. The way this works is: | 4 | * Allow an NFS filesystem to be mounted as root. The way this works is: |
@@ -297,10 +295,10 @@ static int __init root_nfs_name(char *name) | |||
297 | nfs_data.flags = NFS_MOUNT_NONLM; /* No lockd in nfs root yet */ | 295 | nfs_data.flags = NFS_MOUNT_NONLM; /* No lockd in nfs root yet */ |
298 | nfs_data.rsize = NFS_DEF_FILE_IO_SIZE; | 296 | nfs_data.rsize = NFS_DEF_FILE_IO_SIZE; |
299 | nfs_data.wsize = NFS_DEF_FILE_IO_SIZE; | 297 | nfs_data.wsize = NFS_DEF_FILE_IO_SIZE; |
300 | nfs_data.acregmin = 3; | 298 | nfs_data.acregmin = NFS_DEF_ACREGMIN; |
301 | nfs_data.acregmax = 60; | 299 | nfs_data.acregmax = NFS_DEF_ACREGMAX; |
302 | nfs_data.acdirmin = 30; | 300 | nfs_data.acdirmin = NFS_DEF_ACDIRMIN; |
303 | nfs_data.acdirmax = 60; | 301 | nfs_data.acdirmax = NFS_DEF_ACDIRMAX; |
304 | strcpy(buf, NFS_ROOT); | 302 | strcpy(buf, NFS_ROOT); |
305 | 303 | ||
306 | /* Process options received from the remote server */ | 304 | /* Process options received from the remote server */ |
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 03599bfe81cf..4dbb84df1b68 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -129,6 +129,8 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
129 | sattr->ia_mode &= S_IALLUGO; | 129 | sattr->ia_mode &= S_IALLUGO; |
130 | 130 | ||
131 | dprintk("NFS call setattr\n"); | 131 | dprintk("NFS call setattr\n"); |
132 | if (sattr->ia_valid & ATTR_FILE) | ||
133 | msg.rpc_cred = nfs_file_cred(sattr->ia_file); | ||
132 | nfs_fattr_init(fattr); | 134 | nfs_fattr_init(fattr); |
133 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 135 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
134 | if (status == 0) | 136 | if (status == 0) |
@@ -598,6 +600,29 @@ nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl) | |||
598 | return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); | 600 | return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); |
599 | } | 601 | } |
600 | 602 | ||
603 | /* Helper functions for NFS lock bounds checking */ | ||
604 | #define NFS_LOCK32_OFFSET_MAX ((__s32)0x7fffffffUL) | ||
605 | static int nfs_lock_check_bounds(const struct file_lock *fl) | ||
606 | { | ||
607 | __s32 start, end; | ||
608 | |||
609 | start = (__s32)fl->fl_start; | ||
610 | if ((loff_t)start != fl->fl_start) | ||
611 | goto out_einval; | ||
612 | |||
613 | if (fl->fl_end != OFFSET_MAX) { | ||
614 | end = (__s32)fl->fl_end; | ||
615 | if ((loff_t)end != fl->fl_end) | ||
616 | goto out_einval; | ||
617 | } else | ||
618 | end = NFS_LOCK32_OFFSET_MAX; | ||
619 | |||
620 | if (start < 0 || start > end) | ||
621 | goto out_einval; | ||
622 | return 0; | ||
623 | out_einval: | ||
624 | return -EINVAL; | ||
625 | } | ||
601 | 626 | ||
602 | const struct nfs_rpc_ops nfs_v2_clientops = { | 627 | const struct nfs_rpc_ops nfs_v2_clientops = { |
603 | .version = 2, /* protocol version */ | 628 | .version = 2, /* protocol version */ |
@@ -630,7 +655,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = { | |||
630 | .write_setup = nfs_proc_write_setup, | 655 | .write_setup = nfs_proc_write_setup, |
631 | .write_done = nfs_write_done, | 656 | .write_done = nfs_write_done, |
632 | .commit_setup = nfs_proc_commit_setup, | 657 | .commit_setup = nfs_proc_commit_setup, |
633 | .file_open = nfs_open, | ||
634 | .file_release = nfs_release, | ||
635 | .lock = nfs_proc_lock, | 658 | .lock = nfs_proc_lock, |
659 | .lock_check_bounds = nfs_lock_check_bounds, | ||
636 | }; | 660 | }; |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 614efeed5437..1b94e3650f5c 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/inet.h> | 47 | #include <linux/inet.h> |
48 | #include <linux/in6.h> | 48 | #include <linux/in6.h> |
49 | #include <net/ipv6.h> | 49 | #include <net/ipv6.h> |
50 | #include <linux/netdevice.h> | ||
50 | #include <linux/nfs_xdr.h> | 51 | #include <linux/nfs_xdr.h> |
51 | #include <linux/magic.h> | 52 | #include <linux/magic.h> |
52 | #include <linux/parser.h> | 53 | #include <linux/parser.h> |
@@ -65,7 +66,6 @@ | |||
65 | enum { | 66 | enum { |
66 | /* Mount options that take no arguments */ | 67 | /* Mount options that take no arguments */ |
67 | Opt_soft, Opt_hard, | 68 | Opt_soft, Opt_hard, |
68 | Opt_intr, Opt_nointr, | ||
69 | Opt_posix, Opt_noposix, | 69 | Opt_posix, Opt_noposix, |
70 | Opt_cto, Opt_nocto, | 70 | Opt_cto, Opt_nocto, |
71 | Opt_ac, Opt_noac, | 71 | Opt_ac, Opt_noac, |
@@ -92,8 +92,8 @@ enum { | |||
92 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, | 92 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, |
93 | Opt_addr, Opt_mountaddr, Opt_clientaddr, | 93 | Opt_addr, Opt_mountaddr, Opt_clientaddr, |
94 | 94 | ||
95 | /* Mount options that are ignored */ | 95 | /* Special mount options */ |
96 | Opt_userspace, Opt_deprecated, | 96 | Opt_userspace, Opt_deprecated, Opt_sloppy, |
97 | 97 | ||
98 | Opt_err | 98 | Opt_err |
99 | }; | 99 | }; |
@@ -101,10 +101,14 @@ enum { | |||
101 | static match_table_t nfs_mount_option_tokens = { | 101 | static match_table_t nfs_mount_option_tokens = { |
102 | { Opt_userspace, "bg" }, | 102 | { Opt_userspace, "bg" }, |
103 | { Opt_userspace, "fg" }, | 103 | { Opt_userspace, "fg" }, |
104 | { Opt_userspace, "retry=%s" }, | ||
105 | |||
106 | { Opt_sloppy, "sloppy" }, | ||
107 | |||
104 | { Opt_soft, "soft" }, | 108 | { Opt_soft, "soft" }, |
105 | { Opt_hard, "hard" }, | 109 | { Opt_hard, "hard" }, |
106 | { Opt_intr, "intr" }, | 110 | { Opt_deprecated, "intr" }, |
107 | { Opt_nointr, "nointr" }, | 111 | { Opt_deprecated, "nointr" }, |
108 | { Opt_posix, "posix" }, | 112 | { Opt_posix, "posix" }, |
109 | { Opt_noposix, "noposix" }, | 113 | { Opt_noposix, "noposix" }, |
110 | { Opt_cto, "cto" }, | 114 | { Opt_cto, "cto" }, |
@@ -136,7 +140,6 @@ static match_table_t nfs_mount_option_tokens = { | |||
136 | { Opt_acdirmin, "acdirmin=%u" }, | 140 | { Opt_acdirmin, "acdirmin=%u" }, |
137 | { Opt_acdirmax, "acdirmax=%u" }, | 141 | { Opt_acdirmax, "acdirmax=%u" }, |
138 | { Opt_actimeo, "actimeo=%u" }, | 142 | { Opt_actimeo, "actimeo=%u" }, |
139 | { Opt_userspace, "retry=%u" }, | ||
140 | { Opt_namelen, "namlen=%u" }, | 143 | { Opt_namelen, "namlen=%u" }, |
141 | { Opt_mountport, "mountport=%u" }, | 144 | { Opt_mountport, "mountport=%u" }, |
142 | { Opt_mountvers, "mountvers=%u" }, | 145 | { Opt_mountvers, "mountvers=%u" }, |
@@ -207,6 +210,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, | |||
207 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 210 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
208 | static void nfs_kill_super(struct super_block *); | 211 | static void nfs_kill_super(struct super_block *); |
209 | static void nfs_put_super(struct super_block *); | 212 | static void nfs_put_super(struct super_block *); |
213 | static int nfs_remount(struct super_block *sb, int *flags, char *raw_data); | ||
210 | 214 | ||
211 | static struct file_system_type nfs_fs_type = { | 215 | static struct file_system_type nfs_fs_type = { |
212 | .owner = THIS_MODULE, | 216 | .owner = THIS_MODULE, |
@@ -234,6 +238,7 @@ static const struct super_operations nfs_sops = { | |||
234 | .umount_begin = nfs_umount_begin, | 238 | .umount_begin = nfs_umount_begin, |
235 | .show_options = nfs_show_options, | 239 | .show_options = nfs_show_options, |
236 | .show_stats = nfs_show_stats, | 240 | .show_stats = nfs_show_stats, |
241 | .remount_fs = nfs_remount, | ||
237 | }; | 242 | }; |
238 | 243 | ||
239 | #ifdef CONFIG_NFS_V4 | 244 | #ifdef CONFIG_NFS_V4 |
@@ -278,6 +283,7 @@ static const struct super_operations nfs4_sops = { | |||
278 | .umount_begin = nfs_umount_begin, | 283 | .umount_begin = nfs_umount_begin, |
279 | .show_options = nfs_show_options, | 284 | .show_options = nfs_show_options, |
280 | .show_stats = nfs_show_stats, | 285 | .show_stats = nfs_show_stats, |
286 | .remount_fs = nfs_remount, | ||
281 | }; | 287 | }; |
282 | #endif | 288 | #endif |
283 | 289 | ||
@@ -368,8 +374,6 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
368 | }; | 374 | }; |
369 | int error; | 375 | int error; |
370 | 376 | ||
371 | lock_kernel(); | ||
372 | |||
373 | error = server->nfs_client->rpc_ops->statfs(server, fh, &res); | 377 | error = server->nfs_client->rpc_ops->statfs(server, fh, &res); |
374 | if (error < 0) | 378 | if (error < 0) |
375 | goto out_err; | 379 | goto out_err; |
@@ -401,12 +405,10 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
401 | 405 | ||
402 | buf->f_namelen = server->namelen; | 406 | buf->f_namelen = server->namelen; |
403 | 407 | ||
404 | unlock_kernel(); | ||
405 | return 0; | 408 | return 0; |
406 | 409 | ||
407 | out_err: | 410 | out_err: |
408 | dprintk("%s: statfs error = %d\n", __func__, -error); | 411 | dprintk("%s: statfs error = %d\n", __func__, -error); |
409 | unlock_kernel(); | ||
410 | return error; | 412 | return error; |
411 | } | 413 | } |
412 | 414 | ||
@@ -514,13 +516,13 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | |||
514 | if (nfss->bsize != 0) | 516 | if (nfss->bsize != 0) |
515 | seq_printf(m, ",bsize=%u", nfss->bsize); | 517 | seq_printf(m, ",bsize=%u", nfss->bsize); |
516 | seq_printf(m, ",namlen=%u", nfss->namelen); | 518 | seq_printf(m, ",namlen=%u", nfss->namelen); |
517 | if (nfss->acregmin != 3*HZ || showdefaults) | 519 | if (nfss->acregmin != NFS_DEF_ACREGMIN*HZ || showdefaults) |
518 | seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ); | 520 | seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ); |
519 | if (nfss->acregmax != 60*HZ || showdefaults) | 521 | if (nfss->acregmax != NFS_DEF_ACREGMAX*HZ || showdefaults) |
520 | seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ); | 522 | seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ); |
521 | if (nfss->acdirmin != 30*HZ || showdefaults) | 523 | if (nfss->acdirmin != NFS_DEF_ACDIRMIN*HZ || showdefaults) |
522 | seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ); | 524 | seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ); |
523 | if (nfss->acdirmax != 60*HZ || showdefaults) | 525 | if (nfss->acdirmax != NFS_DEF_ACDIRMAX*HZ || showdefaults) |
524 | seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ); | 526 | seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ); |
525 | for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { | 527 | for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { |
526 | if (nfss->flags & nfs_infop->flag) | 528 | if (nfss->flags & nfs_infop->flag) |
@@ -702,49 +704,233 @@ static int nfs_verify_server_address(struct sockaddr *addr) | |||
702 | return 0; | 704 | return 0; |
703 | } | 705 | } |
704 | 706 | ||
707 | static void nfs_parse_ipv4_address(char *string, size_t str_len, | ||
708 | struct sockaddr *sap, size_t *addr_len) | ||
709 | { | ||
710 | struct sockaddr_in *sin = (struct sockaddr_in *)sap; | ||
711 | u8 *addr = (u8 *)&sin->sin_addr.s_addr; | ||
712 | |||
713 | if (str_len <= INET_ADDRSTRLEN) { | ||
714 | dfprintk(MOUNT, "NFS: parsing IPv4 address %*s\n", | ||
715 | (int)str_len, string); | ||
716 | |||
717 | sin->sin_family = AF_INET; | ||
718 | *addr_len = sizeof(*sin); | ||
719 | if (in4_pton(string, str_len, addr, '\0', NULL)) | ||
720 | return; | ||
721 | } | ||
722 | |||
723 | sap->sa_family = AF_UNSPEC; | ||
724 | *addr_len = 0; | ||
725 | } | ||
726 | |||
727 | #define IPV6_SCOPE_DELIMITER '%' | ||
728 | |||
729 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
730 | static void nfs_parse_ipv6_scope_id(const char *string, const size_t str_len, | ||
731 | const char *delim, | ||
732 | struct sockaddr_in6 *sin6) | ||
733 | { | ||
734 | char *p; | ||
735 | size_t len; | ||
736 | |||
737 | if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)) | ||
738 | return ; | ||
739 | if (*delim != IPV6_SCOPE_DELIMITER) | ||
740 | return; | ||
741 | |||
742 | len = (string + str_len) - delim - 1; | ||
743 | p = kstrndup(delim + 1, len, GFP_KERNEL); | ||
744 | if (p) { | ||
745 | unsigned long scope_id = 0; | ||
746 | struct net_device *dev; | ||
747 | |||
748 | dev = dev_get_by_name(&init_net, p); | ||
749 | if (dev != NULL) { | ||
750 | scope_id = dev->ifindex; | ||
751 | dev_put(dev); | ||
752 | } else { | ||
753 | /* scope_id is set to zero on error */ | ||
754 | strict_strtoul(p, 10, &scope_id); | ||
755 | } | ||
756 | |||
757 | kfree(p); | ||
758 | sin6->sin6_scope_id = scope_id; | ||
759 | dfprintk(MOUNT, "NFS: IPv6 scope ID = %lu\n", scope_id); | ||
760 | } | ||
761 | } | ||
762 | |||
763 | static void nfs_parse_ipv6_address(char *string, size_t str_len, | ||
764 | struct sockaddr *sap, size_t *addr_len) | ||
765 | { | ||
766 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | ||
767 | u8 *addr = (u8 *)&sin6->sin6_addr.in6_u; | ||
768 | const char *delim; | ||
769 | |||
770 | if (str_len <= INET6_ADDRSTRLEN) { | ||
771 | dfprintk(MOUNT, "NFS: parsing IPv6 address %*s\n", | ||
772 | (int)str_len, string); | ||
773 | |||
774 | sin6->sin6_family = AF_INET6; | ||
775 | *addr_len = sizeof(*sin6); | ||
776 | if (in6_pton(string, str_len, addr, IPV6_SCOPE_DELIMITER, &delim)) { | ||
777 | nfs_parse_ipv6_scope_id(string, str_len, delim, sin6); | ||
778 | return; | ||
779 | } | ||
780 | } | ||
781 | |||
782 | sap->sa_family = AF_UNSPEC; | ||
783 | *addr_len = 0; | ||
784 | } | ||
785 | #else | ||
786 | static void nfs_parse_ipv6_address(char *string, size_t str_len, | ||
787 | struct sockaddr *sap, size_t *addr_len) | ||
788 | { | ||
789 | sap->sa_family = AF_UNSPEC; | ||
790 | *addr_len = 0; | ||
791 | } | ||
792 | #endif | ||
793 | |||
705 | /* | 794 | /* |
706 | * Parse string addresses passed in via a mount option, | 795 | * Construct a sockaddr based on the contents of a string that contains |
707 | * and construct a sockaddr based on the result. | 796 | * an IP address in presentation format. |
708 | * | 797 | * |
709 | * If address parsing fails, set the sockaddr's address | 798 | * If there is a problem constructing the new sockaddr, set the address |
710 | * family to AF_UNSPEC to force nfs_verify_server_address() | 799 | * family to AF_UNSPEC. |
711 | * to punt the mount. | ||
712 | */ | 800 | */ |
713 | static void nfs_parse_server_address(char *value, | 801 | static void nfs_parse_ip_address(char *string, size_t str_len, |
714 | struct sockaddr *sap, | 802 | struct sockaddr *sap, size_t *addr_len) |
715 | size_t *len) | ||
716 | { | 803 | { |
717 | if (strchr(value, ':')) { | 804 | unsigned int i, colons; |
718 | struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap; | ||
719 | u8 *addr = (u8 *)&ap->sin6_addr.in6_u; | ||
720 | 805 | ||
721 | ap->sin6_family = AF_INET6; | 806 | colons = 0; |
722 | *len = sizeof(*ap); | 807 | for (i = 0; i < str_len; i++) |
723 | if (in6_pton(value, -1, addr, '\0', NULL)) | 808 | if (string[i] == ':') |
724 | return; | 809 | colons++; |
725 | } else { | 810 | |
726 | struct sockaddr_in *ap = (struct sockaddr_in *)sap; | 811 | if (colons >= 2) |
727 | u8 *addr = (u8 *)&ap->sin_addr.s_addr; | 812 | nfs_parse_ipv6_address(string, str_len, sap, addr_len); |
813 | else | ||
814 | nfs_parse_ipv4_address(string, str_len, sap, addr_len); | ||
815 | } | ||
816 | |||
817 | /* | ||
818 | * Sanity check the NFS transport protocol. | ||
819 | * | ||
820 | */ | ||
821 | static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt) | ||
822 | { | ||
823 | switch (mnt->nfs_server.protocol) { | ||
824 | case XPRT_TRANSPORT_UDP: | ||
825 | case XPRT_TRANSPORT_TCP: | ||
826 | case XPRT_TRANSPORT_RDMA: | ||
827 | break; | ||
828 | default: | ||
829 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | ||
830 | } | ||
831 | } | ||
832 | |||
833 | /* | ||
834 | * For text based NFSv2/v3 mounts, the mount protocol transport default | ||
835 | * settings should depend upon the specified NFS transport. | ||
836 | */ | ||
837 | static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt) | ||
838 | { | ||
839 | nfs_validate_transport_protocol(mnt); | ||
728 | 840 | ||
729 | ap->sin_family = AF_INET; | 841 | if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP || |
730 | *len = sizeof(*ap); | 842 | mnt->mount_server.protocol == XPRT_TRANSPORT_TCP) |
731 | if (in4_pton(value, -1, addr, '\0', NULL)) | ||
732 | return; | 843 | return; |
844 | switch (mnt->nfs_server.protocol) { | ||
845 | case XPRT_TRANSPORT_UDP: | ||
846 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; | ||
847 | break; | ||
848 | case XPRT_TRANSPORT_TCP: | ||
849 | case XPRT_TRANSPORT_RDMA: | ||
850 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; | ||
733 | } | 851 | } |
852 | } | ||
734 | 853 | ||
735 | sap->sa_family = AF_UNSPEC; | 854 | /* |
736 | *len = 0; | 855 | * Parse the value of the 'sec=' option. |
856 | * | ||
857 | * The flavor_len setting is for v4 mounts. | ||
858 | */ | ||
859 | static int nfs_parse_security_flavors(char *value, | ||
860 | struct nfs_parsed_mount_data *mnt) | ||
861 | { | ||
862 | substring_t args[MAX_OPT_ARGS]; | ||
863 | |||
864 | dfprintk(MOUNT, "NFS: parsing sec=%s option\n", value); | ||
865 | |||
866 | switch (match_token(value, nfs_secflavor_tokens, args)) { | ||
867 | case Opt_sec_none: | ||
868 | mnt->auth_flavor_len = 0; | ||
869 | mnt->auth_flavors[0] = RPC_AUTH_NULL; | ||
870 | break; | ||
871 | case Opt_sec_sys: | ||
872 | mnt->auth_flavor_len = 0; | ||
873 | mnt->auth_flavors[0] = RPC_AUTH_UNIX; | ||
874 | break; | ||
875 | case Opt_sec_krb5: | ||
876 | mnt->auth_flavor_len = 1; | ||
877 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5; | ||
878 | break; | ||
879 | case Opt_sec_krb5i: | ||
880 | mnt->auth_flavor_len = 1; | ||
881 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I; | ||
882 | break; | ||
883 | case Opt_sec_krb5p: | ||
884 | mnt->auth_flavor_len = 1; | ||
885 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P; | ||
886 | break; | ||
887 | case Opt_sec_lkey: | ||
888 | mnt->auth_flavor_len = 1; | ||
889 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY; | ||
890 | break; | ||
891 | case Opt_sec_lkeyi: | ||
892 | mnt->auth_flavor_len = 1; | ||
893 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI; | ||
894 | break; | ||
895 | case Opt_sec_lkeyp: | ||
896 | mnt->auth_flavor_len = 1; | ||
897 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP; | ||
898 | break; | ||
899 | case Opt_sec_spkm: | ||
900 | mnt->auth_flavor_len = 1; | ||
901 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM; | ||
902 | break; | ||
903 | case Opt_sec_spkmi: | ||
904 | mnt->auth_flavor_len = 1; | ||
905 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI; | ||
906 | break; | ||
907 | case Opt_sec_spkmp: | ||
908 | mnt->auth_flavor_len = 1; | ||
909 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP; | ||
910 | break; | ||
911 | default: | ||
912 | return 0; | ||
913 | } | ||
914 | |||
915 | return 1; | ||
916 | } | ||
917 | |||
918 | static void nfs_parse_invalid_value(const char *option) | ||
919 | { | ||
920 | dfprintk(MOUNT, "NFS: bad value specified for %s option\n", option); | ||
737 | } | 921 | } |
738 | 922 | ||
739 | /* | 923 | /* |
740 | * Error-check and convert a string of mount options from user space into | 924 | * Error-check and convert a string of mount options from user space into |
741 | * a data structure | 925 | * a data structure. The whole mount string is processed; bad options are |
926 | * skipped as they are encountered. If there were no errors, return 1; | ||
927 | * otherwise return 0 (zero). | ||
742 | */ | 928 | */ |
743 | static int nfs_parse_mount_options(char *raw, | 929 | static int nfs_parse_mount_options(char *raw, |
744 | struct nfs_parsed_mount_data *mnt) | 930 | struct nfs_parsed_mount_data *mnt) |
745 | { | 931 | { |
746 | char *p, *string, *secdata; | 932 | char *p, *string, *secdata; |
747 | int rc; | 933 | int rc, sloppy = 0, errors = 0; |
748 | 934 | ||
749 | if (!raw) { | 935 | if (!raw) { |
750 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); | 936 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); |
@@ -777,15 +963,16 @@ static int nfs_parse_mount_options(char *raw, | |||
777 | 963 | ||
778 | token = match_token(p, nfs_mount_option_tokens, args); | 964 | token = match_token(p, nfs_mount_option_tokens, args); |
779 | switch (token) { | 965 | switch (token) { |
966 | |||
967 | /* | ||
968 | * boolean options: foo/nofoo | ||
969 | */ | ||
780 | case Opt_soft: | 970 | case Opt_soft: |
781 | mnt->flags |= NFS_MOUNT_SOFT; | 971 | mnt->flags |= NFS_MOUNT_SOFT; |
782 | break; | 972 | break; |
783 | case Opt_hard: | 973 | case Opt_hard: |
784 | mnt->flags &= ~NFS_MOUNT_SOFT; | 974 | mnt->flags &= ~NFS_MOUNT_SOFT; |
785 | break; | 975 | break; |
786 | case Opt_intr: | ||
787 | case Opt_nointr: | ||
788 | break; | ||
789 | case Opt_posix: | 976 | case Opt_posix: |
790 | mnt->flags |= NFS_MOUNT_POSIX; | 977 | mnt->flags |= NFS_MOUNT_POSIX; |
791 | break; | 978 | break; |
@@ -819,20 +1006,14 @@ static int nfs_parse_mount_options(char *raw, | |||
819 | case Opt_udp: | 1006 | case Opt_udp: |
820 | mnt->flags &= ~NFS_MOUNT_TCP; | 1007 | mnt->flags &= ~NFS_MOUNT_TCP; |
821 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; | 1008 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
822 | mnt->timeo = 7; | ||
823 | mnt->retrans = 5; | ||
824 | break; | 1009 | break; |
825 | case Opt_tcp: | 1010 | case Opt_tcp: |
826 | mnt->flags |= NFS_MOUNT_TCP; | 1011 | mnt->flags |= NFS_MOUNT_TCP; |
827 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1012 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
828 | mnt->timeo = 600; | ||
829 | mnt->retrans = 2; | ||
830 | break; | 1013 | break; |
831 | case Opt_rdma: | 1014 | case Opt_rdma: |
832 | mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */ | 1015 | mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */ |
833 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | 1016 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; |
834 | mnt->timeo = 600; | ||
835 | mnt->retrans = 2; | ||
836 | break; | 1017 | break; |
837 | case Opt_acl: | 1018 | case Opt_acl: |
838 | mnt->flags &= ~NFS_MOUNT_NOACL; | 1019 | mnt->flags &= ~NFS_MOUNT_NOACL; |
@@ -853,165 +1034,144 @@ static int nfs_parse_mount_options(char *raw, | |||
853 | mnt->flags |= NFS_MOUNT_UNSHARED; | 1034 | mnt->flags |= NFS_MOUNT_UNSHARED; |
854 | break; | 1035 | break; |
855 | 1036 | ||
1037 | /* | ||
1038 | * options that take numeric values | ||
1039 | */ | ||
856 | case Opt_port: | 1040 | case Opt_port: |
857 | if (match_int(args, &option)) | 1041 | if (match_int(args, &option) || |
858 | return 0; | 1042 | option < 0 || option > USHORT_MAX) { |
859 | if (option < 0 || option > 65535) | 1043 | errors++; |
860 | return 0; | 1044 | nfs_parse_invalid_value("port"); |
861 | mnt->nfs_server.port = option; | 1045 | } else |
1046 | mnt->nfs_server.port = option; | ||
862 | break; | 1047 | break; |
863 | case Opt_rsize: | 1048 | case Opt_rsize: |
864 | if (match_int(args, &mnt->rsize)) | 1049 | if (match_int(args, &option) || option < 0) { |
865 | return 0; | 1050 | errors++; |
1051 | nfs_parse_invalid_value("rsize"); | ||
1052 | } else | ||
1053 | mnt->rsize = option; | ||
866 | break; | 1054 | break; |
867 | case Opt_wsize: | 1055 | case Opt_wsize: |
868 | if (match_int(args, &mnt->wsize)) | 1056 | if (match_int(args, &option) || option < 0) { |
869 | return 0; | 1057 | errors++; |
1058 | nfs_parse_invalid_value("wsize"); | ||
1059 | } else | ||
1060 | mnt->wsize = option; | ||
870 | break; | 1061 | break; |
871 | case Opt_bsize: | 1062 | case Opt_bsize: |
872 | if (match_int(args, &option)) | 1063 | if (match_int(args, &option) || option < 0) { |
873 | return 0; | 1064 | errors++; |
874 | if (option < 0) | 1065 | nfs_parse_invalid_value("bsize"); |
875 | return 0; | 1066 | } else |
876 | mnt->bsize = option; | 1067 | mnt->bsize = option; |
877 | break; | 1068 | break; |
878 | case Opt_timeo: | 1069 | case Opt_timeo: |
879 | if (match_int(args, &mnt->timeo)) | 1070 | if (match_int(args, &option) || option <= 0) { |
880 | return 0; | 1071 | errors++; |
1072 | nfs_parse_invalid_value("timeo"); | ||
1073 | } else | ||
1074 | mnt->timeo = option; | ||
881 | break; | 1075 | break; |
882 | case Opt_retrans: | 1076 | case Opt_retrans: |
883 | if (match_int(args, &mnt->retrans)) | 1077 | if (match_int(args, &option) || option <= 0) { |
884 | return 0; | 1078 | errors++; |
1079 | nfs_parse_invalid_value("retrans"); | ||
1080 | } else | ||
1081 | mnt->retrans = option; | ||
885 | break; | 1082 | break; |
886 | case Opt_acregmin: | 1083 | case Opt_acregmin: |
887 | if (match_int(args, &mnt->acregmin)) | 1084 | if (match_int(args, &option) || option < 0) { |
888 | return 0; | 1085 | errors++; |
1086 | nfs_parse_invalid_value("acregmin"); | ||
1087 | } else | ||
1088 | mnt->acregmin = option; | ||
889 | break; | 1089 | break; |
890 | case Opt_acregmax: | 1090 | case Opt_acregmax: |
891 | if (match_int(args, &mnt->acregmax)) | 1091 | if (match_int(args, &option) || option < 0) { |
892 | return 0; | 1092 | errors++; |
1093 | nfs_parse_invalid_value("acregmax"); | ||
1094 | } else | ||
1095 | mnt->acregmax = option; | ||
893 | break; | 1096 | break; |
894 | case Opt_acdirmin: | 1097 | case Opt_acdirmin: |
895 | if (match_int(args, &mnt->acdirmin)) | 1098 | if (match_int(args, &option) || option < 0) { |
896 | return 0; | 1099 | errors++; |
1100 | nfs_parse_invalid_value("acdirmin"); | ||
1101 | } else | ||
1102 | mnt->acdirmin = option; | ||
897 | break; | 1103 | break; |
898 | case Opt_acdirmax: | 1104 | case Opt_acdirmax: |
899 | if (match_int(args, &mnt->acdirmax)) | 1105 | if (match_int(args, &option) || option < 0) { |
900 | return 0; | 1106 | errors++; |
1107 | nfs_parse_invalid_value("acdirmax"); | ||
1108 | } else | ||
1109 | mnt->acdirmax = option; | ||
901 | break; | 1110 | break; |
902 | case Opt_actimeo: | 1111 | case Opt_actimeo: |
903 | if (match_int(args, &option)) | 1112 | if (match_int(args, &option) || option < 0) { |
904 | return 0; | 1113 | errors++; |
905 | if (option < 0) | 1114 | nfs_parse_invalid_value("actimeo"); |
906 | return 0; | 1115 | } else |
907 | mnt->acregmin = | 1116 | mnt->acregmin = mnt->acregmax = |
908 | mnt->acregmax = | 1117 | mnt->acdirmin = mnt->acdirmax = option; |
909 | mnt->acdirmin = | ||
910 | mnt->acdirmax = option; | ||
911 | break; | 1118 | break; |
912 | case Opt_namelen: | 1119 | case Opt_namelen: |
913 | if (match_int(args, &mnt->namlen)) | 1120 | if (match_int(args, &option) || option < 0) { |
914 | return 0; | 1121 | errors++; |
1122 | nfs_parse_invalid_value("namlen"); | ||
1123 | } else | ||
1124 | mnt->namlen = option; | ||
915 | break; | 1125 | break; |
916 | case Opt_mountport: | 1126 | case Opt_mountport: |
917 | if (match_int(args, &option)) | 1127 | if (match_int(args, &option) || |
918 | return 0; | 1128 | option < 0 || option > USHORT_MAX) { |
919 | if (option < 0 || option > 65535) | 1129 | errors++; |
920 | return 0; | 1130 | nfs_parse_invalid_value("mountport"); |
921 | mnt->mount_server.port = option; | 1131 | } else |
1132 | mnt->mount_server.port = option; | ||
922 | break; | 1133 | break; |
923 | case Opt_mountvers: | 1134 | case Opt_mountvers: |
924 | if (match_int(args, &option)) | 1135 | if (match_int(args, &option) || |
925 | return 0; | 1136 | option < NFS_MNT_VERSION || |
926 | if (option < 0) | 1137 | option > NFS_MNT3_VERSION) { |
927 | return 0; | 1138 | errors++; |
928 | mnt->mount_server.version = option; | 1139 | nfs_parse_invalid_value("mountvers"); |
1140 | } else | ||
1141 | mnt->mount_server.version = option; | ||
929 | break; | 1142 | break; |
930 | case Opt_nfsvers: | 1143 | case Opt_nfsvers: |
931 | if (match_int(args, &option)) | 1144 | if (match_int(args, &option)) { |
932 | return 0; | 1145 | errors++; |
1146 | nfs_parse_invalid_value("nfsvers"); | ||
1147 | break; | ||
1148 | } | ||
933 | switch (option) { | 1149 | switch (option) { |
934 | case 2: | 1150 | case NFS2_VERSION: |
935 | mnt->flags &= ~NFS_MOUNT_VER3; | 1151 | mnt->flags &= ~NFS_MOUNT_VER3; |
936 | break; | 1152 | break; |
937 | case 3: | 1153 | case NFS3_VERSION: |
938 | mnt->flags |= NFS_MOUNT_VER3; | 1154 | mnt->flags |= NFS_MOUNT_VER3; |
939 | break; | 1155 | break; |
940 | default: | 1156 | default: |
941 | goto out_unrec_vers; | 1157 | errors++; |
1158 | nfs_parse_invalid_value("nfsvers"); | ||
942 | } | 1159 | } |
943 | break; | 1160 | break; |
944 | 1161 | ||
1162 | /* | ||
1163 | * options that take text values | ||
1164 | */ | ||
945 | case Opt_sec: | 1165 | case Opt_sec: |
946 | string = match_strdup(args); | 1166 | string = match_strdup(args); |
947 | if (string == NULL) | 1167 | if (string == NULL) |
948 | goto out_nomem; | 1168 | goto out_nomem; |
949 | token = match_token(string, nfs_secflavor_tokens, args); | 1169 | rc = nfs_parse_security_flavors(string, mnt); |
950 | kfree(string); | 1170 | kfree(string); |
951 | 1171 | if (!rc) { | |
952 | /* | 1172 | errors++; |
953 | * The flags setting is for v2/v3. The flavor_len | 1173 | dfprintk(MOUNT, "NFS: unrecognized " |
954 | * setting is for v4. v2/v3 also need to know the | 1174 | "security flavor\n"); |
955 | * difference between NULL and UNIX. | ||
956 | */ | ||
957 | switch (token) { | ||
958 | case Opt_sec_none: | ||
959 | mnt->flags &= ~NFS_MOUNT_SECFLAVOUR; | ||
960 | mnt->auth_flavor_len = 0; | ||
961 | mnt->auth_flavors[0] = RPC_AUTH_NULL; | ||
962 | break; | ||
963 | case Opt_sec_sys: | ||
964 | mnt->flags &= ~NFS_MOUNT_SECFLAVOUR; | ||
965 | mnt->auth_flavor_len = 0; | ||
966 | mnt->auth_flavors[0] = RPC_AUTH_UNIX; | ||
967 | break; | ||
968 | case Opt_sec_krb5: | ||
969 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
970 | mnt->auth_flavor_len = 1; | ||
971 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5; | ||
972 | break; | ||
973 | case Opt_sec_krb5i: | ||
974 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
975 | mnt->auth_flavor_len = 1; | ||
976 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I; | ||
977 | break; | ||
978 | case Opt_sec_krb5p: | ||
979 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
980 | mnt->auth_flavor_len = 1; | ||
981 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P; | ||
982 | break; | ||
983 | case Opt_sec_lkey: | ||
984 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
985 | mnt->auth_flavor_len = 1; | ||
986 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY; | ||
987 | break; | ||
988 | case Opt_sec_lkeyi: | ||
989 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
990 | mnt->auth_flavor_len = 1; | ||
991 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI; | ||
992 | break; | ||
993 | case Opt_sec_lkeyp: | ||
994 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
995 | mnt->auth_flavor_len = 1; | ||
996 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP; | ||
997 | break; | ||
998 | case Opt_sec_spkm: | ||
999 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
1000 | mnt->auth_flavor_len = 1; | ||
1001 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM; | ||
1002 | break; | ||
1003 | case Opt_sec_spkmi: | ||
1004 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
1005 | mnt->auth_flavor_len = 1; | ||
1006 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI; | ||
1007 | break; | ||
1008 | case Opt_sec_spkmp: | ||
1009 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
1010 | mnt->auth_flavor_len = 1; | ||
1011 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP; | ||
1012 | break; | ||
1013 | default: | ||
1014 | goto out_unrec_sec; | ||
1015 | } | 1175 | } |
1016 | break; | 1176 | break; |
1017 | case Opt_proto: | 1177 | case Opt_proto: |
@@ -1026,24 +1186,20 @@ static int nfs_parse_mount_options(char *raw, | |||
1026 | case Opt_xprt_udp: | 1186 | case Opt_xprt_udp: |
1027 | mnt->flags &= ~NFS_MOUNT_TCP; | 1187 | mnt->flags &= ~NFS_MOUNT_TCP; |
1028 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; | 1188 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
1029 | mnt->timeo = 7; | ||
1030 | mnt->retrans = 5; | ||
1031 | break; | 1189 | break; |
1032 | case Opt_xprt_tcp: | 1190 | case Opt_xprt_tcp: |
1033 | mnt->flags |= NFS_MOUNT_TCP; | 1191 | mnt->flags |= NFS_MOUNT_TCP; |
1034 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1192 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
1035 | mnt->timeo = 600; | ||
1036 | mnt->retrans = 2; | ||
1037 | break; | 1193 | break; |
1038 | case Opt_xprt_rdma: | 1194 | case Opt_xprt_rdma: |
1039 | /* vector side protocols to TCP */ | 1195 | /* vector side protocols to TCP */ |
1040 | mnt->flags |= NFS_MOUNT_TCP; | 1196 | mnt->flags |= NFS_MOUNT_TCP; |
1041 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | 1197 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; |
1042 | mnt->timeo = 600; | ||
1043 | mnt->retrans = 2; | ||
1044 | break; | 1198 | break; |
1045 | default: | 1199 | default: |
1046 | goto out_unrec_xprt; | 1200 | errors++; |
1201 | dfprintk(MOUNT, "NFS: unrecognized " | ||
1202 | "transport protocol\n"); | ||
1047 | } | 1203 | } |
1048 | break; | 1204 | break; |
1049 | case Opt_mountproto: | 1205 | case Opt_mountproto: |
@@ -1063,16 +1219,19 @@ static int nfs_parse_mount_options(char *raw, | |||
1063 | break; | 1219 | break; |
1064 | case Opt_xprt_rdma: /* not used for side protocols */ | 1220 | case Opt_xprt_rdma: /* not used for side protocols */ |
1065 | default: | 1221 | default: |
1066 | goto out_unrec_xprt; | 1222 | errors++; |
1223 | dfprintk(MOUNT, "NFS: unrecognized " | ||
1224 | "transport protocol\n"); | ||
1067 | } | 1225 | } |
1068 | break; | 1226 | break; |
1069 | case Opt_addr: | 1227 | case Opt_addr: |
1070 | string = match_strdup(args); | 1228 | string = match_strdup(args); |
1071 | if (string == NULL) | 1229 | if (string == NULL) |
1072 | goto out_nomem; | 1230 | goto out_nomem; |
1073 | nfs_parse_server_address(string, (struct sockaddr *) | 1231 | nfs_parse_ip_address(string, strlen(string), |
1074 | &mnt->nfs_server.address, | 1232 | (struct sockaddr *) |
1075 | &mnt->nfs_server.addrlen); | 1233 | &mnt->nfs_server.address, |
1234 | &mnt->nfs_server.addrlen); | ||
1076 | kfree(string); | 1235 | kfree(string); |
1077 | break; | 1236 | break; |
1078 | case Opt_clientaddr: | 1237 | case Opt_clientaddr: |
@@ -1093,24 +1252,33 @@ static int nfs_parse_mount_options(char *raw, | |||
1093 | string = match_strdup(args); | 1252 | string = match_strdup(args); |
1094 | if (string == NULL) | 1253 | if (string == NULL) |
1095 | goto out_nomem; | 1254 | goto out_nomem; |
1096 | nfs_parse_server_address(string, (struct sockaddr *) | 1255 | nfs_parse_ip_address(string, strlen(string), |
1097 | &mnt->mount_server.address, | 1256 | (struct sockaddr *) |
1098 | &mnt->mount_server.addrlen); | 1257 | &mnt->mount_server.address, |
1258 | &mnt->mount_server.addrlen); | ||
1099 | kfree(string); | 1259 | kfree(string); |
1100 | break; | 1260 | break; |
1101 | 1261 | ||
1262 | /* | ||
1263 | * Special options | ||
1264 | */ | ||
1265 | case Opt_sloppy: | ||
1266 | sloppy = 1; | ||
1267 | dfprintk(MOUNT, "NFS: relaxing parsing rules\n"); | ||
1268 | break; | ||
1102 | case Opt_userspace: | 1269 | case Opt_userspace: |
1103 | case Opt_deprecated: | 1270 | case Opt_deprecated: |
1271 | dfprintk(MOUNT, "NFS: ignoring mount option " | ||
1272 | "'%s'\n", p); | ||
1104 | break; | 1273 | break; |
1105 | 1274 | ||
1106 | default: | 1275 | default: |
1107 | goto out_unknown; | 1276 | errors++; |
1277 | dfprintk(MOUNT, "NFS: unrecognized mount option " | ||
1278 | "'%s'\n", p); | ||
1108 | } | 1279 | } |
1109 | } | 1280 | } |
1110 | 1281 | ||
1111 | nfs_set_port((struct sockaddr *)&mnt->nfs_server.address, | ||
1112 | mnt->nfs_server.port); | ||
1113 | |||
1114 | return 1; | 1282 | return 1; |
1115 | 1283 | ||
1116 | out_nomem: | 1284 | out_nomem: |
@@ -1120,21 +1288,6 @@ out_security_failure: | |||
1120 | free_secdata(secdata); | 1288 | free_secdata(secdata); |
1121 | printk(KERN_INFO "NFS: security options invalid: %d\n", rc); | 1289 | printk(KERN_INFO "NFS: security options invalid: %d\n", rc); |
1122 | return 0; | 1290 | return 0; |
1123 | out_unrec_vers: | ||
1124 | printk(KERN_INFO "NFS: unrecognized NFS version number\n"); | ||
1125 | return 0; | ||
1126 | |||
1127 | out_unrec_xprt: | ||
1128 | printk(KERN_INFO "NFS: unrecognized transport protocol\n"); | ||
1129 | return 0; | ||
1130 | |||
1131 | out_unrec_sec: | ||
1132 | printk(KERN_INFO "NFS: unrecognized security flavor\n"); | ||
1133 | return 0; | ||
1134 | |||
1135 | out_unknown: | ||
1136 | printk(KERN_INFO "NFS: unknown mount option: %s\n", p); | ||
1137 | return 0; | ||
1138 | } | 1291 | } |
1139 | 1292 | ||
1140 | /* | 1293 | /* |
@@ -1188,11 +1341,146 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args, | |||
1188 | if (status == 0) | 1341 | if (status == 0) |
1189 | return 0; | 1342 | return 0; |
1190 | 1343 | ||
1191 | dfprintk(MOUNT, "NFS: unable to mount server %s, error %d", | 1344 | dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n", |
1192 | hostname, status); | 1345 | hostname, status); |
1193 | return status; | 1346 | return status; |
1194 | } | 1347 | } |
1195 | 1348 | ||
1349 | static int nfs_parse_simple_hostname(const char *dev_name, | ||
1350 | char **hostname, size_t maxnamlen, | ||
1351 | char **export_path, size_t maxpathlen) | ||
1352 | { | ||
1353 | size_t len; | ||
1354 | char *colon, *comma; | ||
1355 | |||
1356 | colon = strchr(dev_name, ':'); | ||
1357 | if (colon == NULL) | ||
1358 | goto out_bad_devname; | ||
1359 | |||
1360 | len = colon - dev_name; | ||
1361 | if (len > maxnamlen) | ||
1362 | goto out_hostname; | ||
1363 | |||
1364 | /* N.B. caller will free nfs_server.hostname in all cases */ | ||
1365 | *hostname = kstrndup(dev_name, len, GFP_KERNEL); | ||
1366 | if (!*hostname) | ||
1367 | goto out_nomem; | ||
1368 | |||
1369 | /* kill possible hostname list: not supported */ | ||
1370 | comma = strchr(*hostname, ','); | ||
1371 | if (comma != NULL) { | ||
1372 | if (comma == *hostname) | ||
1373 | goto out_bad_devname; | ||
1374 | *comma = '\0'; | ||
1375 | } | ||
1376 | |||
1377 | colon++; | ||
1378 | len = strlen(colon); | ||
1379 | if (len > maxpathlen) | ||
1380 | goto out_path; | ||
1381 | *export_path = kstrndup(colon, len, GFP_KERNEL); | ||
1382 | if (!*export_path) | ||
1383 | goto out_nomem; | ||
1384 | |||
1385 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", *export_path); | ||
1386 | return 0; | ||
1387 | |||
1388 | out_bad_devname: | ||
1389 | dfprintk(MOUNT, "NFS: device name not in host:path format\n"); | ||
1390 | return -EINVAL; | ||
1391 | |||
1392 | out_nomem: | ||
1393 | dfprintk(MOUNT, "NFS: not enough memory to parse device name\n"); | ||
1394 | return -ENOMEM; | ||
1395 | |||
1396 | out_hostname: | ||
1397 | dfprintk(MOUNT, "NFS: server hostname too long\n"); | ||
1398 | return -ENAMETOOLONG; | ||
1399 | |||
1400 | out_path: | ||
1401 | dfprintk(MOUNT, "NFS: export pathname too long\n"); | ||
1402 | return -ENAMETOOLONG; | ||
1403 | } | ||
1404 | |||
1405 | /* | ||
1406 | * Hostname has square brackets around it because it contains one or | ||
1407 | * more colons. We look for the first closing square bracket, and a | ||
1408 | * colon must follow it. | ||
1409 | */ | ||
1410 | static int nfs_parse_protected_hostname(const char *dev_name, | ||
1411 | char **hostname, size_t maxnamlen, | ||
1412 | char **export_path, size_t maxpathlen) | ||
1413 | { | ||
1414 | size_t len; | ||
1415 | char *start, *end; | ||
1416 | |||
1417 | start = (char *)(dev_name + 1); | ||
1418 | |||
1419 | end = strchr(start, ']'); | ||
1420 | if (end == NULL) | ||
1421 | goto out_bad_devname; | ||
1422 | if (*(end + 1) != ':') | ||
1423 | goto out_bad_devname; | ||
1424 | |||
1425 | len = end - start; | ||
1426 | if (len > maxnamlen) | ||
1427 | goto out_hostname; | ||
1428 | |||
1429 | /* N.B. caller will free nfs_server.hostname in all cases */ | ||
1430 | *hostname = kstrndup(start, len, GFP_KERNEL); | ||
1431 | if (*hostname == NULL) | ||
1432 | goto out_nomem; | ||
1433 | |||
1434 | end += 2; | ||
1435 | len = strlen(end); | ||
1436 | if (len > maxpathlen) | ||
1437 | goto out_path; | ||
1438 | *export_path = kstrndup(end, len, GFP_KERNEL); | ||
1439 | if (!*export_path) | ||
1440 | goto out_nomem; | ||
1441 | |||
1442 | return 0; | ||
1443 | |||
1444 | out_bad_devname: | ||
1445 | dfprintk(MOUNT, "NFS: device name not in host:path format\n"); | ||
1446 | return -EINVAL; | ||
1447 | |||
1448 | out_nomem: | ||
1449 | dfprintk(MOUNT, "NFS: not enough memory to parse device name\n"); | ||
1450 | return -ENOMEM; | ||
1451 | |||
1452 | out_hostname: | ||
1453 | dfprintk(MOUNT, "NFS: server hostname too long\n"); | ||
1454 | return -ENAMETOOLONG; | ||
1455 | |||
1456 | out_path: | ||
1457 | dfprintk(MOUNT, "NFS: export pathname too long\n"); | ||
1458 | return -ENAMETOOLONG; | ||
1459 | } | ||
1460 | |||
1461 | /* | ||
1462 | * Split "dev_name" into "hostname:export_path". | ||
1463 | * | ||
1464 | * The leftmost colon demarks the split between the server's hostname | ||
1465 | * and the export path. If the hostname starts with a left square | ||
1466 | * bracket, then it may contain colons. | ||
1467 | * | ||
1468 | * Note: caller frees hostname and export path, even on error. | ||
1469 | */ | ||
1470 | static int nfs_parse_devname(const char *dev_name, | ||
1471 | char **hostname, size_t maxnamlen, | ||
1472 | char **export_path, size_t maxpathlen) | ||
1473 | { | ||
1474 | if (*dev_name == '[') | ||
1475 | return nfs_parse_protected_hostname(dev_name, | ||
1476 | hostname, maxnamlen, | ||
1477 | export_path, maxpathlen); | ||
1478 | |||
1479 | return nfs_parse_simple_hostname(dev_name, | ||
1480 | hostname, maxnamlen, | ||
1481 | export_path, maxpathlen); | ||
1482 | } | ||
1483 | |||
1196 | /* | 1484 | /* |
1197 | * Validate the NFS2/NFS3 mount data | 1485 | * Validate the NFS2/NFS3 mount data |
1198 | * - fills in the mount root filehandle | 1486 | * - fills in the mount root filehandle |
@@ -1222,16 +1510,14 @@ static int nfs_validate_mount_data(void *options, | |||
1222 | args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP); | 1510 | args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP); |
1223 | args->rsize = NFS_MAX_FILE_IO_SIZE; | 1511 | args->rsize = NFS_MAX_FILE_IO_SIZE; |
1224 | args->wsize = NFS_MAX_FILE_IO_SIZE; | 1512 | args->wsize = NFS_MAX_FILE_IO_SIZE; |
1225 | args->timeo = 600; | 1513 | args->acregmin = NFS_DEF_ACREGMIN; |
1226 | args->retrans = 2; | 1514 | args->acregmax = NFS_DEF_ACREGMAX; |
1227 | args->acregmin = 3; | 1515 | args->acdirmin = NFS_DEF_ACDIRMIN; |
1228 | args->acregmax = 60; | 1516 | args->acdirmax = NFS_DEF_ACDIRMAX; |
1229 | args->acdirmin = 30; | ||
1230 | args->acdirmax = 60; | ||
1231 | args->mount_server.port = 0; /* autobind unless user sets port */ | 1517 | args->mount_server.port = 0; /* autobind unless user sets port */ |
1232 | args->mount_server.protocol = XPRT_TRANSPORT_UDP; | ||
1233 | args->nfs_server.port = 0; /* autobind unless user sets port */ | 1518 | args->nfs_server.port = 0; /* autobind unless user sets port */ |
1234 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1519 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
1520 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
1235 | 1521 | ||
1236 | switch (data->version) { | 1522 | switch (data->version) { |
1237 | case 1: | 1523 | case 1: |
@@ -1289,7 +1575,9 @@ static int nfs_validate_mount_data(void *options, | |||
1289 | args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL); | 1575 | args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL); |
1290 | args->namlen = data->namlen; | 1576 | args->namlen = data->namlen; |
1291 | args->bsize = data->bsize; | 1577 | args->bsize = data->bsize; |
1292 | args->auth_flavors[0] = data->pseudoflavor; | 1578 | |
1579 | if (data->flags & NFS_MOUNT_SECFLAVOUR) | ||
1580 | args->auth_flavors[0] = data->pseudoflavor; | ||
1293 | if (!args->nfs_server.hostname) | 1581 | if (!args->nfs_server.hostname) |
1294 | goto out_nomem; | 1582 | goto out_nomem; |
1295 | 1583 | ||
@@ -1321,8 +1609,6 @@ static int nfs_validate_mount_data(void *options, | |||
1321 | 1609 | ||
1322 | break; | 1610 | break; |
1323 | default: { | 1611 | default: { |
1324 | unsigned int len; | ||
1325 | char *c; | ||
1326 | int status; | 1612 | int status; |
1327 | 1613 | ||
1328 | if (nfs_parse_mount_options((char *)options, args) == 0) | 1614 | if (nfs_parse_mount_options((char *)options, args) == 0) |
@@ -1332,21 +1618,22 @@ static int nfs_validate_mount_data(void *options, | |||
1332 | &args->nfs_server.address)) | 1618 | &args->nfs_server.address)) |
1333 | goto out_no_address; | 1619 | goto out_no_address; |
1334 | 1620 | ||
1335 | c = strchr(dev_name, ':'); | 1621 | nfs_set_port((struct sockaddr *)&args->nfs_server.address, |
1336 | if (c == NULL) | 1622 | args->nfs_server.port); |
1337 | return -EINVAL; | ||
1338 | len = c - dev_name; | ||
1339 | /* N.B. caller will free nfs_server.hostname in all cases */ | ||
1340 | args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL); | ||
1341 | if (!args->nfs_server.hostname) | ||
1342 | goto out_nomem; | ||
1343 | 1623 | ||
1344 | c++; | 1624 | nfs_set_mount_transport_protocol(args); |
1345 | if (strlen(c) > NFS_MAXPATHLEN) | 1625 | |
1346 | return -ENAMETOOLONG; | 1626 | status = nfs_parse_devname(dev_name, |
1347 | args->nfs_server.export_path = c; | 1627 | &args->nfs_server.hostname, |
1628 | PAGE_SIZE, | ||
1629 | &args->nfs_server.export_path, | ||
1630 | NFS_MAXPATHLEN); | ||
1631 | if (!status) | ||
1632 | status = nfs_try_mount(args, mntfh); | ||
1633 | |||
1634 | kfree(args->nfs_server.export_path); | ||
1635 | args->nfs_server.export_path = NULL; | ||
1348 | 1636 | ||
1349 | status = nfs_try_mount(args, mntfh); | ||
1350 | if (status) | 1637 | if (status) |
1351 | return status; | 1638 | return status; |
1352 | 1639 | ||
@@ -1354,9 +1641,6 @@ static int nfs_validate_mount_data(void *options, | |||
1354 | } | 1641 | } |
1355 | } | 1642 | } |
1356 | 1643 | ||
1357 | if (!(args->flags & NFS_MOUNT_SECFLAVOUR)) | ||
1358 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
1359 | |||
1360 | #ifndef CONFIG_NFS_V3 | 1644 | #ifndef CONFIG_NFS_V3 |
1361 | if (args->flags & NFS_MOUNT_VER3) | 1645 | if (args->flags & NFS_MOUNT_VER3) |
1362 | goto out_v3_not_compiled; | 1646 | goto out_v3_not_compiled; |
@@ -1396,6 +1680,80 @@ out_invalid_fh: | |||
1396 | return -EINVAL; | 1680 | return -EINVAL; |
1397 | } | 1681 | } |
1398 | 1682 | ||
1683 | static int | ||
1684 | nfs_compare_remount_data(struct nfs_server *nfss, | ||
1685 | struct nfs_parsed_mount_data *data) | ||
1686 | { | ||
1687 | if (data->flags != nfss->flags || | ||
1688 | data->rsize != nfss->rsize || | ||
1689 | data->wsize != nfss->wsize || | ||
1690 | data->retrans != nfss->client->cl_timeout->to_retries || | ||
1691 | data->auth_flavors[0] != nfss->client->cl_auth->au_flavor || | ||
1692 | data->acregmin != nfss->acregmin / HZ || | ||
1693 | data->acregmax != nfss->acregmax / HZ || | ||
1694 | data->acdirmin != nfss->acdirmin / HZ || | ||
1695 | data->acdirmax != nfss->acdirmax / HZ || | ||
1696 | data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) || | ||
1697 | data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen || | ||
1698 | memcmp(&data->nfs_server.address, &nfss->nfs_client->cl_addr, | ||
1699 | data->nfs_server.addrlen) != 0) | ||
1700 | return -EINVAL; | ||
1701 | |||
1702 | return 0; | ||
1703 | } | ||
1704 | |||
1705 | static int | ||
1706 | nfs_remount(struct super_block *sb, int *flags, char *raw_data) | ||
1707 | { | ||
1708 | int error; | ||
1709 | struct nfs_server *nfss = sb->s_fs_info; | ||
1710 | struct nfs_parsed_mount_data *data; | ||
1711 | struct nfs_mount_data *options = (struct nfs_mount_data *)raw_data; | ||
1712 | struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data; | ||
1713 | u32 nfsvers = nfss->nfs_client->rpc_ops->version; | ||
1714 | |||
1715 | /* | ||
1716 | * Userspace mount programs that send binary options generally send | ||
1717 | * them populated with default values. We have no way to know which | ||
1718 | * ones were explicitly specified. Fall back to legacy behavior and | ||
1719 | * just return success. | ||
1720 | */ | ||
1721 | if ((nfsvers == 4 && options4->version == 1) || | ||
1722 | (nfsvers <= 3 && options->version >= 1 && | ||
1723 | options->version <= 6)) | ||
1724 | return 0; | ||
1725 | |||
1726 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
1727 | if (data == NULL) | ||
1728 | return -ENOMEM; | ||
1729 | |||
1730 | /* fill out struct with values from existing mount */ | ||
1731 | data->flags = nfss->flags; | ||
1732 | data->rsize = nfss->rsize; | ||
1733 | data->wsize = nfss->wsize; | ||
1734 | data->retrans = nfss->client->cl_timeout->to_retries; | ||
1735 | data->auth_flavors[0] = nfss->client->cl_auth->au_flavor; | ||
1736 | data->acregmin = nfss->acregmin / HZ; | ||
1737 | data->acregmax = nfss->acregmax / HZ; | ||
1738 | data->acdirmin = nfss->acdirmin / HZ; | ||
1739 | data->acdirmax = nfss->acdirmax / HZ; | ||
1740 | data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ; | ||
1741 | data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen; | ||
1742 | memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr, | ||
1743 | data->nfs_server.addrlen); | ||
1744 | |||
1745 | /* overwrite those values with any that were specified */ | ||
1746 | error = nfs_parse_mount_options((char *)options, data); | ||
1747 | if (error < 0) | ||
1748 | goto out; | ||
1749 | |||
1750 | /* compare new mount options with old ones */ | ||
1751 | error = nfs_compare_remount_data(nfss, data); | ||
1752 | out: | ||
1753 | kfree(data); | ||
1754 | return error; | ||
1755 | } | ||
1756 | |||
1399 | /* | 1757 | /* |
1400 | * Initialise the common bits of the superblock | 1758 | * Initialise the common bits of the superblock |
1401 | */ | 1759 | */ |
@@ -1811,14 +2169,13 @@ static int nfs4_validate_mount_data(void *options, | |||
1811 | 2169 | ||
1812 | args->rsize = NFS_MAX_FILE_IO_SIZE; | 2170 | args->rsize = NFS_MAX_FILE_IO_SIZE; |
1813 | args->wsize = NFS_MAX_FILE_IO_SIZE; | 2171 | args->wsize = NFS_MAX_FILE_IO_SIZE; |
1814 | args->timeo = 600; | 2172 | args->acregmin = NFS_DEF_ACREGMIN; |
1815 | args->retrans = 2; | 2173 | args->acregmax = NFS_DEF_ACREGMAX; |
1816 | args->acregmin = 3; | 2174 | args->acdirmin = NFS_DEF_ACDIRMIN; |
1817 | args->acregmax = 60; | 2175 | args->acdirmax = NFS_DEF_ACDIRMAX; |
1818 | args->acdirmin = 30; | ||
1819 | args->acdirmax = 60; | ||
1820 | args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */ | 2176 | args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */ |
1821 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 2177 | args->auth_flavors[0] = RPC_AUTH_UNIX; |
2178 | args->auth_flavor_len = 0; | ||
1822 | 2179 | ||
1823 | switch (data->version) { | 2180 | switch (data->version) { |
1824 | case 1: | 2181 | case 1: |
@@ -1834,18 +2191,13 @@ static int nfs4_validate_mount_data(void *options, | |||
1834 | &args->nfs_server.address)) | 2191 | &args->nfs_server.address)) |
1835 | goto out_no_address; | 2192 | goto out_no_address; |
1836 | 2193 | ||
1837 | switch (data->auth_flavourlen) { | 2194 | if (data->auth_flavourlen) { |
1838 | case 0: | 2195 | if (data->auth_flavourlen > 1) |
1839 | args->auth_flavors[0] = RPC_AUTH_UNIX; | 2196 | goto out_inval_auth; |
1840 | break; | ||
1841 | case 1: | ||
1842 | if (copy_from_user(&args->auth_flavors[0], | 2197 | if (copy_from_user(&args->auth_flavors[0], |
1843 | data->auth_flavours, | 2198 | data->auth_flavours, |
1844 | sizeof(args->auth_flavors[0]))) | 2199 | sizeof(args->auth_flavors[0]))) |
1845 | return -EFAULT; | 2200 | return -EFAULT; |
1846 | break; | ||
1847 | default: | ||
1848 | goto out_inval_auth; | ||
1849 | } | 2201 | } |
1850 | 2202 | ||
1851 | c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); | 2203 | c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); |
@@ -1879,10 +2231,11 @@ static int nfs4_validate_mount_data(void *options, | |||
1879 | args->acdirmin = data->acdirmin; | 2231 | args->acdirmin = data->acdirmin; |
1880 | args->acdirmax = data->acdirmax; | 2232 | args->acdirmax = data->acdirmax; |
1881 | args->nfs_server.protocol = data->proto; | 2233 | args->nfs_server.protocol = data->proto; |
2234 | nfs_validate_transport_protocol(args); | ||
1882 | 2235 | ||
1883 | break; | 2236 | break; |
1884 | default: { | 2237 | default: { |
1885 | unsigned int len; | 2238 | int status; |
1886 | 2239 | ||
1887 | if (nfs_parse_mount_options((char *)options, args) == 0) | 2240 | if (nfs_parse_mount_options((char *)options, args) == 0) |
1888 | return -EINVAL; | 2241 | return -EINVAL; |
@@ -1891,44 +2244,25 @@ static int nfs4_validate_mount_data(void *options, | |||
1891 | &args->nfs_server.address)) | 2244 | &args->nfs_server.address)) |
1892 | return -EINVAL; | 2245 | return -EINVAL; |
1893 | 2246 | ||
1894 | switch (args->auth_flavor_len) { | 2247 | nfs_set_port((struct sockaddr *)&args->nfs_server.address, |
1895 | case 0: | 2248 | args->nfs_server.port); |
1896 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
1897 | break; | ||
1898 | case 1: | ||
1899 | break; | ||
1900 | default: | ||
1901 | goto out_inval_auth; | ||
1902 | } | ||
1903 | 2249 | ||
1904 | /* | 2250 | nfs_validate_transport_protocol(args); |
1905 | * Split "dev_name" into "hostname:mntpath". | ||
1906 | */ | ||
1907 | c = strchr(dev_name, ':'); | ||
1908 | if (c == NULL) | ||
1909 | return -EINVAL; | ||
1910 | /* while calculating len, pretend ':' is '\0' */ | ||
1911 | len = c - dev_name; | ||
1912 | if (len > NFS4_MAXNAMLEN) | ||
1913 | return -ENAMETOOLONG; | ||
1914 | /* N.B. caller will free nfs_server.hostname in all cases */ | ||
1915 | args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL); | ||
1916 | if (!args->nfs_server.hostname) | ||
1917 | goto out_nomem; | ||
1918 | |||
1919 | c++; /* step over the ':' */ | ||
1920 | len = strlen(c); | ||
1921 | if (len > NFS4_MAXPATHLEN) | ||
1922 | return -ENAMETOOLONG; | ||
1923 | args->nfs_server.export_path = kstrndup(c, len, GFP_KERNEL); | ||
1924 | if (!args->nfs_server.export_path) | ||
1925 | goto out_nomem; | ||
1926 | 2251 | ||
1927 | dprintk("NFS: MNTPATH: '%s'\n", args->nfs_server.export_path); | 2252 | if (args->auth_flavor_len > 1) |
2253 | goto out_inval_auth; | ||
1928 | 2254 | ||
1929 | if (args->client_address == NULL) | 2255 | if (args->client_address == NULL) |
1930 | goto out_no_client_address; | 2256 | goto out_no_client_address; |
1931 | 2257 | ||
2258 | status = nfs_parse_devname(dev_name, | ||
2259 | &args->nfs_server.hostname, | ||
2260 | NFS4_MAXNAMLEN, | ||
2261 | &args->nfs_server.export_path, | ||
2262 | NFS4_MAXPATHLEN); | ||
2263 | if (status < 0) | ||
2264 | return status; | ||
2265 | |||
1932 | break; | 2266 | break; |
1933 | } | 2267 | } |
1934 | } | 2268 | } |
@@ -1944,10 +2278,6 @@ out_inval_auth: | |||
1944 | data->auth_flavourlen); | 2278 | data->auth_flavourlen); |
1945 | return -EINVAL; | 2279 | return -EINVAL; |
1946 | 2280 | ||
1947 | out_nomem: | ||
1948 | dfprintk(MOUNT, "NFS4: not enough memory to handle mount options\n"); | ||
1949 | return -ENOMEM; | ||
1950 | |||
1951 | out_no_address: | 2281 | out_no_address: |
1952 | dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n"); | 2282 | dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n"); |
1953 | return -EINVAL; | 2283 | return -EINVAL; |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index f333848fd3be..3229e217c773 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -34,9 +34,6 @@ | |||
34 | /* | 34 | /* |
35 | * Local function declarations | 35 | * Local function declarations |
36 | */ | 36 | */ |
37 | static struct nfs_page * nfs_update_request(struct nfs_open_context*, | ||
38 | struct page *, | ||
39 | unsigned int, unsigned int); | ||
40 | static void nfs_pageio_init_write(struct nfs_pageio_descriptor *desc, | 37 | static void nfs_pageio_init_write(struct nfs_pageio_descriptor *desc, |
41 | struct inode *inode, int ioflags); | 38 | struct inode *inode, int ioflags); |
42 | static void nfs_redirty_request(struct nfs_page *req); | 39 | static void nfs_redirty_request(struct nfs_page *req); |
@@ -136,16 +133,21 @@ static struct nfs_page *nfs_page_find_request(struct page *page) | |||
136 | static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count) | 133 | static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count) |
137 | { | 134 | { |
138 | struct inode *inode = page->mapping->host; | 135 | struct inode *inode = page->mapping->host; |
139 | loff_t end, i_size = i_size_read(inode); | 136 | loff_t end, i_size; |
140 | pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; | 137 | pgoff_t end_index; |
141 | 138 | ||
139 | spin_lock(&inode->i_lock); | ||
140 | i_size = i_size_read(inode); | ||
141 | end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; | ||
142 | if (i_size > 0 && page->index < end_index) | 142 | if (i_size > 0 && page->index < end_index) |
143 | return; | 143 | goto out; |
144 | end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + ((loff_t)offset+count); | 144 | end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + ((loff_t)offset+count); |
145 | if (i_size >= end) | 145 | if (i_size >= end) |
146 | return; | 146 | goto out; |
147 | nfs_inc_stats(inode, NFSIOS_EXTENDWRITE); | ||
148 | i_size_write(inode, end); | 147 | i_size_write(inode, end); |
148 | nfs_inc_stats(inode, NFSIOS_EXTENDWRITE); | ||
149 | out: | ||
150 | spin_unlock(&inode->i_lock); | ||
149 | } | 151 | } |
150 | 152 | ||
151 | /* A writeback failed: mark the page as bad, and invalidate the page cache */ | 153 | /* A writeback failed: mark the page as bad, and invalidate the page cache */ |
@@ -169,29 +171,6 @@ static void nfs_mark_uptodate(struct page *page, unsigned int base, unsigned int | |||
169 | SetPageUptodate(page); | 171 | SetPageUptodate(page); |
170 | } | 172 | } |
171 | 173 | ||
172 | static int nfs_writepage_setup(struct nfs_open_context *ctx, struct page *page, | ||
173 | unsigned int offset, unsigned int count) | ||
174 | { | ||
175 | struct nfs_page *req; | ||
176 | int ret; | ||
177 | |||
178 | for (;;) { | ||
179 | req = nfs_update_request(ctx, page, offset, count); | ||
180 | if (!IS_ERR(req)) | ||
181 | break; | ||
182 | ret = PTR_ERR(req); | ||
183 | if (ret != -EBUSY) | ||
184 | return ret; | ||
185 | ret = nfs_wb_page(page->mapping->host, page); | ||
186 | if (ret != 0) | ||
187 | return ret; | ||
188 | } | ||
189 | /* Update file length */ | ||
190 | nfs_grow_file(page, offset, count); | ||
191 | nfs_clear_page_tag_locked(req); | ||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static int wb_priority(struct writeback_control *wbc) | 174 | static int wb_priority(struct writeback_control *wbc) |
196 | { | 175 | { |
197 | if (wbc->for_reclaim) | 176 | if (wbc->for_reclaim) |
@@ -268,12 +247,9 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, | |||
268 | return ret; | 247 | return ret; |
269 | spin_lock(&inode->i_lock); | 248 | spin_lock(&inode->i_lock); |
270 | } | 249 | } |
271 | if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) { | 250 | if (test_bit(PG_CLEAN, &req->wb_flags)) { |
272 | /* This request is marked for commit */ | ||
273 | spin_unlock(&inode->i_lock); | 251 | spin_unlock(&inode->i_lock); |
274 | nfs_clear_page_tag_locked(req); | 252 | BUG(); |
275 | nfs_pageio_complete(pgio); | ||
276 | return 0; | ||
277 | } | 253 | } |
278 | if (nfs_set_page_writeback(page) != 0) { | 254 | if (nfs_set_page_writeback(page) != 0) { |
279 | spin_unlock(&inode->i_lock); | 255 | spin_unlock(&inode->i_lock); |
@@ -355,11 +331,19 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) | |||
355 | /* | 331 | /* |
356 | * Insert a write request into an inode | 332 | * Insert a write request into an inode |
357 | */ | 333 | */ |
358 | static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | 334 | static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req) |
359 | { | 335 | { |
360 | struct nfs_inode *nfsi = NFS_I(inode); | 336 | struct nfs_inode *nfsi = NFS_I(inode); |
361 | int error; | 337 | int error; |
362 | 338 | ||
339 | error = radix_tree_preload(GFP_NOFS); | ||
340 | if (error != 0) | ||
341 | goto out; | ||
342 | |||
343 | /* Lock the request! */ | ||
344 | nfs_lock_request_dontget(req); | ||
345 | |||
346 | spin_lock(&inode->i_lock); | ||
363 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); | 347 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); |
364 | BUG_ON(error); | 348 | BUG_ON(error); |
365 | if (!nfsi->npages) { | 349 | if (!nfsi->npages) { |
@@ -373,6 +357,10 @@ static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | |||
373 | kref_get(&req->wb_kref); | 357 | kref_get(&req->wb_kref); |
374 | radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, | 358 | radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, |
375 | NFS_PAGE_TAG_LOCKED); | 359 | NFS_PAGE_TAG_LOCKED); |
360 | spin_unlock(&inode->i_lock); | ||
361 | radix_tree_preload_end(); | ||
362 | out: | ||
363 | return error; | ||
376 | } | 364 | } |
377 | 365 | ||
378 | /* | 366 | /* |
@@ -405,19 +393,6 @@ nfs_mark_request_dirty(struct nfs_page *req) | |||
405 | __set_page_dirty_nobuffers(req->wb_page); | 393 | __set_page_dirty_nobuffers(req->wb_page); |
406 | } | 394 | } |
407 | 395 | ||
408 | /* | ||
409 | * Check if a request is dirty | ||
410 | */ | ||
411 | static inline int | ||
412 | nfs_dirty_request(struct nfs_page *req) | ||
413 | { | ||
414 | struct page *page = req->wb_page; | ||
415 | |||
416 | if (page == NULL || test_bit(PG_NEED_COMMIT, &req->wb_flags)) | ||
417 | return 0; | ||
418 | return !PageWriteback(page); | ||
419 | } | ||
420 | |||
421 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) | 396 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) |
422 | /* | 397 | /* |
423 | * Add a request to the inode's commit list. | 398 | * Add a request to the inode's commit list. |
@@ -430,7 +405,7 @@ nfs_mark_request_commit(struct nfs_page *req) | |||
430 | 405 | ||
431 | spin_lock(&inode->i_lock); | 406 | spin_lock(&inode->i_lock); |
432 | nfsi->ncommit++; | 407 | nfsi->ncommit++; |
433 | set_bit(PG_NEED_COMMIT, &(req)->wb_flags); | 408 | set_bit(PG_CLEAN, &(req)->wb_flags); |
434 | radix_tree_tag_set(&nfsi->nfs_page_tree, | 409 | radix_tree_tag_set(&nfsi->nfs_page_tree, |
435 | req->wb_index, | 410 | req->wb_index, |
436 | NFS_PAGE_TAG_COMMIT); | 411 | NFS_PAGE_TAG_COMMIT); |
@@ -440,6 +415,19 @@ nfs_mark_request_commit(struct nfs_page *req) | |||
440 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); | 415 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); |
441 | } | 416 | } |
442 | 417 | ||
418 | static int | ||
419 | nfs_clear_request_commit(struct nfs_page *req) | ||
420 | { | ||
421 | struct page *page = req->wb_page; | ||
422 | |||
423 | if (test_and_clear_bit(PG_CLEAN, &(req)->wb_flags)) { | ||
424 | dec_zone_page_state(page, NR_UNSTABLE_NFS); | ||
425 | dec_bdi_stat(page->mapping->backing_dev_info, BDI_RECLAIMABLE); | ||
426 | return 1; | ||
427 | } | ||
428 | return 0; | ||
429 | } | ||
430 | |||
443 | static inline | 431 | static inline |
444 | int nfs_write_need_commit(struct nfs_write_data *data) | 432 | int nfs_write_need_commit(struct nfs_write_data *data) |
445 | { | 433 | { |
@@ -449,7 +437,7 @@ int nfs_write_need_commit(struct nfs_write_data *data) | |||
449 | static inline | 437 | static inline |
450 | int nfs_reschedule_unstable_write(struct nfs_page *req) | 438 | int nfs_reschedule_unstable_write(struct nfs_page *req) |
451 | { | 439 | { |
452 | if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) { | 440 | if (test_and_clear_bit(PG_NEED_COMMIT, &req->wb_flags)) { |
453 | nfs_mark_request_commit(req); | 441 | nfs_mark_request_commit(req); |
454 | return 1; | 442 | return 1; |
455 | } | 443 | } |
@@ -465,6 +453,12 @@ nfs_mark_request_commit(struct nfs_page *req) | |||
465 | { | 453 | { |
466 | } | 454 | } |
467 | 455 | ||
456 | static inline int | ||
457 | nfs_clear_request_commit(struct nfs_page *req) | ||
458 | { | ||
459 | return 0; | ||
460 | } | ||
461 | |||
468 | static inline | 462 | static inline |
469 | int nfs_write_need_commit(struct nfs_write_data *data) | 463 | int nfs_write_need_commit(struct nfs_write_data *data) |
470 | { | 464 | { |
@@ -522,11 +516,8 @@ static void nfs_cancel_commit_list(struct list_head *head) | |||
522 | 516 | ||
523 | while(!list_empty(head)) { | 517 | while(!list_empty(head)) { |
524 | req = nfs_list_entry(head->next); | 518 | req = nfs_list_entry(head->next); |
525 | dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); | ||
526 | dec_bdi_stat(req->wb_page->mapping->backing_dev_info, | ||
527 | BDI_RECLAIMABLE); | ||
528 | nfs_list_remove_request(req); | 519 | nfs_list_remove_request(req); |
529 | clear_bit(PG_NEED_COMMIT, &(req)->wb_flags); | 520 | nfs_clear_request_commit(req); |
530 | nfs_inode_remove_request(req); | 521 | nfs_inode_remove_request(req); |
531 | nfs_unlock_request(req); | 522 | nfs_unlock_request(req); |
532 | } | 523 | } |
@@ -564,110 +555,124 @@ static inline int nfs_scan_commit(struct inode *inode, struct list_head *dst, pg | |||
564 | #endif | 555 | #endif |
565 | 556 | ||
566 | /* | 557 | /* |
567 | * Try to update any existing write request, or create one if there is none. | 558 | * Search for an existing write request, and attempt to update |
568 | * In order to match, the request's credentials must match those of | 559 | * it to reflect a new dirty region on a given page. |
569 | * the calling process. | ||
570 | * | 560 | * |
571 | * Note: Should always be called with the Page Lock held! | 561 | * If the attempt fails, then the existing request is flushed out |
562 | * to disk. | ||
572 | */ | 563 | */ |
573 | static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx, | 564 | static struct nfs_page *nfs_try_to_update_request(struct inode *inode, |
574 | struct page *page, unsigned int offset, unsigned int bytes) | 565 | struct page *page, |
566 | unsigned int offset, | ||
567 | unsigned int bytes) | ||
575 | { | 568 | { |
576 | struct address_space *mapping = page->mapping; | 569 | struct nfs_page *req; |
577 | struct inode *inode = mapping->host; | 570 | unsigned int rqend; |
578 | struct nfs_page *req, *new = NULL; | 571 | unsigned int end; |
579 | pgoff_t rqend, end; | 572 | int error; |
573 | |||
574 | if (!PagePrivate(page)) | ||
575 | return NULL; | ||
580 | 576 | ||
581 | end = offset + bytes; | 577 | end = offset + bytes; |
578 | spin_lock(&inode->i_lock); | ||
582 | 579 | ||
583 | for (;;) { | 580 | for (;;) { |
584 | /* Loop over all inode entries and see if we find | 581 | req = nfs_page_find_request_locked(page); |
585 | * A request for the page we wish to update | 582 | if (req == NULL) |
583 | goto out_unlock; | ||
584 | |||
585 | rqend = req->wb_offset + req->wb_bytes; | ||
586 | /* | ||
587 | * Tell the caller to flush out the request if | ||
588 | * the offsets are non-contiguous. | ||
589 | * Note: nfs_flush_incompatible() will already | ||
590 | * have flushed out requests having wrong owners. | ||
586 | */ | 591 | */ |
587 | if (new) { | 592 | if (offset > rqend |
588 | if (radix_tree_preload(GFP_NOFS)) { | 593 | || end < req->wb_offset) |
589 | nfs_release_request(new); | 594 | goto out_flushme; |
590 | return ERR_PTR(-ENOMEM); | ||
591 | } | ||
592 | } | ||
593 | 595 | ||
594 | spin_lock(&inode->i_lock); | 596 | if (nfs_set_page_tag_locked(req)) |
595 | req = nfs_page_find_request_locked(page); | ||
596 | if (req) { | ||
597 | if (!nfs_set_page_tag_locked(req)) { | ||
598 | int error; | ||
599 | |||
600 | spin_unlock(&inode->i_lock); | ||
601 | error = nfs_wait_on_request(req); | ||
602 | nfs_release_request(req); | ||
603 | if (error < 0) { | ||
604 | if (new) { | ||
605 | radix_tree_preload_end(); | ||
606 | nfs_release_request(new); | ||
607 | } | ||
608 | return ERR_PTR(error); | ||
609 | } | ||
610 | continue; | ||
611 | } | ||
612 | spin_unlock(&inode->i_lock); | ||
613 | if (new) { | ||
614 | radix_tree_preload_end(); | ||
615 | nfs_release_request(new); | ||
616 | } | ||
617 | break; | 597 | break; |
618 | } | ||
619 | 598 | ||
620 | if (new) { | 599 | /* The request is locked, so wait and then retry */ |
621 | nfs_lock_request_dontget(new); | ||
622 | nfs_inode_add_request(inode, new); | ||
623 | spin_unlock(&inode->i_lock); | ||
624 | radix_tree_preload_end(); | ||
625 | req = new; | ||
626 | goto zero_page; | ||
627 | } | ||
628 | spin_unlock(&inode->i_lock); | 600 | spin_unlock(&inode->i_lock); |
629 | 601 | error = nfs_wait_on_request(req); | |
630 | new = nfs_create_request(ctx, inode, page, offset, bytes); | 602 | nfs_release_request(req); |
631 | if (IS_ERR(new)) | 603 | if (error != 0) |
632 | return new; | 604 | goto out_err; |
605 | spin_lock(&inode->i_lock); | ||
633 | } | 606 | } |
634 | 607 | ||
635 | /* We have a request for our page. | 608 | if (nfs_clear_request_commit(req)) |
636 | * If the creds don't match, or the | 609 | radix_tree_tag_clear(&NFS_I(inode)->nfs_page_tree, |
637 | * page addresses don't match, | 610 | req->wb_index, NFS_PAGE_TAG_COMMIT); |
638 | * tell the caller to wait on the conflicting | ||
639 | * request. | ||
640 | */ | ||
641 | rqend = req->wb_offset + req->wb_bytes; | ||
642 | if (req->wb_context != ctx | ||
643 | || req->wb_page != page | ||
644 | || !nfs_dirty_request(req) | ||
645 | || offset > rqend || end < req->wb_offset) { | ||
646 | nfs_clear_page_tag_locked(req); | ||
647 | return ERR_PTR(-EBUSY); | ||
648 | } | ||
649 | 611 | ||
650 | /* Okay, the request matches. Update the region */ | 612 | /* Okay, the request matches. Update the region */ |
651 | if (offset < req->wb_offset) { | 613 | if (offset < req->wb_offset) { |
652 | req->wb_offset = offset; | 614 | req->wb_offset = offset; |
653 | req->wb_pgbase = offset; | 615 | req->wb_pgbase = offset; |
654 | req->wb_bytes = max(end, rqend) - req->wb_offset; | ||
655 | goto zero_page; | ||
656 | } | 616 | } |
657 | |||
658 | if (end > rqend) | 617 | if (end > rqend) |
659 | req->wb_bytes = end - req->wb_offset; | 618 | req->wb_bytes = end - req->wb_offset; |
660 | 619 | else | |
620 | req->wb_bytes = rqend - req->wb_offset; | ||
621 | out_unlock: | ||
622 | spin_unlock(&inode->i_lock); | ||
661 | return req; | 623 | return req; |
662 | zero_page: | 624 | out_flushme: |
663 | /* If this page might potentially be marked as up to date, | 625 | spin_unlock(&inode->i_lock); |
664 | * then we need to zero any uninitalised data. */ | 626 | nfs_release_request(req); |
665 | if (req->wb_pgbase == 0 && req->wb_bytes != PAGE_CACHE_SIZE | 627 | error = nfs_wb_page(inode, page); |
666 | && !PageUptodate(req->wb_page)) | 628 | out_err: |
667 | zero_user_segment(req->wb_page, req->wb_bytes, PAGE_CACHE_SIZE); | 629 | return ERR_PTR(error); |
630 | } | ||
631 | |||
632 | /* | ||
633 | * Try to update an existing write request, or create one if there is none. | ||
634 | * | ||
635 | * Note: Should always be called with the Page Lock held to prevent races | ||
636 | * if we have to add a new request. Also assumes that the caller has | ||
637 | * already called nfs_flush_incompatible() if necessary. | ||
638 | */ | ||
639 | static struct nfs_page * nfs_setup_write_request(struct nfs_open_context* ctx, | ||
640 | struct page *page, unsigned int offset, unsigned int bytes) | ||
641 | { | ||
642 | struct inode *inode = page->mapping->host; | ||
643 | struct nfs_page *req; | ||
644 | int error; | ||
645 | |||
646 | req = nfs_try_to_update_request(inode, page, offset, bytes); | ||
647 | if (req != NULL) | ||
648 | goto out; | ||
649 | req = nfs_create_request(ctx, inode, page, offset, bytes); | ||
650 | if (IS_ERR(req)) | ||
651 | goto out; | ||
652 | error = nfs_inode_add_request(inode, req); | ||
653 | if (error != 0) { | ||
654 | nfs_release_request(req); | ||
655 | req = ERR_PTR(error); | ||
656 | } | ||
657 | out: | ||
668 | return req; | 658 | return req; |
669 | } | 659 | } |
670 | 660 | ||
661 | static int nfs_writepage_setup(struct nfs_open_context *ctx, struct page *page, | ||
662 | unsigned int offset, unsigned int count) | ||
663 | { | ||
664 | struct nfs_page *req; | ||
665 | |||
666 | req = nfs_setup_write_request(ctx, page, offset, count); | ||
667 | if (IS_ERR(req)) | ||
668 | return PTR_ERR(req); | ||
669 | /* Update file length */ | ||
670 | nfs_grow_file(page, offset, count); | ||
671 | nfs_mark_uptodate(page, req->wb_pgbase, req->wb_bytes); | ||
672 | nfs_clear_page_tag_locked(req); | ||
673 | return 0; | ||
674 | } | ||
675 | |||
671 | int nfs_flush_incompatible(struct file *file, struct page *page) | 676 | int nfs_flush_incompatible(struct file *file, struct page *page) |
672 | { | 677 | { |
673 | struct nfs_open_context *ctx = nfs_file_open_context(file); | 678 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
@@ -685,8 +690,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page) | |||
685 | req = nfs_page_find_request(page); | 690 | req = nfs_page_find_request(page); |
686 | if (req == NULL) | 691 | if (req == NULL) |
687 | return 0; | 692 | return 0; |
688 | do_flush = req->wb_page != page || req->wb_context != ctx | 693 | do_flush = req->wb_page != page || req->wb_context != ctx; |
689 | || !nfs_dirty_request(req); | ||
690 | nfs_release_request(req); | 694 | nfs_release_request(req); |
691 | if (!do_flush) | 695 | if (!do_flush) |
692 | return 0; | 696 | return 0; |
@@ -721,10 +725,10 @@ int nfs_updatepage(struct file *file, struct page *page, | |||
721 | 725 | ||
722 | nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE); | 726 | nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE); |
723 | 727 | ||
724 | dprintk("NFS: nfs_updatepage(%s/%s %d@%Ld)\n", | 728 | dprintk("NFS: nfs_updatepage(%s/%s %d@%lld)\n", |
725 | file->f_path.dentry->d_parent->d_name.name, | 729 | file->f_path.dentry->d_parent->d_name.name, |
726 | file->f_path.dentry->d_name.name, count, | 730 | file->f_path.dentry->d_name.name, count, |
727 | (long long)(page_offset(page) +offset)); | 731 | (long long)(page_offset(page) + offset)); |
728 | 732 | ||
729 | /* If we're not using byte range locks, and we know the page | 733 | /* If we're not using byte range locks, and we know the page |
730 | * is up to date, it may be more efficient to extend the write | 734 | * is up to date, it may be more efficient to extend the write |
@@ -744,7 +748,7 @@ int nfs_updatepage(struct file *file, struct page *page, | |||
744 | else | 748 | else |
745 | __set_page_dirty_nobuffers(page); | 749 | __set_page_dirty_nobuffers(page); |
746 | 750 | ||
747 | dprintk("NFS: nfs_updatepage returns %d (isize %Ld)\n", | 751 | dprintk("NFS: nfs_updatepage returns %d (isize %lld)\n", |
748 | status, (long long)i_size_read(inode)); | 752 | status, (long long)i_size_read(inode)); |
749 | return status; | 753 | return status; |
750 | } | 754 | } |
@@ -752,12 +756,7 @@ int nfs_updatepage(struct file *file, struct page *page, | |||
752 | static void nfs_writepage_release(struct nfs_page *req) | 756 | static void nfs_writepage_release(struct nfs_page *req) |
753 | { | 757 | { |
754 | 758 | ||
755 | if (PageError(req->wb_page)) { | 759 | if (PageError(req->wb_page) || !nfs_reschedule_unstable_write(req)) { |
756 | nfs_end_page_writeback(req->wb_page); | ||
757 | nfs_inode_remove_request(req); | ||
758 | } else if (!nfs_reschedule_unstable_write(req)) { | ||
759 | /* Set the PG_uptodate flag */ | ||
760 | nfs_mark_uptodate(req->wb_page, req->wb_pgbase, req->wb_bytes); | ||
761 | nfs_end_page_writeback(req->wb_page); | 760 | nfs_end_page_writeback(req->wb_page); |
762 | nfs_inode_remove_request(req); | 761 | nfs_inode_remove_request(req); |
763 | } else | 762 | } else |
@@ -834,7 +833,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req, | |||
834 | NFS_PROTO(inode)->write_setup(data, &msg); | 833 | NFS_PROTO(inode)->write_setup(data, &msg); |
835 | 834 | ||
836 | dprintk("NFS: %5u initiated write call " | 835 | dprintk("NFS: %5u initiated write call " |
837 | "(req %s/%Ld, %u bytes @ offset %Lu)\n", | 836 | "(req %s/%lld, %u bytes @ offset %llu)\n", |
838 | data->task.tk_pid, | 837 | data->task.tk_pid, |
839 | inode->i_sb->s_id, | 838 | inode->i_sb->s_id, |
840 | (long long)NFS_FILEID(inode), | 839 | (long long)NFS_FILEID(inode), |
@@ -978,13 +977,13 @@ static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, | |||
978 | static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata) | 977 | static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata) |
979 | { | 978 | { |
980 | struct nfs_write_data *data = calldata; | 979 | struct nfs_write_data *data = calldata; |
981 | struct nfs_page *req = data->req; | ||
982 | 980 | ||
983 | dprintk("NFS: write (%s/%Ld %d@%Ld)", | 981 | dprintk("NFS: %5u write(%s/%lld %d@%lld)", |
984 | req->wb_context->path.dentry->d_inode->i_sb->s_id, | 982 | task->tk_pid, |
985 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), | 983 | data->req->wb_context->path.dentry->d_inode->i_sb->s_id, |
986 | req->wb_bytes, | 984 | (long long) |
987 | (long long)req_offset(req)); | 985 | NFS_FILEID(data->req->wb_context->path.dentry->d_inode), |
986 | data->req->wb_bytes, (long long)req_offset(data->req)); | ||
988 | 987 | ||
989 | nfs_writeback_done(task, data); | 988 | nfs_writeback_done(task, data); |
990 | } | 989 | } |
@@ -1058,7 +1057,8 @@ static void nfs_writeback_release_full(void *calldata) | |||
1058 | 1057 | ||
1059 | nfs_list_remove_request(req); | 1058 | nfs_list_remove_request(req); |
1060 | 1059 | ||
1061 | dprintk("NFS: write (%s/%Ld %d@%Ld)", | 1060 | dprintk("NFS: %5u write (%s/%lld %d@%lld)", |
1061 | data->task.tk_pid, | ||
1062 | req->wb_context->path.dentry->d_inode->i_sb->s_id, | 1062 | req->wb_context->path.dentry->d_inode->i_sb->s_id, |
1063 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), | 1063 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), |
1064 | req->wb_bytes, | 1064 | req->wb_bytes, |
@@ -1078,8 +1078,6 @@ static void nfs_writeback_release_full(void *calldata) | |||
1078 | dprintk(" marked for commit\n"); | 1078 | dprintk(" marked for commit\n"); |
1079 | goto next; | 1079 | goto next; |
1080 | } | 1080 | } |
1081 | /* Set the PG_uptodate flag? */ | ||
1082 | nfs_mark_uptodate(page, req->wb_pgbase, req->wb_bytes); | ||
1083 | dprintk(" OK\n"); | 1081 | dprintk(" OK\n"); |
1084 | remove_request: | 1082 | remove_request: |
1085 | nfs_end_page_writeback(page); | 1083 | nfs_end_page_writeback(page); |
@@ -1133,7 +1131,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) | |||
1133 | static unsigned long complain; | 1131 | static unsigned long complain; |
1134 | 1132 | ||
1135 | if (time_before(complain, jiffies)) { | 1133 | if (time_before(complain, jiffies)) { |
1136 | dprintk("NFS: faulty NFS server %s:" | 1134 | dprintk("NFS: faulty NFS server %s:" |
1137 | " (committed = %d) != (stable = %d)\n", | 1135 | " (committed = %d) != (stable = %d)\n", |
1138 | NFS_SERVER(data->inode)->nfs_client->cl_hostname, | 1136 | NFS_SERVER(data->inode)->nfs_client->cl_hostname, |
1139 | resp->verf->committed, argp->stable); | 1137 | resp->verf->committed, argp->stable); |
@@ -1297,12 +1295,9 @@ static void nfs_commit_release(void *calldata) | |||
1297 | while (!list_empty(&data->pages)) { | 1295 | while (!list_empty(&data->pages)) { |
1298 | req = nfs_list_entry(data->pages.next); | 1296 | req = nfs_list_entry(data->pages.next); |
1299 | nfs_list_remove_request(req); | 1297 | nfs_list_remove_request(req); |
1300 | clear_bit(PG_NEED_COMMIT, &(req)->wb_flags); | 1298 | nfs_clear_request_commit(req); |
1301 | dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); | ||
1302 | dec_bdi_stat(req->wb_page->mapping->backing_dev_info, | ||
1303 | BDI_RECLAIMABLE); | ||
1304 | 1299 | ||
1305 | dprintk("NFS: commit (%s/%Ld %d@%Ld)", | 1300 | dprintk("NFS: commit (%s/%lld %d@%lld)", |
1306 | req->wb_context->path.dentry->d_inode->i_sb->s_id, | 1301 | req->wb_context->path.dentry->d_inode->i_sb->s_id, |
1307 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), | 1302 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), |
1308 | req->wb_bytes, | 1303 | req->wb_bytes, |
@@ -1318,9 +1313,6 @@ static void nfs_commit_release(void *calldata) | |||
1318 | * returned by the server against all stored verfs. */ | 1313 | * returned by the server against all stored verfs. */ |
1319 | if (!memcmp(req->wb_verf.verifier, data->verf.verifier, sizeof(data->verf.verifier))) { | 1314 | if (!memcmp(req->wb_verf.verifier, data->verf.verifier, sizeof(data->verf.verifier))) { |
1320 | /* We have a match */ | 1315 | /* We have a match */ |
1321 | /* Set the PG_uptodate flag */ | ||
1322 | nfs_mark_uptodate(req->wb_page, req->wb_pgbase, | ||
1323 | req->wb_bytes); | ||
1324 | nfs_inode_remove_request(req); | 1316 | nfs_inode_remove_request(req); |
1325 | dprintk(" OK\n"); | 1317 | dprintk(" OK\n"); |
1326 | goto next; | 1318 | goto next; |
@@ -1479,7 +1471,7 @@ int nfs_wb_page_cancel(struct inode *inode, struct page *page) | |||
1479 | req = nfs_page_find_request(page); | 1471 | req = nfs_page_find_request(page); |
1480 | if (req == NULL) | 1472 | if (req == NULL) |
1481 | goto out; | 1473 | goto out; |
1482 | if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) { | 1474 | if (test_bit(PG_CLEAN, &req->wb_flags)) { |
1483 | nfs_release_request(req); | 1475 | nfs_release_request(req); |
1484 | break; | 1476 | break; |
1485 | } | 1477 | } |