linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@poochiereds.net>
To: Benjamin Coddington <bcodding@redhat.com>
Cc: bfields@fieldses.org, Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks
Date: Tue, 20 Jun 2017 13:06:55 -0400	[thread overview]
Message-ID: <1497978415.4555.14.camel@poochiereds.net> (raw)
In-Reply-To: <D1AFE5C7-427F-4B0B-8337-3D6A247156A3@redhat.com>

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>

  reply	other threads:[~2017-06-20 17:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19 13:24 [PATCH 0/2 v5] Fixups for l_pid Benjamin Coddington
2017-06-19 13:24 ` [PATCH 1/2] fs/locks: Use allocation rather than the stack in fcntl_getlk() Benjamin Coddington
2017-06-19 13:24 ` [PATCH 2/2] fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks Benjamin Coddington
2017-06-19 17:32   ` Jeff Layton
2017-06-20 14:03     ` Benjamin Coddington
2017-06-20 16:09       ` Benjamin Coddington
2017-06-20 17:06         ` Jeff Layton [this message]
2017-06-20 19:17           ` Benjamin Coddington
2017-06-20 19:32             ` Jeff Layton
2017-06-20 19:39               ` Benjamin Coddington
2017-06-20 20:13                 ` Jeff Layton

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=1497978415.4555.14.camel@poochiereds.net \
    --to=jlayton@poochiereds.net \
    --cc=bcodding@redhat.com \
    --cc=bfields@fieldses.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).