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

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

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

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

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

示例1: xfs_inode_item_trylock

/* * This is called to attempt to lock the inode associated with this * inode log item, in preparation for the push routine which does the actual * iflush.  Don't sleep on the inode lock or the flush lock. * * If the flush lock is already held, indicating that the inode has * been or is in the process of being flushed, then (ideally) we'd like to * see if the inode's buffer is still incore, and if so give it a nudge. * We delay doing so until the pushbuf routine, though, to avoid holding * the AIL lock across a call to the blackhole which is the buffer cache. * Also we don't want to sleep in any device strategy routines, which can happen * if we do the subsequent bawrite in here. */STATIC uintxfs_inode_item_trylock(	xfs_inode_log_item_t	*iip){	register xfs_inode_t	*ip;	ip = iip->ili_inode;	if (xfs_ipincount(ip) > 0) {		return XFS_ITEM_PINNED;	}	if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) {		return XFS_ITEM_LOCKED;	}	if (!xfs_iflock_nowait(ip)) {		/*		 * If someone else isn't already trying to push the inode		 * buffer, we get to do it.		 */		if (iip->ili_pushbuf_flag == 0) {			iip->ili_pushbuf_flag = 1;#ifdef DEBUG			iip->ili_push_owner = current_pid();#endif			/*			 * Inode is left locked in shared mode.			 * Pushbuf routine gets to unlock it.			 */			return XFS_ITEM_PUSHBUF;		} else {			/*			 * We hold the AIL lock, so we must specify the			 * NONOTIFY flag so that we won't double trip.			 */			xfs_iunlock(ip, XFS_ILOCK_SHARED|XFS_IUNLOCK_NONOTIFY);			return XFS_ITEM_FLUSHING;		}		/* NOTREACHED */	}	/* Stale items should force out the iclog */	if (ip->i_flags & XFS_ISTALE) {		xfs_ifunlock(ip);		xfs_iunlock(ip, XFS_ILOCK_SHARED|XFS_IUNLOCK_NONOTIFY);		return XFS_ITEM_PINNED;	}#ifdef DEBUG	if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {		ASSERT(iip->ili_format.ilf_fields != 0);		ASSERT(iip->ili_logged == 0);		ASSERT(iip->ili_item.li_flags & XFS_LI_IN_AIL);	}#endif	return XFS_ITEM_SUCCESS;}
开发者ID:458941968,项目名称:mini2440-kernel-2.6.29,代码行数:71,


示例2: xfs_file_fsync

STATIC intxfs_file_fsync(    struct file		*file,    loff_t			start,    loff_t			end,    int			datasync){    struct inode		*inode = file->f_mapping->host;    struct xfs_inode	*ip = XFS_I(inode);    struct xfs_mount	*mp = ip->i_mount;    int			error = 0;    int			log_flushed = 0;    xfs_lsn_t		lsn = 0;    trace_xfs_file_fsync(ip);    error = filemap_write_and_wait_range(inode->i_mapping, start, end);    if (error)        return error;    if (XFS_FORCED_SHUTDOWN(mp))        return -XFS_ERROR(EIO);    xfs_iflags_clear(ip, XFS_ITRUNCATED);    if (mp->m_flags & XFS_MOUNT_BARRIER) {        /*         * If we have an RT and/or log subvolume we need to make sure         * to flush the write cache the device used for file data         * first.  This is to ensure newly written file data make         * it to disk before logging the new inode size in case of         * an extending write.         */        if (XFS_IS_REALTIME_INODE(ip))            xfs_blkdev_issue_flush(mp->m_rtdev_targp);        else if (mp->m_logdev_targp != mp->m_ddev_targp)            xfs_blkdev_issue_flush(mp->m_ddev_targp);    }    xfs_ilock(ip, XFS_ILOCK_SHARED);    if (xfs_ipincount(ip)) {        if (!datasync ||                (ip->i_itemp->ili_fields & ~XFS_ILOG_TIMESTAMP))            lsn = ip->i_itemp->ili_last_lsn;    }    xfs_iunlock(ip, XFS_ILOCK_SHARED);    if (lsn)        error = _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, &log_flushed);    if ((mp->m_flags & XFS_MOUNT_BARRIER) &&            mp->m_logdev_targp == mp->m_ddev_targp &&            !XFS_IS_REALTIME_INODE(ip) &&            !log_flushed)        xfs_blkdev_issue_flush(mp->m_ddev_targp);    return -error;}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:58,


示例3: xfs_fs_nfs_commit_metadata

STATIC intxfs_fs_nfs_commit_metadata(	struct inode		*inode){	struct xfs_inode	*ip = XFS_I(inode);	struct xfs_mount	*mp = ip->i_mount;	xfs_lsn_t		lsn = 0;	xfs_ilock(ip, XFS_ILOCK_SHARED);	if (xfs_ipincount(ip))		lsn = ip->i_itemp->ili_last_lsn;	xfs_iunlock(ip, XFS_ILOCK_SHARED);	if (!lsn)		return 0;	return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:17,


示例4: xfs_fs_nfs_commit_metadata

STATIC intxfs_fs_nfs_commit_metadata(	struct inode		*inode){	struct xfs_inode	*ip = XFS_I(inode);	struct xfs_mount	*mp = ip->i_mount;	int			error = 0;	xfs_ilock(ip, XFS_ILOCK_SHARED);	if (xfs_ipincount(ip)) {		error = _xfs_log_force_lsn(mp, ip->i_itemp->ili_last_lsn,				XFS_LOG_SYNC, NULL);	}	xfs_iunlock(ip, XFS_ILOCK_SHARED);	return error;}
开发者ID:1yankeedt,项目名称:D710BST_FL24_Kernel,代码行数:17,


示例5: xfs_inode_item_trylock

/* * This is called to attempt to lock the inode associated with this * inode log item, in preparation for the push routine which does the actual * iflush.  Don't sleep on the inode lock or the flush lock. * * If the flush lock is already held, indicating that the inode has * been or is in the process of being flushed, then (ideally) we'd like to * see if the inode's buffer is still incore, and if so give it a nudge. * We delay doing so until the pushbuf routine, though, to avoid holding * the AIL lock across a call to the blackhole which is the buffer cache. * Also we don't want to sleep in any device strategy routines, which can happen * if we do the subsequent bawrite in here. */STATIC uintxfs_inode_item_trylock(	struct xfs_log_item	*lip){	struct xfs_inode_log_item *iip = INODE_ITEM(lip);	struct xfs_inode	*ip = iip->ili_inode;	if (xfs_ipincount(ip) > 0)		return XFS_ITEM_PINNED;	if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED))		return XFS_ITEM_LOCKED;	if (!xfs_iflock_nowait(ip)) {		/*		 * inode has already been flushed to the backing buffer,		 * leave it locked in shared mode, pushbuf routine will		 * unlock it.		 */		return XFS_ITEM_PUSHBUF;	}	/* Stale items should force out the iclog */	if (ip->i_flags & XFS_ISTALE) {		xfs_ifunlock(ip);		/*		 * we hold the AIL lock - notify the unlock routine of this		 * so it doesn't try to get the lock again.		 */		xfs_iunlock(ip, XFS_ILOCK_SHARED|XFS_IUNLOCK_NONOTIFY);		return XFS_ITEM_PINNED;	}#ifdef DEBUG	if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {		ASSERT(iip->ili_format.ilf_fields != 0);		ASSERT(iip->ili_logged == 0);		ASSERT(lip->li_flags & XFS_LI_IN_AIL);	}#endif	return XFS_ITEM_SUCCESS;}
开发者ID:GerardGarcia,项目名称:linux,代码行数:55,


示例6: xfs_dir_fsync

/* * Fsync operations on directories are much simpler than on regular files, * as there is no file data to flush, and thus also no need for explicit * cache flush operations, and there are no non-transaction metadata updates * on directories either. */STATIC intxfs_dir_fsync(	struct file		*file,	loff_t			start,	loff_t			end,	int			datasync){	struct xfs_inode	*ip = XFS_I(file->f_mapping->host);	struct xfs_mount	*mp = ip->i_mount;	xfs_lsn_t		lsn = 0;	trace_xfs_dir_fsync(ip);	xfs_ilock(ip, XFS_ILOCK_SHARED);	if (xfs_ipincount(ip))		lsn = ip->i_itemp->ili_last_lsn;	xfs_iunlock(ip, XFS_ILOCK_SHARED);	if (!lsn)		return 0;	return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);}
开发者ID:oscardagrach,项目名称:linux,代码行数:28,


