]> git.ipfire.org Git - thirdparty/mdadm.git/commit - mdassemble.c
mdopen: open md devices O_RDONLY
authorNeilBrown <neilb@suse.com>
Mon, 5 Dec 2016 06:27:03 +0000 (17:27 +1100)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Mon, 5 Dec 2016 14:26:22 +0000 (09:26 -0500)
commitf71d2b8f4bd50888d1e20e9fdf7af9beb0729aae
treed9be5c2762e7c4ccd14188c0a97121fd8125c4a2
parente4467bc73096f3434a2fcd912569cfeb06d182ac
mdopen: open md devices O_RDONLY

There is no need to request write access when opening
the md device, as we never write to it, and none of the
ioctls we use require write access.

If we do open with write access, then when we close, udev notices that
the device was closed after being open for write access, and it
generates a CHANGE event.

This is generally unwanted, and particularly problematic when mdadm is
trying to --stop the array, as the CHANGE event can cause the array to
be re-opened before it completely closed, which results in a new mddev
being allocated.

So just use O_RDONLY instead of O_RDWR.

Reported-by: Marc Smith <marc.smith@mcc.edu>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
mdassemble.c
mdopen.c