From: Ian Kent on
On Tue, Jun 15, 2010 at 11:39:37AM -0700, Valerie Aurora wrote:
> From: Jan Blunck <jblunck(a)suse.de>
>
> In case of an union directory we don't want that the directories on lower
> layers of the union "show through". So to prevent that the contents of
> underlying directories magically shows up after a mkdir() we set the S_OPAQUE
> flag if directories are created where a whiteout existed before.

I found this hard to understand.

Do you mean:

For directories within a union that are whiteouts we don't want the entries of
lower layer file system to "show through". To achieve this we set the S_OPAQUE
flag after a mkdir() on directories that are whiteouts.

>
> Signed-off-by: Jan Blunck <jblunck(a)suse.de>
> Signed-off-by: Valerie Aurora <vaurora(a)redhat.com>
> ---
> fs/namei.c | 11 ++++++++++-
> include/linux/fs.h | 3 +++
> 2 files changed, 13 insertions(+), 1 deletions(-)
>
> diff --git a/fs/namei.c b/fs/namei.c
> index 2c723e2..8c67636 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -2107,6 +2107,7 @@ SYSCALL_DEFINE3(mknod, const char __user *, filename, int, mode, unsigned, dev)
> int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
> {
> int error = may_create(dir, dentry);
> + int opaque = 0;
>
> if (error)
> return error;
> @@ -2119,9 +2120,17 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
> if (error)
> return error;
>
> + if (d_is_whiteout(dentry))
> + opaque = 1;
> +
> error = dir->i_op->mkdir(dir, dentry, mode);
> - if (!error)
> + if (!error) {
> fsnotify_mkdir(dir, dentry);
> + if (opaque) {
> + dentry->d_inode->i_flags |= S_OPAQUE;
> + mark_inode_dirty(dentry->d_inode);
> + }
> + }
> return error;
> }
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 7afdbd4..e9aa650 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -236,6 +236,7 @@ struct inodes_stat_t {
> #define S_NOCMTIME 128 /* Do not update file c/mtime */
> #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
> #define S_PRIVATE 512 /* Inode is fs-internal */
> +#define S_OPAQUE 1024 /* Directory is opaque */
>
> /*
> * Note that nosuid etc flags are inode-specific: setting some file-system
> @@ -271,6 +272,8 @@ struct inodes_stat_t {
> #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
> #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
>
> +#define IS_OPAQUE(inode) ((inode)->i_flags & S_OPAQUE)
> +
> /* the read-only stuff doesn't really belong here, but any other place is
> probably as bad and I don't want to create yet another include file. */
>
> --
> 1.6.3.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo(a)vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Ian Kent on
On Fri, 2010-07-16 at 16:12 -0400, Valerie Aurora wrote:
> On Tue, Jul 13, 2010 at 12:05:56PM +0800, Ian Kent wrote:
> > On Tue, Jun 15, 2010 at 11:39:37AM -0700, Valerie Aurora wrote:
> > > From: Jan Blunck <jblunck(a)suse.de>
> > >
> > > In case of an union directory we don't want that the directories on lower
> > > layers of the union "show through". So to prevent that the contents of
> > > underlying directories magically shows up after a mkdir() we set the S_OPAQUE
> > > flag if directories are created where a whiteout existed before.
> >
> > I found this hard to understand.
> >
> > Do you mean:
> >
> > For directories within a union that are whiteouts we don't want the entries of
> > lower layer file system to "show through". To achieve this we set the S_OPAQUE
> > flag after a mkdir() on directories that are whiteouts.
>
> That is much clearer. I ended up with this version, what do you think?
>
> whiteout: Set opaque flag if new directory was previously a whiteout
>
> If we mkdir() a directory on the top layer of a union, we don't want
> entries from a matching directory on the lower layer to "show through"
> suddenly. To prevent this, we set the opaque flag on a directory if
> there was previously a white-out with the same name. (If there is no
> white-out and the directory exists in a lower layer, then mkdir() will
> fail with EEXIST.)

That's much clearer IMHO.

>
> -VAL


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/