From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Vivek Goyal <vgoyal@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 03/16] ovl: check if all layers are on the same fs
Date: Thu, 27 Apr 2017 00:35:05 +0300 [thread overview]
Message-ID: <1493242518-15266-4-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1493242518-15266-1-git-send-email-amir73il@gmail.com>
Some features can only work when all lower layers are on the same fs
and some features require that upper layer is also on the same fs.
Test those conditions during mount time, so features can check them later.
Add helper ovl_same_lower_sb() to return the common super block in case
all lower layers are on the same fs and helper ovl_same_sb() to return
the super block common to all layers.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/overlayfs.h | 2 ++
fs/overlayfs/ovl_entry.h | 3 +++
fs/overlayfs/super.c | 9 +++++++++
fs/overlayfs/util.c | 14 ++++++++++++++
4 files changed, 28 insertions(+)
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 9420101..48d0dae 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -153,6 +153,8 @@ int ovl_want_write(struct dentry *dentry);
void ovl_drop_write(struct dentry *dentry);
struct dentry *ovl_workdir(struct dentry *dentry);
const struct cred *ovl_override_creds(struct super_block *sb);
+struct super_block *ovl_same_lower_sb(struct super_block *sb);
+struct super_block *ovl_same_sb(struct super_block *sb);
struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
bool ovl_dentry_remote(struct dentry *dentry);
bool ovl_dentry_weird(struct dentry *dentry);
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
index 12c4922..41708bf 100644
--- a/fs/overlayfs/ovl_entry.h
+++ b/fs/overlayfs/ovl_entry.h
@@ -29,6 +29,9 @@ struct ovl_fs {
const struct cred *creator_cred;
bool tmpfile;
wait_queue_head_t copyup_wq;
+ /* sb common to all (or all lower) layers */
+ struct super_block *same_lower_sb;
+ struct super_block *same_sb;
};
enum ovl_path_type;
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 671bac0..b8830ee 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -898,6 +898,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
ufs->lower_mnt = kcalloc(numlower, sizeof(struct vfsmount *), GFP_KERNEL);
if (ufs->lower_mnt == NULL)
goto out_put_workdir;
+
for (i = 0; i < numlower; i++) {
struct vfsmount *mnt = clone_private_mount(&stack[i]);
@@ -914,11 +915,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_lower_sb = mnt->mnt_sb;
+ else if (ufs->same_lower_sb != mnt->mnt_sb)
+ ufs->same_lower_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_lower_sb)
+ ufs->same_sb = ufs->same_lower_sb;
if (remote)
sb->s_d_op = &ovl_reval_dentry_operations;
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 88cfc2a..e015bc3 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -41,6 +41,20 @@ const struct cred *ovl_override_creds(struct super_block *sb)
return override_creds(ofs->creator_cred);
}
+struct super_block *ovl_same_lower_sb(struct super_block *sb)
+{
+ struct ovl_fs *ofs = sb->s_fs_info;
+
+ return ofs->same_lower_sb;
+}
+
+struct super_block *ovl_same_sb(struct super_block *sb)
+{
+ struct ovl_fs *ofs = sb->s_fs_info;
+
+ return ofs->same_sb;
+}
+
struct ovl_entry *ovl_alloc_entry(unsigned int numlower)
{
size_t size = offsetof(struct ovl_entry, lowerstack[numlower]);
--
2.7.4
next prev parent reply other threads:[~2017-04-26 21:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 21:35 [PATCH v3 00/16] overlayfs constant inode numbers Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 01/16] ovl: store path type in dentry Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 02/16] ovl: cram opaque boolean into type flags Amir Goldstein
2017-04-26 21:35 ` Amir Goldstein [this message]
2017-04-26 21:35 ` [PATCH v3 04/16] ovl: store file handle of lower inode on copy up Amir Goldstein
2017-04-27 7:23 ` Miklos Szeredi
2017-04-27 7:46 ` Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 05/16] ovl: use an auxiliary var for overlay root entry Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 06/16] ovl: factor out ovl_lookup_data() Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 07/16] ovl: lookup redirect by file handle Amir Goldstein
2017-04-27 17:28 ` kbuild test robot
2017-04-26 21:35 ` [PATCH v3 08/16] ovl: validate lower layer uuid and root on redirect by fh Amir Goldstein
2017-04-27 7:15 ` Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 09/16] ovl: lookup non-dir inode copy up origin Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 10/16] ovl: set the COPYUP type flag for non-dirs Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 11/16] ovl: redirect non-dir by path on rename Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 12/16] ovl: constant st_ino/st_dev across copy up Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 13/16] ovl: persistent inode number for directories Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 14/16] ovl: fix du --one-file-system on overlay mount Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 15/16] ovl: persistent inode numbers for hardlinks Amir Goldstein
2017-04-26 21:35 ` [PATCH v3 16/16] ovl: update documentation w.r.t. constant inode numbers Amir Goldstein
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=1493242518-15266-4-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=vgoyal@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox