linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET block/for-4.2/writeback] ext4: implement cgroup writeback support
@ 2015-06-12 22:02 Tejun Heo
  2015-06-12 22:02 ` [PATCH 1/2] ext4: replace ext4_io_submit->io_op with ->io_wbc Tejun Heo
  2015-06-12 22:02 ` [PATCH 2/2] ext4: implement cgroup writeback support Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Tejun Heo @ 2015-06-12 22:02 UTC (permalink / raw)
  To: axboe-tSWWG44O7X1aa/9Udqfwiw
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	lizefan-hv44wF8Li93QT0dZR+AlfA, cgroups-u79uwXL29TY76Z2rM5mHXA,
	tytso-3s7WtUTddSA, adilger.kernel-m1MBpc4rdrD3fQ9qLvQP4Q,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA

Hello,

This patchset implements cgroup writeback support for ext4, which is
enabled for writeback and ordered data modes.  This patchset contains
the following two patches.

 0001-ext4-replace-ext4_io_submit-io_op-with-io_wbc.patch
 0002-ext4-implement-cgroup-writeback-support.patch

0001 is a prep patch which replaces io_submit->io_op w/ ->io_wbc.
0002 implements cgroup writeback support.

This patchset is on top of

 [1] block/for-4.2/writeback
+[2] [PATCHSET] cgroup, writeback: misc updates for cgroup writeback support

and available on in the following git branch.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git review-cgroup-writeback-ext4

diffstat follows.  Thanks.

 fs/ext4/ext4.h    |    2 +-
 fs/ext4/page-io.c |    8 ++++++--
 fs/ext4/super.c   |    2 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

--
tejun

[1] git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-4.2/writeback
[2] http://lkml.kernel.org/g/1434146254-26220-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] ext4: replace ext4_io_submit->io_op with ->io_wbc
  2015-06-12 22:02 [PATCHSET block/for-4.2/writeback] ext4: implement cgroup writeback support Tejun Heo
@ 2015-06-12 22:02 ` Tejun Heo
  2015-06-12 22:02 ` [PATCH 2/2] ext4: implement cgroup writeback support Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2015-06-12 22:02 UTC (permalink / raw)
  To: axboe
  Cc: linux-kernel, linux-fsdevel, lizefan, cgroups, tytso,
	adilger.kernel, linux-ext4, Tejun Heo

ext4_io_submit_init() takes the pointer to writeback_control to test
its sync_mode and determine between WRITE and WRITE_SYNC and records
the result in ->io_op.  This patch makes it record the pointer
directly and moves the test to ext4_io_submit().

This doesn't cause any noticeable differences now but having
writeback_control available throughout IO submission path will be
depended upon by the planned cgroup writeback support.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: linux-ext4@vger.kernel.org
---
 fs/ext4/ext4.h    | 2 +-
 fs/ext4/page-io.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 009a059..74a4923 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -191,7 +191,7 @@ typedef struct ext4_io_end {
 } ext4_io_end_t;
 
 struct ext4_io_submit {
-	int			io_op;
+	struct writeback_control *io_wbc;
 	struct bio		*io_bio;
 	ext4_io_end_t		*io_end;
 	sector_t		io_next_block;
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index c5d81e8..3f80cb2 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -357,8 +357,10 @@ void ext4_io_submit(struct ext4_io_submit *io)
 	struct bio *bio = io->io_bio;
 
 	if (bio) {
+		int io_op = io->io_wbc->sync_mode == WB_SYNC_ALL ?
+			    WRITE_SYNC : WRITE;
 		bio_get(io->io_bio);
-		submit_bio(io->io_op, io->io_bio);
+		submit_bio(io_op, io->io_bio);
 		bio_put(io->io_bio);
 	}
 	io->io_bio = NULL;
@@ -367,7 +369,7 @@ void ext4_io_submit(struct ext4_io_submit *io)
 void ext4_io_submit_init(struct ext4_io_submit *io,
 			 struct writeback_control *wbc)
 {
-	io->io_op = (wbc->sync_mode == WB_SYNC_ALL ?  WRITE_SYNC : WRITE);
+	io->io_wbc = wbc;
 	io->io_bio = NULL;
 	io->io_end = NULL;
 }
-- 
2.4.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ext4: implement cgroup writeback support
  2015-06-12 22:02 [PATCHSET block/for-4.2/writeback] ext4: implement cgroup writeback support Tejun Heo
  2015-06-12 22:02 ` [PATCH 1/2] ext4: replace ext4_io_submit->io_op with ->io_wbc Tejun Heo
@ 2015-06-12 22:02 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2015-06-12 22:02 UTC (permalink / raw)
  To: axboe
  Cc: linux-kernel, linux-fsdevel, lizefan, cgroups, tytso,
	adilger.kernel, linux-ext4, Tejun Heo

For ordered and writeback data modes, all data IOs go through
ext4_io_submit.  This patch adds cgroup writeback support by invoking
wbc_init_bio() from io_submit_init_bio() and wbc_account_io() in
io_submit_add_bh().  Journal data which is written by jbd2 worker is
left alone by this patch and will always be written out from the root
cgroup.

ext4_fill_super() is updated to set MS_CGROUPWB when data mode is
either ordered or writeback.  In journaled data mode, most IOs become
synchronous through the journal and enabling cgroup writeback support
doesn't make much sense or difference.  Journaled data mode is left
alone.

Lightly tested with sequential data write workload.  Behaves as
expected.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: linux-ext4@vger.kernel.org
---
 fs/ext4/page-io.c | 2 ++
 fs/ext4/super.c   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 3f80cb2..c56ba7b 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -383,6 +383,7 @@ static int io_submit_init_bio(struct ext4_io_submit *io,
 	bio = bio_alloc(GFP_NOIO, min(nvecs, BIO_MAX_PAGES));
 	if (!bio)
 		return -ENOMEM;
+	wbc_init_bio(io->io_wbc, bio);
 	bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
 	bio->bi_bdev = bh->b_bdev;
 	bio->bi_end_io = ext4_end_bio;
@@ -411,6 +412,7 @@ static int io_submit_add_bh(struct ext4_io_submit *io,
 	ret = bio_add_page(io->io_bio, page, bh->b_size, bh_offset(bh));
 	if (ret != bh->b_size)
 		goto submit_and_retry;
+	wbc_account_io(io->io_wbc, page, bh->b_size);
 	io->io_next_block++;
 	return 0;
 }
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 56b8bb7..a9a3de3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3623,6 +3623,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		}
 		if (test_opt(sb, DELALLOC))
 			clear_opt(sb, DELALLOC);
+	} else {
+		sb->s_flags |= MS_CGROUPWB;
 	}
 
 	sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
-- 
2.4.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-12 22:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 22:02 [PATCHSET block/for-4.2/writeback] ext4: implement cgroup writeback support Tejun Heo
2015-06-12 22:02 ` [PATCH 1/2] ext4: replace ext4_io_submit->io_op with ->io_wbc Tejun Heo
2015-06-12 22:02 ` [PATCH 2/2] ext4: implement cgroup writeback support Tejun Heo

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).