All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Olszak <j.olszak@samsung.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: David Howells <dhowells@redhat.com>,
	"linux-unionfs@vger.kernel.org" <linux-unionfs@vger.kernel.org>
Subject: Re: Optional switching off cow in overlayfs
Date: Mon, 22 Jun 2015 17:32:53 +0200	[thread overview]
Message-ID: <55882AA5.10908@samsung.com> (raw)
In-Reply-To: <CAJfpegtcUt6jR7t_2Ca1osu6+-BKGtnTVVTVXEcWrqBtY0fCzA@mail.gmail.com>

On 06/22/2015 04:37 PM, Miklos Szeredi wrote:
> On Mon, Jun 22, 2015 at 4:26 PM, Jan Olszak <j.olszak@samsung.com> wrote:
>>> You can bind mount individual files from the lower layer to the
>>> overlay.  That fixes the "allow modification" part.
>> Well bind mounting every file that should have COW is unmaintainable - if
>> new files appear admin has to mount each one.
> No.  I was proposing bind mounts for non-COW ones.
>
> mount -t overlay -olowerdir=/lower,upperdir=/upper,workdir=/work  overlay /ovl
> mount --bind /lower/this-file-is-non-cow /ovl/this-file-is-non-cow
> ...
Yes, you are right. This should work, but introduces an overhead of many 
mounts for each Linux container.

The proposed alternative is: Use setfattr only once for each file and 
then forget about it.

>>>    But what should happen on rename or unlink?
>> Both would operate on the original inode.
> And that would make this hugely complex.
Are you sure? I haven't looked into rename and unlink routines but this 
patch covers opening the file and is pretty simple (though it probably 
breaks fchmod/fchown...).

I can try to prepare a real solution if you like the idea.




 From 20e590c0e37f087955b25edfbc2ab4c9c034b5b1 Mon Sep 17 00:00:00 2001
From: Jan Olszak <j.olszak@samsung.com>
Date: Mon, 22 Jun 2015 17:07:31 +0200
Subject: [PATCH] Optional copy on write in overlayfs

---
  fs/overlayfs/inode.c     | 17 +++++++++++++++++
  fs/overlayfs/overlayfs.h |  1 +
  fs/overlayfs/super.c     |  5 -----
  3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 04f1248..4f9f399 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -321,6 +321,20 @@ out:
      return err;
  }

+static bool ovl_dentry_need_copy_up(struct dentry *realdentry)
+{
+    int res;
+    char val;
+    struct inode *inode = realdentry->d_inode;
+
+    res = inode->i_op->getxattr(realdentry, OVL_XATTR_COW, &val, 1);
+    if (res == 1 && val == 'n'){
+        return false;
+    }
+
+    return true;
+}
+
  static bool ovl_open_need_copy_up(int flags, enum ovl_path_type type,
                    struct dentry *realdentry)
  {
@@ -330,6 +344,9 @@ static bool ovl_open_need_copy_up(int flags, enum 
ovl_path_type type,
      if (special_file(realdentry->d_inode->i_mode))
          return false;

+    if (!ovl_dentry_need_copy_up(realdentry))
+        return false;
+
      if (!(OPEN_FMODE(flags) & FMODE_WRITE) && !(flags & O_TRUNC))
          return false;

diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 17ac5af..b364888 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -26,6 +26,7 @@ enum ovl_path_type {
  #define OVL_XATTR_PRE_NAME "trusted.overlay."
  #define OVL_XATTR_PRE_LEN  16
  #define OVL_XATTR_OPAQUE   OVL_XATTR_PRE_NAME"opaque"
+#define OVL_XATTR_COW      OVL_XATTR_PRE_NAME"cow"

  static inline int ovl_do_rmdir(struct inode *dir, struct dentry *dentry)
  {
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index bf8537c..916a4b5 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -944,11 +944,6 @@ static int ovl_fill_super(struct super_block *sb, 
void *data, int silent)
              pr_err("overlayfs: failed to clone lowerpath\n");
              goto out_put_lower_mnt;
          }
-        /*
-         * Make lower_mnt R/O.  That way fchmod/fchown on lower file
-         * will fail instead of modifying lower fs.
-         */
-        mnt->mnt_flags |= MNT_READONLY;

          ufs->lower_mnt[ufs->numlower] = mnt;
          ufs->numlower++;
-- 
1.9.1





Thanks,
Jan

  reply	other threads:[~2015-06-22 15:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18 13:25 Optional switching off cow in overlayfs Jan Olszak
2015-06-18 13:39 ` David Howells
2015-06-18 14:43   ` Jan Olszak
2015-06-22 11:32     ` Miklos Szeredi
2015-06-22 13:45       ` Jan Olszak
2015-06-22 13:53         ` Miklos Szeredi
2015-06-22 14:26           ` Jan Olszak
2015-06-22 14:37             ` Miklos Szeredi
2015-06-22 15:32               ` Jan Olszak [this message]
2015-06-23  9:27               ` David Howells
2015-06-23 10:36                 ` Jan Olszak
2015-06-23 13:23                 ` David Howells
2015-06-23 16:05                   ` Jan Olszak
2015-06-23 16:07                   ` Jan Olszak
2015-06-24 16:03                     ` Jan Olszak

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=55882AA5.10908@samsung.com \
    --to=j.olszak@samsung.com \
    --cc=dhowells@redhat.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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.