mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
btrfs: use slab for end_io_wq structures
The structure is frequently reused. Rename it according to the slab name. Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
af13b4922b
commit
97eb6b69d1
3 changed files with 38 additions and 10 deletions
|
@ -72,11 +72,11 @@ static int btrfs_cleanup_transaction(struct btrfs_root *root);
|
|||
static void btrfs_error_commit_super(struct btrfs_root *root);
|
||||
|
||||
/*
|
||||
* end_io_wq structs are used to do processing in task context when an IO is
|
||||
* complete. This is used during reads to verify checksums, and it is used
|
||||
* btrfs_end_io_wq structs are used to do processing in task context when an IO
|
||||
* is complete. This is used during reads to verify checksums, and it is used
|
||||
* by writes to insert metadata for new file extents after IO is complete.
|
||||
*/
|
||||
struct end_io_wq {
|
||||
struct btrfs_end_io_wq {
|
||||
struct bio *bio;
|
||||
bio_end_io_t *end_io;
|
||||
void *private;
|
||||
|
@ -87,6 +87,26 @@ struct end_io_wq {
|
|||
struct btrfs_work work;
|
||||
};
|
||||
|
||||
static struct kmem_cache *btrfs_end_io_wq_cache;
|
||||
|
||||
int __init btrfs_end_io_wq_init(void)
|
||||
{
|
||||
btrfs_end_io_wq_cache = kmem_cache_create("btrfs_end_io_wq",
|
||||
sizeof(struct btrfs_end_io_wq),
|
||||
0,
|
||||
SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
|
||||
NULL);
|
||||
if (!btrfs_end_io_wq_cache)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btrfs_end_io_wq_exit(void)
|
||||
{
|
||||
if (btrfs_end_io_wq_cache)
|
||||
kmem_cache_destroy(btrfs_end_io_wq_cache);
|
||||
}
|
||||
|
||||
/*
|
||||
* async submit bios are used to offload expensive checksumming
|
||||
* onto the worker threads. They checksum file and metadata bios
|
||||
|
@ -690,7 +710,7 @@ static int btree_io_failed_hook(struct page *page, int failed_mirror)
|
|||
|
||||
static void end_workqueue_bio(struct bio *bio, int err)
|
||||
{
|
||||
struct end_io_wq *end_io_wq = bio->bi_private;
|
||||
struct btrfs_end_io_wq *end_io_wq = bio->bi_private;
|
||||
struct btrfs_fs_info *fs_info;
|
||||
struct btrfs_workqueue *wq;
|
||||
btrfs_work_func_t func;
|
||||
|
@ -736,9 +756,9 @@ static void end_workqueue_bio(struct bio *bio, int err)
|
|||
int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
|
||||
enum btrfs_wq_endio_type metadata)
|
||||
{
|
||||
struct end_io_wq *end_io_wq;
|
||||
struct btrfs_end_io_wq *end_io_wq;
|
||||
|
||||
end_io_wq = kmalloc(sizeof(*end_io_wq), GFP_NOFS);
|
||||
end_io_wq = kmem_cache_alloc(btrfs_end_io_wq_cache, GFP_NOFS);
|
||||
if (!end_io_wq)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -1723,16 +1743,16 @@ static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
|
|||
static void end_workqueue_fn(struct btrfs_work *work)
|
||||
{
|
||||
struct bio *bio;
|
||||
struct end_io_wq *end_io_wq;
|
||||
struct btrfs_end_io_wq *end_io_wq;
|
||||
int error;
|
||||
|
||||
end_io_wq = container_of(work, struct end_io_wq, work);
|
||||
end_io_wq = container_of(work, struct btrfs_end_io_wq, work);
|
||||
bio = end_io_wq->bio;
|
||||
|
||||
error = end_io_wq->error;
|
||||
bio->bi_private = end_io_wq->private;
|
||||
bio->bi_end_io = end_io_wq->end_io;
|
||||
kfree(end_io_wq);
|
||||
kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq);
|
||||
bio_endio_nodec(bio, error);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue