Linux-XFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] xfs: Add __packed to xfs_dir2_sf_entry_t definition
@ 2020-01-14 12:03 Vincenzo Frascino
  2020-01-14 15:45 ` Christoph Hellwig
  2020-01-15  0:43 ` Darrick J. Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Vincenzo Frascino @ 2020-01-14 12:03 UTC (permalink / raw)
  To: hch, darrick.wong; +Cc: linux-xfs, linux-kernel, vincenzo.frascino

xfs_check_ondisk_structs() verifies that the sizes of the data types
used by xfs are correct via the XFS_CHECK_STRUCT_SIZE() macro.

Since the structures padding can vary depending on the ABI (e.g. on
ARM OABI structures are padded to multiple of 32 bits), it may happen
that xfs_dir2_sf_entry_t size check breaks the compilation with the
assertion below:

In file included from linux/include/linux/string.h:6,
                 from linux/include/linux/uuid.h:12,
                 from linux/fs/xfs/xfs_linux.h:10,
                 from linux/fs/xfs/xfs.h:22,
                 from linux/fs/xfs/xfs_super.c:7:
In function ‘xfs_check_ondisk_structs’,
    inlined from ‘init_xfs_fs’ at linux/fs/xfs/xfs_super.c:2025:2:
linux/include/linux/compiler.h:350:38:
    error: call to ‘__compiletime_assert_107’ declared with attribute
    error: XFS: sizeof(xfs_dir2_sf_entry_t) is wrong, expected 3
    _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)

Restore the correct behavior adding __packed to the structure definition.

Cc: Darrick J. Wong <darrick.wong@oracle.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 fs/xfs/libxfs/xfs_da_format.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
index 3dee33043e09..60db25f30430 100644
--- a/fs/xfs/libxfs/xfs_da_format.h
+++ b/fs/xfs/libxfs/xfs_da_format.h
@@ -217,7 +217,7 @@ typedef struct xfs_dir2_sf_entry {
 	 * A 64-bit or 32-bit inode number follows here, at a variable offset
 	 * after the name.
 	 */
-} xfs_dir2_sf_entry_t;
+} __packed xfs_dir2_sf_entry_t;
 
 static inline int xfs_dir2_sf_hdr_size(int i8count)
 {
-- 
2.24.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: Add __packed to xfs_dir2_sf_entry_t definition
  2020-01-14 12:03 [PATCH] xfs: Add __packed to xfs_dir2_sf_entry_t definition Vincenzo Frascino
@ 2020-01-14 15:45 ` Christoph Hellwig
  2020-01-15  0:43 ` Darrick J. Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-01-14 15:45 UTC (permalink / raw)
  To: Vincenzo Frascino; +Cc: hch, darrick.wong, linux-xfs, linux-kernel

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: Add __packed to xfs_dir2_sf_entry_t definition
  2020-01-14 12:03 [PATCH] xfs: Add __packed to xfs_dir2_sf_entry_t definition Vincenzo Frascino
  2020-01-14 15:45 ` Christoph Hellwig
@ 2020-01-15  0:43 ` Darrick J. Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2020-01-15  0:43 UTC (permalink / raw)
  To: Vincenzo Frascino; +Cc: hch, linux-xfs, linux-kernel

On Tue, Jan 14, 2020 at 12:03:52PM +0000, Vincenzo Frascino wrote:
> xfs_check_ondisk_structs() verifies that the sizes of the data types
> used by xfs are correct via the XFS_CHECK_STRUCT_SIZE() macro.
> 
> Since the structures padding can vary depending on the ABI (e.g. on
> ARM OABI structures are padded to multiple of 32 bits), it may happen
> that xfs_dir2_sf_entry_t size check breaks the compilation with the
> assertion below:
> 
> In file included from linux/include/linux/string.h:6,
>                  from linux/include/linux/uuid.h:12,
>                  from linux/fs/xfs/xfs_linux.h:10,
>                  from linux/fs/xfs/xfs.h:22,
>                  from linux/fs/xfs/xfs_super.c:7:
> In function ‘xfs_check_ondisk_structs’,
>     inlined from ‘init_xfs_fs’ at linux/fs/xfs/xfs_super.c:2025:2:
> linux/include/linux/compiler.h:350:38:
>     error: call to ‘__compiletime_assert_107’ declared with attribute
>     error: XFS: sizeof(xfs_dir2_sf_entry_t) is wrong, expected 3
>     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
> 
> Restore the correct behavior adding __packed to the structure definition.
> 
> Cc: Darrick J. Wong <darrick.wong@oracle.com>
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

Will give this a spin,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_da_format.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
> index 3dee33043e09..60db25f30430 100644
> --- a/fs/xfs/libxfs/xfs_da_format.h
> +++ b/fs/xfs/libxfs/xfs_da_format.h
> @@ -217,7 +217,7 @@ typedef struct xfs_dir2_sf_entry {
>  	 * A 64-bit or 32-bit inode number follows here, at a variable offset
>  	 * after the name.
>  	 */
> -} xfs_dir2_sf_entry_t;
> +} __packed xfs_dir2_sf_entry_t;
>  
>  static inline int xfs_dir2_sf_hdr_size(int i8count)
>  {
> -- 
> 2.24.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 12:03 [PATCH] xfs: Add __packed to xfs_dir2_sf_entry_t definition Vincenzo Frascino
2020-01-14 15:45 ` Christoph Hellwig
2020-01-15  0:43 ` Darrick J. Wong

Linux-XFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-xfs/0 linux-xfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-xfs linux-xfs/ https://lore.kernel.org/linux-xfs \
		linux-xfs@vger.kernel.org
	public-inbox-index linux-xfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-xfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git