Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: sr: Reinstate rotational media flag

Reinstate the rotational media flag for the CD-ROM driver. The flag has
been cleared since commit bd4a633b6f7c ("block: move the nonrot flag to
queue_limits") and this breaks some applications.

Move queue limit configuration from get_sectorsize() to
sr_revalidate_disk() and set the rotational flag.

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>
Link: https://lore.kernel.org/r/20250827113550.2614535-1-ming.lei@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Ming Lei and committed by
Martin K. Petersen
708e2371 9dba9a45

+10 -6
+10 -6
drivers/scsi/sr.c
··· 475 475 476 476 static int sr_revalidate_disk(struct scsi_cd *cd) 477 477 { 478 + struct request_queue *q = cd->device->request_queue; 478 479 struct scsi_sense_hdr sshdr; 480 + struct queue_limits lim; 481 + int sector_size; 479 482 480 483 /* if the unit is not ready, nothing more to do */ 481 484 if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr)) 482 485 return 0; 483 486 sr_cd_check(&cd->cdi); 484 - return get_sectorsize(cd); 487 + sector_size = get_sectorsize(cd); 488 + 489 + lim = queue_limits_start_update(q); 490 + lim.logical_block_size = sector_size; 491 + lim.features |= BLK_FEAT_ROTATIONAL; 492 + return queue_limits_commit_update_frozen(q, &lim); 485 493 } 486 494 487 495 static int sr_block_open(struct gendisk *disk, blk_mode_t mode) ··· 729 721 730 722 static int get_sectorsize(struct scsi_cd *cd) 731 723 { 732 - struct request_queue *q = cd->device->request_queue; 733 724 static const u8 cmd[10] = { READ_CAPACITY }; 734 725 unsigned char buffer[8] = { }; 735 - struct queue_limits lim; 736 726 int err; 737 727 int sector_size; 738 728 struct scsi_failure failure_defs[] = { ··· 801 795 set_capacity(cd->disk, cd->capacity); 802 796 } 803 797 804 - lim = queue_limits_start_update(q); 805 - lim.logical_block_size = sector_size; 806 - return queue_limits_commit_update_frozen(q, &lim); 798 + return sector_size; 807 799 } 808 800 809 801 static int get_capabilities(struct scsi_cd *cd)