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

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

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

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

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

示例1: xfs_attr_rmtval_get

/* * Read the value associated with an attribute from the out-of-line buffer * that we stored it in. */intxfs_attr_rmtval_get(	struct xfs_da_args	*args){	struct xfs_bmbt_irec	map[ATTR_RMTVALUE_MAPSIZE];	struct xfs_mount	*mp = args->dp->i_mount;	struct xfs_buf		*bp;	xfs_dablk_t		lblkno = args->rmtblkno;	__uint8_t		*dst = args->value;	int			valuelen;	int			nmap;	int			error;	int			blkcnt = args->rmtblkcnt;	int			i;	int			offset = 0;	trace_xfs_attr_rmtval_get(args);	ASSERT(!(args->flags & ATTR_KERNOVAL));	ASSERT(args->rmtvaluelen == args->valuelen);	valuelen = args->rmtvaluelen;	while (valuelen > 0) {		nmap = ATTR_RMTVALUE_MAPSIZE;		error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,				       blkcnt, map, &nmap,				       XFS_BMAPI_ATTRFORK);		if (error)			return error;		ASSERT(nmap >= 1);		for (i = 0; (i < nmap) && (valuelen > 0); i++) {			xfs_daddr_t	dblkno;			int		dblkcnt;			ASSERT((map[i].br_startblock != DELAYSTARTBLOCK) &&			       (map[i].br_startblock != HOLESTARTBLOCK));			dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);			dblkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);			error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,						   dblkno, dblkcnt, 0, &bp,						   &xfs_attr3_rmt_buf_ops);			if (error)				return error;			error = xfs_attr_rmtval_copyout(mp, bp, args->dp->i_ino,							&offset, &valuelen,							&dst);			xfs_buf_relse(bp);			if (error)				return error;			/* roll attribute extent map forwards */			lblkno += map[i].br_blockcount;			blkcnt -= map[i].br_blockcount;		}	}	ASSERT(valuelen == 0);	return 0;}
开发者ID:3null,项目名称:linux,代码行数:64,


示例2: xfs_dquot_disk_read

/* * Read in the in-core dquot's on-disk metadata and return the buffer. * Returns ENOENT to signal a hole. */STATIC intxfs_dquot_disk_read(	struct xfs_mount	*mp,	struct xfs_dquot	*dqp,	struct xfs_buf		**bpp){	struct xfs_bmbt_irec	map;	struct xfs_buf		*bp;	struct xfs_inode	*quotip = xfs_quota_inode(mp, dqp->dq_flags);	uint			lock_mode;	int			nmaps = 1;	int			error;	lock_mode = xfs_ilock_data_map_shared(quotip);	if (!xfs_this_quota_on(mp, dqp->dq_flags)) {		/*		 * Return if this type of quotas is turned off while we		 * didn't have the quota inode lock.		 */		xfs_iunlock(quotip, lock_mode);		return -ESRCH;	}	/*	 * Find the block map; no allocations yet	 */	error = xfs_bmapi_read(quotip, dqp->q_fileoffset,			XFS_DQUOT_CLUSTER_SIZE_FSB, &map, &nmaps, 0);	xfs_iunlock(quotip, lock_mode);	if (error)		return error;	ASSERT(nmaps == 1);	ASSERT(map.br_blockcount >= 1);	ASSERT(map.br_startblock != DELAYSTARTBLOCK);	if (map.br_startblock == HOLESTARTBLOCK)		return -ENOENT;	trace_xfs_dqtobp_read(dqp);	/*	 * store the blkno etc so that we don't have to do the	 * mapping all the time	 */	dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock);	error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno,			mp->m_quotainfo->qi_dqchunklen, 0, &bp,			&xfs_dquot_buf_ops);	if (error) {		ASSERT(bp == NULL);		return error;	}	ASSERT(xfs_buf_islocked(bp));	xfs_buf_set_ref(bp, XFS_DQUOT_REF);	*bpp = bp;	return 0;}
开发者ID:avagin,项目名称:linux,代码行数:64,


示例3: error

/* * This routine is called to handle zeroing any space in the last block of the * file that is beyond the EOF.  We do this since the size is being increased * without writing anything to that block and we don't want to read the * garbage on the disk. */STATIC int				/* error (positive) */xfs_zero_last_block(	struct xfs_inode	*ip,	xfs_fsize_t		offset,	xfs_fsize_t		isize){	struct xfs_mount	*mp = ip->i_mount;	xfs_fileoff_t		last_fsb = XFS_B_TO_FSBT(mp, isize);	int			zero_offset = XFS_B_FSB_OFFSET(mp, isize);	int			zero_len;	int			nimaps = 1;	int			error = 0;	struct xfs_bmbt_irec	imap;	xfs_ilock(ip, XFS_ILOCK_EXCL);	error = xfs_bmapi_read(ip, last_fsb, 1, &imap, &nimaps, 0);	xfs_iunlock(ip, XFS_ILOCK_EXCL);	if (error)		return error;	ASSERT(nimaps > 0);	/*	 * If the block underlying isize is just a hole, then there	 * is nothing to zero.	 */	if (imap.br_startblock == HOLESTARTBLOCK)		return 0;	zero_len = mp->m_sb.sb_blocksize - zero_offset;	if (isize + zero_len > offset)		zero_len = offset - isize;	return xfs_iozero(ip, isize, zero_len);}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:40,


示例4: xfs_rtbuf_get

/* * Get a buffer for the bitmap or summary file block specified. * The buffer is returned read and locked. */intxfs_rtbuf_get(	xfs_mount_t	*mp,		/* file system mount structure */	xfs_trans_t	*tp,		/* transaction pointer */	xfs_rtblock_t	block,		/* block number in bitmap or summary */	int		issum,		/* is summary not bitmap */	xfs_buf_t	**bpp)		/* output: buffer for the block */{	xfs_buf_t	*bp;		/* block buffer, result */	xfs_inode_t	*ip;		/* bitmap or summary inode */	xfs_bmbt_irec_t	map;	int		nmap = 1;	int		error;		/* error value */	ip = issum ? mp->m_rsumip : mp->m_rbmip;	error = xfs_bmapi_read(ip, block, 1, &map, &nmap, XFS_DATA_FORK);	if (error)		return error;	if (nmap == 0 || !xfs_bmap_is_real_extent(&map))		return -EFSCORRUPTED;	ASSERT(map.br_startblock != NULLFSBLOCK);	error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,				   XFS_FSB_TO_DADDR(mp, map.br_startblock),				   mp->m_bsize, 0, &bp, &xfs_rtbuf_ops);	if (error)		return error;	xfs_trans_buf_set_type(tp, bp, issum ? XFS_BLFT_RTSUMMARY_BUF					     : XFS_BLFT_RTBITMAP_BUF);	*bpp = bp;	return 0;}
开发者ID:Lyude,项目名称:linux,代码行数:39,


示例5: xfs_reflink_remap_blocks

