mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	btrfs: make block group flags in balance printks human-readable
They're not even documented anywhere, letting users with no recourse but to RTFS. It's no big burden to output the bitfield as words. Also, display unknown flags as hex. Signed-off-by: Adam Borowski <kilobyte@angband.pl> Tested-by: Holger Hoffstätte <holger@applied-asynchrony.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
		
							parent
							
								
									8e2bd3b7fa
								
							
						
					
					
						commit
						ebce0e01b9
					
				
					 1 changed files with 40 additions and 3 deletions
				
			
		|  | @ -4332,6 +4332,45 @@ static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info) | |||
| 	return rc; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * Print the block group being relocated | ||||
|  */ | ||||
| static void describe_relocation(struct btrfs_fs_info *fs_info, | ||||
| 				struct btrfs_block_group_cache *block_group) | ||||
| { | ||||
| 	char buf[128];		/* prefixed by a '|' that'll be dropped */ | ||||
| 	u64 flags = block_group->flags; | ||||
| 
 | ||||
| 	/* Shouldn't happen */ | ||||
| 	if (!flags) { | ||||
| 		strcpy(buf, "|NONE"); | ||||
| 	} else { | ||||
| 		char *bp = buf; | ||||
| 
 | ||||
| #define DESCRIBE_FLAG(f, d) \ | ||||
| 		if (flags & BTRFS_BLOCK_GROUP_##f) { \ | ||||
| 			bp += snprintf(bp, buf - bp + sizeof(buf), "|%s", d); \ | ||||
| 			flags &= ~BTRFS_BLOCK_GROUP_##f; \ | ||||
| 		} | ||||
| 		DESCRIBE_FLAG(DATA,     "data"); | ||||
| 		DESCRIBE_FLAG(SYSTEM,   "system"); | ||||
| 		DESCRIBE_FLAG(METADATA, "metadata"); | ||||
| 		DESCRIBE_FLAG(RAID0,    "raid0"); | ||||
| 		DESCRIBE_FLAG(RAID1,    "raid1"); | ||||
| 		DESCRIBE_FLAG(DUP,      "dup"); | ||||
| 		DESCRIBE_FLAG(RAID10,   "raid10"); | ||||
| 		DESCRIBE_FLAG(RAID5,    "raid5"); | ||||
| 		DESCRIBE_FLAG(RAID6,    "raid6"); | ||||
| 		if (flags) | ||||
| 			snprintf(buf, buf - bp + sizeof(buf), "|0x%llx", flags); | ||||
| #undef DESCRIBE_FLAG | ||||
| 	} | ||||
| 
 | ||||
| 	btrfs_info(fs_info, | ||||
| 		   "relocating block group %llu flags %s", | ||||
| 		   block_group->key.objectid, buf + 1); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * function to relocate all extents in a block group. | ||||
|  */ | ||||
|  | @ -4388,9 +4427,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start) | |||
| 		goto out; | ||||
| 	} | ||||
| 
 | ||||
| 	btrfs_info(extent_root->fs_info, | ||||
| 		   "relocating block group %llu flags %llu", | ||||
| 		   rc->block_group->key.objectid, rc->block_group->flags); | ||||
| 	describe_relocation(extent_root->fs_info, rc->block_group); | ||||
| 
 | ||||
| 	btrfs_wait_block_group_reservations(rc->block_group); | ||||
| 	btrfs_wait_nocow_writers(rc->block_group); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Adam Borowski
						Adam Borowski