From patchwork Fri May 31 07:48:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 800866 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B3F974BF8; Fri, 31 May 2024 07:49:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717141745; cv=none; b=PQ2me/H3o3chr2ffhBf4KIg8x5ICwbhqKT93+EMaHfCcPpB3UiuZ9Zuzv7wH9VU36A2XC/BNgRaDIJsblKg/GvijKTjtbRCUga5CnOrpMXfDedQrMg8+X+PlZ9RoGJP53EkwVjnV7YMEnDZEgXx+KGFiRhwz9ekh4MZ9MdhpagM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717141745; c=relaxed/simple; bh=zom7OvhqgUyafDB1RqHo90k13agYhq0fGJ1QtjCs1r8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jZkjfjLEt3xZtvtYrKnGNhx3bDPXjZ/h3WsZIcHcQZrDwT4CcMF/Vss9lCryktXaX4xnqu9hZgC6NXvN6GGaDA+/67eXpV1zXfI0Aq/NFpW4kaP7WethM1l2SNUMq7K+w37V3IUIVpeZhNeuBxj1jGLEw8GNa0DM+D9QQ4MENBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=mCfAB2Q3; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="mCfAB2Q3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=G254IYRsUd/F6t4PlJahixfTtyWkS+KjkuNozPFW2uM=; b=mCfAB2Q3IG7ARRB/1pICP3EKhx BtsvlSjEu+mUGJHdLHTvoJOmfRKjXxZbNxLy4KOfOIoTiP37YS600VEXpgV/uP9orX00qlWer8q/4 MqGvCypDXaIwvVXmRrJ1K8o1tyNVFri/wRN+r8xhPtEgtnttXcI2/uR1po1i3iqcBuzQdmttvNtJF oChxsdFiMIHdgU8Fvaju7qPUGHzeaRTfRR1LK2zbdzzOelGNuR2nbzEhvJ15Xap/+vOuczm4IhNaA 4KPN2ftKI7ksG9v6J9jDdoyHPHRrn7UXV85lXH0GCoodOce35RcaAaP3IEmY28xn6qGm+n9XQh5zR gLnZ0o+w==; Received: from 2a02-8389-2341-5b80-5ba9-f4da-76fa-44a9.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:5ba9:f4da:76fa:44a9] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCx0V-00000009Xcv-0vGx; Fri, 31 May 2024 07:48:59 +0000 From: Christoph Hellwig To: Jens Axboe , "Martin K. Petersen" Cc: Richard Weinberger , Anton Ivanov , Johannes Berg , Josef Bacik , Ilya Dryomov , Dongsheng Yang , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , linux-um@lists.infradead.org, linux-block@vger.kernel.org, nbd@other.debian.org, ceph-devel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-scsi@vger.kernel.org, Bart Van Assche , Damien Le Moal Subject: [PATCH 06/14] sd: add a sd_disable_discard helper Date: Fri, 31 May 2024 09:48:01 +0200 Message-ID: <20240531074837.1648501-7-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240531074837.1648501-1-hch@lst.de> References: <20240531074837.1648501-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Add helper to disable discard when it is not supported and use it instead of sd_config_discard in the I/O completion handler. This avoids touching more fields than required in the I/O completion handler and prepares for converting sd to use the atomic queue limits API. Signed-off-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Damien Le Moal Reviewed-by: Martin K. Petersen --- drivers/scsi/sd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 83aa17fea39d39..f07d90474e682b 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -821,6 +821,12 @@ static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd, return protect; } +static void sd_disable_discard(struct scsi_disk *sdkp) +{ + sdkp->provisioning_mode = SD_LBP_DISABLE; + blk_queue_max_discard_sectors(sdkp->disk->queue, 0); +} + static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) { struct request_queue *q = sdkp->disk->queue; @@ -2245,12 +2251,12 @@ static int sd_done(struct scsi_cmnd *SCpnt) case 0x24: /* INVALID FIELD IN CDB */ switch (SCpnt->cmnd[0]) { case UNMAP: - sd_config_discard(sdkp, SD_LBP_DISABLE); + sd_disable_discard(sdkp); break; case WRITE_SAME_16: case WRITE_SAME: if (SCpnt->cmnd[1] & 8) { /* UNMAP */ - sd_config_discard(sdkp, SD_LBP_DISABLE); + sd_disable_discard(sdkp); } else { sdkp->device->no_write_same = 1; sd_config_write_same(sdkp);