linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	lizefan@huawei.com, cgroups@vger.kernel.org, hannes@cmpxchg.org,
	kernel-team@fb.com, tytso@mit.edu, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 2/2] ext4: implement cgroup writeback support
Date: Tue, 16 Jun 2015 18:53:13 -0400	[thread overview]
Message-ID: <1434495193-31182-3-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1434495193-31182-1-git-send-email-tj@kernel.org>

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.

v2: Updated for MS_CGROUPWB -> SB_I_CGROUPWB.

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..3ad1eb4 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_iflags |= SB_I_CGROUPWB;
 	}
 
 	sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
-- 
2.4.3

  parent reply	other threads:[~2015-06-16 22:53 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-16 22:53 [PATCHSET v2 block/for-4.2/writeback] ext4: implement cgroup writeback support Tejun Heo
2015-06-16 22:53 ` [PATCH 1/2] ext4: replace ext4_io_submit->io_op with ->io_wbc Tejun Heo
     [not found]   ` <1434495193-31182-2-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-22  3:56     ` Theodore Ts'o
2015-06-16 22:53 ` Tejun Heo [this message]
     [not found]   ` <1434495193-31182-3-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-22  3:56     ` [PATCH 2/2] ext4: implement cgroup writeback support Theodore Ts'o
2015-09-23 12:49       ` Artem Bityutskiy
2015-09-23 13:50         ` Artem Bityutskiy
2015-09-23 17:02           ` Theodore Ts'o
2015-09-23 17:57             ` Tejun Heo
2015-09-23 17:25         ` Chris Mason
     [not found]           ` <CAF4G-tKEcnVw76-ZU77AjmBDGybLnNEOKjkJtYBN67es0wb30g@mail.gmail.com>
2015-09-23 17:53             ` Chris Mason
2015-09-23 18:24               ` Theodore Ts'o
     [not found]                 ` <CAF4G-t+E89a_A3RzQYB9wXxqE6nM0t7wN6fNmLABZ70=ivHTRQ@mail.gmail.com>
     [not found]                   ` <CAF4G-t+E89a_A3RzQYB9wXxqE6nM0t7wN6fNmLABZ70=ivHTRQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-23 19:47                     ` Artem Bityutskiy
2015-09-23 20:48                       ` Theodore Ts'o
2015-09-24  8:13                         ` Artem Bityutskiy
     [not found]             ` <CAF4G-tKEcnVw76-ZU77AjmBDGybLnNEOKjkJtYBN67es0wb30g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-23 19:03               ` Tejun Heo
     [not found]         ` <1443012552.19983.209.camel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-23 18:09           ` Tejun Heo
     [not found]             ` <20150923180934.GE26647-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-09-23 18:51               ` Tejun Heo
2015-09-23 21:07                 ` [PATCH cgroup/for-4.3-fixes] cgroup, writeback: don't enable cgroup writeback on traditional hierarchies Tejun Heo
2015-09-24  8:09                   ` Artem Bityutskiy
     [not found]                     ` <1443082186.19983.234.camel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-24  8:40                       ` Dexuan Cui
     [not found]                         ` <d6cf09f352a84b8d811da55fbc64a869-NHRYisGuqk8ni+flWUsx/pbBmlrREI7+ECdVDZe1NQc@public.gmane.org>
2015-09-24 20:47                           ` Tejun Heo
2015-09-28 21:39                             ` Tejun Heo
2015-09-24 20:45                       ` Tejun Heo
2015-09-25  6:49                         ` Artem Bityutskiy
     [not found]                           ` <1443163749.19983.254.camel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-25 10:50                             ` Artem Bityutskiy
2015-09-25 15:49                               ` Tejun Heo
2015-09-26  8:06                                 ` Artem Bityutskiy
2015-09-26 22:14                                   ` Tejun Heo
     [not found]                                     ` <20150926221413.GI3572-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2015-09-29 11:37                                       ` Artem Bityutskiy
2015-09-29 14:26                                         ` Tejun Heo
     [not found]                   ` <20150923210729.GA23180-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-09-24 16:17                     ` Jens Axboe
2015-09-24 20:48                   ` Tejun Heo
2015-07-12 18:05 ` [PATCHSET v2 block/for-4.2/writeback] ext4: implement cgroup writeback support Tejun Heo
     [not found]   ` <20150712180520.GE18734-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-07-16 19:40     ` Tejun Heo
2015-07-16 23:21       ` Dave Chinner
2015-07-16 23:37         ` Tejun Heo
2015-07-17  1:37     ` Theodore Ts'o
2015-07-17 15:20       ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2015-06-12 22:02 [PATCHSET " Tejun Heo
2015-06-12 22:02 ` [PATCH 2/2] " Tejun Heo

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=1434495193-31182-3-git-send-email-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=tytso@mit.edu \
    /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).