From: Nikolaus Rath <Nikolaus@rath.org>
To: fuse-devel@lists.sourceforge.net,
Maxim Patlasov <mpatlasov@virtuozzo.com>,
Miklos Szeredi <mszeredi@redhat.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [fuse] writeback cache triggers read() for O_WRONLY files - bug?
Date: Fri, 04 Aug 2017 21:00:54 +0200 [thread overview]
Message-ID: <87pocbupi1.fsf@vostro.rath.org> (raw)
In-Reply-To: <87tw1nuq49.fsf@vostro.rath.org> (Nikolaus Rath's message of "Fri, 04 Aug 2017 20:47:34 +0200")
Hi again,
Small clarification: the O_APPEND flag muddles the water a bit (I'll
write a second mail about that). The behavior that I'm describing here
also happens if userspace opens without O_APPEND but seeks to the end of
the file before writing.
Best,
-Nikolaus
On Aug 04 2017, Nikolaus Rath <Nikolaus@rath.org> wrote:
> Hello,
>
> When enabling writeback cache for SSHFS, appending to files overwrites
> data at a different position (cf. https://github.com/libfuse/sshfs/issues/72).
>
> When trying to track this issue down, I noticed that the libfuse
> passthrough_ll example also has problems with appending: calling
> fuse_reply_data gives a "Bad File Descriptior" error.
>
> This in turn I traced this down to the fact that when writeback caching
> is enabled, and userspace calls open(name, O_WRONLY|O_APPEND) the kernel
> passes the O_WRONLY flag on to libfuse. But when userspace then writes
> data, the kernel issues a read() request to libfuse (presumably to fill
> the write cache) - for a file that has been opened write-only.
>
> In the passthrough_ll example, this then fails because the underlying
> file has also been opened O_WRONLY and the strace read then fails.
>
> I am not sure what to make of this. Is this behavior of the kernel
> correct? Should libfuse be prepared to accept READ requests for files
> that have been opened write-only? Or should the kernel never open files
> write-only when writeback caching is enabled?
>
> (I am not sure if something like this is also the cause of the
> dataloss problem in SSHFS, but it seems worth addressing in any case)
>
> Thanks,
> -Nikolaus
>
> --
> GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
> »Time flies like an arrow, fruit flies like a Banana.«
--
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
»Time flies like an arrow, fruit flies like a Banana.«
next prev parent reply other threads:[~2017-08-04 19:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 18:47 [fuse] writeback cache triggers read() for O_WRONLY files - bug? Nikolaus Rath
2017-08-04 19:00 ` Nikolaus Rath [this message]
2017-08-04 19:04 ` Maxim Patlasov
2017-08-04 19:13 ` Nikolaus Rath
2017-08-05 0:11 ` Maxim Patlasov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pocbupi1.fsf@vostro.rath.org \
--to=nikolaus@rath.org \
--cc=fuse-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mpatlasov@virtuozzo.com \
--cc=mszeredi@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox