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

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

dm: support REQ_OP_WRITE_ZEROES



Copy & paste from the REQ_OP_WRITE_SAME code.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 0f5d690f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ void dm_init_md_queue(struct mapped_device *md);
void dm_init_normal_md_queue(struct mapped_device *md);
int md_in_flight(struct mapped_device *md);
void disable_write_same(struct mapped_device *md);
void disable_write_zeroes(struct mapped_device *md);

static inline struct completion *dm_get_completion_from_kobject(struct kobject *kobj)
{
+6 −2
Original line number Diff line number Diff line
@@ -312,9 +312,12 @@ static void do_region(int op, int op_flags, unsigned region,
	 */
	if (op == REQ_OP_DISCARD)
		special_cmd_max_sectors = q->limits.max_discard_sectors;
	else if (op == REQ_OP_WRITE_ZEROES)
		special_cmd_max_sectors = q->limits.max_write_zeroes_sectors;
	else if (op == REQ_OP_WRITE_SAME)
		special_cmd_max_sectors = q->limits.max_write_same_sectors;
	if ((op == REQ_OP_DISCARD || op == REQ_OP_WRITE_SAME) &&
	if ((op == REQ_OP_DISCARD || op == REQ_OP_WRITE_ZEROES ||
	     op == REQ_OP_WRITE_SAME)  &&
	    special_cmd_max_sectors == 0) {
		dec_count(io, region, -EOPNOTSUPP);
		return;
@@ -330,6 +333,7 @@ static void do_region(int op, int op_flags, unsigned region,
		 */
		switch (op) {
		case REQ_OP_DISCARD:
		case REQ_OP_WRITE_ZEROES:
			num_bvecs = 0;
			break;
		case REQ_OP_WRITE_SAME:
@@ -347,7 +351,7 @@ static void do_region(int op, int op_flags, unsigned region,
		bio_set_op_attrs(bio, op, op_flags);
		store_io_and_region_in_bio(bio, io, region);

		if (op == REQ_OP_DISCARD) {
		if (op == REQ_OP_DISCARD || op == REQ_OP_WRITE_ZEROES) {
			num_sectors = min_t(sector_t, special_cmd_max_sectors, remaining);
			bio->bi_iter.bi_size = num_sectors << SECTOR_SHIFT;
			remaining -= num_sectors;
+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
	ti->num_flush_bios = 1;
	ti->num_discard_bios = 1;
	ti->num_write_same_bios = 1;
	ti->num_write_zeroes_bios = 1;
	ti->private = lc;
	return 0;

+1 −0
Original line number Diff line number Diff line
@@ -1103,6 +1103,7 @@ static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv)
	ti->num_flush_bios = 1;
	ti->num_discard_bios = 1;
	ti->num_write_same_bios = 1;
	ti->num_write_zeroes_bios = 1;
	if (m->queue_mode == DM_TYPE_BIO_BASED)
		ti->per_io_data_size = multipath_per_bio_data_size();
	else
+8 −3
Original line number Diff line number Diff line
@@ -298,9 +298,14 @@ static void dm_done(struct request *clone, int error, bool mapped)
			r = rq_end_io(tio->ti, clone, error, &tio->info);
	}

	if (unlikely(r == -EREMOTEIO && (req_op(clone) == REQ_OP_WRITE_SAME) &&
		     !clone->q->limits.max_write_same_sectors))
	if (unlikely(r == -EREMOTEIO)) {
		if (req_op(clone) == REQ_OP_WRITE_SAME &&
		    !clone->q->limits.max_write_same_sectors)
			disable_write_same(tio->md);
		if (req_op(clone) == REQ_OP_WRITE_ZEROES &&
		    !clone->q->limits.max_write_zeroes_sectors)
			disable_write_zeroes(tio->md);
	}

	if (r <= 0)
		/* The target wants to complete the I/O */
Loading