/* * Iteratively remap one file's extents (and holes) to another's. */STATIC intxfs_reflink_remap_blocks(	struct xfs_inode	*src,	xfs_fileoff_t		srcoff,	struct xfs_inode	*dest,	xfs_fileoff_t		destoff,	xfs_filblks_t		len,	xfs_off_t		new_isize){	struct xfs_bmbt_irec	imap;	int			nimaps;	int			error = 0;	xfs_filblks_t		range_len;	/* drange = (destoff, destoff + len); srange = (srcoff, srcoff + len) */	while (len) {		trace_xfs_reflink_remap_blocks_loop(src, srcoff, len,				dest, destoff);		/* Read extent from the source file */		nimaps = 1;		xfs_ilock(src, XFS_ILOCK_EXCL);		error = xfs_bmapi_read(src, srcoff, len, &imap, &nimaps, 0);		xfs_iunlock(src, XFS_ILOCK_EXCL);		if (error)			goto err;		ASSERT(nimaps == 1);		trace_xfs_reflink_remap_imap(src, srcoff, len, XFS_IO_OVERWRITE,				&imap);		/* Translate imap into the destination file. */		range_len = imap.br_startoff + imap.br_blockcount - srcoff;		imap.br_startoff += destoff - srcoff;		/* Clear dest from destoff to the end of imap and map it in. */		error = xfs_reflink_remap_extent(dest, &imap, destoff,				new_isize);		if (error)			goto err;		if (fatal_signal_pending(current)) {			error = -EINTR;			goto err;		}		/* Advance drange/srange */		srcoff += range_len;		destoff += range_len;		len -= range_len;	}	return 0;err:	trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_);	return error;}
开发者ID:oscardagrach,项目名称:linux,代码行数:60,


示例6: xfs_map_blocks

STATIC intxfs_map_blocks(	struct inode		*inode,	loff_t			offset,	struct xfs_bmbt_irec	*imap,	int			type){	struct xfs_inode	*ip = XFS_I(inode);	struct xfs_mount	*mp = ip->i_mount;	ssize_t			count = 1 << inode->i_blkbits;	xfs_fileoff_t		offset_fsb, end_fsb;	int			error = 0;	int			bmapi_flags = XFS_BMAPI_ENTIRE;	int			nimaps = 1;	if (XFS_FORCED_SHUTDOWN(mp))		return -EIO;	if (type == XFS_IO_UNWRITTEN)		bmapi_flags |= XFS_BMAPI_IGSTATE;	xfs_ilock(ip, XFS_ILOCK_SHARED);	ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||	       (ip->i_df.if_flags & XFS_IFEXTENTS));	ASSERT(offset <= mp->m_super->s_maxbytes);	if (offset + count > mp->m_super->s_maxbytes)		count = mp->m_super->s_maxbytes - offset;	end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);	offset_fsb = XFS_B_TO_FSBT(mp, offset);	error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb,				imap, &nimaps, bmapi_flags);	xfs_iunlock(ip, XFS_ILOCK_SHARED);	if (error)		return error;	if (type == XFS_IO_DELALLOC &&	    (!nimaps || isnullstartblock(imap->br_startblock))) {		error = xfs_iomap_write_allocate(ip, offset, imap);		if (!error)			trace_xfs_map_blocks_alloc(ip, offset, count, type, imap);		return error;	}#ifdef DEBUG	if (type == XFS_IO_UNWRITTEN) {		ASSERT(nimaps);		ASSERT(imap->br_startblock != HOLESTARTBLOCK);		ASSERT(imap->br_startblock != DELAYSTARTBLOCK);	}#endif	if (nimaps)		trace_xfs_map_blocks_found(ip, offset, count, type, imap);	return 0;}
开发者ID:020gzh,项目名称:linux,代码行数:56,


示例7: xfs_zero_last_block

STATIC intxfs_zero_last_block(    xfs_inode_t	*ip,    xfs_fsize_t	offset,    xfs_fsize_t	isize){    xfs_fileoff_t	last_fsb;    xfs_mount_t	*mp = ip->i_mount;    int		nimaps;    int		zero_offset;    int		zero_len;    int		error = 0;    xfs_bmbt_irec_t	imap;    ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));    zero_offset = XFS_B_FSB_OFFSET(mp, isize);    if (zero_offset == 0) {        return 0;    }    last_fsb = XFS_B_TO_FSBT(mp, isize);    nimaps = 1;    error = xfs_bmapi_read(ip, last_fsb, 1, &imap, &nimaps, 0);    if (error)        return error;    ASSERT(nimaps > 0);    if (imap.br_startblock == HOLESTARTBLOCK) {        return 0;    }    xfs_iunlock(ip, XFS_ILOCK_EXCL);    zero_len = mp->m_sb.sb_blocksize - zero_offset;    if (isize + zero_len > offset)        zero_len = offset - isize;    error = xfs_iozero(ip, isize, zero_len);    xfs_ilock(ip, XFS_ILOCK_EXCL);    ASSERT(error >= 0);    return error;}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:41,


示例8: xfs_pnfs_validate_isize

/* * Ensure the size update falls into a valid allocated block. */static intxfs_pnfs_validate_isize(	struct xfs_inode	*ip,	xfs_off_t		isize){	struct xfs_bmbt_irec	imap;	int			nimaps = 1;	int			error = 0;	xfs_ilock(ip, XFS_ILOCK_SHARED);	error = xfs_bmapi_read(ip, XFS_B_TO_FSBT(ip->i_mount, isize - 1), 1,				&imap, &nimaps, 0);	xfs_iunlock(ip, XFS_ILOCK_SHARED);	if (error)		return error;	if (imap.br_startblock == HOLESTARTBLOCK ||	    imap.br_startblock == DELAYSTARTBLOCK ||	    imap.br_state == XFS_EXT_UNWRITTEN)		return -EIO;	return 0;}
开发者ID:513855417,项目名称:linux,代码行数:25,


示例9: xfs_attr_rmtval_remove

/* * Remove the value associated with an attribute by deleting the * out-of-line buffer that it is stored on. */intxfs_attr_rmtval_remove(	struct xfs_da_args	*args){	struct xfs_mount	*mp = args->dp->i_mount;	xfs_dablk_t		lblkno;	int			blkcnt;	int			error;	int			done;	trace_xfs_attr_rmtval_remove(args);	/*	 * Roll through the "value", invalidating the attribute value's blocks.	 */	lblkno = args->rmtblkno;	blkcnt = args->rmtblkcnt;	while (blkcnt > 0) {		struct xfs_bmbt_irec	map;		struct xfs_buf		*bp;		xfs_daddr_t		dblkno;		int			dblkcnt;		int			nmap;		/*		 * Try to remember where we decided to put the value.		 */		nmap = 1;		error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,				       blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK);		if (error)			return error;		ASSERT(nmap == 1);		ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&		       (map.br_startblock != HOLESTARTBLOCK));		dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),		dblkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);		/*		 * If the "remote" value is in the cache, remove it.		 */		bp = xfs_incore(mp->m_ddev_targp, dblkno, dblkcnt, XBF_TRYLOCK);		if (bp) {			xfs_buf_stale(bp);			xfs_buf_relse(bp);			bp = NULL;		}		lblkno += map.br_blockcount;		blkcnt -= map.br_blockcount;	}	/*	 * Keep de-allocating extents until the remote-value region is gone.	 */	lblkno = args->rmtblkno;	blkcnt = args->rmtblkcnt;	done = 0;	while (!done) {		int committed;		xfs_bmap_init(args->flist, args->firstblock);		error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,				    XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,				    1, args->firstblock, args->flist,				    &done);		if (!error) {			error = xfs_bmap_finish(&args->trans, args->flist,						&committed);		}		if (error) {			ASSERT(committed);			args->trans = NULL;			xfs_bmap_cancel(args->flist);			return error;		}		/*		 * bmap_finish() may have committed the last trans and started		 * a new one.  We need the inode to be in all transactions.		 */		if (committed)			xfs_trans_ijoin(args->trans, args->dp, 0);		/*		 * Close out trans and start the next one in the chain.		 */		error = xfs_trans_roll(&args->trans, args->dp);		if (error)			return error;	}	return 0;}
开发者ID:3null,项目名称:linux,代码行数:98,


示例10: xfs_readlink_bmap

/* ----- Kernel only functions below ----- */STATIC intxfs_readlink_bmap(	struct xfs_inode	*ip,	char			*link){	struct xfs_mount	*mp = ip->i_mount;	struct xfs_bmbt_irec	mval[XFS_SYMLINK_MAPS];	struct xfs_buf		*bp;	xfs_daddr_t		d;	char			*cur_chunk;	int			pathlen = ip->i_d.di_size;	int			nmaps = XFS_SYMLINK_MAPS;	int			byte_cnt;	int			n;	int			error = 0;	int			fsblocks = 0;	int			offset;	fsblocks = xfs_symlink_blocks(mp, pathlen);	error = xfs_bmapi_read(ip, 0, fsblocks, mval, &nmaps, 0);	if (error)		goto out;	offset = 0;	for (n = 0; n < nmaps; n++) {		d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);		byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);		bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0,				  &xfs_symlink_buf_ops);		if (!bp)			return XFS_ERROR(ENOMEM);		error = bp->b_error;		if (error) {			xfs_buf_ioerror_alert(bp, __func__);			xfs_buf_relse(bp);			/* bad CRC means corrupted metadata */			if (error == EFSBADCRC)				error = EFSCORRUPTED;			goto out;		}		byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);		if (pathlen < byte_cnt)			byte_cnt = pathlen;		cur_chunk = bp->b_addr;		if (xfs_sb_version_hascrc(&mp->m_sb)) {			if (!xfs_symlink_hdr_ok(mp, ip->i_ino, offset,							byte_cnt, bp)) {				error = EFSCORRUPTED;				xfs_alert(mp,"symlink header does not match required off/len/owner (0x%x/Ox%x,0x%llx)",					offset, byte_cnt, ip->i_ino);				xfs_buf_relse(bp);				goto out;			}			cur_chunk += sizeof(struct xfs_dsymlink_hdr);		}		memcpy(link + offset, bp->b_addr, byte_cnt);		pathlen -= byte_cnt;		offset += byte_cnt;		xfs_buf_relse(bp);	}	ASSERT(pathlen == 0);	link[ip->i_d.di_size] = '/0';	error = 0; out:	return error;}
开发者ID:spacex,项目名称:kernel-centos7,代码行数:78,


示例11: xfs_free_eofblocks

/* * This is called by xfs_inactive to free any blocks beyond eof * when the link count isn't zero and by xfs_dm_punch_hole() when * punching a hole to EOF. */intxfs_free_eofblocks(	xfs_mount_t	*mp,	xfs_inode_t	*ip,	bool		need_iolock){	xfs_trans_t	*tp;	int		error;	xfs_fileoff_t	end_fsb;	xfs_fileoff_t	last_fsb;	xfs_filblks_t	map_len;	int		nimaps;	xfs_bmbt_irec_t	imap;	/*	 * Figure out if there are any blocks beyond the end	 * of the file.  If not, then there is nothing to do.	 */	end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip));	last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);	if (last_fsb <= end_fsb)		return 0;	map_len = last_fsb - end_fsb;	nimaps = 1;	xfs_ilock(ip, XFS_ILOCK_SHARED);	error = xfs_bmapi_read(ip, end_fsb, map_len, &imap, &nimaps, 0);	xfs_iunlock(ip, XFS_ILOCK_SHARED);	if (!error && (nimaps != 0) &&	    (imap.br_startblock != HOLESTARTBLOCK ||	     ip->i_delayed_blks)) {		/*		 * Attach the dquots to the inode up front.		 */		error = xfs_qm_dqattach(ip, 0);		if (error)			return error;		/*		 * There are blocks after the end of file.		 * Free them up now by truncating the file to		 * its current size.		 */		tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);		if (need_iolock) {			if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {				xfs_trans_cancel(tp, 0);				return EAGAIN;			}		}		error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);		if (error) {			ASSERT(XFS_FORCED_SHUTDOWN(mp));			xfs_trans_cancel(tp, 0);			if (need_iolock)				xfs_iunlock(ip, XFS_IOLOCK_EXCL);			return error;		}		xfs_ilock(ip, XFS_ILOCK_EXCL);		xfs_trans_ijoin(tp, ip, 0);		/*		 * Do not update the on-disk file size.  If we update the		 * on-disk file size and then the system crashes before the		 * contents of the file are flushed to disk then the files		 * may be full of holes (ie NULL files bug).		 */		error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK,					      XFS_ISIZE(ip));		if (error) {			/*			 * If we get an error at this point we simply don't			 * bother truncating the file.			 */			xfs_trans_cancel(tp,					 (XFS_TRANS_RELEASE_LOG_RES |					  XFS_TRANS_ABORT));		} else {			error = xfs_trans_commit(tp,						XFS_TRANS_RELEASE_LOG_RES);			if (!error)				xfs_inode_clear_eofblocks_tag(ip);		}		xfs_iunlock(ip, XFS_ILOCK_EXCL);		if (need_iolock)			xfs_iunlock(ip, XFS_IOLOCK_EXCL);	}	return error;}
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:99,


示例12: xfs_getbmap

//.........这里部分代码省略.........	/*	 * Don't let nex be bigger than the number of extents	 * we can have assuming alternating holes and real extents.	 */	if (nex > XFS_IFORK_NEXTENTS(ip, whichfork) * 2 + 1)		nex = XFS_IFORK_NEXTENTS(ip, whichfork) * 2 + 1;	bmapi_flags = xfs_bmapi_aflag(whichfork);	if (!(iflags & BMV_IF_PREALLOC))		bmapi_flags |= XFS_BMAPI_IGSTATE;	/*	 * Allocate enough space to handle "subnex" maps at a time.	 */	error = ENOMEM;	subnex = 16;	map = kmem_alloc(subnex * sizeof(*map), KM_MAYFAIL | KM_NOFS);	if (!map)		goto out_unlock_ilock;	bmv->bmv_entries = 0;	if (XFS_IFORK_NEXTENTS(ip, whichfork) == 0 &&	    (whichfork == XFS_ATTR_FORK || !(iflags & BMV_IF_DELALLOC))) {		error = 0;		goto out_free_map;	}	nexleft = nex;	do {		nmap = (nexleft > subnex) ? subnex : nexleft;		error = xfs_bmapi_read(ip, XFS_BB_TO_FSBT(mp, bmv->bmv_offset),				       XFS_BB_TO_FSB(mp, bmv->bmv_length),				       map, &nmap, bmapi_flags);		if (error)			goto out_free_map;		ASSERT(nmap <= subnex);		for (i = 0; i < nmap && nexleft && bmv->bmv_length; i++) {			out[cur_ext].bmv_oflags = 0;			if (map[i].br_state == XFS_EXT_UNWRITTEN)				out[cur_ext].bmv_oflags |= BMV_OF_PREALLOC;			else if (map[i].br_startblock == DELAYSTARTBLOCK)				out[cur_ext].bmv_oflags |= BMV_OF_DELALLOC;			out[cur_ext].bmv_offset =				XFS_FSB_TO_BB(mp, map[i].br_startoff);			out[cur_ext].bmv_length =				XFS_FSB_TO_BB(mp, map[i].br_blockcount);			out[cur_ext].bmv_unused1 = 0;			out[cur_ext].bmv_unused2 = 0;			/*			 * delayed allocation extents that start beyond EOF can			 * occur due to speculative EOF allocation when the			 * delalloc extent is larger than the largest freespace			 * extent at conversion time. These extents cannot be			 * converted by data writeback, so can exist here even			 * if we are not supposed to be finding delalloc			 * extents.			 */			if (map[i].br_startblock == DELAYSTARTBLOCK &&			    map[i].br_startoff <= XFS_B_TO_FSB(mp, XFS_ISIZE(ip)))				ASSERT((iflags & BMV_IF_DELALLOC) != 0);
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:66,


