mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 11:19:37 +00:00
![Philippe Liard](/assets/img/avatar_default.png)
ll_rw_block() function has been deprecated in favor of BIO which appears to come with large performance improvements. This patch decreases boot time by close to 40% when using squashfs for the root file-system. This is observed at least in the context of starting an Android VM on Chrome OS using crosvm. The patch was tested on 4.19 as well as master. This patch is largely based on Adrien Schildknecht's patch that was originally sent as https://lkml.org/lkml/2017/9/22/814 though with some significant changes and simplifications while also taking Phillip Lougher's feedback into account, around preserving support for FILE_CACHE in particular. [akpm@linux-foundation.org: fix build error reported by Randy] Link: http://lkml.kernel.org/r/319997c2-5fc8-f889-2ea3-d913308a7c1f@infradead.org Signed-off-by: Philippe Liard <pliard@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Adrien Schildknecht <adrien+dev@schischi.me> Cc: Phillip Lougher <phillip@squashfs.org.uk> Cc: Guenter Roeck <groeck@chromium.org> Cc: Daniel Rosenberg <drosen@google.com> Link: https://chromium.googlesource.com/chromiumos/platform/crosvm Link: http://lkml.kernel.org/r/20191106074238.186023-1-pliard@google.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
84 lines
1.7 KiB
C
84 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (c) 2013
|
|
* Phillip Lougher <phillip@squashfs.org.uk>
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/bio.h>
|
|
|
|
#include "squashfs_fs.h"
|
|
#include "squashfs_fs_sb.h"
|
|
#include "decompressor.h"
|
|
#include "squashfs.h"
|
|
|
|
/*
|
|
* This file implements single-threaded decompression in the
|
|
* decompressor framework
|
|
*/
|
|
|
|
struct squashfs_stream {
|
|
void *stream;
|
|
struct mutex mutex;
|
|
};
|
|
|
|
void *squashfs_decompressor_create(struct squashfs_sb_info *msblk,
|
|
void *comp_opts)
|
|
{
|
|
struct squashfs_stream *stream;
|
|
int err = -ENOMEM;
|
|
|
|
stream = kmalloc(sizeof(*stream), GFP_KERNEL);
|
|
if (stream == NULL)
|
|
goto out;
|
|
|
|
stream->stream = msblk->decompressor->init(msblk, comp_opts);
|
|
if (IS_ERR(stream->stream)) {
|
|
err = PTR_ERR(stream->stream);
|
|
goto out;
|
|
}
|
|
|
|
kfree(comp_opts);
|
|
mutex_init(&stream->mutex);
|
|
return stream;
|
|
|
|
out:
|
|
kfree(stream);
|
|
return ERR_PTR(err);
|
|
}
|
|
|
|
void squashfs_decompressor_destroy(struct squashfs_sb_info *msblk)
|
|
{
|
|
struct squashfs_stream *stream = msblk->stream;
|
|
|
|
if (stream) {
|
|
msblk->decompressor->free(stream->stream);
|
|
kfree(stream);
|
|
}
|
|
}
|
|
|
|
int squashfs_decompress(struct squashfs_sb_info *msblk, struct bio *bio,
|
|
int offset, int length,
|
|
struct squashfs_page_actor *output)
|
|
{
|
|
int res;
|
|
struct squashfs_stream *stream = msblk->stream;
|
|
|
|
mutex_lock(&stream->mutex);
|
|
res = msblk->decompressor->decompress(msblk, stream->stream, bio,
|
|
offset, length, output);
|
|
mutex_unlock(&stream->mutex);
|
|
|
|
if (res < 0)
|
|
ERROR("%s decompression failed, data probably corrupt\n",
|
|
msblk->decompressor->name);
|
|
|
|
return res;
|
|
}
|
|
|
|
int squashfs_max_decompressors(void)
|
|
{
|
|
return 1;
|
|
}
|