From patchwork Mon Jul 27 03:09:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6868011 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6EA6FC05AC for ; Mon, 27 Jul 2015 03:09:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88D3420529 for ; Mon, 27 Jul 2015 03:09:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A14B1205FE for ; Mon, 27 Jul 2015 03:09:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755260AbbG0DJV (ORCPT ); Sun, 26 Jul 2015 23:09:21 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33929 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754071AbbG0DJU (ORCPT ); Sun, 26 Jul 2015 23:09:20 -0400 Received: by pacan13 with SMTP id an13so44428051pac.1; Sun, 26 Jul 2015 20:09:20 -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=1b8VPMNVjSjzbrefUEjiUYv/MwP8ts6EKxSnPdojN4c=; b=Uv0Ey3iksrpN5A/g47B+6nvBM/yQaDeHlSXh5quOfJC6XjT+RjrL+UcfRMsbZ0jhBI ykQStcxzB6bMJNK6Lqn2MSOJeptJCnEvdTmXKRmau0hO00mBtkxL1froXNwZss/YBFpd KMIKIuh96EL2oqbE/IFDvr4RiU9al2VBlk+KwjgiFmxrOZZ5mPPPfpgWowSr5Xy/i3Wx OvDy76kPECGITWJmgjZFrvyhl3HU5tEk4ELcbVNPtjb/WWo4jKWZh8JmOsp8nkgzd6YL RbfQoFjzNpJcOMDpNo2P6FSktoffwGdExIL6zF+NkPD3ZhxNqqbUmYVFx8iDvw5LxfwZ O9qw== X-Received: by 10.66.236.167 with SMTP id uv7mr61573137pac.134.1437966560106; Sun, 26 Jul 2015 20:09:20 -0700 (PDT) Received: from [192.168.99.25] ([104.143.41.79]) by smtp.googlemail.com with ESMTPSA id of5sm26341175pdb.52.2015.07.26.20.09.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jul 2015 20:09:19 -0700 (PDT) Message-ID: <55B5A0D6.8040908@gmail.com> Date: Mon, 27 Jul 2015 11:09:10 +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: "J. Bruce Fields" , Al Viro CC: "linux-nfs@vger.kernel.org" , linux-fsdevel@vger.kernel.org, NeilBrown , Trond Myklebust , kinglongmee@gmail.com Subject: [PATCH 5/9 v8] sunrpc: Store cache_detail in seq_file's private directly References: <55B5A012.1030006@gmail.com> In-Reply-To: <55B5A012.1030006@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 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=unavailable 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. v8, same as v6. Signed-off-by: Kinglong Mee Reviewed-by: NeilBrown --- 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; }