Skip to content

Commit

Permalink
btrfs-progs: set transid in btrfs_insert_dir_item
Browse files Browse the repository at this point in the history
btrfs_insert_dir_item wasn't setting the transid field in
btrfs_dir_item. Set it to the current transaction ID rather than writing
uninitialized memory to disk.

Reviewed-by: Josef Bacik <[email protected]>
Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Mark Harmstone <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
  • Loading branch information
maharmstone authored and adam900710 committed Jul 28, 2024
1 parent b702630 commit 1535049
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel-shared/dir-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "kernel-shared/accessors.h"
#include "kernel-shared/extent_io.h"
#include "kernel-shared/uapi/btrfs_tree.h"
#include "kernel-shared/transaction.h"

struct btrfs_trans_handle;

Expand Down Expand Up @@ -173,6 +174,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
btrfs_set_dir_flags(leaf, dir_item, type);
btrfs_set_dir_data_len(leaf, dir_item, 0);
btrfs_set_dir_name_len(leaf, dir_item, name_len);
btrfs_set_dir_transid(leaf, dir_item, trans->transid);
name_ptr = (unsigned long)(dir_item + 1);

write_extent_buffer(leaf, name, name_ptr, name_len);
Expand Down Expand Up @@ -202,6 +204,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
btrfs_set_dir_flags(leaf, dir_item, type);
btrfs_set_dir_data_len(leaf, dir_item, 0);
btrfs_set_dir_name_len(leaf, dir_item, name_len);
btrfs_set_dir_transid(leaf, dir_item, trans->transid);
name_ptr = (unsigned long)(dir_item + 1);
write_extent_buffer(leaf, name, name_ptr, name_len);
btrfs_mark_buffer_dirty(leaf);
Expand Down

0 comments on commit 1535049

Please sign in to comment.