From: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
To: "linux-btrfs@vger.kernel.org Btrfs" <linux-btrfs@vger.kernel.org>
Cc: "dsterba@suse.cz Sterba" <dsterba@suse.cz>,
Anand Jain <Anand.Jain@oracle.com>
Subject: Race condition between btrfs and udev
Date: Wed, 4 Jun 2014 17:12:59 +0800 [thread overview]
Message-ID: <538EE31B.8080701@cn.fujitsu.com> (raw)
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 trigger this problem is by running the followng c
codes repeatedly:
int main(int argc, char **argv)
{
int fd = open(argv[1], O_RDWR | O_EXCL);
if (fd < 0) {
perror("fail to open");
exit(1);
}
close(fd);
return 0;
}
here @argv[1] needs a btrfs block device.
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_EXCL, it would fail with EBUSY....
I don't know whether this is a serious problem, now there are two places
in btrfs-progs that is
trying to open device with O_EXCL:
1. in utils.c: test_dev_for_mkfs()
2. in disk-io.c: __open_ctree_fd()
Any ideas on this? maybe we can remove @EXCL flag from btrfs-progs?
Thanks,
Wang
reply other threads:[~2014-06-04 9:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=538EE31B.8080701@cn.fujitsu.com \
--to=wangsl.fnst@cn.fujitsu.com \
--cc=Anand.Jain@oracle.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).