Re: [PATCH 5/5] generic block based fiemap implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 24, 2008  17:02 -0700, Mark Fasheh wrote:
> +int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
> +		u64 start, u64 len)
> +{
> +	return generic_block_fiemap(inode, fieinfo, start, len,
> +				    ext3_get_block);
> +}

We can wire up ext2 in the same way, and likely most of the other filesystems.


#define GENERIC_FIEMAP_FLAG_SUPP (FIEMAP_FLAG_NUM_EXTENTS | FIEMAP_FLAG_SYNC |
				  FIEMAP_FLAG_HSM_READ | FIEMAP_FLAG_LUN_ORDER)

> +int generic_block_fiemap(struct inode *inode,
> +			 struct fiemap_extent_info *fieinfo, u64 start,
> +			 u64 len, get_block_t *get_block)
> +{
> +	int just_count = fieinfo->fi_flags & FIEMAP_FLAG_NUM_EXTENTS;

Don't need this anymore.


	if (fieinfo->fi_flags & ~GENERIC_FIEMAP_FLAG_SUPP) {
		fieinfo->fi_flags &= ~GENERIC_FIEMAP_FLAG_SUPP;
		return -EBADF;
	}
		
> +		/* HOLE */
> +		if (!tmp.b_blocknr) {
> +			if (length <= 0) {
> +				if (just_count) {
> +					fieinfo->fi_extents_mapped++;
> +					break;
> +				}
> +				flags = FIEMAP_EXTENT_LAST;
> +				ret = fiemap_fill_next_extent(fieinfo, logical,
> +							      phys, size,
> +							      flags, 0);
> +				break;

Can remove the just_count check, fiemap_fill_next_extent() will handle it.

> +		} else {
> +			if (length <= 0 && size && !just_count) {
> +				ret = fiemap_fill_next_extent(fieinfo, logical,
> +							      phys, size,
> +							      flags, 0);
> +				if (ret)
> +					break;
> +			}
> +
> +			logical = blk_to_logical(inode, start_blk);
> +			phys = blk_to_logical(inode, tmp.b_blocknr);
> +			size = tmp.b_size;
> +			flags = 0;
> +
> +			length -= tmp.b_size;
> +			start_blk += logical_to_blk(inode, size);
> +
> +			if (just_count) {
> +				fieinfo->fi_extents_mapped++;
> +				if (fieinfo->fi_extents_mapped ==
> +				    fieinfo->fi_extents_max)
> +					break;
> +				continue;
> +			}

Can also remove this just_count check, which is incorrect in any case.
The fi_extents_max is only when storing extents in the array, it isn't
meaningful when only counting extents.

More important is the extent merging I proposed for fiemap_fill_next_extent()
for filesystems that only return single blocks, so we want to always
call it from the generic_block_fiemap() code.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux