From patchwork Tue Aug 14 16:24:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 1322971 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by patchwork1.kernel.org (Postfix) with ESMTP id D208540210 for ; Tue, 14 Aug 2012 18:31:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7EITG7J004337; Tue, 14 Aug 2012 14:29:16 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7EGQR9P013602 for ; Tue, 14 Aug 2012 12:26:27 -0400 Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.16]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7EGQMgu029611; Tue, 14 Aug 2012 12:26:22 -0400 Received: from mail-bk0-f46.google.com (mail-bk0-f46.google.com [209.85.214.46]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7EGOqgr002535; Tue, 14 Aug 2012 12:26:19 -0400 Received: by mail-bk0-f46.google.com with SMTP id j10so238412bkw.33 for ; Tue, 14 Aug 2012 09:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=n/e3unMkvdWfjMxXS0ZiWQRXZL4es9JUHTqdPB061kg=; b=E7LZtTCVz1iE5B++aQ/aZqAJraJ22+hlc1HcgkAexjqISa0EiTNB2Zr27Vdk71XHvr iSBQDgAibCsqT/DRbdzlq2orXzUaGY6JypjQ24q/wE0981y6y9+Tal4ZLGHX5uUfW/ud i4eO2rCN+GnT+ch2tO5w1poRLtUdbvsKOZUPU+AAwq3Vqz3JPZgawBpKpvmOb2bPbS4P XGEI4qX+n0cglU6InpXQ49WE0tYkXvd1rAYXUzOBaYvN5wiYl6tfCzrqORxEndedbLVg SR9rIybIK0FvnmwzeTrc7/QMAGpLHWgr7dXKZlaYwFszgR2XaI+tdLX+bkuy/hfIw6QZ RkfQ== Received: by 10.204.157.18 with SMTP id z18mr6768211bkw.16.1344961579273; Tue, 14 Aug 2012 09:26:19 -0700 (PDT) Received: from localhost.localdomain (95-89-78-76-dynip.superkabel.de. [95.89.78.76]) by mx.google.com with ESMTPS id t23sm1470660bks.4.2012.08.14.09.26.12 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Aug 2012 09:26:17 -0700 (PDT) From: Sasha Levin To: torvalds@linux-foundation.org Date: Tue, 14 Aug 2012 18:24:47 +0200 Message-Id: <1344961490-4068-14-git-send-email-levinsasha928@gmail.com> In-Reply-To: <1344961490-4068-1-git-send-email-levinsasha928@gmail.com> References: <1344961490-4068-1-git-send-email-levinsasha928@gmail.com> X-RedHat-Spam-Score: -2.45 (BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.16 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Tue, 14 Aug 2012 14:21:01 -0400 Cc: snitzer@redhat.com, fweisbec@gmail.com, Trond.Myklebust@netapp.com, bfields@fieldses.org, paul.gortmaker@windriver.com, dm-devel@redhat.com, agk@redhat.com, aarcange@redhat.com, rds-devel@oss.oracle.com, eric.dumazet@gmail.com, venkat.x.venkatsubra@oracle.com, ccaulfie@redhat.com, mingo@elte.hu, dev@openvswitch.org, jesse@nicira.com, josh@joshtriplett.org, rostedt@goodmis.org, lw@cn.fujitsu.com, mathieu.desnoyers@efficios.com, Sasha Levin , axboe@kernel.dk, linux-nfs@vger.kernel.org, edumazet@google.com, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ejt@redhat.com, ebiederm@xmission.com, tj@kernel.org, teigland@redhat.com, akpm@linux-foundation.org, davem@davemloft.net Subject: [dm-devel] [PATCH 13/16] lockd: use new hashtable implementation X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Switch lockd to use the new hashtable implementation. This reduces the amount of generic unrelated code in lockd. Signed-off-by: Sasha Levin --- fs/lockd/svcsubs.c | 58 +++++++++++++++++++++++++-------------------------- 1 files changed, 28 insertions(+), 30 deletions(-) diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index 0deb5f6..26c90c8 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -20,6 +20,7 @@ #include #include #include +#include #define NLMDBG_FACILITY NLMDBG_SVCSUBS @@ -28,8 +29,7 @@ * Global file hash table */ #define FILE_HASH_BITS 7 -#define FILE_NRHASH (1<data[i]; - return tmp & (FILE_NRHASH - 1); + return tmp; } /* @@ -86,17 +86,17 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, { struct hlist_node *pos; struct nlm_file *file; - unsigned int hash; + unsigned int key; __be32 nfserr; nlm_debug_print_fh("nlm_lookup_file", f); - hash = file_hash(f); + key = file_hash(f); /* Lock file table */ mutex_lock(&nlm_file_mutex); - hlist_for_each_entry(file, pos, &nlm_files[hash], f_list) + hash_for_each_possible(nlm_files, file, pos, f_list, file_hash(f)) if (!nfs_compare_fh(&file->f_handle, f)) goto found; @@ -123,7 +123,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, goto out_free; } - hlist_add_head(&file->f_list, &nlm_files[hash]); + hash_add(nlm_files, &file->f_list, key); found: dprintk("lockd: found file %p (count %d)\n", file, file->f_count); @@ -147,8 +147,8 @@ static inline void nlm_delete_file(struct nlm_file *file) { nlm_debug_print_file("closing file", file); - if (!hlist_unhashed(&file->f_list)) { - hlist_del(&file->f_list); + if (hash_hashed(&file->f_list)) { + hash_del(&file->f_list); nlmsvc_ops->fclose(file->f_file); kfree(file); } else { @@ -253,27 +253,25 @@ nlm_traverse_files(void *data, nlm_host_match_fn_t match, int i, ret = 0; mutex_lock(&nlm_file_mutex); - for (i = 0; i < FILE_NRHASH; i++) { - hlist_for_each_entry_safe(file, pos, next, &nlm_files[i], f_list) { - if (is_failover_file && !is_failover_file(data, file)) - continue; - file->f_count++; - mutex_unlock(&nlm_file_mutex); - - /* Traverse locks, blocks and shares of this file - * and update file->f_locks count */ - if (nlm_inspect_file(data, file, match)) - ret = 1; - - mutex_lock(&nlm_file_mutex); - file->f_count--; - /* No more references to this file. Let go of it. */ - if (list_empty(&file->f_blocks) && !file->f_locks - && !file->f_shares && !file->f_count) { - hlist_del(&file->f_list); - nlmsvc_ops->fclose(file->f_file); - kfree(file); - } + hash_for_each_safe(nlm_files, i, pos, next, file, f_list) { + if (is_failover_file && !is_failover_file(data, file)) + continue; + file->f_count++; + mutex_unlock(&nlm_file_mutex); + + /* Traverse locks, blocks and shares of this file + * and update file->f_locks count */ + if (nlm_inspect_file(data, file, match)) + ret = 1; + + mutex_lock(&nlm_file_mutex); + file->f_count--; + /* No more references to this file. Let go of it. */ + if (list_empty(&file->f_blocks) && !file->f_locks + && !file->f_shares && !file->f_count) { + hash_del(&file->f_list); + nlmsvc_ops->fclose(file->f_file); + kfree(file); } } mutex_unlock(&nlm_file_mutex);