From: Jens Axboe <jens.axboe@oracle.com>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: chris.mason@oracle.com, david@fromorbit.com, npiggin@suse.de,
hch@infradead.org, akpm@linux-foundation.org,
Jens Axboe <jens.axboe@oracle.com>
Subject: [PATCH 09/12] writeback: include default_backing_dev_info in writeback
Date: Sun, 22 Mar 2009 20:26:01 +0100 [thread overview]
Message-ID: <1237749964-8343-10-git-send-email-jens.axboe@oracle.com> (raw)
In-Reply-To: <1237749964-8343-1-git-send-email-jens.axboe@oracle.com>
We see dirty inodes there occasionally, so better be safe and write them
out.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
---
fs/fs-writeback.c | 60 +++++++++++++++++++++++++------------------
include/linux/backing-dev.h | 5 +++
include/linux/writeback.h | 1 +
mm/backing-dev.c | 35 +++++++++++++++----------
4 files changed, 62 insertions(+), 39 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 741e127..5fcdcd4 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -34,6 +34,10 @@
*/
int nr_pdflush_threads = 0;
+static void generic_sync_wb_inodes(struct bdi_writeback *wb,
+ struct super_block *sb,
+ struct writeback_control *wbc);
+
/**
* writeback_acquire - attempt to get exclusive writeback access to a device
* @bdi: the device's backing_dev_info structure
@@ -149,7 +153,7 @@ int bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb,
* older_than_this takes precedence over nr_to_write. So we'll only write back
* all dirty pages if they are all attached to "old" mappings.
*/
-static void wb_kupdated(struct bdi_writeback *wb)
+void wb_kupdated(struct bdi_writeback *wb)
{
long nr_to_write;
struct writeback_control wbc = {
@@ -177,11 +181,7 @@ static void wb_kupdated(struct bdi_writeback *wb)
}
}
-static void generic_sync_wb_inodes(struct bdi_writeback *wb,
- struct super_block *sb,
- struct writeback_control *wbc);
-
-static void wb_writeback(struct bdi_writeback *wb)
+void wb_writeback(struct bdi_writeback *wb)
{
struct writeback_control wbc = {
.bdi = wb->bdi,
@@ -217,6 +217,34 @@ static void wb_writeback(struct bdi_writeback *wb)
}
/*
+ * This will be inlined in bdi_writeback_task() once we get rid of any
+ * dirty inodes on the default_backing_dev_info
+ */
+void wb_do_writeback(struct bdi_writeback *wb)
+{
+ /*
+ * We get here in two cases:
+ *
+ * schedule_timeout() returned because the dirty writeback
+ * interval has elapsed. If that happens, we will be able
+ * to acquire the writeback lock and will proceed to do
+ * kupdated style writeout.
+ *
+ * Someone called bdi_start_writeback(), which will acquire
+ * the writeback lock. This means our writeback_acquire()
+ * below will fail and we call into bdi_pdflush() for
+ * pdflush style writeout.
+ *
+ */
+ if (writeback_acquire(wb))
+ wb_kupdated(wb);
+ else
+ wb_writeback(wb);
+
+ writeback_release(wb);
+}
+
+/*
* Handle writeback of dirty data for the device backed by this bdi. Also
* wakes up periodically and does kupdated style flushing.
*/
@@ -229,26 +257,8 @@ int bdi_writeback_task(struct bdi_writeback *wb)
schedule_timeout(dirty_writeback_interval);
try_to_freeze();
- /*
- * We get here in two cases:
- *
- * schedule_timeout() returned because the dirty writeback
- * interval has elapsed. If that happens, we will be able
- * to acquire the writeback lock and will proceed to do
- * kupdated style writeout.
- *
- * Someone called bdi_start_writeback(), which will acquire
- * the writeback lock. This means our writeback_acquire()
- * below will fail and we call into bdi_pdflush() for
- * pdflush style writeout.
- *
- */
- if (writeback_acquire(wb))
- wb_kupdated(wb);
- else
- wb_writeback(wb);
+ wb_do_writeback(wb);
- writeback_release(wb);
finish_wait(&wb->wait, &wait);
}
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 279bc3f..9dd8cb9 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -308,6 +308,11 @@ static inline bool bdi_cap_swap_backed(struct backing_dev_info *bdi)
return bdi->capabilities & BDI_CAP_SWAP_BACKED;
}
+static inline bool bdi_cap_flush_forker(struct backing_dev_info *bdi)
+{
+ return bdi->capabilities & BDI_CAP_FLUSH_FORKER;
+}
+
static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
{
return bdi_cap_writeback_dirty(mapping->backing_dev_info);
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index f96fea3..5f1d59f 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -69,6 +69,7 @@ void writeback_inodes(struct writeback_control *wbc);
int inode_wait(void *);
void sync_inodes_sb(struct super_block *, int wait);
void sync_inodes(int wait);
+void wb_do_writeback(struct bdi_writeback *wb);
/* writeback.h requires fs.h; it, too, is not included from here. */
static inline void wait_on_inode(struct inode *inode)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 21406f2..7551648 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -357,14 +357,6 @@ static int bdi_forker_task(void *ptr)
struct bdi_writeback *wb;
DEFINE_WAIT(wait);
- /*
- * Should never trigger on the default bdi
- */
- if (wb_has_dirty_io(me)) {
- bdi_flush_io(me->bdi);
- WARN_ON(1);
- }
-
prepare_to_wait(&me->wait, &wait, TASK_INTERRUPTIBLE);
smp_mb();
@@ -372,6 +364,21 @@ static int bdi_forker_task(void *ptr)
schedule();
finish_wait(&me->wait, &wait);
+
+ /*
+ * Ideally we'd like not to see any dirty inodes on the
+ * default_backing_dev_info. Until these are tracked down,
+ * perform the same writeback here that bdi_writeback_task
+ * does. For logic, see comment in
+ * fs/fs-writeback.c:bdi_writeback_task()
+ */
+ if (wb_has_dirty_io(me))
+ wb_do_writeback(me);
+
+ /*
+ * This is our real job - check for pending entries in
+ * bdi_pending_list, and create the tasks that got added
+ */
repeat:
bdi = NULL;
spin_lock_bh(&bdi_lock);
@@ -489,7 +496,7 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
* and add other bdi's to the list. They will get a thread created
* on-demand when they need it.
*/
- if (bdi->capabilities & BDI_CAP_FLUSH_FORKER) {
+ if (bdi_cap_flush_forker(bdi)) {
struct bdi_writeback *wb;
wb = bdi_new_wb(bdi);
@@ -505,12 +512,12 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
ret = -ENOMEM;
goto exit;
}
- } else {
- spin_lock_bh(&bdi_lock);
- list_add_tail_rcu(&bdi->bdi_list, &bdi_list);
- spin_unlock_bh(&bdi_lock);
}
+ spin_lock_bh(&bdi_lock);
+ list_add_tail_rcu(&bdi->bdi_list, &bdi_list);
+ spin_unlock_bh(&bdi_lock);
+
bdi->dev = dev;
bdi_debug_register(bdi, dev_name(dev));
@@ -570,7 +577,7 @@ static void bdi_wb_shutdown(struct backing_dev_info *bdi)
void bdi_unregister(struct backing_dev_info *bdi)
{
if (bdi->dev) {
- if (!(bdi->capabilities & BDI_CAP_FLUSH_FORKER))
+ if (!bdi_cap_flush_forker(bdi))
bdi_wb_shutdown(bdi);
bdi_debug_unregister(bdi);
device_unregister(bdi->dev);
--
1.6.2.12.g83676
next prev parent reply other threads:[~2009-03-22 19:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-22 19:25 [PATCH 0/12] Per-bdi writeback flusher threads #2 Jens Axboe
2009-03-22 19:25 ` [PATCH 01/12] Move the default_backing_dev_info out of readahead.c and into backing-dev.c Jens Axboe
2009-03-22 19:25 ` [PATCH 02/12] btrfs: get rid of current_is_pdflush() in btrfs_btree_balance_dirty Jens Axboe
2009-03-22 19:25 ` [PATCH 03/12] Get rid of pdflush_operation() in emergency sync and remount Jens Axboe
2009-03-22 19:25 ` [PATCH 04/12] writeback: move dirty inodes from super_block to backing_dev_info Jens Axboe
2009-03-22 19:25 ` [PATCH 05/12] writeback: switch to per-bdi threads for flushing data Jens Axboe
2009-03-31 14:11 ` Jan Kara
2009-03-31 16:50 ` Jens Axboe
2009-04-01 9:12 ` Jan Kara
2009-03-22 19:25 ` [PATCH 06/12] writeback get rid of pdflush completely Jens Axboe
2009-03-22 19:25 ` [PATCH 07/12] writeback: separate the flushing state/task from the bdi Jens Axboe
2009-03-22 19:26 ` [PATCH 08/12] writeback: support > 1 flusher thread per bdi Jens Axboe
2009-03-22 19:26 ` Jens Axboe [this message]
2009-03-22 19:26 ` [PATCH 10/12] writeback: add some debug inode list counters to bdi stats Jens Axboe
2009-03-22 19:26 ` [PATCH 11/12] writeback: add name to backing_dev_info Jens Axboe
2009-03-22 19:26 ` [PATCH 12/12] writeback: check for registered bdi in flusher add Jens Axboe
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=1237749964-8343-10-git-send-email-jens.axboe@oracle.com \
--to=jens.axboe@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=chris.mason@oracle.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@suse.de \
/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).