Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1670805 > unrolled thread
| Started by | "Benjamin Coddington" <bcodding@redhat.com> |
|---|---|
| First post | 2017-06-20 16:10 +0200 |
| Last post | 2017-06-20 22:20 +0200 |
| Articles | 7 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks "Benjamin Coddington" <bcodding@redhat.com> - 2017-06-20 16:10 +0200
Re: [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks "Benjamin Coddington" <bcodding@redhat.com> - 2017-06-20 18:20 +0200
Re: [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks Jeff Layton <jlayton@poochiereds.net> - 2017-06-20 19:10 +0200
Re: [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks "Benjamin Coddington" <bcodding@redhat.com> - 2017-06-20 21:20 +0200
Re: [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks Jeff Layton <jlayton@poochiereds.net> - 2017-06-20 21:40 +0200
Re: [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks "Benjamin Coddington" <bcodding@redhat.com> - 2017-06-20 21:50 +0200
Re: [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks Jeff Layton <jlayton@poochiereds.net> - 2017-06-20 22:20 +0200
| From | "Benjamin Coddington" <bcodding@redhat.com> |
|---|---|
| Date | 2017-06-20 16:10 +0200 |
| Subject | Re: [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks |
| Message-ID | <tUs0X-1bG-33@gated-at.bofh.it> |
On 19 Jun 2017, at 13:32, Jeff Layton wrote:
> On Mon, 2017-06-19 at 09:24 -0400, Benjamin Coddington wrote:
>> @@ -2041,16 +2034,46 @@ SYSCALL_DEFINE2(flock, unsigned int, fd,
>> unsigned int, cmd)
>> */
>> int vfs_test_lock(struct file *filp, struct file_lock *fl)
>> {
>> - if (filp->f_op->lock && is_remote_lock(filp))
>> + if (filp->f_op->lock && is_remote_lock(filp)) {
>> + fl->fl_flags |= FL_PID_PRIV;
>> return filp->f_op->lock(filp, F_GETLK, fl);
>> + }
>> posix_test_lock(filp, fl);
>> return 0;
>> }
>> EXPORT_SYMBOL_GPL(vfs_test_lock);
>>
>
> I think this looks wrong for NFS.
Oh yes, this is completely wrong.. It should be looking for fl_ops,
which
would set the flag for lock managers.
> There are really two cases we're concerned with here:
>
> 1) the lock is held by a task on the client itself, in which case we
> probably want to report the pid as we would on a local fs.
>
> ...or...
>
> 2) the lock is held by another host entirely in which case the pid
> doesn't have any meaning. We probably ought to return something like
> '-
> 1' as the pid (like we would for OFD locks).
I don't think we have f_op->lock() users that only set remote locks.
For
NFS, the remote lock is always matched by a local lock.
> The problem for NFS is that you're setting the flag unconditionally
> there. It may very well be the case that we _want_ to translate the
> fl_pid according to the local namespace (i.e. if the lock is held by a
> task on the same host).
>
> I think what you want to do here is have the fs ->lock operation set
> that flag if the fl_pid should be used "as-is" instead of being
> translated.
>
> Most of the current lock operations can just set it early (to preserve
> the existing behavior), but NFS could be set up to set that flag if
> the
> lock request goes to the server.
I think this is just a mistake.. I think we want to always translate all
local locks, unless the lock is placed by a lock manager.
I'll send a corrected version.
Ben
[toc] | [next] | [standalone]
| From | "Benjamin Coddington" <bcodding@redhat.com> |
|---|---|
| Date | 2017-06-20 18:20 +0200 |
| Message-ID | <tUu2J-2t3-9@gated-at.bofh.it> |
| In reply to | #1670805 |
On 20 Jun 2017, at 10:03, Benjamin Coddington wrote:
> On 19 Jun 2017, at 13:32, Jeff Layton wrote:
>
>> On Mon, 2017-06-19 at 09:24 -0400, Benjamin Coddington wrote:
>>> @@ -2041,16 +2034,46 @@ SYSCALL_DEFINE2(flock, unsigned int, fd,
>>> unsigned int, cmd)
>>> */
>>> int vfs_test_lock(struct file *filp, struct file_lock *fl)
>>> {
>>> - if (filp->f_op->lock && is_remote_lock(filp))
>>> + if (filp->f_op->lock && is_remote_lock(filp)) {
>>> + fl->fl_flags |= FL_PID_PRIV;
>>> return filp->f_op->lock(filp, F_GETLK, fl);
>>> + }
>>> posix_test_lock(filp, fl);
>>> return 0;
>>> }
>>> EXPORT_SYMBOL_GPL(vfs_test_lock);
>>>
>>
>> I think this looks wrong for NFS.
>
> Oh yes, this is completely wrong.. It should be looking for fl_ops,
> which
> would set the flag for lock managers.
OK, please disregard this response completely. You're absolutely
correct.
I spent too much time away from this problem and was confused.
>> There are really two cases we're concerned with here:
>>
>> 1) the lock is held by a task on the client itself, in which case we
>> probably want to report the pid as we would on a local fs.
>>
>> ...or...
>>
>> 2) the lock is held by another host entirely in which case the pid
>> doesn't have any meaning. We probably ought to return something like
>> '-
>> 1' as the pid (like we would for OFD locks).
Right, exactly.
> I don't think we have f_op->lock() users that only set remote locks.
> For
> NFS, the remote lock is always matched by a local lock.
But we can do F_GETLK for a remote file with a remote lock.
>> The problem for NFS is that you're setting the flag unconditionally
>> there. It may very well be the case that we _want_ to translate the
>> fl_pid according to the local namespace (i.e. if the lock is held by
>> a
>> task on the same host).
>>
>> I think what you want to do here is have the fs ->lock operation set
>> that flag if the fl_pid should be used "as-is" instead of being
>> translated.
>>
>> Most of the current lock operations can just set it early (to
>> preserve
>> the existing behavior), but NFS could be set up to set that flag if
>> the
>> lock request goes to the server.
Yes, I think we ought to add the flag in this patch, but as you suggest
push
the responsibility for setting it out to the filesystems. I'll send one
more version that adds the flag, but doesn't set it in vfs_test_lock(),
and
follow that with a patch for where the flag ought to be set.
Ben
[toc] | [prev] | [next] | [standalone]
| From | Jeff Layton <jlayton@poochiereds.net> |
|---|---|
| Date | 2017-06-20 19:10 +0200 |
| Message-ID | <tUuP7-2YK-3@gated-at.bofh.it> |
| In reply to | #1670917 |
On Tue, 2017-06-20 at 12:09 -0400, Benjamin Coddington wrote:
> On 20 Jun 2017, at 10:03, Benjamin Coddington wrote:
>
> > On 19 Jun 2017, at 13:32, Jeff Layton wrote:
> >
> > > On Mon, 2017-06-19 at 09:24 -0400, Benjamin Coddington wrote:
> > > > @@ -2041,16 +2034,46 @@ SYSCALL_DEFINE2(flock, unsigned int, fd,
> > > > unsigned int, cmd)
> > > > */
> > > > int vfs_test_lock(struct file *filp, struct file_lock *fl)
> > > > {
> > > > - if (filp->f_op->lock && is_remote_lock(filp))
> > > > + if (filp->f_op->lock && is_remote_lock(filp)) {
> > > > + fl->fl_flags |= FL_PID_PRIV;
> > > > return filp->f_op->lock(filp, F_GETLK, fl);
> > > > + }
> > > > posix_test_lock(filp, fl);
> > > > return 0;
> > > > }
> > > > EXPORT_SYMBOL_GPL(vfs_test_lock);
> > > >
> > >
> > > I think this looks wrong for NFS.
> >
> > Oh yes, this is completely wrong.. It should be looking for fl_ops,
> > which
> > would set the flag for lock managers.
>
> OK, please disregard this response completely. You're absolutely
> correct.
> I spent too much time away from this problem and was confused.
>
> > > There are really two cases we're concerned with here:
> > >
> > > 1) the lock is held by a task on the client itself, in which case we
> > > probably want to report the pid as we would on a local fs.
> > >
> > > ...or...
> > >
> > > 2) the lock is held by another host entirely in which case the pid
> > > doesn't have any meaning. We probably ought to return something like
> > > '-
> > > 1' as the pid (like we would for OFD locks).
>
> Right, exactly.
>
> > I don't think we have f_op->lock() users that only set remote locks.
> > For
> > NFS, the remote lock is always matched by a local lock.
>
> But we can do F_GETLK for a remote file with a remote lock.
>
> > > The problem for NFS is that you're setting the flag unconditionally
> > > there. It may very well be the case that we _want_ to translate the
> > > fl_pid according to the local namespace (i.e. if the lock is held by
> > > a
> > > task on the same host).
> > >
> > > I think what you want to do here is have the fs ->lock operation set
> > > that flag if the fl_pid should be used "as-is" instead of being
> > > translated.
> > >
> > > Most of the current lock operations can just set it early (to
> > > preserve
> > > the existing behavior), but NFS could be set up to set that flag if
> > > the
> > > lock request goes to the server.
>
> Yes, I think we ought to add the flag in this patch, but as you suggest
> push
> the responsibility for setting it out to the filesystems. I'll send one
> more version that adds the flag, but doesn't set it in vfs_test_lock(),
> and
> follow that with a patch for where the flag ought to be set.
>
> Ben
Now that I think about it a bit more, I don't think we really need a
flag here.
Just have the ->lock operation set the fl_pid to a negative value. That
will never be a valid pid anyway. Then flock_translate_pid could just
return any negative value directly instead of trying to translate it.
In practice we would always just set it to -1. Maybe even add something
like this that the lock-> operation could set it to?
#define FILE_LOCK_OWNER_UNDEFINED -1
--
Jeff Layton <jlayton@poochiereds.net>
[toc] | [prev] | [next] | [standalone]
| From | "Benjamin Coddington" <bcodding@redhat.com> |
|---|---|
| Date | 2017-06-20 21:20 +0200 |
| Message-ID | <tUwQV-4dQ-3@gated-at.bofh.it> |
| In reply to | #1670962 |
On 20 Jun 2017, at 13:06, Jeff Layton wrote: > > Now that I think about it a bit more, I don't think we really need a > flag here. > > Just have the ->lock operation set the fl_pid to a negative value. That > will never be a valid pid anyway. Then flock_translate_pid could just > return any negative value directly instead of trying to translate it. > > In practice we would always just set it to -1. Maybe even add something > like this that the lock-> operation could set it to? > > #define FILE_LOCK_OWNER_UNDEFINED -1 So for filesystems that set a remote pid, they should negate the pid to mean that the pid should not be translated? Then when we return that pid, we flip it back again, or display a negative number, or turn it into -1? The flag, having a readable name, would make things a bit clearer as to what the filesystems expect to happen to that pid value. Ben
[toc] | [prev] | [next] | [standalone]
| From | Jeff Layton <jlayton@poochiereds.net> |
|---|---|
| Date | 2017-06-20 21:40 +0200 |
| Message-ID | <tUxah-4kt-11@gated-at.bofh.it> |
| In reply to | #1671028 |
On Tue, 2017-06-20 at 15:17 -0400, Benjamin Coddington wrote: > On 20 Jun 2017, at 13:06, Jeff Layton wrote: > > > > Now that I think about it a bit more, I don't think we really need a > > flag here. > > > > Just have the ->lock operation set the fl_pid to a negative value. That > > will never be a valid pid anyway. Then flock_translate_pid could just > > return any negative value directly instead of trying to translate it. > > > > In practice we would always just set it to -1. Maybe even add something > > like this that the lock-> operation could set it to? > > > > #define FILE_LOCK_OWNER_UNDEFINED -1 > > So for filesystems that set a remote pid, they should negate the pid to mean > that the pid should not be translated? Then when we return that pid, we > flip it back again, or display a negative number, or turn it into -1? > > The flag, having a readable name, would make things a bit clearer as to what > the filesystems expect to happen to that pid value. > I now think that we really only ought to be filling out the pid when it refers to a process on the local host. It seems sketchy to me to return a pid here that is really the pid on another host, but happens to have the same pid as something else on this host. It's misleading at best, and if anyone tries to act on that info it could be dangerous. So I'm thinking that we should just set it to -1 when the lock is held by another host entirely. But, since pid values must be positive, we can code the basic infrastructure to return any negative value as-is instead of trying to translate it. -- Jeff Layton <jlayton@poochiereds.net>
[toc] | [prev] | [next] | [standalone]
| From | "Benjamin Coddington" <bcodding@redhat.com> |
|---|---|
| Date | 2017-06-20 21:50 +0200 |
| Message-ID | <tUxjX-4nI-13@gated-at.bofh.it> |
| In reply to | #1671040 |
On 20 Jun 2017, at 15:32, Jeff Layton wrote: > On Tue, 2017-06-20 at 15:17 -0400, Benjamin Coddington wrote: >> On 20 Jun 2017, at 13:06, Jeff Layton wrote: >>> >>> Now that I think about it a bit more, I don't think we really need a >>> flag here. >>> >>> Just have the ->lock operation set the fl_pid to a negative value. >>> That >>> will never be a valid pid anyway. Then flock_translate_pid could >>> just >>> return any negative value directly instead of trying to translate >>> it. >>> >>> In practice we would always just set it to -1. Maybe even add >>> something >>> like this that the lock-> operation could set it to? >>> >>> #define FILE_LOCK_OWNER_UNDEFINED -1 >> >> So for filesystems that set a remote pid, they should negate the pid >> to mean >> that the pid should not be translated? Then when we return that pid, >> we >> flip it back again, or display a negative number, or turn it into -1? >> >> The flag, having a readable name, would make things a bit clearer as >> to what >> the filesystems expect to happen to that pid value. >> > > I now think that we really only ought to be filling out the pid when > it > refers to a process on the local host. It seems sketchy to me to > return > a pid here that is really the pid on another host, but happens to have > the same pid as something else on this host. It's misleading at best, > and if anyone tries to act on that info it could be dangerous. So I'm > thinking that we should just set it to -1 when the lock is held by > another host entirely. > > But, since pid values must be positive, we can code the basic > infrastructure to return any negative value as-is instead of trying to > translate it. Ok, so we have to patch several filesystems. The question is do we patch those filesystems that set remote pids to negate their pid values in the lock they return from F_GETLK, or do we ask them to set a flag? We'd be patching them to negate their pid just to then transform it to -1.. I'd prefer a flag rather than carrying meaning in a modified value since the flag has readable information. No one will come along later and wonder why some filesystems are negating their pid values. If we're going to touch filesystems that set have remote locks anyway, perhaps it makes sense to take a step toward l_sysid by adding another member to file_lock. Then a special value of fl_sysid would indicate the local system. Ben
[toc] | [prev] | [next] | [standalone]
| From | Jeff Layton <jlayton@poochiereds.net> |
|---|---|
| Date | 2017-06-20 22:20 +0200 |
| Message-ID | <tUxN1-4P5-41@gated-at.bofh.it> |
| In reply to | #1671046 |
On Tue, 2017-06-20 at 15:39 -0400, Benjamin Coddington wrote: > On 20 Jun 2017, at 15:32, Jeff Layton wrote: > > > On Tue, 2017-06-20 at 15:17 -0400, Benjamin Coddington wrote: > > > On 20 Jun 2017, at 13:06, Jeff Layton wrote: > > > > > > > > Now that I think about it a bit more, I don't think we really need a > > > > flag here. > > > > > > > > Just have the ->lock operation set the fl_pid to a negative value. > > > > That > > > > will never be a valid pid anyway. Then flock_translate_pid could > > > > just > > > > return any negative value directly instead of trying to translate > > > > it. > > > > > > > > In practice we would always just set it to -1. Maybe even add > > > > something > > > > like this that the lock-> operation could set it to? > > > > > > > > #define FILE_LOCK_OWNER_UNDEFINED -1 > > > > > > So for filesystems that set a remote pid, they should negate the pid > > > to mean > > > that the pid should not be translated? Then when we return that pid, > > > we > > > flip it back again, or display a negative number, or turn it into -1? > > > > > > The flag, having a readable name, would make things a bit clearer as > > > to what > > > the filesystems expect to happen to that pid value. > > > > > > > I now think that we really only ought to be filling out the pid when > > it > > refers to a process on the local host. It seems sketchy to me to > > return > > a pid here that is really the pid on another host, but happens to have > > the same pid as something else on this host. It's misleading at best, > > and if anyone tries to act on that info it could be dangerous. So I'm > > thinking that we should just set it to -1 when the lock is held by > > another host entirely. > > > > But, since pid values must be positive, we can code the basic > > infrastructure to return any negative value as-is instead of trying to > > translate it. > > Ok, so we have to patch several filesystems. The question is do we > patch > those filesystems that set remote pids to negate their pid values in the > lock > they return from F_GETLK, or do we ask them to set a flag? We'd be > patching > them to negate their pid just to then transform it to -1.. > > I'd prefer a flag rather than carrying meaning in a modified value since > the > flag has readable information. No one will come along later and wonder > why > some filesystems are negating their pid values. > > If we're going to touch filesystems that set have remote locks anyway, > perhaps it makes sense to take a step toward l_sysid by adding another > member to file_lock. Then a special value of fl_sysid would indicate > the > local system. > I think we need to fix up the current API first. My main interest is that we have the kernel report l_pid properly to the best of its ability, and when it can't that it report some clearly non- sensical value (e.g., -1) for the pid. I think that's the only sane thing we can do at this point. If we want to start discussing new locking APIs then I'm fine with that, but I'd still want to do something sane here before we start down that road anyway. -- Jeff Layton <jlayton@poochiereds.net>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web