Skip to content

Commit 6e145f9

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: make if_data a void pointer
The xfs_ifork structure currently has a union of the if_root void pointer and the if_data char pointer. In either case it is an opaque pointer that depends on the fork format. Replace the union with a single if_data void pointer as that is what almost all callers want. Only the symlink NULL termination code in xfs_init_local_fork actually needs a new local variable now. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
1 parent e1ead23 commit 6e145f9

18 files changed

+119
-167
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,8 @@ xfs_attr_set(
10491049

10501050
static inline int xfs_attr_sf_totsize(struct xfs_inode *dp)
10511051
{
1052-
struct xfs_attr_shortform *sf;
1052+
struct xfs_attr_shortform *sf = dp->i_af.if_data;
10531053

1054-
sf = (struct xfs_attr_shortform *)dp->i_af.if_u1.if_data;
10551054
return be16_to_cpu(sf->hdr.totsize);
10561055
}
10571056

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ xfs_attr_shortform_create(
691691
if (ifp->if_format == XFS_DINODE_FMT_EXTENTS)
692692
ifp->if_format = XFS_DINODE_FMT_LOCAL;
693693
xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
694-
hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;
694+
hdr = ifp->if_data;
695695
memset(hdr, 0, sizeof(*hdr));
696696
hdr->totsize = cpu_to_be16(sizeof(*hdr));
697697
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
@@ -712,14 +712,13 @@ xfs_attr_sf_findname(
712712
struct xfs_attr_sf_entry **sfep,
713713
unsigned int *basep)
714714
{
715-
struct xfs_attr_shortform *sf;
715+
struct xfs_attr_shortform *sf = args->dp->i_af.if_data;
716716
struct xfs_attr_sf_entry *sfe;
717717
unsigned int base = sizeof(struct xfs_attr_sf_hdr);
718718
int size = 0;
719719
int end;
720720
int i;
721721

722-
sf = (struct xfs_attr_shortform *)args->dp->i_af.if_u1.if_data;
723722
sfe = &sf->list[0];
724723
end = sf->hdr.count;
725724
for (i = 0; i < end; sfe = xfs_attr_sf_nextentry(sfe),
@@ -751,29 +750,25 @@ xfs_attr_shortform_add(
751750
struct xfs_da_args *args,
752751
int forkoff)
753752
{
754-
struct xfs_attr_shortform *sf;
753+
struct xfs_inode *dp = args->dp;
754+
struct xfs_mount *mp = dp->i_mount;
755+
struct xfs_ifork *ifp = &dp->i_af;
756+
struct xfs_attr_shortform *sf = ifp->if_data;
755757
struct xfs_attr_sf_entry *sfe;
756758
int offset, size;
757-
struct xfs_mount *mp;
758-
struct xfs_inode *dp;
759-
struct xfs_ifork *ifp;
760759

761760
trace_xfs_attr_sf_add(args);
762761

763-
dp = args->dp;
764-
mp = dp->i_mount;
765762
dp->i_forkoff = forkoff;
766763

767-
ifp = &dp->i_af;
768764
ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
769-
sf = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
770765
if (xfs_attr_sf_findname(args, &sfe, NULL) == -EEXIST)
771766
ASSERT(0);
772767

773768
offset = (char *)sfe - (char *)sf;
774769
size = xfs_attr_sf_entsize_byname(args->namelen, args->valuelen);
775770
xfs_idata_realloc(dp, size, XFS_ATTR_FORK);
776-
sf = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
771+
sf = ifp->if_data;
777772
sfe = (struct xfs_attr_sf_entry *)((char *)sf + offset);
778773

779774
sfe->namelen = args->namelen;
@@ -811,20 +806,16 @@ int
811806
xfs_attr_sf_removename(
812807
struct xfs_da_args *args)
813808
{
814-
struct xfs_attr_shortform *sf;
809+
struct xfs_inode *dp = args->dp;
810+
struct xfs_mount *mp = dp->i_mount;
811+
struct xfs_attr_shortform *sf = dp->i_af.if_data;
815812
struct xfs_attr_sf_entry *sfe;
816813
int size = 0, end, totsize;
817814
unsigned int base;
818-
struct xfs_mount *mp;
819-
struct xfs_inode *dp;
820815
int error;
821816

822817
trace_xfs_attr_sf_remove(args);
823818

824-
dp = args->dp;
825-
mp = dp->i_mount;
826-
sf = (struct xfs_attr_shortform *)dp->i_af.if_u1.if_data;
827-
828819
error = xfs_attr_sf_findname(args, &sfe, &base);
829820

830821
/*
@@ -878,18 +869,17 @@ xfs_attr_sf_removename(
878869
*/
879870
/*ARGSUSED*/
880871
int
881-
xfs_attr_shortform_lookup(xfs_da_args_t *args)
872+
xfs_attr_shortform_lookup(
873+
struct xfs_da_args *args)
882874
{
883-
struct xfs_attr_shortform *sf;
884-
struct xfs_attr_sf_entry *sfe;
885-
int i;
886-
struct xfs_ifork *ifp;
875+
struct xfs_ifork *ifp = &args->dp->i_af;
876+
struct xfs_attr_shortform *sf = ifp->if_data;
877+
struct xfs_attr_sf_entry *sfe;
878+
int i;
887879

888880
trace_xfs_attr_sf_lookup(args);
889881

890-
ifp = &args->dp->i_af;
891882
ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
892-
sf = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
893883
sfe = &sf->list[0];
894884
for (i = 0; i < sf->hdr.count;
895885
sfe = xfs_attr_sf_nextentry(sfe), i++) {
@@ -909,14 +899,13 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args)
909899
*/
910900
int
911901
xfs_attr_shortform_getvalue(
912-
struct xfs_da_args *args)
902+
struct xfs_da_args *args)
913903
{
914-
struct xfs_attr_shortform *sf;
915-
struct xfs_attr_sf_entry *sfe;
916-
int i;
904+
struct xfs_attr_shortform *sf = args->dp->i_af.if_data;
905+
struct xfs_attr_sf_entry *sfe;
906+
int i;
917907

918908
ASSERT(args->dp->i_af.if_format == XFS_DINODE_FMT_LOCAL);
919-
sf = (struct xfs_attr_shortform *)args->dp->i_af.if_u1.if_data;
920909
sfe = &sf->list[0];
921910
for (i = 0; i < sf->hdr.count;
922911
sfe = xfs_attr_sf_nextentry(sfe), i++) {
@@ -933,25 +922,22 @@ int
933922
xfs_attr_shortform_to_leaf(
934923
struct xfs_da_args *args)
935924
{
936-
struct xfs_inode *dp;
937-
struct xfs_attr_shortform *sf;
925+
struct xfs_inode *dp = args->dp;
926+
struct xfs_ifork *ifp = &dp->i_af;
927+
struct xfs_attr_shortform *sf = ifp->if_data;
938928
struct xfs_attr_sf_entry *sfe;
939929
struct xfs_da_args nargs;
940930
char *tmpbuffer;
941931
int error, i, size;
942932
xfs_dablk_t blkno;
943933
struct xfs_buf *bp;
944-
struct xfs_ifork *ifp;
945934

946935
trace_xfs_attr_sf_to_leaf(args);
947936

948-
dp = args->dp;
949-
ifp = &dp->i_af;
950-
sf = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
951937
size = be16_to_cpu(sf->hdr.totsize);
952938
tmpbuffer = kmem_alloc(size, 0);
953939
ASSERT(tmpbuffer != NULL);
954-
memcpy(tmpbuffer, ifp->if_u1.if_data, size);
940+
memcpy(tmpbuffer, ifp->if_data, size);
955941
sf = (struct xfs_attr_shortform *)tmpbuffer;
956942

957943
xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ xfs_bmap_local_to_extents_empty(
747747
ASSERT(ifp->if_nextents == 0);
748748

749749
xfs_bmap_forkoff_reset(ip, whichfork);
750-
ifp->if_u1.if_root = NULL;
750+
ifp->if_data = NULL;
751751
ifp->if_height = 0;
752752
ifp->if_format = XFS_DINODE_FMT_EXTENTS;
753753
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
@@ -832,7 +832,7 @@ xfs_bmap_local_to_extents(
832832
xfs_bmap_local_to_extents_empty(tp, ip, whichfork);
833833
flags |= XFS_ILOG_CORE;
834834

835-
ifp->if_u1.if_root = NULL;
835+
ifp->if_data = NULL;
836836
ifp->if_height = 0;
837837

838838
rec.br_startoff = 0;

fs/xfs/libxfs/xfs_dir2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ xfs_dir_isempty(
196196
return 1;
197197
if (dp->i_disk_size > xfs_inode_data_fork_size(dp))
198198
return 0;
199-
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
199+
sfp = dp->i_df.if_data;
200200
return !sfp->count;
201201
}
202202

fs/xfs/libxfs/xfs_dir2_block.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ xfs_dir2_sf_to_block(
10891089
int newoffset; /* offset from current entry */
10901090
unsigned int offset = geo->data_entry_offset;
10911091
xfs_dir2_sf_entry_t *sfep; /* sf entry pointer */
1092-
xfs_dir2_sf_hdr_t *oldsfp; /* old shortform header */
1092+
struct xfs_dir2_sf_hdr *oldsfp = ifp->if_data;
10931093
xfs_dir2_sf_hdr_t *sfp; /* shortform header */
10941094
__be16 *tagp; /* end of data entry */
10951095
struct xfs_name name;
@@ -1099,10 +1099,8 @@ xfs_dir2_sf_to_block(
10991099
ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
11001100
ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
11011101

1102-
oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data;
1103-
11041102
ASSERT(ifp->if_bytes == dp->i_disk_size);
1105-
ASSERT(ifp->if_u1.if_data != NULL);
1103+
ASSERT(oldsfp != NULL);
11061104
ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
11071105
ASSERT(dp->i_df.if_nextents == 0);
11081106

0 commit comments

Comments
 (0)