Skip to content

Commit

Permalink
Merge branch 'QK-eleven' into upstreamed-common
Browse files Browse the repository at this point in the history
# Conflicts:
#	drivers/block/virtio_blk.c
#	drivers/block/zram/zram_drv.c
#	drivers/nvme/host/core.c
#	drivers/nvme/host/multipath.c
  • Loading branch information
Official-Ayrton990 committed Jun 1, 2022
2 parents b63ebf9 + efaad1e commit 8c9ad1f
Show file tree
Hide file tree
Showing 45 changed files with 738 additions and 911 deletions.
262 changes: 166 additions & 96 deletions Documentation/blockdev/zram.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions arch/arm64/configs/vendor/alioth_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ CONFIG_MTD_OOPS=y
CONFIG_MTD_BLOCK2MTD=y
CONFIG_ZRAM=y
CONFIG_ZRAM_SIZE_OVERRIDE=2
CONFIG_ZRAM_WRITEBACK=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_LOOP_MIN_COUNT=16
CONFIG_BLK_DEV_RAM=y
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/configs/vendor/apollo_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ CONFIG_MTD_OOPS=y
CONFIG_MTD_BLOCK2MTD=y
CONFIG_ZRAM=y
CONFIG_ZRAM_SIZE_OVERRIDE=2
CONFIG_ZRAM_WRITEBACK=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_LOOP_MIN_COUNT=16
CONFIG_BLK_DEV_RAM=y
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/configs/vendor/cmi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ CONFIG_MTD_OOPS=y
CONFIG_MTD_BLOCK2MTD=y
CONFIG_ZRAM=y
CONFIG_ZRAM_SIZE_OVERRIDE=2
CONFIG_ZRAM_WRITEBACK=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_LOOP_MIN_COUNT=16
CONFIG_BLK_DEV_RAM=y
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/configs/vendor/lmi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ CONFIG_MTD_OOPS=y
CONFIG_MTD_BLOCK2MTD=y
CONFIG_ZRAM=y
CONFIG_ZRAM_SIZE_OVERRIDE=2
CONFIG_ZRAM_WRITEBACK=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_LOOP_MIN_COUNT=16
CONFIG_BLK_DEV_RAM=y
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/configs/vendor/thyme_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ CONFIG_MTD_OOPS=y
CONFIG_MTD_BLOCK2MTD=y
CONFIG_ZRAM=y
CONFIG_ZRAM_SIZE_OVERRIDE=2
CONFIG_ZRAM_WRITEBACK=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_LOOP_MIN_COUNT=16
CONFIG_BLK_DEV_RAM=y
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/configs/vendor/umi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ CONFIG_MTD_OOPS=y
CONFIG_MTD_BLOCK2MTD=y
CONFIG_ZRAM=y
CONFIG_ZRAM_SIZE_OVERRIDE=2
CONFIG_ZRAM_WRITEBACK=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_LOOP_MIN_COUNT=16
CONFIG_BLK_DEV_RAM=y
Expand Down
19 changes: 16 additions & 3 deletions arch/x86/mm/pat_rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,23 @@ static u64 get_subtree_max_end(struct rb_node *node)
return ret;
}

#define NODE_END(node) ((node)->end)
static u64 compute_subtree_max_end(struct memtype *data)
{
u64 max_end = data->end, child_max_end;

child_max_end = get_subtree_max_end(data->rb.rb_right);
if (child_max_end > max_end)
max_end = child_max_end;

child_max_end = get_subtree_max_end(data->rb.rb_left);
if (child_max_end > max_end)
max_end = child_max_end;

return max_end;
}

RB_DECLARE_CALLBACKS_MAX(static, memtype_rb_augment_cb,
struct memtype, rb, u64, subtree_max_end, NODE_END)
RB_DECLARE_CALLBACKS(static, memtype_rb_augment_cb, struct memtype, rb,
u64, subtree_max_end, compute_subtree_max_end)

/* Find the first (lowest start addr) overlapping range from rb tree */
static struct memtype *memtype_rb_lowest_match(struct rb_root *root,
Expand Down
1 change: 0 additions & 1 deletion drivers/block/brd.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ static struct brd_device *brd_alloc(int i)
disk->flags = GENHD_FL_EXT_DEVT;
sprintf(disk->disk_name, "ram%d", i);
set_capacity(disk, rd_size * 2);
brd->brd_queue->backing_dev_info->capabilities |= BDI_CAP_SYNCHRONOUS_IO;

/* Tell the block layer that this is not a rotational device */
blk_queue_flag_set(QUEUE_FLAG_NONROT, brd->brd_queue);
Expand Down
29 changes: 26 additions & 3 deletions drivers/block/drbd/drbd_interval.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,33 @@ sector_t interval_end(struct rb_node *node)
return this->end;
}

#define NODE_END(node) ((node)->sector + ((node)->size >> 9))
/**
* compute_subtree_last - compute end of @node
*
* The end of an interval is the highest (start + (size >> 9)) value of this
* node and of its children. Called for @node and its parents whenever the end
* may have changed.
*/
static inline sector_t
compute_subtree_last(struct drbd_interval *node)
{
sector_t max = node->sector + (node->size >> 9);

if (node->rb.rb_left) {
sector_t left = interval_end(node->rb.rb_left);
if (left > max)
max = left;
}
if (node->rb.rb_right) {
sector_t right = interval_end(node->rb.rb_right);
if (right > max)
max = right;
}
return max;
}

RB_DECLARE_CALLBACKS_MAX(static, augment_callbacks,
struct drbd_interval, rb, sector_t, end, NODE_END);
RB_DECLARE_CALLBACKS(static, augment_callbacks, struct drbd_interval, rb,
sector_t, end, compute_subtree_last);

/**
* drbd_insert_interval - insert a new interval into a tree
Expand Down
14 changes: 13 additions & 1 deletion drivers/block/virtio_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,19 @@ static int virtblk_probe(struct virtio_device *vdev)
virtblk_update_capacity(vblk, false);
virtio_device_ready(vdev);

device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups);
device_add_disk(&vdev->dev, vblk->disk, NULL);
err = device_create_file(disk_to_dev(vblk->disk), &dev_attr_serial);
if (err)
goto out_del_disk;

if (virtio_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE))
err = device_create_file(disk_to_dev(vblk->disk),
&dev_attr_cache_type_rw);
else
err = device_create_file(disk_to_dev(vblk->disk),
&dev_attr_cache_type_ro);
if (err)
goto out_del_disk;
return 0;

out_free_tags:
Expand Down
52 changes: 43 additions & 9 deletions drivers/block/zram/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
config ZRAM
tristate "Compressed RAM block device support"
depends on BLOCK && SYSFS && ZSMALLOC && CRYPTO
select CRYPTO_LZ4
default n
depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842
help
Creates virtual block devices called /dev/zramX (X = 0, 1, ...).
Pages written to these disks are compressed and stored in memory
Expand All @@ -15,10 +14,51 @@ config ZRAM

See Documentation/blockdev/zram.txt for more information.

choice
prompt "Default zram compressor"
default ZRAM_DEF_COMP_LZORLE
depends on ZRAM

config ZRAM_DEF_COMP_LZORLE
bool "lzo-rle"
depends on CRYPTO_LZO

config ZRAM_DEF_COMP_ZSTD
bool "zstd"
depends on CRYPTO_ZSTD

config ZRAM_DEF_COMP_LZ4
bool "lz4"
depends on CRYPTO_LZ4

config ZRAM_DEF_COMP_LZO
bool "lzo"
depends on CRYPTO_LZO

config ZRAM_DEF_COMP_LZ4HC
bool "lz4hc"
depends on CRYPTO_LZ4HC

config ZRAM_DEF_COMP_842
bool "842"
depends on CRYPTO_842

endchoice

config ZRAM_DEF_COMP
string
default "lzo-rle" if ZRAM_DEF_COMP_LZORLE
default "zstd" if ZRAM_DEF_COMP_ZSTD
default "lz4" if ZRAM_DEF_COMP_LZ4
default "lzo" if ZRAM_DEF_COMP_LZO
default "lz4hc" if ZRAM_DEF_COMP_LZ4HC
default "842" if ZRAM_DEF_COMP_842

config ZRAM_DEDUP
bool "Deduplication support for ZRAM data"
depends on ZRAM
default n
select XXHASH
default y
help
Deduplicate ZRAM data to reduce amount of memory consumption.
Advantage largely depends on the workload. In some cases, this
Expand All @@ -32,7 +72,6 @@ config ZRAM_DEDUP
config ZRAM_WRITEBACK
bool "Write back incompressible or idle page to backing device"
depends on ZRAM
default n
help
With incompressible page, there is no memory saving to keep it
in memory. Instead, write it out to backing device.
Expand All @@ -53,8 +92,3 @@ config ZRAM_MEMORY_TRACKING
/sys/kernel/debug/zram/zramX/block_state.

See Documentation/blockdev/zram.txt for more information.

config ZRAM_SIZE_OVERRIDE
int "zram size to set from kernel"
range 1 8
default 2
3 changes: 2 additions & 1 deletion drivers/block/zram/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
zram-y := zcomp.o zram_drv.o
# SPDX-License-Identifier: GPL-2.0-only
zram-y := zcomp.o zram_drv.o
zram-$(CONFIG_ZRAM_DEDUP) += zram_dedup.o

obj-$(CONFIG_ZRAM) += zram.o
11 changes: 5 additions & 6 deletions drivers/block/zram/zcomp.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2014 Sergey Senozhatsky.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/

#include <linux/kernel.h>
Expand All @@ -19,9 +15,12 @@
#include "zcomp.h"

static const char * const backends[] = {
"lz4",
#if IS_ENABLED(CONFIG_CRYPTO_LZO)
"lzo",
"lzo-rle",
#endif
#if IS_ENABLED(CONFIG_CRYPTO_LZ4)
"lz4",
#endif
#if IS_ENABLED(CONFIG_CRYPTO_LZ4HC)
"lz4hc",
Expand Down
6 changes: 1 addition & 5 deletions drivers/block/zram/zcomp.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2014 Sergey Senozhatsky.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/

#ifndef _ZCOMP_H_
Expand Down
14 changes: 7 additions & 7 deletions drivers/block/zram/zram_dedup.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

#include <linux/vmalloc.h>
#include <linux/jhash.h>
#include <linux/xxhash.h>
#include <linux/highmem.h>

#include "zram_drv.h"
Expand All @@ -28,13 +28,13 @@ u64 zram_dedup_meta_size(struct zram *zram)
return (u64)atomic64_read(&zram->stats.meta_data_size);
}

static u32 zram_dedup_checksum(unsigned char *mem)
static u64 zram_dedup_checksum(unsigned char *mem)
{
return jhash(mem, PAGE_SIZE, 0);
return xxh64(mem, PAGE_SIZE, 0);
}

void zram_dedup_insert(struct zram *zram, struct zram_entry *new,
u32 checksum)
u64 checksum)
{
struct zram_hash *hash;
struct rb_root *rb_root;
Expand Down Expand Up @@ -91,7 +91,7 @@ static unsigned long zram_dedup_put(struct zram *zram,
struct zram_entry *entry)
{
struct zram_hash *hash;
u32 checksum;
u64 checksum;
unsigned long val;

checksum = entry->checksum;
Expand Down Expand Up @@ -156,7 +156,7 @@ static struct zram_entry *__zram_dedup_get(struct zram *zram,
}

static struct zram_entry *zram_dedup_get(struct zram *zram,
unsigned char *mem, u32 checksum)
unsigned char *mem, u64 checksum)
{
struct zram_hash *hash;
struct zram_entry *entry;
Expand All @@ -182,7 +182,7 @@ static struct zram_entry *zram_dedup_get(struct zram *zram,
}

struct zram_entry *zram_dedup_find(struct zram *zram, struct page *page,
u32 *checksum)
u64 *checksum)
{
void *mem;
struct zram_entry *entry;
Expand Down
8 changes: 4 additions & 4 deletions drivers/block/zram/zram_dedup.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ u64 zram_dedup_dup_size(struct zram *zram);
u64 zram_dedup_meta_size(struct zram *zram);

void zram_dedup_insert(struct zram *zram, struct zram_entry *new,
u32 checksum);
u64 checksum);
struct zram_entry *zram_dedup_find(struct zram *zram, struct page *page,
u32 *checksum);
u64 *checksum);

void zram_dedup_init_entry(struct zram *zram, struct zram_entry *entry,
unsigned long handle, unsigned int len);
Expand All @@ -26,9 +26,9 @@ static inline u64 zram_dedup_dup_size(struct zram *zram) { return 0; }
static inline u64 zram_dedup_meta_size(struct zram *zram) { return 0; }

static inline void zram_dedup_insert(struct zram *zram, struct zram_entry *new,
u32 checksum) { }
u64 checksum) { }
static inline struct zram_entry *zram_dedup_find(struct zram *zram,
struct page *page, u32 *checksum) { return NULL; }
struct page *page, u64 *checksum) { return NULL; }

static inline void zram_dedup_init_entry(struct zram *zram,
struct zram_entry *entry, unsigned long handle,
Expand Down
Loading

0 comments on commit 8c9ad1f

Please sign in to comment.