]> Git Repo - linux.git/blobdiff - fs/btrfs/tree-log.c
Merge tag 'for-5.4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
[linux.git] / fs / btrfs / tree-log.c
index 1bfd7e34f31e33709f0e937f83c6d978d74564c6..29b82a7955227bc68daa7628ceeceff95e2204ee 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/blkdev.h>
 #include <linux/list_sort.h>
 #include <linux/iversion.h>
+#include "misc.h"
 #include "ctree.h"
 #include "tree-log.h"
 #include "disk-io.h"
  * LOG_INODE_EXISTS means to log just enough to recreate the inode
  * during log replay
  */
-#define LOG_INODE_ALL 0
-#define LOG_INODE_EXISTS 1
-#define LOG_OTHER_INODE 2
-#define LOG_OTHER_INODE_ALL 3
+enum {
+       LOG_INODE_ALL,
+       LOG_INODE_EXISTS,
+       LOG_OTHER_INODE,
+       LOG_OTHER_INODE_ALL,
+};
 
 /*
  * directory trouble cases
  * The last stage is to deal with directories and links and extents
  * and all the other fun semantics
  */
-#define LOG_WALK_PIN_ONLY 0
-#define LOG_WALK_REPLAY_INODES 1
-#define LOG_WALK_REPLAY_DIR_INDEX 2
-#define LOG_WALK_REPLAY_ALL 3
+enum {
+       LOG_WALK_PIN_ONLY,
+       LOG_WALK_REPLAY_INODES,
+       LOG_WALK_REPLAY_DIR_INDEX,
+       LOG_WALK_REPLAY_ALL,
+};
 
 static int btrfs_log_inode(struct btrfs_trans_handle *trans,
                           struct btrfs_root *root, struct btrfs_inode *inode,
@@ -188,10 +193,6 @@ static int join_running_log_trans(struct btrfs_root *root)
 {
        int ret = -ENOENT;
 
-       smp_mb();
-       if (!root->log_root)
-               return -ENOENT;
-
        mutex_lock(&root->log_mutex);
        if (root->log_root) {
                ret = 0;
@@ -505,7 +506,7 @@ insert:
                            ino_size != 0) {
                                struct btrfs_map_token token;
 
-                               btrfs_init_map_token(&token);
+                               btrfs_init_map_token(&token, dst_eb);
                                btrfs_set_token_inode_size(dst_eb, dst_item,
                                                           ino_size, &token);
                        }
@@ -967,7 +968,7 @@ static noinline int backref_in_log(struct btrfs_root *log,
                if (btrfs_find_name_in_ext_backref(path->nodes[0],
                                                   path->slots[0],
                                                   ref_objectid,
-                                                  name, namelen, NULL))
+                                                  name, namelen))
                        match = 1;
 
                goto out;
@@ -1266,12 +1267,12 @@ again:
                        goto out;
 
                if (key->type == BTRFS_INODE_EXTREF_KEY)
-                       ret = btrfs_find_name_in_ext_backref(log_eb, log_slot,
-                                                            parent_id, name,
-                                                            namelen, NULL);
+                       ret = !!btrfs_find_name_in_ext_backref(log_eb, log_slot,
+                                                              parent_id, name,
+                                                              namelen);
                else
-                       ret = btrfs_find_name_in_backref(log_eb, log_slot, name,
-                                                        namelen, NULL);
+                       ret = !!btrfs_find_name_in_backref(log_eb, log_slot,
+                                                          name, namelen);
 
                if (!ret) {
                        struct inode *dir;
@@ -1333,12 +1334,11 @@ static int btrfs_inode_ref_exists(struct inode *inode, struct inode *dir,
                goto out;
        }
        if (key.type == BTRFS_INODE_EXTREF_KEY)
-               ret = btrfs_find_name_in_ext_backref(path->nodes[0],
-                                                    path->slots[0], parent_id,
-                                                    name, namelen, NULL);
+               ret = !!btrfs_find_name_in_ext_backref(path->nodes[0],
+                               path->slots[0], parent_id, name, namelen);
        else
-               ret = btrfs_find_name_in_backref(path->nodes[0], path->slots[0],
-                                                name, namelen, NULL);
+               ret = !!btrfs_find_name_in_backref(path->nodes[0], path->slots[0],
+                                                  name, namelen);
 
 out:
        btrfs_free_path(path);
@@ -3842,7 +3842,7 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
 {
        struct btrfs_map_token token;
 
-       btrfs_init_map_token(&token);
+       btrfs_init_map_token(&token, leaf);
 
        if (log_inode_only) {
                /* set the generation to zero so the recover code
@@ -4302,8 +4302,6 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
        if (ret)
                return ret;
 
-       btrfs_init_map_token(&token);
-
        ret = __btrfs_drop_extents(trans, log, &inode->vfs_inode, path, em->start,
                                   em->start + em->len, NULL, 0, 1,
                                   sizeof(*fi), &extent_inserted);
@@ -4321,6 +4319,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
                        return ret;
        }
        leaf = path->nodes[0];
+       btrfs_init_map_token(&token, leaf);
        fi = btrfs_item_ptr(leaf, path->slots[0],
                            struct btrfs_file_extent_item);
 
@@ -6233,7 +6232,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
        struct btrfs_fs_info *fs_info = log_root_tree->fs_info;
        struct walk_control wc = {
                .process_func = process_one_buffer,
-               .stage = 0,
+               .stage = LOG_WALK_PIN_ONLY,
        };
 
        path = btrfs_alloc_path();
This page took 0.045017 seconds and 4 git commands to generate.