From patchwork Thu Jun 25 14:25:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6675541 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3329C9F380 for ; Thu, 25 Jun 2015 14:25:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3AB66206C7 for ; Thu, 25 Jun 2015 14:25:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 445D3206C0 for ; Thu, 25 Jun 2015 14:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751395AbbFYOZf (ORCPT ); Thu, 25 Jun 2015 10:25:35 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:33709 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750786AbbFYOZf (ORCPT ); Thu, 25 Jun 2015 10:25:35 -0400 Received: by padev16 with SMTP id ev16so50865711pad.0; Thu, 25 Jun 2015 07:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=CBHjprxqq21hi66repGJ/ut9A/2NzWKgZSlV8C5Puik=; b=O1LqCev92TRmtUTpekoEsG5mC1kCn7ZvVU4C6NGAdy/TTireJ8242D03oItO9ps+RV uZfr0T99VwzuTcnQif3o+MZj4wEn6+/UWvyaLQBEAybpUp+fJ1p7yaW3QF/v4eMaAG33 WUXY/c+JDcEa9r20ie9w5s7obYy7OVzuC6HFSDQQZQXh+/yCLQsHN3AsCnInohnAKN1u t6bmrpdM+u5papQpdyNrjUeJDMyVbJau5F/rnpmZCfNBmn3+6hSwMvM00ApS5Es6AOgg c7u/5lWW9vDyA7VGWdSN6gYCDpAygvyMdFEUINxCq8OPowXXJSyJYcfYDr7GPi2Yo9ko I+ew== X-Received: by 10.70.47.138 with SMTP id d10mr90244990pdn.137.1435242334544; Thu, 25 Jun 2015 07:25:34 -0700 (PDT) Received: from [192.168.99.10] ([104.143.41.79]) by mx.google.com with ESMTPSA id o7sm30332631pdi.16.2015.06.25.07.25.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2015 07:25:33 -0700 (PDT) Message-ID: <558C0F52.4070307@gmail.com> Date: Thu, 25 Jun 2015 22:25:22 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Al Viro , "J. Bruce Fields" , "linux-nfs@vger.kernel.org" , linux-fsdevel@vger.kernel.org CC: NeilBrown , Trond Myklebust , kinglongmee@gmail.com Subject: [PATCH 05/10 v6] sunrpc: Store cache_detail in seq_file's private directly References: <558C0D6A.9050104@gmail.com> In-Reply-To: <558C0D6A.9050104@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Cleanup. Just store cache_detail in seq_file's private, an allocated handle is redundant. Signed-off-by: Kinglong Mee --- net/sunrpc/cache.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 2928aff..edec603 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1270,18 +1270,13 @@ EXPORT_SYMBOL_GPL(qword_get); * get a header, then pass each real item in the cache */ -struct handle { - struct cache_detail *cd; -}; - static void *c_start(struct seq_file *m, loff_t *pos) __acquires(cd->hash_lock) { loff_t n = *pos; unsigned int hash, entry; struct cache_head *ch; - struct cache_detail *cd = ((struct handle*)m->private)->cd; - + struct cache_detail *cd = m->private; read_lock(&cd->hash_lock); if (!n--) @@ -1308,7 +1303,7 @@ static void *c_next(struct seq_file *m, void *p, loff_t *pos) { struct cache_head *ch = p; int hash = (*pos >> 32); - struct cache_detail *cd = ((struct handle*)m->private)->cd; + struct cache_detail *cd = m->private; if (p == SEQ_START_TOKEN) hash = 0; @@ -1334,14 +1329,14 @@ static void *c_next(struct seq_file *m, void *p, loff_t *pos) static void c_stop(struct seq_file *m, void *p) __releases(cd->hash_lock) { - struct cache_detail *cd = ((struct handle*)m->private)->cd; + struct cache_detail *cd = m->private; read_unlock(&cd->hash_lock); } static int c_show(struct seq_file *m, void *p) { struct cache_head *cp = p; - struct cache_detail *cd = ((struct handle*)m->private)->cd; + struct cache_detail *cd = m->private; if (p == SEQ_START_TOKEN) return cd->cache_show(m, cd, NULL); @@ -1373,24 +1368,27 @@ static const struct seq_operations cache_content_op = { static int content_open(struct inode *inode, struct file *file, struct cache_detail *cd) { - struct handle *han; + struct seq_file *seq; + int err; if (!cd || !try_module_get(cd->owner)) return -EACCES; - han = __seq_open_private(file, &cache_content_op, sizeof(*han)); - if (han == NULL) { + + err = seq_open(file, &cache_content_op); + if (err) { module_put(cd->owner); - return -ENOMEM; + return err; } - han->cd = cd; + seq = file->private_data; + seq->private = cd; return 0; } static int content_release(struct inode *inode, struct file *file, struct cache_detail *cd) { - int ret = seq_release_private(inode, file); + int ret = seq_release(inode, file); module_put(cd->owner); return ret; }