您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xfs_trans_log_inode函数代码示例

51自学网 2021-06-03 10:20:51
  C++
这篇教程C++ xfs_trans_log_inode函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xfs_trans_log_inode函数的典型用法代码示例。如果您正苦于以下问题:C++ xfs_trans_log_inode函数的具体用法?C++ xfs_trans_log_inode怎么用?C++ xfs_trans_log_inode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xfs_trans_log_inode函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: xfs_reflink_set_inode_flag

/* * Ensure the reflink bit is set in both inodes. */STATIC intxfs_reflink_set_inode_flag(	struct xfs_inode	*src,	struct xfs_inode	*dest){	struct xfs_mount	*mp = src->i_mount;	int			error;	struct xfs_trans	*tp;	if (xfs_is_reflink_inode(src) && xfs_is_reflink_inode(dest))		return 0;	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp);	if (error)		goto out_error;	/* Lock both files against IO */	if (src->i_ino == dest->i_ino)		xfs_ilock(src, XFS_ILOCK_EXCL);	else		xfs_lock_two_inodes(src, dest, XFS_ILOCK_EXCL);	if (!xfs_is_reflink_inode(src)) {		trace_xfs_reflink_set_inode_flag(src);		xfs_trans_ijoin(tp, src, XFS_ILOCK_EXCL);		src->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;		xfs_trans_log_inode(tp, src, XFS_ILOG_CORE);		xfs_ifork_init_cow(src);	} else		xfs_iunlock(src, XFS_ILOCK_EXCL);	if (src->i_ino == dest->i_ino)		goto commit_flags;	if (!xfs_is_reflink_inode(dest)) {		trace_xfs_reflink_set_inode_flag(dest);		xfs_trans_ijoin(tp, dest, XFS_ILOCK_EXCL);		dest->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK;		xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);		xfs_ifork_init_cow(dest);	} else		xfs_iunlock(dest, XFS_ILOCK_EXCL);commit_flags:	error = xfs_trans_commit(tp);	if (error)		goto out_error;	return error;out_error:	trace_xfs_reflink_set_inode_flag_error(dest, error, _RET_IP_);	return error;}
开发者ID:oscardagrach,项目名称:linux,代码行数:56,


示例2: xfs_dir2_sf_create

int					/*                 */xfs_dir2_sf_create(	xfs_da_args_t	*args,		/*                     */	xfs_ino_t	pino)		/*                     */{	xfs_inode_t	*dp;		/*                        */	int		i8count;	/*                                  */	xfs_dir2_sf_hdr_t *sfp;		/*                     */	int		size;		/*                */	trace_xfs_dir2_sf_create(args);	dp = args->dp;	ASSERT(dp != NULL);	ASSERT(dp->i_d.di_size == 0);	/*                                                                                 */	if (dp->i_d.di_format == XFS_DINODE_FMT_EXTENTS) {		dp->i_df.if_flags &= ~XFS_IFEXTENTS;	/*              */		dp->i_d.di_format = XFS_DINODE_FMT_LOCAL;		xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);		dp->i_df.if_flags |= XFS_IFINLINE;	}	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);	ASSERT(dp->i_df.if_bytes == 0);	i8count = pino > XFS_DIR2_MAX_SHORT_INUM;	size = xfs_dir2_sf_hdr_size(i8count);	/*                                 */	xfs_idata_realloc(dp, size, XFS_DATA_FORK);	/*                         */	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;	sfp->i8count = i8count;	/*                                                            */	xfs_dir2_sf_put_parent_ino(sfp, pino);	sfp->count = 0;	dp->i_d.di_size = size;	xfs_dir2_sf_check(args);	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);	return 0;}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:49,


示例3: xfs_dir2_sf_create

/* * Create a new (shortform) directory. */int					/* error, always 0 */xfs_dir2_sf_create(	xfs_da_args_t	*args,		/* operation arguments */	xfs_ino_t	pino)		/* parent inode number */{	xfs_inode_t	*dp;		/* incore directory inode */	int		i8count;	/* parent inode is an 8-byte number */	xfs_dir2_sf_hdr_t *sfp;		/* shortform structure */	int		size;		/* directory size */	trace_xfs_dir2_sf_create(args);	dp = args->dp;	ASSERT(dp != NULL);	ASSERT(dp->i_d.di_size == 0);	/*	 * If it's currently a zero-length extent file,	 * convert it to local format.	 */	if (dp->i_d.di_format == XFS_DINODE_FMT_EXTENTS) {		dp->i_df.if_flags &= ~XFS_IFEXTENTS;	/* just in case */		dp->i_d.di_format = XFS_DINODE_FMT_LOCAL;		xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);		dp->i_df.if_flags |= XFS_IFINLINE;	}	ASSERT(dp->i_df.if_flags & XFS_IFINLINE);	ASSERT(dp->i_df.if_bytes == 0);	i8count = pino > XFS_DIR2_MAX_SHORT_INUM;	size = xfs_dir2_sf_hdr_size(i8count);	/*	 * Make a buffer for the data.	 */	xfs_idata_realloc(dp, size, XFS_DATA_FORK);	/*	 * Fill in the header,	 */	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;	sfp->i8count = i8count;	/*	 * Now can put in the inode number, since i8count is set.	 */	xfs_dir2_sf_put_parent_ino(sfp, pino);	sfp->count = 0;	dp->i_d.di_size = size;	xfs_dir2_sf_check(args);	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);	return 0;}
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:52,


示例4: xfs_commit_dummy_trans

