kernel: fix conntrack fixup of offloaded flows on timeout
[oweals/openwrt.git] / target / linux / generic / pending-4.14 / 140-jffs2-use-.rename2-and-add-RENAME_WHITEOUT-support.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Subject: jffs2: use .rename2 and add RENAME_WHITEOUT support
3
4 It is required for renames on overlayfs
5
6 Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 ---
8
9 --- a/fs/jffs2/dir.c
10 +++ b/fs/jffs2/dir.c
11 @@ -752,6 +752,24 @@ static int jffs2_mknod (struct inode *di
12         return ret;
13  }
14  
15 +static int jffs2_whiteout (struct inode *old_dir, struct dentry *old_dentry)
16 +{
17 +       struct dentry *wh;
18 +       int err;
19 +
20 +       wh = d_alloc(old_dentry->d_parent, &old_dentry->d_name);
21 +       if (!wh)
22 +               return -ENOMEM;
23 +
24 +       err = jffs2_mknod(old_dir, wh, S_IFCHR | WHITEOUT_MODE,
25 +                         WHITEOUT_DEV);
26 +       if (err)
27 +               return err;
28 +
29 +       d_rehash(wh);
30 +       return 0;
31 +}
32 +
33  static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
34                          struct inode *new_dir_i, struct dentry *new_dentry,
35                          unsigned int flags)
36 @@ -762,7 +780,7 @@ static int jffs2_rename (struct inode *o
37         uint8_t type;
38         uint32_t now;
39  
40 -       if (flags & ~RENAME_NOREPLACE)
41 +       if (flags & ~(RENAME_NOREPLACE|RENAME_WHITEOUT))
42                 return -EINVAL;
43  
44         /* The VFS will check for us and prevent trying to rename a
45 @@ -828,9 +846,14 @@ static int jffs2_rename (struct inode *o
46         if (d_is_dir(old_dentry) && !victim_f)
47                 inc_nlink(new_dir_i);
48  
49 -       /* Unlink the original */
50 -       ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i),
51 -                             old_dentry->d_name.name, old_dentry->d_name.len, NULL, now);
52 +       if (flags & RENAME_WHITEOUT)
53 +               /* Replace with whiteout */
54 +               ret = jffs2_whiteout(old_dir_i, old_dentry);
55 +       else
56 +               /* Unlink the original */
57 +               ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i),
58 +                                     old_dentry->d_name.name,
59 +                                     old_dentry->d_name.len, NULL, now);
60  
61         /* We don't touch inode->i_nlink */
62