linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: sr: Set rotational feature flag back
@ 2025-08-27 11:35 Ming Lei
  2025-08-31  2:11 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2025-08-27 11:35 UTC (permalink / raw)
  To: Martin K . Petersen, linux-scsi; +Cc: linux-block, Ming Lei, Christoph Hellwig

Set rotational feature flag back for cd-rom which is really rotational disk,
and the flag is `cleared` since commit bd4a633b6f7c ("block: move the nonrot
flag to queue_limits"). And this way breaks some applications.

Move queue limits configuration from get_sectorsize() to
sr_revalidate_disk(), so that it is more readable to set rotational
feature flag and sector size limit in sr_revalidate_disk().

Cc: Christoph Hellwig <hch@lst.de>
Fixes: bd4a633b6f7c ("block: move the nonrot flag to queue_limits")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/scsi/sr.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index b17796d5ee66..add13e306898 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -475,13 +475,21 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt)
 
 static int sr_revalidate_disk(struct scsi_cd *cd)
 {
+	struct request_queue *q = cd->device->request_queue;
 	struct scsi_sense_hdr sshdr;
+	struct queue_limits lim;
+	int sector_size;
 
 	/* if the unit is not ready, nothing more to do */
 	if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr))
 		return 0;
 	sr_cd_check(&cd->cdi);
-	return get_sectorsize(cd);
+	sector_size = get_sectorsize(cd);
+
+	lim = queue_limits_start_update(q);
+	lim.logical_block_size = sector_size;
+	lim.features |= BLK_FEAT_ROTATIONAL;
+	return queue_limits_commit_update_frozen(q, &lim);
 }
 
 static int sr_block_open(struct gendisk *disk, blk_mode_t mode)
@@ -721,10 +729,8 @@ static int sr_probe(struct device *dev)
 
 static int get_sectorsize(struct scsi_cd *cd)
 {
-	struct request_queue *q = cd->device->request_queue;
 	static const u8 cmd[10] = { READ_CAPACITY };
 	unsigned char buffer[8] = { };
-	struct queue_limits lim;
 	int err;
 	int sector_size;
 	struct scsi_failure failure_defs[] = {
@@ -795,9 +801,7 @@ static int get_sectorsize(struct scsi_cd *cd)
 		set_capacity(cd->disk, cd->capacity);
 	}
 
-	lim = queue_limits_start_update(q);
-	lim.logical_block_size = sector_size;
-	return queue_limits_commit_update_frozen(q, &lim);
+	return sector_size;
 }
 
 static int get_capabilities(struct scsi_cd *cd)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: sr: Set rotational feature flag back
  2025-08-27 11:35 [PATCH] scsi: sr: Set rotational feature flag back Ming Lei
@ 2025-08-31  2:11 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2025-08-31  2:11 UTC (permalink / raw)
  To: linux-scsi, Ming Lei; +Cc: Martin K . Petersen, linux-block, Christoph Hellwig

On Wed, 27 Aug 2025 19:35:50 +0800, Ming Lei wrote:

> Set rotational feature flag back for cd-rom which is really rotational disk,
> and the flag is `cleared` since commit bd4a633b6f7c ("block: move the nonrot
> flag to queue_limits"). And this way breaks some applications.
> 
> Move queue limits configuration from get_sectorsize() to
> sr_revalidate_disk(), so that it is more readable to set rotational
> feature flag and sector size limit in sr_revalidate_disk().
> 
> [...]

Applied to 6.17/scsi-fixes, thanks!

[1/1] scsi: sr: Set rotational feature flag back
      https://git.kernel.org/mkp/scsi/c/708e2371f77a

-- 
Martin K. Petersen

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-31  2:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27 11:35 [PATCH] scsi: sr: Set rotational feature flag back Ming Lei
2025-08-31  2:11 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).