All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Teigland <teigland@redhat.com>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: linux-fsdevel@vger.kernel.org, swhiteho@redhat.com, bfields@redhat.com
Subject: Re: [PATCH v2] locks: skip posix unlock when there are no posix locks
Date: Fri, 19 Aug 2011 13:46:44 -0400	[thread overview]
Message-ID: <20110819174644.GC14345@redhat.com> (raw)
In-Reply-To: <1313773776.12907.4.camel@lade.trondhjem.org>

On Fri, Aug 19, 2011 at 01:09:36PM -0400, Trond Myklebust wrote:
> >  void locks_remove_posix(struct file *filp, fl_owner_t owner)
> >  {
> >  	struct file_lock lock;
> > +	struct file_lock **before;
> > +	struct inode *inode;
> >  
> >  	/*
> >  	 * If there are no locks held on this file, we don't need to call
> >  	 * posix_lock_file().  Another process could be setting a lock on this
> >  	 * file at the same time, but we wouldn't remove that lock anyway.
> >  	 */
> > -	if (!filp->f_path.dentry->d_inode->i_flock)
> > +	inode = filp->f_path.dentry->d_inode;
> > +
> > +	if (!inode->i_flock)
> >  		return;
> >  
> > +	lock_flocks();
> > +	for_each_lock(inode, before) {
> > +		struct file_lock *fl = *before;
> > +		if (IS_POSIX(fl))
> > +			goto do_unlock;
> > +	}
> > +	unlock_flocks();
> > +	return;
> > +
> > +do_unlock:
> > +	unlock_flocks();
> >  	lock.fl_type = F_UNLCK;
> >  	lock.fl_flags = FL_POSIX | FL_CLOSE;
> >  	lock.fl_start = 0;
> 
> This assumes that all locks are mirrored in inode->i_flock, which may
> not be the case if the filesystem implements its own f_op->lock(). The
> right place for this optimisation would be in your filesystem callback.

I suppose if i_flock is being faked at the same time to avoid the null
check.  I once looked at not doing lock mirroring in vfs and couldn't for
reasons I don't remember... may the null i_flock check was the only
reason, not sure.

Dave

      reply	other threads:[~2011-08-19 17:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19 16:56 [PATCH v2] locks: skip posix unlock when there are no posix locks David Teigland
2011-08-19 17:09 ` Trond Myklebust
2011-08-19 17:46   ` David Teigland [this message]

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=20110819174644.GC14345@redhat.com \
    --to=teigland@redhat.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=bfields@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=swhiteho@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 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.