Skip to content

Commit

Permalink
btrfs: Update existing btrfs_device for renaming device
Browse files Browse the repository at this point in the history
When we scan devices in a multi-device filesystem, we memorize the original
name.  If the device gets a new name, later scans don't update the
in-kernel structures related to it, and we're not able to mount the
filesystem.

This patch updates device name during scaning.

Signed-off-by: TARUISI Hiroaki <taruishi.hiroak@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
TARUISI Hiroaki authored and Chris Mason committed Mar 15, 2010
1 parent 1e701a3 commit 3a0524d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ static noinline int device_list_add(const char *path,
struct btrfs_device *device;
struct btrfs_fs_devices *fs_devices;
u64 found_transid = btrfs_super_generation(disk_super);
char *name;

fs_devices = find_fsid(disk_super->fsid);
if (!fs_devices) {
Expand Down Expand Up @@ -411,6 +412,12 @@ static noinline int device_list_add(const char *path,

device->fs_devices = fs_devices;
fs_devices->num_devices++;
} else if (strcmp(device->name, path)) {
name = kstrdup(path, GFP_NOFS);
if (!name)
return -ENOMEM;
kfree(device->name);
device->name = name;
}

if (found_transid > fs_devices->latest_trans) {
Expand Down

0 comments on commit 3a0524d

Please sign in to comment.