All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: linux-fsdevel@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	dchinner@redhat.com, Wu Fengguang <fengguang.wu@intel.com>,
	Jan Kara <jack@suse.cz>
Subject: [PATCH 3/9] writeback: Move I_DIRTY_PAGES handling
Date: Thu,  3 May 2012 14:47:57 +0200	[thread overview]
Message-ID: <1336049283-5859-4-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1336049283-5859-1-git-send-email-jack@suse.cz>

Instead of clearing I_DIRTY_PAGES and resetting it when we didn't succeed in
writing them all, just clear the bit only when we succeeded writing all the
pages. We also move the clearing of the bit close to other i_state handling to
separate it from writeback list handling. This is desirable because list
handling will differ for flusher thread and other writeback_single_inode()
callers in future. No filesystem plays any tricks with I_DIRTY_PAGES (like
checking it in ->writepages or ->write_inode implementation) so this movement
is safe.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/fs-writeback.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 65cd147..3804a10 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -385,7 +385,6 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb,
 
 	/* Set I_SYNC, reset I_DIRTY_PAGES */
 	inode->i_state |= I_SYNC;
-	inode->i_state &= ~I_DIRTY_PAGES;
 	spin_unlock(&inode->i_lock);
 	spin_unlock(&wb->list_lock);
 
@@ -408,6 +407,9 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb,
 	 * write_inode()
 	 */
 	spin_lock(&inode->i_lock);
+	/* Clear I_DIRTY_PAGES if we've written out all dirty pages */
+	if (!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
+		inode->i_state &= ~I_DIRTY_PAGES;
 	dirty = inode->i_state & I_DIRTY;
 	inode->i_state &= ~(I_DIRTY_SYNC | I_DIRTY_DATASYNC);
 	spin_unlock(&inode->i_lock);
@@ -435,7 +437,6 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb,
 			 * We didn't write back all the pages.  nfs_writepages()
 			 * sometimes bales out without doing anything.
 			 */
-			inode->i_state |= I_DIRTY_PAGES;
 			if (wbc->nr_to_write <= 0) {
 				/*
 				 * slice used up: queue for next turn
-- 
1.7.1


  parent reply	other threads:[~2012-05-03 12:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03 12:47 [PATCH 0/7 v3] writeback: Avoid iput() from flusher thread Jan Kara
2012-05-03 12:47 ` [PATCH 1/9] writeback: Move clearing of I_SYNC into inode_sync_complete() Jan Kara
2012-05-03 12:47 ` [PATCH 2/9] writeback: Move requeueing when I_SYNC set to writeback_sb_inodes() Jan Kara
2012-05-03 12:47 ` Jan Kara [this message]
2012-05-03 12:47 ` [PATCH 4/9] writeback: Separate inode requeueing after writeback Jan Kara
2012-05-03 12:47 ` [PATCH 5/9] writeback: Remove wb->list_lock from writeback_single_inode() Jan Kara
2012-05-03 12:48 ` [PATCH 6/9] writeback: Refactor writeback_single_inode() Jan Kara
2012-05-03 12:48 ` [PATCH 7/9] vfs: Move waiting for inode writeback from end_writeback() to evict_inode() Jan Kara
2012-05-03 12:48 ` [PATCH 8/9] vfs: Rename end_writeback() to clear_inode() Jan Kara
2012-05-03 12:48 ` [PATCH 9/9] writeback: Avoid iput() from flusher thread Jan Kara
2012-05-07  2:57 ` [PATCH 0/7 v3] " Fengguang Wu

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=1336049283-5859-4-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=dchinner@redhat.com \
    --cc=fengguang.wu@intel.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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.