mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
[cascardo/linux.git] / fs / btrfs / volumes.c
index 366b335..bd0f45f 100644 (file)
@@ -138,7 +138,7 @@ static struct btrfs_fs_devices *__alloc_fs_devices(void)
 {
        struct btrfs_fs_devices *fs_devs;
 
-       fs_devs = kzalloc(sizeof(*fs_devs), GFP_NOFS);
+       fs_devs = kzalloc(sizeof(*fs_devs), GFP_KERNEL);
        if (!fs_devs)
                return ERR_PTR(-ENOMEM);
 
@@ -220,7 +220,7 @@ static struct btrfs_device *__alloc_device(void)
 {
        struct btrfs_device *dev;
 
-       dev = kzalloc(sizeof(*dev), GFP_NOFS);
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev)
                return ERR_PTR(-ENOMEM);
 
@@ -733,7 +733,8 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
                 * uuid mutex so nothing we touch in here is going to disappear.
                 */
                if (orig_dev->name) {
-                       name = rcu_string_strdup(orig_dev->name->str, GFP_NOFS);
+                       name = rcu_string_strdup(orig_dev->name->str,
+                                       GFP_KERNEL);
                        if (!name) {
                                kfree(device);
                                goto error;
@@ -1024,16 +1025,16 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
        }
 
        /* make sure our super fits in the device */
-       if (bytenr + PAGE_CACHE_SIZE >= i_size_read(bdev->bd_inode))
+       if (bytenr + PAGE_SIZE >= i_size_read(bdev->bd_inode))
                goto error_bdev_put;
 
        /* make sure our super fits in the page */
-       if (sizeof(*disk_super) > PAGE_CACHE_SIZE)
+       if (sizeof(*disk_super) > PAGE_SIZE)
                goto error_bdev_put;
 
        /* make sure our super doesn't straddle pages on disk */
-       index = bytenr >> PAGE_CACHE_SHIFT;
-       if ((bytenr + sizeof(*disk_super) - 1) >> PAGE_CACHE_SHIFT != index)
+       index = bytenr >> PAGE_SHIFT;
+       if ((bytenr + sizeof(*disk_super) - 1) >> PAGE_SHIFT != index)
                goto error_bdev_put;
 
        /* pull in the page with our super */
@@ -1046,7 +1047,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
        p = kmap(page);
 
        /* align our pointer to the offset of the super block */
-       disk_super = p + (bytenr & ~PAGE_CACHE_MASK);
+       disk_super = p + (bytenr & ~PAGE_MASK);
 
        if (btrfs_super_bytenr(disk_super) != bytenr ||
            btrfs_super_magic(disk_super) != BTRFS_MAGIC)
@@ -1074,7 +1075,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
 
 error_unmap:
        kunmap(page);
-       page_cache_release(page);
+       put_page(page);
 
 error_bdev_put:
        blkdev_put(bdev, flags);
@@ -1714,12 +1715,12 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
        } while (read_seqretry(&root->fs_info->profiles_lock, seq));
 
        num_devices = root->fs_info->fs_devices->num_devices;
-       btrfs_dev_replace_lock(&root->fs_info->dev_replace);
+       btrfs_dev_replace_lock(&root->fs_info->dev_replace, 0);
        if (btrfs_dev_replace_is_ongoing(&root->fs_info->dev_replace)) {
                WARN_ON(num_devices < 1);
                num_devices--;
        }
-       btrfs_dev_replace_unlock(&root->fs_info->dev_replace);
+       btrfs_dev_replace_unlock(&root->fs_info->dev_replace, 0);
 
        if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && num_devices <= 4) {
                ret = BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET;
@@ -2287,7 +2288,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
                goto error;
        }
 
-       name = rcu_string_strdup(device_path, GFP_NOFS);
+       name = rcu_string_strdup(device_path, GFP_KERNEL);
        if (!name) {
                kfree(device);
                ret = -ENOMEM;
@@ -2748,7 +2749,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
            em->start + em->len < chunk_offset) {
                /*
                 * This is a logic error, but we don't want to just rely on the
-                * user having built with ASSERT enabled, so if ASSERT doens't
+                * user having built with ASSERT enabled, so if ASSERT doesn't
                 * do anything we still error out.
                 */
                ASSERT(0);
@@ -2966,7 +2967,7 @@ static int insert_balance_item(struct btrfs_root *root,
        }
 
        key.objectid = BTRFS_BALANCE_OBJECTID;
-       key.type = BTRFS_BALANCE_ITEM_KEY;
+       key.type = BTRFS_TEMPORARY_ITEM_KEY;
        key.offset = 0;
 
        ret = btrfs_insert_empty_item(trans, root, path, &key,
@@ -3015,7 +3016,7 @@ static int del_balance_item(struct btrfs_root *root)
        }
 
        key.objectid = BTRFS_BALANCE_OBJECTID;
-       key.type = BTRFS_BALANCE_ITEM_KEY;
+       key.type = BTRFS_TEMPORARY_ITEM_KEY;
        key.offset = 0;
 
        ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
@@ -3686,12 +3687,12 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
        }
 
        num_devices = fs_info->fs_devices->num_devices;
