summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-18 20:29:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-18 20:29:31 -0400
commit7d14df2d280fb7411eba2eb96682da0683ad97f6 (patch)
tree5ab7d51dfabcccbeafd02415bb082a9456658177 /fs/btrfs/tree-log.c
parent0bb73e42f027db64054fff4c3b3203c1626b9dc1 (diff)
parent6af112b11a4bc1b560f60a618ac9c1dcefe9836e (diff)
Merge tag 'for-5.4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs updates from David Sterba: "This continues with work on code refactoring, sanity checks and space handling. There are some less user visible changes, nothing that would particularly stand out. User visible changes: - tree checker, more sanity checks of: - ROOT_ITEM (key, size, generation, level, alignment, flags) - EXTENT_ITEM and METADATA_ITEM checks (key, size, offset, alignment, refs) - tree block reference items - EXTENT_DATA_REF (key, hash, offset) - deprecate flag BTRFS_SUBVOL_CREATE_ASYNC for subvolume creation ioctl, scheduled removal in 5.7 - delete stale and unused UAPI definitions BTRFS_DEV_REPLACE_ITEM_STATE_* - improved export of debugging information available via existing sysfs directory structure - try harder to delete relations between qgroups and allow to delete orphan entries - remove unreliable space checks before relocation starts Core: - space handling: - improved ticket reservations and other high level logic in order to remove special cases - factor flushing infrastructure and use it for different contexts, allows to remove some special case handling - reduce metadata reservation when only updating inodes - reduce global block reserve minimum size (affects small filesystems) - improved overcommit logic wrt global block reserve - tests: - fix memory leaks in extent IO tree - catch all TRIM range Fixes: - fix ENOSPC errors, leading to transaction aborts, when cloning extents - several fixes for inode number cache (mount option inode_cache) - fix potential soft lockups during send when traversing large trees - fix unaligned access to space cache pages with SLUB debug on (PowerPC) Other: - refactoring public/private functions, moving to new or more appropriate files - defines converted to enums - error handling improvements - more assertions and comments - old code deletion" * tag 'for-5.4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: (138 commits) btrfs: Relinquish CPUs in btrfs_compare_trees btrfs: Don't assign retval of btrfs_try_tree_write_lock/btrfs_tree_read_lock_atomic btrfs: create structure to encode checksum type and length btrfs: turn checksum type define into an enum btrfs: add enospc debug messages for ticket failure btrfs: do not account global reserve in can_overcommit btrfs: use btrfs_try_granting_tickets in update_global_rsv btrfs: always reserve our entire size for the global reserve btrfs: change the minimum global reserve size btrfs: rename btrfs_space_info_add_old_bytes btrfs: remove orig_bytes from reserve_ticket btrfs: fix may_commit_transaction to deal with no partial filling btrfs: rework wake_all_tickets btrfs: refactor the ticket wakeup code btrfs: stop partially refilling tickets when releasing space btrfs: add space reservation tracepoint for reserved bytes btrfs: roll tracepoint into btrfs_space_info_update helper btrfs: do not allow reservations if we have pending tickets btrfs: stop clearing EXTENT_DIRTY in inode I/O tree btrfs: treat RWF_{,D}SYNC writes as sync for CRCs ...
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1bfd7e34f31e..29b82a795522 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -8,6 +8,7 @@
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/list_sort.h> 9#include <linux/list_sort.h>
10#include <linux/iversion.h> 10#include <linux/iversion.h>
11#include "misc.h"
11#include "ctree.h" 12#include "ctree.h"
12#include "tree-log.h" 13#include "tree-log.h"
13#include "disk-io.h" 14#include "disk-io.h"
@@ -24,10 +25,12 @@
24 * LOG_INODE_EXISTS means to log just enough to recreate the inode 25 * LOG_INODE_EXISTS means to log just enough to recreate the inode
25 * during log replay 26 * during log replay
26 */ 27 */
27#define LOG_INODE_ALL 0 28enum {
28#define LOG_INODE_EXISTS 1 29 LOG_INODE_ALL,
29#define LOG_OTHER_INODE 2 30 LOG_INODE_EXISTS,
30#define LOG_OTHER_INODE_ALL 3 31 LOG_OTHER_INODE,
32 LOG_OTHER_INODE_ALL,
33};
31 34
32/* 35/*
33 * directory trouble cases 36 * directory trouble cases
@@ -81,10 +84,12 @@
81 * The last stage is to deal with directories and links and extents 84 * The last stage is to deal with directories and links and extents
82 * and all the other fun semantics 85 * and all the other fun semantics
83 */ 86 */
84#define LOG_WALK_PIN_ONLY 0 87enum {
85#define LOG_WALK_REPLAY_INODES 1 88 LOG_WALK_PIN_ONLY,
86#define LOG_WALK_REPLAY_DIR_INDEX 2 89 LOG_WALK_REPLAY_INODES,
87#define LOG_WALK_REPLAY_ALL 3 90 LOG_WALK_REPLAY_DIR_INDEX,
91 LOG_WALK_REPLAY_ALL,
92};
88 93
89static int btrfs_log_inode(struct btrfs_trans_handle *trans, 94static int btrfs_log_inode(struct btrfs_trans_handle *trans,
90 struct btrfs_root *root, struct btrfs_inode *inode, 95 struct btrfs_root *root, struct btrfs_inode *inode,
@@ -188,10 +193,6 @@ static int join_running_log_trans(struct btrfs_root *root)
188{ 193{
189 int ret = -ENOENT; 194 int ret = -ENOENT;
190 195
191 smp_mb();
192 if (!root->log_root)
193 return -ENOENT;
194
195 mutex_lock(&root->log_mutex); 196 mutex_lock(&root->log_mutex);
196 if (root->log_root) { 197 if (root->log_root) {
197 ret = 0; 198 ret = 0;
@@ -505,7 +506,7 @@ insert:
505 ino_size != 0) { 506 ino_size != 0) {
506 struct btrfs_map_token token; 507 struct btrfs_map_token token;
507 508
508 btrfs_init_map_token(&token); 509 btrfs_init_map_token(&token, dst_eb);
509 btrfs_set_token_inode_size(dst_eb, dst_item, 510 btrfs_set_token_inode_size(dst_eb, dst_item,
510 ino_size, &token); 511 ino_size, &token);
511 } 512 }
@@ -967,7 +968,7 @@ static noinline int backref_in_log(struct btrfs_root *log,
967 if (btrfs_find_name_in_ext_backref(path->nodes[0], 968 if (btrfs_find_name_in_ext_backref(path->nodes[0],
968 path->slots[0], 969 path->slots[0],
969 ref_objectid, 970 ref_objectid,
970 name, namelen, NULL)) 971 name, namelen))
971 match = 1; 972 match = 1;
972 973
973 goto out; 974 goto out;
@@ -1266,12 +1267,12 @@ again:
1266 goto out; 1267 goto out;
1267 1268
1268 if (key->type == BTRFS_INODE_EXTREF_KEY) 1269 if (key->type == BTRFS_INODE_EXTREF_KEY)
1269 ret = btrfs_find_name_in_ext_backref(log_eb, log_slot, 1270 ret = !!btrfs_find_name_in_ext_backref(log_eb, log_slot,
1270 parent_id, name, 1271 parent_id, name,
1271 namelen, NULL); 1272 namelen);
1272 else 1273 else
1273 ret = btrfs_find_name_in_backref(log_eb, log_slot, name, 1274 ret = !!btrfs_find_name_in_backref(log_eb, log_slot,
1274 namelen, NULL); 1275 name, namelen);
1275 1276
1276 if (!ret) { 1277 if (!ret) {
1277 struct inode *dir; 1278 struct inode *dir;
@@ -1333,12 +1334,11 @@ static int btrfs_inode_ref_exists(struct inode *inode, struct inode *dir,
1333 goto out; 1334 goto out;
1334 } 1335 }
1335 if (key.type == BTRFS_INODE_EXTREF_KEY) 1336 if (key.type == BTRFS_INODE_EXTREF_KEY)
1336 ret = btrfs_find_name_in_ext_backref(path->nodes[0], 1337 ret = !!btrfs_find_name_in_ext_backref(path->nodes[0],
1337 path->slots[0], parent_id, 1338 path->slots[0], parent_id, name, namelen);
1338 name, namelen, NULL);
1339 else 1339 else
1340 ret = btrfs_find_name_in_backref(path->nodes[0], path->slots[0], 1340 ret = !!btrfs_find_name_in_backref(path->nodes[0], path->slots[0],
1341 name, namelen, NULL); 1341 name, namelen);
1342 1342
1343out: 1343out:
1344 btrfs_free_path(path); 1344 btrfs_free_path(path);
@@ -3842,7 +3842,7 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
3842{ 3842{
3843 struct btrfs_map_token token; 3843 struct btrfs_map_token token;
3844 3844
3845 btrfs_init_map_token(&token); 3845 btrfs_init_map_token(&token, leaf);
3846 3846
3847 if (log_inode_only) { 3847 if (log_inode_only) {
3848 /* set the generation to zero so the recover code 3848 /* set the generation to zero so the recover code
@@ -4302,8 +4302,6 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
4302 if (ret) 4302 if (ret)
4303 return ret; 4303 return ret;
4304 4304
4305 btrfs_init_map_token(&token);
4306
4307 ret = __btrfs_drop_extents(trans, log, &inode->vfs_inode, path, em->start, 4305 ret = __btrfs_drop_extents(trans, log, &inode->vfs_inode, path, em->start,
4308 em->start + em->len, NULL, 0, 1, 4306 em->start + em->len, NULL, 0, 1,
4309 sizeof(*fi), &extent_inserted); 4307 sizeof(*fi), &extent_inserted);
@@ -4321,6 +4319,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
4321 return ret; 4319 return ret;
4322 } 4320 }
4323 leaf = path->nodes[0]; 4321 leaf = path->nodes[0];
4322 btrfs_init_map_token(&token, leaf);
4324 fi = btrfs_item_ptr(leaf, path->slots[0], 4323 fi = btrfs_item_ptr(leaf, path->slots[0],
4325 struct btrfs_file_extent_item); 4324 struct btrfs_file_extent_item);
4326 4325
@@ -6233,7 +6232,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
6233 struct btrfs_fs_info *fs_info = log_root_tree->fs_info; 6232 struct btrfs_fs_info *fs_info = log_root_tree->fs_info;
6234 struct walk_control wc = { 6233 struct walk_control wc = {
6235 .process_func = process_one_buffer, 6234 .process_func = process_one_buffer,
6236 .stage = 0, 6235 .stage = LOG_WALK_PIN_ONLY,
6237 }; 6236 };
6238 6237
6239 path = btrfs_alloc_path(); 6238 path = btrfs_alloc_path();