From patchwork Fri Jun 19 06:59:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11614075 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D521B14B7 for ; Fri, 19 Jun 2020 12:39:21 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93D9820809 for ; Fri, 19 Jun 2020 12:39:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NaUIp8+b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93D9820809 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592570360; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=623hptyABgKTJ2LMe6MInxsSHmNdOvR3leW4b6UO0j8=; b=NaUIp8+bunxeAxB9ywopIFt/7BOET6jaPd1LyYPRrFyqjxhxT6dpjX7QcZLkd4Qj7rInJz vvwr4uOrhK7y18F8lSkczgniiKAosI/+waRX/D4yhofUmjsKiMjH7xJggKdigom43A9HMv cAFjW7e0w7G2O2zqFqFF0ChM0RW/wOo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-503-162o7yG-OrG-7CLHSZtcmg-1; Fri, 19 Jun 2020 08:39:18 -0400 X-MC-Unique: 162o7yG-OrG-7CLHSZtcmg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B392107ACCA; Fri, 19 Jun 2020 12:39:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70F3F5D9CA; Fri, 19 Jun 2020 12:39:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 48E971809554; Fri, 19 Jun 2020 12:39:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05J70s93014917 for ; Fri, 19 Jun 2020 03:00:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE92A2017EA7; Fri, 19 Jun 2020 07:00:54 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7FA42029F62 for ; Fri, 19 Jun 2020 07:00:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E5331019CAA for ; Fri, 19 Jun 2020 07:00:52 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-7x3ZPLeuMciUngebUJKHZg-2; Fri, 19 Jun 2020 03:00:48 -0400 X-MC-Unique: 7x3ZPLeuMciUngebUJKHZg-2 IronPort-SDR: GMHg1ZBnYrxzNhKqIFwe9OJs7b/syG5qt4MSRseqJiPW/BRsyRlmLSXBrTf37540qr+RRbCkb6 AwqZLLve8TG0/OI9IW44NLADtsH8NkSKGS4bwK1pNhD7qHN2/OHZG35iy3WJTdEDRoQ3o5Cfbt Mb1/XbI0u3Ub315jQZXPpdUamQmbbGMTLmOyE9ODuCUssHhzO2eg5fdrDMAjjZkg0HK5Nx73rU 60N3AkmGBByFFkNpdK9wuMPTNRH/8uDXNwrRrpReV5zpGTiSNMSMcwhxkRJCHWN85+9dKnMf12 B1o= X-IronPort-AV: E=Sophos;i="5.75,254,1589212800"; d="scan'208";a="140655410" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:59:36 +0800 IronPort-SDR: YdzCmtQnh0ApbChJ4nkx9HHqnAXSTFt0P9wIh3IRGzwzTPLKYI2pbSrKTDc0PWoKTFb7oE88M9 fer1zS6popciVpb4TREp8Fyq7scwgxyBM= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2020 23:48:13 -0700 IronPort-SDR: 4dy8/kN3qrCG6mS0UpGTc1PHUIiEhq6DN/I9DlHGP1GBNYFhF6BihxpavInPBmGrJjdTNTjYVS DWb+RkHuV2Og== WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 18 Jun 2020 23:59:35 -0700 From: Johannes Thumshirn To: Mike Snitzer Date: Fri, 19 Jun 2020 15:59:04 +0900 Message-Id: <20200619065905.22228-2-johannes.thumshirn@wdc.com> In-Reply-To: <20200619065905.22228-1-johannes.thumshirn@wdc.com> References: <20200619065905.22228-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 19 Jun 2020 08:38:54 -0400 Cc: linux-block@vger.kernel.org, Naohiro Aota , dm-devel@redhat.com, Damien Le Moal , Johannes Thumshirn Subject: [dm-devel] [PATCH 1/2] dm: update original bio sector on Zone Append X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Naohiro reported that issuing zone-append bios to a zoned block device underneath a dm-linear device does not work as expected. This because we forgot to reverse-map the sector the device wrote to the original bio. For zone-append bios, get the offset in the zone of the written sector from the clone bio and add that to the original bio's sector position. Reported-by: Naohiro Aota Fixes: 0512a75b98f8 ("block: Introduce REQ_OP_ZONE_APPEND") Signed-off-by: Johannes Thumshirn --- drivers/md/dm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 109e81f33edb..058c34abe9d1 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1009,6 +1009,7 @@ static void clone_endio(struct bio *bio) struct dm_io *io = tio->io; struct mapped_device *md = tio->io->md; dm_endio_fn endio = tio->ti->type->end_io; + struct bio *orig_bio = io->orig_bio; if (unlikely(error == BLK_STS_TARGET) && md->type != DM_TYPE_NVME_BIO_BASED) { if (bio_op(bio) == REQ_OP_DISCARD && @@ -1022,6 +1023,18 @@ static void clone_endio(struct bio *bio) disable_write_zeroes(md); } + /* + * for zone-append bios get offset in zone of the written sector and add + * that to the original bio sector pos. + */ + if (bio_op(orig_bio) == REQ_OP_ZONE_APPEND) { + sector_t written_sector = bio->bi_iter.bi_sector; + struct request_queue *q = orig_bio->bi_disk->queue; + u64 mask = (u64)blk_queue_zone_sectors(q) - 1; + + orig_bio->bi_iter.bi_sector += written_sector & mask; + } + if (endio) { int r = endio(tio->ti, bio, &error); switch (r) { From patchwork Fri Jun 19 06:59:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11614087 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C87513A0 for ; Fri, 19 Jun 2020 12:39:30 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C13E207E8 for ; Fri, 19 Jun 2020 12:39:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YZU4JV8Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C13E207E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592570369; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=l5rbNer6TptGaTf16FZhhrs7NBLbv0fl1VXT3gAyyVQ=; b=YZU4JV8ZSy6EJ9Qw5Iy8Fb11PIm0qA+Y3B4AbbwEK2tDg6Cm87zlxZXOKiOzXfuGsAA/ms AOaRCJWdo0Dl5s8zXlZ4Vuj+aWX06XD6eeETI3oeHoQVJDU0lBu8sDd9uGqFwQFwaagSq+ lLUoHyxoCBUSUwFoS8ILuqqtScpNsFw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-360-0IHopsLDOkyOFKZ-Lgarhg-1; Fri, 19 Jun 2020 08:39:25 -0400 X-MC-Unique: 0IHopsLDOkyOFKZ-Lgarhg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03CFB18A823B; Fri, 19 Jun 2020 12:39:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD7F65BADB; Fri, 19 Jun 2020 12:39:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B5E9B1809561; Fri, 19 Jun 2020 12:39:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05J70x1M014932 for ; Fri, 19 Jun 2020 03:00:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id F09542157F23; Fri, 19 Jun 2020 07:00:58 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC2FD2166B27 for ; Fri, 19 Jun 2020 07:00:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0F05A858EE2 for ; Fri, 19 Jun 2020 07:00:53 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-1-SHlXO5ElMZiVGIJjFGELyg-1; Fri, 19 Jun 2020 03:00:48 -0400 X-MC-Unique: SHlXO5ElMZiVGIJjFGELyg-1 IronPort-SDR: n1/Xiug9MiwF4QcHCtqu+L7j12jKul+gqp71GOHUE8/w8AakeRHM3VFrZzJneRdmL9hF3tTQ30 tslb1cwmOBdxdTjJyVuJAySU3hhpsde5QLn2akflVg7FnnBPxpeTJjJ/wTiEBlWLEc7QVqgKHA zaun/Ygvj4zTlTUoIQ8w54mf92F/nH8Rrws6yJLWrmiwQCuG+1ngHSCONbtuqx4Xu+BorVnJ+p ffILxVcHVG32A6ZWy3BRjEQrfB5hwP8bJ/7GARYAddtq5NvC0UEwsvKFOUu5nTbUhDNDfd6l+8 rRg= X-IronPort-AV: E=Sophos;i="5.75,254,1589212800"; d="scan'208";a="140655411" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:59:37 +0800 IronPort-SDR: mrg4TEupsTLl7lp7U7uLU71SaybhOUczbkygLnpIKvEZgbDQGDwpNHsOvyYoaFeWqo2zSl0H2n lnFAK/0xeTFiPXzHhHcKbabJ7PXEBiJI4= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2020 23:48:15 -0700 IronPort-SDR: u9Kv7E5QQyn81KViuTNae0YHX8OB5WFteqds4KJ20uGT18MTcG0vVXBqTzpxKdWm3w6lFrM5dR EykqgG4lWh6g== WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 18 Jun 2020 23:59:36 -0700 From: Johannes Thumshirn To: Mike Snitzer Date: Fri, 19 Jun 2020 15:59:05 +0900 Message-Id: <20200619065905.22228-3-johannes.thumshirn@wdc.com> In-Reply-To: <20200619065905.22228-1-johannes.thumshirn@wdc.com> References: <20200619065905.22228-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 19 Jun 2020 08:38:54 -0400 Cc: linux-block@vger.kernel.org, Naohiro Aota , dm-devel@redhat.com, Damien Le Moal , Johannes Thumshirn Subject: [dm-devel] [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com REQ_OP_ZONE_APPEND bios cannot be split so return EIO if we can't fit it into one IO. Signed-off-by: Johannes Thumshirn --- drivers/md/dm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 058c34abe9d1..c720a7e3269a 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1609,6 +1609,9 @@ static int __split_and_process_non_flush(struct clone_info *ci) len = min_t(sector_t, max_io_len(ci->sector, ti), ci->sector_count); + if (bio_op(ci->bio) == REQ_OP_ZONE_APPEND && len < ci->sector_count) + return -EIO; + r = __clone_and_map_data_bio(ci, ti, ci->sector, &len); if (r < 0) return r;