From: Trond Myklebust Subject: Re: [PATCH, RFC] lockd: stop abusing file_lock_list Date: Thu, 16 Feb 2006 09:21:26 -0500 Message-ID: <1140099686.8891.18.camel@lade.trondhjem.org> References: <20060214192051.GA20751@lst.de> <1139956050.7867.64.camel@lade.trondhjem.org> <1140065071.8209.3.camel@lade.trondhjem.org> <20060216135734.GA3393@lst.de> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from pat.uio.no ([129.240.130.16]:40179 "EHLO pat.uio.no") by vger.kernel.org with ESMTP id S932468AbWBPOVn (ORCPT ); Thu, 16 Feb 2006 09:21:43 -0500 To: Christoph Hellwig In-Reply-To: <20060216135734.GA3393@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Thu, 2006-02-16 at 14:57 +0100, Christoph Hellwig wrote: > On Wed, Feb 15, 2006 at 11:44:31PM -0500, Trond Myklebust wrote: > > Author: Trond Myklebust > > lockd: Fix Oopses due to list manipulation errors. > > > > The patch "stop abusing file_lock_list introduces a couple of bugs since > > the locks may be copied and need to be removed from the lists when they are > > destroyed. > > > > Signed-off-by: Trond Myklebust > > --- > > > > fs/lockd/clntproc.c | 9 ++++++++- > > 1 files changed, 8 insertions(+), 1 deletions(-) > > > > diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c > > index 211113a..b1b924d 100644 > > --- a/fs/lockd/clntproc.c > > +++ b/fs/lockd/clntproc.c > > @@ -447,12 +447,17 @@ static void nlmclnt_locks_copy_lock(stru > > { > > memcpy(&new->fl_u.nfs_fl, &fl->fl_u.nfs_fl, sizeof(new->fl_u.nfs_fl)); > > nlm_get_lockowner(new->fl_u.nfs_fl.owner); > > + INIT_LIST_HEAD(&new->fl_u.nfs_fl.list); > > + if (!list_empty(&fl->fl_u.nfs_fl.list)) > > + list_add(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.list); > > list_add initializes nough so we don't need the INIT_LIST_HEAD in that > case, so this could become: > > if (list_empty(&fl->fl_u.nfs_fl.list)) > INIT_LIST_HEAD(&new->fl_u.nfs_fl.list); > else > list_add(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.list); Sure. > > * Remove from the granted list now so the lock doesn't get > > * reclaimed while we're stuck in the unlock call. > > */ > > - list_del(&fl->fl_u.nfs_fl.list); > > + if (!list_empty(&fl->fl_u.nfs_fl.list)) > > + list_del_init(&fl->fl_u.nfs_fl.list); > > Probably should be just unconditionaly. list_del_init isn't a whole lot > of instructions, but we save a branch and have more readable code. True. > While we're at it, don't we need a INIT_LIST_HEAD in > nlmclnt_locks_init_private aswell? Yes. The patch does include one, I believe. Cheers, Trond