# Re: \[mdadm PATCH\] mdopen: open md devices O\_RDONLY

- From: Jes Sorensen \<hidden\>
- Date: 2016-12-05 14:26:42 
- List: linux-raid
- Page: https://ratatoskr.run/linux-raid/2016/12/6633822
- Thread: https://ratatoskr.run/linux-raid/2016/12/6633822/t.md

```text
NeilBrown [ref] writes:
> 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 <redacted>
> Signed-off-by: NeilBrown <redacted>
> ---
>  mdassemble.c | 2 +-
>  mdopen.c     | 4 +---
>  2 files changed, 2 insertions(+), 4 deletions(-)

Applied!

Thanks,
Jes
```
