Skip to content

Commit f7e67b2

Browse files
Christoph Hellwigdjwong
authored andcommitted
xfs: move the fork format fields into struct xfs_ifork
Both the data and attr fork have a format that is stored in the legacy idinode. Move it into the xfs_ifork structure instead, where it uses up padding. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Chandan Babu R <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent daf8396 commit f7e67b2

27 files changed

+182
-215
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ xfs_inode_hasattr(
6161
struct xfs_inode *ip)
6262
{
6363
if (!XFS_IFORK_Q(ip) ||
64-
(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
64+
(ip->i_afp->if_format == XFS_DINODE_FMT_EXTENTS &&
6565
ip->i_afp->if_nextents == 0))
6666
return 0;
6767
return 1;
@@ -84,7 +84,7 @@ xfs_attr_get_ilocked(
8484
if (!xfs_inode_hasattr(args->dp))
8585
return -ENOATTR;
8686

87-
if (args->dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL)
87+
if (args->dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL)
8888
return xfs_attr_shortform_getvalue(args);
8989
if (xfs_bmap_one_block(args->dp, XFS_ATTR_FORK))
9090
return xfs_attr_leaf_get(args);
@@ -212,14 +212,14 @@ xfs_attr_set_args(
212212
* If the attribute list is non-existent or a shortform list,
213213
* upgrade it to a single-leaf-block attribute list.
214214
*/
215-
if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL ||
216-
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
215+
if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL ||
216+
(dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS &&
217217
dp->i_afp->if_nextents == 0)) {
218218

219219
/*
220220
* Build initial attribute list (if required).
221221
*/
222-
if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS)
222+
if (dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS)
223223
xfs_attr_shortform_create(args);
224224

225225
/*
@@ -272,7 +272,7 @@ xfs_attr_remove_args(
272272

273273
if (!xfs_inode_hasattr(dp)) {
274274
error = -ENOATTR;
275-
} else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
275+
} else if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) {
276276
ASSERT(dp->i_afp->if_flags & XFS_IFINLINE);
277277
error = xfs_attr_shortform_remove(args);
278278
} else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) {

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ xfs_attr_shortform_bytesfit(
538538
/* rounded down */
539539
offset = (XFS_LITINO(mp) - bytes) >> 3;
540540

541-
if (dp->i_d.di_format == XFS_DINODE_FMT_DEV) {
541+
if (dp->i_df.if_format == XFS_DINODE_FMT_DEV) {
542542
minforkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
543543
return (offset >= minforkoff) ? minforkoff : 0;
544544
}
@@ -566,7 +566,7 @@ xfs_attr_shortform_bytesfit(
566566

567567
dsize = dp->i_df.if_bytes;
568568

569-
switch (dp->i_d.di_format) {
569+
switch (dp->i_df.if_format) {
570570
case XFS_DINODE_FMT_EXTENTS:
571571
/*
572572
* If there is no attr fork and the data fork is extents,
@@ -635,22 +635,19 @@ xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
635635
* Create the initial contents of a shortform attribute list.
636636
*/
637637
void
638-
xfs_attr_shortform_create(xfs_da_args_t *args)
638+
xfs_attr_shortform_create(
639+
struct xfs_da_args *args)
639640
{
640-
xfs_attr_sf_hdr_t *hdr;
641-
xfs_inode_t *dp;
642-
struct xfs_ifork *ifp;
641+
struct xfs_inode *dp = args->dp;
642+
struct xfs_ifork *ifp = dp->i_afp;
643+
struct xfs_attr_sf_hdr *hdr;
643644

644645
trace_xfs_attr_sf_create(args);
645646

646-
dp = args->dp;
647-
ASSERT(dp != NULL);
648-
ifp = dp->i_afp;
649-
ASSERT(ifp != NULL);
650647
ASSERT(ifp->if_bytes == 0);
651-
if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS) {
648+
if (ifp->if_format == XFS_DINODE_FMT_EXTENTS) {
652649
ifp->if_flags &= ~XFS_IFEXTENTS; /* just in case */
653-
dp->i_d.di_aformat = XFS_DINODE_FMT_LOCAL;
650+
ifp->if_format = XFS_DINODE_FMT_LOCAL;
654651
ifp->if_flags |= XFS_IFINLINE;
655652
} else {
656653
ASSERT(ifp->if_flags & XFS_IFINLINE);
@@ -722,7 +719,6 @@ xfs_attr_fork_remove(
722719

723720
xfs_idestroy_fork(ip, XFS_ATTR_FORK);
724721
ip->i_d.di_forkoff = 0;
725-
ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
726722

727723
ASSERT(ip->i_afp == NULL);
728724

@@ -775,7 +771,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
775771
totsize -= size;
776772
if (totsize == sizeof(xfs_attr_sf_hdr_t) &&
777773
(mp->m_flags & XFS_MOUNT_ATTR2) &&
778-
(dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
774+
(dp->i_df.if_format != XFS_DINODE_FMT_BTREE) &&
779775
!(args->op_flags & XFS_DA_OP_ADDNAME)) {
780776
xfs_attr_fork_remove(dp, args->trans);
781777
} else {
@@ -785,7 +781,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
785781
ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) ||
786782
(args->op_flags & XFS_DA_OP_ADDNAME) ||
787783
!(mp->m_flags & XFS_MOUNT_ATTR2) ||
788-
dp->i_d.di_format == XFS_DINODE_FMT_BTREE);
784+
dp->i_df.if_format == XFS_DINODE_FMT_BTREE);
789785
xfs_trans_log_inode(args->trans, dp,
790786
XFS_ILOG_CORE | XFS_ILOG_ADATA);
791787
}
@@ -962,7 +958,7 @@ xfs_attr_shortform_allfit(
962958
+ be16_to_cpu(name_loc->valuelen);
963959
}
964960
if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) &&
965-
(dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
961+
(dp->i_df.if_format != XFS_DINODE_FMT_BTREE) &&
966962
(bytes == sizeof(struct xfs_attr_sf_hdr)))
967963
return -1;
968964
return xfs_attr_shortform_bytesfit(dp, bytes);
@@ -981,7 +977,7 @@ xfs_attr_shortform_verify(
981977
int i;
982978
int64_t size;
983979

984-
ASSERT(ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL);
980+
ASSERT(ip->i_afp->if_format == XFS_DINODE_FMT_LOCAL);
985981
ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK);
986982
sfp = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
987983
size = ifp->if_bytes;
@@ -1085,7 +1081,7 @@ xfs_attr3_leaf_to_shortform(
10851081

10861082
if (forkoff == -1) {
10871083
ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2);
1088-
ASSERT(dp->i_d.di_format != XFS_DINODE_FMT_BTREE);
1084+
ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_BTREE);
10891085
xfs_attr_fork_remove(dp, args->trans);
10901086
goto out;
10911087
}

0 commit comments

Comments
 (0)