summaryrefslogtreecommitdiffstats
path: root/fs/overlayfs/inode.c
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@mykernel.net>2021-04-24 22:03:15 +0800
committerMiklos Szeredi <mszeredi@redhat.com>2021-08-17 11:47:44 +0200
commitb71759ef1e1730db81dab98e9dab9455e8c7f5a2 (patch)
tree5488afd94a375880b955372a98dc2d401aec73e7 /fs/overlayfs/inode.c
parentffb24e3c657869b256c3f90792d262fe09f49628 (diff)
downloadlinux-b71759ef1e1730db81dab98e9dab9455e8c7f5a2.tar.gz
linux-b71759ef1e1730db81dab98e9dab9455e8c7f5a2.tar.bz2
linux-b71759ef1e1730db81dab98e9dab9455e8c7f5a2.zip
ovl: skip checking lower file's i_writecount on truncate
It is possible that a directory tree is shared between multiple overlay instances as a lower layer. In this case when one instance executes a file residing on the lower layer, the other instance denies a truncate(2) call on this file. This only happens for truncate(2) and not for open(2) with the O_TRUNC flag. Fix this interference and inconsistency by removing the preliminary i_writecount check before copy-up. This means that unlike on normal filesystems truncate(argv[0]) will now succeed. If this ever causes a regression in a real world use case this needs to be revisited. One way to fix this properly would be to keep a correct i_writecount in the overlay inode, but that is difficult due to memory mapping code only dealing with the real file/inode. Signed-off-by: Chengguang Xu <cgxu519@mykernel.net> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/inode.c')
-rw-r--r--fs/overlayfs/inode.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 37300e972a39..8aa370e8143a 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -33,12 +33,6 @@ int ovl_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
goto out;
if (attr->ia_valid & ATTR_SIZE) {
- struct inode *realinode = d_inode(ovl_dentry_real(dentry));
-
- err = -ETXTBSY;
- if (atomic_read(&realinode->i_writecount) < 0)
- goto out_drop_write;
-
/* Truncate should trigger data copy up as well */
full_copy_up = true;
}