From patchwork Thu Jan 4 17:20:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10145255 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 B72FD6034B for ; Thu, 4 Jan 2018 17:21:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EF7728761 for ; Thu, 4 Jan 2018 17:21:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93E7928791; Thu, 4 Jan 2018 17:21:21 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 41B5A28761 for ; Thu, 4 Jan 2018 17:21:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751294AbeADRVT (ORCPT ); Thu, 4 Jan 2018 12:21:19 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:43430 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752368AbeADRUv (ORCPT ); Thu, 4 Jan 2018 12:20:51 -0500 Received: by mail-wm0-f65.google.com with SMTP id n138so4768444wmg.2; Thu, 04 Jan 2018 09:20:50 -0800 (PST) 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=CMlnJawuR7wfNQc5/4H7vEuL7xFYyZyl/4WGbJPivB8=; b=IF22byVVYhk2urLt/Pr2UTrZsLxkkburzlpodMyCBzXuz+3k8N3PMT9E2qv3pJB76C rydvDdt7Yfk6gh/Aa4VAAy2stTanBm97hbWZKDedCV0NVEQiH8wdn2RNuTNot0WtCoCQ 0SFfqDKsr2UP+FS1NITuMDOCaLeDg84YLssrQHf5LJyfcx1o5zSb6bcn6w1+C3t0oPhR snbQJ4w4x9xPLT9SsnUDuzs/OMBh6KLswcO91VM0X2Td3OIF6d3Ih8BDWZzNG4nrbRO8 U6j7TpPYEeIlwdElNiGnZfBAY02F14YEM7oK82S13LrIYmNanAdrHXx8uo3wEuiWSCMN 3jqg== 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=CMlnJawuR7wfNQc5/4H7vEuL7xFYyZyl/4WGbJPivB8=; b=unkD+xb01bgVc9tpfrOaHk09pQ/EnGlAvfc7F5hi903DZK99R/MPqMGum1GeyYawL1 NSqlBU0bDnC7PB4uogGzPgcY/MISoI84T/3/WeGURIrqcpVodIw9KzjYuKckf1xHNY2c lSqHUY3+o9CXwrJi763wfmZubo6zxNIu5Jhc7A8ml25ge7TzlwAta1nZhpkS2B8LKJyY kHZkviiin6iKkZ8rW1X0bANFMscT82OCfUpX+A6J0JvR3c96xbzgRLBV63NUxCKuPg3w LU6pmTNKXKKnOthJRwKhqr2OvgBONhkQl5vCHQd0K0d8JOpaqOSc8oxmI23O1q1/roWH JhgQ== X-Gm-Message-State: AKGB3mLb7IwgBv0KL4I5b5bccBDd8VCo092ggwgM+++Kao/oz+rmsk41 3+9gK3oLHwNyDBudYDjGdjc= X-Google-Smtp-Source: ACJfBouEmXwsiNWUHxZJJnaXVHAuiGDQyfPYImegZXzobtoJu1/XZsmcHX1tHfKIaSxEEC5+ORT7GQ== X-Received: by 10.28.131.17 with SMTP id f17mr134844wmd.139.1515086450061; Thu, 04 Jan 2018 09:20:50 -0800 (PST) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id c6sm2777750wmd.21.2018.01.04.09.20.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jan 2018 09:20:49 -0800 (PST) From: Amir Goldstein To: Miklos Szeredi Cc: Jeff Layton , "J . Bruce Fields" , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 11/17] ovl: decode indexed dir file handles Date: Thu, 4 Jan 2018 19:20:43 +0200 Message-Id: <1515086449-26563-12-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515086449-26563-1-git-send-email-amir73il@gmail.com> References: <1515086449-26563-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 Decoding an indexed dir file handle is done by looking up the file handle in index dir by name and then decoding the upper dir from the index origin file handle. The decoded upper path is used to lookup an overlay dentry of the same path. Signed-off-by: Amir Goldstein --- fs/overlayfs/export.c | 13 +++++++++++++ fs/overlayfs/namei.c | 2 +- fs/overlayfs/overlayfs.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c index 6ecb54d4b52c..6141682301d6 100644 --- a/fs/overlayfs/export.c +++ b/fs/overlayfs/export.c @@ -401,6 +401,19 @@ static struct dentry *ovl_lower_fh_to_d(struct super_block *sb, index = NULL; } + /* Then try to get upper dir by index */ + if (index && d_is_dir(index)) { + struct dentry *upper = ovl_index_upper(ofs, index); + + err = PTR_ERR(upper); + if (IS_ERR_OR_NULL(upper)) + goto out_err; + + dentry = ovl_get_dentry(sb, upper, NULL, NULL); + dput(upper); + goto out; + } + /* Then lookup origin by fh */ err = ovl_check_origin_fh(fh, NULL, ofs->lower_layers, ofs->numlower, &stack); diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index 638ff196da93..13869108dc32 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -436,7 +436,7 @@ int ovl_verify_origin(struct dentry *dentry, struct dentry *origin, } /* Get upper dentry from index */ -static struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index) +struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index) { struct ovl_fh *fh; struct ovl_layer layer = { .mnt = ofs->upper_mnt }; diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 8fa8253af7cb..7310e0eca383 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -265,6 +265,7 @@ int ovl_check_origin_fh(struct ovl_fh *fh, struct dentry *upperdentry, struct ovl_path **stackp); int ovl_verify_origin(struct dentry *dentry, struct dentry *origin, bool is_upper, bool set); +struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index); int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index); int ovl_get_index_name(struct dentry *origin, struct qstr *name); struct dentry *ovl_get_index_fh(struct ovl_fs *ofs, struct ovl_fh *fh);