From patchwork Wed Apr 26 21:35:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9702117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 98DD4603F4 for ; Wed, 26 Apr 2017 21:36:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 895CE285EE for ; Wed, 26 Apr 2017 21:36:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E508285F3; Wed, 26 Apr 2017 21:36:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6F50285EE for ; Wed, 26 Apr 2017 21:36:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030922AbdDZVf7 (ORCPT ); Wed, 26 Apr 2017 17:35:59 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:33887 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030885AbdDZVfh (ORCPT ); Wed, 26 Apr 2017 17:35:37 -0400 Received: by mail-wr0-f194.google.com with SMTP id 6so1682732wrb.1; Wed, 26 Apr 2017 14:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8xhZyksquIAfzTHvZTORhs3H0ZNR/vTP/qfcWquGetw=; b=lHKjeTM60O/6c4wi2kMILjeuzuQpISA2yKTTMM2nJKXoaoFYPAsOk//jgErFptS89e HCHufmY/vhC8/dIsY+l8xeTPOBg1UsEgINARN4VHbKf1mez3W/9T0/8gzBrt9HRIJyq9 qewhAybTr7OTytStX6UHWJjqkfnOrQSdK70XSyT4yJjIvkyZdolixY0WvdWYahSB7GT5 ZZXxoEW967n5toq41x26yXUcm0f2RXewdMlWsL+3EfVu5pJPhfC/aGXX0/1IoxNKZlGp R4OwKmZNIfcfCJ0SwyQ3vk5hN1bOSzNPZuvKzRH3b5SZk5QbbzGkw+Qm1ylpNWLnhIxZ unRA== 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:in-reply-to :references; bh=8xhZyksquIAfzTHvZTORhs3H0ZNR/vTP/qfcWquGetw=; b=KSNS8IMDCdSLmSOUosP17lhGI5zgwBXqR0Hqms48qOqB1XKlwMDuRjtdaX0dBk4rvU KOO9qKauCgAOsqDqJoZqq4D5O2ud3BhzlawiqrnMYPjUVog3L0sikyj6bANR3iUxn8aU qNiJ/OBI+0flgq4SZSUcrhpJhH0fNyFtCiWg3YN+JH3wylLLSvwcF96UCOFYMsvfd9wd 6roCVN2lrYH4RcakQg6rOHe+qqabI7MaFlzoXtc2ZglEts7GK3xwMcP5PLLCqRLXuhfS yXbJ/IGa5EEGpFZf+tCBydZl19RcrW2iPFRuHKbqhskH48NuPmU+rC5fkaomvuif60Uj GitQ== X-Gm-Message-State: AN3rC/760tC7JeDhlx6BEJ1eupsncvLml6YWnSwlhDJ77lJpSZlR7sQs 37QCufZp40+Vd/KO X-Received: by 10.223.171.26 with SMTP id q26mr1177526wrc.15.1493242525491; Wed, 26 Apr 2017 14:35:25 -0700 (PDT) Received: from amir-VirtualBox.lan (bzq-79-179-55-127.red.bezeqint.net. [79.179.55.127]) by smtp.gmail.com with ESMTPSA id 81sm931577wmj.9.2017.04.26.14.35.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Apr 2017 14:35:24 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Vivek Goyal , Al Viro , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 10/16] ovl: set the COPYUP type flag for non-dirs Date: Thu, 27 Apr 2017 00:35:12 +0300 Message-Id: <1493242518-15266-11-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493242518-15266-1-git-send-email-amir73il@gmail.com> References: <1493242518-15266-1-git-send-email-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For directory entries, non zero oe->numlower implies OVL_TYPE_MERGE. Define a new type flag OVL_TYPE_COPYUP to indicate that an entry is a target of a copy up. For directory entries COPYUP = MERGE && UPPER. For non-dir entries non zero oe->numlower implies COPYUP, but COPYUP does not imply non zero oe->numlower. COPYUP can also be set on lookup when detecting an overlay.fh xattr on a non-dir, even if that fh cannot be followed. Signed-off-by: Amir Goldstein --- fs/overlayfs/namei.c | 3 +++ fs/overlayfs/overlayfs.h | 2 ++ fs/overlayfs/util.c | 12 ++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index ad2c784..3ebde1b 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -457,6 +457,9 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, } if (d.opaque) type |= __OVL_PATH_OPAQUE; + /* overlay.fh xattr implies this is a copy up */ + if (d.fh) + type |= __OVL_PATH_COPYUP; } /* diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index ea23bef..d9633b3 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -13,11 +13,13 @@ enum ovl_path_type { __OVL_PATH_UPPER = (1 << 0), __OVL_PATH_MERGE = (1 << 1), __OVL_PATH_OPAQUE = (1 << 2), + __OVL_PATH_COPYUP = (1 << 3), }; #define OVL_TYPE_UPPER(type) ((type) & __OVL_PATH_UPPER) #define OVL_TYPE_MERGE(type) ((type) & __OVL_PATH_MERGE) #define OVL_TYPE_OPAQUE(type) ((type) & __OVL_PATH_OPAQUE) +#define OVL_TYPE_COPYUP(type) ((type) & __OVL_PATH_COPYUP) #define OVL_XATTR_PREFIX XATTR_TRUSTED_PREFIX "overlay." #define OVL_XATTR_OPAQUE OVL_XATTR_PREFIX "opaque" diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index a36ca7b..931d199 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -101,11 +101,15 @@ enum ovl_path_type ovl_update_type(struct dentry *dentry, bool is_dir) if (oe->__upperdentry) { type |= __OVL_PATH_UPPER; /* - * Non-dir dentry can hold lower dentry from before - * copy-up. + * oe->numlower implies a copy up, but copy up does not imply + * oe->numlower. It can also be set on lookup when detecting + * an overlay.fh xattr on a non-dir that cannot be followed. */ - if (oe->numlower && is_dir) - type |= __OVL_PATH_MERGE; + if (oe->numlower) { + type |= __OVL_PATH_COPYUP; + if (is_dir) + type |= __OVL_PATH_MERGE; + } } else { if (oe->numlower > 1) type |= __OVL_PATH_MERGE;