From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Mason Subject: [PATCH] fs: add bdi_start_writeback(), bdi_start_writeback_if_idle() Date: Wed, 27 Oct 2010 07:59:07 -0400 Message-ID: <20101027115907.GD27796@think> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: axboe@kernel.dk To: linux-fsdevel@vger.kernel.org Return-path: Received: from rcsinet10.oracle.com ([148.87.113.121]:59290 "EHLO rcsinet10.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759948Ab0J0MAb (ORCPT ); Wed, 27 Oct 2010 08:00:31 -0400 Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Btrfs ENOSPC support requires us to know how many bytes we have delalloc in the FS and also how much metadata we'll need to allocate the file extents and update the file to point to the new extents. When things get out of hand, we start writing delalloc inodes so that we don't have massive amounts of space reserved to service delalloc. The bdi flusher threads already export a synchronous way to kick writeback for ext4, but this isn't quite right for btrfs because it writes everything dirty and isn't async. So, what does everyone think about: fs: add bdi_start_writeback(), bdi_start_writeback_if_idle() filesystems need more ways to get the flusher threads active. This exports bdi_start_writeback so that we can asynchronously kick the flushers into action. Btrfs will use this to make progress on the pending delayed allocation writes regardless of the current dirty memory thresholds. Signed-off-by: Chris Mason --- fs/fs-writeback.c | 11 +++++++++++ include/linux/backing-dev.h | 1 + 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index ab38fef..c5514e8 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -141,6 +141,17 @@ void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages) { __bdi_start_writeback(bdi, nr_pages, true, false); } +EXPORT_SYMBOL(bdi_start_writeback); + +int bdi_start_writeback_if_idle(struct backing_dev_info *bdi, long nr_pages) +{ + if (!writeback_in_progress(bdi)) { + bdi_start_writeback(bdi, nr_pages); + return 1; + } + return 0; +} +EXPORT_SYMBOL(bdi_start_writeback_if_idle); /** * bdi_start_background_writeback - start background writeback diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 35b0074..10607e8 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -103,6 +103,7 @@ int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); void bdi_unregister(struct backing_dev_info *bdi); int bdi_setup_and_register(struct backing_dev_info *, char *, unsigned int); void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages); +int bdi_start_writeback_if_idle(struct backing_dev_info *bdi, long nr_pages); void bdi_start_background_writeback(struct backing_dev_info *bdi); int bdi_writeback_thread(void *data); int bdi_has_dirty_io(struct backing_dev_info *bdi); -- 1.7.1.1