-       btrfs_dev_replace_lock(&fs_info->dev_replace);
+       btrfs_dev_replace_lock(&fs_info->dev_replace, 0);
        if (btrfs_dev_replace_is_ongoing(&fs_info->dev_replace)) {
                BUG_ON(num_devices < 1);
                num_devices--;
        }
-       btrfs_dev_replace_unlock(&fs_info->dev_replace);
+       btrfs_dev_replace_unlock(&fs_info->dev_replace, 0);
        allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE;
        if (num_devices == 1)
                allowed |= BTRFS_BLOCK_GROUP_DUP;
@@ -3867,7 +3868,7 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info)
                return -ENOMEM;
 
        key.objectid = BTRFS_BALANCE_OBJECTID;
-       key.type = BTRFS_BALANCE_ITEM_KEY;
+       key.type = BTRFS_TEMPORARY_ITEM_KEY;
        key.offset = 0;
 
        ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
@@ -4118,7 +4119,7 @@ out:
  * Callback for btrfs_uuid_tree_iterate().
  * returns:
  * 0   check succeeded, the entry is not outdated.
- * < 0 if an error occured.
+ * < 0 if an error occurred.
  * > 0 if the check failed, which means the caller shall remove the entry.
  */
 static int btrfs_check_uuid_tree_entry(struct btrfs_fs_info *fs_info,
@@ -5062,10 +5063,10 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
                ret = 1;
        free_extent_map(em);
 
-       btrfs_dev_replace_lock(&fs_info->dev_replace);
+       btrfs_dev_replace_lock(&fs_info->dev_replace, 0);
        if (btrfs_dev_replace_is_ongoing(&fs_info->dev_replace))
                ret++;
-       btrfs_dev_replace_unlock(&fs_info->dev_replace);
+       btrfs_dev_replace_unlock(&fs_info->dev_replace, 0);
 
        return ret;
 }
@@ -5325,10 +5326,12 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
        if (!bbio_ret)
                goto out;
 
-       btrfs_dev_replace_lock(dev_replace);
+       btrfs_dev_replace_lock(dev_replace, 0);
        dev_replace_is_ongoing = btrfs_dev_replace_is_ongoing(dev_replace);
        if (!dev_replace_is_ongoing)
-               btrfs_dev_replace_unlock(dev_replace);
+               btrfs_dev_replace_unlock(dev_replace, 0);
+       else
+               btrfs_dev_replace_set_lock_blocking(dev_replace);
 
        if (dev_replace_is_ongoing && mirror_num == map->num_stripes + 1 &&
            !(rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS)) &&
@@ -5751,8 +5754,10 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                bbio->mirror_num = map->num_stripes + 1;
        }
 out:
-       if (dev_replace_is_ongoing)
-               btrfs_dev_replace_unlock(dev_replace);
+       if (dev_replace_is_ongoing) {
+               btrfs_dev_replace_clear_lock_blocking(dev_replace);
+               btrfs_dev_replace_unlock(dev_replace, 0);
+       }
        free_extent_map(em);
        return ret;
 }
@@ -6522,7 +6527,7 @@ int btrfs_read_sys_array(struct btrfs_root *root)
         * but sb spans only this function. Add an explicit SetPageUptodate call
         * to silence the warning eg. on PowerPC 64.
         */
-       if (PAGE_CACHE_SIZE > BTRFS_SUPER_INFO_SIZE)
+       if (PAGE_SIZE > BTRFS_SUPER_INFO_SIZE)
                SetPageUptodate(sb->pages[0]);
 
        write_extent_buffer(sb, super_copy, 0, BTRFS_SUPER_INFO_SIZE);
@@ -6705,8 +6710,8 @@ int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info)
                int item_size;
                struct btrfs_dev_stats_item *ptr;
 
-               key.objectid = 0;
-               key.type = BTRFS_DEV_STATS_KEY;
+               key.objectid = BTRFS_DEV_STATS_OBJECTID;
+               key.type = BTRFS_PERSISTENT_ITEM_KEY;
                key.offset = device->devid;
                ret = btrfs_search_slot(NULL, dev_root, &key, path, 0, 0);
                if (ret) {
@@ -6753,8 +6758,8 @@ static int update_dev_stat_item(struct btrfs_trans_handle *trans,
        int ret;
        int i;
 
-       key.objectid = 0;
-       key.type = BTRFS_DEV_STATS_KEY;
+       key.objectid = BTRFS_DEV_STATS_OBJECTID;
+       key.type = BTRFS_PERSISTENT_ITEM_KEY;
        key.offset = device->devid;
 
        path = btrfs_alloc_path();