Detection of modes of NVMe devices in SLES
I am using NVMe devices on SLES15 sp1 and sp2 both. These NVMe devices are exposed through SAN. Because they exported from SAN, these devices can go readonly or back to readwrite due to some changes by host or internally. I am trying to find out a way in sales host if the device is readonly without doing any IOs to it. The small dd command that I did, succeeded but IO errors appeared in dmesg. At a later point when device turned rw, again I couldn't find if the device is rw now. dd command succeeded and no bad messages in dmesg.
In summary, I would like to understand if there is a programmatic way to find out if device is read only. I do see a file called “/sys/block/nvmeXnY/ro” but that always remained 0 even when device is readonly. Moreover, when I try "blockdev –rereadpt /dev/nvmeXnY; blockdev -report /dev/nvmeXnY", the output is always RW.