From patchwork Mon Aug 5 23:42:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 817332 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 8185E273FD for ; Mon, 5 Aug 2024 23:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901402; cv=none; b=CNNA8vDolkYcTVrI+gXoRkwQz26haCraJvcIM2E0lO/PgnzjXeLFZVUJy45r7ZPm3pRHPBfHUIqJAFIlRocInPOkcs8+xTl1pyULaoU0++WvteQ5GSqG19X/XW2HDn5hICe5EClX7bOkBBD9ztHml1mnm+FmQxwj1pugcsjJSi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901402; c=relaxed/simple; bh=e5fkY0n3fW1lqgdeO2n+Ho88k6KSEVpKmggXJAp4R6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=djA4wLcagDVEAD8EAOBRvONugw4xBtYEW0b8NmlAfh54UpvdaJQJsSQ6t0nMHd93EdDCh7R/MD5KGm5BgxiiEcdvZLsJsxOf6tUS25eGEZOmAC8RqeAHdh+Em4FwDTL/Dq4aVGmKroYF6m3KNFkxd2hWuPnT+7Ja7drVZgdp++M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=sivXqJ0D; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="sivXqJ0D" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WdCgD0BYZz6ClY9H; Mon, 5 Aug 2024 23:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1722901396; x=1725493397; bh=QcdTI NhVsKwz1ArBmBkszqPppUXUT84ZQluMtjS8RMs=; b=sivXqJ0DvHAP/JnoMahUG xGaZ4GZkDOaLZm35OaVmdBOFcZA8pW59+le5vFJvgLIZzcNFNnlcBxHRFtrs/eUw L0sz9XeCEAciYrZjmHwKrocsfz4lvo0ccZfdKlz8nnoa7SyFN27JCXayFXTW+uML c+CIklsnZgFJCViehmWPnQHDaNl8G0SUID8DzvGAR3jo9UluyCE8ZKnzguoZlkxS 9gBsfCpXcbkWhp2KYtAjVuaZfgk/sppelE8KXSXkrbIrAIYKOYHJ1yY6rKJqLygB XvSWXOGn1tLDRC6XyhJ3xqPIiRd/D3ZyOgGisPyEMQ0ucgzDhu4LKTkf+l1KdKnU Q== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id P4v39udq5Rab; Mon, 5 Aug 2024 23:43:16 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WdCg659Skz6ClY9C; Mon, 5 Aug 2024 23:43:14 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Damien Le Moal , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v2 1/6] scsi: sd: Move the sd_remove() function definition Date: Mon, 5 Aug 2024 16:42:44 -0700 Message-ID: <20240805234250.271828-2-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240805234250.271828-1-bvanassche@acm.org> References: <20240805234250.271828-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the sd_remove() function definition such that the sd_shutdown() forward declaration can be removed. Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/sd.c | 53 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8bb3a3611851..50be1f01f1c2 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -109,7 +109,6 @@ static void sd_config_write_same(struct scsi_disk *sdkp, struct queue_limits *lim); static int sd_revalidate_disk(struct gendisk *); static void sd_unlock_native_capacity(struct gendisk *disk); -static void sd_shutdown(struct device *); static void scsi_disk_release(struct device *cdev); static DEFINE_IDA(sd_index_ida); @@ -4042,32 +4041,6 @@ static int sd_probe(struct device *dev) return error; } -/** - * sd_remove - called whenever a scsi disk (previously recognized by - * sd_probe) is detached from the system. It is called (potentially - * multiple times) during sd module unload. - * @dev: pointer to device object - * - * Note: this function is invoked from the scsi mid-level. - * This function potentially frees up a device name (e.g. /dev/sdc) - * that could be re-used by a subsequent sd_probe(). - * This function is not called when the built-in sd driver is "exit-ed". - **/ -static int sd_remove(struct device *dev) -{ - struct scsi_disk *sdkp = dev_get_drvdata(dev); - - scsi_autopm_get_device(sdkp->device); - - device_del(&sdkp->disk_dev); - del_gendisk(sdkp->disk); - if (!sdkp->suspended) - sd_shutdown(dev); - - put_disk(sdkp->disk); - return 0; -} - static void scsi_disk_release(struct device *dev) { struct scsi_disk *sdkp = to_scsi_disk(dev); @@ -4147,6 +4120,32 @@ static void sd_shutdown(struct device *dev) } } +/** + * sd_remove - called whenever a scsi disk (previously recognized by + * sd_probe) is detached from the system. It is called (potentially + * multiple times) during sd module unload. + * @dev: pointer to device object + * + * Note: this function is invoked from the scsi mid-level. + * This function potentially frees up a device name (e.g. /dev/sdc) + * that could be re-used by a subsequent sd_probe(). + * This function is not called when the built-in sd driver is "exit-ed". + **/ +static int sd_remove(struct device *dev) +{ + struct scsi_disk *sdkp = dev_get_drvdata(dev); + + scsi_autopm_get_device(sdkp->device); + + device_del(&sdkp->disk_dev); + del_gendisk(sdkp->disk); + if (!sdkp->suspended) + sd_shutdown(dev); + + put_disk(sdkp->disk); + return 0; +} + static inline bool sd_do_start_stop(struct scsi_device *sdev, bool runtime) { return (sdev->manage_system_start_stop && !runtime) || From patchwork Mon Aug 5 23:42:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 816930 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 01AF1273FD for ; Mon, 5 Aug 2024 23:43:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901404; cv=none; b=XudAEnFTk6VpPjhZnCjgAxoM6OAmO0/Jlvy8DlzLetPFg5UJ3I2AjCqL0gznVRzAeDu80Ck97dcUeJZ4a7Dg/8xlqA6T4OkjfOGmG4mdAYWUu8x8pbmeB5kOEqH1G7zVyKVy6fpQrKFuSTu58AeIVYtqO2cwvY6yl8PIYKRRrVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901404; c=relaxed/simple; bh=RCgiNx69mKEvbPwxKIrfAgYU6gxYPRTeoHT+yf6mBh0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JrflHGcsn+zNaa0bt/yB7qukYUZe5V+FlPMmBX3SUuij5ZT1YshM7N0q0DTe9aewCkSffu9n22VA8ZmNIRFdKJ9TVaGnBcNA3rMxML9D+6CYvlixtgi+d6nVyutd4uX5/GM8bLmzgZRA0j/5ePa6bOD27grY0I2cR8D405nuKrs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=1TP2UAHl; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="1TP2UAHl" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WdCgG3VCLz6ClY9H; Mon, 5 Aug 2024 23:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1722901398; x=1725493399; bh=gunkQ RB4dNOtR+VKS6eEAaWx2OxD823cAftWHYAQan8=; b=1TP2UAHlT31B6cVCGOYTW k4+wqnhOGDuvc7twAN4C0H9CWTLtu9kc6HgN7yELbSsdo9NeFc9T6xcwj68nwFe2 x019piaDnvbcH8bRkLAu6OiJMJmvQW0jvJkwRzVGtfPvjwcckog0bb2UY9Ra1Otg 6PLSwHLpV4F8su7oVs+SFRoaAvQoc2A+LdCz4c2pf/j0f2CkZjGc/Nq+R498Ubn2 ezy0bFMGaG4o7V6xnh3CD9rzBpcMBZWxkzb5KBYxcNPuXv1TrM8J4swgnyq4y5S+ d2xL7wovuH2ERcWYonIPVXv2o1/sRc2YMboGUychcANdszB1tsN4xpo3Z3tMydGG Q== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id UeLukZ-EbO1s; Mon, 5 Aug 2024 23:43:18 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WdCg85J6Mz6CmLxj; Mon, 5 Aug 2024 23:43:16 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Damien Le Moal , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v2 2/6] scsi: sd: Move the sd_config_discard() function definition Date: Mon, 5 Aug 2024 16:42:45 -0700 Message-ID: <20240805234250.271828-3-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240805234250.271828-1-bvanassche@acm.org> References: <20240805234250.271828-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the sd_config_discard() function definition such that its forward declaration can be removed. Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/sd.c | 114 +++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 50be1f01f1c2..61a0c02b3246 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -103,8 +103,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_ZBC); #define SD_MINORS 16 -static void sd_config_discard(struct scsi_disk *sdkp, struct queue_limits *lim, - unsigned int mode); static void sd_config_write_same(struct scsi_disk *sdkp, struct queue_limits *lim); static int sd_revalidate_disk(struct gendisk *); @@ -121,6 +119,62 @@ static const char *sd_cache_types[] = { "write back, no read (daft)" }; +static void sd_disable_discard(struct scsi_disk *sdkp) +{ + sdkp->provisioning_mode = SD_LBP_DISABLE; + blk_queue_disable_discard(sdkp->disk->queue); +} + +static void sd_config_discard(struct scsi_disk *sdkp, struct queue_limits *lim, + unsigned int mode) +{ + unsigned int logical_block_size = sdkp->device->sector_size; + unsigned int max_blocks = 0; + + lim->discard_alignment = sdkp->unmap_alignment * logical_block_size; + lim->discard_granularity = max(sdkp->physical_block_size, + sdkp->unmap_granularity * logical_block_size); + sdkp->provisioning_mode = mode; + + switch (mode) { + + case SD_LBP_FULL: + case SD_LBP_DISABLE: + break; + + case SD_LBP_UNMAP: + max_blocks = min_not_zero(sdkp->max_unmap_blocks, + (u32)SD_MAX_WS16_BLOCKS); + break; + + case SD_LBP_WS16: + if (sdkp->device->unmap_limit_for_ws) + max_blocks = sdkp->max_unmap_blocks; + else + max_blocks = sdkp->max_ws_blocks; + + max_blocks = min_not_zero(max_blocks, (u32)SD_MAX_WS16_BLOCKS); + break; + + case SD_LBP_WS10: + if (sdkp->device->unmap_limit_for_ws) + max_blocks = sdkp->max_unmap_blocks; + else + max_blocks = sdkp->max_ws_blocks; + + max_blocks = min_not_zero(max_blocks, (u32)SD_MAX_WS10_BLOCKS); + break; + + case SD_LBP_ZERO: + max_blocks = min_not_zero(sdkp->max_ws_blocks, + (u32)SD_MAX_WS10_BLOCKS); + break; + } + + lim->max_hw_discard_sectors = max_blocks * + (logical_block_size >> SECTOR_SHIFT); +} + static void sd_set_flush_flag(struct scsi_disk *sdkp, struct queue_limits *lim) { @@ -841,62 +895,6 @@ 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_disable_discard(sdkp->disk->queue); -} - -static void sd_config_discard(struct scsi_disk *sdkp, struct queue_limits *lim, - unsigned int mode) -{ - unsigned int logical_block_size = sdkp->device->sector_size; - unsigned int max_blocks = 0; - - lim->discard_alignment = sdkp->unmap_alignment * logical_block_size; - lim->discard_granularity = max(sdkp->physical_block_size, - sdkp->unmap_granularity * logical_block_size); - sdkp->provisioning_mode = mode; - - switch (mode) { - - case SD_LBP_FULL: - case SD_LBP_DISABLE: - break; - - case SD_LBP_UNMAP: - max_blocks = min_not_zero(sdkp->max_unmap_blocks, - (u32)SD_MAX_WS16_BLOCKS); - break; - - case SD_LBP_WS16: - if (sdkp->device->unmap_limit_for_ws) - max_blocks = sdkp->max_unmap_blocks; - else - max_blocks = sdkp->max_ws_blocks; - - max_blocks = min_not_zero(max_blocks, (u32)SD_MAX_WS16_BLOCKS); - break; - - case SD_LBP_WS10: - if (sdkp->device->unmap_limit_for_ws) - max_blocks = sdkp->max_unmap_blocks; - else - max_blocks = sdkp->max_ws_blocks; - - max_blocks = min_not_zero(max_blocks, (u32)SD_MAX_WS10_BLOCKS); - break; - - case SD_LBP_ZERO: - max_blocks = min_not_zero(sdkp->max_ws_blocks, - (u32)SD_MAX_WS10_BLOCKS); - break; - } - - lim->max_hw_discard_sectors = max_blocks * - (logical_block_size >> SECTOR_SHIFT); -} - static void *sd_set_special_bvec(struct request *rq, unsigned int data_len) { struct page *page; From patchwork Mon Aug 5 23:42:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 816929 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 3D6E9149C4E for ; Mon, 5 Aug 2024 23:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901407; cv=none; b=YVKuZGDKUjl11GboLa5tF6veroIt71ZSImf0gkNIxW74KkVzwZGS0bwZX7TsCvPm7xkS8uF0jgTAoG+slm3RbonP4Hsi4tsRUwLMDAwkntvHMxQ4E/PBHYcQRtRJfFk2pYi6pxauNiHc2tl0egJQNuKb1cth0kMLiF5pgDXB6M8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901407; c=relaxed/simple; bh=REw2I9pPmIVucGWocpWPRdU0am64MZRGRT2JH1qcR1I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q961TL10gDmyiyGuibNgRdvRsMbAaLG1RtSNoj5HN/p0gLfOpRsCvtX6qIZtTvDzZ50mgxh3XsJ3ceuHpsValwopv2zwUcfXUSgmL7pPuuT11+chPPVETVNJc91kuWqCtCSU4EzU41ST8duD5Kv5KP/4cz2h331FpF+dBxHr10E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=G5NAkDhB; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="G5NAkDhB" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WdCgK4jjCz6ClY9J; Mon, 5 Aug 2024 23:43:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1722901400; x=1725493401; bh=4XT0S rONfjEb1ffWqUTIkv9d69z3UZIkUKzmnGU1n6o=; b=G5NAkDhBdQnEaZ7Itp/+I 3VpwXmMDfTlmer68dcK1mtg838LoOSUW+jEkb1o/viZ86gzmkBAf6OQF/b9TwWZf 2JFzCeJrgyGd84iuv3NYMSAFBAT49QpOI3dVoZeGrrxE8ldPcKvmGHPbIwFI5NV+ vCEIFbY5ll2WkIpV9/ZRndw+fyRCXgOBrN2xDuPLy0FJQdG6zEI5BM67HBP3wtEZ 06KMtP1vJp9x5Ho2/CkV5vOJqzW5k/VOdS8/zaIT1b0jJPmfzBuQT3ct76UUO4O/ K4Rxx2OmasS+dqnhGo1zzKmXibdg7zN5t3MjT7CBpPeyuBDIsmC1lMXQ4g4OhRX1 A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id JbcfuetAOZqq; Mon, 5 Aug 2024 23:43:20 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WdCgB5X0yz6ClY9F; Mon, 5 Aug 2024 23:43:18 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Damien Le Moal , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v2 3/6] scsi: sd: Move the sd_config_write_same() function definition Date: Mon, 5 Aug 2024 16:42:46 -0700 Message-ID: <20240805234250.271828-4-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240805234250.271828-1-bvanassche@acm.org> References: <20240805234250.271828-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the sd_config_write_same() function definition such that its forward declaration can be removed. Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/sd.c | 136 +++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 69 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 61a0c02b3246..b9a9b24ff027 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -103,8 +103,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_ZBC); #define SD_MINORS 16 -static void sd_config_write_same(struct scsi_disk *sdkp, - struct queue_limits *lim); static int sd_revalidate_disk(struct gendisk *); static void sd_unlock_native_capacity(struct gendisk *disk); static void scsi_disk_release(struct device *cdev); @@ -175,6 +173,73 @@ static void sd_config_discard(struct scsi_disk *sdkp, struct queue_limits *lim, (logical_block_size >> SECTOR_SHIFT); } +static void sd_disable_write_same(struct scsi_disk *sdkp) +{ + sdkp->device->no_write_same = 1; + sdkp->max_ws_blocks = 0; + blk_queue_disable_write_zeroes(sdkp->disk->queue); +} + +static void sd_config_write_same(struct scsi_disk *sdkp, + struct queue_limits *lim) +{ + unsigned int logical_block_size = sdkp->device->sector_size; + + if (sdkp->device->no_write_same) { + sdkp->max_ws_blocks = 0; + goto out; + } + + /* Some devices can not handle block counts above 0xffff despite + * supporting WRITE SAME(16). Consequently we default to 64k + * blocks per I/O unless the device explicitly advertises a + * bigger limit. + */ + if (sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS) + sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, + (u32)SD_MAX_WS16_BLOCKS); + else if (sdkp->ws16 || sdkp->ws10 || sdkp->device->no_report_opcodes) + sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, + (u32)SD_MAX_WS10_BLOCKS); + else { + sdkp->device->no_write_same = 1; + sdkp->max_ws_blocks = 0; + } + + if (sdkp->lbprz && sdkp->lbpws) + sdkp->zeroing_mode = SD_ZERO_WS16_UNMAP; + else if (sdkp->lbprz && sdkp->lbpws10) + sdkp->zeroing_mode = SD_ZERO_WS10_UNMAP; + else if (sdkp->max_ws_blocks) + sdkp->zeroing_mode = SD_ZERO_WS; + else + sdkp->zeroing_mode = SD_ZERO_WRITE; + + if (sdkp->max_ws_blocks && + sdkp->physical_block_size > logical_block_size) { + /* + * Reporting a maximum number of blocks that is not aligned + * on the device physical size would cause a large write same + * request to be split into physically unaligned chunks by + * __blkdev_issue_write_zeroes() even if the caller of this + * functions took care to align the large request. So make sure + * the maximum reported is aligned to the device physical block + * size. This is only an optional optimization for regular + * disks, but this is mandatory to avoid failure of large write + * same requests directed at sequential write required zones of + * host-managed ZBC disks. + */ + sdkp->max_ws_blocks = + round_down(sdkp->max_ws_blocks, + bytes_to_logical(sdkp->device, + sdkp->physical_block_size)); + } + +out: + lim->max_write_zeroes_sectors = + sdkp->max_ws_blocks * (logical_block_size >> SECTOR_SHIFT); +} + static void sd_set_flush_flag(struct scsi_disk *sdkp, struct queue_limits *lim) { @@ -1078,73 +1143,6 @@ static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd) return sd_setup_write_same10_cmnd(cmd, false); } -static void sd_disable_write_same(struct scsi_disk *sdkp) -{ - sdkp->device->no_write_same = 1; - sdkp->max_ws_blocks = 0; - blk_queue_disable_write_zeroes(sdkp->disk->queue); -} - -static void sd_config_write_same(struct scsi_disk *sdkp, - struct queue_limits *lim) -{ - unsigned int logical_block_size = sdkp->device->sector_size; - - if (sdkp->device->no_write_same) { - sdkp->max_ws_blocks = 0; - goto out; - } - - /* Some devices can not handle block counts above 0xffff despite - * supporting WRITE SAME(16). Consequently we default to 64k - * blocks per I/O unless the device explicitly advertises a - * bigger limit. - */ - if (sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS) - sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, - (u32)SD_MAX_WS16_BLOCKS); - else if (sdkp->ws16 || sdkp->ws10 || sdkp->device->no_report_opcodes) - sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, - (u32)SD_MAX_WS10_BLOCKS); - else { - sdkp->device->no_write_same = 1; - sdkp->max_ws_blocks = 0; - } - - if (sdkp->lbprz && sdkp->lbpws) - sdkp->zeroing_mode = SD_ZERO_WS16_UNMAP; - else if (sdkp->lbprz && sdkp->lbpws10) - sdkp->zeroing_mode = SD_ZERO_WS10_UNMAP; - else if (sdkp->max_ws_blocks) - sdkp->zeroing_mode = SD_ZERO_WS; - else - sdkp->zeroing_mode = SD_ZERO_WRITE; - - if (sdkp->max_ws_blocks && - sdkp->physical_block_size > logical_block_size) { - /* - * Reporting a maximum number of blocks that is not aligned - * on the device physical size would cause a large write same - * request to be split into physically unaligned chunks by - * __blkdev_issue_write_zeroes() even if the caller of this - * functions took care to align the large request. So make sure - * the maximum reported is aligned to the device physical block - * size. This is only an optional optimization for regular - * disks, but this is mandatory to avoid failure of large write - * same requests directed at sequential write required zones of - * host-managed ZBC disks. - */ - sdkp->max_ws_blocks = - round_down(sdkp->max_ws_blocks, - bytes_to_logical(sdkp->device, - sdkp->physical_block_size)); - } - -out: - lim->max_write_zeroes_sectors = - sdkp->max_ws_blocks * (logical_block_size >> SECTOR_SHIFT); -} - static blk_status_t sd_setup_flush_cmnd(struct scsi_cmnd *cmd) { struct request *rq = scsi_cmd_to_rq(cmd); From patchwork Mon Aug 5 23:42:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 817331 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 92F56273FD for ; Mon, 5 Aug 2024 23:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901407; cv=none; b=clgbXeVMLwRBquoLTczZQxLTqAP1syHSRSJOLv9ttLOOf9aqJZ4m9oQdvOQE3mambupkfyJQUKm1dy9PfyIQ9GsUcCaZgtIwaAwSyQ9FYFOpABIjQeeoqFuz2E9e35uOZEvadoiHa4qBwGMmw31//DaDifDTO5EI0Q/CwWnRJYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901407; c=relaxed/simple; bh=lxl+D0WES0sW06H+yFy5cB2GNGcCdsrBrQ8FiKdqCH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X0c50tHosogoL1xis6QbIM3YAq+afqXOzPS2ZIgihdfQ4A+DwJhW3lit7fta31WnKPE5gbdNHHxxfP+kyU6v0/GD6dtFBHsos/sW9UGOnrctgeUkSWldun/4h9UymlmugyRN7QvCfKz3euCu7WLVcLQjWvEvDDE3faEQQo/7bZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=nbbgqGEU; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="nbbgqGEU" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WdCgJ75kKz6ClY9H; Mon, 5 Aug 2024 23:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1722901402; x=1725493403; bh=JzaFZ MKiOgbqdySnqAydHknCkQTB/lBxo+CdbudEK7g=; b=nbbgqGEUXDqIFoKU52DH/ qsJc4VN61xDQw+cMHCs97rns0YaZ9AfFJmKhN5Hnxjdac25J+TRb0s6kUUq7coWP hdktfSEoZ98MOX/jx/E5vbgwGmf4a3ENeEvsQu+pXzuFl6v8dZAz6l1+cEKwcKCq tpsNdihUCPX3TiNi5box/3TtcGkAVM6AVj+K3rrBjg7OuHoH2OH+R84Jg2/LUBls Q6AFSAoHdbNIAlTQk3FZ8oWMfx8OsHKt0faN1bkrPdWgVjjJV0HNhxGMr0AJcwcf WqiRf0TWuh/p8uli7Qlx+WBG4VhrtrvPqQvl8YxNAy8RD/MJQR7EyxExmdvlSrCI w== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id ydiJmoDE_aAp; Mon, 5 Aug 2024 23:43:22 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WdCgD5Z7Bz6ClY9C; Mon, 5 Aug 2024 23:43:20 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Damien Le Moal , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v2 4/6] scsi: sd: Move the scsi_disk_release() function definition Date: Mon, 5 Aug 2024 16:42:47 -0700 Message-ID: <20240805234250.271828-5-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240805234250.271828-1-bvanassche@acm.org> References: <20240805234250.271828-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the scsi_disk_release() function definition such that its forward declaration can be removed. Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/sd.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index b9a9b24ff027..0ee4c54401ec 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -105,7 +105,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_ZBC); static int sd_revalidate_disk(struct gendisk *); static void sd_unlock_native_capacity(struct gendisk *disk); -static void scsi_disk_release(struct device *cdev); static DEFINE_IDA(sd_index_ida); @@ -792,6 +791,17 @@ static struct attribute *sd_disk_attrs[] = { }; ATTRIBUTE_GROUPS(sd_disk); +static void scsi_disk_release(struct device *dev) +{ + struct scsi_disk *sdkp = to_scsi_disk(dev); + + ida_free(&sd_index_ida, sdkp->index); + put_device(&sdkp->device->sdev_gendev); + free_opal_dev(sdkp->opal_dev); + + kfree(sdkp); +} + static struct class sd_disk_class = { .name = "scsi_disk", .dev_release = scsi_disk_release, @@ -4037,17 +4047,6 @@ static int sd_probe(struct device *dev) return error; } -static void scsi_disk_release(struct device *dev) -{ - struct scsi_disk *sdkp = to_scsi_disk(dev); - - ida_free(&sd_index_ida, sdkp->index); - put_device(&sdkp->device->sdev_gendev); - free_opal_dev(sdkp->opal_dev); - - kfree(sdkp); -} - static int sd_start_stop_device(struct scsi_disk *sdkp, int start) { unsigned char cmd[6] = { START_STOP }; /* START_VALID */ From patchwork Mon Aug 5 23:42:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 817330 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 2C3F416F0C6 for ; Mon, 5 Aug 2024 23:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901409; cv=none; b=dKfAeEJvg2LdI/S8wUEvlo7MQXVR2dRB0zJtX2VrK9z000xbAwLxSeFSOsOjEAPcIoTTdJaHNd9vuwM7L/zi5MlgBkEHvn4f0OmXjyg5YLHlK80NGfJGRWZBcc3Y+9onPSWnvcHa4lh/Mj1SdmFNxQbhBGLibri+sWBtW3NI6L4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901409; c=relaxed/simple; bh=B3XNjMhJncUCh+F/iAezQzI7BU/tDUP/j+23cu9YpzA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EBj5xFSjYvX5kJCtwkD/eYp7IDyd+bh2fr3r0UzGF7v2X6LQmBr6U0utvhexjskbwXKNoTlP5PvPnrC1krfMuOky/HQDSQkLZTVQJCMjSC26THrxTUU9+/W3yI/oLdf56nT25kksBe8QdAHhb7qCvDVylhsAyT2xDaHHI+OxOoE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=Q/xOqrAx; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="Q/xOqrAx" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WdCgM4BHHz6ClY9F; Mon, 5 Aug 2024 23:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1722901404; x=1725493405; bh=hDyCL 32RWlbCwJpWdKdkJeAXlbLmdGhXtJqWA+HKuWs=; b=Q/xOqrAx/Mhz/SfUILSpY P5y18clvkAy+kqtmVjOUxSEsp6IyRlX+YY30lxVbbiPCX7ehQthOzPJwaBdnbEL2 BPHzzGViRltXKu50TM4/qcWhYIF6E1A+u3kED4gdwVCTHAKe5o3/VHwXqGAn9/4n /HxwT19fOro0RmpQS6zTeuQlWRUeggGJtp8kofd7JM5/HQPJQ2V1nCWi77S5NxLC yRgrTXir7BBk5brWjLNghDUo8bPZTK2A0ZqlG4hGAYE3dRfNYr4WH1eaqVzp2/pU 0kGvS1wqUbZfx04PQnLcf/KdgJKev1lNE0wvA6HdKCHT3u/7qOMDDuH13375mU4u A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id RhegGD3-5d3W; Mon, 5 Aug 2024 23:43:24 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WdCgG5d5Rz6CmLxj; Mon, 5 Aug 2024 23:43:22 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Damien Le Moal , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v2 5/6] scsi: sd: Move the sd_fops definition Date: Mon, 5 Aug 2024 16:42:48 -0700 Message-ID: <20240805234250.271828-6-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240805234250.271828-1-bvanassche@acm.org> References: <20240805234250.271828-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the sd_fops definition such that the sd_unlock_native_capacity() forward declaration can be removed. Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/sd.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 0ee4c54401ec..afd53ef2afcb 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -104,7 +104,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_ZBC); #define SD_MINORS 16 static int sd_revalidate_disk(struct gendisk *); -static void sd_unlock_native_capacity(struct gendisk *disk); static DEFINE_IDA(sd_index_ida); @@ -2140,21 +2139,6 @@ static void scsi_disk_free_disk(struct gendisk *disk) put_device(&sdkp->disk_dev); } -static const struct block_device_operations sd_fops = { - .owner = THIS_MODULE, - .open = sd_open, - .release = sd_release, - .ioctl = sd_ioctl, - .getgeo = sd_getgeo, - .compat_ioctl = blkdev_compat_ptr_ioctl, - .check_events = sd_check_events, - .unlock_native_capacity = sd_unlock_native_capacity, - .report_zones = sd_zbc_report_zones, - .get_unique_id = sd_get_unique_id, - .free_disk = scsi_disk_free_disk, - .pr_ops = &sd_pr_ops, -}; - /** * sd_eh_reset - reset error handling callback * @scmd: sd-issued command that has failed @@ -3845,6 +3829,21 @@ static void sd_unlock_native_capacity(struct gendisk *disk) sdev->host->hostt->unlock_native_capacity(sdev); } +static const struct block_device_operations sd_fops = { + .owner = THIS_MODULE, + .open = sd_open, + .release = sd_release, + .ioctl = sd_ioctl, + .getgeo = sd_getgeo, + .compat_ioctl = blkdev_compat_ptr_ioctl, + .check_events = sd_check_events, + .unlock_native_capacity = sd_unlock_native_capacity, + .report_zones = sd_zbc_report_zones, + .get_unique_id = sd_get_unique_id, + .free_disk = scsi_disk_free_disk, + .pr_ops = &sd_pr_ops, +}; + /** * sd_format_disk_name - format disk name * @prefix: name prefix - ie. "sd" for SCSI disks From patchwork Mon Aug 5 23:42:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 816928 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 761A516CD12 for ; Mon, 5 Aug 2024 23:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901414; cv=none; b=fYhoBtYMTA/8k6o/PGf/P0AdSiknkGM32qNdXMXrj9yufdyuL5wpxWDi26mB4CELwF5brS9cLoiQT5OkeGt2TpcmHTOMjGCr3Qa+/PHFRKOi4J6nWybYu9ZsnxksTG/iqtZINgJrLfs+Nzbw7oEw5m31QDbhv+8WMzgqlBT4cSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722901414; c=relaxed/simple; bh=big2EkYbsP9b4uHaTcnm2ab6//7xuPAIbmapeclvQkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GMzBNRoQ1i6kfrevfJzlgda4kyg+LUo8Eur2hoXmkpDBUh6DtvQra8itPhfd2TOdVbLNv2BnziW7f8BFrIyteMl1TN8u3BETQbfkH5LecVh5g8yER5uFaAtrXIg57CCcLntd6c7sEW/raYu+bAuFqwiqCUsjSjUSI+4juSzcw1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=JnKI0lof; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="JnKI0lof" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WdCgS1SgWz6CmLxj; Mon, 5 Aug 2024 23:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1722901406; x=1725493407; bh=2z32L TDBuwvtL1ms0FeOXmh9kAqrtpH9+meB23gQLP0=; b=JnKI0lof1TuwETLJ8ZE98 /Spn8rngY98aML+9bQ8QaDyWvm1bJgXtIFhUdbhCtKETk4eg6yZBelv2RS7FqYUl Qn5nS6nBonMqs0tWSoxiXowZeK2ZqMQTFZHve4walqitgU1ftKJKuXMZumWjkJaj 3liVAFDZ93YFitiH/ArHWpgfKgDpR8muXBRodLLsz5fn/V8Bw13EyrWi74qZFE3H dGrp9vsODnP7cL0q13m2wnGOwE6CMn07vPJnEi2Mv7Tq5AZOfGVuHUT53HaHxk17 uEoDQsBECXCZ7A+UDw55fajyFVdjJAXa/RD/iUbaqzRjH2mKJrKaZtfvCUUyoe1N Q== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 4okLHSno1NbD; Mon, 5 Aug 2024 23:43:26 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WdCgK0dRHz6ClY9C; Mon, 5 Aug 2024 23:43:24 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Damien Le Moal , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v2 6/6] scsi: sd: Do not split error messages Date: Mon, 5 Aug 2024 16:42:49 -0700 Message-ID: <20240805234250.271828-7-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240805234250.271828-1-bvanassche@acm.org> References: <20240805234250.271828-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make it easier to find these error messages with grep. This patch has been created as follows: * Delete all occurrences of the following regular expression: "[[:blank:]]*\\*\n[[:blank:]]*" * Split long lines manually where necessary. Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/sd.c | 56 ++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index afd53ef2afcb..e40492792a5d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1651,8 +1651,9 @@ static int sd_ioctl(struct block_device *bdev, blk_mode_t mode, void __user *p = (void __user *)arg; int error; - SCSI_LOG_IOCTL(1, sd_printk(KERN_INFO, sdkp, "sd_ioctl: disk=%s, " - "cmd=0x%x\n", disk->disk_name, cmd)); + SCSI_LOG_IOCTL(1, sd_printk(KERN_INFO, sdkp, + "sd_ioctl: disk=%s, cmd=0x%x\n", + disk->disk_name, cmd)); if (bdev_is_partition(bdev) && !capable(CAP_SYS_RAWIO)) return -ENOIOCTLCMD; @@ -2549,8 +2550,8 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */ if (type > T10_PI_TYPE3_PROTECTION) { - sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \ - " protection type %u. Disabling disk!\n", + sd_printk(KERN_ERR, sdkp, + "formatted with unsupported protection type %u. Disabling disk!\n", type); sdkp->protection_type = 0; return -ENODEV; @@ -2829,8 +2830,8 @@ sd_read_capacity(struct scsi_disk *sdkp, struct queue_limits *lim, if ((sizeof(sdkp->capacity) > 4) && (sdkp->capacity > 0xffffffffULL)) { int old_sector_size = sector_size; - sd_printk(KERN_NOTICE, sdkp, "Very big device. " - "Trying to use READ CAPACITY(16).\n"); + sd_printk(KERN_NOTICE, sdkp, + "Very big device. Trying to use READ CAPACITY(16).\n"); sector_size = read_capacity_16(sdkp, sdp, lim, buffer); if (sector_size < 0) { sd_printk(KERN_NOTICE, sdkp, @@ -2856,17 +2857,16 @@ sd_read_capacity(struct scsi_disk *sdkp, struct queue_limits *lim, */ if (sdp->fix_capacity || (sdp->guess_capacity && (sdkp->capacity & 0x01))) { - sd_printk(KERN_INFO, sdkp, "Adjusting the sector count " - "from its reported value: %llu\n", - (unsigned long long) sdkp->capacity); + sd_printk(KERN_INFO, sdkp, + "Adjusting the sector count from its reported value: %llu\n", + (unsigned long long) sdkp->capacity); --sdkp->capacity; } got_data: if (sector_size == 0) { sector_size = 512; - sd_printk(KERN_NOTICE, sdkp, "Sector size 0 reported, " - "assuming 512.\n"); + sd_printk(KERN_NOTICE, sdkp, "Sector size 0 reported, assuming 512.\n"); } if (sector_size != 512 && @@ -3071,8 +3071,9 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) if (len < 3) goto bad_sense; else if (len > SD_BUF_SIZE) { - sd_first_printk(KERN_NOTICE, sdkp, "Truncating mode parameter " - "data from %d to %d bytes\n", len, SD_BUF_SIZE); + sd_first_printk(KERN_NOTICE, sdkp, + "Truncating mode parameter data from %d to %d bytes\n", + len, SD_BUF_SIZE); len = SD_BUF_SIZE; } if (modepage == 0x3F && sdp->use_192_bytes_for_3f) @@ -3095,8 +3096,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) */ if (len - offset <= 2) { sd_first_printk(KERN_ERR, sdkp, - "Incomplete mode parameter " - "data\n"); + "Incomplete mode parameter data\n"); goto defaults; } else { modepage = page_code; @@ -3111,8 +3111,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) offset += 2 + buffer[offset+1]; else { sd_first_printk(KERN_ERR, sdkp, - "Incomplete mode " - "parameter data\n"); + "Incomplete mode parameter data\n"); goto defaults; } } @@ -3579,8 +3578,7 @@ static bool sd_validate_min_xfer_size(struct scsi_disk *sdkp) if (min_xfer_bytes & (sdkp->physical_block_size - 1)) { sd_first_printk(KERN_WARNING, sdkp, - "Preferred minimum I/O size %u bytes not a " \ - "multiple of physical block size (%u bytes)\n", + "Preferred minimum I/O size %u bytes not a multiple of physical block size (%u bytes)\n", min_xfer_bytes, sdkp->physical_block_size); sdkp->min_xfer_blocks = 0; return false; @@ -3610,41 +3608,35 @@ static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp, if (sdkp->opt_xfer_blocks > dev_max) { sd_first_printk(KERN_WARNING, sdkp, - "Optimal transfer size %u logical blocks " \ - "> dev_max (%u logical blocks)\n", + "Optimal transfer size %u logical blocks > dev_max (%u logical blocks)\n", sdkp->opt_xfer_blocks, dev_max); return false; } if (sdkp->opt_xfer_blocks > SD_DEF_XFER_BLOCKS) { sd_first_printk(KERN_WARNING, sdkp, - "Optimal transfer size %u logical blocks " \ - "> sd driver limit (%u logical blocks)\n", + "Optimal transfer size %u logical blocks > sd driver limit (%u logical blocks)\n", sdkp->opt_xfer_blocks, SD_DEF_XFER_BLOCKS); return false; } if (opt_xfer_bytes < PAGE_SIZE) { sd_first_printk(KERN_WARNING, sdkp, - "Optimal transfer size %u bytes < " \ - "PAGE_SIZE (%u bytes)\n", + "Optimal transfer size %u bytes < PAGE_SIZE (%u bytes)\n", opt_xfer_bytes, (unsigned int)PAGE_SIZE); return false; } if (min_xfer_bytes && opt_xfer_bytes % min_xfer_bytes) { sd_first_printk(KERN_WARNING, sdkp, - "Optimal transfer size %u bytes not a " \ - "multiple of preferred minimum block " \ - "size (%u bytes)\n", + "Optimal transfer size %u bytes not a multiple of preferred minimum block size (%u bytes)\n", opt_xfer_bytes, min_xfer_bytes); return false; } if (opt_xfer_bytes & (sdkp->physical_block_size - 1)) { sd_first_printk(KERN_WARNING, sdkp, - "Optimal transfer size %u bytes not a " \ - "multiple of physical block size (%u bytes)\n", + "Optimal transfer size %u bytes not a multiple of physical block size (%u bytes)\n", opt_xfer_bytes, sdkp->physical_block_size); return false; } @@ -3706,8 +3698,8 @@ static int sd_revalidate_disk(struct gendisk *disk) buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL); if (!buffer) { - sd_printk(KERN_WARNING, sdkp, "sd_revalidate_disk: Memory " - "allocation failure.\n"); + sd_printk(KERN_WARNING, sdkp, + "sd_revalidate_disk: Memory allocation failure.\n"); goto out; }