linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: npiggin@suse.de
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: [patch 6/8] mm: write_cache_pages cleanups
Date: Fri, 10 Oct 2008 02:50:45 +1100	[thread overview]
Message-ID: <20081009174822.740252331@suse.de> (raw)
In-Reply-To: 20081009155039.139856823@suse.de

[-- Attachment #1: mm-wcp-cleanup.patch --]
[-- Type: text/plain, Size: 2264 bytes --]

Get rid of some complex expressions from flow control statements, add a
comment, remove some duplicate code.

Signed-off-by: Nick Piggin <npiggin@suse.de>
---
Index: linux-2.6/mm/page-writeback.c
===================================================================
--- linux-2.6.orig/mm/page-writeback.c
+++ linux-2.6/mm/page-writeback.c
@@ -900,11 +900,14 @@ int write_cache_pages(struct address_spa
 		cycled = 1; /* ignore range_cyclic tests */
 	}
 retry:
-	while (!done && (index <= end) &&
-	       (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
-					      PAGECACHE_TAG_DIRTY,
-					      min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) {
-		unsigned i;
+	while (!done && (index <= end)) {
+		int i;
+
+		nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
+			      PAGECACHE_TAG_DIRTY,
+			      min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
+		if (nr_pages == 0)
+			break;
 
 		for (i = 0; i < nr_pages; i++) {
 			struct page *page = pvec.pages[i];
@@ -919,7 +922,16 @@ retry:
 again:
 			lock_page(page);
 
+			/*
+			 * Page truncated or invalidated. We can freely skip it
+			 * then, even for data integrity operations: the page
+			 * has disappeared concurrently, so there could be no
+			 * real expectation of this data interity operation
+			 * even if there is now a new, dirty page at the same
+			 * pagecache address.
+			 */
 			if (unlikely(page->mapping != mapping)) {
+continue_unlock:
 				unlock_page(page);
 				continue;
 			}
@@ -927,18 +939,15 @@ again:
 			if (page->index > end) {
 				/* Can't be range_cyclic: end == -1 there */
 				done = 1;
-				unlock_page(page);
-				continue;
+				goto continue_unlock;
 			}
 
 			if (wbc->sync_mode != WB_SYNC_NONE)
 				wait_on_page_writeback(page);
 
 			if (PageWriteback(page) ||
-			    !clear_page_dirty_for_io(page)) {
-				unlock_page(page);
-				continue;
-			}
+			    !clear_page_dirty_for_io(page))
+				goto continue_unlock;
 
 			ret = (*writepage)(page, wbc, data);
 			if (unlikely(ret)) {
@@ -952,7 +961,8 @@ again:
 				break;
 			}
 			if (wbc->sync_mode == WB_SYNC_NONE) {
-				if (--(wbc->nr_to_write) <= 0)
+				wbc->nr_to_write--;
+				if (wbc->nr_to_write <= 0)
 					done = 1;
 			}
 			if (wbc->nonblocking && bdi_write_congested(bdi)) {

-- 


  parent reply	other threads:[~2008-10-09  7:58 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-09 15:50 [patch 0/8] write_cache_pages fixes npiggin
2008-10-09 15:50 ` [patch 1/8] mm: write_cache_pages cyclic fix npiggin
2008-10-09 15:50 ` [patch 2/8] mm: write_cache_pages AOP_WRITEPAGE_ACTIVATE fix npiggin
2008-10-10 16:00   ` Miklos Szeredi
2008-10-10 18:29     ` Hugh Dickins
2008-10-11  4:05       ` Nick Piggin
2008-10-09 15:50 ` [patch 3/8] mm: write_cache_pages writepage error fix npiggin
2008-10-09 15:50 ` [patch 4/8] mm: write_cache_pages type overflow fix npiggin
2008-10-09  8:23   ` Christoph Hellwig
2008-10-09  8:33     ` Nick Piggin
2008-10-10 13:10     ` Theodore Tso
2008-10-10 13:13       ` Christoph Hellwig
2008-10-10 13:37         ` Theodore Tso
2008-10-10 13:48           ` Steven Whitehouse
2008-10-10 14:05             ` Theodore Tso
2008-10-10 14:08               ` Christoph Hellwig
2008-10-10 15:54                 ` Aneesh Kumar K.V
2008-10-10 15:59                   ` Chris Mason
2008-10-10 16:10                   ` Theodore Tso
2008-10-10 16:34                   ` Christoph Hellwig
2008-10-10 13:56           ` Chris Mason
2008-10-09 15:50 ` [patch 5/8] mm: write_cache_pages integrity fix npiggin
2008-10-09 12:52   ` Chris Mason
2008-10-09 13:27     ` Nick Piggin
2008-10-09 13:35       ` Chris Mason
2008-10-09 13:55         ` Nick Piggin
2008-10-09 14:12           ` Chris Mason
2008-10-09 14:21             ` Nick Piggin
2008-10-09 14:39               ` Chris Mason
2008-10-09 14:50                 ` Nick Piggin
2008-10-09 15:16                   ` Chris Mason
2008-10-10  2:40                     ` Nick Piggin
2008-10-09 15:50 ` npiggin [this message]
2008-10-09 14:37   ` [patch 6/8] mm: write_cache_pages cleanups Artem Bityutskiy
2008-10-09 15:50 ` [patch 7/8] mm: write_cache_pages optimise page cleaning npiggin
2008-10-09 15:50 ` [patch 8/8] mm: write_cache_pages terminate quickly npiggin

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=20081009174822.740252331@suse.de \
    --to=npiggin@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mpatocka@redhat.com \
    /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).