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

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

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

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

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

示例1: xfs_iget

/* * Look up an inode by number in the given file system. * The inode is looked up in the cache held in each AG. * If the inode is found in the cache, initialise the vfs inode * if necessary. * * If it is not in core, read it in from the file system's device, * add it to the cache and initialise the vfs inode. * * The inode is locked according to the value of the lock_flags parameter. * This flag parameter indicates how and if the inode's IO lock and inode lock * should be taken. * * mp -- the mount point structure for the current file system.  It points *       to the inode hash table. * tp -- a pointer to the current transaction if there is one.  This is *       simply passed through to the xfs_iread() call. * ino -- the number of the inode desired.  This is the unique identifier *        within the file system for the inode being requested. * lock_flags -- flags indicating how to lock the inode.  See the comment *		 for xfs_ilock() for a list of valid values. */intxfs_iget(	xfs_mount_t	*mp,	xfs_trans_t	*tp,	xfs_ino_t	ino,	uint		flags,	uint		lock_flags,	xfs_inode_t	**ipp){	xfs_inode_t	*ip;	int		error;	xfs_perag_t	*pag;	xfs_agino_t	agino;	/* reject inode numbers outside existing AGs */	if (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount)		return EINVAL;	/* get the perag structure and ensure that it's inode capable */	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino));	agino = XFS_INO_TO_AGINO(mp, ino);again:	error = 0;	rcu_read_lock();	ip = radix_tree_lookup(&pag->pag_ici_root, agino);	if (ip) {		error = xfs_iget_cache_hit(pag, ip, ino, flags, lock_flags);		if (error)			goto out_error_or_again;	} else {		rcu_read_unlock();		XFS_STATS_INC(xs_ig_missed);		error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip,							flags, lock_flags);		if (error)			goto out_error_or_again;	}	xfs_perag_put(pag);	*ipp = ip;	/*	 * If we have a real type for an on-disk inode, we can set ops(&unlock)	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.	 */	if (xfs_iflags_test(ip, XFS_INEW) && ip->i_d.di_mode != 0)		xfs_setup_inode(ip);	return 0;out_error_or_again:	if (error == EAGAIN) {		delay(1);		goto again;	}	xfs_perag_put(pag);	return error;}
开发者ID:OneOfMany07,项目名称:fjord-kernel,代码行数:82,


示例2: xfs_iget

intxfs_iget(	xfs_mount_t	*mp,	xfs_trans_t	*tp,	xfs_ino_t	ino,	uint		flags,	uint		lock_flags,	xfs_inode_t	**ipp){	xfs_inode_t	*ip;	int		error;	xfs_perag_t	*pag;	xfs_agino_t	agino;	ASSERT((lock_flags & (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED)) == 0);		if (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount)		return EINVAL;		pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino));	agino = XFS_INO_TO_AGINO(mp, ino);again:	error = 0;	rcu_read_lock();	ip = radix_tree_lookup(&pag->pag_ici_root, agino);	if (ip) {		error = xfs_iget_cache_hit(pag, ip, ino, flags, lock_flags);		if (error)			goto out_error_or_again;	} else {		rcu_read_unlock();		XFS_STATS_INC(xs_ig_missed);		error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip,							flags, lock_flags);		if (error)			goto out_error_or_again;	}	xfs_perag_put(pag);	*ipp = ip;	if (xfs_iflags_test(ip, XFS_INEW) && ip->i_d.di_mode != 0)		xfs_setup_inode(ip);	return 0;out_error_or_again:	if (error == EAGAIN) {		delay(1);		goto again;	}	xfs_perag_put(pag);	return error;}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:58,


示例3: __xfs_inode_clear_eofblocks_tag

static void__xfs_inode_clear_eofblocks_tag(	xfs_inode_t	*ip,	void		(*clear_tp)(struct xfs_mount *mp, xfs_agnumber_t agno,				    int error, unsigned long caller_ip),	int		tag){	struct xfs_mount *mp = ip->i_mount;	struct xfs_perag *pag;	spin_lock(&ip->i_flags_lock);	ip->i_flags &= ~XFS_IEOFBLOCKS;	spin_unlock(&ip->i_flags_lock);	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));	spin_lock(&pag->pag_ici_lock);	radix_tree_tag_clear(&pag->pag_ici_root,			     XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino), tag);	if (!radix_tree_tagged(&pag->pag_ici_root, tag)) {		/* clear the eofblocks tag from the perag radix tree */		spin_lock(&ip->i_mount->m_perag_lock);		radix_tree_tag_clear(&ip->i_mount->m_perag_tree,				     XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino),				     tag);		spin_unlock(&ip->i_mount->m_perag_lock);		clear_tp(ip->i_mount, pag->pag_agno, -1, _RET_IP_);	}	spin_unlock(&pag->pag_ici_lock);	xfs_perag_put(pag);}
开发者ID:BWhitten,项目名称:linux-stable,代码行数:32,


示例4: xfs_inode_ag_iterator_tag

intxfs_inode_ag_iterator_tag(	struct xfs_mount	*mp,	int			(*execute)(struct xfs_inode *ip, int flags,					   void *args),	int			flags,	void			*args,	int			tag){	struct xfs_perag	*pag;	int			error = 0;	int			last_error = 0;	xfs_agnumber_t		ag;	ag = 0;	while ((pag = xfs_perag_get_tag(mp, ag, tag))) {		ag = pag->pag_agno + 1;		error = xfs_inode_ag_walk(mp, pag, execute, flags, args, tag);		xfs_perag_put(pag);		if (error) {			last_error = error;			if (error == -EFSCORRUPTED)				break;		}	}	return last_error;}
开发者ID:BWhitten,项目名称:linux-stable,代码行数:27,


示例5: xfs_inode_clear_eofblocks_tag

voidxfs_inode_clear_eofblocks_tag(	xfs_inode_t	*ip){	struct xfs_mount *mp = ip->i_mount;	struct xfs_perag *pag;	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));	spin_lock(&pag->pag_ici_lock);	trace_xfs_inode_clear_eofblocks_tag(ip);	radix_tree_tag_clear(&pag->pag_ici_root,			     XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino),			     XFS_ICI_EOFBLOCKS_TAG);	if (!radix_tree_tagged(&pag->pag_ici_root, XFS_ICI_EOFBLOCKS_TAG)) {		/* clear the eofblocks tag from the perag radix tree */		spin_lock(&ip->i_mount->m_perag_lock);		radix_tree_tag_clear(&ip->i_mount->m_perag_tree,				     XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino),				     XFS_ICI_EOFBLOCKS_TAG);		spin_unlock(&ip->i_mount->m_perag_lock);		trace_xfs_perag_clear_eofblocks(ip->i_mount, pag->pag_agno,					       -1, _RET_IP_);	}	spin_unlock(&pag->pag_ici_lock);	xfs_perag_put(pag);}
开发者ID:DenisLug,项目名称:mptcp,代码行数:28,


