From: Christoph Hellwig <hch@lst.de>
To: axboe@kernel.dk
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 2/6] writeback: queue work on stack in writeback_inodes_sb
Date: Tue, 8 Jun 2010 18:14:43 +0200 [thread overview]
Message-ID: <20100608161443.GC11735@lst.de> (raw)
In-Reply-To: <20100608161424.GA11735@lst.de>
If we want to rely on s_umount in the caller we need to wait for completion
of the I/O submission before returning to the caller. Refactor
bdi_sync_writeback into a bdi_queue_work_onstack helper and use it for this
case.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6/fs/fs-writeback.c
===================================================================
--- linux-2.6.orig/fs/fs-writeback.c 2010-06-08 16:22:24.293254045 +0200
+++ linux-2.6/fs/fs-writeback.c 2010-06-08 16:25:35.794005969 +0200
@@ -178,30 +178,22 @@ static void bdi_alloc_queue_work(struct
}
/**
- * bdi_sync_writeback - start and wait for writeback
- * @bdi: the backing device to write from
+ * bdi_queue_work_onstack - start and wait for writeback
* @sb: write inodes from this super_block
*
* Description:
- * This does WB_SYNC_ALL data integrity writeback and waits for the
- * IO to complete. Callers must hold the sb s_umount semaphore for
+ * This function initiates writeback and waits for the operation to
+ * complete. Callers must hold the sb s_umount semaphore for
* reading, to avoid having the super disappear before we are done.
*/
-static void bdi_sync_writeback(struct backing_dev_info *bdi,
- struct super_block *sb)
+static void bdi_queue_work_onstack(struct wb_writeback_args *args)
{
- struct wb_writeback_args args = {
- .sb = sb,
- .sync_mode = WB_SYNC_ALL,
- .nr_pages = LONG_MAX,
- .range_cyclic = 0,
- };
struct bdi_work work;
- bdi_work_init(&work, &args);
+ bdi_work_init(&work, args);
__set_bit(WS_ONSTACK, &work.state);
- bdi_queue_work(bdi, &work);
+ bdi_queue_work(args->sb->s_bdi, &work);
bdi_wait_on_work_done(&work);
}
@@ -944,7 +936,7 @@ int bdi_writeback_task(struct bdi_writeb
/*
* Schedule writeback for all backing devices. This does WB_SYNC_NONE
- * writeback, for integrity writeback see bdi_sync_writeback().
+ * writeback, for integrity writeback see bdi_queue_work_onstack().
*/
static void bdi_writeback_all(struct super_block *sb, long nr_pages)
{
@@ -1183,12 +1175,15 @@ void writeback_inodes_sb(struct super_bl
{
unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY);
unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS);
- long nr_to_write;
+ struct wb_writeback_args args = {
+ .sb = sb,
+ .sync_mode = WB_SYNC_NONE,
+ };
- nr_to_write = nr_dirty + nr_unstable +
+ args.nr_pages = nr_dirty + nr_unstable +
(inodes_stat.nr_inodes - inodes_stat.nr_unused);
- bdi_start_writeback(sb->s_bdi, sb, nr_to_write);
+ bdi_queue_work_onstack(&args);
}
EXPORT_SYMBOL(writeback_inodes_sb);
@@ -1218,7 +1213,14 @@ EXPORT_SYMBOL(writeback_inodes_sb_if_idl
*/
void sync_inodes_sb(struct super_block *sb)
{
- bdi_sync_writeback(sb->s_bdi, sb);
+ struct wb_writeback_args args = {
+ .sb = sb,
+ .sync_mode = WB_SYNC_ALL,
+ .nr_pages = LONG_MAX,
+ .range_cyclic = 0,
+ };
+
+ bdi_queue_work_onstack(&args);
wait_sb_inodes(sb);
}
EXPORT_SYMBOL(sync_inodes_sb);
next prev parent reply other threads:[~2010-06-08 16:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-08 16:14 [PATCH 0/6] writeback fixes - slow unmount and others Christoph Hellwig
2010-06-08 16:14 ` [PATCH 1/6] writeback: fix writeback completion notifications Christoph Hellwig
2010-06-08 19:50 ` Jens Axboe
2010-06-15 17:25 ` Jan Kara
2010-06-15 17:30 ` Christoph Hellwig
2010-06-08 16:14 ` Christoph Hellwig [this message]
2010-06-08 19:51 ` [PATCH 2/6] writeback: queue work on stack in writeback_inodes_sb Jens Axboe
2010-06-08 16:14 ` [PATCH 3/6] writeback: enforce s_umount locking " Christoph Hellwig
2010-06-15 17:54 ` Jan Kara
2010-06-15 17:59 ` Christoph Hellwig
2010-06-15 18:04 ` Jan Kara
2010-06-08 16:14 ` [PATCH 4/6] writeback: fix writeback_inodes_wb from writeback_inodes_sb Christoph Hellwig
2010-06-08 19:51 ` Jens Axboe
2010-06-09 12:25 ` Christoph Hellwig
2010-06-09 12:29 ` Jens Axboe
2010-06-08 16:15 ` [PATCH 5/6] writeback: simplify wakeup_flusher_threads Christoph Hellwig
2010-06-08 19:51 ` Jens Axboe
2010-06-08 16:15 ` [PATCH 6/6] writeback: simplify and split bdi_start_writeback Christoph Hellwig
2010-06-08 19:52 ` 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=20100608161443.GC11735@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=linux-fsdevel@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).