STATIC intxfs_commit_dummy_trans(	struct xfs_mount	*mp,	uint			flags){	struct xfs_inode	*ip = mp->m_rootip;	struct xfs_trans	*tp;	int			error;	/*	 * Put a dummy transaction in the log to tell recovery	 * that all others are OK.	 */	tp = xfs_trans_alloc(mp, XFS_TRANS_DUMMY1);	error = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);	if (error) {		xfs_trans_cancel(tp, 0);		return error;	}	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_ihold(tp, ip);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	error = xfs_trans_commit(tp, 0);	xfs_iunlock(ip, XFS_ILOCK_EXCL);	/* the log force ensures this transaction is pushed to disk */	xfs_log_force(mp, (flags & SYNC_WAIT) ? XFS_LOG_SYNC : 0);	return error;}
开发者ID:KaZoom,项目名称:buildroot-linux-kernel-m3,代码行数:32,


示例5: xfs_setfilesize

/* * Update on-disk file size now that data has been written to disk. */STATIC intxfs_setfilesize(	struct xfs_ioend	*ioend){	struct xfs_inode	*ip = XFS_I(ioend->io_inode);	struct xfs_trans	*tp = ioend->io_append_trans;	xfs_fsize_t		isize;	/*	 * The transaction was allocated in the I/O submission thread,	 * thus we need to mark ourselves as beeing in a transaction	 * manually.	 */	current_set_flags_nested(&tp->t_pflags, PF_FSTRANS);	xfs_ilock(ip, XFS_ILOCK_EXCL);	isize = xfs_new_eof(ip, ioend->io_offset + ioend->io_size);	if (!isize) {		xfs_iunlock(ip, XFS_ILOCK_EXCL);		xfs_trans_cancel(tp, 0);		return 0;	}	trace_xfs_setfilesize(ip, ioend->io_offset, ioend->io_size);	ip->i_d.di_size = isize;	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	return xfs_trans_commit(tp, 0);}
开发者ID:404992361,项目名称:mi1_kernel,代码行数:34,


示例6: xfs_log_dirty_inode

intxfs_log_dirty_inode(	struct xfs_inode	*ip,	struct xfs_perag	*pag,	int			flags){	struct xfs_mount	*mp = ip->i_mount;	struct xfs_trans	*tp;	int			error;	if (!ip->i_update_core)		return 0;	tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);	error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0);	if (error) {		xfs_trans_cancel(tp, 0);		return error;	}	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	return xfs_trans_commit(tp, 0);}
开发者ID:1yankeedt,项目名称:D710BST_FL24_Kernel,代码行数:25,


示例7: xfs_vn_update_time

STATIC intxfs_vn_update_time(	struct inode		*inode,	struct timespec		*now,	int			flags){	struct xfs_inode	*ip = XFS_I(inode);	struct xfs_mount	*mp = ip->i_mount;	struct xfs_trans	*tp;	int			error;	trace_xfs_update_time(ip);	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);	if (error)		return error;	xfs_ilock(ip, XFS_ILOCK_EXCL);	if (flags & S_CTIME)		inode->i_ctime = *now;	if (flags & S_MTIME)		inode->i_mtime = *now;	if (flags & S_ATIME)		inode->i_atime = *now;	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);	return xfs_trans_commit(tp);}
开发者ID:gxt,项目名称:linux,代码行数:29,


示例8: xfs_bumplink

/* * Increment the link count on an inode & log the change. */intxfs_bumplink(	xfs_trans_t *tp,	xfs_inode_t *ip){	if (ip->i_d.di_nlink >= XFS_MAXLINK)		return XFS_ERROR(EMLINK);	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);	ASSERT(ip->i_d.di_nlink > 0);	ip->i_d.di_nlink++;	inc_nlink(VFS_I(ip));	if ((ip->i_d.di_version == 1) &&	    (ip->i_d.di_nlink > XFS_MAXLINK_1)) {		/*		 * The inode has increased its number of links beyond		 * what can fit in an old format inode.  It now needs		 * to be converted to a version 2 inode with a 32 bit		 * link count.  If this is the first inode in the file		 * system to do this, then we need to bump the superblock		 * version number as well.		 */		xfs_bump_ino_vers2(tp, ip);	}	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	return 0;}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:31,


示例9: xfs_reflink_clear_inode_flag

/* Clear the inode reflink flag if there are no shared extents. */intxfs_reflink_clear_inode_flag(	struct xfs_inode	*ip,	struct xfs_trans	**tpp){	bool			needs_flag;	int			error = 0;	ASSERT(xfs_is_reflink_inode(ip));	error = xfs_reflink_inode_has_shared_extents(*tpp, ip, &needs_flag);	if (error || needs_flag)		return error;	/*	 * We didn't find any shared blocks so turn off the reflink flag.	 * First, get rid of any leftover CoW mappings.	 */	error = xfs_reflink_cancel_cow_blocks(ip, tpp, 0, NULLFILEOFF, true);	if (error)		return error;	/* Clear the inode flag. */	trace_xfs_reflink_unset_inode_flag(ip);	ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;	xfs_inode_clear_cowblocks_tag(ip);	xfs_trans_ijoin(*tpp, ip, 0);	xfs_trans_log_inode(*tpp, ip, XFS_ILOG_CORE);	return error;}
开发者ID:oscardagrach,项目名称:linux,代码行数:32,


示例10: xfs_setfilesize

/* * Update on-disk file size now that data has been written to disk. */STATIC intxfs_setfilesize(	struct xfs_inode	*ip,	struct xfs_trans	*tp,	xfs_off_t		offset,	size_t			size){	xfs_fsize_t		isize;	xfs_ilock(ip, XFS_ILOCK_EXCL);	isize = xfs_new_eof(ip, offset + size);	if (!isize) {		xfs_iunlock(ip, XFS_ILOCK_EXCL);		xfs_trans_cancel(tp);		return 0;	}	trace_xfs_setfilesize(ip, offset, size);	ip->i_d.di_size = isize;	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	return xfs_trans_commit(tp);}
开发者ID:020gzh,项目名称:linux,代码行数:28,


示例11: xfs_setfilesize

