mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	btrfs: zoned: sink zone check into btrfs_repair_one_zone
Sink zone check into btrfs_repair_one_zone() so we don't need to do it in all callers. Also as btrfs_repair_one_zone() doesn't return a sensible error, make it a boolean function and return false in case it got called on a non-zoned filesystem and true on a zoned filesystem. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
		
							parent
							
								
									8fdf54fe69
								
							
						
					
					
						commit
						554aed7da2
					
				
					 4 changed files with 13 additions and 10 deletions
				
			
		| 
						 | 
					@ -2314,8 +2314,8 @@ static int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
 | 
				
			||||||
	ASSERT(!(fs_info->sb->s_flags & SB_RDONLY));
 | 
						ASSERT(!(fs_info->sb->s_flags & SB_RDONLY));
 | 
				
			||||||
	BUG_ON(!mirror_num);
 | 
						BUG_ON(!mirror_num);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (btrfs_is_zoned(fs_info))
 | 
						if (btrfs_repair_one_zone(fs_info, logical))
 | 
				
			||||||
		return btrfs_repair_one_zone(fs_info, logical);
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bio = btrfs_bio_alloc(1);
 | 
						bio = btrfs_bio_alloc(1);
 | 
				
			||||||
	bio->bi_iter.bi_size = 0;
 | 
						bio->bi_iter.bi_size = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -845,8 +845,8 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
 | 
				
			||||||
	have_csum = sblock_to_check->pagev[0]->have_csum;
 | 
						have_csum = sblock_to_check->pagev[0]->have_csum;
 | 
				
			||||||
	dev = sblock_to_check->pagev[0]->dev;
 | 
						dev = sblock_to_check->pagev[0]->dev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (btrfs_is_zoned(fs_info) && !sctx->is_dev_replace)
 | 
						if (!sctx->is_dev_replace && btrfs_repair_one_zone(fs_info, logical))
 | 
				
			||||||
		return btrfs_repair_one_zone(fs_info, logical);
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * We must use GFP_NOFS because the scrub task might be waiting for a
 | 
						 * We must use GFP_NOFS because the scrub task might be waiting for a
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8341,23 +8341,26 @@ static int relocating_repair_kthread(void *data)
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)
 | 
					bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct btrfs_block_group *cache;
 | 
						struct btrfs_block_group *cache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!btrfs_is_zoned(fs_info))
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Do not attempt to repair in degraded state */
 | 
						/* Do not attempt to repair in degraded state */
 | 
				
			||||||
	if (btrfs_test_opt(fs_info, DEGRADED))
 | 
						if (btrfs_test_opt(fs_info, DEGRADED))
 | 
				
			||||||
		return 0;
 | 
							return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cache = btrfs_lookup_block_group(fs_info, logical);
 | 
						cache = btrfs_lookup_block_group(fs_info, logical);
 | 
				
			||||||
	if (!cache)
 | 
						if (!cache)
 | 
				
			||||||
		return 0;
 | 
							return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spin_lock(&cache->lock);
 | 
						spin_lock(&cache->lock);
 | 
				
			||||||
	if (cache->relocating_repair) {
 | 
						if (cache->relocating_repair) {
 | 
				
			||||||
		spin_unlock(&cache->lock);
 | 
							spin_unlock(&cache->lock);
 | 
				
			||||||
		btrfs_put_block_group(cache);
 | 
							btrfs_put_block_group(cache);
 | 
				
			||||||
		return 0;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	cache->relocating_repair = 1;
 | 
						cache->relocating_repair = 1;
 | 
				
			||||||
	spin_unlock(&cache->lock);
 | 
						spin_unlock(&cache->lock);
 | 
				
			||||||
| 
						 | 
					@ -8365,5 +8368,5 @@ int btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)
 | 
				
			||||||
	kthread_run(relocating_repair_kthread, cache,
 | 
						kthread_run(relocating_repair_kthread, cache,
 | 
				
			||||||
		    "btrfs-relocating-repair");
 | 
							    "btrfs-relocating-repair");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -637,6 +637,6 @@ enum btrfs_raid_types __attribute_const__ btrfs_bg_flags_to_raid_index(u64 flags
 | 
				
			||||||
int btrfs_bg_type_to_factor(u64 flags);
 | 
					int btrfs_bg_type_to_factor(u64 flags);
 | 
				
			||||||
const char *btrfs_bg_type_to_raid_name(u64 flags);
 | 
					const char *btrfs_bg_type_to_raid_name(u64 flags);
 | 
				
			||||||
int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info);
 | 
					int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info);
 | 
				
			||||||
int btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical);
 | 
					bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue