]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bcachefs: replace memcpy with memcpy_and_pad for jset_entry_log->d buff
authorRoxana Nicolescu <nicolescu.roxana@protonmail.com>
Thu, 27 Mar 2025 14:50:09 +0000 (14:50 +0000)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:13:25 +0000 (20:13 -0400)
commitcaa6baa45f809bd932362030b16a8bb3e1dae083
tree34ef0ebf244c5df3a9f01a474c48bea6fa45e78a
parent4e2caf82ce958d1fae96a6d6ba23ea9e80c597b4
bcachefs: replace memcpy with memcpy_and_pad for jset_entry_log->d buff

This was achieved before by zero-ing out the source buffer and then
copying the bytes into the destination buffer. This can also be done with
memcpy_and_pad which will zero out only the destination buffer if its
size is bigger than the size of the source buffer. This is already used in
the same way in journal_transaction_name().

Moreover, zero-ing the source buffer was done twice, first in
__bch2_fs_log_msg() and then in bch2_trans_log_msg(). And this method
may also require allocating some extra memory for the source buffer.

In conclusion, using memcpy_and_pad is better even tough the result is
the same because it brings uniformity with what's already used in
journal_transaction_name, it avoids code duplication and reallocating
extra memory.

Signed-off-by: Roxana Nicolescu <nicolescu.roxana@protonmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_update.c