aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-12 17:49:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-12 17:49:50 -0400
commit5166701b368caea89d57b14bf41cf39e819dad51 (patch)
treec73b9d4860809e3afa9359be9d03ba2d8d98a18e /fs
parent0a7418f5f569512e98789c439198eed4b507cce3 (diff)
parenta786c06d9f2719203c00b3d97b21f9a96980d0b5 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: "The first vfs pile, with deep apologies for being very late in this window. Assorted cleanups and fixes, plus a large preparatory part of iov_iter work. There's a lot more of that, but it'll probably go into the next merge window - it *does* shape up nicely, removes a lot of boilerplate, gets rid of locking inconsistencie between aio_write and splice_write and I hope to get Kent's direct-io rewrite merged into the same queue, but some of the stuff after this point is having (mostly trivial) conflicts with the things already merged into mainline and with some I want more testing. This one passes LTP and xfstests without regressions, in addition to usual beating. BTW, readahead02 in ltp syscalls testsuite has started giving failures since "mm/readahead.c: fix readahead failure for memoryless NUMA nodes and limit readahead pages" - might be a false positive, might be a real regression..." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits) missing bits of "splice: fix racy pipe->buffers uses" cifs: fix the race in cifs_writev() ceph_sync_{,direct_}write: fix an oops on ceph_osdc_new_request() failure kill generic_file_buffered_write() ocfs2_file_aio_write(): switch to generic_perform_write() ceph_aio_write(): switch to generic_perform_write() xfs_file_buffered_aio_write(): switch to generic_perform_write() export generic_perform_write(), start getting rid of generic_file_buffer_write() generic_file_direct_write(): get rid of ppos argument btrfs_file_aio_write(): get rid of ppos kill the 5th argument of generic_file_buffered_write() kill the 4th argument of __generic_file_aio_write() lustre: don't open-code kernel_recvmsg() ocfs2: don't open-code kernel_recvmsg() drbd: don't open-code kernel_recvmsg() constify blk_rq_map_user_iov() and friends lustre: switch to kernel_sendmsg() ocfs2: don't open-code kernel_sendmsg() take iov_iter stuff to mm/iov_iter.c process_vm_access: tidy up a bit ...
Diffstat (limited to 'fs')
-rw-r--r--fs/bio.c10
-rw-r--r--fs/block_dev.c2
-rw-r--r--fs/btrfs/file.c16
-rw-r--r--fs/buffer.c6
-rw-r--r--fs/cachefiles/bind.c1
-rw-r--r--fs/cachefiles/namei.c3
-rw-r--r--fs/ceph/file.c12
-rw-r--r--fs/cifs/cifsfs.c1
-rw-r--r--fs/cifs/file.c128
-rw-r--r--fs/exec.c2
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/file.c11
-rw-r--r--fs/file_table.c43
-rw-r--r--fs/fuse/dev.c14
-rw-r--r--fs/fuse/file.c5
-rw-r--r--fs/mount.h5
-rw-r--r--fs/namei.c67
-rw-r--r--fs/namespace.c56
-rw-r--r--fs/ncpfs/inode.c50
-rw-r--r--fs/ncpfs/ncp_fs_sb.h2
-rw-r--r--fs/ntfs/inode.c2
-rw-r--r--fs/ocfs2/cluster/tcp.c49
-rw-r--r--fs/ocfs2/file.c9
-rw-r--r--fs/open.c68
-rw-r--r--fs/pipe.c133
-rw-r--r--fs/pnode.c198
-rw-r--r--fs/pnode.h3
-rw-r--r--fs/proc/namespaces.c14
-rw-r--r--fs/proc/self.c2
-rw-r--r--fs/proc_namespace.c1
-rw-r--r--fs/splice.c126
-rw-r--r--fs/udf/file.c2
-rw-r--r--fs/xfs/xfs_file.c13
-rw-r--r--fs/xfs/xfs_ioctl.c28
34 files changed, 385 insertions, 699 deletions
diff --git a/fs/bio.c b/fs/bio.c
index b1bc722b89aa..6f0362b77806 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1002,7 +1002,7 @@ struct bio_map_data {
1002}; 1002};
1003 1003
1004static void bio_set_map_data(struct bio_map_data *bmd, struct bio *bio, 1004static void bio_set_map_data(struct bio_map_data *bmd, struct bio *bio,
1005 struct sg_iovec *iov, int iov_count, 1005 const struct sg_iovec *iov, int iov_count,
1006 int is_our_pages) 1006 int is_our_pages)
1007{ 1007{
1008 memcpy(bmd->sgvecs, iov, sizeof(struct sg_iovec) * iov_count); 1008 memcpy(bmd->sgvecs, iov, sizeof(struct sg_iovec) * iov_count);
@@ -1022,7 +1022,7 @@ static struct bio_map_data *bio_alloc_map_data(int nr_segs,
1022 sizeof(struct sg_iovec) * iov_count, gfp_mask); 1022 sizeof(struct sg_iovec) * iov_count, gfp_mask);
1023} 1023}
1024 1024
1025static int __bio_copy_iov(struct bio *bio, struct sg_iovec *iov, int iov_count, 1025static int __bio_copy_iov(struct bio *bio, const struct sg_iovec *iov, int iov_count,
1026 int to_user, int from_user, int do_free_page) 1026 int to_user, int from_user, int do_free_page)
1027{ 1027{
1028 int ret = 0, i; 1028 int ret = 0, i;
@@ -1120,7 +1120,7 @@ EXPORT_SYMBOL(bio_uncopy_user);
1120 */ 1120 */
1121struct bio *bio_copy_user_iov(struct request_queue *q, 1121struct bio *bio_copy_user_iov(struct request_queue *q,
1122 struct rq_map_data *map_data, 1122 struct rq_map_data *map_data,
1123 struct sg_iovec *iov, int iov_count, 1123 const struct sg_iovec *iov, int iov_count,
1124 int write_to_vm, gfp_t gfp_mask) 1124 int write_to_vm, gfp_t gfp_mask)
1125{ 1125{
1126 struct bio_map_data *bmd; 1126 struct bio_map_data *bmd;
@@ -1259,7 +1259,7 @@ EXPORT_SYMBOL(bio_copy_user);
1259 1259
1260static struct bio *__bio_map_user_iov(struct request_queue *q, 1260static struct bio *__bio_map_user_iov(struct request_queue *q,
1261 struct block_device *bdev, 1261 struct block_device *bdev,
1262 struct sg_iovec *iov, int iov_count, 1262 const struct sg_iovec *iov, int iov_count,
1263 int write_to_vm, gfp_t gfp_mask) 1263 int write_to_vm, gfp_t gfp_mask)
1264{ 1264{
1265 int i, j; 1265 int i, j;
@@ -1407,7 +1407,7 @@ EXPORT_SYMBOL(bio_map_user);
1407 * device. Returns an error pointer in case of error. 1407 * device. Returns an error pointer in case of error.
1408 */ 1408 */
1409struct bio *bio_map_user_iov(struct request_queue *q, struct block_device *bdev, 1409struct bio *bio_map_user_iov(struct request_queue *q, struct block_device *bdev,
1410 struct sg_iovec *iov, int iov_count, 1410 const struct sg_iovec *iov, int iov_count,
1411 int write_to_vm, gfp_t gfp_mask) 1411 int write_to_vm, gfp_t gfp_mask)
1412{ 1412{
1413 struct bio *bio; 1413 struct bio *bio;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index ba0d2b05bb78..552a8d13bc32 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1518,7 +1518,7 @@ ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
1518 BUG_ON(iocb->ki_pos != pos); 1518 BUG_ON(iocb->ki_pos != pos);
1519 1519
1520 blk_start_plug(&plug); 1520 blk_start_plug(&plug);
1521 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 1521 ret = __generic_file_aio_write(iocb, iov, nr_segs);
1522 if (ret > 0) { 1522 if (ret > 0) {
1523 ssize_t err; 1523 ssize_t err;
1524 1524
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index c5998477fe60..eb742c07e7a4 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -425,13 +425,8 @@ static noinline int btrfs_copy_from_user(loff_t pos, int num_pages,
425 struct page *page = prepared_pages[pg]; 425 struct page *page = prepared_pages[pg];
426 /* 426 /*
427 * Copy data from userspace to the current page 427 * Copy data from userspace to the current page
428 *
429 * Disable pagefault to avoid recursive lock since
430 * the pages are already locked
431 */ 428 */
432 pagefault_disable();
433 copied = iov_iter_copy_from_user_atomic(page, i, offset, count); 429 copied = iov_iter_copy_from_user_atomic(page, i, offset, count);
434 pagefault_enable();
435 430
436 /* Flush processor's dcache for this page */ 431 /* Flush processor's dcache for this page */
437 flush_dcache_page(page); 432 flush_dcache_page(page);
@@ -1665,7 +1660,7 @@ again:
1665static ssize_t __btrfs_direct_write(struct kiocb *iocb, 1660static ssize_t __btrfs_direct_write(struct kiocb *iocb,
1666 const struct iovec *iov, 1661 const struct iovec *iov,
1667 unsigned long nr_segs, loff_t pos, 1662 unsigned long nr_segs, loff_t pos,
1668 loff_t *ppos, size_t count, size_t ocount) 1663 size_t count, size_t ocount)
1669{ 1664{
1670 struct file *file = iocb->ki_filp; 1665 struct file *file = iocb->ki_filp;
1671 struct iov_iter i; 1666 struct iov_iter i;
@@ -1674,7 +1669,7 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb,
1674 loff_t endbyte; 1669 loff_t endbyte;
1675 int err; 1670 int err;
1676 1671
1677 written = generic_file_direct_write(iocb, iov, &nr_segs, pos, ppos, 1672 written = generic_file_direct_write(iocb, iov, &nr_segs, pos,
1678 count, ocount); 1673 count, ocount);
1679 1674
1680 if (written < 0 || written == count) 1675 if (written < 0 || written == count)
@@ -1693,7 +1688,7 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb,
1693 if (err) 1688 if (err)
1694 goto out; 1689 goto out;
1695 written += written_buffered; 1690 written += written_buffered;
1696 *ppos = pos + written_buffered; 1691 iocb->ki_pos = pos + written_buffered;
1697 invalidate_mapping_pages(file->f_mapping, pos >> PAGE_CACHE_SHIFT, 1692 invalidate_mapping_pages(file->f_mapping, pos >> PAGE_CACHE_SHIFT,
1698 endbyte >> PAGE_CACHE_SHIFT); 1693 endbyte >> PAGE_CACHE_SHIFT);
1699out: 1694out:
@@ -1725,7 +1720,6 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1725 struct file *file = iocb->ki_filp; 1720 struct file *file = iocb->ki_filp;
1726 struct inode *inode = file_inode(file); 1721 struct inode *inode = file_inode(file);
1727 struct btrfs_root *root = BTRFS_I(inode)->root; 1722 struct btrfs_root *root = BTRFS_I(inode)->root;
1728 loff_t *ppos = &iocb->ki_pos;
1729 u64 start_pos; 1723 u64 start_pos;
1730 u64 end_pos; 1724 u64 end_pos;
1731 ssize_t num_written = 0; 1725 ssize_t num_written = 0;
@@ -1796,7 +1790,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1796 1790
1797 if (unlikely(file->f_flags & O_DIRECT)) { 1791 if (unlikely(file->f_flags & O_DIRECT)) {
1798 num_written = __btrfs_direct_write(iocb, iov, nr_segs, 1792 num_written = __btrfs_direct_write(iocb, iov, nr_segs,
1799 pos, ppos, count, ocount); 1793 pos, count, ocount);
1800 } else { 1794 } else {
1801 struct iov_iter i; 1795 struct iov_iter i;
1802 1796
@@ -1804,7 +1798,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1804 1798
1805 num_written = __btrfs_buffered_write(file, &i, pos); 1799 num_written = __btrfs_buffered_write(file, &i, pos);
1806 if (num_written > 0) 1800 if (num_written > 0)
1807 *ppos = pos + num_written; 1801 iocb->ki_pos = pos + num_written;
1808 } 1802 }
1809 1803
1810 mutex_unlock(&inode->i_mutex); 1804 mutex_unlock(&inode->i_mutex);
diff --git a/fs/buffer.c b/fs/buffer.c
index 8c53a2b15ecb..9ddb9fc7d923 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2114,8 +2114,8 @@ EXPORT_SYMBOL(generic_write_end);
2114 * Returns true if all buffers which correspond to a file portion 2114 * Returns true if all buffers which correspond to a file portion
2115 * we want to read are uptodate. 2115 * we want to read are uptodate.
2116 */ 2116 */
2117int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc, 2117int block_is_partially_uptodate(struct page *page, unsigned long from,
2118 unsigned long from) 2118 unsigned long count)
2119{ 2119{
2120 unsigned block_start, block_end, blocksize; 2120 unsigned block_start, block_end, blocksize;
2121 unsigned to; 2121 unsigned to;
@@ -2127,7 +2127,7 @@ int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc,
2127 2127
2128 head = page_buffers(page); 2128 head = page_buffers(page);
2129 blocksize = head->b_size; 2129 blocksize = head->b_size;
2130 to = min_t(unsigned, PAGE_CACHE_SIZE - from, desc->count); 2130 to = min_t(unsigned, PAGE_CACHE_SIZE - from, count);
2131 to = from + to; 2131 to = from + to;
2132 if (from < blocksize && to > PAGE_CACHE_SIZE - blocksize) 2132 if (from < blocksize && to > PAGE_CACHE_SIZE - blocksize)
2133 return 0; 2133 return 0;
diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
index 622f4696e484..5b99bafc31d1 100644
--- a/fs/cachefiles/bind.c
+++ b/fs/cachefiles/bind.c
@@ -124,7 +124,6 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
124 /* check parameters */ 124 /* check parameters */
125 ret = -EOPNOTSUPP; 125 ret = -EOPNOTSUPP;
126 if (!root->d_inode || 126 if (!root->d_inode ||
127 !root->d_inode->i_op ||
128 !root->d_inode->i_op->lookup || 127 !root->d_inode->i_op->lookup ||
129 !root->d_inode->i_op->mkdir || 128 !root->d_inode->i_op->mkdir ||
130 !root->d_inode->i_op->setxattr || 129 !root->d_inode->i_op->setxattr ||
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 6494d9f673aa..c0a681705104 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -779,8 +779,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
779 } 779 }
780 780
781 ret = -EPERM; 781 ret = -EPERM;
782 if (!subdir->d_inode->i_op || 782 if (!subdir->d_inode->i_op->setxattr ||
783 !subdir->d_inode->i_op->setxattr ||
784 !subdir->d_inode->i_op->getxattr || 783 !subdir->d_inode->i_op->getxattr ||
785 !subdir->d_inode->i_op->lookup || 784 !subdir->d_inode->i_op->lookup ||
786 !subdir->d_inode->i_op->mkdir || 785 !subdir->d_inode->i_op->mkdir ||
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 66075a4ad979..39da1c2efa50 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -601,7 +601,7 @@ ceph_sync_direct_write(struct kiocb *iocb, const struct iovec *iov,
601 false); 601 false);
602 if (IS_ERR(req)) { 602 if (IS_ERR(req)) {
603 ret = PTR_ERR(req); 603 ret = PTR_ERR(req);
604 goto out; 604 break;
605 } 605 }
606 606
607 num_pages = calc_pages_for(page_align, len); 607 num_pages = calc_pages_for(page_align, len);
@@ -719,7 +719,7 @@ static ssize_t ceph_sync_write(struct kiocb *iocb, const struct iovec *iov,
719 false); 719 false);
720 if (IS_ERR(req)) { 720 if (IS_ERR(req)) {
721 ret = PTR_ERR(req); 721 ret = PTR_ERR(req);
722 goto out; 722 break;
723 } 723 }
724 724
725 /* 725 /*
@@ -972,6 +972,7 @@ retry_snap:
972 } 972 }
973 } else { 973 } else {
974 loff_t old_size = inode->i_size; 974 loff_t old_size = inode->i_size;
975 struct iov_iter from;
975 /* 976 /*
976 * No need to acquire the i_truncate_mutex. Because 977 * No need to acquire the i_truncate_mutex. Because
977 * the MDS revokes Fwb caps before sending truncate 978 * the MDS revokes Fwb caps before sending truncate
@@ -979,9 +980,10 @@ retry_snap:
979 * are pending vmtruncate. So write and vmtruncate 980 * are pending vmtruncate. So write and vmtruncate
980 * can not run at the same time 981 * can not run at the same time
981 */ 982 */
982 written = generic_file_buffered_write(iocb, iov, nr_segs, 983 iov_iter_init(&from, iov, nr_segs, count, 0);
983 pos, &iocb->ki_pos, 984 written = generic_perform_write(file, &from, pos);
984 count, 0); 985 if (likely(written >= 0))
986 iocb->ki_pos = pos + written;
985 if (inode->i_size > old_size) 987 if (inode->i_size > old_size)
986 ceph_fscache_update_objectsize(inode); 988 ceph_fscache_update_objectsize(inode);
987 mutex_unlock(&inode->i_mutex); 989 mutex_unlock(&inode->i_mutex);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 2c70cbe35d39..df9c9141c099 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -850,7 +850,6 @@ const struct inode_operations cifs_file_inode_ops = {
850/* revalidate:cifs_revalidate, */ 850/* revalidate:cifs_revalidate, */
851 .setattr = cifs_setattr, 851 .setattr = cifs_setattr,
852 .getattr = cifs_getattr, /* do we need this anymore? */ 852 .getattr = cifs_getattr, /* do we need this anymore? */
853 .rename = cifs_rename,
854 .permission = cifs_permission, 853 .permission = cifs_permission,
855#ifdef CONFIG_CIFS_XATTR 854#ifdef CONFIG_CIFS_XATTR
856 .setxattr = cifs_setxattr, 855 .setxattr = cifs_setxattr,
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 216d7e99f921..8807442c94dd 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2579,19 +2579,32 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
2579 struct cifsInodeInfo *cinode = CIFS_I(inode); 2579 struct cifsInodeInfo *cinode = CIFS_I(inode);
2580 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server; 2580 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
2581 ssize_t rc = -EACCES; 2581 ssize_t rc = -EACCES;
2582 loff_t lock_pos = pos; 2582 loff_t lock_pos = iocb->ki_pos;
2583 2583
2584 if (file->f_flags & O_APPEND)
2585 lock_pos = i_size_read(inode);
2586 /* 2584 /*
2587 * We need to hold the sem to be sure nobody modifies lock list 2585 * We need to hold the sem to be sure nobody modifies lock list
2588 * with a brlock that prevents writing. 2586 * with a brlock that prevents writing.
2589 */ 2587 */
2590 down_read(&cinode->lock_sem); 2588 down_read(&cinode->lock_sem);
2589 mutex_lock(&inode->i_mutex);
2590 if (file->f_flags & O_APPEND)
2591 lock_pos = i_size_read(inode);
2591 if (!cifs_find_lock_conflict(cfile, lock_pos, iov_length(iov, nr_segs), 2592 if (!cifs_find_lock_conflict(cfile, lock_pos, iov_length(iov, nr_segs),
2592 server->vals->exclusive_lock_type, NULL, 2593 server->vals->exclusive_lock_type, NULL,
2593 CIFS_WRITE_OP)) 2594 CIFS_WRITE_OP)) {
2594 rc = generic_file_aio_write(iocb, iov, nr_segs, pos); 2595 rc = __generic_file_aio_write(iocb, iov, nr_segs);
2596 mutex_unlock(&inode->i_mutex);
2597
2598 if (rc > 0) {
2599 ssize_t err;
2600
2601 err = generic_write_sync(file, iocb->ki_pos - rc, rc);
2602 if (rc < 0)
2603 rc = err;
2604 }
2605 } else {
2606 mutex_unlock(&inode->i_mutex);
2607 }
2595 up_read(&cinode->lock_sem); 2608 up_read(&cinode->lock_sem);
2596 return rc; 2609 return rc;
2597} 2610}
@@ -2727,56 +2740,27 @@ cifs_retry_async_readv(struct cifs_readdata *rdata)
2727/** 2740/**
2728 * cifs_readdata_to_iov - copy data from pages in response to an iovec 2741 * cifs_readdata_to_iov - copy data from pages in response to an iovec
2729 * @rdata: the readdata response with list of pages holding data 2742 * @rdata: the readdata response with list of pages holding data
2730 * @iov: vector in which we should copy the data 2743 * @iter: destination for our data
2731 * @nr_segs: number of segments in vector
2732 * @offset: offset into file of the first iovec
2733 * @copied: used to return the amount of data copied to the iov
2734 * 2744 *
2735 * This function copies data from a list of pages in a readdata response into 2745 * This function copies data from a list of pages in a readdata response into
2736 * an array of iovecs. It will first calculate where the data should go 2746 * an array of iovecs. It will first calculate where the data should go
2737 * based on the info in the readdata and then copy the data into that spot. 2747 * based on the info in the readdata and then copy the data into that spot.
2738 */ 2748 */
2739static ssize_t 2749static int
2740cifs_readdata_to_iov(struct cifs_readdata *rdata, const struct iovec *iov, 2750cifs_readdata_to_iov(struct cifs_readdata *rdata, struct iov_iter *iter)
2741 unsigned long nr_segs, loff_t offset, ssize_t *copied)
2742{ 2751{
2743 int rc = 0; 2752 size_t remaining = rdata->bytes;
2744 struct iov_iter ii;
2745 size_t pos = rdata->offset - offset;
2746 ssize_t remaining = rdata->bytes;
2747 unsigned char *pdata;
2748 unsigned int i; 2753 unsigned int i;
2749 2754
2750 /* set up iov_iter and advance to the correct offset */
2751 iov_iter_init(&ii, iov, nr_segs, iov_length(iov, nr_segs), 0);
2752 iov_iter_advance(&ii, pos);
2753
2754 *copied = 0;
2755 for (i = 0; i < rdata->nr_pages; i++) { 2755 for (i = 0; i < rdata->nr_pages; i++) {
2756 ssize_t copy;
2757 struct page *page = rdata->pages[i]; 2756 struct page *page = rdata->pages[i];
2758 2757 size_t copy = min(remaining, PAGE_SIZE);
2759 /* copy a whole page or whatever's left */ 2758 size_t written = copy_page_to_iter(page, 0, copy, iter);
2760 copy = min_t(ssize_t, remaining, PAGE_SIZE); 2759 remaining -= written;
2761 2760 if (written < copy && iov_iter_count(iter) > 0)
2762 /* ...but limit it to whatever space is left in the iov */ 2761 break;
2763 copy = min_t(ssize_t, copy, iov_iter_count(&ii));
2764
2765 /* go while there's data to be copied and no errors */
2766 if (copy && !rc) {
2767 pdata = kmap(page);
2768 rc = memcpy_toiovecend(ii.iov, pdata, ii.iov_offset,
2769 (int)copy);
2770 kunmap(page);
2771 if (!rc) {
2772 *copied += copy;
2773 remaining -= copy;
2774 iov_iter_advance(&ii, copy);
2775 }
2776 }
2777 } 2762 }
2778 2763 return remaining ? -EFAULT : 0;
2779 return rc;
2780} 2764}
2781 2765
2782static void 2766static void
@@ -2837,20 +2821,21 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server,
2837 return total_read > 0 ? total_read : result; 2821 return total_read > 0 ? total_read : result;
2838} 2822}
2839 2823
2840static ssize_t 2824ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov,
2841cifs_iovec_read(struct file *file, const struct iovec *iov, 2825 unsigned long nr_segs, loff_t pos)
2842 unsigned long nr_segs, loff_t *poffset)
2843{ 2826{
2827 struct file *file = iocb->ki_filp;
2844 ssize_t rc; 2828 ssize_t rc;
2845 size_t len, cur_len; 2829 size_t len, cur_len;
2846 ssize_t total_read = 0; 2830 ssize_t total_read = 0;
2847 loff_t offset = *poffset; 2831 loff_t offset = pos;
2848 unsigned int npages; 2832 unsigned int npages;
2849 struct cifs_sb_info *cifs_sb; 2833 struct cifs_sb_info *cifs_sb;
2850 struct cifs_tcon *tcon; 2834 struct cifs_tcon *tcon;
2851 struct cifsFileInfo *open_file; 2835 struct cifsFileInfo *open_file;
2852 struct cifs_readdata *rdata, *tmp; 2836 struct cifs_readdata *rdata, *tmp;
2853 struct list_head rdata_list; 2837 struct list_head rdata_list;
2838 struct iov_iter to;
2854 pid_t pid; 2839 pid_t pid;
2855 2840
2856 if (!nr_segs) 2841 if (!nr_segs)
@@ -2860,6 +2845,8 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
2860 if (!len) 2845 if (!len)
2861 return 0; 2846 return 0;
2862 2847
2848 iov_iter_init(&to, iov, nr_segs, len, 0);
2849
2863 INIT_LIST_HEAD(&rdata_list); 2850 INIT_LIST_HEAD(&rdata_list);
2864 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 2851 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
2865 open_file = file->private_data; 2852 open_file = file->private_data;
@@ -2917,55 +2904,44 @@ error:
2917 if (!list_empty(&rdata_list)) 2904 if (!list_empty(&rdata_list))
2918 rc = 0; 2905 rc = 0;
2919 2906
2907 len = iov_iter_count(&to);
2920 /* the loop below should proceed in the order of increasing offsets */ 2908 /* the loop below should proceed in the order of increasing offsets */
2921restart_loop:
2922 list_for_each_entry_safe(rdata, tmp, &rdata_list, list) { 2909 list_for_each_entry_safe(rdata, tmp, &rdata_list, list) {
2910 again:
2923 if (!rc) { 2911 if (!rc) {
2924 ssize_t copied;
2925
2926 /* FIXME: freezable sleep too? */ 2912 /* FIXME: freezable sleep too? */
2927 rc = wait_for_completion_killable(&rdata->done); 2913 rc = wait_for_completion_killable(&rdata->done);
2928 if (rc) 2914 if (rc)
2929 rc = -EINTR; 2915 rc = -EINTR;
2930 else if (rdata->result) 2916 else if (rdata->result) {
2931 rc = rdata->result; 2917 rc = rdata->result;
2932 else { 2918 /* resend call if it's a retryable error */
2933 rc = cifs_readdata_to_iov(rdata, iov, 2919 if (rc == -EAGAIN) {
2934 nr_segs, *poffset, 2920 rc = cifs_retry_async_readv(rdata);
2935 &copied); 2921 goto again;
2936 total_read += copied; 2922 }
2923 } else {
2924 rc = cifs_readdata_to_iov(rdata, &to);
2937 } 2925 }
2938 2926
2939 /* resend call if it's a retryable error */
2940 if (rc == -EAGAIN) {
2941 rc = cifs_retry_async_readv(rdata);
2942 goto restart_loop;
2943 }
2944 } 2927 }
2945 list_del_init(&rdata->list); 2928 list_del_init(&rdata->list);
2946 kref_put(&rdata->refcount, cifs_uncached_readdata_release); 2929 kref_put(&rdata->refcount, cifs_uncached_readdata_release);
2947 } 2930 }
2948 2931
2932 total_read = len - iov_iter_count(&to);
2933
2949 cifs_stats_bytes_read(tcon, total_read); 2934 cifs_stats_bytes_read(tcon, total_read);
2950 *poffset += total_read;
2951 2935
2952 /* mask nodata case */ 2936 /* mask nodata case */
2953 if (rc == -ENODATA) 2937 if (rc == -ENODATA)
2954 rc = 0; 2938 rc = 0;
2955 2939
2956 return total_read ? total_read : rc; 2940 if (total_read) {
2957} 2941 iocb->ki_pos = pos + total_read;
2958 2942 return total_read;
2959ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov, 2943 }
2960 unsigned long nr_segs, loff_t pos) 2944 return rc;
2961{
2962 ssize_t read;
2963
2964 read = cifs_iovec_read(iocb->ki_filp, iov, nr_segs, &pos);
2965 if (read > 0)
2966 iocb->ki_pos = pos;
2967
2968 return read;
2969} 2945}
2970 2946
2971ssize_t 2947ssize_t
diff --git a/fs/exec.c b/fs/exec.c
index 9e81c630dfa7..476f3ebf437e 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -813,7 +813,7 @@ EXPORT_SYMBOL(kernel_read);
813 813
814ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len) 814ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len)
815{ 815{
816 ssize_t res = file->f_op->read(file, (void __user *)addr, len, &pos); 816 ssize_t res = vfs_read(file, (void __user *)addr, len, &pos);
817 if (res > 0) 817 if (res > 0)
818 flush_icache_range(addr, addr + len); 818 flush_icache_range(addr, addr + len);
819 return res; 819 return res;
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 4e508fc83dcf..ca7502d89fde 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -146,7 +146,7 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov,
146 overwrite = 1; 146 overwrite = 1;
147 } 147 }
148 148
149 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 149 ret = __generic_file_aio_write(iocb, iov, nr_segs);
150 mutex_unlock(&inode->i_mutex); 150 mutex_unlock(&inode->i_mutex);
151 151
152 if (ret > 0) { 152 if (ret > 0) {
diff --git a/fs/file.c b/fs/file.c
index b61293badfb1..8f294cfac697 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -25,7 +25,10 @@
25 25
26int sysctl_nr_open __read_mostly = 1024*1024; 26int sysctl_nr_open __read_mostly = 1024*1024;
27int sysctl_nr_open_min = BITS_PER_LONG; 27int sysctl_nr_open_min = BITS_PER_LONG;
28int sysctl_nr_open_max = 1024 * 1024; /* raised later */ 28/* our max() is unusable in constant expressions ;-/ */
29#define __const_max(x, y) ((x) < (y) ? (x) : (y))
30int sysctl_nr_open_max = __const_max(INT_MAX, ~(size_t)0/sizeof(void *)) &
31 -BITS_PER_LONG;
29 32
30static void *alloc_fdmem(size_t size) 33static void *alloc_fdmem(size_t size)
31{ 34{
@@ -429,12 +432,6 @@ void exit_files(struct task_struct *tsk)
429 } 432 }
430} 433}
431 434
432void __init files_defer_init(void)
433{
434 sysctl_nr_open_max = min((size_t)INT_MAX, ~(size_t)0/sizeof(void *)) &
435 -BITS_PER_LONG;
436}
437
438struct files_struct init_files = { 435struct files_struct init_files = {
439 .count = ATOMIC_INIT(1), 436 .count = ATOMIC_INIT(1),
440 .fdt = &init_files.fdtab, 437 .fdt = &init_files.fdtab,
diff --git a/fs/file_table.c b/fs/file_table.c
index 01071c4d752e..a374f5033e97 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -52,7 +52,6 @@ static void file_free_rcu(struct rcu_head *head)
52static inline void file_free(struct file *f) 52static inline void file_free(struct file *f)
53{ 53{
54 percpu_counter_dec(&nr_files); 54 percpu_counter_dec(&nr_files);
55 file_check_state(f);
56 call_rcu(&f->f_u.fu_rcuhead, file_free_rcu); 55 call_rcu(&f->f_u.fu_rcuhead, file_free_rcu);
57} 56}
58 57
@@ -178,47 +177,12 @@ struct file *alloc_file(struct path *path, fmode_t mode,
178 file->f_mapping = path->dentry->d_inode->i_mapping; 177 file->f_mapping = path->dentry->d_inode->i_mapping;
179 file->f_mode = mode; 178 file->f_mode = mode;
180 file->f_op = fop; 179 file->f_op = fop;
181
182 /*
183 * These mounts don't really matter in practice
184 * for r/o bind mounts. They aren't userspace-
185 * visible. We do this for consistency, and so
186 * that we can do debugging checks at __fput()
187 */
188 if ((mode & FMODE_WRITE) && !special_file(path->dentry->d_inode->i_mode)) {
189 file_take_write(file);
190 WARN_ON(mnt_clone_write(path->mnt));
191 }
192 if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) 180 if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
193 i_readcount_inc(path->dentry->d_inode); 181 i_readcount_inc(path->dentry->d_inode);
194 return file; 182 return file;
195} 183}
196EXPORT_SYMBOL(alloc_file); 184EXPORT_SYMBOL(alloc_file);
197 185
198/**
199 * drop_file_write_access - give up ability to write to a file
200 * @file: the file to which we will stop writing
201 *
202 * This is a central place which will give up the ability
203 * to write to @file, along with access to write through
204 * its vfsmount.
205 */
206static void drop_file_write_access(struct file *file)
207{
208 struct vfsmount *mnt = file->f_path.mnt;
209 struct dentry *dentry = file->f_path.dentry;
210 struct inode *inode = dentry->d_inode;
211
212 put_write_access(inode);
213
214 if (special_file(inode->i_mode))
215 return;
216 if (file_check_writeable(file) != 0)
217 return;
218 __mnt_drop_write(mnt);
219 file_release_write(file);
220}
221
222/* the real guts of fput() - releasing the last reference to file 186/* the real guts of fput() - releasing the last reference to file
223 */ 187 */
224static void __fput(struct file *file) 188static void __fput(struct file *file)
@@ -253,8 +217,10 @@ static void __fput(struct file *file)
253 put_pid(file->f_owner.pid); 217 put_pid(file->f_owner.pid);
254 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) 218 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
255 i_readcount_dec(inode); 219 i_readcount_dec(inode);
256 if (file->f_mode & FMODE_WRITE) 220 if (file->f_mode & FMODE_WRITER) {
257 drop_file_write_access(file); 221 put_write_access(inode);
222 __mnt_drop_write(mnt);
223 }
258 file->f_path.dentry = NULL; 224 file->f_path.dentry = NULL;
259 file->f_path.mnt = NULL; 225 file->f_path.mnt = NULL;
260 file->f_inode = NULL; 226 file->f_inode = NULL;
@@ -359,6 +325,5 @@ void __init files_init(unsigned long mempages)
359 325
360 n = (mempages * (PAGE_SIZE / 1024)) / 10; 326 n = (mempages * (PAGE_SIZE / 1024)) / 10;
361 files_stat.max_files = max_t(unsigned long, n, NR_FILE); 327 files_stat.max_files = max_t(unsigned long, n, NR_FILE);
362 files_defer_init();
363 percpu_counter_init(&nr_files, 0); 328 percpu_counter_init(&nr_files, 0);
364} 329}
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 0a648bb455ae..aac71ce373e4 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -667,15 +667,15 @@ static void fuse_copy_finish(struct fuse_copy_state *cs)
667 struct pipe_buffer *buf = cs->currbuf; 667 struct pipe_buffer *buf = cs->currbuf;
668 668
669 if (!cs->write) { 669 if (!cs->write) {
670 buf->ops->unmap(cs->pipe, buf, cs->mapaddr); 670 kunmap_atomic(cs->mapaddr);
671 } else { 671 } else {
672 kunmap(buf->page); 672 kunmap_atomic(cs->mapaddr);
673 buf->len = PAGE_SIZE - cs->len; 673 buf->len = PAGE_SIZE - cs->len;
674 } 674 }
675 cs->currbuf = NULL; 675 cs->currbuf = NULL;
676 cs->mapaddr = NULL; 676 cs->mapaddr = NULL;
677 } else if (cs->mapaddr) { 677 } else if (cs->mapaddr) {
678 kunmap(cs->pg); 678 kunmap_atomic(cs->mapaddr);
679 if (cs->write) { 679 if (cs->write) {
680 flush_dcache_page(cs->pg); 680 flush_dcache_page(cs->pg);
681 set_page_dirty_lock(cs->pg); 681 set_page_dirty_lock(cs->pg);
@@ -706,7 +706,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs)
706 706
707 BUG_ON(!cs->nr_segs); 707 BUG_ON(!cs->nr_segs);
708 cs->currbuf = buf; 708 cs->currbuf = buf;
709 cs->mapaddr = buf->ops->map(cs->pipe, buf, 0); 709 cs->mapaddr = kmap_atomic(buf->page);
710 cs->len = buf->len; 710 cs->len = buf->len;
711 cs->buf = cs->mapaddr + buf->offset; 711 cs->buf = cs->mapaddr + buf->offset;
712 cs->pipebufs++; 712 cs->pipebufs++;
@@ -726,7 +726,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs)
726 buf->len = 0; 726 buf->len = 0;
727 727
728 cs->currbuf = buf; 728 cs->currbuf = buf;
729 cs->mapaddr = kmap(page); 729 cs->mapaddr = kmap_atomic(page);
730 cs->buf = cs->mapaddr; 730 cs->buf = cs->mapaddr;
731 cs->len = PAGE_SIZE; 731 cs->len = PAGE_SIZE;
732 cs->pipebufs++; 732 cs->pipebufs++;
@@ -745,7 +745,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs)
745 return err; 745 return err;
746 BUG_ON(err != 1); 746 BUG_ON(err != 1);
747 offset = cs->addr % PAGE_SIZE; 747 offset = cs->addr % PAGE_SIZE;
748 cs->mapaddr = kmap(cs->pg); 748 cs->mapaddr = kmap_atomic(cs->pg);
749 cs->buf = cs->mapaddr + offset; 749 cs->buf = cs->mapaddr + offset;
750 cs->len = min(PAGE_SIZE - offset, cs->seglen); 750 cs->len = min(PAGE_SIZE - offset, cs->seglen);
751 cs->seglen -= cs->len; 751 cs->seglen -= cs->len;
@@ -874,7 +874,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
874out_fallback_unlock: 874out_fallback_unlock:
875 unlock_page(newpage); 875 unlock_page(newpage);
876out_fallback: 876out_fallback:
877 cs->mapaddr = buf->ops->map(cs->pipe, buf, 1); 877 cs->mapaddr = kmap_atomic(buf->page);
878 cs->buf = cs->mapaddr + buf->offset; 878 cs->buf = cs->mapaddr + buf->offset;
879 879
880 err = lock_request(cs->fc, cs->req); 880 err = lock_request(cs->fc, cs->req);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 48992cac714b..13f8bdec5110 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1086,9 +1086,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
1086 if (mapping_writably_mapped(mapping)) 1086 if (mapping_writably_mapped(mapping))
1087 flush_dcache_page(page); 1087 flush_dcache_page(page);
1088 1088
1089 pagefault_disable();
1090 tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes); 1089 tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);
1091 pagefault_enable();
1092 flush_dcache_page(page); 1090 flush_dcache_page(page);
1093 1091
1094 mark_page_accessed(page); 1092 mark_page_accessed(page);
@@ -1237,8 +1235,7 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
1237 goto out; 1235 goto out;
1238 1236
1239 if (file->f_flags & O_DIRECT) { 1237 if (file->f_flags & O_DIRECT) {
1240 written = generic_file_direct_write(iocb, iov, &nr_segs, 1238 written = generic_file_direct_write(iocb, iov, &nr_segs, pos,
1241 pos, &iocb->ki_pos,
1242 count, ocount); 1239 count, ocount);
1243 if (written < 0 || written == count) 1240 if (written < 0 || written == count)
1244 goto out; 1241 goto out;
diff --git a/fs/mount.h b/fs/mount.h
index b29e42f05f34..d55297f2fa05 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -10,7 +10,7 @@ struct mnt_namespace {
10 struct user_namespace *user_ns; 10 struct user_namespace *user_ns;
11 u64 seq; /* Sequence number to prevent loops */ 11 u64 seq; /* Sequence number to prevent loops */
12 wait_queue_head_t poll; 12 wait_queue_head_t poll;
13 int event; 13 u64 event;
14}; 14};
15 15
16struct mnt_pcp { 16struct mnt_pcp {
@@ -104,6 +104,9 @@ struct proc_mounts {
104 struct mnt_namespace *ns; 104 struct mnt_namespace *ns;
105 struct path root; 105 struct path root;
106 int (*show)(struct seq_file *, struct vfsmount *); 106 int (*show)(struct seq_file *, struct vfsmount *);
107 void *cached_mount;
108 u64 cached_event;
109 loff_t cached_index;
107}; 110};
108 111
109#define proc_mounts(p) (container_of((p), struct proc_mounts, m)) 112#define proc_mounts(p) (container_of((p), struct proc_mounts, m))
diff --git a/fs/namei.c b/fs/namei.c
index 88339f59efb5..c6157c894fce 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -358,6 +358,7 @@ int generic_permission(struct inode *inode, int mask)
358 358
359 return -EACCES; 359 return -EACCES;
360} 360}
361EXPORT_SYMBOL(generic_permission);
361 362
362/* 363/*
363 * We _really_ want to just do "generic_permission()" without 364 * We _really_ want to just do "generic_permission()" without
@@ -455,6 +456,7 @@ int inode_permission(struct inode *inode, int mask)
455 return retval; 456 return retval;
456 return __inode_permission(inode, mask); 457 return __inode_permission(inode, mask);
457} 458}
459EXPORT_SYMBOL(inode_permission);
458 460
459/** 461/**
460 * path_get - get a reference to a path 462 * path_get - get a reference to a path
@@ -924,6 +926,7 @@ int follow_up(struct path *path)
924 path->mnt = &parent->mnt; 926 path->mnt = &parent->mnt;
925 return 1; 927 return 1;
926} 928}
929EXPORT_SYMBOL(follow_up);
927 930
928/* 931/*
929 * Perform an automount 932 * Perform an automount
@@ -1085,6 +1088,7 @@ int follow_down_one(struct path *path)
1085 } 1088 }
1086 return 0; 1089 return 0;
1087} 1090}
1091EXPORT_SYMBOL(follow_down_one);
1088 1092
1089static inline bool managed_dentry_might_block(struct dentry *dentry) 1093static inline bool managed_dentry_might_block(struct dentry *dentry)
1090{ 1094{
@@ -1223,6 +1227,7 @@ int follow_down(struct path *path)
1223 } 1227 }
1224 return 0; 1228 return 0;
1225} 1229}
1230EXPORT_SYMBOL(follow_down);
1226 1231
1227/* 1232/*
1228 * Skip to top of mountpoint pile in refwalk mode for follow_dotdot() 1233 * Skip to top of mountpoint pile in refwalk mode for follow_dotdot()
@@ -2025,6 +2030,7 @@ int kern_path(const char *name, unsigned int flags, struct path *path)
2025 *path = nd.path; 2030 *path = nd.path;
2026 return res; 2031 return res;
2027} 2032}
2033EXPORT_SYMBOL(kern_path);
2028 2034
2029/** 2035/**
2030 * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair 2036 * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
@@ -2049,6 +2055,7 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
2049 *path = nd.path; 2055 *path = nd.path;
2050 return err; 2056 return err;
2051} 2057}
2058EXPORT_SYMBOL(vfs_path_lookup);
2052 2059
2053/* 2060/*
2054 * Restricted form of lookup. Doesn't follow links, single-component only, 2061 * Restricted form of lookup. Doesn't follow links, single-component only,
@@ -2111,6 +2118,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
2111 2118
2112 return __lookup_hash(&this, base, 0); 2119 return __lookup_hash(&this, base, 0);
2113} 2120}
2121EXPORT_SYMBOL(lookup_one_len);
2114 2122
2115int user_path_at_empty(int dfd, const char __user *name, unsigned flags, 2123int user_path_at_empty(int dfd, const char __user *name, unsigned flags,
2116 struct path *path, int *empty) 2124 struct path *path, int *empty)
@@ -2135,6 +2143,7 @@ int user_path_at(int dfd, const char __user *name, unsigned flags,
2135{ 2143{
2136 return user_path_at_empty(dfd, name, flags, path, NULL); 2144 return user_path_at_empty(dfd, name, flags, path, NULL);
2137} 2145}
2146EXPORT_SYMBOL(user_path_at);
2138 2147
2139/* 2148/*
2140 * NB: most callers don't do anything directly with the reference to the 2149 * NB: most callers don't do anything directly with the reference to the
@@ -2477,6 +2486,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
2477 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD); 2486 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD);
2478 return NULL; 2487 return NULL;
2479} 2488}
2489EXPORT_SYMBOL(lock_rename);
2480 2490
2481void unlock_rename(struct dentry *p1, struct dentry *p2) 2491void unlock_rename(struct dentry *p1, struct dentry *p2)
2482{ 2492{
@@ -2486,6 +2496,7 @@ void unlock_rename(struct dentry *p1, struct dentry *p2)
2486 mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex); 2496 mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex);
2487 } 2497 }
2488} 2498}
2499EXPORT_SYMBOL(unlock_rename);
2489 2500
2490int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, 2501int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
2491 bool want_excl) 2502 bool want_excl)
@@ -2506,6 +2517,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
2506 fsnotify_create(dir, dentry); 2517 fsnotify_create(dir, dentry);
2507 return error; 2518 return error;
2508} 2519}
2520EXPORT_SYMBOL(vfs_create);
2509 2521
2510static int may_open(struct path *path, int acc_mode, int flag) 2522static int may_open(struct path *path, int acc_mode, int flag)
2511{ 2523{
@@ -3375,6 +3387,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
3375 fsnotify_create(dir, dentry); 3387 fsnotify_create(dir, dentry);
3376 return error; 3388 return error;
3377} 3389}
3390EXPORT_SYMBOL(vfs_mknod);
3378 3391
3379static int may_mknod(umode_t mode) 3392static int may_mknod(umode_t mode)
3380{ 3393{
@@ -3464,6 +3477,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
3464 fsnotify_mkdir(dir, dentry); 3477 fsnotify_mkdir(dir, dentry);
3465 return error; 3478 return error;
3466} 3479}
3480EXPORT_SYMBOL(vfs_mkdir);
3467 3481
3468SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode) 3482SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
3469{ 3483{
@@ -3518,6 +3532,7 @@ void dentry_unhash(struct dentry *dentry)
3518 __d_drop(dentry); 3532 __d_drop(dentry);
3519 spin_unlock(&dentry->d_lock); 3533 spin_unlock(&dentry->d_lock);
3520} 3534}
3535EXPORT_SYMBOL(dentry_unhash);
3521 3536
3522int vfs_rmdir(struct inode *dir, struct dentry *dentry) 3537int vfs_rmdir(struct inode *dir, struct dentry *dentry)
3523{ 3538{
@@ -3555,6 +3570,7 @@ out:
3555 d_delete(dentry); 3570 d_delete(dentry);
3556 return error; 3571 return error;
3557} 3572}
3573EXPORT_SYMBOL(vfs_rmdir);
3558 3574
3559static long do_rmdir(int dfd, const char __user *pathname) 3575static long do_rmdir(int dfd, const char __user *pathname)
3560{ 3576{
@@ -3672,6 +3688,7 @@ out:
3672 3688
3673 return error; 3689 return error;
3674} 3690}
3691EXPORT_SYMBOL(vfs_unlink);
3675 3692
3676/* 3693/*
3677 * Make sure that the actual truncation of the file will occur outside its 3694 * Make sure that the actual truncation of the file will occur outside its
@@ -3785,6 +3802,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
3785 fsnotify_create(dir, dentry); 3802 fsnotify_create(dir, dentry);
3786 return error; 3803 return error;
3787} 3804}
3805EXPORT_SYMBOL(vfs_symlink);
3788 3806
3789SYSCALL_DEFINE3(symlinkat, const char __user *, oldname, 3807SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
3790 int, newdfd, const char __user *, newname) 3808 int, newdfd, const char __user *, newname)
@@ -3893,6 +3911,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
3893 fsnotify_link(dir, inode, new_dentry); 3911 fsnotify_link(dir, inode, new_dentry);
3894 return error; 3912 return error;
3895} 3913}
3914EXPORT_SYMBOL(vfs_link);
3896 3915
3897/* 3916/*
3898 * Hardlinks are often used in delicate situations. We avoid 3917 * Hardlinks are often used in delicate situations. We avoid
@@ -4152,6 +4171,7 @@ out:
4152 4171
4153 return error; 4172 return error;
4154} 4173}
4174EXPORT_SYMBOL(vfs_rename);
4155 4175
4156SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname, 4176SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname,
4157 int, newdfd, const char __user *, newname, unsigned int, flags) 4177 int, newdfd, const char __user *, newname, unsigned int, flags)
@@ -4304,11 +4324,9 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
4304 return sys_renameat2(AT_FDCWD, oldname, AT_FDCWD, newname, 0); 4324 return sys_renameat2(AT_FDCWD, oldname, AT_FDCWD, newname, 0);
4305} 4325}
4306 4326
4307int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link) 4327int readlink_copy(char __user *buffer, int buflen, const char *link)
4308{ 4328{
4309 int len; 4329 int len = PTR_ERR(link);
4310
4311 len = PTR_ERR(link);
4312 if (IS_ERR(link)) 4330 if (IS_ERR(link))
4313 goto out; 4331 goto out;
4314 4332
@@ -4320,6 +4338,7 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
4320out: 4338out:
4321 return len; 4339 return len;
4322} 4340}
4341EXPORT_SYMBOL(readlink_copy);
4323 4342
4324/* 4343/*
4325 * A helper for ->readlink(). This should be used *ONLY* for symlinks that 4344 * A helper for ->readlink(). This should be used *ONLY* for symlinks that
@@ -4337,11 +4356,12 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
4337 if (IS_ERR(cookie)) 4356 if (IS_ERR(cookie))
4338 return PTR_ERR(cookie); 4357 return PTR_ERR(cookie);
4339 4358
4340 res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd)); 4359 res = readlink_copy(buffer, buflen, nd_get_link(&nd));
4341 if (dentry->d_inode->i_op->put_link) 4360 if (dentry->d_inode->i_op->put_link)
4342 dentry->d_inode->i_op->put_link(dentry, &nd, cookie); 4361 dentry->d_inode->i_op->put_link(dentry, &nd, cookie);
4343 return res; 4362 return res;
4344} 4363}
4364EXPORT_SYMBOL(generic_readlink);
4345 4365
4346/* get the link contents into pagecache */ 4366/* get the link contents into pagecache */
4347static char *page_getlink(struct dentry * dentry, struct page **ppage) 4367static char *page_getlink(struct dentry * dentry, struct page **ppage)
@@ -4361,14 +4381,14 @@ static char *page_getlink(struct dentry * dentry, struct page **ppage)
4361int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) 4381int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
4362{ 4382{
4363 struct page *page = NULL; 4383 struct page *page = NULL;
4364 char *s = page_getlink(dentry, &page); 4384 int res = readlink_copy(buffer, buflen, page_getlink(dentry, &page));
4365 int res = vfs_readlink(dentry,buffer,buflen,s);
4366 if (page) { 4385 if (page) {
4367 kunmap(page); 4386 kunmap(page);
4368 page_cache_release(page); 4387 page_cache_release(page);
4369 } 4388 }
4370 return res; 4389 return res;
4371} 4390}
4391EXPORT_SYMBOL(page_readlink);
4372 4392
4373void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd) 4393void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd)
4374{ 4394{
@@ -4376,6 +4396,7 @@ void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd)
4376 nd_set_link(nd, page_getlink(dentry, &page)); 4396 nd_set_link(nd, page_getlink(dentry, &page));
4377 return page; 4397 return page;
4378} 4398}
4399EXPORT_SYMBOL(page_follow_link_light);
4379 4400
4380void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) 4401void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
4381{ 4402{
@@ -4386,6 +4407,7 @@ void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
4386 page_cache_release(page); 4407 page_cache_release(page);
4387 } 4408 }
4388} 4409}
4410EXPORT_SYMBOL(page_put_link);
4389 4411
4390/* 4412/*
4391 * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS 4413 * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS
@@ -4423,45 +4445,18 @@ retry:
4423fail: 4445fail:
4424 return err; 4446 return err;
4425} 4447}
4448EXPORT_SYMBOL(__page_symlink);
4426 4449
4427int page_symlink(struct inode *inode, const char *symname, int len) 4450int page_symlink(struct inode *inode, const char *symname, int len)
4428{ 4451{
4429 return __page_symlink(inode, symname, len, 4452 return __page_symlink(inode, symname, len,
4430 !(mapping_gfp_mask(inode->i_mapping) & __GFP_FS)); 4453 !(mapping_gfp_mask(inode->i_mapping) & __GFP_FS));
4431} 4454}
4455EXPORT_SYMBOL(page_symlink);
4432 4456
4433const struct inode_operations page_symlink_inode_operations = { 4457const struct inode_operations page_symlink_inode_operations = {
4434 .readlink = generic_readlink, 4458 .readlink = generic_readlink,
4435 .follow_link = page_follow_link_light, 4459 .follow_link = page_follow_link_light,
4436 .put_link = page_put_link, 4460 .put_link = page_put_link,
4437}; 4461};
4438
4439EXPORT_SYMBOL(user_path_at);
4440EXPORT_SYMBOL(follow_down_one);
4441EXPORT_SYMBOL(follow_down);
4442EXPORT_SYMBOL(follow_up);
4443EXPORT_SYMBOL(get_write_access); /* nfsd */
4444EXPORT_SYMBOL(lock_rename);
4445EXPORT_SYMBOL(lookup_one_len);
4446EXPORT_SYMBOL(page_follow_link_light);
4447EXPORT_SYMBOL(page_put_link);
4448EXPORT_SYMBOL(page_readlink);
4449EXPORT_SYMBOL(__page_symlink);
4450EXPORT_SYMBOL(page_symlink);
4451EXPORT_SYMBOL(page_symlink_inode_operations); 4462EXPORT_SYMBOL(page_symlink_inode_operations);
4452EXPORT_SYMBOL(kern_path);
4453EXPORT_SYMBOL(vfs_path_lookup);
4454EXPORT_SYMBOL(inode_permission);
4455EXPORT_SYMBOL(unlock_rename);
4456EXPORT_SYMBOL(vfs_create);
4457EXPORT_SYMBOL(vfs_link);
4458EXPORT_SYMBOL(vfs_mkdir);
4459EXPORT_SYMBOL(vfs_mknod);
4460EXPORT_SYMBOL(generic_permission);
4461EXPORT_SYMBOL(vfs_readlink);
4462EXPORT_SYMBOL(vfs_rename);
4463EXPORT_SYMBOL(vfs_rmdir);
4464EXPORT_SYMBOL(vfs_symlink);
4465EXPORT_SYMBOL(vfs_unlink);
4466EXPORT_SYMBOL(dentry_unhash);
4467EXPORT_SYMBOL(generic_readlink);
diff --git a/fs/namespace.c b/fs/namespace.c
index 2ffc5a2905d4..182bc41cd887 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -52,7 +52,7 @@ static int __init set_mphash_entries(char *str)
52} 52}
53__setup("mphash_entries=", set_mphash_entries); 53__setup("mphash_entries=", set_mphash_entries);
54 54
55static int event; 55static u64 event;
56static DEFINE_IDA(mnt_id_ida); 56static DEFINE_IDA(mnt_id_ida);
57static DEFINE_IDA(mnt_group_ida); 57static DEFINE_IDA(mnt_group_ida);
58static DEFINE_SPINLOCK(mnt_id_lock); 58static DEFINE_SPINLOCK(mnt_id_lock);
@@ -414,9 +414,7 @@ EXPORT_SYMBOL_GPL(mnt_clone_write);
414 */ 414 */
415int __mnt_want_write_file(struct file *file) 415int __mnt_want_write_file(struct file *file)
416{ 416{
417 struct inode *inode = file_inode(file); 417 if (!(file->f_mode & FMODE_WRITER))
418
419 if (!(file->f_mode & FMODE_WRITE) || special_file(inode->i_mode))
420 return __mnt_want_write(file->f_path.mnt); 418 return __mnt_want_write(file->f_path.mnt);
421 else 419 else
422 return mnt_clone_write(file->f_path.mnt); 420 return mnt_clone_write(file->f_path.mnt);
@@ -570,13 +568,17 @@ int sb_prepare_remount_readonly(struct super_block *sb)
570static void free_vfsmnt(struct mount *mnt) 568static void free_vfsmnt(struct mount *mnt)
571{ 569{
572 kfree(mnt->mnt_devname); 570 kfree(mnt->mnt_devname);
573 mnt_free_id(mnt);
574#ifdef CONFIG_SMP 571#ifdef CONFIG_SMP
575 free_percpu(mnt->mnt_pcp); 572 free_percpu(mnt->mnt_pcp);
576#endif 573#endif
577 kmem_cache_free(mnt_cache, mnt); 574 kmem_cache_free(mnt_cache, mnt);
578} 575}
579 576
577static void delayed_free_vfsmnt(struct rcu_head *head)
578{
579 free_vfsmnt(container_of(head, struct mount, mnt_rcu));
580}
581
580/* call under rcu_read_lock */ 582/* call under rcu_read_lock */
581bool legitimize_mnt(struct vfsmount *bastard, unsigned seq) 583bool legitimize_mnt(struct vfsmount *bastard, unsigned seq)
582{ 584{
@@ -848,6 +850,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
848 850
849 root = mount_fs(type, flags, name, data); 851 root = mount_fs(type, flags, name, data);
850 if (IS_ERR(root)) { 852 if (IS_ERR(root)) {
853 mnt_free_id(mnt);
851 free_vfsmnt(mnt); 854 free_vfsmnt(mnt);
852 return ERR_CAST(root); 855 return ERR_CAST(root);
853 } 856 }
@@ -885,7 +888,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
885 goto out_free; 888 goto out_free;
886 } 889 }
887 890
888 mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~MNT_WRITE_HOLD; 891 mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~(MNT_WRITE_HOLD|MNT_MARKED);
889 /* Don't allow unprivileged users to change mount flags */ 892 /* Don't allow unprivileged users to change mount flags */
890 if ((flag & CL_UNPRIVILEGED) && (mnt->mnt.mnt_flags & MNT_READONLY)) 893 if ((flag & CL_UNPRIVILEGED) && (mnt->mnt.mnt_flags & MNT_READONLY))
891 mnt->mnt.mnt_flags |= MNT_LOCK_READONLY; 894 mnt->mnt.mnt_flags |= MNT_LOCK_READONLY;
@@ -928,20 +931,11 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
928 return mnt; 931 return mnt;
929 932
930 out_free: 933 out_free:
934 mnt_free_id(mnt);
931 free_vfsmnt(mnt); 935 free_vfsmnt(mnt);
932 return ERR_PTR(err); 936 return ERR_PTR(err);
933} 937}
934 938
935static void delayed_free(struct rcu_head *head)
936{
937 struct mount *mnt = container_of(head, struct mount, mnt_rcu);
938 kfree(mnt->mnt_devname);
939#ifdef CONFIG_SMP
940 free_percpu(mnt->mnt_pcp);
941#endif
942 kmem_cache_free(mnt_cache, mnt);
943}
944
945static void mntput_no_expire(struct mount *mnt) 939static void mntput_no_expire(struct mount *mnt)
946{ 940{
947put_again: 941put_again:
@@ -991,7 +985,7 @@ put_again:
991 dput(mnt->mnt.mnt_root); 985 dput(mnt->mnt.mnt_root);
992 deactivate_super(mnt->mnt.mnt_sb); 986 deactivate_super(mnt->mnt.mnt_sb);
993 mnt_free_id(mnt); 987 mnt_free_id(mnt);
994 call_rcu(&mnt->mnt_rcu, delayed_free); 988 call_rcu(&mnt->mnt_rcu, delayed_free_vfsmnt);
995} 989}
996 990
997void mntput(struct vfsmount *mnt) 991void mntput(struct vfsmount *mnt)
@@ -1100,14 +1094,29 @@ static void *m_start(struct seq_file *m, loff_t *pos)
1100 struct proc_mounts *p = proc_mounts(m); 1094 struct proc_mounts *p = proc_mounts(m);
1101 1095
1102 down_read(&namespace_sem); 1096 down_read(&namespace_sem);
1103 return seq_list_start(&p->ns->list, *pos); 1097 if (p->cached_event == p->ns->event) {
1098 void *v = p->cached_mount;
1099 if (*pos == p->cached_index)
1100 return v;
1101 if (*pos == p->cached_index + 1) {
1102 v = seq_list_next(v, &p->ns->list, &p->cached_index);
1103 return p->cached_mount = v;
1104 }
1105 }
1106
1107 p->cached_event = p->ns->event;
1108 p->cached_mount = seq_list_start(&p->ns->list, *pos);
1109 p->cached_index = *pos;
1110 return p->cached_mount;
1104} 1111}
1105 1112
1106static void *m_next(struct seq_file *m, void *v, loff_t *pos) 1113static void *m_next(struct seq_file *m, void *v, loff_t *pos)
1107{ 1114{
1108 struct proc_mounts *p = proc_mounts(m); 1115 struct proc_mounts *p = proc_mounts(m);
1109 1116
1110 return seq_list_next(v, &p->ns->list, pos); 1117 p->cached_mount = seq_list_next(v, &p->ns->list, pos);
1118 p->cached_index = *pos;
1119 return p->cached_mount;
1111} 1120}
1112 1121
1113static void m_stop(struct seq_file *m, void *v) 1122static void m_stop(struct seq_file *m, void *v)
@@ -1661,9 +1670,9 @@ static int attach_recursive_mnt(struct mount *source_mnt,
1661 if (err) 1670 if (err)
1662 goto out; 1671 goto out;
1663 err = propagate_mnt(dest_mnt, dest_mp, source_mnt, &tree_list); 1672 err = propagate_mnt(dest_mnt, dest_mp, source_mnt, &tree_list);
1673 lock_mount_hash();
1664 if (err) 1674 if (err)
1665 goto out_cleanup_ids; 1675 goto out_cleanup_ids;
1666 lock_mount_hash();
1667 for (p = source_mnt; p; p = next_mnt(p, source_mnt)) 1676 for (p = source_mnt; p; p = next_mnt(p, source_mnt))
1668 set_mnt_shared(p); 1677 set_mnt_shared(p);
1669 } else { 1678 } else {
@@ -1690,6 +1699,11 @@ static int attach_recursive_mnt(struct mount *source_mnt,
1690 return 0; 1699 return 0;
1691 1700
1692 out_cleanup_ids: 1701 out_cleanup_ids:
1702 while (!hlist_empty(&tree_list)) {
1703 child = hlist_entry(tree_list.first, struct mount, mnt_hash);
1704 umount_tree(child, 0);
1705 }
1706 unlock_mount_hash();
1693 cleanup_group_ids(source_mnt, NULL); 1707 cleanup_group_ids(source_mnt, NULL);
1694 out: 1708 out:
1695 return err; 1709 return err;
@@ -2044,7 +2058,7 @@ static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags)
2044 struct mount *parent; 2058 struct mount *parent;
2045 int err; 2059 int err;
2046 2060
2047 mnt_flags &= ~(MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | MNT_DOOMED | MNT_SYNC_UMOUNT); 2061 mnt_flags &= ~MNT_INTERNAL_FLAGS;
2048 2062
2049 mp = lock_mount(path); 2063 mp = lock_mount(path);
2050 if (IS_ERR(mp)) 2064 if (IS_ERR(mp))
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 81b4f643ecef..e31e589369a4 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -470,9 +470,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
470{ 470{
471 struct ncp_mount_data_kernel data; 471 struct ncp_mount_data_kernel data;
472 struct ncp_server *server; 472 struct ncp_server *server;
473 struct file *ncp_filp;
474 struct inode *root_inode; 473 struct inode *root_inode;
475 struct inode *sock_inode;
476 struct socket *sock; 474 struct socket *sock;
477 int error; 475 int error;
478 int default_bufsize; 476 int default_bufsize;
@@ -541,18 +539,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
541 if (!uid_valid(data.mounted_uid) || !uid_valid(data.uid) || 539 if (!uid_valid(data.mounted_uid) || !uid_valid(data.uid) ||
542 !gid_valid(data.gid)) 540 !gid_valid(data.gid))
543 goto out; 541 goto out;
544 error = -EBADF; 542 sock = sockfd_lookup(data.ncp_fd, &error);
545 ncp_filp = fget(data.ncp_fd);
546 if (!ncp_filp)
547 goto out;
548 error = -ENOTSOCK;
549 sock_inode = file_inode(ncp_filp);
550 if (!S_ISSOCK(sock_inode->i_mode))
551 goto out_fput;
552 sock = SOCKET_I(sock_inode);
553 if (!sock) 543 if (!sock)
554 goto out_fput; 544 goto out;
555 545
556 if (sock->type == SOCK_STREAM) 546 if (sock->type == SOCK_STREAM)
557 default_bufsize = 0xF000; 547 default_bufsize = 0xF000;
558 else 548 else
@@ -574,27 +564,16 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
574 if (error) 564 if (error)
575 goto out_fput; 565 goto out_fput;
576 566
577 server->ncp_filp = ncp_filp;
578 server->ncp_sock = sock; 567 server->ncp_sock = sock;
579 568
580 if (data.info_fd != -1) { 569 if (data.info_fd != -1) {
581 struct socket *info_sock; 570 struct socket *info_sock = sockfd_lookup(data.info_fd, &error);
582
583 error = -EBADF;
584 server->info_filp = fget(data.info_fd);
585 if (!server->info_filp)
586 goto out_bdi;
587 error = -ENOTSOCK;
588 sock_inode = file_inode(server->info_filp);
589 if (!S_ISSOCK(sock_inode->i_mode))
590 goto out_fput2;
591 info_sock = SOCKET_I(sock_inode);
592 if (!info_sock) 571 if (!info_sock)
593 goto out_fput2; 572 goto out_bdi;
573 server->info_sock = info_sock;
594 error = -EBADFD; 574 error = -EBADFD;
595 if (info_sock->type != SOCK_STREAM) 575 if (info_sock->type != SOCK_STREAM)
596 goto out_fput2; 576 goto out_fput2;
597 server->info_sock = info_sock;
598 } 577 }
599 578
600/* server->lock = 0; */ 579/* server->lock = 0; */
@@ -766,17 +745,12 @@ out_nls:
766 mutex_destroy(&server->root_setup_lock); 745 mutex_destroy(&server->root_setup_lock);
767 mutex_destroy(&server->mutex); 746 mutex_destroy(&server->mutex);
768out_fput2: 747out_fput2:
769 if (server->info_filp) 748 if (server->info_sock)
770 fput(server->info_filp); 749 sockfd_put(server->info_sock);
771out_bdi: 750out_bdi:
772 bdi_destroy(&server->bdi); 751 bdi_destroy(&server->bdi);
773out_fput: 752out_fput:
774 /* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>: 753 sockfd_put(sock);
775 *
776 * The previously used put_filp(ncp_filp); was bogus, since
777 * it doesn't perform proper unlocking.
778 */
779 fput(ncp_filp);
780out: 754out:
781 put_pid(data.wdog_pid); 755 put_pid(data.wdog_pid);
782 sb->s_fs_info = NULL; 756 sb->s_fs_info = NULL;
@@ -809,9 +783,9 @@ static void ncp_put_super(struct super_block *sb)
809 mutex_destroy(&server->root_setup_lock); 783 mutex_destroy(&server->root_setup_lock);
810 mutex_destroy(&server->mutex); 784 mutex_destroy(&server->mutex);
811 785
812 if (server->info_filp) 786 if (server->info_sock)
813 fput(server->info_filp); 787 sockfd_put(server->info_sock);
814 fput(server->ncp_filp); 788 sockfd_put(server->ncp_sock);
815 kill_pid(server->m.wdog_pid, SIGTERM, 1); 789 kill_pid(server->m.wdog_pid, SIGTERM, 1);
816 put_pid(server->m.wdog_pid); 790 put_pid(server->m.wdog_pid);
817 791
diff --git a/fs/ncpfs/ncp_fs_sb.h b/fs/ncpfs/ncp_fs_sb.h
index b81e97adc5a9..7fa17e459366 100644
--- a/fs/ncpfs/ncp_fs_sb.h
+++ b/fs/ncpfs/ncp_fs_sb.h
@@ -45,9 +45,7 @@ struct ncp_server {
45 45
46 __u8 name_space[NCP_NUMBER_OF_VOLUMES + 2]; 46 __u8 name_space[NCP_NUMBER_OF_VOLUMES + 2];
47 47
48 struct file *ncp_filp; /* File pointer to ncp socket */
49 struct socket *ncp_sock;/* ncp socket */ 48 struct socket *ncp_sock;/* ncp socket */
50 struct file *info_filp;
51 struct socket *info_sock; 49 struct socket *info_sock;
52 50
53 u8 sequence; 51 u8 sequence;
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 9d8153ebacfb..f47af5e6e230 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1704,8 +1704,6 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
1704 iput(bvi); 1704 iput(bvi);
1705skip_large_index_stuff: 1705skip_large_index_stuff:
1706 /* Setup the operations for this index inode. */ 1706 /* Setup the operations for this index inode. */
1707 vi->i_op = NULL;
1708 vi->i_fop = NULL;
1709 vi->i_mapping->a_ops = &ntfs_mst_aops; 1707 vi->i_mapping->a_ops = &ntfs_mst_aops;
1710 vi->i_blocks = ni->allocated_size >> 9; 1708 vi->i_blocks = ni->allocated_size >> 9;
1711 /* 1709 /*
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index eb649d23a4de..dfda2ffdb16c 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -916,57 +916,30 @@ static struct o2net_msg_handler *o2net_handler_get(u32 msg_type, u32 key)
916 916
917static int o2net_recv_tcp_msg(struct socket *sock, void *data, size_t len) 917static int o2net_recv_tcp_msg(struct socket *sock, void *data, size_t len)
918{ 918{
919 int ret; 919 struct kvec vec = { .iov_len = len, .iov_base = data, };
920 mm_segment_t oldfs; 920 struct msghdr msg = { .msg_flags = MSG_DONTWAIT, };
921 struct kvec vec = { 921 return kernel_recvmsg(sock, &msg, &vec, 1, len, msg.msg_flags);
922 .iov_len = len,
923 .iov_base = data,
924 };
925 struct msghdr msg = {
926 .msg_iovlen = 1,
927 .msg_iov = (struct iovec *)&vec,
928 .msg_flags = MSG_DONTWAIT,
929 };
930
931 oldfs = get_fs();
932 set_fs(get_ds());
933 ret = sock_recvmsg(sock, &msg, len, msg.msg_flags);
934 set_fs(oldfs);
935
936 return ret;
937} 922}
938 923
939static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec, 924static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec,
940 size_t veclen, size_t total) 925 size_t veclen, size_t total)
941{ 926{
942 int ret; 927 int ret;
943 mm_segment_t oldfs; 928 struct msghdr msg;
944 struct msghdr msg = {
945 .msg_iov = (struct iovec *)vec,
946 .msg_iovlen = veclen,
947 };
948 929
949 if (sock == NULL) { 930 if (sock == NULL) {
950 ret = -EINVAL; 931 ret = -EINVAL;
951 goto out; 932 goto out;
952 } 933 }
953 934
954 oldfs = get_fs(); 935 ret = kernel_sendmsg(sock, &msg, vec, veclen, total);
955 set_fs(get_ds()); 936 if (likely(ret == total))
956 ret = sock_sendmsg(sock, &msg, total); 937 return 0;
957 set_fs(oldfs); 938 mlog(ML_ERROR, "sendmsg returned %d instead of %zu\n", ret, total);
958 if (ret != total) { 939 if (ret >= 0)
959 mlog(ML_ERROR, "sendmsg returned %d instead of %zu\n", ret, 940 ret = -EPIPE; /* should be smarter, I bet */
960 total);
961 if (ret >= 0)
962 ret = -EPIPE; /* should be smarter, I bet */
963 goto out;
964 }
965
966 ret = 0;
967out: 941out:
968 if (ret < 0) 942 mlog(0, "returning error: %d\n", ret);
969 mlog(0, "returning error: %d\n", ret);
970 return ret; 943 return ret;
971} 944}
972 945
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index ff33c5ef87f2..8970dcf74de5 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2367,15 +2367,18 @@ relock:
2367 2367
2368 if (direct_io) { 2368 if (direct_io) {
2369 written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos, 2369 written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos,
2370 ppos, count, ocount); 2370 count, ocount);
2371 if (written < 0) { 2371 if (written < 0) {
2372 ret = written; 2372 ret = written;
2373 goto out_dio; 2373 goto out_dio;
2374 } 2374 }
2375 } else { 2375 } else {
2376 struct iov_iter from;
2377 iov_iter_init(&from, iov, nr_segs, count, 0);
2376 current->backing_dev_info = file->f_mapping->backing_dev_info; 2378 current->backing_dev_info = file->f_mapping->backing_dev_info;
2377 written = generic_file_buffered_write(iocb, iov, nr_segs, *ppos, 2379 written = generic_perform_write(file, &from, *ppos);
2378 ppos, count, 0); 2380 if (likely(written >= 0))
2381 iocb->ki_pos = *ppos + written;
2379 current->backing_dev_info = NULL; 2382 current->backing_dev_info = NULL;
2380 } 2383 }
2381 2384
diff --git a/fs/open.c b/fs/open.c
index 631aea815def..3d30eb1fc95e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -655,35 +655,6 @@ out:
655 return error; 655 return error;
656} 656}
657 657
658/*
659 * You have to be very careful that these write
660 * counts get cleaned up in error cases and
661 * upon __fput(). This should probably never
662 * be called outside of __dentry_open().
663 */
664static inline int __get_file_write_access(struct inode *inode,
665 struct vfsmount *mnt)
666{
667 int error;
668 error = get_write_access(inode);
669 if (error)
670 return error;
671 /*
672 * Do not take mount writer counts on
673 * special files since no writes to
674 * the mount itself will occur.
675 */
676 if (!special_file(inode->i_mode)) {
677 /*
678 * Balanced in __fput()
679 */
680 error = __mnt_want_write(mnt);
681 if (error)
682 put_write_access(inode);
683 }
684 return error;
685}
686
687int open_check_o_direct(struct file *f) 658int open_check_o_direct(struct file *f)
688{ 659{
689 /* NB: we're sure to have correct a_ops only after f_op->open */ 660 /* NB: we're sure to have correct a_ops only after f_op->open */
@@ -708,26 +679,28 @@ static int do_dentry_open(struct file *f,
708 f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK | 679 f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK |
709 FMODE_PREAD | FMODE_PWRITE; 680 FMODE_PREAD | FMODE_PWRITE;
710 681
711 if (unlikely(f->f_flags & O_PATH))
712 f->f_mode = FMODE_PATH;
713
714 path_get(&f->f_path); 682 path_get(&f->f_path);
715 inode = f->f_inode = f->f_path.dentry->d_inode; 683 inode = f->f_inode = f->f_path.dentry->d_inode;
716 if (f->f_mode & FMODE_WRITE) {
717 error = __get_file_write_access(inode, f->f_path.mnt);
718 if (error)
719 goto cleanup_file;
720 if (!special_file(inode->i_mode))
721 file_take_write(f);
722 }
723
724 f->f_mapping = inode->i_mapping; 684 f->f_mapping = inode->i_mapping;
725 685
726 if (unlikely(f->f_mode & FMODE_PATH)) { 686 if (unlikely(f->f_flags & O_PATH)) {
687 f->f_mode = FMODE_PATH;
727 f->f_op = &empty_fops; 688 f->f_op = &empty_fops;
728 return 0; 689 return 0;
729 } 690 }
730 691
692 if (f->f_mode & FMODE_WRITE && !special_file(inode->i_mode)) {
693 error = get_write_access(inode);
694 if (unlikely(error))
695 goto cleanup_file;
696 error = __mnt_want_write(f->f_path.mnt);
697 if (unlikely(error)) {
698 put_write_access(inode);
699 goto cleanup_file;
700 }
701 f->f_mode |= FMODE_WRITER;
702 }
703
731 /* POSIX.1-2008/SUSv4 Section XSI 2.9.7 */ 704 /* POSIX.1-2008/SUSv4 Section XSI 2.9.7 */
732 if (S_ISREG(inode->i_mode)) 705 if (S_ISREG(inode->i_mode))
733 f->f_mode |= FMODE_ATOMIC_POS; 706 f->f_mode |= FMODE_ATOMIC_POS;
@@ -764,18 +737,9 @@ static int do_dentry_open(struct file *f,
764 737
765cleanup_all: 738cleanup_all:
766 fops_put(f->f_op); 739 fops_put(f->f_op);
767 if (f->f_mode & FMODE_WRITE) { 740 if (f->f_mode & FMODE_WRITER) {
768 put_write_access(inode); 741 put_write_access(inode);
769 if (!special_file(inode->i_mode)) { 742 __mnt_drop_write(f->f_path.mnt);
770 /*
771 * We don't consider this a real
772 * mnt_want/drop_write() pair
773 * because it all happenend right
774 * here, so just reset the state.
775 */
776 file_reset_write(f);
777 __mnt_drop_write(f->f_path.mnt);
778 }
779 } 743 }
780cleanup_file: 744cleanup_file:
781 path_put(&f->f_path); 745 path_put(&f->f_path);
diff --git a/fs/pipe.c b/fs/pipe.c
index 78fd0d0788db..034bffac3f97 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -142,55 +142,6 @@ pipe_iov_copy_from_user(void *to, struct iovec *iov, unsigned long len,
142 return 0; 142 return 0;
143} 143}
144 144
145static int
146pipe_iov_copy_to_user(struct iovec *iov, const void *from, unsigned long len,
147 int atomic)
148{
149 unsigned long copy;
150
151 while (len > 0) {
152 while (!iov->iov_len)
153 iov++;
154 copy = min_t(unsigned long, len, iov->iov_len);
155
156 if (atomic) {
157 if (__copy_to_user_inatomic(iov->iov_base, from, copy))
158 return -EFAULT;
159 } else {
160 if (copy_to_user(iov->iov_base, from, copy))
161 return -EFAULT;
162 }
163 from += copy;
164 len -= copy;
165 iov->iov_base += copy;
166 iov->iov_len -= copy;
167 }
168 return 0;
169}
170
171/*
172 * Attempt to pre-fault in the user memory, so we can use atomic copies.
173 * Returns the number of bytes not faulted in.
174 */
175static int iov_fault_in_pages_write(struct iovec *iov, unsigned long len)
176{
177 while (!iov->iov_len)
178 iov++;
179
180 while (len > 0) {
181 unsigned long this_len;
182
183 this_len = min_t(unsigned long, len, iov->iov_len);
184 if (fault_in_pages_writeable(iov->iov_base, this_len))
185 break;
186
187 len -= this_len;
188 iov++;
189 }
190
191 return len;
192}
193
194/* 145/*
195 * Pre-fault in the user memory, so we can use atomic copies. 146 * Pre-fault in the user memory, so we can use atomic copies.
196 */ 147 */
@@ -226,52 +177,6 @@ static void anon_pipe_buf_release(struct pipe_inode_info *pipe,
226} 177}
227 178
228/** 179/**
229 * generic_pipe_buf_map - virtually map a pipe buffer
230 * @pipe: the pipe that the buffer belongs to
231 * @buf: the buffer that should be mapped
232 * @atomic: whether to use an atomic map
233 *
234 * Description:
235 * This function returns a kernel virtual address mapping for the
236 * pipe_buffer passed in @buf. If @atomic is set, an atomic map is provided
237 * and the caller has to be careful not to fault before calling
238 * the unmap function.
239 *
240 * Note that this function calls kmap_atomic() if @atomic != 0.
241 */
242void *generic_pipe_buf_map(struct pipe_inode_info *pipe,
243 struct pipe_buffer *buf, int atomic)
244{
245 if (atomic) {
246 buf->flags |= PIPE_BUF_FLAG_ATOMIC;
247 return kmap_atomic(buf->page);
248 }
249
250 return kmap(buf->page);
251}
252EXPORT_SYMBOL(generic_pipe_buf_map);
253
254/**
255 * generic_pipe_buf_unmap - unmap a previously mapped pipe buffer
256 * @pipe: the pipe that the buffer belongs to
257 * @buf: the buffer that should be unmapped
258 * @map_data: the data that the mapping function returned
259 *
260 * Description:
261 * This function undoes the mapping that ->map() provided.
262 */
263void generic_pipe_buf_unmap(struct pipe_inode_info *pipe,
264 struct pipe_buffer *buf, void *map_data)
265{
266 if (buf->flags & PIPE_BUF_FLAG_ATOMIC) {
267 buf->flags &= ~PIPE_BUF_FLAG_ATOMIC;
268 kunmap_atomic(map_data);
269 } else
270 kunmap(buf->page);
271}
272EXPORT_SYMBOL(generic_pipe_buf_unmap);
273
274/**
275 * generic_pipe_buf_steal - attempt to take ownership of a &pipe_buffer 180 * generic_pipe_buf_steal - attempt to take ownership of a &pipe_buffer
276 * @pipe: the pipe that the buffer belongs to 181 * @pipe: the pipe that the buffer belongs to
277 * @buf: the buffer to attempt to steal 182 * @buf: the buffer to attempt to steal
@@ -351,8 +256,6 @@ EXPORT_SYMBOL(generic_pipe_buf_release);
351 256
352static const struct pipe_buf_operations anon_pipe_buf_ops = { 257static const struct pipe_buf_operations anon_pipe_buf_ops = {
353 .can_merge = 1, 258 .can_merge = 1,
354 .map = generic_pipe_buf_map,
355 .unmap = generic_pipe_buf_unmap,
356 .confirm = generic_pipe_buf_confirm, 259 .confirm = generic_pipe_buf_confirm,
357 .release = anon_pipe_buf_release, 260 .release = anon_pipe_buf_release,
358 .steal = generic_pipe_buf_steal, 261 .steal = generic_pipe_buf_steal,
@@ -361,8 +264,6 @@ static const struct pipe_buf_operations anon_pipe_buf_ops = {
361 264
362static const struct pipe_buf_operations packet_pipe_buf_ops = { 265static const struct pipe_buf_operations packet_pipe_buf_ops = {
363 .can_merge = 0, 266 .can_merge = 0,
364 .map = generic_pipe_buf_map,
365 .unmap = generic_pipe_buf_unmap,
366 .confirm = generic_pipe_buf_confirm, 267 .confirm = generic_pipe_buf_confirm,
367 .release = anon_pipe_buf_release, 268 .release = anon_pipe_buf_release,
368 .steal = generic_pipe_buf_steal, 269 .steal = generic_pipe_buf_steal,
@@ -379,12 +280,15 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
379 ssize_t ret; 280 ssize_t ret;
380 struct iovec *iov = (struct iovec *)_iov; 281 struct iovec *iov = (struct iovec *)_iov;
381 size_t total_len; 282 size_t total_len;
283 struct iov_iter iter;
382 284
383 total_len = iov_length(iov, nr_segs); 285 total_len = iov_length(iov, nr_segs);
384 /* Null read succeeds. */ 286 /* Null read succeeds. */
385 if (unlikely(total_len == 0)) 287 if (unlikely(total_len == 0))
386 return 0; 288 return 0;
387 289
290 iov_iter_init(&iter, iov, nr_segs, total_len, 0);
291
388 do_wakeup = 0; 292 do_wakeup = 0;
389 ret = 0; 293 ret = 0;
390 __pipe_lock(pipe); 294 __pipe_lock(pipe);
@@ -394,9 +298,9 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
394 int curbuf = pipe->curbuf; 298 int curbuf = pipe->curbuf;
395 struct pipe_buffer *buf = pipe->bufs + curbuf; 299 struct pipe_buffer *buf = pipe->bufs + curbuf;
396 const struct pipe_buf_operations *ops = buf->ops; 300 const struct pipe_buf_operations *ops = buf->ops;
397 void *addr;
398 size_t chars = buf->len; 301 size_t chars = buf->len;
399 int error, atomic; 302 size_t written;
303 int error;
400 304
401 if (chars > total_len) 305 if (chars > total_len)
402 chars = total_len; 306 chars = total_len;
@@ -408,21 +312,10 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
408 break; 312 break;
409 } 313 }
410 314
411 atomic = !iov_fault_in_pages_write(iov, chars); 315 written = copy_page_to_iter(buf->page, buf->offset, chars, &iter);
412redo: 316 if (unlikely(written < chars)) {
413 addr = ops->map(pipe, buf, atomic);
414 error = pipe_iov_copy_to_user(iov, addr + buf->offset, chars, atomic);
415 ops->unmap(pipe, buf, addr);
416 if (unlikely(error)) {
417 /*
418 * Just retry with the slow path if we failed.
419 */
420 if (atomic) {
421 atomic = 0;
422 goto redo;
423 }
424 if (!ret) 317 if (!ret)
425 ret = error; 318 ret = -EFAULT;
426 break; 319 break;
427 } 320 }
428 ret += chars; 321 ret += chars;
@@ -538,10 +431,16 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
538 431
539 iov_fault_in_pages_read(iov, chars); 432 iov_fault_in_pages_read(iov, chars);
540redo1: 433redo1:
541 addr = ops->map(pipe, buf, atomic); 434 if (atomic)
435 addr = kmap_atomic(buf->page);
436 else
437 addr = kmap(buf->page);
542 error = pipe_iov_copy_from_user(offset + addr, iov, 438 error = pipe_iov_copy_from_user(offset + addr, iov,
543 chars, atomic); 439 chars, atomic);
544 ops->unmap(pipe, buf, addr); 440 if (atomic)
441 kunmap_atomic(addr);
442 else
443 kunmap(buf->page);
545 ret = error; 444 ret = error;
546 do_wakeup = 1; 445 do_wakeup = 1;
547 if (error) { 446 if (error) {
diff --git a/fs/pnode.c b/fs/pnode.c
index 88396df725b4..302bf22c4a30 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -164,46 +164,94 @@ static struct mount *propagation_next(struct mount *m,
164 } 164 }
165} 165}
166 166
167/* 167static struct mount *next_group(struct mount *m, struct mount *origin)
168 * return the source mount to be used for cloning
169 *
170 * @dest the current destination mount
171 * @last_dest the last seen destination mount
172 * @last_src the last seen source mount
173 * @type return CL_SLAVE if the new mount has to be
174 * cloned as a slave.
175 */
176static struct mount *get_source(struct mount *dest,
177 struct mount *last_dest,
178 struct mount *last_src,
179 int *type)
180{ 168{
181 struct mount *p_last_src = NULL; 169 while (1) {
182 struct mount *p_last_dest = NULL; 170 while (1) {
183 171 struct mount *next;
184 while (last_dest != dest->mnt_master) { 172 if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list))
185 p_last_dest = last_dest; 173 return first_slave(m);
186 p_last_src = last_src; 174 next = next_peer(m);
187 last_dest = last_dest->mnt_master; 175 if (m->mnt_group_id == origin->mnt_group_id) {
188 last_src = last_src->mnt_master; 176 if (next == origin)
177 return NULL;
178 } else if (m->mnt_slave.next != &next->mnt_slave)
179 break;
180 m = next;
181 }
182 /* m is the last peer */
183 while (1) {
184 struct mount *master = m->mnt_master;
185 if (m->mnt_slave.next != &master->mnt_slave_list)
186 return next_slave(m);
187 m = next_peer(master);
188 if (master->mnt_group_id == origin->mnt_group_id)
189 break;
190 if (master->mnt_slave.next == &m->mnt_slave)
191 break;
192 m = master;
193 }
194 if (m == origin)
195 return NULL;
189 } 196 }
197}
190 198
191 if (p_last_dest) { 199/* all accesses are serialized by namespace_sem */
192 do { 200static struct user_namespace *user_ns;
193 p_last_dest = next_peer(p_last_dest); 201static struct mount *last_dest, *last_source, *dest_master;
194 } while (IS_MNT_NEW(p_last_dest)); 202static struct mountpoint *mp;
195 /* is that a peer of the earlier? */ 203static struct hlist_head *list;
196 if (dest == p_last_dest) { 204
197 *type = CL_MAKE_SHARED; 205static int propagate_one(struct mount *m)
198 return p_last_src; 206{
207 struct mount *child;
208 int type;
209 /* skip ones added by this propagate_mnt() */
210 if (IS_MNT_NEW(m))
211 return 0;
212 /* skip if mountpoint isn't covered by it */
213 if (!is_subdir(mp->m_dentry, m->mnt.mnt_root))
214 return 0;
215 if (m->mnt_group_id == last_dest->mnt_group_id) {
216 type = CL_MAKE_SHARED;
217 } else {
218 struct mount *n, *p;
219 for (n = m; ; n = p) {
220 p = n->mnt_master;
221 if (p == dest_master || IS_MNT_MARKED(p)) {
222 while (last_dest->mnt_master != p) {
223 last_source = last_source->mnt_master;
224 last_dest = last_source->mnt_parent;
225 }
226 if (n->mnt_group_id != last_dest->mnt_group_id) {
227 last_source = last_source->mnt_master;
228 last_dest = last_source->mnt_parent;
229 }
230 break;
231 }
199 } 232 }
233 type = CL_SLAVE;
234 /* beginning of peer group among the slaves? */
235 if (IS_MNT_SHARED(m))
236 type |= CL_MAKE_SHARED;
200 } 237 }
201 /* slave of the earlier, then */ 238
202 *type = CL_SLAVE; 239 /* Notice when we are propagating across user namespaces */
203 /* beginning of peer group among the slaves? */ 240 if (m->mnt_ns->user_ns != user_ns)
204 if (IS_MNT_SHARED(dest)) 241 type |= CL_UNPRIVILEGED;
205 *type |= CL_MAKE_SHARED; 242 child = copy_tree(last_source, last_source->mnt.mnt_root, type);
206 return last_src; 243 if (IS_ERR(child))
244 return PTR_ERR(child);
245 mnt_set_mountpoint(m, mp, child);
246 last_dest = m;
247 last_source = child;
248 if (m->mnt_master != dest_master) {
249 read_seqlock_excl(&mount_lock);
250 SET_MNT_MARK(m->mnt_master);
251 read_sequnlock_excl(&mount_lock);
252 }
253 hlist_add_head(&child->mnt_hash, list);
254 return 0;
207} 255}
208 256
209/* 257/*
@@ -222,56 +270,48 @@ static struct mount *get_source(struct mount *dest,
222int propagate_mnt(struct mount *dest_mnt, struct mountpoint *dest_mp, 270int propagate_mnt(struct mount *dest_mnt, struct mountpoint *dest_mp,
223 struct mount *source_mnt, struct hlist_head *tree_list) 271 struct mount *source_mnt, struct hlist_head *tree_list)
224{ 272{
225 struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns; 273 struct mount *m, *n;
226 struct mount *m, *child;
227 int ret = 0; 274 int ret = 0;
228 struct mount *prev_dest_mnt = dest_mnt; 275
229 struct mount *prev_src_mnt = source_mnt; 276 /*
230 HLIST_HEAD(tmp_list); 277 * we don't want to bother passing tons of arguments to
231 278 * propagate_one(); everything is serialized by namespace_sem,
232 for (m = propagation_next(dest_mnt, dest_mnt); m; 279 * so globals will do just fine.
233 m = propagation_next(m, dest_mnt)) { 280 */
234 int type; 281 user_ns = current->nsproxy->mnt_ns->user_ns;
235 struct mount *source; 282 last_dest = dest_mnt;
236 283 last_source = source_mnt;
237 if (IS_MNT_NEW(m)) 284 mp = dest_mp;
238 continue; 285 list = tree_list;
239 286 dest_master = dest_mnt->mnt_master;
240 source = get_source(m, prev_dest_mnt, prev_src_mnt, &type); 287
241 288 /* all peers of dest_mnt, except dest_mnt itself */
242 /* Notice when we are propagating across user namespaces */ 289 for (n = next_peer(dest_mnt); n != dest_mnt; n = next_peer(n)) {
243 if (m->mnt_ns->user_ns != user_ns) 290 ret = propagate_one(n);
244 type |= CL_UNPRIVILEGED; 291 if (ret)
245
246 child = copy_tree(source, source->mnt.mnt_root, type);
247 if (IS_ERR(child)) {
248 ret = PTR_ERR(child);
249 tmp_list = *tree_list;
250 tmp_list.first->pprev = &tmp_list.first;
251 INIT_HLIST_HEAD(tree_list);
252 goto out; 292 goto out;
253 } 293 }
254 294
255 if (is_subdir(dest_mp->m_dentry, m->mnt.mnt_root)) { 295 /* all slave groups */
256 mnt_set_mountpoint(m, dest_mp, child); 296 for (m = next_group(dest_mnt, dest_mnt); m;
257 hlist_add_head(&child->mnt_hash, tree_list); 297 m = next_group(m, dest_mnt)) {
258 } else { 298 /* everything in that slave group */
259 /* 299 n = m;
260 * This can happen if the parent mount was bind mounted 300 do {
261 * on some subdirectory of a shared/slave mount. 301 ret = propagate_one(n);
262 */ 302 if (ret)
263 hlist_add_head(&child->mnt_hash, &tmp_list); 303 goto out;
264 } 304 n = next_peer(n);
265 prev_dest_mnt = m; 305 } while (n != m);
266 prev_src_mnt = child;
267 } 306 }
268out: 307out:
269 lock_mount_hash(); 308 read_seqlock_excl(&mount_lock);
270 while (!hlist_empty(&tmp_list)) { 309 hlist_for_each_entry(n, tree_list, mnt_hash) {
271 child = hlist_entry(tmp_list.first, struct mount, mnt_hash); 310 m = n->mnt_parent;
272 umount_tree(child, 0); 311 if (m->mnt_master != dest_mnt->mnt_master)
312 CLEAR_MNT_MARK(m->mnt_master);
273 } 313 }
274 unlock_mount_hash(); 314 read_sequnlock_excl(&mount_lock);
275 return ret; 315 return ret;
276} 316}
277 317
diff --git a/fs/pnode.h b/fs/pnode.h
index fc28a27fa892..4a246358b031 100644
--- a/fs/pnode.h
+++ b/fs/pnode.h
@@ -16,6 +16,9 @@
16#define IS_MNT_NEW(m) (!(m)->mnt_ns) 16#define IS_MNT_NEW(m) (!(m)->mnt_ns)
17#define CLEAR_MNT_SHARED(m) ((m)->mnt.mnt_flags &= ~MNT_SHARED) 17#define CLEAR_MNT_SHARED(m) ((m)->mnt.mnt_flags &= ~MNT_SHARED)
18#define IS_MNT_UNBINDABLE(m) ((m)->mnt.mnt_flags & MNT_UNBINDABLE) 18#define IS_MNT_UNBINDABLE(m) ((m)->mnt.mnt_flags & MNT_UNBINDABLE)
19#define IS_MNT_MARKED(m) ((m)->mnt.mnt_flags & MNT_MARKED)
20#define SET_MNT_MARK(m) ((m)->mnt.mnt_flags |= MNT_MARKED)
21#define CLEAR_MNT_MARK(m) ((m)->mnt.mnt_flags &= ~MNT_MARKED)
19 22
20#define CL_EXPIRE 0x01 23#define CL_EXPIRE 0x01
21#define CL_SLAVE 0x02 24#define CL_SLAVE 0x02
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 9ae46b87470d..89026095f2b5 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -146,7 +146,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
146 struct task_struct *task; 146 struct task_struct *task;
147 void *ns; 147 void *ns;
148 char name[50]; 148 char name[50];
149 int len = -EACCES; 149 int res = -EACCES;
150 150
151 task = get_proc_task(inode); 151 task = get_proc_task(inode);
152 if (!task) 152 if (!task)
@@ -155,24 +155,18 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
155 if (!ptrace_may_access(task, PTRACE_MODE_READ)) 155 if (!ptrace_may_access(task, PTRACE_MODE_READ))
156 goto out_put_task; 156 goto out_put_task;
157 157
158 len = -ENOENT; 158 res = -ENOENT;
159 ns = ns_ops->get(task); 159 ns = ns_ops->get(task);
160 if (!ns) 160 if (!ns)
161 goto out_put_task; 161 goto out_put_task;
162 162
163 snprintf(name, sizeof(name), "%s:[%u]", ns_ops->name, ns_ops->inum(ns)); 163 snprintf(name, sizeof(name), "%s:[%u]", ns_ops->name, ns_ops->inum(ns));
164 len = strlen(name); 164 res = readlink_copy(buffer, buflen, name);
165
166 if (len > buflen)
167 len = buflen;
168 if (copy_to_user(buffer, name, len))
169 len = -EFAULT;
170
171 ns_ops->put(ns); 165 ns_ops->put(ns);
172out_put_task: 166out_put_task:
173 put_task_struct(task); 167 put_task_struct(task);
174out: 168out:
175 return len; 169 return res;
176} 170}
177 171
178static const struct inode_operations proc_ns_link_inode_operations = { 172static const struct inode_operations proc_ns_link_inode_operations = {
diff --git a/fs/proc/self.c b/fs/proc/self.c
index ffeb202ec942..4348bb8907c2 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -16,7 +16,7 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
16 if (!tgid) 16 if (!tgid)
17 return -ENOENT; 17 return -ENOENT;
18 sprintf(tmp, "%d", tgid); 18 sprintf(tmp, "%d", tgid);
19 return vfs_readlink(dentry,buffer,buflen,tmp); 19 return readlink_copy(buffer, buflen, tmp);
20} 20}
21 21
22static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) 22static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index 7be26f03a3f5..1a81373947f3 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -267,6 +267,7 @@ static int mounts_open_common(struct inode *inode, struct file *file,
267 p->root = root; 267 p->root = root;
268 p->m.poll_event = ns->event; 268 p->m.poll_event = ns->event;
269 p->show = show; 269 p->show = show;
270 p->cached_event = ~0ULL;
270 271
271 return 0; 272 return 0;
272 273
diff --git a/fs/splice.c b/fs/splice.c
index 12028fa41def..9bc07d2b53cf 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -136,8 +136,6 @@ error:
136 136
137const struct pipe_buf_operations page_cache_pipe_buf_ops = { 137const struct pipe_buf_operations page_cache_pipe_buf_ops = {
138 .can_merge = 0, 138 .can_merge = 0,
139 .map = generic_pipe_buf_map,
140 .unmap = generic_pipe_buf_unmap,
141 .confirm = page_cache_pipe_buf_confirm, 139 .confirm = page_cache_pipe_buf_confirm,
142 .release = page_cache_pipe_buf_release, 140 .release = page_cache_pipe_buf_release,
143 .steal = page_cache_pipe_buf_steal, 141 .steal = page_cache_pipe_buf_steal,
@@ -156,8 +154,6 @@ static int user_page_pipe_buf_steal(struct pipe_inode_info *pipe,
156 154
157static const struct pipe_buf_operations user_page_pipe_buf_ops = { 155static const struct pipe_buf_operations user_page_pipe_buf_ops = {
158 .can_merge = 0, 156 .can_merge = 0,
159 .map = generic_pipe_buf_map,
160 .unmap = generic_pipe_buf_unmap,
161 .confirm = generic_pipe_buf_confirm, 157 .confirm = generic_pipe_buf_confirm,
162 .release = page_cache_pipe_buf_release, 158 .release = page_cache_pipe_buf_release,
163 .steal = user_page_pipe_buf_steal, 159 .steal = user_page_pipe_buf_steal,
@@ -547,8 +543,6 @@ EXPORT_SYMBOL(generic_file_splice_read);
547 543
548static const struct pipe_buf_operations default_pipe_buf_ops = { 544static const struct pipe_buf_operations default_pipe_buf_ops = {
549 .can_merge = 0, 545 .can_merge = 0,
550 .map = generic_pipe_buf_map,
551 .unmap = generic_pipe_buf_unmap,
552 .confirm = generic_pipe_buf_confirm, 546 .confirm = generic_pipe_buf_confirm,
553 .release = generic_pipe_buf_release, 547 .release = generic_pipe_buf_release,
554 .steal = generic_pipe_buf_steal, 548 .steal = generic_pipe_buf_steal,
@@ -564,8 +558,6 @@ static int generic_pipe_buf_nosteal(struct pipe_inode_info *pipe,
564/* Pipe buffer operations for a socket and similar. */ 558/* Pipe buffer operations for a socket and similar. */
565const struct pipe_buf_operations nosteal_pipe_buf_ops = { 559const struct pipe_buf_operations nosteal_pipe_buf_ops = {
566 .can_merge = 0, 560 .can_merge = 0,
567 .map = generic_pipe_buf_map,
568 .unmap = generic_pipe_buf_unmap,
569 .confirm = generic_pipe_buf_confirm, 561 .confirm = generic_pipe_buf_confirm,
570 .release = generic_pipe_buf_release, 562 .release = generic_pipe_buf_release,
571 .steal = generic_pipe_buf_nosteal, 563 .steal = generic_pipe_buf_nosteal,
@@ -767,13 +759,13 @@ int pipe_to_file(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
767 goto out; 759 goto out;
768 760
769 if (buf->page != page) { 761 if (buf->page != page) {
770 char *src = buf->ops->map(pipe, buf, 1); 762 char *src = kmap_atomic(buf->page);
771 char *dst = kmap_atomic(page); 763 char *dst = kmap_atomic(page);
772 764
773 memcpy(dst + offset, src + buf->offset, this_len); 765 memcpy(dst + offset, src + buf->offset, this_len);
774 flush_dcache_page(page); 766 flush_dcache_page(page);
775 kunmap_atomic(dst); 767 kunmap_atomic(dst);
776 buf->ops->unmap(pipe, buf, src); 768 kunmap_atomic(src);
777 } 769 }
778 ret = pagecache_write_end(file, mapping, sd->pos, this_len, this_len, 770 ret = pagecache_write_end(file, mapping, sd->pos, this_len, this_len,
779 page, fsdata); 771 page, fsdata);
@@ -1067,9 +1059,9 @@ static int write_pipe_buf(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
1067 void *data; 1059 void *data;
1068 loff_t tmp = sd->pos; 1060 loff_t tmp = sd->pos;
1069 1061
1070 data = buf->ops->map(pipe, buf, 0); 1062 data = kmap(buf->page);
1071 ret = __kernel_write(sd->u.file, data + buf->offset, sd->len, &tmp); 1063 ret = __kernel_write(sd->u.file, data + buf->offset, sd->len, &tmp);
1072 buf->ops->unmap(pipe, buf, data); 1064 kunmap(buf->page);
1073 1065
1074 return ret; 1066 return ret;
1075} 1067}
@@ -1528,116 +1520,48 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1528static int pipe_to_user(struct pipe_inode_info *pipe, struct pipe_buffer *buf, 1520static int pipe_to_user(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
1529 struct splice_desc *sd) 1521 struct splice_desc *sd)
1530{ 1522{
1531 char *src; 1523 int n = copy_page_to_iter(buf->page, buf->offset, sd->len, sd->u.data);
1532 int ret; 1524 return n == sd->len ? n : -EFAULT;
1533
1534 /*
1535 * See if we can use the atomic maps, by prefaulting in the
1536 * pages and doing an atomic copy
1537 */
1538 if (!fault_in_pages_writeable(sd->u.userptr, sd->len)) {
1539 src = buf->ops->map(pipe, buf, 1);
1540 ret = __copy_to_user_inatomic(sd->u.userptr, src + buf->offset,
1541 sd->len);
1542 buf->ops->unmap(pipe, buf, src);
1543 if (!ret) {
1544 ret = sd->len;
1545 goto out;
1546 }
1547 }
1548
1549 /*
1550 * No dice, use slow non-atomic map and copy
1551 */
1552 src = buf->ops->map(pipe, buf, 0);
1553
1554 ret = sd->len;
1555 if (copy_to_user(sd->u.userptr, src + buf->offset, sd->len))
1556 ret = -EFAULT;
1557
1558 buf->ops->unmap(pipe, buf, src);
1559out:
1560 if (ret > 0)
1561 sd->u.userptr += ret;
1562 return ret;
1563} 1525}
1564 1526
1565/* 1527/*
1566 * For lack of a better implementation, implement vmsplice() to userspace 1528 * For lack of a better implementation, implement vmsplice() to userspace
1567 * as a simple copy of the pipes pages to the user iov. 1529 * as a simple copy of the pipes pages to the user iov.
1568 */ 1530 */
1569static long vmsplice_to_user(struct file *file, const struct iovec __user *iov, 1531static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov,
1570 unsigned long nr_segs, unsigned int flags) 1532 unsigned long nr_segs, unsigned int flags)
1571{ 1533{
1572 struct pipe_inode_info *pipe; 1534 struct pipe_inode_info *pipe;
1573 struct splice_desc sd; 1535 struct splice_desc sd;
1574 ssize_t size;
1575 int error;
1576 long ret; 1536 long ret;
1537 struct iovec iovstack[UIO_FASTIOV];
1538 struct iovec *iov = iovstack;
1539 struct iov_iter iter;
1540 ssize_t count = 0;
1577 1541
1578 pipe = get_pipe_info(file); 1542 pipe = get_pipe_info(file);
1579 if (!pipe) 1543 if (!pipe)
1580 return -EBADF; 1544 return -EBADF;
1581 1545
1582 pipe_lock(pipe); 1546 ret = rw_copy_check_uvector(READ, uiov, nr_segs,
1583 1547 ARRAY_SIZE(iovstack), iovstack, &iov);
1584 error = ret = 0; 1548 if (ret <= 0)
1585 while (nr_segs) { 1549 return ret;
1586 void __user *base;
1587 size_t len;
1588
1589 /*
1590 * Get user address base and length for this iovec.
1591 */
1592 error = get_user(base, &iov->iov_base);
1593 if (unlikely(error))
1594 break;
1595 error = get_user(len, &iov->iov_len);
1596 if (unlikely(error))
1597 break;
1598
1599 /*
1600 * Sanity check this iovec. 0 read succeeds.
1601 */
1602 if (unlikely(!len))
1603 break;
1604 if (unlikely(!base)) {
1605 error = -EFAULT;
1606 break;
1607 }
1608
1609 if (unlikely(!access_ok(VERIFY_WRITE, base, len))) {
1610 error = -EFAULT;
1611 break;
1612 }
1613
1614 sd.len = 0;
1615 sd.total_len = len;
1616 sd.flags = flags;
1617 sd.u.userptr = base;
1618 sd.pos = 0;
1619
1620 size = __splice_from_pipe(pipe, &sd, pipe_to_user);
1621 if (size < 0) {
1622 if (!ret)
1623 ret = size;
1624
1625 break;
1626 }
1627
1628 ret += size;
1629 1550
1630 if (size < len) 1551 iov_iter_init(&iter, iov, nr_segs, count, 0);
1631 break;
1632 1552
1633 nr_segs--; 1553 sd.len = 0;
1634 iov++; 1554 sd.total_len = count;
1635 } 1555 sd.flags = flags;
1556 sd.u.data = &iter;
1557 sd.pos = 0;
1636 1558
1559 pipe_lock(pipe);
1560 ret = __splice_from_pipe(pipe, &sd, pipe_to_user);
1637 pipe_unlock(pipe); 1561 pipe_unlock(pipe);
1638 1562
1639 if (!ret) 1563 if (iov != iovstack)
1640 ret = error; 1564 kfree(iov);
1641 1565
1642 return ret; 1566 return ret;
1643} 1567}
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 1037637957c7..d2c170f8b035 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -171,7 +171,7 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
171 } else 171 } else
172 up_write(&iinfo->i_data_sem); 172 up_write(&iinfo->i_data_sem);
173 173
174 retval = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 174 retval = __generic_file_aio_write(iocb, iov, nr_segs);
175 mutex_unlock(&inode->i_mutex); 175 mutex_unlock(&inode->i_mutex);
176 176
177 if (retval > 0) { 177 if (retval > 0) {
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 003c0051b62f..79e96ce98733 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -699,7 +699,7 @@ xfs_file_dio_aio_write(
699 699
700 trace_xfs_file_direct_write(ip, count, iocb->ki_pos, 0); 700 trace_xfs_file_direct_write(ip, count, iocb->ki_pos, 0);
701 ret = generic_file_direct_write(iocb, iovp, 701 ret = generic_file_direct_write(iocb, iovp,
702 &nr_segs, pos, &iocb->ki_pos, count, ocount); 702 &nr_segs, pos, count, ocount);
703 703
704out: 704out:
705 xfs_rw_iunlock(ip, iolock); 705 xfs_rw_iunlock(ip, iolock);
@@ -715,7 +715,7 @@ xfs_file_buffered_aio_write(
715 const struct iovec *iovp, 715 const struct iovec *iovp,
716 unsigned long nr_segs, 716 unsigned long nr_segs,
717 loff_t pos, 717 loff_t pos,
718 size_t ocount) 718 size_t count)
719{ 719{
720 struct file *file = iocb->ki_filp; 720 struct file *file = iocb->ki_filp;
721 struct address_space *mapping = file->f_mapping; 721 struct address_space *mapping = file->f_mapping;
@@ -724,7 +724,7 @@ xfs_file_buffered_aio_write(
724 ssize_t ret; 724 ssize_t ret;
725 int enospc = 0; 725 int enospc = 0;
726 int iolock = XFS_IOLOCK_EXCL; 726 int iolock = XFS_IOLOCK_EXCL;
727 size_t count = ocount; 727 struct iov_iter from;
728 728
729 xfs_rw_ilock(ip, iolock); 729 xfs_rw_ilock(ip, iolock);
730 730
@@ -732,14 +732,15 @@ xfs_file_buffered_aio_write(
732 if (ret) 732 if (ret)
733 goto out; 733 goto out;
734 734
735 iov_iter_init(&from, iovp, nr_segs, count, 0);
735 /* We can write back this queue in page reclaim */ 736 /* We can write back this queue in page reclaim */
736 current->backing_dev_info = mapping->backing_dev_info; 737 current->backing_dev_info = mapping->backing_dev_info;
737 738
738write_retry: 739write_retry:
739 trace_xfs_file_buffered_write(ip, count, iocb->ki_pos, 0); 740 trace_xfs_file_buffered_write(ip, count, iocb->ki_pos, 0);
740 ret = generic_file_buffered_write(iocb, iovp, nr_segs, 741 ret = generic_perform_write(file, &from, pos);
741 pos, &iocb->ki_pos, count, 0); 742 if (likely(ret >= 0))
742 743 iocb->ki_pos = pos + ret;
743 /* 744 /*
744 * If we just got an ENOSPC, try to write back all dirty inodes to 745 * If we just got an ENOSPC, try to write back all dirty inodes to
745 * convert delalloc space to free up some of the excess reserved 746 * convert delalloc space to free up some of the excess reserved
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index bcfe61202115..0b18776b075e 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -271,32 +271,6 @@ xfs_open_by_handle(
271 return error; 271 return error;
272} 272}
273 273
274/*
275 * This is a copy from fs/namei.c:vfs_readlink(), except for removing it's
276 * unused first argument.
277 */
278STATIC int
279do_readlink(
280 char __user *buffer,
281 int buflen,
282 const char *link)
283{
284 int len;
285
286 len = PTR_ERR(link);
287 if (IS_ERR(link))
288 goto out;
289
290 len = strlen(link);
291 if (len > (unsigned) buflen)
292 len = buflen;
293 if (copy_to_user(buffer, link, len))
294 len = -EFAULT;
295 out:
296 return len;
297}
298
299
300int 274int
301xfs_readlink_by_handle( 275xfs_readlink_by_handle(
302 struct file *parfilp, 276 struct file *parfilp,
@@ -334,7 +308,7 @@ xfs_readlink_by_handle(
334 error = -xfs_readlink(XFS_I(dentry->d_inode), link); 308 error = -xfs_readlink(XFS_I(dentry->d_inode), link);
335 if (error) 309 if (error)
336 goto out_kfree; 310 goto out_kfree;
337 error = do_readlink(hreq->ohandle, olen, link); 311 error = readlink_copy(hreq->ohandle, olen, link);
338 if (error) 312 if (error)
339 goto out_kfree; 313 goto out_kfree;
340 314