summaryrefslogtreecommitdiff
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2019-10-04 02:57:22 +0200
committerDavid Sterba <dsterba@suse.com>2019-11-18 12:46:59 +0100
commit1e002351605db4f2fc4114cbb973d5aead72d006 (patch)
tree419e0e6d31355814df45e972df173869aa6bf399 /fs/btrfs/compression.c
parenta3bbd2a9ee3c08b60b3127843866bdc76757c24f (diff)
btrfs: compression: inline free_workspace
Replace indirect calls to free_workspace by switch and calls to the specific callbacks. This is mainly to get rid of the indirection due to spectre vulnerability mitigations. Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/compression.c')
-rw-r--r--fs/btrfs/compression.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 2a77c91c194b..b2342f99b093 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -912,7 +912,6 @@ fail:
const struct btrfs_compress_op btrfs_heuristic_compress = {
.workspace_manager = &heuristic_wsm,
- .free_workspace = free_heuristic_ws,
};
static const struct btrfs_compress_op * const btrfs_compress_op[] = {
@@ -939,6 +938,22 @@ static struct list_head *alloc_workspace(int type, unsigned int level)
}
}
+static void free_workspace(int type, struct list_head *ws)
+{
+ switch (type) {
+ case BTRFS_COMPRESS_NONE: return free_heuristic_ws(ws);
+ case BTRFS_COMPRESS_ZLIB: return zlib_free_workspace(ws);
+ case BTRFS_COMPRESS_LZO: return lzo_free_workspace(ws);
+ case BTRFS_COMPRESS_ZSTD: return zstd_free_workspace(ws);
+ default:
+ /*
+ * This can't happen, the type is validated several times
+ * before we get here.
+ */
+ BUG();
+ }
+}
+
static void btrfs_init_workspace_manager(int type)
{
const struct btrfs_compress_op *ops = btrfs_compress_op[type];
@@ -976,7 +991,7 @@ static void btrfs_cleanup_workspace_manager(int type)
while (!list_empty(&wsman->idle_ws)) {
ws = wsman->idle_ws.next;
list_del(ws);
- wsman->ops->free_workspace(ws);
+ free_workspace(type, ws);
atomic_dec(&wsman->total_ws);
}
}
@@ -1111,7 +1126,7 @@ void btrfs_put_workspace(int type, struct list_head *ws)
}
spin_unlock(ws_lock);
- wsm->ops->free_workspace(ws);
+ free_workspace(type, ws);
atomic_dec(total_ws);
wake:
cond_wake_up(ws_wait);