open-iscsi / tcmu-runner

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

Add support for mark as write protected #654

Open liulanzheng opened 3 years ago

liulanzheng commented 3 years ago

I need to mark a device write protected or not depending on what file is opened. But i didn't find an api to set the write protected bit in libtcmu.

lxbsz commented 3 years ago

Yeah, it doesn't implement the SWP bit in the mode sense control page.

You can implement it in handle_control_page() if you want, which is similar to dev->write_cache_enabled.

liulanzheng commented 3 years ago

@lxbsz Thanks for you advice, I implemented it and worked. But I am not quite familiar with iSCSI protocol and 'mode sense control page', I didn't find how to implement it in handle_control_page(). At last, I set the SWP bit in the 'DEVICE-SPECIFIC PARAMETER' field in the 'mode parameter header'. I am not sure whether it is correct even thong it worked.

lxbsz commented 3 years ago

Yeah, set the wp bit in DEVICE-SPECIFIC PARAMETER should be enough. For the spec, you can refer to https://origin-www.seagate.com/files/staticfiles/support/docs/manual/Interface%20manuals/100293068j.pdf