aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-07-19 21:47:21 -0400
committerDave Chinner <david@fromorbit.com>2016-07-19 21:47:21 -0400
commit8353a649f577a5d775f4666a31b286b8a5156dfb (patch)
tree363f13ebeb5920957cc7e638ae7f228fbff0f80a /fs/xfs
parent1a695a905c18548062509178b98bc91e67510864 (diff)
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_da_format.h14
-rw-r--r--fs/xfs/libxfs/xfs_dir2_sf.c13
-rw-r--r--fs/xfs/xfs_ondisk.h1
3 files changed, 10 insertions, 18 deletions
diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
index 8d4d8bce41bf..a5f4d6ee2bb3 100644
--- a/fs/xfs/libxfs/xfs_da_format.h
+++ b/fs/xfs/libxfs/xfs_da_format.h
@@ -192,12 +192,6 @@ typedef __uint16_t xfs_dir2_data_off_t;
192typedef uint xfs_dir2_data_aoff_t; /* argument form */ 192typedef uint xfs_dir2_data_aoff_t; /* argument form */
193 193
194/* 194/*
195 * Normalized offset (in a data block) of the entry, really xfs_dir2_data_off_t.
196 * Only need 16 bits, this is the byte offset into the single block form.
197 */
198typedef struct { __uint8_t i[2]; } __arch_pack xfs_dir2_sf_off_t;
199
200/*
201 * Offset in data space of a data entry. 195 * Offset in data space of a data entry.
202 */ 196 */
203typedef __uint32_t xfs_dir2_dataptr_t; 197typedef __uint32_t xfs_dir2_dataptr_t;
@@ -251,7 +245,7 @@ typedef struct xfs_dir2_sf_hdr {
251 245
252typedef struct xfs_dir2_sf_entry { 246typedef struct xfs_dir2_sf_entry {
253 __u8 namelen; /* actual name length */ 247 __u8 namelen; /* actual name length */
254 xfs_dir2_sf_off_t offset; /* saved offset */ 248 __u8 offset[2]; /* saved offset */
255 __u8 name[]; /* name, variable size */ 249 __u8 name[]; /* name, variable size */
256 /* 250 /*
257 * A single byte containing the file type field follows the inode 251 * A single byte containing the file type field follows the inode
@@ -260,7 +254,7 @@ typedef struct xfs_dir2_sf_entry {
260 * A xfs_dir2_ino8_t or xfs_dir2_ino4_t follows here, at a 254 * A xfs_dir2_ino8_t or xfs_dir2_ino4_t follows here, at a
261 * variable offset after the name. 255 * variable offset after the name.
262 */ 256 */
263} __arch_pack xfs_dir2_sf_entry_t; 257} xfs_dir2_sf_entry_t;
264 258
265static inline int xfs_dir2_sf_hdr_size(int i8count) 259static inline int xfs_dir2_sf_hdr_size(int i8count)
266{ 260{
@@ -272,13 +266,13 @@ static inline int xfs_dir2_sf_hdr_size(int i8count)
272static inline xfs_dir2_data_aoff_t 266static inline xfs_dir2_data_aoff_t
273xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep) 267xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep)
274{ 268{
275 return get_unaligned_be16(&sfep->offset.i); 269 return get_unaligned_be16(sfep->offset);
276} 270}
277 271
278static inline void 272static inline void
279xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off) 273xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
280{ 274{
281 put_unaligned_be16(off, &sfep->offset.i); 275 put_unaligned_be16(off, sfep->offset);
282} 276}
283 277
284static inline struct xfs_dir2_sf_entry * 278static inline struct xfs_dir2_sf_entry *
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index e5bb9cc3b243..f8ccfd5a0477 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -126,11 +126,10 @@ xfs_dir2_block_sfsize(
126 /* 126 /*
127 * Calculate the new size, see if we should give up yet. 127 * Calculate the new size, see if we should give up yet.
128 */ 128 */
129 size = xfs_dir2_sf_hdr_size(i8count) + /* header */ 129 size = xfs_dir2_sf_hdr_size(i8count) + /* header */
130 count + /* namelen */ 130 count * 3 * sizeof(u8) + /* namelen + offset */
131 count * (uint)sizeof(xfs_dir2_sf_off_t) + /* offset */ 131 namelen + /* name */
132 namelen + /* name */ 132 (i8count ? /* inumber */
133 (i8count ? /* inumber */
134 (uint)sizeof(xfs_dir2_ino8_t) * count : 133 (uint)sizeof(xfs_dir2_ino8_t) * count :
135 (uint)sizeof(xfs_dir2_ino4_t) * count); 134 (uint)sizeof(xfs_dir2_ino4_t) * count);
136 if (size > XFS_IFORK_DSIZE(dp)) 135 if (size > XFS_IFORK_DSIZE(dp))
@@ -1048,7 +1047,7 @@ xfs_dir2_sf_toino4(
1048 i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep), 1047 i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep),
1049 oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) { 1048 oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) {
1050 sfep->namelen = oldsfep->namelen; 1049 sfep->namelen = oldsfep->namelen;
1051 sfep->offset = oldsfep->offset; 1050 memcpy(sfep->offset, oldsfep->offset, sizeof(sfep->offset));
1052 memcpy(sfep->name, oldsfep->name, sfep->namelen); 1051 memcpy(sfep->name, oldsfep->name, sfep->namelen);
1053 dp->d_ops->sf_put_ino(sfp, sfep, 1052 dp->d_ops->sf_put_ino(sfp, sfep,
1054 dp->d_ops->sf_get_ino(oldsfp, oldsfep)); 1053 dp->d_ops->sf_get_ino(oldsfp, oldsfep));
@@ -1124,7 +1123,7 @@ xfs_dir2_sf_toino8(
1124 i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep), 1123 i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep),
1125 oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) { 1124 oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) {
1126 sfep->namelen = oldsfep->namelen; 1125 sfep->namelen = oldsfep->namelen;
1127 sfep->offset = oldsfep->offset; 1126 memcpy(sfep->offset, oldsfep->offset, sizeof(sfep->offset));
1128 memcpy(sfep->name, oldsfep->name, sfep->namelen); 1127 memcpy(sfep->name, oldsfep->name, sfep->namelen);
1129 dp->d_ops->sf_put_ino(sfp, sfep, 1128 dp->d_ops->sf_put_ino(sfp, sfep,
1130 dp->d_ops->sf_get_ino(oldsfp, oldsfep)); 1129 dp->d_ops->sf_get_ino(oldsfp, oldsfep));
diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h
index 184c44effdd5..918f13c5dd58 100644
--- a/fs/xfs/xfs_ondisk.h
+++ b/fs/xfs/xfs_ondisk.h
@@ -95,7 +95,6 @@ xfs_check_ondisk_structs(void)
95 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_tail_t, 4); 95 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_tail_t, 4);
96 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_entry_t, 3); 96 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_entry_t, 3);
97 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t, 10); 97 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t, 10);
98 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_off_t, 2);
99 98
100 /* log structures */ 99 /* log structures */
101 XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24); 100 XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24);