Commit 6e145f94 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
parent e1ead237
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1049,9 +1049,8 @@ xfs_attr_set(

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

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

+24 −38
Original line number Diff line number Diff line
@@ -691,7 +691,7 @@ xfs_attr_shortform_create(
	if (ifp->if_format == XFS_DINODE_FMT_EXTENTS)
		ifp->if_format = XFS_DINODE_FMT_LOCAL;
	xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
	hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;
	hdr = ifp->if_data;
	memset(hdr, 0, sizeof(*hdr));
	hdr->totsize = cpu_to_be16(sizeof(*hdr));
	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
@@ -712,14 +712,13 @@ xfs_attr_sf_findname(
	struct xfs_attr_sf_entry **sfep,
	unsigned int		 *basep)
{
	struct xfs_attr_shortform *sf;
	struct xfs_attr_shortform *sf = args->dp->i_af.if_data;
	struct xfs_attr_sf_entry *sfe;
	unsigned int		base = sizeof(struct xfs_attr_sf_hdr);
	int			size = 0;
	int			end;
	int			i;

	sf = (struct xfs_attr_shortform *)args->dp->i_af.if_u1.if_data;
	sfe = &sf->list[0];
	end = sf->hdr.count;
	for (i = 0; i < end; sfe = xfs_attr_sf_nextentry(sfe),
@@ -751,29 +750,25 @@ xfs_attr_shortform_add(
	struct xfs_da_args		*args,
	int				forkoff)
{
	struct xfs_attr_shortform	*sf;
	struct xfs_inode		*dp = args->dp;
	struct xfs_mount		*mp = dp->i_mount;
	struct xfs_ifork		*ifp = &dp->i_af;
	struct xfs_attr_shortform	*sf = ifp->if_data;
	struct xfs_attr_sf_entry	*sfe;
	int				offset, size;
	struct xfs_mount		*mp;
	struct xfs_inode		*dp;
	struct xfs_ifork		*ifp;

	trace_xfs_attr_sf_add(args);

	dp = args->dp;
	mp = dp->i_mount;
	dp->i_forkoff = forkoff;

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

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

	sfe->namelen = args->namelen;
@@ -811,20 +806,16 @@ int
xfs_attr_sf_removename(
	struct xfs_da_args		*args)
{
	struct xfs_attr_shortform	*sf;
	struct xfs_inode		*dp = args->dp;
	struct xfs_mount		*mp = dp->i_mount;
	struct xfs_attr_shortform	*sf = dp->i_af.if_data;
	struct xfs_attr_sf_entry	*sfe;
	int				size = 0, end, totsize;
	unsigned int			base;
	struct xfs_mount		*mp;
	struct xfs_inode		*dp;
	int				error;

	trace_xfs_attr_sf_remove(args);

	dp = args->dp;
	mp = dp->i_mount;
	sf = (struct xfs_attr_shortform *)dp->i_af.if_u1.if_data;

	error = xfs_attr_sf_findname(args, &sfe, &base);

	/*
@@ -878,18 +869,17 @@ xfs_attr_sf_removename(
 */
/*ARGSUSED*/
int
xfs_attr_shortform_lookup(xfs_da_args_t *args)
xfs_attr_shortform_lookup(
	struct xfs_da_args		*args)
{
	struct xfs_attr_shortform *sf;
	struct xfs_ifork		*ifp = &args->dp->i_af;
	struct xfs_attr_shortform	*sf = ifp->if_data;
	struct xfs_attr_sf_entry	*sfe;
	int				i;
	struct xfs_ifork *ifp;

	trace_xfs_attr_sf_lookup(args);

	ifp = &args->dp->i_af;
	ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
	sf = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
	sfe = &sf->list[0];
	for (i = 0; i < sf->hdr.count;
				sfe = xfs_attr_sf_nextentry(sfe), i++) {
@@ -911,12 +901,11 @@ int
xfs_attr_shortform_getvalue(
	struct xfs_da_args		*args)
{
	struct xfs_attr_shortform *sf;
	struct xfs_attr_shortform	*sf = args->dp->i_af.if_data;
	struct xfs_attr_sf_entry	*sfe;
	int				i;

	ASSERT(args->dp->i_af.if_format == XFS_DINODE_FMT_LOCAL);
	sf = (struct xfs_attr_shortform *)args->dp->i_af.if_u1.if_data;
	sfe = &sf->list[0];
	for (i = 0; i < sf->hdr.count;
				sfe = xfs_attr_sf_nextentry(sfe), i++) {
@@ -933,25 +922,22 @@ int
xfs_attr_shortform_to_leaf(
	struct xfs_da_args		*args)
{
	struct xfs_inode		*dp;
	struct xfs_attr_shortform	*sf;
	struct xfs_inode		*dp = args->dp;
	struct xfs_ifork		*ifp = &dp->i_af;
	struct xfs_attr_shortform	*sf = ifp->if_data;
	struct xfs_attr_sf_entry	*sfe;
	struct xfs_da_args		nargs;
	char				*tmpbuffer;
	int				error, i, size;
	xfs_dablk_t			blkno;
	struct xfs_buf			*bp;
	struct xfs_ifork		*ifp;

	trace_xfs_attr_sf_to_leaf(args);

	dp = args->dp;
	ifp = &dp->i_af;
	sf = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
	size = be16_to_cpu(sf->hdr.totsize);
	tmpbuffer = kmem_alloc(size, 0);
	ASSERT(tmpbuffer != NULL);
	memcpy(tmpbuffer, ifp->if_u1.if_data, size);
	memcpy(tmpbuffer, ifp->if_data, size);
	sf = (struct xfs_attr_shortform *)tmpbuffer;

	xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
+2 −2
Original line number Diff line number Diff line
@@ -747,7 +747,7 @@ xfs_bmap_local_to_extents_empty(
	ASSERT(ifp->if_nextents == 0);

	xfs_bmap_forkoff_reset(ip, whichfork);
	ifp->if_u1.if_root = NULL;
	ifp->if_data = NULL;
	ifp->if_height = 0;
	ifp->if_format = XFS_DINODE_FMT_EXTENTS;
	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
@@ -832,7 +832,7 @@ xfs_bmap_local_to_extents(
	xfs_bmap_local_to_extents_empty(tp, ip, whichfork);
	flags |= XFS_ILOG_CORE;

	ifp->if_u1.if_root = NULL;
	ifp->if_data = NULL;
	ifp->if_height = 0;

	rec.br_startoff = 0;
+1 −1
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ xfs_dir_isempty(
		return 1;
	if (dp->i_disk_size > xfs_inode_data_fork_size(dp))
		return 0;
	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
	sfp = dp->i_df.if_data;
	return !sfp->count;
}

+2 −4
Original line number Diff line number Diff line
@@ -1089,7 +1089,7 @@ xfs_dir2_sf_to_block(
	int			newoffset;	/* offset from current entry */
	unsigned int		offset = geo->data_entry_offset;
	xfs_dir2_sf_entry_t	*sfep;		/* sf entry pointer */
	xfs_dir2_sf_hdr_t	*oldsfp;	/* old shortform header  */
	struct xfs_dir2_sf_hdr	*oldsfp = ifp->if_data;
	xfs_dir2_sf_hdr_t	*sfp;		/* shortform header  */
	__be16			*tagp;		/* end of data entry */
	struct xfs_name		name;
@@ -1099,10 +1099,8 @@ xfs_dir2_sf_to_block(
	ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
	ASSERT(dp->i_disk_size >= offsetof(struct xfs_dir2_sf_hdr, parent));

	oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data;

	ASSERT(ifp->if_bytes == dp->i_disk_size);
	ASSERT(ifp->if_u1.if_data != NULL);
	ASSERT(oldsfp != NULL);
	ASSERT(dp->i_disk_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
	ASSERT(dp->i_df.if_nextents == 0);

Loading