All of lore.kernel.org
 help / color / mirror / Atom feed
* fuse does not show lock info in /proc/.../fdinfo/...
@ 2016-06-03 18:49 Maxim Patlasov
  2016-06-16 11:49 ` Miklos Szeredi
  0 siblings, 1 reply; 4+ messages in thread
From: Maxim Patlasov @ 2016-06-03 18:49 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: fuse-devel, linux-fsdevel, Kinsbursky Stanislav

Hi Miklos,

fuse_file_lock() since its inception in 2006 implements F_SETLK command 
like this:

>         if (fc->no_lock)
>             err = posix_lock_file(file, fl, NULL);
>         else
>             err = fuse_setlk(file, fl, 0);

where fc->no_lock is a per-mount-point tunable. It would be more natural 
to posix-lock in both cases, like this:

>         err = posix_lock_file(file, fl, NULL);
>         if (!err && !fc->no_lock)
>             err = fuse_setlk(file, fl, 0);

Otherwise, by default, when fc->no_lock=0, posix_lock_file() is never 
called, and from end-user perspective it is weird that the file was 
locked successfully, but "fdinfo" does not show the lock.

Do you think there were some reasons to implement it that way -- not 
calling posix_lock_file unconditionally?

Thanks,
Maxim

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: fuse does not show lock info in /proc/.../fdinfo/...
  2016-06-03 18:49 fuse does not show lock info in /proc/.../fdinfo/ Maxim Patlasov
@ 2016-06-16 11:49 ` Miklos Szeredi
  2016-06-16 13:22   ` Stanislav Kinsburskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2016-06-16 11:49 UTC (permalink / raw)
  To: Maxim Patlasov; +Cc: fuse-devel, linux-fsdevel, Kinsbursky Stanislav

On Fri, Jun 3, 2016 at 8:49 PM, Maxim Patlasov <mpatlasov@virtuozzo.com> wrote:
> Hi Miklos,
>
> fuse_file_lock() since its inception in 2006 implements F_SETLK command like
> this:
>
>>         if (fc->no_lock)
>>             err = posix_lock_file(file, fl, NULL);
>>         else
>>             err = fuse_setlk(file, fl, 0);
>
>
> where fc->no_lock is a per-mount-point tunable. It would be more natural to
> posix-lock in both cases, like this:
>
>>         err = posix_lock_file(file, fl, NULL);
>>         if (!err && !fc->no_lock)
>>             err = fuse_setlk(file, fl, 0);
>
>
> Otherwise, by default, when fc->no_lock=0, posix_lock_file() is never
> called, and from end-user perspective it is weird that the file was locked
> successfully, but "fdinfo" does not show the lock.
>
> Do you think there were some reasons to implement it that way -- not calling
> posix_lock_file unconditionally?

Calling posix_lock_file() *before* we know the file can actually be
locked may be setting us up for weird bugs.  It could be called
afterwards, when we already know the real locking operation succeeded.
  But we need to think very carefully about races between two locking
operations, because locking state update is non-atomic after that
change.

So I think this possibly can be done, but needs some thought.

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: fuse does not show lock info in /proc/.../fdinfo/...
  2016-06-16 11:49 ` Miklos Szeredi
@ 2016-06-16 13:22   ` Stanislav Kinsburskiy
  2016-06-16 16:07     ` Miklos Szeredi
  0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Kinsburskiy @ 2016-06-16 13:22 UTC (permalink / raw)
  To: Miklos Szeredi, Maxim Patlasov; +Cc: fuse-devel, linux-fsdevel

Hello Miklos,

