logflags |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); 
sbfields |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); 
xfs_bmap_add_attrfork(	xfs_inode_t		*ip,		/* incore inode pointer */	int			size,		/* space new attribute needs */	int			rsvd)		/* xact may use reserved blks */{	xfs_fsblock_t		firstblock;	/* 1st block/ag allocated */	xfs_bmap_free_t		flist;		/* freed extent list */	xfs_mount_t		*mp;		/* mount structure */	xfs_trans_t		*tp;		/* transaction pointer */	unsigned long		s;		/* spinlock spl value */	int			blks;		/* space reservation */	int			version = 1;	/* superblock attr version */	int			committed;	/* xaction was committed */	int			logflags;	/* logging flags */	int			error;		/* error return value */	ASSERT(XFS_IFORK_Q(ip) == 0);	ASSERT(ip->i_df.if_ext_max ==	       XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));	mp = ip->i_mount;	ASSERT(!XFS_NOT_DQATTACHED(mp, ip));	tp = xfs_trans_alloc(mp, XFS_TRANS_ADDAFORK);	blks = XFS_ADDAFORK_SPACE_RES(mp);	if (rsvd)		tp->t_flags |= XFS_TRANS_RESERVE;	if ((error = xfs_trans_reserve(tp, blks, XFS_ADDAFORK_LOG_RES(mp), 0,			XFS_TRANS_PERM_LOG_RES, XFS_ADDAFORK_LOG_COUNT)))		goto error0;	xfs_ilock(ip, XFS_ILOCK_EXCL);	error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, blks, 0, rsvd ?			XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES :			XFS_QMOPT_RES_REGBLKS);	if (error) {		xfs_iunlock(ip, XFS_ILOCK_EXCL);		xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES);		return error;	}	if (XFS_IFORK_Q(ip))		goto error1;	if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS) {		/*		 * For inodes coming from pre-6.2 filesystems.		 */		ASSERT(ip->i_d.di_aformat == 0);		ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;	}	ASSERT(ip->i_d.di_anextents == 0);	VN_HOLD(XFS_ITOV(ip));	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	switch (ip->i_d.di_format) {	case XFS_DINODE_FMT_DEV:		ip->i_d.di_forkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;		break;	case XFS_DINODE_FMT_UUID:		ip->i_d.di_forkoff = roundup(sizeof(uuid_t), 8) >> 3;		break;	case XFS_DINODE_FMT_LOCAL:	case XFS_DINODE_FMT_EXTENTS:	case XFS_DINODE_FMT_BTREE:		ip->i_d.di_forkoff = xfs_attr_shortform_bytesfit(ip, size);		if (!ip->i_d.di_forkoff)			ip->i_d.di_forkoff = mp->m_attroffset >> 3;		else if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR))			version = 2;		break;	default:		ASSERT(0);		error = XFS_ERROR(EINVAL);		goto error1;	}	ip->i_df.if_ext_max =		XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);	ASSERT(ip->i_afp == NULL);	ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP);	ip->i_afp->if_ext_max =		XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);	ip->i_afp->if_flags = XFS_IFEXTENTS;	logflags = 0;	XFS_BMAP_INIT(&flist, &firstblock);	switch (ip->i_d.di_format) {	case XFS_DINODE_FMT_LOCAL:		error = xfs_bmap_add_attrfork_local(tp, ip, &firstblock, &flist,			&logflags);		break;	case XFS_DINODE_FMT_EXTENTS:		error = xfs_bmap_add_attrfork_extents(tp, ip, &firstblock,			&flist, &logflags);		break;	case XFS_DINODE_FMT_BTREE:		error = xfs_bmap_add_attrfork_btree(tp, ip, &firstblock, &flist,			&logflags);		break;	default:		error = 0;		break;	}	if (logflags)		xfs_trans_log_inode(tp, ip, logflags);	if (error)		goto error2;	if (!XFS_SB_VERSION_HASATTR(&mp->m_sb) ||	   (!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2)) {		logflags = 0;		s = XFS_SB_LOCK(mp);		if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) {			XFS_SB_VERSION_ADDATTR(&mp->m_sb);			logflags |= XFS_SB_VERSIONNUM;		}		if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2) {			XFS_SB_VERSION_ADDATTR2(&mp->m_sb);			logflags |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2);		}		if (logflags) {			XFS_SB_UNLOCK(mp, s);			xfs_mod_sb(tp, logflags);		} else			XFS_SB_UNLOCK(mp, s);	}	if ((error = xfs_bmap_finish(&tp, &flist, firstblock, &committed)))		goto error2;	error = xfs_trans_commit(tp, XFS_TRANS_PERM_LOG_RES, NULL);	ASSERT(ip->i_df.if_ext_max ==	       XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));	return error;error2:	xfs_bmap_cancel(&flist);error1:	ASSERT(ismrlocked(&ip->i_lock,MR_UPDATE));	xfs_iunlock(ip, XFS_ILOCK_EXCL);error0:	xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);	ASSERT(ip->i_df.if_ext_max ==	       XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));	return error;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/da087bad810b48dd889a504e6af0a582ba18df0d/xfs_bmap.c/buggy/fs/xfs/xfs_bmap.c