示例13: xfs_zero_remaining_bytes

/* * Zero file bytes between startoff and endoff inclusive. * The iolock is held exclusive and no blocks are buffered. * * This function is used by xfs_free_file_space() to zero * partial blocks when the range to free is not block aligned. * When unreserving space with boundaries that are not block * aligned we round up the start and round down the end * boundaries and then use this function to zero the parts of * the blocks that got dropped during the rounding. */STATIC intxfs_zero_remaining_bytes(	xfs_inode_t		*ip,	xfs_off_t		startoff,	xfs_off_t		endoff){	xfs_bmbt_irec_t		imap;	xfs_fileoff_t		offset_fsb;	xfs_off_t		lastoffset;	xfs_off_t		offset;	xfs_buf_t		*bp;	xfs_mount_t		*mp = ip->i_mount;	int			nimap;	int			error = 0;	/*	 * Avoid doing I/O beyond eof - it's not necessary	 * since nothing can read beyond eof.  The space will	 * be zeroed when the file is extended anyway.	 */	if (startoff >= XFS_ISIZE(ip))		return 0;	if (endoff > XFS_ISIZE(ip))		endoff = XFS_ISIZE(ip);	bp = xfs_buf_get_uncached(XFS_IS_REALTIME_INODE(ip) ?					mp->m_rtdev_targp : mp->m_ddev_targp,				  BTOBB(mp->m_sb.sb_blocksize), 0);	if (!bp)		return XFS_ERROR(ENOMEM);	xfs_buf_unlock(bp);	for (offset = startoff; offset <= endoff; offset = lastoffset + 1) {		uint lock_mode;		offset_fsb = XFS_B_TO_FSBT(mp, offset);		nimap = 1;		lock_mode = xfs_ilock_data_map_shared(ip);		error = xfs_bmapi_read(ip, offset_fsb, 1, &imap, &nimap, 0);		xfs_iunlock(ip, lock_mode);		if (error || nimap < 1)			break;		ASSERT(imap.br_blockcount >= 1);		ASSERT(imap.br_startoff == offset_fsb);		lastoffset = XFS_FSB_TO_B(mp, imap.br_startoff + 1) - 1;		if (lastoffset > endoff)			lastoffset = endoff;		if (imap.br_startblock == HOLESTARTBLOCK)			continue;		ASSERT(imap.br_startblock != DELAYSTARTBLOCK);		if (imap.br_state == XFS_EXT_UNWRITTEN)			continue;		XFS_BUF_UNDONE(bp);		XFS_BUF_UNWRITE(bp);		XFS_BUF_READ(bp);		XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock));		if (XFS_FORCED_SHUTDOWN(mp)) {			error = XFS_ERROR(EIO);			break;		}		xfs_buf_iorequest(bp);		error = xfs_buf_iowait(bp);		if (error) {			xfs_buf_ioerror_alert(bp,					"xfs_zero_remaining_bytes(read)");			break;		}		memset(bp->b_addr +			(offset - XFS_FSB_TO_B(mp, imap.br_startoff)),		      0, lastoffset - offset + 1);		XFS_BUF_UNDONE(bp);		XFS_BUF_UNREAD(bp);		XFS_BUF_WRITE(bp);		if (XFS_FORCED_SHUTDOWN(mp)) {			error = XFS_ERROR(EIO);			break;		}		xfs_buf_iorequest(bp);		error = xfs_buf_iowait(bp);		if (error) {			xfs_buf_ioerror_alert(bp,					"xfs_zero_remaining_bytes(write)");			break;//.........这里部分代码省略.........
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:101,


示例14: xfs_reflink_clear_inode_flag

/* Clear the inode reflink flag if there are no shared extents. */intxfs_reflink_clear_inode_flag(	struct xfs_inode	*ip,	struct xfs_trans	**tpp){	struct xfs_mount	*mp = ip->i_mount;	xfs_fileoff_t		fbno;	xfs_filblks_t		end;	xfs_agnumber_t		agno;	xfs_agblock_t		agbno;	xfs_extlen_t		aglen;	xfs_agblock_t		rbno;	xfs_extlen_t		rlen;	struct xfs_bmbt_irec	map;	int			nmaps;	int			error = 0;	ASSERT(xfs_is_reflink_inode(ip));	fbno = 0;	end = XFS_B_TO_FSB(mp, i_size_read(VFS_I(ip)));	while (end - fbno > 0) {		nmaps = 1;		/*		 * Look for extents in the file.  Skip holes, delalloc, or		 * unwritten extents; they can't be reflinked.		 */		error = xfs_bmapi_read(ip, fbno, end - fbno, &map, &nmaps, 0);		if (error)			return error;		if (nmaps == 0)			break;		if (!xfs_bmap_is_real_extent(&map))			goto next;		agno = XFS_FSB_TO_AGNO(mp, map.br_startblock);		agbno = XFS_FSB_TO_AGBNO(mp, map.br_startblock);		aglen = map.br_blockcount;		error = xfs_reflink_find_shared(mp, agno, agbno, aglen,				&rbno, &rlen, false);		if (error)			return error;		/* Is there still a shared block here? */		if (rbno != NULLAGBLOCK)			return 0;next:		fbno = map.br_startoff + map.br_blockcount;	}	/*	 * We didn't find any shared blocks so turn off the reflink flag.	 * First, get rid of any leftover CoW mappings.	 */	error = xfs_reflink_cancel_cow_blocks(ip, tpp, 0, NULLFILEOFF, true);	if (error)		return error;	/* Clear the inode flag. */	trace_xfs_reflink_unset_inode_flag(ip);	ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;	xfs_inode_clear_cowblocks_tag(ip);	xfs_trans_ijoin(*tpp, ip, 0);	xfs_trans_log_inode(*tpp, ip, XFS_ILOG_CORE);	return error;}
开发者ID:asmalldev,项目名称:linux,代码行数:68,


示例15: xfs_qm_dqtobp

/* * Maps a dquot to the buffer containing its on-disk version. * This returns a ptr to the buffer containing the on-disk dquot * in the bpp param, and a ptr to the on-disk dquot within that buffer */STATIC intxfs_qm_dqtobp(	xfs_trans_t		**tpp,	xfs_dquot_t		*dqp,	xfs_disk_dquot_t	**O_ddpp,	xfs_buf_t		**O_bpp,	uint			flags){	struct xfs_bmbt_irec	map;	int			nmaps = 1, error;	struct xfs_buf		*bp;	struct xfs_inode	*quotip = xfs_dq_to_quota_inode(dqp);	struct xfs_mount	*mp = dqp->q_mount;	xfs_dqid_t		id = be32_to_cpu(dqp->q_core.d_id);	struct xfs_trans	*tp = (tpp ? *tpp : NULL);	uint			lock_mode;	dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk;	lock_mode = xfs_ilock_data_map_shared(quotip);	if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {		/*		 * Return if this type of quotas is turned off while we		 * didn't have the quota inode lock.		 */		xfs_iunlock(quotip, lock_mode);		return ESRCH;	}	/*	 * Find the block map; no allocations yet	 */	error = xfs_bmapi_read(quotip, dqp->q_fileoffset,			       XFS_DQUOT_CLUSTER_SIZE_FSB, &map, &nmaps, 0);	xfs_iunlock(quotip, lock_mode);	if (error)		return error;	ASSERT(nmaps == 1);	ASSERT(map.br_blockcount == 1);	/*	 * Offset of dquot in the (fixed sized) dquot chunk.	 */	dqp->q_bufoffset = (id % mp->m_quotainfo->qi_dqperchunk) *		sizeof(xfs_dqblk_t);	ASSERT(map.br_startblock != DELAYSTARTBLOCK);	if (map.br_startblock == HOLESTARTBLOCK) {		/*		 * We don't allocate unless we're asked to		 */		if (!(flags & XFS_QMOPT_DQALLOC))			return ENOENT;		ASSERT(tp);		error = xfs_qm_dqalloc(tpp, mp, dqp, quotip,					dqp->q_fileoffset, &bp);		if (error)			return error;		tp = *tpp;	} else {		trace_xfs_dqtobp_read(dqp);		/*		 * store the blkno etc so that we don't have to do the		 * mapping all the time		 */		dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock);		error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,					   dqp->q_blkno,					   mp->m_quotainfo->qi_dqchunklen,					   0, &bp, &xfs_dquot_buf_ops);		if (error == EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) {			xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff *						mp->m_quotainfo->qi_dqperchunk;			ASSERT(bp == NULL);			error = xfs_qm_dqrepair(mp, tp, dqp, firstid, &bp);		}		if (error) {			ASSERT(bp == NULL);			return XFS_ERROR(error);		}	}	ASSERT(xfs_buf_islocked(bp));	*O_bpp = bp;	*O_ddpp = bp->b_addr + dqp->q_bufoffset;	return (0);}
开发者ID:MaxChina,项目名称:linux,代码行数:100,


