Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 846785e6 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

dm: don't return errnos from ->map



Instead use the special DM_MAPIO_KILL return value to return -EIO just
like we do for the request based path.  Note that dm-log-writes returned
-ENOMEM in a few places, which now becomes -EIO instead.  No consumer
treats -ENOMEM special so this shouldn't be an issue (and it should
use a mempool to start with to make guaranteed progress).

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 14ef1e48
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2795,10 +2795,10 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
	 * and is aligned to this size as defined in IO hints.
	 */
	if (unlikely((bio->bi_iter.bi_sector & ((cc->sector_size >> SECTOR_SHIFT) - 1)) != 0))
		return -EIO;
		return DM_MAPIO_KILL;

	if (unlikely(bio->bi_iter.bi_size & (cc->sector_size - 1)))
		return -EIO;
		return DM_MAPIO_KILL;

	io = dm_per_bio_data(bio, cc->per_bio_data_size);
	crypt_io_init(io, cc, bio, dm_target_offset(ti, bio->bi_iter.bi_sector));
+2 −2
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
		if (bio_data_dir(bio) == READ) {
			if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags) &&
			    !test_bit(ERROR_WRITES, &fc->flags))
				return -EIO;
				return DM_MAPIO_KILL;
			goto map_bio;
		}

@@ -349,7 +349,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
		/*
		 * By default, error all I/O.
		 */
		return -EIO;
		return DM_MAPIO_KILL;
	}

map_bio:
+6 −6
Original line number Diff line number Diff line
@@ -1352,13 +1352,13 @@ static int dm_integrity_map(struct dm_target *ti, struct bio *bio)
		DMERR("Too big sector number: 0x%llx + 0x%x > 0x%llx",
		      (unsigned long long)dio->range.logical_sector, bio_sectors(bio),
		      (unsigned long long)ic->provided_data_sectors);
		return -EIO;
		return DM_MAPIO_KILL;
	}
	if (unlikely((dio->range.logical_sector | bio_sectors(bio)) & (unsigned)(ic->sectors_per_block - 1))) {
		DMERR("Bio not aligned on %u sectors: 0x%llx, 0x%x",
		      ic->sectors_per_block,
		      (unsigned long long)dio->range.logical_sector, bio_sectors(bio));
		return -EIO;
		return DM_MAPIO_KILL;
	}

	if (ic->sectors_per_block > 1) {
@@ -1368,7 +1368,7 @@ static int dm_integrity_map(struct dm_target *ti, struct bio *bio)
			if (unlikely((bv.bv_offset | bv.bv_len) & ((ic->sectors_per_block << SECTOR_SHIFT) - 1))) {
				DMERR("Bio vector (%u,%u) is not aligned on %u-sector boundary",
					bv.bv_offset, bv.bv_len, ic->sectors_per_block);
				return -EIO;
				return DM_MAPIO_KILL;
			}
		}
	}
@@ -1383,18 +1383,18 @@ static int dm_integrity_map(struct dm_target *ti, struct bio *bio)
				wanted_tag_size *= ic->tag_size;
			if (unlikely(wanted_tag_size != bip->bip_iter.bi_size)) {
				DMERR("Invalid integrity data size %u, expected %u", bip->bip_iter.bi_size, wanted_tag_size);
				return -EIO;
				return DM_MAPIO_KILL;
			}
		}
	} else {
		if (unlikely(bip != NULL)) {
			DMERR("Unexpected integrity data when using internal hash");
			return -EIO;
			return DM_MAPIO_KILL;
		}
	}

	if (unlikely(ic->mode == 'R') && unlikely(dio->write))
		return -EIO;
		return DM_MAPIO_KILL;

	get_area_and_offset(ic, dio->range.logical_sector, &area, &offset);
	dio->metadata_block = get_metadata_sector_and_offset(ic, area, offset, &dio->metadata_offset);
+2 −2
Original line number Diff line number Diff line
@@ -586,7 +586,7 @@ static int log_writes_map(struct dm_target *ti, struct bio *bio)
		spin_lock_irq(&lc->blocks_lock);
		lc->logging_enabled = false;
		spin_unlock_irq(&lc->blocks_lock);
		return -ENOMEM;
		return DM_MAPIO_KILL;
	}
	INIT_LIST_HEAD(&block->list);
	pb->block = block;
@@ -639,7 +639,7 @@ static int log_writes_map(struct dm_target *ti, struct bio *bio)
			spin_lock_irq(&lc->blocks_lock);
			lc->logging_enabled = false;
			spin_unlock_irq(&lc->blocks_lock);
			return -ENOMEM;
			return DM_MAPIO_KILL;
		}

		src = kmap_atomic(bv.bv_page);
+10 −3
Original line number Diff line number Diff line
@@ -559,7 +559,7 @@ static int __multipath_map_bio(struct multipath *m, struct bio *bio, struct dm_m
		if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))
			return DM_MAPIO_REQUEUE;
		dm_report_EIO(m);
		return -EIO;
		return DM_MAPIO_KILL;
	}

	mpio->pgpath = pgpath;
@@ -621,11 +621,18 @@ static void process_queued_bios(struct work_struct *work)
	blk_start_plug(&plug);
	while ((bio = bio_list_pop(&bios))) {
		r = __multipath_map_bio(m, bio, get_mpio_from_bio(bio));
		if (r < 0 || r == DM_MAPIO_REQUEUE) {
		switch (r) {
		case DM_MAPIO_KILL:
			r = -EIO;
			/*FALLTHRU*/
		case DM_MAPIO_REQUEUE:
			bio->bi_error = r;
			bio_endio(bio);
		} else if (r == DM_MAPIO_REMAPPED)
			break;
		case DM_MAPIO_REMAPPED:
			generic_make_request(bio);
			break;
		}
	}
	blk_finish_plug(&plug);
}
Loading