Commit 8353a649 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

xfs: kill xfs_dir2_sf_off_t

Just use an array of two unsigned chars directly to avoid problems
with architectures that pad the size of structures.
Signed-off-by: 's avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: 's avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: 's avatarDave Chinner <david@fromorbit.com>
parent 1a695a90
...@@ -191,12 +191,6 @@ typedef __uint16_t xfs_dir2_data_off_t; ...@@ -191,12 +191,6 @@ typedef __uint16_t xfs_dir2_data_off_t;
#define NULLDATAOFF 0xffffU #define NULLDATAOFF 0xffffU
typedef uint xfs_dir2_data_aoff_t; /* argument form */ typedef uint xfs_dir2_data_aoff_t; /* argument form */
/*
* Normalized offset (in a data block) of the entry, really xfs_dir2_data_off_t.
* Only need 16 bits, this is the byte offset into the single block form.
*/
typedef struct { __uint8_t i[2]; } __arch_pack xfs_dir2_sf_off_t;
/* /*
* Offset in data space of a data entry. * Offset in data space of a data entry.
*/ */
...@@ -251,7 +245,7 @@ typedef struct xfs_dir2_sf_hdr { ...@@ -251,7 +245,7 @@ typedef struct xfs_dir2_sf_hdr {
typedef struct xfs_dir2_sf_entry { typedef struct xfs_dir2_sf_entry {
__u8 namelen; /* actual name length */ __u8 namelen; /* actual name length */
xfs_dir2_sf_off_t offset; /* saved offset */ __u8 offset[2]; /* saved offset */
__u8 name[]; /* name, variable size */ __u8 name[]; /* name, variable size */
/* /*
* A single byte containing the file type field follows the inode * A single byte containing the file type field follows the inode
...@@ -260,7 +254,7 @@ typedef struct xfs_dir2_sf_entry { ...@@ -260,7 +254,7 @@ typedef struct xfs_dir2_sf_entry {
* A xfs_dir2_ino8_t or xfs_dir2_ino4_t follows here, at a * A xfs_dir2_ino8_t or xfs_dir2_ino4_t follows here, at a
* variable offset after the name. * variable offset after the name.
*/ */
} __arch_pack xfs_dir2_sf_entry_t; } xfs_dir2_sf_entry_t;
static inline int xfs_dir2_sf_hdr_size(int i8count) static inline int xfs_dir2_sf_hdr_size(int i8count)
{ {
...@@ -272,13 +266,13 @@ static inline int xfs_dir2_sf_hdr_size(int i8count) ...@@ -272,13 +266,13 @@ static inline int xfs_dir2_sf_hdr_size(int i8count)
static inline xfs_dir2_data_aoff_t static inline xfs_dir2_data_aoff_t
xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep) xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep)
{ {
return get_unaligned_be16(&sfep->offset.i); return get_unaligned_be16(sfep->offset);
} }
static inline void static inline void
xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off) xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
{ {
put_unaligned_be16(off, &sfep->offset.i); put_unaligned_be16(off, sfep->offset);
} }
static inline struct xfs_dir2_sf_entry * static inline struct xfs_dir2_sf_entry *
......
...@@ -126,11 +126,10 @@ xfs_dir2_block_sfsize( ...@@ -126,11 +126,10 @@ xfs_dir2_block_sfsize(
/* /*
* Calculate the new size, see if we should give up yet. * Calculate the new size, see if we should give up yet.
*/ */
size = xfs_dir2_sf_hdr_size(i8count) + /* header */ size = xfs_dir2_sf_hdr_size(i8count) + /* header */
count + /* namelen */ count * 3 * sizeof(u8) + /* namelen + offset */
count * (uint)sizeof(xfs_dir2_sf_off_t) + /* offset */ namelen + /* name */
namelen + /* name */ (i8count ? /* inumber */
(i8count ? /* inumber */
(uint)sizeof(xfs_dir2_ino8_t) * count : (uint)sizeof(xfs_dir2_ino8_t) * count :
(uint)sizeof(xfs_dir2_ino4_t) * count); (uint)sizeof(xfs_dir2_ino4_t) * count);
if (size > XFS_IFORK_DSIZE(dp)) if (size > XFS_IFORK_DSIZE(dp))
...@@ -1048,7 +1047,7 @@ xfs_dir2_sf_toino4( ...@@ -1048,7 +1047,7 @@ xfs_dir2_sf_toino4(
i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep), i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep),
oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) { oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) {
sfep->namelen = oldsfep->namelen; sfep->namelen = oldsfep->namelen;
sfep->offset = oldsfep->offset; memcpy(sfep->offset, oldsfep->offset, sizeof(sfep->offset));
memcpy(sfep->name, oldsfep->name, sfep->namelen); memcpy(sfep->name, oldsfep->name, sfep->namelen);
dp->d_ops->sf_put_ino(sfp, sfep, dp->d_ops->sf_put_ino(sfp, sfep,
dp->d_ops->sf_get_ino(oldsfp, oldsfep)); dp->d_ops->sf_get_ino(oldsfp, oldsfep));
...@@ -1124,7 +1123,7 @@ xfs_dir2_sf_toino8( ...@@ -1124,7 +1123,7 @@ xfs_dir2_sf_toino8(
i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep), i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep),
oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) { oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) {
sfep->namelen = oldsfep->namelen; sfep->namelen = oldsfep->namelen;
sfep->offset = oldsfep->offset; memcpy(sfep->offset, oldsfep->offset, sizeof(sfep->offset));
memcpy(sfep->name, oldsfep->name, sfep->namelen); memcpy(sfep->name, oldsfep->name, sfep->namelen);
dp->d_ops->sf_put_ino(sfp, sfep, dp->d_ops->sf_put_ino(sfp, sfep,
dp->d_ops->sf_get_ino(oldsfp, oldsfep)); dp->d_ops->sf_get_ino(oldsfp, oldsfep));
......
...@@ -95,7 +95,6 @@ xfs_check_ondisk_structs(void) ...@@ -95,7 +95,6 @@ xfs_check_ondisk_structs(void)
XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_tail_t, 4); 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_entry_t, 3);
XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t, 10); XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t, 10);
XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_off_t, 2);
/* log structures */ /* log structures */
XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24); XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment