1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/lib/label
David Teigland 1404e5ee61 metadata: open rw fd before closing ro fd
lvm opens devices readonly to scan them, but
needs to open then readwrite to update the metadata.
Previously, the ro fd was closed before the rw fd
was opened, leaving a small gap where the dev was
not held open, and during which the dev could
possibly change which storage it referred to.

With the bcache_change_fd() interface, lvm opens a
rw fd on a device to be written, tells bcache to
change to the new rw fd, and closes the ro fd.

. open dev ro
. read dev with the ro fd (label_scan)
. lock vg (ex for writing)
. open dev rw
. close ro fd
. rescan dev to check if the metadata changed
  between the scan and the lock
. if the metadata did change, reread in full
. write the metadata
2020-09-18 15:10:11 -05:00
..
hints.c hints: enhance debug messages 2020-09-16 15:01:10 -05:00
hints.h hints: free hint list in error exit path 2020-03-03 12:25:34 -06:00
label.c metadata: open rw fd before closing ro fd 2020-09-18 15:10:11 -05:00
label.h metadata: open rw fd before closing ro fd 2020-09-18 15:10:11 -05:00