diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 13:54:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 13:54:14 -0400 |
commit | 1d77062b1402aef5b26e1d3776991126e8026bde (patch) | |
tree | 96e4da18878f5fb2ae50b260e194b78803d4c7a9 | |
parent | 25581ad107be24b89d805da51a03d616f8f3d1be (diff) | |
parent | 76a9f26c9e40e9c0ed5dc8f0cedd74e733f0088d (diff) |
Merge git://git.linux-nfs.org/pub/linux/nfs-2.6
* git://git.linux-nfs.org/pub/linux/nfs-2.6: (51 commits)
nfs: remove nfs_put_link()
nfs-build-fix-99
git-nfs-build-fixes
Merge branch 'odirect'
NFS: alloc nfs_read/write_data as direct I/O is scheduled
NFS: Eliminate nfs_get_user_pages()
NFS: refactor nfs_direct_free_user_pages
NFS: remove user_addr, user_count, and pos from nfs_direct_req
NFS: "open code" the NFS direct write rescheduler
NFS: Separate functions for counting outstanding NFS direct I/Os
NLM: Fix reclaim races
NLM: sem to mutex conversion
locks.c: add the fl_owner to nlm_compare_locks
NFS: Display the chosen RPCSEC_GSS security flavour in /proc/mounts
NFS: Split fs/nfs/inode.c
NFS: Fix typo in nfs_do_clone_mount()
NFS: Fix compile errors introduced by referrals patches
NFSv4: Ensure that referral mounts bind to a reserved port
NFSv4: A root pathname is sent as a zero component4
NFSv4: Follow a referral
...
59 files changed, 3065 insertions, 1513 deletions
diff --git a/Documentation/filesystems/automount-support.txt b/Documentation/filesystems/automount-support.txt index 58c65a1713e5..7cac200e2a85 100644 --- a/Documentation/filesystems/automount-support.txt +++ b/Documentation/filesystems/automount-support.txt | |||
@@ -19,7 +19,7 @@ following procedure: | |||
19 | 19 | ||
20 | (2) Have the follow_link() op do the following steps: | 20 | (2) Have the follow_link() op do the following steps: |
21 | 21 | ||
22 | (a) Call do_kern_mount() to call the appropriate filesystem to set up a | 22 | (a) Call vfs_kern_mount() to call the appropriate filesystem to set up a |
23 | superblock and gain a vfsmount structure representing it. | 23 | superblock and gain a vfsmount structure representing it. |
24 | 24 | ||
25 | (b) Copy the nameidata provided as an argument and substitute the dentry | 25 | (b) Copy the nameidata provided as an argument and substitute the dentry |
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 95f5ad923b0f..bfc9b28a7242 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
@@ -569,7 +569,7 @@ static int create_special_files (void) | |||
569 | ignore_mount = 1; | 569 | ignore_mount = 1; |
570 | 570 | ||
571 | /* create the devices special file */ | 571 | /* create the devices special file */ |
572 | retval = simple_pin_fs("usbfs", &usbfs_mount, &usbfs_mount_count); | 572 | retval = simple_pin_fs(&usb_fs_type, &usbfs_mount, &usbfs_mount_count); |
573 | if (retval) { | 573 | if (retval) { |
574 | err ("Unable to get usbfs mount"); | 574 | err ("Unable to get usbfs mount"); |
575 | goto exit; | 575 | goto exit; |
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 872943004e59..8b15bb22caca 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
@@ -256,11 +256,12 @@ static int v9fs_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
256 | } | 256 | } |
257 | 257 | ||
258 | static void | 258 | static void |
259 | v9fs_umount_begin(struct super_block *sb) | 259 | v9fs_umount_begin(struct vfsmount *vfsmnt, int flags) |
260 | { | 260 | { |
261 | struct v9fs_session_info *v9ses = sb->s_fs_info; | 261 | struct v9fs_session_info *v9ses = vfsmnt->mnt_sb->s_fs_info; |
262 | 262 | ||
263 | v9fs_session_cancel(v9ses); | 263 | if (flags & MNT_FORCE) |
264 | v9fs_session_cancel(v9ses); | ||
264 | } | 265 | } |
265 | 266 | ||
266 | static struct super_operations v9fs_super_ops = { | 267 | static struct super_operations v9fs_super_ops = { |
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c index b5cf9e1205ad..99785a79d043 100644 --- a/fs/afs/mntpt.c +++ b/fs/afs/mntpt.c | |||
@@ -203,7 +203,7 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) | |||
203 | 203 | ||
204 | /* try and do the mount */ | 204 | /* try and do the mount */ |
205 | kdebug("--- attempting mount %s -o %s ---", devname, options); | 205 | kdebug("--- attempting mount %s -o %s ---", devname, options); |
206 | mnt = do_kern_mount("afs", 0, devname, options); | 206 | mnt = vfs_kern_mount(&afs_fs_type, 0, devname, options); |
207 | kdebug("--- mount result %p ---", mnt); | 207 | kdebug("--- mount result %p ---", mnt); |
208 | 208 | ||
209 | free_page((unsigned long) devname); | 209 | free_page((unsigned long) devname); |
diff --git a/fs/afs/super.c b/fs/afs/super.c index 82468df0ba54..67d1f5c819ec 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c | |||
@@ -48,7 +48,7 @@ static void afs_put_super(struct super_block *sb); | |||
48 | 48 | ||
49 | static void afs_destroy_inode(struct inode *inode); | 49 | static void afs_destroy_inode(struct inode *inode); |
50 | 50 | ||
51 | static struct file_system_type afs_fs_type = { | 51 | struct file_system_type afs_fs_type = { |
52 | .owner = THIS_MODULE, | 52 | .owner = THIS_MODULE, |
53 | .name = "afs", | 53 | .name = "afs", |
54 | .get_sb = afs_get_sb, | 54 | .get_sb = afs_get_sb, |
diff --git a/fs/afs/super.h b/fs/afs/super.h index ac11362f4e95..32de8cc6fae8 100644 --- a/fs/afs/super.h +++ b/fs/afs/super.h | |||
@@ -38,6 +38,8 @@ static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) | |||
38 | return sb->s_fs_info; | 38 | return sb->s_fs_info; |
39 | } | 39 | } |
40 | 40 | ||
41 | extern struct file_system_type afs_fs_type; | ||
42 | |||
41 | #endif /* __KERNEL__ */ | 43 | #endif /* __KERNEL__ */ |
42 | 44 | ||
43 | #endif /* _LINUX_AFS_SUPER_H */ | 45 | #endif /* _LINUX_AFS_SUPER_H */ |
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 07a4996cca3f..34ebbc191e46 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c | |||
@@ -55,6 +55,7 @@ typedef struct { | |||
55 | } Node; | 55 | } Node; |
56 | 56 | ||
57 | static DEFINE_RWLOCK(entries_lock); | 57 | static DEFINE_RWLOCK(entries_lock); |
58 | static struct file_system_type bm_fs_type; | ||
58 | static struct vfsmount *bm_mnt; | 59 | static struct vfsmount *bm_mnt; |
59 | static int entry_count; | 60 | static int entry_count; |
60 | 61 | ||
@@ -637,7 +638,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, | |||
637 | if (!inode) | 638 | if (!inode) |
638 | goto out2; | 639 | goto out2; |
639 | 640 | ||
640 | err = simple_pin_fs("binfmt_misc", &bm_mnt, &entry_count); | 641 | err = simple_pin_fs(&bm_fs_type, &bm_mnt, &entry_count); |
641 | if (err) { | 642 | if (err) { |
642 | iput(inode); | 643 | iput(inode); |
643 | inode = NULL; | 644 | inode = NULL; |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 7520f4687158..8b4de6eaabd0 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -403,12 +403,14 @@ static struct quotactl_ops cifs_quotactl_ops = { | |||
403 | #endif | 403 | #endif |
404 | 404 | ||
405 | #ifdef CONFIG_CIFS_EXPERIMENTAL | 405 | #ifdef CONFIG_CIFS_EXPERIMENTAL |
406 | static void cifs_umount_begin(struct super_block * sblock) | 406 | static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags) |
407 | { | 407 | { |
408 | struct cifs_sb_info *cifs_sb; | 408 | struct cifs_sb_info *cifs_sb; |
409 | struct cifsTconInfo * tcon; | 409 | struct cifsTconInfo * tcon; |
410 | 410 | ||
411 | cifs_sb = CIFS_SB(sblock); | 411 | if (!(flags & MNT_FORCE)) |
412 | return; | ||
413 | cifs_sb = CIFS_SB(vfsmnt->mnt_sb); | ||
412 | if(cifs_sb == NULL) | 414 | if(cifs_sb == NULL) |
413 | return; | 415 | return; |
414 | 416 | ||
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c index 94dab7bdd851..3e5fe843e1df 100644 --- a/fs/configfs/mount.c +++ b/fs/configfs/mount.c | |||
@@ -118,7 +118,7 @@ static struct file_system_type configfs_fs_type = { | |||
118 | 118 | ||
119 | int configfs_pin_fs(void) | 119 | int configfs_pin_fs(void) |
120 | { | 120 | { |
121 | return simple_pin_fs("configfs", &configfs_mount, | 121 | return simple_pin_fs(&configfs_fs_type, &configfs_mount, |
122 | &configfs_mnt_count); | 122 | &configfs_mnt_count); |
123 | } | 123 | } |
124 | 124 | ||
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 440128ebef3b..6fa1e04f8415 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -199,7 +199,7 @@ struct dentry *debugfs_create_file(const char *name, mode_t mode, | |||
199 | 199 | ||
200 | pr_debug("debugfs: creating file '%s'\n",name); | 200 | pr_debug("debugfs: creating file '%s'\n",name); |
201 | 201 | ||
202 | error = simple_pin_fs("debugfs", &debugfs_mount, &debugfs_mount_count); | 202 | error = simple_pin_fs(&debug_fs_type, &debugfs_mount, &debugfs_mount_count); |
203 | if (error) | 203 | if (error) |
204 | goto exit; | 204 | goto exit; |
205 | 205 | ||
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 5ceb8bd7a189..dcaaabd3b9c4 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -198,9 +198,10 @@ struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid, | |||
198 | return inode; | 198 | return inode; |
199 | } | 199 | } |
200 | 200 | ||
201 | static void fuse_umount_begin(struct super_block *sb) | 201 | static void fuse_umount_begin(struct vfsmount *vfsmnt, int flags) |
202 | { | 202 | { |
203 | fuse_abort_conn(get_fuse_conn_super(sb)); | 203 | if (flags & MNT_FORCE) |
204 | fuse_abort_conn(get_fuse_conn_super(vfsmnt->mnt_sb)); | ||
204 | } | 205 | } |
205 | 206 | ||
206 | static void fuse_put_super(struct super_block *sb) | 207 | static void fuse_put_super(struct super_block *sb) |
diff --git a/fs/libfs.c b/fs/libfs.c index 1b1156381787..fc785d8befb9 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -424,13 +424,13 @@ out: | |||
424 | 424 | ||
425 | static DEFINE_SPINLOCK(pin_fs_lock); | 425 | static DEFINE_SPINLOCK(pin_fs_lock); |
426 | 426 | ||
427 | int simple_pin_fs(char *name, struct vfsmount **mount, int *count) | 427 | int simple_pin_fs(struct file_system_type *type, struct vfsmount **mount, int *count) |
428 | { | 428 | { |
429 | struct vfsmount *mnt = NULL; | 429 | struct vfsmount *mnt = NULL; |
430 | spin_lock(&pin_fs_lock); | 430 | spin_lock(&pin_fs_lock); |
431 | if (unlikely(!*mount)) { | 431 | if (unlikely(!*mount)) { |
432 | spin_unlock(&pin_fs_lock); | 432 | spin_unlock(&pin_fs_lock); |
433 | mnt = do_kern_mount(name, 0, name, NULL); | 433 | mnt = vfs_kern_mount(type, 0, type->name, NULL); |
434 | if (IS_ERR(mnt)) | 434 | if (IS_ERR(mnt)) |
435 | return PTR_ERR(mnt); | 435 | return PTR_ERR(mnt); |
436 | spin_lock(&pin_fs_lock); | 436 | spin_lock(&pin_fs_lock); |
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index bce744468708..52774feab93f 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c | |||
@@ -147,11 +147,10 @@ u32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock) | |||
147 | * Someone has sent us an SM_NOTIFY. Ensure we bind to the new port number, | 147 | * Someone has sent us an SM_NOTIFY. Ensure we bind to the new port number, |
148 | * that we mark locks for reclaiming, and that we bump the pseudo NSM state. | 148 | * that we mark locks for reclaiming, and that we bump the pseudo NSM state. |
149 | */ | 149 | */ |
150 | static inline | 150 | static void nlmclnt_prepare_reclaim(struct nlm_host *host) |
151 | void nlmclnt_prepare_reclaim(struct nlm_host *host, u32 newstate) | ||
152 | { | 151 | { |
152 | down_write(&host->h_rwsem); | ||
153 | host->h_monitored = 0; | 153 | host->h_monitored = 0; |
154 | host->h_nsmstate = newstate; | ||
155 | host->h_state++; | 154 | host->h_state++; |
156 | host->h_nextrebind = 0; | 155 | host->h_nextrebind = 0; |
157 | nlm_rebind_host(host); | 156 | nlm_rebind_host(host); |
@@ -164,6 +163,13 @@ void nlmclnt_prepare_reclaim(struct nlm_host *host, u32 newstate) | |||
164 | dprintk("NLM: reclaiming locks for host %s", host->h_name); | 163 | dprintk("NLM: reclaiming locks for host %s", host->h_name); |
165 | } | 164 | } |
166 | 165 | ||
166 | static void nlmclnt_finish_reclaim(struct nlm_host *host) | ||
167 | { | ||
168 | host->h_reclaiming = 0; | ||
169 | up_write(&host->h_rwsem); | ||
170 | dprintk("NLM: done reclaiming locks for host %s", host->h_name); | ||
171 | } | ||
172 | |||
167 | /* | 173 | /* |
168 | * Reclaim all locks on server host. We do this by spawning a separate | 174 | * Reclaim all locks on server host. We do this by spawning a separate |
169 | * reclaimer thread. | 175 | * reclaimer thread. |
@@ -171,12 +177,10 @@ void nlmclnt_prepare_reclaim(struct nlm_host *host, u32 newstate) | |||
171 | void | 177 | void |
172 | nlmclnt_recovery(struct nlm_host *host, u32 newstate) | 178 | nlmclnt_recovery(struct nlm_host *host, u32 newstate) |
173 | { | 179 | { |
174 | if (host->h_reclaiming++) { | 180 | if (host->h_nsmstate == newstate) |
175 | if (host->h_nsmstate == newstate) | 181 | return; |
176 | return; | 182 | host->h_nsmstate = newstate; |
177 | nlmclnt_prepare_reclaim(host, newstate); | 183 | if (!host->h_reclaiming++) { |
178 | } else { | ||
179 | nlmclnt_prepare_reclaim(host, newstate); | ||
180 | nlm_get_host(host); | 184 | nlm_get_host(host); |
181 | __module_get(THIS_MODULE); | 185 | __module_get(THIS_MODULE); |
182 | if (kernel_thread(reclaimer, host, CLONE_KERNEL) < 0) | 186 | if (kernel_thread(reclaimer, host, CLONE_KERNEL) < 0) |
@@ -190,6 +194,7 @@ reclaimer(void *ptr) | |||
190 | struct nlm_host *host = (struct nlm_host *) ptr; | 194 | struct nlm_host *host = (struct nlm_host *) ptr; |
191 | struct nlm_wait *block; | 195 | struct nlm_wait *block; |
192 | struct file_lock *fl, *next; | 196 | struct file_lock *fl, *next; |
197 | u32 nsmstate; | ||
193 | 198 | ||
194 | daemonize("%s-reclaim", host->h_name); | 199 | daemonize("%s-reclaim", host->h_name); |
195 | allow_signal(SIGKILL); | 200 | allow_signal(SIGKILL); |
@@ -199,19 +204,25 @@ reclaimer(void *ptr) | |||
199 | lock_kernel(); | 204 | lock_kernel(); |
200 | lockd_up(); | 205 | lockd_up(); |
201 | 206 | ||
207 | nlmclnt_prepare_reclaim(host); | ||
202 | /* First, reclaim all locks that have been marked. */ | 208 | /* First, reclaim all locks that have been marked. */ |
203 | restart: | 209 | restart: |
210 | nsmstate = host->h_nsmstate; | ||
204 | list_for_each_entry_safe(fl, next, &host->h_reclaim, fl_u.nfs_fl.list) { | 211 | list_for_each_entry_safe(fl, next, &host->h_reclaim, fl_u.nfs_fl.list) { |
205 | list_del_init(&fl->fl_u.nfs_fl.list); | 212 | list_del_init(&fl->fl_u.nfs_fl.list); |
206 | 213 | ||
207 | if (signalled()) | 214 | if (signalled()) |
208 | continue; | 215 | continue; |
209 | if (nlmclnt_reclaim(host, fl) == 0) | 216 | if (nlmclnt_reclaim(host, fl) != 0) |
210 | list_add_tail(&fl->fl_u.nfs_fl.list, &host->h_granted); | 217 | continue; |
211 | goto restart; | 218 | list_add_tail(&fl->fl_u.nfs_fl.list, &host->h_granted); |
219 | if (host->h_nsmstate != nsmstate) { | ||
220 | /* Argh! The server rebooted again! */ | ||
221 | list_splice_init(&host->h_granted, &host->h_reclaim); | ||
222 | goto restart; | ||
223 | } | ||
212 | } | 224 | } |
213 | 225 | nlmclnt_finish_reclaim(host); | |
214 | host->h_reclaiming = 0; | ||
215 | 226 | ||
216 | /* Now, wake up all processes that sleep on a blocked lock */ | 227 | /* Now, wake up all processes that sleep on a blocked lock */ |
217 | list_for_each_entry(block, &nlm_blocked, b_list) { | 228 | list_for_each_entry(block, &nlm_blocked, b_list) { |
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index f96e38155b5c..4db62098d3f4 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c | |||
@@ -508,7 +508,10 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) | |||
508 | } | 508 | } |
509 | 509 | ||
510 | block = nlmclnt_prepare_block(host, fl); | 510 | block = nlmclnt_prepare_block(host, fl); |
511 | again: | ||
511 | for(;;) { | 512 | for(;;) { |
513 | /* Reboot protection */ | ||
514 | fl->fl_u.nfs_fl.state = host->h_state; | ||
512 | status = nlmclnt_call(req, NLMPROC_LOCK); | 515 | status = nlmclnt_call(req, NLMPROC_LOCK); |
513 | if (status < 0) | 516 | if (status < 0) |
514 | goto out_unblock; | 517 | goto out_unblock; |
@@ -531,10 +534,16 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) | |||
531 | } | 534 | } |
532 | 535 | ||
533 | if (resp->status == NLM_LCK_GRANTED) { | 536 | if (resp->status == NLM_LCK_GRANTED) { |
534 | fl->fl_u.nfs_fl.state = host->h_state; | 537 | down_read(&host->h_rwsem); |
538 | /* Check whether or not the server has rebooted */ | ||
539 | if (fl->fl_u.nfs_fl.state != host->h_state) { | ||
540 | up_read(&host->h_rwsem); | ||
541 | goto again; | ||
542 | } | ||
535 | fl->fl_flags |= FL_SLEEP; | 543 | fl->fl_flags |= FL_SLEEP; |
536 | /* Ensure the resulting lock will get added to granted list */ | 544 | /* Ensure the resulting lock will get added to granted list */ |
537 | do_vfs_lock(fl); | 545 | do_vfs_lock(fl); |
546 | up_read(&host->h_rwsem); | ||
538 | } | 547 | } |
539 | status = nlm_stat_to_errno(resp->status); | 548 | status = nlm_stat_to_errno(resp->status); |
540 | out_unblock: | 549 | out_unblock: |
@@ -596,6 +605,7 @@ nlmclnt_reclaim(struct nlm_host *host, struct file_lock *fl) | |||
596 | static int | 605 | static int |
597 | nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) | 606 | nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) |
598 | { | 607 | { |
608 | struct nlm_host *host = req->a_host; | ||
599 | struct nlm_res *resp = &req->a_res; | 609 | struct nlm_res *resp = &req->a_res; |
600 | int status; | 610 | int status; |
601 | 611 | ||
@@ -604,7 +614,9 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) | |||
604 | * request, or to deny it with NLM_LCK_DENIED_GRACE_PERIOD. In either | 614 | * request, or to deny it with NLM_LCK_DENIED_GRACE_PERIOD. In either |
605 | * case, we want to unlock. | 615 | * case, we want to unlock. |
606 | */ | 616 | */ |
617 | down_read(&host->h_rwsem); | ||
607 | do_vfs_lock(fl); | 618 | do_vfs_lock(fl); |
619 | up_read(&host->h_rwsem); | ||
608 | 620 | ||
609 | if (req->a_flags & RPC_TASK_ASYNC) | 621 | if (req->a_flags & RPC_TASK_ASYNC) |
610 | return nlm_async_call(req, NLMPROC_UNLOCK, &nlmclnt_unlock_ops); | 622 | return nlm_async_call(req, NLMPROC_UNLOCK, &nlmclnt_unlock_ops); |
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 729ac427d359..38b0e8a1aec0 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c | |||
@@ -112,11 +112,12 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, | |||
112 | host->h_version = version; | 112 | host->h_version = version; |
113 | host->h_proto = proto; | 113 | host->h_proto = proto; |
114 | host->h_rpcclnt = NULL; | 114 | host->h_rpcclnt = NULL; |
115 | init_MUTEX(&host->h_sema); | 115 | mutex_init(&host->h_mutex); |
116 | host->h_nextrebind = jiffies + NLM_HOST_REBIND; | 116 | host->h_nextrebind = jiffies + NLM_HOST_REBIND; |
117 | host->h_expires = jiffies + NLM_HOST_EXPIRE; | 117 | host->h_expires = jiffies + NLM_HOST_EXPIRE; |
118 | atomic_set(&host->h_count, 1); | 118 | atomic_set(&host->h_count, 1); |
119 | init_waitqueue_head(&host->h_gracewait); | 119 | init_waitqueue_head(&host->h_gracewait); |
120 | init_rwsem(&host->h_rwsem); | ||
120 | host->h_state = 0; /* pseudo NSM state */ | 121 | host->h_state = 0; /* pseudo NSM state */ |
121 | host->h_nsmstate = 0; /* real NSM state */ | 122 | host->h_nsmstate = 0; /* real NSM state */ |
122 | host->h_server = server; | 123 | host->h_server = server; |
@@ -172,7 +173,7 @@ nlm_bind_host(struct nlm_host *host) | |||
172 | (unsigned)ntohl(host->h_addr.sin_addr.s_addr)); | 173 | (unsigned)ntohl(host->h_addr.sin_addr.s_addr)); |
173 | 174 | ||
174 | /* Lock host handle */ | 175 | /* Lock host handle */ |
175 | down(&host->h_sema); | 176 | mutex_lock(&host->h_mutex); |
176 | 177 | ||
177 | /* If we've already created an RPC client, check whether | 178 | /* If we've already created an RPC client, check whether |
178 | * RPC rebind is required | 179 | * RPC rebind is required |
@@ -204,12 +205,12 @@ nlm_bind_host(struct nlm_host *host) | |||
204 | host->h_rpcclnt = clnt; | 205 | host->h_rpcclnt = clnt; |
205 | } | 206 | } |
206 | 207 | ||
207 | up(&host->h_sema); | 208 | mutex_unlock(&host->h_mutex); |
208 | return clnt; | 209 | return clnt; |
209 | 210 | ||
210 | forgetit: | 211 | forgetit: |
211 | printk("lockd: couldn't create RPC handle for %s\n", host->h_name); | 212 | printk("lockd: couldn't create RPC handle for %s\n", host->h_name); |
212 | up(&host->h_sema); | 213 | mutex_unlock(&host->h_mutex); |
213 | return NULL; | 214 | return NULL; |
214 | } | 215 | } |
215 | 216 | ||
diff --git a/fs/namespace.c b/fs/namespace.c index c13072a5f1ee..866430bb024d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -585,8 +585,8 @@ static int do_umount(struct vfsmount *mnt, int flags) | |||
585 | */ | 585 | */ |
586 | 586 | ||
587 | lock_kernel(); | 587 | lock_kernel(); |
588 | if ((flags & MNT_FORCE) && sb->s_op->umount_begin) | 588 | if (sb->s_op->umount_begin) |
589 | sb->s_op->umount_begin(sb); | 589 | sb->s_op->umount_begin(mnt, flags); |
590 | unlock_kernel(); | 590 | unlock_kernel(); |
591 | 591 | ||
592 | /* | 592 | /* |
@@ -1172,13 +1172,46 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts, | |||
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | /* | 1174 | /* |
1175 | * go through the vfsmounts we've just consigned to the graveyard to | ||
1176 | * - check that they're still dead | ||
1177 | * - delete the vfsmount from the appropriate namespace under lock | ||
1178 | * - dispose of the corpse | ||
1179 | */ | ||
1180 | static void expire_mount_list(struct list_head *graveyard, struct list_head *mounts) | ||
1181 | { | ||
1182 | struct namespace *namespace; | ||
1183 | struct vfsmount *mnt; | ||
1184 | |||
1185 | while (!list_empty(graveyard)) { | ||
1186 | LIST_HEAD(umounts); | ||
1187 | mnt = list_entry(graveyard->next, struct vfsmount, mnt_expire); | ||
1188 | list_del_init(&mnt->mnt_expire); | ||
1189 | |||
1190 | /* don't do anything if the namespace is dead - all the | ||
1191 | * vfsmounts from it are going away anyway */ | ||
1192 | namespace = mnt->mnt_namespace; | ||
1193 | if (!namespace || !namespace->root) | ||
1194 | continue; | ||
1195 | get_namespace(namespace); | ||
1196 | |||
1197 | spin_unlock(&vfsmount_lock); | ||
1198 | down_write(&namespace_sem); | ||
1199 | expire_mount(mnt, mounts, &umounts); | ||
1200 | up_write(&namespace_sem); | ||
1201 | release_mounts(&umounts); | ||
1202 | mntput(mnt); | ||
1203 | put_namespace(namespace); | ||
1204 | spin_lock(&vfsmount_lock); | ||
1205 | } | ||
1206 | } | ||
1207 | |||
1208 | /* | ||
1175 | * process a list of expirable mountpoints with the intent of discarding any | 1209 | * process a list of expirable mountpoints with the intent of discarding any |
1176 | * mountpoints that aren't in use and haven't been touched since last we came | 1210 | * mountpoints that aren't in use and haven't been touched since last we came |
1177 | * here | 1211 | * here |
1178 | */ | 1212 | */ |
1179 | void mark_mounts_for_expiry(struct list_head *mounts) | 1213 | void mark_mounts_for_expiry(struct list_head *mounts) |
1180 | { | 1214 | { |
1181 | struct namespace *namespace; | ||
1182 | struct vfsmount *mnt, *next; | 1215 | struct vfsmount *mnt, *next; |
1183 | LIST_HEAD(graveyard); | 1216 | LIST_HEAD(graveyard); |
1184 | 1217 | ||
@@ -1202,38 +1235,79 @@ void mark_mounts_for_expiry(struct list_head *mounts) | |||
1202 | list_move(&mnt->mnt_expire, &graveyard); | 1235 | list_move(&mnt->mnt_expire, &graveyard); |
1203 | } | 1236 | } |
1204 | 1237 | ||
1205 | /* | 1238 | expire_mount_list(&graveyard, mounts); |
1206 | * go through the vfsmounts we've just consigned to the graveyard to | ||
1207 | * - check that they're still dead | ||
1208 | * - delete the vfsmount from the appropriate namespace under lock | ||
1209 | * - dispose of the corpse | ||
1210 | */ | ||
1211 | while (!list_empty(&graveyard)) { | ||
1212 | LIST_HEAD(umounts); | ||
1213 | mnt = list_entry(graveyard.next, struct vfsmount, mnt_expire); | ||
1214 | list_del_init(&mnt->mnt_expire); | ||
1215 | 1239 | ||
1216 | /* don't do anything if the namespace is dead - all the | 1240 | spin_unlock(&vfsmount_lock); |
1217 | * vfsmounts from it are going away anyway */ | 1241 | } |
1218 | namespace = mnt->mnt_namespace; | 1242 | |
1219 | if (!namespace || !namespace->root) | 1243 | EXPORT_SYMBOL_GPL(mark_mounts_for_expiry); |
1244 | |||
1245 | /* | ||
1246 | * Ripoff of 'select_parent()' | ||
1247 | * | ||
1248 | * search the list of submounts for a given mountpoint, and move any | ||
1249 | * shrinkable submounts to the 'graveyard' list. | ||
1250 | */ | ||
1251 | static int select_submounts(struct vfsmount *parent, struct list_head *graveyard) | ||
1252 | { | ||
1253 | struct vfsmount *this_parent = parent; | ||
1254 | struct list_head *next; | ||
1255 | int found = 0; | ||
1256 | |||
1257 | repeat: | ||
1258 | next = this_parent->mnt_mounts.next; | ||
1259 | resume: | ||
1260 | while (next != &this_parent->mnt_mounts) { | ||
1261 | struct list_head *tmp = next; | ||
1262 | struct vfsmount *mnt = list_entry(tmp, struct vfsmount, mnt_child); | ||
1263 | |||
1264 | next = tmp->next; | ||
1265 | if (!(mnt->mnt_flags & MNT_SHRINKABLE)) | ||
1220 | continue; | 1266 | continue; |
1221 | get_namespace(namespace); | 1267 | /* |
1268 | * Descend a level if the d_mounts list is non-empty. | ||
1269 | */ | ||
1270 | if (!list_empty(&mnt->mnt_mounts)) { | ||
1271 | this_parent = mnt; | ||
1272 | goto repeat; | ||
1273 | } | ||
1222 | 1274 | ||
1223 | spin_unlock(&vfsmount_lock); | 1275 | if (!propagate_mount_busy(mnt, 1)) { |
1224 | down_write(&namespace_sem); | 1276 | mntget(mnt); |
1225 | expire_mount(mnt, mounts, &umounts); | 1277 | list_move_tail(&mnt->mnt_expire, graveyard); |
1226 | up_write(&namespace_sem); | 1278 | found++; |
1227 | release_mounts(&umounts); | 1279 | } |
1228 | mntput(mnt); | ||
1229 | put_namespace(namespace); | ||
1230 | spin_lock(&vfsmount_lock); | ||
1231 | } | 1280 | } |
1281 | /* | ||
1282 | * All done at this level ... ascend and resume the search | ||
1283 | */ | ||
1284 | if (this_parent != parent) { | ||
1285 | next = this_parent->mnt_child.next; | ||
1286 | this_parent = this_parent->mnt_parent; | ||
1287 | goto resume; | ||
1288 | } | ||
1289 | return found; | ||
1290 | } | ||
1291 | |||
1292 | /* | ||
1293 | * process a list of expirable mountpoints with the intent of discarding any | ||
1294 | * submounts of a specific parent mountpoint | ||
1295 | */ | ||
1296 | void shrink_submounts(struct vfsmount *mountpoint, struct list_head *mounts) | ||
1297 | { | ||
1298 | LIST_HEAD(graveyard); | ||
1299 | int found; | ||
1300 | |||
1301 | spin_lock(&vfsmount_lock); | ||
1302 | |||
1303 | /* extract submounts of 'mountpoint' from the expiration list */ | ||
1304 | while ((found = select_submounts(mountpoint, &graveyard)) != 0) | ||
1305 | expire_mount_list(&graveyard, mounts); | ||
1232 | 1306 | ||
1233 | spin_unlock(&vfsmount_lock); | 1307 | spin_unlock(&vfsmount_lock); |
1234 | } | 1308 | } |
1235 | 1309 | ||
1236 | EXPORT_SYMBOL_GPL(mark_mounts_for_expiry); | 1310 | EXPORT_SYMBOL_GPL(shrink_submounts); |
1237 | 1311 | ||
1238 | /* | 1312 | /* |
1239 | * Some copy_from_user() implementations do not return the exact number of | 1313 | * Some copy_from_user() implementations do not return the exact number of |
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile index ec61fd56a1a9..0b572a0c1967 100644 --- a/fs/nfs/Makefile +++ b/fs/nfs/Makefile | |||
@@ -4,14 +4,16 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_NFS_FS) += nfs.o | 5 | obj-$(CONFIG_NFS_FS) += nfs.o |
6 | 6 | ||
7 | nfs-y := dir.o file.o inode.o nfs2xdr.o pagelist.o \ | 7 | nfs-y := dir.o file.o inode.o super.o nfs2xdr.o pagelist.o \ |
8 | proc.o read.o symlink.o unlink.o write.o | 8 | proc.o read.o symlink.o unlink.o write.o \ |
9 | namespace.o | ||
9 | nfs-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o | 10 | nfs-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o |
10 | nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o | 11 | nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o |
11 | nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o | 12 | nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o |
12 | nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ | 13 | nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ |
13 | delegation.o idmap.o \ | 14 | delegation.o idmap.o \ |
14 | callback.o callback_xdr.o callback_proc.o | 15 | callback.o callback_xdr.o callback_proc.o \ |
16 | nfs4namespace.o | ||
15 | nfs-$(CONFIG_NFS_DIRECTIO) += direct.o | 17 | nfs-$(CONFIG_NFS_DIRECTIO) += direct.o |
16 | nfs-$(CONFIG_SYSCTL) += sysctl.o | 18 | nfs-$(CONFIG_SYSCTL) += sysctl.o |
17 | nfs-objs := $(nfs-y) | 19 | nfs-objs := $(nfs-y) |
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 90c95adc8c1b..d53f8c6a9ecb 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
@@ -182,8 +182,6 @@ static int nfs_callback_authenticate(struct svc_rqst *rqstp) | |||
182 | /* | 182 | /* |
183 | * Define NFS4 callback program | 183 | * Define NFS4 callback program |
184 | */ | 184 | */ |
185 | extern struct svc_version nfs4_callback_version1; | ||
186 | |||
187 | static struct svc_version *nfs4_callback_version[] = { | 185 | static struct svc_version *nfs4_callback_version[] = { |
188 | [1] = &nfs4_callback_version1, | 186 | [1] = &nfs4_callback_version1, |
189 | }; | 187 | }; |
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 05c38cf40b69..c92991328d9a 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c | |||
@@ -202,7 +202,7 @@ static unsigned decode_recall_args(struct svc_rqst *rqstp, struct xdr_stream *xd | |||
202 | status = decode_fh(xdr, &args->fh); | 202 | status = decode_fh(xdr, &args->fh); |
203 | out: | 203 | out: |
204 | dprintk("%s: exit with status = %d\n", __FUNCTION__, status); | 204 | dprintk("%s: exit with status = %d\n", __FUNCTION__, status); |
205 | return 0; | 205 | return status; |
206 | } | 206 | } |
207 | 207 | ||
208 | static unsigned encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) | 208 | static unsigned encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index cae74dd4c7f5..3ddda6f7ecc2 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -528,7 +528,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
528 | 528 | ||
529 | lock_kernel(); | 529 | lock_kernel(); |
530 | 530 | ||
531 | res = nfs_revalidate_inode(NFS_SERVER(inode), inode); | 531 | res = nfs_revalidate_mapping(inode, filp->f_mapping); |
532 | if (res < 0) { | 532 | if (res < 0) { |
533 | unlock_kernel(); | 533 | unlock_kernel(); |
534 | return res; | 534 | return res; |
@@ -868,6 +868,17 @@ int nfs_is_exclusive_create(struct inode *dir, struct nameidata *nd) | |||
868 | return (nd->intent.open.flags & O_EXCL) != 0; | 868 | return (nd->intent.open.flags & O_EXCL) != 0; |
869 | } | 869 | } |
870 | 870 | ||
871 | static inline int nfs_reval_fsid(struct inode *dir, | ||
872 | struct nfs_fh *fh, struct nfs_fattr *fattr) | ||
873 | { | ||
874 | struct nfs_server *server = NFS_SERVER(dir); | ||
875 | |||
876 | if (!nfs_fsid_equal(&server->fsid, &fattr->fsid)) | ||
877 | /* Revalidate fsid on root dir */ | ||
878 | return __nfs_revalidate_inode(server, dir->i_sb->s_root->d_inode); | ||
879 | return 0; | ||
880 | } | ||
881 | |||
871 | static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd) | 882 | static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd) |
872 | { | 883 | { |
873 | struct dentry *res; | 884 | struct dentry *res; |
@@ -900,6 +911,11 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
900 | res = ERR_PTR(error); | 911 | res = ERR_PTR(error); |
901 | goto out_unlock; | 912 | goto out_unlock; |
902 | } | 913 | } |
914 | error = nfs_reval_fsid(dir, &fhandle, &fattr); | ||
915 | if (error < 0) { | ||
916 | res = ERR_PTR(error); | ||
917 | goto out_unlock; | ||
918 | } | ||
903 | inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); | 919 | inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); |
904 | res = (struct dentry *)inode; | 920 | res = (struct dentry *)inode; |
905 | if (IS_ERR(res)) | 921 | if (IS_ERR(res)) |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 3c72b0c07283..402005c35ab3 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -892,7 +892,7 @@ out: | |||
892 | * nfs_init_directcache - create a slab cache for nfs_direct_req structures | 892 | * nfs_init_directcache - create a slab cache for nfs_direct_req structures |
893 | * | 893 | * |
894 | */ | 894 | */ |
895 | int nfs_init_directcache(void) | 895 | int __init nfs_init_directcache(void) |
896 | { | 896 | { |
897 | nfs_direct_cachep = kmem_cache_create("nfs_direct_cache", | 897 | nfs_direct_cachep = kmem_cache_create("nfs_direct_cache", |
898 | sizeof(struct nfs_direct_req), | 898 | sizeof(struct nfs_direct_req), |
@@ -906,10 +906,10 @@ int nfs_init_directcache(void) | |||
906 | } | 906 | } |
907 | 907 | ||
908 | /** | 908 | /** |
909 | * nfs_init_directcache - destroy the slab cache for nfs_direct_req structures | 909 | * nfs_destroy_directcache - destroy the slab cache for nfs_direct_req structures |
910 | * | 910 | * |
911 | */ | 911 | */ |
912 | void nfs_destroy_directcache(void) | 912 | void __exit nfs_destroy_directcache(void) |
913 | { | 913 | { |
914 | if (kmem_cache_destroy(nfs_direct_cachep)) | 914 | if (kmem_cache_destroy(nfs_direct_cachep)) |
915 | printk(KERN_INFO "nfs_direct_cache: not all structures were freed\n"); | 915 | printk(KERN_INFO "nfs_direct_cache: not all structures were freed\n"); |
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index fa05c027ea11..add289138836 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -127,23 +127,6 @@ nfs_file_release(struct inode *inode, struct file *filp) | |||
127 | } | 127 | } |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * nfs_revalidate_file - Revalidate the page cache & related metadata | ||
131 | * @inode - pointer to inode struct | ||
132 | * @file - pointer to file | ||
133 | */ | ||
134 | static int nfs_revalidate_file(struct inode *inode, struct file *filp) | ||
135 | { | ||
136 | struct nfs_inode *nfsi = NFS_I(inode); | ||
137 | int retval = 0; | ||
138 | |||
139 | if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR)) | ||
140 | || nfs_attribute_timeout(inode)) | ||
141 | retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode); | ||
142 | nfs_revalidate_mapping(inode, filp->f_mapping); | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * nfs_revalidate_size - Revalidate the file size | 130 | * nfs_revalidate_size - Revalidate the file size |
148 | * @inode - pointer to inode struct | 131 | * @inode - pointer to inode struct |
149 | * @file - pointer to struct file | 132 | * @file - pointer to struct file |
@@ -228,7 +211,7 @@ nfs_file_read(struct kiocb *iocb, char __user * buf, size_t count, loff_t pos) | |||
228 | dentry->d_parent->d_name.name, dentry->d_name.name, | 211 | dentry->d_parent->d_name.name, dentry->d_name.name, |
229 | (unsigned long) count, (unsigned long) pos); | 212 | (unsigned long) count, (unsigned long) pos); |
230 | 213 | ||
231 | result = nfs_revalidate_file(inode, iocb->ki_filp); | 214 | result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); |
232 | nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count); | 215 | nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count); |
233 | if (!result) | 216 | if (!result) |
234 | result = generic_file_aio_read(iocb, buf, count, pos); | 217 | result = generic_file_aio_read(iocb, buf, count, pos); |
@@ -247,7 +230,7 @@ nfs_file_sendfile(struct file *filp, loff_t *ppos, size_t count, | |||
247 | dentry->d_parent->d_name.name, dentry->d_name.name, | 230 | dentry->d_parent->d_name.name, dentry->d_name.name, |
248 | (unsigned long) count, (unsigned long long) *ppos); | 231 | (unsigned long) count, (unsigned long long) *ppos); |
249 | 232 | ||
250 | res = nfs_revalidate_file(inode, filp); | 233 | res = nfs_revalidate_mapping(inode, filp->f_mapping); |
251 | if (!res) | 234 | if (!res) |
252 | res = generic_file_sendfile(filp, ppos, count, actor, target); | 235 | res = generic_file_sendfile(filp, ppos, count, actor, target); |
253 | return res; | 236 | return res; |
@@ -263,7 +246,7 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma) | |||
263 | dfprintk(VFS, "nfs: mmap(%s/%s)\n", | 246 | dfprintk(VFS, "nfs: mmap(%s/%s)\n", |
264 | dentry->d_parent->d_name.name, dentry->d_name.name); | 247 | dentry->d_parent->d_name.name, dentry->d_name.name); |
265 | 248 | ||
266 | status = nfs_revalidate_file(inode, file); | 249 | status = nfs_revalidate_mapping(inode, file->f_mapping); |
267 | if (!status) | 250 | if (!status) |
268 | status = generic_file_mmap(file, vma); | 251 | status = generic_file_mmap(file, vma); |
269 | return status; | 252 | return status; |
@@ -320,7 +303,11 @@ static int nfs_commit_write(struct file *file, struct page *page, unsigned offse | |||
320 | 303 | ||
321 | static void nfs_invalidate_page(struct page *page, unsigned long offset) | 304 | static void nfs_invalidate_page(struct page *page, unsigned long offset) |
322 | { | 305 | { |
323 | /* FIXME: we really should cancel any unstarted writes on this page */ | 306 | struct inode *inode = page->mapping->host; |
307 | |||
308 | /* Cancel any unstarted writes on this page */ | ||
309 | if (offset == 0) | ||
310 | nfs_sync_inode_wait(inode, page->index, 1, FLUSH_INVALIDATE); | ||
324 | } | 311 | } |
325 | 312 | ||
326 | static int nfs_release_page(struct page *page, gfp_t gfp) | 313 | static int nfs_release_page(struct page *page, gfp_t gfp) |
@@ -373,7 +360,6 @@ nfs_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t | |||
373 | if (result) | 360 | if (result) |
374 | goto out; | 361 | goto out; |
375 | } | 362 | } |
376 | nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); | ||
377 | 363 | ||
378 | result = count; | 364 | result = count; |
379 | if (!count) | 365 | if (!count) |
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c index 3fab5b0cfc5a..b81e7ed3c902 100644 --- a/fs/nfs/idmap.c +++ b/fs/nfs/idmap.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #include <linux/workqueue.h> | 47 | #include <linux/workqueue.h> |
48 | #include <linux/sunrpc/rpc_pipe_fs.h> | 48 | #include <linux/sunrpc/rpc_pipe_fs.h> |
49 | 49 | ||
50 | #include <linux/nfs_fs_sb.h> | ||
51 | #include <linux/nfs_fs.h> | 50 | #include <linux/nfs_fs.h> |
52 | 51 | ||
53 | #include <linux/nfs_idmap.h> | 52 | #include <linux/nfs_idmap.h> |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 937fbfc381bb..51bc88b662fe 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -36,6 +36,8 @@ | |||
36 | #include <linux/mount.h> | 36 | #include <linux/mount.h> |
37 | #include <linux/nfs_idmap.h> | 37 | #include <linux/nfs_idmap.h> |
38 | #include <linux/vfs.h> | 38 | #include <linux/vfs.h> |
39 | #include <linux/inet.h> | ||
40 | #include <linux/nfs_xdr.h> | ||
39 | 41 | ||
40 | #include <asm/system.h> | 42 | #include <asm/system.h> |
41 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
@@ -44,89 +46,17 @@ | |||
44 | #include "callback.h" | 46 | #include "callback.h" |
45 | #include "delegation.h" | 47 | #include "delegation.h" |
46 | #include "iostat.h" | 48 | #include "iostat.h" |
49 | #include "internal.h" | ||
47 | 50 | ||
48 | #define NFSDBG_FACILITY NFSDBG_VFS | 51 | #define NFSDBG_FACILITY NFSDBG_VFS |
49 | #define NFS_PARANOIA 1 | 52 | #define NFS_PARANOIA 1 |
50 | 53 | ||
51 | /* Maximum number of readahead requests | ||
52 | * FIXME: this should really be a sysctl so that users may tune it to suit | ||
53 | * their needs. People that do NFS over a slow network, might for | ||
54 | * instance want to reduce it to something closer to 1 for improved | ||
55 | * interactive response. | ||
56 | */ | ||
57 | #define NFS_MAX_READAHEAD (RPC_DEF_SLOT_TABLE - 1) | ||
58 | |||
59 | static void nfs_invalidate_inode(struct inode *); | 54 | static void nfs_invalidate_inode(struct inode *); |
60 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); | 55 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); |
61 | 56 | ||
62 | static struct inode *nfs_alloc_inode(struct super_block *sb); | ||
63 | static void nfs_destroy_inode(struct inode *); | ||
64 | static int nfs_write_inode(struct inode *,int); | ||
65 | static void nfs_delete_inode(struct inode *); | ||
66 | static void nfs_clear_inode(struct inode *); | ||
67 | static void nfs_umount_begin(struct super_block *); | ||
68 | static int nfs_statfs(struct dentry *, struct kstatfs *); | ||
69 | static int nfs_show_options(struct seq_file *, struct vfsmount *); | ||
70 | static int nfs_show_stats(struct seq_file *, struct vfsmount *); | ||
71 | static void nfs_zap_acl_cache(struct inode *); | 57 | static void nfs_zap_acl_cache(struct inode *); |
72 | 58 | ||
73 | static struct rpc_program nfs_program; | 59 | static kmem_cache_t * nfs_inode_cachep; |
74 | |||
75 | static struct super_operations nfs_sops = { | ||
76 | .alloc_inode = nfs_alloc_inode, | ||
77 | .destroy_inode = nfs_destroy_inode, | ||
78 | .write_inode = nfs_write_inode, | ||
79 | .delete_inode = nfs_delete_inode, | ||
80 | .statfs = nfs_statfs, | ||
81 | .clear_inode = nfs_clear_inode, | ||
82 | .umount_begin = nfs_umount_begin, | ||
83 | .show_options = nfs_show_options, | ||
84 | .show_stats = nfs_show_stats, | ||
85 | }; | ||
86 | |||
87 | /* | ||
88 | * RPC cruft for NFS | ||
89 | */ | ||
90 | static struct rpc_stat nfs_rpcstat = { | ||
91 | .program = &nfs_program | ||
92 | }; | ||
93 | static struct rpc_version * nfs_version[] = { | ||
94 | NULL, | ||
95 | NULL, | ||
96 | &nfs_version2, | ||
97 | #if defined(CONFIG_NFS_V3) | ||
98 | &nfs_version3, | ||
99 | #elif defined(CONFIG_NFS_V4) | ||
100 | NULL, | ||
101 | #endif | ||
102 | #if defined(CONFIG_NFS_V4) | ||
103 | &nfs_version4, | ||
104 | #endif | ||
105 | }; | ||
106 | |||
107 | static struct rpc_program nfs_program = { | ||
108 | .name = "nfs", | ||
109 | .number = NFS_PROGRAM, | ||
110 | .nrvers = ARRAY_SIZE(nfs_version), | ||
111 | .version = nfs_version, | ||
112 | .stats = &nfs_rpcstat, | ||
113 | .pipe_dir_name = "/nfs", | ||
114 | }; | ||
115 | |||
116 | #ifdef CONFIG_NFS_V3_ACL | ||
117 | static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program }; | ||
118 | static struct rpc_version * nfsacl_version[] = { | ||
119 | [3] = &nfsacl_version3, | ||
120 | }; | ||
121 | |||
122 | struct rpc_program nfsacl_program = { | ||
123 | .name = "nfsacl", | ||
124 | .number = NFS_ACL_PROGRAM, | ||
125 | .nrvers = ARRAY_SIZE(nfsacl_version), | ||
126 | .version = nfsacl_version, | ||
127 | .stats = &nfsacl_rpcstat, | ||
128 | }; | ||
129 | #endif /* CONFIG_NFS_V3_ACL */ | ||
130 | 60 | ||
131 | static inline unsigned long | 61 | static inline unsigned long |
132 | nfs_fattr_to_ino_t(struct nfs_fattr *fattr) | 62 | nfs_fattr_to_ino_t(struct nfs_fattr *fattr) |
@@ -134,8 +64,7 @@ nfs_fattr_to_ino_t(struct nfs_fattr *fattr) | |||
134 | return nfs_fileid_to_ino_t(fattr->fileid); | 64 | return nfs_fileid_to_ino_t(fattr->fileid); |
135 | } | 65 | } |
136 | 66 | ||
137 | static int | 67 | int nfs_write_inode(struct inode *inode, int sync) |
138 | nfs_write_inode(struct inode *inode, int sync) | ||
139 | { | 68 | { |
140 | int flags = sync ? FLUSH_SYNC : 0; | 69 | int flags = sync ? FLUSH_SYNC : 0; |
141 | int ret; | 70 | int ret; |
@@ -146,31 +75,15 @@ nfs_write_inode(struct inode *inode, int sync) | |||
146 | return 0; | 75 | return 0; |
147 | } | 76 | } |
148 | 77 | ||
149 | static void | 78 | void nfs_clear_inode(struct inode *inode) |
150 | nfs_delete_inode(struct inode * inode) | ||
151 | { | 79 | { |
152 | dprintk("NFS: delete_inode(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); | 80 | struct nfs_inode *nfsi = NFS_I(inode); |
153 | 81 | struct rpc_cred *cred; | |
154 | truncate_inode_pages(&inode->i_data, 0); | ||
155 | 82 | ||
156 | nfs_wb_all(inode); | ||
157 | /* | 83 | /* |
158 | * The following should never happen... | 84 | * The following should never happen... |
159 | */ | 85 | */ |
160 | if (nfs_have_writebacks(inode)) { | 86 | BUG_ON(nfs_have_writebacks(inode)); |
161 | printk(KERN_ERR "nfs_delete_inode: inode %ld has pending RPC requests\n", inode->i_ino); | ||
162 | } | ||
163 | |||
164 | clear_inode(inode); | ||
165 | } | ||
166 | |||
167 | static void | ||
168 | nfs_clear_inode(struct inode *inode) | ||
169 | { | ||
170 | struct nfs_inode *nfsi = NFS_I(inode); | ||
171 | struct rpc_cred *cred; | ||
172 | |||
173 | nfs_wb_all(inode); | ||
174 | BUG_ON (!list_empty(&nfsi->open_files)); | 87 | BUG_ON (!list_empty(&nfsi->open_files)); |
175 | nfs_zap_acl_cache(inode); | 88 | nfs_zap_acl_cache(inode); |
176 | cred = nfsi->cache_access.cred; | 89 | cred = nfsi->cache_access.cred; |
@@ -179,555 +92,6 @@ nfs_clear_inode(struct inode *inode) | |||
179 | BUG_ON(atomic_read(&nfsi->data_updates) != 0); | 92 | BUG_ON(atomic_read(&nfsi->data_updates) != 0); |
180 | } | 93 | } |
181 | 94 | ||
182 | void | ||
183 | nfs_umount_begin(struct super_block *sb) | ||
184 | { | ||
185 | struct rpc_clnt *rpc = NFS_SB(sb)->client; | ||
186 | |||
187 | /* -EIO all pending I/O */ | ||
188 | if (!IS_ERR(rpc)) | ||
189 | rpc_killall_tasks(rpc); | ||
190 | rpc = NFS_SB(sb)->client_acl; | ||
191 | if (!IS_ERR(rpc)) | ||
192 | rpc_killall_tasks(rpc); | ||
193 | } | ||
194 | |||
195 | |||
196 | static inline unsigned long | ||
197 | nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp) | ||
198 | { | ||
199 | /* make sure blocksize is a power of two */ | ||
200 | if ((bsize & (bsize - 1)) || nrbitsp) { | ||
201 | unsigned char nrbits; | ||
202 | |||
203 | for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--) | ||
204 | ; | ||
205 | bsize = 1 << nrbits; | ||
206 | if (nrbitsp) | ||
207 | *nrbitsp = nrbits; | ||
208 | } | ||
209 | |||
210 | return bsize; | ||
211 | } | ||
212 | |||
213 | /* | ||
214 | * Calculate the number of 512byte blocks used. | ||
215 | */ | ||
216 | static inline unsigned long | ||
217 | nfs_calc_block_size(u64 tsize) | ||
218 | { | ||
219 | loff_t used = (tsize + 511) >> 9; | ||
220 | return (used > ULONG_MAX) ? ULONG_MAX : used; | ||
221 | } | ||
222 | |||
223 | /* | ||
224 | * Compute and set NFS server blocksize | ||
225 | */ | ||
226 | static inline unsigned long | ||
227 | nfs_block_size(unsigned long bsize, unsigned char *nrbitsp) | ||
228 | { | ||
229 | if (bsize < NFS_MIN_FILE_IO_SIZE) | ||
230 | bsize = NFS_DEF_FILE_IO_SIZE; | ||
231 | else if (bsize >= NFS_MAX_FILE_IO_SIZE) | ||
232 | bsize = NFS_MAX_FILE_IO_SIZE; | ||
233 | |||
234 | return nfs_block_bits(bsize, nrbitsp); | ||
235 | } | ||
236 | |||
237 | /* | ||
238 | * Obtain the root inode of the file system. | ||
239 | */ | ||
240 | static struct inode * | ||
241 | nfs_get_root(struct super_block *sb, struct nfs_fh *rootfh, struct nfs_fsinfo *fsinfo) | ||
242 | { | ||
243 | struct nfs_server *server = NFS_SB(sb); | ||
244 | int error; | ||
245 | |||
246 | error = server->rpc_ops->getroot(server, rootfh, fsinfo); | ||
247 | if (error < 0) { | ||
248 | dprintk("nfs_get_root: getattr error = %d\n", -error); | ||
249 | return ERR_PTR(error); | ||
250 | } | ||
251 | |||
252 | return nfs_fhget(sb, rootfh, fsinfo->fattr); | ||
253 | } | ||
254 | |||
255 | /* | ||
256 | * Do NFS version-independent mount processing, and sanity checking | ||
257 | */ | ||
258 | static int | ||
259 | nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor) | ||
260 | { | ||
261 | struct nfs_server *server; | ||
262 | struct inode *root_inode; | ||
263 | struct nfs_fattr fattr; | ||
264 | struct nfs_fsinfo fsinfo = { | ||
265 | .fattr = &fattr, | ||
266 | }; | ||
267 | struct nfs_pathconf pathinfo = { | ||
268 | .fattr = &fattr, | ||
269 | }; | ||
270 | int no_root_error = 0; | ||
271 | unsigned long max_rpc_payload; | ||
272 | |||
273 | /* We probably want something more informative here */ | ||
274 | snprintf(sb->s_id, sizeof(sb->s_id), "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev)); | ||
275 | |||
276 | server = NFS_SB(sb); | ||
277 | |||
278 | sb->s_magic = NFS_SUPER_MAGIC; | ||
279 | |||
280 | server->io_stats = nfs_alloc_iostats(); | ||
281 | if (server->io_stats == NULL) | ||
282 | return -ENOMEM; | ||
283 | |||
284 | root_inode = nfs_get_root(sb, &server->fh, &fsinfo); | ||
285 | /* Did getting the root inode fail? */ | ||
286 | if (IS_ERR(root_inode)) { | ||
287 | no_root_error = PTR_ERR(root_inode); | ||
288 | goto out_no_root; | ||
289 | } | ||
290 | sb->s_root = d_alloc_root(root_inode); | ||
291 | if (!sb->s_root) { | ||
292 | no_root_error = -ENOMEM; | ||
293 | goto out_no_root; | ||
294 | } | ||
295 | sb->s_root->d_op = server->rpc_ops->dentry_ops; | ||
296 | |||
297 | /* mount time stamp, in seconds */ | ||
298 | server->mount_time = jiffies; | ||
299 | |||
300 | /* Get some general file system info */ | ||
301 | if (server->namelen == 0 && | ||
302 | server->rpc_ops->pathconf(server, &server->fh, &pathinfo) >= 0) | ||
303 | server->namelen = pathinfo.max_namelen; | ||
304 | /* Work out a lot of parameters */ | ||
305 | if (server->rsize == 0) | ||
306 | server->rsize = nfs_block_size(fsinfo.rtpref, NULL); | ||
307 | if (server->wsize == 0) | ||
308 | server->wsize = nfs_block_size(fsinfo.wtpref, NULL); | ||
309 | |||
310 | if (fsinfo.rtmax >= 512 && server->rsize > fsinfo.rtmax) | ||
311 | server->rsize = nfs_block_size(fsinfo.rtmax, NULL); | ||
312 | if (fsinfo.wtmax >= 512 && server->wsize > fsinfo.wtmax) | ||
313 | server->wsize = nfs_block_size(fsinfo.wtmax, NULL); | ||
314 | |||
315 | max_rpc_payload = nfs_block_size(rpc_max_payload(server->client), NULL); | ||
316 | if (server->rsize > max_rpc_payload) | ||
317 | server->rsize = max_rpc_payload; | ||
318 | if (server->rsize > NFS_MAX_FILE_IO_SIZE) | ||
319 | server->rsize = NFS_MAX_FILE_IO_SIZE; | ||
320 | server->rpages = (server->rsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | ||
321 | |||
322 | if (server->wsize > max_rpc_payload) | ||
323 | server->wsize = max_rpc_payload; | ||
324 | if (server->wsize > NFS_MAX_FILE_IO_SIZE) | ||
325 | server->wsize = NFS_MAX_FILE_IO_SIZE; | ||
326 | server->wpages = (server->wsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | ||
327 | |||
328 | if (sb->s_blocksize == 0) | ||
329 | sb->s_blocksize = nfs_block_bits(server->wsize, | ||
330 | &sb->s_blocksize_bits); | ||
331 | server->wtmult = nfs_block_bits(fsinfo.wtmult, NULL); | ||
332 | |||
333 | server->dtsize = nfs_block_size(fsinfo.dtpref, NULL); | ||
334 | if (server->dtsize > PAGE_CACHE_SIZE) | ||
335 | server->dtsize = PAGE_CACHE_SIZE; | ||
336 | if (server->dtsize > server->rsize) | ||
337 | server->dtsize = server->rsize; | ||
338 | |||
339 | if (server->flags & NFS_MOUNT_NOAC) { | ||
340 | server->acregmin = server->acregmax = 0; | ||
341 | server->acdirmin = server->acdirmax = 0; | ||
342 | sb->s_flags |= MS_SYNCHRONOUS; | ||
343 | } | ||
344 | server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD; | ||
345 | |||
346 | sb->s_maxbytes = fsinfo.maxfilesize; | ||
347 | if (sb->s_maxbytes > MAX_LFS_FILESIZE) | ||
348 | sb->s_maxbytes = MAX_LFS_FILESIZE; | ||
349 | |||
350 | server->client->cl_intr = (server->flags & NFS_MOUNT_INTR) ? 1 : 0; | ||
351 | server->client->cl_softrtry = (server->flags & NFS_MOUNT_SOFT) ? 1 : 0; | ||
352 | |||
353 | /* We're airborne Set socket buffersize */ | ||
354 | rpc_setbufsize(server->client, server->wsize + 100, server->rsize + 100); | ||
355 | return 0; | ||
356 | /* Yargs. It didn't work out. */ | ||
357 | out_no_root: | ||
358 | dprintk("nfs_sb_init: get root inode failed: errno %d\n", -no_root_error); | ||
359 | if (!IS_ERR(root_inode)) | ||
360 | iput(root_inode); | ||
361 | return no_root_error; | ||
362 | } | ||
363 | |||
364 | static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, unsigned int timeo, unsigned int retrans) | ||
365 | { | ||
366 | to->to_initval = timeo * HZ / 10; | ||
367 | to->to_retries = retrans; | ||
368 | if (!to->to_retries) | ||
369 | to->to_retries = 2; | ||
370 | |||
371 | switch (proto) { | ||
372 | case IPPROTO_TCP: | ||
373 | if (!to->to_initval) | ||
374 | to->to_initval = 60 * HZ; | ||
375 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) | ||
376 | to->to_initval = NFS_MAX_TCP_TIMEOUT; | ||
377 | to->to_increment = to->to_initval; | ||
378 | to->to_maxval = to->to_initval + (to->to_increment * to->to_retries); | ||
379 | to->to_exponential = 0; | ||
380 | break; | ||
381 | case IPPROTO_UDP: | ||
382 | default: | ||
383 | if (!to->to_initval) | ||
384 | to->to_initval = 11 * HZ / 10; | ||
385 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) | ||
386 | to->to_initval = NFS_MAX_UDP_TIMEOUT; | ||
387 | to->to_maxval = NFS_MAX_UDP_TIMEOUT; | ||
388 | to->to_exponential = 1; | ||
389 | break; | ||
390 | } | ||
391 | } | ||
392 | |||
393 | /* | ||
394 | * Create an RPC client handle. | ||
395 | */ | ||
396 | static struct rpc_clnt * | ||
397 | nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data) | ||
398 | { | ||
399 | struct rpc_timeout timeparms; | ||
400 | struct rpc_xprt *xprt = NULL; | ||
401 | struct rpc_clnt *clnt = NULL; | ||
402 | int proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP; | ||
403 | |||
404 | nfs_init_timeout_values(&timeparms, proto, data->timeo, data->retrans); | ||
405 | |||
406 | server->retrans_timeo = timeparms.to_initval; | ||
407 | server->retrans_count = timeparms.to_retries; | ||
408 | |||
409 | /* create transport and client */ | ||
410 | xprt = xprt_create_proto(proto, &server->addr, &timeparms); | ||
411 | if (IS_ERR(xprt)) { | ||
412 | dprintk("%s: cannot create RPC transport. Error = %ld\n", | ||
413 | __FUNCTION__, PTR_ERR(xprt)); | ||
414 | return (struct rpc_clnt *)xprt; | ||
415 | } | ||
416 | clnt = rpc_create_client(xprt, server->hostname, &nfs_program, | ||
417 | server->rpc_ops->version, data->pseudoflavor); | ||
418 | if (IS_ERR(clnt)) { | ||
419 | dprintk("%s: cannot create RPC client. Error = %ld\n", | ||
420 | __FUNCTION__, PTR_ERR(xprt)); | ||
421 | goto out_fail; | ||
422 | } | ||
423 | |||
424 | clnt->cl_intr = 1; | ||
425 | clnt->cl_softrtry = 1; | ||
426 | |||
427 | return clnt; | ||
428 | |||
429 | out_fail: | ||
430 | return clnt; | ||
431 | } | ||
432 | |||
433 | /* | ||
434 | * The way this works is that the mount process passes a structure | ||
435 | * in the data argument which contains the server's IP address | ||
436 | * and the root file handle obtained from the server's mount | ||
437 | * daemon. We stash these away in the private superblock fields. | ||
438 | */ | ||
439 | static int | ||
440 | nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent) | ||
441 | { | ||
442 | struct nfs_server *server; | ||
443 | rpc_authflavor_t authflavor; | ||
444 | |||
445 | server = NFS_SB(sb); | ||
446 | sb->s_blocksize_bits = 0; | ||
447 | sb->s_blocksize = 0; | ||
448 | if (data->bsize) | ||
449 | sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits); | ||
450 | if (data->rsize) | ||
451 | server->rsize = nfs_block_size(data->rsize, NULL); | ||
452 | if (data->wsize) | ||
453 | server->wsize = nfs_block_size(data->wsize, NULL); | ||
454 | server->flags = data->flags & NFS_MOUNT_FLAGMASK; | ||
455 | |||
456 | server->acregmin = data->acregmin*HZ; | ||
457 | server->acregmax = data->acregmax*HZ; | ||
458 | server->acdirmin = data->acdirmin*HZ; | ||
459 | server->acdirmax = data->acdirmax*HZ; | ||
460 | |||
461 | /* Start lockd here, before we might error out */ | ||
462 | if (!(server->flags & NFS_MOUNT_NONLM)) | ||
463 | lockd_up(); | ||
464 | |||
465 | server->namelen = data->namlen; | ||
466 | server->hostname = kmalloc(strlen(data->hostname) + 1, GFP_KERNEL); | ||
467 | if (!server->hostname) | ||
468 | return -ENOMEM; | ||
469 | strcpy(server->hostname, data->hostname); | ||
470 | |||
471 | /* Check NFS protocol revision and initialize RPC op vector | ||
472 | * and file handle pool. */ | ||
473 | #ifdef CONFIG_NFS_V3 | ||
474 | if (server->flags & NFS_MOUNT_VER3) { | ||
475 | server->rpc_ops = &nfs_v3_clientops; | ||
476 | server->caps |= NFS_CAP_READDIRPLUS; | ||
477 | } else { | ||
478 | server->rpc_ops = &nfs_v2_clientops; | ||
479 | } | ||
480 | #else | ||
481 | server->rpc_ops = &nfs_v2_clientops; | ||
482 | #endif | ||
483 | |||
484 | /* Fill in pseudoflavor for mount version < 5 */ | ||
485 | if (!(data->flags & NFS_MOUNT_SECFLAVOUR)) | ||
486 | data->pseudoflavor = RPC_AUTH_UNIX; | ||
487 | authflavor = data->pseudoflavor; /* save for sb_init() */ | ||
488 | /* XXX maybe we want to add a server->pseudoflavor field */ | ||
489 | |||
490 | /* Create RPC client handles */ | ||
491 | server->client = nfs_create_client(server, data); | ||
492 | if (IS_ERR(server->client)) | ||
493 | return PTR_ERR(server->client); | ||
494 | /* RFC 2623, sec 2.3.2 */ | ||
495 | if (authflavor != RPC_AUTH_UNIX) { | ||
496 | struct rpc_auth *auth; | ||
497 | |||
498 | server->client_sys = rpc_clone_client(server->client); | ||
499 | if (IS_ERR(server->client_sys)) | ||
500 | return PTR_ERR(server->client_sys); | ||
501 | auth = rpcauth_create(RPC_AUTH_UNIX, server->client_sys); | ||
502 | if (IS_ERR(auth)) | ||
503 | return PTR_ERR(auth); | ||
504 | } else { | ||
505 | atomic_inc(&server->client->cl_count); | ||
506 | server->client_sys = server->client; | ||
507 | } | ||
508 | if (server->flags & NFS_MOUNT_VER3) { | ||
509 | #ifdef CONFIG_NFS_V3_ACL | ||
510 | if (!(server->flags & NFS_MOUNT_NOACL)) { | ||
511 | server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3); | ||
512 | /* No errors! Assume that Sun nfsacls are supported */ | ||
513 | if (!IS_ERR(server->client_acl)) | ||
514 | server->caps |= NFS_CAP_ACLS; | ||
515 | } | ||
516 | #else | ||
517 | server->flags &= ~NFS_MOUNT_NOACL; | ||
518 | #endif /* CONFIG_NFS_V3_ACL */ | ||
519 | /* | ||
520 | * The VFS shouldn't apply the umask to mode bits. We will | ||
521 | * do so ourselves when necessary. | ||
522 | */ | ||
523 | sb->s_flags |= MS_POSIXACL; | ||
524 | if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN) | ||
525 | server->namelen = NFS3_MAXNAMLEN; | ||
526 | sb->s_time_gran = 1; | ||
527 | } else { | ||
528 | if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN) | ||
529 | server->namelen = NFS2_MAXNAMLEN; | ||
530 | } | ||
531 | |||
532 | sb->s_op = &nfs_sops; | ||
533 | return nfs_sb_init(sb, authflavor); | ||
534 | } | ||
535 | |||
536 | static int | ||
537 | nfs_statfs(struct dentry *dentry, struct kstatfs *buf) | ||
538 | { | ||
539 | struct super_block *sb = dentry->d_sb; | ||
540 | struct nfs_server *server = NFS_SB(sb); | ||
541 | unsigned char blockbits; | ||
542 | unsigned long blockres; | ||
543 | struct nfs_fh *rootfh = NFS_FH(sb->s_root->d_inode); | ||
544 | struct nfs_fattr fattr; | ||
545 | struct nfs_fsstat res = { | ||
546 | .fattr = &fattr, | ||
547 | }; | ||
548 | int error; | ||
549 | |||
550 | lock_kernel(); | ||
551 | |||
552 | error = server->rpc_ops->statfs(server, rootfh, &res); | ||
553 | buf->f_type = NFS_SUPER_MAGIC; | ||
554 | if (error < 0) | ||
555 | goto out_err; | ||
556 | |||
557 | /* | ||
558 | * Current versions of glibc do not correctly handle the | ||
559 | * case where f_frsize != f_bsize. Eventually we want to | ||
560 | * report the value of wtmult in this field. | ||
561 | */ | ||
562 | buf->f_frsize = sb->s_blocksize; | ||
563 | |||
564 | /* | ||
565 | * On most *nix systems, f_blocks, f_bfree, and f_bavail | ||
566 | * are reported in units of f_frsize. Linux hasn't had | ||
567 | * an f_frsize field in its statfs struct until recently, | ||
568 | * thus historically Linux's sys_statfs reports these | ||
569 | * fields in units of f_bsize. | ||
570 | */ | ||
571 | buf->f_bsize = sb->s_blocksize; | ||
572 | blockbits = sb->s_blocksize_bits; | ||
573 | blockres = (1 << blockbits) - 1; | ||
574 | buf->f_blocks = (res.tbytes + blockres) >> blockbits; | ||
575 | buf->f_bfree = (res.fbytes + blockres) >> blockbits; | ||
576 | buf->f_bavail = (res.abytes + blockres) >> blockbits; | ||
577 | |||
578 | buf->f_files = res.tfiles; | ||
579 | buf->f_ffree = res.afiles; | ||
580 | |||
581 | buf->f_namelen = server->namelen; | ||
582 | out: | ||
583 | unlock_kernel(); | ||
584 | return 0; | ||
585 | |||
586 | out_err: | ||
587 | dprintk("%s: statfs error = %d\n", __FUNCTION__, -error); | ||
588 | buf->f_bsize = buf->f_blocks = buf->f_bfree = buf->f_bavail = -1; | ||
589 | goto out; | ||
590 | |||
591 | } | ||
592 | |||
593 | static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, int showdefaults) | ||
594 | { | ||
595 | static struct proc_nfs_info { | ||
596 | int flag; | ||
597 | char *str; | ||
598 | char *nostr; | ||
599 | } nfs_info[] = { | ||
600 | { NFS_MOUNT_SOFT, ",soft", ",hard" }, | ||
601 | { NFS_MOUNT_INTR, ",intr", "" }, | ||
602 | { NFS_MOUNT_NOCTO, ",nocto", "" }, | ||
603 | { NFS_MOUNT_NOAC, ",noac", "" }, | ||
604 | { NFS_MOUNT_NONLM, ",nolock", "" }, | ||
605 | { NFS_MOUNT_NOACL, ",noacl", "" }, | ||
606 | { 0, NULL, NULL } | ||
607 | }; | ||
608 | struct proc_nfs_info *nfs_infop; | ||
609 | char buf[12]; | ||
610 | char *proto; | ||
611 | |||
612 | seq_printf(m, ",vers=%d", nfss->rpc_ops->version); | ||
613 | seq_printf(m, ",rsize=%d", nfss->rsize); | ||
614 | seq_printf(m, ",wsize=%d", nfss->wsize); | ||
615 | if (nfss->acregmin != 3*HZ || showdefaults) | ||
616 | seq_printf(m, ",acregmin=%d", nfss->acregmin/HZ); | ||
617 | if (nfss->acregmax != 60*HZ || showdefaults) | ||
618 | seq_printf(m, ",acregmax=%d", nfss->acregmax/HZ); | ||
619 | if (nfss->acdirmin != 30*HZ || showdefaults) | ||
620 | seq_printf(m, ",acdirmin=%d", nfss->acdirmin/HZ); | ||
621 | if (nfss->acdirmax != 60*HZ || showdefaults) | ||
622 | seq_printf(m, ",acdirmax=%d", nfss->acdirmax/HZ); | ||
623 | for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { | ||
624 | if (nfss->flags & nfs_infop->flag) | ||
625 | seq_puts(m, nfs_infop->str); | ||
626 | else | ||
627 | seq_puts(m, nfs_infop->nostr); | ||
628 | } | ||
629 | switch (nfss->client->cl_xprt->prot) { | ||
630 | case IPPROTO_TCP: | ||
631 | proto = "tcp"; | ||
632 | break; | ||
633 | case IPPROTO_UDP: | ||
634 | proto = "udp"; | ||
635 | break; | ||
636 | default: | ||
637 | snprintf(buf, sizeof(buf), "%u", nfss->client->cl_xprt->prot); | ||
638 | proto = buf; | ||
639 | } | ||
640 | seq_printf(m, ",proto=%s", proto); | ||
641 | seq_printf(m, ",timeo=%lu", 10U * nfss->retrans_timeo / HZ); | ||
642 | seq_printf(m, ",retrans=%u", nfss->retrans_count); | ||
643 | } | ||
644 | |||
645 | static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt) | ||
646 | { | ||
647 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); | ||
648 | |||
649 | nfs_show_mount_options(m, nfss, 0); | ||
650 | |||
651 | seq_puts(m, ",addr="); | ||
652 | seq_escape(m, nfss->hostname, " \t\n\\"); | ||
653 | |||
654 | return 0; | ||
655 | } | ||
656 | |||
657 | static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) | ||
658 | { | ||
659 | int i, cpu; | ||
660 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); | ||
661 | struct rpc_auth *auth = nfss->client->cl_auth; | ||
662 | struct nfs_iostats totals = { }; | ||
663 | |||
664 | seq_printf(m, "statvers=%s", NFS_IOSTAT_VERS); | ||
665 | |||
666 | /* | ||
667 | * Display all mount option settings | ||
668 | */ | ||
669 | seq_printf(m, "\n\topts:\t"); | ||
670 | seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw"); | ||
671 | seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : ""); | ||
672 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : ""); | ||
673 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : ""); | ||
674 | nfs_show_mount_options(m, nfss, 1); | ||
675 | |||
676 | seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ); | ||
677 | |||
678 | seq_printf(m, "\n\tcaps:\t"); | ||
679 | seq_printf(m, "caps=0x%x", nfss->caps); | ||
680 | seq_printf(m, ",wtmult=%d", nfss->wtmult); | ||
681 | seq_printf(m, ",dtsize=%d", nfss->dtsize); | ||
682 | seq_printf(m, ",bsize=%d", nfss->bsize); | ||
683 | seq_printf(m, ",namelen=%d", nfss->namelen); | ||
684 | |||
685 | #ifdef CONFIG_NFS_V4 | ||
686 | if (nfss->rpc_ops->version == 4) { | ||
687 | seq_printf(m, "\n\tnfsv4:\t"); | ||
688 | seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]); | ||
689 | seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]); | ||
690 | seq_printf(m, ",acl=0x%x", nfss->acl_bitmask); | ||
691 | } | ||
692 | #endif | ||
693 | |||
694 | /* | ||
695 | * Display security flavor in effect for this mount | ||
696 | */ | ||
697 | seq_printf(m, "\n\tsec:\tflavor=%d", auth->au_ops->au_flavor); | ||
698 | if (auth->au_flavor) | ||
699 | seq_printf(m, ",pseudoflavor=%d", auth->au_flavor); | ||
700 | |||
701 | /* | ||
702 | * Display superblock I/O counters | ||
703 | */ | ||
704 | for_each_possible_cpu(cpu) { | ||
705 | struct nfs_iostats *stats; | ||
706 | |||
707 | preempt_disable(); | ||
708 | stats = per_cpu_ptr(nfss->io_stats, cpu); | ||
709 | |||
710 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) | ||
711 | totals.events[i] += stats->events[i]; | ||
712 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) | ||
713 | totals.bytes[i] += stats->bytes[i]; | ||
714 | |||
715 | preempt_enable(); | ||
716 | } | ||
717 | |||
718 | seq_printf(m, "\n\tevents:\t"); | ||
719 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) | ||
720 | seq_printf(m, "%lu ", totals.events[i]); | ||
721 | seq_printf(m, "\n\tbytes:\t"); | ||
722 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) | ||
723 | seq_printf(m, "%Lu ", totals.bytes[i]); | ||
724 | seq_printf(m, "\n"); | ||
725 | |||
726 | rpc_print_iostats(m, nfss->client); | ||
727 | |||
728 | return 0; | ||
729 | } | ||
730 | |||
731 | /** | 95 | /** |
732 | * nfs_sync_mapping - helper to flush all mmapped dirty data to disk | 96 | * nfs_sync_mapping - helper to flush all mmapped dirty data to disk |
733 | */ | 97 | */ |
@@ -890,6 +254,14 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) | |||
890 | if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) | 254 | if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) |
891 | && fattr->size <= NFS_LIMIT_READDIRPLUS) | 255 | && fattr->size <= NFS_LIMIT_READDIRPLUS) |
892 | set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode)); | 256 | set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode)); |
257 | /* Deal with crossing mountpoints */ | ||
258 | if (!nfs_fsid_equal(&NFS_SB(sb)->fsid, &fattr->fsid)) { | ||
259 | if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) | ||
260 | inode->i_op = &nfs_referral_inode_operations; | ||
261 | else | ||
262 | inode->i_op = &nfs_mountpoint_inode_operations; | ||
263 | inode->i_fop = NULL; | ||
264 | } | ||
893 | } else if (S_ISLNK(inode->i_mode)) | 265 | } else if (S_ISLNK(inode->i_mode)) |
894 | inode->i_op = &nfs_symlink_inode_operations; | 266 | inode->i_op = &nfs_symlink_inode_operations; |
895 | else | 267 | else |
@@ -1208,6 +580,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1208 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", | 580 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", |
1209 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); | 581 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); |
1210 | 582 | ||
583 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); | ||
1211 | lock_kernel(); | 584 | lock_kernel(); |
1212 | if (!inode || is_bad_inode(inode)) | 585 | if (!inode || is_bad_inode(inode)) |
1213 | goto out_nowait; | 586 | goto out_nowait; |
@@ -1221,7 +594,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1221 | status = -ESTALE; | 594 | status = -ESTALE; |
1222 | /* Do we trust the cached ESTALE? */ | 595 | /* Do we trust the cached ESTALE? */ |
1223 | if (NFS_ATTRTIMEO(inode) != 0) { | 596 | if (NFS_ATTRTIMEO(inode) != 0) { |
1224 | if (nfsi->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ATIME)) { | 597 | if (nfsi->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME)) { |
1225 | /* no */ | 598 | /* no */ |
1226 | } else | 599 | } else |
1227 | goto out; | 600 | goto out; |
@@ -1252,8 +625,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1252 | } | 625 | } |
1253 | spin_unlock(&inode->i_lock); | 626 | spin_unlock(&inode->i_lock); |
1254 | 627 | ||
1255 | nfs_revalidate_mapping(inode, inode->i_mapping); | ||
1256 | |||
1257 | if (nfsi->cache_validity & NFS_INO_INVALID_ACL) | 628 | if (nfsi->cache_validity & NFS_INO_INVALID_ACL) |
1258 | nfs_zap_acl_cache(inode); | 629 | nfs_zap_acl_cache(inode); |
1259 | 630 | ||
@@ -1287,8 +658,7 @@ int nfs_attribute_timeout(struct inode *inode) | |||
1287 | */ | 658 | */ |
1288 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | 659 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) |
1289 | { | 660 | { |
1290 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); | 661 | if (!(NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATTR) |
1291 | if (!(NFS_I(inode)->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA)) | ||
1292 | && !nfs_attribute_timeout(inode)) | 662 | && !nfs_attribute_timeout(inode)) |
1293 | return NFS_STALE(inode) ? -ESTALE : 0; | 663 | return NFS_STALE(inode) ? -ESTALE : 0; |
1294 | return __nfs_revalidate_inode(server, inode); | 664 | return __nfs_revalidate_inode(server, inode); |
@@ -1299,9 +669,16 @@ int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1299 | * @inode - pointer to host inode | 669 | * @inode - pointer to host inode |
1300 | * @mapping - pointer to mapping | 670 | * @mapping - pointer to mapping |
1301 | */ | 671 | */ |
1302 | void nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) | 672 | int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) |
1303 | { | 673 | { |
1304 | struct nfs_inode *nfsi = NFS_I(inode); | 674 | struct nfs_inode *nfsi = NFS_I(inode); |
675 | int ret = 0; | ||
676 | |||
677 | if (NFS_STALE(inode)) | ||
678 | ret = -ESTALE; | ||
679 | if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) | ||
680 | || nfs_attribute_timeout(inode)) | ||
681 | ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode); | ||
1305 | 682 | ||
1306 | if (nfsi->cache_validity & NFS_INO_INVALID_DATA) { | 683 | if (nfsi->cache_validity & NFS_INO_INVALID_DATA) { |
1307 | nfs_inc_stats(inode, NFSIOS_DATAINVALIDATE); | 684 | nfs_inc_stats(inode, NFSIOS_DATAINVALIDATE); |
@@ -1322,6 +699,7 @@ void nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) | |||
1322 | inode->i_sb->s_id, | 699 | inode->i_sb->s_id, |
1323 | (long long)NFS_FILEID(inode)); | 700 | (long long)NFS_FILEID(inode)); |
1324 | } | 701 | } |
702 | return ret; | ||
1325 | } | 703 | } |
1326 | 704 | ||
1327 | /** | 705 | /** |
@@ -1361,12 +739,6 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1361 | { | 739 | { |
1362 | struct nfs_inode *nfsi = NFS_I(inode); | 740 | struct nfs_inode *nfsi = NFS_I(inode); |
1363 | 741 | ||
1364 | if ((fattr->valid & NFS_ATTR_PRE_CHANGE) != 0 | ||
1365 | && nfsi->change_attr == fattr->pre_change_attr) { | ||
1366 | nfsi->change_attr = fattr->change_attr; | ||
1367 | nfsi->cache_change_attribute = jiffies; | ||
1368 | } | ||
1369 | |||
1370 | /* If we have atomic WCC data, we may update some attributes */ | 742 | /* If we have atomic WCC data, we may update some attributes */ |
1371 | if ((fattr->valid & NFS_ATTR_WCC) != 0) { | 743 | if ((fattr->valid & NFS_ATTR_WCC) != 0) { |
1372 | if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) { | 744 | if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) { |
@@ -1400,9 +772,6 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
1400 | int data_unstable; | 772 | int data_unstable; |
1401 | 773 | ||
1402 | 774 | ||
1403 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) | ||
1404 | return 0; | ||
1405 | |||
1406 | /* Has the inode gone and changed behind our back? */ | 775 | /* Has the inode gone and changed behind our back? */ |
1407 | if (nfsi->fileid != fattr->fileid | 776 | if (nfsi->fileid != fattr->fileid |
1408 | || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) { | 777 | || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) { |
@@ -1415,20 +784,13 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
1415 | /* Do atomic weak cache consistency updates */ | 784 | /* Do atomic weak cache consistency updates */ |
1416 | nfs_wcc_update_inode(inode, fattr); | 785 | nfs_wcc_update_inode(inode, fattr); |
1417 | 786 | ||
1418 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0) { | 787 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && |
1419 | if (nfsi->change_attr == fattr->change_attr) | 788 | nfsi->change_attr != fattr->change_attr) |
1420 | goto out; | 789 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
1421 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; | ||
1422 | if (!data_unstable) | ||
1423 | nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; | ||
1424 | } | ||
1425 | 790 | ||
1426 | /* Verify a few of the more important attributes */ | 791 | /* Verify a few of the more important attributes */ |
1427 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { | 792 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) |
1428 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; | 793 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
1429 | if (!data_unstable) | ||
1430 | nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; | ||
1431 | } | ||
1432 | 794 | ||
1433 | cur_size = i_size_read(inode); | 795 | cur_size = i_size_read(inode); |
1434 | new_isize = nfs_size_to_loff_t(fattr->size); | 796 | new_isize = nfs_size_to_loff_t(fattr->size); |
@@ -1445,7 +807,6 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
1445 | if (inode->i_nlink != fattr->nlink) | 807 | if (inode->i_nlink != fattr->nlink) |
1446 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; | 808 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1447 | 809 | ||
1448 | out: | ||
1449 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) | 810 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) |
1450 | nfsi->cache_validity |= NFS_INO_INVALID_ATIME; | 811 | nfsi->cache_validity |= NFS_INO_INVALID_ATIME; |
1451 | 812 | ||
@@ -1471,7 +832,6 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1471 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) | 832 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) |
1472 | return 0; | 833 | return 0; |
1473 | spin_lock(&inode->i_lock); | 834 | spin_lock(&inode->i_lock); |
1474 | nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE; | ||
1475 | if (time_after(fattr->time_start, nfsi->last_updated)) | 835 | if (time_after(fattr->time_start, nfsi->last_updated)) |
1476 | status = nfs_update_inode(inode, fattr); | 836 | status = nfs_update_inode(inode, fattr); |
1477 | else | 837 | else |
@@ -1496,7 +856,7 @@ int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1496 | 856 | ||
1497 | spin_lock(&inode->i_lock); | 857 | spin_lock(&inode->i_lock); |
1498 | if (unlikely((fattr->valid & NFS_ATTR_FATTR) == 0)) { | 858 | if (unlikely((fattr->valid & NFS_ATTR_FATTR) == 0)) { |
1499 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS; | 859 | nfsi->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
1500 | goto out; | 860 | goto out; |
1501 | } | 861 | } |
1502 | status = nfs_update_inode(inode, fattr); | 862 | status = nfs_update_inode(inode, fattr); |
@@ -1519,6 +879,7 @@ out: | |||
1519 | */ | 879 | */ |
1520 | static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | 880 | static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) |
1521 | { | 881 | { |
882 | struct nfs_server *server; | ||
1522 | struct nfs_inode *nfsi = NFS_I(inode); | 883 | struct nfs_inode *nfsi = NFS_I(inode); |
1523 | loff_t cur_isize, new_isize; | 884 | loff_t cur_isize, new_isize; |
1524 | unsigned int invalid = 0; | 885 | unsigned int invalid = 0; |
@@ -1528,9 +889,6 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1528 | __FUNCTION__, inode->i_sb->s_id, inode->i_ino, | 889 | __FUNCTION__, inode->i_sb->s_id, inode->i_ino, |
1529 | atomic_read(&inode->i_count), fattr->valid); | 890 | atomic_read(&inode->i_count), fattr->valid); |
1530 | 891 | ||
1531 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) | ||
1532 | return 0; | ||
1533 | |||
1534 | if (nfsi->fileid != fattr->fileid) | 892 | if (nfsi->fileid != fattr->fileid) |
1535 | goto out_fileid; | 893 | goto out_fileid; |
1536 | 894 | ||
@@ -1540,6 +898,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1540 | if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) | 898 | if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) |
1541 | goto out_changed; | 899 | goto out_changed; |
1542 | 900 | ||
901 | server = NFS_SERVER(inode); | ||
902 | /* Update the fsid if and only if this is the root directory */ | ||
903 | if (inode == inode->i_sb->s_root->d_inode | ||
904 | && !nfs_fsid_equal(&server->fsid, &fattr->fsid)) | ||
905 | server->fsid = fattr->fsid; | ||
906 | |||
1543 | /* | 907 | /* |
1544 | * Update the read time so we don't revalidate too often. | 908 | * Update the read time so we don't revalidate too often. |
1545 | */ | 909 | */ |
@@ -1549,7 +913,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1549 | /* Are we racing with known updates of the metadata on the server? */ | 913 | /* Are we racing with known updates of the metadata on the server? */ |
1550 | data_stable = nfs_verify_change_attribute(inode, fattr->time_start); | 914 | data_stable = nfs_verify_change_attribute(inode, fattr->time_start); |
1551 | if (data_stable) | 915 | if (data_stable) |
1552 | nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME); | 916 | nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATIME); |
1553 | 917 | ||
1554 | /* Do atomic weak cache consistency updates */ | 918 | /* Do atomic weak cache consistency updates */ |
1555 | nfs_wcc_update_inode(inode, fattr); | 919 | nfs_wcc_update_inode(inode, fattr); |
@@ -1613,15 +977,13 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1613 | inode->i_blksize = fattr->du.nfs2.blocksize; | 977 | inode->i_blksize = fattr->du.nfs2.blocksize; |
1614 | } | 978 | } |
1615 | 979 | ||
1616 | if ((fattr->valid & NFS_ATTR_FATTR_V4)) { | 980 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && |
1617 | if (nfsi->change_attr != fattr->change_attr) { | 981 | nfsi->change_attr != fattr->change_attr) { |
1618 | dprintk("NFS: change_attr change on server for file %s/%ld\n", | 982 | dprintk("NFS: change_attr change on server for file %s/%ld\n", |
1619 | inode->i_sb->s_id, inode->i_ino); | 983 | inode->i_sb->s_id, inode->i_ino); |
1620 | nfsi->change_attr = fattr->change_attr; | 984 | nfsi->change_attr = fattr->change_attr; |
1621 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; | 985 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; |
1622 | nfsi->cache_change_attribute = jiffies; | 986 | nfsi->cache_change_attribute = jiffies; |
1623 | } else | ||
1624 | invalid &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA); | ||
1625 | } | 987 | } |
1626 | 988 | ||
1627 | /* Update attrtimeo value if we're out of the unstable period */ | 989 | /* Update attrtimeo value if we're out of the unstable period */ |
@@ -1669,202 +1031,15 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1669 | goto out_err; | 1031 | goto out_err; |
1670 | } | 1032 | } |
1671 | 1033 | ||
1672 | /* | ||
1673 | * File system information | ||
1674 | */ | ||
1675 | |||
1676 | static int nfs_set_super(struct super_block *s, void *data) | ||
1677 | { | ||
1678 | s->s_fs_info = data; | ||
1679 | return set_anon_super(s, data); | ||
1680 | } | ||
1681 | |||
1682 | static int nfs_compare_super(struct super_block *sb, void *data) | ||
1683 | { | ||
1684 | struct nfs_server *server = data; | ||
1685 | struct nfs_server *old = NFS_SB(sb); | ||
1686 | |||
1687 | if (old->addr.sin_addr.s_addr != server->addr.sin_addr.s_addr) | ||
1688 | return 0; | ||
1689 | if (old->addr.sin_port != server->addr.sin_port) | ||
1690 | return 0; | ||
1691 | return !nfs_compare_fh(&old->fh, &server->fh); | ||
1692 | } | ||
1693 | |||
1694 | static int nfs_get_sb(struct file_system_type *fs_type, | ||
1695 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
1696 | { | ||
1697 | int error; | ||
1698 | struct nfs_server *server = NULL; | ||
1699 | struct super_block *s; | ||
1700 | struct nfs_fh *root; | ||
1701 | struct nfs_mount_data *data = raw_data; | ||
1702 | |||
1703 | error = -EINVAL; | ||
1704 | if (data == NULL) { | ||
1705 | dprintk("%s: missing data argument\n", __FUNCTION__); | ||
1706 | goto out_err_noserver; | ||
1707 | } | ||
1708 | if (data->version <= 0 || data->version > NFS_MOUNT_VERSION) { | ||
1709 | dprintk("%s: bad mount version\n", __FUNCTION__); | ||
1710 | goto out_err_noserver; | ||
1711 | } | ||
1712 | switch (data->version) { | ||
1713 | case 1: | ||
1714 | data->namlen = 0; | ||
1715 | case 2: | ||
1716 | data->bsize = 0; | ||
1717 | case 3: | ||
1718 | if (data->flags & NFS_MOUNT_VER3) { | ||
1719 | dprintk("%s: mount structure version %d does not support NFSv3\n", | ||
1720 | __FUNCTION__, | ||
1721 | data->version); | ||
1722 | goto out_err_noserver; | ||
1723 | } | ||
1724 | data->root.size = NFS2_FHSIZE; | ||
1725 | memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE); | ||
1726 | case 4: | ||
1727 | if (data->flags & NFS_MOUNT_SECFLAVOUR) { | ||
1728 | dprintk("%s: mount structure version %d does not support strong security\n", | ||
1729 | __FUNCTION__, | ||
1730 | data->version); | ||
1731 | goto out_err_noserver; | ||
1732 | } | ||
1733 | case 5: | ||
1734 | memset(data->context, 0, sizeof(data->context)); | ||
1735 | } | ||
1736 | #ifndef CONFIG_NFS_V3 | ||
1737 | /* If NFSv3 is not compiled in, return -EPROTONOSUPPORT */ | ||
1738 | error = -EPROTONOSUPPORT; | ||
1739 | if (data->flags & NFS_MOUNT_VER3) { | ||
1740 | dprintk("%s: NFSv3 not compiled into kernel\n", __FUNCTION__); | ||
1741 | goto out_err_noserver; | ||
1742 | } | ||
1743 | #endif /* CONFIG_NFS_V3 */ | ||
1744 | |||
1745 | error = -ENOMEM; | ||
1746 | server = kzalloc(sizeof(struct nfs_server), GFP_KERNEL); | ||
1747 | if (!server) | ||
1748 | goto out_err_noserver; | ||
1749 | /* Zero out the NFS state stuff */ | ||
1750 | init_nfsv4_state(server); | ||
1751 | server->client = server->client_sys = server->client_acl = ERR_PTR(-EINVAL); | ||
1752 | |||
1753 | root = &server->fh; | ||
1754 | if (data->flags & NFS_MOUNT_VER3) | ||
1755 | root->size = data->root.size; | ||
1756 | else | ||
1757 | root->size = NFS2_FHSIZE; | ||
1758 | error = -EINVAL; | ||
1759 | if (root->size > sizeof(root->data)) { | ||
1760 | dprintk("%s: invalid root filehandle\n", __FUNCTION__); | ||
1761 | goto out_err; | ||
1762 | } | ||
1763 | memcpy(root->data, data->root.data, root->size); | ||
1764 | |||
1765 | /* We now require that the mount process passes the remote address */ | ||
1766 | memcpy(&server->addr, &data->addr, sizeof(server->addr)); | ||
1767 | if (server->addr.sin_addr.s_addr == INADDR_ANY) { | ||
1768 | dprintk("%s: mount program didn't pass remote address!\n", | ||
1769 | __FUNCTION__); | ||
1770 | goto out_err; | ||
1771 | } | ||
1772 | |||
1773 | /* Fire up rpciod if not yet running */ | ||
1774 | error = rpciod_up(); | ||
1775 | if (error < 0) { | ||
1776 | dprintk("%s: couldn't start rpciod! Error = %d\n", | ||
1777 | __FUNCTION__, error); | ||
1778 | goto out_err; | ||
1779 | } | ||
1780 | |||
1781 | s = sget(fs_type, nfs_compare_super, nfs_set_super, server); | ||
1782 | if (IS_ERR(s)) { | ||
1783 | error = PTR_ERR(s); | ||
1784 | goto out_err_rpciod; | ||
1785 | } | ||
1786 | |||
1787 | if (s->s_root) | ||
1788 | goto out_rpciod_down; | ||
1789 | |||
1790 | s->s_flags = flags; | ||
1791 | |||
1792 | error = nfs_fill_super(s, data, flags & MS_SILENT ? 1 : 0); | ||
1793 | if (error) { | ||
1794 | up_write(&s->s_umount); | ||
1795 | deactivate_super(s); | ||
1796 | return error; | ||
1797 | } | ||
1798 | s->s_flags |= MS_ACTIVE; | ||
1799 | return simple_set_mnt(mnt, s); | ||
1800 | |||
1801 | out_rpciod_down: | ||
1802 | rpciod_down(); | ||
1803 | kfree(server); | ||
1804 | return simple_set_mnt(mnt, s); | ||
1805 | |||
1806 | out_err_rpciod: | ||
1807 | rpciod_down(); | ||
1808 | out_err: | ||
1809 | kfree(server); | ||
1810 | out_err_noserver: | ||
1811 | return error; | ||
1812 | } | ||
1813 | |||
1814 | static void nfs_kill_super(struct super_block *s) | ||
1815 | { | ||
1816 | struct nfs_server *server = NFS_SB(s); | ||
1817 | |||
1818 | kill_anon_super(s); | ||
1819 | |||
1820 | if (!IS_ERR(server->client)) | ||
1821 | rpc_shutdown_client(server->client); | ||
1822 | if (!IS_ERR(server->client_sys)) | ||
1823 | rpc_shutdown_client(server->client_sys); | ||
1824 | if (!IS_ERR(server->client_acl)) | ||
1825 | rpc_shutdown_client(server->client_acl); | ||
1826 | |||
1827 | if (!(server->flags & NFS_MOUNT_NONLM)) | ||
1828 | lockd_down(); /* release rpc.lockd */ | ||
1829 | |||
1830 | rpciod_down(); /* release rpciod */ | ||
1831 | |||
1832 | nfs_free_iostats(server->io_stats); | ||
1833 | kfree(server->hostname); | ||
1834 | kfree(server); | ||
1835 | } | ||
1836 | |||
1837 | static struct file_system_type nfs_fs_type = { | ||
1838 | .owner = THIS_MODULE, | ||
1839 | .name = "nfs", | ||
1840 | .get_sb = nfs_get_sb, | ||
1841 | .kill_sb = nfs_kill_super, | ||
1842 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
1843 | }; | ||
1844 | 1034 | ||
1845 | #ifdef CONFIG_NFS_V4 | 1035 | #ifdef CONFIG_NFS_V4 |
1846 | 1036 | ||
1847 | static void nfs4_clear_inode(struct inode *); | ||
1848 | |||
1849 | |||
1850 | static struct super_operations nfs4_sops = { | ||
1851 | .alloc_inode = nfs_alloc_inode, | ||
1852 | .destroy_inode = nfs_destroy_inode, | ||
1853 | .write_inode = nfs_write_inode, | ||
1854 | .delete_inode = nfs_delete_inode, | ||
1855 | .statfs = nfs_statfs, | ||
1856 | .clear_inode = nfs4_clear_inode, | ||
1857 | .umount_begin = nfs_umount_begin, | ||
1858 | .show_options = nfs_show_options, | ||
1859 | .show_stats = nfs_show_stats, | ||
1860 | }; | ||
1861 | |||
1862 | /* | 1037 | /* |
1863 | * Clean out any remaining NFSv4 state that might be left over due | 1038 | * Clean out any remaining NFSv4 state that might be left over due |
1864 | * to open() calls that passed nfs_atomic_lookup, but failed to call | 1039 | * to open() calls that passed nfs_atomic_lookup, but failed to call |
1865 | * nfs_open(). | 1040 | * nfs_open(). |
1866 | */ | 1041 | */ |
1867 | static void nfs4_clear_inode(struct inode *inode) | 1042 | void nfs4_clear_inode(struct inode *inode) |
1868 | { | 1043 | { |
1869 | struct nfs_inode *nfsi = NFS_I(inode); | 1044 | struct nfs_inode *nfsi = NFS_I(inode); |
1870 | 1045 | ||
@@ -1888,365 +1063,9 @@ static void nfs4_clear_inode(struct inode *inode) | |||
1888 | nfs4_close_state(state, state->state); | 1063 | nfs4_close_state(state, state->state); |
1889 | } | 1064 | } |
1890 | } | 1065 | } |
1891 | |||
1892 | |||
1893 | static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data, int silent) | ||
1894 | { | ||
1895 | struct nfs_server *server; | ||
1896 | struct nfs4_client *clp = NULL; | ||
1897 | struct rpc_xprt *xprt = NULL; | ||
1898 | struct rpc_clnt *clnt = NULL; | ||
1899 | struct rpc_timeout timeparms; | ||
1900 | rpc_authflavor_t authflavour; | ||
1901 | int err = -EIO; | ||
1902 | |||
1903 | sb->s_blocksize_bits = 0; | ||
1904 | sb->s_blocksize = 0; | ||
1905 | server = NFS_SB(sb); | ||
1906 | if (data->rsize != 0) | ||
1907 | server->rsize = nfs_block_size(data->rsize, NULL); | ||
1908 | if (data->wsize != 0) | ||
1909 | server->wsize = nfs_block_size(data->wsize, NULL); | ||
1910 | server->flags = data->flags & NFS_MOUNT_FLAGMASK; | ||
1911 | server->caps = NFS_CAP_ATOMIC_OPEN; | ||
1912 | |||
1913 | server->acregmin = data->acregmin*HZ; | ||
1914 | server->acregmax = data->acregmax*HZ; | ||
1915 | server->acdirmin = data->acdirmin*HZ; | ||
1916 | server->acdirmax = data->acdirmax*HZ; | ||
1917 | |||
1918 | server->rpc_ops = &nfs_v4_clientops; | ||
1919 | |||
1920 | nfs_init_timeout_values(&timeparms, data->proto, data->timeo, data->retrans); | ||
1921 | |||
1922 | server->retrans_timeo = timeparms.to_initval; | ||
1923 | server->retrans_count = timeparms.to_retries; | ||
1924 | |||
1925 | clp = nfs4_get_client(&server->addr.sin_addr); | ||
1926 | if (!clp) { | ||
1927 | dprintk("%s: failed to create NFS4 client.\n", __FUNCTION__); | ||
1928 | return -EIO; | ||
1929 | } | ||
1930 | |||
1931 | /* Now create transport and client */ | ||
1932 | authflavour = RPC_AUTH_UNIX; | ||
1933 | if (data->auth_flavourlen != 0) { | ||
1934 | if (data->auth_flavourlen != 1) { | ||
1935 | dprintk("%s: Invalid number of RPC auth flavours %d.\n", | ||
1936 | __FUNCTION__, data->auth_flavourlen); | ||
1937 | err = -EINVAL; | ||
1938 | goto out_fail; | ||
1939 | } | ||
1940 | if (copy_from_user(&authflavour, data->auth_flavours, sizeof(authflavour))) { | ||
1941 | err = -EFAULT; | ||
1942 | goto out_fail; | ||
1943 | } | ||
1944 | } | ||
1945 | |||
1946 | down_write(&clp->cl_sem); | ||
1947 | if (IS_ERR(clp->cl_rpcclient)) { | ||
1948 | xprt = xprt_create_proto(data->proto, &server->addr, &timeparms); | ||
1949 | if (IS_ERR(xprt)) { | ||
1950 | up_write(&clp->cl_sem); | ||
1951 | err = PTR_ERR(xprt); | ||
1952 | dprintk("%s: cannot create RPC transport. Error = %d\n", | ||
1953 | __FUNCTION__, err); | ||
1954 | goto out_fail; | ||
1955 | } | ||
1956 | clnt = rpc_create_client(xprt, server->hostname, &nfs_program, | ||
1957 | server->rpc_ops->version, authflavour); | ||
1958 | if (IS_ERR(clnt)) { | ||
1959 | up_write(&clp->cl_sem); | ||
1960 | err = PTR_ERR(clnt); | ||
1961 | dprintk("%s: cannot create RPC client. Error = %d\n", | ||
1962 | __FUNCTION__, err); | ||
1963 | goto out_fail; | ||
1964 | } | ||
1965 | clnt->cl_intr = 1; | ||
1966 | clnt->cl_softrtry = 1; | ||
1967 | clp->cl_rpcclient = clnt; | ||
1968 | memcpy(clp->cl_ipaddr, server->ip_addr, sizeof(clp->cl_ipaddr)); | ||
1969 | nfs_idmap_new(clp); | ||
1970 | } | ||
1971 | list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); | ||
1972 | clnt = rpc_clone_client(clp->cl_rpcclient); | ||
1973 | if (!IS_ERR(clnt)) | ||
1974 | server->nfs4_state = clp; | ||
1975 | up_write(&clp->cl_sem); | ||
1976 | clp = NULL; | ||
1977 | |||
1978 | if (IS_ERR(clnt)) { | ||
1979 | err = PTR_ERR(clnt); | ||
1980 | dprintk("%s: cannot create RPC client. Error = %d\n", | ||
1981 | __FUNCTION__, err); | ||
1982 | return err; | ||
1983 | } | ||
1984 | |||
1985 | server->client = clnt; | ||
1986 | |||
1987 | if (server->nfs4_state->cl_idmap == NULL) { | ||
1988 | dprintk("%s: failed to create idmapper.\n", __FUNCTION__); | ||
1989 | return -ENOMEM; | ||
1990 | } | ||
1991 | |||
1992 | if (clnt->cl_auth->au_flavor != authflavour) { | ||
1993 | struct rpc_auth *auth; | ||
1994 | |||
1995 | auth = rpcauth_create(authflavour, clnt); | ||
1996 | if (IS_ERR(auth)) { | ||
1997 | dprintk("%s: couldn't create credcache!\n", __FUNCTION__); | ||
1998 | return PTR_ERR(auth); | ||
1999 | } | ||
2000 | } | ||
2001 | |||
2002 | sb->s_time_gran = 1; | ||
2003 | |||
2004 | sb->s_op = &nfs4_sops; | ||
2005 | err = nfs_sb_init(sb, authflavour); | ||
2006 | if (err == 0) | ||
2007 | return 0; | ||
2008 | out_fail: | ||
2009 | if (clp) | ||
2010 | nfs4_put_client(clp); | ||
2011 | return err; | ||
2012 | } | ||
2013 | |||
2014 | static int nfs4_compare_super(struct super_block *sb, void *data) | ||
2015 | { | ||
2016 | struct nfs_server *server = data; | ||
2017 | struct nfs_server *old = NFS_SB(sb); | ||
2018 | |||
2019 | if (strcmp(server->hostname, old->hostname) != 0) | ||
2020 | return 0; | ||
2021 | if (strcmp(server->mnt_path, old->mnt_path) != 0) | ||
2022 | return 0; | ||
2023 | return 1; | ||
2024 | } | ||
2025 | |||
2026 | static void * | ||
2027 | nfs_copy_user_string(char *dst, struct nfs_string *src, int maxlen) | ||
2028 | { | ||
2029 | void *p = NULL; | ||
2030 | |||
2031 | if (!src->len) | ||
2032 | return ERR_PTR(-EINVAL); | ||
2033 | if (src->len < maxlen) | ||
2034 | maxlen = src->len; | ||
2035 | if (dst == NULL) { | ||
2036 | p = dst = kmalloc(maxlen + 1, GFP_KERNEL); | ||
2037 | if (p == NULL) | ||
2038 | return ERR_PTR(-ENOMEM); | ||
2039 | } | ||
2040 | if (copy_from_user(dst, src->data, maxlen)) { | ||
2041 | kfree(p); | ||
2042 | return ERR_PTR(-EFAULT); | ||
2043 | } | ||
2044 | dst[maxlen] = '\0'; | ||
2045 | return dst; | ||
2046 | } | ||
2047 | |||
2048 | static int nfs4_get_sb(struct file_system_type *fs_type, | ||
2049 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
2050 | { | ||
2051 | int error; | ||
2052 | struct nfs_server *server; | ||
2053 | struct super_block *s; | ||
2054 | struct nfs4_mount_data *data = raw_data; | ||
2055 | void *p; | ||
2056 | |||
2057 | if (data == NULL) { | ||
2058 | dprintk("%s: missing data argument\n", __FUNCTION__); | ||
2059 | return -EINVAL; | ||
2060 | } | ||
2061 | if (data->version <= 0 || data->version > NFS4_MOUNT_VERSION) { | ||
2062 | dprintk("%s: bad mount version\n", __FUNCTION__); | ||
2063 | return -EINVAL; | ||
2064 | } | ||
2065 | |||
2066 | server = kzalloc(sizeof(struct nfs_server), GFP_KERNEL); | ||
2067 | if (!server) | ||
2068 | return -ENOMEM; | ||
2069 | /* Zero out the NFS state stuff */ | ||
2070 | init_nfsv4_state(server); | ||
2071 | server->client = server->client_sys = server->client_acl = ERR_PTR(-EINVAL); | ||
2072 | |||
2073 | p = nfs_copy_user_string(NULL, &data->hostname, 256); | ||
2074 | if (IS_ERR(p)) | ||
2075 | goto out_err; | ||
2076 | server->hostname = p; | ||
2077 | |||
2078 | p = nfs_copy_user_string(NULL, &data->mnt_path, 1024); | ||
2079 | if (IS_ERR(p)) | ||
2080 | goto out_err; | ||
2081 | server->mnt_path = p; | ||
2082 | |||
2083 | p = nfs_copy_user_string(server->ip_addr, &data->client_addr, | ||
2084 | sizeof(server->ip_addr) - 1); | ||
2085 | if (IS_ERR(p)) | ||
2086 | goto out_err; | ||
2087 | |||
2088 | /* We now require that the mount process passes the remote address */ | ||
2089 | if (data->host_addrlen != sizeof(server->addr)) { | ||
2090 | error = -EINVAL; | ||
2091 | goto out_free; | ||
2092 | } | ||
2093 | if (copy_from_user(&server->addr, data->host_addr, sizeof(server->addr))) { | ||
2094 | error = -EFAULT; | ||
2095 | goto out_free; | ||
2096 | } | ||
2097 | if (server->addr.sin_family != AF_INET || | ||
2098 | server->addr.sin_addr.s_addr == INADDR_ANY) { | ||
2099 | dprintk("%s: mount program didn't pass remote IP address!\n", | ||
2100 | __FUNCTION__); | ||
2101 | error = -EINVAL; | ||
2102 | goto out_free; | ||
2103 | } | ||
2104 | |||
2105 | /* Fire up rpciod if not yet running */ | ||
2106 | error = rpciod_up(); | ||
2107 | if (error < 0) { | ||
2108 | dprintk("%s: couldn't start rpciod! Error = %d\n", | ||
2109 | __FUNCTION__, error); | ||
2110 | goto out_free; | ||
2111 | } | ||
2112 | |||
2113 | s = sget(fs_type, nfs4_compare_super, nfs_set_super, server); | ||
2114 | if (IS_ERR(s)) { | ||
2115 | error = PTR_ERR(s); | ||
2116 | goto out_free; | ||
2117 | } | ||
2118 | |||
2119 | if (s->s_root) { | ||
2120 | kfree(server->mnt_path); | ||
2121 | kfree(server->hostname); | ||
2122 | kfree(server); | ||
2123 | return simple_set_mnt(mnt, s); | ||
2124 | } | ||
2125 | |||
2126 | s->s_flags = flags; | ||
2127 | |||
2128 | error = nfs4_fill_super(s, data, flags & MS_SILENT ? 1 : 0); | ||
2129 | if (error) { | ||
2130 | up_write(&s->s_umount); | ||
2131 | deactivate_super(s); | ||
2132 | return error; | ||
2133 | } | ||
2134 | s->s_flags |= MS_ACTIVE; | ||
2135 | return simple_set_mnt(mnt, s); | ||
2136 | out_err: | ||
2137 | error = PTR_ERR(p); | ||
2138 | out_free: | ||
2139 | kfree(server->mnt_path); | ||
2140 | kfree(server->hostname); | ||
2141 | kfree(server); | ||
2142 | return error; | ||
2143 | } | ||
2144 | |||
2145 | static void nfs4_kill_super(struct super_block *sb) | ||
2146 | { | ||
2147 | struct nfs_server *server = NFS_SB(sb); | ||
2148 | |||
2149 | nfs_return_all_delegations(sb); | ||
2150 | kill_anon_super(sb); | ||
2151 | |||
2152 | nfs4_renewd_prepare_shutdown(server); | ||
2153 | |||
2154 | if (server->client != NULL && !IS_ERR(server->client)) | ||
2155 | rpc_shutdown_client(server->client); | ||
2156 | |||
2157 | destroy_nfsv4_state(server); | ||
2158 | |||
2159 | rpciod_down(); | ||
2160 | |||
2161 | nfs_free_iostats(server->io_stats); | ||
2162 | kfree(server->hostname); | ||
2163 | kfree(server); | ||
2164 | } | ||
2165 | |||
2166 | static struct file_system_type nfs4_fs_type = { | ||
2167 | .owner = THIS_MODULE, | ||
2168 | .name = "nfs4", | ||
2169 | .get_sb = nfs4_get_sb, | ||
2170 | .kill_sb = nfs4_kill_super, | ||
2171 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
2172 | }; | ||
2173 | |||
2174 | static const int nfs_set_port_min = 0; | ||
2175 | static const int nfs_set_port_max = 65535; | ||
2176 | static int param_set_port(const char *val, struct kernel_param *kp) | ||
2177 | { | ||
2178 | char *endp; | ||
2179 | int num = simple_strtol(val, &endp, 0); | ||
2180 | if (endp == val || *endp || num < nfs_set_port_min || num > nfs_set_port_max) | ||
2181 | return -EINVAL; | ||
2182 | *((int *)kp->arg) = num; | ||
2183 | return 0; | ||
2184 | } | ||
2185 | |||
2186 | module_param_call(callback_tcpport, param_set_port, param_get_int, | ||
2187 | &nfs_callback_set_tcpport, 0644); | ||
2188 | |||
2189 | static int param_set_idmap_timeout(const char *val, struct kernel_param *kp) | ||
2190 | { | ||
2191 | char *endp; | ||
2192 | int num = simple_strtol(val, &endp, 0); | ||
2193 | int jif = num * HZ; | ||
2194 | if (endp == val || *endp || num < 0 || jif < num) | ||
2195 | return -EINVAL; | ||
2196 | *((int *)kp->arg) = jif; | ||
2197 | return 0; | ||
2198 | } | ||
2199 | |||
2200 | module_param_call(idmap_cache_timeout, param_set_idmap_timeout, param_get_int, | ||
2201 | &nfs_idmap_cache_timeout, 0644); | ||
2202 | |||
2203 | #define nfs4_init_once(nfsi) \ | ||
2204 | do { \ | ||
2205 | INIT_LIST_HEAD(&(nfsi)->open_states); \ | ||
2206 | nfsi->delegation = NULL; \ | ||
2207 | nfsi->delegation_state = 0; \ | ||
2208 | init_rwsem(&nfsi->rwsem); \ | ||
2209 | } while(0) | ||
2210 | |||
2211 | static inline int register_nfs4fs(void) | ||
2212 | { | ||
2213 | int ret; | ||
2214 | |||
2215 | ret = nfs_register_sysctl(); | ||
2216 | if (ret != 0) | ||
2217 | return ret; | ||
2218 | ret = register_filesystem(&nfs4_fs_type); | ||
2219 | if (ret != 0) | ||
2220 | nfs_unregister_sysctl(); | ||
2221 | return ret; | ||
2222 | } | ||
2223 | |||
2224 | static inline void unregister_nfs4fs(void) | ||
2225 | { | ||
2226 | unregister_filesystem(&nfs4_fs_type); | ||
2227 | nfs_unregister_sysctl(); | ||
2228 | } | ||
2229 | #else | ||
2230 | #define nfs4_init_once(nfsi) \ | ||
2231 | do { } while (0) | ||
2232 | #define register_nfs4fs() (0) | ||
2233 | #define unregister_nfs4fs() | ||
2234 | #endif | 1066 | #endif |
2235 | 1067 | ||
2236 | extern int nfs_init_nfspagecache(void); | 1068 | struct inode *nfs_alloc_inode(struct super_block *sb) |
2237 | extern void nfs_destroy_nfspagecache(void); | ||
2238 | extern int nfs_init_readpagecache(void); | ||
2239 | extern void nfs_destroy_readpagecache(void); | ||
2240 | extern int nfs_init_writepagecache(void); | ||
2241 | extern void nfs_destroy_writepagecache(void); | ||
2242 | #ifdef CONFIG_NFS_DIRECTIO | ||
2243 | extern int nfs_init_directcache(void); | ||
2244 | extern void nfs_destroy_directcache(void); | ||
2245 | #endif | ||
2246 | |||
2247 | static kmem_cache_t * nfs_inode_cachep; | ||
2248 | |||
2249 | static struct inode *nfs_alloc_inode(struct super_block *sb) | ||
2250 | { | 1069 | { |
2251 | struct nfs_inode *nfsi; | 1070 | struct nfs_inode *nfsi; |
2252 | nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); | 1071 | nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); |
@@ -2265,11 +1084,21 @@ static struct inode *nfs_alloc_inode(struct super_block *sb) | |||
2265 | return &nfsi->vfs_inode; | 1084 | return &nfsi->vfs_inode; |
2266 | } | 1085 | } |
2267 | 1086 | ||
2268 | static void nfs_destroy_inode(struct inode *inode) | 1087 | void nfs_destroy_inode(struct inode *inode) |
2269 | { | 1088 | { |
2270 | kmem_cache_free(nfs_inode_cachep, NFS_I(inode)); | 1089 | kmem_cache_free(nfs_inode_cachep, NFS_I(inode)); |
2271 | } | 1090 | } |
2272 | 1091 | ||
1092 | static inline void nfs4_init_once(struct nfs_inode *nfsi) | ||
1093 | { | ||
1094 | #ifdef CONFIG_NFS_V4 | ||
1095 | INIT_LIST_HEAD(&nfsi->open_states); | ||
1096 | nfsi->delegation = NULL; | ||
1097 | nfsi->delegation_state = 0; | ||
1098 | init_rwsem(&nfsi->rwsem); | ||
1099 | #endif | ||
1100 | } | ||
1101 | |||
2273 | static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) | 1102 | static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) |
2274 | { | 1103 | { |
2275 | struct nfs_inode *nfsi = (struct nfs_inode *) foo; | 1104 | struct nfs_inode *nfsi = (struct nfs_inode *) foo; |
@@ -2290,7 +1119,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) | |||
2290 | } | 1119 | } |
2291 | } | 1120 | } |
2292 | 1121 | ||
2293 | static int nfs_init_inodecache(void) | 1122 | static int __init nfs_init_inodecache(void) |
2294 | { | 1123 | { |
2295 | nfs_inode_cachep = kmem_cache_create("nfs_inode_cache", | 1124 | nfs_inode_cachep = kmem_cache_create("nfs_inode_cache", |
2296 | sizeof(struct nfs_inode), | 1125 | sizeof(struct nfs_inode), |
@@ -2303,7 +1132,7 @@ static int nfs_init_inodecache(void) | |||
2303 | return 0; | 1132 | return 0; |
2304 | } | 1133 | } |
2305 | 1134 | ||
2306 | static void nfs_destroy_inodecache(void) | 1135 | static void __exit nfs_destroy_inodecache(void) |
2307 | { | 1136 | { |
2308 | if (kmem_cache_destroy(nfs_inode_cachep)) | 1137 | if (kmem_cache_destroy(nfs_inode_cachep)) |
2309 | printk(KERN_INFO "nfs_inode_cache: not all structures were freed\n"); | 1138 | printk(KERN_INFO "nfs_inode_cache: not all structures were freed\n"); |
@@ -2332,29 +1161,22 @@ static int __init init_nfs_fs(void) | |||
2332 | if (err) | 1161 | if (err) |
2333 | goto out1; | 1162 | goto out1; |
2334 | 1163 | ||
2335 | #ifdef CONFIG_NFS_DIRECTIO | ||
2336 | err = nfs_init_directcache(); | 1164 | err = nfs_init_directcache(); |
2337 | if (err) | 1165 | if (err) |
2338 | goto out0; | 1166 | goto out0; |
2339 | #endif | ||
2340 | 1167 | ||
2341 | #ifdef CONFIG_PROC_FS | 1168 | #ifdef CONFIG_PROC_FS |
2342 | rpc_proc_register(&nfs_rpcstat); | 1169 | rpc_proc_register(&nfs_rpcstat); |
2343 | #endif | 1170 | #endif |
2344 | err = register_filesystem(&nfs_fs_type); | 1171 | if ((err = register_nfs_fs()) != 0) |
2345 | if (err) | ||
2346 | goto out; | ||
2347 | if ((err = register_nfs4fs()) != 0) | ||
2348 | goto out; | 1172 | goto out; |
2349 | return 0; | 1173 | return 0; |
2350 | out: | 1174 | out: |
2351 | #ifdef CONFIG_PROC_FS | 1175 | #ifdef CONFIG_PROC_FS |
2352 | rpc_proc_unregister("nfs"); | 1176 | rpc_proc_unregister("nfs"); |
2353 | #endif | 1177 | #endif |
2354 | #ifdef CONFIG_NFS_DIRECTIO | ||
2355 | nfs_destroy_directcache(); | 1178 | nfs_destroy_directcache(); |
2356 | out0: | 1179 | out0: |
2357 | #endif | ||
2358 | nfs_destroy_writepagecache(); | 1180 | nfs_destroy_writepagecache(); |
2359 | out1: | 1181 | out1: |
2360 | nfs_destroy_readpagecache(); | 1182 | nfs_destroy_readpagecache(); |
@@ -2368,9 +1190,7 @@ out4: | |||
2368 | 1190 | ||
2369 | static void __exit exit_nfs_fs(void) | 1191 | static void __exit exit_nfs_fs(void) |
2370 | { | 1192 | { |
2371 | #ifdef CONFIG_NFS_DIRECTIO | ||
2372 | nfs_destroy_directcache(); | 1193 | nfs_destroy_directcache(); |
2373 | #endif | ||
2374 | nfs_destroy_writepagecache(); | 1194 | nfs_destroy_writepagecache(); |
2375 | nfs_destroy_readpagecache(); | 1195 | nfs_destroy_readpagecache(); |
2376 | nfs_destroy_inodecache(); | 1196 | nfs_destroy_inodecache(); |
@@ -2378,8 +1198,7 @@ static void __exit exit_nfs_fs(void) | |||
2378 | #ifdef CONFIG_PROC_FS | 1198 | #ifdef CONFIG_PROC_FS |
2379 | rpc_proc_unregister("nfs"); | 1199 | rpc_proc_unregister("nfs"); |
2380 | #endif | 1200 | #endif |
2381 | unregister_filesystem(&nfs_fs_type); | 1201 | unregister_nfs_fs(); |
2382 | unregister_nfs4fs(); | ||
2383 | } | 1202 | } |
2384 | 1203 | ||
2385 | /* Not quite true; I just maintain it */ | 1204 | /* Not quite true; I just maintain it */ |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h new file mode 100644 index 000000000000..bd2815e2dec1 --- /dev/null +++ b/fs/nfs/internal.h | |||
@@ -0,0 +1,186 @@ | |||
1 | /* | ||
2 | * NFS internal definitions | ||
3 | */ | ||
4 | |||
5 | #include <linux/mount.h> | ||
6 | |||
7 | struct nfs_clone_mount { | ||
8 | const struct super_block *sb; | ||
9 | const struct dentry *dentry; | ||
10 | struct nfs_fh *fh; | ||
11 | struct nfs_fattr *fattr; | ||
12 | char *hostname; | ||
13 | char *mnt_path; | ||
14 | struct sockaddr_in *addr; | ||
15 | rpc_authflavor_t authflavor; | ||
16 | }; | ||
17 | |||
18 | /* namespace-nfs4.c */ | ||
19 | #ifdef CONFIG_NFS_V4 | ||
20 | extern struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry); | ||
21 | #else | ||
22 | static inline | ||
23 | struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry) | ||
24 | { | ||
25 | return ERR_PTR(-ENOENT); | ||
26 | } | ||
27 | #endif | ||
28 | |||
29 | /* callback_xdr.c */ | ||
30 | extern struct svc_version nfs4_callback_version1; | ||
31 | |||
32 | /* pagelist.c */ | ||
33 | extern int __init nfs_init_nfspagecache(void); | ||
34 | extern void __exit nfs_destroy_nfspagecache(void); | ||
35 | extern int __init nfs_init_readpagecache(void); | ||
36 | extern void __exit nfs_destroy_readpagecache(void); | ||
37 | extern int __init nfs_init_writepagecache(void); | ||
38 | extern void __exit nfs_destroy_writepagecache(void); | ||
39 | |||
40 | #ifdef CONFIG_NFS_DIRECTIO | ||
41 | extern int __init nfs_init_directcache(void); | ||
42 | extern void __exit nfs_destroy_directcache(void); | ||
43 | #else | ||
44 | #define nfs_init_directcache() (0) | ||
45 | #define nfs_destroy_directcache() do {} while(0) | ||
46 | #endif | ||
47 | |||
48 | /* nfs2xdr.c */ | ||
49 | extern struct rpc_procinfo nfs_procedures[]; | ||
50 | extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int); | ||
51 | |||
52 | /* nfs3xdr.c */ | ||
53 | extern struct rpc_procinfo nfs3_procedures[]; | ||
54 | extern u32 *nfs3_decode_dirent(u32 *, struct nfs_entry *, int); | ||
55 | |||
56 | /* nfs4xdr.c */ | ||
57 | extern int nfs_stat_to_errno(int); | ||
58 | extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus); | ||
59 | |||
60 | /* nfs4proc.c */ | ||
61 | #ifdef CONFIG_NFS_V4 | ||
62 | extern struct rpc_procinfo nfs4_procedures[]; | ||
63 | |||
64 | extern int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry, | ||
65 | struct nfs4_fs_locations *fs_locations, | ||
66 | struct page *page); | ||
67 | #endif | ||
68 | |||
69 | /* inode.c */ | ||
70 | extern struct inode *nfs_alloc_inode(struct super_block *sb); | ||
71 | extern void nfs_destroy_inode(struct inode *); | ||
72 | extern int nfs_write_inode(struct inode *,int); | ||
73 | extern void nfs_clear_inode(struct inode *); | ||
74 | #ifdef CONFIG_NFS_V4 | ||
75 | extern void nfs4_clear_inode(struct inode *); | ||
76 | #endif | ||
77 | |||
78 | /* super.c */ | ||
79 | extern struct file_system_type nfs_referral_nfs4_fs_type; | ||
80 | extern struct file_system_type clone_nfs_fs_type; | ||
81 | #ifdef CONFIG_NFS_V4 | ||
82 | extern struct file_system_type clone_nfs4_fs_type; | ||
83 | #endif | ||
84 | #ifdef CONFIG_PROC_FS | ||
85 | extern struct rpc_stat nfs_rpcstat; | ||
86 | #endif | ||
87 | extern int __init register_nfs_fs(void); | ||
88 | extern void __exit unregister_nfs_fs(void); | ||
89 | |||
90 | /* namespace.c */ | ||
91 | extern char *nfs_path(const char *base, const struct dentry *dentry, | ||
92 | char *buffer, ssize_t buflen); | ||
93 | |||
94 | /* | ||
95 | * Determine the mount path as a string | ||
96 | */ | ||
97 | static inline char * | ||
98 | nfs4_path(const struct dentry *dentry, char *buffer, ssize_t buflen) | ||
99 | { | ||
100 | #ifdef CONFIG_NFS_V4 | ||
101 | return nfs_path(NFS_SB(dentry->d_sb)->mnt_path, dentry, buffer, buflen); | ||
102 | #else | ||
103 | return NULL; | ||
104 | #endif | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | * Determine the device name as a string | ||
109 | */ | ||
110 | static inline char *nfs_devname(const struct vfsmount *mnt_parent, | ||
111 | const struct dentry *dentry, | ||
112 | char *buffer, ssize_t buflen) | ||
113 | { | ||
114 | return nfs_path(mnt_parent->mnt_devname, dentry, buffer, buflen); | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | * Determine the actual block size (and log2 thereof) | ||
119 | */ | ||
120 | static inline | ||
121 | unsigned long nfs_block_bits(unsigned long bsize, unsigned char *nrbitsp) | ||
122 | { | ||
123 | /* make sure blocksize is a power of two */ | ||
124 | if ((bsize & (bsize - 1)) || nrbitsp) { | ||
125 | unsigned char nrbits; | ||
126 | |||
127 | for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--) | ||
128 | ; | ||
129 | bsize = 1 << nrbits; | ||
130 | if (nrbitsp) | ||
131 | *nrbitsp = nrbits; | ||
132 | } | ||
133 | |||
134 | return bsize; | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * Calculate the number of 512byte blocks used. | ||
139 | */ | ||
140 | static inline unsigned long nfs_calc_block_size(u64 tsize) | ||
141 | { | ||
142 | loff_t used = (tsize + 511) >> 9; | ||
143 | return (used > ULONG_MAX) ? ULONG_MAX : used; | ||
144 | } | ||
145 | |||
146 | /* | ||
147 | * Compute and set NFS server blocksize | ||
148 | */ | ||
149 | static inline | ||
150 | unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp) | ||
151 | { | ||
152 | if (bsize < NFS_MIN_FILE_IO_SIZE) | ||
153 | bsize = NFS_DEF_FILE_IO_SIZE; | ||
154 | else if (bsize >= NFS_MAX_FILE_IO_SIZE) | ||
155 | bsize = NFS_MAX_FILE_IO_SIZE; | ||
156 | |||
157 | return nfs_block_bits(bsize, nrbitsp); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * Determine the maximum file size for a superblock | ||
162 | */ | ||
163 | static inline | ||
164 | void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize) | ||
165 | { | ||
166 | sb->s_maxbytes = (loff_t)maxfilesize; | ||
167 | if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0) | ||
168 | sb->s_maxbytes = MAX_LFS_FILESIZE; | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * Check if the string represents a "valid" IPv4 address | ||
173 | */ | ||
174 | static inline int valid_ipaddr4(const char *buf) | ||
175 | { | ||
176 | int rc, count, in[4]; | ||
177 | |||
178 | rc = sscanf(buf, "%d.%d.%d.%d", &in[0], &in[1], &in[2], &in[3]); | ||
179 | if (rc != 4) | ||
180 | return -EINVAL; | ||
181 | for (count = 0; count < 4; count++) { | ||
182 | if (in[count] > 255) | ||
183 | return -EINVAL; | ||
184 | } | ||
185 | return 0; | ||
186 | } | ||
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c new file mode 100644 index 000000000000..19b98ca468eb --- /dev/null +++ b/fs/nfs/namespace.c | |||
@@ -0,0 +1,229 @@ | |||
1 | /* | ||
2 | * linux/fs/nfs/namespace.c | ||
3 | * | ||
4 | * Copyright (C) 2005 Trond Myklebust <Trond.Myklebust@netapp.com> | ||
5 | * | ||
6 | * NFS namespace | ||
7 | */ | ||
8 | |||
9 | #include <linux/config.h> | ||
10 | |||
11 | #include <linux/dcache.h> | ||
12 | #include <linux/mount.h> | ||
13 | #include <linux/namei.h> | ||
14 | #include <linux/nfs_fs.h> | ||
15 | #include <linux/string.h> | ||
16 | #include <linux/sunrpc/clnt.h> | ||
17 | #include <linux/vfs.h> | ||
18 | #include "internal.h" | ||
19 | |||
20 | #define NFSDBG_FACILITY NFSDBG_VFS | ||
21 | |||
22 | static void nfs_expire_automounts(void *list); | ||
23 | |||
24 | LIST_HEAD(nfs_automount_list); | ||
25 | static DECLARE_WORK(nfs_automount_task, nfs_expire_automounts, &nfs_automount_list); | ||
26 | int nfs_mountpoint_expiry_timeout = 500 * HZ; | ||
27 | |||
28 | /* | ||
29 | * nfs_path - reconstruct the path given an arbitrary dentry | ||
30 | * @base - arbitrary string to prepend to the path | ||
31 | * @dentry - pointer to dentry | ||
32 | * @buffer - result buffer | ||
33 | * @buflen - length of buffer | ||
34 | * | ||
35 | * Helper function for constructing the path from the | ||
36 | * root dentry to an arbitrary hashed dentry. | ||
37 | * | ||
38 | * This is mainly for use in figuring out the path on the | ||
39 | * server side when automounting on top of an existing partition. | ||
40 | */ | ||
41 | char *nfs_path(const char *base, const struct dentry *dentry, | ||
42 | char *buffer, ssize_t buflen) | ||
43 | { | ||
44 | char *end = buffer+buflen; | ||
45 | int namelen; | ||
46 | |||
47 | *--end = '\0'; | ||
48 | buflen--; | ||
49 | spin_lock(&dcache_lock); | ||
50 | while (!IS_ROOT(dentry)) { | ||
51 | namelen = dentry->d_name.len; | ||
52 | buflen -= namelen + 1; | ||
53 | if (buflen < 0) | ||
54 | goto Elong; | ||
55 | end -= namelen; | ||
56 | memcpy(end, dentry->d_name.name, namelen); | ||
57 | *--end = '/'; | ||
58 | dentry = dentry->d_parent; | ||
59 | } | ||
60 | spin_unlock(&dcache_lock); | ||
61 | namelen = strlen(base); | ||
62 | /* Strip off excess slashes in base string */ | ||
63 | while (namelen > 0 && base[namelen - 1] == '/') | ||
64 | namelen--; | ||
65 | buflen -= namelen; | ||
66 | if (buflen < 0) | ||
67 | goto Elong; | ||
68 | end -= namelen; | ||
69 | memcpy(end, base, namelen); | ||
70 | return end; | ||
71 | Elong: | ||
72 | return ERR_PTR(-ENAMETOOLONG); | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | * nfs_follow_mountpoint - handle crossing a mountpoint on the server | ||
77 | * @dentry - dentry of mountpoint | ||
78 | * @nd - nameidata info | ||
79 | * | ||
80 | * When we encounter a mountpoint on the server, we want to set up | ||
81 | * a mountpoint on the client too, to prevent inode numbers from | ||
82 | * colliding, and to allow "df" to work properly. | ||
83 | * On NFSv4, we also want to allow for the fact that different | ||
84 | * filesystems may be migrated to different servers in a failover | ||
85 | * situation, and that different filesystems may want to use | ||
86 | * different security flavours. | ||
87 | */ | ||
88 | static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) | ||
89 | { | ||
90 | struct vfsmount *mnt; | ||
91 | struct nfs_server *server = NFS_SERVER(dentry->d_inode); | ||
92 | struct dentry *parent; | ||
93 | struct nfs_fh fh; | ||
94 | struct nfs_fattr fattr; | ||
95 | int err; | ||
96 | |||
97 | BUG_ON(IS_ROOT(dentry)); | ||
98 | dprintk("%s: enter\n", __FUNCTION__); | ||
99 | dput(nd->dentry); | ||
100 | nd->dentry = dget(dentry); | ||
101 | if (d_mountpoint(nd->dentry)) | ||
102 | goto out_follow; | ||
103 | /* Look it up again */ | ||
104 | parent = dget_parent(nd->dentry); | ||
105 | err = server->rpc_ops->lookup(parent->d_inode, &nd->dentry->d_name, &fh, &fattr); | ||
106 | dput(parent); | ||
107 | if (err != 0) | ||
108 | goto out_err; | ||
109 | |||
110 | if (fattr.valid & NFS_ATTR_FATTR_V4_REFERRAL) | ||
111 | mnt = nfs_do_refmount(nd->mnt, nd->dentry); | ||
112 | else | ||
113 | mnt = nfs_do_submount(nd->mnt, nd->dentry, &fh, &fattr); | ||
114 | err = PTR_ERR(mnt); | ||
115 | if (IS_ERR(mnt)) | ||
116 | goto out_err; | ||
117 | |||
118 | mntget(mnt); | ||
119 | err = do_add_mount(mnt, nd, nd->mnt->mnt_flags|MNT_SHRINKABLE, &nfs_automount_list); | ||
120 | if (err < 0) { | ||
121 | mntput(mnt); | ||
122 | if (err == -EBUSY) | ||
123 | goto out_follow; | ||
124 | goto out_err; | ||
125 | } | ||
126 | mntput(nd->mnt); | ||
127 | dput(nd->dentry); | ||
128 | nd->mnt = mnt; | ||
129 | nd->dentry = dget(mnt->mnt_root); | ||
130 | schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); | ||
131 | out: | ||
132 | dprintk("%s: done, returned %d\n", __FUNCTION__, err); | ||
133 | return ERR_PTR(err); | ||
134 | out_err: | ||
135 | path_release(nd); | ||
136 | goto out; | ||
137 | out_follow: | ||
138 | while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) | ||
139 | ; | ||
140 | err = 0; | ||
141 | goto out; | ||
142 | } | ||
143 | |||
144 | struct inode_operations nfs_mountpoint_inode_operations = { | ||
145 | .follow_link = nfs_follow_mountpoint, | ||
146 | .getattr = nfs_getattr, | ||
147 | }; | ||
148 | |||
149 | struct inode_operations nfs_referral_inode_operations = { | ||
150 | .follow_link = nfs_follow_mountpoint, | ||
151 | }; | ||
152 | |||
153 | static void nfs_expire_automounts(void *data) | ||
154 | { | ||
155 | struct list_head *list = (struct list_head *)data; | ||
156 | |||
157 | mark_mounts_for_expiry(list); | ||
158 | if (!list_empty(list)) | ||
159 | schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); | ||
160 | } | ||
161 | |||
162 | void nfs_release_automount_timer(void) | ||
163 | { | ||
164 | if (list_empty(&nfs_automount_list)) { | ||
165 | cancel_delayed_work(&nfs_automount_task); | ||
166 | flush_scheduled_work(); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | /* | ||
171 | * Clone a mountpoint of the appropriate type | ||
172 | */ | ||
173 | static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server, char *devname, | ||
174 | struct nfs_clone_mount *mountdata) | ||
175 | { | ||
176 | #ifdef CONFIG_NFS_V4 | ||
177 | struct vfsmount *mnt = NULL; | ||
178 | switch (server->rpc_ops->version) { | ||
179 | case 2: | ||
180 | case 3: | ||
181 | mnt = vfs_kern_mount(&clone_nfs_fs_type, 0, devname, mountdata); | ||
182 | break; | ||
183 | case 4: | ||
184 | mnt = vfs_kern_mount(&clone_nfs4_fs_type, 0, devname, mountdata); | ||
185 | } | ||
186 | return mnt; | ||
187 | #else | ||
188 | return vfs_kern_mount(&clone_nfs_fs_type, 0, devname, mountdata); | ||
189 | #endif | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * nfs_do_submount - set up mountpoint when crossing a filesystem boundary | ||
194 | * @mnt_parent - mountpoint of parent directory | ||
195 | * @dentry - parent directory | ||
196 | * @fh - filehandle for new root dentry | ||
197 | * @fattr - attributes for new root inode | ||
198 | * | ||
199 | */ | ||
200 | struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent, | ||
201 | const struct dentry *dentry, struct nfs_fh *fh, | ||
202 | struct nfs_fattr *fattr) | ||
203 | { | ||
204 | struct nfs_clone_mount mountdata = { | ||
205 | .sb = mnt_parent->mnt_sb, | ||
206 | .dentry = dentry, | ||
207 | .fh = fh, | ||
208 | .fattr = fattr, | ||
209 | }; | ||
210 | struct vfsmount *mnt = ERR_PTR(-ENOMEM); | ||
211 | char *page = (char *) __get_free_page(GFP_USER); | ||
212 | char *devname; | ||
213 | |||
214 | dprintk("%s: submounting on %s/%s\n", __FUNCTION__, | ||
215 | dentry->d_parent->d_name.name, | ||
216 | dentry->d_name.name); | ||
217 | if (page == NULL) | ||
218 | goto out; | ||
219 | devname = nfs_devname(mnt_parent, dentry, page, PAGE_SIZE); | ||
220 | mnt = (struct vfsmount *)devname; | ||
221 | if (IS_ERR(devname)) | ||
222 | goto free_page; | ||
223 | mnt = nfs_do_clone_mount(NFS_SB(mnt_parent->mnt_sb), devname, &mountdata); | ||
224 | free_page: | ||
225 | free_page((unsigned long)page); | ||
226 | out: | ||
227 | dprintk("%s: done\n", __FUNCTION__); | ||
228 | return mnt; | ||
229 | } | ||
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c index f0015fa876e1..3b939e055a08 100644 --- a/fs/nfs/nfs2xdr.c +++ b/fs/nfs/nfs2xdr.c | |||
@@ -23,12 +23,13 @@ | |||
23 | #include <linux/nfs.h> | 23 | #include <linux/nfs.h> |
24 | #include <linux/nfs2.h> | 24 | #include <linux/nfs2.h> |
25 | #include <linux/nfs_fs.h> | 25 | #include <linux/nfs_fs.h> |
26 | #include "internal.h" | ||
27 | |||
28 | #include "internal.h" | ||
26 | 29 | ||
27 | #define NFSDBG_FACILITY NFSDBG_XDR | 30 | #define NFSDBG_FACILITY NFSDBG_XDR |
28 | /* #define NFS_PARANOIA 1 */ | 31 | /* #define NFS_PARANOIA 1 */ |
29 | 32 | ||
30 | extern int nfs_stat_to_errno(int stat); | ||
31 | |||
32 | /* Mapping from NFS error code to "errno" error code. */ | 33 | /* Mapping from NFS error code to "errno" error code. */ |
33 | #define errno_NFSERR_IO EIO | 34 | #define errno_NFSERR_IO EIO |
34 | 35 | ||
@@ -131,7 +132,8 @@ xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr) | |||
131 | fattr->du.nfs2.blocksize = ntohl(*p++); | 132 | fattr->du.nfs2.blocksize = ntohl(*p++); |
132 | rdev = ntohl(*p++); | 133 | rdev = ntohl(*p++); |
133 | fattr->du.nfs2.blocks = ntohl(*p++); | 134 | fattr->du.nfs2.blocks = ntohl(*p++); |
134 | fattr->fsid_u.nfs3 = ntohl(*p++); | 135 | fattr->fsid.major = ntohl(*p++); |
136 | fattr->fsid.minor = 0; | ||
135 | fattr->fileid = ntohl(*p++); | 137 | fattr->fileid = ntohl(*p++); |
136 | p = xdr_decode_time(p, &fattr->atime); | 138 | p = xdr_decode_time(p, &fattr->atime); |
137 | p = xdr_decode_time(p, &fattr->mtime); | 139 | p = xdr_decode_time(p, &fattr->mtime); |
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c index 33287879bd23..7322da4d2055 100644 --- a/fs/nfs/nfs3acl.c +++ b/fs/nfs/nfs3acl.c | |||
@@ -172,8 +172,10 @@ static void nfs3_cache_acls(struct inode *inode, struct posix_acl *acl, | |||
172 | inode->i_ino, acl, dfacl); | 172 | inode->i_ino, acl, dfacl); |
173 | spin_lock(&inode->i_lock); | 173 | spin_lock(&inode->i_lock); |
174 | __nfs3_forget_cached_acls(NFS_I(inode)); | 174 | __nfs3_forget_cached_acls(NFS_I(inode)); |
175 | nfsi->acl_access = posix_acl_dup(acl); | 175 | if (!IS_ERR(acl)) |
176 | nfsi->acl_default = posix_acl_dup(dfacl); | 176 | nfsi->acl_access = posix_acl_dup(acl); |
177 | if (!IS_ERR(dfacl)) | ||
178 | nfsi->acl_default = posix_acl_dup(dfacl); | ||
177 | spin_unlock(&inode->i_lock); | 179 | spin_unlock(&inode->i_lock); |
178 | } | 180 | } |
179 | 181 | ||
@@ -254,7 +256,9 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) | |||
254 | res.acl_access = NULL; | 256 | res.acl_access = NULL; |
255 | } | 257 | } |
256 | } | 258 | } |
257 | nfs3_cache_acls(inode, res.acl_access, res.acl_default); | 259 | nfs3_cache_acls(inode, |
260 | (res.mask & NFS_ACL) ? res.acl_access : ERR_PTR(-EINVAL), | ||
261 | (res.mask & NFS_DFACL) ? res.acl_default : ERR_PTR(-EINVAL)); | ||
258 | 262 | ||
259 | switch(type) { | 263 | switch(type) { |
260 | case ACL_TYPE_ACCESS: | 264 | case ACL_TYPE_ACCESS: |
@@ -329,6 +333,7 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, | |||
329 | switch (status) { | 333 | switch (status) { |
330 | case 0: | 334 | case 0: |
331 | status = nfs_refresh_inode(inode, &fattr); | 335 | status = nfs_refresh_inode(inode, &fattr); |
336 | nfs3_cache_acls(inode, acl, dfacl); | ||
332 | break; | 337 | break; |
333 | case -EPFNOSUPPORT: | 338 | case -EPFNOSUPPORT: |
334 | case -EPROTONOSUPPORT: | 339 | case -EPROTONOSUPPORT: |
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index cf186f0d2b3b..7143b1f82cea 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -20,11 +20,10 @@ | |||
20 | #include <linux/nfs_mount.h> | 20 | #include <linux/nfs_mount.h> |
21 | 21 | ||
22 | #include "iostat.h" | 22 | #include "iostat.h" |
23 | #include "internal.h" | ||
23 | 24 | ||
24 | #define NFSDBG_FACILITY NFSDBG_PROC | 25 | #define NFSDBG_FACILITY NFSDBG_PROC |
25 | 26 | ||
26 | extern struct rpc_procinfo nfs3_procedures[]; | ||
27 | |||
28 | /* A wrapper to handle the EJUKEBOX error message */ | 27 | /* A wrapper to handle the EJUKEBOX error message */ |
29 | static int | 28 | static int |
30 | nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) | 29 | nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) |
@@ -809,8 +808,6 @@ nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, | |||
809 | return status; | 808 | return status; |
810 | } | 809 | } |
811 | 810 | ||
812 | extern u32 *nfs3_decode_dirent(u32 *, struct nfs_entry *, int); | ||
813 | |||
814 | static int nfs3_read_done(struct rpc_task *task, struct nfs_read_data *data) | 811 | static int nfs3_read_done(struct rpc_task *task, struct nfs_read_data *data) |
815 | { | 812 | { |
816 | if (nfs3_async_handle_jukebox(task, data->inode)) | 813 | if (nfs3_async_handle_jukebox(task, data->inode)) |
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index ec233619687e..0250269e9753 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c | |||
@@ -22,14 +22,13 @@ | |||
22 | #include <linux/nfs3.h> | 22 | #include <linux/nfs3.h> |
23 | #include <linux/nfs_fs.h> | 23 | #include <linux/nfs_fs.h> |
24 | #include <linux/nfsacl.h> | 24 | #include <linux/nfsacl.h> |
25 | #include "internal.h" | ||
25 | 26 | ||
26 | #define NFSDBG_FACILITY NFSDBG_XDR | 27 | #define NFSDBG_FACILITY NFSDBG_XDR |
27 | 28 | ||
28 | /* Mapping from NFS error code to "errno" error code. */ | 29 | /* Mapping from NFS error code to "errno" error code. */ |
29 | #define errno_NFSERR_IO EIO | 30 | #define errno_NFSERR_IO EIO |
30 | 31 | ||
31 | extern int nfs_stat_to_errno(int); | ||
32 | |||
33 | /* | 32 | /* |
34 | * Declare the space requirements for NFS arguments and replies as | 33 | * Declare the space requirements for NFS arguments and replies as |
35 | * number of 32bit-words | 34 | * number of 32bit-words |
@@ -166,7 +165,8 @@ xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr) | |||
166 | if (MAJOR(fattr->rdev) != major || MINOR(fattr->rdev) != minor) | 165 | if (MAJOR(fattr->rdev) != major || MINOR(fattr->rdev) != minor) |
167 | fattr->rdev = 0; | 166 | fattr->rdev = 0; |
168 | 167 | ||
169 | p = xdr_decode_hyper(p, &fattr->fsid_u.nfs3); | 168 | p = xdr_decode_hyper(p, &fattr->fsid.major); |
169 | fattr->fsid.minor = 0; | ||
170 | p = xdr_decode_hyper(p, &fattr->fileid); | 170 | p = xdr_decode_hyper(p, &fattr->fileid); |
171 | p = xdr_decode_time3(p, &fattr->atime); | 171 | p = xdr_decode_time3(p, &fattr->atime); |
172 | p = xdr_decode_time3(p, &fattr->mtime); | 172 | p = xdr_decode_time3(p, &fattr->mtime); |
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 0f5e4e7cddec..9a102860df37 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -217,6 +217,9 @@ extern int nfs4_proc_renew(struct nfs4_client *, struct rpc_cred *); | |||
217 | extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state); | 217 | extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state); |
218 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); | 218 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); |
219 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); | 219 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); |
220 | extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); | ||
221 | extern int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry, | ||
222 | struct nfs4_fs_locations *fs_locations, struct page *page); | ||
220 | 223 | ||
221 | extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops; | 224 | extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops; |
222 | extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops; | 225 | extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops; |
@@ -225,6 +228,7 @@ extern const u32 nfs4_fattr_bitmap[2]; | |||
225 | extern const u32 nfs4_statfs_bitmap[2]; | 228 | extern const u32 nfs4_statfs_bitmap[2]; |
226 | extern const u32 nfs4_pathconf_bitmap[2]; | 229 | extern const u32 nfs4_pathconf_bitmap[2]; |
227 | extern const u32 nfs4_fsinfo_bitmap[2]; | 230 | extern const u32 nfs4_fsinfo_bitmap[2]; |
231 | extern const u32 nfs4_fs_locations_bitmap[2]; | ||
228 | 232 | ||
229 | /* nfs4renewd.c */ | 233 | /* nfs4renewd.c */ |
230 | extern void nfs4_schedule_state_renewal(struct nfs4_client *); | 234 | extern void nfs4_schedule_state_renewal(struct nfs4_client *); |
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c new file mode 100644 index 000000000000..ea38d27b74e6 --- /dev/null +++ b/fs/nfs/nfs4namespace.c | |||
@@ -0,0 +1,201 @@ | |||
1 | /* | ||
2 | * linux/fs/nfs/nfs4namespace.c | ||
3 | * | ||
4 | * Copyright (C) 2005 Trond Myklebust <Trond.Myklebust@netapp.com> | ||
5 | * | ||
6 | * NFSv4 namespace | ||
7 | */ | ||
8 | |||
9 | #include <linux/config.h> | ||
10 | |||
11 | #include <linux/dcache.h> | ||
12 | #include <linux/mount.h> | ||
13 | #include <linux/namei.h> | ||
14 | #include <linux/nfs_fs.h> | ||
15 | #include <linux/string.h> | ||
16 | #include <linux/sunrpc/clnt.h> | ||
17 | #include <linux/vfs.h> | ||
18 | #include <linux/inet.h> | ||
19 | #include "internal.h" | ||
20 | |||
21 | #define NFSDBG_FACILITY NFSDBG_VFS | ||
22 | |||
23 | /* | ||
24 | * Check if fs_root is valid | ||
25 | */ | ||
26 | static inline char *nfs4_pathname_string(struct nfs4_pathname *pathname, | ||
27 | char *buffer, ssize_t buflen) | ||
28 | { | ||
29 | char *end = buffer + buflen; | ||
30 | int n; | ||
31 | |||
32 | *--end = '\0'; | ||
33 | buflen--; | ||
34 | |||
35 | n = pathname->ncomponents; | ||
36 | while (--n >= 0) { | ||
37 | struct nfs4_string *component = &pathname->components[n]; | ||
38 | buflen -= component->len + 1; | ||
39 | if (buflen < 0) | ||
40 | goto Elong; | ||
41 | end -= component->len; | ||
42 | memcpy(end, component->data, component->len); | ||
43 | *--end = '/'; | ||
44 | } | ||
45 | return end; | ||
46 | Elong: | ||
47 | return ERR_PTR(-ENAMETOOLONG); | ||
48 | } | ||
49 | |||
50 | |||
51 | /** | ||
52 | * nfs_follow_referral - set up mountpoint when hitting a referral on moved error | ||
53 | * @mnt_parent - mountpoint of parent directory | ||
54 | * @dentry - parent directory | ||
55 | * @fspath - fs path returned in fs_locations | ||
56 | * @mntpath - mount path to new server | ||
57 | * @hostname - hostname of new server | ||
58 | * @addr - host addr of new server | ||
59 | * | ||
60 | */ | ||
61 | static struct vfsmount *nfs_follow_referral(const struct vfsmount *mnt_parent, | ||
62 | const struct dentry *dentry, | ||
63 | struct nfs4_fs_locations *locations) | ||
64 | { | ||
65 | struct vfsmount *mnt = ERR_PTR(-ENOENT); | ||
66 | struct nfs_clone_mount mountdata = { | ||
67 | .sb = mnt_parent->mnt_sb, | ||
68 | .dentry = dentry, | ||
69 | .authflavor = NFS_SB(mnt_parent->mnt_sb)->client->cl_auth->au_flavor, | ||
70 | }; | ||
71 | char *page, *page2; | ||
72 | char *path, *fs_path; | ||
73 | char *devname; | ||
74 | int loc, s; | ||
75 | |||
76 | if (locations == NULL || locations->nlocations <= 0) | ||
77 | goto out; | ||
78 | |||
79 | dprintk("%s: referral at %s/%s\n", __FUNCTION__, | ||
80 | dentry->d_parent->d_name.name, dentry->d_name.name); | ||
81 | |||
82 | /* Ensure fs path is a prefix of current dentry path */ | ||
83 | page = (char *) __get_free_page(GFP_USER); | ||
84 | if (page == NULL) | ||
85 | goto out; | ||
86 | page2 = (char *) __get_free_page(GFP_USER); | ||
87 | if (page2 == NULL) | ||
88 | goto out; | ||
89 | |||
90 | path = nfs4_path(dentry, page, PAGE_SIZE); | ||
91 | if (IS_ERR(path)) | ||
92 | goto out_free; | ||
93 | |||
94 | fs_path = nfs4_pathname_string(&locations->fs_path, page2, PAGE_SIZE); | ||
95 | if (IS_ERR(fs_path)) | ||
96 | goto out_free; | ||
97 | |||
98 | if (strncmp(path, fs_path, strlen(fs_path)) != 0) { | ||
99 | dprintk("%s: path %s does not begin with fsroot %s\n", __FUNCTION__, path, fs_path); | ||
100 | goto out_free; | ||
101 | } | ||
102 | |||
103 | devname = nfs_devname(mnt_parent, dentry, page, PAGE_SIZE); | ||
104 | if (IS_ERR(devname)) { | ||
105 | mnt = (struct vfsmount *)devname; | ||
106 | goto out_free; | ||
107 | } | ||
108 | |||
109 | loc = 0; | ||
110 | while (loc < locations->nlocations && IS_ERR(mnt)) { | ||
111 | struct nfs4_fs_location *location = &locations->locations[loc]; | ||
112 | char *mnt_path; | ||
113 | |||
114 | if (location == NULL || location->nservers <= 0 || | ||
115 | location->rootpath.ncomponents == 0) { | ||
116 | loc++; | ||
117 | continue; | ||
118 | } | ||
119 | |||
120 | mnt_path = nfs4_pathname_string(&location->rootpath, page2, PAGE_SIZE); | ||
121 | if (IS_ERR(mnt_path)) { | ||
122 | loc++; | ||
123 | continue; | ||
124 | } | ||
125 | mountdata.mnt_path = mnt_path; | ||
126 | |||
127 | s = 0; | ||
128 | while (s < location->nservers) { | ||
129 | struct sockaddr_in addr = {}; | ||
130 | |||
131 | if (location->servers[s].len <= 0 || | ||
132 | valid_ipaddr4(location->servers[s].data) < 0) { | ||
133 | s++; | ||
134 | continue; | ||
135 | } | ||
136 | |||
137 | mountdata.hostname = location->servers[s].data; | ||
138 | addr.sin_addr.s_addr = in_aton(mountdata.hostname); | ||
139 | addr.sin_family = AF_INET; | ||
140 | addr.sin_port = htons(NFS_PORT); | ||
141 | mountdata.addr = &addr; | ||
142 | |||
143 | mnt = vfs_kern_mount(&nfs_referral_nfs4_fs_type, 0, devname, &mountdata); | ||
144 | if (!IS_ERR(mnt)) { | ||
145 | break; | ||
146 | } | ||
147 | s++; | ||
148 | } | ||
149 | loc++; | ||
150 | } | ||
151 | |||
152 | out_free: | ||
153 | free_page((unsigned long)page); | ||
154 | free_page((unsigned long)page2); | ||
155 | out: | ||
156 | dprintk("%s: done\n", __FUNCTION__); | ||
157 | return mnt; | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * nfs_do_refmount - handle crossing a referral on server | ||
162 | * @dentry - dentry of referral | ||
163 | * @nd - nameidata info | ||
164 | * | ||
165 | */ | ||
166 | struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry) | ||
167 | { | ||
168 | struct vfsmount *mnt = ERR_PTR(-ENOENT); | ||
169 | struct dentry *parent; | ||
170 | struct nfs4_fs_locations *fs_locations = NULL; | ||
171 | struct page *page; | ||
172 | int err; | ||
173 | |||
174 | /* BUG_ON(IS_ROOT(dentry)); */ | ||
175 | dprintk("%s: enter\n", __FUNCTION__); | ||
176 | |||
177 | page = alloc_page(GFP_KERNEL); | ||
178 | if (page == NULL) | ||
179 | goto out; | ||
180 | |||
181 | fs_locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL); | ||
182 | if (fs_locations == NULL) | ||
183 | goto out_free; | ||
184 | |||
185 | /* Get locations */ | ||
186 | parent = dget_parent(dentry); | ||
187 | dprintk("%s: getting locations for %s/%s\n", __FUNCTION__, parent->d_name.name, dentry->d_name.name); | ||
188 | err = nfs4_proc_fs_locations(parent->d_inode, dentry, fs_locations, page); | ||
189 | dput(parent); | ||
190 | if (err != 0 || fs_locations->nlocations <= 0 || | ||
191 | fs_locations->fs_path.ncomponents <= 0) | ||
192 | goto out_free; | ||
193 | |||
194 | mnt = nfs_follow_referral(mnt_parent, dentry, fs_locations); | ||
195 | out_free: | ||
196 | __free_page(page); | ||
197 | kfree(fs_locations); | ||
198 | out: | ||
199 | dprintk("%s: done\n", __FUNCTION__); | ||
200 | return mnt; | ||
201 | } | ||
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index d86c0db7b1e8..b4916b092194 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -65,8 +65,6 @@ static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *) | |||
65 | static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry); | 65 | static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry); |
66 | static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception); | 66 | static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception); |
67 | static int nfs4_wait_clnt_recover(struct rpc_clnt *clnt, struct nfs4_client *clp); | 67 | static int nfs4_wait_clnt_recover(struct rpc_clnt *clnt, struct nfs4_client *clp); |
68 | extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus); | ||
69 | extern struct rpc_procinfo nfs4_procedures[]; | ||
70 | 68 | ||
71 | /* Prevent leaks of NFSv4 errors into userland */ | 69 | /* Prevent leaks of NFSv4 errors into userland */ |
72 | int nfs4_map_errors(int err) | 70 | int nfs4_map_errors(int err) |
@@ -121,6 +119,25 @@ const u32 nfs4_fsinfo_bitmap[2] = { FATTR4_WORD0_MAXFILESIZE | |||
121 | 0 | 119 | 0 |
122 | }; | 120 | }; |
123 | 121 | ||
122 | const u32 nfs4_fs_locations_bitmap[2] = { | ||
123 | FATTR4_WORD0_TYPE | ||
124 | | FATTR4_WORD0_CHANGE | ||
125 | | FATTR4_WORD0_SIZE | ||
126 | | FATTR4_WORD0_FSID | ||
127 | | FATTR4_WORD0_FILEID | ||
128 | | FATTR4_WORD0_FS_LOCATIONS, | ||
129 | FATTR4_WORD1_MODE | ||
130 | | FATTR4_WORD1_NUMLINKS | ||
131 | | FATTR4_WORD1_OWNER | ||
132 | | FATTR4_WORD1_OWNER_GROUP | ||
133 | | FATTR4_WORD1_RAWDEV | ||
134 | | FATTR4_WORD1_SPACE_USED | ||
135 | | FATTR4_WORD1_TIME_ACCESS | ||
136 | | FATTR4_WORD1_TIME_METADATA | ||
137 | | FATTR4_WORD1_TIME_MODIFY | ||
138 | | FATTR4_WORD1_MOUNTED_ON_FILEID | ||
139 | }; | ||
140 | |||
124 | static void nfs4_setup_readdir(u64 cookie, u32 *verifier, struct dentry *dentry, | 141 | static void nfs4_setup_readdir(u64 cookie, u32 *verifier, struct dentry *dentry, |
125 | struct nfs4_readdir_arg *readdir) | 142 | struct nfs4_readdir_arg *readdir) |
126 | { | 143 | { |
@@ -185,15 +202,15 @@ static void renew_lease(const struct nfs_server *server, unsigned long timestamp | |||
185 | spin_unlock(&clp->cl_lock); | 202 | spin_unlock(&clp->cl_lock); |
186 | } | 203 | } |
187 | 204 | ||
188 | static void update_changeattr(struct inode *inode, struct nfs4_change_info *cinfo) | 205 | static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) |
189 | { | 206 | { |
190 | struct nfs_inode *nfsi = NFS_I(inode); | 207 | struct nfs_inode *nfsi = NFS_I(dir); |
191 | 208 | ||
192 | spin_lock(&inode->i_lock); | 209 | spin_lock(&dir->i_lock); |
193 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; | 210 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA; |
194 | if (cinfo->before == nfsi->change_attr && cinfo->atomic) | 211 | if (cinfo->before == nfsi->change_attr && cinfo->atomic) |
195 | nfsi->change_attr = cinfo->after; | 212 | nfsi->change_attr = cinfo->after; |
196 | spin_unlock(&inode->i_lock); | 213 | spin_unlock(&dir->i_lock); |
197 | } | 214 | } |
198 | 215 | ||
199 | struct nfs4_opendata { | 216 | struct nfs4_opendata { |
@@ -1331,7 +1348,7 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f | |||
1331 | return status; | 1348 | return status; |
1332 | } | 1349 | } |
1333 | 1350 | ||
1334 | static int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) | 1351 | int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) |
1335 | { | 1352 | { |
1336 | struct nfs4_exception exception = { }; | 1353 | struct nfs4_exception exception = { }; |
1337 | int err; | 1354 | int err; |
@@ -1443,6 +1460,50 @@ out: | |||
1443 | return nfs4_map_errors(status); | 1460 | return nfs4_map_errors(status); |
1444 | } | 1461 | } |
1445 | 1462 | ||
1463 | /* | ||
1464 | * Get locations and (maybe) other attributes of a referral. | ||
1465 | * Note that we'll actually follow the referral later when | ||
1466 | * we detect fsid mismatch in inode revalidation | ||
1467 | */ | ||
1468 | static int nfs4_get_referral(struct inode *dir, struct qstr *name, struct nfs_fattr *fattr, struct nfs_fh *fhandle) | ||
1469 | { | ||
1470 | int status = -ENOMEM; | ||
1471 | struct page *page = NULL; | ||
1472 | struct nfs4_fs_locations *locations = NULL; | ||
1473 | struct dentry dentry = {}; | ||
1474 | |||
1475 | page = alloc_page(GFP_KERNEL); | ||
1476 | if (page == NULL) | ||
1477 | goto out; | ||
1478 | locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL); | ||
1479 | if (locations == NULL) | ||
1480 | goto out; | ||
1481 | |||
1482 | dentry.d_name.name = name->name; | ||
1483 | dentry.d_name.len = name->len; | ||
1484 | status = nfs4_proc_fs_locations(dir, &dentry, locations, page); | ||
1485 | if (status != 0) | ||
1486 | goto out; | ||
1487 | /* Make sure server returned a different fsid for the referral */ | ||
1488 | if (nfs_fsid_equal(&NFS_SERVER(dir)->fsid, &locations->fattr.fsid)) { | ||
1489 | dprintk("%s: server did not return a different fsid for a referral at %s\n", __FUNCTION__, name->name); | ||
1490 | status = -EIO; | ||
1491 | goto out; | ||
1492 | } | ||
1493 | |||
1494 | memcpy(fattr, &locations->fattr, sizeof(struct nfs_fattr)); | ||
1495 | fattr->valid |= NFS_ATTR_FATTR_V4_REFERRAL; | ||
1496 | if (!fattr->mode) | ||
1497 | fattr->mode = S_IFDIR; | ||
1498 | memset(fhandle, 0, sizeof(struct nfs_fh)); | ||
1499 | out: | ||
1500 | if (page) | ||
1501 | __free_page(page); | ||
1502 | if (locations) | ||
1503 | kfree(locations); | ||
1504 | return status; | ||
1505 | } | ||
1506 | |||
1446 | static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr) | 1507 | static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr) |
1447 | { | 1508 | { |
1448 | struct nfs4_getattr_arg args = { | 1509 | struct nfs4_getattr_arg args = { |
@@ -1547,6 +1608,8 @@ static int _nfs4_proc_lookup(struct inode *dir, struct qstr *name, | |||
1547 | 1608 | ||
1548 | dprintk("NFS call lookup %s\n", name->name); | 1609 | dprintk("NFS call lookup %s\n", name->name); |
1549 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 1610 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
1611 | if (status == -NFS4ERR_MOVED) | ||
1612 | status = nfs4_get_referral(dir, name, fattr, fhandle); | ||
1550 | dprintk("NFS reply lookup: %d\n", status); | 1613 | dprintk("NFS reply lookup: %d\n", status); |
1551 | return status; | 1614 | return status; |
1552 | } | 1615 | } |
@@ -2008,7 +2071,7 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr * | |||
2008 | if (!status) { | 2071 | if (!status) { |
2009 | update_changeattr(dir, &res.cinfo); | 2072 | update_changeattr(dir, &res.cinfo); |
2010 | nfs_post_op_update_inode(dir, res.dir_attr); | 2073 | nfs_post_op_update_inode(dir, res.dir_attr); |
2011 | nfs_refresh_inode(inode, res.fattr); | 2074 | nfs_post_op_update_inode(inode, res.fattr); |
2012 | } | 2075 | } |
2013 | 2076 | ||
2014 | return status; | 2077 | return status; |
@@ -3570,6 +3633,36 @@ ssize_t nfs4_listxattr(struct dentry *dentry, char *buf, size_t buflen) | |||
3570 | return len; | 3633 | return len; |
3571 | } | 3634 | } |
3572 | 3635 | ||
3636 | int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry, | ||
3637 | struct nfs4_fs_locations *fs_locations, struct page *page) | ||
3638 | { | ||
3639 | struct nfs_server *server = NFS_SERVER(dir); | ||
3640 | u32 bitmask[2] = { | ||
3641 | [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS, | ||
3642 | [1] = FATTR4_WORD1_MOUNTED_ON_FILEID, | ||
3643 | }; | ||
3644 | struct nfs4_fs_locations_arg args = { | ||
3645 | .dir_fh = NFS_FH(dir), | ||
3646 | .name = &dentry->d_name, | ||
3647 | .page = page, | ||
3648 | .bitmask = bitmask, | ||
3649 | }; | ||
3650 | struct rpc_message msg = { | ||
3651 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_FS_LOCATIONS], | ||
3652 | .rpc_argp = &args, | ||
3653 | .rpc_resp = fs_locations, | ||
3654 | }; | ||
3655 | int status; | ||
3656 | |||
3657 | dprintk("%s: start\n", __FUNCTION__); | ||
3658 | fs_locations->fattr.valid = 0; | ||
3659 | fs_locations->server = server; | ||
3660 | fs_locations->nlocations = 0; | ||
3661 | status = rpc_call_sync(server->client, &msg, 0); | ||
3662 | dprintk("%s: returned status = %d\n", __FUNCTION__, status); | ||
3663 | return status; | ||
3664 | } | ||
3665 | |||
3573 | struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops = { | 3666 | struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops = { |
3574 | .recover_open = nfs4_open_reclaim, | 3667 | .recover_open = nfs4_open_reclaim, |
3575 | .recover_lock = nfs4_lock_reclaim, | 3668 | .recover_lock = nfs4_lock_reclaim, |
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 7c5d70efe720..1750d996f49f 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -411,6 +411,15 @@ static int nfs_stat_to_errno(int); | |||
411 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ | 411 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
412 | decode_putfh_maxsz + \ | 412 | decode_putfh_maxsz + \ |
413 | op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) | 413 | op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
414 | #define NFS4_enc_fs_locations_sz \ | ||
415 | (compound_encode_hdr_maxsz + \ | ||
416 | encode_putfh_maxsz + \ | ||
417 | encode_getattr_maxsz) | ||
418 | #define NFS4_dec_fs_locations_sz \ | ||
419 | (compound_decode_hdr_maxsz + \ | ||
420 | decode_putfh_maxsz + \ | ||
421 | op_decode_hdr_maxsz + \ | ||
422 | nfs4_fattr_bitmap_maxsz) | ||
414 | 423 | ||
415 | static struct { | 424 | static struct { |
416 | unsigned int mode; | 425 | unsigned int mode; |
@@ -722,6 +731,13 @@ static int encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask) | |||
722 | bitmask[1] & nfs4_fsinfo_bitmap[1]); | 731 | bitmask[1] & nfs4_fsinfo_bitmap[1]); |
723 | } | 732 | } |
724 | 733 | ||
734 | static int encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask) | ||
735 | { | ||
736 | return encode_getattr_two(xdr, | ||
737 | bitmask[0] & nfs4_fs_locations_bitmap[0], | ||
738 | bitmask[1] & nfs4_fs_locations_bitmap[1]); | ||
739 | } | ||
740 | |||
725 | static int encode_getfh(struct xdr_stream *xdr) | 741 | static int encode_getfh(struct xdr_stream *xdr) |
726 | { | 742 | { |
727 | uint32_t *p; | 743 | uint32_t *p; |
@@ -2003,6 +2019,38 @@ out: | |||
2003 | } | 2019 | } |
2004 | 2020 | ||
2005 | /* | 2021 | /* |
2022 | * Encode FS_LOCATIONS request | ||
2023 | */ | ||
2024 | static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, uint32_t *p, struct nfs4_fs_locations_arg *args) | ||
2025 | { | ||
2026 | struct xdr_stream xdr; | ||
2027 | struct compound_hdr hdr = { | ||
2028 | .nops = 3, | ||
2029 | }; | ||
2030 | struct rpc_auth *auth = req->rq_task->tk_auth; | ||
2031 | int replen; | ||
2032 | int status; | ||
2033 | |||
2034 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | ||
2035 | encode_compound_hdr(&xdr, &hdr); | ||
2036 | if ((status = encode_putfh(&xdr, args->dir_fh)) != 0) | ||
2037 | goto out; | ||
2038 | if ((status = encode_lookup(&xdr, args->name)) != 0) | ||
2039 | goto out; | ||
2040 | if ((status = encode_fs_locations(&xdr, args->bitmask)) != 0) | ||
2041 | goto out; | ||
2042 | /* set up reply | ||
2043 | * toplevel_status + OP_PUTFH + status | ||
2044 | * + OP_LOOKUP + status + OP_GETATTR + status = 7 | ||
2045 | */ | ||
2046 | replen = (RPC_REPHDRSIZE + auth->au_rslack + 7) << 2; | ||
2047 | xdr_inline_pages(&req->rq_rcv_buf, replen, &args->page, | ||
2048 | 0, PAGE_SIZE); | ||
2049 | out: | ||
2050 | return status; | ||
2051 | } | ||
2052 | |||
2053 | /* | ||
2006 | * START OF "GENERIC" DECODE ROUTINES. | 2054 | * START OF "GENERIC" DECODE ROUTINES. |
2007 | * These may look a little ugly since they are imported from a "generic" | 2055 | * These may look a little ugly since they are imported from a "generic" |
2008 | * set of XDR encode/decode routines which are intended to be shared by | 2056 | * set of XDR encode/decode routines which are intended to be shared by |
@@ -2036,7 +2084,7 @@ out: | |||
2036 | } \ | 2084 | } \ |
2037 | } while (0) | 2085 | } while (0) |
2038 | 2086 | ||
2039 | static int decode_opaque_inline(struct xdr_stream *xdr, uint32_t *len, char **string) | 2087 | static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) |
2040 | { | 2088 | { |
2041 | uint32_t *p; | 2089 | uint32_t *p; |
2042 | 2090 | ||
@@ -2087,7 +2135,7 @@ static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) | |||
2087 | static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs4_client *clp) | 2135 | static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs4_client *clp) |
2088 | { | 2136 | { |
2089 | uint32_t *p; | 2137 | uint32_t *p; |
2090 | uint32_t strlen; | 2138 | unsigned int strlen; |
2091 | char *str; | 2139 | char *str; |
2092 | 2140 | ||
2093 | READ_BUF(12); | 2141 | READ_BUF(12); |
@@ -2217,7 +2265,7 @@ static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, | |||
2217 | return 0; | 2265 | return 0; |
2218 | } | 2266 | } |
2219 | 2267 | ||
2220 | static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fsid *fsid) | 2268 | static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid) |
2221 | { | 2269 | { |
2222 | uint32_t *p; | 2270 | uint32_t *p; |
2223 | 2271 | ||
@@ -2285,6 +2333,22 @@ static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t | |||
2285 | return 0; | 2333 | return 0; |
2286 | } | 2334 | } |
2287 | 2335 | ||
2336 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) | ||
2337 | { | ||
2338 | uint32_t *p; | ||
2339 | |||
2340 | *fileid = 0; | ||
2341 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) | ||
2342 | return -EIO; | ||
2343 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { | ||
2344 | READ_BUF(8); | ||
2345 | READ64(*fileid); | ||
2346 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; | ||
2347 | } | ||
2348 | dprintk("%s: fileid=%Lu\n", __FUNCTION__, (unsigned long long)*fileid); | ||
2349 | return 0; | ||
2350 | } | ||
2351 | |||
2288 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | 2352 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
2289 | { | 2353 | { |
2290 | uint32_t *p; | 2354 | uint32_t *p; |
@@ -2336,6 +2400,116 @@ static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uin | |||
2336 | return status; | 2400 | return status; |
2337 | } | 2401 | } |
2338 | 2402 | ||
2403 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) | ||
2404 | { | ||
2405 | int n; | ||
2406 | uint32_t *p; | ||
2407 | int status = 0; | ||
2408 | |||
2409 | READ_BUF(4); | ||
2410 | READ32(n); | ||
2411 | if (n < 0) | ||
2412 | goto out_eio; | ||
2413 | if (n == 0) | ||
2414 | goto root_path; | ||
2415 | dprintk("path "); | ||
2416 | path->ncomponents = 0; | ||
2417 | while (path->ncomponents < n) { | ||
2418 | struct nfs4_string *component = &path->components[path->ncomponents]; | ||
2419 | status = decode_opaque_inline(xdr, &component->len, &component->data); | ||
2420 | if (unlikely(status != 0)) | ||
2421 | goto out_eio; | ||
2422 | if (path->ncomponents != n) | ||
2423 | dprintk("/"); | ||
2424 | dprintk("%s", component->data); | ||
2425 | if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS) | ||
2426 | path->ncomponents++; | ||
2427 | else { | ||
2428 | dprintk("cannot parse %d components in path\n", n); | ||
2429 | goto out_eio; | ||
2430 | } | ||
2431 | } | ||
2432 | out: | ||
2433 | dprintk("\n"); | ||
2434 | return status; | ||
2435 | root_path: | ||
2436 | /* a root pathname is sent as a zero component4 */ | ||
2437 | path->ncomponents = 1; | ||
2438 | path->components[0].len=0; | ||
2439 | path->components[0].data=NULL; | ||
2440 | dprintk("path /\n"); | ||
2441 | goto out; | ||
2442 | out_eio: | ||
2443 | dprintk(" status %d", status); | ||
2444 | status = -EIO; | ||
2445 | goto out; | ||
2446 | } | ||
2447 | |||
2448 | static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res) | ||
2449 | { | ||
2450 | int n; | ||
2451 | uint32_t *p; | ||
2452 | int status = -EIO; | ||
2453 | |||
2454 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) | ||
2455 | goto out; | ||
2456 | status = 0; | ||
2457 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) | ||
2458 | goto out; | ||
2459 | dprintk("%s: fsroot ", __FUNCTION__); | ||
2460 | status = decode_pathname(xdr, &res->fs_path); | ||
2461 | if (unlikely(status != 0)) | ||
2462 | goto out; | ||
2463 | READ_BUF(4); | ||
2464 | READ32(n); | ||
2465 | if (n <= 0) | ||
2466 | goto out_eio; | ||
2467 | res->nlocations = 0; | ||
2468 | while (res->nlocations < n) { | ||
2469 | int m; | ||
2470 | struct nfs4_fs_location *loc = &res->locations[res->nlocations]; | ||
2471 | |||
2472 | READ_BUF(4); | ||
2473 | READ32(m); | ||
2474 | if (m <= 0) | ||
2475 | goto out_eio; | ||
2476 | |||
2477 | loc->nservers = 0; | ||
2478 | dprintk("%s: servers ", __FUNCTION__); | ||
2479 | while (loc->nservers < m) { | ||
2480 | struct nfs4_string *server = &loc->servers[loc->nservers]; | ||
2481 | status = decode_opaque_inline(xdr, &server->len, &server->data); | ||
2482 | if (unlikely(status != 0)) | ||
2483 | goto out_eio; | ||
2484 | dprintk("%s ", server->data); | ||
2485 | if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS) | ||
2486 | loc->nservers++; | ||
2487 | else { | ||
2488 | int i; | ||
2489 | dprintk("%s: using first %d of %d servers returned for location %d\n", __FUNCTION__, NFS4_FS_LOCATION_MAXSERVERS, m, res->nlocations); | ||
2490 | for (i = loc->nservers; i < m; i++) { | ||
2491 | int len; | ||
2492 | char *data; | ||
2493 | status = decode_opaque_inline(xdr, &len, &data); | ||
2494 | if (unlikely(status != 0)) | ||
2495 | goto out_eio; | ||
2496 | } | ||
2497 | } | ||
2498 | } | ||
2499 | status = decode_pathname(xdr, &loc->rootpath); | ||
2500 | if (unlikely(status != 0)) | ||
2501 | goto out_eio; | ||
2502 | if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES) | ||
2503 | res->nlocations++; | ||
2504 | } | ||
2505 | out: | ||
2506 | dprintk("%s: fs_locations done, error = %d\n", __FUNCTION__, status); | ||
2507 | return status; | ||
2508 | out_eio: | ||
2509 | status = -EIO; | ||
2510 | goto out; | ||
2511 | } | ||
2512 | |||
2339 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | 2513 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
2340 | { | 2514 | { |
2341 | uint32_t *p; | 2515 | uint32_t *p; |
@@ -2841,6 +3015,7 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons | |||
2841 | bitmap[2] = {0}, | 3015 | bitmap[2] = {0}, |
2842 | type; | 3016 | type; |
2843 | int status, fmode = 0; | 3017 | int status, fmode = 0; |
3018 | uint64_t fileid; | ||
2844 | 3019 | ||
2845 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | 3020 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
2846 | goto xdr_error; | 3021 | goto xdr_error; |
@@ -2863,10 +3038,14 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons | |||
2863 | goto xdr_error; | 3038 | goto xdr_error; |
2864 | if ((status = decode_attr_size(xdr, bitmap, &fattr->size)) != 0) | 3039 | if ((status = decode_attr_size(xdr, bitmap, &fattr->size)) != 0) |
2865 | goto xdr_error; | 3040 | goto xdr_error; |
2866 | if ((status = decode_attr_fsid(xdr, bitmap, &fattr->fsid_u.nfs4)) != 0) | 3041 | if ((status = decode_attr_fsid(xdr, bitmap, &fattr->fsid)) != 0) |
2867 | goto xdr_error; | 3042 | goto xdr_error; |
2868 | if ((status = decode_attr_fileid(xdr, bitmap, &fattr->fileid)) != 0) | 3043 | if ((status = decode_attr_fileid(xdr, bitmap, &fattr->fileid)) != 0) |
2869 | goto xdr_error; | 3044 | goto xdr_error; |
3045 | if ((status = decode_attr_fs_locations(xdr, bitmap, container_of(fattr, | ||
3046 | struct nfs4_fs_locations, | ||
3047 | fattr))) != 0) | ||
3048 | goto xdr_error; | ||
2870 | if ((status = decode_attr_mode(xdr, bitmap, &fattr->mode)) != 0) | 3049 | if ((status = decode_attr_mode(xdr, bitmap, &fattr->mode)) != 0) |
2871 | goto xdr_error; | 3050 | goto xdr_error; |
2872 | fattr->mode |= fmode; | 3051 | fattr->mode |= fmode; |
@@ -2886,6 +3065,10 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons | |||
2886 | goto xdr_error; | 3065 | goto xdr_error; |
2887 | if ((status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime)) != 0) | 3066 | if ((status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime)) != 0) |
2888 | goto xdr_error; | 3067 | goto xdr_error; |
3068 | if ((status = decode_attr_mounted_on_fileid(xdr, bitmap, &fileid)) != 0) | ||
3069 | goto xdr_error; | ||
3070 | if (fattr->fileid == 0 && fileid != 0) | ||
3071 | fattr->fileid = fileid; | ||
2889 | if ((status = verify_attr_len(xdr, savep, attrlen)) == 0) | 3072 | if ((status = verify_attr_len(xdr, savep, attrlen)) == 0) |
2890 | fattr->valid = NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4; | 3073 | fattr->valid = NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4; |
2891 | xdr_error: | 3074 | xdr_error: |
@@ -3350,8 +3533,7 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, | |||
3350 | attrlen, recvd); | 3533 | attrlen, recvd); |
3351 | return -EINVAL; | 3534 | return -EINVAL; |
3352 | } | 3535 | } |
3353 | if (attrlen <= *acl_len) | 3536 | xdr_read_pages(xdr, attrlen); |
3354 | xdr_read_pages(xdr, attrlen); | ||
3355 | *acl_len = attrlen; | 3537 | *acl_len = attrlen; |
3356 | } else | 3538 | } else |
3357 | status = -EOPNOTSUPP; | 3539 | status = -EOPNOTSUPP; |
@@ -4211,6 +4393,29 @@ out: | |||
4211 | return status; | 4393 | return status; |
4212 | } | 4394 | } |
4213 | 4395 | ||
4396 | /* | ||
4397 | * FS_LOCATIONS request | ||
4398 | */ | ||
4399 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, uint32_t *p, struct nfs4_fs_locations *res) | ||
4400 | { | ||
4401 | struct xdr_stream xdr; | ||
4402 | struct compound_hdr hdr; | ||
4403 | int status; | ||
4404 | |||
4405 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | ||
4406 | status = decode_compound_hdr(&xdr, &hdr); | ||
4407 | if (status != 0) | ||
4408 | goto out; | ||
4409 | if ((status = decode_putfh(&xdr)) != 0) | ||
4410 | goto out; | ||
4411 | if ((status = decode_lookup(&xdr)) != 0) | ||
4412 | goto out; | ||
4413 | xdr_enter_page(&xdr, PAGE_SIZE); | ||
4414 | status = decode_getfattr(&xdr, &res->fattr, res->server); | ||
4415 | out: | ||
4416 | return status; | ||
4417 | } | ||
4418 | |||
4214 | uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus) | 4419 | uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus) |
4215 | { | 4420 | { |
4216 | uint32_t bitmap[2] = {0}; | 4421 | uint32_t bitmap[2] = {0}; |
@@ -4382,6 +4587,7 @@ struct rpc_procinfo nfs4_procedures[] = { | |||
4382 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), | 4587 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
4383 | PROC(GETACL, enc_getacl, dec_getacl), | 4588 | PROC(GETACL, enc_getacl, dec_getacl), |
4384 | PROC(SETACL, enc_setacl, dec_setacl), | 4589 | PROC(SETACL, enc_setacl, dec_setacl), |
4590 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), | ||
4385 | }; | 4591 | }; |
4386 | 4592 | ||
4387 | struct rpc_version nfs_version4 = { | 4593 | struct rpc_version nfs_version4 = { |
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 106aca388ebc..ef9429643ebc 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
@@ -325,6 +325,7 @@ out: | |||
325 | 325 | ||
326 | /** | 326 | /** |
327 | * nfs_scan_list - Scan a list for matching requests | 327 | * nfs_scan_list - Scan a list for matching requests |
328 | * @nfsi: NFS inode | ||
328 | * @head: One of the NFS inode request lists | 329 | * @head: One of the NFS inode request lists |
329 | * @dst: Destination list | 330 | * @dst: Destination list |
330 | * @idx_start: lower bound of page->index to scan | 331 | * @idx_start: lower bound of page->index to scan |
@@ -336,14 +337,15 @@ out: | |||
336 | * The requests are *not* checked to ensure that they form a contiguous set. | 337 | * The requests are *not* checked to ensure that they form a contiguous set. |
337 | * You must be holding the inode's req_lock when calling this function | 338 | * You must be holding the inode's req_lock when calling this function |
338 | */ | 339 | */ |
339 | int | 340 | int nfs_scan_list(struct nfs_inode *nfsi, struct list_head *head, |
340 | nfs_scan_list(struct list_head *head, struct list_head *dst, | 341 | struct list_head *dst, unsigned long idx_start, |
341 | unsigned long idx_start, unsigned int npages) | 342 | unsigned int npages) |
342 | { | 343 | { |
343 | struct list_head *pos, *tmp; | 344 | struct nfs_page *pgvec[NFS_SCAN_MAXENTRIES]; |
344 | struct nfs_page *req; | 345 | struct nfs_page *req; |
345 | unsigned long idx_end; | 346 | unsigned long idx_end; |
346 | int res; | 347 | int found, i; |
348 | int res; | ||
347 | 349 | ||
348 | res = 0; | 350 | res = 0; |
349 | if (npages == 0) | 351 | if (npages == 0) |
@@ -351,25 +353,32 @@ nfs_scan_list(struct list_head *head, struct list_head *dst, | |||
351 | else | 353 | else |
352 | idx_end = idx_start + npages - 1; | 354 | idx_end = idx_start + npages - 1; |
353 | 355 | ||
354 | list_for_each_safe(pos, tmp, head) { | 356 | for (;;) { |
355 | 357 | found = radix_tree_gang_lookup(&nfsi->nfs_page_tree, | |
356 | req = nfs_list_entry(pos); | 358 | (void **)&pgvec[0], idx_start, |
357 | 359 | NFS_SCAN_MAXENTRIES); | |
358 | if (req->wb_index < idx_start) | 360 | if (found <= 0) |
359 | continue; | ||
360 | if (req->wb_index > idx_end) | ||
361 | break; | 361 | break; |
362 | for (i = 0; i < found; i++) { | ||
363 | req = pgvec[i]; | ||
364 | if (req->wb_index > idx_end) | ||
365 | goto out; | ||
366 | idx_start = req->wb_index + 1; | ||
367 | if (req->wb_list_head != head) | ||
368 | continue; | ||
369 | if (nfs_set_page_writeback_locked(req)) { | ||
370 | nfs_list_remove_request(req); | ||
371 | nfs_list_add_request(req, dst); | ||
372 | res++; | ||
373 | } | ||
374 | } | ||
362 | 375 | ||
363 | if (!nfs_set_page_writeback_locked(req)) | ||
364 | continue; | ||
365 | nfs_list_remove_request(req); | ||
366 | nfs_list_add_request(req, dst); | ||
367 | res++; | ||
368 | } | 376 | } |
377 | out: | ||
369 | return res; | 378 | return res; |
370 | } | 379 | } |
371 | 380 | ||
372 | int nfs_init_nfspagecache(void) | 381 | int __init nfs_init_nfspagecache(void) |
373 | { | 382 | { |
374 | nfs_page_cachep = kmem_cache_create("nfs_page", | 383 | nfs_page_cachep = kmem_cache_create("nfs_page", |
375 | sizeof(struct nfs_page), | 384 | sizeof(struct nfs_page), |
@@ -381,7 +390,7 @@ int nfs_init_nfspagecache(void) | |||
381 | return 0; | 390 | return 0; |
382 | } | 391 | } |
383 | 392 | ||
384 | void nfs_destroy_nfspagecache(void) | 393 | void __exit nfs_destroy_nfspagecache(void) |
385 | { | 394 | { |
386 | if (kmem_cache_destroy(nfs_page_cachep)) | 395 | if (kmem_cache_destroy(nfs_page_cachep)) |
387 | printk(KERN_INFO "nfs_page: not all structures were freed\n"); | 396 | printk(KERN_INFO "nfs_page: not all structures were freed\n"); |
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 9dd85cac2df0..b3899ea3229e 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -44,11 +44,10 @@ | |||
44 | #include <linux/nfs_page.h> | 44 | #include <linux/nfs_page.h> |
45 | #include <linux/lockd/bind.h> | 45 | #include <linux/lockd/bind.h> |
46 | #include <linux/smp_lock.h> | 46 | #include <linux/smp_lock.h> |
47 | #include "internal.h" | ||
47 | 48 | ||
48 | #define NFSDBG_FACILITY NFSDBG_PROC | 49 | #define NFSDBG_FACILITY NFSDBG_PROC |
49 | 50 | ||
50 | extern struct rpc_procinfo nfs_procedures[]; | ||
51 | |||
52 | /* | 51 | /* |
53 | * Bare-bones access to getattr: this is for nfs_read_super. | 52 | * Bare-bones access to getattr: this is for nfs_read_super. |
54 | */ | 53 | */ |
@@ -611,8 +610,6 @@ nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, | |||
611 | return 0; | 610 | return 0; |
612 | } | 611 | } |
613 | 612 | ||
614 | extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int); | ||
615 | |||
616 | static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data) | 613 | static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data) |
617 | { | 614 | { |
618 | if (task->tk_status >= 0) { | 615 | if (task->tk_status >= 0) { |
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 624ca7146b6b..41c2ffee24f5 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -51,14 +51,11 @@ struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount) | |||
51 | if (p) { | 51 | if (p) { |
52 | memset(p, 0, sizeof(*p)); | 52 | memset(p, 0, sizeof(*p)); |
53 | INIT_LIST_HEAD(&p->pages); | 53 | INIT_LIST_HEAD(&p->pages); |
54 | if (pagecount < NFS_PAGEVEC_SIZE) | 54 | if (pagecount <= ARRAY_SIZE(p->page_array)) |
55 | p->pagevec = &p->page_array[0]; | 55 | p->pagevec = p->page_array; |
56 | else { | 56 | else { |
57 | size_t size = ++pagecount * sizeof(struct page *); | 57 | p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_NOFS); |
58 | p->pagevec = kmalloc(size, GFP_NOFS); | 58 | if (!p->pagevec) { |
59 | if (p->pagevec) { | ||
60 | memset(p->pagevec, 0, size); | ||
61 | } else { | ||
62 | mempool_free(p, nfs_rdata_mempool); | 59 | mempool_free(p, nfs_rdata_mempool); |
63 | p = NULL; | 60 | p = NULL; |
64 | } | 61 | } |
@@ -104,6 +101,28 @@ int nfs_return_empty_page(struct page *page) | |||
104 | return 0; | 101 | return 0; |
105 | } | 102 | } |
106 | 103 | ||
104 | static void nfs_readpage_truncate_uninitialised_page(struct nfs_read_data *data) | ||
105 | { | ||
106 | unsigned int remainder = data->args.count - data->res.count; | ||
107 | unsigned int base = data->args.pgbase + data->res.count; | ||
108 | unsigned int pglen; | ||
109 | struct page **pages; | ||
110 | |||
111 | if (data->res.eof == 0 || remainder == 0) | ||
112 | return; | ||
113 | /* | ||
114 | * Note: "remainder" can never be negative, since we check for | ||
115 | * this in the XDR code. | ||
116 | */ | ||
117 | pages = &data->args.pages[base >> PAGE_CACHE_SHIFT]; | ||
118 | base &= ~PAGE_CACHE_MASK; | ||
119 | pglen = PAGE_CACHE_SIZE - base; | ||
120 | if (pglen < remainder) | ||
121 | memclear_highpage_flush(*pages, base, pglen); | ||
122 | else | ||
123 | memclear_highpage_flush(*pages, base, remainder); | ||
124 | } | ||
125 | |||
107 | /* | 126 | /* |
108 | * Read a page synchronously. | 127 | * Read a page synchronously. |
109 | */ | 128 | */ |
@@ -177,11 +196,9 @@ static int nfs_readpage_sync(struct nfs_open_context *ctx, struct inode *inode, | |||
177 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME; | 196 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME; |
178 | spin_unlock(&inode->i_lock); | 197 | spin_unlock(&inode->i_lock); |
179 | 198 | ||
180 | if (count) | 199 | nfs_readpage_truncate_uninitialised_page(rdata); |
181 | memclear_highpage_flush(page, rdata->args.pgbase, count); | 200 | if (rdata->res.eof || rdata->res.count == rdata->args.count) |
182 | SetPageUptodate(page); | 201 | SetPageUptodate(page); |
183 | if (PageError(page)) | ||
184 | ClearPageError(page); | ||
185 | result = 0; | 202 | result = 0; |
186 | 203 | ||
187 | io_error: | 204 | io_error: |
@@ -436,20 +453,12 @@ static void nfs_readpage_result_partial(struct rpc_task *task, void *calldata) | |||
436 | struct nfs_page *req = data->req; | 453 | struct nfs_page *req = data->req; |
437 | struct page *page = req->wb_page; | 454 | struct page *page = req->wb_page; |
438 | 455 | ||
456 | if (likely(task->tk_status >= 0)) | ||
457 | nfs_readpage_truncate_uninitialised_page(data); | ||
458 | else | ||
459 | SetPageError(page); | ||
439 | if (nfs_readpage_result(task, data) != 0) | 460 | if (nfs_readpage_result(task, data) != 0) |
440 | return; | 461 | return; |
441 | if (task->tk_status >= 0) { | ||
442 | unsigned int request = data->args.count; | ||
443 | unsigned int result = data->res.count; | ||
444 | |||
445 | if (result < request) { | ||
446 | memclear_highpage_flush(page, | ||
447 | data->args.pgbase + result, | ||
448 | request - result); | ||
449 | } | ||
450 | } else | ||
451 | SetPageError(page); | ||
452 | |||
453 | if (atomic_dec_and_test(&req->wb_complete)) { | 462 | if (atomic_dec_and_test(&req->wb_complete)) { |
454 | if (!PageError(page)) | 463 | if (!PageError(page)) |
455 | SetPageUptodate(page); | 464 | SetPageUptodate(page); |
@@ -462,6 +471,40 @@ static const struct rpc_call_ops nfs_read_partial_ops = { | |||
462 | .rpc_release = nfs_readdata_release, | 471 | .rpc_release = nfs_readdata_release, |
463 | }; | 472 | }; |
464 | 473 | ||
474 | static void nfs_readpage_set_pages_uptodate(struct nfs_read_data *data) | ||
475 | { | ||
476 | unsigned int count = data->res.count; | ||
477 | unsigned int base = data->args.pgbase; | ||
478 | struct page **pages; | ||
479 | |||
480 | if (unlikely(count == 0)) | ||
481 | return; | ||
482 | pages = &data->args.pages[base >> PAGE_CACHE_SHIFT]; | ||
483 | base &= ~PAGE_CACHE_MASK; | ||
484 | count += base; | ||
485 | for (;count >= PAGE_CACHE_SIZE; count -= PAGE_CACHE_SIZE, pages++) | ||
486 | SetPageUptodate(*pages); | ||
487 | /* | ||
488 | * Was this an eof or a short read? If the latter, don't mark the page | ||
489 | * as uptodate yet. | ||
490 | */ | ||
491 | if (count > 0 && (data->res.eof || data->args.count == data->res.count)) | ||
492 | SetPageUptodate(*pages); | ||
493 | } | ||
494 | |||
495 | static void nfs_readpage_set_pages_error(struct nfs_read_data *data) | ||
496 | { | ||
497 | unsigned int count = data->args.count; | ||
498 | unsigned int base = data->args.pgbase; | ||
499 | struct page **pages; | ||
500 | |||
501 | pages = &data->args.pages[base >> PAGE_CACHE_SHIFT]; | ||
502 | base &= ~PAGE_CACHE_MASK; | ||
503 | count += base; | ||
504 | for (;count >= PAGE_CACHE_SIZE; count -= PAGE_CACHE_SIZE, pages++) | ||
505 | SetPageError(*pages); | ||
506 | } | ||
507 | |||
465 | /* | 508 | /* |
466 | * This is the callback from RPC telling us whether a reply was | 509 | * This is the callback from RPC telling us whether a reply was |
467 | * received or some error occurred (timeout or socket shutdown). | 510 | * received or some error occurred (timeout or socket shutdown). |
@@ -469,27 +512,24 @@ static const struct rpc_call_ops nfs_read_partial_ops = { | |||
469 | static void nfs_readpage_result_full(struct rpc_task *task, void *calldata) | 512 | static void nfs_readpage_result_full(struct rpc_task *task, void *calldata) |
470 | { | 513 | { |
471 | struct nfs_read_data *data = calldata; | 514 | struct nfs_read_data *data = calldata; |
472 | unsigned int count = data->res.count; | ||
473 | 515 | ||
516 | /* | ||
517 | * Note: nfs_readpage_result may change the values of | ||
518 | * data->args. In the multi-page case, we therefore need | ||
519 | * to ensure that we call the next nfs_readpage_set_page_uptodate() | ||
520 | * first in the multi-page case. | ||
521 | */ | ||
522 | if (likely(task->tk_status >= 0)) { | ||
523 | nfs_readpage_truncate_uninitialised_page(data); | ||
524 | nfs_readpage_set_pages_uptodate(data); | ||
525 | } else | ||
526 | nfs_readpage_set_pages_error(data); | ||
474 | if (nfs_readpage_result(task, data) != 0) | 527 | if (nfs_readpage_result(task, data) != 0) |
475 | return; | 528 | return; |
476 | while (!list_empty(&data->pages)) { | 529 | while (!list_empty(&data->pages)) { |
477 | struct nfs_page *req = nfs_list_entry(data->pages.next); | 530 | struct nfs_page *req = nfs_list_entry(data->pages.next); |
478 | struct page *page = req->wb_page; | ||
479 | nfs_list_remove_request(req); | ||
480 | 531 | ||
481 | if (task->tk_status >= 0) { | 532 | nfs_list_remove_request(req); |
482 | if (count < PAGE_CACHE_SIZE) { | ||
483 | if (count < req->wb_bytes) | ||
484 | memclear_highpage_flush(page, | ||
485 | req->wb_pgbase + count, | ||
486 | req->wb_bytes - count); | ||
487 | count = 0; | ||
488 | } else | ||
489 | count -= PAGE_CACHE_SIZE; | ||
490 | SetPageUptodate(page); | ||
491 | } else | ||
492 | SetPageError(page); | ||
493 | nfs_readpage_release(req); | 533 | nfs_readpage_release(req); |
494 | } | 534 | } |
495 | } | 535 | } |
@@ -654,7 +694,7 @@ int nfs_readpages(struct file *filp, struct address_space *mapping, | |||
654 | return ret; | 694 | return ret; |
655 | } | 695 | } |
656 | 696 | ||
657 | int nfs_init_readpagecache(void) | 697 | int __init nfs_init_readpagecache(void) |
658 | { | 698 | { |
659 | nfs_rdata_cachep = kmem_cache_create("nfs_read_data", | 699 | nfs_rdata_cachep = kmem_cache_create("nfs_read_data", |
660 | sizeof(struct nfs_read_data), | 700 | sizeof(struct nfs_read_data), |
@@ -671,7 +711,7 @@ int nfs_init_readpagecache(void) | |||
671 | return 0; | 711 | return 0; |
672 | } | 712 | } |
673 | 713 | ||
674 | void nfs_destroy_readpagecache(void) | 714 | void __exit nfs_destroy_readpagecache(void) |
675 | { | 715 | { |
676 | mempool_destroy(nfs_rdata_mempool); | 716 | mempool_destroy(nfs_rdata_mempool); |
677 | if (kmem_cache_destroy(nfs_rdata_cachep)) | 717 | if (kmem_cache_destroy(nfs_rdata_cachep)) |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c new file mode 100644 index 000000000000..e8a9bee74d9d --- /dev/null +++ b/fs/nfs/super.c | |||
@@ -0,0 +1,1537 @@ | |||
1 | /* | ||
2 | * linux/fs/nfs/super.c | ||
3 | * | ||
4 | * Copyright (C) 1992 Rick Sladkey | ||
5 | * | ||
6 | * nfs superblock handling functions | ||
7 | * | ||
8 | * Modularised by Alan Cox <Alan.Cox@linux.org>, while hacking some | ||
9 | * experimental NFS changes. Modularisation taken straight from SYS5 fs. | ||
10 | * | ||
11 | * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts. | ||
12 | * J.S.Peatfield@damtp.cam.ac.uk | ||
13 | * | ||
14 | * Split from inode.c by David Howells <dhowells@redhat.com> | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #include <linux/config.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/init.h> | ||
21 | |||
22 | #include <linux/time.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/mm.h> | ||
25 | #include <linux/string.h> | ||
26 | #include <linux/stat.h> | ||
27 | #include <linux/errno.h> | ||
28 | #include <linux/unistd.h> | ||
29 | #include <linux/sunrpc/clnt.h> | ||
30 | #include <linux/sunrpc/stats.h> | ||
31 | #include <linux/sunrpc/metrics.h> | ||
32 | #include <linux/nfs_fs.h> | ||
33 | #include <linux/nfs_mount.h> | ||
34 | #include <linux/nfs4_mount.h> | ||
35 | #include <linux/lockd/bind.h> | ||
36 | #include <linux/smp_lock.h> | ||
37 | #include <linux/seq_file.h> | ||
38 | #include <linux/mount.h> | ||
39 | #include <linux/nfs_idmap.h> | ||
40 | #include <linux/vfs.h> | ||
41 | #include <linux/inet.h> | ||
42 | #include <linux/nfs_xdr.h> | ||
43 | |||
44 | #include <asm/system.h> | ||
45 | #include <asm/uaccess.h> | ||
46 | |||
47 | #include "nfs4_fs.h" | ||
48 | #include "callback.h" | ||
49 | #include "delegation.h" | ||
50 | #include "iostat.h" | ||
51 | #include "internal.h" | ||
52 | |||
53 | #define NFSDBG_FACILITY NFSDBG_VFS | ||
54 | |||
55 | /* Maximum number of readahead requests | ||
56 | * FIXME: this should really be a sysctl so that users may tune it to suit | ||
57 | * their needs. People that do NFS over a slow network, might for | ||
58 | * instance want to reduce it to something closer to 1 for improved | ||
59 | * interactive response. | ||
60 | */ | ||
61 | #define NFS_MAX_READAHEAD (RPC_DEF_SLOT_TABLE - 1) | ||
62 | |||
63 | /* | ||
64 | * RPC cruft for NFS | ||
65 | */ | ||
66 | static struct rpc_version * nfs_version[] = { | ||
67 | NULL, | ||
68 | NULL, | ||
69 | &nfs_version2, | ||
70 | #if defined(CONFIG_NFS_V3) | ||
71 | &nfs_version3, | ||
72 | #elif defined(CONFIG_NFS_V4) | ||
73 | NULL, | ||
74 | #endif | ||
75 | #if defined(CONFIG_NFS_V4) | ||
76 | &nfs_version4, | ||
77 | #endif | ||
78 | }; | ||
79 | |||
80 | static struct rpc_program nfs_program = { | ||
81 | .name = "nfs", | ||
82 | .number = NFS_PROGRAM, | ||
83 | .nrvers = ARRAY_SIZE(nfs_version), | ||
84 | .version = nfs_version, | ||
85 | .stats = &nfs_rpcstat, | ||
86 | .pipe_dir_name = "/nfs", | ||
87 | }; | ||
88 | |||
89 | struct rpc_stat nfs_rpcstat = { | ||
90 | .program = &nfs_program | ||
91 | }; | ||
92 | |||
93 | |||
94 | #ifdef CONFIG_NFS_V3_ACL | ||
95 | static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program }; | ||
96 | static struct rpc_version * nfsacl_version[] = { | ||
97 | [3] = &nfsacl_version3, | ||
98 | }; | ||
99 | |||
100 | struct rpc_program nfsacl_program = { | ||
101 | .name = "nfsacl", | ||
102 | .number = NFS_ACL_PROGRAM, | ||
103 | .nrvers = ARRAY_SIZE(nfsacl_version), | ||
104 | .version = nfsacl_version, | ||
105 | .stats = &nfsacl_rpcstat, | ||
106 | }; | ||
107 | #endif /* CONFIG_NFS_V3_ACL */ | ||
108 | |||
109 | static void nfs_umount_begin(struct vfsmount *, int); | ||
110 | static int nfs_statfs(struct dentry *, struct kstatfs *); | ||
111 | static int nfs_show_options(struct seq_file *, struct vfsmount *); | ||
112 | static int nfs_show_stats(struct seq_file *, struct vfsmount *); | ||
113 | static int nfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *); | ||
114 | static int nfs_clone_nfs_sb(struct file_system_type *fs_type, | ||
115 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | ||
116 | static void nfs_kill_super(struct super_block *); | ||
117 | |||
118 | static struct file_system_type nfs_fs_type = { | ||
119 | .owner = THIS_MODULE, | ||
120 | .name = "nfs", | ||
121 | .get_sb = nfs_get_sb, | ||
122 | .kill_sb = nfs_kill_super, | ||
123 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
124 | }; | ||
125 | |||
126 | struct file_system_type clone_nfs_fs_type = { | ||
127 | .owner = THIS_MODULE, | ||
128 | .name = "nfs", | ||
129 | .get_sb = nfs_clone_nfs_sb, | ||
130 | .kill_sb = nfs_kill_super, | ||
131 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
132 | }; | ||
133 | |||
134 | static struct super_operations nfs_sops = { | ||
135 | .alloc_inode = nfs_alloc_inode, | ||
136 | .destroy_inode = nfs_destroy_inode, | ||
137 | .write_inode = nfs_write_inode, | ||
138 | .statfs = nfs_statfs, | ||
139 | .clear_inode = nfs_clear_inode, | ||
140 | .umount_begin = nfs_umount_begin, | ||
141 | .show_options = nfs_show_options, | ||
142 | .show_stats = nfs_show_stats, | ||
143 | }; | ||
144 | |||
145 | #ifdef CONFIG_NFS_V4 | ||
146 | static int nfs4_get_sb(struct file_system_type *fs_type, | ||
147 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | ||
148 | static int nfs_clone_nfs4_sb(struct file_system_type *fs_type, | ||
149 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | ||
150 | static int nfs_referral_nfs4_sb(struct file_system_type *fs_type, | ||
151 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | ||
152 | static void nfs4_kill_super(struct super_block *sb); | ||
153 | |||
154 | static struct file_system_type nfs4_fs_type = { | ||
155 | .owner = THIS_MODULE, | ||
156 | .name = "nfs4", | ||
157 | .get_sb = nfs4_get_sb, | ||
158 | .kill_sb = nfs4_kill_super, | ||
159 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
160 | }; | ||
161 | |||
162 | struct file_system_type clone_nfs4_fs_type = { | ||
163 | .owner = THIS_MODULE, | ||
164 | .name = "nfs4", | ||
165 | .get_sb = nfs_clone_nfs4_sb, | ||
166 | .kill_sb = nfs4_kill_super, | ||
167 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
168 | }; | ||
169 | |||
170 | struct file_system_type nfs_referral_nfs4_fs_type = { | ||
171 | .owner = THIS_MODULE, | ||
172 | .name = "nfs4", | ||
173 | .get_sb = nfs_referral_nfs4_sb, | ||
174 | .kill_sb = nfs4_kill_super, | ||
175 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
176 | }; | ||
177 | |||
178 | static struct super_operations nfs4_sops = { | ||
179 | .alloc_inode = nfs_alloc_inode, | ||
180 | .destroy_inode = nfs_destroy_inode, | ||
181 | .write_inode = nfs_write_inode, | ||
182 | .statfs = nfs_statfs, | ||
183 | .clear_inode = nfs4_clear_inode, | ||
184 | .umount_begin = nfs_umount_begin, | ||
185 | .show_options = nfs_show_options, | ||
186 | .show_stats = nfs_show_stats, | ||
187 | }; | ||
188 | #endif | ||
189 | |||
190 | #ifdef CONFIG_NFS_V4 | ||
191 | static const int nfs_set_port_min = 0; | ||
192 | static const int nfs_set_port_max = 65535; | ||
193 | |||
194 | static int param_set_port(const char *val, struct kernel_param *kp) | ||
195 | { | ||
196 | char *endp; | ||
197 | int num = simple_strtol(val, &endp, 0); | ||
198 | if (endp == val || *endp || num < nfs_set_port_min || num > nfs_set_port_max) | ||
199 | return -EINVAL; | ||
200 | *((int *)kp->arg) = num; | ||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | module_param_call(callback_tcpport, param_set_port, param_get_int, | ||
205 | &nfs_callback_set_tcpport, 0644); | ||
206 | #endif | ||
207 | |||
208 | #ifdef CONFIG_NFS_V4 | ||
209 | static int param_set_idmap_timeout(const char *val, struct kernel_param *kp) | ||
210 | { | ||
211 | char *endp; | ||
212 | int num = simple_strtol(val, &endp, 0); | ||
213 | int jif = num * HZ; | ||
214 | if (endp == val || *endp || num < 0 || jif < num) | ||
215 | return -EINVAL; | ||
216 | *((int *)kp->arg) = jif; | ||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | module_param_call(idmap_cache_timeout, param_set_idmap_timeout, param_get_int, | ||
221 | &nfs_idmap_cache_timeout, 0644); | ||
222 | #endif | ||
223 | |||
224 | /* | ||
225 | * Register the NFS filesystems | ||
226 | */ | ||
227 | int __init register_nfs_fs(void) | ||
228 | { | ||
229 | int ret; | ||
230 | |||
231 | ret = register_filesystem(&nfs_fs_type); | ||
232 | if (ret < 0) | ||
233 | goto error_0; | ||
234 | |||
235 | #ifdef CONFIG_NFS_V4 | ||
236 | ret = nfs_register_sysctl(); | ||
237 | if (ret < 0) | ||
238 | goto error_1; | ||
239 | ret = register_filesystem(&nfs4_fs_type); | ||
240 | if (ret < 0) | ||
241 | goto error_2; | ||
242 | #endif | ||
243 | return 0; | ||
244 | |||
245 | #ifdef CONFIG_NFS_V4 | ||
246 | error_2: | ||
247 | nfs_unregister_sysctl(); | ||
248 | error_1: | ||
249 | unregister_filesystem(&nfs_fs_type); | ||
250 | #endif | ||
251 | error_0: | ||
252 | return ret; | ||
253 | } | ||
254 | |||
255 | /* | ||
256 | * Unregister the NFS filesystems | ||
257 | */ | ||
258 | void __exit unregister_nfs_fs(void) | ||
259 | { | ||
260 | #ifdef CONFIG_NFS_V4 | ||
261 | unregister_filesystem(&nfs4_fs_type); | ||
262 | nfs_unregister_sysctl(); | ||
263 | #endif | ||
264 | unregister_filesystem(&nfs_fs_type); | ||
265 | } | ||
266 | |||
267 | /* | ||
268 | * Deliver file system statistics to userspace | ||
269 | */ | ||
270 | static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) | ||
271 | { | ||
272 | struct super_block *sb = dentry->d_sb; | ||
273 | struct nfs_server *server = NFS_SB(sb); | ||
274 | unsigned char blockbits; | ||
275 | unsigned long blockres; | ||
276 | struct nfs_fh *rootfh = NFS_FH(sb->s_root->d_inode); | ||
277 | struct nfs_fattr fattr; | ||
278 | struct nfs_fsstat res = { | ||
279 | .fattr = &fattr, | ||
280 | }; | ||
281 | int error; | ||
282 | |||
283 | lock_kernel(); | ||
284 | |||
285 | error = server->rpc_ops->statfs(server, rootfh, &res); | ||
286 | buf->f_type = NFS_SUPER_MAGIC; | ||
287 | if (error < 0) | ||
288 | goto out_err; | ||
289 | |||
290 | /* | ||
291 | * Current versions of glibc do not correctly handle the | ||
292 | * case where f_frsize != f_bsize. Eventually we want to | ||
293 | * report the value of wtmult in this field. | ||
294 | */ | ||
295 | buf->f_frsize = sb->s_blocksize; | ||
296 | |||
297 | /* | ||
298 | * On most *nix systems, f_blocks, f_bfree, and f_bavail | ||
299 | * are reported in units of f_frsize. Linux hasn't had | ||
300 | * an f_frsize field in its statfs struct until recently, | ||
301 | * thus historically Linux's sys_statfs reports these | ||
302 | * fields in units of f_bsize. | ||
303 | */ | ||
304 | buf->f_bsize = sb->s_blocksize; | ||
305 | blockbits = sb->s_blocksize_bits; | ||
306 | blockres = (1 << blockbits) - 1; | ||
307 | buf->f_blocks = (res.tbytes + blockres) >> blockbits; | ||
308 | buf->f_bfree = (res.fbytes + blockres) >> blockbits; | ||
309 | buf->f_bavail = (res.abytes + blockres) >> blockbits; | ||
310 | |||
311 | buf->f_files = res.tfiles; | ||
312 | buf->f_ffree = res.afiles; | ||
313 | |||
314 | buf->f_namelen = server->namelen; | ||
315 | out: | ||
316 | unlock_kernel(); | ||
317 | return 0; | ||
318 | |||
319 | out_err: | ||
320 | dprintk("%s: statfs error = %d\n", __FUNCTION__, -error); | ||
321 | buf->f_bsize = buf->f_blocks = buf->f_bfree = buf->f_bavail = -1; | ||
322 | goto out; | ||
323 | |||
324 | } | ||
325 | |||
326 | static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour) | ||
327 | { | ||
328 | static struct { | ||
329 | rpc_authflavor_t flavour; | ||
330 | const char *str; | ||
331 | } sec_flavours[] = { | ||
332 | { RPC_AUTH_NULL, "null" }, | ||
333 | { RPC_AUTH_UNIX, "sys" }, | ||
334 | { RPC_AUTH_GSS_KRB5, "krb5" }, | ||
335 | { RPC_AUTH_GSS_KRB5I, "krb5i" }, | ||
336 | { RPC_AUTH_GSS_KRB5P, "krb5p" }, | ||
337 | { RPC_AUTH_GSS_LKEY, "lkey" }, | ||
338 | { RPC_AUTH_GSS_LKEYI, "lkeyi" }, | ||
339 | { RPC_AUTH_GSS_LKEYP, "lkeyp" }, | ||
340 | { RPC_AUTH_GSS_SPKM, "spkm" }, | ||
341 | { RPC_AUTH_GSS_SPKMI, "spkmi" }, | ||
342 | { RPC_AUTH_GSS_SPKMP, "spkmp" }, | ||
343 | { -1, "unknown" } | ||
344 | }; | ||
345 | int i; | ||
346 | |||
347 | for (i=0; sec_flavours[i].flavour != -1; i++) { | ||
348 | if (sec_flavours[i].flavour == flavour) | ||
349 | break; | ||
350 | } | ||
351 | return sec_flavours[i].str; | ||
352 | } | ||
353 | |||
354 | /* | ||
355 | * Describe the mount options in force on this server representation | ||
356 | */ | ||
357 | static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, int showdefaults) | ||
358 | { | ||
359 | static struct proc_nfs_info { | ||
360 | int flag; | ||
361 | char *str; | ||
362 | char *nostr; | ||
363 | } nfs_info[] = { | ||
364 | { NFS_MOUNT_SOFT, ",soft", ",hard" }, | ||
365 | { NFS_MOUNT_INTR, ",intr", "" }, | ||
366 | { NFS_MOUNT_NOCTO, ",nocto", "" }, | ||
367 | { NFS_MOUNT_NOAC, ",noac", "" }, | ||
368 | { NFS_MOUNT_NONLM, ",nolock", "" }, | ||
369 | { NFS_MOUNT_NOACL, ",noacl", "" }, | ||
370 | { 0, NULL, NULL } | ||
371 | }; | ||
372 | struct proc_nfs_info *nfs_infop; | ||
373 | char buf[12]; | ||
374 | char *proto; | ||
375 | |||
376 | seq_printf(m, ",vers=%d", nfss->rpc_ops->version); | ||
377 | seq_printf(m, ",rsize=%d", nfss->rsize); | ||
378 | seq_printf(m, ",wsize=%d", nfss->wsize); | ||
379 | if (nfss->acregmin != 3*HZ || showdefaults) | ||
380 | seq_printf(m, ",acregmin=%d", nfss->acregmin/HZ); | ||
381 | if (nfss->acregmax != 60*HZ || showdefaults) | ||
382 | seq_printf(m, ",acregmax=%d", nfss->acregmax/HZ); | ||
383 | if (nfss->acdirmin != 30*HZ || showdefaults) | ||
384 | seq_printf(m, ",acdirmin=%d", nfss->acdirmin/HZ); | ||
385 | if (nfss->acdirmax != 60*HZ || showdefaults) | ||
386 | seq_printf(m, ",acdirmax=%d", nfss->acdirmax/HZ); | ||
387 | for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { | ||
388 | if (nfss->flags & nfs_infop->flag) | ||
389 | seq_puts(m, nfs_infop->str); | ||
390 | else | ||
391 | seq_puts(m, nfs_infop->nostr); | ||
392 | } | ||
393 | switch (nfss->client->cl_xprt->prot) { | ||
394 | case IPPROTO_TCP: | ||
395 | proto = "tcp"; | ||
396 | break; | ||
397 | case IPPROTO_UDP: | ||
398 | proto = "udp"; | ||
399 | break; | ||
400 | default: | ||
401 | snprintf(buf, sizeof(buf), "%u", nfss->client->cl_xprt->prot); | ||
402 | proto = buf; | ||
403 | } | ||
404 | seq_printf(m, ",proto=%s", proto); | ||
405 | seq_printf(m, ",timeo=%lu", 10U * nfss->retrans_timeo / HZ); | ||
406 | seq_printf(m, ",retrans=%u", nfss->retrans_count); | ||
407 | seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor)); | ||
408 | } | ||
409 | |||
410 | /* | ||
411 | * Describe the mount options on this VFS mountpoint | ||
412 | */ | ||
413 | static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt) | ||
414 | { | ||
415 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); | ||
416 | |||
417 | nfs_show_mount_options(m, nfss, 0); | ||
418 | |||
419 | seq_puts(m, ",addr="); | ||
420 | seq_escape(m, nfss->hostname, " \t\n\\"); | ||
421 | |||
422 | return 0; | ||
423 | } | ||
424 | |||
425 | /* | ||
426 | * Present statistical information for this VFS mountpoint | ||
427 | */ | ||
428 | static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) | ||
429 | { | ||
430 | int i, cpu; | ||
431 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); | ||
432 | struct rpc_auth *auth = nfss->client->cl_auth; | ||
433 | struct nfs_iostats totals = { }; | ||
434 | |||
435 | seq_printf(m, "statvers=%s", NFS_IOSTAT_VERS); | ||
436 | |||
437 | /* | ||
438 | * Display all mount option settings | ||
439 | */ | ||
440 | seq_printf(m, "\n\topts:\t"); | ||
441 | seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw"); | ||
442 | seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : ""); | ||
443 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : ""); | ||
444 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : ""); | ||
445 | nfs_show_mount_options(m, nfss, 1); | ||
446 | |||
447 | seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ); | ||
448 | |||
449 | seq_printf(m, "\n\tcaps:\t"); | ||
450 | seq_printf(m, "caps=0x%x", nfss->caps); | ||
451 | seq_printf(m, ",wtmult=%d", nfss->wtmult); | ||
452 | seq_printf(m, ",dtsize=%d", nfss->dtsize); | ||
453 | seq_printf(m, ",bsize=%d", nfss->bsize); | ||
454 | seq_printf(m, ",namelen=%d", nfss->namelen); | ||
455 | |||
456 | #ifdef CONFIG_NFS_V4 | ||
457 | if (nfss->rpc_ops->version == 4) { | ||
458 | seq_printf(m, "\n\tnfsv4:\t"); | ||
459 | seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]); | ||
460 | seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]); | ||
461 | seq_printf(m, ",acl=0x%x", nfss->acl_bitmask); | ||
462 | } | ||
463 | #endif | ||
464 | |||
465 | /* | ||
466 | * Display security flavor in effect for this mount | ||
467 | */ | ||
468 | seq_printf(m, "\n\tsec:\tflavor=%d", auth->au_ops->au_flavor); | ||
469 | if (auth->au_flavor) | ||
470 | seq_printf(m, ",pseudoflavor=%d", auth->au_flavor); | ||
471 | |||
472 | /* | ||
473 | * Display superblock I/O counters | ||
474 | */ | ||
475 | for_each_possible_cpu(cpu) { | ||
476 | struct nfs_iostats *stats; | ||
477 | |||
478 | preempt_disable(); | ||
479 | stats = per_cpu_ptr(nfss->io_stats, cpu); | ||
480 | |||
481 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) | ||
482 | totals.events[i] += stats->events[i]; | ||
483 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) | ||
484 | totals.bytes[i] += stats->bytes[i]; | ||
485 | |||
486 | preempt_enable(); | ||
487 | } | ||
488 | |||
489 | seq_printf(m, "\n\tevents:\t"); | ||
490 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) | ||
491 | seq_printf(m, "%lu ", totals.events[i]); | ||
492 | seq_printf(m, "\n\tbytes:\t"); | ||
493 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) | ||
494 | seq_printf(m, "%Lu ", totals.bytes[i]); | ||
495 | seq_printf(m, "\n"); | ||
496 | |||
497 | rpc_print_iostats(m, nfss->client); | ||
498 | |||
499 | return 0; | ||
500 | } | ||
501 | |||
502 | /* | ||
503 | * Begin unmount by attempting to remove all automounted mountpoints we added | ||
504 | * in response to traversals | ||
505 | */ | ||
506 | static void nfs_umount_begin(struct vfsmount *vfsmnt, int flags) | ||
507 | { | ||
508 | struct nfs_server *server; | ||
509 | struct rpc_clnt *rpc; | ||
510 | |||
511 | shrink_submounts(vfsmnt, &nfs_automount_list); | ||
512 | if (!(flags & MNT_FORCE)) | ||
513 | return; | ||
514 | /* -EIO all pending I/O */ | ||
515 | server = NFS_SB(vfsmnt->mnt_sb); | ||
516 | rpc = server->client; | ||
517 | if (!IS_ERR(rpc)) | ||
518 | rpc_killall_tasks(rpc); | ||
519 | rpc = server->client_acl; | ||
520 | if (!IS_ERR(rpc)) | ||
521 | rpc_killall_tasks(rpc); | ||
522 | } | ||
523 | |||
524 | /* | ||
525 | * Obtain the root inode of the file system. | ||
526 | */ | ||
527 | static struct inode * | ||
528 | nfs_get_root(struct super_block *sb, struct nfs_fh *rootfh, struct nfs_fsinfo *fsinfo) | ||
529 | { | ||
530 | struct nfs_server *server = NFS_SB(sb); | ||
531 | int error; | ||
532 | |||
533 | error = server->rpc_ops->getroot(server, rootfh, fsinfo); | ||
534 | if (error < 0) { | ||
535 | dprintk("nfs_get_root: getattr error = %d\n", -error); | ||
536 | return ERR_PTR(error); | ||
537 | } | ||
538 | |||
539 | server->fsid = fsinfo->fattr->fsid; | ||
540 | return nfs_fhget(sb, rootfh, fsinfo->fattr); | ||
541 | } | ||
542 | |||
543 | /* | ||
544 | * Do NFS version-independent mount processing, and sanity checking | ||
545 | */ | ||
546 | static int | ||
547 | nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor) | ||
548 | { | ||
549 | struct nfs_server *server; | ||
550 | struct inode *root_inode; | ||
551 | struct nfs_fattr fattr; | ||
552 | struct nfs_fsinfo fsinfo = { | ||
553 | .fattr = &fattr, | ||
554 | }; | ||
555 | struct nfs_pathconf pathinfo = { | ||
556 | .fattr = &fattr, | ||
557 | }; | ||
558 | int no_root_error = 0; | ||
559 | unsigned long max_rpc_payload; | ||
560 | |||
561 | /* We probably want something more informative here */ | ||
562 | snprintf(sb->s_id, sizeof(sb->s_id), "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev)); | ||
563 | |||
564 | server = NFS_SB(sb); | ||
565 | |||
566 | sb->s_magic = NFS_SUPER_MAGIC; | ||
567 | |||
568 | server->io_stats = nfs_alloc_iostats(); | ||
569 | if (server->io_stats == NULL) | ||
570 | return -ENOMEM; | ||
571 | |||
572 | root_inode = nfs_get_root(sb, &server->fh, &fsinfo); | ||
573 | /* Did getting the root inode fail? */ | ||
574 | if (IS_ERR(root_inode)) { | ||
575 | no_root_error = PTR_ERR(root_inode); | ||
576 | goto out_no_root; | ||
577 | } | ||
578 | sb->s_root = d_alloc_root(root_inode); | ||
579 | if (!sb->s_root) { | ||
580 | no_root_error = -ENOMEM; | ||
581 | goto out_no_root; | ||
582 | } | ||
583 | sb->s_root->d_op = server->rpc_ops->dentry_ops; | ||
584 | |||
585 | /* mount time stamp, in seconds */ | ||
586 | server->mount_time = jiffies; | ||
587 | |||
588 | /* Get some general file system info */ | ||
589 | if (server->namelen == 0 && | ||
590 | server->rpc_ops->pathconf(server, &server->fh, &pathinfo) >= 0) | ||
591 | server->namelen = pathinfo.max_namelen; | ||
592 | /* Work out a lot of parameters */ | ||
593 | if (server->rsize == 0) | ||
594 | server->rsize = nfs_block_size(fsinfo.rtpref, NULL); | ||
595 | if (server->wsize == 0) | ||
596 | server->wsize = nfs_block_size(fsinfo.wtpref, NULL); | ||
597 | |||
598 | if (fsinfo.rtmax >= 512 && server->rsize > fsinfo.rtmax) | ||
599 | server->rsize = nfs_block_size(fsinfo.rtmax, NULL); | ||
600 | if (fsinfo.wtmax >= 512 && server->wsize > fsinfo.wtmax) | ||
601 | server->wsize = nfs_block_size(fsinfo.wtmax, NULL); | ||
602 | |||
603 | max_rpc_payload = nfs_block_size(rpc_max_payload(server->client), NULL); | ||
604 | if (server->rsize > max_rpc_payload) | ||
605 | server->rsize = max_rpc_payload; | ||
606 | if (server->rsize > NFS_MAX_FILE_IO_SIZE) | ||
607 | server->rsize = NFS_MAX_FILE_IO_SIZE; | ||
608 | server->rpages = (server->rsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | ||
609 | |||
610 | if (server->wsize > max_rpc_payload) | ||
611 | server->wsize = max_rpc_payload; | ||
612 | if (server->wsize > NFS_MAX_FILE_IO_SIZE) | ||
613 | server->wsize = NFS_MAX_FILE_IO_SIZE; | ||
614 | server->wpages = (server->wsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | ||
615 | |||
616 | if (sb->s_blocksize == 0) | ||
617 | sb->s_blocksize = nfs_block_bits(server->wsize, | ||
618 | &sb->s_blocksize_bits); | ||
619 | server->wtmult = nfs_block_bits(fsinfo.wtmult, NULL); | ||
620 | |||
621 | server->dtsize = nfs_block_size(fsinfo.dtpref, NULL); | ||
622 | if (server->dtsize > PAGE_CACHE_SIZE) | ||
623 | server->dtsize = PAGE_CACHE_SIZE; | ||
624 | if (server->dtsize > server->rsize) | ||
625 | server->dtsize = server->rsize; | ||
626 | |||
627 | if (server->flags & NFS_MOUNT_NOAC) { | ||
628 | server->acregmin = server->acregmax = 0; | ||
629 | server->acdirmin = server->acdirmax = 0; | ||
630 | sb->s_flags |= MS_SYNCHRONOUS; | ||
631 | } | ||
632 | server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD; | ||
633 | |||
634 | nfs_super_set_maxbytes(sb, fsinfo.maxfilesize); | ||
635 | |||
636 | server->client->cl_intr = (server->flags & NFS_MOUNT_INTR) ? 1 : 0; | ||
637 | server->client->cl_softrtry = (server->flags & NFS_MOUNT_SOFT) ? 1 : 0; | ||
638 | |||
639 | /* We're airborne Set socket buffersize */ | ||
640 | rpc_setbufsize(server->client, server->wsize + 100, server->rsize + 100); | ||
641 | return 0; | ||
642 | /* Yargs. It didn't work out. */ | ||
643 | out_no_root: | ||
644 | dprintk("nfs_sb_init: get root inode failed: errno %d\n", -no_root_error); | ||
645 | if (!IS_ERR(root_inode)) | ||
646 | iput(root_inode); | ||
647 | return no_root_error; | ||
648 | } | ||
649 | |||
650 | /* | ||
651 | * Initialise the timeout values for a connection | ||
652 | */ | ||
653 | static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, unsigned int timeo, unsigned int retrans) | ||
654 | { | ||
655 | to->to_initval = timeo * HZ / 10; | ||
656 | to->to_retries = retrans; | ||
657 | if (!to->to_retries) | ||
658 | to->to_retries = 2; | ||
659 | |||
660 | switch (proto) { | ||
661 | case IPPROTO_TCP: | ||
662 | if (!to->to_initval) | ||
663 | to->to_initval = 60 * HZ; | ||
664 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) | ||
665 | to->to_initval = NFS_MAX_TCP_TIMEOUT; | ||
666 | to->to_increment = to->to_initval; | ||
667 | to->to_maxval = to->to_initval + (to->to_increment * to->to_retries); | ||
668 | to->to_exponential = 0; | ||
669 | break; | ||
670 | case IPPROTO_UDP: | ||
671 | default: | ||
672 | if (!to->to_initval) | ||
673 | to->to_initval = 11 * HZ / 10; | ||
674 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) | ||
675 | to->to_initval = NFS_MAX_UDP_TIMEOUT; | ||
676 | to->to_maxval = NFS_MAX_UDP_TIMEOUT; | ||
677 | to->to_exponential = 1; | ||
678 | break; | ||
679 | } | ||
680 | } | ||
681 | |||
682 | /* | ||
683 | * Create an RPC client handle. | ||
684 | */ | ||
685 | static struct rpc_clnt * | ||
686 | nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data) | ||
687 | { | ||
688 | struct rpc_timeout timeparms; | ||
689 | struct rpc_xprt *xprt = NULL; | ||
690 | struct rpc_clnt *clnt = NULL; | ||
691 | int proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP; | ||
692 | |||
693 | nfs_init_timeout_values(&timeparms, proto, data->timeo, data->retrans); | ||
694 | |||
695 | server->retrans_timeo = timeparms.to_initval; | ||
696 | server->retrans_count = timeparms.to_retries; | ||
697 | |||
698 | /* create transport and client */ | ||
699 | xprt = xprt_create_proto(proto, &server->addr, &timeparms); | ||
700 | if (IS_ERR(xprt)) { | ||
701 | dprintk("%s: cannot create RPC transport. Error = %ld\n", | ||
702 | __FUNCTION__, PTR_ERR(xprt)); | ||
703 | return (struct rpc_clnt *)xprt; | ||
704 | } | ||
705 | clnt = rpc_create_client(xprt, server->hostname, &nfs_program, | ||
706 | server->rpc_ops->version, data->pseudoflavor); | ||
707 | if (IS_ERR(clnt)) { | ||
708 | dprintk("%s: cannot create RPC client. Error = %ld\n", | ||
709 | __FUNCTION__, PTR_ERR(xprt)); | ||
710 | goto out_fail; | ||
711 | } | ||
712 | |||
713 | clnt->cl_intr = 1; | ||
714 | clnt->cl_softrtry = 1; | ||
715 | |||
716 | return clnt; | ||
717 | |||
718 | out_fail: | ||
719 | return clnt; | ||
720 | } | ||
721 | |||
722 | /* | ||
723 | * Clone a server record | ||
724 | */ | ||
725 | static struct nfs_server *nfs_clone_server(struct super_block *sb, struct nfs_clone_mount *data) | ||
726 | { | ||
727 | struct nfs_server *server = NFS_SB(sb); | ||
728 | struct nfs_server *parent = NFS_SB(data->sb); | ||
729 | struct inode *root_inode; | ||
730 | struct nfs_fsinfo fsinfo; | ||
731 | void *err = ERR_PTR(-ENOMEM); | ||
732 | |||
733 | sb->s_op = data->sb->s_op; | ||
734 | sb->s_blocksize = data->sb->s_blocksize; | ||
735 | sb->s_blocksize_bits = data->sb->s_blocksize_bits; | ||
736 | sb->s_maxbytes = data->sb->s_maxbytes; | ||
737 | |||
738 | server->client_sys = server->client_acl = ERR_PTR(-EINVAL); | ||
739 | server->io_stats = nfs_alloc_iostats(); | ||
740 | if (server->io_stats == NULL) | ||
741 | goto out; | ||
742 | |||
743 | server->client = rpc_clone_client(parent->client); | ||
744 | if (IS_ERR((err = server->client))) | ||
745 | goto out; | ||
746 | |||
747 | if (!IS_ERR(parent->client_sys)) { | ||
748 | server->client_sys = rpc_clone_client(parent->client_sys); | ||
749 | if (IS_ERR((err = server->client_sys))) | ||
750 | goto out; | ||
751 | } | ||
752 | if (!IS_ERR(parent->client_acl)) { | ||
753 | server->client_acl = rpc_clone_client(parent->client_acl); | ||
754 | if (IS_ERR((err = server->client_acl))) | ||
755 | goto out; | ||
756 | } | ||
757 | root_inode = nfs_fhget(sb, data->fh, data->fattr); | ||
758 | if (!root_inode) | ||
759 | goto out; | ||
760 | sb->s_root = d_alloc_root(root_inode); | ||
761 | if (!sb->s_root) | ||
762 | goto out_put_root; | ||
763 | fsinfo.fattr = data->fattr; | ||
764 | if (NFS_PROTO(root_inode)->fsinfo(server, data->fh, &fsinfo) == 0) | ||
765 | nfs_super_set_maxbytes(sb, fsinfo.maxfilesize); | ||
766 | sb->s_root->d_op = server->rpc_ops->dentry_ops; | ||
767 | sb->s_flags |= MS_ACTIVE; | ||
768 | return server; | ||
769 | out_put_root: | ||
770 | iput(root_inode); | ||
771 | out: | ||
772 | return err; | ||
773 | } | ||
774 | |||
775 | /* | ||
776 | * Copy an existing superblock and attach revised data | ||
777 | */ | ||
778 | static int nfs_clone_generic_sb(struct nfs_clone_mount *data, | ||
779 | struct super_block *(*fill_sb)(struct nfs_server *, struct nfs_clone_mount *), | ||
780 | struct nfs_server *(*fill_server)(struct super_block *, struct nfs_clone_mount *), | ||
781 | struct vfsmount *mnt) | ||
782 | { | ||
783 | struct nfs_server *server; | ||
784 | struct nfs_server *parent = NFS_SB(data->sb); | ||
785 | struct super_block *sb = ERR_PTR(-EINVAL); | ||
786 | char *hostname; | ||
787 | int error = -ENOMEM; | ||
788 | int len; | ||
789 | |||
790 | server = kmalloc(sizeof(struct nfs_server), GFP_KERNEL); | ||
791 | if (server == NULL) | ||
792 | goto out_err; | ||
793 | memcpy(server, parent, sizeof(*server)); | ||
794 | hostname = (data->hostname != NULL) ? data->hostname : parent->hostname; | ||
795 | len = strlen(hostname) + 1; | ||
796 | server->hostname = kmalloc(len, GFP_KERNEL); | ||
797 | if (server->hostname == NULL) | ||
798 | goto free_server; | ||
799 | memcpy(server->hostname, hostname, len); | ||
800 | error = rpciod_up(); | ||
801 | if (error != 0) | ||
802 | goto free_hostname; | ||
803 | |||
804 | sb = fill_sb(server, data); | ||
805 | if (IS_ERR(sb)) { | ||
806 | error = PTR_ERR(sb); | ||
807 | goto kill_rpciod; | ||
808 | } | ||
809 | |||
810 | if (sb->s_root) | ||
811 | goto out_rpciod_down; | ||
812 | |||
813 | server = fill_server(sb, data); | ||
814 | if (IS_ERR(server)) { | ||
815 | error = PTR_ERR(server); | ||
816 | goto out_deactivate; | ||
817 | } | ||
818 | return simple_set_mnt(mnt, sb); | ||
819 | out_deactivate: | ||
820 | up_write(&sb->s_umount); | ||
821 | deactivate_super(sb); | ||
822 | return error; | ||
823 | out_rpciod_down: | ||
824 | rpciod_down(); | ||
825 | kfree(server->hostname); | ||
826 | kfree(server); | ||
827 | return simple_set_mnt(mnt, sb); | ||
828 | kill_rpciod: | ||
829 | rpciod_down(); | ||
830 | free_hostname: | ||
831 | kfree(server->hostname); | ||
832 | free_server: | ||
833 | kfree(server); | ||
834 | out_err: | ||
835 | return error; | ||
836 | } | ||
837 | |||
838 | /* | ||
839 | * Set up an NFS2/3 superblock | ||
840 | * | ||
841 | * The way this works is that the mount process passes a structure | ||
842 | * in the data argument which contains the server's IP address | ||
843 | * and the root file handle obtained from the server's mount | ||
844 | * daemon. We stash these away in the private superblock fields. | ||
845 | */ | ||
846 | static int | ||
847 | nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent) | ||
848 | { | ||
849 | struct nfs_server *server; | ||
850 | rpc_authflavor_t authflavor; | ||
851 | |||
852 | server = NFS_SB(sb); | ||
853 | sb->s_blocksize_bits = 0; | ||
854 | sb->s_blocksize = 0; | ||
855 | if (data->bsize) | ||
856 | sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits); | ||
857 | if (data->rsize) | ||
858 | server->rsize = nfs_block_size(data->rsize, NULL); | ||
859 | if (data->wsize) | ||
860 | server->wsize = nfs_block_size(data->wsize, NULL); | ||
861 | server->flags = data->flags & NFS_MOUNT_FLAGMASK; | ||
862 | |||
863 | server->acregmin = data->acregmin*HZ; | ||
864 | server->acregmax = data->acregmax*HZ; | ||
865 | server->acdirmin = data->acdirmin*HZ; | ||
866 | server->acdirmax = data->acdirmax*HZ; | ||
867 | |||
868 | /* Start lockd here, before we might error out */ | ||
869 | if (!(server->flags & NFS_MOUNT_NONLM)) | ||
870 | lockd_up(); | ||
871 | |||
872 | server->namelen = data->namlen; | ||
873 | server->hostname = kmalloc(strlen(data->hostname) + 1, GFP_KERNEL); | ||
874 | if (!server->hostname) | ||
875 | return -ENOMEM; | ||
876 | strcpy(server->hostname, data->hostname); | ||
877 | |||
878 | /* Check NFS protocol revision and initialize RPC op vector | ||
879 | * and file handle pool. */ | ||
880 | #ifdef CONFIG_NFS_V3 | ||
881 | if (server->flags & NFS_MOUNT_VER3) { | ||
882 | server->rpc_ops = &nfs_v3_clientops; | ||
883 | server->caps |= NFS_CAP_READDIRPLUS; | ||
884 | } else { | ||
885 | server->rpc_ops = &nfs_v2_clientops; | ||
886 | } | ||
887 | #else | ||
888 | server->rpc_ops = &nfs_v2_clientops; | ||
889 | #endif | ||
890 | |||
891 | /* Fill in pseudoflavor for mount version < 5 */ | ||
892 | if (!(data->flags & NFS_MOUNT_SECFLAVOUR)) | ||
893 | data->pseudoflavor = RPC_AUTH_UNIX; | ||
894 | authflavor = data->pseudoflavor; /* save for sb_init() */ | ||
895 | /* XXX maybe we want to add a server->pseudoflavor field */ | ||
896 | |||
897 | /* Create RPC client handles */ | ||
898 | server->client = nfs_create_client(server, data); | ||
899 | if (IS_ERR(server->client)) | ||
900 | return PTR_ERR(server->client); | ||
901 | /* RFC 2623, sec 2.3.2 */ | ||
902 | if (authflavor != RPC_AUTH_UNIX) { | ||
903 | struct rpc_auth *auth; | ||
904 | |||
905 | server->client_sys = rpc_clone_client(server->client); | ||
906 | if (IS_ERR(server->client_sys)) | ||
907 | return PTR_ERR(server->client_sys); | ||
908 | auth = rpcauth_create(RPC_AUTH_UNIX, server->client_sys); | ||
909 | if (IS_ERR(auth)) | ||
910 | return PTR_ERR(auth); | ||
911 | } else { | ||
912 | atomic_inc(&server->client->cl_count); | ||
913 | server->client_sys = server->client; | ||
914 | } | ||
915 | if (server->flags & NFS_MOUNT_VER3) { | ||
916 | #ifdef CONFIG_NFS_V3_ACL | ||
917 | if (!(server->flags & NFS_MOUNT_NOACL)) { | ||
918 | server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3); | ||
919 | /* No errors! Assume that Sun nfsacls are supported */ | ||
920 | if (!IS_ERR(server->client_acl)) | ||
921 | server->caps |= NFS_CAP_ACLS; | ||
922 | } | ||
923 | #else | ||
924 | server->flags &= ~NFS_MOUNT_NOACL; | ||
925 | #endif /* CONFIG_NFS_V3_ACL */ | ||
926 | /* | ||
927 | * The VFS shouldn't apply the umask to mode bits. We will | ||
928 | * do so ourselves when necessary. | ||
929 | */ | ||
930 | sb->s_flags |= MS_POSIXACL; | ||
931 | if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN) | ||
932 | server->namelen = NFS3_MAXNAMLEN; | ||
933 | sb->s_time_gran = 1; | ||
934 | } else { | ||
935 | if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN) | ||
936 | server->namelen = NFS2_MAXNAMLEN; | ||
937 | } | ||
938 | |||
939 | sb->s_op = &nfs_sops; | ||
940 | return nfs_sb_init(sb, authflavor); | ||
941 | } | ||
942 | |||
943 | static int nfs_set_super(struct super_block *s, void *data) | ||
944 | { | ||
945 | s->s_fs_info = data; | ||
946 | return set_anon_super(s, data); | ||
947 | } | ||
948 | |||
949 | static int nfs_compare_super(struct super_block *sb, void *data) | ||
950 | { | ||
951 | struct nfs_server *server = data; | ||
952 | struct nfs_server *old = NFS_SB(sb); | ||
953 | |||
954 | if (old->addr.sin_addr.s_addr != server->addr.sin_addr.s_addr) | ||
955 | return 0; | ||
956 | if (old->addr.sin_port != server->addr.sin_port) | ||
957 | return 0; | ||
958 | return !nfs_compare_fh(&old->fh, &server->fh); | ||
959 | } | ||
960 | |||
961 | static int nfs_get_sb(struct file_system_type *fs_type, | ||
962 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
963 | { | ||
964 | int error; | ||
965 | struct nfs_server *server = NULL; | ||
966 | struct super_block *s; | ||
967 | struct nfs_fh *root; | ||
968 | struct nfs_mount_data *data = raw_data; | ||
969 | |||
970 | error = -EINVAL; | ||
971 | if (data == NULL) { | ||
972 | dprintk("%s: missing data argument\n", __FUNCTION__); | ||
973 | goto out_err_noserver; | ||
974 | } | ||
975 | if (data->version <= 0 || data->version > NFS_MOUNT_VERSION) { | ||
976 | dprintk("%s: bad mount version\n", __FUNCTION__); | ||
977 | goto out_err_noserver; | ||
978 | } | ||
979 | switch (data->version) { | ||
980 | case 1: | ||
981 | data->namlen = 0; | ||
982 | case 2: | ||
983 | data->bsize = 0; | ||
984 | case 3: | ||
985 | if (data->flags & NFS_MOUNT_VER3) { | ||
986 | dprintk("%s: mount structure version %d does not support NFSv3\n", | ||
987 | __FUNCTION__, | ||
988 | data->version); | ||
989 | goto out_err_noserver; | ||
990 | } | ||
991 | data->root.size = NFS2_FHSIZE; | ||
992 | memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE); | ||
993 | case 4: | ||
994 | if (data->flags & NFS_MOUNT_SECFLAVOUR) { | ||
995 | dprintk("%s: mount structure version %d does not support strong security\n", | ||
996 | __FUNCTION__, | ||
997 | data->version); | ||
998 | goto out_err_noserver; | ||
999 | } | ||
1000 | case 5: | ||
1001 | memset(data->context, 0, sizeof(data->context)); | ||
1002 | } | ||
1003 | #ifndef CONFIG_NFS_V3 | ||
1004 | /* If NFSv3 is not compiled in, return -EPROTONOSUPPORT */ | ||
1005 | error = -EPROTONOSUPPORT; | ||
1006 | if (data->flags & NFS_MOUNT_VER3) { | ||
1007 | dprintk("%s: NFSv3 not compiled into kernel\n", __FUNCTION__); | ||
1008 | goto out_err_noserver; | ||
1009 | } | ||
1010 | #endif /* CONFIG_NFS_V3 */ | ||
1011 | |||
1012 | error = -ENOMEM; | ||
1013 | server = kzalloc(sizeof(struct nfs_server), GFP_KERNEL); | ||
1014 | if (!server) | ||
1015 | goto out_err_noserver; | ||
1016 | /* Zero out the NFS state stuff */ | ||
1017 | init_nfsv4_state(server); | ||
1018 | server->client = server->client_sys = server->client_acl = ERR_PTR(-EINVAL); | ||
1019 | |||
1020 | root = &server->fh; | ||
1021 | if (data->flags & NFS_MOUNT_VER3) | ||
1022 | root->size = data->root.size; | ||
1023 | else | ||
1024 | root->size = NFS2_FHSIZE; | ||
1025 | error = -EINVAL; | ||
1026 | if (root->size > sizeof(root->data)) { | ||
1027 | dprintk("%s: invalid root filehandle\n", __FUNCTION__); | ||
1028 | goto out_err; | ||
1029 | } | ||
1030 | memcpy(root->data, data->root.data, root->size); | ||
1031 | |||
1032 | /* We now require that the mount process passes the remote address */ | ||
1033 | memcpy(&server->addr, &data->addr, sizeof(server->addr)); | ||
1034 | if (server->addr.sin_addr.s_addr == INADDR_ANY) { | ||
1035 | dprintk("%s: mount program didn't pass remote address!\n", | ||
1036 | __FUNCTION__); | ||
1037 | goto out_err; | ||
1038 | } | ||
1039 | |||
1040 | /* Fire up rpciod if not yet running */ | ||
1041 | error = rpciod_up(); | ||
1042 | if (error < 0) { | ||
1043 | dprintk("%s: couldn't start rpciod! Error = %d\n", | ||
1044 | __FUNCTION__, error); | ||
1045 | goto out_err; | ||
1046 | } | ||
1047 | |||
1048 | s = sget(fs_type, nfs_compare_super, nfs_set_super, server); | ||
1049 | if (IS_ERR(s)) { | ||
1050 | error = PTR_ERR(s); | ||
1051 | goto out_err_rpciod; | ||
1052 | } | ||
1053 | |||
1054 | if (s->s_root) | ||
1055 | goto out_rpciod_down; | ||
1056 | |||
1057 | s->s_flags = flags; | ||
1058 | |||
1059 | error = nfs_fill_super(s, data, flags & MS_SILENT ? 1 : 0); | ||
1060 | if (error) { | ||
1061 | up_write(&s->s_umount); | ||
1062 | deactivate_super(s); | ||
1063 | return error; | ||
1064 | } | ||
1065 | s->s_flags |= MS_ACTIVE; | ||
1066 | return simple_set_mnt(mnt, s); | ||
1067 | |||
1068 | out_rpciod_down: | ||
1069 | rpciod_down(); | ||
1070 | kfree(server); | ||
1071 | return simple_set_mnt(mnt, s); | ||
1072 | |||
1073 | out_err_rpciod: | ||
1074 | rpciod_down(); | ||
1075 | out_err: | ||
1076 | kfree(server); | ||
1077 | out_err_noserver: | ||
1078 | return error; | ||
1079 | } | ||
1080 | |||
1081 | static void nfs_kill_super(struct super_block *s) | ||
1082 | { | ||
1083 | struct nfs_server *server = NFS_SB(s); | ||
1084 | |||
1085 | kill_anon_super(s); | ||
1086 | |||
1087 | if (!IS_ERR(server->client)) | ||
1088 | rpc_shutdown_client(server->client); | ||
1089 | if (!IS_ERR(server->client_sys)) | ||
1090 | rpc_shutdown_client(server->client_sys); | ||
1091 | if (!IS_ERR(server->client_acl)) | ||
1092 | rpc_shutdown_client(server->client_acl); | ||
1093 | |||
1094 | if (!(server->flags & NFS_MOUNT_NONLM)) | ||
1095 | lockd_down(); /* release rpc.lockd */ | ||
1096 | |||
1097 | rpciod_down(); /* release rpciod */ | ||
1098 | |||
1099 | nfs_free_iostats(server->io_stats); | ||
1100 | kfree(server->hostname); | ||
1101 | kfree(server); | ||
1102 | nfs_release_automount_timer(); | ||
1103 | } | ||
1104 | |||
1105 | static struct super_block *nfs_clone_sb(struct nfs_server *server, struct nfs_clone_mount *data) | ||
1106 | { | ||
1107 | struct super_block *sb; | ||
1108 | |||
1109 | server->fsid = data->fattr->fsid; | ||
1110 | nfs_copy_fh(&server->fh, data->fh); | ||
1111 | sb = sget(&nfs_fs_type, nfs_compare_super, nfs_set_super, server); | ||
1112 | if (!IS_ERR(sb) && sb->s_root == NULL && !(server->flags & NFS_MOUNT_NONLM)) | ||
1113 | lockd_up(); | ||
1114 | return sb; | ||
1115 | } | ||
1116 | |||
1117 | static int nfs_clone_nfs_sb(struct file_system_type *fs_type, | ||
1118 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
1119 | { | ||
1120 | struct nfs_clone_mount *data = raw_data; | ||
1121 | return nfs_clone_generic_sb(data, nfs_clone_sb, nfs_clone_server, mnt); | ||
1122 | } | ||
1123 | |||
1124 | #ifdef CONFIG_NFS_V4 | ||
1125 | static struct rpc_clnt *nfs4_create_client(struct nfs_server *server, | ||
1126 | struct rpc_timeout *timeparms, int proto, rpc_authflavor_t flavor) | ||
1127 | { | ||
1128 | struct nfs4_client *clp; | ||
1129 | struct rpc_xprt *xprt = NULL; | ||
1130 | struct rpc_clnt *clnt = NULL; | ||
1131 | int err = -EIO; | ||
1132 | |||
1133 | clp = nfs4_get_client(&server->addr.sin_addr); | ||
1134 | if (!clp) { | ||
1135 | dprintk("%s: failed to create NFS4 client.\n", __FUNCTION__); | ||
1136 | return ERR_PTR(err); | ||
1137 | } | ||
1138 | |||
1139 | /* Now create transport and client */ | ||
1140 | down_write(&clp->cl_sem); | ||
1141 | if (IS_ERR(clp->cl_rpcclient)) { | ||
1142 | xprt = xprt_create_proto(proto, &server->addr, timeparms); | ||
1143 | if (IS_ERR(xprt)) { | ||
1144 | up_write(&clp->cl_sem); | ||
1145 | err = PTR_ERR(xprt); | ||
1146 | dprintk("%s: cannot create RPC transport. Error = %d\n", | ||
1147 | __FUNCTION__, err); | ||
1148 | goto out_fail; | ||
1149 | } | ||
1150 | /* Bind to a reserved port! */ | ||
1151 | xprt->resvport = 1; | ||
1152 | clnt = rpc_create_client(xprt, server->hostname, &nfs_program, | ||
1153 | server->rpc_ops->version, flavor); | ||
1154 | if (IS_ERR(clnt)) { | ||
1155 | up_write(&clp->cl_sem); | ||
1156 | err = PTR_ERR(clnt); | ||
1157 | dprintk("%s: cannot create RPC client. Error = %d\n", | ||
1158 | __FUNCTION__, err); | ||
1159 | goto out_fail; | ||
1160 | } | ||
1161 | clnt->cl_intr = 1; | ||
1162 | clnt->cl_softrtry = 1; | ||
1163 | clp->cl_rpcclient = clnt; | ||
1164 | memcpy(clp->cl_ipaddr, server->ip_addr, sizeof(clp->cl_ipaddr)); | ||
1165 | nfs_idmap_new(clp); | ||
1166 | } | ||
1167 | list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); | ||
1168 | clnt = rpc_clone_client(clp->cl_rpcclient); | ||
1169 | if (!IS_ERR(clnt)) | ||
1170 | server->nfs4_state = clp; | ||
1171 | up_write(&clp->cl_sem); | ||
1172 | clp = NULL; | ||
1173 | |||
1174 | if (IS_ERR(clnt)) { | ||
1175 | dprintk("%s: cannot create RPC client. Error = %d\n", | ||
1176 | __FUNCTION__, err); | ||
1177 | return clnt; | ||
1178 | } | ||
1179 | |||
1180 | if (server->nfs4_state->cl_idmap == NULL) { | ||
1181 | dprintk("%s: failed to create idmapper.\n", __FUNCTION__); | ||
1182 | return ERR_PTR(-ENOMEM); | ||
1183 | } | ||
1184 | |||
1185 | if (clnt->cl_auth->au_flavor != flavor) { | ||
1186 | struct rpc_auth *auth; | ||
1187 | |||
1188 | auth = rpcauth_create(flavor, clnt); | ||
1189 | if (IS_ERR(auth)) { | ||
1190 | dprintk("%s: couldn't create credcache!\n", __FUNCTION__); | ||
1191 | return (struct rpc_clnt *)auth; | ||
1192 | } | ||
1193 | } | ||
1194 | return clnt; | ||
1195 | |||
1196 | out_fail: | ||
1197 | if (clp) | ||
1198 | nfs4_put_client(clp); | ||
1199 | return ERR_PTR(err); | ||
1200 | } | ||
1201 | |||
1202 | /* | ||
1203 | * Set up an NFS4 superblock | ||
1204 | */ | ||
1205 | static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data, int silent) | ||
1206 | { | ||
1207 | struct nfs_server *server; | ||
1208 | struct rpc_timeout timeparms; | ||
1209 | rpc_authflavor_t authflavour; | ||
1210 | int err = -EIO; | ||
1211 | |||
1212 | sb->s_blocksize_bits = 0; | ||
1213 | sb->s_blocksize = 0; | ||
1214 | server = NFS_SB(sb); | ||
1215 | if (data->rsize != 0) | ||
1216 | server->rsize = nfs_block_size(data->rsize, NULL); | ||
1217 | if (data->wsize != 0) | ||
1218 | server->wsize = nfs_block_size(data->wsize, NULL); | ||
1219 | server->flags = data->flags & NFS_MOUNT_FLAGMASK; | ||
1220 | server->caps = NFS_CAP_ATOMIC_OPEN; | ||
1221 | |||
1222 | server->acregmin = data->acregmin*HZ; | ||
1223 | server->acregmax = data->acregmax*HZ; | ||
1224 | server->acdirmin = data->acdirmin*HZ; | ||
1225 | server->acdirmax = data->acdirmax*HZ; | ||
1226 | |||
1227 | server->rpc_ops = &nfs_v4_clientops; | ||
1228 | |||
1229 | nfs_init_timeout_values(&timeparms, data->proto, data->timeo, data->retrans); | ||
1230 | |||
1231 | server->retrans_timeo = timeparms.to_initval; | ||
1232 | server->retrans_count = timeparms.to_retries; | ||
1233 | |||
1234 | /* Now create transport and client */ | ||
1235 | authflavour = RPC_AUTH_UNIX; | ||
1236 | if (data->auth_flavourlen != 0) { | ||
1237 | if (data->auth_flavourlen != 1) { | ||
1238 | dprintk("%s: Invalid number of RPC auth flavours %d.\n", | ||
1239 | __FUNCTION__, data->auth_flavourlen); | ||
1240 | err = -EINVAL; | ||
1241 | goto out_fail; | ||
1242 | } | ||
1243 | if (copy_from_user(&authflavour, data->auth_flavours, sizeof(authflavour))) { | ||
1244 | err = -EFAULT; | ||
1245 | goto out_fail; | ||
1246 | } | ||
1247 | } | ||
1248 | |||
1249 | server->client = nfs4_create_client(server, &timeparms, data->proto, authflavour); | ||
1250 | if (IS_ERR(server->client)) { | ||
1251 | err = PTR_ERR(server->client); | ||
1252 | dprintk("%s: cannot create RPC client. Error = %d\n", | ||
1253 | __FUNCTION__, err); | ||
1254 | goto out_fail; | ||
1255 | } | ||
1256 | |||
1257 | sb->s_time_gran = 1; | ||
1258 | |||
1259 | sb->s_op = &nfs4_sops; | ||
1260 | err = nfs_sb_init(sb, authflavour); | ||
1261 | |||
1262 | out_fail: | ||
1263 | return err; | ||
1264 | } | ||
1265 | |||
1266 | static int nfs4_compare_super(struct super_block *sb, void *data) | ||
1267 | { | ||
1268 | struct nfs_server *server = data; | ||
1269 | struct nfs_server *old = NFS_SB(sb); | ||
1270 | |||
1271 | if (strcmp(server->hostname, old->hostname) != 0) | ||
1272 | return 0; | ||
1273 | if (strcmp(server->mnt_path, old->mnt_path) != 0) | ||
1274 | return 0; | ||
1275 | return 1; | ||
1276 | } | ||
1277 | |||
1278 | static void * | ||
1279 | nfs_copy_user_string(char *dst, struct nfs_string *src, int maxlen) | ||
1280 | { | ||
1281 | void *p = NULL; | ||
1282 | |||
1283 | if (!src->len) | ||
1284 | return ERR_PTR(-EINVAL); | ||
1285 | if (src->len < maxlen) | ||
1286 | maxlen = src->len; | ||
1287 | if (dst == NULL) { | ||
1288 | p = dst = kmalloc(maxlen + 1, GFP_KERNEL); | ||
1289 | if (p == NULL) | ||
1290 | return ERR_PTR(-ENOMEM); | ||
1291 | } | ||
1292 | if (copy_from_user(dst, src->data, maxlen)) { | ||
1293 | kfree(p); | ||
1294 | return ERR_PTR(-EFAULT); | ||
1295 | } | ||
1296 | dst[maxlen] = '\0'; | ||
1297 | return dst; | ||
1298 | } | ||
1299 | |||
1300 | static int nfs4_get_sb(struct file_system_type *fs_type, | ||
1301 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
1302 | { | ||
1303 | int error; | ||
1304 | struct nfs_server *server; | ||
1305 | struct super_block *s; | ||
1306 | struct nfs4_mount_data *data = raw_data; | ||
1307 | void *p; | ||
1308 | |||
1309 | if (data == NULL) { | ||
1310 | dprintk("%s: missing data argument\n", __FUNCTION__); | ||
1311 | return -EINVAL; | ||
1312 | } | ||
1313 | if (data->version <= 0 || data->version > NFS4_MOUNT_VERSION) { | ||
1314 | dprintk("%s: bad mount version\n", __FUNCTION__); | ||
1315 | return -EINVAL; | ||
1316 | } | ||
1317 | |||
1318 | server = kzalloc(sizeof(struct nfs_server), GFP_KERNEL); | ||
1319 | if (!server) | ||
1320 | return -ENOMEM; | ||
1321 | /* Zero out the NFS state stuff */ | ||
1322 | init_nfsv4_state(server); | ||
1323 | server->client = server->client_sys = server->client_acl = ERR_PTR(-EINVAL); | ||
1324 | |||
1325 | p = nfs_copy_user_string(NULL, &data->hostname, 256); | ||
1326 | if (IS_ERR(p)) | ||
1327 | goto out_err; | ||
1328 | server->hostname = p; | ||
1329 | |||
1330 | p = nfs_copy_user_string(NULL, &data->mnt_path, 1024); | ||
1331 | if (IS_ERR(p)) | ||
1332 | goto out_err; | ||
1333 | server->mnt_path = p; | ||
1334 | |||
1335 | p = nfs_copy_user_string(server->ip_addr, &data->client_addr, | ||
1336 | sizeof(server->ip_addr) - 1); | ||
1337 | if (IS_ERR(p)) | ||
1338 | goto out_err; | ||
1339 | |||
1340 | /* We now require that the mount process passes the remote address */ | ||
1341 | if (data->host_addrlen != sizeof(server->addr)) { | ||
1342 | error = -EINVAL; | ||
1343 | goto out_free; | ||
1344 | } | ||
1345 | if (copy_from_user(&server->addr, data->host_addr, sizeof(server->addr))) { | ||
1346 | error = -EFAULT; | ||
1347 | goto out_free; | ||
1348 | } | ||
1349 | if (server->addr.sin_family != AF_INET || | ||
1350 | server->addr.sin_addr.s_addr == INADDR_ANY) { | ||
1351 | dprintk("%s: mount program didn't pass remote IP address!\n", | ||
1352 | __FUNCTION__); | ||
1353 | error = -EINVAL; | ||
1354 | goto out_free; | ||
1355 | } | ||
1356 | |||
1357 | /* Fire up rpciod if not yet running */ | ||
1358 | error = rpciod_up(); | ||
1359 | if (error < 0) { | ||
1360 | dprintk("%s: couldn't start rpciod! Error = %d\n", | ||
1361 | __FUNCTION__, error); | ||
1362 | goto out_free; | ||
1363 | } | ||
1364 | |||
1365 | s = sget(fs_type, nfs4_compare_super, nfs_set_super, server); | ||
1366 | |||
1367 | if (IS_ERR(s)) { | ||
1368 | error = PTR_ERR(s); | ||
1369 | goto out_free; | ||
1370 | } | ||
1371 | |||
1372 | if (s->s_root) { | ||
1373 | kfree(server->mnt_path); | ||
1374 | kfree(server->hostname); | ||
1375 | kfree(server); | ||
1376 | return simple_set_mnt(mnt, s); | ||
1377 | } | ||
1378 | |||
1379 | s->s_flags = flags; | ||
1380 | |||
1381 | error = nfs4_fill_super(s, data, flags & MS_SILENT ? 1 : 0); | ||
1382 | if (error) { | ||
1383 | up_write(&s->s_umount); | ||
1384 | deactivate_super(s); | ||
1385 | return error; | ||
1386 | } | ||
1387 | s->s_flags |= MS_ACTIVE; | ||
1388 | return simple_set_mnt(mnt, s); | ||
1389 | out_err: | ||
1390 | error = PTR_ERR(p); | ||
1391 | out_free: | ||
1392 | kfree(server->mnt_path); | ||
1393 | kfree(server->hostname); | ||
1394 | kfree(server); | ||
1395 | return error; | ||
1396 | } | ||
1397 | |||
1398 | static void nfs4_kill_super(struct super_block *sb) | ||
1399 | { | ||
1400 | struct nfs_server *server = NFS_SB(sb); | ||
1401 | |||
1402 | nfs_return_all_delegations(sb); | ||
1403 | kill_anon_super(sb); | ||
1404 | |||
1405 | nfs4_renewd_prepare_shutdown(server); | ||
1406 | |||
1407 | if (server->client != NULL && !IS_ERR(server->client)) | ||
1408 | rpc_shutdown_client(server->client); | ||
1409 | |||
1410 | destroy_nfsv4_state(server); | ||
1411 | |||
1412 | rpciod_down(); | ||
1413 | |||
1414 | nfs_free_iostats(server->io_stats); | ||
1415 | kfree(server->hostname); | ||
1416 | kfree(server); | ||
1417 | nfs_release_automount_timer(); | ||
1418 | } | ||
1419 | |||
1420 | /* | ||
1421 | * Constructs the SERVER-side path | ||
1422 | */ | ||
1423 | static inline char *nfs4_dup_path(const struct dentry *dentry) | ||
1424 | { | ||
1425 | char *page = (char *) __get_free_page(GFP_USER); | ||
1426 | char *path; | ||
1427 | |||
1428 | path = nfs4_path(dentry, page, PAGE_SIZE); | ||
1429 | if (!IS_ERR(path)) { | ||
1430 | int len = PAGE_SIZE + page - path; | ||
1431 | char *tmp = path; | ||
1432 | |||
1433 | path = kmalloc(len, GFP_KERNEL); | ||
1434 | if (path) | ||
1435 | memcpy(path, tmp, len); | ||
1436 | else | ||
1437 | path = ERR_PTR(-ENOMEM); | ||
1438 | } | ||
1439 | free_page((unsigned long)page); | ||
1440 | return path; | ||
1441 | } | ||
1442 | |||
1443 | static struct super_block *nfs4_clone_sb(struct nfs_server *server, struct nfs_clone_mount *data) | ||
1444 | { | ||
1445 | const struct dentry *dentry = data->dentry; | ||
1446 | struct nfs4_client *clp = server->nfs4_state; | ||
1447 | struct super_block *sb; | ||
1448 | |||
1449 | server->fsid = data->fattr->fsid; | ||
1450 | nfs_copy_fh(&server->fh, data->fh); | ||
1451 | server->mnt_path = nfs4_dup_path(dentry); | ||
1452 | if (IS_ERR(server->mnt_path)) { | ||
1453 | sb = (struct super_block *)server->mnt_path; | ||
1454 | goto err; | ||
1455 | } | ||
1456 | sb = sget(&nfs4_fs_type, nfs4_compare_super, nfs_set_super, server); | ||
1457 | if (IS_ERR(sb) || sb->s_root) | ||
1458 | goto free_path; | ||
1459 | nfs4_server_capabilities(server, &server->fh); | ||
1460 | |||
1461 | down_write(&clp->cl_sem); | ||
1462 | atomic_inc(&clp->cl_count); | ||
1463 | list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); | ||
1464 | up_write(&clp->cl_sem); | ||
1465 | return sb; | ||
1466 | free_path: | ||
1467 | kfree(server->mnt_path); | ||
1468 | err: | ||
1469 | server->mnt_path = NULL; | ||
1470 | return sb; | ||
1471 | } | ||
1472 | |||
1473 | static int nfs_clone_nfs4_sb(struct file_system_type *fs_type, | ||
1474 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
1475 | { | ||
1476 | struct nfs_clone_mount *data = raw_data; | ||
1477 | return nfs_clone_generic_sb(data, nfs4_clone_sb, nfs_clone_server, mnt); | ||
1478 | } | ||
1479 | |||
1480 | static struct super_block *nfs4_referral_sb(struct nfs_server *server, struct nfs_clone_mount *data) | ||
1481 | { | ||
1482 | struct super_block *sb = ERR_PTR(-ENOMEM); | ||
1483 | int len; | ||
1484 | |||
1485 | len = strlen(data->mnt_path) + 1; | ||
1486 | server->mnt_path = kmalloc(len, GFP_KERNEL); | ||
1487 | if (server->mnt_path == NULL) | ||
1488 | goto err; | ||
1489 | memcpy(server->mnt_path, data->mnt_path, len); | ||
1490 | memcpy(&server->addr, data->addr, sizeof(struct sockaddr_in)); | ||
1491 | |||
1492 | sb = sget(&nfs4_fs_type, nfs4_compare_super, nfs_set_super, server); | ||
1493 | if (IS_ERR(sb) || sb->s_root) | ||
1494 | goto free_path; | ||
1495 | return sb; | ||
1496 | free_path: | ||
1497 | kfree(server->mnt_path); | ||
1498 | err: | ||
1499 | server->mnt_path = NULL; | ||
1500 | return sb; | ||
1501 | } | ||
1502 | |||
1503 | static struct nfs_server *nfs4_referral_server(struct super_block *sb, struct nfs_clone_mount *data) | ||
1504 | { | ||
1505 | struct nfs_server *server = NFS_SB(sb); | ||
1506 | struct rpc_timeout timeparms; | ||
1507 | int proto, timeo, retrans; | ||
1508 | void *err; | ||
1509 | |||
1510 | proto = IPPROTO_TCP; | ||
1511 | /* Since we are following a referral and there may be alternatives, | ||
1512 | set the timeouts and retries to low values */ | ||
1513 | timeo = 2; | ||
1514 | retrans = 1; | ||
1515 | nfs_init_timeout_values(&timeparms, proto, timeo, retrans); | ||
1516 | |||
1517 | server->client = nfs4_create_client(server, &timeparms, proto, data->authflavor); | ||
1518 | if (IS_ERR((err = server->client))) | ||
1519 | goto out_err; | ||
1520 | |||
1521 | sb->s_time_gran = 1; | ||
1522 | sb->s_op = &nfs4_sops; | ||
1523 | err = ERR_PTR(nfs_sb_init(sb, data->authflavor)); | ||
1524 | if (!IS_ERR(err)) | ||
1525 | return server; | ||
1526 | out_err: | ||
1527 | return (struct nfs_server *)err; | ||
1528 | } | ||
1529 | |||
1530 | static int nfs_referral_nfs4_sb(struct file_system_type *fs_type, | ||
1531 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
1532 | { | ||
1533 | struct nfs_clone_mount *data = raw_data; | ||
1534 | return nfs_clone_generic_sb(data, nfs4_referral_sb, nfs4_referral_server, mnt); | ||
1535 | } | ||
1536 | |||
1537 | #endif | ||
diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c index 18dc95b0b646..600bbe630abd 100644 --- a/fs/nfs/symlink.c +++ b/fs/nfs/symlink.c | |||
@@ -52,7 +52,7 @@ static void *nfs_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
52 | { | 52 | { |
53 | struct inode *inode = dentry->d_inode; | 53 | struct inode *inode = dentry->d_inode; |
54 | struct page *page; | 54 | struct page *page; |
55 | void *err = ERR_PTR(nfs_revalidate_inode(NFS_SERVER(inode), inode)); | 55 | void *err = ERR_PTR(nfs_revalidate_mapping(inode, inode->i_mapping)); |
56 | if (err) | 56 | if (err) |
57 | goto read_failed; | 57 | goto read_failed; |
58 | page = read_cache_page(&inode->i_data, 0, | 58 | page = read_cache_page(&inode->i_data, 0, |
@@ -75,22 +75,13 @@ read_failed: | |||
75 | return NULL; | 75 | return NULL; |
76 | } | 76 | } |
77 | 77 | ||
78 | static void nfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) | ||
79 | { | ||
80 | if (cookie) { | ||
81 | struct page *page = cookie; | ||
82 | kunmap(page); | ||
83 | page_cache_release(page); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | /* | 78 | /* |
88 | * symlinks can't do much... | 79 | * symlinks can't do much... |
89 | */ | 80 | */ |
90 | struct inode_operations nfs_symlink_inode_operations = { | 81 | struct inode_operations nfs_symlink_inode_operations = { |
91 | .readlink = generic_readlink, | 82 | .readlink = generic_readlink, |
92 | .follow_link = nfs_follow_link, | 83 | .follow_link = nfs_follow_link, |
93 | .put_link = nfs_put_link, | 84 | .put_link = page_put_link, |
94 | .getattr = nfs_getattr, | 85 | .getattr = nfs_getattr, |
95 | .setattr = nfs_setattr, | 86 | .setattr = nfs_setattr, |
96 | }; | 87 | }; |
diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c index 4c486eb867ca..db61e51bb154 100644 --- a/fs/nfs/sysctl.c +++ b/fs/nfs/sysctl.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/nfs4.h> | 13 | #include <linux/nfs4.h> |
14 | #include <linux/nfs_idmap.h> | 14 | #include <linux/nfs_idmap.h> |
15 | #include <linux/nfs_fs.h> | ||
15 | 16 | ||
16 | #include "callback.h" | 17 | #include "callback.h" |
17 | 18 | ||
@@ -46,6 +47,15 @@ static ctl_table nfs_cb_sysctls[] = { | |||
46 | .strategy = &sysctl_jiffies, | 47 | .strategy = &sysctl_jiffies, |
47 | }, | 48 | }, |
48 | #endif | 49 | #endif |
50 | { | ||
51 | .ctl_name = CTL_UNNUMBERED, | ||
52 | .procname = "nfs_mountpoint_timeout", | ||
53 | .data = &nfs_mountpoint_expiry_timeout, | ||
54 | .maxlen = sizeof(nfs_mountpoint_expiry_timeout), | ||
55 | .mode = 0644, | ||
56 | .proc_handler = &proc_dointvec_jiffies, | ||
57 | .strategy = &sysctl_jiffies, | ||
58 | }, | ||
49 | { .ctl_name = 0 } | 59 | { .ctl_name = 0 } |
50 | }; | 60 | }; |
51 | 61 | ||
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 4cfada2cc09f..b383fdd3a15c 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -98,11 +98,10 @@ struct nfs_write_data *nfs_commit_alloc(unsigned int pagecount) | |||
98 | if (p) { | 98 | if (p) { |
99 | memset(p, 0, sizeof(*p)); | 99 | memset(p, 0, sizeof(*p)); |
100 | INIT_LIST_HEAD(&p->pages); | 100 | INIT_LIST_HEAD(&p->pages); |
101 | if (pagecount < NFS_PAGEVEC_SIZE) | 101 | if (pagecount <= ARRAY_SIZE(p->page_array)) |
102 | p->pagevec = &p->page_array[0]; | 102 | p->pagevec = p->page_array; |
103 | else { | 103 | else { |
104 | size_t size = ++pagecount * sizeof(struct page *); | 104 | p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_NOFS); |
105 | p->pagevec = kzalloc(size, GFP_NOFS); | ||
106 | if (!p->pagevec) { | 105 | if (!p->pagevec) { |
107 | mempool_free(p, nfs_commit_mempool); | 106 | mempool_free(p, nfs_commit_mempool); |
108 | p = NULL; | 107 | p = NULL; |
@@ -126,14 +125,11 @@ struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount) | |||
126 | if (p) { | 125 | if (p) { |
127 | memset(p, 0, sizeof(*p)); | 126 | memset(p, 0, sizeof(*p)); |
128 | INIT_LIST_HEAD(&p->pages); | 127 | INIT_LIST_HEAD(&p->pages); |
129 | if (pagecount < NFS_PAGEVEC_SIZE) | 128 | if (pagecount <= ARRAY_SIZE(p->page_array)) |
130 | p->pagevec = &p->page_array[0]; | 129 | p->pagevec = p->page_array; |
131 | else { | 130 | else { |
132 | size_t size = ++pagecount * sizeof(struct page *); | 131 | p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_NOFS); |
133 | p->pagevec = kmalloc(size, GFP_NOFS); | 132 | if (!p->pagevec) { |
134 | if (p->pagevec) { | ||
135 | memset(p->pagevec, 0, size); | ||
136 | } else { | ||
137 | mempool_free(p, nfs_wdata_mempool); | 133 | mempool_free(p, nfs_wdata_mempool); |
138 | p = NULL; | 134 | p = NULL; |
139 | } | 135 | } |
@@ -583,6 +579,17 @@ static int nfs_wait_on_requests(struct inode *inode, unsigned long idx_start, un | |||
583 | return ret; | 579 | return ret; |
584 | } | 580 | } |
585 | 581 | ||
582 | static void nfs_cancel_requests(struct list_head *head) | ||
583 | { | ||
584 | struct nfs_page *req; | ||
585 | while(!list_empty(head)) { | ||
586 | req = nfs_list_entry(head->next); | ||
587 | nfs_list_remove_request(req); | ||
588 | nfs_inode_remove_request(req); | ||
589 | nfs_clear_page_writeback(req); | ||
590 | } | ||
591 | } | ||
592 | |||
586 | /* | 593 | /* |
587 | * nfs_scan_dirty - Scan an inode for dirty requests | 594 | * nfs_scan_dirty - Scan an inode for dirty requests |
588 | * @inode: NFS inode to scan | 595 | * @inode: NFS inode to scan |
@@ -627,7 +634,7 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst, unsigned long idx_st | |||
627 | int res = 0; | 634 | int res = 0; |
628 | 635 | ||
629 | if (nfsi->ncommit != 0) { | 636 | if (nfsi->ncommit != 0) { |
630 | res = nfs_scan_list(&nfsi->commit, dst, idx_start, npages); | 637 | res = nfs_scan_list(nfsi, &nfsi->commit, dst, idx_start, npages); |
631 | nfsi->ncommit -= res; | 638 | nfsi->ncommit -= res; |
632 | if ((nfsi->ncommit == 0) != list_empty(&nfsi->commit)) | 639 | if ((nfsi->ncommit == 0) != list_empty(&nfsi->commit)) |
633 | printk(KERN_ERR "NFS: desynchronized value of nfs_i.ncommit.\n"); | 640 | printk(KERN_ERR "NFS: desynchronized value of nfs_i.ncommit.\n"); |
@@ -1495,15 +1502,25 @@ int nfs_sync_inode_wait(struct inode *inode, unsigned long idx_start, | |||
1495 | pages = nfs_scan_dirty(inode, &head, idx_start, npages); | 1502 | pages = nfs_scan_dirty(inode, &head, idx_start, npages); |
1496 | if (pages != 0) { | 1503 | if (pages != 0) { |
1497 | spin_unlock(&nfsi->req_lock); | 1504 | spin_unlock(&nfsi->req_lock); |
1498 | ret = nfs_flush_list(inode, &head, pages, how); | 1505 | if (how & FLUSH_INVALIDATE) |
1506 | nfs_cancel_requests(&head); | ||
1507 | else | ||
1508 | ret = nfs_flush_list(inode, &head, pages, how); | ||
1499 | spin_lock(&nfsi->req_lock); | 1509 | spin_lock(&nfsi->req_lock); |
1500 | continue; | 1510 | continue; |
1501 | } | 1511 | } |
1502 | if (nocommit) | 1512 | if (nocommit) |
1503 | break; | 1513 | break; |
1504 | pages = nfs_scan_commit(inode, &head, 0, 0); | 1514 | pages = nfs_scan_commit(inode, &head, idx_start, npages); |
1505 | if (pages == 0) | 1515 | if (pages == 0) |
1506 | break; | 1516 | break; |
1517 | if (how & FLUSH_INVALIDATE) { | ||
1518 | spin_unlock(&nfsi->req_lock); | ||
1519 | nfs_cancel_requests(&head); | ||
1520 | spin_lock(&nfsi->req_lock); | ||
1521 | continue; | ||
1522 | } | ||
1523 | pages += nfs_scan_commit(inode, &head, 0, 0); | ||
1507 | spin_unlock(&nfsi->req_lock); | 1524 | spin_unlock(&nfsi->req_lock); |
1508 | ret = nfs_commit_list(inode, &head, how); | 1525 | ret = nfs_commit_list(inode, &head, how); |
1509 | spin_lock(&nfsi->req_lock); | 1526 | spin_lock(&nfsi->req_lock); |
@@ -1512,7 +1529,7 @@ int nfs_sync_inode_wait(struct inode *inode, unsigned long idx_start, | |||
1512 | return ret; | 1529 | return ret; |
1513 | } | 1530 | } |
1514 | 1531 | ||
1515 | int nfs_init_writepagecache(void) | 1532 | int __init nfs_init_writepagecache(void) |
1516 | { | 1533 | { |
1517 | nfs_wdata_cachep = kmem_cache_create("nfs_write_data", | 1534 | nfs_wdata_cachep = kmem_cache_create("nfs_write_data", |
1518 | sizeof(struct nfs_write_data), | 1535 | sizeof(struct nfs_write_data), |
@@ -1534,7 +1551,7 @@ int nfs_init_writepagecache(void) | |||
1534 | return 0; | 1551 | return 0; |
1535 | } | 1552 | } |
1536 | 1553 | ||
1537 | void nfs_destroy_writepagecache(void) | 1554 | void __exit nfs_destroy_writepagecache(void) |
1538 | { | 1555 | { |
1539 | mempool_destroy(nfs_commit_mempool); | 1556 | mempool_destroy(nfs_commit_mempool); |
1540 | mempool_destroy(nfs_wdata_mempool); | 1557 | mempool_destroy(nfs_wdata_mempool); |
diff --git a/fs/super.c b/fs/super.c index 057b5325b7ef..8a669f6f3f52 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -871,8 +871,6 @@ do_kern_mount(const char *fstype, int flags, const char *name, void *data) | |||
871 | return mnt; | 871 | return mnt; |
872 | } | 872 | } |
873 | 873 | ||
874 | EXPORT_SYMBOL_GPL(do_kern_mount); | ||
875 | |||
876 | struct vfsmount *kern_mount(struct file_system_type *type) | 874 | struct vfsmount *kern_mount(struct file_system_type *type) |
877 | { | 875 | { |
878 | return vfs_kern_mount(type, 0, type->name, NULL); | 876 | return vfs_kern_mount(type, 0, type->name, NULL); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index dba4cbd157ee..2d8b348c1192 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1100,7 +1100,7 @@ struct super_operations { | |||
1100 | int (*statfs) (struct dentry *, struct kstatfs *); | 1100 | int (*statfs) (struct dentry *, struct kstatfs *); |
1101 | int (*remount_fs) (struct super_block *, int *, char *); | 1101 | int (*remount_fs) (struct super_block *, int *, char *); |
1102 | void (*clear_inode) (struct inode *); | 1102 | void (*clear_inode) (struct inode *); |
1103 | void (*umount_begin) (struct super_block *); | 1103 | void (*umount_begin) (struct vfsmount *, int); |
1104 | 1104 | ||
1105 | int (*show_options)(struct seq_file *, struct vfsmount *); | 1105 | int (*show_options)(struct seq_file *, struct vfsmount *); |
1106 | int (*show_stats)(struct seq_file *, struct vfsmount *); | 1106 | int (*show_stats)(struct seq_file *, struct vfsmount *); |
@@ -1767,7 +1767,7 @@ extern struct inode_operations simple_dir_inode_operations; | |||
1767 | struct tree_descr { char *name; const struct file_operations *ops; int mode; }; | 1767 | struct tree_descr { char *name; const struct file_operations *ops; int mode; }; |
1768 | struct dentry *d_alloc_name(struct dentry *, const char *); | 1768 | struct dentry *d_alloc_name(struct dentry *, const char *); |
1769 | extern int simple_fill_super(struct super_block *, int, struct tree_descr *); | 1769 | extern int simple_fill_super(struct super_block *, int, struct tree_descr *); |
1770 | extern int simple_pin_fs(char *name, struct vfsmount **mount, int *count); | 1770 | extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count); |
1771 | extern void simple_release_fs(struct vfsmount **mount, int *count); | 1771 | extern void simple_release_fs(struct vfsmount **mount, int *count); |
1772 | 1772 | ||
1773 | extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t); | 1773 | extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t); |
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index a8876bc6513b..aa4fe905bb4d 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h | |||
@@ -49,11 +49,12 @@ struct nlm_host { | |||
49 | h_killed : 1, | 49 | h_killed : 1, |
50 | h_monitored : 1; | 50 | h_monitored : 1; |
51 | wait_queue_head_t h_gracewait; /* wait while reclaiming */ | 51 | wait_queue_head_t h_gracewait; /* wait while reclaiming */ |
52 | struct rw_semaphore h_rwsem; /* Reboot recovery lock */ | ||
52 | u32 h_state; /* pseudo-state counter */ | 53 | u32 h_state; /* pseudo-state counter */ |
53 | u32 h_nsmstate; /* true remote NSM state */ | 54 | u32 h_nsmstate; /* true remote NSM state */ |
54 | u32 h_pidcount; /* Pseudopids */ | 55 | u32 h_pidcount; /* Pseudopids */ |
55 | atomic_t h_count; /* reference count */ | 56 | atomic_t h_count; /* reference count */ |
56 | struct semaphore h_sema; /* mutex for pmap binding */ | 57 | struct mutex h_mutex; /* mutex for pmap binding */ |
57 | unsigned long h_nextrebind; /* next portmap call */ | 58 | unsigned long h_nextrebind; /* next portmap call */ |
58 | unsigned long h_expires; /* eligible for GC */ | 59 | unsigned long h_expires; /* eligible for GC */ |
59 | struct list_head h_lockowners; /* Lockowners for the client */ | 60 | struct list_head h_lockowners; /* Lockowners for the client */ |
@@ -219,6 +220,7 @@ static __inline__ int | |||
219 | nlm_compare_locks(const struct file_lock *fl1, const struct file_lock *fl2) | 220 | nlm_compare_locks(const struct file_lock *fl1, const struct file_lock *fl2) |
220 | { | 221 | { |
221 | return fl1->fl_pid == fl2->fl_pid | 222 | return fl1->fl_pid == fl2->fl_pid |
223 | && fl1->fl_owner == fl2->fl_owner | ||
222 | && fl1->fl_start == fl2->fl_start | 224 | && fl1->fl_start == fl2->fl_start |
223 | && fl1->fl_end == fl2->fl_end | 225 | && fl1->fl_end == fl2->fl_end |
224 | &&(fl1->fl_type == fl2->fl_type || fl2->fl_type == F_UNLCK); | 226 | &&(fl1->fl_type == fl2->fl_type || fl2->fl_type == F_UNLCK); |
diff --git a/include/linux/mount.h b/include/linux/mount.h index 60718f12caa9..403d1a97c512 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h | |||
@@ -28,6 +28,8 @@ struct namespace; | |||
28 | #define MNT_NOATIME 0x08 | 28 | #define MNT_NOATIME 0x08 |
29 | #define MNT_NODIRATIME 0x10 | 29 | #define MNT_NODIRATIME 0x10 |
30 | 30 | ||
31 | #define MNT_SHRINKABLE 0x100 | ||
32 | |||
31 | #define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */ | 33 | #define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */ |
32 | #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */ | 34 | #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */ |
33 | #define MNT_PNODE_MASK 0x3000 /* propogation flag mask */ | 35 | #define MNT_PNODE_MASK 0x3000 /* propogation flag mask */ |
@@ -78,12 +80,18 @@ extern struct vfsmount *alloc_vfsmnt(const char *name); | |||
78 | extern struct vfsmount *do_kern_mount(const char *fstype, int flags, | 80 | extern struct vfsmount *do_kern_mount(const char *fstype, int flags, |
79 | const char *name, void *data); | 81 | const char *name, void *data); |
80 | 82 | ||
83 | struct file_system_type; | ||
84 | extern struct vfsmount *vfs_kern_mount(struct file_system_type *type, | ||
85 | int flags, const char *name, | ||
86 | void *data); | ||
87 | |||
81 | struct nameidata; | 88 | struct nameidata; |
82 | 89 | ||
83 | extern int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd, | 90 | extern int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd, |
84 | int mnt_flags, struct list_head *fslist); | 91 | int mnt_flags, struct list_head *fslist); |
85 | 92 | ||
86 | extern void mark_mounts_for_expiry(struct list_head *mounts); | 93 | extern void mark_mounts_for_expiry(struct list_head *mounts); |
94 | extern void shrink_submounts(struct vfsmount *mountpoint, struct list_head *mounts); | ||
87 | 95 | ||
88 | extern spinlock_t vfsmount_lock; | 96 | extern spinlock_t vfsmount_lock; |
89 | extern dev_t name_to_dev_t(char *name); | 97 | extern dev_t name_to_dev_t(char *name); |
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 1059e6d69d3b..5f681d534295 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h | |||
@@ -384,6 +384,7 @@ enum { | |||
384 | NFSPROC4_CLNT_DELEGRETURN, | 384 | NFSPROC4_CLNT_DELEGRETURN, |
385 | NFSPROC4_CLNT_GETACL, | 385 | NFSPROC4_CLNT_GETACL, |
386 | NFSPROC4_CLNT_SETACL, | 386 | NFSPROC4_CLNT_SETACL, |
387 | NFSPROC4_CLNT_FS_LOCATIONS, | ||
387 | }; | 388 | }; |
388 | 389 | ||
389 | #endif | 390 | #endif |
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 7e079f8ce18b..0a1740b2532e 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h | |||
@@ -9,6 +9,27 @@ | |||
9 | #ifndef _LINUX_NFS_FS_H | 9 | #ifndef _LINUX_NFS_FS_H |
10 | #define _LINUX_NFS_FS_H | 10 | #define _LINUX_NFS_FS_H |
11 | 11 | ||
12 | #include <linux/config.h> | ||
13 | #include <linux/in.h> | ||
14 | #include <linux/mm.h> | ||
15 | #include <linux/pagemap.h> | ||
16 | #include <linux/rwsem.h> | ||
17 | #include <linux/wait.h> | ||
18 | |||
19 | #include <linux/sunrpc/debug.h> | ||
20 | #include <linux/sunrpc/auth.h> | ||
21 | #include <linux/sunrpc/clnt.h> | ||
22 | |||
23 | #include <linux/nfs.h> | ||
24 | #include <linux/nfs2.h> | ||
25 | #include <linux/nfs3.h> | ||
26 | #include <linux/nfs4.h> | ||
27 | #include <linux/nfs_xdr.h> | ||
28 | |||
29 | #include <linux/nfs_fs_sb.h> | ||
30 | |||
31 | #include <linux/rwsem.h> | ||
32 | #include <linux/mempool.h> | ||
12 | 33 | ||
13 | /* | 34 | /* |
14 | * Enable debugging support for nfs client. | 35 | * Enable debugging support for nfs client. |
@@ -41,27 +62,9 @@ | |||
41 | #define FLUSH_LOWPRI 8 /* low priority background flush */ | 62 | #define FLUSH_LOWPRI 8 /* low priority background flush */ |
42 | #define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */ | 63 | #define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */ |
43 | #define FLUSH_NOCOMMIT 32 /* Don't send the NFSv3/v4 COMMIT */ | 64 | #define FLUSH_NOCOMMIT 32 /* Don't send the NFSv3/v4 COMMIT */ |
65 | #define FLUSH_INVALIDATE 64 /* Invalidate the page cache */ | ||
44 | 66 | ||
45 | #ifdef __KERNEL__ | 67 | #ifdef __KERNEL__ |
46 | #include <linux/in.h> | ||
47 | #include <linux/mm.h> | ||
48 | #include <linux/pagemap.h> | ||
49 | #include <linux/rwsem.h> | ||
50 | #include <linux/wait.h> | ||
51 | |||
52 | #include <linux/nfs_fs_sb.h> | ||
53 | |||
54 | #include <linux/sunrpc/debug.h> | ||
55 | #include <linux/sunrpc/auth.h> | ||
56 | #include <linux/sunrpc/clnt.h> | ||
57 | |||
58 | #include <linux/nfs.h> | ||
59 | #include <linux/nfs2.h> | ||
60 | #include <linux/nfs3.h> | ||
61 | #include <linux/nfs4.h> | ||
62 | #include <linux/nfs_xdr.h> | ||
63 | #include <linux/rwsem.h> | ||
64 | #include <linux/mempool.h> | ||
65 | 68 | ||
66 | /* | 69 | /* |
67 | * NFSv3/v4 Access mode cache entry | 70 | * NFSv3/v4 Access mode cache entry |
@@ -233,8 +236,12 @@ static inline int nfs_caches_unstable(struct inode *inode) | |||
233 | 236 | ||
234 | static inline void nfs_mark_for_revalidate(struct inode *inode) | 237 | static inline void nfs_mark_for_revalidate(struct inode *inode) |
235 | { | 238 | { |
239 | struct nfs_inode *nfsi = NFS_I(inode); | ||
240 | |||
236 | spin_lock(&inode->i_lock); | 241 | spin_lock(&inode->i_lock); |
237 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS; | 242 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS; |
243 | if (S_ISDIR(inode->i_mode)) | ||
244 | nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA; | ||
238 | spin_unlock(&inode->i_lock); | 245 | spin_unlock(&inode->i_lock); |
239 | } | 246 | } |
240 | 247 | ||
@@ -296,7 +303,7 @@ extern int nfs_release(struct inode *, struct file *); | |||
296 | extern int nfs_attribute_timeout(struct inode *inode); | 303 | extern int nfs_attribute_timeout(struct inode *inode); |
297 | extern int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode); | 304 | extern int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode); |
298 | extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *); | 305 | extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *); |
299 | extern void nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping); | 306 | extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping); |
300 | extern int nfs_setattr(struct dentry *, struct iattr *); | 307 | extern int nfs_setattr(struct dentry *, struct iattr *); |
301 | extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr); | 308 | extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr); |
302 | extern void nfs_begin_attr_update(struct inode *); | 309 | extern void nfs_begin_attr_update(struct inode *); |
@@ -306,6 +313,10 @@ extern void nfs_end_data_update(struct inode *); | |||
306 | extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx); | 313 | extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx); |
307 | extern void put_nfs_open_context(struct nfs_open_context *ctx); | 314 | extern void put_nfs_open_context(struct nfs_open_context *ctx); |
308 | extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode); | 315 | extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode); |
316 | extern struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent, | ||
317 | const struct dentry *dentry, | ||
318 | struct nfs_fh *fh, | ||
319 | struct nfs_fattr *fattr); | ||
309 | 320 | ||
310 | /* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */ | 321 | /* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */ |
311 | extern u32 root_nfs_parse_addr(char *name); /*__init*/ | 322 | extern u32 root_nfs_parse_addr(char *name); /*__init*/ |
@@ -392,6 +403,15 @@ extern void nfs_unregister_sysctl(void); | |||
392 | #endif | 403 | #endif |
393 | 404 | ||
394 | /* | 405 | /* |
406 | * linux/fs/nfs/namespace.c | ||
407 | */ | ||
408 | extern struct list_head nfs_automount_list; | ||
409 | extern struct inode_operations nfs_mountpoint_inode_operations; | ||
410 | extern struct inode_operations nfs_referral_inode_operations; | ||
411 | extern int nfs_mountpoint_expiry_timeout; | ||
412 | extern void nfs_release_automount_timer(void); | ||
413 | |||
414 | /* | ||
395 | * linux/fs/nfs/unlink.c | 415 | * linux/fs/nfs/unlink.c |
396 | */ | 416 | */ |
397 | extern int nfs_async_unlink(struct dentry *); | 417 | extern int nfs_async_unlink(struct dentry *); |
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 65dec21af774..6b4a13c79474 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h | |||
@@ -35,6 +35,7 @@ struct nfs_server { | |||
35 | char * hostname; /* remote hostname */ | 35 | char * hostname; /* remote hostname */ |
36 | struct nfs_fh fh; | 36 | struct nfs_fh fh; |
37 | struct sockaddr_in addr; | 37 | struct sockaddr_in addr; |
38 | struct nfs_fsid fsid; | ||
38 | unsigned long mount_time; /* when this fs was mounted */ | 39 | unsigned long mount_time; /* when this fs was mounted */ |
39 | #ifdef CONFIG_NFS_V4 | 40 | #ifdef CONFIG_NFS_V4 |
40 | /* Our own IP address, as a null-terminated string. | 41 | /* Our own IP address, as a null-terminated string. |
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h index 66e2ed658527..1f7bd287c230 100644 --- a/include/linux/nfs_page.h +++ b/include/linux/nfs_page.h | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/list.h> | 13 | #include <linux/list.h> |
14 | #include <linux/pagemap.h> | 14 | #include <linux/pagemap.h> |
15 | #include <linux/wait.h> | 15 | #include <linux/wait.h> |
16 | #include <linux/nfs_fs_sb.h> | ||
17 | #include <linux/sunrpc/auth.h> | 16 | #include <linux/sunrpc/auth.h> |
18 | #include <linux/nfs_xdr.h> | 17 | #include <linux/nfs_xdr.h> |
19 | 18 | ||
@@ -63,8 +62,8 @@ extern void nfs_release_request(struct nfs_page *req); | |||
63 | 62 | ||
64 | extern int nfs_scan_lock_dirty(struct nfs_inode *nfsi, struct list_head *dst, | 63 | extern int nfs_scan_lock_dirty(struct nfs_inode *nfsi, struct list_head *dst, |
65 | unsigned long idx_start, unsigned int npages); | 64 | unsigned long idx_start, unsigned int npages); |
66 | extern int nfs_scan_list(struct list_head *, struct list_head *, | 65 | extern int nfs_scan_list(struct nfs_inode *nfsi, struct list_head *head, struct list_head *dst, |
67 | unsigned long, unsigned int); | 66 | unsigned long idx_start, unsigned int npages); |
68 | extern int nfs_coalesce_requests(struct list_head *, struct list_head *, | 67 | extern int nfs_coalesce_requests(struct list_head *, struct list_head *, |
69 | unsigned int); | 68 | unsigned int); |
70 | extern int nfs_wait_on_request(struct nfs_page *); | 69 | extern int nfs_wait_on_request(struct nfs_page *); |
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 7fafc4c546b7..7c7320fa51aa 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -14,11 +14,19 @@ | |||
14 | #define NFS_DEF_FILE_IO_SIZE (4096U) | 14 | #define NFS_DEF_FILE_IO_SIZE (4096U) |
15 | #define NFS_MIN_FILE_IO_SIZE (1024U) | 15 | #define NFS_MIN_FILE_IO_SIZE (1024U) |
16 | 16 | ||
17 | struct nfs4_fsid { | 17 | struct nfs_fsid { |
18 | __u64 major; | 18 | uint64_t major; |
19 | __u64 minor; | 19 | uint64_t minor; |
20 | }; | 20 | }; |
21 | 21 | ||
22 | /* | ||
23 | * Helper for checking equality between 2 fsids. | ||
24 | */ | ||
25 | static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b) | ||
26 | { | ||
27 | return a->major == b->major && a->minor == b->minor; | ||
28 | } | ||
29 | |||
22 | struct nfs_fattr { | 30 | struct nfs_fattr { |
23 | unsigned short valid; /* which fields are valid */ | 31 | unsigned short valid; /* which fields are valid */ |
24 | __u64 pre_size; /* pre_op_attr.size */ | 32 | __u64 pre_size; /* pre_op_attr.size */ |
@@ -40,10 +48,7 @@ struct nfs_fattr { | |||
40 | } nfs3; | 48 | } nfs3; |
41 | } du; | 49 | } du; |
42 | dev_t rdev; | 50 | dev_t rdev; |
43 | union { | 51 | struct nfs_fsid fsid; |
44 | __u64 nfs3; /* also nfs2 */ | ||
45 | struct nfs4_fsid nfs4; | ||
46 | } fsid_u; | ||
47 | __u64 fileid; | 52 | __u64 fileid; |
48 | struct timespec atime; | 53 | struct timespec atime; |
49 | struct timespec mtime; | 54 | struct timespec mtime; |
@@ -57,8 +62,8 @@ struct nfs_fattr { | |||
57 | #define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */ | 62 | #define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */ |
58 | #define NFS_ATTR_FATTR 0x0002 /* post-op attributes */ | 63 | #define NFS_ATTR_FATTR 0x0002 /* post-op attributes */ |
59 | #define NFS_ATTR_FATTR_V3 0x0004 /* NFSv3 attributes */ | 64 | #define NFS_ATTR_FATTR_V3 0x0004 /* NFSv3 attributes */ |
60 | #define NFS_ATTR_FATTR_V4 0x0008 | 65 | #define NFS_ATTR_FATTR_V4 0x0008 /* NFSv4 change attribute */ |
61 | #define NFS_ATTR_PRE_CHANGE 0x0010 | 66 | #define NFS_ATTR_FATTR_V4_REFERRAL 0x0010 /* NFSv4 referral */ |
62 | 67 | ||
63 | /* | 68 | /* |
64 | * Info on the file system | 69 | * Info on the file system |
@@ -675,6 +680,40 @@ struct nfs4_server_caps_res { | |||
675 | u32 has_symlinks; | 680 | u32 has_symlinks; |
676 | }; | 681 | }; |
677 | 682 | ||
683 | struct nfs4_string { | ||
684 | unsigned int len; | ||
685 | char *data; | ||
686 | }; | ||
687 | |||
688 | #define NFS4_PATHNAME_MAXCOMPONENTS 512 | ||
689 | struct nfs4_pathname { | ||
690 | unsigned int ncomponents; | ||
691 | struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS]; | ||
692 | }; | ||
693 | |||
694 | #define NFS4_FS_LOCATION_MAXSERVERS 10 | ||
695 | struct nfs4_fs_location { | ||
696 | unsigned int nservers; | ||
697 | struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS]; | ||
698 | struct nfs4_pathname rootpath; | ||
699 | }; | ||
700 | |||
701 | #define NFS4_FS_LOCATIONS_MAXENTRIES 10 | ||
702 | struct nfs4_fs_locations { | ||
703 | struct nfs_fattr fattr; | ||
704 | const struct nfs_server *server; | ||
705 | struct nfs4_pathname fs_path; | ||
706 | int nlocations; | ||
707 | struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES]; | ||
708 | }; | ||
709 | |||
710 | struct nfs4_fs_locations_arg { | ||
711 | const struct nfs_fh *dir_fh; | ||
712 | const struct qstr *name; | ||
713 | struct page *page; | ||
714 | const u32 *bitmask; | ||
715 | }; | ||
716 | |||
678 | #endif /* CONFIG_NFS_V4 */ | 717 | #endif /* CONFIG_NFS_V4 */ |
679 | 718 | ||
680 | struct nfs_page; | 719 | struct nfs_page; |
@@ -695,7 +734,7 @@ struct nfs_read_data { | |||
695 | #ifdef CONFIG_NFS_V4 | 734 | #ifdef CONFIG_NFS_V4 |
696 | unsigned long timestamp; /* For lease renewal */ | 735 | unsigned long timestamp; /* For lease renewal */ |
697 | #endif | 736 | #endif |
698 | struct page *page_array[NFS_PAGEVEC_SIZE + 1]; | 737 | struct page *page_array[NFS_PAGEVEC_SIZE]; |
699 | }; | 738 | }; |
700 | 739 | ||
701 | struct nfs_write_data { | 740 | struct nfs_write_data { |
@@ -713,7 +752,7 @@ struct nfs_write_data { | |||
713 | #ifdef CONFIG_NFS_V4 | 752 | #ifdef CONFIG_NFS_V4 |
714 | unsigned long timestamp; /* For lease renewal */ | 753 | unsigned long timestamp; /* For lease renewal */ |
715 | #endif | 754 | #endif |
716 | struct page *page_array[NFS_PAGEVEC_SIZE + 1]; | 755 | struct page *page_array[NFS_PAGEVEC_SIZE]; |
717 | }; | 756 | }; |
718 | 757 | ||
719 | struct nfs_access_entry; | 758 | struct nfs_access_entry; |
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 84c35d42d250..e6d3d349506c 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h | |||
@@ -194,6 +194,7 @@ extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, | |||
194 | extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p); | 194 | extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p); |
195 | extern uint32_t *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes); | 195 | extern uint32_t *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes); |
196 | extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len); | 196 | extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len); |
197 | extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); | ||
197 | 198 | ||
198 | #endif /* __KERNEL__ */ | 199 | #endif /* __KERNEL__ */ |
199 | 200 | ||
diff --git a/mm/shmem.c b/mm/shmem.c index 84b5cf9b63c5..38bc3334f263 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -2255,7 +2255,7 @@ static int __init init_tmpfs(void) | |||
2255 | #ifdef CONFIG_TMPFS | 2255 | #ifdef CONFIG_TMPFS |
2256 | devfs_mk_dir("shm"); | 2256 | devfs_mk_dir("shm"); |
2257 | #endif | 2257 | #endif |
2258 | shm_mnt = do_kern_mount(tmpfs_fs_type.name, MS_NOUSER, | 2258 | shm_mnt = vfs_kern_mount(&tmpfs_fs_type, MS_NOUSER, |
2259 | tmpfs_fs_type.name, NULL); | 2259 | tmpfs_fs_type.name, NULL); |
2260 | if (IS_ERR(shm_mnt)) { | 2260 | if (IS_ERR(shm_mnt)) { |
2261 | error = PTR_ERR(shm_mnt); | 2261 | error = PTR_ERR(shm_mnt); |
diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c index f56767aaa927..2eccffa96ba1 100644 --- a/net/sunrpc/auth_null.c +++ b/net/sunrpc/auth_null.c | |||
@@ -118,6 +118,8 @@ struct rpc_auth null_auth = { | |||
118 | .au_cslack = 4, | 118 | .au_cslack = 4, |
119 | .au_rslack = 2, | 119 | .au_rslack = 2, |
120 | .au_ops = &authnull_ops, | 120 | .au_ops = &authnull_ops, |
121 | .au_flavor = RPC_AUTH_NULL, | ||
122 | .au_count = ATOMIC_INIT(0), | ||
121 | }; | 123 | }; |
122 | 124 | ||
123 | static | 125 | static |
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index df14b6bfbf10..74c7406a1054 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c | |||
@@ -225,6 +225,7 @@ struct rpc_auth unix_auth = { | |||
225 | .au_cslack = UNX_WRITESLACK, | 225 | .au_cslack = UNX_WRITESLACK, |
226 | .au_rslack = 2, /* assume AUTH_NULL verf */ | 226 | .au_rslack = 2, /* assume AUTH_NULL verf */ |
227 | .au_ops = &authunix_ops, | 227 | .au_ops = &authunix_ops, |
228 | .au_flavor = RPC_AUTH_UNIX, | ||
228 | .au_count = ATOMIC_INIT(0), | 229 | .au_count = ATOMIC_INIT(0), |
229 | .au_credcache = &unix_cred_cache, | 230 | .au_credcache = &unix_cred_cache, |
230 | }; | 231 | }; |
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 8241fa726803..dafe793c774e 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
@@ -439,7 +439,7 @@ struct vfsmount *rpc_get_mount(void) | |||
439 | { | 439 | { |
440 | int err; | 440 | int err; |
441 | 441 | ||
442 | err = simple_pin_fs("rpc_pipefs", &rpc_mount, &rpc_mount_count); | 442 | err = simple_pin_fs(&rpc_pipe_fs_type, &rpc_mount, &rpc_mount_count); |
443 | if (err != 0) | 443 | if (err != 0) |
444 | return ERR_PTR(err); | 444 | return ERR_PTR(err); |
445 | return rpc_mount; | 445 | return rpc_mount; |
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index ca4bfa57e116..49174f0d0a3e 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c | |||
@@ -568,8 +568,7 @@ EXPORT_SYMBOL(xdr_inline_decode); | |||
568 | * | 568 | * |
569 | * Moves data beyond the current pointer position from the XDR head[] buffer | 569 | * Moves data beyond the current pointer position from the XDR head[] buffer |
570 | * into the page list. Any data that lies beyond current position + "len" | 570 | * into the page list. Any data that lies beyond current position + "len" |
571 | * bytes is moved into the XDR tail[]. The current pointer is then | 571 | * bytes is moved into the XDR tail[]. |
572 | * repositioned at the beginning of the XDR tail. | ||
573 | */ | 572 | */ |
574 | void xdr_read_pages(struct xdr_stream *xdr, unsigned int len) | 573 | void xdr_read_pages(struct xdr_stream *xdr, unsigned int len) |
575 | { | 574 | { |
@@ -606,6 +605,31 @@ void xdr_read_pages(struct xdr_stream *xdr, unsigned int len) | |||
606 | } | 605 | } |
607 | EXPORT_SYMBOL(xdr_read_pages); | 606 | EXPORT_SYMBOL(xdr_read_pages); |
608 | 607 | ||
608 | /** | ||
609 | * xdr_enter_page - decode data from the XDR page | ||
610 | * @xdr: pointer to xdr_stream struct | ||
611 | * @len: number of bytes of page data | ||
612 | * | ||
613 | * Moves data beyond the current pointer position from the XDR head[] buffer | ||
614 | * into the page list. Any data that lies beyond current position + "len" | ||
615 | * bytes is moved into the XDR tail[]. The current pointer is then | ||
616 | * repositioned at the beginning of the first XDR page. | ||
617 | */ | ||
618 | void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) | ||
619 | { | ||
620 | char * kaddr = page_address(xdr->buf->pages[0]); | ||
621 | xdr_read_pages(xdr, len); | ||
622 | /* | ||
623 | * Position current pointer at beginning of tail, and | ||
624 | * set remaining message length. | ||
625 | */ | ||
626 | if (len > PAGE_CACHE_SIZE - xdr->buf->page_base) | ||
627 | len = PAGE_CACHE_SIZE - xdr->buf->page_base; | ||
628 | xdr->p = (uint32_t *)(kaddr + xdr->buf->page_base); | ||
629 | xdr->end = (uint32_t *)((char *)xdr->p + len); | ||
630 | } | ||
631 | EXPORT_SYMBOL(xdr_enter_page); | ||
632 | |||
609 | static struct kvec empty_iov = {.iov_base = NULL, .iov_len = 0}; | 633 | static struct kvec empty_iov = {.iov_base = NULL, .iov_len = 0}; |
610 | 634 | ||
611 | void | 635 | void |
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 4dd5b3cfe754..02060d0e7be8 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/types.h> | 41 | #include <linux/types.h> |
42 | #include <linux/interrupt.h> | 42 | #include <linux/interrupt.h> |
43 | #include <linux/workqueue.h> | 43 | #include <linux/workqueue.h> |
44 | #include <linux/random.h> | 44 | #include <linux/net.h> |
45 | 45 | ||
46 | #include <linux/sunrpc/clnt.h> | 46 | #include <linux/sunrpc/clnt.h> |
47 | #include <linux/sunrpc/metrics.h> | 47 | #include <linux/sunrpc/metrics.h> |
@@ -830,7 +830,7 @@ static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt) | |||
830 | 830 | ||
831 | static inline void xprt_init_xid(struct rpc_xprt *xprt) | 831 | static inline void xprt_init_xid(struct rpc_xprt *xprt) |
832 | { | 832 | { |
833 | get_random_bytes(&xprt->xid, sizeof(xprt->xid)); | 833 | xprt->xid = net_random(); |
834 | } | 834 | } |
835 | 835 | ||
836 | static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) | 836 | static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 4b4e7dfdff14..21006b109101 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -930,6 +930,13 @@ static void xs_udp_timer(struct rpc_task *task) | |||
930 | xprt_adjust_cwnd(task, -ETIMEDOUT); | 930 | xprt_adjust_cwnd(task, -ETIMEDOUT); |
931 | } | 931 | } |
932 | 932 | ||
933 | static unsigned short xs_get_random_port(void) | ||
934 | { | ||
935 | unsigned short range = xprt_max_resvport - xprt_min_resvport; | ||
936 | unsigned short rand = (unsigned short) net_random() % range; | ||
937 | return rand + xprt_min_resvport; | ||
938 | } | ||
939 | |||
933 | /** | 940 | /** |
934 | * xs_set_port - reset the port number in the remote endpoint address | 941 | * xs_set_port - reset the port number in the remote endpoint address |
935 | * @xprt: generic transport | 942 | * @xprt: generic transport |
@@ -1275,7 +1282,7 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to) | |||
1275 | memset(xprt->slot, 0, slot_table_size); | 1282 | memset(xprt->slot, 0, slot_table_size); |
1276 | 1283 | ||
1277 | xprt->prot = IPPROTO_UDP; | 1284 | xprt->prot = IPPROTO_UDP; |
1278 | xprt->port = xprt_max_resvport; | 1285 | xprt->port = xs_get_random_port(); |
1279 | xprt->tsh_size = 0; | 1286 | xprt->tsh_size = 0; |
1280 | xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0; | 1287 | xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0; |
1281 | /* XXX: header size can vary due to auth type, IPv6, etc. */ | 1288 | /* XXX: header size can vary due to auth type, IPv6, etc. */ |
@@ -1317,7 +1324,7 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to) | |||
1317 | memset(xprt->slot, 0, slot_table_size); | 1324 | memset(xprt->slot, 0, slot_table_size); |
1318 | 1325 | ||
1319 | xprt->prot = IPPROTO_TCP; | 1326 | xprt->prot = IPPROTO_TCP; |
1320 | xprt->port = xprt_max_resvport; | 1327 | xprt->port = xs_get_random_port(); |
1321 | xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); | 1328 | xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); |
1322 | xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0; | 1329 | xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0; |
1323 | xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; | 1330 | xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; |
diff --git a/security/inode.c b/security/inode.c index e6fc29ac8564..98a0df500dc6 100644 --- a/security/inode.c +++ b/security/inode.c | |||
@@ -224,7 +224,7 @@ struct dentry *securityfs_create_file(const char *name, mode_t mode, | |||
224 | 224 | ||
225 | pr_debug("securityfs: creating file '%s'\n",name); | 225 | pr_debug("securityfs: creating file '%s'\n",name); |
226 | 226 | ||
227 | error = simple_pin_fs("securityfs", &mount, &mount_count); | 227 | error = simple_pin_fs(&fs_type, &mount, &mount_count); |
228 | if (error) { | 228 | if (error) { |
229 | dentry = ERR_PTR(error); | 229 | dentry = ERR_PTR(error); |
230 | goto exit; | 230 | goto exit; |