Skip to content

Commit

Permalink
btrfs: use uuid_is_null() to verify if an uuid is empty
Browse files Browse the repository at this point in the history
At btrfs_is_empty_uuid() we have our custom code to check if an uuid is
empty, however there a kernel uuid library that has a function named
uuid_is_null() which does the same and probably more efficient.

So change btrfs_is_empty_uuid() to use uuid_is_null(), which is almost
a directly replacement, it just wraps the necessary casting since our
uuid types are u8 arrays while the uuid kernel library uses the uuid_t
type, which is just a typedef of an u8 array of 16 elements as well.

Also since the function is now to trivial, make it a static inline
function in fs.h.

Suggested-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Filipe Manana <[email protected]>
  • Loading branch information
fdmanana authored and adam900710 committed Dec 17, 2024
1 parent 331cce8 commit a724728
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
9 changes: 0 additions & 9 deletions fs/btrfs/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ size_t __attribute_const__ btrfs_get_num_csums(void)
return ARRAY_SIZE(btrfs_csums);
}

bool __pure btrfs_is_empty_uuid(const u8 *uuid)
{
for (int i = 0; i < BTRFS_UUID_SIZE; i++) {
if (uuid[i] != 0)
return false;
}
return true;
}

/*
* Start exclusive operation @type, return true on success.
*/
Expand Down
5 changes: 4 additions & 1 deletion fs/btrfs/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,10 @@ const char *btrfs_super_csum_name(u16 csum_type);
const char *btrfs_super_csum_driver(u16 csum_type);
size_t __attribute_const__ btrfs_get_num_csums(void);

bool __pure btrfs_is_empty_uuid(const u8 *uuid);
static inline bool btrfs_is_empty_uuid(const u8 *uuid)
{
return uuid_is_null((const uuid_t *)uuid);
}

/* Compatibility and incompatibility defines */
void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag,
Expand Down

0 comments on commit a724728

Please sign in to comment.