From: Anand Jain <anand.jain@oracle.com>
To: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs-progs: fix race condition between btrfs and udev
Date: Thu, 12 Jun 2014 14:23:06 +0800 [thread overview]
Message-ID: <5399474A.3040003@oracle.com> (raw)
In-Reply-To: <1402488698-12518-1-git-send-email-wangsl.fnst@cn.fujitsu.com>
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", strerror(errno));
> exit(1);
> }
> close(fd);
> return 0;
> }
>
> 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.
Expected. But do we need O_EXCL in kernel:btrfs_scan_one_device()
at all ?
> This happen seldomly in the real world, but if we use loop device
> for test, we may hit this annoying problem.
> A walkaround way to solve this problem is to wait kernel scanning
> finished and then try it again.
I agree this happens seldom in production. But I don't agree on
something to fix as workaround.
Just sent out the patch:
btrfs: looping mkfs.btrfs -f <dev> may fail with EBUSY
which I believe can be a final fix. Your review / tests appreciated.
Thanks, Anand
prev parent reply other threads:[~2014-06-12 6:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 12:11 [PATCH] Btrfs-progs: fix race condition between btrfs and udev Wang Shilong
2014-06-11 12:23 ` Tomasz Torcz
2014-06-12 6:23 ` Anand Jain [this message]
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=5399474A.3040003@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wangsl.fnst@cn.fujitsu.com \
/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).