nlink_t		nlink, 
xfs_nlink_t	nlink, 
xfs_ialloc(	xfs_trans_t	*tp,	xfs_inode_t	*pip,	mode_t		mode,	nlink_t		nlink,	xfs_dev_t	rdev,	cred_t		*cr,	xfs_prid_t	prid,	int		okalloc,	xfs_buf_t	**ialloc_context,	boolean_t	*call_again,	xfs_inode_t	**ipp){	xfs_ino_t	ino;	xfs_inode_t	*ip;	vnode_t		*vp;	uint		flags;	int		error;	/*	 * Call the space management code to pick	 * the on-disk inode to be allocated.	 */	error = xfs_dialloc(tp, pip->i_ino, mode, okalloc,			    ialloc_context, call_again, &ino);	if (error != 0) {		return error;	}	if (*call_again || ino == NULLFSINO) {		*ipp = NULL;		return 0;	}	ASSERT(*ialloc_context == NULL);	/*	 * Get the in-core inode with the lock held exclusively.	 * This is because we're setting fields here we need	 * to prevent others from looking at until we're done.	 */	error = xfs_trans_iget(tp->t_mountp, tp, ino,			IGET_CREATE, XFS_ILOCK_EXCL, &ip);	if (error != 0) {		return error;	}	ASSERT(ip != NULL);	vp = XFS_ITOV(ip);	vp->v_type = IFTOVT(mode);	ip->i_d.di_mode = (__uint16_t)mode;	ip->i_d.di_onlink = 0;	ip->i_d.di_nlink = nlink;	ASSERT(ip->i_d.di_nlink == nlink);	ip->i_d.di_uid = current_fsuid(cr);	ip->i_d.di_gid = current_fsgid(cr);	ip->i_d.di_projid = prid;	memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));	/*	 * If the superblock version is up to where we support new format	 * inodes and this is currently an old format inode, then change	 * the inode version number now.  This way we only do the conversion	 * here rather than here and in the flush/logging code.	 */	if (XFS_SB_VERSION_HASNLINK(&tp->t_mountp->m_sb) &&	    ip->i_d.di_version == XFS_DINODE_VERSION_1) {		ip->i_d.di_version = XFS_DINODE_VERSION_2;		/*		 * We've already zeroed the old link count, the projid field,		 * and the pad field.		 */	}	/*	 * Project ids won't be stored on disk if we are using a version 1 inode.	 */	if ( (prid != 0) && (ip->i_d.di_version == XFS_DINODE_VERSION_1))		xfs_bump_ino_vers2(tp, ip);	if (XFS_INHERIT_GID(pip, vp->v_vfsp)) {		ip->i_d.di_gid = pip->i_d.di_gid;		if ((pip->i_d.di_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR) {			ip->i_d.di_mode |= S_ISGID;		}	}	/*	 * If the group ID of the new file does not match the effective group	 * ID or one of the supplementary group IDs, the S_ISGID bit is cleared	 * (and only if the irix_sgid_inherit compatibility variable is set).	 */	if ((irix_sgid_inherit) &&	    (ip->i_d.di_mode & S_ISGID) &&	    (!in_group_p((gid_t)ip->i_d.di_gid))) {		ip->i_d.di_mode &= ~S_ISGID;	}	ip->i_d.di_size = 0;	ip->i_d.di_nextents = 0;	ASSERT(ip->i_d.di_nblocks == 0);	xfs_ichgtime(ip, XFS_ICHGTIME_CHG|XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD);	/*	 * di_gen will have been taken care of in xfs_iread.	 */	ip->i_d.di_extsize = 0;	ip->i_d.di_dmevmask = 0;	ip->i_d.di_dmstate = 0;	ip->i_d.di_flags = 0;	flags = XFS_ILOG_CORE;	switch (mode & S_IFMT) {	case S_IFIFO:	case S_IFCHR:	case S_IFBLK:	case S_IFSOCK:		ip->i_d.di_format = XFS_DINODE_FMT_DEV;		ip->i_df.if_u2.if_rdev = rdev;		ip->i_df.if_flags = 0;		flags |= XFS_ILOG_DEV;		break;	case S_IFREG:	case S_IFDIR:		if (unlikely(pip->i_d.di_flags & XFS_DIFLAG_ANY)) {			if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) {				if ((mode & S_IFMT) == S_IFDIR) {					ip->i_d.di_flags |= XFS_DIFLAG_RTINHERIT;				} else {					ip->i_d.di_flags |= XFS_DIFLAG_REALTIME;					ip->i_iocore.io_flags |= XFS_IOCORE_RT;				}			}			if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) &&			    xfs_inherit_noatime)				ip->i_d.di_flags |= XFS_DIFLAG_NOATIME;			if ((pip->i_d.di_flags & XFS_DIFLAG_NODUMP) &&			    xfs_inherit_nodump)				ip->i_d.di_flags |= XFS_DIFLAG_NODUMP;			if ((pip->i_d.di_flags & XFS_DIFLAG_SYNC) &&			    xfs_inherit_sync)				ip->i_d.di_flags |= XFS_DIFLAG_SYNC;			if ((pip->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) &&			    xfs_inherit_nosymlinks)				ip->i_d.di_flags |= XFS_DIFLAG_NOSYMLINKS;		}		/* FALLTHROUGH */	case S_IFLNK:		ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;		ip->i_df.if_flags = XFS_IFEXTENTS;		ip->i_df.if_bytes = ip->i_df.if_real_bytes = 0;		ip->i_df.if_u1.if_extents = NULL;		break;	default:		ASSERT(0);	}	/*	 * Attribute fork settings for new inode.	 */	ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;	ip->i_d.di_anextents = 0;	/*	 * Log the new values stuffed into the inode.	 */	xfs_trans_log_inode(tp, ip, flags);	/* now that we have a v_type we can set Linux inode ops (& unlock) */	VFS_INIT_VNODE(XFS_MTOVFS(tp->t_mountp), vp, XFS_ITOBHV(ip), 1);	*ipp = ip;	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/31b084aef3f088962f56c100b31bb8479c5dd769/xfs_inode.c/clean/fs/xfs/xfs_inode.c