Message ID | 20240719110447.3211103-1-maharmstone@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: set transid in btrfs_insert_dir_item | expand |
On Fri, Jul 19, 2024 at 12:05 PM Mark Harmstone <maharmstone@fb.com> wrote: > > btrfs_insert_dir_item wasn't setting the transid field in > btrfs_dir_item. This field doesn't matter, so set it to 0 rather than > writing uninitialized memory to disk. > > Signed-off-by: Mark Harmstone <maharmstone@fb.com> > --- > kernel-shared/dir-item.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel-shared/dir-item.c b/kernel-shared/dir-item.c > index 4c62597b..78ad108c 100644 > --- a/kernel-shared/dir-item.c > +++ b/kernel-shared/dir-item.c > @@ -173,6 +173,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, 0); > name_ptr = (unsigned long)(dir_item + 1); > > write_extent_buffer(leaf, name, name_ptr, name_len); > @@ -202,6 +203,7 @@ insert: > 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, 0); Why set 0? 0 isn't even a valid transaction id. The logical value here is trans->transid just like we do in the respective kernel counterpart. At the very least having the transaction id used to insert the item is helpful when debugging and looking at tree dumps. Thanks. > name_ptr = (unsigned long)(dir_item + 1); > write_extent_buffer(leaf, name, name_ptr, name_len); > btrfs_mark_buffer_dirty(leaf); > -- > 2.44.2 > >
diff --git a/kernel-shared/dir-item.c b/kernel-shared/dir-item.c index 4c62597b..78ad108c 100644 --- a/kernel-shared/dir-item.c +++ b/kernel-shared/dir-item.c @@ -173,6 +173,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, 0); name_ptr = (unsigned long)(dir_item + 1); write_extent_buffer(leaf, name, name_ptr, name_len); @@ -202,6 +203,7 @@ insert: 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, 0); name_ptr = (unsigned long)(dir_item + 1); write_extent_buffer(leaf, name, name_ptr, name_len); btrfs_mark_buffer_dirty(leaf);
btrfs_insert_dir_item wasn't setting the transid field in btrfs_dir_item. This field doesn't matter, so set it to 0 rather than writing uninitialized memory to disk. Signed-off-by: Mark Harmstone <maharmstone@fb.com> --- kernel-shared/dir-item.c | 2 ++ 1 file changed, 2 insertions(+)