]> git.ipfire.org Git - thirdparty/util-linux.git/commit
blkzone: deny destructive ioctls on busy blockdev
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Fri, 15 May 2020 08:41:33 +0000 (17:41 +0900)
committerKarel Zak <kzak@redhat.com>
Fri, 15 May 2020 12:41:53 +0000 (14:41 +0200)
commitaef845850c91c2aa5abfb510e5e787522b2cc6a0
tree89d26fbd94f3b7291575a84e1ac71425fac424a0
parent62e978dbf7bec21888f8cb4f881d23389c8f9ed6
blkzone: deny destructive ioctls on busy blockdev

If a user submits a zone management ioctl from user-space, like a zone
reset and a file-system (like zonefs or f2fs) is mounted on the zoned
block device, the zone will get reset and the file-system's cached value
of the zone's write-pointer becomes invalid.

Subsequent writes to this zone from the file-system will result in
unaligned writes and the drive will error out.

Open the block device file in exclusive mode for submitting these ioctls.
If a file-system is mounted the kernel will return -EBUSY and we can't
continue issuing the ioctl.

[kzak@redhat.com: - remove unnecessary error message]

Reported-by: Coly Li <colyli@suse.de>
Cc: Damien Le Moal <Damien.LeMoal@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/blkzone.c