Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 287900
b: refs/heads/master
c: a6b0d5c
h: refs/heads/master
v: v3
  • Loading branch information
Chris Mason committed Feb 23, 2012
1 parent 7e9388b commit 5e1d0c1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fe66a05a06795bd3b788404d69ea7709f46a1609
refs/heads/master: a6b0d5c8dbfd428717fc4db4c36757783f391c7b
6 changes: 6 additions & 0 deletions trunk/fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2305,6 +2305,12 @@ struct btrfs_root *open_ctree(struct super_block *sb,

btrfs_close_extra_devices(fs_devices);

if (!fs_devices->latest_bdev) {
printk(KERN_CRIT "btrfs: failed to read devices on %s\n",
sb->s_id);
goto fail_tree_roots;
}

retry_root_backup:
blocksize = btrfs_level_size(tree_root,
btrfs_super_root_level(disk_super));
Expand Down
17 changes: 16 additions & 1 deletion trunk/fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,23 @@ int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices)
{
struct btrfs_device *device, *next;

struct block_device *latest_bdev = NULL;
u64 latest_devid = 0;
u64 latest_transid = 0;

mutex_lock(&uuid_mutex);
again:
/* This is the initialized path, it is safe to release the devices. */
list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) {
if (device->in_fs_metadata)
if (device->in_fs_metadata) {
if (!latest_transid ||
device->generation > latest_transid) {
latest_devid = device->devid;
latest_transid = device->generation;
latest_bdev = device->bdev;
}
continue;
}

if (device->bdev) {
blkdev_put(device->bdev, device->mode);
Expand All @@ -487,6 +498,10 @@ int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices)
goto again;
}

fs_devices->latest_bdev = latest_bdev;
fs_devices->latest_devid = latest_devid;
fs_devices->latest_trans = latest_transid;

mutex_unlock(&uuid_mutex);
return 0;
}
Expand Down

0 comments on commit 5e1d0c1

Please sign in to comment.