aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>2018-08-08 02:01:06 -0400
committerChristoph Hellwig <hch@lst.de>2018-08-08 05:55:49 -0400
commit1293477f4f324f9cf23a36f6cc0adc6801f1baac (patch)
treee7e7558e7d9c9d4675893cd12e1fc52d9851e326
parent93045d5942da60801e71764597d448cf37a798c1 (diff)
nvme: set gendisk read only based on nsattr
NVMe 1.3 TP 4005 introduces new filed (NSATTR). This field indicates whether given namespace is write protected or not. This patch sets the gendisk associated with the namespace to read only based on the identify namespace nsattr field. Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/nvme/host/core.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 603fe59756fb..dd8ec1dd9219 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1484,6 +1484,12 @@ static void nvme_update_disk_info(struct gendisk *disk,
1484 1484
1485 set_capacity(disk, capacity); 1485 set_capacity(disk, capacity);
1486 nvme_config_discard(ns); 1486 nvme_config_discard(ns);
1487
1488 if (id->nsattr & (1 << 0))
1489 set_disk_ro(disk, true);
1490 else
1491 set_disk_ro(disk, false);
1492
1487 blk_mq_unfreeze_queue(disk->queue); 1493 blk_mq_unfreeze_queue(disk->queue);
1488} 1494}
1489 1495