示例16: xfs_zero_eof

intxfs_zero_eof(    xfs_inode_t	*ip,    xfs_off_t	offset,    xfs_fsize_t	isize){    xfs_mount_t	*mp = ip->i_mount;    xfs_fileoff_t	start_zero_fsb;    xfs_fileoff_t	end_zero_fsb;    xfs_fileoff_t	zero_count_fsb;    xfs_fileoff_t	last_fsb;    xfs_fileoff_t	zero_off;    xfs_fsize_t	zero_len;    int		nimaps;    int		error = 0;    xfs_bmbt_irec_t	imap;    ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_IOLOCK_EXCL));    ASSERT(offset > isize);    error = xfs_zero_last_block(ip, offset, isize);    if (error) {        ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_IOLOCK_EXCL));        return error;    }    last_fsb = isize ? XFS_B_TO_FSBT(mp, isize - 1) : (xfs_fileoff_t)-1;    start_zero_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)isize);    end_zero_fsb = XFS_B_TO_FSBT(mp, offset - 1);    ASSERT((xfs_sfiloff_t)last_fsb < (xfs_sfiloff_t)start_zero_fsb);    if (last_fsb == end_zero_fsb) {        return 0;    }    ASSERT(start_zero_fsb <= end_zero_fsb);    while (start_zero_fsb <= end_zero_fsb) {        nimaps = 1;        zero_count_fsb = end_zero_fsb - start_zero_fsb + 1;        error = xfs_bmapi_read(ip, start_zero_fsb, zero_count_fsb,                               &imap, &nimaps, 0);        if (error) {            ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_IOLOCK_EXCL));            return error;        }        ASSERT(nimaps > 0);        if (imap.br_state == XFS_EXT_UNWRITTEN ||                imap.br_startblock == HOLESTARTBLOCK) {            start_zero_fsb = imap.br_startoff + imap.br_blockcount;            ASSERT(start_zero_fsb <= (end_zero_fsb + 1));            continue;        }        xfs_iunlock(ip, XFS_ILOCK_EXCL);        zero_off = XFS_FSB_TO_B(mp, start_zero_fsb);        zero_len = XFS_FSB_TO_B(mp, imap.br_blockcount);        if ((zero_off + zero_len) > offset)            zero_len = offset - zero_off;        error = xfs_iozero(ip, zero_off, zero_len);        if (error) {            goto out_lock;        }        start_zero_fsb = imap.br_startoff + imap.br_blockcount;        ASSERT(start_zero_fsb <= (end_zero_fsb + 1));        xfs_ilock(ip, XFS_ILOCK_EXCL);    }    return 0;out_lock:    xfs_ilock(ip, XFS_ILOCK_EXCL);    ASSERT(error >= 0);    return error;}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:79,


示例17: xfs_seek_data

STATIC loff_txfs_seek_data(	struct file		*file,	loff_t			start,	u32			type){	struct inode		*inode = file->f_mapping->host;	struct xfs_inode	*ip = XFS_I(inode);	struct xfs_mount	*mp = ip->i_mount;	struct xfs_bmbt_irec	map[2];	int			nmap = 2;	loff_t			uninitialized_var(offset);	xfs_fsize_t		isize;	xfs_fileoff_t		fsbno;	xfs_filblks_t		end;	uint			lock;	int			error;	lock = xfs_ilock_map_shared(ip);	isize = i_size_read(inode);	if (start >= isize) {		error = ENXIO;		goto out_unlock;	}	fsbno = XFS_B_TO_FSBT(mp, start);	/*	 * Try to read extents from the first block indicated	 * by fsbno to the end block of the file.	 */	end = XFS_B_TO_FSB(mp, isize);	error = xfs_bmapi_read(ip, fsbno, end - fsbno, map, &nmap,			       XFS_BMAPI_ENTIRE);	if (error)		goto out_unlock;	/*	 * Treat unwritten extent as data extent since it might	 * contains dirty data in page cache.	 */	if (map[0].br_startblock != HOLESTARTBLOCK) {		offset = max_t(loff_t, start,			       XFS_FSB_TO_B(mp, map[0].br_startoff));	} else {		if (nmap == 1) {			error = ENXIO;			goto out_unlock;		}		offset = max_t(loff_t, start,			       XFS_FSB_TO_B(mp, map[1].br_startoff));	}	if (offset != file->f_pos)		file->f_pos = offset;out_unlock:	xfs_iunlock_map_shared(ip, lock);	if (error)		return -error;	return offset;}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:66,


示例18: xfs_qm_dqiterate

