Skip to content
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

blkdiscard should require exclusive access to device? #915

Closed
jiri-lunacek opened this issue Dec 16, 2019 · 3 comments
Closed

blkdiscard should require exclusive access to device? #915

jiri-lunacek opened this issue Dec 16, 2019 · 3 comments

Comments

@jiri-lunacek
Copy link

Hi.
After an unfortunate incident on one of our systems (dropped data using blkdiscard due to a typo), I was wondering if this tool should not check that the device is not used.

Most utils that work with block devices require this. (Including device-mapper, md raid, lvm, mount etc.). umount of mountpoint that is merely used by a single console will fail but the system will allow you to discard the whole drive the system is running on.

Thanks for comments.

Jiri

@karelzak
Copy link
Collaborator

@lczerner any objection to add O_EXCL to open() for the ioctl?

@lczerner
Copy link
Contributor

This sounds fine, but it would be nice to have an option to override it as well.

@karelzak
Copy link
Collaborator

karelzak commented Jan 3, 2020

OK, it's too late for v2.35; O_EXCL and --force (to override) will be available in v2.36. Thanks.

karelzak added a commit that referenced this issue Jan 9, 2020
Let's make it more robust and safe. O_EXCL is an elegant way how to avoid
unwanted discard on mounted device.

Addresses: #915
Signed-off-by: Karel Zak <kzak@redhat.com>
karelzak added a commit that referenced this issue Jan 23, 2020
Let's make it more robust and safe. O_EXCL is an elegant way how to avoid
unwanted discard on mounted device.

Addresses: #915
Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak karelzak closed this as completed Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants