lkml.org 
[lkml]   [2023]   [Aug]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [REGRESSION] fuse: execve() fails with ETXTBSY due to async fuse_flush
From


On 8/14/23 13:02, Miklos Szeredi wrote:
> On Mon, 14 Aug 2023 at 08:03, Jürg Billeter <j@bitron.ch> wrote:
>>
>> Since v6.3-rc1 commit 5a8bee63b1 ("fuse: in fuse_flush only wait if
>> someone wants the return code") `fput()` is called asynchronously if a
>> file is closed as part of a process exiting, i.e., if there was no
>> explicit `close()` before exit.
>>
>> If the file was open for writing, also `put_write_access()` is called
>> asynchronously as part of the async `fput()`.
>>
>> If that newly written file is an executable, attempting to `execve()`
>> the new file can fail with `ETXTBSY` if it's called after the writer
>> process exited but before the async `fput()` has run.
>
> Thanks for the report.
>
> At this point, I think it would be best to revert the original patch,
> since only v6.4 has it.
>
> The original fix was already a workaround, and I don't see a clear
> path forward in this direction. We need to see if there's better
> direction.
>
> Ideas?

Is there a good reason to flush O_RDONLY?


fuse: Avoid flush for O_RDONLY

From: Bernd Schubert <bschubert@ddn.com>

A file opened in read-only moded does not have data to be
flushed, so no need to send flush at all.

This also mitigates -EBUSY for executables, which is due to
async flush with commit 5a8bee63b1.

Fixes: 5a8bee63b1 (unless executable opened in rw)
Signed-off-by: Bernd Schubert <bschubert@ddn.com>


index 89d97f6188e0..e058a6af6751 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -545,7 +545,8 @@ static int fuse_flush(struct file *file, fl_owner_t id)
if (fuse_is_bad(inode))
return -EIO;

- if (ff->open_flags & FOPEN_NOFLUSH && !fm->fc->writeback_cache)
+ if ((ff->open_flags & FOPEN_NOFLUSH && !fm->fc->writeback_cache) ||
+ ((file->f_flags & O_ACCMODE) == O_RDONLY))
return 0;

fa = kzalloc(sizeof(*fa), GFP_KERNEL);


\
 
 \ /
  Last update: 2023-08-14 14:08    [W:0.154 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site