/* * Update on-disk file size now that data has been written to disk. */STATIC intxfs_setfilesize(	struct xfs_ioend	*ioend){	struct xfs_inode	*ip = XFS_I(ioend->io_inode);	struct xfs_trans	*tp = ioend->io_append_trans;	xfs_fsize_t		isize;	/*	 * The transaction may have been allocated in the I/O submission thread,	 * thus we need to mark ourselves as beeing in a transaction manually.	 * Similarly for freeze protection.	 */	current_set_flags_nested(&tp->t_pflags, PF_FSTRANS);	rwsem_acquire_read(&VFS_I(ip)->i_sb->s_writers.lock_map[SB_FREEZE_FS-1],			   0, 1, _THIS_IP_);	xfs_ilock(ip, XFS_ILOCK_EXCL);	isize = xfs_new_eof(ip, ioend->io_offset + ioend->io_size);	if (!isize) {		xfs_iunlock(ip, XFS_ILOCK_EXCL);		xfs_trans_cancel(tp, 0);		return 0;	}	trace_xfs_setfilesize(ip, ioend->io_offset, ioend->io_size);	ip->i_d.di_size = isize;	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	return xfs_trans_commit(tp, 0);}
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:36,


示例12: xfs_commit_dummy_trans

STATIC intxfs_commit_dummy_trans(	struct xfs_mount	*mp,	uint			log_flags){	struct xfs_inode	*ip = mp->m_rootip;	struct xfs_trans	*tp;	int			error;	/*	 * Put a dummy transaction in the log to tell recovery	 * that all others are OK.	 */	tp = xfs_trans_alloc(mp, XFS_TRANS_DUMMY1);	error = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);	if (error) {		xfs_trans_cancel(tp, 0);		return error;	}	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_ihold(tp, ip);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	/* XXX(hch): ignoring the error here.. */	error = xfs_trans_commit(tp, 0);	xfs_iunlock(ip, XFS_ILOCK_EXCL);	xfs_log_force(mp, 0, log_flags);	return 0;}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:33,


示例13: xfs_setfilesize

/* * Update on-disk file size now that data has been written to disk. */STATIC intxfs_setfilesize(	struct xfs_ioend	*ioend){	struct xfs_inode	*ip = XFS_I(ioend->io_inode);	struct xfs_trans	*tp = ioend->io_append_trans;	xfs_fsize_t		isize;	current_set_flags_nested(&tp->t_pflags, PF_FSTRANS);	xfs_ilock(ip, XFS_ILOCK_EXCL);	isize = xfs_new_eof(ip, ioend->io_offset + ioend->io_size);	if (!isize) {		xfs_iunlock(ip, XFS_ILOCK_EXCL);		xfs_trans_cancel(tp, 0);		return 0;	}	trace_xfs_setfilesize(ip, ioend->io_offset, ioend->io_size);	ip->i_d.di_size = isize;	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	return xfs_trans_commit(tp, 0);}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:29,


示例14: xfs_update_prealloc_flags

intxfs_update_prealloc_flags(	struct xfs_inode	*ip,	enum xfs_prealloc_flags	flags){	struct xfs_trans	*tp;	int			error;	error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_writeid,			0, 0, 0, &tp);	if (error)		return error;	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	if (!(flags & XFS_PREALLOC_INVISIBLE)) {		VFS_I(ip)->i_mode &= ~S_ISUID;		if (VFS_I(ip)->i_mode & S_IXGRP)			VFS_I(ip)->i_mode &= ~S_ISGID;		xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);	}	if (flags & XFS_PREALLOC_SET)		ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC;	if (flags & XFS_PREALLOC_CLEAR)		ip->i_d.di_flags &= ~XFS_DIFLAG_PREALLOC;	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	if (flags & XFS_PREALLOC_SYNC)		xfs_trans_set_sync(tp);	return xfs_trans_commit(tp);}
开发者ID:oscardagrach,项目名称:linux,代码行数:33,


示例15: xfs_set_dmattrs

intxfs_set_dmattrs(	xfs_inode_t     *ip,	u_int		evmask,	u_int16_t	state){	xfs_mount_t	*mp = ip->i_mount;	xfs_trans_t	*tp;	int		error;	if (!capable(CAP_SYS_ADMIN))		return -EPERM;	if (XFS_FORCED_SHUTDOWN(mp))		return -EIO;	tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS);	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);	if (error) {		xfs_trans_cancel(tp, 0);		return error;	}	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	ip->i_d.di_dmevmask = evmask;	ip->i_d.di_dmstate  = state;	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	error = xfs_trans_commit(tp, 0);	return error;}
开发者ID:19Dan01,项目名称:linux,代码行数:33,


示例16: xfs_droplink

/* * Decrement the link count on an inode & log the change. * If this causes the link count to go to zero, initiate the * logging activity required to truncate a file. */int				/* error */xfs_droplink(	xfs_trans_t *tp,	xfs_inode_t *ip){	int	error;	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);	ASSERT (ip->i_d.di_nlink > 0);	ip->i_d.di_nlink--;	drop_nlink(VFS_I(ip));	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	error = 0;	if (ip->i_d.di_nlink == 0) {		/*		 * We're dropping the last link to this file.		 * Move the on-disk inode to the AGI unlinked list.		 * From xfs_inactive() we will pull the inode from		 * the list and free it.		 */		error = xfs_iunlink(tp, ip);	}	return error;}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:31,


示例17: libxfs_trans_roll

/* * Roll from one trans in the sequence of PERMANENT transactions to * the next: permanent transactions are only flushed out when * committed with XFS_TRANS_RELEASE_LOG_RES, but we still want as soon * as possible to let chunks of it go to the log. So we commit the * chunk we've been working on and get a new transaction to continue. */intlibxfs_trans_roll(	struct xfs_trans	**tpp,	struct xfs_inode	*dp){	struct xfs_mount	*mp;	struct xfs_trans	*trans;	struct xfs_trans_res	tres;	int			error;	/*	 * Ensure that the inode is always logged.	 */	trans = *tpp;	if (dp)		xfs_trans_log_inode(trans, dp, XFS_ILOG_CORE);	/*	 * Copy the critical parameters from one trans to the next.	 */	mp = trans->t_mountp;	tres.tr_logres = trans->t_log_res;	tres.tr_logcount = trans->t_log_count;	/*	 * Commit the current transaction.	 * If this commit failed, then it'd just unlock those items that	 * are marked to be released. That also means that a filesystem shutdown	 * is in progress. The caller takes the responsibility to cancel	 * the duplicate transaction that gets returned.	 */	error = xfs_trans_commit(trans);	if (error)		return error;	/*	 * Reserve space in the log for th next transaction.	 * This also pushes items in the "AIL", the list of logged items,	 * out to disk if they are taking up space at the tail of the log	 * that we want to use.  This requires that either nothing be locked	 * across this call, or that anything that is locked be logged in	 * the prior and the next transactions.	 */	tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;	error = libxfs_trans_alloc(mp, &tres, 0, 0, 0, tpp);	trans = *tpp;	/*	 *  Ensure that the inode is in the new transaction and locked.	 */	if (error)		return error;	if (dp)		xfs_trans_ijoin(trans, dp, 0);	return 0;}
开发者ID:djwong,项目名称:xfsprogs,代码行数:64,


示例18: xfs_qm_scall_trunc_qfile

STATIC intxfs_qm_scall_trunc_qfile(	struct xfs_mount	*mp,	xfs_ino_t		ino){	struct xfs_inode	*ip;	struct xfs_trans	*tp;	int			error;	if (ino == NULLFSINO)		return 0;	error = xfs_iget(mp, NULL, ino, 0, 0, &ip);	if (error)		return error;	xfs_ilock(ip, XFS_IOLOCK_EXCL);	tp = xfs_trans_alloc(mp, XFS_TRANS_TRUNCATE_FILE);	error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0,				  XFS_TRANS_PERM_LOG_RES,				  XFS_ITRUNCATE_LOG_COUNT);	if (error) {		xfs_trans_cancel(tp, 0);		xfs_iunlock(ip, XFS_IOLOCK_EXCL);		goto out_put;	}	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, 0);	ip->i_d.di_size = 0;	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);	if (error) {		xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES |				     XFS_TRANS_ABORT);		goto out_unlock;	}	ASSERT(ip->i_d.di_nextents == 0);	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);	error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);out_unlock:	xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);out_put:	IRELE(ip);	return error;}
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:52,


示例19: xfs_trans_roll_inode

intxfs_trans_roll_inode(	struct xfs_trans	**tpp,	struct xfs_inode	*ip){	int			error;	xfs_trans_log_inode(*tpp, ip, XFS_ILOG_CORE);	error = xfs_trans_roll(tpp);	if (!error)		xfs_trans_ijoin(*tpp, ip, 0);	return error;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:13,


示例20: xfs_reflink_update_dest

/* * Update destination inode size & cowextsize hint, if necessary. */STATIC intxfs_reflink_update_dest(	struct xfs_inode	*dest,	xfs_off_t		newlen,	xfs_extlen_t		cowextsize,	bool			is_dedupe){	struct xfs_mount	*mp = dest->i_mount;	struct xfs_trans	*tp;	int			error;	if (is_dedupe && newlen <= i_size_read(VFS_I(dest)) && cowextsize == 0)		return 0;	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp);	if (error)		goto out_error;	xfs_ilock(dest, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, dest, XFS_ILOCK_EXCL);	if (newlen > i_size_read(VFS_I(dest))) {		trace_xfs_reflink_update_inode_size(dest, newlen);		i_size_write(VFS_I(dest), newlen);		dest->i_d.di_size = newlen;	}	if (cowextsize) {		dest->i_d.di_cowextsize = cowextsize;		dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;	}	if (!is_dedupe) {		xfs_trans_ichgtime(tp, dest,				   XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);	}	xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);	error = xfs_trans_commit(tp);	if (error)		goto out_error;	return error;out_error:	trace_xfs_reflink_update_inode_size_error(dest, error, _RET_IP_);	return error;}
开发者ID:oscardagrach,项目名称:linux,代码行数:50,


示例21: xfs_ioctl_setattr_xflags

static intxfs_ioctl_setattr_xflags(	struct xfs_trans	*tp,	struct xfs_inode	*ip,	struct fsxattr		*fa){	struct xfs_mount	*mp = ip->i_mount;	/* Can't change realtime flag if any extents are allocated. */	if ((ip->i_d.di_nextents || ip->i_delayed_blks) &&	    XFS_IS_REALTIME_INODE(ip) != (fa->fsx_xflags & FS_XFLAG_REALTIME))		return -EINVAL;	/* If realtime flag is set then must have realtime device */	if (fa->fsx_xflags & FS_XFLAG_REALTIME) {		if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||		    (ip->i_d.di_extsize % mp->m_sb.sb_rextsize))			return -EINVAL;	}	/* Clear reflink if we are actually able to set the rt flag. */	if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip))		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;	/* Don't allow us to set DAX mode for a reflinked file for now. */	if ((fa->fsx_xflags & FS_XFLAG_DAX) && xfs_is_reflink_inode(ip))		return -EINVAL;	/*	 * Can't modify an immutable/append-only file unless	 * we have appropriate permission.	 */	if (((ip->i_d.di_flags & (XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND)) ||	     (fa->fsx_xflags & (FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND))) &&	    !capable(CAP_LINUX_IMMUTABLE))		return -EPERM;	xfs_set_diflags(ip, fa->fsx_xflags);	xfs_diflags_to_linux(ip);	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	XFS_STATS_INC(mp, xs_ig_attrchg);	return 0;}
开发者ID:asmalldev,项目名称:linux,代码行数:44,


示例22: xfs_dir2_grow_inode