/* * Iterate over all allocated USR/GRP/PRJ dquots in the system, calling a * caller supplied function for every chunk of dquots that we find. */STATIC intxfs_qm_dqiterate(	struct xfs_mount	*mp,	struct xfs_inode	*qip,	uint			flags,	struct list_head	*buffer_list){	struct xfs_bmbt_irec	*map;	int			i, nmaps;	/* number of map entries */	int			error;		/* return value */	xfs_fileoff_t		lblkno;	xfs_filblks_t		maxlblkcnt;	xfs_dqid_t		firstid;	xfs_fsblock_t		rablkno;	xfs_filblks_t		rablkcnt;	error = 0;	/*	 * This looks racy, but we can't keep an inode lock across a	 * trans_reserve. But, this gets called during quotacheck, and that	 * happens only at mount time which is single threaded.	 */	if (qip->i_d.di_nblocks == 0)		return 0;	map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), KM_SLEEP);	lblkno = 0;	maxlblkcnt = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);	do {		nmaps = XFS_DQITER_MAP_SIZE;		/*		 * We aren't changing the inode itself. Just changing		 * some of its data. No new blocks are added here, and		 * the inode is never added to the transaction.		 */		xfs_ilock(qip, XFS_ILOCK_SHARED);		error = xfs_bmapi_read(qip, lblkno, maxlblkcnt - lblkno,				       map, &nmaps, 0);		xfs_iunlock(qip, XFS_ILOCK_SHARED);		if (error)			break;		ASSERT(nmaps <= XFS_DQITER_MAP_SIZE);		for (i = 0; i < nmaps; i++) {			ASSERT(map[i].br_startblock != DELAYSTARTBLOCK);			ASSERT(map[i].br_blockcount);			lblkno += map[i].br_blockcount;			if (map[i].br_startblock == HOLESTARTBLOCK)				continue;			firstid = (xfs_dqid_t) map[i].br_startoff *				mp->m_quotainfo->qi_dqperchunk;			/*			 * Do a read-ahead on the next extent.			 */			if ((i+1 < nmaps) &&			    (map[i+1].br_startblock != HOLESTARTBLOCK)) {				rablkcnt =  map[i+1].br_blockcount;				rablkno = map[i+1].br_startblock;				while (rablkcnt--) {					xfs_buf_readahead(mp->m_ddev_targp,					       XFS_FSB_TO_DADDR(mp, rablkno),					       mp->m_quotainfo->qi_dqchunklen,					       NULL);					rablkno++;				}			}			/*			 * Iterate thru all the blks in the extent and			 * reset the counters of all the dquots inside them.			 */			error = xfs_qm_dqiter_bufs(mp, firstid,						   map[i].br_startblock,						   map[i].br_blockcount,						   flags, buffer_list);			if (error)				goto out;		}	} while (nmaps > 0);out:	kmem_free(map);	return error;}
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:92,


示例19: xfs_attr3_leaf_freextent

/* * Look at all the extents for this logical region, * invalidate any buffers that are incore/in transactions. */STATIC intxfs_attr3_leaf_freextent(	struct xfs_trans	**trans,	struct xfs_inode	*dp,	xfs_dablk_t		blkno,	int			blkcnt){	struct xfs_bmbt_irec	map;	struct xfs_buf		*bp;	xfs_dablk_t		tblkno;	xfs_daddr_t		dblkno;	int			tblkcnt;	int			dblkcnt;	int			nmap;	int			error;	/*	 * Roll through the "value", invalidating the attribute value's	 * blocks.	 */	tblkno = blkno;	tblkcnt = blkcnt;	while (tblkcnt > 0) {		/*		 * Try to remember where we decided to put the value.		 */		nmap = 1;		error = xfs_bmapi_read(dp, (xfs_fileoff_t)tblkno, tblkcnt,				       &map, &nmap, XFS_BMAPI_ATTRFORK);		if (error) {			return error;		}		ASSERT(nmap == 1);		ASSERT(map.br_startblock != DELAYSTARTBLOCK);		/*		 * If it's a hole, these are already unmapped		 * so there's nothing to invalidate.		 */		if (map.br_startblock != HOLESTARTBLOCK) {			dblkno = XFS_FSB_TO_DADDR(dp->i_mount,						  map.br_startblock);			dblkcnt = XFS_FSB_TO_BB(dp->i_mount,						map.br_blockcount);			bp = xfs_trans_get_buf(*trans,					dp->i_mount->m_ddev_targp,					dblkno, dblkcnt, 0);			if (!bp)				return -ENOMEM;			xfs_trans_binval(*trans, bp);			/*			 * Roll to next transaction.			 */			error = xfs_trans_roll(trans, dp);			if (error)				return error;		}		tblkno += map.br_blockcount;		tblkcnt -= map.br_blockcount;	}	return 0;}
开发者ID:19Dan01,项目名称:linux,代码行数:69,


示例20: xfs_free_file_space

intxfs_free_file_space(	struct xfs_inode	*ip,	xfs_off_t		offset,	xfs_off_t		len){	int			committed;	int			done;	xfs_fileoff_t		endoffset_fsb;	int			error;	xfs_fsblock_t		firstfsb;	xfs_bmap_free_t		free_list;	xfs_bmbt_irec_t		imap;	xfs_off_t		ioffset;	xfs_extlen_t		mod=0;	xfs_mount_t		*mp;	int			nimap;	uint			resblks;	xfs_off_t		rounding;	int			rt;	xfs_fileoff_t		startoffset_fsb;	xfs_trans_t		*tp;	mp = ip->i_mount;	trace_xfs_free_file_space(ip);	error = xfs_qm_dqattach(ip, 0);	if (error)		return error;	error = 0;	if (len <= 0)	/* if nothing being freed */		return error;	rt = XFS_IS_REALTIME_INODE(ip);	startoffset_fsb	= XFS_B_TO_FSB(mp, offset);	endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len);	/* wait for the completion of any pending DIOs */	inode_dio_wait(VFS_I(ip));	rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);	ioffset = offset & ~(rounding - 1);	error = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping,					      ioffset, -1);	if (error)		goto out;	truncate_pagecache_range(VFS_I(ip), ioffset, -1);	/*	 * Need to zero the stuff we're not freeing, on disk.	 * If it's a realtime file & can't use unwritten extents then we	 * actually need to zero the extent edges.  Otherwise xfs_bunmapi	 * will take care of it for us.	 */	if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) {		nimap = 1;		error = xfs_bmapi_read(ip, startoffset_fsb, 1,					&imap, &nimap, 0);		if (error)			goto out;		ASSERT(nimap == 0 || nimap == 1);		if (nimap && imap.br_startblock != HOLESTARTBLOCK) {			xfs_daddr_t	block;			ASSERT(imap.br_startblock != DELAYSTARTBLOCK);			block = imap.br_startblock;			mod = do_div(block, mp->m_sb.sb_rextsize);			if (mod)				startoffset_fsb += mp->m_sb.sb_rextsize - mod;		}		nimap = 1;		error = xfs_bmapi_read(ip, endoffset_fsb - 1, 1,					&imap, &nimap, 0);		if (error)			goto out;		ASSERT(nimap == 0 || nimap == 1);		if (nimap && imap.br_startblock != HOLESTARTBLOCK) {			ASSERT(imap.br_startblock != DELAYSTARTBLOCK);			mod++;			if (mod && (mod != mp->m_sb.sb_rextsize))				endoffset_fsb -= mod;		}	}	if ((done = (endoffset_fsb <= startoffset_fsb)))		/*		 * One contiguous piece to clear		 */		error = xfs_zero_remaining_bytes(ip, offset, offset + len - 1);	else {		/*		 * Some full blocks, possibly two pieces to clear		 */		if (offset < XFS_FSB_TO_B(mp, startoffset_fsb))			error = xfs_zero_remaining_bytes(ip, offset,				XFS_FSB_TO_B(mp, startoffset_fsb) - 1);		if (!error &&		    XFS_FSB_TO_B(mp, endoffset_fsb) < offset + len)			error = xfs_zero_remaining_bytes(ip,				XFS_FSB_TO_B(mp, endoffset_fsb),//.........这里部分代码省略.........
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:101,


示例21: xfs_qm_dqtobp

/* * Maps a dquot to the buffer containing its on-disk version. * This returns a ptr to the buffer containing the on-disk dquot * in the bpp param, and a ptr to the on-disk dquot within that buffer */STATIC intxfs_qm_dqtobp(	xfs_trans_t		**tpp,	xfs_dquot_t		*dqp,	xfs_disk_dquot_t	**O_ddpp,	xfs_buf_t		**O_bpp,	uint			flags){	xfs_bmbt_irec_t map;	int		nmaps = 1, error;	xfs_buf_t	*bp;	xfs_inode_t	*quotip = XFS_DQ_TO_QIP(dqp);	xfs_mount_t	*mp = dqp->q_mount;	xfs_disk_dquot_t *ddq;	xfs_dqid_t	id = be32_to_cpu(dqp->q_core.d_id);	xfs_trans_t	*tp = (tpp ? *tpp : NULL);	dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk;	xfs_ilock(quotip, XFS_ILOCK_SHARED);	if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {		/*		 * Return if this type of quotas is turned off while we		 * didn't have the quota inode lock.		 */		xfs_iunlock(quotip, XFS_ILOCK_SHARED);		return ESRCH;	}	/*	 * Find the block map; no allocations yet	 */	error = xfs_bmapi_read(quotip, dqp->q_fileoffset,			       XFS_DQUOT_CLUSTER_SIZE_FSB, &map, &nmaps, 0);	xfs_iunlock(quotip, XFS_ILOCK_SHARED);	if (error)		return error;	ASSERT(nmaps == 1);	ASSERT(map.br_blockcount == 1);	/*	 * Offset of dquot in the (fixed sized) dquot chunk.	 */	dqp->q_bufoffset = (id % mp->m_quotainfo->qi_dqperchunk) *		sizeof(xfs_dqblk_t);	ASSERT(map.br_startblock != DELAYSTARTBLOCK);	if (map.br_startblock == HOLESTARTBLOCK) {		/*		 * We don't allocate unless we're asked to		 */		if (!(flags & XFS_QMOPT_DQALLOC))			return ENOENT;		ASSERT(tp);		error = xfs_qm_dqalloc(tpp, mp, dqp, quotip,					dqp->q_fileoffset, &bp);		if (error)			return error;		tp = *tpp;	} else {		trace_xfs_dqtobp_read(dqp);		/*		 * store the blkno etc so that we don't have to do the		 * mapping all the time		 */		dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock);		error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,					   dqp->q_blkno,					   mp->m_quotainfo->qi_dqchunklen,					   0, &bp);		if (error || !bp)			return XFS_ERROR(error);	}	ASSERT(xfs_buf_islocked(bp));	/*	 * calculate the location of the dquot inside the buffer.	 */	ddq = bp->b_addr + dqp->q_bufoffset;	/*	 * A simple sanity check in case we got a corrupted dquot...	 */	error = xfs_qm_dqcheck(mp, ddq, id, dqp->dq_flags & XFS_DQ_ALLTYPES,			   flags & (XFS_QMOPT_DQREPAIR|XFS_QMOPT_DOWARN),			   "dqtobp");	if (error) {		if (!(flags & XFS_QMOPT_DQREPAIR)) {			xfs_trans_brelse(tp, bp);//.........这里部分代码省略.........
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:101,


示例22: xfs_bmap_punch_delalloc_range

/* * dead simple method of punching delalyed allocation blocks from a range in * the inode. Walks a block at a time so will be slow, but is only executed in * rare error cases so the overhead is not critical. This will always punch out * both the start and end blocks, even if the ranges only partially overlap * them, so it is up to the caller to ensure that partial blocks are not * passed in. */intxfs_bmap_punch_delalloc_range(	struct xfs_inode	*ip,	xfs_fileoff_t		start_fsb,	xfs_fileoff_t		length){	xfs_fileoff_t		remaining = length;	int			error = 0;	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));	do {		int		done;		xfs_bmbt_irec_t	imap;		int		nimaps = 1;		xfs_fsblock_t	firstblock;		xfs_bmap_free_t flist;		/*		 * Map the range first and check that it is a delalloc extent		 * before trying to unmap the range. Otherwise we will be		 * trying to remove a real extent (which requires a		 * transaction) or a hole, which is probably a bad idea...		 */		error = xfs_bmapi_read(ip, start_fsb, 1, &imap, &nimaps,				       XFS_BMAPI_ENTIRE);		if (error) {			/* something screwed, just bail */			if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {				xfs_alert(ip->i_mount,			"Failed delalloc mapping lookup ino %lld fsb %lld.",						ip->i_ino, start_fsb);			}			break;		}		if (!nimaps) {			/* nothing there */			goto next_block;		}		if (imap.br_startblock != DELAYSTARTBLOCK) {			/* been converted, ignore */			goto next_block;		}		WARN_ON(imap.br_blockcount == 0);		/*		 * Note: while we initialise the firstblock/flist pair, they		 * should never be used because blocks should never be		 * allocated or freed for a delalloc extent and hence we need		 * don't cancel or finish them after the xfs_bunmapi() call.		 */		xfs_bmap_init(&flist, &firstblock);		error = xfs_bunmapi(NULL, ip, start_fsb, 1, 0, 1, &firstblock,					&flist, &done);		if (error)			break;		ASSERT(!flist.xbf_count && !flist.xbf_first);next_block:		start_fsb++;		remaining--;	} while(remaining > 0);	return error;}
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:74,


示例23: xfs_reflink_dirty_extents

/* * The user wants to preemptively CoW all shared blocks in this file, * which enables us to turn off the reflink flag.  Iterate all * extents which are not prealloc/delalloc to see which ranges are * mentioned in the refcount tree, then read those blocks into the * pagecache, dirty them, fsync them back out, and then we can update * the inode flag.  What happens if we run out of memory? :) */STATIC intxfs_reflink_dirty_extents(	struct xfs_inode	*ip,	xfs_fileoff_t		fbno,	xfs_filblks_t		end,	xfs_off_t		isize){	struct xfs_mount	*mp = ip->i_mount;	xfs_agnumber_t		agno;	xfs_agblock_t		agbno;	xfs_extlen_t		aglen;	xfs_agblock_t		rbno;	xfs_extlen_t		rlen;	xfs_off_t		fpos;	xfs_off_t		flen;	struct xfs_bmbt_irec	map[2];	int			nmaps;	int			error = 0;	while (end - fbno > 0) {		nmaps = 1;		/*		 * Look for extents in the file.  Skip holes, delalloc, or		 * unwritten extents; they can't be reflinked.		 */		error = xfs_bmapi_read(ip, fbno, end - fbno, map, &nmaps, 0);		if (error)			goto out;		if (nmaps == 0)			break;		if (!xfs_bmap_is_real_extent(&map[0]))			goto next;		map[1] = map[0];		while (map[1].br_blockcount) {			agno = XFS_FSB_TO_AGNO(mp, map[1].br_startblock);			agbno = XFS_FSB_TO_AGBNO(mp, map[1].br_startblock);			aglen = map[1].br_blockcount;			error = xfs_reflink_find_shared(mp, NULL, agno, agbno,					aglen, &rbno, &rlen, true);			if (error)				goto out;			if (rbno == NULLAGBLOCK)				break;			/* Dirty the pages */			xfs_iunlock(ip, XFS_ILOCK_EXCL);			fpos = XFS_FSB_TO_B(mp, map[1].br_startoff +					(rbno - agbno));			flen = XFS_FSB_TO_B(mp, rlen);			if (fpos + flen > isize)				flen = isize - fpos;			error = iomap_file_dirty(VFS_I(ip), fpos, flen,					&xfs_iomap_ops);			xfs_ilock(ip, XFS_ILOCK_EXCL);			if (error)				goto out;			map[1].br_blockcount -= (rbno - agbno + rlen);			map[1].br_startoff += (rbno - agbno + rlen);			map[1].br_startblock += (rbno - agbno + rlen);		}next:		fbno = map[0].br_startoff + map[0].br_blockcount;	}out:	return error;}
开发者ID:oscardagrach,项目名称:linux,代码行数:78,


示例24: xfs_inactive_symlink_rmt

/* * Free a symlink that has blocks associated with it. */STATIC intxfs_inactive_symlink_rmt(	struct xfs_inode *ip){	xfs_buf_t	*bp;	int		committed;	int		done;	int		error;	xfs_fsblock_t	first_block;	xfs_bmap_free_t	free_list;	int		i;	xfs_mount_t	*mp;	xfs_bmbt_irec_t	mval[XFS_SYMLINK_MAPS];	int		nmaps;	int		size;	xfs_trans_t	*tp;	mp = ip->i_mount;	ASSERT(ip->i_df.if_flags & XFS_IFEXTENTS);	/*	 * We're freeing a symlink that has some	 * blocks allocated to it.  Free the	 * blocks here.  We know that we've got	 * either 1 or 2 extents and that we can	 * free them all in one bunmapi call.	 */	ASSERT(ip->i_d.di_nextents > 0 && ip->i_d.di_nextents <= 2);	tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);	if (error) {		xfs_trans_cancel(tp, 0);		return error;	}	xfs_ilock(ip, XFS_ILOCK_EXCL);	xfs_trans_ijoin(tp, ip, 0);	/*	 * Lock the inode, fix the size, and join it to the transaction.	 * Hold it so in the normal path, we still have it locked for	 * the second transaction.  In the error paths we need it	 * held so the cancel won't rele it, see below.	 */	size = (int)ip->i_d.di_size;	ip->i_d.di_size = 0;	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);	/*	 * Find the block(s) so we can inval and unmap them.	 */	done = 0;	xfs_bmap_init(&free_list, &first_block);	nmaps = ARRAY_SIZE(mval);	error = xfs_bmapi_read(ip, 0, xfs_symlink_blocks(mp, size),				mval, &nmaps, 0);	if (error)		goto error_trans_cancel;	/*	 * Invalidate the block(s). No validation is done.	 */	for (i = 0; i < nmaps; i++) {		bp = xfs_trans_get_buf(tp, mp->m_ddev_targp,			XFS_FSB_TO_DADDR(mp, mval[i].br_startblock),			XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0);		if (!bp) {			error = ENOMEM;			goto error_bmap_cancel;		}		xfs_trans_binval(tp, bp);	}	/*	 * Unmap the dead block(s) to the free_list.	 */	error = xfs_bunmapi(tp, ip, 0, size, XFS_BMAPI_METADATA, nmaps,			    &first_block, &free_list, &done);	if (error)		goto error_bmap_cancel;	ASSERT(done);	/*	 * Commit the first transaction.  This logs the EFI and the inode.	 */	error = xfs_bmap_finish(&tp, &free_list, &committed);	if (error)		goto error_bmap_cancel;	/*	 * The transaction must have been committed, since there were	 * actually extents freed by xfs_bunmapi.  See xfs_bmap_finish.	 * The new tp has the extent freeing and EFDs.	 */	ASSERT(committed);	/*	 * The first xact was committed, so add the inode to the new one.	 * Mark it dirty so it will be logged and moved forward in the log as	 * part of every commit.	 */	xfs_trans_ijoin(tp, ip, 0);	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);//.........这里部分代码省略.........
开发者ID:spacex,项目名称:kernel-centos7,代码行数:101,


