Commit 15916de8 authored by Chris Mason's avatar Chris Mason

Btrfs: Fixes for 2.6.28-rc API changes

* open/close_bdev_excl -> open/close_bdev_exclusive
* blkdev_issue_discard takes a GFP mask now
* Fix blkdev_issue_discard usage now that it is enabled
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent ae20a6af
......@@ -21,4 +21,11 @@ static inline struct dentry *d_obtain_alias(struct inode *inode)
}
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
# define __pagevec_lru_add_file __pagevec_lru_add
# define open_bdev_exclusive open_bdev_excl
# define close_bdev_exclusive(bdev, mode) close_bdev_excl(bdev)
#endif
#endif /* _COMPAT_H_ */
......@@ -419,7 +419,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
/* open coding of lru_cache_add, also not exported */
page_cache_get(page);
if (!pagevec_add(&pvec, page))
__pagevec_lru_add(&pvec);
__pagevec_lru_add_file(&pvec);
end = last_offset + PAGE_CACHE_SIZE - 1;
/*
......@@ -475,7 +475,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
last_offset += PAGE_CACHE_SIZE;
}
if (pagevec_count(&pvec))
__pagevec_lru_add(&pvec);
__pagevec_lru_add_file(&pvec);
return 0;
}
......
......@@ -28,6 +28,7 @@
#include "volumes.h"
#include "locking.h"
#include "ref-cache.h"
#include "compat.h"
#define PENDING_EXTENT_INSERT 0
#define PENDING_EXTENT_DELETE 1
......@@ -899,6 +900,17 @@ static int noinline remove_extent_backref(struct btrfs_trans_handle *trans,
return ret;
}
static void btrfs_issue_discard(struct block_device *bdev,
u64 start, u64 len)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL);
#else
blkdev_issue_discard(bdev, start >> 9, len >> 9);
#endif
}
static int noinline free_extents(struct btrfs_trans_handle *trans,
struct btrfs_root *extent_root,
struct list_head *del_list)
......@@ -1108,6 +1120,7 @@ static int noinline free_extents(struct btrfs_trans_handle *trans,
BUG_ON(ret);
#ifdef BIO_RW_DISCARD
map_length = tmp->num_bytes;
ret = btrfs_map_block(&info->mapping_tree, READ,
tmp->bytenr, &map_length, &multi,
0);
......@@ -1115,16 +1128,16 @@ static int noinline free_extents(struct btrfs_trans_handle *trans,
struct btrfs_bio_stripe *stripe;
int i;
stripe = multi->stripe;
stripe = multi->stripes;
if (map_length > tmp->num_bytes)
map_length = tmp->num_bytes;
for (i = 0; i < multi->num_stripes;
i++, stripe++)
blkdev_issue_discard(stripe->dev->bdev,
stripe->physical >> 9,
map_length >> 9);
btrfs_issue_discard(stripe->dev->bdev,
stripe->physical,
map_length);
kfree(multi);
}
#endif
......@@ -2498,9 +2511,9 @@ static int __free_extent(struct btrfs_trans_handle *trans,
map_length = num_bytes;
for (i = 0; i < multi->num_stripes; i++, stripe++) {
blkdev_issue_discard(stripe->dev->bdev,
stripe->physical >> 9,
map_length >> 9);
btrfs_issue_discard(stripe->dev->bdev,
stripe->physical,
map_length);
}
kfree(multi);
}
......
......@@ -2639,14 +2639,14 @@ int extent_readpages(struct extent_io_tree *tree,
/* open coding of lru_cache_add, also not exported */
page_cache_get(page);
if (!pagevec_add(&pvec, page))
__pagevec_lru_add(&pvec);
__pagevec_lru_add_file(&pvec);
__extent_read_full_page(tree, page, get_extent,
&bio, 0, &bio_flags);
}
page_cache_release(page);
}
if (pagevec_count(&pvec))
__pagevec_lru_add(&pvec);
__pagevec_lru_add_file(&pvec);
BUG_ON(!list_empty(pages));
if (bio)
submit_one_bio(READ, bio, 0, bio_flags);
......
......@@ -8,23 +8,23 @@
v="v0.16"
which hg > /dev/null
if [ -d .hg ] && [ $? == 0 ]; then
last=$(hg tags | grep -m1 -o '^v[0-9.]\+')
which git &> /dev/null
if [ $? == 0 ]; then
git branch >& /dev/null
if [ $? == 0 ]; then
if head=`git rev-parse --verify HEAD 2>/dev/null`; then
if tag=`git describe --tags 2>/dev/null`; then
v="$tag"
fi
# now check if the repo has commits since then...
if [[ $(hg id -t) == $last || \
$(hg di -r "$last:." | awk '/^diff/{print $NF}' | sort -u) == .hgtags ]]
then
# check if it's dirty
if [[ $(hg id | cut -d' ' -f1) == *+ ]]; then
v=$last+
else
v=$last
# Are there uncommitted changes?
git update-index --refresh --unmerged > /dev/null
if git diff-index --name-only HEAD | \
grep -v "^scripts/package" \
| read dummy; then
v="$v"-dirty
fi
fi
else
# includes dirty flag
v=$last+$(hg id -i)
fi
fi
......
......@@ -85,7 +85,7 @@ int btrfs_cleanup_fs_uuids(void)
dev = list_entry(fs_devices->devices.next,
struct btrfs_device, dev_list);
if (dev->bdev) {
close_bdev_excl(dev->bdev);
close_bdev_exclusive(dev->bdev, dev->mode);
fs_devices->open_devices--;
}
fs_devices->num_devices--;
......@@ -317,7 +317,7 @@ int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices)
continue;
if (device->bdev) {
close_bdev_excl(device->bdev);
close_bdev_exclusive(device->bdev, device->mode);
device->bdev = NULL;
fs_devices->open_devices--;
}
......@@ -356,7 +356,7 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
list_for_each(cur, &fs_devices->devices) {
device = list_entry(cur, struct btrfs_device, dev_list);
if (device->bdev) {
close_bdev_excl(device->bdev);
close_bdev_exclusive(device->bdev, device->mode);
fs_devices->open_devices--;
}
if (device->writeable) {
......@@ -391,7 +391,8 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
return ret;
}
int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder)
int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
int flags, void *holder)
{
struct block_device *bdev;
struct list_head *head = &fs_devices->devices;
......@@ -413,7 +414,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder)
if (!device->name)
continue;
bdev = open_bdev_excl(device->name, MS_RDONLY, holder);
bdev = open_bdev_exclusive(device->name, flags, holder);
if (IS_ERR(bdev)) {
printk("open %s failed\n", device->name);
goto error;
......@@ -453,6 +454,8 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder)
device->bdev = bdev;
device->in_fs_metadata = 0;
device->mode = flags;
fs_devices->open_devices++;
if (device->writeable) {
fs_devices->rw_devices++;
......@@ -464,7 +467,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder)
error_brelse:
brelse(bh);
error_close:
close_bdev_excl(bdev);
close_bdev_exclusive(bdev, MS_RDONLY);
error:
continue;
}
......@@ -496,7 +499,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
ret = 0;
}
} else {
ret = __btrfs_open_devices(fs_devices, holder);
ret = __btrfs_open_devices(fs_devices, flags, holder);
}
mutex_unlock(&uuid_mutex);
return ret;
......@@ -514,7 +517,7 @@ int btrfs_scan_one_device(const char *path, int flags, void *holder,
mutex_lock(&uuid_mutex);
bdev = open_bdev_excl(path, flags, holder);
bdev = open_bdev_exclusive(path, flags, holder);
if (IS_ERR(bdev)) {
ret = PTR_ERR(bdev);
......@@ -551,7 +554,7 @@ int btrfs_scan_one_device(const char *path, int flags, void *holder,
error_brelse:
brelse(bh);
error_close:
close_bdev_excl(bdev);
close_bdev_exclusive(bdev, flags);
error:
mutex_unlock(&uuid_mutex);
return ret;
......@@ -1003,7 +1006,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
goto out;
}
} else {
bdev = open_bdev_excl(device_path, MS_RDONLY,
bdev = open_bdev_exclusive(device_path, MS_RDONLY,
root->fs_info->bdev_holder);
if (IS_ERR(bdev)) {
ret = PTR_ERR(bdev);
......@@ -1073,10 +1076,10 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
BUG_ON(device->writeable);
brelse(bh);
if (bdev)
close_bdev_excl(bdev);
close_bdev_exclusive(bdev, MS_RDONLY);
if (device->bdev) {
close_bdev_excl(device->bdev);
close_bdev_exclusive(device->bdev, device->mode);
device->bdev = NULL;
device->fs_devices->open_devices--;
}
......@@ -1112,11 +1115,11 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
if (device->bdev) {
/* one close for the device struct or super_block */
close_bdev_excl(device->bdev);
close_bdev_exclusive(device->bdev, device->mode);
}
if (bdev) {
/* one close for us */
close_bdev_excl(bdev);
close_bdev_exclusive(bdev, MS_RDONLY);
}
kfree(device->name);
kfree(device);
......@@ -1127,7 +1130,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
brelse(bh);
error_close:
if (bdev)
close_bdev_excl(bdev);
close_bdev_exclusive(bdev, MS_RDONLY);
out:
mutex_unlock(&root->fs_info->volume_mutex);
mutex_unlock(&uuid_mutex);
......@@ -1272,7 +1275,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding)
return -EINVAL;
bdev = open_bdev_excl(device_path, 0, root->fs_info->bdev_holder);
bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder);
if (!bdev) {
return -EIO;
}
......@@ -1331,6 +1334,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
device->dev_root = root->fs_info->dev_root;
device->bdev = bdev;
device->in_fs_metadata = 1;
device->mode = 0;
set_blocksize(device->bdev, 4096);
if (seeding_dev) {
......@@ -1379,7 +1383,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
mutex_unlock(&root->fs_info->volume_mutex);
return ret;
error:
close_bdev_excl(bdev);
close_bdev_exclusive(bdev, 0);
if (seeding_dev) {
mutex_unlock(&uuid_mutex);
up_write(&sb->s_umount);
......@@ -2907,7 +2911,8 @@ static int open_seed_devices(struct btrfs_root *root, u8 *fsid)
goto out;
}
ret = __btrfs_open_devices(fs_devices, root->fs_info->bdev_holder);
ret = __btrfs_open_devices(fs_devices, MS_RDONLY,
root->fs_info->bdev_holder);
if (ret)
goto out;
......
......@@ -42,6 +42,9 @@ struct btrfs_device {
struct block_device *bdev;
/* the mode sent to open_bdev_exclusive */
fmode_t mode;
char *name;
/* the internal btrfs device id */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment