Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6e30871 authored by Qinghuang Feng's avatar Qinghuang Feng Committed by Chris Mason
Browse files

Btrfs: simplify iteration codes



Merge list_for_each* and list_entry to list_for_each_entry*

Signed-off-by: default avatarQinghuang Feng <qhfeng.kernel@gmail.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 57506d50
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -1135,7 +1135,6 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
{
	struct btrfs_fs_info *info = (struct btrfs_fs_info *)congested_data;
	int ret = 0;
	struct list_head *cur;
	struct btrfs_device *device;
	struct backing_dev_info *bdi;
#if 0
@@ -1143,8 +1142,7 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
	    btrfs_congested_async(info, 0))
		return 1;
#endif
	list_for_each(cur, &info->fs_devices->devices) {
		device = list_entry(cur, struct btrfs_device, dev_list);
	list_for_each_entry(device, &info->fs_devices->devices, dev_list) {
		if (!device->bdev)
			continue;
		bdi = blk_get_backing_dev_info(device->bdev);
@@ -1162,13 +1160,11 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
 */
static void __unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
{
	struct list_head *cur;
	struct btrfs_device *device;
	struct btrfs_fs_info *info;

	info = (struct btrfs_fs_info *)bdi->unplug_io_data;
	list_for_each(cur, &info->fs_devices->devices) {
		device = list_entry(cur, struct btrfs_device, dev_list);
	list_for_each_entry(device, &info->fs_devices->devices, dev_list) {
		if (!device->bdev)
			continue;

@@ -1994,7 +1990,6 @@ static int write_dev_supers(struct btrfs_device *device,

int write_all_supers(struct btrfs_root *root, int max_mirrors)
{
	struct list_head *cur;
	struct list_head *head = &root->fs_info->fs_devices->devices;
	struct btrfs_device *dev;
	struct btrfs_super_block *sb;
@@ -2010,8 +2005,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)

	sb = &root->fs_info->super_for_commit;
	dev_item = &sb->dev_item;
	list_for_each(cur, head) {
		dev = list_entry(cur, struct btrfs_device, dev_list);
	list_for_each_entry(dev, head, dev_list) {
		if (!dev->bdev) {
			total_errors++;
			continue;
@@ -2044,8 +2038,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
	}

	total_errors = 0;
	list_for_each(cur, head) {
		dev = list_entry(cur, struct btrfs_device, dev_list);
	list_for_each_entry(dev, head, dev_list) {
		if (!dev->bdev)
			continue;
		if (!dev->in_fs_metadata || !dev->writeable)
+2 −6
Original line number Diff line number Diff line
@@ -325,10 +325,8 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info,
						  u64 flags)
{
	struct list_head *head = &info->space_info;
	struct list_head *cur;
	struct btrfs_space_info *found;
	list_for_each(cur, head) {
		found = list_entry(cur, struct btrfs_space_info, list);
	list_for_each_entry(found, head, list) {
		if (found->flags == flags)
			return found;
	}
@@ -3013,7 +3011,6 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
static void dump_space_info(struct btrfs_space_info *info, u64 bytes)
{
	struct btrfs_block_group_cache *cache;
	struct list_head *l;

	printk(KERN_INFO "space_info has %llu free, is %sfull\n",
	       (unsigned long long)(info->total_bytes - info->bytes_used -
@@ -3021,8 +3018,7 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes)
	       (info->full) ? "" : "not ");

	down_read(&info->groups_sem);
	list_for_each(l, &info->block_groups) {
		cache = list_entry(l, struct btrfs_block_group_cache, list);
	list_for_each_entry(cache, &info->block_groups, list) {
		spin_lock(&cache->lock);
		printk(KERN_INFO "block group %llu has %llu bytes, %llu used "
		       "%llu pinned %llu reserved\n",
+2 −3
Original line number Diff line number Diff line
@@ -1323,12 +1323,11 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans,
			     struct inode *inode, u64 file_offset,
			     struct list_head *list)
{
	struct list_head *cur;
	struct btrfs_ordered_sum *sum;

	btrfs_set_trans_block_group(trans, inode);
	list_for_each(cur, list) {
		sum = list_entry(cur, struct btrfs_ordered_sum, list);

	list_for_each_entry(sum, list, list) {
		btrfs_csum_file_blocks(trans,
		       BTRFS_I(inode)->root->fs_info->csum_root, sum);
	}
+1 −3
Original line number Diff line number Diff line
@@ -613,7 +613,6 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
	struct btrfs_sector_sum *sector_sums;
	struct btrfs_ordered_extent *ordered;
	struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree;
	struct list_head *cur;
	unsigned long num_sectors;
	unsigned long i;
	u32 sectorsize = BTRFS_I(inode)->root->sectorsize;
@@ -624,8 +623,7 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
		return 1;

	mutex_lock(&tree->mutex);
	list_for_each_prev(cur, &ordered->list) {
		ordered_sum = list_entry(cur, struct btrfs_ordered_sum, list);
	list_for_each_entry_reverse(ordered_sum, &ordered->list, list) {
		if (disk_bytenr >= ordered_sum->bytenr) {
			num_sectors = ordered_sum->len / sectorsize;
			sector_sums = ordered_sum->sums;
+1 −3
Original line number Diff line number Diff line
@@ -852,11 +852,9 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
{
	struct btrfs_pending_snapshot *pending;
	struct list_head *head = &trans->transaction->pending_snapshots;
	struct list_head *cur;
	int ret;

	list_for_each(cur, head) {
		pending = list_entry(cur, struct btrfs_pending_snapshot, list);
	list_for_each_entry(pending, head, list) {
		ret = create_pending_snapshot(trans, fs_info, pending);
		BUG_ON(ret);
	}
Loading