summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-03-14 15:28:54 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2017-03-17 19:49:26 -0800
commit3f4f3d4e3708b0f520044af9078b154fe09d2afd (patch)
treeed2b36bb8d970cfe0505e598b0c388d0baf42232
parented4774ace1debae84932b3b02e56d2d9f3e2a54f (diff)
bcachefs: use system_unbound_wq for decryption/decompression
this allows decryption/decompression to run on any available cpu
-rw-r--r--fs/bcachefs/bcache.h2
-rw-r--r--fs/bcachefs/compress.c18
-rw-r--r--fs/bcachefs/io.c43
-rw-r--r--fs/bcachefs/io.h2
-rw-r--r--fs/bcachefs/io_types.h9
5 files changed, 14 insertions, 60 deletions
diff --git a/fs/bcachefs/bcache.h b/fs/bcachefs/bcache.h
index dd9e3b8253ff..d32d092b459c 100644
--- a/fs/bcachefs/bcache.h
+++ b/fs/bcachefs/bcache.h
@@ -716,8 +716,6 @@ struct bch_fs {
void *zlib_workspace;
struct mutex zlib_workspace_lock;
mempool_t compression_bounce[2];
- struct bio_decompress_worker __percpu
- *bio_decompress_worker;
struct crypto_blkcipher *chacha20;
struct crypto_shash *poly1305;
diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c
index d6a345cb0dbe..8e2d3e55b596 100644
--- a/fs/bcachefs/compress.c
+++ b/fs/bcachefs/compress.c
@@ -443,7 +443,6 @@ void bch_fs_compress_exit(struct bch_fs *c)
mempool_exit(&c->lz4_workspace_pool);
mempool_exit(&c->compression_bounce[WRITE]);
mempool_exit(&c->compression_bounce[READ]);
- free_percpu(c->bio_decompress_worker);
}
#define COMPRESSION_WORKSPACE_SIZE \
@@ -453,22 +452,7 @@ void bch_fs_compress_exit(struct bch_fs *c)
int bch_fs_compress_init(struct bch_fs *c)
{
unsigned order = get_order(BCH_ENCODED_EXTENT_MAX << 9);
- int ret, cpu;
-
- if (!c->bio_decompress_worker) {
- c->bio_decompress_worker = alloc_percpu(*c->bio_decompress_worker);
- if (!c->bio_decompress_worker)
- return -ENOMEM;
-
- for_each_possible_cpu(cpu) {
- struct bio_decompress_worker *d =
- per_cpu_ptr(c->bio_decompress_worker, cpu);
-
- d->c = c;
- INIT_WORK(&d->work, bch_bio_decompress_work);
- init_llist_head(&d->bio_list);
- }
- }
+ int ret;
if (!bch_sb_test_feature(c->disk_sb, BCH_FEATURE_LZ4) &&
!bch_sb_test_feature(c->disk_sb, BCH_FEATURE_GZIP))
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index 636986498153..ddec3bfb1bbb 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -1036,8 +1036,11 @@ static void cache_promote_done(struct closure *cl)
}
/* Inner part that may run in process context */
-static void __bch_read_endio(struct bch_fs *c, struct bch_read_bio *rbio)
+static void __bch_read_endio(struct work_struct *work)
{
+ struct bch_read_bio *rbio =
+ container_of(work, struct bch_read_bio, work);
+ struct bch_fs *c = rbio->c;
int ret;
ret = bio_checksum_uncompress(c, rbio);
@@ -1074,24 +1077,6 @@ static void __bch_read_endio(struct bch_fs *c, struct bch_read_bio *rbio)
}
}
-void bch_bio_decompress_work(struct work_struct *work)
-{
- struct bio_decompress_worker *d =
- container_of(work, struct bio_decompress_worker, work);
- struct llist_node *list, *next;
- struct bch_read_bio *rbio;
-
- while ((list = llist_del_all(&d->bio_list)))
- for (list = llist_reverse_order(list);
- list;
- list = next) {
- next = llist_next(list);
- rbio = container_of(list, struct bch_read_bio, list);
-
- __bch_read_endio(d->c, rbio);
- }
-}
-
static void bch_read_endio(struct bio *bio)
{
struct bch_read_bio *rbio =
@@ -1120,18 +1105,13 @@ static void bch_read_endio(struct bio *bio)
return;
}
- if (rbio->crc.compression_type != BCH_COMPRESSION_NONE ||
- bch_csum_type_is_encryption(rbio->crc.csum_type)) {
- struct bio_decompress_worker *d;
-
- preempt_disable();
- d = this_cpu_ptr(c->bio_decompress_worker);
- llist_add(&rbio->list, &d->bio_list);
- queue_work(system_highpri_wq, &d->work);
- preempt_enable();
- } else {
- __bch_read_endio(c, rbio);
- }
+ if (rbio->crc.compression_type ||
+ bch_csum_type_is_encryption(rbio->crc.csum_type))
+ queue_work(system_unbound_wq, &rbio->work);
+ else if (rbio->crc.csum_type)
+ queue_work(system_highpri_wq, &rbio->work);
+ else
+ __bch_read_endio(&rbio->work);
}
static bool should_promote(struct bch_fs *c,
@@ -1260,6 +1240,7 @@ void bch_read_extent_iter(struct bch_fs *c, struct bch_read_bio *orig,
rbio->version = k.k->version;
rbio->promote = promote_op;
rbio->inode = k.k->p.inode;
+ INIT_WORK(&rbio->work, __bch_read_endio);
rbio->bio.bi_bdev = pick->ca->disk_sb.bdev;
rbio->bio.bi_opf = orig->bio.bi_opf;
diff --git a/fs/bcachefs/io.h b/fs/bcachefs/io.h
index 975951a84dbc..3d2d81fca297 100644
--- a/fs/bcachefs/io.h
+++ b/fs/bcachefs/io.h
@@ -86,6 +86,4 @@ int bch_discard(struct bch_fs *, struct bpos, struct bpos,
void bch_read_retry_work(struct work_struct *);
void bch_wake_delayed_writes(unsigned long data);
-void bch_bio_decompress_work(struct work_struct *);
-
#endif /* _BCACHE_IO_H */
diff --git a/fs/bcachefs/io_types.h b/fs/bcachefs/io_types.h
index 73d18e361ecc..ca1b0192fad0 100644
--- a/fs/bcachefs/io_types.h
+++ b/fs/bcachefs/io_types.h
@@ -51,8 +51,7 @@ struct bch_read_bio {
*/
u64 inode;
- /* bio_decompress_worker list */
- struct llist_node list;
+ struct work_struct work;
struct bio bio;
};
@@ -143,10 +142,4 @@ struct bch_write_op {
u64 inline_keys[BKEY_EXTENT_U64s_MAX * 2];
};
-struct bio_decompress_worker {
- struct bch_fs *c;
- struct work_struct work;
- struct llist_head bio_list;
-};
-
#endif /* _BCACHE_IO_TYPES_H */