Re: [PATCH] buffer: Associate the meta bio with blkg from buffer page

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

 



Hi, Tejun!

在 2024/08/31 3:37, Tejun Heo 写道:
Hello, Haifeng.

On Wed, Aug 28, 2024 at 11:32:24AM +0800, Haifeng Xu wrote:
...
The filesystem is ext4(ordered). The meta data can be written out by
writeback, but if there are too many dirty pages, we had to do
checkpoint to write out the meta data in current thread context.

In this case, the blkg of thread1 has set io.max, so the j_checkpoint_mutex
can't be released and many threads must wait for it. However, the blkg from
buffer page didn' set any io policy. Therefore, for the meta buffer head,
we can associate the bio with blkg from the buffer page instead of current
thread context.

Signed-off-by: Haifeng Xu <haifeng.xu@xxxxxxxxxx>
---
  fs/buffer.c | 11 +++++++++++
  1 file changed, 11 insertions(+)

diff --git a/fs/buffer.c b/fs/buffer.c
index e55ad471c530..a7889f258d0d 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2819,6 +2819,17 @@ static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
  	if (wbc) {
  		wbc_init_bio(wbc, bio);
  		wbc_account_cgroup_owner(wbc, bh->b_page, bh->b_size);
+	} else if (buffer_meta(bh)) {
+		struct folio *folio;
+		struct cgroup_subsys_state *memcg_css, *blkcg_css;
+
+		folio = page_folio(bh->b_page);
+		memcg_css = mem_cgroup_css_from_folio(folio);
+		if (cgroup_subsys_on_dfl(memory_cgrp_subsys) &&
+		    cgroup_subsys_on_dfl(io_cgrp_subsys)) {
+			blkcg_css = cgroup_e_css(memcg_css->cgroup, &io_cgrp_subsys);
+			bio_associate_blkg_from_css(bio, blkcg_css);

I think the right way to do it is marking the bio with REQ_META and
implement forced charging in blk-throtl similar to blk-iocost.

This is the exact thing I did in the code I attached in the other
thread, do you take a look?

https://lore.kernel.org/all/97fc38e6-a226-5e22-efc2-4405beb6d75b@xxxxxxxxxxxxxxx/

Thanks,
Kuai

Thanks.






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

  Powered by Linux