aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/Kconfig11
-rw-r--r--fs/afs/mntpt.c8
-rw-r--r--fs/autofs/symlink.c5
-rw-r--r--fs/autofs4/symlink.c4
-rw-r--r--fs/befs/linuxvfs.c10
-rw-r--r--fs/bio.c235
-rw-r--r--fs/cifs/CHANGES6
-rw-r--r--fs/cifs/cifsfs.h4
-rw-r--r--fs/cifs/cifssmb.c3
-rw-r--r--fs/cifs/file.c2
-rw-r--r--fs/cifs/link.c6
-rw-r--r--fs/cifs/misc.c1
-rw-r--r--fs/dcache.c7
-rw-r--r--fs/devfs/base.c4
-rw-r--r--fs/ext2/symlink.c4
-rw-r--r--fs/ext3/symlink.c4
-rw-r--r--fs/freevxfs/vxfs_immed.c6
-rw-r--r--fs/hfs/bnode.c2
-rw-r--r--fs/hfs/extent.c3
-rw-r--r--fs/hfsplus/bnode.c2
-rw-r--r--fs/hfsplus/extents.c4
-rw-r--r--fs/hppfs/hppfs_kern.c30
-rw-r--r--fs/inotify.c5
-rw-r--r--fs/ioprio.c2
-rw-r--r--fs/isofs/compress.c6
-rw-r--r--fs/jffs2/symlink.c16
-rw-r--r--fs/jfs/inode.c4
-rw-r--r--fs/jfs/jfs_logmgr.c36
-rw-r--r--fs/jfs/jfs_logmgr.h2
-rw-r--r--fs/jfs/jfs_txnmgr.c12
-rw-r--r--fs/jfs/super.c4
-rw-r--r--fs/jfs/symlink.c4
-rw-r--r--fs/namei.c45
-rw-r--r--fs/namespace.c2
-rw-r--r--fs/nfs/dir.c28
-rw-r--r--fs/nfs/file.c5
-rw-r--r--fs/nfs/inode.c197
-rw-r--r--fs/nfs/nfs3acl.c4
-rw-r--r--fs/nfs/nfs3proc.c4
-rw-r--r--fs/nfs/nfs4proc.c10
-rw-r--r--fs/nfs/proc.c2
-rw-r--r--fs/nfs/read.c8
-rw-r--r--fs/nfs/symlink.c37
-rw-r--r--fs/nfs_common/nfsacl.c1
-rw-r--r--fs/nfsd/nfssvc.c1
-rw-r--r--fs/ntfs/ChangeLog3
-rw-r--r--fs/ntfs/aops.c1
-rw-r--r--fs/ntfs/mft.c2
-rw-r--r--fs/proc/base.c8
-rw-r--r--fs/proc/generic.c4
-rw-r--r--fs/reiserfs/inode.c2
-rw-r--r--fs/reiserfs/namei.c3
-rw-r--r--fs/smbfs/symlink.c6
-rw-r--r--fs/sysfs/inode.c4
-rw-r--r--fs/sysfs/symlink.c6
-rw-r--r--fs/sysv/symlink.c4
-rw-r--r--fs/ufs/symlink.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c10
58 files changed, 557 insertions, 296 deletions
diff --git a/fs/Kconfig b/fs/Kconfig
index 5d0c4be43dba..e54be7058359 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -363,12 +363,15 @@ config INOTIFY
363 bool "Inotify file change notification support" 363 bool "Inotify file change notification support"
364 default y 364 default y
365 ---help--- 365 ---help---
366 Say Y here to enable inotify support and the /dev/inotify character 366 Say Y here to enable inotify support and the associated system
367 device. Inotify is a file change notification system and a 367 calls. Inotify is a file change notification system and a
368 replacement for dnotify. Inotify fixes numerous shortcomings in 368 replacement for dnotify. Inotify fixes numerous shortcomings in
369 dnotify and introduces several new features. It allows monitoring 369 dnotify and introduces several new features. It allows monitoring
370 of both files and directories via a single open fd. Multiple file 370 of both files and directories via a single open fd. Other features
371 events are supported. 371 include multiple file events, one-shot support, and unmount
372 notification.
373
374 For more information, see Documentation/filesystems/inotify.txt
372 375
373 If unsure, say Y. 376 If unsure, say Y.
374 377
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index bfc28abe1cb1..31ee06590de5 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -30,7 +30,7 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir,
30 struct dentry *dentry, 30 struct dentry *dentry,
31 struct nameidata *nd); 31 struct nameidata *nd);
32static int afs_mntpt_open(struct inode *inode, struct file *file); 32static int afs_mntpt_open(struct inode *inode, struct file *file);
33static int afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd); 33static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd);
34 34
35struct file_operations afs_mntpt_file_operations = { 35struct file_operations afs_mntpt_file_operations = {
36 .open = afs_mntpt_open, 36 .open = afs_mntpt_open,
@@ -233,7 +233,7 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
233/* 233/*
234 * follow a link from a mountpoint directory, thus causing it to be mounted 234 * follow a link from a mountpoint directory, thus causing it to be mounted
235 */ 235 */
236static int afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd) 236static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
237{ 237{
238 struct vfsmount *newmnt; 238 struct vfsmount *newmnt;
239 struct dentry *old_dentry; 239 struct dentry *old_dentry;
@@ -249,7 +249,7 @@ static int afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
249 newmnt = afs_mntpt_do_automount(dentry); 249 newmnt = afs_mntpt_do_automount(dentry);
250 if (IS_ERR(newmnt)) { 250 if (IS_ERR(newmnt)) {
251 path_release(nd); 251 path_release(nd);
252 return PTR_ERR(newmnt); 252 return (void *)newmnt;
253 } 253 }
254 254
255 old_dentry = nd->dentry; 255 old_dentry = nd->dentry;
@@ -267,7 +267,7 @@ static int afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
267 } 267 }
268 268
269 kleave(" = %d", err); 269 kleave(" = %d", err);
270 return err; 270 return ERR_PTR(err);
271} /* end afs_mntpt_follow_link() */ 271} /* end afs_mntpt_follow_link() */
272 272
273/*****************************************************************************/ 273/*****************************************************************************/
diff --git a/fs/autofs/symlink.c b/fs/autofs/symlink.c
index f028396f1383..52e8772b066e 100644
--- a/fs/autofs/symlink.c
+++ b/fs/autofs/symlink.c
@@ -12,11 +12,12 @@
12 12
13#include "autofs_i.h" 13#include "autofs_i.h"
14 14
15static int autofs_follow_link(struct dentry *dentry, struct nameidata *nd) 15/* Nothing to release.. */
16static void *autofs_follow_link(struct dentry *dentry, struct nameidata *nd)
16{ 17{
17 char *s=((struct autofs_symlink *)dentry->d_inode->u.generic_ip)->data; 18 char *s=((struct autofs_symlink *)dentry->d_inode->u.generic_ip)->data;
18 nd_set_link(nd, s); 19 nd_set_link(nd, s);
19 return 0; 20 return NULL;
20} 21}
21 22
22struct inode_operations autofs_symlink_inode_operations = { 23struct inode_operations autofs_symlink_inode_operations = {
diff --git a/fs/autofs4/symlink.c b/fs/autofs4/symlink.c
index c265a66edf0f..2ea2c98fd84b 100644
--- a/fs/autofs4/symlink.c
+++ b/fs/autofs4/symlink.c
@@ -12,11 +12,11 @@
12 12
13#include "autofs_i.h" 13#include "autofs_i.h"
14 14
15static int autofs4_follow_link(struct dentry *dentry, struct nameidata *nd) 15static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
16{ 16{
17 struct autofs_info *ino = autofs4_dentry_ino(dentry); 17 struct autofs_info *ino = autofs4_dentry_ino(dentry);
18 nd_set_link(nd, (char *)ino->u.symlink); 18 nd_set_link(nd, (char *)ino->u.symlink);
19 return 0; 19 return NULL;
20} 20}
21 21
22struct inode_operations autofs4_symlink_inode_operations = { 22struct inode_operations autofs4_symlink_inode_operations = {
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index de5bb280a828..e0a6025f1d06 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -41,8 +41,8 @@ static struct inode *befs_alloc_inode(struct super_block *sb);
41static void befs_destroy_inode(struct inode *inode); 41static void befs_destroy_inode(struct inode *inode);
42static int befs_init_inodecache(void); 42static int befs_init_inodecache(void);
43static void befs_destroy_inodecache(void); 43static void befs_destroy_inodecache(void);
44static int befs_follow_link(struct dentry *, struct nameidata *); 44static void *befs_follow_link(struct dentry *, struct nameidata *);
45static void befs_put_link(struct dentry *, struct nameidata *); 45static void befs_put_link(struct dentry *, struct nameidata *, void *);
46static int befs_utf2nls(struct super_block *sb, const char *in, int in_len, 46static int befs_utf2nls(struct super_block *sb, const char *in, int in_len,
47 char **out, int *out_len); 47 char **out, int *out_len);
48static int befs_nls2utf(struct super_block *sb, const char *in, int in_len, 48static int befs_nls2utf(struct super_block *sb, const char *in, int in_len,
@@ -461,7 +461,7 @@ befs_destroy_inodecache(void)
461 * The data stream become link name. Unless the LONG_SYMLINK 461 * The data stream become link name. Unless the LONG_SYMLINK
462 * flag is set. 462 * flag is set.
463 */ 463 */
464static int 464static void *
465befs_follow_link(struct dentry *dentry, struct nameidata *nd) 465befs_follow_link(struct dentry *dentry, struct nameidata *nd)
466{ 466{
467 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode); 467 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
@@ -487,10 +487,10 @@ befs_follow_link(struct dentry *dentry, struct nameidata *nd)
487 } 487 }
488 488
489 nd_set_link(nd, link); 489 nd_set_link(nd, link);
490 return 0; 490 return NULL;
491} 491}
492 492
493static void befs_put_link(struct dentry *dentry, struct nameidata *nd) 493static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
494{ 494{
495 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode); 495 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
496 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) { 496 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
diff --git a/fs/bio.c b/fs/bio.c
index 249dd6bb66c8..e49cf7dd2e92 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -25,6 +25,7 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/mempool.h> 26#include <linux/mempool.h>
27#include <linux/workqueue.h> 27#include <linux/workqueue.h>
28#include <scsi/sg.h> /* for struct sg_iovec */
28 29
29#define BIO_POOL_SIZE 256 30#define BIO_POOL_SIZE 256
30 31
@@ -248,17 +249,13 @@ inline void __bio_clone(struct bio *bio, struct bio *bio_src)
248{ 249{
249 request_queue_t *q = bdev_get_queue(bio_src->bi_bdev); 250 request_queue_t *q = bdev_get_queue(bio_src->bi_bdev);
250 251
251 memcpy(bio->bi_io_vec, bio_src->bi_io_vec, bio_src->bi_max_vecs * sizeof(struct bio_vec)); 252 memcpy(bio->bi_io_vec, bio_src->bi_io_vec,
253 bio_src->bi_max_vecs * sizeof(struct bio_vec));
252 254
253 bio->bi_sector = bio_src->bi_sector; 255 bio->bi_sector = bio_src->bi_sector;
254 bio->bi_bdev = bio_src->bi_bdev; 256 bio->bi_bdev = bio_src->bi_bdev;
255 bio->bi_flags |= 1 << BIO_CLONED; 257 bio->bi_flags |= 1 << BIO_CLONED;
256 bio->bi_rw = bio_src->bi_rw; 258 bio->bi_rw = bio_src->bi_rw;
257
258 /*
259 * notes -- maybe just leave bi_idx alone. assume identical mapping
260 * for the clone
261 */
262 bio->bi_vcnt = bio_src->bi_vcnt; 259 bio->bi_vcnt = bio_src->bi_vcnt;
263 bio->bi_size = bio_src->bi_size; 260 bio->bi_size = bio_src->bi_size;
264 bio->bi_idx = bio_src->bi_idx; 261 bio->bi_idx = bio_src->bi_idx;
@@ -550,22 +547,34 @@ out_bmd:
550 return ERR_PTR(ret); 547 return ERR_PTR(ret);
551} 548}
552 549
553static struct bio *__bio_map_user(request_queue_t *q, struct block_device *bdev, 550static struct bio *__bio_map_user_iov(request_queue_t *q,
554 unsigned long uaddr, unsigned int len, 551 struct block_device *bdev,
555 int write_to_vm) 552 struct sg_iovec *iov, int iov_count,
553 int write_to_vm)
556{ 554{
557 unsigned long end = (uaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; 555 int i, j;
558 unsigned long start = uaddr >> PAGE_SHIFT; 556 int nr_pages = 0;
559 const int nr_pages = end - start;
560 int ret, offset, i;
561 struct page **pages; 557 struct page **pages;
562 struct bio *bio; 558 struct bio *bio;
559 int cur_page = 0;
560 int ret, offset;
563 561
564 /* 562 for (i = 0; i < iov_count; i++) {
565 * transfer and buffer must be aligned to at least hardsector 563 unsigned long uaddr = (unsigned long)iov[i].iov_base;
566 * size for now, in the future we can relax this restriction 564 unsigned long len = iov[i].iov_len;
567 */ 565 unsigned long end = (uaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
568 if ((uaddr & queue_dma_alignment(q)) || (len & queue_dma_alignment(q))) 566 unsigned long start = uaddr >> PAGE_SHIFT;
567
568 nr_pages += end - start;
569 /*
570 * transfer and buffer must be aligned to at least hardsector
571 * size for now, in the future we can relax this restriction
572 */
573 if ((uaddr & queue_dma_alignment(q)) || (len & queue_dma_alignment(q)))
574 return ERR_PTR(-EINVAL);
575 }
576
577 if (!nr_pages)
569 return ERR_PTR(-EINVAL); 578 return ERR_PTR(-EINVAL);
570 579
571 bio = bio_alloc(GFP_KERNEL, nr_pages); 580 bio = bio_alloc(GFP_KERNEL, nr_pages);
@@ -577,42 +586,54 @@ static struct bio *__bio_map_user(request_queue_t *q, struct block_device *bdev,
577 if (!pages) 586 if (!pages)
578 goto out; 587 goto out;
579 588
580 down_read(&current->mm->mmap_sem); 589 memset(pages, 0, nr_pages * sizeof(struct page *));
581 ret = get_user_pages(current, current->mm, uaddr, nr_pages, 590
582 write_to_vm, 0, pages, NULL); 591 for (i = 0; i < iov_count; i++) {
583 up_read(&current->mm->mmap_sem); 592 unsigned long uaddr = (unsigned long)iov[i].iov_base;
584 593 unsigned long len = iov[i].iov_len;
585 if (ret < nr_pages) 594 unsigned long end = (uaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
586 goto out; 595 unsigned long start = uaddr >> PAGE_SHIFT;
587 596 const int local_nr_pages = end - start;
588 bio->bi_bdev = bdev; 597 const int page_limit = cur_page + local_nr_pages;
589 598
590 offset = uaddr & ~PAGE_MASK; 599 down_read(&current->mm->mmap_sem);
591 for (i = 0; i < nr_pages; i++) { 600 ret = get_user_pages(current, current->mm, uaddr,
592 unsigned int bytes = PAGE_SIZE - offset; 601 local_nr_pages,
593 602 write_to_vm, 0, &pages[cur_page], NULL);
594 if (len <= 0) 603 up_read(&current->mm->mmap_sem);
595 break; 604
596 605 if (ret < local_nr_pages)
597 if (bytes > len) 606 goto out_unmap;
598 bytes = len; 607
608
609 offset = uaddr & ~PAGE_MASK;
610 for (j = cur_page; j < page_limit; j++) {
611 unsigned int bytes = PAGE_SIZE - offset;
612
613 if (len <= 0)
614 break;
615
616 if (bytes > len)
617 bytes = len;
618
619 /*
620 * sorry...
621 */
622 if (__bio_add_page(q, bio, pages[j], bytes, offset) < bytes)
623 break;
624
625 len -= bytes;
626 offset = 0;
627 }
599 628
629 cur_page = j;
600 /* 630 /*
601 * sorry... 631 * release the pages we didn't map into the bio, if any
602 */ 632 */
603 if (__bio_add_page(q, bio, pages[i], bytes, offset) < bytes) 633 while (j < page_limit)
604 break; 634 page_cache_release(pages[j++]);
605
606 len -= bytes;
607 offset = 0;
608 } 635 }
609 636
610 /*
611 * release the pages we didn't map into the bio, if any
612 */
613 while (i < nr_pages)
614 page_cache_release(pages[i++]);
615
616 kfree(pages); 637 kfree(pages);
617 638
618 /* 639 /*
@@ -621,9 +642,17 @@ static struct bio *__bio_map_user(request_queue_t *q, struct block_device *bdev,
621 if (!write_to_vm) 642 if (!write_to_vm)
622 bio->bi_rw |= (1 << BIO_RW); 643 bio->bi_rw |= (1 << BIO_RW);
623 644
645 bio->bi_bdev = bdev;
624 bio->bi_flags |= (1 << BIO_USER_MAPPED); 646 bio->bi_flags |= (1 << BIO_USER_MAPPED);
625 return bio; 647 return bio;
626out: 648
649 out_unmap:
650 for (i = 0; i < nr_pages; i++) {
651 if(!pages[i])
652 break;
653 page_cache_release(pages[i]);
654 }
655 out:
627 kfree(pages); 656 kfree(pages);
628 bio_put(bio); 657 bio_put(bio);
629 return ERR_PTR(ret); 658 return ERR_PTR(ret);
@@ -643,9 +672,33 @@ out:
643struct bio *bio_map_user(request_queue_t *q, struct block_device *bdev, 672struct bio *bio_map_user(request_queue_t *q, struct block_device *bdev,
644 unsigned long uaddr, unsigned int len, int write_to_vm) 673 unsigned long uaddr, unsigned int len, int write_to_vm)
645{ 674{
675 struct sg_iovec iov;
676
677 iov.iov_base = (__user void *)uaddr;
678 iov.iov_len = len;
679
680 return bio_map_user_iov(q, bdev, &iov, 1, write_to_vm);
681}
682
683/**
684 * bio_map_user_iov - map user sg_iovec table into bio
685 * @q: the request_queue_t for the bio
686 * @bdev: destination block device
687 * @iov: the iovec.
688 * @iov_count: number of elements in the iovec
689 * @write_to_vm: bool indicating writing to pages or not
690 *
691 * Map the user space address into a bio suitable for io to a block
692 * device. Returns an error pointer in case of error.
693 */
694struct bio *bio_map_user_iov(request_queue_t *q, struct block_device *bdev,
695 struct sg_iovec *iov, int iov_count,
696 int write_to_vm)
697{
646 struct bio *bio; 698 struct bio *bio;
699 int len = 0, i;
647 700
648 bio = __bio_map_user(q, bdev, uaddr, len, write_to_vm); 701 bio = __bio_map_user_iov(q, bdev, iov, iov_count, write_to_vm);
649 702
650 if (IS_ERR(bio)) 703 if (IS_ERR(bio))
651 return bio; 704 return bio;
@@ -658,6 +711,9 @@ struct bio *bio_map_user(request_queue_t *q, struct block_device *bdev,
658 */ 711 */
659 bio_get(bio); 712 bio_get(bio);
660 713
714 for (i = 0; i < iov_count; i++)
715 len += iov[i].iov_len;
716
661 if (bio->bi_size == len) 717 if (bio->bi_size == len)
662 return bio; 718 return bio;
663 719
@@ -702,6 +758,82 @@ void bio_unmap_user(struct bio *bio)
702 bio_put(bio); 758 bio_put(bio);
703} 759}
704 760
761static int bio_map_kern_endio(struct bio *bio, unsigned int bytes_done, int err)
762{
763 if (bio->bi_size)
764 return 1;
765
766 bio_put(bio);
767 return 0;
768}
769
770
771static struct bio *__bio_map_kern(request_queue_t *q, void *data,
772 unsigned int len, unsigned int gfp_mask)
773{
774 unsigned long kaddr = (unsigned long)data;
775 unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
776 unsigned long start = kaddr >> PAGE_SHIFT;
777 const int nr_pages = end - start;
778 int offset, i;
779 struct bio *bio;
780
781 bio = bio_alloc(gfp_mask, nr_pages);
782 if (!bio)
783 return ERR_PTR(-ENOMEM);
784
785 offset = offset_in_page(kaddr);
786 for (i = 0; i < nr_pages; i++) {
787 unsigned int bytes = PAGE_SIZE - offset;
788
789 if (len <= 0)
790 break;
791
792 if (bytes > len)
793 bytes = len;
794
795 if (__bio_add_page(q, bio, virt_to_page(data), bytes,
796 offset) < bytes)
797 break;
798
799 data += bytes;
800 len -= bytes;
801 offset = 0;
802 }
803
804 bio->bi_end_io = bio_map_kern_endio;
805 return bio;
806}
807
808/**
809 * bio_map_kern - map kernel address into bio
810 * @q: the request_queue_t for the bio
811 * @data: pointer to buffer to map
812 * @len: length in bytes
813 * @gfp_mask: allocation flags for bio allocation
814 *
815 * Map the kernel address into a bio suitable for io to a block
816 * device. Returns an error pointer in case of error.
817 */
818struct bio *bio_map_kern(request_queue_t *q, void *data, unsigned int len,
819 unsigned int gfp_mask)
820{
821 struct bio *bio;
822
823 bio = __bio_map_kern(q, data, len, gfp_mask);
824 if (IS_ERR(bio))
825 return bio;
826
827 if (bio->bi_size == len)
828 return bio;
829
830 /*
831 * Don't support partial mappings.
832 */
833 bio_put(bio);
834 return ERR_PTR(-EINVAL);
835}
836
705/* 837/*
706 * bio_set_pages_dirty() and bio_check_pages_dirty() are support functions 838 * bio_set_pages_dirty() and bio_check_pages_dirty() are support functions
707 * for performing direct-IO in BIOs. 839 * for performing direct-IO in BIOs.
@@ -1089,6 +1221,7 @@ EXPORT_SYMBOL(bio_add_page);
1089EXPORT_SYMBOL(bio_get_nr_vecs); 1221EXPORT_SYMBOL(bio_get_nr_vecs);
1090EXPORT_SYMBOL(bio_map_user); 1222EXPORT_SYMBOL(bio_map_user);
1091EXPORT_SYMBOL(bio_unmap_user); 1223EXPORT_SYMBOL(bio_unmap_user);
1224EXPORT_SYMBOL(bio_map_kern);
1092EXPORT_SYMBOL(bio_pair_release); 1225EXPORT_SYMBOL(bio_pair_release);
1093EXPORT_SYMBOL(bio_split); 1226EXPORT_SYMBOL(bio_split);
1094EXPORT_SYMBOL(bio_split_pool); 1227EXPORT_SYMBOL(bio_split_pool);
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index dab4774ee7bb..3196d4c4eed3 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,3 +1,9 @@
1Version 1.35
2------------
3Add writepage performance improvements. Fix path name conversions
4for long filenames on mounts which were done with "mapchars" mount option
5specified.
6
1Version 1.34 7Version 1.34
2------------ 8------------
3Fix error mapping of the TOO_MANY_LINKS (hardlinks) case. 9Fix error mapping of the TOO_MANY_LINKS (hardlinks) case.
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 78af5850c558..1fd21f66f243 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -83,8 +83,8 @@ extern int cifs_dir_notify(struct file *, unsigned long arg);
83extern struct dentry_operations cifs_dentry_ops; 83extern struct dentry_operations cifs_dentry_ops;
84 84
85/* Functions related to symlinks */ 85/* Functions related to symlinks */
86extern int cifs_follow_link(struct dentry *direntry, struct nameidata *nd); 86extern void *cifs_follow_link(struct dentry *direntry, struct nameidata *nd);
87extern void cifs_put_link(struct dentry *direntry, struct nameidata *nd); 87extern void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *);
88extern int cifs_readlink(struct dentry *direntry, char __user *buffer, 88extern int cifs_readlink(struct dentry *direntry, char __user *buffer,
89 int buflen); 89 int buflen);
90extern int cifs_symlink(struct inode *inode, struct dentry *direntry, 90extern int cifs_symlink(struct inode *inode, struct dentry *direntry,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 3c628bf667a5..0db0b313d715 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -2602,6 +2602,9 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
2602 if(name_len < PATH_MAX) { 2602 if(name_len < PATH_MAX) {
2603 memcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len); 2603 memcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len);
2604 byte_count += name_len; 2604 byte_count += name_len;
2605 /* 14 byte parm len above enough for 2 byte null terminator */
2606 pSMB->ResumeFileName[name_len] = 0;
2607 pSMB->ResumeFileName[name_len+1] = 0;
2605 } else { 2608 } else {
2606 rc = -EINVAL; 2609 rc = -EINVAL;
2607 goto FNext2_err_exit; 2610 goto FNext2_err_exit;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 30ab70ce5547..3497125189df 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -643,7 +643,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
643 netfid, length, 643 netfid, length,
644 pfLock->fl_start, numUnlock, numLock, lockType, 644 pfLock->fl_start, numUnlock, numLock, lockType,
645 wait_flag); 645 wait_flag);
646 if (rc == 0 && (pfLock->fl_flags & FL_POSIX)) 646 if (pfLock->fl_flags & FL_POSIX)
647 posix_lock_file_wait(file, pfLock); 647 posix_lock_file_wait(file, pfLock);
648 FreeXid(xid); 648 FreeXid(xid);
649 return rc; 649 return rc;
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index bde0fabfece0..ab925ef4f863 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -92,7 +92,7 @@ cifs_hl_exit:
92 return rc; 92 return rc;
93} 93}
94 94
95int 95void *
96cifs_follow_link(struct dentry *direntry, struct nameidata *nd) 96cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
97{ 97{
98 struct inode *inode = direntry->d_inode; 98 struct inode *inode = direntry->d_inode;
@@ -148,7 +148,7 @@ out:
148out_no_free: 148out_no_free:
149 FreeXid(xid); 149 FreeXid(xid);
150 nd_set_link(nd, target_path); 150 nd_set_link(nd, target_path);
151 return 0; 151 return NULL; /* No cookie */
152} 152}
153 153
154int 154int
@@ -330,7 +330,7 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
330 return rc; 330 return rc;
331} 331}
332 332
333void cifs_put_link(struct dentry *direntry, struct nameidata *nd) 333void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
334{ 334{
335 char *p = nd_get_link(nd); 335 char *p = nd_get_link(nd);
336 if (!IS_ERR(p)) 336 if (!IS_ERR(p))
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 072b4ee8c53e..20ae4153f791 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -611,6 +611,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
611 src_char = source[i]; 611 src_char = source[i];
612 switch (src_char) { 612 switch (src_char) {
613 case 0: 613 case 0:
614 target[j] = 0;
614 goto ctoUCS_out; 615 goto ctoUCS_out;
615 case ':': 616 case ':':
616 target[j] = cpu_to_le16(UNI_COLON); 617 target[j] = cpu_to_le16(UNI_COLON);
diff --git a/fs/dcache.c b/fs/dcache.c
index 3aa8a7e980d8..a15a2e1f5520 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -19,6 +19,7 @@
19#include <linux/string.h> 19#include <linux/string.h>
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/fsnotify.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23#include <linux/init.h> 24#include <linux/init.h>
24#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
@@ -101,6 +102,7 @@ static inline void dentry_iput(struct dentry * dentry)
101 list_del_init(&dentry->d_alias); 102 list_del_init(&dentry->d_alias);
102 spin_unlock(&dentry->d_lock); 103 spin_unlock(&dentry->d_lock);
103 spin_unlock(&dcache_lock); 104 spin_unlock(&dcache_lock);
105 fsnotify_inoderemove(inode);
104 if (dentry->d_op && dentry->d_op->d_iput) 106 if (dentry->d_op && dentry->d_op->d_iput)
105 dentry->d_op->d_iput(dentry, inode); 107 dentry->d_op->d_iput(dentry, inode);
106 else 108 else
@@ -1165,13 +1167,16 @@ out:
1165 1167
1166void d_delete(struct dentry * dentry) 1168void d_delete(struct dentry * dentry)
1167{ 1169{
1170 int isdir = 0;
1168 /* 1171 /*
1169 * Are we the only user? 1172 * Are we the only user?
1170 */ 1173 */
1171 spin_lock(&dcache_lock); 1174 spin_lock(&dcache_lock);
1172 spin_lock(&dentry->d_lock); 1175 spin_lock(&dentry->d_lock);
1176 isdir = S_ISDIR(dentry->d_inode->i_mode);
1173 if (atomic_read(&dentry->d_count) == 1) { 1177 if (atomic_read(&dentry->d_count) == 1) {
1174 dentry_iput(dentry); 1178 dentry_iput(dentry);
1179 fsnotify_nameremove(dentry, isdir);
1175 return; 1180 return;
1176 } 1181 }
1177 1182
@@ -1180,6 +1185,8 @@ void d_delete(struct dentry * dentry)
1180 1185
1181 spin_unlock(&dentry->d_lock); 1186 spin_unlock(&dentry->d_lock);
1182 spin_unlock(&dcache_lock); 1187 spin_unlock(&dcache_lock);
1188
1189 fsnotify_nameremove(dentry, isdir);
1183} 1190}
1184 1191
1185static void __d_rehash(struct dentry * entry, struct hlist_head *list) 1192static void __d_rehash(struct dentry * entry, struct hlist_head *list)
diff --git a/fs/devfs/base.c b/fs/devfs/base.c
index 1ecfe1f184d4..8b679b67e5e0 100644
--- a/fs/devfs/base.c
+++ b/fs/devfs/base.c
@@ -2491,11 +2491,11 @@ static int devfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
2491 return 0; 2491 return 0;
2492} /* End Function devfs_mknod */ 2492} /* End Function devfs_mknod */
2493 2493
2494static int devfs_follow_link(struct dentry *dentry, struct nameidata *nd) 2494static void *devfs_follow_link(struct dentry *dentry, struct nameidata *nd)
2495{ 2495{
2496 struct devfs_entry *p = get_devfs_entry_from_vfs_inode(dentry->d_inode); 2496 struct devfs_entry *p = get_devfs_entry_from_vfs_inode(dentry->d_inode);
2497 nd_set_link(nd, p ? p->u.symlink.linkname : ERR_PTR(-ENODEV)); 2497 nd_set_link(nd, p ? p->u.symlink.linkname : ERR_PTR(-ENODEV));
2498 return 0; 2498 return NULL;
2499} /* End Function devfs_follow_link */ 2499} /* End Function devfs_follow_link */
2500 2500
2501static struct inode_operations devfs_iops = { 2501static struct inode_operations devfs_iops = {
diff --git a/fs/ext2/symlink.c b/fs/ext2/symlink.c
index 9f7bac01d557..1e67d87cfa91 100644
--- a/fs/ext2/symlink.c
+++ b/fs/ext2/symlink.c
@@ -21,11 +21,11 @@
21#include "xattr.h" 21#include "xattr.h"
22#include <linux/namei.h> 22#include <linux/namei.h>
23 23
24static int ext2_follow_link(struct dentry *dentry, struct nameidata *nd) 24static void *ext2_follow_link(struct dentry *dentry, struct nameidata *nd)
25{ 25{
26 struct ext2_inode_info *ei = EXT2_I(dentry->d_inode); 26 struct ext2_inode_info *ei = EXT2_I(dentry->d_inode);
27 nd_set_link(nd, (char *)ei->i_data); 27 nd_set_link(nd, (char *)ei->i_data);
28 return 0; 28 return NULL;
29} 29}
30 30
31struct inode_operations ext2_symlink_inode_operations = { 31struct inode_operations ext2_symlink_inode_operations = {
diff --git a/fs/ext3/symlink.c b/fs/ext3/symlink.c
index 8c3e72818fb0..4f79122cde67 100644
--- a/fs/ext3/symlink.c
+++ b/fs/ext3/symlink.c
@@ -23,11 +23,11 @@
23#include <linux/namei.h> 23#include <linux/namei.h>
24#include "xattr.h" 24#include "xattr.h"
25 25
26static int ext3_follow_link(struct dentry *dentry, struct nameidata *nd) 26static void * ext3_follow_link(struct dentry *dentry, struct nameidata *nd)
27{ 27{
28 struct ext3_inode_info *ei = EXT3_I(dentry->d_inode); 28 struct ext3_inode_info *ei = EXT3_I(dentry->d_inode);
29 nd_set_link(nd, (char*)ei->i_data); 29 nd_set_link(nd, (char*)ei->i_data);
30 return 0; 30 return NULL;
31} 31}
32 32
33struct inode_operations ext3_symlink_inode_operations = { 33struct inode_operations ext3_symlink_inode_operations = {
diff --git a/fs/freevxfs/vxfs_immed.c b/fs/freevxfs/vxfs_immed.c
index ac677ab262b2..d0401dc68d41 100644
--- a/fs/freevxfs/vxfs_immed.c
+++ b/fs/freevxfs/vxfs_immed.c
@@ -38,7 +38,7 @@
38#include "vxfs_inode.h" 38#include "vxfs_inode.h"
39 39
40 40
41static int vxfs_immed_follow_link(struct dentry *, struct nameidata *); 41static void * vxfs_immed_follow_link(struct dentry *, struct nameidata *);
42 42
43static int vxfs_immed_readpage(struct file *, struct page *); 43static int vxfs_immed_readpage(struct file *, struct page *);
44 44
@@ -72,12 +72,12 @@ struct address_space_operations vxfs_immed_aops = {
72 * Returns: 72 * Returns:
73 * Zero on success, else a negative error code. 73 * Zero on success, else a negative error code.
74 */ 74 */
75static int 75static void *
76vxfs_immed_follow_link(struct dentry *dp, struct nameidata *np) 76vxfs_immed_follow_link(struct dentry *dp, struct nameidata *np)
77{ 77{
78 struct vxfs_inode_info *vip = VXFS_INO(dp->d_inode); 78 struct vxfs_inode_info *vip = VXFS_INO(dp->d_inode);
79 nd_set_link(np, vip->vii_immed.vi_immed); 79 nd_set_link(np, vip->vii_immed.vi_immed);
80 return 0; 80 return NULL;
81} 81}
82 82
83/** 83/**
diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index 6ad1211f84ed..a096c5a56664 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -480,6 +480,8 @@ void hfs_bnode_put(struct hfs_bnode *node)
480 return; 480 return;
481 } 481 }
482 for (i = 0; i < tree->pages_per_bnode; i++) { 482 for (i = 0; i < tree->pages_per_bnode; i++) {
483 if (!node->page[i])
484 continue;
483 mark_page_accessed(node->page[i]); 485 mark_page_accessed(node->page[i]);
484#if REF_PAGES 486#if REF_PAGES
485 put_page(node->page[i]); 487 put_page(node->page[i]);
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
index cbc8510ad222..5ea6b3d45eaa 100644
--- a/fs/hfs/extent.c
+++ b/fs/hfs/extent.c
@@ -482,7 +482,8 @@ void hfs_file_truncate(struct inode *inode)
482 page_cache_release(page); 482 page_cache_release(page);
483 mark_inode_dirty(inode); 483 mark_inode_dirty(inode);
484 return; 484 return;
485 } 485 } else if (inode->i_size == HFS_I(inode)->phys_size)
486 return;
486 size = inode->i_size + HFS_SB(sb)->alloc_blksz - 1; 487 size = inode->i_size + HFS_SB(sb)->alloc_blksz - 1;
487 blk_cnt = size / HFS_SB(sb)->alloc_blksz; 488 blk_cnt = size / HFS_SB(sb)->alloc_blksz;
488 alloc_cnt = HFS_I(inode)->alloc_blocks; 489 alloc_cnt = HFS_I(inode)->alloc_blocks;
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index 267872e84d71..8868d3b766fd 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -643,6 +643,8 @@ void hfs_bnode_put(struct hfs_bnode *node)
643 return; 643 return;
644 } 644 }
645 for (i = 0; i < tree->pages_per_bnode; i++) { 645 for (i = 0; i < tree->pages_per_bnode; i++) {
646 if (!node->page[i])
647 continue;
646 mark_page_accessed(node->page[i]); 648 mark_page_accessed(node->page[i]);
647#if REF_PAGES 649#if REF_PAGES
648 put_page(node->page[i]); 650 put_page(node->page[i]);
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index 376498cc64fd..e7235ca79a95 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -461,7 +461,9 @@ void hfsplus_file_truncate(struct inode *inode)
461 page_cache_release(page); 461 page_cache_release(page);
462 mark_inode_dirty(inode); 462 mark_inode_dirty(inode);
463 return; 463 return;
464 } 464 } else if (inode->i_size == HFSPLUS_I(inode).phys_size)
465 return;
466
465 blk_cnt = (inode->i_size + HFSPLUS_SB(sb).alloc_blksz - 1) >> HFSPLUS_SB(sb).alloc_blksz_shift; 467 blk_cnt = (inode->i_size + HFSPLUS_SB(sb).alloc_blksz - 1) >> HFSPLUS_SB(sb).alloc_blksz_shift;
466 alloc_cnt = HFSPLUS_I(inode).alloc_blocks; 468 alloc_cnt = HFSPLUS_I(inode).alloc_blocks;
467 if (blk_cnt == alloc_cnt) 469 if (blk_cnt == alloc_cnt)
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs_kern.c
index ff150fedb981..52930915bad8 100644
--- a/fs/hppfs/hppfs_kern.c
+++ b/fs/hppfs/hppfs_kern.c
@@ -38,7 +38,7 @@ struct hppfs_inode_info {
38 38
39static inline struct hppfs_inode_info *HPPFS_I(struct inode *inode) 39static inline struct hppfs_inode_info *HPPFS_I(struct inode *inode)
40{ 40{
41 return(list_entry(inode, struct hppfs_inode_info, vfs_inode)); 41 return container_of(inode, struct hppfs_inode_info, vfs_inode);
42} 42}
43 43
44#define HPPFS_SUPER_MAGIC 0xb00000ee 44#define HPPFS_SUPER_MAGIC 0xb00000ee
@@ -662,42 +662,36 @@ static int hppfs_readlink(struct dentry *dentry, char *buffer, int buflen)
662{ 662{
663 struct file *proc_file; 663 struct file *proc_file;
664 struct dentry *proc_dentry; 664 struct dentry *proc_dentry;
665 int (*readlink)(struct dentry *, char *, int); 665 int ret;
666 int err, n;
667 666
668 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; 667 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
669 proc_file = dentry_open(dget(proc_dentry), NULL, O_RDONLY); 668 proc_file = dentry_open(dget(proc_dentry), NULL, O_RDONLY);
670 err = PTR_ERR(proc_dentry); 669 if (IS_ERR(proc_file))
671 if(IS_ERR(proc_dentry)) 670 return PTR_ERR(proc_file);
672 return(err);
673 671
674 readlink = proc_dentry->d_inode->i_op->readlink; 672 ret = proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer, buflen);
675 n = (*readlink)(proc_dentry, buffer, buflen);
676 673
677 fput(proc_file); 674 fput(proc_file);
678 675
679 return(n); 676 return ret;
680} 677}
681 678
682static int hppfs_follow_link(struct dentry *dentry, struct nameidata *nd) 679static void* hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
683{ 680{
684 struct file *proc_file; 681 struct file *proc_file;
685 struct dentry *proc_dentry; 682 struct dentry *proc_dentry;
686 int (*follow_link)(struct dentry *, struct nameidata *); 683 void *ret;
687 int err, n;
688 684
689 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; 685 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
690 proc_file = dentry_open(dget(proc_dentry), NULL, O_RDONLY); 686 proc_file = dentry_open(dget(proc_dentry), NULL, O_RDONLY);
691 err = PTR_ERR(proc_dentry); 687 if (IS_ERR(proc_file))
692 if(IS_ERR(proc_dentry)) 688 return proc_file;
693 return(err);
694 689
695 follow_link = proc_dentry->d_inode->i_op->follow_link; 690 ret = proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd);
696 n = (*follow_link)(proc_dentry, nd);
697 691
698 fput(proc_file); 692 fput(proc_file);
699 693
700 return(n); 694 return ret;
701} 695}
702 696
703static struct inode_operations hppfs_dir_iops = { 697static struct inode_operations hppfs_dir_iops = {
diff --git a/fs/inotify.c b/fs/inotify.c
index a8a714e48140..2e4e2a57708c 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -90,6 +90,7 @@ struct inotify_device {
90 unsigned int queue_size; /* size of the queue (bytes) */ 90 unsigned int queue_size; /* size of the queue (bytes) */
91 unsigned int event_count; /* number of pending events */ 91 unsigned int event_count; /* number of pending events */
92 unsigned int max_events; /* maximum number of events */ 92 unsigned int max_events; /* maximum number of events */
93 u32 last_wd; /* the last wd allocated */
93}; 94};
94 95
95/* 96/*
@@ -352,7 +353,7 @@ static int inotify_dev_get_wd(struct inotify_device *dev,
352 do { 353 do {
353 if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL))) 354 if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL)))
354 return -ENOSPC; 355 return -ENOSPC;
355 ret = idr_get_new(&dev->idr, watch, &watch->wd); 356 ret = idr_get_new_above(&dev->idr, watch, dev->last_wd+1, &watch->wd);
356 } while (ret == -EAGAIN); 357 } while (ret == -EAGAIN);
357 358
358 return ret; 359 return ret;
@@ -401,6 +402,7 @@ static struct inotify_watch *create_watch(struct inotify_device *dev,
401 return ERR_PTR(ret); 402 return ERR_PTR(ret);
402 } 403 }
403 404
405 dev->last_wd = watch->wd;
404 watch->mask = mask; 406 watch->mask = mask;
405 atomic_set(&watch->count, 0); 407 atomic_set(&watch->count, 0);
406 INIT_LIST_HEAD(&watch->d_list); 408 INIT_LIST_HEAD(&watch->d_list);
@@ -899,6 +901,7 @@ asmlinkage long sys_inotify_init(void)
899 dev->queue_size = 0; 901 dev->queue_size = 0;
900 dev->max_events = inotify_max_queued_events; 902 dev->max_events = inotify_max_queued_events;
901 dev->user = user; 903 dev->user = user;
904 dev->last_wd = 0;
902 atomic_set(&dev->count, 0); 905 atomic_set(&dev->count, 0);
903 906
904 get_inotify_dev(dev); 907 get_inotify_dev(dev);
diff --git a/fs/ioprio.c b/fs/ioprio.c
index 97e1f088ba00..d1c1f2b2c9da 100644
--- a/fs/ioprio.c
+++ b/fs/ioprio.c
@@ -62,6 +62,8 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
62 62
63 break; 63 break;
64 case IOPRIO_CLASS_IDLE: 64 case IOPRIO_CLASS_IDLE:
65 if (!capable(CAP_SYS_ADMIN))
66 return -EPERM;
65 break; 67 break;
66 default: 68 default:
67 return -EINVAL; 69 return -EINVAL;
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c
index 34a44e451689..4917315db732 100644
--- a/fs/isofs/compress.c
+++ b/fs/isofs/compress.c
@@ -129,8 +129,14 @@ static int zisofs_readpage(struct file *file, struct page *page)
129 cend = le32_to_cpu(*(__le32 *)(bh->b_data + (blockendptr & bufmask))); 129 cend = le32_to_cpu(*(__le32 *)(bh->b_data + (blockendptr & bufmask)));
130 brelse(bh); 130 brelse(bh);
131 131
132 if (cstart > cend)
133 goto eio;
134
132 csize = cend-cstart; 135 csize = cend-cstart;
133 136
137 if (csize > deflateBound(1UL << zisofs_block_shift))
138 goto eio;
139
134 /* Now page[] contains an array of pages, any of which can be NULL, 140 /* Now page[] contains an array of pages, any of which can be NULL,
135 and the locks on which we hold. We should now read the data and 141 and the locks on which we hold. We should now read the data and
136 release the pages. If the pages are NULL the decompressed data 142 release the pages. If the pages are NULL the decompressed data
diff --git a/fs/jffs2/symlink.c b/fs/jffs2/symlink.c
index 65ab6b001dca..82ef484f5e12 100644
--- a/fs/jffs2/symlink.c
+++ b/fs/jffs2/symlink.c
@@ -18,7 +18,7 @@
18#include <linux/namei.h> 18#include <linux/namei.h>
19#include "nodelist.h" 19#include "nodelist.h"
20 20
21static int jffs2_follow_link(struct dentry *dentry, struct nameidata *nd); 21static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd);
22 22
23struct inode_operations jffs2_symlink_inode_operations = 23struct inode_operations jffs2_symlink_inode_operations =
24{ 24{
@@ -27,9 +27,10 @@ struct inode_operations jffs2_symlink_inode_operations =
27 .setattr = jffs2_setattr 27 .setattr = jffs2_setattr
28}; 28};
29 29
30static int jffs2_follow_link(struct dentry *dentry, struct nameidata *nd) 30static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd)
31{ 31{
32 struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode); 32 struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode);
33 char *p = (char *)f->dents;
33 34
34 /* 35 /*
35 * We don't acquire the f->sem mutex here since the only data we 36 * We don't acquire the f->sem mutex here since the only data we
@@ -45,19 +46,20 @@ static int jffs2_follow_link(struct dentry *dentry, struct nameidata *nd)
45 * nd_set_link() call. 46 * nd_set_link() call.
46 */ 47 */
47 48
48 if (!f->dents) { 49 if (!p) {
49 printk(KERN_ERR "jffs2_follow_link(): can't find symlink taerget\n"); 50 printk(KERN_ERR "jffs2_follow_link(): can't find symlink taerget\n");
50 return -EIO; 51 p = ERR_PTR(-EIO);
52 } else {
53 D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->dents));
51 } 54 }
52 D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->dents));
53 55
54 nd_set_link(nd, (char *)f->dents); 56 nd_set_link(nd, p);
55 57
56 /* 58 /*
57 * We unlock the f->sem mutex but VFS will use the f->dents string. This is safe 59 * We unlock the f->sem mutex but VFS will use the f->dents string. This is safe
58 * since the only way that may cause f->dents to be changed is iput() operation. 60 * since the only way that may cause f->dents to be changed is iput() operation.
59 * But VFS will not use f->dents after iput() has been called. 61 * But VFS will not use f->dents after iput() has been called.
60 */ 62 */
61 return 0; 63 return NULL;
62} 64}
63 65
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 2137138c59b0..767c7ecb429e 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -128,6 +128,10 @@ void jfs_delete_inode(struct inode *inode)
128{ 128{
129 jfs_info("In jfs_delete_inode, inode = 0x%p", inode); 129 jfs_info("In jfs_delete_inode, inode = 0x%p", inode);
130 130
131 if (is_bad_inode(inode) ||
132 (JFS_IP(inode)->fileset != cpu_to_le32(FILESYSTEM_I)))
133 return;
134
131 if (test_cflag(COMMIT_Freewmap, inode)) 135 if (test_cflag(COMMIT_Freewmap, inode))
132 jfs_free_zero_link(inode); 136 jfs_free_zero_link(inode);
133 137
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index 22815e88e7cc..d27bac6acaa3 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -191,7 +191,7 @@ static int lbmIOWait(struct lbuf * bp, int flag);
191static bio_end_io_t lbmIODone; 191static bio_end_io_t lbmIODone;
192static void lbmStartIO(struct lbuf * bp); 192static void lbmStartIO(struct lbuf * bp);
193static void lmGCwrite(struct jfs_log * log, int cant_block); 193static void lmGCwrite(struct jfs_log * log, int cant_block);
194static int lmLogSync(struct jfs_log * log, int nosyncwait); 194static int lmLogSync(struct jfs_log * log, int hard_sync);
195 195
196 196
197 197
@@ -915,19 +915,17 @@ static void lmPostGC(struct lbuf * bp)
915 * if new sync address is available 915 * if new sync address is available
916 * (normally the case if sync() is executed by back-ground 916 * (normally the case if sync() is executed by back-ground
917 * process). 917 * process).
918 * if not, explicitly run jfs_blogsync() to initiate
919 * getting of new sync address.
920 * calculate new value of i_nextsync which determines when 918 * calculate new value of i_nextsync which determines when
921 * this code is called again. 919 * this code is called again.
922 * 920 *
923 * PARAMETERS: log - log structure 921 * PARAMETERS: log - log structure
924 * nosyncwait - 1 if called asynchronously 922 * hard_sync - 1 to force all metadata to be written
925 * 923 *
926 * RETURN: 0 924 * RETURN: 0
927 * 925 *
928 * serialization: LOG_LOCK() held on entry/exit 926 * serialization: LOG_LOCK() held on entry/exit
929 */ 927 */
930static int lmLogSync(struct jfs_log * log, int nosyncwait) 928static int lmLogSync(struct jfs_log * log, int hard_sync)
931{ 929{
932 int logsize; 930 int logsize;
933 int written; /* written since last syncpt */ 931 int written; /* written since last syncpt */
@@ -941,11 +939,18 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
941 unsigned long flags; 939 unsigned long flags;
942 940
943 /* push dirty metapages out to disk */ 941 /* push dirty metapages out to disk */
944 list_for_each_entry(sbi, &log->sb_list, log_list) { 942 if (hard_sync)
945 filemap_flush(sbi->ipbmap->i_mapping); 943 list_for_each_entry(sbi, &log->sb_list, log_list) {
946 filemap_flush(sbi->ipimap->i_mapping); 944 filemap_fdatawrite(sbi->ipbmap->i_mapping);
947 filemap_flush(sbi->direct_inode->i_mapping); 945 filemap_fdatawrite(sbi->ipimap->i_mapping);
948 } 946 filemap_fdatawrite(sbi->direct_inode->i_mapping);
947 }
948 else
949 list_for_each_entry(sbi, &log->sb_list, log_list) {
950 filemap_flush(sbi->ipbmap->i_mapping);
951 filemap_flush(sbi->ipimap->i_mapping);
952 filemap_flush(sbi->direct_inode->i_mapping);
953 }
949 954
950 /* 955 /*
951 * forward syncpt 956 * forward syncpt
@@ -1021,10 +1026,6 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
1021 /* next syncpt trigger = written + more */ 1026 /* next syncpt trigger = written + more */
1022 log->nextsync = written + more; 1027 log->nextsync = written + more;
1023 1028
1024 /* return if lmLogSync() from outside of transaction, e.g., sync() */
1025 if (nosyncwait)
1026 return lsn;
1027
1028 /* if number of bytes written from last sync point is more 1029 /* if number of bytes written from last sync point is more
1029 * than 1/4 of the log size, stop new transactions from 1030 * than 1/4 of the log size, stop new transactions from
1030 * starting until all current transactions are completed 1031 * starting until all current transactions are completed
@@ -1049,11 +1050,12 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
1049 * 1050 *
1050 * FUNCTION: write log SYNCPT record for specified log 1051 * FUNCTION: write log SYNCPT record for specified log
1051 * 1052 *
1052 * PARAMETERS: log - log structure 1053 * PARAMETERS: log - log structure
1054 * hard_sync - set to 1 to force metadata to be written
1053 */ 1055 */
1054void jfs_syncpt(struct jfs_log *log) 1056void jfs_syncpt(struct jfs_log *log, int hard_sync)
1055{ LOG_LOCK(log); 1057{ LOG_LOCK(log);
1056 lmLogSync(log, 1); 1058 lmLogSync(log, hard_sync);
1057 LOG_UNLOCK(log); 1059 LOG_UNLOCK(log);
1058} 1060}
1059 1061
diff --git a/fs/jfs/jfs_logmgr.h b/fs/jfs/jfs_logmgr.h
index 747114cd38b8..e4978b5b65ee 100644
--- a/fs/jfs/jfs_logmgr.h
+++ b/fs/jfs/jfs_logmgr.h
@@ -510,6 +510,6 @@ extern int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize);
510extern int lmGroupCommit(struct jfs_log *, struct tblock *); 510extern int lmGroupCommit(struct jfs_log *, struct tblock *);
511extern int jfsIOWait(void *); 511extern int jfsIOWait(void *);
512extern void jfs_flush_journal(struct jfs_log * log, int wait); 512extern void jfs_flush_journal(struct jfs_log * log, int wait);
513extern void jfs_syncpt(struct jfs_log *log); 513extern void jfs_syncpt(struct jfs_log *log, int hard_sync);
514 514
515#endif /* _H_JFS_LOGMGR */ 515#endif /* _H_JFS_LOGMGR */
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index 121c981ff453..c7a92f9deb2b 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -552,6 +552,11 @@ void txEnd(tid_t tid)
552 * synchronize with logsync barrier 552 * synchronize with logsync barrier
553 */ 553 */
554 if (test_bit(log_SYNCBARRIER, &log->flag)) { 554 if (test_bit(log_SYNCBARRIER, &log->flag)) {
555 TXN_UNLOCK();
556
557 /* write dirty metadata & forward log syncpt */
558 jfs_syncpt(log, 1);
559
555 jfs_info("log barrier off: 0x%x", log->lsn); 560 jfs_info("log barrier off: 0x%x", log->lsn);
556 561
557 /* enable new transactions start */ 562 /* enable new transactions start */
@@ -560,11 +565,6 @@ void txEnd(tid_t tid)
560 /* wakeup all waitors for logsync barrier */ 565 /* wakeup all waitors for logsync barrier */
561 TXN_WAKEUP(&log->syncwait); 566 TXN_WAKEUP(&log->syncwait);
562 567
563 TXN_UNLOCK();
564
565 /* forward log syncpt */
566 jfs_syncpt(log);
567
568 goto wakeup; 568 goto wakeup;
569 } 569 }
570 } 570 }
@@ -657,7 +657,9 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
657 /* only anonymous txn. 657 /* only anonymous txn.
658 * Remove from anon_list 658 * Remove from anon_list
659 */ 659 */
660 TXN_LOCK();
660 list_del_init(&jfs_ip->anon_inode_list); 661 list_del_init(&jfs_ip->anon_inode_list);
662 TXN_UNLOCK();
661 } 663 }
662 jfs_ip->atlhead = tlck->next; 664 jfs_ip->atlhead = tlck->next;
663 } else { 665 } else {
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index ee32211288ce..9ff89720f93b 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -114,6 +114,8 @@ static void jfs_destroy_inode(struct inode *inode)
114{ 114{
115 struct jfs_inode_info *ji = JFS_IP(inode); 115 struct jfs_inode_info *ji = JFS_IP(inode);
116 116
117 BUG_ON(!list_empty(&ji->anon_inode_list));
118
117 spin_lock_irq(&ji->ag_lock); 119 spin_lock_irq(&ji->ag_lock);
118 if (ji->active_ag != -1) { 120 if (ji->active_ag != -1) {
119 struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap; 121 struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap;
@@ -531,7 +533,7 @@ static int jfs_sync_fs(struct super_block *sb, int wait)
531 /* log == NULL indicates read-only mount */ 533 /* log == NULL indicates read-only mount */
532 if (log) { 534 if (log) {
533 jfs_flush_journal(log, wait); 535 jfs_flush_journal(log, wait);
534 jfs_syncpt(log); 536 jfs_syncpt(log, 0);
535 } 537 }
536 538
537 return 0; 539 return 0;
diff --git a/fs/jfs/symlink.c b/fs/jfs/symlink.c
index 287d8d6c3cfd..16477b3835e1 100644
--- a/fs/jfs/symlink.c
+++ b/fs/jfs/symlink.c
@@ -22,11 +22,11 @@
22#include "jfs_inode.h" 22#include "jfs_inode.h"
23#include "jfs_xattr.h" 23#include "jfs_xattr.h"
24 24
25static int jfs_follow_link(struct dentry *dentry, struct nameidata *nd) 25static void *jfs_follow_link(struct dentry *dentry, struct nameidata *nd)
26{ 26{
27 char *s = JFS_IP(dentry->d_inode)->i_inline; 27 char *s = JFS_IP(dentry->d_inode)->i_inline;
28 nd_set_link(nd, s); 28 nd_set_link(nd, s);
29 return 0; 29 return NULL;
30} 30}
31 31
32struct inode_operations jfs_symlink_inode_operations = { 32struct inode_operations jfs_symlink_inode_operations = {
diff --git a/fs/namei.c b/fs/namei.c
index 02a824cd3c5c..6ec1f0fefc5b 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -501,6 +501,7 @@ struct path {
501static inline int __do_follow_link(struct path *path, struct nameidata *nd) 501static inline int __do_follow_link(struct path *path, struct nameidata *nd)
502{ 502{
503 int error; 503 int error;
504 void *cookie;
504 struct dentry *dentry = path->dentry; 505 struct dentry *dentry = path->dentry;
505 506
506 touch_atime(path->mnt, dentry); 507 touch_atime(path->mnt, dentry);
@@ -508,13 +509,15 @@ static inline int __do_follow_link(struct path *path, struct nameidata *nd)
508 509
509 if (path->mnt == nd->mnt) 510 if (path->mnt == nd->mnt)
510 mntget(path->mnt); 511 mntget(path->mnt);
511 error = dentry->d_inode->i_op->follow_link(dentry, nd); 512 cookie = dentry->d_inode->i_op->follow_link(dentry, nd);
512 if (!error) { 513 error = PTR_ERR(cookie);
514 if (!IS_ERR(cookie)) {
513 char *s = nd_get_link(nd); 515 char *s = nd_get_link(nd);
516 error = 0;
514 if (s) 517 if (s)
515 error = __vfs_follow_link(nd, s); 518 error = __vfs_follow_link(nd, s);
516 if (dentry->d_inode->i_op->put_link) 519 if (dentry->d_inode->i_op->put_link)
517 dentry->d_inode->i_op->put_link(dentry, nd); 520 dentry->d_inode->i_op->put_link(dentry, nd, cookie);
518 } 521 }
519 dput(dentry); 522 dput(dentry);
520 mntput(path->mnt); 523 mntput(path->mnt);
@@ -1801,7 +1804,6 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
1801 } 1804 }
1802 up(&dentry->d_inode->i_sem); 1805 up(&dentry->d_inode->i_sem);
1803 if (!error) { 1806 if (!error) {
1804 fsnotify_rmdir(dentry, dentry->d_inode, dir);
1805 d_delete(dentry); 1807 d_delete(dentry);
1806 } 1808 }
1807 dput(dentry); 1809 dput(dentry);
@@ -1874,7 +1876,6 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
1874 1876
1875 /* We don't d_delete() NFS sillyrenamed files--they still exist. */ 1877 /* We don't d_delete() NFS sillyrenamed files--they still exist. */
1876 if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) { 1878 if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
1877 fsnotify_unlink(dentry, dir);
1878 d_delete(dentry); 1879 d_delete(dentry);
1879 } 1880 }
1880 1881
@@ -2218,7 +2219,8 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2218 error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); 2219 error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
2219 if (!error) { 2220 if (!error) {
2220 const char *new_name = old_dentry->d_name.name; 2221 const char *new_name = old_dentry->d_name.name;
2221 fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir); 2222 fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir,
2223 new_dentry->d_inode, old_dentry->d_inode);
2222 } 2224 }
2223 fsnotify_oldname_free(old_name); 2225 fsnotify_oldname_free(old_name);
2224 2226
@@ -2345,15 +2347,17 @@ out:
2345int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen) 2347int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
2346{ 2348{
2347 struct nameidata nd; 2349 struct nameidata nd;
2348 int res; 2350 void *cookie;
2351
2349 nd.depth = 0; 2352 nd.depth = 0;
2350 res = dentry->d_inode->i_op->follow_link(dentry, &nd); 2353 cookie = dentry->d_inode->i_op->follow_link(dentry, &nd);
2351 if (!res) { 2354 if (!IS_ERR(cookie)) {
2352 res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd)); 2355 int res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd));
2353 if (dentry->d_inode->i_op->put_link) 2356 if (dentry->d_inode->i_op->put_link)
2354 dentry->d_inode->i_op->put_link(dentry, &nd); 2357 dentry->d_inode->i_op->put_link(dentry, &nd, cookie);
2358 cookie = ERR_PTR(res);
2355 } 2359 }
2356 return res; 2360 return PTR_ERR(cookie);
2357} 2361}
2358 2362
2359int vfs_follow_link(struct nameidata *nd, const char *link) 2363int vfs_follow_link(struct nameidata *nd, const char *link)
@@ -2396,23 +2400,20 @@ int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
2396 return res; 2400 return res;
2397} 2401}
2398 2402
2399int page_follow_link_light(struct dentry *dentry, struct nameidata *nd) 2403void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd)
2400{ 2404{
2401 struct page *page; 2405 struct page *page = NULL;
2402 nd_set_link(nd, page_getlink(dentry, &page)); 2406 nd_set_link(nd, page_getlink(dentry, &page));
2403 return 0; 2407 return page;
2404} 2408}
2405 2409
2406void page_put_link(struct dentry *dentry, struct nameidata *nd) 2410void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
2407{ 2411{
2408 if (!IS_ERR(nd_get_link(nd))) { 2412 struct page *page = cookie;
2409 struct page *page; 2413
2410 page = find_get_page(dentry->d_inode->i_mapping, 0); 2414 if (page) {
2411 if (!page)
2412 BUG();
2413 kunmap(page); 2415 kunmap(page);
2414 page_cache_release(page); 2416 page_cache_release(page);
2415 page_cache_release(page);
2416 } 2417 }
2417} 2418}
2418 2419
diff --git a/fs/namespace.c b/fs/namespace.c
index 587eb0d707ee..79bd8a46e1e7 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -160,7 +160,7 @@ clone_mnt(struct vfsmount *old, struct dentry *root)
160 mnt->mnt_root = dget(root); 160 mnt->mnt_root = dget(root);
161 mnt->mnt_mountpoint = mnt->mnt_root; 161 mnt->mnt_mountpoint = mnt->mnt_root;
162 mnt->mnt_parent = mnt; 162 mnt->mnt_parent = mnt;
163 mnt->mnt_namespace = old->mnt_namespace; 163 mnt->mnt_namespace = current->namespace;
164 164
165 /* stick the duplicate mount on the same expiry list 165 /* stick the duplicate mount on the same expiry list
166 * as the original if that was on one */ 166 * as the original if that was on one */
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index b38a57e78a63..2df639f143e8 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -182,14 +182,16 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
182 /* We requested READDIRPLUS, but the server doesn't grok it */ 182 /* We requested READDIRPLUS, but the server doesn't grok it */
183 if (error == -ENOTSUPP && desc->plus) { 183 if (error == -ENOTSUPP && desc->plus) {
184 NFS_SERVER(inode)->caps &= ~NFS_CAP_READDIRPLUS; 184 NFS_SERVER(inode)->caps &= ~NFS_CAP_READDIRPLUS;
185 NFS_FLAGS(inode) &= ~NFS_INO_ADVISE_RDPLUS; 185 clear_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode));
186 desc->plus = 0; 186 desc->plus = 0;
187 goto again; 187 goto again;
188 } 188 }
189 goto error; 189 goto error;
190 } 190 }
191 SetPageUptodate(page); 191 SetPageUptodate(page);
192 NFS_FLAGS(inode) |= NFS_INO_INVALID_ATIME; 192 spin_lock(&inode->i_lock);
193 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
194 spin_unlock(&inode->i_lock);
193 /* Ensure consistent page alignment of the data. 195 /* Ensure consistent page alignment of the data.
194 * Note: assumes we have exclusive access to this mapping either 196 * Note: assumes we have exclusive access to this mapping either
195 * through inode->i_sem or some other mechanism. 197 * through inode->i_sem or some other mechanism.
@@ -462,7 +464,9 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
462 page, 464 page,
463 NFS_SERVER(inode)->dtsize, 465 NFS_SERVER(inode)->dtsize,
464 desc->plus); 466 desc->plus);
465 NFS_FLAGS(inode) |= NFS_INO_INVALID_ATIME; 467 spin_lock(&inode->i_lock);
468 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
469 spin_unlock(&inode->i_lock);
466 desc->page = page; 470 desc->page = page;
467 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */ 471 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */
468 if (desc->error >= 0) { 472 if (desc->error >= 0) {
@@ -545,7 +549,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
545 break; 549 break;
546 } 550 }
547 if (res == -ETOOSMALL && desc->plus) { 551 if (res == -ETOOSMALL && desc->plus) {
548 NFS_FLAGS(inode) &= ~NFS_INO_ADVISE_RDPLUS; 552 clear_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode));
549 nfs_zap_caches(inode); 553 nfs_zap_caches(inode);
550 desc->plus = 0; 554 desc->plus = 0;
551 desc->entry->eof = 0; 555 desc->entry->eof = 0;
@@ -608,7 +612,7 @@ static inline int nfs_check_verifier(struct inode *dir, struct dentry *dentry)
608{ 612{
609 if (IS_ROOT(dentry)) 613 if (IS_ROOT(dentry))
610 return 1; 614 return 1;
611 if ((NFS_FLAGS(dir) & NFS_INO_INVALID_ATTR) != 0 615 if ((NFS_I(dir)->cache_validity & NFS_INO_INVALID_ATTR) != 0
612 || nfs_attribute_timeout(dir)) 616 || nfs_attribute_timeout(dir))
613 return 0; 617 return 0;
614 return nfs_verify_change_attribute(dir, (unsigned long)dentry->d_fsdata); 618 return nfs_verify_change_attribute(dir, (unsigned long)dentry->d_fsdata);
@@ -935,6 +939,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
935 error = nfs_revalidate_inode(NFS_SERVER(dir), dir); 939 error = nfs_revalidate_inode(NFS_SERVER(dir), dir);
936 if (error < 0) { 940 if (error < 0) {
937 res = ERR_PTR(error); 941 res = ERR_PTR(error);
942 unlock_kernel();
938 goto out; 943 goto out;
939 } 944 }
940 945
@@ -1575,11 +1580,12 @@ out:
1575 1580
1576int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res) 1581int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res)
1577{ 1582{
1578 struct nfs_access_entry *cache = &NFS_I(inode)->cache_access; 1583 struct nfs_inode *nfsi = NFS_I(inode);
1584 struct nfs_access_entry *cache = &nfsi->cache_access;
1579 1585
1580 if (cache->cred != cred 1586 if (cache->cred != cred
1581 || time_after(jiffies, cache->jiffies + NFS_ATTRTIMEO(inode)) 1587 || time_after(jiffies, cache->jiffies + NFS_ATTRTIMEO(inode))
1582 || (NFS_FLAGS(inode) & NFS_INO_INVALID_ACCESS)) 1588 || (nfsi->cache_validity & NFS_INO_INVALID_ACCESS))
1583 return -ENOENT; 1589 return -ENOENT;
1584 memcpy(res, cache, sizeof(*res)); 1590 memcpy(res, cache, sizeof(*res));
1585 return 0; 1591 return 0;
@@ -1587,14 +1593,18 @@ int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs
1587 1593
1588void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set) 1594void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set)
1589{ 1595{
1590 struct nfs_access_entry *cache = &NFS_I(inode)->cache_access; 1596 struct nfs_inode *nfsi = NFS_I(inode);
1597 struct nfs_access_entry *cache = &nfsi->cache_access;
1591 1598
1592 if (cache->cred != set->cred) { 1599 if (cache->cred != set->cred) {
1593 if (cache->cred) 1600 if (cache->cred)
1594 put_rpccred(cache->cred); 1601 put_rpccred(cache->cred);
1595 cache->cred = get_rpccred(set->cred); 1602 cache->cred = get_rpccred(set->cred);
1596 } 1603 }
1597 NFS_FLAGS(inode) &= ~NFS_INO_INVALID_ACCESS; 1604 /* FIXME: replace current access_cache BKL reliance with inode->i_lock */
1605 spin_lock(&inode->i_lock);
1606 nfsi->cache_validity &= ~NFS_INO_INVALID_ACCESS;
1607 spin_unlock(&inode->i_lock);
1598 cache->jiffies = set->jiffies; 1608 cache->jiffies = set->jiffies;
1599 cache->mask = set->mask; 1609 cache->mask = set->mask;
1600} 1610}
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 5621ba9885f4..f6b9eda925c5 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -134,9 +134,10 @@ nfs_file_release(struct inode *inode, struct file *filp)
134 */ 134 */
135static int nfs_revalidate_file(struct inode *inode, struct file *filp) 135static int nfs_revalidate_file(struct inode *inode, struct file *filp)
136{ 136{
137 struct nfs_inode *nfsi = NFS_I(inode);
137 int retval = 0; 138 int retval = 0;
138 139
139 if ((NFS_FLAGS(inode) & NFS_INO_REVAL_PAGECACHE) || nfs_attribute_timeout(inode)) 140 if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) || nfs_attribute_timeout(inode))
140 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode); 141 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
141 nfs_revalidate_mapping(inode, filp->f_mapping); 142 nfs_revalidate_mapping(inode, filp->f_mapping);
142 return 0; 143 return 0;
@@ -164,7 +165,7 @@ static int nfs_revalidate_file_size(struct inode *inode, struct file *filp)
164 goto force_reval; 165 goto force_reval;
165 if (nfsi->npages != 0) 166 if (nfsi->npages != 0)
166 return 0; 167 return 0;
167 if (!(NFS_FLAGS(inode) & NFS_INO_REVAL_PAGECACHE) && !nfs_attribute_timeout(inode)) 168 if (!(nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) && !nfs_attribute_timeout(inode))
168 return 0; 169 return 0;
169force_reval: 170force_reval:
170 return __nfs_revalidate_inode(server, inode); 171 return __nfs_revalidate_inode(server, inode);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 4845911f1c63..541b418327c8 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -615,14 +615,18 @@ nfs_zap_caches(struct inode *inode)
615 struct nfs_inode *nfsi = NFS_I(inode); 615 struct nfs_inode *nfsi = NFS_I(inode);
616 int mode = inode->i_mode; 616 int mode = inode->i_mode;
617 617
618 spin_lock(&inode->i_lock);
619
618 NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); 620 NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode);
619 NFS_ATTRTIMEO_UPDATE(inode) = jiffies; 621 NFS_ATTRTIMEO_UPDATE(inode) = jiffies;
620 622
621 memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); 623 memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
622 if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) 624 if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))
623 nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; 625 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
624 else 626 else
625 nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; 627 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
628
629 spin_unlock(&inode->i_lock);
626} 630}
627 631
628static void nfs_zap_acl_cache(struct inode *inode) 632static void nfs_zap_acl_cache(struct inode *inode)
@@ -632,7 +636,9 @@ static void nfs_zap_acl_cache(struct inode *inode)
632 clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache; 636 clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache;
633 if (clear_acl_cache != NULL) 637 if (clear_acl_cache != NULL)
634 clear_acl_cache(inode); 638 clear_acl_cache(inode);
635 NFS_I(inode)->flags &= ~NFS_INO_INVALID_ACL; 639 spin_lock(&inode->i_lock);
640 NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ACL;
641 spin_unlock(&inode->i_lock);
636} 642}
637 643
638/* 644/*
@@ -739,7 +745,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
739 inode->i_fop = &nfs_dir_operations; 745 inode->i_fop = &nfs_dir_operations;
740 if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) 746 if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS)
741 && fattr->size <= NFS_LIMIT_READDIRPLUS) 747 && fattr->size <= NFS_LIMIT_READDIRPLUS)
742 NFS_FLAGS(inode) |= NFS_INO_ADVISE_RDPLUS; 748 set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode));
743 } else if (S_ISLNK(inode->i_mode)) 749 } else if (S_ISLNK(inode->i_mode))
744 inode->i_op = &nfs_symlink_inode_operations; 750 inode->i_op = &nfs_symlink_inode_operations;
745 else 751 else
@@ -814,55 +820,84 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
814 nfs_wb_all(inode); 820 nfs_wb_all(inode);
815 } 821 }
816 error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); 822 error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr);
817 if (error == 0) { 823 if (error == 0)
818 nfs_refresh_inode(inode, &fattr); 824 nfs_refresh_inode(inode, &fattr);
825 nfs_end_data_update(inode);
826 unlock_kernel();
827 return error;
828}
829
830/**
831 * nfs_setattr_update_inode - Update inode metadata after a setattr call.
832 * @inode: pointer to struct inode
833 * @attr: pointer to struct iattr
834 *
835 * Note: we do this in the *proc.c in order to ensure that
836 * it works for things like exclusive creates too.
837 */
838void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr)
839{
840 if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) {
819 if ((attr->ia_valid & ATTR_MODE) != 0) { 841 if ((attr->ia_valid & ATTR_MODE) != 0) {
820 int mode; 842 int mode = attr->ia_mode & S_IALLUGO;
821 mode = inode->i_mode & ~S_IALLUGO; 843 mode |= inode->i_mode & ~S_IALLUGO;
822 mode |= attr->ia_mode & S_IALLUGO;
823 inode->i_mode = mode; 844 inode->i_mode = mode;
824 } 845 }
825 if ((attr->ia_valid & ATTR_UID) != 0) 846 if ((attr->ia_valid & ATTR_UID) != 0)
826 inode->i_uid = attr->ia_uid; 847 inode->i_uid = attr->ia_uid;
827 if ((attr->ia_valid & ATTR_GID) != 0) 848 if ((attr->ia_valid & ATTR_GID) != 0)
828 inode->i_gid = attr->ia_gid; 849 inode->i_gid = attr->ia_gid;
829 if ((attr->ia_valid & ATTR_SIZE) != 0) { 850 spin_lock(&inode->i_lock);
830 inode->i_size = attr->ia_size; 851 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
831 vmtruncate(inode, attr->ia_size); 852 spin_unlock(&inode->i_lock);
832 }
833 } 853 }
834 if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) 854 if ((attr->ia_valid & ATTR_SIZE) != 0) {
835 NFS_FLAGS(inode) |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; 855 inode->i_size = attr->ia_size;
836 nfs_end_data_update(inode); 856 vmtruncate(inode, attr->ia_size);
837 unlock_kernel(); 857 }
838 return error; 858}
859
860static int nfs_wait_schedule(void *word)
861{
862 if (signal_pending(current))
863 return -ERESTARTSYS;
864 schedule();
865 return 0;
839} 866}
840 867
841/* 868/*
842 * Wait for the inode to get unlocked. 869 * Wait for the inode to get unlocked.
843 * (Used for NFS_INO_LOCKED and NFS_INO_REVALIDATING).
844 */ 870 */
845static int 871static int nfs_wait_on_inode(struct inode *inode)
846nfs_wait_on_inode(struct inode *inode, int flag)
847{ 872{
848 struct rpc_clnt *clnt = NFS_CLIENT(inode); 873 struct rpc_clnt *clnt = NFS_CLIENT(inode);
849 struct nfs_inode *nfsi = NFS_I(inode); 874 struct nfs_inode *nfsi = NFS_I(inode);
850 875 sigset_t oldmask;
851 int error; 876 int error;
852 if (!(NFS_FLAGS(inode) & flag)) 877
853 return 0;
854 atomic_inc(&inode->i_count); 878 atomic_inc(&inode->i_count);
855 error = nfs_wait_event(clnt, nfsi->nfs_i_wait, 879 rpc_clnt_sigmask(clnt, &oldmask);
856 !(NFS_FLAGS(inode) & flag)); 880 error = wait_on_bit_lock(&nfsi->flags, NFS_INO_REVALIDATING,
881 nfs_wait_schedule, TASK_INTERRUPTIBLE);
882 rpc_clnt_sigunmask(clnt, &oldmask);
857 iput(inode); 883 iput(inode);
884
858 return error; 885 return error;
859} 886}
860 887
888static void nfs_wake_up_inode(struct inode *inode)
889{
890 struct nfs_inode *nfsi = NFS_I(inode);
891
892 clear_bit(NFS_INO_REVALIDATING, &nfsi->flags);
893 smp_mb__after_clear_bit();
894 wake_up_bit(&nfsi->flags, NFS_INO_REVALIDATING);
895}
896
861int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) 897int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
862{ 898{
863 struct inode *inode = dentry->d_inode; 899 struct inode *inode = dentry->d_inode;
864 struct nfs_inode *nfsi = NFS_I(inode); 900 int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME;
865 int need_atime = nfsi->flags & NFS_INO_INVALID_ATIME;
866 int err; 901 int err;
867 902
868 if (__IS_FLG(inode, MS_NOATIME)) 903 if (__IS_FLG(inode, MS_NOATIME))
@@ -1008,7 +1043,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1008 struct nfs_fattr fattr; 1043 struct nfs_fattr fattr;
1009 struct nfs_inode *nfsi = NFS_I(inode); 1044 struct nfs_inode *nfsi = NFS_I(inode);
1010 unsigned long verifier; 1045 unsigned long verifier;
1011 unsigned int flags; 1046 unsigned long cache_validity;
1012 1047
1013 dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", 1048 dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n",
1014 inode->i_sb->s_id, (long long)NFS_FILEID(inode)); 1049 inode->i_sb->s_id, (long long)NFS_FILEID(inode));
@@ -1019,18 +1054,19 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1019 if (NFS_STALE(inode)) 1054 if (NFS_STALE(inode))
1020 goto out_nowait; 1055 goto out_nowait;
1021 1056
1022 while (NFS_REVALIDATING(inode)) { 1057 status = nfs_wait_on_inode(inode);
1023 status = nfs_wait_on_inode(inode, NFS_INO_REVALIDATING); 1058 if (status < 0)
1024 if (status < 0) 1059 goto out;
1025 goto out_nowait; 1060 if (NFS_STALE(inode)) {
1026 if (NFS_ATTRTIMEO(inode) == 0) 1061 status = -ESTALE;
1027 continue; 1062 /* Do we trust the cached ESTALE? */
1028 if (NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ATIME)) 1063 if (NFS_ATTRTIMEO(inode) != 0) {
1029 continue; 1064 if (nfsi->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ATIME)) {
1030 status = NFS_STALE(inode) ? -ESTALE : 0; 1065 /* no */
1031 goto out_nowait; 1066 } else
1067 goto out;
1068 }
1032 } 1069 }
1033 NFS_FLAGS(inode) |= NFS_INO_REVALIDATING;
1034 1070
1035 /* Protect against RPC races by saving the change attribute */ 1071 /* Protect against RPC races by saving the change attribute */
1036 verifier = nfs_save_change_attribute(inode); 1072 verifier = nfs_save_change_attribute(inode);
@@ -1042,7 +1078,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1042 if (status == -ESTALE) { 1078 if (status == -ESTALE) {
1043 nfs_zap_caches(inode); 1079 nfs_zap_caches(inode);
1044 if (!S_ISDIR(inode->i_mode)) 1080 if (!S_ISDIR(inode->i_mode))
1045 NFS_FLAGS(inode) |= NFS_INO_STALE; 1081 set_bit(NFS_INO_STALE, &NFS_FLAGS(inode));
1046 } 1082 }
1047 goto out; 1083 goto out;
1048 } 1084 }
@@ -1054,25 +1090,30 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1054 (long long)NFS_FILEID(inode), status); 1090 (long long)NFS_FILEID(inode), status);
1055 goto out; 1091 goto out;
1056 } 1092 }
1057 flags = nfsi->flags; 1093 spin_lock(&inode->i_lock);
1058 nfsi->flags &= ~NFS_INO_REVAL_PAGECACHE; 1094 cache_validity = nfsi->cache_validity;
1095 nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
1096
1059 /* 1097 /*
1060 * We may need to keep the attributes marked as invalid if 1098 * We may need to keep the attributes marked as invalid if
1061 * we raced with nfs_end_attr_update(). 1099 * we raced with nfs_end_attr_update().
1062 */ 1100 */
1063 if (verifier == nfsi->cache_change_attribute) 1101 if (verifier == nfsi->cache_change_attribute)
1064 nfsi->flags &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME); 1102 nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME);
1065 /* Do the page cache invalidation */ 1103 spin_unlock(&inode->i_lock);
1104
1066 nfs_revalidate_mapping(inode, inode->i_mapping); 1105 nfs_revalidate_mapping(inode, inode->i_mapping);
1067 if (flags & NFS_INO_INVALID_ACL) 1106
1107 if (cache_validity & NFS_INO_INVALID_ACL)
1068 nfs_zap_acl_cache(inode); 1108 nfs_zap_acl_cache(inode);
1109
1069 dfprintk(PAGECACHE, "NFS: (%s/%Ld) revalidation complete\n", 1110 dfprintk(PAGECACHE, "NFS: (%s/%Ld) revalidation complete\n",
1070 inode->i_sb->s_id, 1111 inode->i_sb->s_id,
1071 (long long)NFS_FILEID(inode)); 1112 (long long)NFS_FILEID(inode));
1072 1113
1073out: 1114 out:
1074 NFS_FLAGS(inode) &= ~NFS_INO_REVALIDATING; 1115 nfs_wake_up_inode(inode);
1075 wake_up(&nfsi->nfs_i_wait); 1116
1076 out_nowait: 1117 out_nowait:
1077 unlock_kernel(); 1118 unlock_kernel();
1078 return status; 1119 return status;
@@ -1096,7 +1137,7 @@ int nfs_attribute_timeout(struct inode *inode)
1096 */ 1137 */
1097int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) 1138int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1098{ 1139{
1099 if (!(NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA)) 1140 if (!(NFS_I(inode)->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA))
1100 && !nfs_attribute_timeout(inode)) 1141 && !nfs_attribute_timeout(inode))
1101 return NFS_STALE(inode) ? -ESTALE : 0; 1142 return NFS_STALE(inode) ? -ESTALE : 0;
1102 return __nfs_revalidate_inode(server, inode); 1143 return __nfs_revalidate_inode(server, inode);
@@ -1111,19 +1152,23 @@ void nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
1111{ 1152{
1112 struct nfs_inode *nfsi = NFS_I(inode); 1153 struct nfs_inode *nfsi = NFS_I(inode);
1113 1154
1114 if (nfsi->flags & NFS_INO_INVALID_DATA) { 1155 if (nfsi->cache_validity & NFS_INO_INVALID_DATA) {
1115 if (S_ISREG(inode->i_mode)) { 1156 if (S_ISREG(inode->i_mode)) {
1116 if (filemap_fdatawrite(mapping) == 0) 1157 if (filemap_fdatawrite(mapping) == 0)
1117 filemap_fdatawait(mapping); 1158 filemap_fdatawait(mapping);
1118 nfs_wb_all(inode); 1159 nfs_wb_all(inode);
1119 } 1160 }
1120 invalidate_inode_pages2(mapping); 1161 invalidate_inode_pages2(mapping);
1121 nfsi->flags &= ~NFS_INO_INVALID_DATA; 1162
1163 spin_lock(&inode->i_lock);
1164 nfsi->cache_validity &= ~NFS_INO_INVALID_DATA;
1122 if (S_ISDIR(inode->i_mode)) { 1165 if (S_ISDIR(inode->i_mode)) {
1123 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); 1166 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
1124 /* This ensures we revalidate child dentries */ 1167 /* This ensures we revalidate child dentries */
1125 nfsi->cache_change_attribute++; 1168 nfsi->cache_change_attribute++;
1126 } 1169 }
1170 spin_unlock(&inode->i_lock);
1171
1127 dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n", 1172 dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n",
1128 inode->i_sb->s_id, 1173 inode->i_sb->s_id,
1129 (long long)NFS_FILEID(inode)); 1174 (long long)NFS_FILEID(inode));
@@ -1153,10 +1198,12 @@ void nfs_end_data_update(struct inode *inode)
1153 1198
1154 if (!nfs_have_delegation(inode, FMODE_READ)) { 1199 if (!nfs_have_delegation(inode, FMODE_READ)) {
1155 /* Mark the attribute cache for revalidation */ 1200 /* Mark the attribute cache for revalidation */
1156 nfsi->flags |= NFS_INO_INVALID_ATTR; 1201 spin_lock(&inode->i_lock);
1202 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1157 /* Directories and symlinks: invalidate page cache too */ 1203 /* Directories and symlinks: invalidate page cache too */
1158 if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) 1204 if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
1159 nfsi->flags |= NFS_INO_INVALID_DATA; 1205 nfsi->cache_validity |= NFS_INO_INVALID_DATA;
1206 spin_unlock(&inode->i_lock);
1160 } 1207 }
1161 nfsi->cache_change_attribute ++; 1208 nfsi->cache_change_attribute ++;
1162 atomic_dec(&nfsi->data_updates); 1209 atomic_dec(&nfsi->data_updates);
@@ -1181,6 +1228,8 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1181 if (nfs_have_delegation(inode, FMODE_READ)) 1228 if (nfs_have_delegation(inode, FMODE_READ))
1182 return 0; 1229 return 0;
1183 1230
1231 spin_lock(&inode->i_lock);
1232
1184 /* Are we in the process of updating data on the server? */ 1233 /* Are we in the process of updating data on the server? */
1185 data_unstable = nfs_caches_unstable(inode); 1234 data_unstable = nfs_caches_unstable(inode);
1186 1235
@@ -1189,19 +1238,23 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1189 && nfsi->change_attr == fattr->pre_change_attr) 1238 && nfsi->change_attr == fattr->pre_change_attr)
1190 nfsi->change_attr = fattr->change_attr; 1239 nfsi->change_attr = fattr->change_attr;
1191 if (nfsi->change_attr != fattr->change_attr) { 1240 if (nfsi->change_attr != fattr->change_attr) {
1192 nfsi->flags |= NFS_INO_INVALID_ATTR; 1241 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1193 if (!data_unstable) 1242 if (!data_unstable)
1194 nfsi->flags |= NFS_INO_REVAL_PAGECACHE; 1243 nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE;
1195 } 1244 }
1196 } 1245 }
1197 1246
1198 if ((fattr->valid & NFS_ATTR_FATTR) == 0) 1247 if ((fattr->valid & NFS_ATTR_FATTR) == 0) {
1248 spin_unlock(&inode->i_lock);
1199 return 0; 1249 return 0;
1250 }
1200 1251
1201 /* Has the inode gone and changed behind our back? */ 1252 /* Has the inode gone and changed behind our back? */
1202 if (nfsi->fileid != fattr->fileid 1253 if (nfsi->fileid != fattr->fileid
1203 || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) 1254 || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) {
1255 spin_unlock(&inode->i_lock);
1204 return -EIO; 1256 return -EIO;
1257 }
1205 1258
1206 cur_size = i_size_read(inode); 1259 cur_size = i_size_read(inode);
1207 new_isize = nfs_size_to_loff_t(fattr->size); 1260 new_isize = nfs_size_to_loff_t(fattr->size);
@@ -1216,30 +1269,31 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1216 1269
1217 /* Verify a few of the more important attributes */ 1270 /* Verify a few of the more important attributes */
1218 if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { 1271 if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) {
1219 nfsi->flags |= NFS_INO_INVALID_ATTR; 1272 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1220 if (!data_unstable) 1273 if (!data_unstable)
1221 nfsi->flags |= NFS_INO_REVAL_PAGECACHE; 1274 nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE;
1222 } 1275 }
1223 if (cur_size != new_isize) { 1276 if (cur_size != new_isize) {
1224 nfsi->flags |= NFS_INO_INVALID_ATTR; 1277 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1225 if (nfsi->npages == 0) 1278 if (nfsi->npages == 0)
1226 nfsi->flags |= NFS_INO_REVAL_PAGECACHE; 1279 nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE;
1227 } 1280 }
1228 1281
1229 /* Have any file permissions changed? */ 1282 /* Have any file permissions changed? */
1230 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) 1283 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
1231 || inode->i_uid != fattr->uid 1284 || inode->i_uid != fattr->uid
1232 || inode->i_gid != fattr->gid) 1285 || inode->i_gid != fattr->gid)
1233 nfsi->flags |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; 1286 nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
1234 1287
1235 /* Has the link count changed? */ 1288 /* Has the link count changed? */
1236 if (inode->i_nlink != fattr->nlink) 1289 if (inode->i_nlink != fattr->nlink)
1237 nfsi->flags |= NFS_INO_INVALID_ATTR; 1290 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1238 1291
1239 if (!timespec_equal(&inode->i_atime, &fattr->atime)) 1292 if (!timespec_equal(&inode->i_atime, &fattr->atime))
1240 nfsi->flags |= NFS_INO_INVALID_ATIME; 1293 nfsi->cache_validity |= NFS_INO_INVALID_ATIME;
1241 1294
1242 nfsi->read_cache_jiffies = fattr->timestamp; 1295 nfsi->read_cache_jiffies = fattr->timestamp;
1296 spin_unlock(&inode->i_lock);
1243 return 0; 1297 return 0;
1244} 1298}
1245 1299
@@ -1278,11 +1332,15 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1278 goto out_err; 1332 goto out_err;
1279 } 1333 }
1280 1334
1335 spin_lock(&inode->i_lock);
1336
1281 /* 1337 /*
1282 * Make sure the inode's type hasn't changed. 1338 * Make sure the inode's type hasn't changed.
1283 */ 1339 */
1284 if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) 1340 if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) {
1341 spin_unlock(&inode->i_lock);
1285 goto out_changed; 1342 goto out_changed;
1343 }
1286 1344
1287 /* 1345 /*
1288 * Update the read time so we don't revalidate too often. 1346 * Update the read time so we don't revalidate too often.
@@ -1373,8 +1431,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1373 || S_ISLNK(inode->i_mode))) 1431 || S_ISLNK(inode->i_mode)))
1374 invalid &= ~NFS_INO_INVALID_DATA; 1432 invalid &= ~NFS_INO_INVALID_DATA;
1375 if (!nfs_have_delegation(inode, FMODE_READ)) 1433 if (!nfs_have_delegation(inode, FMODE_READ))
1376 nfsi->flags |= invalid; 1434 nfsi->cache_validity |= invalid;
1377 1435
1436 spin_unlock(&inode->i_lock);
1378 return 0; 1437 return 0;
1379 out_changed: 1438 out_changed:
1380 /* 1439 /*
@@ -1391,7 +1450,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1391 */ 1450 */
1392 nfs_invalidate_inode(inode); 1451 nfs_invalidate_inode(inode);
1393 out_err: 1452 out_err:
1394 NFS_FLAGS(inode) |= NFS_INO_STALE; 1453 set_bit(NFS_INO_STALE, &NFS_FLAGS(inode));
1395 return -ESTALE; 1454 return -ESTALE;
1396} 1455}
1397 1456
@@ -1950,7 +2009,8 @@ static struct inode *nfs_alloc_inode(struct super_block *sb)
1950 nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); 2009 nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL);
1951 if (!nfsi) 2010 if (!nfsi)
1952 return NULL; 2011 return NULL;
1953 nfsi->flags = 0; 2012 nfsi->flags = 0UL;
2013 nfsi->cache_validity = 0UL;
1954#ifdef CONFIG_NFS_V3_ACL 2014#ifdef CONFIG_NFS_V3_ACL
1955 nfsi->acl_access = ERR_PTR(-EAGAIN); 2015 nfsi->acl_access = ERR_PTR(-EAGAIN);
1956 nfsi->acl_default = ERR_PTR(-EAGAIN); 2016 nfsi->acl_default = ERR_PTR(-EAGAIN);
@@ -1982,7 +2042,6 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
1982 nfsi->ndirty = 0; 2042 nfsi->ndirty = 0;
1983 nfsi->ncommit = 0; 2043 nfsi->ncommit = 0;
1984 nfsi->npages = 0; 2044 nfsi->npages = 0;
1985 init_waitqueue_head(&nfsi->nfs_i_wait);
1986 nfs4_init_once(nfsi); 2045 nfs4_init_once(nfsi);
1987 } 2046 }
1988} 2047}
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index 1b7a3ef2f813..6a5bbc0ae941 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -308,7 +308,9 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
308 nfs_begin_data_update(inode); 308 nfs_begin_data_update(inode);
309 status = rpc_call(server->client_acl, ACLPROC3_SETACL, 309 status = rpc_call(server->client_acl, ACLPROC3_SETACL,
310 &args, &fattr, 0); 310 &args, &fattr, 0);
311 NFS_FLAGS(inode) |= NFS_INO_INVALID_ACCESS; 311 spin_lock(&inode->i_lock);
312 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS;
313 spin_unlock(&inode->i_lock);
312 nfs_end_data_update(inode); 314 nfs_end_data_update(inode);
313 dprintk("NFS reply setacl: %d\n", status); 315 dprintk("NFS reply setacl: %d\n", status);
314 316
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 7851569b31c6..2681485cf2d0 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -120,6 +120,8 @@ nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
120 dprintk("NFS call setattr\n"); 120 dprintk("NFS call setattr\n");
121 fattr->valid = 0; 121 fattr->valid = 0;
122 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_SETATTR, &arg, fattr, 0); 122 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_SETATTR, &arg, fattr, 0);
123 if (status == 0)
124 nfs_setattr_update_inode(inode, sattr);
123 dprintk("NFS reply setattr: %d\n", status); 125 dprintk("NFS reply setattr: %d\n", status);
124 return status; 126 return status;
125} 127}
@@ -370,6 +372,8 @@ again:
370 * not sure this buys us anything (and I'd have 372 * not sure this buys us anything (and I'd have
371 * to revamp the NFSv3 XDR code) */ 373 * to revamp the NFSv3 XDR code) */
372 status = nfs3_proc_setattr(dentry, &fattr, sattr); 374 status = nfs3_proc_setattr(dentry, &fattr, sattr);
375 if (status == 0)
376 nfs_setattr_update_inode(dentry->d_inode, sattr);
373 nfs_refresh_inode(dentry->d_inode, &fattr); 377 nfs_refresh_inode(dentry->d_inode, &fattr);
374 dprintk("NFS reply setattr (post-create): %d\n", status); 378 dprintk("NFS reply setattr (post-create): %d\n", status);
375 } 379 }
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 1b76f80aedb9..0c5a308e4963 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -753,6 +753,7 @@ static int _nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr,
753 .rpc_argp = &arg, 753 .rpc_argp = &arg,
754 .rpc_resp = &res, 754 .rpc_resp = &res,
755 }; 755 };
756 int status;
756 757
757 fattr->valid = 0; 758 fattr->valid = 0;
758 759
@@ -762,7 +763,8 @@ static int _nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr,
762 } else 763 } else
763 memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid)); 764 memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid));
764 765
765 return rpc_call_sync(server->client, &msg, 0); 766 status = rpc_call_sync(server->client, &msg, 0);
767 return status;
766} 768}
767 769
768static int nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr, 770static int nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr,
@@ -1145,6 +1147,8 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
1145 1147
1146 status = nfs4_do_setattr(NFS_SERVER(inode), fattr, 1148 status = nfs4_do_setattr(NFS_SERVER(inode), fattr,
1147 NFS_FH(inode), sattr, state); 1149 NFS_FH(inode), sattr, state);
1150 if (status == 0)
1151 nfs_setattr_update_inode(inode, sattr);
1148 if (state != NULL) 1152 if (state != NULL)
1149 nfs4_close_state(state, FMODE_WRITE); 1153 nfs4_close_state(state, FMODE_WRITE);
1150 put_rpccred(cred); 1154 put_rpccred(cred);
@@ -1449,8 +1453,10 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
1449 struct nfs_fattr fattr; 1453 struct nfs_fattr fattr;
1450 status = nfs4_do_setattr(NFS_SERVER(dir), &fattr, 1454 status = nfs4_do_setattr(NFS_SERVER(dir), &fattr,
1451 NFS_FH(state->inode), sattr, state); 1455 NFS_FH(state->inode), sattr, state);
1452 if (status == 0) 1456 if (status == 0) {
1457 nfs_setattr_update_inode(state->inode, sattr);
1453 goto out; 1458 goto out;
1459 }
1454 } else if (flags != 0) 1460 } else if (flags != 0)
1455 goto out; 1461 goto out;
1456 nfs4_close_state(state, flags); 1462 nfs4_close_state(state, flags);
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index cedf636bcf3c..be23c3fb9260 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -114,6 +114,8 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
114 dprintk("NFS call setattr\n"); 114 dprintk("NFS call setattr\n");
115 fattr->valid = 0; 115 fattr->valid = 0;
116 status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0); 116 status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0);
117 if (status == 0)
118 nfs_setattr_update_inode(inode, sattr);
117 dprintk("NFS reply setattr: %d\n", status); 119 dprintk("NFS reply setattr: %d\n", status);
118 return status; 120 return status;
119} 121}
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 6f866b8aa2d5..6ceb1d471f20 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -140,7 +140,9 @@ static int nfs_readpage_sync(struct nfs_open_context *ctx, struct inode *inode,
140 if (rdata->res.eof != 0 || result == 0) 140 if (rdata->res.eof != 0 || result == 0)
141 break; 141 break;
142 } while (count); 142 } while (count);
143 NFS_FLAGS(inode) |= NFS_INO_INVALID_ATIME; 143 spin_lock(&inode->i_lock);
144 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
145 spin_unlock(&inode->i_lock);
144 146
145 if (count) 147 if (count)
146 memclear_highpage_flush(page, rdata->args.pgbase, count); 148 memclear_highpage_flush(page, rdata->args.pgbase, count);
@@ -473,7 +475,9 @@ void nfs_readpage_result(struct rpc_task *task)
473 } 475 }
474 task->tk_status = -EIO; 476 task->tk_status = -EIO;
475 } 477 }
476 NFS_FLAGS(data->inode) |= NFS_INO_INVALID_ATIME; 478 spin_lock(&data->inode->i_lock);
479 NFS_I(data->inode)->cache_validity |= NFS_INO_INVALID_ATIME;
480 spin_unlock(&data->inode->i_lock);
477 data->complete(data, status); 481 data->complete(data, status);
478} 482}
479 483
diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c
index 35f106599144..18dc95b0b646 100644
--- a/fs/nfs/symlink.c
+++ b/fs/nfs/symlink.c
@@ -27,26 +27,14 @@
27 27
28/* Symlink caching in the page cache is even more simplistic 28/* Symlink caching in the page cache is even more simplistic
29 * and straight-forward than readdir caching. 29 * and straight-forward than readdir caching.
30 *
31 * At the beginning of the page we store pointer to struct page in question,
32 * simplifying nfs_put_link() (if inode got invalidated we can't find the page
33 * to be freed via pagecache lookup).
34 * The NUL-terminated string follows immediately thereafter.
35 */ 30 */
36 31
37struct nfs_symlink {
38 struct page *page;
39 char body[0];
40};
41
42static int nfs_symlink_filler(struct inode *inode, struct page *page) 32static int nfs_symlink_filler(struct inode *inode, struct page *page)
43{ 33{
44 const unsigned int pgbase = offsetof(struct nfs_symlink, body);
45 const unsigned int pglen = PAGE_SIZE - pgbase;
46 int error; 34 int error;
47 35
48 lock_kernel(); 36 lock_kernel();
49 error = NFS_PROTO(inode)->readlink(inode, page, pgbase, pglen); 37 error = NFS_PROTO(inode)->readlink(inode, page, 0, PAGE_SIZE);
50 unlock_kernel(); 38 unlock_kernel();
51 if (error < 0) 39 if (error < 0)
52 goto error; 40 goto error;
@@ -60,11 +48,10 @@ error:
60 return -EIO; 48 return -EIO;
61} 49}
62 50
63static int nfs_follow_link(struct dentry *dentry, struct nameidata *nd) 51static void *nfs_follow_link(struct dentry *dentry, struct nameidata *nd)
64{ 52{
65 struct inode *inode = dentry->d_inode; 53 struct inode *inode = dentry->d_inode;
66 struct page *page; 54 struct page *page;
67 struct nfs_symlink *p;
68 void *err = ERR_PTR(nfs_revalidate_inode(NFS_SERVER(inode), inode)); 55 void *err = ERR_PTR(nfs_revalidate_inode(NFS_SERVER(inode), inode));
69 if (err) 56 if (err)
70 goto read_failed; 57 goto read_failed;
@@ -78,28 +65,20 @@ static int nfs_follow_link(struct dentry *dentry, struct nameidata *nd)
78 err = ERR_PTR(-EIO); 65 err = ERR_PTR(-EIO);
79 goto getlink_read_error; 66 goto getlink_read_error;
80 } 67 }
81 p = kmap(page); 68 nd_set_link(nd, kmap(page));
82 p->page = page; 69 return page;
83 nd_set_link(nd, p->body);
84 return 0;
85 70
86getlink_read_error: 71getlink_read_error:
87 page_cache_release(page); 72 page_cache_release(page);
88read_failed: 73read_failed:
89 nd_set_link(nd, err); 74 nd_set_link(nd, err);
90 return 0; 75 return NULL;
91} 76}
92 77
93static void nfs_put_link(struct dentry *dentry, struct nameidata *nd) 78static void nfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
94{ 79{
95 char *s = nd_get_link(nd); 80 if (cookie) {
96 if (!IS_ERR(s)) { 81 struct page *page = cookie;
97 struct nfs_symlink *p;
98 struct page *page;
99
100 p = container_of(s, struct nfs_symlink, body[0]);
101 page = p->page;
102
103 kunmap(page); 82 kunmap(page);
104 page_cache_release(page); 83 page_cache_release(page);
105 } 84 }
diff --git a/fs/nfs_common/nfsacl.c b/fs/nfs_common/nfsacl.c
index 18c58c32e326..251e5a1bb1c4 100644
--- a/fs/nfs_common/nfsacl.c
+++ b/fs/nfs_common/nfsacl.c
@@ -239,6 +239,7 @@ nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
239 if (xdr_decode_word(buf, base, &entries) || 239 if (xdr_decode_word(buf, base, &entries) ||
240 entries > NFS_ACL_MAX_ENTRIES) 240 entries > NFS_ACL_MAX_ENTRIES)
241 return -EINVAL; 241 return -EINVAL;
242 nfsacl_desc.desc.array_maxlen = entries;
242 err = xdr_decode_array2(buf, base + 4, &nfsacl_desc.desc); 243 err = xdr_decode_array2(buf, base + 4, &nfsacl_desc.desc);
243 if (err) 244 if (err)
244 return err; 245 return err;
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 07b9a065e9da..1697539a7171 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -287,6 +287,7 @@ out:
287 svc_exit_thread(rqstp); 287 svc_exit_thread(rqstp);
288 288
289 /* Release module */ 289 /* Release module */
290 unlock_kernel();
290 module_put_and_exit(0); 291 module_put_and_exit(0);
291} 292}
292 293
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
index 9709fac6531d..9eecc9939dfe 100644
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -174,6 +174,9 @@ ToDo/Notes:
174 fact that the vfs and ntfs inodes are one struct in memory to find 174 fact that the vfs and ntfs inodes are one struct in memory to find
175 the ntfs inode in memory if present. Also, the ntfs inode has its 175 the ntfs inode in memory if present. Also, the ntfs inode has its
176 own locking so it does not matter if the vfs inode is locked. 176 own locking so it does not matter if the vfs inode is locked.
177 - Fix bug in mft record writing where we forgot to set the device in
178 the buffers when mapping them after the VM had discarded them.
179 Thanks to Martin MOKREJÅ  for the bug report.
177 180
1782.1.22 - Many bug and race fixes and error handling improvements. 1812.1.22 - Many bug and race fixes and error handling improvements.
179 182
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 3f43bfe6184e..78adad7a988d 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -924,6 +924,7 @@ static int ntfs_write_mst_block(struct page *page,
924 LCN lcn; 924 LCN lcn;
925 unsigned int vcn_ofs; 925 unsigned int vcn_ofs;
926 926
927 bh->b_bdev = vol->sb->s_bdev;
927 /* Obtain the vcn and offset of the current block. */ 928 /* Obtain the vcn and offset of the current block. */
928 vcn = (VCN)block << bh_size_bits; 929 vcn = (VCN)block << bh_size_bits;
929 vcn_ofs = vcn & vol->cluster_size_mask; 930 vcn_ofs = vcn & vol->cluster_size_mask;
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index ac9ff39aa834..317f7c679fd3 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -533,6 +533,7 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no,
533 LCN lcn; 533 LCN lcn;
534 unsigned int vcn_ofs; 534 unsigned int vcn_ofs;
535 535
536 bh->b_bdev = vol->sb->s_bdev;
536 /* Obtain the vcn and offset of the current block. */ 537 /* Obtain the vcn and offset of the current block. */
537 vcn = ((VCN)mft_no << vol->mft_record_size_bits) + 538 vcn = ((VCN)mft_no << vol->mft_record_size_bits) +
538 (block_start - m_start); 539 (block_start - m_start);
@@ -725,6 +726,7 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync)
725 LCN lcn; 726 LCN lcn;
726 unsigned int vcn_ofs; 727 unsigned int vcn_ofs;
727 728
729 bh->b_bdev = vol->sb->s_bdev;
728 /* Obtain the vcn and offset of the current block. */ 730 /* Obtain the vcn and offset of the current block. */
729 vcn = ((VCN)ni->mft_no << vol->mft_record_size_bits) + 731 vcn = ((VCN)ni->mft_no << vol->mft_record_size_bits) +
730 (block_start - m_start); 732 (block_start - m_start);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index ace151fa4878..491f2d9f89ac 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -890,7 +890,7 @@ static struct file_operations proc_seccomp_operations = {
890}; 890};
891#endif /* CONFIG_SECCOMP */ 891#endif /* CONFIG_SECCOMP */
892 892
893static int proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) 893static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
894{ 894{
895 struct inode *inode = dentry->d_inode; 895 struct inode *inode = dentry->d_inode;
896 int error = -EACCES; 896 int error = -EACCES;
@@ -907,7 +907,7 @@ static int proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
907 error = PROC_I(inode)->op.proc_get_link(inode, &nd->dentry, &nd->mnt); 907 error = PROC_I(inode)->op.proc_get_link(inode, &nd->dentry, &nd->mnt);
908 nd->last_type = LAST_BIND; 908 nd->last_type = LAST_BIND;
909out: 909out:
910 return error; 910 return ERR_PTR(error);
911} 911}
912 912
913static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt, 913static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt,
@@ -1692,11 +1692,11 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
1692 return vfs_readlink(dentry,buffer,buflen,tmp); 1692 return vfs_readlink(dentry,buffer,buflen,tmp);
1693} 1693}
1694 1694
1695static int proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) 1695static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
1696{ 1696{
1697 char tmp[30]; 1697 char tmp[30];
1698 sprintf(tmp, "%d", current->tgid); 1698 sprintf(tmp, "%d", current->tgid);
1699 return vfs_follow_link(nd,tmp); 1699 return ERR_PTR(vfs_follow_link(nd,tmp));
1700} 1700}
1701 1701
1702static struct inode_operations proc_self_inode_operations = { 1702static struct inode_operations proc_self_inode_operations = {
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 6c6315d04028..abe8920313fb 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -329,10 +329,10 @@ static void release_inode_number(unsigned int inum)
329 spin_unlock(&proc_inum_lock); 329 spin_unlock(&proc_inum_lock);
330} 330}
331 331
332static int proc_follow_link(struct dentry *dentry, struct nameidata *nd) 332static void *proc_follow_link(struct dentry *dentry, struct nameidata *nd)
333{ 333{
334 nd_set_link(nd, PDE(dentry->d_inode)->data); 334 nd_set_link(nd, PDE(dentry->d_inode)->data);
335 return 0; 335 return NULL;
336} 336}
337 337
338static struct inode_operations proc_link_inode_operations = { 338static struct inode_operations proc_link_inode_operations = {
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index d9f614a57731..ff291c973a56 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1985,7 +1985,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1985 * iput doesn't deadlock in reiserfs_delete_xattrs. The locking 1985 * iput doesn't deadlock in reiserfs_delete_xattrs. The locking
1986 * code really needs to be reworked, but this will take care of it 1986 * code really needs to be reworked, but this will take care of it
1987 * for now. -jeffm */ 1987 * for now. -jeffm */
1988 if (REISERFS_I(dir)->i_acl_default) { 1988 if (REISERFS_I(dir)->i_acl_default && !IS_ERR(REISERFS_I(dir)->i_acl_default)) {
1989 reiserfs_write_unlock_xattrs(dir->i_sb); 1989 reiserfs_write_unlock_xattrs(dir->i_sb);
1990 iput(inode); 1990 iput(inode);
1991 reiserfs_write_lock_xattrs(dir->i_sb); 1991 reiserfs_write_lock_xattrs(dir->i_sb);
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index a20bbc1642dc..3549067c42d9 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -593,6 +593,9 @@ static int new_inode_init(struct inode *inode, struct inode *dir, int mode)
593 */ 593 */
594 inode->i_uid = current->fsuid; 594 inode->i_uid = current->fsuid;
595 inode->i_mode = mode; 595 inode->i_mode = mode;
596 /* Make inode invalid - just in case we are going to drop it before
597 * the initialization happens */
598 INODE_PKEY(inode)->k_objectid = 0;
596 599
597 if (dir->i_mode & S_ISGID) { 600 if (dir->i_mode & S_ISGID) {
598 inode->i_gid = dir->i_gid; 601 inode->i_gid = dir->i_gid;
diff --git a/fs/smbfs/symlink.c b/fs/smbfs/symlink.c
index 8b069e06433d..0c64bc3a0127 100644
--- a/fs/smbfs/symlink.c
+++ b/fs/smbfs/symlink.c
@@ -34,7 +34,7 @@ int smb_symlink(struct inode *inode, struct dentry *dentry, const char *oldname)
34 return smb_proc_symlink(server_from_dentry(dentry), dentry, oldname); 34 return smb_proc_symlink(server_from_dentry(dentry), dentry, oldname);
35} 35}
36 36
37static int smb_follow_link(struct dentry *dentry, struct nameidata *nd) 37static void *smb_follow_link(struct dentry *dentry, struct nameidata *nd)
38{ 38{
39 char *link = __getname(); 39 char *link = __getname();
40 DEBUG1("followlink of %s/%s\n", DENTRY_PATH(dentry)); 40 DEBUG1("followlink of %s/%s\n", DENTRY_PATH(dentry));
@@ -52,10 +52,10 @@ static int smb_follow_link(struct dentry *dentry, struct nameidata *nd)
52 } 52 }
53 } 53 }
54 nd_set_link(nd, link); 54 nd_set_link(nd, link);
55 return 0; 55 return NULL;
56} 56}
57 57
58static void smb_put_link(struct dentry *dentry, struct nameidata *nd) 58static void smb_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
59{ 59{
60 char *s = nd_get_link(nd); 60 char *s = nd_get_link(nd);
61 if (!IS_ERR(s)) 61 if (!IS_ERR(s))
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index d727dc960634..970a33f03299 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -228,6 +228,10 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name)
228 struct sysfs_dirent * sd; 228 struct sysfs_dirent * sd;
229 struct sysfs_dirent * parent_sd = dir->d_fsdata; 229 struct sysfs_dirent * parent_sd = dir->d_fsdata;
230 230
231 if (dir->d_inode == NULL)
232 /* no inode means this hasn't been made visible yet */
233 return;
234
231 down(&dir->d_inode->i_sem); 235 down(&dir->d_inode->i_sem);
232 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { 236 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
233 if (!sd->s_element) 237 if (!sd->s_element)
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index fae57c83a722..de402fa915f2 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -151,17 +151,17 @@ static int sysfs_getlink(struct dentry *dentry, char * path)
151 151
152} 152}
153 153
154static int sysfs_follow_link(struct dentry *dentry, struct nameidata *nd) 154static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
155{ 155{
156 int error = -ENOMEM; 156 int error = -ENOMEM;
157 unsigned long page = get_zeroed_page(GFP_KERNEL); 157 unsigned long page = get_zeroed_page(GFP_KERNEL);
158 if (page) 158 if (page)
159 error = sysfs_getlink(dentry, (char *) page); 159 error = sysfs_getlink(dentry, (char *) page);
160 nd_set_link(nd, error ? ERR_PTR(error) : (char *)page); 160 nd_set_link(nd, error ? ERR_PTR(error) : (char *)page);
161 return 0; 161 return NULL;
162} 162}
163 163
164static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd) 164static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
165{ 165{
166 char *page = nd_get_link(nd); 166 char *page = nd_get_link(nd);
167 if (!IS_ERR(page)) 167 if (!IS_ERR(page))
diff --git a/fs/sysv/symlink.c b/fs/sysv/symlink.c
index ed637db2dcb1..b85ce61d635c 100644
--- a/fs/sysv/symlink.c
+++ b/fs/sysv/symlink.c
@@ -8,10 +8,10 @@
8#include "sysv.h" 8#include "sysv.h"
9#include <linux/namei.h> 9#include <linux/namei.h>
10 10
11static int sysv_follow_link(struct dentry *dentry, struct nameidata *nd) 11static void *sysv_follow_link(struct dentry *dentry, struct nameidata *nd)
12{ 12{
13 nd_set_link(nd, (char *)SYSV_I(dentry->d_inode)->i_data); 13 nd_set_link(nd, (char *)SYSV_I(dentry->d_inode)->i_data);
14 return 0; 14 return NULL;
15} 15}
16 16
17struct inode_operations sysv_fast_symlink_inode_operations = { 17struct inode_operations sysv_fast_symlink_inode_operations = {
diff --git a/fs/ufs/symlink.c b/fs/ufs/symlink.c
index a0e49149098f..337512ed5781 100644
--- a/fs/ufs/symlink.c
+++ b/fs/ufs/symlink.c
@@ -29,11 +29,11 @@
29#include <linux/namei.h> 29#include <linux/namei.h>
30#include <linux/ufs_fs.h> 30#include <linux/ufs_fs.h>
31 31
32static int ufs_follow_link(struct dentry *dentry, struct nameidata *nd) 32static void *ufs_follow_link(struct dentry *dentry, struct nameidata *nd)
33{ 33{
34 struct ufs_inode_info *p = UFS_I(dentry->d_inode); 34 struct ufs_inode_info *p = UFS_I(dentry->d_inode);
35 nd_set_link(nd, (char*)p->i_u1.i_symlink); 35 nd_set_link(nd, (char*)p->i_u1.i_symlink);
36 return 0; 36 return NULL;
37} 37}
38 38
39struct inode_operations ufs_fast_symlink_inode_operations = { 39struct inode_operations ufs_fast_symlink_inode_operations = {
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 407e99359391..f252605514eb 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -374,7 +374,7 @@ linvfs_rename(
374 * we need to be very careful about how much stack we use. 374 * we need to be very careful about how much stack we use.
375 * uio is kmalloced for this reason... 375 * uio is kmalloced for this reason...
376 */ 376 */
377STATIC int 377STATIC void *
378linvfs_follow_link( 378linvfs_follow_link(
379 struct dentry *dentry, 379 struct dentry *dentry,
380 struct nameidata *nd) 380 struct nameidata *nd)
@@ -391,14 +391,14 @@ linvfs_follow_link(
391 link = (char *)kmalloc(MAXNAMELEN+1, GFP_KERNEL); 391 link = (char *)kmalloc(MAXNAMELEN+1, GFP_KERNEL);
392 if (!link) { 392 if (!link) {
393 nd_set_link(nd, ERR_PTR(-ENOMEM)); 393 nd_set_link(nd, ERR_PTR(-ENOMEM));
394 return 0; 394 return NULL;
395 } 395 }
396 396
397 uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL); 397 uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL);
398 if (!uio) { 398 if (!uio) {
399 kfree(link); 399 kfree(link);
400 nd_set_link(nd, ERR_PTR(-ENOMEM)); 400 nd_set_link(nd, ERR_PTR(-ENOMEM));
401 return 0; 401 return NULL;
402 } 402 }
403 403
404 vp = LINVFS_GET_VP(dentry->d_inode); 404 vp = LINVFS_GET_VP(dentry->d_inode);
@@ -422,10 +422,10 @@ linvfs_follow_link(
422 kfree(uio); 422 kfree(uio);
423 423
424 nd_set_link(nd, link); 424 nd_set_link(nd, link);
425 return 0; 425 return NULL;
426} 426}
427 427
428static void linvfs_put_link(struct dentry *dentry, struct nameidata *nd) 428static void linvfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
429{ 429{
430 char *s = nd_get_link(nd); 430 char *s = nd_get_link(nd);
431 if (!IS_ERR(s)) 431 if (!IS_ERR(s))