Commit 1fc6dd1b authored by Amir Goldstein's avatar Amir Goldstein Committed by Stefan Bader

ovl: check if all layers are on the same fs

BugLink: http://bugs.launchpad.net/bugs/1728489

Some features can only work when all layers are on the same fs.  Test this
condition during mount time, so features can check them later.

Add helper ovl_same_sb() to return the common super block in case all
layers are on the same fs.
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
(backported from commit 7bcd74b9)
Signed-off-by: default avatarDaniel Axtens <daniel.axtens@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarColin King <colin.king@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 7901f342
......@@ -164,6 +164,7 @@ static inline int ovl_do_whiteout(struct inode *dir, struct dentry *dentry,
}
const struct cred *ovl_override_creds(struct super_block *sb);
struct super_block *ovl_same_sb(struct super_block *sb);
enum ovl_path_type ovl_path_type(struct dentry *dentry);
u64 ovl_dentry_version_get(struct dentry *dentry);
void ovl_dentry_version_inc(struct dentry *dentry);
......
......@@ -44,6 +44,8 @@ struct ovl_fs {
/* pathnames of lower and upper dirs, for show_options */
struct ovl_config config;
struct cred *mounter_creds;
/* sb common to all layers */
struct super_block *same_sb;
};
struct ovl_dir_cache;
......@@ -430,6 +432,13 @@ static const struct dentry_operations ovl_reval_dentry_operations = {
.d_weak_revalidate = ovl_dentry_weak_revalidate,
};
struct super_block *ovl_same_sb(struct super_block *sb)
{
struct ovl_fs *ofs = sb->s_fs_info;
return ofs->same_sb;
}
static struct ovl_entry *ovl_alloc_entry(unsigned int numlower)
{
size_t size = offsetof(struct ovl_entry, lowerstack[numlower]);
......@@ -1157,11 +1166,19 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
ufs->lower_mnt[ufs->numlower] = mnt;
ufs->numlower++;
/* Check if all lower layers are on same sb */
if (i == 0)
ufs->same_sb = mnt->mnt_sb;
else if (ufs->same_sb != mnt->mnt_sb)
ufs->same_sb = NULL;
}
/* If the upper fs is nonexistent, we mark overlayfs r/o too */
if (!ufs->upper_mnt)
sb->s_flags |= MS_RDONLY;
else if (ufs->upper_mnt->mnt_sb != ufs->same_sb)
ufs->same_sb = NULL;
if (remote)
sb->s_d_op = &ovl_reval_dentry_operations;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment