btrfs: remove blocksize from btrfs_alloc_free_block and rename
[linux-2.6-block.git] / fs / btrfs / ioctl.c
index 8a8e29878c34283812f8d990c2432cff94bbab2a..2fc48905ccf51c09e14d53cb38874450dcc24b45 100644 (file)
@@ -332,6 +332,9 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
                        goto out_drop;
 
        } else {
+               ret = btrfs_set_prop(inode, "btrfs.compression", NULL, 0, 0);
+               if (ret && ret != -ENODATA)
+                       goto out_drop;
                ip->flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);
        }
 
@@ -477,8 +480,7 @@ static noinline int create_subvol(struct inode *dir,
        if (ret)
                goto fail;
 
-       leaf = btrfs_alloc_free_block(trans, root, root->leafsize,
-                                     0, objectid, NULL, 0, 0, 0);
+       leaf = btrfs_alloc_tree_block(trans, root, 0, objectid, NULL, 0, 0, 0);
        if (IS_ERR(leaf)) {
                ret = PTR_ERR(leaf);
                goto fail;
@@ -503,7 +505,7 @@ static noinline int create_subvol(struct inode *dir,
        btrfs_set_stack_inode_generation(inode_item, 1);
        btrfs_set_stack_inode_size(inode_item, 3);
        btrfs_set_stack_inode_nlink(inode_item, 1);
-       btrfs_set_stack_inode_nbytes(inode_item, root->leafsize);
+       btrfs_set_stack_inode_nbytes(inode_item, root->nodesize);
        btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755);
 
        btrfs_set_root_flags(&root_item, 0);
@@ -535,7 +537,7 @@ static noinline int create_subvol(struct inode *dir,
 
        key.objectid = objectid;
        key.offset = 0;
-       btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
+       key.type = BTRFS_ROOT_ITEM_KEY;
        ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key,
                                &root_item);
        if (ret)
@@ -936,12 +938,9 @@ static int find_new_extents(struct btrfs_root *root,
        min_key.offset = *off;
 
        while (1) {
-               path->keep_locks = 1;
                ret = btrfs_search_forward(root, &min_key, path, newer_than);
                if (ret != 0)
                        goto none;
-               path->keep_locks = 0;
-               btrfs_unlock_up_safe(path, 1);
 process_slot:
                if (min_key.objectid != ino)
                        goto none;
@@ -1335,8 +1334,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
                inode->i_mapping->writeback_index = i;
 
        while (i <= last_index && defrag_count < max_to_defrag &&
-              (i < (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>
-               PAGE_CACHE_SHIFT)) {
+              (i < DIV_ROUND_UP(i_size_read(inode), PAGE_CACHE_SIZE))) {
                /*
                 * make sure we stop running if someone unmounts
                 * the FS
@@ -1359,7 +1357,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
                         * the should_defrag function tells us how much to skip
                         * bump our counter by the suggested amount
                         */
-                       next = (skip + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+                       next = DIV_ROUND_UP(skip, PAGE_CACHE_SIZE);
                        i = max(i + 1, next);
                        continue;
                }
@@ -1554,7 +1552,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
                goto out_free;
        }
 
-       old_size = device->total_bytes;
+       old_size = btrfs_device_get_total_bytes(device);
 
        if (mod < 0) {
                if (new_size > old_size) {
@@ -2089,8 +2087,6 @@ static noinline int search_ioctl(struct inode *inode,
        key.type = sk->min_type;
        key.offset = sk->min_offset;
 
-       path->keep_locks = 1;
-
        while (1) {
                ret = btrfs_search_forward(root, &key, path, sk->min_transid);
                if (ret != 0) {
@@ -2526,9 +2522,9 @@ out_unlock:
                ASSERT(dest->send_in_progress == 0);
 
                /* the last ref */
-               if (dest->cache_inode) {
-                       iput(dest->cache_inode);
-                       dest->cache_inode = NULL;
+               if (dest->ino_cache_inode) {
+                       iput(dest->ino_cache_inode);
+                       dest->ino_cache_inode = NULL;
                }
        }
 out_dput:
@@ -2634,6 +2630,9 @@ static long btrfs_ioctl_add_dev(struct btrfs_root *root, void __user *arg)
        vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
        ret = btrfs_init_new_device(root, vol_args->name);
 
+       if (!ret)
+               btrfs_info(root->fs_info, "disk added %s",vol_args->name);
+
        kfree(vol_args);
 out:
        mutex_unlock(&root->fs_info->volume_mutex);
@@ -2673,6 +2672,9 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
        mutex_unlock(&root->fs_info->volume_mutex);
        atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);
 
+       if (!ret)
+               btrfs_info(root->fs_info, "disk deleted %s",vol_args->name);
+
 out:
        kfree(vol_args);
 err_drop:
@@ -2737,8 +2739,8 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)
        }
 
        di_args->devid = dev->devid;
-       di_args->bytes_used = dev->bytes_used;
-       di_args->total_bytes = dev->total_bytes;
+       di_args->bytes_used = btrfs_device_get_bytes_used(dev);
+       di_args->total_bytes = btrfs_device_get_total_bytes(dev);
        memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
        if (dev->name) {
                struct rcu_string *name;
@@ -3199,7 +3201,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
        u64 last_dest_end = destoff;
 
        ret = -ENOMEM;
-       buf = vmalloc(btrfs_level_size(root, 0));
+       buf = vmalloc(root->nodesize);
        if (!buf)
                return ret;
 
@@ -3252,11 +3254,11 @@ process_slot:
                slot = path->slots[0];
 
                btrfs_item_key_to_cpu(leaf, &key, slot);
-               if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY ||
+               if (key.type > BTRFS_EXTENT_DATA_KEY ||
                    key.objectid != btrfs_ino(src))
                        break;
 
-               if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY) {
+               if (key.type == BTRFS_EXTENT_DATA_KEY) {
                        struct btrfs_file_extent_item *extent;
                        int type;
                        u32 size;
@@ -5283,6 +5285,12 @@ long btrfs_ioctl(struct file *file, unsigned int
                if (ret)
                        return ret;
                ret = btrfs_sync_fs(file->f_dentry->d_sb, 1);
+               /*
+                * The transaction thread may want to do more work,
+                * namely it pokes the cleaner ktread that will start
+                * processing uncleaned subvols.
+                */
+               wake_up_process(root->fs_info->transaction_kthread);
                return ret;
        }
        case BTRFS_IOC_START_SYNC: