From patchwork Thu Aug 1 18:08:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 1140671 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=brauner.io Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=brauner.io header.i=@brauner.io header.b="SnYef5Pe"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45zywK5HfDz9sDQ; Fri, 2 Aug 2019 04:08:49 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1htFVN-0002iu-2a; Thu, 01 Aug 2019 18:08:45 +0000 Received: from mail-io1-f67.google.com ([209.85.166.67]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1htFVK-0002ig-EG for kernel-team@lists.ubuntu.com; Thu, 01 Aug 2019 18:08:42 +0000 Received: by mail-io1-f67.google.com with SMTP id e20so13424072iob.9 for ; Thu, 01 Aug 2019 11:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4yEB27qBamg5sOLsceyvyPwFpsdGjft3mOX6bWcpJSo=; b=SnYef5PejHLMKGAF81BAelon7h6l/5kDuokXzAZmBYHPFsnSID9kV95MntnDw9Ubbn 8FykxfUQ6Tqzi2rnIOk1D+jLKmxY/ZLZ+ZV2VjXkQ+1fHvLD772B9gBegnGX77civzSd CggAUc8nYpR6Wmk4HbtaAbHpkuOhJ9kJeyAjcXhmqbWv4xS4zKKqFaT6+RaczKfyw1/B bDoxaOiqmi2ZX/eshc9wsTL8SNyJZmLaWiO7Y9dpXbaPmixR+ryfVDgNDaChQm3nHjRp bzAPuA+0NfT54tbJZLcUDD3IYVC0OXslEXzzVA7dsCxTGixqolxh5Vkmgz5qlFeMv0kU zguQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4yEB27qBamg5sOLsceyvyPwFpsdGjft3mOX6bWcpJSo=; b=YqSUfNj8LC+An5GuNiT/BuqtPgmmaMcZKLI6TImYXboo8YA3LHfP20RJl6YZaU28oj EdVGSSim8UUbvb2W8ku3/RV2pVV/AHxC39lUBXtRcbXRqLZLRLPGYfT0UNUdy4Iefm8Q xDd0cUwTCeD85FZZZ1IMTVREQQ4F/Td9KfzLCrbSRmMQuOj6ryeJ6juVr5q66VYQvj7u AHbaw1mA4j+x0h8GsCBHsZFDCMYn1A38On63rcqucSLI8zjKwU+eTlBc8YLLMv6FZFSS i+99VHuqPqX64V2YI6eeYf/qzbs2Cv7GNSs/dv5QySqlEbiR6LZxk/YdkIeqfx6jehEj bizA== X-Gm-Message-State: APjAAAX1g1Ep1vIMEPxjA3asIfKJpnOFfOpLZ6ygGx2q27IeqpSPlVXD EuHEbbmsxSCM9b+yuCKKvzSMmpCE+8w= X-Google-Smtp-Source: APXvYqwl7Y+FwPAlBVGsM53beUkCnAvX+gCRmilqkzdAcycr47daWYITenEXzyK9B70vg2c0uI6BUw== X-Received: by 2002:a6b:f216:: with SMTP id q22mr79562751ioh.65.1564682920505; Thu, 01 Aug 2019 11:08:40 -0700 (PDT) Received: from localhost.localdomain ([162.223.5.78]) by smtp.gmail.com with ESMTPSA id n2sm75336556ioa.27.2019.08.01.11.08.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 11:08:39 -0700 (PDT) From: Christian Brauner X-Google-Original-From: Christian Brauner To: kernel-team@lists.ubuntu.com Subject: [PATCH][SRU][Disco] UBUNTU: SAUCE: shiftfs: enable overlayfs on shiftfs Date: Thu, 1 Aug 2019 20:08:29 +0200 Message-Id: <20190801180829.26981-1-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Brauner , stgraber@ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Christian Brauner BugLink: https://bugs.launchpad.net/bugs/1838677 This patch enables overlayfs to use shiftfs as an underlay. Currently it is not possible to use overlayfs on top of shiftfs. This means Docker inside of LXD cannot make user of the overlay2 graph driver which is blocking users such as Travis from making use of it efficiently. Co-Developed-by: Seth Forshee Signed-off-by: Seth Forshee Signed-off-by: Christian Brauner Acked-by: Stefan Bader Acked-by: Kleber Sacilotto de Souza --- fs/open.c | 4 +++- fs/overlayfs/file.c | 1 + fs/overlayfs/super.c | 5 +++-- fs/shiftfs.c | 4 +++- include/linux/fs.h | 3 ++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/fs/open.c b/fs/open.c index 14502dde6403..b8268a334dc9 100644 --- a/fs/open.c +++ b/fs/open.c @@ -914,13 +914,15 @@ struct file *dentry_open(const struct path *path, int flags, EXPORT_SYMBOL(dentry_open); struct file *open_with_fake_path(const struct path *path, int flags, - struct inode *inode, const struct cred *cred) + struct inode *inode, struct dentry *dentry, + const struct cred *cred) { struct file *f = alloc_empty_file_noaccount(flags, cred); if (!IS_ERR(f)) { int error; f->f_path = *path; + f->f_path.dentry = dentry; error = do_dentry_open(f, inode, NULL); if (error) { fput(f); diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 6f6eb638a320..fe61b86c843b 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -33,6 +33,7 @@ static struct file *ovl_open_realfile(const struct file *file, old_cred = ovl_override_creds(inode->i_sb); realfile = open_with_fake_path(&file->f_path, flags, realinode, + ovl_dentry_real(file->f_path.dentry), current_cred()); revert_creds(old_cred); diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index bb2a6f80ffd0..46def89a3664 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -748,13 +748,14 @@ static int ovl_mount_dir(const char *name, struct path *path) ovl_unescape(tmp); err = ovl_mount_dir_noesc(tmp, path); - if (!err) - if (ovl_dentry_remote(path->dentry)) { + if (!err) { + if ((path->dentry->d_sb->s_magic != SHIFTFS_MAGIC) && ovl_dentry_remote(path->dentry)) { pr_err("overlayfs: filesystem on '%s' not supported as upperdir\n", tmp); path_put_init(path); err = -EINVAL; } + } kfree(tmp); } return err; diff --git a/fs/shiftfs.c b/fs/shiftfs.c index 49f6714e9f95..400c3062365c 100644 --- a/fs/shiftfs.c +++ b/fs/shiftfs.c @@ -1048,7 +1048,9 @@ static struct file *shiftfs_open_realfile(const struct file *file, oldcred = shiftfs_override_creds(inode->i_sb); /* XXX: open_with_fake_path() not gauranteed to stay around, if * removed use dentry_open() */ - lowerf = open_with_fake_path(realpath, file->f_flags, loweri, info->creator_cred); + lowerf = open_with_fake_path(realpath, file->f_flags, loweri, + realpath->dentry, + info->creator_cred); revert_creds(oldcred); return lowerf; diff --git a/include/linux/fs.h b/include/linux/fs.h index 5dd548c73f8d..4cb7a1124c5f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2524,7 +2524,8 @@ extern struct file *file_open_root(struct dentry *, struct vfsmount *, const char *, int, umode_t); extern struct file * dentry_open(const struct path *, int, const struct cred *); extern struct file * open_with_fake_path(const struct path *, int, - struct inode*, const struct cred *); + struct inode*, struct dentry *dentry, + const struct cred *); static inline struct file *file_clone_open(struct file *file) { return dentry_open(&file->f_path, file->f_flags, file->f_cred);