/* * Add a block to the directory. * * This routine is for data and free blocks, not leaf/node blocks which are * handled by xfs_da_grow_inode. */intxfs_dir2_grow_inode(	struct xfs_da_args	*args,	int			space,	/* v2 dir's space XFS_DIR2_xxx_SPACE */	xfs_dir2_db_t		*dbp)	/* out: block number added */{	struct xfs_inode	*dp = args->dp;	struct xfs_mount	*mp = dp->i_mount;	xfs_fileoff_t		bno;	/* directory offset of new block */	int			count;	/* count of filesystem blocks */	int			error;	trace_xfs_dir2_grow_inode(args, space);	/*	 * Set lowest possible block in the space requested.	 */	bno = XFS_B_TO_FSBT(mp, space * XFS_DIR2_SPACE_SIZE);	count = args->geo->fsbcount;	error = xfs_da_grow_inode_int(args, &bno, count);	if (error)		return error;	*dbp = xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)bno);	/*	 * Update file's size if this is the data space and it grew.	 */	if (space == XFS_DIR2_DATA_SPACE) {		xfs_fsize_t	size;		/* directory file (data) size */		size = XFS_FSB_TO_B(mp, bno + count);		if (size > dp->i_d.di_size) {			dp->i_d.di_size = size;			xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);		}	}	return 0;}
开发者ID:3null,项目名称:linux,代码行数:46,


示例23: xfs_vn_update_time

STATIC intxfs_vn_update_time(	struct inode		*inode,	struct timespec		*now,	int			flags){	struct xfs_inode	*ip = XFS_I(inode);	struct xfs_mount	*mp = ip->i_mount;	struct xfs_trans	*tp;	int			error;	trace_xfs_update_time(ip);	tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0);	if (error) {		xfs_trans_cancel(tp, 0);		return -error;	}	xfs_ilock(ip, XFS_ILOCK_EXCL);	if (flags & S_CTIME) {		inode->i_ctime = *now;		ip->i_d.di_ctime.t_sec = (__int32_t)now->tv_sec;		ip->i_d.di_ctime.t_nsec = (__int32_t)now->tv_nsec;	}	if (flags & S_MTIME) {		inode->i_mtime = *now;		ip->i_d.di_mtime.t_sec = (__int32_t)now->tv_sec;		ip->i_d.di_mtime.t_nsec = (__int32_t)now->tv_nsec;	}	if (flags & S_ATIME) {		inode->i_atime = *now;		ip->i_d.di_atime.t_sec = (__int32_t)now->tv_sec;		ip->i_d.di_atime.t_nsec = (__int32_t)now->tv_nsec;	}	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);	return -xfs_trans_commit(tp, 0);}
开发者ID:luyanseu,项目名称:linux,代码行数:40,


示例24: xfs_write_clear_setuid

/* * This is a subroutine for xfs_write() and other writers (xfs_ioctl) * which clears the setuid and setgid bits when a file is written. */intxfs_write_clear_setuid(	xfs_inode_t	*ip){	xfs_mount_t	*mp;	xfs_trans_t	*tp;	int		error;	mp = ip->i_mount;	tp = xfs_trans_alloc(mp, XFS_TRANS_WRITEID);	if ((error = xfs_trans_reserve(tp, 0,				      XFS_WRITEID_LOG_RES(mp),				      0, 0, 0))) {		xfs_trans_cancel(tp, 0);		return error;	}	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);	xfs_trans_ihold(tp, ip);	ip->i_d.di_mode &= ~S_ISUID;	/*	 * Note that we don't have to worry about mandatory	 * file locking being disabled here because we only	 * clear the S_ISGID bit if the Group execute bit is	 * on, but if it was on then mandatory locking wouldn't	 * have been enabled.	 */	if (ip->i_d.di_mode & S_IXGRP) {		ip->i_d.di_mode &= ~S_ISGID;	}	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	xfs_trans_set_sync(tp);	error = xfs_trans_commit(tp, 0, NULL);	xfs_iunlock(ip, XFS_ILOCK_EXCL);	return 0;}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:41,


示例25: xfs_write_sync_logforce

/* * Handle logging requirements of various synchronous types of write. */intxfs_write_sync_logforce(	xfs_mount_t	*mp,	xfs_inode_t	*ip){	int		error = 0;	/*	 * If we're treating this as O_DSYNC and we have not updated the	 * size, force the log.	 */	if (!(mp->m_flags & XFS_MOUNT_OSYNCISOSYNC) &&	    !(ip->i_update_size)) {		xfs_inode_log_item_t	*iip = ip->i_itemp;		/*		 * If an allocation transaction occurred		 * without extending the size, then we have to force		 * the log up the proper point to ensure that the		 * allocation is permanent.  We can't count on		 * the fact that buffered writes lock out direct I/O		 * writes - the direct I/O write could have extended		 * the size nontransactionally, then finished before		 * we started.  xfs_write_file will think that the file		 * didn't grow but the update isn't safe unless the		 * size change is logged.		 *		 * Force the log if we've committed a transaction		 * against the inode or if someone else has and		 * the commit record hasn't gone to disk (e.g.		 * the inode is pinned).  This guarantees that		 * all changes affecting the inode are permanent		 * when we return.		 */		if (iip && iip->ili_last_lsn) {			xfs_log_force(mp, iip->ili_last_lsn,					XFS_LOG_FORCE | XFS_LOG_SYNC);		} else if (xfs_ipincount(ip) > 0) {			xfs_log_force(mp, (xfs_lsn_t)0,					XFS_LOG_FORCE | XFS_LOG_SYNC);		}	} else {		xfs_trans_t	*tp;		/*		 * O_SYNC or O_DSYNC _with_ a size update are handled		 * the same way.		 *		 * If the write was synchronous then we need to make		 * sure that the inode modification time is permanent.		 * We'll have updated the timestamp above, so here		 * we use a synchronous transaction to log the inode.		 * It's not fast, but it's necessary.		 *		 * If this a dsync write and the size got changed		 * non-transactionally, then we need to ensure that		 * the size change gets logged in a synchronous		 * transaction.		 */		tp = xfs_trans_alloc(mp, XFS_TRANS_WRITE_SYNC);		if ((error = xfs_trans_reserve(tp, 0,						XFS_SWRITE_LOG_RES(mp),						0, 0, 0))) {			/* Transaction reserve failed */			xfs_trans_cancel(tp, 0);		} else {			/* Transaction reserve successful */			xfs_ilock(ip, XFS_ILOCK_EXCL);			xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);			xfs_trans_ihold(tp, ip);			xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);			xfs_trans_set_sync(tp);			error = xfs_trans_commit(tp, 0, NULL);			xfs_iunlock(ip, XFS_ILOCK_EXCL);		}	}	return error;}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:83,