示例6: xfs_inode_set_eofblocks_tag

voidxfs_inode_set_eofblocks_tag(	xfs_inode_t	*ip){	struct xfs_mount *mp = ip->i_mount;	struct xfs_perag *pag;	int tagged;	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));	spin_lock(&pag->pag_ici_lock);	trace_xfs_inode_set_eofblocks_tag(ip);	tagged = radix_tree_tagged(&pag->pag_ici_root,				   XFS_ICI_EOFBLOCKS_TAG);	radix_tree_tag_set(&pag->pag_ici_root,			   XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino),			   XFS_ICI_EOFBLOCKS_TAG);	if (!tagged) {		/* propagate the eofblocks tag up into the perag radix tree */		spin_lock(&ip->i_mount->m_perag_lock);		radix_tree_tag_set(&ip->i_mount->m_perag_tree,				   XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino),				   XFS_ICI_EOFBLOCKS_TAG);		spin_unlock(&ip->i_mount->m_perag_lock);		/* kick off background trimming */		xfs_queue_eofblocks(ip->i_mount);		trace_xfs_perag_set_eofblocks(ip->i_mount, pag->pag_agno,					      -1, _RET_IP_);	}	spin_unlock(&pag->pag_ici_lock);	xfs_perag_put(pag);}
开发者ID:DenisLug,项目名称:mptcp,代码行数:35,


示例7: xfs_inode_ag_iterator

intxfs_inode_ag_iterator(	struct xfs_mount	*mp,	int			(*execute)(struct xfs_inode *ip,					   struct xfs_perag *pag, int flags),	int			flags){	struct xfs_perag	*pag;	int			error = 0;	int			last_error = 0;	xfs_agnumber_t		ag;	ag = 0;	while ((pag = xfs_perag_get(mp, ag))) {		ag = pag->pag_agno + 1;		error = xfs_inode_ag_walk(mp, pag, execute, flags);		xfs_perag_put(pag);		if (error) {			last_error = error;			if (error == EFSCORRUPTED)				break;		}	}	return XFS_ERROR(last_error);}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:25,


示例8: xfs_filestream_put_ag

static voidxfs_filestream_put_ag(	xfs_mount_t	*mp,	xfs_agnumber_t	agno){	struct xfs_perag *pag;	pag = xfs_perag_get(mp, agno);	atomic_dec(&pag->pagf_fstrms);	xfs_perag_put(pag);}
开发者ID:AeroGirl,项目名称:VAR-SOM-AM33-SDK7-Kernel,代码行数:11,


示例9: xfs_filestream_get_ag

static intxfs_filestream_get_ag(	xfs_mount_t	*mp,	xfs_agnumber_t	agno){	struct xfs_perag *pag;	int		ret;	pag = xfs_perag_get(mp, agno);	ret = atomic_inc_return(&pag->pagf_fstrms);	xfs_perag_put(pag);	return ret;}
开发者ID:AeroGirl,项目名称:VAR-SOM-AM33-SDK7-Kernel,代码行数:13,


示例10: xfs_inode_ag_iterator

intxfs_inode_ag_iterator(	struct xfs_mount	*mp,	int			(*execute)(struct xfs_inode *ip,					   struct xfs_perag *pag, int flags),	int			flags,	int			tag,	int			exclusive,	int			*nr_to_scan){	int			error = 0;	int			last_error = 0;	xfs_agnumber_t		ag;	int			nr;	nr = nr_to_scan ? *nr_to_scan : INT_MAX;	for (ag = 0; ag < mp->m_sb.sb_agcount; ag++) {		struct xfs_perag	*pag;		pag = xfs_perag_get(mp, ag);		if (!pag->pag_ici_init) {			xfs_perag_put(pag);			continue;		}		error = xfs_inode_ag_walk(mp, pag, execute, flags, tag,						exclusive, &nr);		xfs_perag_put(pag);		if (error) {			last_error = error;			if (error == EFSCORRUPTED)				break;		}		if (nr <= 0)			break;	}	if (nr_to_scan)		*nr_to_scan = nr;	return XFS_ERROR(last_error);}
开发者ID:KaZoom,项目名称:buildroot-linux-kernel-m3,代码行数:39,


示例11: xfs_initialize_perag_data

/* * xfs_initialize_perag_data * * Read in each per-ag structure so we can count up the number of * allocated inodes, free inodes and used filesystem blocks as this * information is no longer persistent in the superblock. Once we have * this information, write it into the in-core superblock structure. */intxfs_initialize_perag_data(	struct xfs_mount *mp,	xfs_agnumber_t	agcount){	xfs_agnumber_t	index;	xfs_perag_t	*pag;	xfs_sb_t	*sbp = &mp->m_sb;	uint64_t	ifree = 0;	uint64_t	ialloc = 0;	uint64_t	bfree = 0;	uint64_t	bfreelst = 0;	uint64_t	btree = 0;	int		error;	for (index = 0; index < agcount; index++) {		/*		 * read the agf, then the agi. This gets us		 * all the information we need and populates the		 * per-ag structures for us.		 */		error = xfs_alloc_pagf_init(mp, NULL, index, 0);		if (error)			return error;		error = xfs_ialloc_pagi_init(mp, NULL, index);		if (error)			return error;		pag = xfs_perag_get(mp, index);		ifree += pag->pagi_freecount;		ialloc += pag->pagi_count;		bfree += pag->pagf_freeblks;		bfreelst += pag->pagf_flcount;		btree += pag->pagf_btreeblks;		xfs_perag_put(pag);	}	/*	 * Overwrite incore superblock counters with just-read data	 */	spin_lock(&mp->m_sb_lock);	sbp->sb_ifree = ifree;	sbp->sb_icount = ialloc;	sbp->sb_fdblocks = bfree + bfreelst + btree;	spin_unlock(&mp->m_sb_lock);	/* Fixup the per-cpu counters as well. */	xfs_icsb_reinit_counters(mp);	return 0;}
开发者ID:AkyZero,项目名称:wrapfs-latest,代码行数:58,


示例12: xfs_reclaim_inodes_count

intxfs_reclaim_inodes_count(	struct xfs_mount	*mp){	struct xfs_perag	*pag;	xfs_agnumber_t		ag = 0;	int			reclaimable = 0;	while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) {		ag = pag->pag_agno + 1;		reclaimable += pag->pag_ici_reclaimable;		xfs_perag_put(pag);	}	return reclaimable;}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:15,


示例13: xfs_inode_set_reclaim_tag

voidxfs_inode_set_reclaim_tag(	xfs_inode_t	*ip){	struct xfs_mount *mp = ip->i_mount;	struct xfs_perag *pag;	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));	spin_lock(&pag->pag_ici_lock);	spin_lock(&ip->i_flags_lock);	__xfs_inode_set_reclaim_tag(pag, ip);	__xfs_iflags_set(ip, XFS_IRECLAIMABLE);	spin_unlock(&ip->i_flags_lock);	spin_unlock(&pag->pag_ici_lock);	xfs_perag_put(pag);}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:16,


示例14: __xfs_inode_set_eofblocks_tag

static void__xfs_inode_set_eofblocks_tag(	xfs_inode_t	*ip,	void		(*execute)(struct xfs_mount *mp),	void		(*set_tp)(struct xfs_mount *mp, xfs_agnumber_t agno,				  int error, unsigned long caller_ip),	int		tag){	struct xfs_mount *mp = ip->i_mount;	struct xfs_perag *pag;	int tagged;	/*	 * Don't bother locking the AG and looking up in the radix trees	 * if we already know that we have the tag set.	 */	if (ip->i_flags & XFS_IEOFBLOCKS)		return;	spin_lock(&ip->i_flags_lock);	ip->i_flags |= XFS_IEOFBLOCKS;	spin_unlock(&ip->i_flags_lock);	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));	spin_lock(&pag->pag_ici_lock);	tagged = radix_tree_tagged(&pag->pag_ici_root, tag);	radix_tree_tag_set(&pag->pag_ici_root,			   XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino), tag);	if (!tagged) {		/* propagate the eofblocks tag up into the perag radix tree */		spin_lock(&ip->i_mount->m_perag_lock);		radix_tree_tag_set(&ip->i_mount->m_perag_tree,				   XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino),				   tag);		spin_unlock(&ip->i_mount->m_perag_lock);		/* kick off background trimming */		execute(ip->i_mount);		set_tp(ip->i_mount, pag->pag_agno, -1, _RET_IP_);	}	spin_unlock(&pag->pag_ici_lock);	xfs_perag_put(pag);}
开发者ID:BWhitten,项目名称:linux-stable,代码行数:45,


示例15: xfs_reflink_ag_has_free_space

/* * Do we have enough reserve in this AG to handle a reflink?  The refcount * btree already reserved all the space it needs, but the rmap btree can grow * infinitely, so we won't allow more reflinks when the AG is down to the * btree reserves. */static intxfs_reflink_ag_has_free_space(	struct xfs_mount	*mp,	xfs_agnumber_t		agno){	struct xfs_perag	*pag;	int			error = 0;	if (!xfs_sb_version_hasrmapbt(&mp->m_sb))		return 0;	pag = xfs_perag_get(mp, agno);	if (xfs_ag_resv_critical(pag, XFS_AG_RESV_AGFL) ||	    xfs_ag_resv_critical(pag, XFS_AG_RESV_METADATA))		error = -ENOSPC;	xfs_perag_put(pag);	return error;}
开发者ID:oscardagrach,项目名称:linux,代码行数:24,


示例16: xfs_inode_set_reclaim_tag

/* * We set the inode flag atomically with the radix tree tag. * Once we get tag lookups on the radix tree, this inode flag * can go away. */voidxfs_inode_set_reclaim_tag(	struct xfs_inode	*ip){	struct xfs_mount	*mp = ip->i_mount;	struct xfs_perag	*pag;	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));	spin_lock(&pag->pag_ici_lock);	spin_lock(&ip->i_flags_lock);	radix_tree_tag_set(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino),			   XFS_ICI_RECLAIM_TAG);	xfs_perag_set_reclaim_tag(pag);	__xfs_iflags_set(ip, XFS_IRECLAIMABLE);	spin_unlock(&ip->i_flags_lock);	spin_unlock(&pag->pag_ici_lock);	xfs_perag_put(pag);}
开发者ID:BWhitten,项目名称:linux-stable,代码行数:25,


示例17: xfs_refcountbt_set_root

STATIC voidxfs_refcountbt_set_root(	struct xfs_btree_cur	*cur,	union xfs_btree_ptr	*ptr,	int			inc){	struct xfs_buf		*agbp = cur->bc_private.a.agbp;	struct xfs_agf		*agf = XFS_BUF_TO_AGF(agbp);	xfs_agnumber_t		seqno = be32_to_cpu(agf->agf_seqno);	struct xfs_perag	*pag = xfs_perag_get(cur->bc_mp, seqno);	ASSERT(ptr->s != 0);	agf->agf_refcount_root = ptr->s;	be32_add_cpu(&agf->agf_refcount_level, inc);	pag->pagf_refcount_level += inc;	xfs_perag_put(pag);	xfs_alloc_log_agf(cur->bc_tp, agbp,			XFS_AGF_REFCOUNT_ROOT | XFS_AGF_REFCOUNT_LEVEL);}
开发者ID:AshishNamdev,项目名称:linux,代码行数:21,


示例18: xfs_reclaim_inode_shrink

/* * Inode cache shrinker. * * When called we make sure that there is a background (fast) inode reclaim in * progress, while we will throttle the speed of reclaim via doiing synchronous * reclaim of inodes. That means if we come across dirty inodes, we wait for * them to be cleaned, which we hope will not be very long due to the * background walker having already kicked the IO off on those dirty inodes. */static intxfs_reclaim_inode_shrink(	struct shrinker	*shrink,	struct shrink_control *sc){	struct xfs_mount *mp;	struct xfs_perag *pag;	xfs_agnumber_t	ag;	int		reclaimable;	int nr_to_scan = sc->nr_to_scan;	gfp_t gfp_mask = sc->gfp_mask;	mp = container_of(shrink, struct xfs_mount, m_inode_shrink);	if (nr_to_scan) {		/* kick background reclaimer and push the AIL */		xfs_syncd_queue_reclaim(mp);		xfs_ail_push_all(mp->m_ail);		if (!(gfp_mask & __GFP_FS))			return -1;		xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT,					&nr_to_scan);		/* terminate if we don't exhaust the scan */		if (nr_to_scan > 0)			return -1;       }	reclaimable = 0;	ag = 0;	while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) {		ag = pag->pag_agno + 1;		reclaimable += pag->pag_ici_reclaimable;		xfs_perag_put(pag);	}	return reclaimable;}
开发者ID:1yankeedt,项目名称:D710BST_FL24_Kernel,代码行数:46,


示例19: libxfs_initialize_perag

