Project

General

Profile

Actions

Bug #2909

closed

/dev/md* open behavior

Added by tkusumi over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
05/01/2016
Due date:
% Done:

0%

Estimated time:

Description

Running
https://leaf.dragonflybsd.org/~tkusumi/diff/md1.py
adds an extra md device for no reason.

The issue is in open(2) when the path /dev/mdN contains the maximum available N at that point.
From the way sys/dev/disk/md/md.c is implemented it seems this is intended behavior, but weird.

This becomes a problem when running autofs userspace sh script which runs fstyp internally.
Everytime it runs it adds /dev/md(N+1) whether /dev/md* is really used or not.

[root@]~# uname -r
4.5-DEVELOPMENT
[root@]~# python ./md1.py
['/dev/md0']
<open file '/dev/md0', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1']
[root@]~# python ./md1.py
['/dev/md0', '/dev/md1']
<open file '/dev/md1', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1', '/dev/md2']
[root@]~# python ./md1.py
['/dev/md0', '/dev/md1', '/dev/md2']
<open file '/dev/md2', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3']
[root@]~# python ./md1.py
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3']
<open file '/dev/md3', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4']
[root@]~# python ./md1.py
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4']
<open file '/dev/md4', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5']
[root@]~# python ./md1.py
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5']
<open file '/dev/md5', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5', '/dev/md6']
[root@]~# python ./md1.py
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5', '/dev/md6']
<open file '/dev/md6', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5', '/dev/md6', '/dev/md7']
[root@]~# python ./md1.py
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5', '/dev/md6', '/dev/md7']
<open file '/dev/md7', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5', '/dev/md6', '/dev/md7', '/dev/md8']
[root@]~# python ./md1.py
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5', '/dev/md6', '/dev/md7', '/dev/md8']
<open file '/dev/md8', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5', '/dev/md6', '/dev/md7', '/dev/md8', '/dev/md9']
[root@]~# python ./md1.py
['/dev/md0', '/dev/md1', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5', '/dev/md6', '/dev/md7', '/dev/md8', '/dev/md9']
<open file '/dev/md9', mode 'r' at 0x800c8f5d0>
['/dev/md0', '/dev/md1', '/dev/md10', '/dev/md2', '/dev/md3', '/dev/md4', '/dev/md5', '/dev/md6', '/dev/md7', '/dev/md8', '/dev/md9']

On FreeBSD, though the code base is not the same.

[root@]~# uname -r
11.0-CURRENT
[root@]~# python ./md1.py
['/dev/md0']
<open file '/dev/md0', mode 'r' at 0x80073d5d0>
['/dev/md0']
[root@]~# python ./md1.py
['/dev/md0']
<open file '/dev/md0', mode 'r' at 0x80073d5d0>
['/dev/md0']
[root@]~# python ./md1.py
['/dev/md0']
<open file '/dev/md0', mode 'r' at 0x80073d5d0>
['/dev/md0']
[root@]~# python ./md1.py
['/dev/md0']
<open file '/dev/md0', mode 'r' at 0x80073d5d0>
['/dev/md0']
[root@]~# python ./md1.py
['/dev/md0']
<open file '/dev/md0', mode 'r' at 0x80073d5d0>
['/dev/md0']
[root@]~# python ./md1.py
['/dev/md0']
<open file '/dev/md0', mode 'r' at 0x80073d5d0>
['/dev/md0']

Actions #1

Updated by tkusumi over 8 years ago

http://lists.dragonflybsd.org/pipermail/users/2016-May/249578.html
Mention this in BUGS section of AUTO_MASTER(5) and AUTOMOUNTD.

Actions #2

Updated by tkusumi over 8 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF