From patchwork Wed Apr 26 21:35:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9702111 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 DAD35603F4 for ; Wed, 26 Apr 2017 21:35:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB9362858E for ; Wed, 26 Apr 2017 21:35:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0610285EB; Wed, 26 Apr 2017 21:35:57 +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 6216B2858E for ; Wed, 26 Apr 2017 21:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030921AbdDZVfy (ORCPT ); Wed, 26 Apr 2017 17:35:54 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:35466 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030881AbdDZVfg (ORCPT ); Wed, 26 Apr 2017 17:35:36 -0400 Received: by mail-wr0-f195.google.com with SMTP id g12so1674384wrg.2; Wed, 26 Apr 2017 14:35:31 -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=yGEs57Zy+Aekq6iF9CfCKA81ceH9Wb8pdImWDl3jAE8=; b=as9RRqYrIA8OkykJwmYLFeXiSCjw7Y5B9rWNmeOdFh8JwDfxl5EgQna9gVomJKwUD3 AKGmpLQ5/LxkkiWoMQt9ZEN9SGyE8MLpr7L7MtofYszvcYLmMAjOyaUve8w6AWedCPb4 DqwNICsxMtre1h/4XrCKwYILQvRQ0oKb//+7R7l1jQBelkB5g8onNj3FdVwWNxPg3IgG RHDwpWtVbh9B3sWclt/fQFv9GXqzeJ0/pQtaSAC9to4hUquUqAdR1tZWKx345jB0pit6 dCnxLTZfu0F9BH28w2aYAzqCXkX6QpqczSSAEo/hJqF6p7qm87kqlPhQoQp0bSUCQJHL ih6g== 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=yGEs57Zy+Aekq6iF9CfCKA81ceH9Wb8pdImWDl3jAE8=; b=fpY7auEefxOwDe/wmNAI0OH1u7rbW5ycNwOrpV4PLNhPUDBH4PwpBZwiWsrEKF9TZf 6t+ig/sUg4zE3GW2AqfvE2NHfyjAG+wTIP3CM5ChkbhaGfJoV7IRAu5WPzHuGya9g/3/ GINWSchhN9ohvgw+ZyHfJkf+e+8XEnQVS6kAcPRpjI899q8637A3yIJRie4BHMcG2XZe jUK2cJ5jaZSzVqTewbX80whf1R7/8w2YjtZ4z1fq2riKiVQRDeaXqcQ1t97jd5efuU9v DdvniIPyNNXB81PHDtZ6obkYDWxxe8zrseJtW5sNsB4Jdys/Yu2BvkIFolTnQ8+tULIs q2zw== X-Gm-Message-State: AN3rC/6MJ6Me/heQ2Mxr1m4qCtLfbdZOdFfEYlTL7jIGUG97Nh1P2M91 PafTJEo/aoItOQ== X-Received: by 10.223.181.131 with SMTP id c3mr1305777wre.155.1493242530403; Wed, 26 Apr 2017 14:35:30 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Apr 2017 14:35:29 -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 13/16] ovl: persistent inode number for directories Date: Thu, 27 Apr 2017 00:35:15 +0300 Message-Id: <1493242518-15266-14-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 stat(2) on overlay directories reports the overlay temp inode number, which is constant across copy up, but is not persistent. When all layers are on the same fs, report the upper most lower inode (a.k.a stable inode) number for directories. This inode number is persistent, unique across the overlay mount and constant across copy up. Signed-off-by: Amir Goldstein --- fs/overlayfs/dir.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 7372c15..da65c02 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -154,8 +154,23 @@ static int ovl_dir_getattr(const struct path *path, struct kstat *stat, if (err) return err; + /* + * Always use the overlay bdev for directories, so 'find -xdev' will + * scan the entire overlay mount and won't cross the overlay mount + * boundaries. + */ stat->dev = dentry->d_sb->s_dev; - stat->ino = dentry->d_inode->i_ino; + /* + * When all layers are not on the same fs, the pair real inode numbers + * and overlay bdev is not unique, so use the non persistent overlay + * inode number. + * When all layers are on the same fs, use the stable inode number, + * which is persistent, unique and constant across copy up. + */ + if (!ovl_same_sb(dentry->d_sb)) + stat->ino = dentry->d_inode->i_ino; + else if (OVL_TYPE_UPPER(type) && OVL_TYPE_MERGE(type)) + stat->ino = ovl_dentry_lower(dentry)->d_inode->i_ino; /* * It's probably not worth it to count subdirs to get the