diff options
-rw-r--r-- | fs/btrfs/compat.h | 7 | ||||
-rw-r--r-- | fs/btrfs/compression.c | 4 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 27 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 4 | ||||
-rw-r--r-- | fs/btrfs/version.sh | 34 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 41 | ||||
-rw-r--r-- | fs/btrfs/volumes.h | 3 |
7 files changed, 74 insertions, 46 deletions
diff --git a/fs/btrfs/compat.h b/fs/btrfs/compat.h index cd6598b169df..dd1defdbfa36 100644 --- a/fs/btrfs/compat.h +++ b/fs/btrfs/compat.h | |||
@@ -21,4 +21,11 @@ static inline struct dentry *d_obtain_alias(struct inode *inode) | |||
21 | } | 21 | } |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) | ||
25 | # define __pagevec_lru_add_file __pagevec_lru_add | ||
26 | # define open_bdev_exclusive open_bdev_excl | ||
27 | # define close_bdev_exclusive(bdev, mode) close_bdev_excl(bdev) | ||
28 | #endif | ||
29 | |||
30 | |||
24 | #endif /* _COMPAT_H_ */ | 31 | #endif /* _COMPAT_H_ */ |
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index bfd1512cce0a..df05f513e1eb 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c | |||
@@ -419,7 +419,7 @@ static noinline int add_ra_bio_pages(struct inode *inode, | |||
419 | /* open coding of lru_cache_add, also not exported */ | 419 | /* open coding of lru_cache_add, also not exported */ |
420 | page_cache_get(page); | 420 | page_cache_get(page); |
421 | if (!pagevec_add(&pvec, page)) | 421 | if (!pagevec_add(&pvec, page)) |
422 | __pagevec_lru_add(&pvec); | 422 | __pagevec_lru_add_file(&pvec); |
423 | 423 | ||
424 | end = last_offset + PAGE_CACHE_SIZE - 1; | 424 | end = last_offset + PAGE_CACHE_SIZE - 1; |
425 | /* | 425 | /* |
@@ -475,7 +475,7 @@ next: | |||
475 | last_offset += PAGE_CACHE_SIZE; | 475 | last_offset += PAGE_CACHE_SIZE; |
476 | } | 476 | } |
477 | if (pagevec_count(&pvec)) | 477 | if (pagevec_count(&pvec)) |
478 | __pagevec_lru_add(&pvec); | 478 | __pagevec_lru_add_file(&pvec); |
479 | return 0; | 479 | return 0; |
480 | } | 480 | } |
481 | 481 | ||
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index ee73efe75423..62d49705d140 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "volumes.h" | 28 | #include "volumes.h" |
29 | #include "locking.h" | 29 | #include "locking.h" |
30 | #include "ref-cache.h" | 30 | #include "ref-cache.h" |
31 | #include "compat.h" | ||
31 | 32 | ||
32 | #define PENDING_EXTENT_INSERT 0 | 33 | #define PENDING_EXTENT_INSERT 0 |
33 | #define PENDING_EXTENT_DELETE 1 | 34 | #define PENDING_EXTENT_DELETE 1 |
@@ -899,6 +900,17 @@ static int noinline remove_extent_backref(struct btrfs_trans_handle *trans, | |||
899 | return ret; | 900 | return ret; |
900 | } | 901 | } |
901 | 902 | ||
903 | static void btrfs_issue_discard(struct block_device *bdev, | ||
904 | u64 start, u64 len) | ||
905 | { | ||
906 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) | ||
907 | blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL); | ||
908 | #else | ||
909 | blkdev_issue_discard(bdev, start >> 9, len >> 9); | ||
910 | #endif | ||
911 | } | ||
912 | |||
913 | |||
902 | static int noinline free_extents(struct btrfs_trans_handle *trans, | 914 | static int noinline free_extents(struct btrfs_trans_handle *trans, |
903 | struct btrfs_root *extent_root, | 915 | struct btrfs_root *extent_root, |
904 | struct list_head *del_list) | 916 | struct list_head *del_list) |
@@ -1108,6 +1120,7 @@ search: | |||
1108 | BUG_ON(ret); | 1120 | BUG_ON(ret); |
1109 | 1121 | ||
1110 | #ifdef BIO_RW_DISCARD | 1122 | #ifdef BIO_RW_DISCARD |
1123 | map_length = tmp->num_bytes; | ||
1111 | ret = btrfs_map_block(&info->mapping_tree, READ, | 1124 | ret = btrfs_map_block(&info->mapping_tree, READ, |
1112 | tmp->bytenr, &map_length, &multi, | 1125 | tmp->bytenr, &map_length, &multi, |
1113 | 0); | 1126 | 0); |
@@ -1115,16 +1128,16 @@ search: | |||
1115 | struct btrfs_bio_stripe *stripe; | 1128 | struct btrfs_bio_stripe *stripe; |
1116 | int i; | 1129 | int i; |
1117 | 1130 | ||
1118 | stripe = multi->stripe; | 1131 | stripe = multi->stripes; |
1119 | 1132 | ||
1120 | if (map_length > tmp->num_bytes) | 1133 | if (map_length > tmp->num_bytes) |
1121 | map_length = tmp->num_bytes; | 1134 | map_length = tmp->num_bytes; |
1122 | 1135 | ||
1123 | for (i = 0; i < multi->num_stripes; | 1136 | for (i = 0; i < multi->num_stripes; |
1124 | i++, stripe++) | 1137 | i++, stripe++) |
1125 | blkdev_issue_discard(stripe->dev->bdev, | 1138 | btrfs_issue_discard(stripe->dev->bdev, |
1126 | stripe->physical >> 9, | 1139 | stripe->physical, |
1127 | map_length >> 9); | 1140 | map_length); |
1128 | kfree(multi); | 1141 | kfree(multi); |
1129 | } | 1142 | } |
1130 | #endif | 1143 | #endif |
@@ -2498,9 +2511,9 @@ static int __free_extent(struct btrfs_trans_handle *trans, | |||
2498 | map_length = num_bytes; | 2511 | map_length = num_bytes; |
2499 | 2512 | ||
2500 | for (i = 0; i < multi->num_stripes; i++, stripe++) { | 2513 | for (i = 0; i < multi->num_stripes; i++, stripe++) { |
2501 | blkdev_issue_discard(stripe->dev->bdev, | 2514 | btrfs_issue_discard(stripe->dev->bdev, |
2502 | stripe->physical >> 9, | 2515 | stripe->physical, |
2503 | map_length >> 9); | 2516 | map_length); |
2504 | } | 2517 | } |
2505 | kfree(multi); | 2518 | kfree(multi); |
2506 | } | 2519 | } |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index a0f3804efe4f..3a65c10dce33 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -2639,14 +2639,14 @@ int extent_readpages(struct extent_io_tree *tree, | |||
2639 | /* open coding of lru_cache_add, also not exported */ | 2639 | /* open coding of lru_cache_add, also not exported */ |
2640 | page_cache_get(page); | 2640 | page_cache_get(page); |
2641 | if (!pagevec_add(&pvec, page)) | 2641 | if (!pagevec_add(&pvec, page)) |
2642 | __pagevec_lru_add(&pvec); | 2642 | __pagevec_lru_add_file(&pvec); |
2643 | __extent_read_full_page(tree, page, get_extent, | 2643 | __extent_read_full_page(tree, page, get_extent, |
2644 | &bio, 0, &bio_flags); | 2644 | &bio, 0, &bio_flags); |
2645 | } | 2645 | } |
2646 | page_cache_release(page); | 2646 | page_cache_release(page); |
2647 | } | 2647 | } |
2648 | if (pagevec_count(&pvec)) | 2648 | if (pagevec_count(&pvec)) |
2649 | __pagevec_lru_add(&pvec); | 2649 | __pagevec_lru_add_file(&pvec); |
2650 | BUG_ON(!list_empty(pages)); | 2650 | BUG_ON(!list_empty(pages)); |
2651 | if (bio) | 2651 | if (bio) |
2652 | submit_one_bio(READ, bio, 0, bio_flags); | 2652 | submit_one_bio(READ, bio, 0, bio_flags); |
diff --git a/fs/btrfs/version.sh b/fs/btrfs/version.sh index 0f57f24404d9..1ca1952fd917 100644 --- a/fs/btrfs/version.sh +++ b/fs/btrfs/version.sh | |||
@@ -8,24 +8,24 @@ | |||
8 | 8 | ||
9 | v="v0.16" | 9 | v="v0.16" |
10 | 10 | ||
11 | which hg > /dev/null | 11 | which git &> /dev/null |
12 | if [ -d .hg ] && [ $? == 0 ]; then | 12 | if [ $? == 0 ]; then |
13 | last=$(hg tags | grep -m1 -o '^v[0-9.]\+') | 13 | git branch >& /dev/null |
14 | 14 | if [ $? == 0 ]; then | |
15 | # now check if the repo has commits since then... | 15 | if head=`git rev-parse --verify HEAD 2>/dev/null`; then |
16 | if [[ $(hg id -t) == $last || \ | 16 | if tag=`git describe --tags 2>/dev/null`; then |
17 | $(hg di -r "$last:." | awk '/^diff/{print $NF}' | sort -u) == .hgtags ]] | 17 | v="$tag" |
18 | then | 18 | fi |
19 | # check if it's dirty | 19 | |
20 | if [[ $(hg id | cut -d' ' -f1) == *+ ]]; then | 20 | # Are there uncommitted changes? |
21 | v=$last+ | 21 | git update-index --refresh --unmerged > /dev/null |
22 | else | 22 | if git diff-index --name-only HEAD | \ |
23 | v=$last | 23 | grep -v "^scripts/package" \ |
24 | | read dummy; then | ||
25 | v="$v"-dirty | ||
26 | fi | ||
24 | fi | 27 | fi |
25 | else | 28 | fi |
26 | # includes dirty flag | ||
27 | v=$last+$(hg id -i) | ||
28 | fi | ||
29 | fi | 29 | fi |
30 | 30 | ||
31 | echo "#ifndef __BUILD_VERSION" > .build-version.h | 31 | echo "#ifndef __BUILD_VERSION" > .build-version.h |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ecf0633ab8cc..c3ee63f92a5f 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -85,7 +85,7 @@ int btrfs_cleanup_fs_uuids(void) | |||
85 | dev = list_entry(fs_devices->devices.next, | 85 | dev = list_entry(fs_devices->devices.next, |
86 | struct btrfs_device, dev_list); | 86 | struct btrfs_device, dev_list); |
87 | if (dev->bdev) { | 87 | if (dev->bdev) { |
88 | close_bdev_excl(dev->bdev); | 88 | close_bdev_exclusive(dev->bdev, dev->mode); |
89 | fs_devices->open_devices--; | 89 | fs_devices->open_devices--; |
90 | } | 90 | } |
91 | fs_devices->num_devices--; | 91 | fs_devices->num_devices--; |
@@ -317,7 +317,7 @@ again: | |||
317 | continue; | 317 | continue; |
318 | 318 | ||
319 | if (device->bdev) { | 319 | if (device->bdev) { |
320 | close_bdev_excl(device->bdev); | 320 | close_bdev_exclusive(device->bdev, device->mode); |
321 | device->bdev = NULL; | 321 | device->bdev = NULL; |
322 | fs_devices->open_devices--; | 322 | fs_devices->open_devices--; |
323 | } | 323 | } |
@@ -356,7 +356,7 @@ again: | |||
356 | list_for_each(cur, &fs_devices->devices) { | 356 | list_for_each(cur, &fs_devices->devices) { |
357 | device = list_entry(cur, struct btrfs_device, dev_list); | 357 | device = list_entry(cur, struct btrfs_device, dev_list); |
358 | if (device->bdev) { | 358 | if (device->bdev) { |
359 | close_bdev_excl(device->bdev); | 359 | close_bdev_exclusive(device->bdev, device->mode); |
360 | fs_devices->open_devices--; | 360 | fs_devices->open_devices--; |
361 | } | 361 | } |
362 | if (device->writeable) { | 362 | if (device->writeable) { |
@@ -391,7 +391,8 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices) | |||
391 | return ret; | 391 | return ret; |
392 | } | 392 | } |
393 | 393 | ||
394 | int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder) | 394 | int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, |
395 | int flags, void *holder) | ||
395 | { | 396 | { |
396 | struct block_device *bdev; | 397 | struct block_device *bdev; |
397 | struct list_head *head = &fs_devices->devices; | 398 | struct list_head *head = &fs_devices->devices; |
@@ -413,7 +414,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder) | |||
413 | if (!device->name) | 414 | if (!device->name) |
414 | continue; | 415 | continue; |
415 | 416 | ||
416 | bdev = open_bdev_excl(device->name, MS_RDONLY, holder); | 417 | bdev = open_bdev_exclusive(device->name, flags, holder); |
417 | if (IS_ERR(bdev)) { | 418 | if (IS_ERR(bdev)) { |
418 | printk("open %s failed\n", device->name); | 419 | printk("open %s failed\n", device->name); |
419 | goto error; | 420 | goto error; |
@@ -453,6 +454,8 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder) | |||
453 | 454 | ||
454 | device->bdev = bdev; | 455 | device->bdev = bdev; |
455 | device->in_fs_metadata = 0; | 456 | device->in_fs_metadata = 0; |
457 | device->mode = flags; | ||
458 | |||
456 | fs_devices->open_devices++; | 459 | fs_devices->open_devices++; |
457 | if (device->writeable) { | 460 | if (device->writeable) { |
458 | fs_devices->rw_devices++; | 461 | fs_devices->rw_devices++; |
@@ -464,7 +467,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder) | |||
464 | error_brelse: | 467 | error_brelse: |
465 | brelse(bh); | 468 | brelse(bh); |
466 | error_close: | 469 | error_close: |
467 | close_bdev_excl(bdev); | 470 | close_bdev_exclusive(bdev, MS_RDONLY); |
468 | error: | 471 | error: |
469 | continue; | 472 | continue; |
470 | } | 473 | } |
@@ -496,7 +499,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | |||
496 | ret = 0; | 499 | ret = 0; |
497 | } | 500 | } |
498 | } else { | 501 | } else { |
499 | ret = __btrfs_open_devices(fs_devices, holder); | 502 | ret = __btrfs_open_devices(fs_devices, flags, holder); |
500 | } | 503 | } |
501 | mutex_unlock(&uuid_mutex); | 504 | mutex_unlock(&uuid_mutex); |
502 | return ret; | 505 | return ret; |
@@ -514,7 +517,7 @@ int btrfs_scan_one_device(const char *path, int flags, void *holder, | |||
514 | 517 | ||
515 | mutex_lock(&uuid_mutex); | 518 | mutex_lock(&uuid_mutex); |
516 | 519 | ||
517 | bdev = open_bdev_excl(path, flags, holder); | 520 | bdev = open_bdev_exclusive(path, flags, holder); |
518 | 521 | ||
519 | if (IS_ERR(bdev)) { | 522 | if (IS_ERR(bdev)) { |
520 | ret = PTR_ERR(bdev); | 523 | ret = PTR_ERR(bdev); |
@@ -551,7 +554,7 @@ int btrfs_scan_one_device(const char *path, int flags, void *holder, | |||
551 | error_brelse: | 554 | error_brelse: |
552 | brelse(bh); | 555 | brelse(bh); |
553 | error_close: | 556 | error_close: |
554 | close_bdev_excl(bdev); | 557 | close_bdev_exclusive(bdev, flags); |
555 | error: | 558 | error: |
556 | mutex_unlock(&uuid_mutex); | 559 | mutex_unlock(&uuid_mutex); |
557 | return ret; | 560 | return ret; |
@@ -1003,7 +1006,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1003 | goto out; | 1006 | goto out; |
1004 | } | 1007 | } |
1005 | } else { | 1008 | } else { |
1006 | bdev = open_bdev_excl(device_path, MS_RDONLY, | 1009 | bdev = open_bdev_exclusive(device_path, MS_RDONLY, |
1007 | root->fs_info->bdev_holder); | 1010 | root->fs_info->bdev_holder); |
1008 | if (IS_ERR(bdev)) { | 1011 | if (IS_ERR(bdev)) { |
1009 | ret = PTR_ERR(bdev); | 1012 | ret = PTR_ERR(bdev); |
@@ -1073,10 +1076,10 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1073 | BUG_ON(device->writeable); | 1076 | BUG_ON(device->writeable); |
1074 | brelse(bh); | 1077 | brelse(bh); |
1075 | if (bdev) | 1078 | if (bdev) |
1076 | close_bdev_excl(bdev); | 1079 | close_bdev_exclusive(bdev, MS_RDONLY); |
1077 | 1080 | ||
1078 | if (device->bdev) { | 1081 | if (device->bdev) { |
1079 | close_bdev_excl(device->bdev); | 1082 | close_bdev_exclusive(device->bdev, device->mode); |
1080 | device->bdev = NULL; | 1083 | device->bdev = NULL; |
1081 | device->fs_devices->open_devices--; | 1084 | device->fs_devices->open_devices--; |
1082 | } | 1085 | } |
@@ -1112,11 +1115,11 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1112 | 1115 | ||
1113 | if (device->bdev) { | 1116 | if (device->bdev) { |
1114 | /* one close for the device struct or super_block */ | 1117 | /* one close for the device struct or super_block */ |
1115 | close_bdev_excl(device->bdev); | 1118 | close_bdev_exclusive(device->bdev, device->mode); |
1116 | } | 1119 | } |
1117 | if (bdev) { | 1120 | if (bdev) { |
1118 | /* one close for us */ | 1121 | /* one close for us */ |
1119 | close_bdev_excl(bdev); | 1122 | close_bdev_exclusive(bdev, MS_RDONLY); |
1120 | } | 1123 | } |
1121 | kfree(device->name); | 1124 | kfree(device->name); |
1122 | kfree(device); | 1125 | kfree(device); |
@@ -1127,7 +1130,7 @@ error_brelse: | |||
1127 | brelse(bh); | 1130 | brelse(bh); |
1128 | error_close: | 1131 | error_close: |
1129 | if (bdev) | 1132 | if (bdev) |
1130 | close_bdev_excl(bdev); | 1133 | close_bdev_exclusive(bdev, MS_RDONLY); |
1131 | out: | 1134 | out: |
1132 | mutex_unlock(&root->fs_info->volume_mutex); | 1135 | mutex_unlock(&root->fs_info->volume_mutex); |
1133 | mutex_unlock(&uuid_mutex); | 1136 | mutex_unlock(&uuid_mutex); |
@@ -1272,7 +1275,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
1272 | if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding) | 1275 | if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding) |
1273 | return -EINVAL; | 1276 | return -EINVAL; |
1274 | 1277 | ||
1275 | bdev = open_bdev_excl(device_path, 0, root->fs_info->bdev_holder); | 1278 | bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder); |
1276 | if (!bdev) { | 1279 | if (!bdev) { |
1277 | return -EIO; | 1280 | return -EIO; |
1278 | } | 1281 | } |
@@ -1331,6 +1334,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
1331 | device->dev_root = root->fs_info->dev_root; | 1334 | device->dev_root = root->fs_info->dev_root; |
1332 | device->bdev = bdev; | 1335 | device->bdev = bdev; |
1333 | device->in_fs_metadata = 1; | 1336 | device->in_fs_metadata = 1; |
1337 | device->mode = 0; | ||
1334 | set_blocksize(device->bdev, 4096); | 1338 | set_blocksize(device->bdev, 4096); |
1335 | 1339 | ||
1336 | if (seeding_dev) { | 1340 | if (seeding_dev) { |
@@ -1379,7 +1383,7 @@ out: | |||
1379 | mutex_unlock(&root->fs_info->volume_mutex); | 1383 | mutex_unlock(&root->fs_info->volume_mutex); |
1380 | return ret; | 1384 | return ret; |
1381 | error: | 1385 | error: |
1382 | close_bdev_excl(bdev); | 1386 | close_bdev_exclusive(bdev, 0); |
1383 | if (seeding_dev) { | 1387 | if (seeding_dev) { |
1384 | mutex_unlock(&uuid_mutex); | 1388 | mutex_unlock(&uuid_mutex); |
1385 | up_write(&sb->s_umount); | 1389 | up_write(&sb->s_umount); |
@@ -2907,7 +2911,8 @@ static int open_seed_devices(struct btrfs_root *root, u8 *fsid) | |||
2907 | goto out; | 2911 | goto out; |
2908 | } | 2912 | } |
2909 | 2913 | ||
2910 | ret = __btrfs_open_devices(fs_devices, root->fs_info->bdev_holder); | 2914 | ret = __btrfs_open_devices(fs_devices, MS_RDONLY, |
2915 | root->fs_info->bdev_holder); | ||
2911 | if (ret) | 2916 | if (ret) |
2912 | goto out; | 2917 | goto out; |
2913 | 2918 | ||
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 1f6f25a5787f..9b41e4d3984d 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -42,6 +42,9 @@ struct btrfs_device { | |||
42 | 42 | ||
43 | struct block_device *bdev; | 43 | struct block_device *bdev; |
44 | 44 | ||
45 | /* the mode sent to open_bdev_exclusive */ | ||
46 | fmode_t mode; | ||
47 | |||
45 | char *name; | 48 | char *name; |
46 | 49 | ||
47 | /* the internal btrfs device id */ | 50 | /* the internal btrfs device id */ |