Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8164029imu; Fri, 28 Dec 2018 11:52:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Ll3eHPj+9438AVGE3tE4jTPebLPwyO4R3QPdgJh6MMQZVN9lmL/oxVPrn3AU8lvvBxJ0C X-Received: by 2002:a63:d450:: with SMTP id i16mr27153648pgj.246.1546026725457; Fri, 28 Dec 2018 11:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546026725; cv=none; d=google.com; s=arc-20160816; b=g1w32Wv3SjV2UZSBFXlqz2OVD3jvdul9or1uYzb/N6svIKBzdoC2pk1KzeunIo2Kvz D5vFCaLMoErJio2AYUT+8GWJvqg7K/9KX+yUgYAul7/Q+xWic2vyWX2t/bYyNWrcNhCw FHqy58uAMRv3SVVXqc8ZOXJ+rHzDMbTDPcKBBRYeWzTUh5iu4bBj/XwZ4IENbg4z3bw6 wrCJ3RPGQrCAUG2DRbjOSoiQ39fgThw3BJEha2naAzZGEvNZMcD+DW06qGemQLjDprAw IaZ0l/UXBCcYae4uRP2k0+ZJBam+S2WoHMd83somKL/BXqb6Ax0RufotTr3U78r9a4WW 7bog== 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=xIH+F6PaNQc0E4gvXJbdhzJnyn4+dtIi3Lb68JoFJs4=; b=jzoavE6HGpEs8SJuExbnljh5qX/C6ltXJN5qW6AFmsEALInYuBLXTl3PY26xxt8TsM PHIZxv5lIPIiVjRbKSjNKDYr2lSsrHSolmIKGbuLx5Yv34u+VOJgbThkWHTg/bcPREW8 CFak2uMftYV7Ykkde+O5tpD8XBTjbvY72wZhwcKvUxWHsa8uAIw30WbfqSUSge8TZAmM nm+lzIrYNlnIhYdwamVWktooaX/aX4KMuL6PNJtQVwoGtlr1l/u0+tJTbim4+BYQZ6uP qBPkyGBuIhnshVCcsoSEuBqZ4S8Zy/8yqAqIudfnK8PJ+gxvdDYr6giX4LE5eUmUDLuw 0HNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N39k25M7; 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 b36si3931003pla.354.2018.12.28.11.51.50; Fri, 28 Dec 2018 11:52:05 -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=N39k25M7; 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 S1731271AbeL1LxQ (ORCPT + 99 others); Fri, 28 Dec 2018 06:53:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:53034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbeL1LxP (ORCPT ); Fri, 28 Dec 2018 06:53:15 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 6E5282087F; Fri, 28 Dec 2018 11:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545997994; bh=MBhSwKKg5lfZpzbUPh5KYKXA/kZR9RRw5pueXoRO2YI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N39k25M7noQkatSRTg4z0fx891U4UIUYRHs1RteaOVb45q4z7MrODMKNUruRzRIcx aWcRfaUDeablzG25wqKgtZWuUMeLf8Fzew7lIOhfZn3H59BlkHBsftea57qeKVSdeB 7oEiarlgV//hQzUlXrlBu+UAJRUub59o6J3MQtpY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Garry , Xiang Chen , "Martin K. Petersen" Subject: [PATCH 4.19 12/46] scsi: t10-pi: Return correct ref tag when queue has no integrity profile Date: Fri, 28 Dec 2018 12:52:06 +0100 Message-Id: <20181228113125.503803504@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181228113124.971620049@linuxfoundation.org> References: <20181228113124.971620049@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin K. Petersen commit 60a89a3ce0cce515dc663bc1b45ac89202ad6c79 upstream. Commit ddd0bc756983 ("block: move ref_tag calculation func to the block layer") moved ref tag calculation from SCSI to a library function. However, this change broke returning the correct ref tag for devices operating in DIF mode since these do not have an associated block integrity profile. This in turn caused read/write failures on PI-formatted disks attached to an mpt3sas controller. Fixes: ddd0bc756983 ("block: move ref_tag calculation func to the block layer") Cc: stable@vger.kernel.org # 4.19+ Reported-by: John Garry Tested-by: Xiang Chen Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- include/linux/t10-pi.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/include/linux/t10-pi.h +++ b/include/linux/t10-pi.h @@ -39,12 +39,13 @@ struct t10_pi_tuple { static inline u32 t10_pi_ref_tag(struct request *rq) { + unsigned int shift = ilog2(queue_logical_block_size(rq->q)); + #ifdef CONFIG_BLK_DEV_INTEGRITY - return blk_rq_pos(rq) >> - (rq->q->integrity.interval_exp - 9) & 0xffffffff; -#else - return -1U; + if (rq->q->integrity.interval_exp) + shift = rq->q->integrity.interval_exp; #endif + return blk_rq_pos(rq) >> (shift - SECTOR_SHIFT) & 0xffffffff; } extern const struct blk_integrity_profile t10_pi_type1_crc;