Btrfs: Fixes for 2.6.28-rc API changes
authorChris Mason <chris.mason@oracle.com>
Thu, 20 Nov 2008 02:17:22 +0000 (21:17 -0500)
committerChris Mason <chris.mason@oracle.com>
Thu, 20 Nov 2008 02:17:22 +0000 (21:17 -0500)
* 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: Chris Mason <chris.mason@oracle.com>
fs/btrfs/compat.h
fs/btrfs/compression.c
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c
fs/btrfs/version.sh
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index cd6598b169df34d61904197ce00361db86752b5c..dd1defdbfa36801548b8b287612df9d737a2f2f6 100644 (file)
@@ -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_ */
index bfd1512cce0a5616796b6328d22b581e7b3e3ace..df05f513e1ebcb2f4ae20511c1cc1165f26f83e4 100644 (file)
@@ -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 @@ next:
                last_offset += PAGE_CACHE_SIZE;
        }
        if (pagevec_count(&pvec))
-               __pagevec_lru_add(&pvec);
+               __pagevec_lru_add_file(&pvec);
        return 0;
 }
 
index ee73efe75423e71b47e38e3096081f0b1c644a43..62d49705d14047890996a965123fd630ef53735c 100644 (file)
@@ -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 @@ search:
                        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 @@ search:
                                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);
                }
index a0f3804efe4f36e46ebaa4a1fe1ac5d0b0ca9153..3a65c10dce3358b57f7b4b50b37ac1951e452d89 100644 (file)
@@ -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);
index 0f57f24404d95fffeecfcc80beae6eb57cf95242..1ca1952fd917efac9978d6596343e74f6cc05cec 100644 (file)
@@ -8,24 +8,24 @@
  
 v="v0.16"
 
-which hg > /dev/null
-if [ -d .hg ] && [ $? == 0 ]; then
-       last=$(hg tags | grep -m1 -o '^v[0-9.]\+')
-        
-       # 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
+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
+
+               # 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
 fi
  
 echo "#ifndef __BUILD_VERSION" > .build-version.h
index ecf0633ab8cc9093cb6e48beb034dfc1274c5a24..c3ee63f92a5f968518a0d1f7a10911baac14d819 100644 (file)
@@ -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 @@ again:
                        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 @@ again:
        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 @@ error_brelse:
        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 @@ out:
        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;
 
index 1f6f25a5787f49ab1314ac8a464f889d80085dab..9b41e4d3984d2206670b351deb6a1ad10060ac0e 100644 (file)
@@ -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 */