open-iscsi / tcmu-runner

A daemon that handles the userspace side of the LIO TCM-User backstore.
Apache License 2.0
190 stars 148 forks source link

libtcmu: add support for write protect #680

Closed liulanzheng closed 2 years ago

liulanzheng commented 2 years ago

As discussed in #654, add an api to set write-protect for dev, and set the corresponding parameter when mode sense.

Signed-off-by: liulanzheng lanzheng.liulz@alibaba-inc.com

lxbsz commented 2 years ago

Do you have any use case for this ?

liulanzheng commented 2 years ago

@lxbsz in overlaybd, we output container images as block device through libtcmu for data acceleration. Images, like overlaybd containerd images, and vm images, also iso images, are readonly, it is better to provided a method to mark the device as readonly fundamentally, which is significantly better than executing blockdev --setro command on client. At first, we use tgtd as the backstore and it has readonly option for target configuration. So i think adding an option for write-protect/readonly is a real need.

lxbsz commented 2 years ago

BTW, which spc or sbc you are referring to for orig_buf[3] and orig_buf[2] ? From the sbc for MODE_SENSE_10 the first 8 bytes are reserved only for the NUMBER OF LOGICAL BLOCKS, and for MODE_SENSE there are 4 bytes.

lxbsz commented 2 years ago

BTW, which spc or sbc you are referring to for orig_buf[3] and orig_buf[2] ? From the sbc for MODE_SENSE_10 the first 8 bytes are reserved only for the NUMBER OF LOGICAL BLOCKS, and for MODE_SENSE there are 4 bytes.

Okay, I misread the docs and I see it.