[PATCH] fs: add bdi_start_writeback(), bdi_start_writeback_if_idle()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <chris.mason@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux