From: Anand Jain <Anand.Jain@oracle.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/9] btrfs-progs: mkfs should first check all disks before writing to a disk
Date: Mon, 15 Apr 2013 14:47:20 +0800 [thread overview]
Message-ID: <516BA278.6000400@oracle.com> (raw)
In-Reply-To: <20130412160619.GZ18193@twin.jikos.cz>
On 04/13/2013 12:06 AM, David Sterba wrote:
> On Fri, Apr 05, 2013 at 01:54:57PM +0800, Anand Jain wrote:
>> In the cases where one of the disk is not suitable for
>> btrfs, then we would fail the mkfs, however we determine
>> that after we have written btrfs to the preceding disks.
>> At this time if user changes mind for not to use btrfs
>> will left with no choice.
>>
>> So this patch will check if all the provided disks are
>> suitable for the btrfs at once before proceeding to
>> create btrfs on a disk.
>
> Good fix and cleanup.
>
>> +void __test_dev_for_mkfs(char *file, int force_overwrite)
>> +{
>> + int ret, fd;
>> +
>> + ret = is_swap_device(file);
>> + if (ret < 0) {
>> + fprintf(stderr, "error checking %s status: %s\n", file,
>> + strerror(-ret));
>> + exit(1);
>
> The exit()s were ok when this code was in main(), but should be
> converted to return for a helper function.
I got this integrated in v2.
>> + }
>> int main(int ac, char **av)
>> {
>> char *file;
>> @@ -1378,6 +1418,8 @@ int main(int ac, char **av)
>> char *pretty_buf;
>> struct btrfs_super_block *super;
>> u64 flags;
>> + int dev_cnt=0;
>
> int dev_cnt = 0;
>
>> + int saved_optind;
>>
>> while(1) {
>> int c;
>> + dev_cnt = ac - optind;
>> + if (dev_cnt == 0)
>> print_usage();
>>
>> + if (source_dir_set && dev_cnt > 1) {
>> + fprintf(stderr,
>> + "The -r option is limited to a single device\n");
>> + exit(1);
>> + }
>> + while (dev_cnt-- > 0) {
>> + file = av[optind++];
>> + /* following func would exit on error */
>> + if (is_block_device(file))
>> + __test_dev_for_mkfs(file, force_overwrite);
>
> Catch errors here and exit() eventually.
>
>> + }
>> +
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2013-04-15 6:46 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-05 5:54 [PATCH 0/9] a bunch of miscellaneous bug fixes Anand Jain
2013-04-05 5:54 ` [PATCH 1/9] [RESEND] btrfs-progs: root_item generation_v2 is out of sync after btrfsck Anand Jain
2013-04-05 5:54 ` [PATCH 2/9] btrfs-progs: no pending balance is not an error Anand Jain
2013-04-12 15:57 ` David Sterba
2013-04-15 2:22 ` Anand Jain
2013-04-05 5:54 ` [PATCH 3/9] btrfs-progs: mkfs should first check all disks before writing to a disk Anand Jain
2013-04-12 16:06 ` David Sterba
2013-04-15 6:47 ` Anand Jain [this message]
2013-04-05 5:54 ` [PATCH 4/9] btrfs-progs: check if btrfs kernel module is loaded Anand Jain
2013-04-10 8:23 ` [PATCH 4/9 v2] " Anand Jain
2013-04-12 16:23 ` David Sterba
2013-04-15 7:14 ` Anand Jain
2013-04-05 5:54 ` [PATCH 5/9] [RESEND] btrfs-progs: delete unused function get_mountpt Anand Jain
2013-04-05 5:55 ` [PATCH 6/9] btrfs-progs: mkfs stdout print to match chronology Anand Jain
2013-04-05 5:55 ` [PATCH 7/9] btrfs-progs: cmd replace should check target-dev fully Anand Jain
2013-04-05 5:55 ` [PATCH 8/9] btrfs-progs: btrfs-select-super output is confusing when it fails Anand Jain
2013-04-05 5:55 ` [PATCH 9/9] btrfs-progs: fix btrfs scrub start help Anand Jain
2013-04-05 9:05 ` Stefan Behrens
2013-04-08 2:09 ` [PATCH 9/9 v2] " Anand Jain
2013-04-08 2:20 ` [PATCH 9/9 v3] " Anand Jain
2013-04-11 9:58 ` [PATCH] btrfs-progs: avoid ioctl for multipath-dev with its non-multipath path Anand Jain
2013-04-15 6:38 ` [PATCH 00/11 v2] a bunch of miscellaneous bug fixes Anand Jain
2013-04-15 6:38 ` [PATCH 01/11, RESEND] btrfs-progs: root_item generation_v2 is out of sync after btrfsck Anand Jain
2013-04-21 23:09 ` Eric Sandeen
2013-04-15 6:38 ` [PATCH 02/11, RESEND] btrfs-progs: no pending balance is not an error Anand Jain
2013-04-15 6:44 ` [PATCH 02/11, v2] " Anand Jain
2013-04-16 4:58 ` [PATCH 02/11 v3] " Anand Jain
2013-04-15 16:21 ` [PATCH 02/11, RESEND] " David Sterba
2013-04-16 5:02 ` Anand Jain
2013-04-15 6:38 ` [PATCH 03/11 v2] btrfs-progs: mkfs should first check all disks before writing to a disk Anand Jain
2013-04-15 6:38 ` [PATCH 04/11 v2] btrfs-progs: cmd replace should check target-dev fully Anand Jain
2013-04-15 6:38 ` [PATCH 05/11, RESEND] btrfs-progs: mkfs stdout print to match chronology Anand Jain
2013-04-15 6:38 ` [PATCH 06/11, v2] btrfs-progs: check if btrfs kernel module is loaded Anand Jain
2013-04-15 7:11 ` [PATCH 06/11 v3] " Anand Jain
2013-04-15 6:38 ` [PATCH 07/11, RESEND] btrfs-progs: delete unused function get_mountpt Anand Jain
2013-04-15 6:38 ` [PATCH 08/11, RESEND] btrfs-progs: btrfs-select-super output is confusing when it fails Anand Jain
2013-04-15 6:38 ` [PATCH 09/11, RESEND] btrfs-progs: fix btrfs scrub start help Anand Jain
2013-04-15 6:38 ` [PATCH 10/11, RESEND] btrfs-progs: avoid ioctl for multipath-dev with its non-multipath path Anand Jain
2013-04-15 6:38 ` [PATCH 11/11, RESEND] btrfs-progs: a copy of superblock is zero may not mean btrfs is not there Anand Jain
2013-04-16 12:15 ` [PATCH 00/11 v2] a bunch of miscellaneous bug fixes David Sterba
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=516BA278.6000400@oracle.com \
--to=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