From patchwork Wed Aug 20 11:16:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4749041 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 316379F50F for ; Wed, 20 Aug 2014 11:17:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 523F120176 for ; Wed, 20 Aug 2014 11:17:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BD2020172 for ; Wed, 20 Aug 2014 11:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751653AbaHTLQv (ORCPT ); Wed, 20 Aug 2014 07:16:51 -0400 Received: from mail-qc0-f171.google.com ([209.85.216.171]:58646 "EHLO mail-qc0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751534AbaHTLQu (ORCPT ); Wed, 20 Aug 2014 07:16:50 -0400 Received: by mail-qc0-f171.google.com with SMTP id r5so7491239qcx.16 for ; Wed, 20 Aug 2014 04:16:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=NKX+aIi40gisC2iG82wZhPiMXBS7fIL+kftjzExvBew=; b=HTuMvKDt8+Wlf9T3gbH5cJJ1uZzACpQPeMNe1yhlXQlS+tNtOWRtTjzJyp+jAeR5+K HWfoH3L5xdIvpQhPs2ALj9T4MlCAgrThGGabF/iV2ng1JvOis3rJFJAc6i+xkKbsll5y n5+ZQBTzbNOg+x1padnRx9OQQn4CLvbjNbQU08ZR5Bdr1Xxn3P+soR0Bhe1FGx1cNgcb i+z46jK913leDiv8oxYihsiM1dG4/GTHmmPuXTpSCjPrT5kFu8DAKphvlfKFWmZ+dYWz H7s//9Kq7tKogy2MSyl9M+n8lVdnXepcwdHiP5XC0eNauLqIMn5NK72MsYXz0/v8IZJy IXmQ== X-Gm-Message-State: ALoCoQk9OLn3Ip3LttgwZevR/jGLeYTPdFfQHRqc3zUgeOcoNYGFD6d3m3x3Qzb1aSi1venbmvvF X-Received: by 10.140.18.211 with SMTP id 77mr71650757qgf.57.1408533409547; Wed, 20 Aug 2014 04:16:49 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id n74sm25197152qga.34.2014.08.20.04.16.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Aug 2014 04:16:49 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton Date: Wed, 20 Aug 2014 07:16:47 -0400 To: Kinglong Mee Cc: Jeff Layton , "J. Bruce Fields" , Linux NFS Mailing List , Joe Perches Subject: Re: [PATCH] lockd: Remove unused b_fl member from struct nlm_block Message-ID: <20140820071647.2b607e3f@tlielax.poochiereds.net> In-Reply-To: <53F47357.7050608@gmail.com> References: <53F47357.7050608@gmail.com> X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.22; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 20 Aug 2014 18:07:19 +0800 Kinglong Mee wrote: > Fix left code by Joe Perches's patch, > "locks: Remove unused conf argument from lm_grant" > > Signed-off-by: Kinglong Mee > --- > fs/lockd/svclock.c | 26 +++++--------------------- > include/linux/lockd/lockd.h | 1 - > 2 files changed, 5 insertions(+), 22 deletions(-) > > diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c > index 2a61701..796e63b 100644 > --- a/fs/lockd/svclock.c > +++ b/fs/lockd/svclock.c > @@ -245,7 +245,6 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host, > block->b_daemon = rqstp->rq_server; > block->b_host = host; > block->b_file = file; > - block->b_fl = NULL; > file->f_count++; > > /* Add to file's list of blocks */ > @@ -295,7 +294,6 @@ static void nlmsvc_free_block(struct kref *kref) > nlmsvc_freegrantargs(block->b_call); > nlmsvc_release_call(block->b_call); > nlm_release_file(block->b_file); > - kfree(block->b_fl); > kfree(block); > } > > @@ -523,20 +521,13 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, > block = nlmsvc_lookup_block(file, lock); > > if (block == NULL) { > - struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL); > - I think the problem here is that we're allocating a file_lock with kzalloc instead of using locks_alloc_lock. I think we should change this code to use that, and the kfree in nlmsvc_free_block to use locks_free_lock. Maybe something like this? (untested, but it compiles). I'll plan to resend the patch below for 3.18 once I've tested it out and Trond, Bruce and I can work out who should merge it. -------------------------[snip]------------------------- [PATCH] lockd: switch allocation of conflock to standard lock allocation routines lockd currently allocates a struct file_lock with kzalloc to use as a conflock. Change it to use locks_alloc_lock and locks_free_lock instead. In the event that someone were to add lm_get_owner/lm_put_owner ops for lockd, then this would help ensure that things get cleaned up properly. It's also less wasteful with memory since locks_alloc_lock allocates from a dedicated slabcache. Cc: Kinglong Mee Signed-off-by: Jeff Layton --- fs/lockd/svclock.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 2a6170133c1d..1eb2ae47e6b1 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -295,7 +295,8 @@ static void nlmsvc_free_block(struct kref *kref) nlmsvc_freegrantargs(block->b_call); nlmsvc_release_call(block->b_call); nlm_release_file(block->b_file); - kfree(block->b_fl); + if (block->b_fl) + locks_free_lock(block->b_fl); kfree(block); } @@ -523,13 +524,13 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, block = nlmsvc_lookup_block(file, lock); if (block == NULL) { - struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL); + struct file_lock *conf = locks_alloc_lock(); if (conf == NULL) return nlm_granted; block = nlmsvc_create_block(rqstp, host, file, lock, cookie); if (block == NULL) { - kfree(conf); + locks_free_lock(conf); return nlm_granted; } block->b_fl = conf;