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

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

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

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

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

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


示例16: _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;		minfree = mp->m_sb.sb_agblocks / 50;	ag = startag;	*agp = NULLAGNUMBER;		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;			}		}				if (!pag->pagf_init)			goto next_ag;				if (pag->pagf_freeblks > maxfree) {			maxfree = pag->pagf_freeblks;			max_streams = atomic_read(&pag->pagf_fstrms);			max_ag = ag;		}		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))) {						free = pag->pagf_freeblks;			streams = atomic_read(&pag->pagf_fstrms);			xfs_perag_put(pag);			*agp = ag;			break;		}				xfs_filestream_put_ag(mp, ag);next_ag:		xfs_perag_put(pag);				if (++ag >= mp->m_sb.sb_agcount)			ag = 0;				if (ag != startag)			continue;				if (trylock != 0) {			trylock = 0;			continue;		}				if (!(flags & XFS_PICK_LOWSPACE)) {			flags |= XFS_PICK_LOWSPACE;			continue;		}		if (max_ag != NULLAGNUMBER) {			xfs_filestream_get_ag(mp, max_ag);			TRACE_AG_PICK1(mp, max_ag, maxfree);			streams = max_streams;			free = maxfree;			*agp = max_ag;			break;		}				TRACE_AG_PICK1(mp, max_ag, maxfree);//.........这里部分代码省略.........
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:101,


示例17: xfs_filestream_pick_ag

