All of lore.kernel.org
 help / color / mirror / Atom feed
From: "zhangyi (F)" <yi.zhang@huawei.com>
To: linux-unionfs@vger.kernel.org
Cc: miklos@szeredi.hu, amir73il@gmail.com, yi.zhang@huawei.com,
	miaoxie@huawei.com, yangerkun@huawei.com
Subject: [RFC PATCH v2 5/9] ovl: add redirect dir feature when set redirect xattr to dir
Date: Tue, 31 Jul 2018 17:37:23 +0800	[thread overview]
Message-ID: <20180731093727.26855-6-yi.zhang@huawei.com> (raw)
In-Reply-To: <20180731093727.26855-1-yi.zhang@huawei.com>

Redirect dir feature is backward incompatible because old kernel (which
not support this feature) may corrupt the merge relationship between
directories when change the directory which have redirect xattr.

This patch check and set the upper layer's redirect dir feature when
kernel set redirect xattr to directory in the upper layer.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
---
 fs/overlayfs/dir.c       | 11 +++++++++++
 fs/overlayfs/overlayfs.h |  5 ++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index f480b1a2cd2e..238999e5f47b 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -969,6 +969,7 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
 	bool is_dir = d_is_dir(old);
 	bool new_is_dir = d_is_dir(new);
 	bool samedir = olddir == newdir;
+	struct ovl_fs* ofs = old->d_sb->s_fs_info;
 	struct dentry *opaquedir = NULL;
 	const struct cred *old_cred = NULL;
 	LIST_HEAD(list);
@@ -1061,6 +1062,16 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
 		}
 	}
 
+	if ((is_dir && ovl_type_merge_or_lower(old)) ||
+	    (!overwrite && new_is_dir && ovl_type_merge_or_lower(new))) {
+		/*
+		 * Set redirect dir feature to the upper root dir if this
+		 * feature doesn't exist.
+		 */
+		if (!ovl_has_feature_redirect_dir(ofs->upper_layer))
+			err = ovl_set_feature_redirect_dir(ofs);
+	}
+
 	trap = lock_rename(new_upperdir, old_upperdir);
 
 	olddentry = lookup_one_len(old->d_name.name, old_upperdir,
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index d6231acc660a..7ed8ed49266f 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -62,7 +62,8 @@ struct ovl_d_feature {
 #define OVL_FEATURE_RO_COMPAT_SUPP		(0)
 #define OVL_FEATURE_RO_COMPAT_UNKNOWN		(~OVL_FEATURE_RO_COMPAT_SUPP)
 
-#define OVL_FEATURE_INCOMPAT_SUPP		(0)
+#define OVL_FEATURE_INCOMPAT_REDIRECT_DIR	(1 << 0)
+#define OVL_FEATURE_INCOMPAT_SUPP		(OVL_FEATURE_INCOMPAT_REDIRECT_DIR)
 #define OVL_FEATURE_INCOMPAT_UNKNOWN		(~OVL_FEATURE_INCOMPAT_SUPP)
 
 static inline bool ovl_has_unknown_compat_features(struct ovl_layer *layer)
@@ -129,6 +130,8 @@ static inline int ovl_set_feature_##name(struct ovl_fs *ofs) \
 			OVL_FEATURE_INCOMPAT_##flagname); \
 } \
 
+OVL_FEATURE_INCOMPAT_FUNCS(redirect_dir,	REDIRECT_DIR)
+
 /*
  * The tuple (fh,uuid) is a universal unique identifier for a copy up origin,
  * where:
-- 
2.13.6


  parent reply	other threads:[~2018-07-31 11:04 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31  9:37 [RFC PATCH v2 0/9] ovl: add feature set support zhangyi (F)
2018-07-31  9:37 ` [RFC PATCH v2 1/9] ovl: store ovl upper root path in ovl_fs zhangyi (F)
2018-08-01  6:48   ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 2/9] ovl: read feature set from each layer's root dir zhangyi (F)
2018-08-01  7:44   ` Amir Goldstein
2018-08-03 12:11     ` zhangyi (F)
2018-07-31  9:37 ` [RFC PATCH v2 3/9] ovl: check file system features can be mounted properly zhangyi (F)
2018-08-01  8:06   ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 4/9] ovl: add helper funcs to set upper layer feature set zhangyi (F)
2018-08-01  8:51   ` Amir Goldstein
2018-08-01 11:04     ` Amir Goldstein
2018-07-31  9:37 ` zhangyi (F) [this message]
2018-08-01 11:03   ` [RFC PATCH v2 5/9] ovl: add redirect dir feature when set redirect xattr to dir Amir Goldstein
2018-08-03 11:52     ` zhangyi (F)
2018-08-03 20:38       ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 6/9] ovl: add index feature if index dir exists zhangyi (F)
2018-08-01 11:15   ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 7/9] ovl: add nfs_export feature when nfs_export is enabled zhangyi (F)
2018-08-01 11:20   ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 8/9] ovl: force mount underlying layers which have feature sets zhangyi (F)
     [not found]   ` <CAOQ4uxgZcwxENyf5STfNgL6juLoHvOBnWkORpifp0pv04oi8Ww@mail.gmail.com>
2018-08-03 11:25     ` zhangyi (F)
     [not found]       ` <CAOQ4uxjxY1Urjy2fUEkV24ZfxbDjAu1vkJcERNc_7uZVmJ+2YA@mail.gmail.com>
2018-08-06  1:15         ` zhangyi (F)
2018-07-31  9:37 ` [RFC PATCH v2 9/9] ovl: check redirect_dir feature when detect redirect xattr on dir zhangyi (F)
2018-08-01 11:30   ` Amir Goldstein
2018-08-01 11:35     ` Amir Goldstein
2018-08-02 12:30       ` Vivek Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180731093727.26855-6-yi.zhang@huawei.com \
    --to=yi.zhang@huawei.com \
    --cc=amir73il@gmail.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=miklos@szeredi.hu \
    --cc=yangerkun@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.