* [PATCH] writeback: Update dirty flags in two steps
@ 2010-05-07 9:35 Dmitry Monakhov
2010-05-07 12:23 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Monakhov @ 2010-05-07 9:35 UTC (permalink / raw)
To: linux-fsdevel; +Cc: jens.axboe, chris.mason
Filesystems with delalloc support may dirty inode during writepages.
As result inode will have dirty metadata flags even after write_inode.
In fact we have two dedicated functions for proper data and metadata
writeback. It is reasonable to separate flags updates in two stages.
https://bugzilla.kernel.org/show_bug.cgi?id=15906
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/fs-writeback.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index fdc07e3..e73d8ff 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -459,11 +459,9 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
BUG_ON(inode->i_state & I_SYNC);
- /* Set I_SYNC, reset I_DIRTY */
- dirty = inode->i_state & I_DIRTY;
+ /* Set I_SYNC, reset I_DIRTY_PAGES */
inode->i_state |= I_SYNC;
- inode->i_state &= ~I_DIRTY;
-
+ inode->i_state &= ~I_DIRTY_PAGES;
spin_unlock(&inode_lock);
ret = do_writepages(mapping, wbc);
@@ -479,6 +477,15 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
ret = err;
}
+ /*
+ * Some filesystems may redirty the inode during the writeback
+ * due to delalloc, clear dirty metadata flags right before
+ * write_inode()
+ */
+ spin_lock(&inode_lock);
+ dirty = inode->i_state & I_DIRTY;
+ inode->i_state &= ~(I_DIRTY_SYNC | I_DIRTY_DATASYNC);
+ spin_unlock(&inode_lock);
/* Don't write the inode if only I_DIRTY_PAGES was set */
if (dirty & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) {
int err = write_inode(inode, wbc);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] writeback: Update dirty flags in two steps
2010-05-07 9:35 [PATCH] writeback: Update dirty flags in two steps Dmitry Monakhov
@ 2010-05-07 12:23 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2010-05-07 12:23 UTC (permalink / raw)
To: Dmitry Monakhov; +Cc: linux-fsdevel, jens.axboe, chris.mason
On Fri, May 07, 2010 at 01:35:44PM +0400, Dmitry Monakhov wrote:
>
> Filesystems with delalloc support may dirty inode during writepages.
> As result inode will have dirty metadata flags even after write_inode.
> In fact we have two dedicated functions for proper data and metadata
> writeback. It is reasonable to separate flags updates in two stages.
>
> https://bugzilla.kernel.org/show_bug.cgi?id=15906
>
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Looks good and passes XFSQA for me.
Reviewed-by: Christoph Hellwig <hch@lst.de>
> + spin_lock(&inode_lock);
> + dirty = inode->i_state & I_DIRTY;
> + inode->i_state &= ~(I_DIRTY_SYNC | I_DIRTY_DATASYNC);
> + spin_unlock(&inode_lock);
> /* Don't write the inode if only I_DIRTY_PAGES was set */
> if (dirty & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) {
No need for the double masking, the first line could be just
dirty = inode->i_state;
or you could do:
/* Don't write the inode if only I_DIRTY_PAGES was set */
dirty = inode->i_state & (I_DIRTY_SYNC | I_DIRTY_DATASYNC);
and then just
if (dirty) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-07 12:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-07 9:35 [PATCH] writeback: Update dirty flags in two steps Dmitry Monakhov
2010-05-07 12:23 ` Christoph Hellwig
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).