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

Commit 1be56909 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

dm: change ->end_io calling convention



Turn the error paramter into a pointer so that target drivers can change
the value, and make sure only DM_ENDIO_* values are returned from the
methods.

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 846785e6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2820,7 +2820,7 @@ static int cache_map(struct dm_target *ti, struct bio *bio)
	return r;
}

static int cache_end_io(struct dm_target *ti, struct bio *bio, int error)
static int cache_end_io(struct dm_target *ti, struct bio *bio, int *error)
{
	struct cache *cache = ti->private;
	unsigned long flags;
@@ -2838,7 +2838,7 @@ static int cache_end_io(struct dm_target *ti, struct bio *bio, int error)
	bio_drop_shared_lock(cache, bio);
	accounted_complete(cache, bio);

	return 0;
	return DM_ENDIO_DONE;
}

static int write_dirty_bitset(struct cache *cache)
+4 −4
Original line number Diff line number Diff line
@@ -358,12 +358,12 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
	return DM_MAPIO_REMAPPED;
}

static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
static int flakey_end_io(struct dm_target *ti, struct bio *bio, int *error)
{
	struct flakey_c *fc = ti->private;
	struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));

	if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
	if (!*error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
		if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
		    all_corrupt_bio_flags_match(bio, fc)) {
			/*
@@ -377,11 +377,11 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
			 * Error read during the down_interval if drop_writes
			 * and error_writes were not configured.
			 */
			return -EIO;
			*error = -EIO;
		}
	}

	return error;
	return DM_ENDIO_DONE;
}

static void flakey_status(struct dm_target *ti, status_type_t type,
+2 −2
Original line number Diff line number Diff line
@@ -664,7 +664,7 @@ static int log_writes_map(struct dm_target *ti, struct bio *bio)
	return DM_MAPIO_REMAPPED;
}

static int normal_end_io(struct dm_target *ti, struct bio *bio, int error)
static int normal_end_io(struct dm_target *ti, struct bio *bio, int *error)
{
	struct log_writes_c *lc = ti->private;
	struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
@@ -686,7 +686,7 @@ static int normal_end_io(struct dm_target *ti, struct bio *bio, int error)
		spin_unlock_irqrestore(&lc->blocks_lock, flags);
	}

	return error;
	return DM_ENDIO_DONE;
}

/*
+6 −5
Original line number Diff line number Diff line
@@ -1517,14 +1517,15 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
	return r;
}

static int multipath_end_io_bio(struct dm_target *ti, struct bio *clone, int error)
static int multipath_end_io_bio(struct dm_target *ti, struct bio *clone, int *error)
{
	struct multipath *m = ti->private;
	struct dm_mpath_io *mpio = get_mpio_from_bio(clone);
	struct pgpath *pgpath = mpio->pgpath;
	unsigned long flags;
	int r = DM_ENDIO_DONE;

	if (!error || noretry_error(error))
	if (!*error || noretry_error(*error))
		goto done;

	if (pgpath)
@@ -1533,7 +1534,7 @@ static int multipath_end_io_bio(struct dm_target *ti, struct bio *clone, int err
	if (atomic_read(&m->nr_valid_paths) == 0 &&
	    !test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) {
		dm_report_EIO(m);
		error = -EIO;
		*error = -EIO;
		goto done;
	}

@@ -1546,7 +1547,7 @@ static int multipath_end_io_bio(struct dm_target *ti, struct bio *clone, int err
	if (!test_bit(MPATHF_QUEUE_IO, &m->flags))
		queue_work(kmultipathd, &m->process_queued_bios);

	error = DM_ENDIO_INCOMPLETE;
	r = DM_ENDIO_INCOMPLETE;
done:
	if (pgpath) {
		struct path_selector *ps = &pgpath->pg->ps;
@@ -1555,7 +1556,7 @@ static int multipath_end_io_bio(struct dm_target *ti, struct bio *clone, int err
			ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes);
	}

	return error;
	return r;
}

/*
+7 −7
Original line number Diff line number Diff line
@@ -1236,7 +1236,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio)
	return DM_MAPIO_REMAPPED;
}

static int mirror_end_io(struct dm_target *ti, struct bio *bio, int error)
static int mirror_end_io(struct dm_target *ti, struct bio *bio, int *error)
{
	int rw = bio_data_dir(bio);
	struct mirror_set *ms = (struct mirror_set *) ti->private;
@@ -1252,16 +1252,16 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, int error)
		if (!(bio->bi_opf & REQ_PREFLUSH) &&
		    bio_op(bio) != REQ_OP_DISCARD)
			dm_rh_dec(ms->rh, bio_record->write_region);
		return error;
		return DM_ENDIO_DONE;
	}

	if (error == -EOPNOTSUPP)
		return error;
	if (*error == -EOPNOTSUPP)
		return DM_ENDIO_DONE;

	if (bio->bi_opf & REQ_RAHEAD)
		return error;
		return DM_ENDIO_DONE;

	if (unlikely(error)) {
	if (unlikely(*error)) {
		m = bio_record->m;

		DMERR("Mirror read failed from %s. Trying alternative device.",
@@ -1285,7 +1285,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, int error)
		DMERR("All replicated volumes dead, failing I/O");
	}

	return error;
	return DM_ENDIO_DONE;
}

static void mirror_presuspend(struct dm_target *ti)
Loading