16.06.2016 13:49, Miklos Szeredi пишет:
> On Fri, Jun 3, 2016 at 8:49 PM, Maxim Patlasov <mpatlasov@virtuozzo.com> wrote:
>> Hi Miklos,
>>
>> fuse_file_lock() since its inception in 2006 implements F_SETLK command like
>> this:
>>
>>>          if (fc->no_lock)
>>>              err = posix_lock_file(file, fl, NULL);
>>>          else
>>>              err = fuse_setlk(file, fl, 0);
>>
>> where fc->no_lock is a per-mount-point tunable. It would be more natural to
>> posix-lock in both cases, like this:
>>
>>>          err = posix_lock_file(file, fl, NULL);
>>>          if (!err && !fc->no_lock)
>>>              err = fuse_setlk(file, fl, 0);
>>
>> Otherwise, by default, when fc->no_lock=0, posix_lock_file() is never
>> called, and from end-user perspective it is weird that the file was locked
>> successfully, but "fdinfo" does not show the lock.
>>
>> Do you think there were some reasons to implement it that way -- not calling
>> posix_lock_file unconditionally?
> Calling posix_lock_file() *before* we know the file can actually be
> locked may be setting us up for weird bugs.

Could you elaborate a bit on these bugs?
(BTW, it's done like this in NFS)

> It could be called
> afterwards, when we already know the real locking operation succeeded.
>    But we need to think very carefully about races between two locking
> operations, because locking state update is non-atomic after that
> change.
>
> So I think this possibly can be done, but needs some thought.
>
> Thanks,
> Miklos


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: fuse does not show lock info in /proc/.../fdinfo/...
  2016-06-16 13:22   ` Stanislav Kinsburskiy
@ 2016-06-16 16:07     ` Miklos Szeredi
  0 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2016-06-16 16:07 UTC (permalink / raw)
  To: Kinsbursky Stanislav; +Cc: Maxim Patlasov, fuse-devel, linux-fsdevel

On Thu, Jun 16, 2016 at 3:22 PM, Stanislav Kinsburskiy
<skinsbursky@virtuozzo.com> wrote:
> Hello Miklos,
>
> 16.06.2016 13:49, Miklos Szeredi пишет:
>>
>> On Fri, Jun 3, 2016 at 8:49 PM, Maxim Patlasov <mpatlasov@virtuozzo.com>
>> wrote:
>>>
>>> Hi Miklos,
>>>
>>> fuse_file_lock() since its inception in 2006 implements F_SETLK command
>>> like
>>> this:
>>>
>>>>          if (fc->no_lock)
>>>>              err = posix_lock_file(file, fl, NULL);
>>>>          else
>>>>              err = fuse_setlk(file, fl, 0);
>>>
>>>
>>> where fc->no_lock is a per-mount-point tunable. It would be more natural
>>> to
>>> posix-lock in both cases, like this:
>>>
>>>>          err = posix_lock_file(file, fl, NULL);
>>>>          if (!err && !fc->no_lock)
>>>>              err = fuse_setlk(file, fl, 0);
>>>
>>>
>>> Otherwise, by default, when fc->no_lock=0, posix_lock_file() is never
>>> called, and from end-user perspective it is weird that the file was
>>> locked
>>> successfully, but "fdinfo" does not show the lock.
>>>
>>> Do you think there were some reasons to implement it that way -- not
>>> calling.
>>> posix_lock_file unconditionally?
>>
>> Calling posix_lock_file() *before* we know the file can actually be
>> locked may be setting us up for weird bugs.
>
>
> Could you elaborate a bit on these bugs?
> (BTW, it's done like this in NFS)

Suppose range 0-9 is locked remotely two processes are concurrently
trying to lock the following ranges (nonblocking):

A: 5-15
B: 10-19

The situation is clear enough: "A" should fail, "B" should succeed.

However, with the above logic "B" might fail as well if it's done
after "A" acquired the lock locally, but before failure from the
remote lock operation was received

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-16 16:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-03 18:49 fuse does not show lock info in /proc/.../fdinfo/ Maxim Patlasov
2016-06-16 11:49 ` Miklos Szeredi
2016-06-16 13:22   ` Stanislav Kinsburskiy
2016-06-16 16:07     ` Miklos Szeredi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.