From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Chandan Rajendra <chandan@linux.vnet.ibm.com>,
Vivek Goyal <vgoyal@redhat.com>,
linux-unionfs@vger.kernel.org
Subject: [PATCH v6 4/9] ovl: return anonymous st_dev for lower inodes
Date: Wed, 1 Nov 2017 22:22:48 +0200 [thread overview]
Message-ID: <1509567773-25590-5-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1509567773-25590-1-git-send-email-amir73il@gmail.com>
From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
For non-samefs setup, to make sure that st_dev/st_ino pair
is unique across the system, we return a unique anonymous
st_dev for stat(2) of lower layer inode.
We need to make this change before fixing constant st_dev/st_ino across
copy up for non-samefs. Otherwise, we can end up with two objects
in the system, the real lower inode and the overlay inode which
have same st_dev/st_ino value, but different content.
[amir: simplify ovl_get_pseudo_dev()
split from allocate anonymous bdev patch]
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/inode.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index b772e5a2a730..607a50c50042 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -15,6 +15,14 @@
#include <linux/ratelimit.h>
#include "overlayfs.h"
+
+static dev_t ovl_get_pseudo_dev(struct dentry *dentry)
+{
+ struct ovl_entry *oe = dentry->d_fsdata;
+
+ return oe->lowerstack[0].layer->pseudo_dev;
+}
+
int ovl_setattr(struct dentry *dentry, struct iattr *attr)
{
int err;
@@ -121,6 +129,13 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
*/
stat->dev = dentry->d_sb->s_dev;
stat->ino = dentry->d_inode->i_ino;
+ } else if (!OVL_TYPE_UPPER(type)) {
+ /*
+ * For non-samefs setup, to make sure that st_dev/st_ino pair
+ * is unique across the system, we use a unique anonymous
+ * st_dev for lower layer inode.
+ */
+ stat->dev = ovl_get_pseudo_dev(dentry);
}
/*
--
2.7.4
next prev parent reply other threads:[~2017-11-01 20:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-01 20:22 [PATCH v6 0/9] Overlayfs: constant st_ino/d_ino for non-samefs Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 1/9] ovl: move include of ovl_entry.h into overlayfs.h Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 2/9] ovl: re-structure overlay lower layers in-memory Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 3/9] ovl: allocate anonymous devs for lowerdirs Amir Goldstein
2017-11-02 12:28 ` Vivek Goyal
2017-11-02 13:05 ` Amir Goldstein
2017-11-01 20:22 ` Amir Goldstein [this message]
2017-11-01 20:22 ` [PATCH v6 5/9] ovl: relax same fs constraint for constant st_ino Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 6/9] ovl: fix d_ino of current pure upper in non-samefs case Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 7/9] ovl: update cache version of impure parent on rename Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 8/9] ovl: update merge dir cache for non-samefs case Amir Goldstein
2017-11-01 20:22 ` [PATCH v6 9/9] ovl: update non-merge " Amir Goldstein
2017-11-02 16:33 ` [PATCH v6 0/9] Overlayfs: constant st_ino/d_ino for non-samefs Miklos Szeredi
2017-11-02 18:06 ` Amir Goldstein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1509567773-25590-5-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=chandan@linux.vnet.ibm.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=vgoyal@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).