From patchwork Mon Oct 30 06:53:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 831898 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=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3yQQDw1Yt4z9t3F; Mon, 30 Oct 2017 17:53:52 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1e93xD-00024Z-UD; Mon, 30 Oct 2017 06:53:47 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1e93xB-00023u-HZ for kernel-team@lists.canonical.com; Mon, 30 Oct 2017 06:53:45 +0000 Received: from mail-pf0-f200.google.com ([209.85.192.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1e93xB-00039d-6I for kernel-team@lists.canonical.com; Mon, 30 Oct 2017 06:53:45 +0000 Received: by mail-pf0-f200.google.com with SMTP id a8so11005458pfc.6 for ; Sun, 29 Oct 2017 23:53:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=3vTFxUnpHduc4QF1UfmcfoDbsJwc/MbGo11EhG31P/0=; b=igmtynXL2YnOV0Y+dHwFfgyV5zPZ7zCUO8qO3aT1rogbs5DuH68R+NUzdMqGcD/n/u AMjs58L0yZSgzWROSQdHzmh+KmXg48dX/ejHSxOX/SDUbjeabXmwkpRKnkfWZxdMkDVA L/hodh6yWgLn4DjwR9Sz5PKZeJzpRpcRGFL/YrGKqK9oWeLsgtn0/V/ka9/aM8iMXKPC jc1l3l2XeuQKqIp8ffH0VrF/Ic36vZuOkNGCGusF0SAdRqlz41fKcuurTN3sL7P0Ck1r rbkBO9Tjv8lgFW+kd2pvdCEFQQqXAOk7tfmtLtYX/wQqaps6aPPvpAjSngRPHGZ1yFZ4 PjRg== X-Gm-Message-State: AMCzsaVOJBO8FV7Fk4bZwpr+cf6Ejb21H7PXtS9Zcxib1Kj22txQ+hEz Cco5TA7t62I+OFaoyGZO+RdlM2z6wyAyDgEOwfD0y4//omegu0ZweuWkxu3Sif0e/4v/6h3ykc5 Dpw8ZoCm0MR5gaw1nc0W/wRSnClDW/nC0Cbwxwv6GnKNalC3V X-Received: by 10.84.149.102 with SMTP id b35mr6494396plh.331.1509346423830; Sun, 29 Oct 2017 23:53:43 -0700 (PDT) X-Google-Smtp-Source: ABhQp+ThrWGFYFPgHVQ9zUSYo6J37U6k4EjhZen+b0hnwh2rHxxdHHGLYa4gQjYCngMkiqqEQhr4NA== X-Received: by 10.84.149.102 with SMTP id b35mr6494386plh.331.1509346423518; Sun, 29 Oct 2017 23:53:43 -0700 (PDT) Received: from localhost.localdomain (ppp121-45-199-178.bras1.cbr1.internode.on.net. [121.45.199.178]) by smtp.gmail.com with ESMTPSA id b23sm27929580pfm.148.2017.10.29.23.53.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Oct 2017 23:53:42 -0700 (PDT) From: Daniel Axtens X-Google-Original-From: Daniel Axtens To: kernel-team@lists.canonical.com Subject: [SRU][Zesty][PATCH 01/10] ovl: check if all layers are on the same fs Date: Mon, 30 Oct 2017 17:53:22 +1100 Message-Id: <20171030065331.9452-2-dja@axtens.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171030065331.9452-1-dja@axtens.net> References: <20171030065331.9452-1-dja@axtens.net> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Amir Goldstein BugLink: https://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: Amir Goldstein Signed-off-by: Miklos Szeredi (backported from commit 7bcd74b98d7bac3e5149894caaf72de6989af7f0) Signed-off-by: Daniel Axtens --- fs/overlayfs/overlayfs.h | 1 + fs/overlayfs/ovl_entry.h | 2 ++ fs/overlayfs/super.c | 8 ++++++++ fs/overlayfs/util.c | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index f14fb7b56b09..ee05d77ad7cd 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -154,6 +154,7 @@ 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_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 d14bca1850d9..1894ce31c20b 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -27,6 +27,8 @@ struct ovl_fs { struct ovl_config config; /* creds of process who forced instantiation of super block */ const struct cred *creator_cred; + /* sb common to all layers */ + struct super_block *same_sb; }; /* private information held for every overlayfs dentry */ diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index ed2607904a1a..18c8bb3baff5 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -865,11 +865,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; diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 952286f4826c..9889daaae78b 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -39,6 +39,13 @@ const struct cred *ovl_override_creds(struct super_block *sb) return override_creds(ofs->creator_cred); } +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]);