id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc 1527,linux megaraid: opening the device for ioctls with O_RDWR causes a partition rescan,charlotte,,"When calling smartctl to get the health status, e.g. {{{ sudo smartctl -H -d megaraid,0 /dev/sdb }}} smartctl opens /dev/sdb as O_RDWR before using the fd to do the SG_GET_SCSI_ID and SCSI_IOCTL_GET_BUS_NUMBER ioctls. This causes the kernel to rescan partitions when the fd closes, which can be disruptive. For example, other processes trying to open a partition like /dev/sdb1 can fail if their timing is unlucky. e.g. you can get a transient error by doing stat in a loop then running smartctl on that device. {{{ $ while true; do stat /dev/sdb1 > /dev/null; done [ ... no output before smartctl call ... ] stat: cannot statx '/dev/sdb1': No such file or directory }}} I've attached a patch changing O_RDWR to O_RDONLY for megaraid to match the convention in the rest of the file, though O_ACCMODE might be relevant here according to the man page for open: > Linux reserves the special, nonstandard access mode 3 (binary 11) in flags to mean: check for read and write permission on the file and return a file descriptor that can't be used for reading or writing. This nonstandard access mode is used by some Linux drivers to return a file descriptor that is to be used only for device-specific ioctl(2) operations. We've worked around this in the meantime by passing the partition to smartctl (e.g. /dev/sdb1), but we'd want to avoid the rescan even if no partitions exist.",patch,new,major,undecided,all,7.2,,megaraid linux,