static intlibxfs_initialize_perag(	xfs_mount_t	*mp,	xfs_agnumber_t	agcount,	xfs_agnumber_t	*maxagi){	xfs_agnumber_t	index, max_metadata;	xfs_agnumber_t	first_initialised = 0;	xfs_perag_t	*pag;	xfs_agino_t	agino;	xfs_ino_t	ino;	xfs_sb_t	*sbp = &mp->m_sb;	int		error = -ENOMEM;	/*	 * Walk the current per-ag tree so we don't try to initialise AGs	 * that already exist (growfs case). Allocate and insert all the	 * AGs we don't find ready for initialisation.	 */	for (index = 0; index < agcount; index++) {		pag = xfs_perag_get(mp, index);		if (pag) {			xfs_perag_put(pag);			continue;		}		if (!first_initialised)			first_initialised = index;		pag = kmem_zalloc(sizeof(*pag), KM_MAYFAIL);		if (!pag)			goto out_unwind;		pag->pag_agno = index;		pag->pag_mount = mp;		if (radix_tree_insert(&mp->m_perag_tree, index, pag)) {			error = -EEXIST;			goto out_unwind;		}	}	/*	 * If we mount with the inode64 option, or no inode overflows	 * the legacy 32-bit address space clear the inode32 option.	 */	agino = XFS_OFFBNO_TO_AGINO(mp, sbp->sb_agblocks - 1, 0);	ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino);	if ((mp->m_flags & XFS_MOUNT_SMALL_INUMS) && ino > XFS_MAXINUMBER_32)		mp->m_flags |= XFS_MOUNT_32BITINODES;	else		mp->m_flags &= ~XFS_MOUNT_32BITINODES;	if (mp->m_flags & XFS_MOUNT_32BITINODES) {		/*		 * Calculate how much should be reserved for inodes to meet		 * the max inode percentage.		 */		if (mp->m_maxicount) {			__uint64_t	icount;			icount = sbp->sb_dblocks * sbp->sb_imax_pct;			do_div(icount, 100);			icount += sbp->sb_agblocks - 1;			do_div(icount, sbp->sb_agblocks);			max_metadata = icount;		} else {			max_metadata = agcount;		}		for (index = 0; index < agcount; index++) {			ino = XFS_AGINO_TO_INO(mp, index, agino);			if (ino > XFS_MAXINUMBER_32) {				index++;				break;			}			pag = xfs_perag_get(mp, index);			pag->pagi_inodeok = 1;			if (index < max_metadata)				pag->pagf_metadata = 1;			xfs_perag_put(pag);		}	} else {		for (index = 0; index < agcount; index++) {			pag = xfs_perag_get(mp, index);			pag->pagi_inodeok = 1;			xfs_perag_put(pag);		}	}	if (maxagi)		*maxagi = index;	return 0;out_unwind:	kmem_free(pag);	for (; index > first_initialised; index--) {		pag = radix_tree_delete(&mp->m_perag_tree, index);		kmem_free(pag);	}//.........这里部分代码省略.........
开发者ID:kenhys,项目名称:partclone,代码行数:101,


示例20: xfs_reclaim_inodes_ag

intxfs_reclaim_inodes_ag(	struct xfs_mount	*mp,	int			flags,	int			*nr_to_scan){	struct xfs_perag	*pag;	int			error = 0;	int			last_error = 0;	xfs_agnumber_t		ag;	int			trylock = flags & SYNC_TRYLOCK;	int			skipped;restart:	ag = 0;	skipped = 0;	while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) {		unsigned long	first_index = 0;		int		done = 0;		int		nr_found = 0;		ag = pag->pag_agno + 1;		if (trylock) {			if (!mutex_trylock(&pag->pag_ici_reclaim_lock)) {				skipped++;				xfs_perag_put(pag);				continue;			}			first_index = pag->pag_ici_reclaim_cursor;		} else			mutex_lock(&pag->pag_ici_reclaim_lock);		do {			struct xfs_inode *batch[XFS_LOOKUP_BATCH];			int	i;			rcu_read_lock();			nr_found = radix_tree_gang_lookup_tag(					&pag->pag_ici_root,					(void **)batch, first_index,					XFS_LOOKUP_BATCH,					XFS_ICI_RECLAIM_TAG);			if (!nr_found) {				done = 1;				rcu_read_unlock();				break;			}			for (i = 0; i < nr_found; i++) {				struct xfs_inode *ip = batch[i];				if (done || xfs_reclaim_inode_grab(ip, flags))					batch[i] = NULL;				if (XFS_INO_TO_AGNO(mp, ip->i_ino) !=								pag->pag_agno)					continue;				first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1);				if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino))					done = 1;			}						rcu_read_unlock();			for (i = 0; i < nr_found; i++) {				if (!batch[i])					continue;				error = xfs_reclaim_inode(batch[i], pag, flags);				if (error && last_error != EFSCORRUPTED)					last_error = error;			}			*nr_to_scan -= XFS_LOOKUP_BATCH;			cond_resched();		} while (nr_found && !done && *nr_to_scan > 0);		if (trylock && !done)			pag->pag_ici_reclaim_cursor = first_index;		else			pag->pag_ici_reclaim_cursor = 0;		mutex_unlock(&pag->pag_ici_reclaim_lock);		xfs_perag_put(pag);	}	if (skipped && (flags & SYNC_WAIT) && *nr_to_scan > 0) {		trylock = 0;		goto restart;	}	return XFS_ERROR(last_error);}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:94,


示例21: xrep_calc_ag_resblks