示例26: xfs_setattr_size

//.........这里部分代码省略.........			return error;	}	/*	 * Wait for all direct I/O to complete.	 */	inode_dio_wait(inode);	error = -block_truncate_page(inode->i_mapping, newsize, xfs_get_blocks);	if (error)		return error;	tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_SIZE);	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);	if (error)		goto out_trans_cancel;	truncate_setsize(inode, newsize);	commit_flags = XFS_TRANS_RELEASE_LOG_RES;	lock_flags |= XFS_ILOCK_EXCL;	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, 0);	/*	 * Only change the c/mtime if we are changing the size or we are	 * explicitly asked to change it.  This handles the semantic difference	 * between truncate() and ftruncate() as implemented in the VFS.	 *	 * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a	 * special case where we need to update the times despite not having	 * these flags set.  For all other operations the VFS set these flags	 * explicitly if it wants a timestamp update.	 */	if (newsize != oldsize &&	    !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) {		iattr->ia_ctime = iattr->ia_mtime =			current_fs_time(inode->i_sb);		iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME;	}	/*	 * The first thing we do is set the size to new_size permanently on	 * disk.  This way we don't have to worry about anyone ever being able	 * to look at the data being freed even in the face of a crash.	 * What we're getting around here is the case where we free a block, it	 * is allocated to another file, it is written to, and then we crash.	 * If the new data gets written to the file but the log buffers	 * containing the free and reallocation don't, then we'd end up with	 * garbage in the blocks being freed.  As long as we make the new size	 * permanent before actually freeing any blocks it doesn't matter if	 * they get written to.	 */	ip->i_d.di_size = newsize;	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	if (newsize <= oldsize) {		error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, newsize);		if (error)			goto out_trans_abort;		/*		 * Truncated "down", so we're removing references to old data		 * here - if we delay flushing for a long time, we expose		 * ourselves unduly to the notorious NULL files problem.  So,		 * we mark this inode and flush it when the file is closed,		 * and do not wait the usual (long) time for writeout.		 */		xfs_iflags_set(ip, XFS_ITRUNCATED);		/* A truncate down always removes post-EOF blocks. */		xfs_inode_clear_eofblocks_tag(ip);	}	if (iattr->ia_valid & ATTR_MODE)		xfs_setattr_mode(ip, iattr);	if (iattr->ia_valid & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME))		xfs_setattr_time(ip, iattr);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	XFS_STATS_INC(xs_ig_attrchg);	if (mp->m_flags & XFS_MOUNT_WSYNC)		xfs_trans_set_sync(tp);	error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);out_unlock:	if (lock_flags)		xfs_iunlock(ip, lock_flags);	return error;out_trans_abort:	commit_flags |= XFS_TRANS_ABORT;out_trans_cancel:	xfs_trans_cancel(tp, commit_flags);	goto out_unlock;}
开发者ID:luyanseu,项目名称:linux,代码行数:101,


示例27: xfs_setattr_nonsize

//.........这里部分代码省略.........						NULL, capable(CAP_FOWNER) ?						XFS_QMOPT_FORCE_RES : 0);			if (error)	/* out of quota */				goto out_trans_cancel;		}	}	xfs_trans_ijoin(tp, ip, 0);	/*	 * Change file ownership.  Must be the owner or privileged.	 */	if (mask & (ATTR_UID|ATTR_GID)) {		/*		 * CAP_FSETID overrides the following restrictions:		 *		 * The set-user-ID and set-group-ID bits of a file will be		 * cleared upon successful return from chown()		 */		if ((ip->i_d.di_mode & (S_ISUID|S_ISGID)) &&		    !capable(CAP_FSETID))			ip->i_d.di_mode &= ~(S_ISUID|S_ISGID);		/*		 * Change the ownerships and register quota modifications		 * in the transaction.		 */		if (!uid_eq(iuid, uid)) {			if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {				ASSERT(mask & ATTR_UID);				ASSERT(udqp);				olddquot1 = xfs_qm_vop_chown(tp, ip,							&ip->i_udquot, udqp);			}			ip->i_d.di_uid = xfs_kuid_to_uid(uid);			inode->i_uid = uid;		}		if (!gid_eq(igid, gid)) {			if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) {				ASSERT(xfs_sb_version_has_pquotino(&mp->m_sb) ||				       !XFS_IS_PQUOTA_ON(mp));				ASSERT(mask & ATTR_GID);				ASSERT(gdqp);				olddquot2 = xfs_qm_vop_chown(tp, ip,							&ip->i_gdquot, gdqp);			}			ip->i_d.di_gid = xfs_kgid_to_gid(gid);			inode->i_gid = gid;		}	}	if (mask & ATTR_MODE)		xfs_setattr_mode(ip, iattr);	if (mask & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME))		xfs_setattr_time(ip, iattr);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	XFS_STATS_INC(xs_ig_attrchg);	if (mp->m_flags & XFS_MOUNT_WSYNC)		xfs_trans_set_sync(tp);	error = xfs_trans_commit(tp, 0);	xfs_iunlock(ip, XFS_ILOCK_EXCL);	/*	 * Release any dquot(s) the inode had kept before chown.	 */	xfs_qm_dqrele(olddquot1);	xfs_qm_dqrele(olddquot2);	xfs_qm_dqrele(udqp);	xfs_qm_dqrele(gdqp);	if (error)		return XFS_ERROR(error);	/*	 * XXX(hch): Updating the ACL entries is not atomic vs the i_mode	 * 	     update.  We could avoid this with linked transactions	 * 	     and passing down the transaction pointer all the way	 *	     to attr_set.  No previous user of the generic	 * 	     Posix ACL code seems to care about this issue either.	 */	if ((mask & ATTR_MODE) && !(flags & XFS_ATTR_NOACL)) {		error = -posix_acl_chmod(inode, inode->i_mode);		if (error)			return XFS_ERROR(error);	}	return 0;out_trans_cancel:	xfs_trans_cancel(tp, 0);	xfs_iunlock(ip, XFS_ILOCK_EXCL);out_dqrele:	xfs_qm_dqrele(udqp);	xfs_qm_dqrele(gdqp);	return error;}
开发者ID:luyanseu,项目名称:linux,代码行数:101,


