Re: [PATCH v3 3/6] btrfs: add scrub code and prototypes

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

 



On Sat, Mar 12, 2011 at 03:50:42PM +0100, Arne Jansen wrote:

All extent maps are leaked after unmount.  lookup_extent_mapping() takes
a reference, so they are all left with em->refs = 1.  I suggest the
following:

> +static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev, 
> +	u64 chunk_tree, u64 chunk_objectid, u64 chunk_offset, u64 length)
> +{
> +	struct btrfs_mapping_tree *map_tree =
> +		&sdev->dev->dev_root->fs_info->mapping_tree;
> +	struct map_lookup *map;
> +	struct extent_map *em;
> +	int i;
> +	int ret;
> +
> +	read_lock(&map_tree->map_tree.lock);
> +	em = lookup_extent_mapping(&map_tree->map_tree, chunk_offset, 1);
> +	read_unlock(&map_tree->map_tree.lock);
> +
> +	if (!em)
> +		return -EINVAL;
> +
> +	map = (struct map_lookup *)em->bdev;
> +	if (em->start != chunk_offset)
> +		return -EINVAL;
> +
> +	if (em->len < length)
> +		return -EINVAL;
> +
> +	for (i = 0; i < map->num_stripes; ++i) {
> +		if (map->stripes[i].dev == sdev->dev) {
> +			ret = scrub_stripe(sdev, map, i, chunk_offset, length);
> +			if (ret)
> +				return ret;
> +		}
> +	}

+	free_extent_map(em);

> +	return 0;
> +}

Thanks,

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


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux