From patchwork Thu Jan 4 17:20:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10145229 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 BBCBE6034B for ; Thu, 4 Jan 2018 17:20:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0533223C6 for ; Thu, 4 Jan 2018 17:20:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 951812874E; Thu, 4 Jan 2018 17:20:50 +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 33C39223C6 for ; Thu, 4 Jan 2018 17:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751975AbeADRUt (ORCPT ); Thu, 4 Jan 2018 12:20:49 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:38488 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751682AbeADRUo (ORCPT ); Thu, 4 Jan 2018 12:20:44 -0500 Received: by mail-wm0-f67.google.com with SMTP id 64so4651785wme.3; Thu, 04 Jan 2018 09:20:43 -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=v+cFibs63+LQRaeOpZn8IjQXZon1vTJ35im9RdrAM+A=; b=ZJuhyczubwyzt1areov19I25t8XucpTl6J+Pc7YAqoKvGhtG1f9aUDGZGpKQn4pR/c SelcptjlFt2Oi6hG80nC3SUGoIMNIspN+tjk8wqZFFnJgcpfMhpfaMCY/vTbq3DP4gHs VvMcASQFOYYy2YDPazI/WOTDVjA9Xm1Of14VR2BxB8sxh9fZjrK0uRiil7QtHz9lb6pS fklFgCQzJIcKT0hZ16nXC77QLxmozwkWxbZ4JsQd2DTqahkFoSMOTGsO324sAXjZr+S9 zqKjuGqWF3mI+XFxraPDlgBoVSX/xcx7OlkC38LlCqjj6XEgpy0pI8H63dZtlsoWzywS nvow== 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=v+cFibs63+LQRaeOpZn8IjQXZon1vTJ35im9RdrAM+A=; b=Gg+FRjPY3JwVS1xU6nkhEjoyxVFVwlCrqgORzclWTjzbAK2fH2XwnnvXgUYStepFJj CAzQJqXsFe7+cK9glCRWDAeRCNxtg60tR9pJzsgG9nxrQkWeLzpgCEOKHmLXEMszpNU7 Mw8QlmJdSln3VByxLxSaByON/SFr3RpCbYroK31LelANzZhjlKjnLnV+56t2pivAoFUk C8kbKr5tCuSKeQWlPLaXmGhO2Rlsq+KMYiJ7fo7ntA/lqqgGwBQEJBskFaQ/88BcJBsU Z/1/sYnfBDHkYOEgCVyMLI9ylih23jBQ8TSMAqsXjxTe3iohxpdpBfH+wAJuNgpRxBHJ zMAw== X-Gm-Message-State: AKGB3mLHFTsb8l5eHvaJPrVRQrj0tQpQc/ynWq2XPPf+5MObL0/gSSa4 fdD/yoLlSqFGXAXAjm4p7X0= X-Google-Smtp-Source: ACJfBoukNEvqru/FUJmn7KpySJfMRv+oj+EpBO4CLtmI1jT99Ysgaw01jYpqF57j8W+zvW528FFkSA== X-Received: by 10.28.238.72 with SMTP id m69mr186890wmh.17.1515086442910; Thu, 04 Jan 2018 09:20:42 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jan 2018 09:20:42 -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 05/17] ovl: encode non-indexed upper file handles Date: Thu, 4 Jan 2018 19:20:37 +0200 Message-Id: <1515086449-26563-6-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 We only need to encode origin if there is a chance that the same object was encoded pre copy up and then we need to stay consistent with the same encoding also after copy up. In case a non-pure upper is not indexed, then it was copied up before NFS export support was enabled. In that case, we don't need to worry about staying consistent with pre copy up encoding and we encode an upper file handle. This mitigates the problem that with no index, we cannot find an upper inode from origin inode, so we cannot decode a non-indexed upper from origin file handle. Signed-off-by: Amir Goldstein --- fs/overlayfs/export.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c index 48ae02f3acb8..919d43aaa387 100644 --- a/fs/overlayfs/export.c +++ b/fs/overlayfs/export.c @@ -19,6 +19,28 @@ #include #include "overlayfs.h" +/* + * We only need to encode origin if there is a chance that the same object was + * encoded pre copy up and then we need to stay consistent with the same + * encoding also after copy up. If non-pure upper is not indexed, then it was + * copied up before NFS export was enabled. In that case we don't need to worry + * about staying consistent with pre copy up encoding and we encode an upper + * file handle. + */ +static bool ovl_should_encode_origin(struct dentry *dentry) +{ + /* Root dentry was born upper */ + if (dentry == dentry->d_sb->s_root) + return false; + + /* Decoding a non-indexed upper from origin is not implemented */ + if (ovl_dentry_upper(dentry) && + !ovl_test_flag(OVL_INDEX, d_inode(dentry))) + return false; + + return true; +} + int ovl_d_to_fh(struct dentry *dentry, char *buf, int buflen) { struct dentry *upper = ovl_dentry_upper(dentry); @@ -26,11 +48,7 @@ int ovl_d_to_fh(struct dentry *dentry, char *buf, int buflen) struct ovl_fh *fh = NULL; int err; - /* - * Overlay root dir inode is encoded as an upper file handle upper, - * because root dir dentry is born upper and not indexed. - */ - if (dentry == dentry->d_sb->s_root) + if (!ovl_should_encode_origin(dentry)) origin = NULL; err = -EACCES;