From 4cf5f7addf18ecae2ea49b11944976cbd26d5281 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Wed, 23 Apr 2014 10:00:35 -0400 Subject: 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 Signed-off-by: Jan Kara --- fs/reiserfs/item_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs/reiserfs/item_ops.c') diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c index ee382ef..c9f1365 100644 --- a/fs/reiserfs/item_ops.c +++ b/fs/reiserfs/item_ops.c @@ -396,7 +396,7 @@ static void direntry_print_item(struct item_head *ih, char *item) deh = (struct reiserfs_de_head *)item; - for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) { + for (i = 0; i < ih_entry_count(ih); i++, deh++) { namelen = (i ? (deh_location(deh - 1)) : ih_item_len(ih)) - deh_location(deh); @@ -430,7 +430,7 @@ static void direntry_check_item(struct item_head *ih, char *item) // FIXME: type something here! deh = (struct reiserfs_de_head *)item; - for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) { + for (i = 0; i < ih_entry_count(ih); i++, deh++) { ; } } -- cgit v1.1 From 098297b27d23ad9d0fc302e3417474d9342c6c14 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Wed, 23 Apr 2014 10:00:36 -0400 Subject: reiserfs: cleanup, reformat comments to normal kernel style This patch reformats comments in the reiserfs code to fit in 80 columns and to follow the style rules. There is no functional change but it helps make my eyes bleed less. Signed-off-by: Jeff Mahoney Signed-off-by: Jan Kara --- fs/reiserfs/item_ops.c | 100 ++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 52 deletions(-) (limited to 'fs/reiserfs/item_ops.c') diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c index c9f1365..cb6b826 100644 --- a/fs/reiserfs/item_ops.c +++ b/fs/reiserfs/item_ops.c @@ -5,15 +5,17 @@ #include #include "reiserfs.h" -// this contains item handlers for old item types: sd, direct, -// indirect, directory +/* + * this contains item handlers for old item types: sd, direct, + * indirect, directory + */ -/* and where are the comments? how about saying where we can find an - explanation of each item handler method? -Hans */ +/* + * and where are the comments? how about saying where we can find an + * explanation of each item handler method? -Hans + */ -////////////////////////////////////////////////////////////////////////////// -// stat data functions -// +/* stat data functions */ static int sd_bytes_number(struct item_head *ih, int block_size) { return 0; @@ -60,7 +62,7 @@ static void sd_print_item(struct item_head *ih, char *item) static void sd_check_item(struct item_head *ih, char *item) { - // FIXME: type something here! + /* unused */ } static int sd_create_vi(struct virtual_node *vn, @@ -68,7 +70,6 @@ static int sd_create_vi(struct virtual_node *vn, int is_affected, int insert_size) { vi->vi_index = TYPE_STAT_DATA; - //vi->vi_type |= VI_TYPE_STAT_DATA;// not needed? return 0; } @@ -117,15 +118,13 @@ static struct item_operations stat_data_ops = { .print_vi = sd_print_vi }; -////////////////////////////////////////////////////////////////////////////// -// direct item functions -// +/* direct item functions */ static int direct_bytes_number(struct item_head *ih, int block_size) { return ih_item_len(ih); } -// FIXME: this should probably switch to indirect as well +/* FIXME: this should probably switch to indirect as well */ static void direct_decrement_key(struct cpu_key *key) { cpu_key_k_offset_dec(key); @@ -144,7 +143,7 @@ static void direct_print_item(struct item_head *ih, char *item) { int j = 0; -// return; +/* return; */ printk("\""); while (j < ih_item_len(ih)) printk("%c", item[j++]); @@ -153,7 +152,7 @@ static void direct_print_item(struct item_head *ih, char *item) static void direct_check_item(struct item_head *ih, char *item) { - // FIXME: type something here! + /* unused */ } static int direct_create_vi(struct virtual_node *vn, @@ -161,7 +160,6 @@ static int direct_create_vi(struct virtual_node *vn, int is_affected, int insert_size) { vi->vi_index = TYPE_DIRECT; - //vi->vi_type |= VI_TYPE_DIRECT; return 0; } @@ -211,16 +209,13 @@ static struct item_operations direct_ops = { .print_vi = direct_print_vi }; -////////////////////////////////////////////////////////////////////////////// -// indirect item functions -// - +/* indirect item functions */ static int indirect_bytes_number(struct item_head *ih, int block_size) { - return ih_item_len(ih) / UNFM_P_SIZE * block_size; //- get_ih_free_space (ih); + return ih_item_len(ih) / UNFM_P_SIZE * block_size; } -// decrease offset, if it becomes 0, change type to stat data +/* decrease offset, if it becomes 0, change type to stat data */ static void indirect_decrement_key(struct cpu_key *key) { cpu_key_k_offset_dec(key); @@ -228,7 +223,7 @@ static void indirect_decrement_key(struct cpu_key *key) set_cpu_key_k_type(key, TYPE_STAT_DATA); } -// if it is not first item of the body, then it is mergeable +/* if it is not first item of the body, then it is mergeable */ static int indirect_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize) { @@ -236,7 +231,7 @@ static int indirect_is_left_mergeable(struct reiserfs_key *key, return (le_key_k_offset(version, key) != 1); } -// printing of indirect item +/* printing of indirect item */ static void start_new_sequence(__u32 * start, int *len, __u32 new) { *start = new; @@ -295,7 +290,7 @@ static void indirect_print_item(struct item_head *ih, char *item) static void indirect_check_item(struct item_head *ih, char *item) { - // FIXME: type something here! + /* unused */ } static int indirect_create_vi(struct virtual_node *vn, @@ -303,7 +298,6 @@ static int indirect_create_vi(struct virtual_node *vn, int is_affected, int insert_size) { vi->vi_index = TYPE_INDIRECT; - //vi->vi_type |= VI_TYPE_INDIRECT; return 0; } @@ -321,16 +315,19 @@ static int indirect_check_right(struct virtual_item *vi, int free) return indirect_check_left(vi, free, 0, 0); } -// return size in bytes of 'units' units. If first == 0 - calculate from the head (left), otherwise - from tail (right) +/* + * return size in bytes of 'units' units. If first == 0 - calculate + * from the head (left), otherwise - from tail (right) + */ static int indirect_part_size(struct virtual_item *vi, int first, int units) { - // unit of indirect item is byte (yet) + /* unit of indirect item is byte (yet) */ return units; } static int indirect_unit_num(struct virtual_item *vi) { - // unit of indirect item is byte (yet) + /* unit of indirect item is byte (yet) */ return vi->vi_item_len - IH_SIZE; } @@ -356,10 +353,7 @@ static struct item_operations indirect_ops = { .print_vi = indirect_print_vi }; -////////////////////////////////////////////////////////////////////////////// -// direntry functions -// - +/* direntry functions */ static int direntry_bytes_number(struct item_head *ih, int block_size) { reiserfs_warning(NULL, "vs-16090", @@ -428,7 +422,7 @@ static void direntry_check_item(struct item_head *ih, char *item) int i; struct reiserfs_de_head *deh; - // FIXME: type something here! + /* unused */ deh = (struct reiserfs_de_head *)item; for (i = 0; i < ih_entry_count(ih); i++, deh++) { ; @@ -439,7 +433,8 @@ static void direntry_check_item(struct item_head *ih, char *item) /* * function returns old entry number in directory item in real node - * using new entry number in virtual item in virtual node */ + * using new entry number in virtual item in virtual node + */ static inline int old_entry_num(int is_affected, int virtual_entry_num, int pos_in_item, int mode) { @@ -463,9 +458,11 @@ static inline int old_entry_num(int is_affected, int virtual_entry_num, return virtual_entry_num - 1; } -/* Create an array of sizes of directory entries for virtual - item. Return space used by an item. FIXME: no control over - consuming of space used by this item handler */ +/* + * Create an array of sizes of directory entries for virtual + * item. Return space used by an item. FIXME: no control over + * consuming of space used by this item handler + */ static int direntry_create_vi(struct virtual_node *vn, struct virtual_item *vi, int is_affected, int insert_size) @@ -529,10 +526,10 @@ static int direntry_create_vi(struct virtual_node *vn, } -// -// return number of entries which may fit into specified amount of -// free space, or -1 if free space is not enough even for 1 entry -// +/* + * return number of entries which may fit into specified amount of + * free space, or -1 if free space is not enough even for 1 entry + */ static int direntry_check_left(struct virtual_item *vi, int free, int start_skip, int end_skip) { @@ -541,8 +538,8 @@ static int direntry_check_left(struct virtual_item *vi, int free, struct direntry_uarea *dir_u = vi->vi_uarea; for (i = start_skip; i < dir_u->entry_count - end_skip; i++) { + /* i-th entry doesn't fit into the remaining free space */ if (dir_u->entry_sizes[i] > free) - /* i-th entry doesn't fit into the remaining free space */ break; free -= dir_u->entry_sizes[i]; @@ -570,8 +567,8 @@ static int direntry_check_right(struct virtual_item *vi, int free) struct direntry_uarea *dir_u = vi->vi_uarea; for (i = dir_u->entry_count - 1; i >= 0; i--) { + /* i-th entry doesn't fit into the remaining free space */ if (dir_u->entry_sizes[i] > free) - /* i-th entry doesn't fit into the remaining free space */ break; free -= dir_u->entry_sizes[i]; @@ -643,9 +640,7 @@ static struct item_operations direntry_ops = { .print_vi = direntry_print_vi }; -////////////////////////////////////////////////////////////////////////////// -// Error catching functions to catch errors caused by incorrect item types. -// +/* Error catching functions to catch errors caused by incorrect item types. */ static int errcatch_bytes_number(struct item_head *ih, int block_size) { reiserfs_warning(NULL, "green-16001", @@ -685,8 +680,12 @@ static int errcatch_create_vi(struct virtual_node *vn, { reiserfs_warning(NULL, "green-16006", "Invalid item type observed, run fsck ASAP"); - return 0; // We might return -1 here as well, but it won't help as create_virtual_node() from where - // this operation is called from is of return type void. + /* + * We might return -1 here as well, but it won't help as + * create_virtual_node() from where this operation is called + * from is of return type void. + */ + return 0; } static int errcatch_check_left(struct virtual_item *vi, int free, @@ -739,9 +738,6 @@ static struct item_operations errcatch_ops = { errcatch_print_vi }; -////////////////////////////////////////////////////////////////////////////// -// -// #if ! (TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3) #error Item types must use disk-format assigned values. #endif -- cgit v1.1 From a228bf8f0a3e5f1406edbd61f7400e87e23af5f7 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Wed, 23 Apr 2014 10:00:42 -0400 Subject: reiserfs: cleanup, remove unnecessary parens The reiserfs code is littered with extra parens in places where the authors may not have been certain about precedence of & vs ->. This patch cleans them out. Signed-off-by: Jeff Mahoney Signed-off-by: Jan Kara --- fs/reiserfs/item_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs/reiserfs/item_ops.c') diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c index cb6b826..cfaee91 100644 --- a/fs/reiserfs/item_ops.c +++ b/fs/reiserfs/item_ops.c @@ -491,8 +491,8 @@ static int direntry_create_vi(struct virtual_node *vn, j = old_entry_num(is_affected, i, vn->vn_pos_in_item, vn->vn_mode); dir_u->entry_sizes[i] = - (j ? deh_location(&(deh[j - 1])) : ih_item_len(vi->vi_ih)) - - deh_location(&(deh[j])) + DEH_SIZE; + (j ? deh_location(&deh[j - 1]) : ih_item_len(vi->vi_ih)) - + deh_location(&deh[j]) + DEH_SIZE; } size += (dir_u->entry_count * sizeof(short)); -- cgit v1.1