From patchwork Tue May 29 14:45:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10435921 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 8CA86601E9 for ; Tue, 29 May 2018 15:03:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FAE9287A5 for ; Tue, 29 May 2018 15:03:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B2C1287A0; Tue, 29 May 2018 15:03:18 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 D0AA72884E for ; Tue, 29 May 2018 15:03:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935760AbeE2PCw (ORCPT ); Tue, 29 May 2018 11:02:52 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:38117 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935401AbeE2OqQ (ORCPT ); Tue, 29 May 2018 10:46:16 -0400 Received: by mail-wr0-f193.google.com with SMTP id 94-v6so25983523wrf.5 for ; Tue, 29 May 2018 07:46:16 -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:cc:subject:date:message-id:in-reply-to :references; bh=FHmzrDDzGqyyukDvv03m/9mMHMG+uzd1bh6cRmmCtbs=; b=VjlwPb+XCoCPALW4taMQSUFL+BTPXFBUF8BZaICsUHi2nYbSM18kVh6UXPXrUnmVji xQTbyVypV/gA33WeGjgTW7OjfjxSe0j0sMt9a6MqBuPB2+4eteKVeCrZ55Wqn9HeEC3P r0L+gEKx6jvSw3OBP/x3eiXF559tiLUPTJ6dibTeQdfYx5Eq4u0o18Dzz+WwnsywAPod OrS8MyEhPisyPslXkZkdaTKBe8D0OTv2aBTScKf8QiyYG0/Y9NezIUrnUqmRO2ohMPbE yM7dme4A3roZk3hrmPt3wqNLVtboDYQ+lR2l9pO7ZviHj0ADYVJhu9bZmLr+FD5CsTMV ESJg== X-Gm-Message-State: ALKqPwcclbESKhqDCu3QYBgJceY3b1aY59EhqitMAgcOikZTH9HXqNf2 t8xoox5JmCAmb6MeWxMOggUOsQ== X-Google-Smtp-Source: ADUXVKI4SyQXHdiuE2q7t5bmirIsw1Xhl79vLlCLMhSYx8nmLIanwZUdExeEQe6C8DRSQX7UxPS8Nw== X-Received: by 2002:adf:9025:: with SMTP id h34-v6mr8682948wrh.123.1527605175596; Tue, 29 May 2018 07:46:15 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id n71-v6sm20942227wmi.14.2018.05.29.07.46.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:46:15 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/28] ovl: Initialize ovl_inode->redirect in ovl_get_inode() Date: Tue, 29 May 2018 16:45:45 +0200 Message-Id: <20180529144612.16675-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529144612.16675-1-mszeredi@redhat.com> References: <20180529144612.16675-1-mszeredi@redhat.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 From: Vivek Goyal ovl_inode->redirect is an inode property and should be initialized in ovl_get_inode() only when we are adding a new inode to cache. If inode is already in cache, it is already initialized and we should not be touching ovl_inode->redirect field. As of now this is not a problem as redirects are used only for directories which don't share inode. But soon I want to use redirects for regular files also and there it can become an issue. Hence, move ->redirect initialization in ovl_get_inode(). Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/inode.c | 3 +++ fs/overlayfs/namei.c | 8 +------- fs/overlayfs/overlayfs.h | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index cd46dd8e7e54..c365b94fa158 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -844,6 +844,7 @@ struct inode *ovl_get_inode(struct super_block *sb, } dput(upperdentry); + kfree(oip->redirect); goto out; } @@ -867,6 +868,8 @@ struct inode *ovl_get_inode(struct super_block *sb, if (oip->index) ovl_set_flag(OVL_INDEX, inode); + OVL_I(inode)->redirect = oip->redirect; + /* Check for non-merge dir that may have whiteouts */ if (is_dir) { if (((upperdentry && lowerdentry) || oip->numlower > 1) || diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index 08801b45df00..54f206485ab8 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -1009,19 +1009,13 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, .lowerpath = stack, .index = index, .numlower = ctr, + .redirect = upperredirect, }; inode = ovl_get_inode(dentry->d_sb, &oip); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out_free_oe; - - /* - * NB: handle redirected hard links when non-dir redirects - * become possible - */ - WARN_ON(OVL_I(inode)->redirect); - OVL_I(inode)->redirect = upperredirect; } revert_creds(old_cred); diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index be4f1664f662..1948e38c3c95 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -342,6 +342,7 @@ struct ovl_inode_params { struct ovl_path *lowerpath; struct dentry *index; unsigned int numlower; + char *redirect; }; struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, dev_t rdev); struct inode *ovl_lookup_inode(struct super_block *sb, struct dentry *real,