From: Josef Bacik <jbacik@fusionio.com>
To: Anand Jain <Anand.Jain@oracle.com>
Cc: Josef Bacik <jbacik@fusionio.com>, <linux-btrfs@vger.kernel.org>,
<dsterba@suse.cz>
Subject: Re: [PATCH 4/6] btrfs-progs: mkfs.c overwrites fd without appropriate close
Date: Wed, 14 Aug 2013 09:32:58 -0400 [thread overview]
Message-ID: <20130814133258.GB26269@localhost.localdomain> (raw)
In-Reply-To: <520AF6B1.5020605@oracle.com>
On Wed, Aug 14, 2013 at 11:17:05AM +0800, Anand Jain wrote:
>
>
> On 08/14/2013 10:04 AM, Anand Jain wrote:
> >
> >
> >On 08/14/2013 03:14 AM, Josef Bacik wrote:
> >>On Fri, Jul 26, 2013 at 01:35:28AM +0800, Anand Jain wrote:
> >>>Signed-off-by: Anand Jain <anand.jain@oracle.com>
> >>>---
> >>> mkfs.c | 3 ++-
> >>> 1 files changed, 2 insertions(+), 1 deletions(-)
> >>>
> >>>diff --git a/mkfs.c b/mkfs.c
> >>>index 60f906c..66f558a 100644
> >>>--- a/mkfs.c
> >>>+++ b/mkfs.c
> >>>@@ -1570,6 +1570,8 @@ int main(int ac, char **av)
> >>> * occur by the following processing.
> >>> * (btrfs_register_one_device() fails if O_EXCL is on)
> >>> */
> >>>+ if (fd > 0)
> >>>+ close(fd);
> >>> fd = open(file, O_RDWR);
> >>> if (fd < 0) {
> >>> fprintf(stderr, "unable to open %s: %s\n", file,
> >>>@@ -1581,7 +1583,6 @@ int main(int ac, char **av)
> >>> if (ret) {
> >>> fprintf(stderr, "skipping duplicate device %s in FS\n",
> >>> file);
> >>>- close(fd);
> >>> continue;
> >>> }
> >>> ret = btrfs_prepare_device(fd, file, zero_end,
> >>>&dev_block_count,
> >>
> >>This breaks mkfs with multiple disks.
> >
> > I can't believe as I have been playing with multiple disks
> > quite a lot recently. let me dig more.
>
> Sorry my mistake.
>
> Indeed further down btrfs_add_to_fsid() stores fd. closing a
> stored fd is not correct theoretically.
>
> Josef, Would be keen to know which xfstest caught this. ?
>
It was btrfs/265, the one that does raid tests and such.
Josef
next prev parent reply other threads:[~2013-08-14 13:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 17:35 [PATCH 0/6] Anand Jain
2013-07-25 17:35 ` [PATCH 1/6] btrfs-progs: close_all_devices() in btrfs-find-root.c does nothing Anand Jain
2013-07-25 17:35 ` [PATCH 2/6] btrfs-progs: let user know that devid can be used if path is missing Anand Jain
2013-07-25 17:35 ` [PATCH 3/6] btrfs-progs: cmd_start_replace() to use test_dev_for_mkfs() Anand Jain
2013-07-25 17:35 ` [PATCH 4/6] btrfs-progs: mkfs.c overwrites fd without appropriate close Anand Jain
2013-08-13 19:14 ` Josef Bacik
2013-08-13 19:19 ` Josef Bacik
2013-08-14 2:04 ` Anand Jain
2013-08-14 3:17 ` Anand Jain
2013-08-14 13:32 ` Josef Bacik [this message]
2013-08-14 4:37 ` [PATCH] btrfs-progs: Fix: mkfs.c overwrites fd without appropriate close patch Anand Jain
2013-07-25 17:35 ` [PATCH 5/6] btrfs-progs: avoid write to the disk before sure to create fs Anand Jain
2013-07-25 17:35 ` [PATCH 6/6] btrfs-progs: don't have to report ENOMEDIUM error during open Anand Jain
2013-08-07 12:11 ` [PATCH 0/3 resend] Anand Jain
2013-08-07 12:11 ` [PATCH 1/3] btrfs-progs: let user know that devid can be used if path is missing Anand Jain
2013-08-07 12:11 ` [PATCH 2/3] btrfs-progs: cmd_start_replace() to use test_dev_for_mkfs() Anand Jain
2013-08-07 12:11 ` [PATCH 3/3] btrfs-progs: avoid write to the disk before sure to create fs Anand Jain
2013-08-20 19:19 ` Josef Bacik
2013-08-21 3:15 ` Anand Jain
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=20130814133258.GB26269@localhost.localdomain \
--to=jbacik@fusionio.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).