Wang,
Futher, a easy way to trigger this problem is by running the following
c codes repeatedly:
int main(int argc, char **argv)
{
/* pass a btrfs block device */
int fd = open(argv[1], O_RDWR | O_EXCL);
if (fd < 0) {
perror("fail to open: %s", strer
On Wed, Jun 11, 2014 at 08:11:38PM +0800, Wang Shilong wrote:
> So the problem is RW opening would trigger udev event which will
> call btrfs_scan_one_device(). In btrfs_scan_one_device(), it
> would open the block device with EXCL flag..meanwhile if another
> program try to open that device with O
data_profile,
return 0;
}
+/*
+ * there is a race condition between btrfs and udev, we may fail
+ * because udev call btrfs_scan_device() which will open the block
+ * device with O_EXCL. A walkaround solution is to wait kernel
+ * scanning finished and then try again.
+ */
+int btrfs_open_blo
Originally this problem was reproduced by the following scripts:
# dd if=/dev/zero of=data bs=1M count=50
# losetup /dev/loop1 data
# i=1
# while [ 1 ]
do
mkfs.btrfs -fK /dev/loop1 >& /dev/null || exit 1
i++
echo "loop $i"
done
Further, a easy way to trigg