From patchwork Tue Jul 30 21:00:36 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: 13747893 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 8E0C814B94C for ; Tue, 30 Jul 2024 21:01:30 +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=1722373292; cv=none; b=pyAiWIi99Daen5KWasQK4KD8ABgVLRXQOyVb6LgpVM4B4mebhCpnb0+/H2CXACclJ3kUS0wNFweH1rR9/dyqHGzdNzH8rvjuo65m+dt9p32wO930LL53WPOshdzEgalflyisY1R76PmUw40OElO57BbiAGRXNEXXjTtiSwD7ttc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722373292; c=relaxed/simple; bh=MSCDvzmhGpUUKowAsg7B5/si3ikKThoVck0E3qk2ZJU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XIVcESOhR1gmwOx8lq5DPUzjtxPfBY4+Ks2Y5Y7xlNCbw51J4QeJaDXJyPrI13/0jLOTlECi8fEzFqGxy75rillRCAMM4g1Y9Klb1WOaq+DKfEjXPvyPpLlDvmGsoznxZwXBvYe8ApocIKAPCUzubvIZiDtxtimJD6cGxEA7OsI= 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=CSCp5KQ4; 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="CSCp5KQ4" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WYSM76599z6CmM6f; Tue, 30 Jul 2024 21:01:23 +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=1722373279; x=1724965280; bh=MoB+v WcGV34z9qL1SBrnAObpzsa3T5PWZ7ibSXidmCU=; b=CSCp5KQ4TMX27BM2GKhKu 0LV0CqX9+4KWGA/5yhoM97NVpCg5lkvT4+p0lbvbT37+W1XtJzwvkzjlyly7P1pE XV7oRCMKEwGrmzpqPPaCUk40EIKMqOSSbUVa5mNZqeBe4bdOoV06UZD7MGrC7ZYb Jwi5lEM1IYvOosudS40bdQ4CO4KEInI74qDYqRbF1kR6OBIUl/UXG3sKtmJjp6ml nBQY2yNslLXMjyeicVPf0PtzzuH5pPS3lJzZlDe6qeeC/quSdoXwQncMs0wNwo49 j0C9E3IGDgdm1dDtIjGKdMWIyf+gtQxxUsNI/fgWlZdHINlk+7Np1+YIhENzGTOF 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 GVdkJFIoOW9h; Tue, 30 Jul 2024 21:01:19 +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 4WYSM23Wh5z6CmQvG; Tue, 30 Jul 2024 21:01:18 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Hannes Reinecke , Bart Van Assche , "James E.J. Bottomley" Subject: [PATCH 1/6] scsi: sd: Move the sd_remove() function definition Date: Tue, 30 Jul 2024 14:00:36 -0700 Message-ID: <20240730210042.266504-2-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240730210042.266504-1-bvanassche@acm.org> References: <20240730210042.266504-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. Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- 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 adeaa8ab9951..58ea8c06205b 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 Tue Jul 30 21:00:37 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: 13747892 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 CD28B183098 for ; Tue, 30 Jul 2024 21:01:28 +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=1722373290; cv=none; b=eKW0NQAJojy2rThrajedaThkY9HiPMGHsbPbI2Iov+WnUQMFH05cJhpDMjKl7lqdF+kxLSmDcJFVmi7CZkN+ssl6+2l5GsvEjLDj9oXc3cQb7BAsA0inNGXoJASnvkwQHU1j+zNkTIUOnvNZele0X9z2Svi0McdjOxFyXk8uQUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722373290; c=relaxed/simple; bh=tcueXEYWUCXsd6Q04wwapFKjz87Rhx34RIpqHJhcPLE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qhlkm4O8qp/srirJ8ISB1Vchg9gIdE1jO367u1fclgzuW+wCTxzAOf1KlJR3ulQ3HNgZdqa0S16zjLMgseg5YfE0zQB+zGsSQRCEp+U5xbjQCtlgyMzuJf2jHyUwd/sGimbYc9yHhm69FJwXlZ2VutSh8auaMsrW3bXP3Yj7I0Q= 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=VpMXpx+m; 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="VpMXpx+m" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WYSMB1nh5z6CmQvG; Tue, 30 Jul 2024 21:01:26 +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=1722373280; x=1724965281; bh=npT0P eHTMYyLMQYofV+NwKiIxZmsRKY/fnTX8a1bfLw=; b=VpMXpx+mafgS3XW+TlgI1 /7YWEDOceRbpmvYtCsZHhY8P2xuh4WRtIGt3hLLp9X1XpFxk/YSNhlaZr8XngnEC tjitwzkEbQRwpa0EqV59MXRHiXvQWokuoknQLdstlji+eIcvpa0KONgmt+N/5UCv GzMW9kNw0PXPnb5IDjdDb1N/OIq6t5wqJb5sgAOqWMfc2hxZ5D8r74MmlPGcG3qe w2KqNvjqGrqO3wTrbZ0PfoPE1B24lCF4ZvNwf9eq9RFu3JKgsAfoxLftAwTT8U9j Soyy7VAvdDh1WMIyFxa+yoVOtk+hFWA/CSoQSq45rJoMyJ8qX4Fq9Hz8dr6C/1NM 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 0dKs5yKCOUxt; Tue, 30 Jul 2024 21:01: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 4WYSM32Swgz6CmM5x; Tue, 30 Jul 2024 21:01:19 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Hannes Reinecke , Bart Van Assche , "James E.J. Bottomley" Subject: [PATCH 2/6] scsi: sd: Move the sd_config_discard() function definition Date: Tue, 30 Jul 2024 14:00:37 -0700 Message-ID: <20240730210042.266504-3-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240730210042.266504-1-bvanassche@acm.org> References: <20240730210042.266504-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. Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- 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 58ea8c06205b..8b8a355435b4 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 Tue Jul 30 21:00:38 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: 13747896 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 E1EF9189911 for ; Tue, 30 Jul 2024 21:01: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=1722373294; cv=none; b=QokpSUcXRl5JTJAj74/kw0HZoScHqVxF5yA9+PuOyjRweRFsvrID2zhD1Len6q5KSgI7Oa2a1pEM+kokQqLnyvysyoXwUBvHjJ0WGYzfhDKKrL3tXEuA/X47pEJEGw5rLrQT7uErrNnefwr8Gva6VaDiJ+GdsoVU2p6sY0JZzV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722373294; c=relaxed/simple; bh=l/+WoSNi19R+4IZxSwVHrZ+sxCh2wi/ZAfp/iw/Nzpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qUeAicdqofydekOGOofzjb9+2Lwfj2qKzO8zDF6vSpR1Gl72Qjn3C5sXLIsLgkq6zR0l3wzNBGsqcKBEPuG3MnU2APa2NWUWSLBlNUaFXbriOSxuWSlledK6OL487bvMvtaX7saEjxO49WyCgYrkthoPFnppu8rGwfYDdDAc3T0= 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=KI62K/9z; 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="KI62K/9z" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WYSMC6W3Cz6CmM6V; Tue, 30 Jul 2024 21:01: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=1722373280; x=1724965281; bh=Pl2qy xuZRH33KeW7vDfhkDN23rhmdImEgb3fTePIdwY=; b=KI62K/9zsOmWDb2oeHD3D /NIEZYB7AWcWdCMJvXlQdXF+oduuwIpK9kvAaG9xoLl0fUEyBkwWUwBFiL+SkhD4 ncfBdzOjBpjEo4eFaaZheCkDT4y6BNKeNWLMMKp5a3LI0HLtTjO5EEPtaed7NkSS YV3jT+QzPY11Gn+Jy8Go/1SmJJ0hdAwwldMuOJZ0fadWava8ae8RPwQx2btJfm8+ e1z0JRp/g5LbbnbaRmzquMQgLASGGLKrQZGKRUBJmdO42xNo2ksAZsUxjnbaRvOS PyK/HwXoVs7xCTnuWm2F/UBHsymD3mEHEojLypcAObIoHbreY8+o7NS1N47pHt8N 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 pyIVk6xmjblX; Tue, 30 Jul 2024 21:01: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 4WYSM41PQdz6CmM6L; Tue, 30 Jul 2024 21:01:20 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Hannes Reinecke , Bart Van Assche , "James E.J. Bottomley" Subject: [PATCH 3/6] scsi: sd: Move the sd_config_write_same() function definition Date: Tue, 30 Jul 2024 14:00:38 -0700 Message-ID: <20240730210042.266504-4-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240730210042.266504-1-bvanassche@acm.org> References: <20240730210042.266504-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. Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- 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 8b8a355435b4..30c1792df1b3 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 Tue Jul 30 21:00:39 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: 13747894 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 EC1C418CC05 for ; Tue, 30 Jul 2024 21:01:30 +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=1722373292; cv=none; b=kK8znLs95tWrz/7R8JeiQcm/b16eZhJTWCGSPKzJfn++BDFyQmxACPOJ5luStwrhKOUsvMc1AmybMHbrDASvkGY3ZVEoclraxPg/WMqA97qZa7UrZA9q94OJzsQfdhxzgT6oHUFJ3PBT0K14XuSktseg0f0cT663Y8f2/mFglzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722373292; c=relaxed/simple; bh=CBmpXk5Nbvh3lnBjV1qYu68yz7NIAEKATg0NZK3kQ2g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bvsWgGZq27pWtnpOOpKQpgVzO/+S5lI+mGgCH/4jpiDMBefcpIcmRBAferobHs098/vQyhjYvNwx/0bEz39nAgrDo6S7Tm0GGzwV/RRYR0mjujFjHjpsRPGAuXvd8Gz0jppX6oc/z6uvAYcbgsZWKeXGuEvcApD0lICfniWZre8= 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=jOOsmKD2; 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="jOOsmKD2" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WYSMC377Xz6CmM5x; Tue, 30 Jul 2024 21:01: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=1722373283; x=1724965284; bh=LPlXb avZQYC1J/63gyuayZvIZuUNSl3EEhiFzPPrAJc=; b=jOOsmKD2pncJFNJYLx4H5 9H6vyC5nPhR0btAudkVA6tt3GacHeWwKIRoKbwF+ahPfV9eSs3D3Xk1iiqCsAP33 E9KmrRuCSkDl+lLd2B1JlRMXti+fIc1yZIFCCPWA5cYiggv7oyOIn6eCa3pargI6 bn2jh2QfP3NhkyxCMAnbMyQM1ddmebd2QGirRet3SR6/Jqb1/nudJQzVdlw3k8BF r/93+54WWKXIHrw16iHQI1EuoU49L6qPNgmRAbw654E7Sd08edH92MZ/aqQKWE58 SHw0V1uA5IVezI13YbyfGZUzAeUX3mlS+FriW1VNbCqYqCQgVtWtkYvuB/p44o/0 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 qgEAHu9FdgP7; Tue, 30 Jul 2024 21:01:23 +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 4WYSM508bDz6CmQwN; Tue, 30 Jul 2024 21:01:20 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Hannes Reinecke , Bart Van Assche , "James E.J. Bottomley" Subject: [PATCH 4/6] scsi: sd: Move the scsi_disk_release() function definition Date: Tue, 30 Jul 2024 14:00:39 -0700 Message-ID: <20240730210042.266504-5-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240730210042.266504-1-bvanassche@acm.org> References: <20240730210042.266504-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. Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- 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 30c1792df1b3..cefc40de6ee8 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 Tue Jul 30 21:00:40 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: 13747895 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 57A99186E2E for ; Tue, 30 Jul 2024 21:01: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=1722373293; cv=none; b=BktDY+0AodbGJcxm8vsBnaZBIMRYodiATYUNGvOYzxnhHZj0PbNWDlh8cF8KQ4UOPvzWXWdkqEoQl5oLZnlF4wGwJcQYQr0q+90sh6XZwgc7NYo1j+sXjIWSse56bXDrWQRLKUDCFkSlDZAC8e05fMZf5zMy7Ddwtca/P5t8S8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722373293; c=relaxed/simple; bh=DIYns7sOpWGlxsMZctLGbqA3+geaRrpDHk/RW0OnYgc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uyLAN9U4meyl29qD60KvEbDvbCs5opa+pcV+QH0COaquARnV8zpM2JuOOeiKE/dkgw74j79mXJKLuOQAQpiQ3kP/PU9bcpsz0K2D5Zcw3NuVzGIns0e4ufDKVNijvgr+57xe52c89Xg9OezBRTkzX0IIJncypDtcSviv4kTieNQ= 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=hYDUox6c; 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="hYDUox6c" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WYSMC575Hz6CmQwN; Tue, 30 Jul 2024 21:01: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=1722373283; x=1724965284; bh=BtBCf 44TfWZBCjg679irYhvMDUYvD4YdQj0HqflK2jQ=; b=hYDUox6c/X40IeIJTACeY gRJh3idiGCP3Vu1ym5tM5sv3PgEycKHlcm7PT9a7mTNMPEjhwLYVCTRsuziJR/a7 s7zkI1KUVc/MUbfBGpTEO80pgkd61iBjdAbcDsItl4K0zh5HEhB2pwFM8HrQOGA2 +s+7LF1Kho1INEmelENaA2BLmNxzv0w2KZJDVI/QtA0Xy/CW0Jm3UT5mG07YKy+S HtHAiLeo2qAFaJ96fo5zYQBRvzAntEv8lojLTQbSheXlMmxEMis7Yt0H/Bs5RoVb dN5STRmGEIMn0+msZ4QsF5dHD9A8YmkLNpKOXyk0Ed2MKaFkzxFgEA+y8yYXC13G g== 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 3mDcrbhrhPZ9; Tue, 30 Jul 2024 21:01:23 +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 4WYSM5664Gz6CmM6V; Tue, 30 Jul 2024 21:01:21 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Hannes Reinecke , Bart Van Assche , "James E.J. Bottomley" Subject: [PATCH 5/6] scsi: sd: Move the sd_fops definition Date: Tue, 30 Jul 2024 14:00:40 -0700 Message-ID: <20240730210042.266504-6-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240730210042.266504-1-bvanassche@acm.org> References: <20240730210042.266504-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. Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- 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 cefc40de6ee8..3f4df58f2bbc 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 Tue Jul 30 21:00:41 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: 13747897 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 5A26238B for ; Tue, 30 Jul 2024 21:01:34 +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=1722373295; cv=none; b=UIsMBm2hfyzuhc1QClu3RqYsgK5J1fPmHwIEA9PaDC0Cl30Vpq57cQRaBYIvZ3aebjfCMIH4R9yK19Db15IFG8iQF7osLqoBk15CcRsW7Tm4QoFiW2T6p15vaERtMr+mVF0u/frZF2V78uoA1L961dKzdmoyinlXhgau9HUsu60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722373295; c=relaxed/simple; bh=DHTfTxuBDTKrML70ZzDW8kEyRl/ZhNYbPQpcEpT1GnM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sPOBhbL1k11msMCTrENKIJTzHWOAVz4z/rCy3iXRS43ma42CgLYqEvU0qUNTR98PZd3kEZZjMw8nuaC5liaWATVvZVG8q+uw2SZ7rAXi/Nvk5mTYzsnXOQ+DikwSnow2ZDiE1Qy2BIsUaVxYgl2WBI0i2cxSMDrToa1LW1qWHTw= 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=LHB4aSBV; 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="LHB4aSBV" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WYSML0w7nz6CmM6L; Tue, 30 Jul 2024 21:01:34 +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=1722373286; x=1724965287; bh=986xW wd3dVG9NJPb+VcWZcQ9B0JA4Q5YqwyiSpQHvi4=; b=LHB4aSBVj1CAPN56FyY+K DMzakG2ydXL6NKLMq0Q2kPHMBcKt3LPtnGaa3zgQcBnzjrGRAmsjHU9ELJXt1yWI Gbig5ndoMG3Bu3dutUnNMjdbvBCVgrfd30SOt5FhAnJQae6Fky/IiyzOGtt3Mjj2 q2Nm4VxdXkeV4CTCdx4nWzJ7pjW1ksqgeOIoWc4b95ABB3LcFuAIZMq0yLhZM7QA 4VLRJ5fxNSqaOfbABfaET7VAfLcKjM4bochnSM9bSXygj3LVVcxkBPVXa6Td8Dx1 16V+WB5ToOi6i4RvrL0+Z7xhp22Qf9uH0N76ZyGCpZk110dxv5zctsUBgf/aLij5 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 0fs65KoK2-rk; Tue, 30 Jul 2024 21:01: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 4WYSM653j6z6CmM6d; Tue, 30 Jul 2024 21:01:22 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Hannes Reinecke , Bart Van Assche , "James E.J. Bottomley" Subject: [PATCH 6/6] scsi: sd: Do not split error messages Date: Tue, 30 Jul 2024 14:00:41 -0700 Message-ID: <20240730210042.266504-7-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240730210042.266504-1-bvanassche@acm.org> References: <20240730210042.266504-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. Signed-off-by: Bart Van Assche Reviewed-by: Damien Le Moal --- drivers/scsi/sd.c | 54 ++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 3f4df58f2bbc..304da82fea4f 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,8 +2857,8 @@ 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", + sd_printk(KERN_INFO, sdkp, + "Adjusting the sector count from its reported value: %llu\n", (unsigned long long) sdkp->capacity); --sdkp->capacity; } @@ -2865,8 +2866,7 @@ sd_read_capacity(struct scsi_disk *sdkp, struct queue_limits *lim, 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; }