Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8509238ybl; Thu, 16 Jan 2020 18:24:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyGp2wLMMU8f3MWz+N1gcZP+zkJfd3J9d9G9Os4ztVKTheMfzSV7Jbjm5EqhvFW4Nft2hDj X-Received: by 2002:a05:6808:658:: with SMTP id z24mr1801484oih.91.1579227851230; Thu, 16 Jan 2020 18:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579227851; cv=none; d=google.com; s=arc-20160816; b=CxgtR5FJrtfrwJBsxmx5kz3W0WYs0VB8UvQdt2ZG1uFORHd25PD2/wpk5EM1P/9ICq +C3I4ReSJBoT6LuL7cCLvNw1EReR13KOiWuvc7PYZCbTaJjhD74uM+aSZeJD0dUAzsdK CKknjjPiivKcP1cjtBaHBF9NIeylnL32cQpb3kXy8JwTegW9rpMtjtE8rSKVraRRe8Lq fJCKE6yXO3L2NLBW1/xh7hrg84ZtKKlphm7e1xB3egdWbhZP6VdeUVaZyeYNk7mVxmZg 16VXMWFwxHd1WQV+lcqjVunM6hggogydwcczoAhjPpco/DrDLphdjBUBibLg3pKpc1MG pn9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=v2KFJ69gm5VTBv1RZbda3SyhnhIZZ/PVSFjAVHaliDw=; b=iMY2zWXPXHsKrLfIm/Qk7hheBcL/oZqEhrhfMbiHT2pnOAxpUqm2EEWRJiI5Au9I5s J+gMCkTV2SWzaQAeO9geanJHcLCbsoWY80R3BkZ/eLS/nNpUDcq9h/Q3x3E9GG0h6qfH KwMeqkCq21pj4Ofu6kW3jTwaRqB7gyDYRNZ+FLXMMkj1vaT7qZaYNVLkeGX0uM4hIutZ zac/evSHhgnu7dwOHP5taGy/75KlQu/A8b+1fEKfYD7ku6mbusZTRwedcwoiPiivh10W S8InH0IHOCrZVn1U3DvKv1EW0YIAy8pfvCMTgmt48Me+fLBwOaSL5oaK2IroUMt2oWtu kIXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="l418/EnE"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l84si12242114oig.5.2020.01.16.18.23.59; Thu, 16 Jan 2020 18:24:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="l418/EnE"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388581AbgAPX1j (ORCPT + 99 others); Thu, 16 Jan 2020 18:27:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:59544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390267AbgAPX1f (ORCPT ); Thu, 16 Jan 2020 18:27:35 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A066B2072E; Thu, 16 Jan 2020 23:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217255; bh=2slIPSeN0K9COdPi9pHFU+IzZRcSjCu1x7KhCyX6gMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l418/EnECoOQeNJBryjRavVU3r8TUpZWpS7NX1F9LjZ/Zru4611wzNJGYoScEepWW 33ZPLt8TNFFwS5Uw4z608/+OPj0FwhKuAGPPHPMGUf2qSmfnOiX1F4YG1eNF3ARB5Q C8l1piM8eRwhoMjstcWwQTbdF3yVIF3mEZZfku+w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Israel Rukshin , Max Gurtovoy , Sagi Grimberg , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 183/203] scsi: target/iblock: Fix protection error with blocks greater than 512B Date: Fri, 17 Jan 2020 00:18:20 +0100 Message-Id: <20200116231800.360412824@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Israel Rukshin [ Upstream commit e4dc9a4c31fe10d1751c542702afc85be8a5c56a ] The sector size of the block layer is 512 bytes, but integrity interval size might be different (in case of 4K block size of the media). At the initiator side the virtual start sector is the one that was originally submitted by the block layer (512 bytes) for the Reftag usage. The initiator converts the Reftag to integrity interval units and sends it to the target. So the target virtual start sector should be calculated at integrity interval units. prepare_fn() and complete_fn() don't remap correctly the Reftag when using incorrect units of the virtual start sector, which leads to the following protection error at the device: "blk_update_request: protection error, dev sdb, sector 2048 op 0x0:(READ) flags 0x10000 phys_seg 1 prio class 0" To fix that, set the seed in integrity interval units. Link: https://lore.kernel.org/r/1576078562-15240-1-git-send-email-israelr@mellanox.com Signed-off-by: Israel Rukshin Reviewed-by: Max Gurtovoy Reviewed-by: Sagi Grimberg Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/target/target_core_iblock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 6949ea8bc387..51ffd5c002de 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -646,7 +646,9 @@ iblock_alloc_bip(struct se_cmd *cmd, struct bio *bio, } bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio)); - bip_set_seed(bip, bio->bi_iter.bi_sector); + /* virtual start sector must be in integrity interval units */ + bip_set_seed(bip, bio->bi_iter.bi_sector >> + (bi->interval_exp - SECTOR_SHIFT)); pr_debug("IBLOCK BIP Size: %u Sector: %llu\n", bip->bip_iter.bi_size, (unsigned long long)bip->bip_iter.bi_sector); -- 2.20.1