Skip to content

Commit 788324f

Browse files
adam900710kdave
authored andcommitted
btrfs-progs: convert: replace the bytenrs check with a UASSERT()
The bytenr sequence of all roots are controlled by our code, so if something went wrong with the sequence, it's a bug. A UASSERT() is more suitable for this case. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 97740f6 commit 788324f

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

convert/common.c

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -260,19 +260,8 @@ static int setup_temp_root_tree(int fd, struct btrfs_mkfs_config *cfg,
260260
* Provided bytenr must in ascending order, or tree root will have a
261261
* bad key order.
262262
*/
263-
if (!(root_bytenr < extent_bytenr && extent_bytenr < dev_bytenr &&
264-
dev_bytenr < fs_bytenr && fs_bytenr < csum_bytenr)) {
265-
error("bad tree bytenr order: "
266-
"root < extent %llu < %llu, "
267-
"extent < dev %llu < %llu, "
268-
"dev < fs %llu < %llu, "
269-
"fs < csum %llu < %llu",
270-
root_bytenr, extent_bytenr,
271-
extent_bytenr, dev_bytenr,
272-
dev_bytenr, fs_bytenr,
273-
fs_bytenr, csum_bytenr);
274-
return -EINVAL;
275-
}
263+
UASSERT(root_bytenr < extent_bytenr && extent_bytenr < dev_bytenr &&
264+
dev_bytenr < fs_bytenr && fs_bytenr < csum_bytenr);
276265
buf = malloc(sizeof(*buf) + cfg->nodesize);
277266
if (!buf)
278267
return -ENOMEM;
@@ -703,22 +692,9 @@ static int setup_temp_extent_tree(int fd, struct btrfs_mkfs_config *cfg,
703692
* We must ensure provided bytenr are in ascending order,
704693
* or extent tree key order will be broken.
705694
*/
706-
if (!(chunk_bytenr < root_bytenr && root_bytenr < extent_bytenr &&
707-
extent_bytenr < dev_bytenr && dev_bytenr < fs_bytenr &&
708-
fs_bytenr < csum_bytenr)) {
709-
error("bad tree bytenr order: "
710-
"chunk < root %llu < %llu, "
711-
"root < extent %llu < %llu, "
712-
"extent < dev %llu < %llu, "
713-
"dev < fs %llu < %llu, "
714-
"fs < csum %llu < %llu",
715-
chunk_bytenr, root_bytenr,
716-
root_bytenr, extent_bytenr,
717-
extent_bytenr, dev_bytenr,
718-
dev_bytenr, fs_bytenr,
719-
fs_bytenr, csum_bytenr);
720-
return -EINVAL;
721-
}
695+
UASSERT(chunk_bytenr < root_bytenr && root_bytenr < extent_bytenr &&
696+
extent_bytenr < dev_bytenr && dev_bytenr < fs_bytenr &&
697+
fs_bytenr < csum_bytenr);
722698
buf = malloc(sizeof(*buf) + cfg->nodesize);
723699
if (!buf)
724700
return -ENOMEM;

0 commit comments

Comments
 (0)