diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2019-08-23 09:55:26 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2019-08-23 10:13:12 -0400 |
commit | 123d87d553e26f67e7be318c97c971b6b5fb1daa (patch) | |
tree | 874e61dd6809114c3b5186c2d7e0fc25a43b3662 /drivers/md/dm.c | |
parent | 1cfd5d3399e87167b7f9157ef99daa0e959f395d (diff) | |
download | linux-123d87d553e26f67e7be318c97c971b6b5fb1daa.tar.bz2 |
dm: make dm_table_find_target return NULL
Currently, if we pass too high sector number to dm_table_find_target, it
returns zeroed dm_target structure and callers test if the structure is
zeroed with the macro dm_target_is_valid.
However, returning NULL is common practice to indicate errors.
This patch refactors the dm code, so that dm_table_find_target returns
NULL and its callers test the returned value for NULL. The macro
dm_target_is_valid is deleted. In alloc_targets, we no longer allocate an
extra zeroed target.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r-- | drivers/md/dm.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index d0beef033e2f..1a5e328c443a 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -457,7 +457,7 @@ static int dm_blk_report_zones(struct gendisk *disk, sector_t sector, return -EIO; tgt = dm_table_find_target(map, sector); - if (!dm_target_is_valid(tgt)) { + if (!tgt) { ret = -EIO; goto out; } @@ -1072,7 +1072,7 @@ static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, return NULL; ti = dm_table_find_target(map, sector); - if (!dm_target_is_valid(ti)) + if (!ti) return NULL; return ti; @@ -1572,7 +1572,7 @@ static int __split_and_process_non_flush(struct clone_info *ci) int r; ti = dm_table_find_target(ci->map, ci->sector); - if (!dm_target_is_valid(ti)) + if (!ti) return -EIO; if (__process_abnormal_io(ci, ti, &r)) @@ -1748,7 +1748,7 @@ static blk_qc_t dm_process_bio(struct mapped_device *md, if (!ti) { ti = dm_table_find_target(map, bio->bi_iter.bi_sector); - if (unlikely(!ti || !dm_target_is_valid(ti))) { + if (unlikely(!ti)) { bio_io_error(bio); return ret; } |