/* * Figure out how many blocks to reserve for an AG repair.  We calculate the * worst case estimate for the number of blocks we'd need to rebuild one of * any type of per-AG btree. */xfs_extlen_txrep_calc_ag_resblks(	struct xfs_scrub		*sc){	struct xfs_mount		*mp = sc->mp;	struct xfs_scrub_metadata	*sm = sc->sm;	struct xfs_perag		*pag;	struct xfs_buf			*bp;	xfs_agino_t			icount = NULLAGINO;	xfs_extlen_t			aglen = NULLAGBLOCK;	xfs_extlen_t			usedlen;	xfs_extlen_t			freelen;	xfs_extlen_t			bnobt_sz;	xfs_extlen_t			inobt_sz;	xfs_extlen_t			rmapbt_sz;	xfs_extlen_t			refcbt_sz;	int				error;	if (!(sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR))		return 0;	pag = xfs_perag_get(mp, sm->sm_agno);	if (pag->pagi_init) {		/* Use in-core icount if possible. */		icount = pag->pagi_count;	} else {		/* Try to get the actual counters from disk. */		error = xfs_ialloc_read_agi(mp, NULL, sm->sm_agno, &bp);		if (!error) {			icount = pag->pagi_count;			xfs_buf_relse(bp);		}	}	/* Now grab the block counters from the AGF. */	error = xfs_alloc_read_agf(mp, NULL, sm->sm_agno, 0, &bp);	if (!error) {		aglen = be32_to_cpu(XFS_BUF_TO_AGF(bp)->agf_length);		freelen = be32_to_cpu(XFS_BUF_TO_AGF(bp)->agf_freeblks);		usedlen = aglen - freelen;		xfs_buf_relse(bp);	}	xfs_perag_put(pag);	/* If the icount is impossible, make some worst-case assumptions. */	if (icount == NULLAGINO ||	    !xfs_verify_agino(mp, sm->sm_agno, icount)) {		xfs_agino_t	first, last;		xfs_agino_range(mp, sm->sm_agno, &first, &last);		icount = last - first + 1;	}	/* If the block counts are impossible, make worst-case assumptions. */	if (aglen == NULLAGBLOCK ||	    aglen != xfs_ag_block_count(mp, sm->sm_agno) ||	    freelen >= aglen) {		aglen = xfs_ag_block_count(mp, sm->sm_agno);		freelen = aglen;		usedlen = aglen;	}	trace_xrep_calc_ag_resblks(mp, sm->sm_agno, icount, aglen,			freelen, usedlen);	/*	 * Figure out how many blocks we'd need worst case to rebuild	 * each type of btree.  Note that we can only rebuild the	 * bnobt/cntbt or inobt/finobt as pairs.	 */	bnobt_sz = 2 * xfs_allocbt_calc_size(mp, freelen);	if (xfs_sb_version_hassparseinodes(&mp->m_sb))		inobt_sz = xfs_iallocbt_calc_size(mp, icount /				XFS_INODES_PER_HOLEMASK_BIT);	else		inobt_sz = xfs_iallocbt_calc_size(mp, icount /				XFS_INODES_PER_CHUNK);	if (xfs_sb_version_hasfinobt(&mp->m_sb))		inobt_sz *= 2;	if (xfs_sb_version_hasreflink(&mp->m_sb))		refcbt_sz = xfs_refcountbt_calc_size(mp, usedlen);	else		refcbt_sz = 0;	if (xfs_sb_version_hasrmapbt(&mp->m_sb)) {		/*		 * Guess how many blocks we need to rebuild the rmapbt.		 * For non-reflink filesystems we can't have more records than		 * used blocks.  However, with reflink it's possible to have		 * more than one rmap record per AG block.  We don't know how		 * many rmaps there could be in the AG, so we start off with		 * what we hope is an generous over-estimation.		 */		if (xfs_sb_version_hasreflink(&mp->m_sb))			rmapbt_sz = xfs_rmapbt_calc_size(mp,					(unsigned long long)aglen * 2);//.........这里部分代码省略.........
开发者ID:avagin,项目名称:linux,代码行数:101,


示例22: xfs_dialloc_ag

//.........这里部分代码省略.........								 &doneright, 0);			}			if (error)				goto error1;		}		/*		 * We've reached the end of the btree. because		 * we are only searching a small chunk of the		 * btree each search, there is obviously free		 * inodes closer to the parent inode than we		 * are now. restart the search again.		 */		pag->pagl_pagino = NULLAGINO;		pag->pagl_leftrec = NULLAGINO;		pag->pagl_rightrec = NULLAGINO;		xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);		xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);		goto restart_pagno;	}	/*	 * In a different AG from the parent.	 * See if the most recently allocated block has any free.	 */newino:	if (agi->agi_newino != cpu_to_be32(NULLAGINO)) {		error = xfs_inobt_lookup(cur, be32_to_cpu(agi->agi_newino),					 XFS_LOOKUP_EQ, &i);		if (error)			goto error0;		if (i == 1) {			error = xfs_inobt_get_rec(cur, &rec, &j);			if (error)				goto error0;			if (j == 1 && rec.ir_freecount > 0) {				/*				 * The last chunk allocated in the group				 * still has a free inode.				 */				goto alloc_inode;			}		}	}	/*	 * None left in the last group, search the whole AG	 */	error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i);	if (error)		goto error0;	XFS_WANT_CORRUPTED_GOTO(i == 1, error0);	for (;;) {		error = xfs_inobt_get_rec(cur, &rec, &i);		if (error)			goto error0;		XFS_WANT_CORRUPTED_GOTO(i == 1, error0);		if (rec.ir_freecount > 0)			break;		error = xfs_btree_increment(cur, 0, &i);		if (error)			goto error0;		XFS_WANT_CORRUPTED_GOTO(i == 1, error0);	}alloc_inode:	offset = xfs_lowbit64(rec.ir_free);	ASSERT(offset >= 0);	ASSERT(offset < XFS_INODES_PER_CHUNK);	ASSERT((XFS_AGINO_TO_OFFSET(mp, rec.ir_startino) %				   XFS_INODES_PER_CHUNK) == 0);	ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino + offset);	rec.ir_free &= ~XFS_INOBT_MASK(offset);	rec.ir_freecount--;	error = xfs_inobt_update(cur, &rec);	if (error)		goto error0;	be32_add_cpu(&agi->agi_freecount, -1);	xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT);	pag->pagi_freecount--;	error = xfs_check_agi_freecount(cur, agi);	if (error)		goto error0;	xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);	xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, -1);	xfs_perag_put(pag);	*inop = ino;	return 0;error1:	xfs_btree_del_cursor(tcur, XFS_BTREE_ERROR);error0:	xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);	xfs_perag_put(pag);	return error;}
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:101,


示例23: xfs_iget

/* * Look up an inode by number in the given file system. * The inode is looked up in the cache held in each AG. * If the inode is found in the cache, initialise the vfs inode * if necessary. * * If it is not in core, read it in from the file system's device, * add it to the cache and initialise the vfs inode. * * The inode is locked according to the value of the lock_flags parameter. * This flag parameter indicates how and if the inode's IO lock and inode lock * should be taken. * * mp -- the mount point structure for the current file system.  It points *       to the inode hash table. * tp -- a pointer to the current transaction if there is one.  This is *       simply passed through to the xfs_iread() call. * ino -- the number of the inode desired.  This is the unique identifier *        within the file system for the inode being requested. * lock_flags -- flags indicating how to lock the inode.  See the comment *		 for xfs_ilock() for a list of valid values. */intxfs_iget(	xfs_mount_t	*mp,	xfs_trans_t	*tp,	xfs_ino_t	ino,	uint		flags,	uint		lock_flags,	xfs_inode_t	**ipp){	xfs_inode_t	*ip;	int		error;	xfs_perag_t	*pag;	xfs_agino_t	agino;	/*	 * xfs_reclaim_inode() uses the ILOCK to ensure an inode	 * doesn't get freed while it's being referenced during a	 * radix tree traversal here.  It assumes this function	 * aqcuires only the ILOCK (and therefore it has no need to	 * involve the IOLOCK in this synchronization).	 */	ASSERT((lock_flags & (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED)) == 0);	/* reject inode numbers outside existing AGs */	if (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount)		return EINVAL;	/* get the perag structure and ensure that it's inode capable */	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino));	agino = XFS_INO_TO_AGINO(mp, ino);again:	error = 0;	rcu_read_lock();	ip = radix_tree_lookup(&pag->pag_ici_root, agino);	if (ip) {		error = xfs_iget_cache_hit(pag, ip, ino, flags, lock_flags);		if (error)			goto out_error_or_again;	} else {		rcu_read_unlock();		XFS_STATS_INC(xs_ig_missed);		error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip,							flags, lock_flags);		if (error)			goto out_error_or_again;	}	xfs_perag_put(pag);	*ipp = ip;	/*	 * If we have a real type for an on-disk inode, we can set ops(&unlock)	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.	 */	if (xfs_iflags_test(ip, XFS_INEW) && ip->i_d.di_mode != 0)		xfs_setup_inode(ip);	return 0;out_error_or_again:	if (error == EAGAIN) {		delay(1);		goto again;	}	xfs_perag_put(pag);	return error;}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:91,


示例24: xfs_dialloc

//.........这里部分代码省略.........				} else					return error;			}			if (ialloced) {				/*				 * We successfully allocated some inodes, return				 * the current context to the caller so that it				 * can commit the current transaction and call				 * us again where we left off.				 */				ASSERT(be32_to_cpu(agi->agi_freecount) > 0);				*alloc_done = B_TRUE;				*IO_agbp = agbp;				*inop = NULLFSINO;				return 0;			}		}		/*		 * If it failed, give up on this ag.		 */		xfs_trans_brelse(tp, agbp);		/*		 * Go on to the next ag: get its ag header.		 */nextag:		if (++tagno == agcount)			tagno = 0;		if (tagno == agno) {			*inop = NULLFSINO;			return noroom ? ENOSPC : 0;		}		pag = xfs_perag_get(mp, tagno);		if (pag->pagi_inodeok == 0) {			xfs_perag_put(pag);			goto nextag;		}		error = xfs_ialloc_read_agi(mp, tp, tagno, &agbp);		xfs_perag_put(pag);		if (error)			goto nextag;		agi = XFS_BUF_TO_AGI(agbp);		ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));	}	/*	 * Here with an allocation group that has a free inode.	 * Reset agno since we may have chosen a new ag in the	 * loop above.	 */	agno = tagno;	*IO_agbp = NULL;	pag = xfs_perag_get(mp, agno); restart_pagno:	cur = xfs_inobt_init_cursor(mp, tp, agbp, be32_to_cpu(agi->agi_seqno));	/*	 * If pagino is 0 (this is the root inode allocation) use newino.	 * This must work because we've just allocated some.	 */	if (!pagino)		pagino = be32_to_cpu(agi->agi_newino);	error = xfs_check_agi_freecount(cur, agi);	if (error)		goto error0;	/*
开发者ID:acuicultor,项目名称:Radioactive-kernel,代码行数:67,


示例25: xfs_ialloc_ag_select

