mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
btrfs: simplify dir item location setup in btrfs_insert_xattr_item()
The location (a btrfs_disk_key) of a btrfs_dir_item used for a xattr is always zeroed and we have a complex setup in btrfs_insert_xattr_item() where we declare an on stack btrfs_key, zero it out, convert it into a btrfs_disk_key, also declared on stack, and then pass that btrfs_disk_key to a btrfs_set_dir_item_key() call. We can simplify this, and save stack space (one btrfs_disk_key and one btrfs_key), by simply using memzero_extent_buffer(). Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
7d69a3c9b5
commit
6fa6630f95
|
|
@ -62,8 +62,7 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
|
|||
int ret = 0;
|
||||
struct btrfs_dir_item *dir_item;
|
||||
unsigned long name_ptr, data_ptr;
|
||||
struct btrfs_key key, location;
|
||||
struct btrfs_disk_key disk_key;
|
||||
struct btrfs_key key;
|
||||
struct extent_buffer *leaf;
|
||||
u32 data_size;
|
||||
|
||||
|
|
@ -79,11 +78,11 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
|
|||
name, name_len);
|
||||
if (IS_ERR(dir_item))
|
||||
return PTR_ERR(dir_item);
|
||||
memset(&location, 0, sizeof(location));
|
||||
|
||||
leaf = path->nodes[0];
|
||||
btrfs_cpu_key_to_disk(&disk_key, &location);
|
||||
btrfs_set_dir_item_key(leaf, dir_item, &disk_key);
|
||||
memzero_extent_buffer(leaf, (unsigned long)dir_item +
|
||||
offsetof(struct btrfs_dir_item, location),
|
||||
sizeof(struct btrfs_disk_key));
|
||||
btrfs_set_dir_flags(leaf, dir_item, BTRFS_FT_XATTR);
|
||||
btrfs_set_dir_name_len(leaf, dir_item, name_len);
|
||||
btrfs_set_dir_transid(leaf, dir_item, trans->transid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user