示例25: xfs_reflink_remap_blocks

/* * Iteratively remap one file's extents (and holes) to another's. */intxfs_reflink_remap_blocks(	struct xfs_inode	*src,	loff_t			pos_in,	struct xfs_inode	*dest,	loff_t			pos_out,	loff_t			remap_len,	loff_t			*remapped){	struct xfs_bmbt_irec	imap;	xfs_fileoff_t		srcoff;	xfs_fileoff_t		destoff;	xfs_filblks_t		len;	xfs_filblks_t		range_len;	xfs_filblks_t		remapped_len = 0;	xfs_off_t		new_isize = pos_out + remap_len;	int			nimaps;	int			error = 0;	destoff = XFS_B_TO_FSBT(src->i_mount, pos_out);	srcoff = XFS_B_TO_FSBT(src->i_mount, pos_in);	len = XFS_B_TO_FSB(src->i_mount, remap_len);	/* drange = (destoff, destoff + len); srange = (srcoff, srcoff + len) */	while (len) {		uint		lock_mode;		trace_xfs_reflink_remap_blocks_loop(src, srcoff, len,				dest, destoff);		/* Read extent from the source file */		nimaps = 1;		lock_mode = xfs_ilock_data_map_shared(src);		error = xfs_bmapi_read(src, srcoff, len, &imap, &nimaps, 0);		xfs_iunlock(src, lock_mode);		if (error)			break;		ASSERT(nimaps == 1);		trace_xfs_reflink_remap_imap(src, srcoff, len, XFS_DATA_FORK,				&imap);		/* Translate imap into the destination file. */		range_len = imap.br_startoff + imap.br_blockcount - srcoff;		imap.br_startoff += destoff - srcoff;		/* Clear dest from destoff to the end of imap and map it in. */		error = xfs_reflink_remap_extent(dest, &imap, destoff,				new_isize);		if (error)			break;		if (fatal_signal_pending(current)) {			error = -EINTR;			break;		}		/* Advance drange/srange */		srcoff += range_len;		destoff += range_len;		len -= range_len;		remapped_len += range_len;	}	if (error)		trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_);	*remapped = min_t(loff_t, remap_len,			  XFS_FSB_TO_B(src->i_mount, remapped_len));	return error;}
开发者ID:Anjali05,项目名称:linux,代码行数:73,



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


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