示例7: xfs_inode_item_trylock

STATIC uintxfs_inode_item_trylock(	struct xfs_log_item	*lip){	struct xfs_inode_log_item *iip = INODE_ITEM(lip);	struct xfs_inode	*ip = iip->ili_inode;	if (xfs_ipincount(ip) > 0)		return XFS_ITEM_PINNED;	if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED))		return XFS_ITEM_LOCKED;	if (!xfs_iflock_nowait(ip)) {		/*                                                                                                                                     */		return XFS_ITEM_PUSHBUF;	}	/*                                        */	if (ip->i_flags & XFS_ISTALE) {		xfs_ifunlock(ip);		xfs_iunlock(ip, XFS_ILOCK_SHARED);		return XFS_ITEM_PINNED;	}#ifdef DEBUG	if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {		ASSERT(iip->ili_fields != 0);		ASSERT(iip->ili_logged == 0);		ASSERT(lip->li_flags & XFS_LI_IN_AIL);	}#endif	return XFS_ITEM_SUCCESS;}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:38,


示例8: xfs_reclaim_inode

/* * Inodes in different states need to be treated differently. The following * table lists the inode states and the reclaim actions necessary: * *	inode state	     iflush ret		required action *      ---------------      ----------         --------------- *	bad			-		reclaim *	shutdown		EIO		unpin and reclaim *	clean, unpinned		0		reclaim *	stale, unpinned		0		reclaim *	clean, pinned(*)	0		requeue *	stale, pinned		EAGAIN		requeue *	dirty, async		-		requeue *	dirty, sync		0		reclaim * * (*) dgc: I don't think the clean, pinned state is possible but it gets * handled anyway given the order of checks implemented. * * Also, because we get the flush lock first, we know that any inode that has * been flushed delwri has had the flush completed by the time we check that * the inode is clean. * * Note that because the inode is flushed delayed write by AIL pushing, the * flush lock may already be held here and waiting on it can result in very * long latencies.  Hence for sync reclaims, where we wait on the flush lock, * the caller should push the AIL first before trying to reclaim inodes to * minimise the amount of time spent waiting.  For background relaim, we only * bother to reclaim clean inodes anyway. * * Hence the order of actions after gaining the locks should be: *	bad		=> reclaim *	shutdown	=> unpin and reclaim *	pinned, async	=> requeue *	pinned, sync	=> unpin *	stale		=> reclaim *	clean		=> reclaim *	dirty, async	=> requeue *	dirty, sync	=> flush, wait and reclaim */STATIC intxfs_reclaim_inode(	struct xfs_inode	*ip,	struct xfs_perag	*pag,	int			sync_mode){	struct xfs_buf		*bp = NULL;	xfs_ino_t		ino = ip->i_ino; /* for radix_tree_delete */	int			error;restart:	error = 0;	xfs_ilock(ip, XFS_ILOCK_EXCL);	if (!xfs_iflock_nowait(ip)) {		if (!(sync_mode & SYNC_WAIT))			goto out;		xfs_iflock(ip);	}	if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {		xfs_iunpin_wait(ip);		/* xfs_iflush_abort() drops the flush lock */		xfs_iflush_abort(ip, false);		goto reclaim;	}	if (xfs_ipincount(ip)) {		if (!(sync_mode & SYNC_WAIT))			goto out_ifunlock;		xfs_iunpin_wait(ip);	}	if (xfs_iflags_test(ip, XFS_ISTALE) || xfs_inode_clean(ip)) {		xfs_ifunlock(ip);		goto reclaim;	}	/*	 * Never flush out dirty data during non-blocking reclaim, as it would	 * just contend with AIL pushing trying to do the same job.	 */	if (!(sync_mode & SYNC_WAIT))		goto out_ifunlock;	/*	 * Now we have an inode that needs flushing.	 *	 * Note that xfs_iflush will never block on the inode buffer lock, as	 * xfs_ifree_cluster() can lock the inode buffer before it locks the	 * ip->i_lock, and we are doing the exact opposite here.  As a result,	 * doing a blocking xfs_imap_to_bp() to get the cluster buffer would	 * result in an ABBA deadlock with xfs_ifree_cluster().	 *	 * As xfs_ifree_cluser() must gather all inodes that are active in the	 * cache to mark them stale, if we hit this case we don't actually want	 * to do IO here - we want the inode marked stale so we can simply	 * reclaim it.  Hence if we get an EAGAIN error here,  just unlock the	 * inode, back off and try again.  Hopefully the next pass through will	 * see the stale flag set on the inode.	 */	error = xfs_iflush(ip, &bp);	if (error == -EAGAIN) {		xfs_iunlock(ip, XFS_ILOCK_EXCL);//.........这里部分代码省略.........
开发者ID:BWhitten,项目名称:linux-stable,代码行数:101,


示例9: xfs_file_fsync

STATIC intxfs_file_fsync(	struct file		*file,	loff_t			start,	loff_t			end,	int			datasync){	struct inode		*inode = file->f_mapping->host;	struct xfs_inode	*ip = XFS_I(inode);	struct xfs_mount	*mp = ip->i_mount;	int			error = 0;	int			log_flushed = 0;	xfs_lsn_t		lsn = 0;	trace_xfs_file_fsync(ip);	error = filemap_write_and_wait_range(inode->i_mapping, start, end);	if (error)		return error;	if (XFS_FORCED_SHUTDOWN(mp))		return -EIO;	xfs_iflags_clear(ip, XFS_ITRUNCATED);	if (mp->m_flags & XFS_MOUNT_BARRIER) {		/*		 * If we have an RT and/or log subvolume we need to make sure		 * to flush the write cache the device used for file data		 * first.  This is to ensure newly written file data make		 * it to disk before logging the new inode size in case of		 * an extending write.		 */		if (XFS_IS_REALTIME_INODE(ip))			xfs_blkdev_issue_flush(mp->m_rtdev_targp);		else if (mp->m_logdev_targp != mp->m_ddev_targp)			xfs_blkdev_issue_flush(mp->m_ddev_targp);	}	/*	 * All metadata updates are logged, which means that we just have	 * to flush the log up to the latest LSN that touched the inode.	 */	xfs_ilock(ip, XFS_ILOCK_SHARED);	if (xfs_ipincount(ip)) {		if (!datasync ||		    (ip->i_itemp->ili_fields & ~XFS_ILOG_TIMESTAMP))			lsn = ip->i_itemp->ili_last_lsn;	}	xfs_iunlock(ip, XFS_ILOCK_SHARED);	if (lsn)		error = _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, &log_flushed);	/*	 * If we only have a single device, and the log force about was	 * a no-op we might have to flush the data device cache here.	 * This can only happen for fdatasync/O_DSYNC if we were overwriting	 * an already allocated file and thus do not have any metadata to	 * commit.	 */	if ((mp->m_flags & XFS_MOUNT_BARRIER) &&	    mp->m_logdev_targp == mp->m_ddev_targp &&	    !XFS_IS_REALTIME_INODE(ip) &&	    !log_flushed)		xfs_blkdev_issue_flush(mp->m_ddev_targp);	return error;}
开发者ID:Abioy,项目名称:kasan,代码行数:69,


示例10: or

//.........这里部分代码省略.........			mark_inode_dirty_sync(inode);		}		xfs_iunlock(xip, XFS_ILOCK_EXCL);	}	/* Handle various SYNC-type writes */	if ((file->f_flags & O_SYNC) || IS_SYNC(file->f_dentry->d_inode)) {		/*		 * 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)			&& !(xip->i_update_size)) {			/*			 * 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.			 */			xfs_inode_log_item_t *iip;			xfs_lsn_t lsn;			iip = xip->i_itemp;			if (iip && iip->ili_last_lsn) {				lsn = iip->ili_last_lsn;				xfs_log_force(mp, lsn,						XFS_LOG_FORCE | XFS_LOG_SYNC);			} else if (xfs_ipincount(xip) > 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(xip, XFS_ILOCK_EXCL);				xfs_trans_ijoin(tp, xip, XFS_ILOCK_EXCL);				xfs_trans_ihold(tp, xip);				xfs_trans_log_inode(tp, xip, XFS_ILOG_CORE);				xfs_trans_set_sync(tp);				error = xfs_trans_commit(tp, 0, NULL);				xfs_iunlock(xip, XFS_ILOCK_EXCL);			}		}	} /* (ioflags & O_SYNC) */	/*	 * If we are coming from an nfsd thread then insert into the	 * reference cache.	 */	if (!strcmp(current->comm, "nfsd"))		xfs_refcache_insert(xip);	/* Drop lock this way - the old refcache release is in here */	if (iolock)		xfs_rwunlock(bdp, locktype);	return(ret);}
开发者ID:JBTech,项目名称:ralink_rt5350,代码行数:101,


示例11: or

//.........这里部分代码省略.........			xip->i_d.di_size = *offset;			i_size_write(inode, *offset);			xip->i_update_core = 1;			xip->i_update_size = 1;		}		xfs_iunlock(xip, XFS_ILOCK_EXCL);	}	if (ret <= 0) {		xfs_rwunlock(bdp, locktype);		return ret;	}	XFS_STATS_ADD(xs_write_bytes, ret);	/* Handle various SYNC-type writes */	if ((file->f_flags & O_SYNC) || IS_SYNC(file->f_dentry->d_inode)) {		/*		 * 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)			&& !(xip->i_update_size)) {			/*			 * 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.			 */			xfs_inode_log_item_t *iip;			xfs_lsn_t lsn;			iip = xip->i_itemp;			if (iip && iip->ili_last_lsn) {				lsn = iip->ili_last_lsn;				xfs_log_force(mp, lsn,						XFS_LOG_FORCE | XFS_LOG_SYNC);			} else if (xfs_ipincount(xip) > 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(xip, XFS_ILOCK_EXCL);				xfs_trans_ijoin(tp, xip, XFS_ILOCK_EXCL);				xfs_trans_ihold(tp, xip);				xfs_trans_log_inode(tp, xip, XFS_ILOG_CORE);				xfs_trans_set_sync(tp);				error = xfs_trans_commit(tp, 0, (xfs_lsn_t)0);				xfs_iunlock(xip, XFS_ILOCK_EXCL);			}		}	} /* (ioflags & O_SYNC) */	xfs_rwunlock(bdp, locktype);	return(ret);}
开发者ID:xricson,项目名称:knoppix,代码行数:101,


示例12: xfs_file_fsync

STATIC intxfs_file_fsync(	struct file		*file,	struct dentry		*dentry,	int			datasync){	struct xfs_inode	*ip = XFS_I(dentry->d_inode);	struct xfs_trans	*tp;	int			error = 0;	int			log_flushed = 0;	xfs_itrace_entry(ip);	if (XFS_FORCED_SHUTDOWN(ip->i_mount))		return -XFS_ERROR(EIO);	xfs_iflags_clear(ip, XFS_ITRUNCATED);	/*	 * We always need to make sure that the required inode state is safe on	 * disk.  The inode might be clean but we still might need to force the	 * log because of committed transactions that haven't hit the disk yet.	 * Likewise, there could be unflushed non-transactional changes to the	 * inode core that have to go to disk and this requires us to issue	 * a synchronous transaction to capture these changes correctly.	 *	 * This code relies on the assumption that if the i_update_core field	 * of the inode is clear and the inode is unpinned then it is clean	 * and no action is required.	 */	xfs_ilock(ip, XFS_ILOCK_SHARED);	/*	 * First check if the VFS inode is marked dirty.  All the dirtying	 * of non-transactional updates no goes through mark_inode_dirty*,	 * which allows us to distinguish beteeen pure timestamp updates	 * and i_size updates which need to be caught for fdatasync.	 * After that also theck for the dirty state in the XFS inode, which	 * might gets cleared when the inode gets written out via the AIL	 * or xfs_iflush_cluster.	 */	if (((dentry->d_inode->i_state & I_DIRTY_DATASYNC) ||	    ((dentry->d_inode->i_state & I_DIRTY_SYNC) && !datasync)) &&	    ip->i_update_core) {		/*		 * Kick off a transaction to log the inode core to get the		 * updates.  The sync transaction will also force the log.		 */		xfs_iunlock(ip, XFS_ILOCK_SHARED);		tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_FSYNC_TS);		error = xfs_trans_reserve(tp, 0,				XFS_FSYNC_TS_LOG_RES(ip->i_mount), 0, 0, 0);		if (error) {			xfs_trans_cancel(tp, 0);			return -error;		}		xfs_ilock(ip, XFS_ILOCK_EXCL);		/*		 * Note - it's possible that we might have pushed ourselves out		 * of the way during trans_reserve which would flush the inode.		 * But there's no guarantee that the inode buffer has actually		 * gone out yet (it's delwri).	Plus the buffer could be pinned		 * anyway if it's part of an inode in another recent		 * transaction.	 So we play it safe and fire off the		 * transaction anyway.		 */		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, &log_flushed);		xfs_iunlock(ip, XFS_ILOCK_EXCL);	} else {		/*		 * Timestamps/size haven't changed since last inode flush or		 * inode transaction commit.  That means either nothing got		 * written or a transaction committed which caught the updates.		 * If the latter happened and the transaction hasn't hit the		 * disk yet, the inode will be still be pinned.  If it is,		 * force the log.		 */		if (xfs_ipincount(ip)) {			error = _xfs_log_force_lsn(ip->i_mount,					ip->i_itemp->ili_last_lsn,					XFS_LOG_SYNC, &log_flushed);		}		xfs_iunlock(ip, XFS_ILOCK_SHARED);	}	if (ip->i_mount->m_flags & XFS_MOUNT_BARRIER) {		/*		 * If the log write didn't issue an ordered tag we need		 * to flush the disk cache for the data device now.		 */		if (!log_flushed)			xfs_blkdev_issue_flush(ip->i_mount->m_ddev_targp);		/*//.........这里部分代码省略.........
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:101,


示例13: or

//.........这里部分代码省略.........	error = -ret;	if (ret <= 0)		goto out_unlock_internal;	XFS_STATS_ADD(xs_write_bytes, ret);	/* Handle various SYNC-type writes */	if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) {		/*		 * 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) &&		    !(xip->i_update_size)) {			xfs_inode_log_item_t	*iip = xip->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(xip) > 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(xip, XFS_ILOCK_EXCL);				xfs_trans_ijoin(tp, xip, XFS_ILOCK_EXCL);				xfs_trans_ihold(tp, xip);				xfs_trans_log_inode(tp, xip, XFS_ILOG_CORE);				xfs_trans_set_sync(tp);				error = xfs_trans_commit(tp, 0, NULL);				xfs_iunlock(xip, XFS_ILOCK_EXCL);				if (error)					goto out_unlock_internal;			}		}			xfs_rwunlock(bdp, locktype);		if (need_isem)			up(&inode->i_sem);		error = sync_page_range(inode, mapping, pos, ret);		if (!error)			error = ret;		return error;	} out_unlock_internal:	xfs_rwunlock(bdp, locktype); out_unlock_isem:	if (need_isem)		up(&inode->i_sem);	return -error;}
开发者ID:GodFox,项目名称:magx_kernel_xpixl,代码行数:101,


示例14: xfs_sync_inodes

//.........这里部分代码省略.........		/*		 * There were no inodes in the list, just break out		 * of the loop.		 */		if (ip == NULL) {			break;		}		/*		 * We found another sync thread marker - skip it		 */		if (ip->i_mount == NULL) {			ip = ip->i_mnext;			continue;		}		vp = XFS_ITOV_NULL(ip);		/*		 * If the vnode is gone then this is being torn down,		 * call reclaim if it is flushed, else let regular flush		 * code deal with it later in the loop.		 */		if (vp == NULL) {			/* Skip ones already in reclaim */			if (ip->i_flags & XFS_IRECLAIM) {				ip = ip->i_mnext;				continue;			}			if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) {				ip = ip->i_mnext;			} else if ((xfs_ipincount(ip) == 0) &&				    xfs_iflock_nowait(ip)) {				IPOINTER_INSERT(ip, mp);				xfs_finish_reclaim(ip, 1,						XFS_IFLUSH_DELWRI_ELSE_ASYNC);				XFS_MOUNT_ILOCK(mp);				mount_locked = B_TRUE;				IPOINTER_REMOVE(ip, mp);			} else {				xfs_iunlock(ip, XFS_ILOCK_EXCL);				ip = ip->i_mnext;			}			continue;		}		if (XFS_FORCED_SHUTDOWN(mp) && !(flags & SYNC_CLOSE)) {			XFS_MOUNT_IUNLOCK(mp);			kmem_free(ipointer, sizeof(xfs_iptr_t));			return 0;		}		/*		 * If this is just vfs_sync() or pflushd() calling		 * then we can skip inodes for which it looks like		 * there is nothing to do.  Since we don't have the		 * inode locked this is racey, but these are periodic		 * calls so it doesn't matter.  For the others we want		 * to know for sure, so we at least try to lock them.		 */		if (flags & SYNC_BDFLUSH) {			if (((ip->i_itemp == NULL) ||
开发者ID:iPodLinux,项目名称:linux-2.6.7-ipod,代码行数:67,


示例15: xfs_reclaim_inode

STATIC intxfs_reclaim_inode(	struct xfs_inode	*ip,	struct xfs_perag	*pag,	int			sync_mode){	int	error;restart:	error = 0;	xfs_ilock(ip, XFS_ILOCK_EXCL);	if (!xfs_iflock_nowait(ip)) {		if (!(sync_mode & SYNC_WAIT))			goto out;		xfs_promote_inode(ip);		xfs_iflock(ip);	}	if (is_bad_inode(VFS_I(ip)))		goto reclaim;	if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {		xfs_iunpin_wait(ip);		goto reclaim;	}	if (xfs_ipincount(ip)) {		if (!(sync_mode & SYNC_WAIT)) {			xfs_ifunlock(ip);			goto out;		}		xfs_iunpin_wait(ip);	}	if (xfs_iflags_test(ip, XFS_ISTALE))		goto reclaim;	if (xfs_inode_clean(ip))		goto reclaim;	error = xfs_iflush(ip, SYNC_TRYLOCK | sync_mode);	if (sync_mode & SYNC_WAIT) {		if (error == EAGAIN) {			xfs_iunlock(ip, XFS_ILOCK_EXCL);						delay(2);			goto restart;		}		xfs_iflock(ip);		goto reclaim;	}	if (error && error != EAGAIN && !XFS_FORCED_SHUTDOWN(ip->i_mount)) {		xfs_warn(ip->i_mount,			"inode 0x%llx background reclaim flush failed with %d",			(long long)ip->i_ino, error);	}out:	xfs_iflags_clear(ip, XFS_IRECLAIM);	xfs_iunlock(ip, XFS_ILOCK_EXCL);	return 0;reclaim:	xfs_ifunlock(ip);	xfs_iunlock(ip, XFS_ILOCK_EXCL);	XFS_STATS_INC(xs_ig_reclaims);	spin_lock(&pag->pag_ici_lock);	if (!radix_tree_delete(&pag->pag_ici_root,				XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino)))		ASSERT(0);	__xfs_inode_clear_reclaim(pag, ip);	spin_unlock(&pag->pag_ici_lock);	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_qm_dqdetach(ip);	xfs_iunlock(ip, XFS_ILOCK_EXCL);	xfs_inode_free(ip);	return error;}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:79,


示例16: xfs_file_fsync

//.........这里部分代码省略.........		/*		 * If we have an RT and/or log subvolume we need to make sure		 * to flush the write cache the device used for file data		 * first.  This is to ensure newly written file data make		 * it to disk before logging the new inode size in case of		 * an extending write.		 */		if (XFS_IS_REALTIME_INODE(ip))			xfs_blkdev_issue_flush(mp->m_rtdev_targp);		else if (mp->m_logdev_targp != mp->m_ddev_targp)			xfs_blkdev_issue_flush(mp->m_ddev_targp);	}	/*	 * We always need to make sure that the required inode state is safe on	 * disk.  The inode might be clean but we still might need to force the	 * log because of committed transactions that haven't hit the disk yet.	 * Likewise, there could be unflushed non-transactional changes to the	 * inode core that have to go to disk and this requires us to issue	 * a synchronous transaction to capture these changes correctly.	 *	 * This code relies on the assumption that if the i_update_core field	 * of the inode is clear and the inode is unpinned then it is clean	 * and no action is required.	 */	xfs_ilock(ip, XFS_ILOCK_SHARED);	/*	 * First check if the VFS inode is marked dirty.  All the dirtying	 * of non-transactional updates no goes through mark_inode_dirty*,	 * which allows us to distinguish beteeen pure timestamp updates	 * and i_size updates which need to be caught for fdatasync.	 * After that also theck for the dirty state in the XFS inode, which	 * might gets cleared when the inode gets written out via the AIL	 * or xfs_iflush_cluster.	 */	if (((inode->i_state & I_DIRTY_DATASYNC) ||	    ((inode->i_state & I_DIRTY_SYNC) && !datasync)) &&	    ip->i_update_core) {		/*		 * Kick off a transaction to log the inode core to get the		 * updates.  The sync transaction will also force the log.		 */		xfs_iunlock(ip, XFS_ILOCK_SHARED);		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);		/*		 * Note - it's possible that we might have pushed ourselves out		 * of the way during trans_reserve which would flush the inode.		 * But there's no guarantee that the inode buffer has actually		 * gone out yet (it's delwri).	Plus the buffer could be pinned		 * anyway if it's part of an inode in another recent		 * transaction.	 So we play it safe and fire off the		 * transaction anyway.		 */		xfs_trans_ijoin(tp, ip);		xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);		xfs_trans_set_sync(tp);		error = _xfs_trans_commit(tp, 0, &log_flushed);		xfs_iunlock(ip, XFS_ILOCK_EXCL);	} else {		/*		 * Timestamps/size haven't changed since last inode flush or		 * inode transaction commit.  That means either nothing got		 * written or a transaction committed which caught the updates.		 * If the latter happened and the transaction hasn't hit the		 * disk yet, the inode will be still be pinned.  If it is,		 * force the log.		 */		if (xfs_ipincount(ip)) {			error = _xfs_log_force_lsn(mp,					ip->i_itemp->ili_last_lsn,					XFS_LOG_SYNC, &log_flushed);		}		xfs_iunlock(ip, XFS_ILOCK_SHARED);	}	/*	 * If we only have a single device, and the log force about was	 * a no-op we might have to flush the data device cache here.	 * This can only happen for fdatasync/O_DSYNC if we were overwriting	 * an already allocated file and thus do not have any metadata to	 * commit.	 */	if ((mp->m_flags & XFS_MOUNT_BARRIER) &&	    mp->m_logdev_targp == mp->m_ddev_targp &&	    !XFS_IS_REALTIME_INODE(ip) &&	    !log_flushed)		xfs_blkdev_issue_flush(mp->m_ddev_targp);	return -error;}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:101,


示例17: or

//.........这里部分代码省略.........			xip->i_update_core = 1;			xip->i_update_size = 1;		}		xfs_iunlock(xip, XFS_ILOCK_EXCL);	}	/* Handle various SYNC-type writes */#if 0//	if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) {#endif	if (ioflag & IO_SYNC) {		/*		 * 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) &&		    !(xip->i_update_size)) {			xfs_inode_log_item_t	*iip = xip->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(xip) > 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(xip, XFS_ILOCK_EXCL);				xfs_trans_ijoin(tp, xip, XFS_ILOCK_EXCL);				xfs_trans_ihold(tp, xip);				xfs_trans_log_inode(tp, xip, XFS_ILOG_CORE);				xfs_trans_set_sync(tp);				error = xfs_trans_commit(tp, 0, NULL);				xfs_iunlock(xip, XFS_ILOCK_EXCL);			}			if (error)				goto out_unlock_internal;		}		xfs_rwunlock(bdp, locktype);		return ret;	} /* (ioflags & O_SYNC) */out_unlock_internal:	xfs_rwunlock(bdp, locktype);#if 0out_unlock_mutex:	if (need_i_mutex)		mutex_unlock(&inode->i_mutex);#endif //out_nounlocks:	return -error;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:101,


示例18: xfs_file_fsync

STATIC intxfs_file_fsync(	struct file		*file,	loff_t			start,	loff_t			end,	int			datasync){	struct inode		*inode = file->f_mapping->host;	struct xfs_inode	*ip = XFS_I(inode);	struct xfs_mount	*mp = ip->i_mount;	int			error = 0;	int			log_flushed = 0;	xfs_lsn_t		lsn = 0;	trace_xfs_file_fsync(ip);	error = file_write_and_wait_range(file, start, end);	if (error)		return error;	if (XFS_FORCED_SHUTDOWN(mp))		return -EIO;	xfs_iflags_clear(ip, XFS_ITRUNCATED);	/*	 * If we have an RT and/or log subvolume we need to make sure to flush	 * the write cache the device used for file data first.  This is to	 * ensure newly written file data make it to disk before logging the new	 * inode size in case of an extending write.	 */	if (XFS_IS_REALTIME_INODE(ip))		xfs_blkdev_issue_flush(mp->m_rtdev_targp);	else if (mp->m_logdev_targp != mp->m_ddev_targp)		xfs_blkdev_issue_flush(mp->m_ddev_targp);	/*	 * All metadata updates are logged, which means that we just have to	 * flush the log up to the latest LSN that touched the inode. If we have	 * concurrent fsync/fdatasync() calls, we need them to all block on the	 * log force before we clear the ili_fsync_fields field. This ensures	 * that we don't get a racing sync operation that does not wait for the	 * metadata to hit the journal before returning. If we race with	 * clearing the ili_fsync_fields, then all that will happen is the log	 * force will do nothing as the lsn will already be on disk. We can't	 * race with setting ili_fsync_fields because that is done under	 * XFS_ILOCK_EXCL, and that can't happen because we hold the lock shared	 * until after the ili_fsync_fields is cleared.	 */	xfs_ilock(ip, XFS_ILOCK_SHARED);	if (xfs_ipincount(ip)) {		if (!datasync ||		    (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP))			lsn = ip->i_itemp->ili_last_lsn;	}	if (lsn) {		error = _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, &log_flushed);		ip->i_itemp->ili_fsync_fields = 0;	}	xfs_iunlock(ip, XFS_ILOCK_SHARED);	/*	 * If we only have a single device, and the log force about was	 * a no-op we might have to flush the data device cache here.	 * This can only happen for fdatasync/O_DSYNC if we were overwriting	 * an already allocated file and thus do not have any metadata to	 * commit.	 */	if (!log_flushed && !XFS_IS_REALTIME_INODE(ip) &&	    mp->m_logdev_targp == mp->m_ddev_targp)		xfs_blkdev_issue_flush(mp->m_ddev_targp);	return error;}
开发者ID:oscardagrach,项目名称:linux,代码行数:75,


示例19: xfs_reclaim_inode

/* * Inodes in different states need to be treated differently, and the return * value of xfs_iflush is not sufficient to get this right. The following table * lists the inode states and the reclaim actions necessary for non-blocking * reclaim: * * *	inode state	     iflush ret		required action *      ---------------      ----------         --------------- *	bad			-		reclaim *	shutdown		EIO		unpin and reclaim *	clean, unpinned		0		reclaim *	stale, unpinned		0		reclaim *	clean, pinned(*)	0		requeue *	stale, pinned		EAGAIN		requeue *	dirty, delwri ok	0		requeue *	dirty, delwri blocked	EAGAIN		requeue *	dirty, sync flush	0		reclaim * * (*) dgc: I don't think the clean, pinned state is possible but it gets * handled anyway given the order of checks implemented. * * As can be seen from the table, the return value of xfs_iflush() is not * sufficient to correctly decide the reclaim action here. The checks in * xfs_iflush() might look like duplicates, but they are not. * * Also, because we get the flush lock first, we know that any inode that has * been flushed delwri has had the flush completed by the time we check that * the inode is clean. The clean inode check needs to be done before flushing * the inode delwri otherwise we would loop forever requeuing clean inodes as * we cannot tell apart a successful delwri flush and a clean inode from the * return value of xfs_iflush(). * * Note that because the inode is flushed delayed write by background * writeback, the flush lock may already be held here and waiting on it can * result in very long latencies. Hence for sync reclaims, where we wait on the * flush lock, the caller should push out delayed write inodes first before * trying to reclaim them to minimise the amount of time spent waiting. For * background relaim, we just requeue the inode for the next pass. * * Hence the order of actions after gaining the locks should be: *	bad		=> reclaim *	shutdown	=> unpin and reclaim *	pinned, delwri	=> requeue *	pinned, sync	=> unpin *	stale		=> reclaim *	clean		=> reclaim *	dirty, delwri	=> flush and requeue *	dirty, sync	=> flush, wait and reclaim */STATIC intxfs_reclaim_inode(	struct xfs_inode	*ip,	struct xfs_perag	*pag,	int			sync_mode){	int	error;restart:	error = 0;	xfs_ilock(ip, XFS_ILOCK_EXCL);	if (!xfs_iflock_nowait(ip)) {		if (!(sync_mode & SYNC_WAIT))			goto out;		/*		 * If we only have a single dirty inode in a cluster there is		 * a fair chance that the AIL push may have pushed it into		 * the buffer, but xfsbufd won't touch it until 30 seconds		 * from now, and thus we will lock up here.		 *		 * Promote the inode buffer to the front of the delwri list		 * and wake up xfsbufd now.		 */		xfs_promote_inode(ip);		xfs_iflock(ip);	}	if (is_bad_inode(VFS_I(ip)))		goto reclaim;	if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {		xfs_iunpin_wait(ip);		goto reclaim;	}	if (xfs_ipincount(ip)) {		if (!(sync_mode & SYNC_WAIT)) {			xfs_ifunlock(ip);			goto out;		}		xfs_iunpin_wait(ip);	}	if (xfs_iflags_test(ip, XFS_ISTALE))		goto reclaim;	if (xfs_inode_clean(ip))		goto reclaim;	/*	 * Now we have an inode that needs flushing.	 *	 * We do a nonblocking flush here even if we are doing a SYNC_WAIT//.........这里部分代码省略.........
开发者ID:1yankeedt,项目名称:D710BST_FL24_Kernel,代码行数:101,


示例20: 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,


示例21: xfs_inode_item_push

STATIC uintxfs_inode_item_push(    struct xfs_log_item	*lip,    struct list_head	*buffer_list){    struct xfs_inode_log_item *iip = INODE_ITEM(lip);    struct xfs_inode	*ip = iip->ili_inode;    struct xfs_buf		*bp = NULL;    uint			rval = XFS_ITEM_SUCCESS;    int			error;    if (xfs_ipincount(ip) > 0)        return XFS_ITEM_PINNED;    if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED))        return XFS_ITEM_LOCKED;    /*     * Re-check the pincount now that we stabilized the value by     * taking the ilock.     */    if (xfs_ipincount(ip) > 0) {        rval = XFS_ITEM_PINNED;        goto out_unlock;    }    /*     * Stale inode items should force out the iclog.     */    if (ip->i_flags & XFS_ISTALE) {        rval = XFS_ITEM_PINNED;        goto out_unlock;    }    /*     * Someone else is already flushing the inode.  Nothing we can do     * here but wait for the flush to finish and remove the item from     * the AIL.     */    if (!xfs_iflock_nowait(ip)) {        rval = XFS_ITEM_FLUSHING;        goto out_unlock;    }    ASSERT(iip->ili_fields != 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));    ASSERT(iip->ili_logged == 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));    spin_unlock(&lip->li_ailp->xa_lock);    error = xfs_iflush(ip, &bp);    if (!error) {        if (!xfs_buf_delwri_queue(bp, buffer_list))            rval = XFS_ITEM_FLUSHING;        xfs_buf_relse(bp);    }    spin_lock(&lip->li_ailp->xa_lock);out_unlock:    xfs_iunlock(ip, XFS_ILOCK_SHARED);    return rval;}
开发者ID:Juan31,项目名称:linux,代码行数:61,



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


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