* [PATCH 0/2] Fix hardlinks in overlay
@ 2015-10-09 19:34 Alexander Morozov
2015-10-09 19:34 ` [PATCH 1/2] fs/overlay: move update and instantiate dentry code to function Alexander Morozov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Alexander Morozov @ 2015-10-09 19:34 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: LKML, Alexander Morozov
There were reports that overlay doesn't work very well with unix-sockets.
In particular you can't access unix-socket through hardlink on overlay fs.
Problem is that overlay creates different inodes for hardlinks and code in
net/unix/af_unix.c relies on inodes for unix-socket lookup. I think this
affects any code which relies on inodes from kern_path. There is helper
d_backing_inode, which I think supposed to get inodes from underlying fs
(for example ext4), but in current implementation it does nothing. These
patches made on top of v4.3-rc4 of main linux tree (master is broken for my
ubuntu VM), but I tested that they applying on master and there was no
changes to overlay since v4.3-rc4.
Alexander Morozov (2):
fs/overlay: move update and instantiate dentry code to function
fs/overlay: use same inodes for hardlinks
fs/overlayfs/dir.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
--
2.6.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] fs/overlay: move update and instantiate dentry code to function
2015-10-09 19:34 [PATCH 0/2] Fix hardlinks in overlay Alexander Morozov
@ 2015-10-09 19:34 ` Alexander Morozov
2015-10-09 19:34 ` [PATCH 2/2] fs/overlay: use same inodes for hardlinks Alexander Morozov
2016-03-07 10:49 ` [PATCH 0/2] Fix hardlinks in overlay Miklos Szeredi
2 siblings, 0 replies; 6+ messages in thread
From: Alexander Morozov @ 2015-10-09 19:34 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: LKML, Alexander Morozov
ovl_create_upper and ovl_create_over_whiteout shared same code about
updating and instantiating dentry. Move that code to
ovl_dentry_update_instantiate function, so it'll be easier to bring new
changes there.
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
---
fs/overlayfs/dir.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 692ceda..487a157 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -158,6 +158,16 @@ static int ovl_dir_getattr(struct vfsmount *mnt, struct dentry *dentry,
return 0;
}
+static void ovl_dentry_update_instantiate(struct dentry *dentry,
+ struct dentry *newdentry,
+ struct inode *inode)
+{
+ ovl_dentry_version_inc(dentry->d_parent);
+ ovl_dentry_update(dentry, newdentry);
+ ovl_copyattr(newdentry->d_inode, inode);
+ d_instantiate(dentry, inode);
+}
+
static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
struct kstat *stat, const char *link,
struct dentry *hardlink)
@@ -177,10 +187,7 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
if (err)
goto out_dput;
- ovl_dentry_version_inc(dentry->d_parent);
- ovl_dentry_update(dentry, newdentry);
- ovl_copyattr(newdentry->d_inode, inode);
- d_instantiate(dentry, inode);
+ ovl_dentry_update_instantiate(dentry, newdentry, inode);
newdentry = NULL;
out_dput:
dput(newdentry);
@@ -363,10 +370,7 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
if (err)
goto out_cleanup;
}
- ovl_dentry_version_inc(dentry->d_parent);
- ovl_dentry_update(dentry, newdentry);
- ovl_copyattr(newdentry->d_inode, inode);
- d_instantiate(dentry, inode);
+ ovl_dentry_update_instantiate(dentry, newdentry, inode);
newdentry = NULL;
out_dput2:
dput(upper);
--
2.6.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] fs/overlay: use same inodes for hardlinks
2015-10-09 19:34 [PATCH 0/2] Fix hardlinks in overlay Alexander Morozov
2015-10-09 19:34 ` [PATCH 1/2] fs/overlay: move update and instantiate dentry code to function Alexander Morozov
@ 2015-10-09 19:34 ` Alexander Morozov
2015-11-23 23:23 ` Alexander Morozov
2016-03-07 10:49 ` [PATCH 0/2] Fix hardlinks in overlay Miklos Szeredi
2 siblings, 1 reply; 6+ messages in thread
From: Alexander Morozov @ 2015-10-09 19:34 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: LKML, Alexander Morozov
Fix problem with accessing hardlink to unix-socket. unix_find_other
function from net/unix/af_unix.c uses d_backing_inode helper which in
current implementation doesn't return any "backing" inode, but just
dentry->d_inode, so, there from kern_path we have path with dentry from
overlayfs and not underlying file system. Further in code in
unix_find_socket_byinode we looking for unix-socket by inode, but due
overlayfs implementation that inode for hardlink will be different from
original inode of unix-socket.
Now ovl_link doesn't create new inode, but uses old->d_inode for
instantiating new dentry. Not use inc_nlink, because nlink seems to be
correctly propagated from underlying fs where it need.
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
---
fs/overlayfs/dir.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 487a157..a55c89b 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -164,8 +164,14 @@ static void ovl_dentry_update_instantiate(struct dentry *dentry,
{
ovl_dentry_version_inc(dentry->d_parent);
ovl_dentry_update(dentry, newdentry);
- ovl_copyattr(newdentry->d_inode, inode);
- d_instantiate(dentry, inode);
+ /*
+ * inode == NULL only in case of hardlink
+ * for hardlink dentry will be instantiated in ovl_link
+ */
+ if (inode) {
+ ovl_copyattr(newdentry->d_inode, inode);
+ d_instantiate(dentry, inode);
+ }
}
static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
@@ -390,16 +396,19 @@ static int ovl_create_or_link(struct dentry *dentry, int mode, dev_t rdev,
const char *link, struct dentry *hardlink)
{
int err;
- struct inode *inode;
+ struct inode *inode = NULL;
struct kstat stat = {
.mode = mode,
.rdev = rdev,
};
err = -ENOMEM;
- inode = ovl_new_inode(dentry->d_sb, mode, dentry->d_fsdata);
- if (!inode)
- goto out;
+ /* We don't need inode for hardlink */
+ if (!hardlink) {
+ inode = ovl_new_inode(dentry->d_sb, mode, dentry->d_fsdata);
+ if (!inode)
+ goto out;
+ }
err = ovl_copy_up(dentry->d_parent);
if (err)
@@ -498,6 +507,10 @@ static int ovl_link(struct dentry *old, struct inode *newdir,
upper = ovl_dentry_upper(old);
err = ovl_create_or_link(new, upper->d_inode->i_mode, 0, NULL, upper);
+ if (!err) {
+ ihold(old->d_inode);
+ d_instantiate(new, old->d_inode);
+ }
out_drop_write:
ovl_drop_write(old);
--
2.6.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] fs/overlay: use same inodes for hardlinks
2015-10-09 19:34 ` [PATCH 2/2] fs/overlay: use same inodes for hardlinks Alexander Morozov
@ 2015-11-23 23:23 ` Alexander Morozov
0 siblings, 0 replies; 6+ messages in thread
From: Alexander Morozov @ 2015-11-23 23:23 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: LKML, Alexander Morozov, linux-unionfs
ping
it's still fixes issue for me
and still can be applied to master of main linux tree
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] Fix hardlinks in overlay
2015-10-09 19:34 [PATCH 0/2] Fix hardlinks in overlay Alexander Morozov
2015-10-09 19:34 ` [PATCH 1/2] fs/overlay: move update and instantiate dentry code to function Alexander Morozov
2015-10-09 19:34 ` [PATCH 2/2] fs/overlay: use same inodes for hardlinks Alexander Morozov
@ 2016-03-07 10:49 ` Miklos Szeredi
2016-03-07 17:33 ` Alexander Morozov
2 siblings, 1 reply; 6+ messages in thread
From: Miklos Szeredi @ 2016-03-07 10:49 UTC (permalink / raw)
To: Alexander Morozov; +Cc: LKML, Alexander Morozov, linux-unionfs
On Fri, Oct 9, 2015 at 9:34 PM, Alexander Morozov
<alexandr.morozov@docker.com> wrote:
> There were reports that overlay doesn't work very well with unix-sockets.
> In particular you can't access unix-socket through hardlink on overlay fs.
> Problem is that overlay creates different inodes for hardlinks and code in
> net/unix/af_unix.c relies on inodes for unix-socket lookup. I think this
> affects any code which relies on inodes from kern_path. There is helper
> d_backing_inode, which I think supposed to get inodes from underlying fs
> (for example ext4), but in current implementation it does nothing. These
> patches made on top of v4.3-rc4 of main linux tree (master is broken for my
> ubuntu VM), but I tested that they applying on master and there was no
> changes to overlay since v4.3-rc4.
>
> Alexander Morozov (2):
> fs/overlay: move update and instantiate dentry code to function
> fs/overlay: use same inodes for hardlinks
Problem is with lookup: how do we go from backing dentry to overlayfs
dentry so the inode can be shared?
Thanks,
Miklos
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] Fix hardlinks in overlay
2016-03-07 10:49 ` [PATCH 0/2] Fix hardlinks in overlay Miklos Szeredi
@ 2016-03-07 17:33 ` Alexander Morozov
0 siblings, 0 replies; 6+ messages in thread
From: Alexander Morozov @ 2016-03-07 17:33 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: LKML, Alexander Morozov, linux-unionfs
Sequence of calls is kern_path(filename, LOOKUP_FOLLOW, &path) ->
filename_lookup(AT_FDCWD, getname_kernel(name), flags, path, NULL) ->
path_lookup(nameidata *nd, flags | LOOKUP_RCU, path) -> path_init(nd,
flags). In that function if I understand correctly nd->path is set to
current_thread_info()->task->fs->pwd and I don't see any further
tricks with dentry, so I suppose that
current_thread_info()->task->fs->pwd->dentry already points to
overlayfs dentry.
Let me know what we can do with it.
Thanks!
- Alex
On Mon, Mar 7, 2016 at 2:49 AM, Miklos Szeredi <miklos@szeredi.hu> wrote:
> On Fri, Oct 9, 2015 at 9:34 PM, Alexander Morozov
> <alexandr.morozov@docker.com> wrote:
>> There were reports that overlay doesn't work very well with unix-sockets.
>> In particular you can't access unix-socket through hardlink on overlay fs.
>> Problem is that overlay creates different inodes for hardlinks and code in
>> net/unix/af_unix.c relies on inodes for unix-socket lookup. I think this
>> affects any code which relies on inodes from kern_path. There is helper
>> d_backing_inode, which I think supposed to get inodes from underlying fs
>> (for example ext4), but in current implementation it does nothing. These
>> patches made on top of v4.3-rc4 of main linux tree (master is broken for my
>> ubuntu VM), but I tested that they applying on master and there was no
>> changes to overlay since v4.3-rc4.
>>
>> Alexander Morozov (2):
>> fs/overlay: move update and instantiate dentry code to function
>> fs/overlay: use same inodes for hardlinks
>
> Problem is with lookup: how do we go from backing dentry to overlayfs
> dentry so the inode can be shared?
>
> Thanks,
> Miklos
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-03-07 17:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-09 19:34 [PATCH 0/2] Fix hardlinks in overlay Alexander Morozov
2015-10-09 19:34 ` [PATCH 1/2] fs/overlay: move update and instantiate dentry code to function Alexander Morozov
2015-10-09 19:34 ` [PATCH 2/2] fs/overlay: use same inodes for hardlinks Alexander Morozov
2015-11-23 23:23 ` Alexander Morozov
2016-03-07 10:49 ` [PATCH 0/2] Fix hardlinks in overlay Miklos Szeredi
2016-03-07 17:33 ` Alexander Morozov
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).