diff options
| author | Mister Oyster <oysterized@gmail.com> | 2017-09-25 20:19:42 +0200 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-09-25 20:26:42 +0200 |
| commit | 6f44eca8c982bcebea87cca776193ddefa062a6f (patch) | |
| tree | f02bf8685a31f9fbe98777315f3a56cba28d24b4 /drivers/block | |
| parent | 6b5d7677388995ef417e80efe14795a8284687c4 (diff) | |
Revert zram updates to merge 4.1 drivers
Revert "zram: do not use copy_page with non-page aligned address"
This reverts commit ed3e8707d2e19d6da506d8ab298e68e79b6621f2.
Revert "zram: sym permissions -> octal perm (checkpath warnings)"
This reverts commit 920095f4566b901834f9b41395968b739b402d4c.
Revert "zram: fix indents/warnings from checkpath"
This reverts commit 0a2fdee5446969c8c70bbdc9f8fde93eb1d47327.
Revert "UPSTREAM: zram/zcomp: do not zero out zcomp private pages"
This reverts commit d13c0c08323df29367affc7b7623d9d2d0ccfbb2.
Revert "UPSTREAM: zram: pass gfp from zcomp frontend to backend"
This reverts commit 6d22d73c07a0f2ffe706e88c302d52371ad29206.
Revert "UPSTREAM: zram: try vmalloc() after kmalloc()"
This reverts commit e6af82ad8a5599a783e9850aca8f1b32fc1f93f4.
Revert "UPSTREAM: zram/zcomp: use GFP_NOIO to allocate streams"
This reverts commit 38e34f1f6f1c9ee9c7f3958fcb35e72174337690.
Revert "zram: Fix a wrong return after merged new LZ4 version"
This reverts commit 7832ce6d8a006747a4c27840b4f7e7d3c12f0dbb.
Revert "zram: change usage of LZ4 to work with new LZ4 version"
This reverts commit 56622e86d4356054aad833aa8547992fdb76e4e3.
Revert "zram: avoid lockdep splat by revalidate_disk"
This reverts commit 149cadf4d8043f55a0d92cacc4b3d3d9cfb75148.
Revert "zram: revalidate disk after capacity change"
This reverts commit 270bdcb8d33f5c4769edab61f33f2fe43c8636f8.
Diffstat (limited to 'drivers/block')
| -rw-r--r-- | drivers/block/zram/zcomp.c | 29 | ||||
| -rw-r--r-- | drivers/block/zram/zcomp_lz4.c | 23 | ||||
| -rw-r--r-- | drivers/block/zram/zcomp_lzo.c | 15 | ||||
| -rw-r--r-- | drivers/block/zram/zram_drv.c | 39 |
4 files changed, 25 insertions, 81 deletions
diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c index 4781eab83..6a7692281 100644 --- a/drivers/block/zram/zcomp.c +++ b/drivers/block/zram/zcomp.c @@ -54,7 +54,6 @@ static struct zcomp_backend *backends[] = { static struct zcomp_backend *find_backend(const char *compress) { int i = 0; - while (backends[i]) { if (sysfs_streq(compress, backends[i]->name)) break; @@ -75,19 +74,18 @@ static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm) * allocate new zcomp_strm structure with ->private initialized by * backend, return NULL on error */ -static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp, gfp_t flags) +static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp) { - struct zcomp_strm *zstrm = kmalloc(sizeof(*zstrm), flags); - + struct zcomp_strm *zstrm = kmalloc(sizeof(*zstrm), GFP_KERNEL); if (!zstrm) return NULL; - zstrm->private = comp->backend->create(flags); + zstrm->private = comp->backend->create(); /* * allocate 2 pages. 1 for compressed data, plus 1 extra for the * case when compressed size is larger than the original one */ - zstrm->buffer = (void *)__get_free_pages(flags | __GFP_ZERO, 1); + zstrm->buffer = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1); if (!zstrm->private || !zstrm->buffer) { zcomp_strm_free(comp, zstrm); zstrm = NULL; @@ -123,16 +121,7 @@ static struct zcomp_strm *zcomp_strm_multi_find(struct zcomp *comp) zs->avail_strm++; spin_unlock(&zs->strm_lock); - /* - * This function can be called in swapout/fs write path - * so we can't use GFP_FS|IO. And it assumes we already - * have at least one stream in zram initialization so we - * don't do best effort to allocate more stream in here. - * A default stream will work well without further multiple - * streams. That's why we use NORETRY | NOWARN. - */ - zstrm = zcomp_strm_alloc(comp, GFP_NOIO | __GFP_NORETRY | - __GFP_NOWARN); + zstrm = zcomp_strm_alloc(comp); if (!zstrm) { spin_lock(&zs->strm_lock); zs->avail_strm--; @@ -220,7 +209,7 @@ static int zcomp_strm_multi_create(struct zcomp *comp, int max_strm) zs->max_strm = max_strm; zs->avail_strm = 1; - zstrm = zcomp_strm_alloc(comp, GFP_KERNEL); + zstrm = zcomp_strm_alloc(comp); if (!zstrm) { kfree(zs); return -ENOMEM; @@ -232,7 +221,6 @@ static int zcomp_strm_multi_create(struct zcomp *comp, int max_strm) static struct zcomp_strm *zcomp_strm_single_find(struct zcomp *comp) { struct zcomp_strm_single *zs = comp->stream; - mutex_lock(&zs->strm_lock); return zs->zstrm; } @@ -241,7 +229,6 @@ static void zcomp_strm_single_release(struct zcomp *comp, struct zcomp_strm *zstrm) { struct zcomp_strm_single *zs = comp->stream; - mutex_unlock(&zs->strm_lock); } @@ -254,9 +241,7 @@ static bool zcomp_strm_single_set_max_streams(struct zcomp *comp, int num_strm) static void zcomp_strm_single_destroy(struct zcomp *comp) { struct zcomp_strm_single *zs = comp->stream; - zcomp_strm_free(comp, zs->zstrm); - kfree(zs); } @@ -274,7 +259,7 @@ static int zcomp_strm_single_create(struct zcomp *comp) comp->stream = zs; mutex_init(&zs->strm_lock); - zs->zstrm = zcomp_strm_alloc(comp, GFP_KERNEL); + zs->zstrm = zcomp_strm_alloc(comp); if (!zs->zstrm) { kfree(zs); return -ENOMEM; diff --git a/drivers/block/zram/zcomp_lz4.c b/drivers/block/zram/zcomp_lz4.c index 387c76071..f2afb7e98 100644 --- a/drivers/block/zram/zcomp_lz4.c +++ b/drivers/block/zram/zcomp_lz4.c @@ -10,35 +10,24 @@ #include <linux/kernel.h> #include <linux/slab.h> #include <linux/lz4.h> -#include <linux/vmalloc.h> -#include <linux/mm.h> #include "zcomp_lz4.h" -static void *zcomp_lz4_create(gfp_t flags) +static void *zcomp_lz4_create(void) { - void *ret; - - ret = kmalloc(LZ4_MEM_COMPRESS, flags); - if (!ret) - ret = __vmalloc(LZ4_MEM_COMPRESS, - flags | __GFP_HIGHMEM, - PAGE_KERNEL); - return ret; + return kzalloc(LZ4_MEM_COMPRESS, GFP_KERNEL); } static void zcomp_lz4_destroy(void *private) { - kvfree(private); + kfree(private); } static int zcomp_lz4_compress(const unsigned char *src, unsigned char *dst, size_t *dst_len, void *private) { - /* return : Failed if return 0 */ - if (!LZ4_compress_default(src, dst, PAGE_SIZE, *dst_len, private)) - return -EIO; - return 0; + /* return : Success if return 0 */ + return lz4_compress(src, PAGE_SIZE, dst, dst_len, private); } static int zcomp_lz4_decompress(const unsigned char *src, size_t src_len, @@ -46,7 +35,7 @@ static int zcomp_lz4_decompress(const unsigned char *src, size_t src_len, { size_t dst_len = PAGE_SIZE; /* return : Success if return 0 */ - return LZ4_decompress_safe(src, dst, src_len, dst_len); + return lz4_decompress_unknownoutputsize(src, src_len, dst, &dst_len); } struct zcomp_backend zcomp_lz4 = { diff --git a/drivers/block/zram/zcomp_lzo.c b/drivers/block/zram/zcomp_lzo.c index 2029ee4ab..da1bc47d5 100644 --- a/drivers/block/zram/zcomp_lzo.c +++ b/drivers/block/zram/zcomp_lzo.c @@ -10,26 +10,17 @@ #include <linux/kernel.h> #include <linux/slab.h> #include <linux/lzo.h> -#include <linux/vmalloc.h> -#include <linux/mm.h> #include "zcomp_lzo.h" -static void *lzo_create(gfp_t flags) +static void *lzo_create(void) { - void *ret; - - ret = kmalloc(LZO1X_MEM_COMPRESS, flags); - if (!ret) - ret = __vmalloc(LZO1X_MEM_COMPRESS, - flags | __GFP_HIGHMEM, - PAGE_KERNEL); - return ret; + return kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); } static void lzo_destroy(void *private) { - kvfree(private); + kfree(private); } static int lzo_compress(const unsigned char *src, unsigned char *dst, diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 69fedf7a1..167f94304 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -52,7 +52,7 @@ static ssize_t zram_attr_##name##_show(struct device *d, \ (u64)atomic64_read(&zram->stats.name)); \ } \ static struct device_attribute dev_attr_##name = \ - __ATTR(name, 0444, zram_attr_##name##_show, NULL); + __ATTR(name, S_IRUGO, zram_attr_##name##_show, NULL); static inline int init_done(struct zram *zram) { @@ -168,7 +168,6 @@ static ssize_t comp_algorithm_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct zram *zram = dev_to_zram(dev); - down_write(&zram->init_lock); if (init_done(zram)) { up_write(&zram->init_lock); @@ -239,7 +238,6 @@ static struct zram_meta *zram_meta_alloc(u64 disksize) { size_t num_pages; struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL); - if (!meta) goto out; @@ -346,7 +344,7 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index) if (!handle || zram_test_flag(meta, index, ZRAM_ZERO)) { read_unlock(&meta->tb_lock); - memset(mem, 0, PAGE_SIZE); + clear_page(mem); return 0; } @@ -375,7 +373,6 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec, struct page *page; unsigned char *user_mem, *uncmem = NULL; struct zram_meta *meta = zram->meta; - page = bvec->bv_page; read_lock(&meta->tb_lock); @@ -609,7 +606,6 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity) /* Free all pages that are still in this zram device */ for (index = 0; index < zram->disksize >> PAGE_SHIFT; index++) { unsigned long handle = meta->table[index].handle; - if (!handle) continue; @@ -627,16 +623,7 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity) zram->disksize = 0; if (reset_capacity) set_capacity(zram->disk, 0); - up_write(&zram->init_lock); - - /* - * Revalidate disk out of the init_lock to avoid lockdep splat. - * It's okay because disk's capacity is protected by init_lock - * so that revalidate_disk always sees up-to-date capacity. - */ - if (reset_capacity) - revalidate_disk(zram->disk); } static ssize_t disksize_store(struct device *dev, @@ -677,14 +664,6 @@ static ssize_t disksize_store(struct device *dev, zram->disksize = disksize; set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); up_write(&zram->init_lock); - - /* - * Revalidate disk out of the init_lock to avoid lockdep splat. - * It's okay because disk's capacity is protected by init_lock - * so that revalidate_disk always sees up-to-date capacity. - */ - revalidate_disk(zram->disk); - return len; out_destroy_comp: @@ -834,15 +813,15 @@ static const struct block_device_operations zram_devops = { .owner = THIS_MODULE }; -static DEVICE_ATTR(disksize, 0644, +static DEVICE_ATTR(disksize, S_IRUGO | S_IWUSR, disksize_show, disksize_store); -static DEVICE_ATTR(initstate, 0444, initstate_show, NULL); -static DEVICE_ATTR(reset, 0200, NULL, reset_store); -static DEVICE_ATTR(orig_data_size, 0444, orig_data_size_show, NULL); -static DEVICE_ATTR(mem_used_total, 0444, mem_used_total_show, NULL); -static DEVICE_ATTR(max_comp_streams, 0644, +static DEVICE_ATTR(initstate, S_IRUGO, initstate_show, NULL); +static DEVICE_ATTR(reset, S_IWUSR, NULL, reset_store); +static DEVICE_ATTR(orig_data_size, S_IRUGO, orig_data_size_show, NULL); +static DEVICE_ATTR(mem_used_total, S_IRUGO, mem_used_total_show, NULL); +static DEVICE_ATTR(max_comp_streams, S_IRUGO | S_IWUSR, max_comp_streams_show, max_comp_streams_store); -static DEVICE_ATTR(comp_algorithm, 0644, +static DEVICE_ATTR(comp_algorithm, S_IRUGO | S_IWUSR, comp_algorithm_show, comp_algorithm_store); ZRAM_ATTR_RO(num_reads); |
