Return-Path: From: "zhangyi (F)" Subject: [RFC PATCH v2 7/9] ovl: add nfs_export feature when nfs_export is enabled Date: Tue, 31 Jul 2018 17:37:25 +0800 Message-ID: <20180731093727.26855-8-yi.zhang@huawei.com> In-Reply-To: <20180731093727.26855-1-yi.zhang@huawei.com> References: <20180731093727.26855-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain To: linux-unionfs@vger.kernel.org Cc: miklos@szeredi.hu, amir73il@gmail.com, yi.zhang@huawei.com, miaoxie@huawei.com, yangerkun@huawei.com List-ID: nfs_export feature is base on index feature and also backward read-only compatible. Check the upper layer's nfs_export feature when index dir exists and nfs_export was enabled through mount option, set this feature if it was not yet set. Signed-off-by: zhangyi (F) --- fs/overlayfs/overlayfs.h | 5 ++++- fs/overlayfs/super.c | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 21a41c12168c..0f95e60cae69 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -60,7 +60,9 @@ struct ovl_d_feature { #define OVL_FEATURE_COMPAT_UNKNOWN (~OVL_FEATURE_COMPAT_SUPP) #define OVL_FEATURE_RO_COMPAT_INDEX (1 << 0) -#define OVL_FEATURE_RO_COMPAT_SUPP (OVL_FEATURE_RO_COMPAT_INDEX) +#define OVL_FEATURE_RO_COMPAT_NFS_EXPORT (1 << 1) +#define OVL_FEATURE_RO_COMPAT_SUPP (OVL_FEATURE_RO_COMPAT_INDEX | \ + OVL_FEATURE_RO_COMPAT_NFS_EXPORT) #define OVL_FEATURE_RO_COMPAT_UNKNOWN (~OVL_FEATURE_RO_COMPAT_SUPP) #define OVL_FEATURE_INCOMPAT_REDIRECT_DIR (1 << 0) @@ -132,6 +134,7 @@ static inline int ovl_set_feature_##name(struct ovl_fs *ofs) \ } \ OVL_FEATURE_RO_COMPAT_FUNCS(index, INDEX) +OVL_FEATURE_RO_COMPAT_FUNCS(nfs_export, NFS_EXPORT) OVL_FEATURE_INCOMPAT_FUNCS(redirect_dir, REDIRECT_DIR) /* diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 197329f7d284..860a533ae5a9 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1450,6 +1450,17 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) if (err) goto out_free_oe; } + + /* + * Set nfs_export feature if index dir exists and + * nfs_export mount option enabled. + */ + if (ofs->config.nfs_export && + !ovl_has_feature_nfs_export(ofs->upper_layer)) { + err = ovl_set_feature_nfs_export(ofs); + if (err) + goto out_free_oe; + } } else { /* Force r/o mount with no index dir */ dput(ofs->workdir); -- 2.13.6