From: Johannes Thumshirn <jthumshirn@suse.de>
To: Su Yue <Damenly_Su@gmx.com>
Cc: David Sterba <dsterba@suse.com>,
Linux BTRFS Mailinglist <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 1/2] btrfs-progs: add 'btrfs inspect-internal csum-dump' command
Date: Tue, 9 Apr 2019 12:30:39 +0200 [thread overview]
Message-ID: <20190409103039.GD5099@linux-x5ow.site> (raw)
In-Reply-To: <adb47c0d-6c71-3b34-7f20-7764bc16e036@gmx.com>
On Tue, Apr 09, 2019 at 05:34:22PM +0800, Su Yue wrote:
>
>
> On 2019/4/8 9:31 PM, Johannes Thumshirn wrote:
> > Add a 'btrfs inspect-internal csum-dump' command to dump the on-disk
> > checksums of a file.
> >
> > The dump command first uses the FIEMAP ioctl() to get a map of the file's
> > extents and then uses the BTRFS_TREE_SEARCH_V2 ioctl() to get the
> > checksums for these extents.
> >
> > Using FIEMAP instead of the BTRFS_TREE_SEARCH_V2 ioctl() to get the
> > extents allows us to quickly filter out any holes in the file, as this is
> > already done for us in the kernel.
> >
>
> Looks much better than V1. Some comments bellow.
>
Thanks.
[...]
> > + fiemap = calloc(1, sizeof(*fiemap));
> > + if (!fiemap)
> > + return -1;
>
> -ENOMEM is better.
OK.
> > +
> > + fiemap->fm_length = ~0;
> > +
> > + ret = ioctl(fd, FS_IOC_FIEMAP, fiemap);
> > + if (ret)
> > + goto free_fiemap;
> > +
> > + ext_size = fiemap->fm_mapped_extents * sizeof(struct fiemap_extent);
> > +
> > + tmp = realloc(fiemap, sizeof(*fiemap) + ext_size);
> > + if (!tmp)
>
> ret = -ENOMEM;
> else btrfs_get_extent_csum() will return 0.
>
Good catch, thanks
[...]
> > + fd = open(filename, O_RDONLY);
> > + if (fd < 0) {
> > + error("cannot open file %s:%m\n", filename);
>
> error() does break a line, no need of '\n'.
> > + return 1;
>
> -errno is better here.
OK.
--
Johannes Thumshirn SUSE Labs Filesystems
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
next prev parent reply other threads:[~2019-04-09 10:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-08 13:31 [PATCH 0/2] btrfs-progs: provide command to dump checksums Johannes Thumshirn
2019-04-08 13:31 ` [PATCH 1/2] btrfs-progs: add 'btrfs inspect-internal csum-dump' command Johannes Thumshirn
2019-04-09 8:47 ` Nikolay Borisov
2019-04-09 9:43 ` Johannes Thumshirn
2019-04-09 9:34 ` Su Yue
2019-04-09 10:30 ` Johannes Thumshirn [this message]
2019-04-08 13:31 ` [PATCH 2/2] btrfs-progs: completion: wire-up dump-csum Johannes Thumshirn
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=20190409103039.GD5099@linux-x5ow.site \
--to=jthumshirn@suse.de \
--cc=Damenly_Su@gmx.com \
--cc=dsterba@suse.com \
--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).