]> git.pld-linux.org Git - packages/kernel.git/blob - ovl10-overlayfs-create-new-inode-in-ovl_link.patch
- describe vserver fix and feat patches
[packages/kernel.git] / ovl10-overlayfs-create-new-inode-in-ovl_link.patch
1 From cb0b868591b574eb344e9c564a44e2f9b5e923eb Mon Sep 17 00:00:00 2001
2 From: Robin Dong <hao.bigrat@gmail.com>
3 Date: Mon, 12 Mar 2012 13:44:59 +0800
4 Subject: [PATCH 10/13] overlayfs: create new inode in ovl_link
5 Patch-mainline: not yet
6
7 Imaging using ext4 as upperdir which has a file "hello" and lowdir is
8 totally empty.
9
10 1. mount -t overlayfs overlayfs -o lowerdir=/lower,upperdir=/upper /overlay
11 2. cd /overlay
12 3. ln hello bye
13
14 then the overlayfs code will call vfs_link to create a real ext4
15 dentry for "bye" and create
16 a new overlayfs dentry point to overlayfs inode (which standed for
17 "hello"). That means:
18         two overlayfs dentries and only one overlayfs inode.
19
20 and then
21
22 4. umount /overlay
23 5. mount -t overlayfs overlayfs -o lowerdir=/lower,upperdir=/upper
24 /overlay (again)
25 6. cd /overlay
26 7. ls hello bye
27
28 the overlayfs will create two inodes(one for the "hello", another
29 for the "bye") and two dentries (each point a inode).That means:
30         two dentries and two inodes.
31
32 As above, with different order of "create link" and "mount", the
33 result is not the same.
34
35 In order to make the behavior coherent, we need to create inode in ovl_link.
36
37 Signed-off-by: Robin Dong <sanbai@taobao.com>
38 Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
39 ---
40  fs/overlayfs/dir.c |    9 +++++++--
41  1 file changed, 7 insertions(+), 2 deletions(-)
42
43 Index: 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.034585 seconds and 3 git commands to generate.