/* * Select an allocation group to look for a free inode in, based on the parent * inode and then mode.  Return the allocation group buffer. */STATIC xfs_buf_t *			/* allocation group buffer */xfs_ialloc_ag_select(	xfs_trans_t	*tp,		/* transaction pointer */	xfs_ino_t	parent,		/* parent directory inode number */	umode_t		mode,		/* bits set to indicate file type */	int		okalloc)	/* ok to allocate more space */{	xfs_buf_t	*agbp;		/* allocation group header buffer */	xfs_agnumber_t	agcount;	/* number of ag's in the filesystem */	xfs_agnumber_t	agno;		/* current ag number */	int		flags;		/* alloc buffer locking flags */	xfs_extlen_t	ineed;		/* blocks needed for inode allocation */	xfs_extlen_t	longest = 0;	/* longest extent available */	xfs_mount_t	*mp;		/* mount point structure */	int		needspace;	/* file mode implies space allocated */	xfs_perag_t	*pag;		/* per allocation group data */	xfs_agnumber_t	pagno;		/* parent (starting) ag number */	/*	 * Files of these types need at least one block if length > 0	 * (and they won't fit in the inode, but that's hard to figure out).	 */	needspace = S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode);	mp = tp->t_mountp;	agcount = mp->m_maxagi;	if (S_ISDIR(mode))		pagno = xfs_ialloc_next_ag(mp);	else {		pagno = XFS_INO_TO_AGNO(mp, parent);		if (pagno >= agcount)			pagno = 0;	}	ASSERT(pagno < agcount);	/*	 * Loop through allocation groups, looking for one with a little	 * free space in it.  Note we don't look for free inodes, exactly.	 * Instead, we include whether there is a need to allocate inodes	 * to mean that blocks must be allocated for them,	 * if none are currently free.	 */	agno = pagno;	flags = XFS_ALLOC_FLAG_TRYLOCK;	for (;;) {		pag = xfs_perag_get(mp, agno);		if (!pag->pagi_init) {			if (xfs_ialloc_read_agi(mp, tp, agno, &agbp)) {				agbp = NULL;				goto nextag;			}		} else			agbp = NULL;		if (!pag->pagi_inodeok) {			xfs_ialloc_next_ag(mp);			goto unlock_nextag;		}		/*		 * Is there enough free space for the file plus a block		 * of inodes (if we need to allocate some)?		 */		ineed = pag->pagi_freecount ? 0 : XFS_IALLOC_BLOCKS(mp);		if (ineed && !pag->pagf_init) {			if (agbp == NULL &&			    xfs_ialloc_read_agi(mp, tp, agno, &agbp)) {				agbp = NULL;				goto nextag;			}			(void)xfs_alloc_pagf_init(mp, tp, agno, flags);		}		if (!ineed || pag->pagf_init) {			if (ineed && !(longest = pag->pagf_longest))				longest = pag->pagf_flcount > 0;			if (!ineed ||			    (pag->pagf_freeblks >= needspace + ineed &&			     longest >= ineed &&			     okalloc)) {				if (agbp == NULL &&				    xfs_ialloc_read_agi(mp, tp, agno, &agbp)) {					agbp = NULL;					goto nextag;				}				xfs_perag_put(pag);				return agbp;			}		}unlock_nextag:		if (agbp)			xfs_trans_brelse(tp, agbp);nextag:		xfs_perag_put(pag);		/*		 * No point in iterating over the rest, if we're shutting		 * down.		 */		if (XFS_FORCED_SHUTDOWN(mp))//.........这里部分代码省略.........
开发者ID:acuicultor,项目名称:Radioactive-kernel,代码行数:101,


示例26: xfs_ialloc_ag_alloc

//.........这里部分代码省略.........		 * For now, just allocate blocks up front.		 */		args.agbno = be32_to_cpu(agi->agi_root);		args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);		/*		 * Allocate a fixed-size extent of inodes.		 */		args.type = XFS_ALLOCTYPE_NEAR_BNO;		args.mod = args.total = args.wasdel = args.isfl =			args.userdata = args.minalignslop = 0;		args.prod = 1;		/*		 * Allow space for the inode btree to split.		 */		args.minleft = args.mp->m_in_maxlevels - 1;		if ((error = xfs_alloc_vextent(&args)))			return error;	}	/*	 * If stripe alignment is turned on, then try again with cluster	 * alignment.	 */	if (isaligned && args.fsbno == NULLFSBLOCK) {		args.type = XFS_ALLOCTYPE_NEAR_BNO;		args.agbno = be32_to_cpu(agi->agi_root);		args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);		args.alignment = xfs_ialloc_cluster_alignment(&args);		if ((error = xfs_alloc_vextent(&args)))			return error;	}	if (args.fsbno == NULLFSBLOCK) {		*alloc = 0;		return 0;	}	ASSERT(args.len == args.minlen);	/*	 * Stamp and write the inode buffers.	 *	 * Seed the new inode cluster with a random generation number. This	 * prevents short-term reuse of generation numbers if a chunk is	 * freed and then immediately reallocated. We use random numbers	 * rather than a linear progression to prevent the next generation	 * number from being easily guessable.	 */	error = xfs_ialloc_inode_init(args.mp, tp, agno, args.agbno,			args.len, prandom_u32());	if (error)		return error;	/*	 * Convert the results.	 */	newino = XFS_OFFBNO_TO_AGINO(args.mp, args.agbno, 0);	be32_add_cpu(&agi->agi_count, newlen);	be32_add_cpu(&agi->agi_freecount, newlen);	pag = xfs_perag_get(args.mp, agno);	pag->pagi_freecount += newlen;	xfs_perag_put(pag);	agi->agi_newino = cpu_to_be32(newino);	/*	 * Insert records describing the new inode chunk into the btree.	 */	cur = xfs_inobt_init_cursor(args.mp, tp, agbp, agno);	for (thisino = newino;	     thisino < newino + newlen;	     thisino += XFS_INODES_PER_CHUNK) {		cur->bc_rec.i.ir_startino = thisino;		cur->bc_rec.i.ir_freecount = XFS_INODES_PER_CHUNK;		cur->bc_rec.i.ir_free = XFS_INOBT_ALL_FREE;		error = xfs_btree_lookup(cur, XFS_LOOKUP_EQ, &i);		if (error) {			xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);			return error;		}		ASSERT(i == 0);		error = xfs_btree_insert(cur, &i);		if (error) {			xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);			return error;		}		ASSERT(i == 1);	}	xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);	/*	 * Log allocation group header fields	 */	xfs_ialloc_log_agi(tp, agbp,		XFS_AGI_COUNT | XFS_AGI_FREECOUNT | XFS_AGI_NEWINO);	/*	 * Modify/log superblock values for inode count and inode free count.	 */	xfs_trans_mod_sb(tp, XFS_TRANS_SB_ICOUNT, (long)newlen);	xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, (long)newlen);	*alloc = 1;	return 0;}
开发者ID:acuicultor,项目名称:Radioactive-kernel,代码行数:101,


示例27: xfs_dialloc

//.........这里部分代码省略.........	/*	 * If we have already hit the ceiling of inode blocks then clear	 * okalloc so we scan all available agi structures for a free	 * inode.	 */	if (mp->m_maxicount &&	    mp->m_sb.sb_icount + XFS_IALLOC_INODES(mp) > mp->m_maxicount) {		noroom = 1;		okalloc = 0;	}	/*	 * Loop until we find an allocation group that either has free inodes	 * or in which we can allocate some inodes.  Iterate through the	 * allocation groups upward, wrapping at the end.	 */	agno = start_agno;	for (;;) {		pag = xfs_perag_get(mp, agno);		if (!pag->pagi_inodeok) {			xfs_ialloc_next_ag(mp);			goto nextag;		}		if (!pag->pagi_init) {			error = xfs_ialloc_pagi_init(mp, tp, agno);			if (error)				goto out_error;		}		/*		 * Do a first racy fast path check if this AG is usable.		 */		if (!pag->pagi_freecount && !okalloc)			goto nextag;		/*		 * Then read in the AGI buffer and recheck with the AGI buffer		 * lock held.		 */		error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);		if (error)			goto out_error;		if (pag->pagi_freecount) {			xfs_perag_put(pag);			goto out_alloc;		}		if (!okalloc)			goto nextag_relse_buffer;		error = xfs_ialloc_ag_alloc(tp, agbp, &ialloced);		if (error) {			xfs_trans_brelse(tp, agbp);			if (error != ENOSPC)				goto out_error;			xfs_perag_put(pag);			*inop = NULLFSINO;			return 0;		}		if (ialloced) {			/*			 * We successfully allocated some inodes, return			 * the current context to the caller so that it			 * can commit the current transaction and call			 * us again where we left off.			 */			ASSERT(pag->pagi_freecount > 0);			xfs_perag_put(pag);			*IO_agbp = agbp;			*inop = NULLFSINO;			return 0;		}nextag_relse_buffer:		xfs_trans_brelse(tp, agbp);nextag:		xfs_perag_put(pag);		if (++agno == mp->m_sb.sb_agcount)			agno = 0;		if (agno == start_agno) {			*inop = NULLFSINO;			return noroom ? ENOSPC : 0;		}	}out_alloc:	*IO_agbp = NULL;	return xfs_dialloc_ag(tp, agbp, parent, inop);out_error:	xfs_perag_put(pag);	return XFS_ERROR(error);}
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:101,


示例28: xfs_reclaim_inodes_ag

/* * Walk the AGs and reclaim the inodes in them. Even if the filesystem is * corrupted, we still want to try to reclaim all the inodes. If we don't, * then a shut down during filesystem unmount reclaim walk leak all the * unreclaimed inodes. */intxfs_reclaim_inodes_ag(	struct xfs_mount	*mp,	int			flags,	int			*nr_to_scan){	struct xfs_perag	*pag;	int			error = 0;	int			last_error = 0;	xfs_agnumber_t		ag;	int			trylock = flags & SYNC_TRYLOCK;	int			skipped;restart:	ag = 0;	skipped = 0;	while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) {		unsigned long	first_index = 0;		int		done = 0;		int		nr_found = 0;		ag = pag->pag_agno + 1;		if (trylock) {			if (!mutex_trylock(&pag->pag_ici_reclaim_lock)) {				skipped++;				xfs_perag_put(pag);				continue;			}			first_index = pag->pag_ici_reclaim_cursor;		} else			mutex_lock(&pag->pag_ici_reclaim_lock);		do {			struct xfs_inode *batch[XFS_LOOKUP_BATCH];			int	i;			rcu_read_lock();			nr_found = radix_tree_gang_lookup_tag(					&pag->pag_ici_root,					(void **)batch, first_index,					XFS_LOOKUP_BATCH,					XFS_ICI_RECLAIM_TAG);			if (!nr_found) {				done = 1;				rcu_read_unlock();				break;			}			/*			 * Grab the inodes before we drop the lock. if we found			 * nothing, nr == 0 and the loop will be skipped.			 */			for (i = 0; i < nr_found; i++) {				struct xfs_inode *ip = batch[i];				if (done || xfs_reclaim_inode_grab(ip, flags))					batch[i] = NULL;				/*				 * Update the index for the next lookup. Catch				 * overflows into the next AG range which can				 * occur if we have inodes in the last block of				 * the AG and we are currently pointing to the				 * last inode.				 *				 * Because we may see inodes that are from the				 * wrong AG due to RCU freeing and				 * reallocation, only update the index if it				 * lies in this AG. It was a race that lead us				 * to see this inode, so another lookup from				 * the same index will not find it again.				 */				if (XFS_INO_TO_AGNO(mp, ip->i_ino) !=								pag->pag_agno)					continue;				first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1);				if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino))					done = 1;			}			/* unlock now we've grabbed the inodes. */			rcu_read_unlock();			for (i = 0; i < nr_found; i++) {				if (!batch[i])					continue;				error = xfs_reclaim_inode(batch[i], pag, flags);				if (error && last_error != EFSCORRUPTED)					last_error = error;			}			*nr_to_scan -= XFS_LOOKUP_BATCH;//.........这里部分代码省略.........
开发者ID:1yankeedt,项目名称:D710BST_FL24_Kernel,代码行数:101,


