提交 dc4113d2 编写于 作者: D Dave Chinner

Merge branch 'xfs-4.8-dir2-sf-fixes' into for-next

...@@ -40,8 +40,7 @@ xfs_dir2_sf_entsize( ...@@ -40,8 +40,7 @@ xfs_dir2_sf_entsize(
int count = sizeof(struct xfs_dir2_sf_entry); /* namelen + offset */ int count = sizeof(struct xfs_dir2_sf_entry); /* namelen + offset */
count += len; /* name */ count += len; /* name */
count += hdr->i8count ? sizeof(xfs_dir2_ino8_t) : count += hdr->i8count ? XFS_INO64_SIZE : XFS_INO32_SIZE; /* ino # */
sizeof(xfs_dir2_ino4_t); /* ino # */
return count; return count;
} }
...@@ -125,33 +124,33 @@ xfs_dir3_sfe_put_ftype( ...@@ -125,33 +124,33 @@ xfs_dir3_sfe_put_ftype(
static xfs_ino_t static xfs_ino_t
xfs_dir2_sf_get_ino( xfs_dir2_sf_get_ino(
struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_hdr *hdr,
xfs_dir2_inou_t *from) __uint8_t *from)
{ {
if (hdr->i8count) if (hdr->i8count)
return get_unaligned_be64(&from->i8.i) & 0x00ffffffffffffffULL; return get_unaligned_be64(from) & 0x00ffffffffffffffULL;
else else
return get_unaligned_be32(&from->i4.i); return get_unaligned_be32(from);
} }
static void static void
xfs_dir2_sf_put_ino( xfs_dir2_sf_put_ino(
struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_hdr *hdr,
xfs_dir2_inou_t *to, __uint8_t *to,
xfs_ino_t ino) xfs_ino_t ino)
{ {
ASSERT((ino & 0xff00000000000000ULL) == 0); ASSERT((ino & 0xff00000000000000ULL) == 0);
if (hdr->i8count) if (hdr->i8count)
put_unaligned_be64(ino, &to->i8.i); put_unaligned_be64(ino, to);
else else
put_unaligned_be32(ino, &to->i4.i); put_unaligned_be32(ino, to);
} }
static xfs_ino_t static xfs_ino_t
xfs_dir2_sf_get_parent_ino( xfs_dir2_sf_get_parent_ino(
struct xfs_dir2_sf_hdr *hdr) struct xfs_dir2_sf_hdr *hdr)
{ {
return xfs_dir2_sf_get_ino(hdr, &hdr->parent); return xfs_dir2_sf_get_ino(hdr, hdr->parent);
} }
static void static void
...@@ -159,7 +158,7 @@ xfs_dir2_sf_put_parent_ino( ...@@ -159,7 +158,7 @@ xfs_dir2_sf_put_parent_ino(
struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_hdr *hdr,
xfs_ino_t ino) xfs_ino_t ino)
{ {
xfs_dir2_sf_put_ino(hdr, &hdr->parent, ino); xfs_dir2_sf_put_ino(hdr, hdr->parent, ino);
} }
/* /*
...@@ -173,8 +172,7 @@ xfs_dir2_sfe_get_ino( ...@@ -173,8 +172,7 @@ xfs_dir2_sfe_get_ino(
struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_hdr *hdr,
struct xfs_dir2_sf_entry *sfep) struct xfs_dir2_sf_entry *sfep)
{ {
return xfs_dir2_sf_get_ino(hdr, return xfs_dir2_sf_get_ino(hdr, &sfep->name[sfep->namelen]);
(xfs_dir2_inou_t *)&sfep->name[sfep->namelen]);
} }
static void static void
...@@ -183,8 +181,7 @@ xfs_dir2_sfe_put_ino( ...@@ -183,8 +181,7 @@ xfs_dir2_sfe_put_ino(
struct xfs_dir2_sf_entry *sfep, struct xfs_dir2_sf_entry *sfep,
xfs_ino_t ino) xfs_ino_t ino)
{ {
xfs_dir2_sf_put_ino(hdr, xfs_dir2_sf_put_ino(hdr, &sfep->name[sfep->namelen], ino);
(xfs_dir2_inou_t *)&sfep->name[sfep->namelen], ino);
} }
static xfs_ino_t static xfs_ino_t
...@@ -192,8 +189,7 @@ xfs_dir3_sfe_get_ino( ...@@ -192,8 +189,7 @@ xfs_dir3_sfe_get_ino(
struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_hdr *hdr,
struct xfs_dir2_sf_entry *sfep) struct xfs_dir2_sf_entry *sfep)
{ {
return xfs_dir2_sf_get_ino(hdr, return xfs_dir2_sf_get_ino(hdr, &sfep->name[sfep->namelen + 1]);
(xfs_dir2_inou_t *)&sfep->name[sfep->namelen + 1]);
} }
static void static void
...@@ -202,8 +198,7 @@ xfs_dir3_sfe_put_ino( ...@@ -202,8 +198,7 @@ xfs_dir3_sfe_put_ino(
struct xfs_dir2_sf_entry *sfep, struct xfs_dir2_sf_entry *sfep,
xfs_ino_t ino) xfs_ino_t ino)
{ {
xfs_dir2_sf_put_ino(hdr, xfs_dir2_sf_put_ino(hdr, &sfep->name[sfep->namelen + 1], ino);
(xfs_dir2_inou_t *)&sfep->name[sfep->namelen + 1], ino);
} }
......
...@@ -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.
*/ */
...@@ -214,22 +208,10 @@ typedef xfs_off_t xfs_dir2_off_t; ...@@ -214,22 +208,10 @@ typedef xfs_off_t xfs_dir2_off_t;
*/ */
typedef __uint32_t xfs_dir2_db_t; typedef __uint32_t xfs_dir2_db_t;
/* #define XFS_INO32_SIZE 4
* Inode number stored as 8 8-bit values. #define XFS_INO64_SIZE 8
*/ #define XFS_INO64_DIFF (XFS_INO64_SIZE - XFS_INO32_SIZE)
typedef struct { __uint8_t i[8]; } xfs_dir2_ino8_t;
/*
* Inode number stored as 4 8-bit values.
* Works a lot of the time, when all the inode numbers in a directory
* fit in 32 bits.
*/
typedef struct { __uint8_t i[4]; } xfs_dir2_ino4_t;
typedef union {
xfs_dir2_ino8_t i8;
xfs_dir2_ino4_t i4;
} xfs_dir2_inou_t;
#define XFS_DIR2_MAX_SHORT_INUM ((xfs_ino_t)0xffffffffULL) #define XFS_DIR2_MAX_SHORT_INUM ((xfs_ino_t)0xffffffffULL)
/* /*
...@@ -246,39 +228,38 @@ typedef union { ...@@ -246,39 +228,38 @@ typedef union {
typedef struct xfs_dir2_sf_hdr { typedef struct xfs_dir2_sf_hdr {
__uint8_t count; /* count of entries */ __uint8_t count; /* count of entries */
__uint8_t i8count; /* count of 8-byte inode #s */ __uint8_t i8count; /* count of 8-byte inode #s */
xfs_dir2_inou_t parent; /* parent dir inode number */ __uint8_t parent[8]; /* parent dir inode number */
} __arch_pack xfs_dir2_sf_hdr_t; } __packed xfs_dir2_sf_hdr_t;
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
* number for version 3 directory entries. * number for version 3 directory entries.
* *
* A xfs_dir2_ino8_t or xfs_dir2_ino4_t follows here, at a * A 64-bit or 32-bit inode number follows here, at a variable offset
* variable offset after the name. * 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)
{ {
return sizeof(struct xfs_dir2_sf_hdr) - return sizeof(struct xfs_dir2_sf_hdr) -
(i8count == 0) * (i8count == 0) * XFS_INO64_DIFF;
(sizeof(xfs_dir2_ino8_t) - sizeof(xfs_dir2_ino4_t));
} }
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 *
......
...@@ -127,12 +127,11 @@ xfs_dir2_block_sfsize( ...@@ -127,12 +127,11 @@ 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 : count * XFS_INO64_SIZE :
(uint)sizeof(xfs_dir2_ino4_t) * count); count * XFS_INO32_SIZE);
if (size > XFS_IFORK_DSIZE(dp)) if (size > XFS_IFORK_DSIZE(dp))
return size; /* size value is a failure */ return size; /* size value is a failure */
} }
...@@ -319,10 +318,7 @@ xfs_dir2_sf_addname( ...@@ -319,10 +318,7 @@ xfs_dir2_sf_addname(
/* /*
* Yes, adjust the inode size. old count + (parent + new) * Yes, adjust the inode size. old count + (parent + new)
*/ */
incr_isize += incr_isize += (sfp->count + 2) * XFS_INO64_DIFF;
(sfp->count + 2) *
((uint)sizeof(xfs_dir2_ino8_t) -
(uint)sizeof(xfs_dir2_ino4_t));
objchange = 1; objchange = 1;
} }
...@@ -897,11 +893,7 @@ xfs_dir2_sf_replace( ...@@ -897,11 +893,7 @@ xfs_dir2_sf_replace(
int error; /* error return value */ int error; /* error return value */
int newsize; /* new inode size */ int newsize; /* new inode size */
newsize = newsize = dp->i_df.if_bytes + (sfp->count + 1) * XFS_INO64_DIFF;
dp->i_df.if_bytes +
(sfp->count + 1) *
((uint)sizeof(xfs_dir2_ino8_t) -
(uint)sizeof(xfs_dir2_ino4_t));
/* /*
* Won't fit as shortform, convert to block then do replace. * Won't fit as shortform, convert to block then do replace.
*/ */
...@@ -1022,10 +1014,7 @@ xfs_dir2_sf_toino4( ...@@ -1022,10 +1014,7 @@ xfs_dir2_sf_toino4(
/* /*
* Compute the new inode size. * Compute the new inode size.
*/ */
newsize = newsize = oldsize - (oldsfp->count + 1) * XFS_INO64_DIFF;
oldsize -
(oldsfp->count + 1) *
((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t));
xfs_idata_realloc(dp, -oldsize, XFS_DATA_FORK); xfs_idata_realloc(dp, -oldsize, XFS_DATA_FORK);
xfs_idata_realloc(dp, newsize, XFS_DATA_FORK); xfs_idata_realloc(dp, newsize, XFS_DATA_FORK);
/* /*
...@@ -1048,7 +1037,7 @@ xfs_dir2_sf_toino4( ...@@ -1048,7 +1037,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));
...@@ -1098,10 +1087,7 @@ xfs_dir2_sf_toino8( ...@@ -1098,10 +1087,7 @@ xfs_dir2_sf_toino8(
/* /*
* Compute the new inode size (nb: entry count + 1 for parent) * Compute the new inode size (nb: entry count + 1 for parent)
*/ */
newsize = newsize = oldsize + (oldsfp->count + 1) * XFS_INO64_DIFF;
oldsize +
(oldsfp->count + 1) *
((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t));
xfs_idata_realloc(dp, -oldsize, XFS_DATA_FORK); xfs_idata_realloc(dp, -oldsize, XFS_DATA_FORK);
xfs_idata_realloc(dp, newsize, XFS_DATA_FORK); xfs_idata_realloc(dp, newsize, XFS_DATA_FORK);
/* /*
...@@ -1124,7 +1110,7 @@ xfs_dir2_sf_toino8( ...@@ -1124,7 +1110,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));
......
...@@ -328,13 +328,6 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) ...@@ -328,13 +328,6 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y)
return x; return x;
} }
/* ARM old ABI has some weird alignment/padding */
#if defined(__arm__) && !defined(__ARM_EABI__)
#define __arch_pack __attribute__((packed))
#else
#define __arch_pack
#endif
#define ASSERT_ALWAYS(expr) \ #define ASSERT_ALWAYS(expr) \
(unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
......
...@@ -106,9 +106,6 @@ xfs_check_ondisk_structs(void) ...@@ -106,9 +106,6 @@ xfs_check_ondisk_structs(void)
XFS_CHECK_OFFSET(xfs_dir2_data_unused_t, length, 2); XFS_CHECK_OFFSET(xfs_dir2_data_unused_t, length, 2);
XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_hdr_t, 16); 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_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_entry_t, 8);
XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_hdr_t, 16); 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_t, 16);
...@@ -118,7 +115,6 @@ xfs_check_ondisk_structs(void) ...@@ -118,7 +115,6 @@ xfs_check_ondisk_structs(void)
XFS_CHECK_OFFSET(xfs_dir2_sf_entry_t, offset, 1); XFS_CHECK_OFFSET(xfs_dir2_sf_entry_t, offset, 1);
XFS_CHECK_OFFSET(xfs_dir2_sf_entry_t, name, 3); XFS_CHECK_OFFSET(xfs_dir2_sf_entry_t, name, 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册