* [PATCH 0/3] xfs: miscellaneous bugfixes
@ 2016-01-23 0:34 Darrick J. Wong
2016-01-23 0:34 ` [PATCH 1/3] xfs: use named array initializers for log item dumping Darrick J. Wong
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Darrick J. Wong @ 2016-01-23 0:34 UTC (permalink / raw)
To: david, darrick.wong; +Cc: xfs
Hi all,
I'm pushing a pile of miscellaneous bugfixes for the kernel, xfsprogs,
xfstests, and xfsdocs. None of these are rmap or reflink patches.
They've been compile-tested and run through xfstests on x86.
The biggest changes in these patches add structure size checking to
XFS and reorganize libxfs a bit so that xfs/122 (the userspace part
of structure size checking) will now pass with modern xfsprogs.
--D
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] xfs: use named array initializers for log item dumping
2016-01-23 0:34 [PATCH 0/3] xfs: miscellaneous bugfixes Darrick J. Wong
@ 2016-01-23 0:34 ` Darrick J. Wong
2016-01-27 13:31 ` Brian Foster
2016-01-23 0:34 ` [PATCH 2/3] xfs: move struct xfs_attr_shortform to xfs_da_format.h Darrick J. Wong
2016-01-23 0:34 ` [PATCH 3/3] xfs: check sizes of XFS on-disk structures at compile time Darrick J. Wong
2 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2016-01-23 0:34 UTC (permalink / raw)
To: david, darrick.wong; +Cc: xfs
Use named array initializers for the string arrays used to dump log
items, rather than depending on the order being maintained correctly.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/xfs_log.c | 132 ++++++++++++++++++++++++++++--------------------------
1 file changed, 68 insertions(+), 64 deletions(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 2aa187e..4758f06 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1989,77 +1989,81 @@ xlog_print_tic_res(
uint ophdr_spc = ticket->t_res_num_ophdrs * (uint)sizeof(xlog_op_header_t);
/* match with XLOG_REG_TYPE_* in xfs_log.h */
- static char *res_type_str[XLOG_REG_TYPE_MAX] = {
- "bformat",
- "bchunk",
- "efi_format",
- "efd_format",
- "iformat",
- "icore",
- "iext",
- "ibroot",
- "ilocal",
- "iattr_ext",
- "iattr_broot",
- "iattr_local",
- "qformat",
- "dquot",
- "quotaoff",
- "LR header",
- "unmount",
- "commit",
- "trans header"
+#define REG_TYPE_STR(type, str) [XLOG_REG_TYPE_##type] = str
+ static char *res_type_str[XLOG_REG_TYPE_MAX + 1] = {
+ REG_TYPE_STR(BFORMAT, "bformat"),
+ REG_TYPE_STR(BCHUNK, "bchunk"),
+ REG_TYPE_STR(EFI_FORMAT, "efi_format"),
+ REG_TYPE_STR(EFD_FORMAT, "efd_format"),
+ REG_TYPE_STR(IFORMAT, "iformat"),
+ REG_TYPE_STR(ICORE, "icore"),
+ REG_TYPE_STR(IEXT, "iext"),
+ REG_TYPE_STR(IBROOT, "ibroot"),
+ REG_TYPE_STR(ILOCAL, "ilocal"),
+ REG_TYPE_STR(IATTR_EXT, "iattr_ext"),
+ REG_TYPE_STR(IATTR_BROOT, "iattr_broot"),
+ REG_TYPE_STR(IATTR_LOCAL, "iattr_local"),
+ REG_TYPE_STR(QFORMAT, "qformat"),
+ REG_TYPE_STR(DQUOT, "dquot"),
+ REG_TYPE_STR(QUOTAOFF, "quotaoff"),
+ REG_TYPE_STR(LRHEADER, "LR header"),
+ REG_TYPE_STR(UNMOUNT, "unmount"),
+ REG_TYPE_STR(COMMIT, "commit"),
+ REG_TYPE_STR(TRANSHDR, "trans header"),
+ REG_TYPE_STR(ICREATE, "inode create")
};
+#undef REG_TYPE_STR
+#define TRANS_TYPE_STR(type) [XFS_TRANS_##type] = #type
static char *trans_type_str[XFS_TRANS_TYPE_MAX] = {
- "SETATTR_NOT_SIZE",
- "SETATTR_SIZE",
- "INACTIVE",
- "CREATE",
- "CREATE_TRUNC",
- "TRUNCATE_FILE",
- "REMOVE",
- "LINK",
- "RENAME",
- "MKDIR",
- "RMDIR",
- "SYMLINK",
- "SET_DMATTRS",
- "GROWFS",
- "STRAT_WRITE",
- "DIOSTRAT",
- "WRITE_SYNC",
- "WRITEID",
- "ADDAFORK",
- "ATTRINVAL",
- "ATRUNCATE",
- "ATTR_SET",
- "ATTR_RM",
- "ATTR_FLAG",
- "CLEAR_AGI_BUCKET",
- "QM_SBCHANGE",
- "DUMMY1",
- "DUMMY2",
- "QM_QUOTAOFF",
- "QM_DQALLOC",
- "QM_SETQLIM",
- "QM_DQCLUSTER",
- "QM_QINOCREATE",
- "QM_QUOTAOFF_END",
- "FSYNC_TS",
- "GROWFSRT_ALLOC",
- "GROWFSRT_ZERO",
- "GROWFSRT_FREE",
- "SWAPEXT",
- "CHECKPOINT",
- "ICREATE",
- "CREATE_TMPFILE"
+ TRANS_TYPE_STR(SETATTR_NOT_SIZE),
+ TRANS_TYPE_STR(SETATTR_SIZE),
+ TRANS_TYPE_STR(INACTIVE),
+ TRANS_TYPE_STR(CREATE),
+ TRANS_TYPE_STR(CREATE_TRUNC),
+ TRANS_TYPE_STR(TRUNCATE_FILE),
+ TRANS_TYPE_STR(REMOVE),
+ TRANS_TYPE_STR(LINK),
+ TRANS_TYPE_STR(RENAME),
+ TRANS_TYPE_STR(MKDIR),
+ TRANS_TYPE_STR(RMDIR),
+ TRANS_TYPE_STR(SYMLINK),
+ TRANS_TYPE_STR(SET_DMATTRS),
+ TRANS_TYPE_STR(GROWFS),
+ TRANS_TYPE_STR(STRAT_WRITE),
+ TRANS_TYPE_STR(DIOSTRAT),
+ TRANS_TYPE_STR(WRITEID),
+ TRANS_TYPE_STR(ADDAFORK),
+ TRANS_TYPE_STR(ATTRINVAL),
+ TRANS_TYPE_STR(ATRUNCATE),
+ TRANS_TYPE_STR(ATTR_SET),
+ TRANS_TYPE_STR(ATTR_RM),
+ TRANS_TYPE_STR(ATTR_FLAG),
+ TRANS_TYPE_STR(CLEAR_AGI_BUCKET),
+ TRANS_TYPE_STR(SB_CHANGE),
+ TRANS_TYPE_STR(DUMMY1),
+ TRANS_TYPE_STR(DUMMY2),
+ TRANS_TYPE_STR(QM_QUOTAOFF),
+ TRANS_TYPE_STR(QM_DQALLOC),
+ TRANS_TYPE_STR(QM_SETQLIM),
+ TRANS_TYPE_STR(QM_DQCLUSTER),
+ TRANS_TYPE_STR(QM_QINOCREATE),
+ TRANS_TYPE_STR(QM_QUOTAOFF_END),
+ TRANS_TYPE_STR(FSYNC_TS),
+ TRANS_TYPE_STR(GROWFSRT_ALLOC),
+ TRANS_TYPE_STR(GROWFSRT_ZERO),
+ TRANS_TYPE_STR(GROWFSRT_FREE),
+ TRANS_TYPE_STR(SWAPEXT),
+ TRANS_TYPE_STR(CHECKPOINT),
+ TRANS_TYPE_STR(ICREATE),
+ TRANS_TYPE_STR(CREATE_TMPFILE)
};
+#undef TRANS_TYPE_STR
xfs_warn(mp, "xlog_write: reservation summary:");
xfs_warn(mp, " trans type = %s (%u)",
((ticket->t_trans_type <= 0 ||
ticket->t_trans_type > XFS_TRANS_TYPE_MAX) ?
- "bad-trans-type" : trans_type_str[ticket->t_trans_type-1]),
+ "bad-trans-type" : trans_type_str[ticket->t_trans_type]),
ticket->t_trans_type);
xfs_warn(mp, " unit res = %d bytes",
ticket->t_unit_res);
@@ -2078,7 +2082,7 @@ xlog_print_tic_res(
uint r_type = ticket->t_res_arr[i].r_type;
xfs_warn(mp, "region[%u]: %s - %u bytes", i,
((r_type <= 0 || r_type > XLOG_REG_TYPE_MAX) ?
- "bad-rtype" : res_type_str[r_type-1]),
+ "bad-rtype" : res_type_str[r_type]),
ticket->t_res_arr[i].r_len);
}
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] xfs: move struct xfs_attr_shortform to xfs_da_format.h
2016-01-23 0:34 [PATCH 0/3] xfs: miscellaneous bugfixes Darrick J. Wong
2016-01-23 0:34 ` [PATCH 1/3] xfs: use named array initializers for log item dumping Darrick J. Wong
@ 2016-01-23 0:34 ` Darrick J. Wong
2016-01-27 13:31 ` Brian Foster
2016-01-23 0:34 ` [PATCH 3/3] xfs: check sizes of XFS on-disk structures at compile time Darrick J. Wong
2 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2016-01-23 0:34 UTC (permalink / raw)
To: david, darrick.wong; +Cc: xfs
Move the shortform attr structure definition to the same place as the
other attribute structure definitions for consistency and also so that
xfs/122 verifies the structure size.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/libxfs/xfs_attr_sf.h | 16 ----------------
fs/xfs/libxfs/xfs_da_format.h | 16 ++++++++++++++++
fs/xfs/libxfs/xfs_inode_fork.c | 1 +
3 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_attr_sf.h b/fs/xfs/libxfs/xfs_attr_sf.h
index 919756e..90928bb 100644
--- a/fs/xfs/libxfs/xfs_attr_sf.h
+++ b/fs/xfs/libxfs/xfs_attr_sf.h
@@ -24,22 +24,6 @@
* Small attribute lists are packed as tightly as possible so as
* to fit into the literal area of the inode.
*/
-
-/*
- * Entries are packed toward the top as tight as possible.
- */
-typedef struct xfs_attr_shortform {
- struct xfs_attr_sf_hdr { /* constant-structure header block */
- __be16 totsize; /* total bytes in shortform list */
- __u8 count; /* count of active entries */
- } hdr;
- struct xfs_attr_sf_entry {
- __uint8_t namelen; /* actual length of name (no NULL) */
- __uint8_t valuelen; /* actual length of value (no NULL) */
- __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
- __uint8_t nameval[1]; /* name & value bytes concatenated */
- } list[1]; /* variable sized array */
-} xfs_attr_shortform_t;
typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
index b14bbd6..8d4d8bc 100644
--- a/fs/xfs/libxfs/xfs_da_format.h
+++ b/fs/xfs/libxfs/xfs_da_format.h
@@ -641,6 +641,22 @@ xfs_dir2_block_leaf_p(struct xfs_dir2_block_tail *btp)
*/
#define XFS_ATTR_LEAF_MAPSIZE 3 /* how many freespace slots */
+/*
+ * Entries are packed toward the top as tight as possible.
+ */
+typedef struct xfs_attr_shortform {
+ struct xfs_attr_sf_hdr { /* constant-structure header block */
+ __be16 totsize; /* total bytes in shortform list */
+ __u8 count; /* count of active entries */
+ } hdr;
+ struct xfs_attr_sf_entry {
+ __uint8_t namelen; /* actual length of name (no NULL) */
+ __uint8_t valuelen; /* actual length of value (no NULL) */
+ __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
+ __uint8_t nameval[1]; /* name & value bytes concatenated */
+ } list[1]; /* variable sized array */
+} xfs_attr_shortform_t;
+
typedef struct xfs_attr_leaf_map { /* RLE map of free bytes */
__be16 base; /* base of free region */
__be16 size; /* length of free region */
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 0defbd0..ef22a78 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -31,6 +31,7 @@
#include "xfs_error.h"
#include "xfs_trace.h"
#include "xfs_attr_sf.h"
+#include "xfs_da_format.h"
kmem_zone_t *xfs_ifork_zone;
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] xfs: check sizes of XFS on-disk structures at compile time
2016-01-23 0:34 [PATCH 0/3] xfs: miscellaneous bugfixes Darrick J. Wong
2016-01-23 0:34 ` [PATCH 1/3] xfs: use named array initializers for log item dumping Darrick J. Wong
2016-01-23 0:34 ` [PATCH 2/3] xfs: move struct xfs_attr_shortform to xfs_da_format.h Darrick J. Wong
@ 2016-01-23 0:34 ` Darrick J. Wong
2016-01-27 13:31 ` Brian Foster
2 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2016-01-23 0:34 UTC (permalink / raw)
To: david, darrick.wong; +Cc: xfs
Check the sizes of XFS on-disk structures when compiling the kernel.
Use this to catch inadvertent changes in structure size due to padding
and alignment issues, etc.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/xfs_ondisk.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++
fs/xfs/xfs_super.c | 3 +
2 files changed, 111 insertions(+)
create mode 100644 fs/xfs/xfs_ondisk.h
diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h
new file mode 100644
index 0000000..56fab46
--- /dev/null
+++ b/fs/xfs/xfs_ondisk.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2016 Oracle.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __XFS_ONDISK_H
+#define __XFS_ONDISK_H
+
+#define XFS_CHECK_STRUCT_SIZE(structname, size) \
+ BUILD_BUG_ON_MSG(sizeof(structname) != (size), "XFS: sizeof(struct " \
+ #structname ") is wrong, expected " #size)
+
+static inline void __init
+xfs_check_ondisk_structs(void)
+{
+ /* ag/file structures */
+ XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 336);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_key, 8);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_rec, 16);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_bmdr_block, 4);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block, 72);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_timestamp, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_alloc_key_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_alloc_ptr_t, 4);
+ XFS_CHECK_STRUCT_SIZE(xfs_alloc_rec_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_inobt_ptr_t, 4);
+
+ /* dir/attr trees */
+ XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leaf_hdr, 80);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leafblock, 88);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_rmt_hdr, 56);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_da3_blkinfo, 56);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_da3_intnode, 64);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_da3_node_hdr, 64);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_blk_hdr, 48);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_data_hdr, 64);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free, 64);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free_hdr, 64);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf, 64);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf_hdr, 64);
+ XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_entry_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_hdr_t, 32);
+ XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_map_t, 4);
+ XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_name_local_t, 4);
+ XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_name_remote_t, 12);
+ XFS_CHECK_STRUCT_SIZE(xfs_attr_leafblock_t, 40);
+ XFS_CHECK_STRUCT_SIZE(xfs_attr_shortform_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_da_blkinfo_t, 12);
+ XFS_CHECK_STRUCT_SIZE(xfs_da_intnode_t, 16);
+ XFS_CHECK_STRUCT_SIZE(xfs_da_node_entry_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_da_node_hdr_t, 16);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_free_t, 4);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_hdr_t, 16);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_unused_t, 6);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_hdr_t, 16);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_t, 16);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino4_t, 4);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino8_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_inou_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_entry_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_hdr_t, 16);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_t, 16);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_tail_t, 4);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_entry_t, 3);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t, 10);
+ XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_off_t, 2);
+
+ /* log structures */
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_32, 28);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_64, 32);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_32, 28);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_64, 32);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_extent_32, 12);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_extent_64, 16);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_icdinode, 176);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
+}
+
+#endif /* __XFS_ONDISK_H */
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 36bd882..f63d212 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -45,6 +45,7 @@
#include "xfs_filestream.h"
#include "xfs_quota.h"
#include "xfs_sysfs.h"
+#include "xfs_ondisk.h"
#include <linux/namei.h>
#include <linux/init.h>
@@ -1817,6 +1818,8 @@ init_xfs_fs(void)
{
int error;
+ xfs_check_ondisk_structs();
+
printk(KERN_INFO XFS_VERSION_STRING " with "
XFS_BUILD_OPTIONS " enabled\n");
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] xfs: use named array initializers for log item dumping
2016-01-23 0:34 ` [PATCH 1/3] xfs: use named array initializers for log item dumping Darrick J. Wong
@ 2016-01-27 13:31 ` Brian Foster
0 siblings, 0 replies; 9+ messages in thread
From: Brian Foster @ 2016-01-27 13:31 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
On Fri, Jan 22, 2016 at 04:34:31PM -0800, Darrick J. Wong wrote:
> Use named array initializers for the string arrays used to dump log
> items, rather than depending on the order being maintained correctly.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/xfs/xfs_log.c | 132 ++++++++++++++++++++++++++++--------------------------
> 1 file changed, 68 insertions(+), 64 deletions(-)
>
>
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 2aa187e..4758f06 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -1989,77 +1989,81 @@ xlog_print_tic_res(
> uint ophdr_spc = ticket->t_res_num_ophdrs * (uint)sizeof(xlog_op_header_t);
>
> /* match with XLOG_REG_TYPE_* in xfs_log.h */
> - static char *res_type_str[XLOG_REG_TYPE_MAX] = {
> - "bformat",
> - "bchunk",
> - "efi_format",
> - "efd_format",
> - "iformat",
> - "icore",
> - "iext",
> - "ibroot",
> - "ilocal",
> - "iattr_ext",
> - "iattr_broot",
> - "iattr_local",
> - "qformat",
> - "dquot",
> - "quotaoff",
> - "LR header",
> - "unmount",
> - "commit",
> - "trans header"
> +#define REG_TYPE_STR(type, str) [XLOG_REG_TYPE_##type] = str
> + static char *res_type_str[XLOG_REG_TYPE_MAX + 1] = {
Maybe we should just fix XLOG_REG_TYPE_MAX to hold the array size (as
XFS_TRANS_TYPE_MAX does)..?
> + REG_TYPE_STR(BFORMAT, "bformat"),
> + REG_TYPE_STR(BCHUNK, "bchunk"),
> + REG_TYPE_STR(EFI_FORMAT, "efi_format"),
> + REG_TYPE_STR(EFD_FORMAT, "efd_format"),
> + REG_TYPE_STR(IFORMAT, "iformat"),
> + REG_TYPE_STR(ICORE, "icore"),
> + REG_TYPE_STR(IEXT, "iext"),
> + REG_TYPE_STR(IBROOT, "ibroot"),
> + REG_TYPE_STR(ILOCAL, "ilocal"),
> + REG_TYPE_STR(IATTR_EXT, "iattr_ext"),
> + REG_TYPE_STR(IATTR_BROOT, "iattr_broot"),
> + REG_TYPE_STR(IATTR_LOCAL, "iattr_local"),
> + REG_TYPE_STR(QFORMAT, "qformat"),
> + REG_TYPE_STR(DQUOT, "dquot"),
> + REG_TYPE_STR(QUOTAOFF, "quotaoff"),
> + REG_TYPE_STR(LRHEADER, "LR header"),
> + REG_TYPE_STR(UNMOUNT, "unmount"),
> + REG_TYPE_STR(COMMIT, "commit"),
> + REG_TYPE_STR(TRANSHDR, "trans header"),
> + REG_TYPE_STR(ICREATE, "inode create")
> };
> +#undef REG_TYPE_STR
> +#define TRANS_TYPE_STR(type) [XFS_TRANS_##type] = #type
> static char *trans_type_str[XFS_TRANS_TYPE_MAX] = {
...
> };
> +#undef TRANS_TYPE_STR
>
> xfs_warn(mp, "xlog_write: reservation summary:");
> xfs_warn(mp, " trans type = %s (%u)",
> ((ticket->t_trans_type <= 0 ||
> ticket->t_trans_type > XFS_TRANS_TYPE_MAX) ?
> - "bad-trans-type" : trans_type_str[ticket->t_trans_type-1]),
> + "bad-trans-type" : trans_type_str[ticket->t_trans_type]),
Why not incorporate the -1 offset in the new macros and leave these as
is? That avoids a dummy entry at index 0 in each array as well.
Brian
> ticket->t_trans_type);
> xfs_warn(mp, " unit res = %d bytes",
> ticket->t_unit_res);
> @@ -2078,7 +2082,7 @@ xlog_print_tic_res(
> uint r_type = ticket->t_res_arr[i].r_type;
> xfs_warn(mp, "region[%u]: %s - %u bytes", i,
> ((r_type <= 0 || r_type > XLOG_REG_TYPE_MAX) ?
> - "bad-rtype" : res_type_str[r_type-1]),
> + "bad-rtype" : res_type_str[r_type]),
> ticket->t_res_arr[i].r_len);
> }
>
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] xfs: move struct xfs_attr_shortform to xfs_da_format.h
2016-01-23 0:34 ` [PATCH 2/3] xfs: move struct xfs_attr_shortform to xfs_da_format.h Darrick J. Wong
@ 2016-01-27 13:31 ` Brian Foster
0 siblings, 0 replies; 9+ messages in thread
From: Brian Foster @ 2016-01-27 13:31 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
On Fri, Jan 22, 2016 at 04:34:38PM -0800, Darrick J. Wong wrote:
> Move the shortform attr structure definition to the same place as the
> other attribute structure definitions for consistency and also so that
> xfs/122 verifies the structure size.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
Seems fine:
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/libxfs/xfs_attr_sf.h | 16 ----------------
> fs/xfs/libxfs/xfs_da_format.h | 16 ++++++++++++++++
> fs/xfs/libxfs/xfs_inode_fork.c | 1 +
> 3 files changed, 17 insertions(+), 16 deletions(-)
>
>
> diff --git a/fs/xfs/libxfs/xfs_attr_sf.h b/fs/xfs/libxfs/xfs_attr_sf.h
> index 919756e..90928bb 100644
> --- a/fs/xfs/libxfs/xfs_attr_sf.h
> +++ b/fs/xfs/libxfs/xfs_attr_sf.h
> @@ -24,22 +24,6 @@
> * Small attribute lists are packed as tightly as possible so as
> * to fit into the literal area of the inode.
> */
> -
> -/*
> - * Entries are packed toward the top as tight as possible.
> - */
> -typedef struct xfs_attr_shortform {
> - struct xfs_attr_sf_hdr { /* constant-structure header block */
> - __be16 totsize; /* total bytes in shortform list */
> - __u8 count; /* count of active entries */
> - } hdr;
> - struct xfs_attr_sf_entry {
> - __uint8_t namelen; /* actual length of name (no NULL) */
> - __uint8_t valuelen; /* actual length of value (no NULL) */
> - __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
> - __uint8_t nameval[1]; /* name & value bytes concatenated */
> - } list[1]; /* variable sized array */
> -} xfs_attr_shortform_t;
> typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
> typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
>
> diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
> index b14bbd6..8d4d8bc 100644
> --- a/fs/xfs/libxfs/xfs_da_format.h
> +++ b/fs/xfs/libxfs/xfs_da_format.h
> @@ -641,6 +641,22 @@ xfs_dir2_block_leaf_p(struct xfs_dir2_block_tail *btp)
> */
> #define XFS_ATTR_LEAF_MAPSIZE 3 /* how many freespace slots */
>
> +/*
> + * Entries are packed toward the top as tight as possible.
> + */
> +typedef struct xfs_attr_shortform {
> + struct xfs_attr_sf_hdr { /* constant-structure header block */
> + __be16 totsize; /* total bytes in shortform list */
> + __u8 count; /* count of active entries */
> + } hdr;
> + struct xfs_attr_sf_entry {
> + __uint8_t namelen; /* actual length of name (no NULL) */
> + __uint8_t valuelen; /* actual length of value (no NULL) */
> + __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
> + __uint8_t nameval[1]; /* name & value bytes concatenated */
> + } list[1]; /* variable sized array */
> +} xfs_attr_shortform_t;
> +
> typedef struct xfs_attr_leaf_map { /* RLE map of free bytes */
> __be16 base; /* base of free region */
> __be16 size; /* length of free region */
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index 0defbd0..ef22a78 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -31,6 +31,7 @@
> #include "xfs_error.h"
> #include "xfs_trace.h"
> #include "xfs_attr_sf.h"
> +#include "xfs_da_format.h"
>
> kmem_zone_t *xfs_ifork_zone;
>
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] xfs: check sizes of XFS on-disk structures at compile time
2016-01-23 0:34 ` [PATCH 3/3] xfs: check sizes of XFS on-disk structures at compile time Darrick J. Wong
@ 2016-01-27 13:31 ` Brian Foster
2016-02-02 23:27 ` Darrick J. Wong
0 siblings, 1 reply; 9+ messages in thread
From: Brian Foster @ 2016-01-27 13:31 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
On Fri, Jan 22, 2016 at 04:34:44PM -0800, Darrick J. Wong wrote:
> Check the sizes of XFS on-disk structures when compiling the kernel.
> Use this to catch inadvertent changes in structure size due to padding
> and alignment issues, etc.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/xfs/xfs_ondisk.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++
> fs/xfs/xfs_super.c | 3 +
> 2 files changed, 111 insertions(+)
> create mode 100644 fs/xfs/xfs_ondisk.h
>
>
> diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h
> new file mode 100644
> index 0000000..56fab46
> --- /dev/null
> +++ b/fs/xfs/xfs_ondisk.h
> @@ -0,0 +1,108 @@
> +/*
> + * Copyright (c) 2016 Oracle.
> + * All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it would be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write the Free Software Foundation,
> + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +#ifndef __XFS_ONDISK_H
> +#define __XFS_ONDISK_H
> +
> +#define XFS_CHECK_STRUCT_SIZE(structname, size) \
> + BUILD_BUG_ON_MSG(sizeof(structname) != (size), "XFS: sizeof(struct " \
We're printing "struct" in the core message as well as part of the
structname (where appropriate). E.g., "sizeof(struct struct xfs_acl) is
wrong, ..."
It would also be nice to include the current structure size in the
message if it happens to be unexpected. Otherwise, seems fine to me.
Brian
> + #structname ") is wrong, expected " #size)
> +
> +static inline void __init
> +xfs_check_ondisk_structs(void)
> +{
> + /* ag/file structures */
> + XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 336);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_key, 8);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_rec, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_bmdr_block, 4);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block, 72);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_timestamp, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_alloc_key_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_alloc_ptr_t, 4);
> + XFS_CHECK_STRUCT_SIZE(xfs_alloc_rec_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_inobt_ptr_t, 4);
> +
> + /* dir/attr trees */
> + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leaf_hdr, 80);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leafblock, 88);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_rmt_hdr, 56);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_da3_blkinfo, 56);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_da3_intnode, 64);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_da3_node_hdr, 64);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_blk_hdr, 48);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_data_hdr, 64);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free, 64);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free_hdr, 64);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf, 64);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf_hdr, 64);
> + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_entry_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_hdr_t, 32);
> + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_map_t, 4);
> + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_name_local_t, 4);
> + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_name_remote_t, 12);
> + XFS_CHECK_STRUCT_SIZE(xfs_attr_leafblock_t, 40);
> + XFS_CHECK_STRUCT_SIZE(xfs_attr_shortform_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_da_blkinfo_t, 12);
> + XFS_CHECK_STRUCT_SIZE(xfs_da_intnode_t, 16);
> + XFS_CHECK_STRUCT_SIZE(xfs_da_node_entry_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_da_node_hdr_t, 16);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_free_t, 4);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_hdr_t, 16);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_unused_t, 6);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_hdr_t, 16);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_t, 16);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino4_t, 4);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino8_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_inou_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_entry_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_hdr_t, 16);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_t, 16);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_tail_t, 4);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_entry_t, 3);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t, 10);
> + XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_off_t, 2);
> +
> + /* log structures */
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_32, 28);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_64, 32);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_32, 28);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_64, 32);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_32, 12);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_64, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_icdinode, 176);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
> +}
> +
> +#endif /* __XFS_ONDISK_H */
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 36bd882..f63d212 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -45,6 +45,7 @@
> #include "xfs_filestream.h"
> #include "xfs_quota.h"
> #include "xfs_sysfs.h"
> +#include "xfs_ondisk.h"
>
> #include <linux/namei.h>
> #include <linux/init.h>
> @@ -1817,6 +1818,8 @@ init_xfs_fs(void)
> {
> int error;
>
> + xfs_check_ondisk_structs();
> +
> printk(KERN_INFO XFS_VERSION_STRING " with "
> XFS_BUILD_OPTIONS " enabled\n");
>
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] xfs: check sizes of XFS on-disk structures at compile time
2016-01-27 13:31 ` Brian Foster
@ 2016-02-02 23:27 ` Darrick J. Wong
2016-02-03 12:37 ` Brian Foster
0 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2016-02-02 23:27 UTC (permalink / raw)
To: Brian Foster; +Cc: xfs
On Wed, Jan 27, 2016 at 08:31:17AM -0500, Brian Foster wrote:
> On Fri, Jan 22, 2016 at 04:34:44PM -0800, Darrick J. Wong wrote:
> > Check the sizes of XFS on-disk structures when compiling the kernel.
> > Use this to catch inadvertent changes in structure size due to padding
> > and alignment issues, etc.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > fs/xfs/xfs_ondisk.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++
> > fs/xfs/xfs_super.c | 3 +
> > 2 files changed, 111 insertions(+)
> > create mode 100644 fs/xfs/xfs_ondisk.h
> >
> >
> > diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h
> > new file mode 100644
> > index 0000000..56fab46
> > --- /dev/null
> > +++ b/fs/xfs/xfs_ondisk.h
> > @@ -0,0 +1,108 @@
> > +/*
> > + * Copyright (c) 2016 Oracle.
> > + * All Rights Reserved.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it would be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with this program; if not, write the Free Software Foundation,
> > + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> > + */
> > +#ifndef __XFS_ONDISK_H
> > +#define __XFS_ONDISK_H
> > +
> > +#define XFS_CHECK_STRUCT_SIZE(structname, size) \
> > + BUILD_BUG_ON_MSG(sizeof(structname) != (size), "XFS: sizeof(struct " \
>
> We're printing "struct" in the core message as well as part of the
> structname (where appropriate). E.g., "sizeof(struct struct xfs_acl) is
> wrong, ..."
Heh, fixed.
> It would also be nice to include the current structure size in the
> message if it happens to be unexpected. Otherwise, seems fine to me.
I don't think it's possible to pass the size to __attribute__((error(msg...)))?
gcc only seems only to accept string arguments to the error() attribute.
--D
>
> Brian
>
> > + #structname ") is wrong, expected " #size)
> > +
>
> > +static inline void __init
> > +xfs_check_ondisk_structs(void)
> > +{
> > + /* ag/file structures */
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 336);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_key, 8);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_rec, 16);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_bmdr_block, 4);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block, 72);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_timestamp, 8);
> > + XFS_CHECK_STRUCT_SIZE(xfs_alloc_key_t, 8);
> > + XFS_CHECK_STRUCT_SIZE(xfs_alloc_ptr_t, 4);
> > + XFS_CHECK_STRUCT_SIZE(xfs_alloc_rec_t, 8);
> > + XFS_CHECK_STRUCT_SIZE(xfs_inobt_ptr_t, 4);
> > +
> > + /* dir/attr trees */
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leaf_hdr, 80);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leafblock, 88);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_rmt_hdr, 56);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_da3_blkinfo, 56);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_da3_intnode, 64);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_da3_node_hdr, 64);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_blk_hdr, 48);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_data_hdr, 64);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free, 64);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free_hdr, 64);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf, 64);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf_hdr, 64);
> > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_entry_t, 8);
> > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_hdr_t, 32);
> > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_map_t, 4);
> > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_name_local_t, 4);
> > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_name_remote_t, 12);
> > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leafblock_t, 40);
> > + XFS_CHECK_STRUCT_SIZE(xfs_attr_shortform_t, 8);
> > + XFS_CHECK_STRUCT_SIZE(xfs_da_blkinfo_t, 12);
> > + XFS_CHECK_STRUCT_SIZE(xfs_da_intnode_t, 16);
> > + XFS_CHECK_STRUCT_SIZE(xfs_da_node_entry_t, 8);
> > + XFS_CHECK_STRUCT_SIZE(xfs_da_node_hdr_t, 16);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_free_t, 4);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_hdr_t, 16);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_unused_t, 6);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_hdr_t, 16);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_t, 16);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino4_t, 4);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino8_t, 8);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_inou_t, 8);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_entry_t, 8);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_hdr_t, 16);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_t, 16);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_tail_t, 4);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_entry_t, 3);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t, 10);
> > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_off_t, 2);
> > +
> > + /* log structures */
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_32, 28);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_64, 32);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_32, 28);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_64, 32);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_32, 12);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_64, 16);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_icdinode, 176);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
> > +}
> > +
> > +#endif /* __XFS_ONDISK_H */
> > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > index 36bd882..f63d212 100644
> > --- a/fs/xfs/xfs_super.c
> > +++ b/fs/xfs/xfs_super.c
> > @@ -45,6 +45,7 @@
> > #include "xfs_filestream.h"
> > #include "xfs_quota.h"
> > #include "xfs_sysfs.h"
> > +#include "xfs_ondisk.h"
> >
> > #include <linux/namei.h>
> > #include <linux/init.h>
> > @@ -1817,6 +1818,8 @@ init_xfs_fs(void)
> > {
> > int error;
> >
> > + xfs_check_ondisk_structs();
> > +
> > printk(KERN_INFO XFS_VERSION_STRING " with "
> > XFS_BUILD_OPTIONS " enabled\n");
> >
> >
> > _______________________________________________
> > xfs mailing list
> > xfs@oss.sgi.com
> > http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] xfs: check sizes of XFS on-disk structures at compile time
2016-02-02 23:27 ` Darrick J. Wong
@ 2016-02-03 12:37 ` Brian Foster
0 siblings, 0 replies; 9+ messages in thread
From: Brian Foster @ 2016-02-03 12:37 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
On Tue, Feb 02, 2016 at 03:27:35PM -0800, Darrick J. Wong wrote:
> On Wed, Jan 27, 2016 at 08:31:17AM -0500, Brian Foster wrote:
> > On Fri, Jan 22, 2016 at 04:34:44PM -0800, Darrick J. Wong wrote:
> > > Check the sizes of XFS on-disk structures when compiling the kernel.
> > > Use this to catch inadvertent changes in structure size due to padding
> > > and alignment issues, etc.
> > >
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > ---
> > > fs/xfs/xfs_ondisk.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++
> > > fs/xfs/xfs_super.c | 3 +
> > > 2 files changed, 111 insertions(+)
> > > create mode 100644 fs/xfs/xfs_ondisk.h
> > >
> > >
> > > diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h
> > > new file mode 100644
> > > index 0000000..56fab46
> > > --- /dev/null
> > > +++ b/fs/xfs/xfs_ondisk.h
> > > @@ -0,0 +1,108 @@
> > > +/*
> > > + * Copyright (c) 2016 Oracle.
> > > + * All Rights Reserved.
> > > + *
> > > + * This program is free software; you can redistribute it and/or
> > > + * modify it under the terms of the GNU General Public License as
> > > + * published by the Free Software Foundation.
> > > + *
> > > + * This program is distributed in the hope that it would be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > > + * GNU General Public License for more details.
> > > + *
> > > + * You should have received a copy of the GNU General Public License
> > > + * along with this program; if not, write the Free Software Foundation,
> > > + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> > > + */
> > > +#ifndef __XFS_ONDISK_H
> > > +#define __XFS_ONDISK_H
> > > +
> > > +#define XFS_CHECK_STRUCT_SIZE(structname, size) \
> > > + BUILD_BUG_ON_MSG(sizeof(structname) != (size), "XFS: sizeof(struct " \
> >
> > We're printing "struct" in the core message as well as part of the
> > structname (where appropriate). E.g., "sizeof(struct struct xfs_acl) is
> > wrong, ..."
>
> Heh, fixed.
>
> > It would also be nice to include the current structure size in the
> > message if it happens to be unexpected. Otherwise, seems fine to me.
>
> I don't think it's possible to pass the size to __attribute__((error(msg...)))?
>
> gcc only seems only to accept string arguments to the error() attribute.
>
Ah, I guess we'd have to preconstruct the string or something like that.
Definitely not worth it, thanks!
Brian
> --D
>
> >
> > Brian
> >
> > > + #structname ") is wrong, expected " #size)
> > > +
> >
> > > +static inline void __init
> > > +xfs_check_ondisk_structs(void)
> > > +{
> > > + /* ag/file structures */
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 336);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_key, 8);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_rec, 16);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_bmdr_block, 4);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block, 72);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_timestamp, 8);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_alloc_key_t, 8);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_alloc_ptr_t, 4);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_alloc_rec_t, 8);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_inobt_ptr_t, 4);
> > > +
> > > + /* dir/attr trees */
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leaf_hdr, 80);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leafblock, 88);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_rmt_hdr, 56);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_da3_blkinfo, 56);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_da3_intnode, 64);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_da3_node_hdr, 64);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_blk_hdr, 48);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_data_hdr, 64);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free, 64);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free_hdr, 64);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf, 64);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf_hdr, 64);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_entry_t, 8);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_hdr_t, 32);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_map_t, 4);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_name_local_t, 4);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_name_remote_t, 12);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_attr_leafblock_t, 40);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_attr_shortform_t, 8);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_da_blkinfo_t, 12);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_da_intnode_t, 16);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_da_node_entry_t, 8);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_da_node_hdr_t, 16);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_free_t, 4);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_hdr_t, 16);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_unused_t, 6);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_hdr_t, 16);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_t, 16);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino4_t, 4);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino8_t, 8);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_inou_t, 8);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_entry_t, 8);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_hdr_t, 16);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_t, 16);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_tail_t, 4);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_entry_t, 3);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t, 10);
> > > + XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_off_t, 2);
> > > +
> > > + /* log structures */
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_32, 28);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_64, 32);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_32, 28);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_64, 32);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_32, 12);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_64, 16);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_icdinode, 176);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20);
> > > + XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
> > > +}
> > > +
> > > +#endif /* __XFS_ONDISK_H */
> > > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > > index 36bd882..f63d212 100644
> > > --- a/fs/xfs/xfs_super.c
> > > +++ b/fs/xfs/xfs_super.c
> > > @@ -45,6 +45,7 @@
> > > #include "xfs_filestream.h"
> > > #include "xfs_quota.h"
> > > #include "xfs_sysfs.h"
> > > +#include "xfs_ondisk.h"
> > >
> > > #include <linux/namei.h>
> > > #include <linux/init.h>
> > > @@ -1817,6 +1818,8 @@ init_xfs_fs(void)
> > > {
> > > int error;
> > >
> > > + xfs_check_ondisk_structs();
> > > +
> > > printk(KERN_INFO XFS_VERSION_STRING " with "
> > > XFS_BUILD_OPTIONS " enabled\n");
> > >
> > >
> > > _______________________________________________
> > > xfs mailing list
> > > xfs@oss.sgi.com
> > > http://oss.sgi.com/mailman/listinfo/xfs
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-02-03 12:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-23 0:34 [PATCH 0/3] xfs: miscellaneous bugfixes Darrick J. Wong
2016-01-23 0:34 ` [PATCH 1/3] xfs: use named array initializers for log item dumping Darrick J. Wong
2016-01-27 13:31 ` Brian Foster
2016-01-23 0:34 ` [PATCH 2/3] xfs: move struct xfs_attr_shortform to xfs_da_format.h Darrick J. Wong
2016-01-27 13:31 ` Brian Foster
2016-01-23 0:34 ` [PATCH 3/3] xfs: check sizes of XFS on-disk structures at compile time Darrick J. Wong
2016-01-27 13:31 ` Brian Foster
2016-02-02 23:27 ` Darrick J. Wong
2016-02-03 12:37 ` Brian Foster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox