aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2016-12-16 05:02:55 -0500
committerMiklos Szeredi <mszeredi@redhat.com>2016-12-16 05:02:55 -0500
commitc412ce498396097cb96b3e24e062752312a962c9 (patch)
tree607029b78cb046e211919cfc6f7cc796a0ad44c9
parent99f5d08e3640c8319f353e6c883da150c48067f6 (diff)
ovl: add ovl_dentry_is_whiteout()
And use it instead of ovl_dentry_is_opaque() where appropriate. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/overlayfs/dir.c6
-rw-r--r--fs/overlayfs/overlayfs.h1
-rw-r--r--fs/overlayfs/super.c5
3 files changed, 9 insertions, 3 deletions
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index fdc7b14ab571..b559221b2d34 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -504,7 +504,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
504 put_cred(override_creds(override_cred)); 504 put_cred(override_creds(override_cred));
505 put_cred(override_cred); 505 put_cred(override_cred);
506 506
507 if (!ovl_dentry_is_opaque(dentry)) 507 if (!ovl_dentry_is_whiteout(dentry))
508 err = ovl_create_upper(dentry, inode, stat, link, 508 err = ovl_create_upper(dentry, inode, stat, link,
509 hardlink); 509 hardlink);
510 else 510 else
@@ -842,14 +842,14 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
842 842
843 if (overwrite) { 843 if (overwrite) {
844 if (old_opaque) { 844 if (old_opaque) {
845 if (new->d_inode || !new_opaque) { 845 if (!ovl_dentry_is_whiteout(new)) {
846 /* Whiteout source */ 846 /* Whiteout source */
847 flags |= RENAME_WHITEOUT; 847 flags |= RENAME_WHITEOUT;
848 } else { 848 } else {
849 /* Switch whiteouts */ 849 /* Switch whiteouts */
850 flags |= RENAME_EXCHANGE; 850 flags |= RENAME_EXCHANGE;
851 } 851 }
852 } else if (is_dir && !new->d_inode && new_opaque) { 852 } else if (is_dir && ovl_dentry_is_whiteout(new)) {
853 flags |= RENAME_EXCHANGE; 853 flags |= RENAME_EXCHANGE;
854 cleanup_whiteout = true; 854 cleanup_whiteout = true;
855 } 855 }
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 95d0d86c2d54..51e7d58276ce 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -161,6 +161,7 @@ struct dentry *ovl_workdir(struct dentry *dentry);
161int ovl_want_write(struct dentry *dentry); 161int ovl_want_write(struct dentry *dentry);
162void ovl_drop_write(struct dentry *dentry); 162void ovl_drop_write(struct dentry *dentry);
163bool ovl_dentry_is_opaque(struct dentry *dentry); 163bool ovl_dentry_is_opaque(struct dentry *dentry);
164bool ovl_dentry_is_whiteout(struct dentry *dentry);
164void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque); 165void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque);
165bool ovl_is_whiteout(struct dentry *dentry); 166bool ovl_is_whiteout(struct dentry *dentry);
166const struct cred *ovl_override_creds(struct super_block *sb); 167const struct cred *ovl_override_creds(struct super_block *sb);
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index e296312005cc..aa0427dabea8 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -209,6 +209,11 @@ bool ovl_dentry_is_opaque(struct dentry *dentry)
209 return oe->opaque; 209 return oe->opaque;
210} 210}
211 211
212bool ovl_dentry_is_whiteout(struct dentry *dentry)
213{
214 return !dentry->d_inode && ovl_dentry_is_opaque(dentry);
215}
216
212void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque) 217void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque)
213{ 218{
214 struct ovl_entry *oe = dentry->d_fsdata; 219 struct ovl_entry *oe = dentry->d_fsdata;