Skip to content

Commit c489db0

Browse files
adam900710kdave
authored andcommitted
btrfs: remove btrfs_fs_info::compressed_write_workers
The reason why end_bbio_compressed_write() queues a work into compressed_write_workers wq is for end_compressed_writeback() call, as it will grab all the involved folioes and clear the writeback flags, which may sleep. However now we always run btrfs_bio::end_io() in task context, there is no need to queue the work anymore. Just remove btrfs_fs_info::compressed_write_workers and compressed_bio::write_end_work. There is a comment about the works queued into compressed_write_workers, now change to flush endio wq instead, which is responsible to handle all data endio functions. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 7836dbb commit c489db0

File tree

4 files changed

+12
-32
lines changed

4 files changed

+12
-32
lines changed

fs/btrfs/compression.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -319,22 +319,6 @@ static noinline void end_compressed_writeback(const struct compressed_bio *cb)
319319
/* the inode may be gone now */
320320
}
321321

322-
static void btrfs_finish_compressed_write_work(struct work_struct *work)
323-
{
324-
struct compressed_bio *cb =
325-
container_of(work, struct compressed_bio, write_end_work);
326-
327-
btrfs_finish_ordered_extent(cb->bbio.ordered, NULL, cb->start, cb->len,
328-
cb->bbio.bio.bi_status == BLK_STS_OK);
329-
330-
if (cb->writeback)
331-
end_compressed_writeback(cb);
332-
/* Note, our inode could be gone now */
333-
334-
btrfs_free_compressed_folios(cb);
335-
bio_put(&cb->bbio.bio);
336-
}
337-
338322
/*
339323
* Do the cleanup once all the compressed pages hit the disk. This will clear
340324
* writeback on the file pages and free the compressed pages.
@@ -345,9 +329,15 @@ static void btrfs_finish_compressed_write_work(struct work_struct *work)
345329
static void end_bbio_compressed_write(struct btrfs_bio *bbio)
346330
{
347331
struct compressed_bio *cb = to_compressed_bio(bbio);
348-
struct btrfs_fs_info *fs_info = bbio->inode->root->fs_info;
349332

350-
queue_work(fs_info->compressed_write_workers, &cb->write_end_work);
333+
btrfs_finish_ordered_extent(cb->bbio.ordered, NULL, cb->start, cb->len,
334+
cb->bbio.bio.bi_status == BLK_STS_OK);
335+
336+
if (cb->writeback)
337+
end_compressed_writeback(cb);
338+
/* Note, our inode could be gone now */
339+
btrfs_free_compressed_folios(cb);
340+
bio_put(&cb->bbio.bio);
351341
}
352342

353343
static void btrfs_add_compressed_bio_folios(struct compressed_bio *cb)
@@ -400,7 +390,6 @@ void btrfs_submit_compressed_write(struct btrfs_ordered_extent *ordered,
400390
cb->compressed_folios = compressed_folios;
401391
cb->compressed_len = ordered->disk_num_bytes;
402392
cb->writeback = writeback;
403-
INIT_WORK(&cb->write_end_work, btrfs_finish_compressed_write_work);
404393
cb->nr_folios = nr_folios;
405394
cb->bbio.bio.bi_iter.bi_sector = ordered->disk_bytenr >> SECTOR_SHIFT;
406395
cb->bbio.ordered = ordered;

fs/btrfs/compression.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@ struct compressed_bio {
6363
/* Whether this is a write for writeback. */
6464
bool writeback;
6565

66-
union {
67-
/* For reads, this is the bio we are copying the data into */
68-
struct btrfs_bio *orig_bbio;
69-
struct work_struct write_end_work;
70-
};
66+
/* For reads, this is the bio we are copying the data into */
67+
struct btrfs_bio *orig_bbio;
7168

7269
/* Must be last. */
7370
struct btrfs_bio bbio;

fs/btrfs/disk-io.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,8 +1774,6 @@ static void btrfs_stop_all_workers(struct btrfs_fs_info *fs_info)
17741774
destroy_workqueue(fs_info->endio_workers);
17751775
if (fs_info->rmw_workers)
17761776
destroy_workqueue(fs_info->rmw_workers);
1777-
if (fs_info->compressed_write_workers)
1778-
destroy_workqueue(fs_info->compressed_write_workers);
17791777
btrfs_destroy_workqueue(fs_info->endio_write_workers);
17801778
btrfs_destroy_workqueue(fs_info->endio_freespace_worker);
17811779
btrfs_destroy_workqueue(fs_info->delayed_workers);
@@ -1987,8 +1985,6 @@ static int btrfs_init_workqueues(struct btrfs_fs_info *fs_info)
19871985
fs_info->endio_write_workers =
19881986
btrfs_alloc_workqueue(fs_info, "endio-write", flags,
19891987
max_active, 2);
1990-
fs_info->compressed_write_workers =
1991-
alloc_workqueue("btrfs-compressed-write", flags, max_active);
19921988
fs_info->endio_freespace_worker =
19931989
btrfs_alloc_workqueue(fs_info, "freespace-write", flags,
19941990
max_active, 0);
@@ -2004,7 +2000,6 @@ static int btrfs_init_workqueues(struct btrfs_fs_info *fs_info)
20042000
if (!(fs_info->workers &&
20052001
fs_info->delalloc_workers && fs_info->flush_workers &&
20062002
fs_info->endio_workers && fs_info->endio_meta_workers &&
2007-
fs_info->compressed_write_workers &&
20082003
fs_info->endio_write_workers &&
20092004
fs_info->endio_freespace_worker && fs_info->rmw_workers &&
20102005
fs_info->caching_workers && fs_info->fixup_workers &&
@@ -4291,15 +4286,15 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
42914286

42924287
/*
42934288
* When finishing a compressed write bio we schedule a work queue item
4294-
* to finish an ordered extent - btrfs_finish_compressed_write_work()
4289+
* to finish an ordered extent - end_bbio_compressed_write()
42954290
* calls btrfs_finish_ordered_extent() which in turns does a call to
42964291
* btrfs_queue_ordered_fn(), and that queues the ordered extent
42974292
* completion either in the endio_write_workers work queue or in the
42984293
* fs_info->endio_freespace_worker work queue. We flush those queues
42994294
* below, so before we flush them we must flush this queue for the
43004295
* workers of compressed writes.
43014296
*/
4302-
flush_workqueue(fs_info->compressed_write_workers);
4297+
flush_workqueue(fs_info->endio_workers);
43034298

43044299
/*
43054300
* After we parked the cleaner kthread, ordered extents may have

fs/btrfs/fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,6 @@ struct btrfs_fs_info {
654654
struct workqueue_struct *endio_workers;
655655
struct workqueue_struct *endio_meta_workers;
656656
struct workqueue_struct *rmw_workers;
657-
struct workqueue_struct *compressed_write_workers;
658657
struct btrfs_workqueue *endio_write_workers;
659658
struct btrfs_workqueue *endio_freespace_worker;
660659
struct btrfs_workqueue *caching_workers;

0 commit comments

Comments
 (0)