aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-23 15:24:56 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-23 15:24:56 -0500
commitcc673757e24d018d64ff8038e28835db1e2902c4 (patch)
tree6eab3dab15725cda04dafabe9a8440697dca26cc /mm
parentfa7d9a1d286e6bab49ffa59cbd3c8b394ce54339 (diff)
parente62e560fc8b65ef5debc9041a792d18a8f98b2ca (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull final vfs updates from Al Viro: - The ->i_mutex wrappers (with small prereq in lustre) - a fix for too early freeing of symlink bodies on shmem (they need to be RCU-delayed) (-stable fodder) - followup to dedupe stuff merged this cycle * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: vfs: abort dedupe loop if fatal signals are pending make sure that freeing shmem fast symlinks is RCU-delayed wrappers for ->i_mutex access lustre: remove unused declaration
Diffstat (limited to 'mm')
-rw-r--r--mm/filemap.c4
-rw-r--r--mm/shmem.c21
-rw-r--r--mm/swapfile.c12
3 files changed, 18 insertions, 19 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 2e7c8d980d5e..bc943867d68c 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2763,11 +2763,11 @@ ssize_t generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
2763 struct inode *inode = file->f_mapping->host; 2763 struct inode *inode = file->f_mapping->host;
2764 ssize_t ret; 2764 ssize_t ret;
2765 2765
2766 mutex_lock(&inode->i_mutex); 2766 inode_lock(inode);
2767 ret = generic_write_checks(iocb, from); 2767 ret = generic_write_checks(iocb, from);
2768 if (ret > 0) 2768 if (ret > 0)
2769 ret = __generic_file_write_iter(iocb, from); 2769 ret = __generic_file_write_iter(iocb, from);
2770 mutex_unlock(&inode->i_mutex); 2770 inode_unlock(inode);
2771 2771
2772 if (ret > 0) { 2772 if (ret > 0) {
2773 ssize_t err; 2773 ssize_t err;
diff --git a/mm/shmem.c b/mm/shmem.c
index fa2ceb2d2655..440e2a7e6c1c 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -701,8 +701,7 @@ static void shmem_evict_inode(struct inode *inode)
701 list_del_init(&info->swaplist); 701 list_del_init(&info->swaplist);
702 mutex_unlock(&shmem_swaplist_mutex); 702 mutex_unlock(&shmem_swaplist_mutex);
703 } 703 }
704 } else 704 }
705 kfree(info->symlink);
706 705
707 simple_xattrs_free(&info->xattrs); 706 simple_xattrs_free(&info->xattrs);
708 WARN_ON(inode->i_blocks); 707 WARN_ON(inode->i_blocks);
@@ -1902,7 +1901,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
1902 if (whence != SEEK_DATA && whence != SEEK_HOLE) 1901 if (whence != SEEK_DATA && whence != SEEK_HOLE)
1903 return generic_file_llseek_size(file, offset, whence, 1902 return generic_file_llseek_size(file, offset, whence,
1904 MAX_LFS_FILESIZE, i_size_read(inode)); 1903 MAX_LFS_FILESIZE, i_size_read(inode));
1905 mutex_lock(&inode->i_mutex); 1904 inode_lock(inode);
1906 /* We're holding i_mutex so we can access i_size directly */ 1905 /* We're holding i_mutex so we can access i_size directly */
1907 1906
1908 if (offset < 0) 1907 if (offset < 0)
@@ -1926,7 +1925,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
1926 1925
1927 if (offset >= 0) 1926 if (offset >= 0)
1928 offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE); 1927 offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE);
1929 mutex_unlock(&inode->i_mutex); 1928 inode_unlock(inode);
1930 return offset; 1929 return offset;
1931} 1930}
1932 1931
@@ -2091,7 +2090,7 @@ int shmem_add_seals(struct file *file, unsigned int seals)
2091 if (seals & ~(unsigned int)F_ALL_SEALS) 2090 if (seals & ~(unsigned int)F_ALL_SEALS)
2092 return -EINVAL; 2091 return -EINVAL;
2093 2092
2094 mutex_lock(&inode->i_mutex); 2093 inode_lock(inode);
2095 2094
2096 if (info->seals & F_SEAL_SEAL) { 2095 if (info->seals & F_SEAL_SEAL) {
2097 error = -EPERM; 2096 error = -EPERM;
@@ -2114,7 +2113,7 @@ int shmem_add_seals(struct file *file, unsigned int seals)
2114 error = 0; 2113 error = 0;
2115 2114
2116unlock: 2115unlock:
2117 mutex_unlock(&inode->i_mutex); 2116 inode_unlock(inode);
2118 return error; 2117 return error;
2119} 2118}
2120EXPORT_SYMBOL_GPL(shmem_add_seals); 2119EXPORT_SYMBOL_GPL(shmem_add_seals);
@@ -2164,7 +2163,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
2164 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) 2163 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
2165 return -EOPNOTSUPP; 2164 return -EOPNOTSUPP;
2166 2165
2167 mutex_lock(&inode->i_mutex); 2166 inode_lock(inode);
2168 2167
2169 if (mode & FALLOC_FL_PUNCH_HOLE) { 2168 if (mode & FALLOC_FL_PUNCH_HOLE) {
2170 struct address_space *mapping = file->f_mapping; 2169 struct address_space *mapping = file->f_mapping;
@@ -2277,7 +2276,7 @@ undone:
2277 inode->i_private = NULL; 2276 inode->i_private = NULL;
2278 spin_unlock(&inode->i_lock); 2277 spin_unlock(&inode->i_lock);
2279out: 2278out:
2280 mutex_unlock(&inode->i_mutex); 2279 inode_unlock(inode);
2281 return error; 2280 return error;
2282} 2281}
2283 2282
@@ -2549,13 +2548,12 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
2549 info = SHMEM_I(inode); 2548 info = SHMEM_I(inode);
2550 inode->i_size = len-1; 2549 inode->i_size = len-1;
2551 if (len <= SHORT_SYMLINK_LEN) { 2550 if (len <= SHORT_SYMLINK_LEN) {
2552 info->symlink = kmemdup(symname, len, GFP_KERNEL); 2551 inode->i_link = kmemdup(symname, len, GFP_KERNEL);
2553 if (!info->symlink) { 2552 if (!inode->i_link) {
2554 iput(inode); 2553 iput(inode);
2555 return -ENOMEM; 2554 return -ENOMEM;
2556 } 2555 }
2557 inode->i_op = &shmem_short_symlink_operations; 2556 inode->i_op = &shmem_short_symlink_operations;
2558 inode->i_link = info->symlink;
2559 } else { 2557 } else {
2560 inode_nohighmem(inode); 2558 inode_nohighmem(inode);
2561 error = shmem_getpage(inode, 0, &page, SGP_WRITE, NULL); 2559 error = shmem_getpage(inode, 0, &page, SGP_WRITE, NULL);
@@ -3132,6 +3130,7 @@ static struct inode *shmem_alloc_inode(struct super_block *sb)
3132static void shmem_destroy_callback(struct rcu_head *head) 3130static void shmem_destroy_callback(struct rcu_head *head)
3133{ 3131{
3134 struct inode *inode = container_of(head, struct inode, i_rcu); 3132 struct inode *inode = container_of(head, struct inode, i_rcu);
3133 kfree(inode->i_link);
3135 kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode)); 3134 kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode));
3136} 3135}
3137 3136
diff --git a/mm/swapfile.c b/mm/swapfile.c
index c43f654a7b64..d2c37365e2d6 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1956,9 +1956,9 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1956 set_blocksize(bdev, old_block_size); 1956 set_blocksize(bdev, old_block_size);
1957 blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); 1957 blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
1958 } else { 1958 } else {
1959 mutex_lock(&inode->i_mutex); 1959 inode_lock(inode);
1960 inode->i_flags &= ~S_SWAPFILE; 1960 inode->i_flags &= ~S_SWAPFILE;
1961 mutex_unlock(&inode->i_mutex); 1961 inode_unlock(inode);
1962 } 1962 }
1963 filp_close(swap_file, NULL); 1963 filp_close(swap_file, NULL);
1964 1964
@@ -2183,7 +2183,7 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
2183 p->flags |= SWP_BLKDEV; 2183 p->flags |= SWP_BLKDEV;
2184 } else if (S_ISREG(inode->i_mode)) { 2184 } else if (S_ISREG(inode->i_mode)) {
2185 p->bdev = inode->i_sb->s_bdev; 2185 p->bdev = inode->i_sb->s_bdev;
2186 mutex_lock(&inode->i_mutex); 2186 inode_lock(inode);
2187 if (IS_SWAPFILE(inode)) 2187 if (IS_SWAPFILE(inode))
2188 return -EBUSY; 2188 return -EBUSY;
2189 } else 2189 } else
@@ -2416,7 +2416,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
2416 mapping = swap_file->f_mapping; 2416 mapping = swap_file->f_mapping;
2417 inode = mapping->host; 2417 inode = mapping->host;
2418 2418
2419 /* If S_ISREG(inode->i_mode) will do mutex_lock(&inode->i_mutex); */ 2419 /* If S_ISREG(inode->i_mode) will do inode_lock(inode); */
2420 error = claim_swapfile(p, inode); 2420 error = claim_swapfile(p, inode);
2421 if (unlikely(error)) 2421 if (unlikely(error))
2422 goto bad_swap; 2422 goto bad_swap;
@@ -2561,7 +2561,7 @@ bad_swap:
2561 vfree(cluster_info); 2561 vfree(cluster_info);
2562 if (swap_file) { 2562 if (swap_file) {
2563 if (inode && S_ISREG(inode->i_mode)) { 2563 if (inode && S_ISREG(inode->i_mode)) {
2564 mutex_unlock(&inode->i_mutex); 2564 inode_unlock(inode);
2565 inode = NULL; 2565 inode = NULL;
2566 } 2566 }
2567 filp_close(swap_file, NULL); 2567 filp_close(swap_file, NULL);
@@ -2574,7 +2574,7 @@ out:
2574 if (name) 2574 if (name)
2575 putname(name); 2575 putname(name);
2576 if (inode && S_ISREG(inode->i_mode)) 2576 if (inode && S_ISREG(inode->i_mode))
2577 mutex_unlock(&inode->i_mutex); 2577 inode_unlock(inode);
2578 return error; 2578 return error;
2579} 2579}
2580 2580