aboutsummaryrefslogtreecommitdiffstats
path: root/mm/shmem.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-11 14:44:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-11 14:44:11 -0400
commitf6f993328b2abcab86a3c99d7bd9f2066ab03d36 (patch)
treeea6f3902a0fa546493731b3b52a31d98cc747a90 /mm/shmem.c
parentc7a19c795b4b0a3232c157ed29eea85077e95da6 (diff)
parent12a5b5294cb1896e9a3c9fca8ff5a7e3def4e8c6 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: "Stuff in here: - acct.c fixes and general rework of mnt_pin mechanism. That allows to go for delayed-mntput stuff, which will permit mntput() on deep stack without worrying about stack overflows - fs shutdown will happen on shallow stack. IOW, we can do Eric's umount-on-rmdir series without introducing tons of stack overflows on new mntput() call chains it introduces. - Bruce's d_splice_alias() patches - more Miklos' rename() stuff. - a couple of regression fixes (stable fodder, in the end of branch) and a fix for API idiocy in iov_iter.c. There definitely will be another pile, maybe even two. I'd like to get Eric's series in this time, but even if we miss it, it'll go right in the beginning of for-next in the next cycle - the tricky part of prereqs is in this pile" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (40 commits) fix copy_tree() regression __generic_file_write_iter(): fix handling of sync error after DIO switch iov_iter_get_pages() to passing maximal number of pages fs: mark __d_obtain_alias static dcache: d_splice_alias should detect loops exportfs: update Exporting documentation dcache: d_find_alias needn't recheck IS_ROOT && DCACHE_DISCONNECTED dcache: remove unused d_find_alias parameter dcache: d_obtain_alias callers don't all want DISCONNECTED dcache: d_splice_alias should ignore DCACHE_DISCONNECTED dcache: d_splice_alias mustn't create directory aliases dcache: close d_move race in d_splice_alias dcache: move d_splice_alias namei: trivial fix to vfs_rename_dir comment VFS: allow ->d_manage() to declare -EISDIR in rcu_walk mode. cifs: support RENAME_NOREPLACE hostfs: support rename flags shmem: support RENAME_EXCHANGE shmem: support RENAME_NOREPLACE btrfs: add RENAME_NOREPLACE ...
Diffstat (limited to 'mm/shmem.c')
-rw-r--r--mm/shmem.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index a42add14331c..0e5fb225007c 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2323,17 +2323,45 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry)
2323 return shmem_unlink(dir, dentry); 2323 return shmem_unlink(dir, dentry);
2324} 2324}
2325 2325
2326static int shmem_exchange(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry)
2327{
2328 bool old_is_dir = S_ISDIR(old_dentry->d_inode->i_mode);
2329 bool new_is_dir = S_ISDIR(new_dentry->d_inode->i_mode);
2330
2331 if (old_dir != new_dir && old_is_dir != new_is_dir) {
2332 if (old_is_dir) {
2333 drop_nlink(old_dir);
2334 inc_nlink(new_dir);
2335 } else {
2336 drop_nlink(new_dir);
2337 inc_nlink(old_dir);
2338 }
2339 }
2340 old_dir->i_ctime = old_dir->i_mtime =
2341 new_dir->i_ctime = new_dir->i_mtime =
2342 old_dentry->d_inode->i_ctime =
2343 new_dentry->d_inode->i_ctime = CURRENT_TIME;
2344
2345 return 0;
2346}
2347
2326/* 2348/*
2327 * The VFS layer already does all the dentry stuff for rename, 2349 * The VFS layer already does all the dentry stuff for rename,
2328 * we just have to decrement the usage count for the target if 2350 * we just have to decrement the usage count for the target if
2329 * it exists so that the VFS layer correctly free's it when it 2351 * it exists so that the VFS layer correctly free's it when it
2330 * gets overwritten. 2352 * gets overwritten.
2331 */ 2353 */
2332static int shmem_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry) 2354static int shmem_rename2(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags)
2333{ 2355{
2334 struct inode *inode = old_dentry->d_inode; 2356 struct inode *inode = old_dentry->d_inode;
2335 int they_are_dirs = S_ISDIR(inode->i_mode); 2357 int they_are_dirs = S_ISDIR(inode->i_mode);
2336 2358
2359 if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
2360 return -EINVAL;
2361
2362 if (flags & RENAME_EXCHANGE)
2363 return shmem_exchange(old_dir, old_dentry, new_dir, new_dentry);
2364
2337 if (!simple_empty(new_dentry)) 2365 if (!simple_empty(new_dentry))
2338 return -ENOTEMPTY; 2366 return -ENOTEMPTY;
2339 2367
@@ -3087,7 +3115,7 @@ static const struct inode_operations shmem_dir_inode_operations = {
3087 .mkdir = shmem_mkdir, 3115 .mkdir = shmem_mkdir,
3088 .rmdir = shmem_rmdir, 3116 .rmdir = shmem_rmdir,
3089 .mknod = shmem_mknod, 3117 .mknod = shmem_mknod,
3090 .rename = shmem_rename, 3118 .rename2 = shmem_rename2,
3091 .tmpfile = shmem_tmpfile, 3119 .tmpfile = shmem_tmpfile,
3092#endif 3120#endif
3093#ifdef CONFIG_TMPFS_XATTR 3121#ifdef CONFIG_TMPFS_XATTR