drop ensure-entering-into-panic-after-recording-an-error-in-superblock
[ext4-patch-queue.git] / implement-cgroup-writeback-support
blobee43e70700d4f55c46a9c47bf08f8722d76c879f
1 ext4: implement cgroup writeback support
3 From: Tejun Heo <tj@kernel.org>
5 For ordered and writeback data modes, all data IOs go through
6 ext4_io_submit.  This patch adds cgroup writeback support by invoking
7 wbc_init_bio() from io_submit_init_bio() and wbc_account_io() in
8 io_submit_add_bh().  Journal data which is written by jbd2 worker is
9 left alone by this patch and will always be written out from the root
10 cgroup.
12 ext4_fill_super() is updated to set MS_CGROUPWB when data mode is
13 either ordered or writeback.  In journaled data mode, most IOs become
14 synchronous through the journal and enabling cgroup writeback support
15 doesn't make much sense or difference.  Journaled data mode is left
16 alone.
18 Lightly tested with sequential data write workload.  Behaves as
19 expected.
21 Signed-off-by: Tejun Heo <tj@kernel.org>
22 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
23 ---
24  fs/ext4/page-io.c | 2 ++
25  fs/ext4/super.c   | 2 ++
26  2 files changed, 4 insertions(+)
28 diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
29 index 3f80cb2..c56ba7b 100644
30 --- a/fs/ext4/page-io.c
31 +++ b/fs/ext4/page-io.c
32 @@ -383,6 +383,7 @@ static int io_submit_init_bio(struct ext4_io_submit *io,
33         bio = bio_alloc(GFP_NOIO, min(nvecs, BIO_MAX_PAGES));
34         if (!bio)
35                 return -ENOMEM;
36 +       wbc_init_bio(io->io_wbc, bio);
37         bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
38         bio->bi_bdev = bh->b_bdev;
39         bio->bi_end_io = ext4_end_bio;
40 @@ -411,6 +412,7 @@ static int io_submit_add_bh(struct ext4_io_submit *io,
41         ret = bio_add_page(io->io_bio, page, bh->b_size, bh_offset(bh));
42         if (ret != bh->b_size)
43                 goto submit_and_retry;
44 +       wbc_account_io(io->io_wbc, page, bh->b_size);
45         io->io_next_block++;
46         return 0;
47  }
48 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
49 index 56b8bb7..3ad1eb4 100644
50 --- a/fs/ext4/super.c
51 +++ b/fs/ext4/super.c
52 @@ -3623,6 +3623,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
53                 }
54                 if (test_opt(sb, DELALLOC))
55                         clear_opt(sb, DELALLOC);
56 +       } else {
57 +               sb->s_iflags |= SB_I_CGROUPWB;
58         }
60         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
61 -- 
62 2.4.3