示例28: xfs_swap_extents

//.........这里部分代码省略.........	 */	ifp = &ip->i_df;	tifp = &tip->i_df;	*tempifp = *ifp;	/* struct copy */	*ifp = *tifp;		/* struct copy */	*tifp = *tempifp;	/* struct copy */	/*	 * Fix the on-disk inode values	 */	tmp = (__uint64_t)ip->i_d.di_nblocks;	ip->i_d.di_nblocks = tip->i_d.di_nblocks - taforkblks + aforkblks;	tip->i_d.di_nblocks = tmp + taforkblks - aforkblks;	tmp = (__uint64_t) ip->i_d.di_nextents;	ip->i_d.di_nextents = tip->i_d.di_nextents;	tip->i_d.di_nextents = tmp;	tmp = (__uint64_t) ip->i_d.di_format;	ip->i_d.di_format = tip->i_d.di_format;	tip->i_d.di_format = tmp;	/*	 * The extents in the source inode could still contain speculative	 * preallocation beyond EOF (e.g. the file is open but not modified	 * while defrag is in progress). In that case, we need to copy over the	 * number of delalloc blocks the data fork in the source inode is	 * tracking beyond EOF so that when the fork is truncated away when the	 * temporary inode is unlinked we don't underrun the i_delayed_blks	 * counter on that inode.	 */	ASSERT(tip->i_delayed_blks == 0);	tip->i_delayed_blks = ip->i_delayed_blks;	ip->i_delayed_blks = 0;	switch (ip->i_d.di_format) {	case XFS_DINODE_FMT_EXTENTS:		/* If the extents fit in the inode, fix the		 * pointer.  Otherwise it's already NULL or		 * pointing to the extent.		 */		if (ip->i_d.di_nextents <= XFS_INLINE_EXTS) {			ifp->if_u1.if_extents =				ifp->if_u2.if_inline_ext;		}		src_log_flags |= XFS_ILOG_DEXT;		break;	case XFS_DINODE_FMT_BTREE:		ASSERT(ip->i_d.di_version < 3 ||		       (src_log_flags & XFS_ILOG_DOWNER));		src_log_flags |= XFS_ILOG_DBROOT;		break;	}	switch (tip->i_d.di_format) {	case XFS_DINODE_FMT_EXTENTS:		/* If the extents fit in the inode, fix the		 * pointer.  Otherwise it's already NULL or		 * pointing to the extent.		 */		if (tip->i_d.di_nextents <= XFS_INLINE_EXTS) {			tifp->if_u1.if_extents =				tifp->if_u2.if_inline_ext;		}		target_log_flags |= XFS_ILOG_DEXT;		break;	case XFS_DINODE_FMT_BTREE:		target_log_flags |= XFS_ILOG_DBROOT;		ASSERT(tip->i_d.di_version < 3 ||		       (target_log_flags & XFS_ILOG_DOWNER));		break;	}	xfs_trans_log_inode(tp, ip,  src_log_flags);	xfs_trans_log_inode(tp, tip, target_log_flags);	/*	 * If this is a synchronous mount, make sure that the	 * transaction goes to disk before returning to the user.	 */	if (mp->m_flags & XFS_MOUNT_WSYNC)		xfs_trans_set_sync(tp);	error = xfs_trans_commit(tp, 0);	trace_xfs_swap_extent_after(ip, 0);	trace_xfs_swap_extent_after(tip, 1);out:	kmem_free(tempifp);	return error;out_unlock:	xfs_iunlock(ip,  XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);	xfs_iunlock(tip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);	goto out;out_trans_cancel:	xfs_trans_cancel(tp, 0);	goto out_unlock;}
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:101,


示例29: xfs_bmap_rtalloc

