linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolaus Rath <Nikolaus@rath.org>
To: Maxim Patlasov <mpatlasov@virtuozzo.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	"fuse-devel\@lists.sourceforge.net"
	<fuse-devel@lists.sourceforge.net>
Subject: Re: [fuse-devel] fuse: when are release requests queued?
Date: Wed, 31 May 2017 12:41:15 -0700	[thread overview]
Message-ID: <87inkgvmp0.fsf@thinkpad.rath.org> (raw)
In-Reply-To: <e4e48026-a791-f867-a25f-cedf3b84907d@virtuozzo.com> (Maxim Patlasov's message of "Wed, 31 May 2017 12:32:09 -0700")

On May 31 2017, Maxim Patlasov <mpatlasov@virtuozzo.com> wrote:
> On 05/31/2017 12:19 PM, Nikolaus Rath wrote:
>
>> On May 31 2017, Maxim Patlasov <mpatlasov@virtuozzo.com> wrote:
>>>>>> Can someone tell me at which point the fuse kernel module will send a
>>>>>> RELEASE request to userspace?
>>>>> Anytime after fuse_release(). It only puts request to background
>>>>> queue. Later, the request will be transferred to pending queue. And
>>>>> later, the userspace will fetch it by fuse_dev_do_read().
>>>>>
>>>>>> Is it possible that this is delayed until
>>>>>> after the close() syscall for the last fd has returned and userspace has
>>>>>> submitted a different fuse request for the same fs?
>>>>> I think it's possible. See how flush_bg_queue() do nothing if
>>>>> fc->active_background > fc->max_background.
>>>> Thanks Maxim! Not sure what I'd do with these issues without you :-).
>>>>
>>>>
>>>> Is there a way to deliberate trigger this behavior for debugging? For
>>>> example, is there a kernel equivalent of sleep(1) that I could put into
>>>> fuse_release()?
>>> schedule_timeout_interruptible(HZ).
>> Hmm. I made the following change in linux 4.10:
>>
>> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
>> index 2401c5..3568a8 100644
>> --- a/fs/fuse/file.c
>> +++ b/fs/fuse/file.c
>> @@ -252,6 +252,9 @@ void fuse_release_common(struct file *file, int opcode)
>>          if (unlikely(!ff))
>>                  return;
>>   +        // Wait a little to force race condition in userspace
>> +        schedule_timeout_interruptible(1);
>> +
>>          req = ff->reserved_req;
>>          fuse_prepare_release(ff, file->f_flags, opcode);
>>   
>>
>> But when doing e.g. "echo test > newfile", the RELEASE request still
>> comes right away (judging from the libfuse debugging output).
>>
>> Do I need to do something else?
>
> Try HZ*10 instead of 1 as an argument of
> schedule_timeout_interruptible.

Ok, now the RELEASE comes a lot later. But now userspace is also
blocking until RELEASE comes in.

>>> But it's better to instrument fuse
>>> userspace to postpone processing some i/o requests. Then you'll keep
>>> fc->active_background > fc->max_background for a while. During that
>>> period fuse_release may succeed with FUSE_RELEASE queued, but not
>>> passed to the userspace. Then you cat try to sneak another request --
>>> something not involving fuse background queue.
>>
>> I don't know.. why is this better? It seems a lot more complicated. I
>> need to generate the extra request, add some switch to tell libfuse when
>> to start processing again, synchronize this with sneaking in the other
>> request...
>
> I thought it's better because it would trigger delayed processing of
> FUSE_RELEASE: last __fput() succeeded, but fuse userspace will see
> FUSE_RELEASE only later. Adding sleep to fuse_release_common would
> only extend processing time of last __fput(), is that what you need?

I do not fully understand the difference you describe. What I would like
to construct is the following scenario:

1. Userspace calls close()
2. Userspace close() returns
3. Userspace calls unlink()
4. Userspace unlink() returns
5. libfuse reads UNLINK request from kernel pipe
6. libfuse reads RELEASE request from kernel pipe

What would be the simplest way to do that?

Thanks!
-Nikolaus

-- 
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«

  reply	other threads:[~2017-05-31 19:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-25 23:08 fuse: when are release requests queued? Nikolaus Rath
2017-05-26 15:17 ` [fuse-devel] " David Butterfield
2017-05-26 23:11   ` Nikolaus Rath
2017-05-27  1:49     ` [fuse-devel] " Maxim Patlasov
2017-05-27  1:39 ` Maxim Patlasov
2017-05-29 16:49   ` Nikolaus Rath
2017-05-31 17:50     ` Maxim Patlasov
2017-05-31 19:19       ` Nikolaus Rath
2017-05-31 19:32         ` Maxim Patlasov
2017-05-31 19:41           ` Nikolaus Rath [this message]
     [not found]             ` <87inkgvmp0.fsf-Zv899e0YUSYPWKMTL/zdXNi2O/JbrIOy@public.gmane.org>
2017-05-31 19:51               ` Michael Theall
2017-05-31 20:34                 ` Nikolaus Rath
2017-05-31 20:23             ` [fuse-devel] " Maxim Patlasov
2017-05-31 20:31               ` Nikolaus Rath
2017-05-31 20:47                 ` 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=87inkgvmp0.fsf@thinkpad.rath.org \
    --to=nikolaus@rath.org \
    --cc=fuse-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mpatlasov@virtuozzo.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;
as well as URLs for NNTP newsgroup(s).