btrfs: add define for oldest generation
authorAnand Jain <anand.jain@oracle.com>
Wed, 7 Mar 2018 09:29:18 +0000 (17:29 +0800)
committerDavid Sterba <dsterba@suse.com>
Fri, 30 Mar 2018 23:26:50 +0000 (01:26 +0200)
Some functions can filter metadata by the generation. Add a define that
will annotate such arguments.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/ioctl.c
fs/btrfs/tree-defrag.c
fs/btrfs/uuid-tree.c
fs/btrfs/volumes.c

index f4926dc9649fbbce4acf6c048c377be9c3e5c9ff..15bf111cd5c5d4156923e4c1f54aef6c043a1458 100644 (file)
@@ -66,6 +66,8 @@ struct btrfs_ordered_sum;
 
 #define BTRFS_MAX_LEVEL 8
 
+#define BTRFS_OLDEST_GENERATION        0ULL
+
 #define BTRFS_COMPAT_EXTENT_TREE_V0
 
 /*
index c5a559105949c47b4f921e7b187e64433cfffcad..ba403c00982c73123e8a7e62439e5e1ecd9d9cc3 100644 (file)
@@ -2600,7 +2600,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
                        range->len = (u64)-1;
                }
                ret = btrfs_defrag_file(file_inode(file), file,
-                                       range, 0, 0);
+                                       range, BTRFS_OLDEST_GENERATION, 0);
                if (ret > 0)
                        ret = 0;
                kfree(range);
index cb65089127cc7fc4af7847ff3282bc1bdc125bce..c09dbe4bd6e78a9fe7e4b83d8a5fb39554d7c94c 100644 (file)
@@ -39,7 +39,6 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
        int level;
        int next_key_ret = 0;
        u64 last_ret = 0;
-       u64 min_trans = 0;
 
        if (root->fs_info->extent_root == root) {
                /*
@@ -81,7 +80,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
 
        path->keep_locks = 1;
 
-       ret = btrfs_search_forward(root, &key, path, min_trans);
+       ret = btrfs_search_forward(root, &key, path, BTRFS_OLDEST_GENERATION);
        if (ret < 0)
                goto out;
        if (ret > 0) {
@@ -130,7 +129,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
         */
        path->slots[1] = btrfs_header_nritems(path->nodes[1]);
        next_key_ret = btrfs_find_next_key(root, path, &key, 1,
-                                          min_trans);
+                                          BTRFS_OLDEST_GENERATION);
        if (next_key_ret == 0) {
                memcpy(&root->defrag_progress, &key, sizeof(key));
                ret = -EAGAIN;
index 726f928238d0c86a931cd58613799e59cc35fdf8..9916f03430bc80ab0fbf2216f7f6e9a9693dfe8a 100644 (file)
@@ -282,7 +282,7 @@ int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
        key.offset = 0;
 
 again_search_slot:
-       ret = btrfs_search_forward(root, &key, path, 0);
+       ret = btrfs_search_forward(root, &key, path, BTRFS_OLDEST_GENERATION);
        if (ret) {
                if (ret > 0)
                        ret = 0;
index 1622d3b7377178d5f16bacbe9d46dfcd941f426c..1e72357bdfa8b44d41e523eddc8111e8ca9421a5 100644 (file)
@@ -4208,7 +4208,8 @@ static int btrfs_uuid_scan_kthread(void *data)
        key.offset = 0;
 
        while (1) {
-               ret = btrfs_search_forward(root, &key, path, 0);
+               ret = btrfs_search_forward(root, &key, path,
+                               BTRFS_OLDEST_GENERATION);
                if (ret) {
                        if (ret > 0)
                                ret = 0;