-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libtcmu: add support for write protect #680
Conversation
Do you have any use case for this ? |
@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. |
BTW, which spc or sbc you are referring to for |
Okay, I misread the docs and I see it. |
libtcmu.c
Outdated
@@ -1021,6 +1021,16 @@ bool tcmu_dev_get_unmap_enabled(struct tcmu_device *dev) | |||
return dev->unmap_enabled; | |||
} | |||
|
|||
bool tcmu_dev_set_write_protect_enabled(struct tcmu_device *dev, bool enabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/bool/void/
/data/tcmu-runner/libtcmu.c: In function ‘tcmu_dev_set_write_protect_enabled’:
/data/tcmu-runner/libtcmu.c:1027:1: error: control reaches end of non-void function [-Werror=return-type]
}
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, i remember i fixed it, but ... it's fixed now.
e819707
to
d49be68
Compare
libtcmu_priv.h
Outdated
@@ -55,6 +55,7 @@ struct tcmu_device { | |||
unsigned int write_cache_enabled:1; | |||
unsigned int solid_state_media:1; | |||
unsigned int unmap_enabled:1; | |||
unsigned int write_protect_enabled: 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the white space before 1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Signed-off-by: liulanzheng <[email protected]>
d49be68
to
2977378
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
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 [email protected]