From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: Josef Bacik <josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org>,
Chris Mason <clm-b10kYP2dOMg@public.gmane.org>,
David Sterba <dsterba-IBi9RG/b67k@public.gmane.org>
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Jens Axboe <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-btrfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 1/7] btrfs: move kthread_associate_blkcg out of btrfs_submit_compressed_write
Date: Mon, 27 Mar 2023 09:49:47 +0900 [thread overview]
Message-ID: <20230327004954.728797-2-hch@lst.de> (raw)
In-Reply-To: <20230327004954.728797-1-hch-jcswGhMUV9g@public.gmane.org>
btrfs_submit_compressed_write should not have to care if it is called
from a helper thread or not. Move the kthread_associate_blkcg handling
into submit_one_async_extent, as that is the one caller that needs it.
Also move the assignment of REQ_CGROUP_PUNT into cow_file_range_async,
as that is the routine that sets up the helper thread offload.
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
fs/btrfs/compression.c | 8 --------
fs/btrfs/compression.h | 1 -
fs/btrfs/inode.c | 12 ++++++++----
3 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 44c4276741ceda..d532a8c8c9d8c6 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -286,7 +286,6 @@ void btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
struct page **compressed_pages,
unsigned int nr_pages,
blk_opf_t write_flags,
- struct cgroup_subsys_state *blkcg_css,
bool writeback)
{
struct btrfs_fs_info *fs_info = inode->root->fs_info;
@@ -295,10 +294,6 @@ void btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
ASSERT(IS_ALIGNED(start, fs_info->sectorsize) &&
IS_ALIGNED(len, fs_info->sectorsize));
- if (blkcg_css) {
- kthread_associate_blkcg(blkcg_css);
- write_flags |= REQ_CGROUP_PUNT;
- }
write_flags |= REQ_BTRFS_ONE_ORDERED;
cb = alloc_compressed_bio(inode, start, REQ_OP_WRITE | write_flags,
@@ -314,9 +309,6 @@ void btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
btrfs_add_compressed_bio_pages(cb);
btrfs_submit_bio(&cb->bbio, 0);
-
- if (blkcg_css)
- kthread_associate_blkcg(NULL);
}
/*
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index 5d5146e72a860b..19ab2abeddc088 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -92,7 +92,6 @@ void btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
struct page **compressed_pages,
unsigned int nr_pages,
blk_opf_t write_flags,
- struct cgroup_subsys_state *blkcg_css,
bool writeback);
void btrfs_submit_compressed_read(struct btrfs_bio *bbio, int mirror_num);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 865d56ff2ce150..698915c032bddc 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1053,14 +1053,18 @@ static int submit_one_async_extent(struct btrfs_inode *inode,
extent_clear_unlock_delalloc(inode, start, end,
NULL, EXTENT_LOCKED | EXTENT_DELALLOC,
PAGE_UNLOCK | PAGE_START_WRITEBACK);
+
+ if (async_chunk->blkcg_css)
+ kthread_associate_blkcg(async_chunk->blkcg_css);
btrfs_submit_compressed_write(inode, start, /* file_offset */
async_extent->ram_size, /* num_bytes */
ins.objectid, /* disk_bytenr */
ins.offset, /* compressed_len */
async_extent->pages, /* compressed_pages */
async_extent->nr_pages,
- async_chunk->write_flags,
- async_chunk->blkcg_css, true);
+ async_chunk->write_flags, true);
+ if (async_chunk->blkcg_css)
+ kthread_associate_blkcg(NULL);
*alloc_hint = ins.objectid + ins.offset;
kfree(async_extent);
return ret;
@@ -1612,6 +1616,7 @@ static int cow_file_range_async(struct btrfs_inode *inode,
if (blkcg_css != blkcg_root_css) {
css_get(blkcg_css);
async_chunk[i].blkcg_css = blkcg_css;
+ async_chunk[i].write_flags |= REQ_CGROUP_PUNT;
} else {
async_chunk[i].blkcg_css = NULL;
}
@@ -10374,8 +10379,7 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
btrfs_delalloc_release_extents(inode, num_bytes);
btrfs_submit_compressed_write(inode, start, num_bytes, ins.objectid,
- ins.offset, pages, nr_pages, 0, NULL,
- false);
+ ins.offset, pages, nr_pages, 0, false);
ret = orig_count;
goto out;
--
2.39.2
next prev parent reply other threads:[~2023-03-27 0:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 0:49 move bio cgroup punting into btrfs Christoph Hellwig
[not found] ` <20230327004954.728797-1-hch-jcswGhMUV9g@public.gmane.org>
2023-03-27 0:49 ` Christoph Hellwig [this message]
2023-03-27 0:49 ` [PATCH 2/7] btrfs: don't free the async_extent in submit_uncompressed_range Christoph Hellwig
2023-03-27 0:49 ` [PATCH 5/7] btrfs, block: move REQ_CGROUP_PUNT to btrfs Christoph Hellwig
2023-03-28 1:15 ` Jens Axboe
2023-03-27 0:49 ` [PATCH 7/7] block: make blkcg_punt_bio_submit optional Christoph Hellwig
2023-03-27 23:32 ` Jens Axboe
2023-03-27 0:49 ` [PATCH 3/7] btrfs: also use kthread_associate_blkcg for uncompressible ranges Christoph Hellwig
2023-03-27 0:49 ` [PATCH 4/7] btrfs, mm: remove the punt_to_cgroup field in struct writeback_control Christoph Hellwig
2023-03-27 0:49 ` [PATCH 6/7] block: async_bio_lock does not need to be bh-safe Christoph Hellwig
2023-03-27 23:31 ` Jens Axboe
2023-03-27 23:18 ` move bio cgroup punting into btrfs David Sterba
[not found] ` <20230327231837.GK10580-1ReQVI26iDCaZKY3DrU6dA@public.gmane.org>
2023-03-31 17:25 ` David Sterba
2023-03-28 21:18 ` Chris Mason
[not found] ` <512eaacf-3ff6-f4f9-c856-a0e03c027501-M8Ki61LpUEw@public.gmane.org>
2023-03-28 23:34 ` Christoph Hellwig
2023-03-29 19:16 ` Tejun Heo
2023-03-30 0:15 ` Christoph Hellwig
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=20230327004954.728797-2-hch@lst.de \
--to=hch-jcswghmuv9g@public.gmane.org \
--cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=clm-b10kYP2dOMg@public.gmane.org \
--cc=dsterba-IBi9RG/b67k@public.gmane.org \
--cc=josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org \
--cc=linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-btrfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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).