aboutsummaryrefslogtreecommitdiffstats
path: root/fs/overlayfs/util.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-10-09 03:02:35 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-10-09 03:02:35 -0400
commit1236d6bb6e19fc72ffc6bbcdeb1bfefe450e54ee (patch)
tree47da3feee8e263e8c9352c85cf518e624be3c211 /fs/overlayfs/util.c
parent750b1a6894ecc9b178c6e3d0a1170122971b2036 (diff)
parent8a5776a5f49812d29fe4b2d0a2d71675c3facf3f (diff)
Merge 4.14-rc4 into staging-next
We want the staging/iio fixes in here as well to handle merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/overlayfs/util.c')
-rw-r--r--fs/overlayfs/util.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 117794582f9f..b9b239fa5cfd 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -430,7 +430,7 @@ void ovl_inuse_unlock(struct dentry *dentry)
430 } 430 }
431} 431}
432 432
433/* Called must hold OVL_I(inode)->oi_lock */ 433/* Caller must hold OVL_I(inode)->lock */
434static void ovl_cleanup_index(struct dentry *dentry) 434static void ovl_cleanup_index(struct dentry *dentry)
435{ 435{
436 struct inode *dir = ovl_indexdir(dentry->d_sb)->d_inode; 436 struct inode *dir = ovl_indexdir(dentry->d_sb)->d_inode;
@@ -469,6 +469,9 @@ static void ovl_cleanup_index(struct dentry *dentry)
469 err = PTR_ERR(index); 469 err = PTR_ERR(index);
470 if (!IS_ERR(index)) 470 if (!IS_ERR(index))
471 err = ovl_cleanup(dir, index); 471 err = ovl_cleanup(dir, index);
472 else
473 index = NULL;
474
472 inode_unlock(dir); 475 inode_unlock(dir);
473 if (err) 476 if (err)
474 goto fail; 477 goto fail;
@@ -557,3 +560,22 @@ void ovl_nlink_end(struct dentry *dentry, bool locked)
557 mutex_unlock(&OVL_I(d_inode(dentry))->lock); 560 mutex_unlock(&OVL_I(d_inode(dentry))->lock);
558 } 561 }
559} 562}
563
564int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir)
565{
566 /* Workdir should not be the same as upperdir */
567 if (workdir == upperdir)
568 goto err;
569
570 /* Workdir should not be subdir of upperdir and vice versa */
571 if (lock_rename(workdir, upperdir) != NULL)
572 goto err_unlock;
573
574 return 0;
575
576err_unlock:
577 unlock_rename(workdir, upperdir);
578err:
579 pr_err("overlayfs: failed to lock workdir+upperdir\n");
580 return -EIO;
581}