Skip to content

Commit 708e237

Browse files
Ming Leimartinkpetersen
authored andcommitted
scsi: sr: Reinstate rotational media flag
Reinstate the rotational media flag for the CD-ROM driver. The flag has been cleared since commit bd4a633 ("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 <[email protected]> Fixes: bd4a633 ("block: move the nonrot flag to queue_limits") Signed-off-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 9dba9a4 commit 708e237

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/scsi/sr.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,21 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt)
475475

476476
static int sr_revalidate_disk(struct scsi_cd *cd)
477477
{
478+
struct request_queue *q = cd->device->request_queue;
478479
struct scsi_sense_hdr sshdr;
480+
struct queue_limits lim;
481+
int sector_size;
479482

480483
/* if the unit is not ready, nothing more to do */
481484
if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr))
482485
return 0;
483486
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);
485493
}
486494

487495
static int sr_block_open(struct gendisk *disk, blk_mode_t mode)
@@ -721,10 +729,8 @@ static int sr_probe(struct device *dev)
721729

722730
static int get_sectorsize(struct scsi_cd *cd)
723731
{
724-
struct request_queue *q = cd->device->request_queue;
725732
static const u8 cmd[10] = { READ_CAPACITY };
726733
unsigned char buffer[8] = { };
727-
struct queue_limits lim;
728734
int err;
729735
int sector_size;
730736
struct scsi_failure failure_defs[] = {
@@ -795,9 +801,7 @@ static int get_sectorsize(struct scsi_cd *cd)
795801
set_capacity(cd->disk, cd->capacity);
796802
}
797803

798-
lim = queue_limits_start_update(q);
799-
lim.logical_block_size = sector_size;
800-
return queue_limits_commit_update_frozen(q, &lim);
804+
return sector_size;
801805
}
802806

803807
static int get_capabilities(struct scsi_cd *cd)

0 commit comments

Comments
 (0)