From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Teigland Subject: Re: [PATCH v2] locks: skip posix unlock when there are no posix locks Date: Fri, 19 Aug 2011 13:46:44 -0400 Message-ID: <20110819174644.GC14345@redhat.com> References: <20110819165613.GB14345@redhat.com> <1313773776.12907.4.camel@lade.trondhjem.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, swhiteho@redhat.com, bfields@redhat.com To: Trond Myklebust Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50890 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751685Ab1HSRr1 (ORCPT ); Fri, 19 Aug 2011 13:47:27 -0400 Content-Disposition: inline In-Reply-To: <1313773776.12907.4.camel@lade.trondhjem.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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