cleanup: run indent with the Linux Kernel style across all code

Over the years, the reiserfs kernel code has been gradually cleaned up
to be more readable. This patch does the same to the progs code.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
Jeff Mahoney committed 2013-08-26 17:14:42 -04:00
1 parent b23d40f723
commit 47cff72748
51 files changed
+27279 -25108

No files matched your search

+210 -196
View File
@@ -5,7 +5,6 @@
#include "fsck.h"
/* when --check fsck builds a map of objectids of files it finds in the tree
when --rebuild-tree - fsck builds map of objectids it inserts into tree */
@@ -28,111 +27,116 @@ typedef struct sb_id_map {
} sb_id_map_t;
*/
id_map_t *id_map_init() {
id_map_t *map;
__u32 i;
map = getmem(sizeof(id_map_t));
map->index = mem_alloc(INDEX_COUNT * sizeof(void *));
id_map_t *id_map_init()
{
id_map_t *map;
__u32 i;
for (i = 0; i < INDEX_COUNT; i++) {
if (map->index[i] != (void *)0)
map->index[i] = (void *)0;
}
map = getmem(sizeof(id_map_t));
map->index = mem_alloc(INDEX_COUNT * sizeof(void *));
id_map_mark(map, 0);
id_map_mark(map, 1);
for (i = 0; i < INDEX_COUNT; i++) {
if (map->index[i] != (void *)0)
map->index[i] = (void *)0;
}
/* id == 0 should not be there, just for convinient usage */
map->count--;
return map;
id_map_mark(map, 0);
id_map_mark(map, 1);
/* id == 0 should not be there, just for convinient usage */
map->count--;
return map;
}
void id_map_free(id_map_t *map) {
__u32 i;
for (i = 0; i < INDEX_COUNT; i++) {
if (map->index[i] != (void *)0 && map->index[i] != (void *)1)
freemem(map->index[i]);
}
freemem(map->index);
freemem(map);
void id_map_free(id_map_t *map)
{
__u32 i;
for (i = 0; i < INDEX_COUNT; i++) {
if (map->index[i] != (void *)0 && map->index[i] != (void *)1)
freemem(map->index[i]);
}
freemem(map->index);
freemem(map);
}
int id_map_test(id_map_t *map, __u32 id) {
void **interval = id_map_interval(map, id);
int id_map_test(id_map_t *map, __u32 id)
{
void **interval = id_map_interval(map, id);
if (*interval == (void *)0)
return 0;
if (*interval == (void *)1)
return 1;
return misc_test_bit(id % BM_INTERVAL, *interval);
}
int id_map_mark(id_map_t *map, __u32 id)
{
void **interval = id_map_interval(map, id);
if (*interval == (void *)0)
*interval = getmem(ALLOC_SIZE);
if (*interval == (void *)1)
return 1;
if (misc_test_bit(id % BM_INTERVAL, *interval))
return 1;
misc_set_bit(id % BM_INTERVAL, *interval);
(*(__u16 *) id_map_local_count(*interval))++;
map->count++;
if ((*(__u16 *) id_map_local_count(*interval)) == BM_INTERVAL) {
/* Dealloc fully used bitmap */
freemem(*interval);
*interval = (void *)1;
}
if (map->last_used < (id / BM_INTERVAL))
map->last_used = id / BM_INTERVAL;
if (*interval == (void *)0)
return 0;
if (*interval == (void *)1)
return 1;
return misc_test_bit(id % BM_INTERVAL, *interval);
}
int id_map_mark(id_map_t *map, __u32 id) {
void **interval = id_map_interval(map, id);
if (*interval == (void *)0)
*interval = getmem(ALLOC_SIZE);
if (*interval == (void *)1)
return 1;
if (misc_test_bit(id % BM_INTERVAL, *interval))
return 1;
misc_set_bit(id % BM_INTERVAL, *interval);
(*(__u16 *)id_map_local_count(*interval))++;
map->count++;
if ((*(__u16 *)id_map_local_count(*interval)) == BM_INTERVAL) {
/* Dealloc fully used bitmap */
freemem(*interval);
*interval = (void *)1;
}
if (map->last_used < (id / BM_INTERVAL))
map->last_used = id / BM_INTERVAL;
return 0;
}
/* call this for proper_id_map only!! */
__u32 id_map_alloc(id_map_t *map) {
__u32 i, zero_count;
__u32 id = 0, first = ~(__u32)0;
__u32 id_map_alloc(id_map_t *map)
{
__u32 i, zero_count;
__u32 id = 0, first = ~(__u32) 0;
for (i = 0, zero_count = 0; zero_count < 10 && i < INDEX_COUNT - 1; i++) {
if (map->index[i] == (void *)0) {
if (zero_count == 0)
first = i;
zero_count++;
} else if (map->index[i] != (void *)1)
break;
}
for (i = 0, zero_count = 0; zero_count < 10 && i < INDEX_COUNT - 1; i++) {
if (map->index[i] == (void *)0) {
if (zero_count == 0)
first = i;
if (map->index[i] != (void *)1 && map->index[i] != (void *)0) {
id = misc_find_first_zero_bit(map->index[i], BM_INTERVAL);
if (id >= BM_INTERVAL)
die ("Id is out of interval size, interval looks corrupted.");
id += i * BM_INTERVAL;
} else if (first != ~(__u32)0) {
id = first * BM_INTERVAL;
if (id == 0)
id = 2;
} else
die ("%s: No more free objectid is available.", __FUNCTION__);
zero_count++;
} else if (map->index[i] != (void *)1)
break;
}
id_map_mark(map, id);
if (map->index[i] != (void *)1 && map->index[i] != (void *)0) {
id = misc_find_first_zero_bit(map->index[i], BM_INTERVAL);
if (id >= BM_INTERVAL)
die("Id is out of interval size, interval looks corrupted.");
return id;
id += i * BM_INTERVAL;
} else if (first != ~(__u32) 0) {
id = first * BM_INTERVAL;
if (id == 0)
id = 2;
} else
die("%s: No more free objectid is available.", __FUNCTION__);
id_map_mark(map, id);
return id;
}
/* this could be used if some more sofisticated flushing will be needed. */
@@ -143,133 +147,143 @@ static void sb_id_map_pack(sb_id_map_t *map) {
map->m_used_slot_count = 2;
}*/
static __u32 id_map_next_bound(id_map_t *map, __u32 start) {
__u32 index = start / BM_INTERVAL;
__u32 offset = start % BM_INTERVAL;
int look_for;
if (map->index[index] == (void *)0)
look_for = 1;
else if (map->index[index] == (void *)1)
look_for = 0;
else
look_for = !misc_test_bit(offset, map->index[index]);
static __u32 id_map_next_bound(id_map_t *map, __u32 start)
{
__u32 index = start / BM_INTERVAL;
__u32 offset = start % BM_INTERVAL;
int look_for;
offset++;
if (map->index[index] == (void *)0)
look_for = 1;
else if (map->index[index] == (void *)1)
look_for = 0;
else
look_for = !misc_test_bit(offset, map->index[index]);
offset++;
start_again:
if (look_for) {
while (index < INDEX_COUNT && map->index[index] == (void *)0)
index++;
if (index == INDEX_COUNT)
return 0;
if (map->index[index] == (void *)1)
return index * BM_INTERVAL;
offset = misc_find_next_set_bit(map->index[index], BM_INTERVAL, offset);
if (offset >= BM_INTERVAL) {
offset = 0;
index++;
goto start_again;
}
return index * BM_INTERVAL + offset;
} else {
while (index < INDEX_COUNT && map->index[index] == (void *)1)
index++;
if (index == INDEX_COUNT)
return 0;
if (map->index[index] == (void *)0)
return index * BM_INTERVAL;
if (look_for) {
while (index < INDEX_COUNT && map->index[index] == (void *)0)
index++;
offset = misc_find_next_zero_bit(map->index[index], BM_INTERVAL, offset);
if (offset >= BM_INTERVAL) {
offset = 0;
index++;
goto start_again;
if (index == INDEX_COUNT)
return 0;
if (map->index[index] == (void *)1)
return index * BM_INTERVAL;
offset =
misc_find_next_set_bit(map->index[index], BM_INTERVAL,
offset);
if (offset >= BM_INTERVAL) {
offset = 0;
index++;
goto start_again;
}
return index * BM_INTERVAL + offset;
} else {
while (index < INDEX_COUNT && map->index[index] == (void *)1)
index++;
if (index == INDEX_COUNT)
return 0;
if (map->index[index] == (void *)0)
return index * BM_INTERVAL;
offset =
misc_find_next_zero_bit(map->index[index], BM_INTERVAL,
offset);
if (offset >= BM_INTERVAL) {
offset = 0;
index++;
goto start_again;
}
return index * BM_INTERVAL + offset;
}
return index * BM_INTERVAL + offset;
}
}
void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs) {
int size, max, i;
__u32 id, prev_id;
__u32 * sb_objectid_map;
void id_map_flush(struct id_map *map, reiserfs_filsys_t *fs)
{
int size, max, i;
__u32 id, prev_id;
__u32 *sb_objectid_map;
size = reiserfs_super_block_size (fs->fs_ondisk_sb);
sb_objectid_map = (__u32 *)((char *)(fs->fs_ondisk_sb) + size);
size = reiserfs_super_block_size(fs->fs_ondisk_sb);
sb_objectid_map = (__u32 *) ((char *)(fs->fs_ondisk_sb) + size);
max = ((fs->fs_blocksize - size) >> 3 << 1);
set_sb_oid_maxsize (fs->fs_ondisk_sb, max);
id = 1;
sb_objectid_map[0] = cpu_to_le32(1);
max = ((fs->fs_blocksize - size) >> 3 << 1);
set_sb_oid_maxsize(fs->fs_ondisk_sb, max);
for (i = 1; i < max - 1; i++) {
id = id_map_next_bound(map, id);
sb_objectid_map[i] = cpu_to_le32(id);
if (id == 0) {
if (i % 2)
die ("%s: Used interval is not closed on flushing.", __FUNCTION__);
break;
id = 1;
sb_objectid_map[0] = cpu_to_le32(1);
for (i = 1; i < max - 1; i++) {
id = id_map_next_bound(map, id);
sb_objectid_map[i] = cpu_to_le32(id);
if (id == 0) {
if (i % 2)
die("%s: Used interval is not closed on flushing.", __FUNCTION__);
break;
}
}
}
if (map->index[map->last_used] == (void *)0)
die ("Object id map looks corrupted - last used interval cannot be zeroed.");
i++;
if (i == max) {
if (id == 0)
die ("Objectid interval does not contain any set bit what is expected.");
if (map->index[map->last_used] == (void *)1) {
prev_id = BM_INTERVAL - 1;
} else {
prev_id = ~(__u32)0;
if (id < map->last_used * BM_INTERVAL)
id = 0;
else
id %= BM_INTERVAL;
if (misc_test_bit(id, map->index[map->last_used]))
prev_id = id;
while ((id = misc_find_next_set_bit(map->index[map->last_used],
BM_INTERVAL, (id + 1))) != BM_INTERVAL)
{
prev_id = id;
}
if (map->index[map->last_used] == (void *)0)
die("Object id map looks corrupted - last used interval cannot be zeroed.");
if (prev_id == ~(__u32)0)
die ("Objectid interval does not contain any set bit what is expected.");
i++;
prev_id++;
if (i == max) {
if (id == 0)
die("Objectid interval does not contain any set bit what is expected.");
if (map->index[map->last_used] == (void *)1) {
prev_id = BM_INTERVAL - 1;
} else {
prev_id = ~(__u32) 0;
if (id < map->last_used * BM_INTERVAL)
id = 0;
else
id %= BM_INTERVAL;
if (misc_test_bit(id, map->index[map->last_used]))
prev_id = id;
while ((id =
misc_find_next_set_bit(map->
index[map->last_used],
BM_INTERVAL,
(id + 1))) !=
BM_INTERVAL) {
prev_id = id;
}
if (prev_id == ~(__u32) 0)
die("Objectid interval does not contain any set bit what is expected.");
prev_id++;
}
sb_objectid_map[max - 1] =
cpu_to_le32(prev_id + map->last_used * BM_INTERVAL);
} else {
i--;
memset(sb_objectid_map + i, 0, (max - i) * sizeof(__u32));
}
sb_objectid_map[max - 1] = cpu_to_le32(prev_id + map->last_used * BM_INTERVAL);
} else {
i--;
memset(sb_objectid_map + i, 0, (max - i) * sizeof (__u32));
}
set_sb_oid_cursize (fs->fs_ondisk_sb, i);
set_sb_oid_cursize(fs->fs_ondisk_sb, i);
}
/* FIXME: these 3 methods must be implemented also.
void fetch_objectid_map (struct id_map * map, reiserfs_filsys_t * fs)
void fetch_objectid_map (struct id_map * map, reiserfs_filsys_t *fs)
{
int sb_size;
__u32 * sb_objectid_map;