示例29: xfs_trim_extents

//.........这里部分代码省略.........    xfs_agnumber_t		agno,    xfs_fsblock_t		start,    xfs_fsblock_t		len,    xfs_fsblock_t		minlen,    __uint64_t		*blocks_trimmed){    struct block_device	*bdev = mp->m_ddev_targp->bt_bdev;    struct xfs_btree_cur	*cur;    struct xfs_buf		*agbp;    struct xfs_perag	*pag;    int			error;    int			i;    pag = xfs_perag_get(mp, agno);    error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);    if (error || !agbp)        goto out_put_perag;    cur = xfs_allocbt_init_cursor(mp, NULL, agbp, agno, XFS_BTNUM_CNT);    /*     * Force out the log.  This means any transactions that might have freed     * space before we took the AGF buffer lock are now on disk, and the     * volatile disk cache is flushed.     */    xfs_log_force(mp, XFS_LOG_SYNC);    /*     * Look up the longest btree in the AGF and start with it.     */    error = xfs_alloc_lookup_le(cur, 0,                                XFS_BUF_TO_AGF(agbp)->agf_longest, &i);    if (error)        goto out_del_cursor;    /*     * Loop until we are done with all extents that are large     * enough to be worth discarding.     */    while (i) {        xfs_agblock_t fbno;        xfs_extlen_t flen;        error = xfs_alloc_get_rec(cur, &fbno, &flen, &i);        if (error)            goto out_del_cursor;        XFS_WANT_CORRUPTED_GOTO(i == 1, out_del_cursor);        ASSERT(flen <= XFS_BUF_TO_AGF(agbp)->agf_longest);        /*         * Too small?  Give up.         */        if (flen < minlen) {            trace_xfs_discard_toosmall(mp, agno, fbno, flen);            goto out_del_cursor;        }        /*         * If the extent is entirely outside of the range we are         * supposed to discard skip it.  Do not bother to trim         * down partially overlapping ranges for now.         */        if (XFS_AGB_TO_FSB(mp, agno, fbno) + flen < start ||                XFS_AGB_TO_FSB(mp, agno, fbno) >= start + len) {            trace_xfs_discard_exclude(mp, agno, fbno, flen);            goto next_extent;        }        /*         * If any blocks in the range are still busy, skip the         * discard and try again the next time.         */        if (xfs_alloc_busy_search(mp, agno, fbno, flen)) {            trace_xfs_discard_busy(mp, agno, fbno, flen);            goto next_extent;        }        trace_xfs_discard_extent(mp, agno, fbno, flen);        error = -blkdev_issue_discard(bdev,                                      XFS_AGB_TO_DADDR(mp, agno, fbno),                                      XFS_FSB_TO_BB(mp, flen),                                      GFP_NOFS, 0);        if (error)            goto out_del_cursor;        *blocks_trimmed += flen;next_extent:        error = xfs_btree_decrement(cur, 0, &i);        if (error)            goto out_del_cursor;    }out_del_cursor:    xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);    xfs_buf_relse(agbp);out_put_perag:    xfs_perag_put(pag);    return error;}
开发者ID:Berrrry,项目名称:SPH-L710_NA_Kernel,代码行数:101,


示例30: _xfs_filestream_pick_ag

static int_xfs_filestream_pick_ag(	xfs_mount_t	*mp,	xfs_agnumber_t	startag,	xfs_agnumber_t	*agp,	int		flags,	xfs_extlen_t	minlen){	int		streams, max_streams;	int		err, trylock, nscan;	xfs_extlen_t	longest, free, minfree, maxfree = 0;	xfs_agnumber_t	ag, max_ag = NULLAGNUMBER;	struct xfs_perag *pag;	/* 2% of an AG's blocks must be free for it to be chosen. */	minfree = mp->m_sb.sb_agblocks / 50;	ag = startag;	*agp = NULLAGNUMBER;	/* For the first pass, don't sleep trying to init the per-AG. */	trylock = XFS_ALLOC_FLAG_TRYLOCK;	for (nscan = 0; 1; nscan++) {		pag = xfs_perag_get(mp, ag);		TRACE_AG_SCAN(mp, ag, atomic_read(&pag->pagf_fstrms));		if (!pag->pagf_init) {			err = xfs_alloc_pagf_init(mp, NULL, ag, trylock);			if (err && !trylock) {				xfs_perag_put(pag);				return err;			}		}		/* Might fail sometimes during the 1st pass with trylock set. */		if (!pag->pagf_init)			goto next_ag;		/* Keep track of the AG with the most free blocks. */		if (pag->pagf_freeblks > maxfree) {			maxfree = pag->pagf_freeblks;			max_streams = atomic_read(&pag->pagf_fstrms);			max_ag = ag;		}		/*		 * The AG reference count does two things: it enforces mutual		 * exclusion when examining the suitability of an AG in this		 * loop, and it guards against two filestreams being established		 * in the same AG as each other.		 */		if (xfs_filestream_get_ag(mp, ag) > 1) {			xfs_filestream_put_ag(mp, ag);			goto next_ag;		}		longest = xfs_alloc_longest_free_extent(mp, pag);		if (((minlen && longest >= minlen) ||		     (!minlen && pag->pagf_freeblks >= minfree)) &&		    (!pag->pagf_metadata || !(flags & XFS_PICK_USERDATA) ||		     (flags & XFS_PICK_LOWSPACE))) {			/* Break out, retaining the reference on the AG. */			free = pag->pagf_freeblks;			streams = atomic_read(&pag->pagf_fstrms);			xfs_perag_put(pag);			*agp = ag;			break;		}		/* Drop the reference on this AG, it's not usable. */		xfs_filestream_put_ag(mp, ag);next_ag:		xfs_perag_put(pag);		/* Move to the next AG, wrapping to AG 0 if necessary. */		if (++ag >= mp->m_sb.sb_agcount)			ag = 0;		/* If a full pass of the AGs hasn't been done yet, continue. */		if (ag != startag)			continue;		/* Allow sleeping in xfs_alloc_pagf_init() on the 2nd pass. */		if (trylock != 0) {			trylock = 0;			continue;		}		/* Finally, if lowspace wasn't set, set it for the 3rd pass. */		if (!(flags & XFS_PICK_LOWSPACE)) {			flags |= XFS_PICK_LOWSPACE;			continue;		}		/*		 * Take the AG with the most free space, regardless of whether		 * it's already in use by another filestream.		 */		if (max_ag != NULLAGNUMBER) {//.........这里部分代码省略.........
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:101,



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


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