From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J. Bruce Fields" Subject: Re: [PATCH v7 05/17] locks: eliminate BUG() call when there's an unexpected lock on file close Date: Sun, 23 Mar 2014 16:01:08 -0400 Message-ID: <20140323200108.GD6103@fieldses.org> References: <1395261961-10855-1-git-send-email-jlayton@redhat.com> <1395261961-10855-6-git-send-email-jlayton@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: viro@ZenIV.linux.org.uk, linux-fsdevel@vger.kernel.org To: Jeff Layton Return-path: Received: from fieldses.org ([174.143.236.118]:52140 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbaCWUBN (ORCPT ); Sun, 23 Mar 2014 16:01:13 -0400 Content-Disposition: inline In-Reply-To: <1395261961-10855-6-git-send-email-jlayton@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Mar 19, 2014 at 04:45:49PM -0400, Jeff Layton wrote: > A leftover lock on the list is surely a sign of a problem of some sort, > but it's not necessarily a reason to panic the box. Instead, just log a > warning with some info about the lock, and then delete it like we would > any other lock. > > In the event that the filesystem declares a ->lock f_op, we may end up > leaking something, but that's generally preferable to an immediate > panic. Acked-by: J. Bruce Fields > > Signed-off-by: Jeff Layton > --- > fs/locks.c | 24 ++++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-) > > diff --git a/fs/locks.c b/fs/locks.c > index 6084f5a32e9c..dd309333afc9 100644 > --- a/fs/locks.c > +++ b/fs/locks.c > @@ -2281,16 +2281,28 @@ void locks_remove_flock(struct file *filp) > > while ((fl = *before) != NULL) { > if (fl->fl_file == filp) { > - if (IS_FLOCK(fl)) { > - locks_delete_lock(before); > - continue; > - } > if (IS_LEASE(fl)) { > lease_modify(before, F_UNLCK); > continue; > } > - /* What? */ > - BUG(); > + > + /* > + * There's a leftover lock on the list of a type that > + * we didn't expect to see. Most likely a classic > + * POSIX lock that ended up not getting released > + * properly, or that raced onto the list somehow. Log > + * some info about it and then just remove it from > + * the list. > + */ > + WARN(!IS_FLOCK(fl), > + "leftover lock: dev=%u:%u ino=%lu type=%hhd flags=0x%x start=%lld end=%lld\n", > + MAJOR(inode->i_sb->s_dev), > + MINOR(inode->i_sb->s_dev), inode->i_ino, > + fl->fl_type, fl->fl_flags, > + fl->fl_start, fl->fl_end); > + > + locks_delete_lock(before); > + continue; > } > before = &fl->fl_next; > } > -- > 1.8.5.3 >