From: Zach Brown <zab@redhat.com>
To: Stefan Behrens <sbehrens@giantdisaster.de>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v6 1/8] Btrfs: introduce a tree for items that map UUIDs to something
Date: Wed, 26 Jun 2013 12:55:40 -0700 [thread overview]
Message-ID: <20130626195540.GA3907@lenny.home.zabbo.net> (raw)
In-Reply-To: <dcc3cedb7e15d11570aab0350113bc47eebc262b.1372250828.git.sbehrens@giantdisaster.de>
> + if (!uuid_root) {
> + WARN_ON_ONCE(1);
> + ret = -ENOENT;
> + goto out;
> + }
WARN_ON_ONCE specifically returns the condition so that you can write:
if (WARN_ON_ONCE(!uuid_root)) {
ret = -ENOENT;
goto out;
}
> + while (item_size) {
> + u64 data;
> +
> + read_extent_buffer(eb, &data, offset, sizeof(data));
> + data = le64_to_cpu(data);
> + if (data == subid) {
> + ret = 0;
> + break;
> + }
> + offset += sizeof(data);
> + item_size -= sizeof(data);
> + }
fs/btrfs/uuid-tree.c:81 col 24 warning: cast to restricted __le64
There are a few more instances of this. The good news is that fixing
the sparse warning makes the code better, too.
__le64 data;
read_extent_buffer(eb, &data, offset, sizeof(data));
if (le64_to_cpu(data) == subid) {
Plese make sure the rest of the series doesn't add sparse warnings for
Josef to get email about a few seconds after he merges.
> +int btrfs_insert_uuid_subvol_item(struct btrfs_trans_handle *trans,
> + struct btrfs_root *uuid_root, u8 *uuid,
> + u64 subvol_id)
> +{
> + int ret;
> +
> + ret = btrfs_uuid_tree_lookup(uuid_root, uuid,
> + BTRFS_UUID_KEY_SUBVOL, subvol_id);
> + if (ret == -ENOENT)
> + ret = btrfs_uuid_tree_add(trans, uuid_root, uuid,
> + BTRFS_UUID_KEY_SUBVOL, subvol_id);
> + return ret;
> +}
> +int btrfs_insert_uuid_received_subvol_item(struct btrfs_trans_handle *trans,
> + struct btrfs_root *uuid_root,
> + u8 *uuid, u64 subvol_id)
> +{
> + int ret;
> +
> + ret = btrfs_uuid_tree_lookup(uuid_root, uuid,
> + BTRFS_UUID_KEY_RECEIVED_SUBVOL, subvol_id);
> + if (ret == -ENOENT)
> + ret = btrfs_uuid_tree_add(trans, uuid_root, uuid,
> + BTRFS_UUID_KEY_RECEIVED_SUBVOL,
> + subvol_id);
> + return ret;
> +}
Just have callers pass in the key type so we get slightly less enormous
function names and less cut-and-paste code.
- z
next prev parent reply other threads:[~2013-06-26 19:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-26 15:16 [PATCH v6 0/8] Btrfs: introduce a tree for UUID to subvol ID mapping Stefan Behrens
2013-06-26 15:16 ` [PATCH v6 1/8] Btrfs: introduce a tree for items that map UUIDs to something Stefan Behrens
2013-06-26 19:55 ` Zach Brown [this message]
2013-06-26 21:47 ` Stefan Behrens
2013-06-26 22:16 ` Eric Sandeen
2013-06-26 22:25 ` Zach Brown
2013-06-27 1:45 ` Josef Bacik
2013-06-26 15:16 ` [PATCH v6 2/8] Btrfs: support printing UUID tree elements Stefan Behrens
2013-06-26 15:16 ` [PATCH v6 3/8] Btrfs: create UUID tree if required Stefan Behrens
2013-06-26 15:16 ` [PATCH v6 4/8] Btrfs: maintain subvolume items in the UUID tree Stefan Behrens
2013-06-26 15:16 ` [PATCH v6 5/8] Btrfs: fill UUID tree initially Stefan Behrens
2013-06-26 15:16 ` [PATCH v6 6/8] Btrfs: introduce uuid-tree-gen field Stefan Behrens
2013-06-26 15:16 ` [PATCH v6 7/8] Btrfs: check UUID tree during mount if required Stefan Behrens
2013-06-26 15:16 ` [PATCH v6 8/8] Btrfs: add mount option to force UUID tree checking Stefan Behrens
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=20130626195540.GA3907@lenny.home.zabbo.net \
--to=zab@redhat.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=sbehrens@giantdisaster.de \
/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).