Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
96f3136
Btrfs: rename btrfs_sysfs_add_one to btrfs_sysfs_add_mounted
asj Aug 14, 2015
6618a59
Btrfs: rename btrfs_sysfs_remove_one to btrfs_sysfs_remove_mounted
asj Aug 14, 2015
e3bd697
Btrfs: rename btrfs_kobj_add_device to btrfs_sysfs_add_device_link
asj Aug 14, 2015
3257604
Btrfs: rename btrfs_kobj_rm_device to btrfs_sysfs_rm_device_link
asj Aug 14, 2015
c1b7e47
Btrfs: rename super_kobj to fsid_kobj
asj Aug 14, 2015
92fc03f
Btrfs: SB read failure should return EIO for __bread failure
asj Aug 14, 2015
57d816a
Btrfs: __btrfs_std_error() logic should be consistent w/out CONFIG_PR…
asj Aug 14, 2015
a4553fe
Btrfs: consolidate btrfs_error() to btrfs_std_error()
asj Sep 25, 2015
d74a625
Btrfs: use BTRFS_ERROR_DEV_MISSING_NOT_FOUND when missing device is n…
asj Aug 14, 2015
29c36d7
Btrfs: add btrfs_read_dev_one_super() to read one specific SB
asj Aug 14, 2015
12b1c26
Btrfs: enhance btrfs_scratch_superblock to scratch all superblocks
asj Aug 14, 2015
9e271ae
Btrfs: kernel operation should come after user input has been verified
asj Aug 14, 2015
097efc9
Btrfs: don't log error from btrfs_get_bdev_and_sb
asj Aug 14, 2015
f190aa4
Btrfs: add helper for closing one device
asj Aug 14, 2015
73416da
Btrfs: move kobj stuff out of dev_replace lock range
Aug 14, 2015
6247790
Btrfs: pass the error code to the btrfs_std_error and log ret
asj Oct 2, 2015
a1f170f
Btrfs: create a helper function to read the disk super
asj Sep 20, 2015
dbf8590
btrfs: maintain consistency in logging to help debugging
asj Sep 21, 2015
adef2e2
Btrfs: device path change must be logged
asj May 21, 2015
f2c354c
Btrfs: add missing brelse when superblock checksum fails
asj Oct 5, 2015
26239df
Btrfs: sysfs: support seed devices in the sysfs layout
asj Jun 18, 2015
d7c3547
Btrfs: create a framework to create pool attributes
asj Mar 20, 2015
08f4446
Btrfs: create helper function __check_raid_min_devices()
asj Apr 23, 2015
e17012a
Btrfs: clean up and optimize __check_raid_min_device()
asj Oct 1, 2015
cebed27
Btrfs: create helper btrfs_find_device_by_user_input()
asj Apr 23, 2015
a871c3d
Btrfs: make use of btrfs_find_device_by_user_input()
asj Apr 23, 2015
1e5cd99
Btrfs: enhance btrfs_find_device_by_user_input() to check device path
asj May 31, 2015
74b351a
Btrfs: make use of btrfs_scratch_superblocks() in btrfs_rm_device()
asj Apr 24, 2015
cfe509c
Btrfs: Introduce device delete by devid
asj Apr 13, 2015
cd3b237
Btrfs: Introduce device pool sysfs attributes
asj Nov 24, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Btrfs: enhance btrfs_scratch_superblock to scratch all superblocks
This patch updates and renames btrfs_scratch_superblocks, (which is used
by the replace device thread), with those fixes from the scratch
superblock code section of btrfs_rm_device(). The fixes are:
  Scratch all copies of superblock
  Notify kobject that superblock has been changed
  Update time on the device

So that btrfs_rm_device() can use the function
btrfs_scratch_superblocks() instead of its own scratch code. And further
replace deivce code which similarly releases device back to the system,
will have the fixes from the btrfs device delete.

Signed-off-by: Anand Jain <[email protected]>
[renamed to btrfs_scratch_superblock]
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
asj authored and kdave committed Oct 1, 2015
commit 12b1c2637b6e0763121648d637ffe603b422e986
38 changes: 26 additions & 12 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,8 @@ void btrfs_rm_dev_replace_remove_srcdev(struct btrfs_fs_info *fs_info,
if (srcdev->writeable) {
fs_devices->rw_devices--;
/* zero out the old super if it is writable */
btrfs_scratch_superblock(srcdev);
btrfs_scratch_superblocks(srcdev->bdev,
rcu_str_deref(srcdev->name));
}

if (srcdev->bdev)
Expand Down Expand Up @@ -1974,7 +1975,8 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev);

if (tgtdev->bdev) {
btrfs_scratch_superblock(tgtdev);
btrfs_scratch_superblocks(tgtdev->bdev,
rcu_str_deref(tgtdev->name));
fs_info->fs_devices->open_devices--;
}
fs_info->fs_devices->num_devices--;
Expand Down Expand Up @@ -6738,22 +6740,34 @@ int btrfs_get_dev_stats(struct btrfs_root *root,
return 0;
}

int btrfs_scratch_superblock(struct btrfs_device *device)
void btrfs_scratch_superblocks(struct block_device *bdev, char *device_path)
{
struct buffer_head *bh;
struct btrfs_super_block *disk_super;
int copy_num;

bh = btrfs_read_dev_super(device->bdev);
if (IS_ERR(bh))
return PTR_ERR(bh);
disk_super = (struct btrfs_super_block *)bh->b_data;
if (!bdev)
return;

memset(&disk_super->magic, 0, sizeof(disk_super->magic));
set_buffer_dirty(bh);
sync_dirty_buffer(bh);
brelse(bh);
for (copy_num = 0; copy_num < BTRFS_SUPER_MIRROR_MAX;
copy_num++) {

return 0;
if (btrfs_read_dev_one_super(bdev, copy_num, &bh))
continue;

disk_super = (struct btrfs_super_block *)bh->b_data;

memset(&disk_super->magic, 0, sizeof(disk_super->magic));
set_buffer_dirty(bh);
sync_dirty_buffer(bh);
brelse(bh);
}

/* Notify udev that device has changed */
btrfs_kobject_uevent(bdev, KOBJ_CHANGE);

/* Update ctime/mtime for device path for libblkid */
update_dev_time(device_path);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/volumes.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
struct btrfs_device *tgtdev);
void btrfs_init_dev_replace_tgtdev_for_resume(struct btrfs_fs_info *fs_info,
struct btrfs_device *tgtdev);
int btrfs_scratch_superblock(struct btrfs_device *device);
void btrfs_scratch_superblocks(struct block_device *bdev, char *device_path);
int btrfs_is_parity_mirror(struct btrfs_mapping_tree *map_tree,
u64 logical, u64 len, int mirror_num);
unsigned long btrfs_full_stripe_len(struct btrfs_root *root,
Expand Down