/*
* Copyright (C) 2007 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License v2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*/
#include <linux/sched.h>
#include <linux/bio.h>
#include <linux/buffer_head.h>
#include <asm/div64.h>
#include "ctree.h"
#include "extent_map.h"
#include "disk-io.h"
#include "transaction.h"
#include "print-tree.h"
#include "volumes.h"
struct map_lookup {
u64 type;
int io_align;
int io_width;
int stripe_len;
int sector_size;
int num_stripes;
struct btrfs_bio_stripe stripes[];
};
#define map_lookup_size(n) (sizeof(struct map_lookup) + \
(sizeof(struct btrfs_bio_stripe) * (n)))
static DEFINE_MUTEX(uuid_mutex);
static LIST_HEAD(fs_uuids);
int btrfs_cleanup_fs_uuids(void)
{
struct btrfs_fs_devices *fs_devices;
struct list_head *uuid_cur;
struct list_head *devices_cur;
struct btrfs_device *dev;
list_for_each(uuid_cur, &fs_uuids) {
fs_devices = list_entry(uuid_cur, struct btrfs_fs_devices,
list);
while(!list_empty(&fs_devices->devices)) {
devices_cur = fs_devices->devices.next;
dev = list_entry(devices_cur, struct btrfs_device,
dev_list);
printk("uuid cleanup finds %s\n", dev->name);
if (dev->bdev) {
printk("closing\n");
close_bdev_excl(dev->bdev);
}
list_del(&dev->dev_list);
kfree(dev);
}
}
return 0;
}
static struct btrfs_device *__find_device(struct list_head *head, u64 devid)
{
struct btrfs_device *dev;
struct list_head *cur;
list_for_each(cur, head) {
dev = list_entry(cur, struct btrfs_device, dev_list);
if (dev->devid == devid)
return dev;
}
return NULL;
}
static struct btrfs_fs_devices *find_fsid(u8 *fsid)
{
struct list_head *cur;
struct btrfs_fs_devices *fs_devices;
list_for_each(cur, &fs_uuids) {
fs_devices = list_entry(cur, struct btrfs_fs_devices, list);
if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0)
return fs_devices;
}
return NULL;
}
static int device_list_add(const char *path,
struct btrfs_super_block