mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-5.4.y' into android-5.4
Merged in v5.5-rc1. * aosp/upstream-f2fs-stable-linux-5.4.y: docs: fs-verity: mention statx() support f2fs: support STATX_ATTR_VERITY ext4: support STATX_ATTR_VERITY statx: define STATX_ATTR_VERITY docs: fs-verity: document first supported kernel version f2fs: add support for IV_INO_LBLK_64 encryption policies ext4: add support for IV_INO_LBLK_64 encryption policies fscrypt: add support for IV_INO_LBLK_64 policies fscrypt: avoid data race on fscrypt_mode::logged_impl_name fscrypt: zeroize fscrypt_info before freeing fscrypt: remove struct fscrypt_ctx fscrypt: invoke crypto API for ESSIV handling null_blk: remove unused variable warning on !CONFIG_BLK_DEV_ZONED block: set the zone size in blk_revalidate_disk_zones atomically block: don't handle bio based drivers in blk_revalidate_disk_zones null_blk: cleanup null_gendisk_register null_blk: fix zone size paramter check block: allocate the zone bitmaps lazily block: replace seq_zones_bitmap with conv_zones_bitmap block: simplify blkdev_nr_zones block: remove the empty line at the end of blk-zoned.c scsi: sd_zbc: Improve report zones error printout scsi: sd_zbc: Remove set but not used variable 'buflen' block: rework zone reporting scsi: sd_zbc: Cleanup sd_zbc_alloc_report_buffer() null_blk: clean up report zones null_blk: clean up the block device operations null_blk: return fixed zoned reads > write pointer scsi: sd_zbc: add zone open, close, and finish support block: Remove partition support for zoned block devices block: Simplify report zones execution block: cleanup the !zoned case in blk_revalidate_disk_zones block: Enhance blk_revalidate_disk_zones() block: add zone open, close and finish ioctl support block: add zone open, close and finish operations block: Simplify REQ_OP_ZONE_RESET_ALL handling block: Remove REQ_OP_ZONE_RESET plugging f2fs: stop GC when the victim becomes fully valid f2fs: expose main_blkaddr in sysfs f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project() f2fs: Fix deadlock in f2fs_gc() context during atomic files handling f2fs: show f2fs instance in printk_ratelimited f2fs: fix potential overflow f2fs: fix to update dir's i_pino during cross_rename f2fs: support aligned pinned file f2fs: avoid kernel panic on corruption test f2fs: fix wrong description in document f2fs: cache global IPU bio f2fs: fix to avoid memory leakage in f2fs_listxattr f2fs: check total_segments from devices in raw_super f2fs: update multi-dev metadata in resize_fs f2fs: mark recovery flag correctly in read_raw_super_block() f2fs: fix to update time in lazytime mode Change-Id: I9325127228fb82b67f064ce8b3bc8d40ac76e65b Signed-off-by: Jaegeuk Kim <[email protected]>
This commit is contained in:
commit
57df3030e1
42 changed files with 1092 additions and 956 deletions
|
|
@ -91,11 +91,13 @@ struct nullb {
|
|||
#ifdef CONFIG_BLK_DEV_ZONED
|
||||
int null_zone_init(struct nullb_device *dev);
|
||||
void null_zone_exit(struct nullb_device *dev);
|
||||
int null_zone_report(struct gendisk *disk, sector_t sector,
|
||||
struct blk_zone *zones, unsigned int *nr_zones);
|
||||
int null_report_zones(struct gendisk *disk, sector_t sector,
|
||||
unsigned int nr_zones, report_zones_cb cb, void *data);
|
||||
blk_status_t null_handle_zoned(struct nullb_cmd *cmd,
|
||||
enum req_opf op, sector_t sector,
|
||||
sector_t nr_sectors);
|
||||
size_t null_zone_valid_read_len(struct nullb *nullb,
|
||||
sector_t sector, unsigned int len);
|
||||
#else
|
||||
static inline int null_zone_init(struct nullb_device *dev)
|
||||
{
|
||||
|
|
@ -103,17 +105,18 @@ static inline int null_zone_init(struct nullb_device *dev)
|
|||
return -EINVAL;
|
||||
}
|
||||
static inline void null_zone_exit(struct nullb_device *dev) {}
|
||||
static inline int null_zone_report(struct gendisk *disk, sector_t sector,
|
||||
struct blk_zone *zones,
|
||||
unsigned int *nr_zones)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
static inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd,
|
||||
enum req_opf op, sector_t sector,
|
||||
sector_t nr_sectors)
|
||||
{
|
||||
return BLK_STS_NOTSUPP;
|
||||
}
|
||||
static inline size_t null_zone_valid_read_len(struct nullb *nullb,
|
||||
sector_t sector,
|
||||
unsigned int len)
|
||||
{
|
||||
return len;
|
||||
}
|
||||
#define null_report_zones NULL
|
||||
#endif /* CONFIG_BLK_DEV_ZONED */
|
||||
#endif /* __NULL_BLK_H */
|
||||
|
|
|
|||
|
|
@ -996,6 +996,16 @@ next:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void nullb_fill_pattern(struct nullb *nullb, struct page *page,
|
||||
unsigned int len, unsigned int off)
|
||||
{
|
||||
void *dst;
|
||||
|
||||
dst = kmap_atomic(page);
|
||||
memset(dst + off, 0xFF, len);
|
||||
kunmap_atomic(dst);
|
||||
}
|
||||
|
||||
static void null_handle_discard(struct nullb *nullb, sector_t sector, size_t n)
|
||||
{
|
||||
size_t temp;
|
||||
|
|
@ -1036,10 +1046,24 @@ static int null_transfer(struct nullb *nullb, struct page *page,
|
|||
unsigned int len, unsigned int off, bool is_write, sector_t sector,
|
||||
bool is_fua)
|
||||
{
|
||||
struct nullb_device *dev = nullb->dev;
|
||||
unsigned int valid_len = len;
|
||||
int err = 0;
|
||||
|
||||
if (!is_write) {
|
||||
err = copy_from_nullb(nullb, page, off, sector, len);
|
||||
if (dev->zoned)
|
||||
valid_len = null_zone_valid_read_len(nullb,
|
||||
sector, len);
|
||||
|
||||
if (valid_len) {
|
||||
err = copy_from_nullb(nullb, page, off,
|
||||
sector, valid_len);
|
||||
off += valid_len;
|
||||
len -= valid_len;
|
||||
}
|
||||
|
||||
if (len)
|
||||
nullb_fill_pattern(nullb, page, len, off);
|
||||
flush_dcache_page(page);
|
||||
} else {
|
||||
flush_dcache_page(page);
|
||||
|
|
@ -1418,20 +1442,9 @@ static void null_config_discard(struct nullb *nullb)
|
|||
blk_queue_flag_set(QUEUE_FLAG_DISCARD, nullb->q);
|
||||
}
|
||||
|
||||
static int null_open(struct block_device *bdev, fmode_t mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void null_release(struct gendisk *disk, fmode_t mode)
|
||||
{
|
||||
}
|
||||
|
||||
static const struct block_device_operations null_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = null_open,
|
||||
.release = null_release,
|
||||
.report_zones = null_zone_report,
|
||||
static const struct block_device_operations null_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.report_zones = null_report_zones,
|
||||
};
|
||||
|
||||
static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq)
|
||||
|
|
@ -1520,29 +1533,35 @@ static int init_driver_queues(struct nullb *nullb)
|
|||
|
||||
static int null_gendisk_register(struct nullb *nullb)
|
||||
{
|
||||
sector_t size = ((sector_t)nullb->dev->size * SZ_1M) >> SECTOR_SHIFT;
|
||||
struct gendisk *disk;
|
||||
sector_t size;
|
||||
|
||||
disk = nullb->disk = alloc_disk_node(1, nullb->dev->home_node);
|
||||
if (!disk)
|
||||
return -ENOMEM;
|
||||
size = (sector_t)nullb->dev->size * 1024 * 1024ULL;
|
||||
set_capacity(disk, size >> 9);
|
||||
set_capacity(disk, size);
|
||||
|
||||
disk->flags |= GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO;
|
||||
disk->major = null_major;
|
||||
disk->first_minor = nullb->index;
|
||||
disk->fops = &null_fops;
|
||||
disk->fops = &null_ops;
|
||||
disk->private_data = nullb;
|
||||
disk->queue = nullb->q;
|
||||
strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
|
||||
|
||||
#ifdef CONFIG_BLK_DEV_ZONED
|
||||
if (nullb->dev->zoned) {
|
||||
int ret = blk_revalidate_disk_zones(disk);
|
||||
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
if (queue_is_mq(nullb->q)) {
|
||||
int ret = blk_revalidate_disk_zones(disk);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
blk_queue_chunk_sectors(nullb->q,
|
||||
nullb->dev->zone_size_sects);
|
||||
nullb->q->nr_zones = blkdev_nr_zones(disk);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
add_disk(disk);
|
||||
return 0;
|
||||
|
|
@ -1568,7 +1587,7 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)
|
|||
return blk_mq_alloc_tag_set(set);
|
||||
}
|
||||
|
||||
static void null_validate_conf(struct nullb_device *dev)
|
||||
static int null_validate_conf(struct nullb_device *dev)
|
||||
{
|
||||
dev->blocksize = round_down(dev->blocksize, 512);
|
||||
dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 4096);
|
||||
|
|
@ -1595,6 +1614,14 @@ static void null_validate_conf(struct nullb_device *dev)
|
|||
/* can not stop a queue */
|
||||
if (dev->queue_mode == NULL_Q_BIO)
|
||||
dev->mbps = 0;
|
||||
|
||||
if (dev->zoned &&
|
||||
(!dev->zone_size || !is_power_of_2(dev->zone_size))) {
|
||||
pr_err("zone_size must be power-of-two\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION
|
||||
|
|
@ -1627,7 +1654,9 @@ static int null_add_dev(struct nullb_device *dev)
|
|||
struct nullb *nullb;
|
||||
int rv;
|
||||
|
||||
null_validate_conf(dev);
|
||||
rv = null_validate_conf(dev);
|
||||
if (rv)
|
||||
return rv;
|
||||
|
||||
nullb = kzalloc_node(sizeof(*nullb), GFP_KERNEL, dev->home_node);
|
||||
if (!nullb) {
|
||||
|
|
@ -1692,7 +1721,6 @@ static int null_add_dev(struct nullb_device *dev)
|
|||
if (rv)
|
||||
goto out_cleanup_blk_queue;
|
||||
|
||||
blk_queue_chunk_sectors(nullb->q, dev->zone_size_sects);
|
||||
nullb->q->limits.zoned = BLK_ZONED_HM;
|
||||
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, nullb->q);
|
||||
blk_queue_required_elevator_features(nullb->q,
|
||||
|
|
@ -1753,11 +1781,6 @@ static int __init null_init(void)
|
|||
g_bs = PAGE_SIZE;
|
||||
}
|
||||
|
||||
if (!is_power_of_2(g_zone_size)) {
|
||||
pr_err("zone_size must be power-of-two\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (g_home_node != NUMA_NO_NODE && g_home_node >= nr_online_nodes) {
|
||||
pr_err("invalid home_node value\n");
|
||||
g_home_node = NUMA_NO_NODE;
|
||||
|
|
|
|||
|
|
@ -66,22 +66,53 @@ void null_zone_exit(struct nullb_device *dev)
|
|||
kvfree(dev->zones);
|
||||
}
|
||||
|
||||
int null_zone_report(struct gendisk *disk, sector_t sector,
|
||||
struct blk_zone *zones, unsigned int *nr_zones)
|
||||
int null_report_zones(struct gendisk *disk, sector_t sector,
|
||||
unsigned int nr_zones, report_zones_cb cb, void *data)
|
||||
{
|
||||
struct nullb *nullb = disk->private_data;
|
||||
struct nullb_device *dev = nullb->dev;
|
||||
unsigned int zno, nrz = 0;
|
||||
unsigned int first_zone, i;
|
||||
struct blk_zone zone;
|
||||
int error;
|
||||
|
||||
zno = null_zone_no(dev, sector);
|
||||
if (zno < dev->nr_zones) {
|
||||
nrz = min_t(unsigned int, *nr_zones, dev->nr_zones - zno);
|
||||
memcpy(zones, &dev->zones[zno], nrz * sizeof(struct blk_zone));
|
||||
first_zone = null_zone_no(dev, sector);
|
||||
if (first_zone >= dev->nr_zones)
|
||||
return 0;
|
||||
|
||||
nr_zones = min(nr_zones, dev->nr_zones - first_zone);
|
||||
for (i = 0; i < nr_zones; i++) {
|
||||
/*
|
||||
* Stacked DM target drivers will remap the zone information by
|
||||
* modifying the zone information passed to the report callback.
|
||||
* So use a local copy to avoid corruption of the device zone
|
||||
* array.
|
||||
*/
|
||||
memcpy(&zone, &dev->zones[first_zone + i],
|
||||
sizeof(struct blk_zone));
|
||||
error = cb(&zone, i, data);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
|
||||
*nr_zones = nrz;
|
||||
return nr_zones;
|
||||
}
|
||||
|
||||
return 0;
|
||||
size_t null_zone_valid_read_len(struct nullb *nullb,
|
||||
sector_t sector, unsigned int len)
|
||||
{
|
||||
struct nullb_device *dev = nullb->dev;
|
||||
struct blk_zone *zone = &dev->zones[null_zone_no(dev, sector)];
|
||||
unsigned int nr_sectors = len >> SECTOR_SHIFT;
|
||||
|
||||
/* Read must be below the write pointer position */
|
||||
if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL ||
|
||||
sector + nr_sectors <= zone->wp)
|
||||
return len;
|
||||
|
||||
if (sector > zone->wp)
|
||||
return 0;
|
||||
|
||||
return (zone->wp - sector) << SECTOR_SHIFT;
|
||||
}
|
||||
|
||||
static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
|
||||
|
|
@ -121,8 +152,7 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
|
|||
static blk_status_t null_zone_reset(struct nullb_cmd *cmd, sector_t sector)
|
||||
{
|
||||
struct nullb_device *dev = cmd->nq->dev;
|
||||
unsigned int zno = null_zone_no(dev, sector);
|
||||
struct blk_zone *zone = &dev->zones[zno];
|
||||
struct blk_zone *zone = &dev->zones[null_zone_no(dev, sector)];
|
||||
size_t i;
|
||||
|
||||
switch (req_op(cmd->rq)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue