All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Banks <gnb@sgi.com>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Linux NFS ML <linux-nfs@vger.kernel.org>
Subject: [patch 02/14] sunrpc: Use consistent naming for variables of type struct cache_head*
Date: Thu, 08 Jan 2009 19:25:12 +1100	[thread overview]
Message-ID: <20090108082602.800094000@sgi.com> (raw)
In-Reply-To: 20090108082510.050854000@sgi.com

This makes the cache code easier to read.

Signed-off-by: Greg Banks <gnb@sgi.com>
---

 net/sunrpc/cache.c |  100 +++++++++++++++++++++---------------------
 1 file changed, 50 insertions(+), 50 deletions(-)

Index: bfields/net/sunrpc/cache.c
===================================================================
--- bfields.orig/net/sunrpc/cache.c
+++ bfields/net/sunrpc/cache.c
@@ -34,8 +34,8 @@
 
 #define	 RPCDBG_FACILITY RPCDBG_CACHE
 
-static int cache_defer_req(struct cache_req *req, struct cache_head *item);
-static void cache_revisit_request(struct cache_head *item);
+static int cache_defer_req(struct cache_req *req, struct cache_head *h);
+static void cache_revisit_request(struct cache_head *h);
 
 static void cache_init(struct cache_head *h)
 {
@@ -101,23 +101,23 @@ struct cache_head *sunrpc_cache_lookup(s
 EXPORT_SYMBOL(sunrpc_cache_lookup);
 
 
-static void queue_loose(struct cache_detail *cd, struct cache_head *ch);
+static void queue_loose(struct cache_detail *cd, struct cache_head *h);
 
-static int cache_fresh_locked(struct cache_head *head, time_t expiry)
+static int cache_fresh_locked(struct cache_head *h, time_t expiry)
 {
-	head->expiry_time = expiry;
-	head->last_refresh = get_seconds();
-	return !test_and_set_bit(CACHE_VALID, &head->flags);
+	h->expiry_time = expiry;
+	h->last_refresh = get_seconds();
+	return !test_and_set_bit(CACHE_VALID, &h->flags);
 }
 
-static void cache_fresh_unlocked(struct cache_head *head,
+static void cache_fresh_unlocked(struct cache_head *h,
 			struct cache_detail *cd, int new)
 {
 	if (new)
-		cache_revisit_request(head);
-	if (test_and_clear_bit(CACHE_PENDING, &head->flags)) {
-		cache_revisit_request(head);
-		queue_loose(cd, head);
+		cache_revisit_request(h);
+	if (test_and_clear_bit(CACHE_PENDING, &h->flags)) {
+		cache_revisit_request(h);
+		queue_loose(cd, h);
 	}
 }
 
@@ -444,7 +444,7 @@ static int cache_clean(void)
 	/* find a cleanable entry in the bucket and clean it, or set to next bucket */
 
 	if (current_detail && current_index < current_detail->hash_size) {
-		struct cache_head *ch, **cp;
+		struct cache_head *h, **cp;
 		struct cache_detail *cd;
 
 		write_lock(&current_detail->hash_lock);
@@ -452,33 +452,33 @@ static int cache_clean(void)
 		/* Ok, now to clean this strand */
 
 		cp = & current_detail->hash_table[current_index];
-		ch = *cp;
-		for (; ch; cp= & ch->next, ch= *cp) {
-			if (current_detail->nextcheck > ch->expiry_time)
-				current_detail->nextcheck = ch->expiry_time+1;
-			if (ch->expiry_time >= get_seconds()
-			    && ch->last_refresh >= current_detail->flush_time
+		h = *cp;
+		for (; h; cp= & h->next, h= *cp) {
+			if (current_detail->nextcheck > h->expiry_time)
+				current_detail->nextcheck = h->expiry_time+1;
+			if (h->expiry_time >= get_seconds()
+			    && h->last_refresh >= current_detail->flush_time
 				)
 				continue;
-			if (test_and_clear_bit(CACHE_PENDING, &ch->flags))
-				queue_loose(current_detail, ch);
+			if (test_and_clear_bit(CACHE_PENDING, &h->flags))
+				queue_loose(current_detail, h);
 
-			if (atomic_read(&ch->ref.refcount) == 1)
+			if (atomic_read(&h->ref.refcount) == 1)
 				break;
 		}
-		if (ch) {
-			*cp = ch->next;
-			ch->next = NULL;
+		if (h) {
+			*cp = h->next;
+			h->next = NULL;
 			current_detail->entries--;
 			rv = 1;
 		}
 		write_unlock(&current_detail->hash_lock);
 		cd = current_detail;
-		if (!ch)
+		if (!h)
 			current_index ++;
 		spin_unlock(&cache_list_lock);
-		if (ch)
-			cache_put(ch, cd);
+		if (h)
+			cache_put(h, cd);
 	} else
 		spin_unlock(&cache_list_lock);
 
@@ -551,10 +551,10 @@ static LIST_HEAD(cache_defer_list);
 static struct list_head cache_defer_hash[DFR_HASHSIZE];
 static int cache_defer_cnt;
 
-static int cache_defer_req(struct cache_req *req, struct cache_head *item)
+static int cache_defer_req(struct cache_req *req, struct cache_head *h)
 {
 	struct cache_deferred_req *dreq;
-	int hash = DFR_HASH(item);
+	int hash = DFR_HASH(h);
 
 	if (cache_defer_cnt >= DFR_MAX) {
 		/* too much in the cache, randomly drop this one,
@@ -567,7 +567,7 @@ static int cache_defer_req(struct cache_
 	if (dreq == NULL)
 		return -ETIMEDOUT;
 
-	dreq->item = item;
+	dreq->item = h;
 
 	spin_lock(&cache_defer_lock);
 
@@ -592,20 +592,20 @@ static int cache_defer_req(struct cache_
 		/* there was one too many */
 		dreq->revisit(dreq, 1);
 	}
-	if (!test_bit(CACHE_PENDING, &item->flags)) {
+	if (!test_bit(CACHE_PENDING, &h->flags)) {
 		/* must have just been validated... */
-		cache_revisit_request(item);
+		cache_revisit_request(h);
 	}
 	return 0;
 }
 
-static void cache_revisit_request(struct cache_head *item)
+static void cache_revisit_request(struct cache_head *h)
 {
 	struct cache_deferred_req *dreq;
 	struct list_head pending;
 
 	struct list_head *lp;
-	int hash = DFR_HASH(item);
+	int hash = DFR_HASH(h);
 
 	INIT_LIST_HEAD(&pending);
 	spin_lock(&cache_defer_lock);
@@ -615,7 +615,7 @@ static void cache_revisit_request(struct
 		while (lp != &cache_defer_hash[hash]) {
 			dreq = list_entry(lp, struct cache_deferred_req, hash);
 			lp = lp->next;
-			if (dreq->item == item) {
+			if (dreq->item == h) {
 				list_del(&dreq->hash);
 				list_move(&dreq->recent, &pending);
 				cache_defer_cnt--;
@@ -924,14 +924,14 @@ static const struct file_operations cach
 };
 
 
-static void queue_loose(struct cache_detail *cd, struct cache_head *ch)
+static void queue_loose(struct cache_detail *cd, struct cache_head *h)
 {
 	struct cache_queue *cq;
 	spin_lock(&queue_lock);
 	list_for_each_entry(cq, &cd->queue, list)
 		if (!cq->reader) {
 			struct cache_request *cr = container_of(cq, struct cache_request, q);
-			if (cr->item != ch)
+			if (cr->item != h)
 				continue;
 			if (cr->readers != 0)
 				continue;
@@ -1159,7 +1159,7 @@ static void *c_start(struct seq_file *m,
 {
 	loff_t n = *pos;
 	unsigned hash, entry;
-	struct cache_head *ch;
+	struct cache_head *h;
 	struct cache_detail *cd = ((struct handle*)m->private)->cd;
 
 
@@ -1169,9 +1169,9 @@ static void *c_start(struct seq_file *m,
 	hash = n >> 32;
 	entry = n & ((1LL<<32) - 1);
 
-	for (ch=cd->hash_table[hash]; ch; ch=ch->next)
+	for (h=cd->hash_table[hash]; h; h=h->next)
 		if (!entry--)
-			return ch;
+			return h;
 	n &= ~((1LL<<32) - 1);
 	do {
 		hash++;
@@ -1186,18 +1186,18 @@ static void *c_start(struct seq_file *m,
 
 static void *c_next(struct seq_file *m, void *p, loff_t *pos)
 {
-	struct cache_head *ch = p;
+	struct cache_head *h = p;
 	int hash = (*pos >> 32);
 	struct cache_detail *cd = ((struct handle*)m->private)->cd;
 
 	if (p == SEQ_START_TOKEN)
 		hash = 0;
-	else if (ch->next == NULL) {
+	else if (h->next == NULL) {
 		hash++;
 		*pos += 1LL<<32;
 	} else {
 		++*pos;
-		return ch->next;
+		return h->next;
 	}
 	*pos &= ~((1LL<<32) - 1);
 	while (hash < cd->hash_size &&
@@ -1220,7 +1220,7 @@ static void c_stop(struct seq_file *m, v
 
 static int c_show(struct seq_file *m, void *p)
 {
-	struct cache_head *cp = p;
+	struct cache_head *h = p;
 	struct cache_detail *cd = ((struct handle*)m->private)->cd;
 
 	if (p == SEQ_START_TOKEN)
@@ -1228,15 +1228,15 @@ static int c_show(struct seq_file *m, vo
 
 	ifdebug(CACHE)
 		seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n",
-			   cp->expiry_time, atomic_read(&cp->ref.refcount), cp->flags);
-	cache_get(cp);
-	if (cache_check(cd, cp, NULL))
+			   h->expiry_time, atomic_read(&h->ref.refcount), h->flags);
+	cache_get(h);
+	if (cache_check(cd, h, NULL))
 		/* cache_check does a cache_put on failure */
 		seq_printf(m, "# ");
 	else
-		cache_put(cp, cd);
+		cache_put(h, cd);
 
-	return cd->cache_show(m, cd, cp);
+	return cd->cache_show(m, cd, h);
 }
 
 static const struct seq_operations cache_content_op = {

--
-- 
Greg Banks, P.Engineer, SGI Australian Software Group.
the brightly coloured sporks of revolution.
I don't speak for SGI.

  parent reply	other threads:[~2009-01-08  8:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-08  8:25 [patch 00/14] sunrpc: Sunrpc cache cleanups and upcall rework Greg Banks
2009-01-08  8:25 ` [patch 01/14] sunrpc: Use consistent naming for variables of type struct cache_detail* Greg Banks
2009-01-08  8:25 ` Greg Banks [this message]
2009-01-08  8:25 ` [patch 03/14] sunrpc: Use consistent naming for variables of type struct cache_request* Greg Banks
2009-01-08  8:25 ` [patch 04/14] sunrpc: Minor indentation cleanup in cache.c Greg Banks
2009-01-08  8:25 ` [patch 05/14] sunrpc: Rename queue_loose() to cache_remove_queued() Greg Banks
2009-01-08  8:25 ` [patch 06/14] sunrpc: Gather forward declarations of static functions in cache.c Greg Banks
2009-01-08  8:25 ` [patch 07/14] sunrpc: Make the global queue_lock per-cache-detail Greg Banks
2009-01-08  8:25 ` [patch 08/14] sunrpc: Make the global queue_wait per-cache-detail Greg Banks
2009-01-08  8:25 ` [patch 09/14] sunrpc: Remove the global lock queue_io_mutex Greg Banks
2009-01-08  8:25 ` [patch 10/14] sunrpc: Reorganise the queuing of cache upcalls Greg Banks
2009-01-08 19:57   ` J. Bruce Fields
2009-01-09  2:40     ` Greg Banks
     [not found]       ` <4966B92F.8060008-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org>
2009-01-09  2:57         ` J. Bruce Fields
2009-01-09  3:12           ` Greg Banks
     [not found]             ` <4966C0AB.7000604-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org>
2009-01-09 16:53               ` Chuck Lever
2009-01-10  1:28                 ` Greg Banks
2009-01-09 21:29         ` J. Bruce Fields
2009-01-09 21:41           ` J. Bruce Fields
2009-01-09 23:40             ` Greg Banks
2009-01-09 23:29           ` Greg Banks
2009-01-08  8:25 ` [patch 11/14] sunrpc: Allocate cache_requests in a single allocation Greg Banks
2009-01-08  8:25 ` [patch 12/14] sunrpc: Centralise memory management of cache_requests Greg Banks
2009-01-08  8:25 ` [patch 13/14] sunrpc: Move struct cache_request to linux/sunrpc/cache.h Greg Banks
2009-01-08  8:25 ` [patch 14/14] sunrpc: Improve the usefulness of debug printks in the sunrpc cache code Greg Banks
2009-01-08 19:52 ` [patch 00/14] sunrpc: Sunrpc cache cleanups and upcall rework J. Bruce Fields
2009-01-09  1:42   ` Greg Banks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090108082602.800094000@sgi.com \
    --to=gnb@sgi.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.