intxfs_bmap_rtalloc(	struct xfs_bmalloca	*ap)	/* bmap alloc argument struct */{	xfs_alloctype_t	atype = 0;	/* type for allocation routines */	int		error;		/* error return value */	xfs_mount_t	*mp;		/* mount point structure */	xfs_extlen_t	prod = 0;	/* product factor for allocators */	xfs_extlen_t	ralen = 0;	/* realtime allocation length */	xfs_extlen_t	align;		/* minimum allocation alignment */	xfs_rtblock_t	rtb;	mp = ap->ip->i_mount;	align = xfs_get_extsz_hint(ap->ip);	prod = align / mp->m_sb.sb_rextsize;	error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,					align, 1, ap->eof, 0,					ap->conv, &ap->offset, &ap->length);	if (error)		return error;	ASSERT(ap->length);	ASSERT(ap->length % mp->m_sb.sb_rextsize == 0);	/*	 * If the offset & length are not perfectly aligned	 * then kill prod, it will just get us in trouble.	 */	if (do_mod(ap->offset, align) || ap->length % align)		prod = 1;	/*	 * Set ralen to be the actual requested length in rtextents.	 */	ralen = ap->length / mp->m_sb.sb_rextsize;	/*	 * If the old value was close enough to MAXEXTLEN that	 * we rounded up to it, cut it back so it's valid again.	 * Note that if it's a really large request (bigger than	 * MAXEXTLEN), we don't hear about that number, and can't	 * adjust the starting point to match it.	 */	if (ralen * mp->m_sb.sb_rextsize >= MAXEXTLEN)		ralen = MAXEXTLEN / mp->m_sb.sb_rextsize;	/*	 * Lock out other modifications to the RT bitmap inode.	 */	xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(ap->tp, mp->m_rbmip, XFS_ILOCK_EXCL);	/*	 * If it's an allocation to an empty file at offset 0,	 * pick an extent that will space things out in the rt area.	 */	if (ap->eof && ap->offset == 0) {		xfs_rtblock_t uninitialized_var(rtx); /* realtime extent no */		error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx);		if (error)			return error;		ap->blkno = rtx * mp->m_sb.sb_rextsize;	} else {		ap->blkno = 0;	}	xfs_bmap_adjacent(ap);	/*	 * Realtime allocation, done through xfs_rtallocate_extent.	 */	atype = ap->blkno == 0 ?  XFS_ALLOCTYPE_ANY_AG : XFS_ALLOCTYPE_NEAR_BNO;	do_div(ap->blkno, mp->m_sb.sb_rextsize);	rtb = ap->blkno;	ap->length = ralen;	if ((error = xfs_rtallocate_extent(ap->tp, ap->blkno, 1, ap->length,				&ralen, atype, ap->wasdel, prod, &rtb)))		return error;	if (rtb == NULLFSBLOCK && prod > 1 &&	    (error = xfs_rtallocate_extent(ap->tp, ap->blkno, 1,					   ap->length, &ralen, atype,					   ap->wasdel, 1, &rtb)))		return error;	ap->blkno = rtb;	if (ap->blkno != NULLFSBLOCK) {		ap->blkno *= mp->m_sb.sb_rextsize;		ralen *= mp->m_sb.sb_rextsize;		ap->length = ralen;		ap->ip->i_d.di_nblocks += ralen;		xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);		if (ap->wasdel)			ap->ip->i_delayed_blks -= ralen;		/*		 * Adjust the disk quota also. This was reserved		 * earlier.		 */		xfs_trans_mod_dquot_byino(ap->tp, ap->ip,			ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT :					XFS_TRANS_DQ_RTBCOUNT, (long) ralen);	} else {		ap->length = 0;	}//.........这里部分代码省略.........
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:101,


示例30: xfs_ioctl_setattr

//.........这里部分代码省略.........				goto error_return;			}		}		/*		 * Can't modify an immutable/append-only file unless		 * we have appropriate permission.		 */		if ((ip->i_d.di_flags &				(XFS_DIFLAG_IMMUTABLE|XFS_DIFLAG_APPEND) ||		     (fa->fsx_xflags &				(XFS_XFLAG_IMMUTABLE | XFS_XFLAG_APPEND))) &&		    !capable(CAP_LINUX_IMMUTABLE)) {			code = XFS_ERROR(EPERM);			goto error_return;		}	}	xfs_trans_ijoin(tp, ip, 0);	/*	 * Change file ownership.  Must be the owner or privileged.	 */	if (mask & FSX_PROJID) {		/*		 * CAP_FSETID overrides the following restrictions:		 *		 * The set-user-ID and set-group-ID bits of a file will be		 * cleared upon successful return from chown()		 */		if ((ip->i_d.di_mode & (S_ISUID|S_ISGID)) &&		    !capable(CAP_FSETID))			ip->i_d.di_mode &= ~(S_ISUID|S_ISGID);		/*		 * Change the ownerships and register quota modifications		 * in the transaction.		 */		if (xfs_get_projid(ip) != fa->fsx_projid) {			if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) {				olddquot = xfs_qm_vop_chown(tp, ip,							&ip->i_gdquot, gdqp);			}			xfs_set_projid(ip, fa->fsx_projid);			/*			 * We may have to rev the inode as well as			 * the superblock version number since projids didn't			 * exist before DINODE_VERSION_2 and SB_VERSION_NLINK.			 */			if (ip->i_d.di_version == 1)				xfs_bump_ino_vers2(tp, ip);		}	}	if (mask & FSX_EXTSIZE)		ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;	if (mask & FSX_XFLAGS) {		xfs_set_diflags(ip, fa->fsx_xflags);		xfs_diflags_to_linux(ip);	}	xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	XFS_STATS_INC(xs_ig_attrchg);	/*	 * If this is a synchronous mount, make sure that the	 * transaction goes to disk before returning to the user.	 * This is slightly sub-optimal in that truncates require	 * two sync transactions instead of one for wsync filesystems.	 * One for the truncate and one for the timestamps since we	 * don't want to change the timestamps unless we're sure the	 * truncate worked.  Truncates are less than 1% of the laddis	 * mix so this probably isn't worth the trouble to optimize.	 */	if (mp->m_flags & XFS_MOUNT_WSYNC)		xfs_trans_set_sync(tp);	code = xfs_trans_commit(tp, 0);	xfs_iunlock(ip, lock_flags);	/*	 * Release any dquot(s) the inode had kept before chown.	 */	xfs_qm_dqrele(olddquot);	xfs_qm_dqrele(udqp);	xfs_qm_dqrele(gdqp);	return code; error_return:	xfs_qm_dqrele(udqp);	xfs_qm_dqrele(gdqp);	xfs_trans_cancel(tp, 0);	if (lock_flags)		xfs_iunlock(ip, lock_flags);	return code;}
开发者ID:AiWinters,项目名称:linux,代码行数:101,



注:本文中的xfs_trans_log_inode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ xfs_trans_reserve函数代码示例
C++ xfs_trans_ijoin函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。