linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: linux-cachefs@redhat.com
Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
	hjayasur@redhat.com, jlayton@redhat.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/8] fs/fscache: remove spin_lock() from the condition in while()
Date: Fri, 03 May 2013 01:33:21 +0100	[thread overview]
Message-ID: <20130503003321.14952.50141.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20130503003316.14952.51791.stgit@warthog.procyon.org.uk>

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

The spinlock() within the condition in while() will cause a compile error
if it is not a function. This is not a problem on mainline but it does not
look pretty and there is no reason to do it that way.
That patch writes it a little differently and avoids the double condition.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/fscache/page.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index ff000e5..4882c80 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -796,11 +796,16 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
 
 	_enter("");
 
-	while (spin_lock(&cookie->stores_lock),
-	       n = radix_tree_gang_lookup_tag(&cookie->stores, results, 0,
-					      ARRAY_SIZE(results),
-					      FSCACHE_COOKIE_PENDING_TAG),
-	       n > 0) {
+	for (;;) {
+		spin_lock(&cookie->stores_lock);
+		n = radix_tree_gang_lookup_tag(&cookie->stores, results, 0,
+					       ARRAY_SIZE(results),
+					       FSCACHE_COOKIE_PENDING_TAG);
+		if (n == 0) {
+			spin_unlock(&cookie->stores_lock);
+			break;
+		}
+
 		for (i = n - 1; i >= 0; i--) {
 			page = results[i];
 			radix_tree_delete(&cookie->stores, page->index);
@@ -812,7 +817,6 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
 			page_cache_release(results[i]);
 	}
 
-	spin_unlock(&cookie->stores_lock);
 	_leave("");
 }
 


  reply	other threads:[~2013-05-03  0:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-03  0:33 [PATCH 0/8] Fix assorted FS-Cache issues David Howells
2013-05-03  0:33 ` David Howells [this message]
2013-05-03  0:33 ` [PATCH 2/8] CacheFiles: name i_mutex lock class explicitly David Howells
2013-05-03  0:33 ` [PATCH 3/8] FS-Cache: Don't sleep in page release if __GFP_FS is not set David Howells
2013-05-03  0:33 ` [PATCH 4/8] FS-Cache: Uninline fscache_object_init() David Howells
2013-05-03  0:33 ` [PATCH 5/8] FS-Cache: Wrap checks on object state David Howells
2013-05-03  0:33 ` [PATCH 6/8] Add wait_on_atomic_t() and wake_up_atomic_t() David Howells
2013-05-03  0:33 ` [PATCH 7/8] FS-Cache: Fix object state machine to have separate work and wait states David Howells
2013-05-03  0:33 ` [PATCH 8/8] FS-Cache: Simplify cookie retention for fscache_objects, fixing access problems David Howells

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=20130503003321.14952.50141.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=hjayasur@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).