Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org, Ye Bin <yebin10@huawei.com>
Subject: Re: [PATCH] ext4: use ext4_fc_tl_mem in fast-commit replay path
Date: Wed, 11 Jan 2023 10:30:19 -0800	[thread overview]
Message-ID: <Y78AO7WX5Q6Zju3p@sol.localdomain> (raw)
In-Reply-To: <20230111144327.gb6p3foqj23mby7w@quack3>

On Wed, Jan 11, 2023 at 03:43:27PM +0100, Jan Kara wrote:
> On Fri 16-12-22 21:02:12, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> > 
> > To avoid 'sparse' warnings about missing endianness conversions, don't
> > store native endianness values into struct ext4_fc_tl.  Instead, use a
> > separate struct type, ext4_fc_tl_mem.
> > 
> > Fixes: dcc5827484d6 ("ext4: factor out ext4_fc_get_tl()")
> > Cc: Ye Bin <yebin10@huawei.com>
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
> 
> Looks good to me. Just one nit below:
> 
> > -static inline void ext4_fc_get_tl(struct ext4_fc_tl *tl, u8 *val)
> > +static inline void ext4_fc_get_tl(struct ext4_fc_tl_mem *tl, u8 *val)
> >  {
> > -	memcpy(tl, val, EXT4_FC_TAG_BASE_LEN);
> > -	tl->fc_len = le16_to_cpu(tl->fc_len);
> > -	tl->fc_tag = le16_to_cpu(tl->fc_tag);
> > +	struct ext4_fc_tl tl_disk;
> > +
> > +	memcpy(&tl_disk, val, EXT4_FC_TAG_BASE_LEN);
> > +	tl->fc_len = le16_to_cpu(tl_disk.fc_len);
> > +	tl->fc_tag = le16_to_cpu(tl_disk.fc_tag);
> >  }
> 
> So why not just:
> 
> 	struct ext4_fc_tl *tl_disk = (struct ext4_fc_tl *)val;
> 
> instead of memcpy?

That would result in unaligned memory accesses.

- Eric

  reply	other threads:[~2023-01-11 18:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-17  5:02 [PATCH] ext4: use ext4_fc_tl_mem in fast-commit replay path Eric Biggers
2023-01-11 14:43 ` Jan Kara
2023-01-11 18:30   ` Eric Biggers [this message]
2023-01-12 10:10     ` Jan Kara
2023-02-09 15:56 ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y78AO7WX5Q6Zju3p@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=yebin10@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox