]> git.pld-linux.org Git - packages/kernel.git/blame - ovl10-overlayfs-create-new-inode-in-ovl_link.patch
- updated to 3.9.8
[packages/kernel.git] / ovl10-overlayfs-create-new-inode-in-ovl_link.patch
CommitLineData
68184a5a
JR
1From cb0b868591b574eb344e9c564a44e2f9b5e923eb Mon Sep 17 00:00:00 2001
2From: Robin Dong <hao.bigrat@gmail.com>
3Date: Mon, 12 Mar 2012 13:44:59 +0800
4Subject: [PATCH 10/13] overlayfs: create new inode in ovl_link
5Patch-mainline: not yet
6
7Imaging using ext4 as upperdir which has a file "hello" and lowdir is
8totally empty.
9
101. mount -t overlayfs overlayfs -o lowerdir=/lower,upperdir=/upper /overlay
112. cd /overlay
123. ln hello bye
13
14then the overlayfs code will call vfs_link to create a real ext4
15dentry for "bye" and create
16a new overlayfs dentry point to overlayfs inode (which standed for
17"hello"). That means:
18 two overlayfs dentries and only one overlayfs inode.
19
20and then
21
224. umount /overlay
235. mount -t overlayfs overlayfs -o lowerdir=/lower,upperdir=/upper
24/overlay (again)
256. cd /overlay
267. ls hello bye
27
28the overlayfs will create two inodes(one for the "hello", another
29for the "bye") and two dentries (each point a inode).That means:
30 two dentries and two inodes.
31
32As above, with different order of "create link" and "mount", the
33result is not the same.
34
35In order to make the behavior coherent, we need to create inode in ovl_link.
36
37Signed-off-by: Robin Dong <sanbai@taobao.com>
38Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
39---
40 fs/overlayfs/dir.c | 9 +++++++--
41 1 file changed, 7 insertions(+), 2 deletions(-)
42
43Index: linux-3.6-rc7-master/fs/overlayfs/dir.c
44===================================================================
45--- linux-3.6-rc7-master.orig/fs/overlayfs/dir.c 2012-09-28 13:36:53.000000000 +0200
46+++ linux-3.6-rc7-master/fs/overlayfs/dir.c 2012-09-28 13:37:04.000000000 +0200
47@@ -417,6 +417,7 @@ static int ovl_link(struct dentry *old,
48 struct dentry *olddentry;
49 struct dentry *newdentry;
50 struct dentry *upperdir;
51+ struct inode *newinode;
52
53 err = ovl_copy_up(old);
54 if (err)
55@@ -441,13 +442,17 @@ static int ovl_link(struct dentry *old,
56 err = -ENOENT;
57 goto out_unlock;
58 }
59+ newinode = ovl_new_inode(old->d_sb, newdentry->d_inode->i_mode,
60+ new->d_fsdata);
61+ if (!newinode)
62+ goto link_fail;
63
64 ovl_dentry_version_inc(new->d_parent);
65 ovl_dentry_update(new, newdentry);
66
67- ihold(old->d_inode);
68- d_instantiate(new, old->d_inode);
69+ d_instantiate(new, newinode);
70 } else {
71+link_fail:
72 if (ovl_dentry_is_opaque(new))
73 ovl_whiteout(upperdir, new);
74 dput(newdentry);
This page took 0.031088 seconds and 4 git commands to generate.