/* * Scan the AGs starting at startag looking for an AG that isn't in use and has * at least minlen blocks free. */static intxfs_filestream_pick_ag(	struct xfs_inode	*ip,	xfs_agnumber_t		startag,	xfs_agnumber_t		*agp,	int			flags,	xfs_extlen_t		minlen){	struct xfs_mount	*mp = ip->i_mount;	struct xfs_fstrm_item	*item;	struct xfs_perag	*pag;	xfs_extlen_t		longest, free = 0, minfree, maxfree = 0;	xfs_agnumber_t		ag, max_ag = NULLAGNUMBER;	int			err, trylock, nscan;	ASSERT(S_ISDIR(ip->i_d.di_mode));	/* 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++) {		trace_xfs_filestream_scan(ip, ag);		pag = xfs_perag_get(mp, ag);		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_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;			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;		}//.........这里部分代码省略.........
开发者ID:MaxChina,项目名称:linux,代码行数:101,


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


示例19: xfs_dialloc

//.........这里部分代码省略.........					*inop = NULLFSINO;					return 0;				} 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,


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


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


示例22: build_agf_agfl

//.........这里部分代码省略.........	/*	 * do we have left-over blocks in the btree cursors that should	 * be used to fill the AGFL?	 */	if (bno_bt->num_free_blocks > 0 || bcnt_bt->num_free_blocks > 0)  {		/*		 * yes, now grab as many blocks as we can		 */		i = j = 0;		while (bno_bt->num_free_blocks > 0 && i < XFS_AGFL_SIZE(mp))  {			freelist[i] = cpu_to_be32(					get_next_blockaddr(agno, 0, bno_bt));			i++;		}		while (bcnt_bt->num_free_blocks > 0 && i < XFS_AGFL_SIZE(mp))  {			freelist[i] = cpu_to_be32(					get_next_blockaddr(agno, 0, bcnt_bt));			i++;		}		/*		 * now throw the rest of the blocks away and complain		 */		while (bno_bt->num_free_blocks > 0)  {			(void) get_next_blockaddr(agno, 0, bno_bt);			j++;		}		while (bcnt_bt->num_free_blocks > 0)  {			(void) get_next_blockaddr(agno, 0, bcnt_bt);			j++;		}		if (j > 0)  {			if (j == lostblocks)				do_warn(_("lost %d blocks in ag %u/n"),					j, agno);			else				do_warn(_("thought we were going to lose %d "					  "blocks in ag %u, actually lost "					  "%d/n"),					lostblocks, j, agno);		}		agf->agf_flfirst = 0;		agf->agf_fllast = cpu_to_be32(i - 1);		agf->agf_flcount = cpu_to_be32(i);#ifdef XR_BLD_FREE_TRACE		fprintf(stderr, "writing agfl for ag %u/n", agno);#endif	} else  {		agf->agf_flfirst = 0;		agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);		agf->agf_flcount = 0;	}	libxfs_writebuf(agfl_buf, 0);	ext_ptr = findbiggest_bcnt_extent(agno);	agf->agf_longest = cpu_to_be32((ext_ptr != NULL) ?						ext_ptr->ex_blockcount : 0);	ASSERT(be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNOi]) !=		be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNTi]));	libxfs_writebuf(agf_buf, 0);	/*	 * now fix up the free list appropriately	 * XXX: code lifted from mkfs, should be shared.	 */	{		xfs_alloc_arg_t	args;		xfs_trans_t	*tp;		struct xfs_trans_res tres = {0};		int		error;		memset(&args, 0, sizeof(args));		args.tp = tp = libxfs_trans_alloc(mp, 0);		args.mp = mp;		args.agno = agno;		args.alignment = 1;		args.pag = xfs_perag_get(mp,agno);		libxfs_trans_reserve(tp, &tres,				     xfs_alloc_min_freelist(mp, args.pag), 0);		error = libxfs_alloc_fix_freelist(&args, 0);		xfs_perag_put(args.pag);		if (error) {			do_error(_("failed to fix AGFL on AG %d, error %d/n"),					agno, error);		}		libxfs_trans_commit(tp);	}#ifdef XR_BLD_FREE_TRACE	fprintf(stderr, "wrote agf for ag %u/n", agno);#endif}
开发者ID:chandanr,项目名称:xfsprogs-dev,代码行数:101,


示例23: xfs_trim_extents

STATIC intxfs_trim_extents(    struct xfs_mount	*mp,    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://.........这里部分代码省略.........
开发者ID:Berrrry,项目名称:SPH-L710_NA_Kernel,代码行数:101,


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


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


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


示例27: xfs_dialloc_ag

/* * Allocate an inode. * * The caller selected an AG for us, and made sure that free inodes are * available. */STATIC intxfs_dialloc_ag(	struct xfs_trans	*tp,	struct xfs_buf		*agbp,	xfs_ino_t		parent,	xfs_ino_t		*inop){	struct xfs_mount	*mp = tp->t_mountp;	struct xfs_agi		*agi = XFS_BUF_TO_AGI(agbp);	xfs_agnumber_t		agno = be32_to_cpu(agi->agi_seqno);	xfs_agnumber_t		pagno = XFS_INO_TO_AGNO(mp, parent);	xfs_agino_t		pagino = XFS_INO_TO_AGINO(mp, parent);	struct xfs_perag	*pag;	struct xfs_btree_cur	*cur, *tcur;	struct xfs_inobt_rec_incore rec, trec;	xfs_ino_t		ino;	int			error;	int			offset;	int			i, j;	pag = xfs_perag_get(mp, agno);	ASSERT(pag->pagi_init);	ASSERT(pag->pagi_inodeok);	ASSERT(pag->pagi_freecount > 0); restart_pagno:	cur = xfs_inobt_init_cursor(mp, tp, agbp, agno);	/*	 * 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;	/*	 * If in the same AG as the parent, try to get near the parent.	 */	if (pagno == agno) {		int		doneleft;	/* done, to the left */		int		doneright;	/* done, to the right */		int		searchdistance = 10;		error = xfs_inobt_lookup(cur, pagino, XFS_LOOKUP_LE, &i);		if (error)			goto error0;		XFS_WANT_CORRUPTED_GOTO(i == 1, error0);		error = xfs_inobt_get_rec(cur, &rec, &j);		if (error)			goto error0;		XFS_WANT_CORRUPTED_GOTO(i == 1, error0);		if (rec.ir_freecount > 0) {			/*			 * Found a free inode in the same chunk			 * as the parent, done.			 */			goto alloc_inode;		}		/*		 * In the same AG as parent, but parent's chunk is full.		 */		/* duplicate the cursor, search left & right simultaneously */		error = xfs_btree_dup_cursor(cur, &tcur);		if (error)			goto error0;		/*		 * Skip to last blocks looked up if same parent inode.		 */		if (pagino != NULLAGINO &&		    pag->pagl_pagino == pagino &&		    pag->pagl_leftrec != NULLAGINO &&		    pag->pagl_rightrec != NULLAGINO) {			error = xfs_ialloc_get_rec(tcur, pag->pagl_leftrec,						   &trec, &doneleft);			if (error)				goto error1;			error = xfs_ialloc_get_rec(cur, pag->pagl_rightrec,						   &rec, &doneright);			if (error)				goto error1;		} else {			/* search left with tcur, back up 1 record */			error = xfs_ialloc_next_rec(tcur, &trec, &doneleft, 1);//.........这里部分代码省略.........
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:101,


示例28: xfs_dialloc

/* * Allocate an inode on disk. * * Mode is used to tell whether the new inode will need space, and whether it * is a directory. * * This function is designed to be called twice if it has to do an allocation * to make more free inodes.  On the first call, *IO_agbp should be set to NULL. * If an inode is available without having to performn an allocation, an inode * number is returned.  In this case, *IO_agbp is set to NULL.  If an allocation * needs to be done, xfs_dialloc returns the current AGI buffer in *IO_agbp. * The caller should then commit the current transaction, allocate a * new transaction, and call xfs_dialloc() again, passing in the previous value * of *IO_agbp.  IO_agbp should be held across the transactions. Since the AGI * buffer is locked across the two calls, the second call is guaranteed to have * a free inode available. * * Once we successfully pick an inode its number is returned and the on-disk * data structures are updated.  The inode itself is not read in, since doing so * would break ordering constraints with xfs_reclaim. */intxfs_dialloc(	struct xfs_trans	*tp,	xfs_ino_t		parent,	umode_t			mode,	int			okalloc,	struct xfs_buf		**IO_agbp,	xfs_ino_t		*inop){	struct xfs_mount	*mp = tp->t_mountp;	struct xfs_buf		*agbp;	xfs_agnumber_t		agno;	int			error;	int			ialloced;	int			noroom = 0;	xfs_agnumber_t		start_agno;	struct xfs_perag	*pag;	if (*IO_agbp) {		/*		 * If the caller passes in a pointer to the AGI buffer,		 * continue where we left off before.  In this case, we		 * know that the allocation group has free inodes.		 */		agbp = *IO_agbp;		goto out_alloc;	}	/*	 * We do not have an agbp, so select an initial allocation	 * group for inode allocation.	 */	start_agno = xfs_ialloc_ag_select(tp, parent, mode, okalloc);	if (start_agno == NULLAGNUMBER) {		*inop = NULLFSINO;		return 0;	}	/*	 * 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);//.........这里部分代码省略.........
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:101,



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


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