aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdmund Nadolski <enadolski@suse.com>2017-03-16 12:04:34 -0400
committerDavid Sterba <dsterba@suse.com>2017-04-18 08:07:25 -0400
commitde47c9d3ff875a3cb1251af35ee8d30afaca78bd (patch)
tree5befd3a928d8c49911748f9faf26fe2d419d3aee
parentf58d88b336c1c83a35d6b2582d45cd87cb2ca406 (diff)
btrfs: replace hardcoded value with SEQ_LAST macro
Define the SEQ_LAST macro to replace (u64)-1 in places where said value triggers a special-case ref search behavior. Signed-off-by: Edmund Nadolski <enadolski@suse.com> Reviewed-by: Jeff Mahoney <jeffm@suse.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/backref.c16
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/qgroup.c4
3 files changed, 12 insertions, 10 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 6ce7281749a8..24865da63d8f 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -538,7 +538,7 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
538 * slot==nritems. In that case, go to the next leaf before we continue. 538 * slot==nritems. In that case, go to the next leaf before we continue.
539 */ 539 */
540 if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { 540 if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) {
541 if (time_seq == (u64)-1) 541 if (time_seq == SEQ_LAST)
542 ret = btrfs_next_leaf(root, path); 542 ret = btrfs_next_leaf(root, path);
543 else 543 else
544 ret = btrfs_next_old_leaf(root, path, time_seq); 544 ret = btrfs_next_old_leaf(root, path, time_seq);
@@ -582,7 +582,7 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
582 eie = NULL; 582 eie = NULL;
583 } 583 }
584next: 584next:
585 if (time_seq == (u64)-1) 585 if (time_seq == SEQ_LAST)
586 ret = btrfs_next_item(root, path); 586 ret = btrfs_next_item(root, path);
587 else 587 else
588 ret = btrfs_next_old_item(root, path, time_seq); 588 ret = btrfs_next_old_item(root, path, time_seq);
@@ -634,7 +634,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
634 634
635 if (path->search_commit_root) 635 if (path->search_commit_root)
636 root_level = btrfs_header_level(root->commit_root); 636 root_level = btrfs_header_level(root->commit_root);
637 else if (time_seq == (u64)-1) 637 else if (time_seq == SEQ_LAST)
638 root_level = btrfs_header_level(root->node); 638 root_level = btrfs_header_level(root->node);
639 else 639 else
640 root_level = btrfs_old_root_level(root, time_seq); 640 root_level = btrfs_old_root_level(root, time_seq);
@@ -645,7 +645,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
645 } 645 }
646 646
647 path->lowest_level = level; 647 path->lowest_level = level;
648 if (time_seq == (u64)-1) 648 if (time_seq == SEQ_LAST)
649 ret = btrfs_search_slot(NULL, root, &ref->key_for_search, path, 649 ret = btrfs_search_slot(NULL, root, &ref->key_for_search, path,
650 0, 0); 650 0, 0);
651 else 651 else
@@ -1199,7 +1199,7 @@ static int __add_keyed_refs(struct btrfs_fs_info *fs_info,
1199 * 1199 *
1200 * NOTE: This can return values > 0 1200 * NOTE: This can return values > 0
1201 * 1201 *
1202 * If time_seq is set to (u64)-1, it will not search delayed_refs, and behave 1202 * If time_seq is set to SEQ_LAST, it will not search delayed_refs, and behave
1203 * much like trans == NULL case, the difference only lies in it will not 1203 * much like trans == NULL case, the difference only lies in it will not
1204 * commit root. 1204 * commit root.
1205 * The special case is for qgroup to search roots in commit_transaction(). 1205 * The special case is for qgroup to search roots in commit_transaction().
@@ -1246,7 +1246,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
1246 path->skip_locking = 1; 1246 path->skip_locking = 1;
1247 } 1247 }
1248 1248
1249 if (time_seq == (u64)-1) 1249 if (time_seq == SEQ_LAST)
1250 path->skip_locking = 1; 1250 path->skip_locking = 1;
1251 1251
1252 /* 1252 /*
@@ -1276,9 +1276,9 @@ again:
1276 1276
1277#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS 1277#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
1278 if (trans && likely(trans->type != __TRANS_DUMMY) && 1278 if (trans && likely(trans->type != __TRANS_DUMMY) &&
1279 time_seq != (u64)-1) { 1279 time_seq != SEQ_LAST) {
1280#else 1280#else
1281 if (trans && time_seq != (u64)-1) { 1281 if (trans && time_seq != SEQ_LAST) {
1282#endif 1282#endif
1283 /* 1283 /*
1284 * look if there are updates for this ref queued and lock the 1284 * look if there are updates for this ref queued and lock the
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 7343bf7f2b35..e9d77115e695 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -659,6 +659,8 @@ struct seq_list {
659 659
660#define SEQ_LIST_INIT(name) { .list = LIST_HEAD_INIT((name).list), .seq = 0 } 660#define SEQ_LIST_INIT(name) { .list = LIST_HEAD_INIT((name).list), .seq = 0 }
661 661
662#define SEQ_LAST ((u64)-1)
663
662enum btrfs_orphan_cleanup_state { 664enum btrfs_orphan_cleanup_state {
663 ORPHAN_CLEANUP_STARTED = 1, 665 ORPHAN_CLEANUP_STARTED = 1,
664 ORPHAN_CLEANUP_DONE = 2, 666 ORPHAN_CLEANUP_DONE = 2,
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index b2fdefc6d191..21647a414aa5 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -2055,12 +2055,12 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
2055 2055
2056 if (!ret) { 2056 if (!ret) {
2057 /* 2057 /*
2058 * Use (u64)-1 as time_seq to do special search, which 2058 * Use SEQ_LAST as time_seq to do special search, which
2059 * doesn't lock tree or delayed_refs and search current 2059 * doesn't lock tree or delayed_refs and search current
2060 * root. It's safe inside commit_transaction(). 2060 * root. It's safe inside commit_transaction().
2061 */ 2061 */
2062 ret = btrfs_find_all_roots(trans, fs_info, 2062 ret = btrfs_find_all_roots(trans, fs_info,
2063 record->bytenr, (u64)-1, &new_roots); 2063 record->bytenr, SEQ_LAST, &new_roots);
2064 if (ret < 0) 2064 if (ret < 0)
2065 goto cleanup; 2065 goto cleanup;
2066 if (qgroup_to_skip) 2066 if (qgroup_to_skip)