diff options
author | Jeff Mahoney <jeffm@suse.com> | 2014-04-23 10:00:35 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2014-05-06 16:51:44 -0400 |
commit | 4cf5f7addf18ecae2ea49b11944976cbd26d5281 (patch) | |
tree | 52aa9ebf68e7951bacbdc708f1d19467736187bc /fs/reiserfs/stree.c | |
parent | 797d9016ceca69879bb273218810fa0beef46aac (diff) |
reiserfs: cleanup, rename key and item accessors to more friendly names
This patch does a quick search and replace:
B_N_PITEM_HEAD() -> item_head()
B_N_PDELIM_KEY() -> internal_key()
B_N_PKEY() -> leaf_key()
B_N_PITEM() -> item_body()
And the item_head version:
B_I_PITEM() -> ih_item_body()
I_ENTRY_COUNT() -> ih_entry_count()
And the treepath variants:
get_ih() -> tp_item_head()
PATH_PITEM_HEAD() -> tp_item_head()
get_item() -> tp_item_body()
... which makes the code much easier on the eyes.
I've also removed a few unused macros.
Checkpatch will complain about the 80 character limit for do_balan.c.
I've addressed that in a later patchset to split up balance_leaf().
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/reiserfs/stree.c')
-rw-r--r-- | fs/reiserfs/stree.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index b14706a05d52..40b3e77c8ff3 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -272,7 +272,7 @@ static inline const struct reiserfs_key *get_lkey(const struct treepath *chk_pat | |||
272 | return &MAX_KEY; | 272 | return &MAX_KEY; |
273 | /* Return delimiting key if position in the parent is not equal to zero. */ | 273 | /* Return delimiting key if position in the parent is not equal to zero. */ |
274 | if (position) | 274 | if (position) |
275 | return B_N_PDELIM_KEY(parent, position - 1); | 275 | return internal_key(parent, position - 1); |
276 | } | 276 | } |
277 | /* Return MIN_KEY if we are in the root of the buffer tree. */ | 277 | /* Return MIN_KEY if we are in the root of the buffer tree. */ |
278 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> | 278 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> |
@@ -315,7 +315,7 @@ inline const struct reiserfs_key *get_rkey(const struct treepath *chk_path, | |||
315 | return &MIN_KEY; | 315 | return &MIN_KEY; |
316 | /* Return delimiting key if position in the parent is not the last one. */ | 316 | /* Return delimiting key if position in the parent is not the last one. */ |
317 | if (position != B_NR_ITEMS(parent)) | 317 | if (position != B_NR_ITEMS(parent)) |
318 | return B_N_PDELIM_KEY(parent, position); | 318 | return internal_key(parent, position); |
319 | } | 319 | } |
320 | /* Return MAX_KEY if we are in the root of the buffer tree. */ | 320 | /* Return MAX_KEY if we are in the root of the buffer tree. */ |
321 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> | 321 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> |
@@ -732,7 +732,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s | |||
732 | "vs-5152: tree level (%d) is less than stop level (%d)", | 732 | "vs-5152: tree level (%d) is less than stop level (%d)", |
733 | node_level, stop_level); | 733 | node_level, stop_level); |
734 | 734 | ||
735 | retval = bin_search(key, B_N_PITEM_HEAD(bh, 0), | 735 | retval = bin_search(key, item_head(bh, 0), |
736 | B_NR_ITEMS(bh), | 736 | B_NR_ITEMS(bh), |
737 | (node_level == | 737 | (node_level == |
738 | DISK_LEAF_NODE_LEVEL) ? IH_SIZE : | 738 | DISK_LEAF_NODE_LEVEL) ? IH_SIZE : |
@@ -779,7 +779,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s | |||
779 | /* | 779 | /* |
780 | * check to make sure we're in the same object | 780 | * check to make sure we're in the same object |
781 | */ | 781 | */ |
782 | le_key = B_N_PDELIM_KEY(bh, pos); | 782 | le_key = internal_key(bh, pos); |
783 | if (le32_to_cpu(le_key->k_objectid) != | 783 | if (le32_to_cpu(le_key->k_objectid) != |
784 | key->on_disk_key.k_objectid) { | 784 | key->on_disk_key.k_objectid) { |
785 | break; | 785 | break; |
@@ -830,7 +830,7 @@ int search_for_position_by_key(struct super_block *sb, /* Pointer to the super b | |||
830 | if (retval == ITEM_FOUND) { | 830 | if (retval == ITEM_FOUND) { |
831 | 831 | ||
832 | RFALSE(!ih_item_len | 832 | RFALSE(!ih_item_len |
833 | (B_N_PITEM_HEAD | 833 | (item_head |
834 | (PATH_PLAST_BUFFER(search_path), | 834 | (PATH_PLAST_BUFFER(search_path), |
835 | PATH_LAST_POSITION(search_path))), | 835 | PATH_LAST_POSITION(search_path))), |
836 | "PAP-5165: item length equals zero"); | 836 | "PAP-5165: item length equals zero"); |
@@ -844,7 +844,7 @@ int search_for_position_by_key(struct super_block *sb, /* Pointer to the super b | |||
844 | 844 | ||
845 | /* Item is not found. Set path to the previous item. */ | 845 | /* Item is not found. Set path to the previous item. */ |
846 | p_le_ih = | 846 | p_le_ih = |
847 | B_N_PITEM_HEAD(PATH_PLAST_BUFFER(search_path), | 847 | item_head(PATH_PLAST_BUFFER(search_path), |
848 | --PATH_LAST_POSITION(search_path)); | 848 | --PATH_LAST_POSITION(search_path)); |
849 | blk_size = sb->s_blocksize; | 849 | blk_size = sb->s_blocksize; |
850 | 850 | ||
@@ -892,7 +892,7 @@ int comp_items(const struct item_head *stored_ih, const struct treepath *path) | |||
892 | return 1; | 892 | return 1; |
893 | 893 | ||
894 | /* we need only to know, whether it is the same item */ | 894 | /* we need only to know, whether it is the same item */ |
895 | ih = get_ih(path); | 895 | ih = tp_item_head(path); |
896 | return memcmp(stored_ih, ih, IH_SIZE); | 896 | return memcmp(stored_ih, ih, IH_SIZE); |
897 | } | 897 | } |
898 | 898 | ||
@@ -987,7 +987,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
987 | ) | 987 | ) |
988 | { | 988 | { |
989 | struct super_block *sb = inode->i_sb; | 989 | struct super_block *sb = inode->i_sb; |
990 | struct item_head *p_le_ih = PATH_PITEM_HEAD(path); | 990 | struct item_head *p_le_ih = tp_item_head(path); |
991 | struct buffer_head *bh = PATH_PLAST_BUFFER(path); | 991 | struct buffer_head *bh = PATH_PLAST_BUFFER(path); |
992 | 992 | ||
993 | BUG_ON(!th->t_trans_id); | 993 | BUG_ON(!th->t_trans_id); |
@@ -1033,7 +1033,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1033 | need_re_search = 0; | 1033 | need_re_search = 0; |
1034 | *cut_size = 0; | 1034 | *cut_size = 0; |
1035 | bh = PATH_PLAST_BUFFER(path); | 1035 | bh = PATH_PLAST_BUFFER(path); |
1036 | copy_item_head(&s_ih, PATH_PITEM_HEAD(path)); | 1036 | copy_item_head(&s_ih, tp_item_head(path)); |
1037 | pos = I_UNFM_NUM(&s_ih); | 1037 | pos = I_UNFM_NUM(&s_ih); |
1038 | 1038 | ||
1039 | while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > new_file_length) { | 1039 | while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > new_file_length) { |
@@ -1047,7 +1047,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1047 | reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) | 1047 | reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) |
1048 | break; | 1048 | break; |
1049 | 1049 | ||
1050 | unfm = (__le32 *)B_I_PITEM(bh, &s_ih) + pos - 1; | 1050 | unfm = (__le32 *)ih_item_body(bh, &s_ih) + pos - 1; |
1051 | block = get_block_num(unfm, 0); | 1051 | block = get_block_num(unfm, 0); |
1052 | 1052 | ||
1053 | if (block != 0) { | 1053 | if (block != 0) { |
@@ -1095,7 +1095,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1095 | static int calc_deleted_bytes_number(struct tree_balance *tb, char mode) | 1095 | static int calc_deleted_bytes_number(struct tree_balance *tb, char mode) |
1096 | { | 1096 | { |
1097 | int del_size; | 1097 | int del_size; |
1098 | struct item_head *p_le_ih = PATH_PITEM_HEAD(tb->tb_path); | 1098 | struct item_head *p_le_ih = tp_item_head(tb->tb_path); |
1099 | 1099 | ||
1100 | if (is_statdata_le_ih(p_le_ih)) | 1100 | if (is_statdata_le_ih(p_le_ih)) |
1101 | return 0; | 1101 | return 0; |
@@ -1212,7 +1212,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, | |||
1212 | 1212 | ||
1213 | RFALSE(mode != M_DELETE, "PAP-5320: mode must be M_DELETE"); | 1213 | RFALSE(mode != M_DELETE, "PAP-5320: mode must be M_DELETE"); |
1214 | 1214 | ||
1215 | copy_item_head(&s_ih, PATH_PITEM_HEAD(path)); | 1215 | copy_item_head(&s_ih, tp_item_head(path)); |
1216 | s_del_balance.insert_size[0] = del_size; | 1216 | s_del_balance.insert_size[0] = del_size; |
1217 | 1217 | ||
1218 | ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL); | 1218 | ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL); |
@@ -1240,7 +1240,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, | |||
1240 | } | 1240 | } |
1241 | // reiserfs_delete_item returns item length when success | 1241 | // reiserfs_delete_item returns item length when success |
1242 | ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE); | 1242 | ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE); |
1243 | q_ih = get_ih(path); | 1243 | q_ih = tp_item_head(path); |
1244 | quota_cut_bytes = ih_item_len(q_ih); | 1244 | quota_cut_bytes = ih_item_len(q_ih); |
1245 | 1245 | ||
1246 | /* hack so the quota code doesn't have to guess if the file | 1246 | /* hack so the quota code doesn't have to guess if the file |
@@ -1284,7 +1284,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, | |||
1284 | data = kmap_atomic(un_bh->b_page); | 1284 | data = kmap_atomic(un_bh->b_page); |
1285 | off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1)); | 1285 | off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1)); |
1286 | memcpy(data + off, | 1286 | memcpy(data + off, |
1287 | B_I_PITEM(PATH_PLAST_BUFFER(path), &s_ih), | 1287 | ih_item_body(PATH_PLAST_BUFFER(path), &s_ih), |
1288 | ret_value); | 1288 | ret_value); |
1289 | kunmap_atomic(data); | 1289 | kunmap_atomic(data); |
1290 | } | 1290 | } |
@@ -1362,11 +1362,11 @@ void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th, | |||
1362 | } | 1362 | } |
1363 | if (!tb_init) { | 1363 | if (!tb_init) { |
1364 | tb_init = 1; | 1364 | tb_init = 1; |
1365 | item_len = ih_item_len(PATH_PITEM_HEAD(&path)); | 1365 | item_len = ih_item_len(tp_item_head(&path)); |
1366 | init_tb_struct(th, &tb, th->t_super, &path, | 1366 | init_tb_struct(th, &tb, th->t_super, &path, |
1367 | -(IH_SIZE + item_len)); | 1367 | -(IH_SIZE + item_len)); |
1368 | } | 1368 | } |
1369 | quota_cut_bytes = ih_item_len(PATH_PITEM_HEAD(&path)); | 1369 | quota_cut_bytes = ih_item_len(tp_item_head(&path)); |
1370 | 1370 | ||
1371 | retval = fix_nodes(M_DELETE, &tb, NULL, NULL); | 1371 | retval = fix_nodes(M_DELETE, &tb, NULL, NULL); |
1372 | if (retval == REPEAT_SEARCH) { | 1372 | if (retval == REPEAT_SEARCH) { |
@@ -1521,7 +1521,7 @@ static void indirect_to_direct_roll_back(struct reiserfs_transaction_handle *th, | |||
1521 | reiserfs_panic(inode->i_sb, "vs-5615", | 1521 | reiserfs_panic(inode->i_sb, "vs-5615", |
1522 | "found invalid item"); | 1522 | "found invalid item"); |
1523 | RFALSE(path->pos_in_item != | 1523 | RFALSE(path->pos_in_item != |
1524 | ih_item_len(PATH_PITEM_HEAD(path)) - 1, | 1524 | ih_item_len(tp_item_head(path)) - 1, |
1525 | "vs-5616: appended bytes found"); | 1525 | "vs-5616: appended bytes found"); |
1526 | PATH_LAST_POSITION(path)--; | 1526 | PATH_LAST_POSITION(path)--; |
1527 | 1527 | ||
@@ -1671,7 +1671,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1671 | /* Calculate number of bytes that need to be cut from the item. */ | 1671 | /* Calculate number of bytes that need to be cut from the item. */ |
1672 | quota_cut_bytes = | 1672 | quota_cut_bytes = |
1673 | (mode == | 1673 | (mode == |
1674 | M_DELETE) ? ih_item_len(get_ih(path)) : -s_cut_balance. | 1674 | M_DELETE) ? ih_item_len(tp_item_head(path)) : -s_cut_balance. |
1675 | insert_size[0]; | 1675 | insert_size[0]; |
1676 | if (retval2 == -1) | 1676 | if (retval2 == -1) |
1677 | ret_value = calc_deleted_bytes_number(&s_cut_balance, mode); | 1677 | ret_value = calc_deleted_bytes_number(&s_cut_balance, mode); |
@@ -1681,7 +1681,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1681 | /* For direct items, we only change the quota when deleting the last | 1681 | /* For direct items, we only change the quota when deleting the last |
1682 | ** item. | 1682 | ** item. |
1683 | */ | 1683 | */ |
1684 | p_le_ih = PATH_PITEM_HEAD(s_cut_balance.tb_path); | 1684 | p_le_ih = tp_item_head(s_cut_balance.tb_path); |
1685 | if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_le_ih)) { | 1685 | if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_le_ih)) { |
1686 | if (mode == M_DELETE && | 1686 | if (mode == M_DELETE && |
1687 | (le_ih_k_offset(p_le_ih) & (sb->s_blocksize - 1)) == | 1687 | (le_ih_k_offset(p_le_ih) & (sb->s_blocksize - 1)) == |
@@ -1696,7 +1696,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1696 | #ifdef CONFIG_REISERFS_CHECK | 1696 | #ifdef CONFIG_REISERFS_CHECK |
1697 | if (is_inode_locked) { | 1697 | if (is_inode_locked) { |
1698 | struct item_head *le_ih = | 1698 | struct item_head *le_ih = |
1699 | PATH_PITEM_HEAD(s_cut_balance.tb_path); | 1699 | tp_item_head(s_cut_balance.tb_path); |
1700 | /* we are going to complete indirect2direct conversion. Make | 1700 | /* we are going to complete indirect2direct conversion. Make |
1701 | sure, that we exactly remove last unformatted node pointer | 1701 | sure, that we exactly remove last unformatted node pointer |
1702 | of the item */ | 1702 | of the item */ |
@@ -1819,7 +1819,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, | |||
1819 | s_search_path.pos_in_item--; | 1819 | s_search_path.pos_in_item--; |
1820 | 1820 | ||
1821 | /* Get real file size (total length of all file items) */ | 1821 | /* Get real file size (total length of all file items) */ |
1822 | p_le_ih = PATH_PITEM_HEAD(&s_search_path); | 1822 | p_le_ih = tp_item_head(&s_search_path); |
1823 | if (is_statdata_le_ih(p_le_ih)) | 1823 | if (is_statdata_le_ih(p_le_ih)) |
1824 | file_size = 0; | 1824 | file_size = 0; |
1825 | else { | 1825 | else { |
@@ -1922,7 +1922,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, | |||
1922 | static void check_research_for_paste(struct treepath *path, | 1922 | static void check_research_for_paste(struct treepath *path, |
1923 | const struct cpu_key *key) | 1923 | const struct cpu_key *key) |
1924 | { | 1924 | { |
1925 | struct item_head *found_ih = get_ih(path); | 1925 | struct item_head *found_ih = tp_item_head(path); |
1926 | 1926 | ||
1927 | if (is_direct_le_ih(found_ih)) { | 1927 | if (is_direct_le_ih(found_ih)) { |
1928 | if (le_ih_k_offset(found_ih) + | 1928 | if (le_ih_k_offset(found_ih) + |