reiserfs: run scripts/Lindent on reiserfs code

This was a pure indentation change, using:

	scripts/Lindent fs/reiserfs/*.c include/linux/reiserfs_*.h

to make reiserfs match the regular Linux indentation style.  As Jeff
Mahoney <jeffm@suse.com> writes:

 The ReiserFS code is a mix of a number of different coding styles, sometimes
 different even from line-to-line. Since the code has been relatively stable
 for quite some time and there are few outstanding patches to be applied, it
 is time to reformat the code to conform to the Linux style standard outlined
 in Documentation/CodingStyle.

 This patch contains the result of running scripts/Lindent against
 fs/reiserfs/*.c and include/linux/reiserfs_*.h. There are places where the
 code can be made to look better, but I'd rather keep those patches separate
 so that there isn't a subtle by-hand hand accident in the middle of a huge
 patch. To be clear: This patch is reformatting *only*.

 A number of patches may follow that continue to make the code more consistent
 with the Linux coding style.

 Hans wasn't particularly enthusiastic about these patches, but said he
 wouldn't really oppose them either.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Linus Torvalds 2005-07-12 20:21:28 -07:00
parent 7fa94c8868
commit bd4c625c06
30 changed files with 23428 additions and 21662 deletions

View file

@ -63,7 +63,8 @@ int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value)
int i, j;
if (block == 0 || block >= SB_BLOCK_COUNT(s)) {
reiserfs_warning (s, "vs-4010: is_reusable: block number is out of range %lu (%u)",
reiserfs_warning(s,
"vs-4010: is_reusable: block number is out of range %lu (%u)",
block, SB_BLOCK_COUNT(s));
return 0;
}
@ -80,7 +81,8 @@ int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value)
get_bit_address(s, block, &i, &j);
if (i >= SB_BMAP_NR(s)) {
reiserfs_warning (s, "vs-4030: is_reusable: there is no so many bitmap blocks: "
reiserfs_warning(s,
"vs-4030: is_reusable: there is no so many bitmap blocks: "
"block=%lu, bitmap_nr=%d", block, i);
return 0;
}
@ -89,15 +91,20 @@ int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value)
reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data)) ||
(bit_value == 1 &&
reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data) == 0)) {
reiserfs_warning (s, "vs-4040: is_reusable: corresponding bit of block %lu does not "
reiserfs_warning(s,
"vs-4040: is_reusable: corresponding bit of block %lu does not "
"match required value (i==%d, j==%d) test_bit==%d",
block, i, j, reiserfs_test_le_bit (j, SB_AP_BITMAP (s)[i].bh->b_data));
block, i, j, reiserfs_test_le_bit(j,
SB_AP_BITMAP
(s)[i].bh->
b_data));
return 0;
}
if (bit_value == 0 && block == SB_ROOT_BLOCK(s)) {
reiserfs_warning (s, "vs-4050: is_reusable: this is root block (%u), "
reiserfs_warning(s,
"vs-4050: is_reusable: this is root block (%u), "
"it must be busy", SB_ROOT_BLOCK(s));
return 0;
}
@ -130,7 +137,8 @@ off, int *next)
/* it searches for a window of zero bits with given minimum and maximum lengths in one bitmap
* block; */
static int scan_bitmap_block(struct reiserfs_transaction_handle *th,
int bmap_n, int *beg, int boundary, int min, int max, int unfm)
int bmap_n, int *beg, int boundary, int min,
int max, int unfm)
{
struct super_block *s = th->t_super;
struct reiserfs_bitmap_info *bi = &SB_AP_BITMAP(s)[bmap_n];
@ -139,7 +147,8 @@ static int scan_bitmap_block (struct reiserfs_transaction_handle *th,
BUG_ON(!th->t_trans_id);
RFALSE(bmap_n >= SB_BMAP_NR (s), "Bitmap %d is out of range (0..%d)",bmap_n, SB_BMAP_NR (s) - 1);
RFALSE(bmap_n >= SB_BMAP_NR(s), "Bitmap %d is out of range (0..%d)",
bmap_n, SB_BMAP_NR(s) - 1);
PROC_INFO_INC(s, scan_bitmap.bmap);
/* this is unclear and lacks comments, explain how journal bitmaps
work here for the reader. Convey a sense of the design here. What
@ -147,7 +156,8 @@ static int scan_bitmap_block (struct reiserfs_transaction_handle *th,
/* - I mean `a window of zero bits' as in description of this function - Zam. */
if (!bi) {
reiserfs_warning (s, "NULL bitmap info pointer for bitmap %d", bmap_n);
reiserfs_warning(s, "NULL bitmap info pointer for bitmap %d",
bmap_n);
return 0;
}
if (buffer_locked(bi->bh)) {
@ -173,7 +183,8 @@ static int scan_bitmap_block (struct reiserfs_transaction_handle *th,
continue;
/* first zero bit found; we check next bits */
for (end = *beg + 1;; end++) {
if (end >= *beg + max || end >= boundary || reiserfs_test_le_bit (end, bi->bh->b_data)) {
if (end >= *beg + max || end >= boundary
|| reiserfs_test_le_bit(end, bi->bh->b_data)) {
next = end;
break;
}
@ -191,7 +202,8 @@ static int scan_bitmap_block (struct reiserfs_transaction_handle *th,
/* try to set all blocks used checking are they still free */
for (i = *beg; i < end; i++) {
/* It seems that we should not check in journal again. */
if (reiserfs_test_and_set_le_bit (i, bi->bh->b_data)) {
if (reiserfs_test_and_set_le_bit
(i, bi->bh->b_data)) {
/* bit was set by another process
* while we slept in prepare_for_journal() */
PROC_INFO_INC(s, scan_bitmap.stolen);
@ -202,8 +214,11 @@ static int scan_bitmap_block (struct reiserfs_transaction_handle *th,
}
/* otherwise we clear all bit were set ... */
while (--i >= *beg)
reiserfs_test_and_clear_le_bit (i, bi->bh->b_data);
reiserfs_restore_prepared_buffer (s, bi->bh);
reiserfs_test_and_clear_le_bit
(i, bi->bh->b_data);
reiserfs_restore_prepared_buffer(s,
bi->
bh);
*beg = org;
/* ... and search again in current block from beginning */
goto cont;
@ -213,7 +228,8 @@ static int scan_bitmap_block (struct reiserfs_transaction_handle *th,
journal_mark_dirty(th, s, bi->bh);
/* free block count calculation */
reiserfs_prepare_for_journal (s, SB_BUFFER_WITH_SB(s), 1);
reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s),
1);
PUT_SB_FREE_BLOCKS(s, SB_FREE_BLOCKS(s) - (end - *beg));
journal_mark_dirty(th, s, SB_BUFFER_WITH_SB(s));
@ -224,7 +240,8 @@ static int scan_bitmap_block (struct reiserfs_transaction_handle *th,
}
}
static int bmap_hash_id(struct super_block *s, u32 id) {
static int bmap_hash_id(struct super_block *s, u32 id)
{
char *hash_in = NULL;
unsigned long hash;
unsigned bm;
@ -248,7 +265,8 @@ static int bmap_hash_id(struct super_block *s, u32 id) {
* hashes the id and then returns > 0 if the block group for the
* corresponding hash is full
*/
static inline int block_group_used(struct super_block *s, u32 id) {
static inline int block_group_used(struct super_block *s, u32 id)
{
int bm;
bm = bmap_hash_id(s, id);
if (SB_AP_BITMAP(s)[bm].free_count > ((s->s_blocksize << 3) * 60 / 100)) {
@ -318,10 +336,15 @@ static int scan_bitmap (struct reiserfs_transaction_handle *th,
* This is only an allocation policy and does not make up for getting a
* bad hint. Decent hinting must be implemented for this to work well.
*/
if ( TEST_OPTION(skip_busy, s) && SB_FREE_BLOCKS(s) > SB_BLOCK_COUNT(s)/20 ) {
if (TEST_OPTION(skip_busy, s)
&& SB_FREE_BLOCKS(s) > SB_BLOCK_COUNT(s) / 20) {
for (; bm < end_bm; bm++, off = 0) {
if ( ( off && (!unfm || (file_block != 0))) || SB_AP_BITMAP(s)[bm].free_count > (s->s_blocksize << 3) / 10 )
nr_allocated = scan_bitmap_block(th, bm, &off, off_max, min, max, unfm);
if ((off && (!unfm || (file_block != 0)))
|| SB_AP_BITMAP(s)[bm].free_count >
(s->s_blocksize << 3) / 10)
nr_allocated =
scan_bitmap_block(th, bm, &off, off_max,
min, max, unfm);
if (nr_allocated)
goto ret;
}
@ -330,12 +353,14 @@ static int scan_bitmap (struct reiserfs_transaction_handle *th,
}
for (; bm < end_bm; bm++, off = 0) {
nr_allocated = scan_bitmap_block(th, bm, &off, off_max, min, max, unfm);
nr_allocated =
scan_bitmap_block(th, bm, &off, off_max, min, max, unfm);
if (nr_allocated)
goto ret;
}
nr_allocated = scan_bitmap_block(th, bm, &off, end_off + 1, min, max, unfm);
nr_allocated =
scan_bitmap_block(th, bm, &off, end_off + 1, min, max, unfm);
ret:
*start = bm * off_max + off;
@ -399,7 +424,8 @@ void reiserfs_free_block (struct reiserfs_transaction_handle *th,
BUG_ON(!th->t_trans_id);
RFALSE(!s, "vs-4061: trying to free block on nonexistent device");
RFALSE(is_reusable (s, block, 1) == 0, "vs-4071: can not free such block");
RFALSE(is_reusable(s, block, 1) == 0,
"vs-4071: can not free such block");
/* mark it before we clear it, just in case */
journal_mark_freed(th, s, block);
_reiserfs_free_block(th, inode, block, for_unformatted);
@ -407,9 +433,12 @@ void reiserfs_free_block (struct reiserfs_transaction_handle *th,
/* preallocated blocks don't need to be run through journal_mark_freed */
static void reiserfs_free_prealloc_block(struct reiserfs_transaction_handle *th,
struct inode *inode, b_blocknr_t block) {
RFALSE(!th->t_super, "vs-4060: trying to free block on nonexistent device");
RFALSE(is_reusable (th->t_super, block, 1) == 0, "vs-4070: can not free such block");
struct inode *inode, b_blocknr_t block)
{
RFALSE(!th->t_super,
"vs-4060: trying to free block on nonexistent device");
RFALSE(is_reusable(th->t_super, block, 1) == 0,
"vs-4070: can not free such block");
BUG_ON(!th->t_trans_id);
_reiserfs_free_block(th, inode, block, 1);
}
@ -423,7 +452,9 @@ static void __discard_prealloc (struct reiserfs_transaction_handle * th,
BUG_ON(!th->t_trans_id);
#ifdef CONFIG_REISERFS_CHECK
if (ei->i_prealloc_count < 0)
reiserfs_warning (th->t_super, "zam-4001:%s: inode has negative prealloc blocks count.", __FUNCTION__ );
reiserfs_warning(th->t_super,
"zam-4001:%s: inode has negative prealloc blocks count.",
__FUNCTION__);
#endif
while (ei->i_prealloc_count > 0) {
reiserfs_free_prealloc_block(th, inode, ei->i_prealloc_block);
@ -455,10 +486,13 @@ void reiserfs_discard_all_prealloc (struct reiserfs_transaction_handle *th)
while (!list_empty(plist)) {
struct reiserfs_inode_info *ei;
ei = list_entry(plist->next, struct reiserfs_inode_info, i_prealloc_list);
ei = list_entry(plist->next, struct reiserfs_inode_info,
i_prealloc_list);
#ifdef CONFIG_REISERFS_CHECK
if (!ei->i_prealloc_count) {
reiserfs_warning (th->t_super, "zam-4001:%s: inode is in prealloc list but has no preallocated blocks.", __FUNCTION__);
reiserfs_warning(th->t_super,
"zam-4001:%s: inode is in prealloc list but has no preallocated blocks.",
__FUNCTION__);
}
#endif
__discard_prealloc(th, ei);
@ -486,18 +520,22 @@ int reiserfs_parse_alloc_options(struct super_block * s, char * options)
if (!strcmp(this_char, "concentrating_formatted_nodes")) {
int temp;
SET_OPTION(concentrating_formatted_nodes);
temp = (value && *value) ? simple_strtoul (value, &value, 0) : 10;
temp = (value
&& *value) ? simple_strtoul(value, &value,
0) : 10;
if (temp <= 0 || temp > 100) {
REISERFS_SB(s)->s_alloc_options.border = 10;
} else {
REISERFS_SB(s)->s_alloc_options.border = 100 / temp;
REISERFS_SB(s)->s_alloc_options.border =
100 / temp;
}
continue;
}
if (!strcmp(this_char, "displacing_large_files")) {
SET_OPTION(displacing_large_files);
REISERFS_SB(s)->s_alloc_options.large_file_size =
(value && *value) ? simple_strtoul (value, &value, 0) : 16;
(value
&& *value) ? simple_strtoul(value, &value, 0) : 16;
continue;
}
if (!strcmp(this_char, "displacing_new_packing_localities")) {
@ -554,13 +592,17 @@ int reiserfs_parse_alloc_options(struct super_block * s, char * options)
if (!strcmp(this_char, "preallocmin")) {
REISERFS_SB(s)->s_alloc_options.preallocmin =
(value && *value) ? simple_strtoul (value, &value, 0) : 4;
(value
&& *value) ? simple_strtoul(value, &value, 0) : 4;
continue;
}
if (!strcmp(this_char, "preallocsize")) {
REISERFS_SB(s)->s_alloc_options.preallocsize =
(value && *value) ? simple_strtoul (value, &value, 0) : PREALLOCATION_SIZE;
(value
&& *value) ? simple_strtoul(value, &value,
0) :
PREALLOCATION_SIZE;
continue;
}
@ -586,18 +628,19 @@ static inline void new_hashed_relocation (reiserfs_blocknr_hint_t * hint)
if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id);
else
hash_in = (char *)(&INODE_PKEY(hint->inode)->k_objectid);
hash_in =
(char *)(&INODE_PKEY(hint->inode)->k_objectid);
}
hint->search_start = hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg);
hint->search_start =
hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg);
}
/*
* Relocation based on dirid, hashing them into a given bitmap block
* files. Formatted nodes are unaffected, a seperate policy covers them
*/
static void
dirid_groups (reiserfs_blocknr_hint_t *hint)
static void dirid_groups(reiserfs_blocknr_hint_t * hint)
{
unsigned long hash;
__u32 dirid = 0;
@ -622,8 +665,7 @@ dirid_groups (reiserfs_blocknr_hint_t *hint)
* Relocation based on oid, hashing them into a given bitmap block
* files. Formatted nodes are unaffected, a seperate policy covers them
*/
static void
oid_groups (reiserfs_blocknr_hint_t *hint)
static void oid_groups(reiserfs_blocknr_hint_t * hint)
{
if (hint->inode) {
unsigned long hash;
@ -697,9 +739,11 @@ static int get_left_neighbor(reiserfs_blocknr_hint_t *hint)
specified as number of percent with mount option device, else try to put
on last of device. This is not to say it is good code to do so,
but the effect should be measured. */
static inline void set_border_in_hint(struct super_block *s, reiserfs_blocknr_hint_t *hint)
static inline void set_border_in_hint(struct super_block *s,
reiserfs_blocknr_hint_t * hint)
{
b_blocknr_t border = SB_BLOCK_COUNT(s) / REISERFS_SB(s)->s_alloc_options.border;
b_blocknr_t border =
SB_BLOCK_COUNT(s) / REISERFS_SB(s)->s_alloc_options.border;
if (hint->formatted_node)
hint->end = border - 1;
@ -710,9 +754,15 @@ static inline void set_border_in_hint(struct super_block *s, reiserfs_blocknr_hi
static inline void displace_large_file(reiserfs_blocknr_hint_t * hint)
{
if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
hint->search_start = hint->beg + keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_dir_id), 4) % (hint->end - hint->beg);
hint->search_start =
hint->beg +
keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_dir_id),
4) % (hint->end - hint->beg);
else
hint->search_start = hint->beg + keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_objectid), 4) % (hint->end - hint->beg);
hint->search_start =
hint->beg +
keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_objectid),
4) % (hint->end - hint->beg);
}
static inline void hash_formatted_node(reiserfs_blocknr_hint_t * hint)
@ -726,12 +776,16 @@ static inline void hash_formatted_node(reiserfs_blocknr_hint_t *hint)
else
hash_in = (char *)(&INODE_PKEY(hint->inode)->k_objectid);
hint->search_start = hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg);
hint->search_start =
hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg);
}
static inline int this_blocknr_allocation_would_make_it_a_large_file(reiserfs_blocknr_hint_t *hint)
static inline int
this_blocknr_allocation_would_make_it_a_large_file(reiserfs_blocknr_hint_t *
hint)
{
return hint->block == REISERFS_SB(hint->th->t_super)->s_alloc_options.large_file_size;
return hint->block ==
REISERFS_SB(hint->th->t_super)->s_alloc_options.large_file_size;
}
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
@ -740,7 +794,9 @@ static inline void displace_new_packing_locality (reiserfs_blocknr_hint_t *hint)
struct in_core_key *key = &hint->key;
hint->th->displace_new_blocks = 0;
hint->search_start = hint->beg + keyed_hash((char*)(&key->k_objectid),4) % (hint->end - hint->beg);
hint->search_start =
hint->beg + keyed_hash((char *)(&key->k_objectid),
4) % (hint->end - hint->beg);
}
#endif
@ -754,7 +810,9 @@ static inline int old_hashed_relocation (reiserfs_blocknr_hint_t * hint)
}
hash_in = le32_to_cpu((INODE_PKEY(hint->inode))->k_dir_id);
border = hint->beg + (u32) keyed_hash(((char *) (&hash_in)), 4) % (hint->end - hint->beg - 1);
border =
hint->beg + (u32) keyed_hash(((char *)(&hash_in)),
4) % (hint->end - hint->beg - 1);
if (border > hint->search_start)
hint->search_start = border;
@ -769,7 +827,10 @@ static inline int old_way (reiserfs_blocknr_hint_t * hint)
return 0;
}
border = hint->beg + le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id) % (hint->end - hint->beg);
border =
hint->beg +
le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id) % (hint->end -
hint->beg);
if (border > hint->search_start)
hint->search_start = border;
@ -781,8 +842,10 @@ static inline void hundredth_slices (reiserfs_blocknr_hint_t * hint)
struct in_core_key *key = &hint->key;
b_blocknr_t slice_start;
slice_start = (keyed_hash((char*)(&key->k_dir_id),4) % 100) * (hint->end / 100);
if ( slice_start > hint->search_start || slice_start + (hint->end / 100) <= hint->search_start) {
slice_start =
(keyed_hash((char *)(&key->k_dir_id), 4) % 100) * (hint->end / 100);
if (slice_start > hint->search_start
|| slice_start + (hint->end / 100) <= hint->search_start) {
hint->search_start = slice_start;
}
}
@ -843,46 +906,44 @@ static void determine_search_start(reiserfs_blocknr_hint_t *hint,
else if (!reiserfs_no_unhashed_relocation(s))
old_hashed_relocation(hint);
if ( hint->inode && hint->search_start < REISERFS_I(hint->inode)->i_prealloc_block)
hint->search_start = REISERFS_I(hint->inode)->i_prealloc_block;
if (hint->inode
&& hint->search_start <
REISERFS_I(hint->inode)->i_prealloc_block)
hint->search_start =
REISERFS_I(hint->inode)->i_prealloc_block;
}
return;
}
/* This is an approach proposed by Hans */
if ( TEST_OPTION(hundredth_slices, s) && ! (displacing_large_files(s) && !hint->formatted_node)) {
if (TEST_OPTION(hundredth_slices, s)
&& !(displacing_large_files(s) && !hint->formatted_node)) {
hundredth_slices(hint);
return;
}
/* old_hashed_relocation only works on unformatted */
if (!unfm_hint && !hint->formatted_node &&
TEST_OPTION(old_hashed_relocation, s))
{
TEST_OPTION(old_hashed_relocation, s)) {
old_hashed_relocation(hint);
}
/* new_hashed_relocation works with both formatted/unformatted nodes */
if ((!unfm_hint || hint->formatted_node) &&
TEST_OPTION(new_hashed_relocation, s))
{
TEST_OPTION(new_hashed_relocation, s)) {
new_hashed_relocation(hint);
}
/* dirid grouping works only on unformatted nodes */
if (!unfm_hint && !hint->formatted_node && TEST_OPTION(dirid_groups,s))
{
if (!unfm_hint && !hint->formatted_node && TEST_OPTION(dirid_groups, s)) {
dirid_groups(hint);
}
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
if (hint->formatted_node && TEST_OPTION(dirid_groups,s))
{
if (hint->formatted_node && TEST_OPTION(dirid_groups, s)) {
dirid_groups(hint);
}
#endif
/* oid grouping works only on unformatted nodes */
if (!unfm_hint && !hint->formatted_node && TEST_OPTION(oid_groups,s))
{
if (!unfm_hint && !hint->formatted_node && TEST_OPTION(oid_groups, s)) {
oid_groups(hint);
}
return;
@ -898,8 +959,12 @@ static int determine_prealloc_size(reiserfs_blocknr_hint_t * hint)
if (!hint->formatted_node && hint->preallocate) {
if (S_ISREG(hint->inode->i_mode)
&& hint->inode->i_size >= REISERFS_SB(hint->th->t_super)->s_alloc_options.preallocmin * hint->inode->i_sb->s_blocksize)
hint->prealloc_size = REISERFS_SB(hint->th->t_super)->s_alloc_options.preallocsize - 1;
&& hint->inode->i_size >=
REISERFS_SB(hint->th->t_super)->s_alloc_options.
preallocmin * hint->inode->i_sb->s_blocksize)
hint->prealloc_size =
REISERFS_SB(hint->th->t_super)->s_alloc_options.
preallocsize - 1;
}
return CARRY_ON;
}
@ -908,17 +973,18 @@ static int determine_prealloc_size(reiserfs_blocknr_hint_t * hint)
but may be result function would be too complex. */
static inline int allocate_without_wrapping_disk(reiserfs_blocknr_hint_t * hint,
b_blocknr_t * new_blocknrs,
b_blocknr_t start, b_blocknr_t finish,
int min,
int amount_needed, int prealloc_size)
b_blocknr_t start,
b_blocknr_t finish, int min,
int amount_needed,
int prealloc_size)
{
int rest = amount_needed;
int nr_allocated;
while (rest > 0 && start <= finish) {
nr_allocated = scan_bitmap(hint->th, &start, finish, min,
rest + prealloc_size, !hint->formatted_node,
hint->block);
rest + prealloc_size,
!hint->formatted_node, hint->block);
if (nr_allocated == 0) /* no new blocks allocated, return */
break;
@ -926,16 +992,19 @@ static inline int allocate_without_wrapping_disk (reiserfs_blocknr_hint_t * hint
/* fill free_blocknrs array first */
while (rest > 0 && nr_allocated > 0) {
*new_blocknrs++ = start++;
rest --; nr_allocated --;
rest--;
nr_allocated--;
}
/* do we have something to fill prealloc. array also ? */
if (nr_allocated > 0) {
/* it means prealloc_size was greater that 0 and we do preallocation */
list_add(&REISERFS_I(hint->inode)->i_prealloc_list,
&SB_JOURNAL(hint->th->t_super)->j_prealloc_list);
&SB_JOURNAL(hint->th->t_super)->
j_prealloc_list);
REISERFS_I(hint->inode)->i_prealloc_block = start;
REISERFS_I(hint->inode)->i_prealloc_count = nr_allocated;
REISERFS_I(hint->inode)->i_prealloc_count =
nr_allocated;
break;
}
}
@ -944,8 +1013,8 @@ static inline int allocate_without_wrapping_disk (reiserfs_blocknr_hint_t * hint
}
static inline int blocknrs_and_prealloc_arrays_from_search_start
(reiserfs_blocknr_hint_t *hint, b_blocknr_t *new_blocknrs, int amount_needed)
{
(reiserfs_blocknr_hint_t * hint, b_blocknr_t * new_blocknrs,
int amount_needed) {
struct super_block *s = hint->th->t_super;
b_blocknr_t start = hint->search_start;
b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
@ -957,16 +1026,23 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
if (!hint->formatted_node) {
int quota_ret;
#ifdef REISERQUOTA_DEBUG
reiserfs_debug (s, REISERFS_DEBUG_CODE, "reiserquota: allocating %d blocks id=%u", amount_needed, hint->inode->i_uid);
reiserfs_debug(s, REISERFS_DEBUG_CODE,
"reiserquota: allocating %d blocks id=%u",
amount_needed, hint->inode->i_uid);
#endif
quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
quota_ret =
DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
if (quota_ret) /* Quota exceeded? */
return QUOTA_EXCEEDED;
if (hint->preallocate && hint->prealloc_size) {
#ifdef REISERQUOTA_DEBUG
reiserfs_debug (s, REISERFS_DEBUG_CODE, "reiserquota: allocating (prealloc) %d blocks id=%u", hint->prealloc_size, hint->inode->i_uid);
reiserfs_debug(s, REISERFS_DEBUG_CODE,
"reiserquota: allocating (prealloc) %d blocks id=%u",
hint->prealloc_size, hint->inode->i_uid);
#endif
quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode, hint->prealloc_size);
quota_ret =
DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
hint->prealloc_size);
if (quota_ret)
hint->preallocate = hint->prealloc_size = 0;
}
@ -1010,31 +1086,49 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
/* Free the blocks */
if (!hint->formatted_node) {
#ifdef REISERQUOTA_DEBUG
reiserfs_debug (s, REISERFS_DEBUG_CODE, "reiserquota: freeing (nospace) %d blocks id=%u", amount_needed + hint->prealloc_size - nr_allocated, hint->inode->i_uid);
reiserfs_debug(s, REISERFS_DEBUG_CODE,
"reiserquota: freeing (nospace) %d blocks id=%u",
amount_needed +
hint->prealloc_size -
nr_allocated,
hint->inode->i_uid);
#endif
DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
}
while (nr_allocated--)
reiserfs_free_block(hint->th, hint->inode, new_blocknrs[nr_allocated], !hint->formatted_node);
reiserfs_free_block(hint->th, hint->inode,
new_blocknrs[nr_allocated],
!hint->formatted_node);
return NO_DISK_SPACE;
}
} while ((nr_allocated += allocate_without_wrapping_disk(hint,
new_blocknrs + nr_allocated, start, finish,
bigalloc ? bigalloc : 1,
amount_needed - nr_allocated,
hint->prealloc_size))
new_blocknrs +
nr_allocated,
start, finish,
bigalloc ?
bigalloc : 1,
amount_needed -
nr_allocated,
hint->
prealloc_size))
< amount_needed);
if (!hint->formatted_node &&
amount_needed + hint->prealloc_size >
nr_allocated + REISERFS_I(hint->inode)->i_prealloc_count) {
/* Some of preallocation blocks were not allocated */
#ifdef REISERQUOTA_DEBUG
reiserfs_debug (s, REISERFS_DEBUG_CODE, "reiserquota: freeing (failed prealloc) %d blocks id=%u", amount_needed + hint->prealloc_size - nr_allocated - REISERFS_I(hint->inode)->i_prealloc_count, hint->inode->i_uid);
reiserfs_debug(s, REISERFS_DEBUG_CODE,
"reiserquota: freeing (failed prealloc) %d blocks id=%u",
amount_needed + hint->prealloc_size -
nr_allocated -
REISERFS_I(hint->inode)->i_prealloc_count,
hint->inode->i_uid);
#endif
DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
hint->prealloc_size - nr_allocated -
REISERFS_I(hint->inode)->i_prealloc_count);
REISERFS_I(hint->inode)->
i_prealloc_count);
}
return CARRY_ON;
@ -1043,7 +1137,8 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
/* grab new blocknrs from preallocated list */
/* return amount still needed after using them */
static int use_preallocated_list_if_available(reiserfs_blocknr_hint_t * hint,
b_blocknr_t *new_blocknrs, int amount_needed)
b_blocknr_t * new_blocknrs,
int amount_needed)
{
struct inode *inode = hint->inode;
@ -1065,9 +1160,7 @@ static int use_preallocated_list_if_available (reiserfs_blocknr_hint_t *hint,
return amount_needed;
}
int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *hint,
b_blocknr_t * new_blocknrs, int amount_needed,
int reserved_by_us /* Amount of blocks we have
int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t * hint, b_blocknr_t * new_blocknrs, int amount_needed, int reserved_by_us /* Amount of blocks we have
already reserved */ )
{
int initial_amount_needed = amount_needed;
@ -1108,7 +1201,8 @@ int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *hint,
if (ret != CARRY_ON) {
while (amount_needed++ < initial_amount_needed) {
reiserfs_free_block(hint->th, hint->inode, *(--new_blocknrs), 1);
reiserfs_free_block(hint->th, hint->inode,
*(--new_blocknrs), 1);
}
}
return ret;
@ -1117,8 +1211,7 @@ int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *hint,
/* These 2 functions are here to provide blocks reservation to the rest of kernel */
/* Reserve @blocks amount of blocks in fs pointed by @sb. Caller must make sure
there are actually this much blocks on the FS available */
void reiserfs_claim_blocks_to_be_allocated(
struct super_block *sb, /* super block of
void reiserfs_claim_blocks_to_be_allocated(struct super_block *sb, /* super block of
filesystem where
blocks should be
reserved */
@ -1136,8 +1229,7 @@ void reiserfs_claim_blocks_to_be_allocated(
}
/* Unreserve @blocks amount of blocks in fs pointed by @sb */
void reiserfs_release_claimed_blocks(
struct super_block *sb, /* super block of
void reiserfs_release_claimed_blocks(struct super_block *sb, /* super block of
filesystem where
blocks should be
reserved */
@ -1152,7 +1244,8 @@ void reiserfs_release_claimed_blocks(
spin_lock(&REISERFS_SB(sb)->bitmap_lock);
REISERFS_SB(sb)->reserved_blocks -= blocks;
spin_unlock(&REISERFS_SB(sb)->bitmap_lock);
RFALSE( REISERFS_SB(sb)->reserved_blocks < 0, "amount of blocks reserved became zero?");
RFALSE(REISERFS_SB(sb)->reserved_blocks < 0,
"amount of blocks reserved became zero?");
}
/* This function estimates how much pages we will be able to write to FS
@ -1163,7 +1256,10 @@ int reiserfs_can_fit_pages ( struct super_block *sb /* superblock of filesystem
int space;
spin_lock(&REISERFS_SB(sb)->bitmap_lock);
space = (SB_FREE_BLOCKS(sb) - REISERFS_SB(sb)->reserved_blocks) >> ( PAGE_CACHE_SHIFT - sb->s_blocksize_bits);
space =
(SB_FREE_BLOCKS(sb) -
REISERFS_SB(sb)->reserved_blocks) >> (PAGE_CACHE_SHIFT -
sb->s_blocksize_bits);
spin_unlock(&REISERFS_SB(sb)->bitmap_lock);
return space > 0 ? space : 0;

View file

@ -15,7 +15,8 @@
extern struct reiserfs_key MIN_KEY;
static int reiserfs_readdir(struct file *, void *, filldir_t);
static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, int datasync) ;
static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry,
int datasync);
struct file_operations reiserfs_dir_operations = {
.read = generic_read_dir,
@ -24,7 +25,9 @@ struct file_operations reiserfs_dir_operations = {
.ioctl = reiserfs_ioctl,
};
static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, int datasync) {
static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry,
int datasync)
{
struct inode *inode = dentry->d_inode;
int err;
reiserfs_write_lock(inode->i_sb);
@ -35,7 +38,6 @@ static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, int data
return 0;
}
#define store_ih(where,what) copy_item_head (where, what)
//
@ -61,8 +63,9 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
/* form key for search the next directory entry using f_pos field of
file structure */
make_cpu_key (&pos_key, inode, (filp->f_pos) ? (filp->f_pos) : DOT_OFFSET,
TYPE_DIRENTRY, 3);
make_cpu_key(&pos_key, inode,
(filp->f_pos) ? (filp->f_pos) : DOT_OFFSET, TYPE_DIRENTRY,
3);
next_pos = cpu_key_k_offset(&pos_key);
/* reiserfs_warning (inode->i_sb, "reiserfs_readdir 1: f_pos = %Ld", filp->f_pos); */
@ -71,7 +74,9 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
while (1) {
research:
/* search the directory item, containing entry with specified key */
search_res = search_by_entry_key (inode->i_sb, &pos_key, &path_to_entry, &de);
search_res =
search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
&de);
if (search_res == IO_ERROR) {
// FIXME: we could just skip part of directory which could
// not be read
@ -97,11 +102,14 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
"vs-9010: entry number is too big %d (%d)",
entry_num, I_ENTRY_COUNT(ih));
if (search_res == POSITION_FOUND || entry_num < I_ENTRY_COUNT (ih)) {
if (search_res == POSITION_FOUND
|| entry_num < I_ENTRY_COUNT(ih)) {
/* go through all entries in the directory item beginning from the entry, that has been found */
struct reiserfs_de_head * deh = B_I_DEH (bh, ih) + entry_num;
struct reiserfs_de_head *deh =
B_I_DEH(bh, ih) + entry_num;
for (; entry_num < I_ENTRY_COUNT (ih); entry_num ++, deh ++) {
for (; entry_num < I_ENTRY_COUNT(ih);
entry_num++, deh++) {
int d_reclen;
char *d_name;
off_t d_off;
@ -115,7 +123,9 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
if (!d_name[d_reclen - 1])
d_reclen = strlen(d_name);
if (d_reclen > REISERFS_MAX_NAME(inode->i_sb->s_blocksize)){
if (d_reclen >
REISERFS_MAX_NAME(inode->i_sb->
s_blocksize)) {
/* too big to send back to VFS */
continue;
}
@ -125,8 +135,12 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
!old_format_only(inode->i_sb) &&
filp->f_dentry == inode->i_sb->s_root &&
REISERFS_SB(inode->i_sb)->priv_root &&
REISERFS_SB(inode->i_sb)->priv_root->d_inode &&
deh_objectid(deh) == le32_to_cpu (INODE_PKEY(REISERFS_SB(inode->i_sb)->priv_root->d_inode)->k_objectid)) {
REISERFS_SB(inode->i_sb)->priv_root->d_inode
&& deh_objectid(deh) ==
le32_to_cpu(INODE_PKEY
(REISERFS_SB(inode->i_sb)->
priv_root->d_inode)->
k_objectid)) {
continue;
}
@ -136,14 +150,18 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
if (d_reclen <= 32) {
local_buf = small_buf;
} else {
local_buf = reiserfs_kmalloc(d_reclen, GFP_NOFS, inode->i_sb) ;
local_buf =
reiserfs_kmalloc(d_reclen, GFP_NOFS,
inode->i_sb);
if (!local_buf) {
pathrelse(&path_to_entry);
ret = -ENOMEM;
goto out;
}
if (item_moved(&tmp_ih, &path_to_entry)) {
reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
reiserfs_kfree(local_buf,
d_reclen,
inode->i_sb);
goto research;
}
}
@ -152,17 +170,20 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
// user space buffer is swapped out. At that time
// entry can move to somewhere else
memcpy(local_buf, d_name, d_reclen);
if (filldir (dirent, local_buf, d_reclen, d_off, d_ino,
if (filldir
(dirent, local_buf, d_reclen, d_off, d_ino,
DT_UNKNOWN) < 0) {
if (local_buf != small_buf) {
reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
reiserfs_kfree(local_buf,
d_reclen,
inode->i_sb);
}
goto end;
}
if (local_buf != small_buf) {
reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
reiserfs_kfree(local_buf, d_reclen,
inode->i_sb);
}
// next entry should be looked for with such offset
next_pos = deh_offset(deh) + 1;
@ -192,11 +213,11 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
}
/* directory continues in the right neighboring block */
set_cpu_key_k_offset (&pos_key, le_key_k_offset (KEY_FORMAT_3_5, rkey));
set_cpu_key_k_offset(&pos_key,
le_key_k_offset(KEY_FORMAT_3_5, rkey));
} /* while */
end:
filp->f_pos = next_pos;
pathrelse(&path_to_entry);
@ -266,7 +287,8 @@ void make_empty_dir_item (char * body, __le32 dirid, __le32 objid,
deh[1].deh_dir_id = par_dirid;
deh[1].deh_objectid = par_objid;
deh[1].deh_state = 0; /* Endian safe if 0 */
put_deh_location( &(deh[1]), deh_location( &(deh[0])) - ROUND_UP( strlen( ".." ) ) );
put_deh_location(&(deh[1]),
deh_location(&(deh[0])) - ROUND_UP(strlen("..")));
mark_de_visible(&(deh[1]));
/* copy ".." and "." */

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,6 @@
* Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
*/
#include <linux/time.h>
#include <linux/reiserfs_fs.h>
#include <linux/reiserfs_acl.h>
@ -74,7 +73,8 @@ static int reiserfs_file_release (struct inode * inode, struct file * filp)
* and let the admin know what is going on.
*/
igrab(inode);
reiserfs_warning(inode->i_sb, "pinning inode %lu because the "
reiserfs_warning(inode->i_sb,
"pinning inode %lu because the "
"preallocation can't be freed");
goto out;
}
@ -105,7 +105,8 @@ out:
return err;
}
static void reiserfs_vfs_truncate_file(struct inode *inode) {
static void reiserfs_vfs_truncate_file(struct inode *inode)
{
reiserfs_truncate_file(inode, 1);
}
@ -116,11 +117,9 @@ static void reiserfs_vfs_truncate_file(struct inode *inode) {
* be removed...
*/
static int reiserfs_sync_file(
struct file * p_s_filp,
struct dentry * p_s_dentry,
int datasync
) {
static int reiserfs_sync_file(struct file *p_s_filp,
struct dentry *p_s_dentry, int datasync)
{
struct inode *p_s_inode = p_s_dentry->d_inode;
int n_err;
int barrier_done;
@ -147,9 +146,7 @@ static int reiserfs_sync_file(
/* Allocates blocks for a file to fulfil write request.
Maps all unmapped but prepared pages from the list.
Updates metadata with newly allocated blocknumbers as needed */
static int reiserfs_allocate_blocks_for_region(
struct reiserfs_transaction_handle *th,
struct inode *inode, /* Inode we work with */
static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handle *th, struct inode *inode, /* Inode we work with */
loff_t pos, /* Writing position */
int num_pages, /* number of pages write going
to touch */
@ -182,14 +179,16 @@ static int reiserfs_allocate_blocks_for_region(
// of the fact that we already prepared
// current block for journal
int will_prealloc = 0;
RFALSE(!blocks_to_allocate, "green-9004: tried to allocate zero blocks?");
RFALSE(!blocks_to_allocate,
"green-9004: tried to allocate zero blocks?");
/* only preallocate if this is a small write */
if (REISERFS_I(inode)->i_prealloc_count ||
(!(write_bytes & (inode->i_sb->s_blocksize - 1)) &&
blocks_to_allocate <
REISERFS_SB(inode->i_sb)->s_alloc_options.preallocsize))
will_prealloc = REISERFS_SB(inode->i_sb)->s_alloc_options.preallocsize;
will_prealloc =
REISERFS_SB(inode->i_sb)->s_alloc_options.preallocsize;
allocated_blocks = kmalloc((blocks_to_allocate + will_prealloc) *
sizeof(b_blocknr_t), GFP_NOFS);
@ -225,7 +224,9 @@ static int reiserfs_allocate_blocks_for_region(
hint.preallocate = will_prealloc;
/* Call block allocator to allocate blocks */
res = reiserfs_allocate_blocknrs(&hint, allocated_blocks, blocks_to_allocate, blocks_to_allocate);
res =
reiserfs_allocate_blocknrs(&hint, allocated_blocks,
blocks_to_allocate, blocks_to_allocate);
if (res != CARRY_ON) {
if (res == NO_DISK_SPACE) {
/* We flush the transaction in case of no space. This way some
@ -236,14 +237,19 @@ static int reiserfs_allocate_blocks_for_region(
goto error_exit;
/* We might have scheduled, so search again */
res = search_for_position_by_key(inode->i_sb, &key, &path);
res =
search_for_position_by_key(inode->i_sb, &key,
&path);
if (res == IO_ERROR) {
res = -EIO;
goto error_exit;
}
/* update changed info for hint structure. */
res = reiserfs_allocate_blocknrs(&hint, allocated_blocks, blocks_to_allocate, blocks_to_allocate);
res =
reiserfs_allocate_blocknrs(&hint, allocated_blocks,
blocks_to_allocate,
blocks_to_allocate);
if (res != CARRY_ON) {
res = -ENOSPC;
pathrelse(&path);
@ -255,7 +261,6 @@ static int reiserfs_allocate_blocks_for_region(
goto error_exit;
}
}
#ifdef __BIG_ENDIAN
// Too bad, I have not found any way to convert a given region from
// cpu format to little endian format
@ -297,10 +302,13 @@ static int reiserfs_allocate_blocks_for_region(
if (is_statdata_le_ih(ih))
item_offset = 0;
hole_size = (pos + item_offset -
(le_key_k_offset( get_inode_item_key_version(inode),
&(ih->ih_key)) +
op_bytes_number(ih, inode->i_sb->s_blocksize))) >>
inode->i_sb->s_blocksize_bits;
(le_key_k_offset
(get_inode_item_key_version(inode),
&(ih->ih_key)) + op_bytes_number(ih,
inode->
i_sb->
s_blocksize)))
>> inode->i_sb->s_blocksize_bits;
}
if (hole_size > 0) {
@ -315,12 +323,33 @@ static int reiserfs_allocate_blocks_for_region(
}
memset(zeros, 0, to_paste * UNFM_P_SIZE);
do {
to_paste = min_t(__u64, hole_size, MAX_ITEM_LEN(inode->i_sb->s_blocksize)/UNFM_P_SIZE );
to_paste =
min_t(__u64, hole_size,
MAX_ITEM_LEN(inode->i_sb->
s_blocksize) /
UNFM_P_SIZE);
if (is_indirect_le_ih(ih)) {
/* Ok, there is existing indirect item already. Need to append it */
/* Calculate position past inserted item */
make_cpu_key( &key, inode, le_key_k_offset( get_inode_item_key_version(inode), &(ih->ih_key)) + op_bytes_number(ih, inode->i_sb->s_blocksize), TYPE_INDIRECT, 3);
res = reiserfs_paste_into_item( th, &path, &key, inode, (char *)zeros, UNFM_P_SIZE*to_paste);
make_cpu_key(&key, inode,
le_key_k_offset
(get_inode_item_key_version
(inode),
&(ih->ih_key)) +
op_bytes_number(ih,
inode->
i_sb->
s_blocksize),
TYPE_INDIRECT, 3);
res =
reiserfs_paste_into_item(th, &path,
&key,
inode,
(char *)
zeros,
UNFM_P_SIZE
*
to_paste);
if (res) {
kfree(zeros);
goto error_exit_free_blocks;
@ -331,29 +360,43 @@ static int reiserfs_allocate_blocks_for_region(
struct item_head ins_ih;
/* create a key for our new item */
make_cpu_key( &key, inode, 1, TYPE_INDIRECT, 3);
make_cpu_key(&key, inode, 1,
TYPE_INDIRECT, 3);
/* Create new item head for our new item */
make_le_item_head (&ins_ih, &key, key.version, 1,
TYPE_INDIRECT, to_paste*UNFM_P_SIZE,
make_le_item_head(&ins_ih, &key,
key.version, 1,
TYPE_INDIRECT,
to_paste *
UNFM_P_SIZE,
0 /* free space */ );
/* Find where such item should live in the tree */
res = search_item (inode->i_sb, &key, &path);
res =
search_item(inode->i_sb, &key,
&path);
if (res != ITEM_NOT_FOUND) {
/* item should not exist, otherwise we have error */
if (res != -ENOSPC) {
reiserfs_warning (inode->i_sb,
reiserfs_warning(inode->
i_sb,
"green-9008: search_by_key (%K) returned %d",
&key, res);
&key,
res);
}
res = -EIO;
kfree(zeros);
goto error_exit_free_blocks;
}
res = reiserfs_insert_item( th, &path, &key, &ins_ih, inode, (char *)zeros);
res =
reiserfs_insert_item(th, &path,
&key, &ins_ih,
inode,
(char *)zeros);
} else {
reiserfs_panic(inode->i_sb, "green-9011: Unexpected key type %K\n", &key);
reiserfs_panic(inode->i_sb,
"green-9011: Unexpected key type %K\n",
&key);
}
if (res) {
kfree(zeros);
@ -361,8 +404,11 @@ static int reiserfs_allocate_blocks_for_region(
}
/* Now we want to check if transaction is too full, and if it is
we restart it. This will also free the path. */
if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
res = restart_transaction(th, inode, &path);
if (journal_transaction_should_end
(th, th->t_blocks_allocated)) {
res =
restart_transaction(th, inode,
&path);
if (res) {
pathrelse(&path);
kfree(zeros);
@ -371,8 +417,13 @@ static int reiserfs_allocate_blocks_for_region(
}
/* Well, need to recalculate path and stuff */
set_cpu_key_k_offset( &key, cpu_key_k_offset(&key) + (to_paste << inode->i_blkbits));
res = search_for_position_by_key(inode->i_sb, &key, &path);
set_cpu_key_k_offset(&key,
cpu_key_k_offset(&key) +
(to_paste << inode->
i_blkbits));
res =
search_for_position_by_key(inode->i_sb,
&key, &path);
if (res == IO_ERROR) {
res = -EIO;
kfree(zeros);
@ -386,13 +437,13 @@ static int reiserfs_allocate_blocks_for_region(
kfree(zeros);
}
}
// Go through existing indirect items first
// replace all zeroes with blocknumbers from list
// Note that if no corresponding item was found, by previous search,
// it means there are no existing in-tree representation for file area
// we are going to overwrite, so there is nothing to scan through for holes.
for ( curr_block = 0, itempos = path.pos_in_item ; curr_block < blocks_to_allocate && res == POSITION_FOUND ; ) {
for (curr_block = 0, itempos = path.pos_in_item;
curr_block < blocks_to_allocate && res == POSITION_FOUND;) {
retry:
if (itempos >= ih_item_len(ih) / UNFM_P_SIZE) {
@ -405,9 +456,17 @@ retry:
}
/* Then set the key to look for a new indirect item (offset of old
item is added to old item length */
set_cpu_key_k_offset( &key, le_key_k_offset( get_inode_item_key_version(inode), &(ih->ih_key)) + op_bytes_number(ih, inode->i_sb->s_blocksize));
set_cpu_key_k_offset(&key,
le_key_k_offset
(get_inode_item_key_version(inode),
&(ih->ih_key)) +
op_bytes_number(ih,
inode->i_sb->
s_blocksize));
/* Search ofor position of new key in the tree. */
res = search_for_position_by_key(inode->i_sb, &key, &path);
res =
search_for_position_by_key(inode->i_sb, &key,
&path);
if (res == IO_ERROR) {
res = -EIO;
goto error_exit_free_blocks;
@ -436,14 +495,21 @@ retry:
copy_item_head(&tmp_ih, ih); // Remember itemhead
fs_gen = get_generation(inode->i_sb); // remember fs generation
reiserfs_prepare_for_journal(inode->i_sb, bh, 1); // Prepare a buffer within which indirect item is stored for changing.
if (fs_changed (fs_gen, inode->i_sb) && item_moved (&tmp_ih, &path)) {
if (fs_changed(fs_gen, inode->i_sb)
&& item_moved(&tmp_ih, &path)) {
// Sigh, fs was changed under us, we need to look for new
// location of item we are working with
/* unmark prepaerd area as journaled and search for it's
new position */
reiserfs_restore_prepared_buffer(inode->i_sb, bh);
res = search_for_position_by_key(inode->i_sb, &key, &path);
reiserfs_restore_prepared_buffer(inode->
i_sb,
bh);
res =
search_for_position_by_key(inode->
i_sb,
&key,
&path);
if (res == IO_ERROR) {
res = -EIO;
goto error_exit_free_blocks;
@ -474,8 +540,20 @@ retry:
// Existing indirect item - append. First calculate key for append
// position. We do not need to recalculate path as it should
// already point to correct place.
make_cpu_key( &key, inode, le_key_k_offset( get_inode_item_key_version(inode), &(ih->ih_key)) + op_bytes_number(ih, inode->i_sb->s_blocksize), TYPE_INDIRECT, 3);
res = reiserfs_paste_into_item( th, &path, &key, inode, (char *)(allocated_blocks+curr_block), UNFM_P_SIZE*(blocks_to_allocate-curr_block));
make_cpu_key(&key, inode,
le_key_k_offset(get_inode_item_key_version
(inode),
&(ih->ih_key)) +
op_bytes_number(ih,
inode->i_sb->s_blocksize),
TYPE_INDIRECT, 3);
res =
reiserfs_paste_into_item(th, &path, &key, inode,
(char *)(allocated_blocks +
curr_block),
UNFM_P_SIZE *
(blocks_to_allocate -
curr_block));
if (res) {
goto error_exit_free_blocks;
}
@ -490,8 +568,10 @@ retry:
// indirect item
// begins
/* Create new item head for our new item */
make_le_item_head (&ins_ih, &key, key.version, 1, TYPE_INDIRECT,
(blocks_to_allocate-curr_block)*UNFM_P_SIZE,
make_le_item_head(&ins_ih, &key, key.version, 1,
TYPE_INDIRECT,
(blocks_to_allocate -
curr_block) * UNFM_P_SIZE,
0 /* free space */ );
/* Find where such item should live in the tree */
res = search_item(inode->i_sb, &key, &path);
@ -501,18 +581,24 @@ retry:
if (res != -ENOSPC) {
reiserfs_warning(inode->i_sb,
"green-9009: search_by_key (%K) "
"returned %d", &key, res);
"returned %d", &key,
res);
}
res = -EIO;
goto error_exit_free_blocks;
}
/* Insert item into the tree with the data as its body */
res = reiserfs_insert_item( th, &path, &key, &ins_ih, inode, (char *)(allocated_blocks+curr_block));
res =
reiserfs_insert_item(th, &path, &key, &ins_ih,
inode,
(char *)(allocated_blocks +
curr_block));
} else {
reiserfs_panic(inode->i_sb, "green-9010: unexpected item type for key %K\n",&key);
reiserfs_panic(inode->i_sb,
"green-9010: unexpected item type for key %K\n",
&key);
}
}
// the caller is responsible for closing the transaction
// unless we return an error, they are also responsible for logging
// the inode.
@ -535,13 +621,15 @@ retry:
int block_start, block_end; // in-page offsets for buffers.
if (!page_buffers(page))
reiserfs_panic(inode->i_sb, "green-9005: No buffers for prepared page???");
reiserfs_panic(inode->i_sb,
"green-9005: No buffers for prepared page???");
/* For each buffer in page */
for (bh = head, block_start = 0; bh != head || !block_start;
block_start = block_end, bh = bh->b_this_page) {
if (!bh)
reiserfs_panic(inode->i_sb, "green-9006: Allocated but absent buffer for a page?");
reiserfs_panic(inode->i_sb,
"green-9006: Allocated but absent buffer for a page?");
block_end = block_start + inode->i_sb->s_blocksize;
if (i == 0 && block_end <= from)
/* if this buffer is before requested data to map, skip it */
@ -552,14 +640,17 @@ retry:
break;
if (!buffer_mapped(bh)) { // Ok, unmapped buffer, need to map it
map_bh( bh, inode->i_sb, le32_to_cpu(allocated_blocks[curr_block]));
map_bh(bh, inode->i_sb,
le32_to_cpu(allocated_blocks
[curr_block]));
curr_block++;
set_buffer_new(bh);
}
}
}
RFALSE( curr_block > blocks_to_allocate, "green-9007: Used too many blocks? weird");
RFALSE(curr_block > blocks_to_allocate,
"green-9007: Used too many blocks? weird");
kfree(allocated_blocks);
return 0;
@ -569,14 +660,18 @@ error_exit_free_blocks:
pathrelse(&path);
// free blocks
for (i = 0; i < blocks_to_allocate; i++)
reiserfs_free_block(th, inode, le32_to_cpu(allocated_blocks[i]), 1);
reiserfs_free_block(th, inode, le32_to_cpu(allocated_blocks[i]),
1);
error_exit:
if (th->t_trans_id) {
int err;
// update any changes we made to blk count
reiserfs_update_sd(th, inode);
err = journal_end(th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3 + 1 + 2 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb));
err =
journal_end(th, inode->i_sb,
JOURNAL_PER_BALANCE_CNT * 3 + 1 +
2 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb));
if (err)
res = err;
}
@ -588,7 +683,8 @@ error_exit:
/* Unlock pages prepared by reiserfs_prepare_file_region_for_write */
static void reiserfs_unprepare_pages(struct page **prepared_pages, /* list of locked pages */
size_t num_pages /* amount of pages */) {
size_t num_pages /* amount of pages */ )
{
int i; // loop counter
for (i = 0; i < num_pages; i++) {
@ -602,8 +698,7 @@ static void reiserfs_unprepare_pages(struct page **prepared_pages, /* list of lo
/* This function will copy data from userspace to specified pages within
supplied byte range */
static int reiserfs_copy_from_user_to_file_region(
loff_t pos, /* In-file position */
static int reiserfs_copy_from_user_to_file_region(loff_t pos, /* In-file position */
int num_pages, /* Number of pages affected */
int write_bytes, /* Amount of bytes to write */
struct page **prepared_pages, /* pointer to
@ -618,7 +713,8 @@ static int reiserfs_copy_from_user_to_file_region(
int i; // loop counter.
int offset; // offset in page
for ( i = 0, offset = (pos & (PAGE_CACHE_SIZE-1)); i < num_pages ; i++,offset=0) {
for (i = 0, offset = (pos & (PAGE_CACHE_SIZE - 1)); i < num_pages;
i++, offset = 0) {
size_t count = min_t(size_t, PAGE_CACHE_SIZE - offset, write_bytes); // How much of bytes to write to this page
struct page *page = prepared_pages[i]; // Current page we process.
@ -668,8 +764,7 @@ int reiserfs_commit_page(struct inode *inode, struct page *page,
}
for (bh = head = page_buffers(page), block_start = 0;
bh != head || !block_start;
block_start=block_end, bh = bh->b_this_page)
{
block_start = block_end, bh = bh->b_this_page) {
new = buffer_new(bh);
clear_buffer_new(bh);
@ -710,14 +805,10 @@ drop_write_lock:
return ret;
}
/* Submit pages for write. This was separated from actual file copying
because we might want to allocate block numbers in-between.
This function assumes that caller will adjust file size to correct value. */
static int reiserfs_submit_file_region_for_write(
struct reiserfs_transaction_handle *th,
struct inode *inode,
loff_t pos, /* Writing position offset */
static int reiserfs_submit_file_region_for_write(struct reiserfs_transaction_handle *th, struct inode *inode, loff_t pos, /* Writing position offset */
size_t num_pages, /* Number of pages to write */
size_t write_bytes, /* number of bytes to write */
struct page **prepared_pages /* list of pages */
@ -730,11 +821,13 @@ static int reiserfs_submit_file_region_for_write(
int orig_write_bytes = write_bytes;
int sd_update = 0;
for ( i = 0, offset = (pos & (PAGE_CACHE_SIZE-1)); i < num_pages ; i++,offset=0) {
for (i = 0, offset = (pos & (PAGE_CACHE_SIZE - 1)); i < num_pages;
i++, offset = 0) {
int count = min_t(int, PAGE_CACHE_SIZE - offset, write_bytes); // How much of bytes to write to this page
struct page *page = prepared_pages[i]; // Current page we process.
status = reiserfs_commit_page(inode, page, offset, offset+count);
status =
reiserfs_commit_page(inode, page, offset, offset + count);
if (status)
retval = status; // To not overcomplicate matters We are going to
// submit all the pages even if there was error.
@ -819,7 +912,8 @@ static int reiserfs_check_for_tail_and_convert( struct inode *inode, /* inode to
/* find the item containing the last byte to be written, or if
* writing past the end of the file then the last item of the
* file (and then we check its type). */
make_cpu_key (&key, inode, pos+write_bytes+1, TYPE_ANY, 3/*key length*/);
make_cpu_key(&key, inode, pos + write_bytes + 1, TYPE_ANY,
3 /*key length */ );
res = search_for_position_by_key(inode->i_sb, &key, &path);
if (res == IO_ERROR) {
reiserfs_write_unlock(inode->i_sb);
@ -833,7 +927,9 @@ static int reiserfs_check_for_tail_and_convert( struct inode *inode, /* inode to
/* To not overcomplicate matters, we just call generic_cont_expand
which will in turn call other stuff and finally will boil down to
reiserfs_get_block() that would do necessary conversion. */
cont_expand_offset = le_key_k_offset(get_inode_item_key_version(inode), &(ih->ih_key));
cont_expand_offset =
le_key_k_offset(get_inode_item_key_version(inode),
&(ih->ih_key));
pathrelse(&path);
res = generic_cont_expand(inode, cont_expand_offset);
} else
@ -851,8 +947,8 @@ static int reiserfs_check_for_tail_and_convert( struct inode *inode, /* inode to
append), it is zeroed, then.
Returns number of unallocated blocks that should be allocated to cover
new file data.*/
static int reiserfs_prepare_file_region_for_write(
struct inode *inode /* Inode of the file */,
static int reiserfs_prepare_file_region_for_write(struct inode *inode
/* Inode of the file */ ,
loff_t pos, /* position in the file */
size_t num_pages, /* number of pages to
prepare */
@ -894,7 +990,6 @@ static int reiserfs_prepare_file_region_for_write(
__le32 *item = NULL; // pointer to item we are going to deal with
int item_pos = -1; /* Position in indirect item */
if (num_pages < 1) {
reiserfs_warning(inode->i_sb,
"green-9001: reiserfs_prepare_file_region_for_write "
@ -912,7 +1007,8 @@ static int reiserfs_prepare_file_region_for_write(
goto failed_page_grabbing;
}
if (!page_has_buffers(prepared_pages[i]))
create_empty_buffers(prepared_pages[i], inode->i_sb->s_blocksize, 0);
create_empty_buffers(prepared_pages[i],
inode->i_sb->s_blocksize, 0);
}
/* Let's count amount of blocks for a case where all the blocks
@ -920,11 +1016,11 @@ static int reiserfs_prepare_file_region_for_write(
if (num_pages > 2)
/* These are full-overwritten pages so we count all the blocks in
these pages are counted as needed to be allocated */
blocks = (num_pages - 2) << (PAGE_CACHE_SHIFT - inode->i_blkbits);
blocks =
(num_pages - 2) << (PAGE_CACHE_SHIFT - inode->i_blkbits);
/* count blocks needed for first page (possibly partially written) */
blocks += ((PAGE_CACHE_SIZE - from) >> inode->i_blkbits) +
!!(from & (inode->i_sb->s_blocksize-1)); /* roundup */
blocks += ((PAGE_CACHE_SIZE - from) >> inode->i_blkbits) + !!(from & (inode->i_sb->s_blocksize - 1)); /* roundup */
/* Now we account for last page. If last page == first page (we
overwrite only one page), we substract all the blocks past the
@ -945,7 +1041,9 @@ static int reiserfs_prepare_file_region_for_write(
kunmap_atomic(kaddr, KM_USER0);
}
if (to != PAGE_CACHE_SIZE) { /* Last page needs to be partially zeroed */
char *kaddr = kmap_atomic(prepared_pages[num_pages-1], KM_USER0);
char *kaddr =
kmap_atomic(prepared_pages[num_pages - 1],
KM_USER0);
memset(kaddr + to, 0, PAGE_CACHE_SIZE - to);
kunmap_atomic(kaddr, KM_USER0);
}
@ -962,7 +1060,9 @@ static int reiserfs_prepare_file_region_for_write(
loop for performance reasons */
pos &= ~((loff_t) inode->i_sb->s_blocksize - 1);
/* Set cpu key to the starting position in a file (on left block boundary) */
make_cpu_key (&key, inode, 1 + ((pos) & ~((loff_t) inode->i_sb->s_blocksize - 1)), TYPE_ANY, 3/*key length*/);
make_cpu_key(&key, inode,
1 + ((pos) & ~((loff_t) inode->i_sb->s_blocksize - 1)),
TYPE_ANY, 3 /*key length */ );
reiserfs_write_lock(inode->i_sb); // We need that for at least search_by_key()
for (i = 0; i < num_pages; i++) {
@ -972,7 +1072,8 @@ static int reiserfs_prepare_file_region_for_write(
for (bh = head, block_start = 0; bh != head || !block_start;
block_start = block_end, bh = bh->b_this_page) {
if (!bh)
reiserfs_panic(inode->i_sb, "green-9002: Allocated but absent buffer for a page?");
reiserfs_panic(inode->i_sb,
"green-9002: Allocated but absent buffer for a page?");
/* Find where this buffer ends */
block_end = block_start + inode->i_sb->s_blocksize;
if (i == 0 && block_end <= from)
@ -996,18 +1097,21 @@ static int reiserfs_prepare_file_region_for_write(
*/
item_pos++;
/* Update the key */
set_cpu_key_k_offset( &key, cpu_key_k_offset(&key) + inode->i_sb->s_blocksize);
set_cpu_key_k_offset(&key,
cpu_key_k_offset(&key) +
inode->i_sb->s_blocksize);
blocks--; // Decrease the amount of blocks that need to be
// allocated
continue; // Go to the next buffer
}
if (!itembuf || /* if first iteration */
item_pos >= ih_item_len(ih)/UNFM_P_SIZE)
{ /* or if we progressed past the
item_pos >= ih_item_len(ih) / UNFM_P_SIZE) { /* or if we progressed past the
current unformatted_item */
/* Try to find next item */
res = search_for_position_by_key(inode->i_sb, &key, &path);
res =
search_for_position_by_key(inode->i_sb,
&key, &path);
/* Abort if no more items */
if (res != POSITION_FOUND) {
/* make sure later loops don't use this item */
@ -1022,19 +1126,23 @@ static int reiserfs_prepare_file_region_for_write(
item = get_item(&path);
item_pos = path.pos_in_item;
RFALSE( !is_indirect_le_ih (ih), "green-9003: indirect item expected");
RFALSE(!is_indirect_le_ih(ih),
"green-9003: indirect item expected");
}
/* See if there is some block associated with the file
at that position, map the buffer to this block */
if (get_block_num(item, item_pos)) {
map_bh(bh, inode->i_sb, get_block_num(item,item_pos));
map_bh(bh, inode->i_sb,
get_block_num(item, item_pos));
blocks--; // Decrease the amount of blocks that need to be
// allocated
}
item_pos++;
/* Update the key */
set_cpu_key_k_offset( &key, cpu_key_k_offset(&key) + inode->i_sb->s_blocksize);
set_cpu_key_k_offset(&key,
cpu_key_k_offset(&key) +
inode->i_sb->s_blocksize);
}
}
pathrelse(&path); // Free the path
@ -1051,7 +1159,8 @@ static int reiserfs_prepare_file_region_for_write(
block_start = block_end, bh = bh->b_this_page) {
if (!bh)
reiserfs_panic(inode->i_sb, "green-9002: Allocated but absent buffer for a page?");
reiserfs_panic(inode->i_sb,
"green-9002: Allocated but absent buffer for a page?");
/* Find where this buffer ends */
block_end = block_start + inode->i_sb->s_blocksize;
if (block_end <= from)
@ -1064,8 +1173,11 @@ static int reiserfs_prepare_file_region_for_write(
ll_rw_block(READ, 1, &bh);
*wait_bh++ = bh;
} else { /* Not mapped, zero it */
char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0);
memset(kaddr+block_start, 0, from-block_start);
char *kaddr =
kmap_atomic(prepared_pages[0],
KM_USER0);
memset(kaddr + block_start, 0,
from - block_start);
kunmap_atomic(kaddr, KM_USER0);
set_buffer_uptodate(bh);
}
@ -1075,7 +1187,8 @@ static int reiserfs_prepare_file_region_for_write(
/* Last page, see if it is not uptodate, or if the last page is past the end of the file. */
if (!PageUptodate(prepared_pages[num_pages - 1]) ||
((pos+write_bytes)>>PAGE_CACHE_SHIFT) > (inode->i_size>>PAGE_CACHE_SHIFT) ) {
((pos + write_bytes) >> PAGE_CACHE_SHIFT) >
(inode->i_size >> PAGE_CACHE_SHIFT)) {
head = page_buffers(prepared_pages[num_pages - 1]);
/* for each buffer in page */
@ -1083,7 +1196,8 @@ static int reiserfs_prepare_file_region_for_write(
block_start = block_end, bh = bh->b_this_page) {
if (!bh)
reiserfs_panic(inode->i_sb, "green-9002: Allocated but absent buffer for a page?");
reiserfs_panic(inode->i_sb,
"green-9002: Allocated but absent buffer for a page?");
/* Find where this buffer ends */
block_end = block_start + inode->i_sb->s_blocksize;
if (block_start >= to)
@ -1096,7 +1210,10 @@ static int reiserfs_prepare_file_region_for_write(
ll_rw_block(READ, 1, &bh);
*wait_bh++ = bh;
} else { /* Not mapped, zero it */
char *kaddr = kmap_atomic(prepared_pages[num_pages-1], KM_USER0);
char *kaddr =
kmap_atomic(prepared_pages
[num_pages - 1],
KM_USER0);
memset(kaddr + to, 0, block_end - to);
kunmap_atomic(kaddr, KM_USER0);
set_buffer_uptodate(bh);
@ -1153,7 +1270,8 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
(in userspace) */
size_t count, /* amount of bytes to write */
loff_t * ppos /* pointer to position in file that we start writing at. Should be updated to
* new current position before returning. */ )
* new current position before returning. */
)
{
size_t already_written = 0; // Number of bytes already written to the file.
loff_t pos; // Current position in the file.
@ -1168,12 +1286,15 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
if (file->f_flags & O_DIRECT) { // Direct IO needs treatment
ssize_t result, after_file_end = 0;
if ( (*ppos + count >= inode->i_size) || (file->f_flags & O_APPEND) ) {
if ((*ppos + count >= inode->i_size)
|| (file->f_flags & O_APPEND)) {
/* If we are appending a file, we need to put this savelink in here.
If we will crash while doing direct io, finish_unfinished will
cut the garbage from the file end. */
reiserfs_write_lock(inode->i_sb);
err = journal_begin(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT );
err =
journal_begin(&th, inode->i_sb,
JOURNAL_PER_BALANCE_CNT);
if (err) {
reiserfs_write_unlock(inode->i_sb);
return err;
@ -1181,7 +1302,9 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
reiserfs_update_inode_transaction(inode);
add_save_link(&th, inode, 1 /* Truncate */ );
after_file_end = 1;
err = journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT );
err =
journal_end(&th, inode->i_sb,
JOURNAL_PER_BALANCE_CNT);
reiserfs_write_unlock(inode->i_sb);
if (err)
return err;
@ -1259,7 +1382,8 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
/* (pos & (PAGE_CACHE_SIZE-1)) is an idiom for offset into a page of pos */
num_pages = !!((pos + count) & (PAGE_CACHE_SIZE - 1)) + /* round up partial
pages */
((count + (pos & (PAGE_CACHE_SIZE-1))) >> PAGE_CACHE_SHIFT);
((count +
(pos & (PAGE_CACHE_SIZE - 1))) >> PAGE_CACHE_SHIFT);
/* convert size to amount of
pages */
reiserfs_write_lock(inode->i_sb);
@ -1268,7 +1392,9 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
/* If we were asked to write more data than we want to or if there
is not that much space, then we shorten amount of data to write
for this iteration. */
num_pages = min_t(size_t, REISERFS_WRITE_PAGES_AT_A_TIME, reiserfs_can_fit_pages(inode->i_sb));
num_pages =
min_t(size_t, REISERFS_WRITE_PAGES_AT_A_TIME,
reiserfs_can_fit_pages(inode->i_sb));
/* Also we should not forget to set size in bytes accordingly */
write_bytes = (num_pages << PAGE_CACHE_SHIFT) -
(pos & (PAGE_CACHE_SIZE - 1));
@ -1281,11 +1407,16 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
/* reserve the blocks to be allocated later, so that later on
we still have the space to write the blocks to */
reiserfs_claim_blocks_to_be_allocated(inode->i_sb, num_pages << (PAGE_CACHE_SHIFT - inode->i_blkbits));
reiserfs_claim_blocks_to_be_allocated(inode->i_sb,
num_pages <<
(PAGE_CACHE_SHIFT -
inode->i_blkbits));
reiserfs_write_unlock(inode->i_sb);
if (!num_pages) { /* If we do not have enough space even for a single page... */
if ( pos > inode->i_size+inode->i_sb->s_blocksize-(pos & (inode->i_sb->s_blocksize-1))) {
if (pos >
inode->i_size + inode->i_sb->s_blocksize -
(pos & (inode->i_sb->s_blocksize - 1))) {
res = -ENOSPC;
break; // In case we are writing past the end of the last file block, break.
}
@ -1295,34 +1426,60 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
// But overwriting files on absolutelly full volumes would not
// be very efficient. Well, people are not supposed to fill
// 100% of disk space anyway.
write_bytes = min_t(size_t, count, inode->i_sb->s_blocksize - (pos & (inode->i_sb->s_blocksize - 1)));
write_bytes =
min_t(size_t, count,
inode->i_sb->s_blocksize -
(pos & (inode->i_sb->s_blocksize - 1)));
num_pages = 1;
// No blocks were claimed before, so do it now.
reiserfs_claim_blocks_to_be_allocated(inode->i_sb, 1 << (PAGE_CACHE_SHIFT - inode->i_blkbits));
reiserfs_claim_blocks_to_be_allocated(inode->i_sb,
1 <<
(PAGE_CACHE_SHIFT
-
inode->
i_blkbits));
}
/* Prepare for writing into the region, read in all the
partially overwritten pages, if needed. And lock the pages,
so that nobody else can access these until we are done.
We get number of actual blocks needed as a result. */
blocks_to_allocate = reiserfs_prepare_file_region_for_write(inode, pos, num_pages, write_bytes, prepared_pages);
blocks_to_allocate =
reiserfs_prepare_file_region_for_write(inode, pos,
num_pages,
write_bytes,
prepared_pages);
if (blocks_to_allocate < 0) {
res = blocks_to_allocate;
reiserfs_release_claimed_blocks(inode->i_sb, num_pages << (PAGE_CACHE_SHIFT - inode->i_blkbits));
reiserfs_release_claimed_blocks(inode->i_sb,
num_pages <<
(PAGE_CACHE_SHIFT -
inode->i_blkbits));
break;
}
/* First we correct our estimate of how many blocks we need */
reiserfs_release_claimed_blocks(inode->i_sb, (num_pages << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits)) - blocks_to_allocate );
reiserfs_release_claimed_blocks(inode->i_sb,
(num_pages <<
(PAGE_CACHE_SHIFT -
inode->i_sb->
s_blocksize_bits)) -
blocks_to_allocate);
if (blocks_to_allocate > 0) { /*We only allocate blocks if we need to */
/* Fill in all the possible holes and append the file if needed */
res = reiserfs_allocate_blocks_for_region(&th, inode, pos, num_pages, write_bytes, prepared_pages, blocks_to_allocate);
res =
reiserfs_allocate_blocks_for_region(&th, inode, pos,
num_pages,
write_bytes,
prepared_pages,
blocks_to_allocate);
}
/* well, we have allocated the blocks, so it is time to free
the reservation we made earlier. */
reiserfs_release_claimed_blocks(inode->i_sb, blocks_to_allocate);
reiserfs_release_claimed_blocks(inode->i_sb,
blocks_to_allocate);
if (res) {
reiserfs_unprepare_pages(prepared_pages, num_pages);
break;
@ -1333,15 +1490,21 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
crash */
/* Copy data from user-supplied buffer to file's pages */
res = reiserfs_copy_from_user_to_file_region(pos, num_pages, write_bytes, prepared_pages, buf);
res =
reiserfs_copy_from_user_to_file_region(pos, num_pages,
write_bytes,
prepared_pages, buf);
if (res) {
reiserfs_unprepare_pages(prepared_pages, num_pages);
break;
}
/* Send the pages to disk and unlock them. */
res = reiserfs_submit_file_region_for_write(&th, inode, pos, num_pages,
write_bytes,prepared_pages);
res =
reiserfs_submit_file_region_for_write(&th, inode, pos,
num_pages,
write_bytes,
prepared_pages);
if (res)
break;
@ -1364,7 +1527,9 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
}
if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
res = generic_osync_inode(inode, file->f_mapping, OSYNC_METADATA|OSYNC_DATA);
res =
generic_osync_inode(inode, file->f_mapping,
OSYNC_METADATA | OSYNC_DATA);
up(&inode->i_sem);
reiserfs_async_progress_wait(inode->i_sb);
@ -1381,8 +1546,6 @@ static ssize_t reiserfs_aio_write(struct kiocb *iocb, const char __user *buf,
return generic_file_aio_write(iocb, buf, count, pos);
}
struct file_operations reiserfs_file_operations = {
.read = generic_file_read,
.write = reiserfs_file_write,
@ -1395,7 +1558,6 @@ struct file_operations reiserfs_file_operations = {
.aio_write = reiserfs_aio_write,
};
struct inode_operations reiserfs_file_inode_operations = {
.truncate = reiserfs_vfs_truncate_file,
.setattr = reiserfs_setattr,
@ -1405,5 +1567,3 @@ struct inode_operations reiserfs_file_inode_operations = {
.removexattr = reiserfs_removexattr,
.permission = reiserfs_permission,
};

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,6 @@
#include <asm/types.h>
#include <asm/bug.h>
#define DELTA 0x9E3779B9
#define FULLROUNDS 10 /* 32 is overkill, 16 is strong crypto */
#define PARTROUNDS 6 /* 6 gets complete mixing */
@ -48,7 +47,6 @@
h1 += b1; \
} while(0)
u32 keyed_hash(const signed char *msg, int len)
{
u32 k[] = { 0x9464a485, 0x542e1a94, 0x3e846bff, 0xb75bcfc3 };
@ -63,24 +61,17 @@ u32 keyed_hash(const signed char *msg, int len)
pad = (u32) len | ((u32) len << 8);
pad |= pad << 16;
while(len >= 16)
{
while (len >= 16) {
a = (u32) msg[0] |
(u32)msg[ 1] << 8 |
(u32)msg[ 2] << 16|
(u32)msg[ 3] << 24;
(u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
b = (u32) msg[4] |
(u32)msg[ 5] << 8 |
(u32)msg[ 6] << 16|
(u32)msg[ 7] << 24;
(u32) msg[5] << 8 | (u32) msg[6] << 16 | (u32) msg[7] << 24;
c = (u32) msg[8] |
(u32) msg[9] << 8 |
(u32)msg[10] << 16|
(u32)msg[11] << 24;
(u32) msg[10] << 16 | (u32) msg[11] << 24;
d = (u32) msg[12] |
(u32) msg[13] << 8 |
(u32)msg[14] << 16|
(u32)msg[15] << 24;
(u32) msg[14] << 16 | (u32) msg[15] << 24;
TEACORE(PARTROUNDS);
@ -88,65 +79,43 @@ u32 keyed_hash(const signed char *msg, int len)
msg += 16;
}
if (len >= 12)
{
if (len >= 12) {
a = (u32) msg[0] |
(u32)msg[ 1] << 8 |
(u32)msg[ 2] << 16|
(u32)msg[ 3] << 24;
(u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
b = (u32) msg[4] |
(u32)msg[ 5] << 8 |
(u32)msg[ 6] << 16|
(u32)msg[ 7] << 24;
(u32) msg[5] << 8 | (u32) msg[6] << 16 | (u32) msg[7] << 24;
c = (u32) msg[8] |
(u32) msg[9] << 8 |
(u32)msg[10] << 16|
(u32)msg[11] << 24;
(u32) msg[10] << 16 | (u32) msg[11] << 24;
d = pad;
for(i = 12; i < len; i++)
{
for (i = 12; i < len; i++) {
d <<= 8;
d |= msg[i];
}
}
else if (len >= 8)
{
} else if (len >= 8) {
a = (u32) msg[0] |
(u32)msg[ 1] << 8 |
(u32)msg[ 2] << 16|
(u32)msg[ 3] << 24;
(u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
b = (u32) msg[4] |
(u32)msg[ 5] << 8 |
(u32)msg[ 6] << 16|
(u32)msg[ 7] << 24;
(u32) msg[5] << 8 | (u32) msg[6] << 16 | (u32) msg[7] << 24;
c = d = pad;
for(i = 8; i < len; i++)
{
for (i = 8; i < len; i++) {
c <<= 8;
c |= msg[i];
}
}
else if (len >= 4)
{
} else if (len >= 4) {
a = (u32) msg[0] |
(u32)msg[ 1] << 8 |
(u32)msg[ 2] << 16|
(u32)msg[ 3] << 24;
(u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
b = c = d = pad;
for(i = 4; i < len; i++)
{
for (i = 4; i < len; i++) {
b <<= 8;
b |= msg[i];
}
}
else
{
} else {
a = b = c = d = pad;
for(i = 0; i < len; i++)
{
for (i = 0; i < len; i++) {
a <<= 8;
a |= msg[i];
}
@ -167,7 +136,8 @@ u32 yura_hash (const signed char *msg, int len)
u32 a, c;
int i;
for (pow=1,i=1; i < len; i++) pow = pow * 10;
for (pow = 1, i = 1; i < len; i++)
pow = pow * 10;
if (len == 1)
a = msg[0] - 48;
@ -176,19 +146,22 @@ u32 yura_hash (const signed char *msg, int len)
for (i = 1; i < len; i++) {
c = msg[i] - 48;
for (pow=1,j=i; j < len-1; j++) pow = pow * 10;
for (pow = 1, j = i; j < len - 1; j++)
pow = pow * 10;
a = a + c * pow;
}
for (; i < 40; i++) {
c = '0' - 48;
for (pow=1,j=i; j < len-1; j++) pow = pow * 10;
for (pow = 1, j = i; j < len - 1; j++)
pow = pow * 10;
a = a + c * pow;
}
for (; i < 256; i++) {
c = i;
for (pow=1,j=i; j < len-1; j++) pow = pow * 10;
for (pow = 1, j = i; j < len - 1; j++)
pow = pow * 10;
a = a + c * pow;
}

View file

@ -10,13 +10,8 @@
#include <linux/buffer_head.h>
/* this is one and only function that is used outside (do_balance.c) */
int balance_internal (
struct tree_balance * ,
int,
int,
struct item_head * ,
struct buffer_head **
);
int balance_internal(struct tree_balance *,
int, int, struct item_head *, struct buffer_head **);
/* modes of internal_shift_left, internal_shift_right and internal_insert_childs */
#define INTERNAL_SHIFT_FROM_S_TO_L 0
@ -27,15 +22,12 @@ int balance_internal (
#define INTERNAL_INSERT_TO_L 5
#define INTERNAL_INSERT_TO_R 6
static void internal_define_dest_src_infos (
int shift_mode,
static void internal_define_dest_src_infos(int shift_mode,
struct tree_balance *tb,
int h,
struct buffer_info *dest_bi,
struct buffer_info *src_bi,
int * d_key,
struct buffer_head ** cf
)
int *d_key, struct buffer_head **cf)
{
memset(dest_bi, 0, sizeof(struct buffer_info));
memset(src_bi, 0, sizeof(struct buffer_info));
@ -114,12 +106,12 @@ static void internal_define_dest_src_infos (
break;
default:
reiserfs_panic (tb->tb_sb, "internal_define_dest_src_infos: shift type is unknown (%d)", shift_mode);
reiserfs_panic(tb->tb_sb,
"internal_define_dest_src_infos: shift type is unknown (%d)",
shift_mode);
}
}
/* Insert count node pointers into buffer cur before position to + 1.
* Insert count items into buffer cur before position to.
* Items and node pointers are specified by inserted and bh respectively.
@ -127,8 +119,7 @@ static void internal_define_dest_src_infos (
static void internal_insert_childs(struct buffer_info *cur_bi,
int to, int count,
struct item_head *inserted,
struct buffer_head ** bh
)
struct buffer_head **bh)
{
struct buffer_head *cur = cur_bi->bi_bh;
struct block_head *blkh;
@ -144,8 +135,7 @@ static void internal_insert_childs (struct buffer_info * cur_bi,
blkh = B_BLK_HEAD(cur);
nr = blkh_nr_item(blkh);
RFALSE( count > 2,
"too many children (%d) are to be inserted", count);
RFALSE(count > 2, "too many children (%d) are to be inserted", count);
RFALSE(B_FREE_SPACE(cur) < count * (KEY_SIZE + DC_SIZE),
"no enough free space (%d), needed %d bytes",
B_FREE_SPACE(cur), count * (KEY_SIZE + DC_SIZE));
@ -157,16 +147,17 @@ static void internal_insert_childs (struct buffer_info * cur_bi,
/* copy to_be_insert disk children */
for (i = 0; i < count; i++) {
put_dc_size( &(new_dc[i]), MAX_CHILD_SIZE(bh[i]) - B_FREE_SPACE(bh[i]));
put_dc_size(&(new_dc[i]),
MAX_CHILD_SIZE(bh[i]) - B_FREE_SPACE(bh[i]));
put_dc_block_number(&(new_dc[i]), bh[i]->b_blocknr);
}
memcpy(dc, new_dc, DC_SIZE * count);
/* prepare space for count items */
ih = B_N_PDELIM_KEY(cur, ((to == -1) ? 0 : to));
memmove (ih + count, ih, (nr - to) * KEY_SIZE + (nr + 1 + count) * DC_SIZE);
memmove(ih + count, ih,
(nr - to) * KEY_SIZE + (nr + 1 + count) * DC_SIZE);
/* copy item headers (keys) */
memcpy(ih, inserted, KEY_SIZE);
@ -176,7 +167,8 @@ static void internal_insert_childs (struct buffer_info * cur_bi,
/* sizes, item number */
set_blkh_nr_item(blkh, blkh_nr_item(blkh) + count);
set_blkh_free_space(blkh,
blkh_free_space(blkh) - count * (DC_SIZE + KEY_SIZE ) );
blkh_free_space(blkh) - count * (DC_SIZE +
KEY_SIZE));
do_balance_mark_internal_dirty(cur_bi->tb, cur, 0);
@ -185,9 +177,12 @@ static void internal_insert_childs (struct buffer_info * cur_bi,
/*&&&&&&&&&&&&&&&&&&&&&&&& */
if (cur_bi->bi_parent) {
struct disk_child *t_dc = B_N_CHILD (cur_bi->bi_parent,cur_bi->bi_position);
put_dc_size( t_dc, dc_size(t_dc) + (count * (DC_SIZE + KEY_SIZE)));
do_balance_mark_internal_dirty(cur_bi->tb, cur_bi->bi_parent, 0);
struct disk_child *t_dc =
B_N_CHILD(cur_bi->bi_parent, cur_bi->bi_position);
put_dc_size(t_dc,
dc_size(t_dc) + (count * (DC_SIZE + KEY_SIZE)));
do_balance_mark_internal_dirty(cur_bi->tb, cur_bi->bi_parent,
0);
/*&&&&&&&&&&&&&&&&&&&&&&&& */
check_internal(cur_bi->bi_parent);
@ -196,15 +191,11 @@ static void internal_insert_childs (struct buffer_info * cur_bi,
}
/* Delete del_num items and node pointers from buffer cur starting from *
* the first_i'th item and first_p'th pointers respectively. */
static void internal_delete_pointers_items (
struct buffer_info * cur_bi,
static void internal_delete_pointers_items(struct buffer_info *cur_bi,
int first_p,
int first_i,
int del_num
)
int first_i, int del_num)
{
struct buffer_head *cur = cur_bi->bi_bh;
int nr;
@ -215,11 +206,12 @@ static void internal_delete_pointers_items (
RFALSE(cur == NULL, "buffer is 0");
RFALSE(del_num < 0,
"negative number of items (%d) can not be deleted", del_num);
RFALSE( first_p < 0 || first_p + del_num > B_NR_ITEMS (cur) + 1 || first_i < 0,
RFALSE(first_p < 0 || first_p + del_num > B_NR_ITEMS(cur) + 1
|| first_i < 0,
"first pointer order (%d) < 0 or "
"no so many pointers (%d), only (%d) or "
"first key order %d < 0", first_p,
first_p + del_num, B_NR_ITEMS (cur) + 1, first_i);
"first key order %d < 0", first_p, first_p + del_num,
B_NR_ITEMS(cur) + 1, first_i);
if (del_num == 0)
return;
@ -227,7 +219,8 @@ static void internal_delete_pointers_items (
nr = blkh_nr_item(blkh);
if (first_p == 0 && del_num == nr + 1) {
RFALSE( first_i != 0, "1st deleted key must have order 0, not %d", first_i);
RFALSE(first_i != 0,
"1st deleted key must have order 0, not %d", first_i);
make_empty_node(cur_bi);
return;
}
@ -237,19 +230,20 @@ static void internal_delete_pointers_items (
"no so many keys (%d) in the node (%b)(%z)",
first_i, del_num, first_i + del_num, cur, cur);
/* deleting */
dc = B_N_CHILD(cur, first_p);
memmove(dc, dc + del_num, (nr + 1 - first_p - del_num) * DC_SIZE);
key = B_N_PDELIM_KEY(cur, first_i);
memmove (key, key + del_num, (nr - first_i - del_num) * KEY_SIZE + (nr + 1 - del_num) * DC_SIZE);
memmove(key, key + del_num,
(nr - first_i - del_num) * KEY_SIZE + (nr + 1 -
del_num) * DC_SIZE);
/* sizes, item number */
set_blkh_nr_item(blkh, blkh_nr_item(blkh) - del_num);
set_blkh_free_space(blkh,
blkh_free_space(blkh) + (del_num * (KEY_SIZE + DC_SIZE) ) );
blkh_free_space(blkh) +
(del_num * (KEY_SIZE + DC_SIZE)));
do_balance_mark_internal_dirty(cur_bi->tb, cur, 0);
/*&&&&&&&&&&&&&&&&&&&&&&& */
@ -259,19 +253,19 @@ static void internal_delete_pointers_items (
if (cur_bi->bi_parent) {
struct disk_child *t_dc;
t_dc = B_N_CHILD(cur_bi->bi_parent, cur_bi->bi_position);
put_dc_size( t_dc, dc_size(t_dc) - (del_num * (KEY_SIZE + DC_SIZE) ) );
put_dc_size(t_dc,
dc_size(t_dc) - (del_num * (KEY_SIZE + DC_SIZE)));
do_balance_mark_internal_dirty (cur_bi->tb, cur_bi->bi_parent,0);
do_balance_mark_internal_dirty(cur_bi->tb, cur_bi->bi_parent,
0);
/*&&&&&&&&&&&&&&&&&&&&&&&& */
check_internal(cur_bi->bi_parent);
/*&&&&&&&&&&&&&&&&&&&&&&&& */
}
}
/* delete n node pointers and items starting from given position */
static void internal_delete_childs (struct buffer_info * cur_bi,
int from, int n)
static void internal_delete_childs(struct buffer_info *cur_bi, int from, int n)
{
int i_from;
@ -283,16 +277,13 @@ static void internal_delete_childs (struct buffer_info * cur_bi,
internal_delete_pointers_items(cur_bi, from, i_from, n);
}
/* copy cpy_num node pointers and cpy_num - 1 items from buffer src to buffer dest
* last_first == FIRST_TO_LAST means, that we copy first items from src to tail of dest
* last_first == LAST_TO_FIRST means, that we copy last items from src to head of dest
*/
static void internal_copy_pointers_items (
struct buffer_info * dest_bi,
static void internal_copy_pointers_items(struct buffer_info *dest_bi,
struct buffer_head *src,
int last_first, int cpy_num
)
int last_first, int cpy_num)
{
/* ATTENTION! Number of node pointers in DEST is equal to number of items in DEST *
* as delimiting key have already inserted to buffer dest.*/
@ -325,8 +316,11 @@ static void internal_copy_pointers_items (
/*dest_order = (last_first == LAST_TO_FIRST) ? 0 : nr_dest; */
/*src_order = (last_first == LAST_TO_FIRST) ? (nr_src - cpy_num + 1) : 0; */
(last_first == LAST_TO_FIRST) ? (dest_order = 0, src_order = nr_src - cpy_num + 1) :
(dest_order = nr_dest, src_order = 0);
(last_first == LAST_TO_FIRST) ? (dest_order = 0, src_order =
nr_src - cpy_num + 1) : (dest_order =
nr_dest,
src_order =
0);
/* prepare space for cpy_num pointers */
dc = B_N_CHILD(dest, dest_order);
@ -336,12 +330,11 @@ static void internal_copy_pointers_items (
/* insert pointers */
memcpy(dc, B_N_CHILD(src, src_order), DC_SIZE * cpy_num);
/* prepare space for cpy_num - 1 item headers */
key = B_N_PDELIM_KEY(dest, dest_order);
memmove(key + cpy_num - 1, key,
KEY_SIZE * (nr_dest - dest_order) + DC_SIZE * (nr_dest + cpy_num));
KEY_SIZE * (nr_dest - dest_order) + DC_SIZE * (nr_dest +
cpy_num));
/* insert headers */
memcpy(key, B_N_PDELIM_KEY(src, src_order), KEY_SIZE * (cpy_num - 1));
@ -349,7 +342,8 @@ static void internal_copy_pointers_items (
/* sizes, item number */
set_blkh_nr_item(blkh, blkh_nr_item(blkh) + (cpy_num - 1));
set_blkh_free_space(blkh,
blkh_free_space(blkh) - (KEY_SIZE * (cpy_num - 1) + DC_SIZE * cpy_num ) );
blkh_free_space(blkh) - (KEY_SIZE * (cpy_num - 1) +
DC_SIZE * cpy_num));
do_balance_mark_internal_dirty(dest_bi->tb, dest, 0);
@ -360,9 +354,12 @@ static void internal_copy_pointers_items (
if (dest_bi->bi_parent) {
struct disk_child *t_dc;
t_dc = B_N_CHILD(dest_bi->bi_parent, dest_bi->bi_position);
put_dc_size( t_dc, dc_size(t_dc) + (KEY_SIZE * (cpy_num - 1) + DC_SIZE * cpy_num) );
put_dc_size(t_dc,
dc_size(t_dc) + (KEY_SIZE * (cpy_num - 1) +
DC_SIZE * cpy_num));
do_balance_mark_internal_dirty (dest_bi->tb, dest_bi->bi_parent,0);
do_balance_mark_internal_dirty(dest_bi->tb, dest_bi->bi_parent,
0);
/*&&&&&&&&&&&&&&&&&&&&&&&& */
check_internal(dest_bi->bi_parent);
/*&&&&&&&&&&&&&&&&&&&&&&&& */
@ -370,7 +367,6 @@ static void internal_copy_pointers_items (
}
/* Copy cpy_num node pointers and cpy_num - 1 items from buffer src to buffer dest.
* Delete cpy_num - del_par items and node pointers from buffer src.
* last_first == FIRST_TO_LAST means, that we copy/delete first items from src.
@ -378,33 +374,39 @@ static void internal_copy_pointers_items (
*/
static void internal_move_pointers_items(struct buffer_info *dest_bi,
struct buffer_info *src_bi,
int last_first, int cpy_num, int del_par)
int last_first, int cpy_num,
int del_par)
{
int first_pointer;
int first_item;
internal_copy_pointers_items (dest_bi, src_bi->bi_bh, last_first, cpy_num);
internal_copy_pointers_items(dest_bi, src_bi->bi_bh, last_first,
cpy_num);
if (last_first == FIRST_TO_LAST) { /* shift_left occurs */
first_pointer = 0;
first_item = 0;
/* delete cpy_num - del_par pointers and keys starting for pointers with first_pointer,
for key - with first_item */
internal_delete_pointers_items (src_bi, first_pointer, first_item, cpy_num - del_par);
internal_delete_pointers_items(src_bi, first_pointer,
first_item, cpy_num - del_par);
} else { /* shift_right occurs */
int i, j;
i = ( cpy_num - del_par == ( j = B_NR_ITEMS(src_bi->bi_bh)) + 1 ) ? 0 : j - cpy_num + del_par;
i = (cpy_num - del_par ==
(j =
B_NR_ITEMS(src_bi->bi_bh)) + 1) ? 0 : j - cpy_num +
del_par;
internal_delete_pointers_items (src_bi, j + 1 - cpy_num + del_par, i, cpy_num - del_par);
internal_delete_pointers_items(src_bi,
j + 1 - cpy_num + del_par, i,
cpy_num - del_par);
}
}
/* Insert n_src'th key of buffer src before n_dest'th key of buffer dest. */
static void internal_insert_key (struct buffer_info * dest_bi,
int dest_position_before, /* insert key before key with n_dest number */
struct buffer_head * src,
int src_position)
static void internal_insert_key(struct buffer_info *dest_bi, int dest_position_before, /* insert key before key with n_dest number */
struct buffer_head *src, int src_position)
{
struct buffer_head *dest = dest_bi->bi_bh;
int nr;
@ -429,7 +431,8 @@ static void internal_insert_key (struct buffer_info * dest_bi,
/* prepare space for inserting key */
key = B_N_PDELIM_KEY(dest, dest_position_before);
memmove (key + 1, key, (nr - dest_position_before) * KEY_SIZE + (nr + 1) * DC_SIZE);
memmove(key + 1, key,
(nr - dest_position_before) * KEY_SIZE + (nr + 1) * DC_SIZE);
/* insert key */
memcpy(key, B_N_PDELIM_KEY(src, src_position), KEY_SIZE);
@ -446,45 +449,47 @@ static void internal_insert_key (struct buffer_info * dest_bi,
t_dc = B_N_CHILD(dest_bi->bi_parent, dest_bi->bi_position);
put_dc_size(t_dc, dc_size(t_dc) + KEY_SIZE);
do_balance_mark_internal_dirty (dest_bi->tb, dest_bi->bi_parent,0);
do_balance_mark_internal_dirty(dest_bi->tb, dest_bi->bi_parent,
0);
}
}
/* Insert d_key'th (delimiting) key from buffer cfl to tail of dest.
* Copy pointer_amount node pointers and pointer_amount - 1 items from buffer src to buffer dest.
* Replace d_key'th key in buffer cfl.
* Delete pointer_amount items and node pointers from buffer src.
*/
/* this can be invoked both to shift from S to L and from R to S */
static void internal_shift_left (
int mode, /* INTERNAL_FROM_S_TO_L | INTERNAL_FROM_R_TO_S */
static void internal_shift_left(int mode, /* INTERNAL_FROM_S_TO_L | INTERNAL_FROM_R_TO_S */
struct tree_balance *tb,
int h,
int pointer_amount
)
int h, int pointer_amount)
{
struct buffer_info dest_bi, src_bi;
struct buffer_head *cf;
int d_key_position;
internal_define_dest_src_infos (mode, tb, h, &dest_bi, &src_bi, &d_key_position, &cf);
internal_define_dest_src_infos(mode, tb, h, &dest_bi, &src_bi,
&d_key_position, &cf);
/*printk("pointer_amount = %d\n",pointer_amount); */
if (pointer_amount) {
/* insert delimiting key from common father of dest and src to node dest into position B_NR_ITEM(dest) */
internal_insert_key (&dest_bi, B_NR_ITEMS(dest_bi.bi_bh), cf, d_key_position);
internal_insert_key(&dest_bi, B_NR_ITEMS(dest_bi.bi_bh), cf,
d_key_position);
if (B_NR_ITEMS(src_bi.bi_bh) == pointer_amount - 1) {
if (src_bi.bi_position /*src->b_item_order */ == 0)
replace_key (tb, cf, d_key_position, src_bi.bi_parent/*src->b_parent*/, 0);
replace_key(tb, cf, d_key_position,
src_bi.
bi_parent /*src->b_parent */ , 0);
} else
replace_key (tb, cf, d_key_position, src_bi.bi_bh, pointer_amount - 1);
replace_key(tb, cf, d_key_position, src_bi.bi_bh,
pointer_amount - 1);
}
/* last parameter is del_parameter */
internal_move_pointers_items (&dest_bi, &src_bi, FIRST_TO_LAST, pointer_amount, 0);
internal_move_pointers_items(&dest_bi, &src_bi, FIRST_TO_LAST,
pointer_amount, 0);
}
@ -493,47 +498,43 @@ static void internal_shift_left (
* Delete n - 1 items and node pointers from buffer S[h].
*/
/* it always shifts from S[h] to L[h] */
static void internal_shift1_left (
struct tree_balance * tb,
int h,
int pointer_amount
)
static void internal_shift1_left(struct tree_balance *tb,
int h, int pointer_amount)
{
struct buffer_info dest_bi, src_bi;
struct buffer_head *cf;
int d_key_position;
internal_define_dest_src_infos (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, &dest_bi, &src_bi, &d_key_position, &cf);
internal_define_dest_src_infos(INTERNAL_SHIFT_FROM_S_TO_L, tb, h,
&dest_bi, &src_bi, &d_key_position, &cf);
if (pointer_amount > 0) /* insert lkey[h]-th key from CFL[h] to left neighbor L[h] */
internal_insert_key (&dest_bi, B_NR_ITEMS(dest_bi.bi_bh), cf, d_key_position);
internal_insert_key(&dest_bi, B_NR_ITEMS(dest_bi.bi_bh), cf,
d_key_position);
/* internal_insert_key (tb->L[h], B_NR_ITEM(tb->L[h]), tb->CFL[h], tb->lkey[h]); */
/* last parameter is del_parameter */
internal_move_pointers_items (&dest_bi, &src_bi, FIRST_TO_LAST, pointer_amount, 1);
internal_move_pointers_items(&dest_bi, &src_bi, FIRST_TO_LAST,
pointer_amount, 1);
/* internal_move_pointers_items (tb->L[h], tb->S[h], FIRST_TO_LAST, pointer_amount, 1); */
}
/* Insert d_key'th (delimiting) key from buffer cfr to head of dest.
* Copy n node pointers and n - 1 items from buffer src to buffer dest.
* Replace d_key'th key in buffer cfr.
* Delete n items and node pointers from buffer src.
*/
static void internal_shift_right (
int mode, /* INTERNAL_FROM_S_TO_R | INTERNAL_FROM_L_TO_S */
static void internal_shift_right(int mode, /* INTERNAL_FROM_S_TO_R | INTERNAL_FROM_L_TO_S */
struct tree_balance *tb,
int h,
int pointer_amount
)
int h, int pointer_amount)
{
struct buffer_info dest_bi, src_bi;
struct buffer_head *cf;
int d_key_position;
int nr;
internal_define_dest_src_infos (mode, tb, h, &dest_bi, &src_bi, &d_key_position, &cf);
internal_define_dest_src_infos(mode, tb, h, &dest_bi, &src_bi,
&d_key_position, &cf);
nr = B_NR_ITEMS(src_bi.bi_bh);
@ -547,13 +548,16 @@ static void internal_shift_right (
src_bi.bi_bh, PATH_H_PBUFFER(tb->tb_path, h));
/* when S[h] disappers replace left delemiting key as well */
if (tb->CFL[h])
replace_key (tb, cf, d_key_position, tb->CFL[h], tb->lkey[h]);
replace_key(tb, cf, d_key_position, tb->CFL[h],
tb->lkey[h]);
} else
replace_key (tb, cf, d_key_position, src_bi.bi_bh, nr - pointer_amount);
replace_key(tb, cf, d_key_position, src_bi.bi_bh,
nr - pointer_amount);
}
/* last parameter is del_parameter */
internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, pointer_amount, 0);
internal_move_pointers_items(&dest_bi, &src_bi, LAST_TO_FIRST,
pointer_amount, 0);
}
/* Insert delimiting key to R[h].
@ -561,28 +565,26 @@ static void internal_shift_right (
* Delete n - 1 items and node pointers from buffer S[h].
*/
/* it always shift from S[h] to R[h] */
static void internal_shift1_right (
struct tree_balance * tb,
int h,
int pointer_amount
)
static void internal_shift1_right(struct tree_balance *tb,
int h, int pointer_amount)
{
struct buffer_info dest_bi, src_bi;
struct buffer_head *cf;
int d_key_position;
internal_define_dest_src_infos (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, &dest_bi, &src_bi, &d_key_position, &cf);
internal_define_dest_src_infos(INTERNAL_SHIFT_FROM_S_TO_R, tb, h,
&dest_bi, &src_bi, &d_key_position, &cf);
if (pointer_amount > 0) /* insert rkey from CFR[h] to right neighbor R[h] */
internal_insert_key(&dest_bi, 0, cf, d_key_position);
/* internal_insert_key (tb->R[h], 0, tb->CFR[h], tb->rkey[h]); */
/* last parameter is del_parameter */
internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, pointer_amount, 1);
internal_move_pointers_items(&dest_bi, &src_bi, LAST_TO_FIRST,
pointer_amount, 1);
/* internal_move_pointers_items (tb->R[h], tb->S[h], LAST_TO_FIRST, pointer_amount, 1); */
}
/* Delete insert_num node pointers together with their left items
* and balance current node.*/
static void balance_internal_when_delete(struct tree_balance *tb,
@ -613,9 +615,12 @@ static void balance_internal_when_delete (struct tree_balance * tb,
/* node S[h] (root of the tree) is empty now */
struct buffer_head *new_root;
RFALSE( n || B_FREE_SPACE (tbSh) != MAX_CHILD_SIZE(tbSh) - DC_SIZE,
RFALSE(n
|| B_FREE_SPACE(tbSh) !=
MAX_CHILD_SIZE(tbSh) - DC_SIZE,
"buffer must have only 0 keys (%d)", n);
RFALSE( bi.bi_parent, "root has parent (%p)", bi.bi_parent);
RFALSE(bi.bi_parent, "root has parent (%p)",
bi.bi_parent);
/* choose a new root */
if (!tb->L[h - 1] || !B_NR_ITEMS(tb->L[h - 1]))
@ -625,9 +630,12 @@ static void balance_internal_when_delete (struct tree_balance * tb,
/* switch super block's tree root block number to the new value */
PUT_SB_ROOT_BLOCK(tb->tb_sb, new_root->b_blocknr);
//REISERFS_SB(tb->tb_sb)->s_rs->s_tree_height --;
PUT_SB_TREE_HEIGHT( tb->tb_sb, SB_TREE_HEIGHT(tb->tb_sb) - 1 );
PUT_SB_TREE_HEIGHT(tb->tb_sb,
SB_TREE_HEIGHT(tb->tb_sb) - 1);
do_balance_mark_sb_dirty (tb, REISERFS_SB(tb->tb_sb)->s_sbh, 1);
do_balance_mark_sb_dirty(tb,
REISERFS_SB(tb->tb_sb)->s_sbh,
1);
/*&&&&&&&&&&&&&&&&&&&&&& */
if (h > 1)
/* use check_internal if new root is an internal node */
@ -666,9 +674,11 @@ static void balance_internal_when_delete (struct tree_balance * tb,
if (tb->lnum[h] < 0) { /* borrow from left neighbor L[h] */
RFALSE(tb->rnum[h] != 0,
"wrong tb->rnum[%d]==%d when borrow from L[h]", h, tb->rnum[h]);
"wrong tb->rnum[%d]==%d when borrow from L[h]", h,
tb->rnum[h]);
/*internal_shift_right (tb, h, tb->L[h], tb->CFL[h], tb->lkey[h], tb->S[h], -tb->lnum[h]); */
internal_shift_right (INTERNAL_SHIFT_FROM_L_TO_S, tb, h, -tb->lnum[h]);
internal_shift_right(INTERNAL_SHIFT_FROM_L_TO_S, tb, h,
-tb->lnum[h]);
return;
}
@ -686,23 +696,20 @@ static void balance_internal_when_delete (struct tree_balance * tb,
h, tb->lnum[h], h, tb->rnum[h], n);
internal_shift_left(INTERNAL_SHIFT_FROM_S_TO_L, tb, h, tb->lnum[h]); /*tb->L[h], tb->CFL[h], tb->lkey[h], tb->S[h], tb->lnum[h]); */
internal_shift_right (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, tb->rnum[h]);
internal_shift_right(INTERNAL_SHIFT_FROM_S_TO_R, tb, h,
tb->rnum[h]);
reiserfs_invalidate_buffer(tb, tbSh);
return;
}
reiserfs_panic (tb->tb_sb, "balance_internal_when_delete: unexpected tb->lnum[%d]==%d or tb->rnum[%d]==%d",
reiserfs_panic(tb->tb_sb,
"balance_internal_when_delete: unexpected tb->lnum[%d]==%d or tb->rnum[%d]==%d",
h, tb->lnum[h], h, tb->rnum[h]);
}
/* Replace delimiting key of buffers L[h] and S[h] by the given key.*/
static void replace_lkey (
struct tree_balance * tb,
int h,
struct item_head * key
)
static void replace_lkey(struct tree_balance *tb, int h, struct item_head *key)
{
RFALSE(tb->L[h] == NULL || tb->CFL[h] == NULL,
"L[h](%p) and CFL[h](%p) must exist in replace_lkey",
@ -716,13 +723,8 @@ static void replace_lkey (
do_balance_mark_internal_dirty(tb, tb->CFL[h], 0);
}
/* Replace delimiting key of buffers S[h] and R[h] by the given key.*/
static void replace_rkey (
struct tree_balance * tb,
int h,
struct item_head * key
)
static void replace_rkey(struct tree_balance *tb, int h, struct item_head *key)
{
RFALSE(tb->R[h] == NULL || tb->CFR[h] == NULL,
"R[h](%p) and CFR[h](%p) must exist in replace_rkey",
@ -736,11 +738,9 @@ static void replace_rkey (
do_balance_mark_internal_dirty(tb, tb->CFR[h], 0);
}
int balance_internal(struct tree_balance *tb, /* tree_balance structure */
int h, /* level of the tree */
int child_pos,
struct item_head * insert_key, /* key for insertion on higher level */
int child_pos, struct item_head *insert_key, /* key for insertion on higher level */
struct buffer_head **insert_ptr /* node for insertion on higher level */
)
/* if inserting/pasting
@ -771,7 +771,9 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
PROC_INFO_INC(tb->tb_sb, balance_at[h]);
order = ( tbSh ) ? PATH_H_POSITION (tb->tb_path, h + 1)/*tb->S[h]->b_item_order*/ : 0;
order =
(tbSh) ? PATH_H_POSITION(tb->tb_path,
h + 1) /*tb->S[h]->b_item_order */ : 0;
/* Using insert_size[h] calculate the number insert_num of items
that must be inserted to or deleted from S[h]. */
@ -799,12 +801,14 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
n = B_NR_ITEMS(tb->L[h]); /* number of items in L[h] */
if (tb->lnum[h] <= child_pos) {
/* new items don't fall into L[h] or CFL[h] */
internal_shift_left (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, tb->lnum[h]);
internal_shift_left(INTERNAL_SHIFT_FROM_S_TO_L, tb, h,
tb->lnum[h]);
/*internal_shift_left (tb->L[h],tb->CFL[h],tb->lkey[h],tbSh,tb->lnum[h]); */
child_pos -= tb->lnum[h];
} else if (tb->lnum[h] > child_pos + insert_num) {
/* all new items fall into L[h] */
internal_shift_left (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, tb->lnum[h] - insert_num);
internal_shift_left(INTERNAL_SHIFT_FROM_S_TO_L, tb, h,
tb->lnum[h] - insert_num);
/* internal_shift_left(tb->L[h],tb->CFL[h],tb->lkey[h],tbSh,
tb->lnum[h]-insert_num);
*/
@ -813,8 +817,11 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
bi.bi_bh = tb->L[h];
bi.bi_parent = tb->FL[h];
bi.bi_position = get_left_neighbor_position(tb, h);
internal_insert_childs (&bi,/*tb->L[h], tb->S[h-1]->b_next*/ n + child_pos + 1,
insert_num,insert_key,insert_ptr);
internal_insert_childs(&bi,
/*tb->L[h], tb->S[h-1]->b_next */
n + child_pos + 1,
insert_num, insert_key,
insert_ptr);
insert_num = 0;
} else {
@ -828,14 +835,18 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
bi.bi_bh = tb->L[h];
bi.bi_parent = tb->FL[h];
bi.bi_position = get_left_neighbor_position(tb, h);
internal_insert_childs (&bi,/*tb->L[h], tb->S[h-1]->b_next,*/ n + child_pos + 1,k,
internal_insert_childs(&bi,
/*tb->L[h], tb->S[h-1]->b_next, */
n + child_pos + 1, k,
insert_key, insert_ptr);
replace_lkey(tb, h, insert_key + k);
/* replace the first node-ptr in S[h] by node-ptr to insert_ptr[k] */
dc = B_N_CHILD(tbSh, 0);
put_dc_size( dc, MAX_CHILD_SIZE(insert_ptr[k]) - B_FREE_SPACE (insert_ptr[k]));
put_dc_size(dc,
MAX_CHILD_SIZE(insert_ptr[k]) -
B_FREE_SPACE(insert_ptr[k]));
put_dc_block_number(dc, insert_ptr[k]->b_blocknr);
do_balance_mark_internal_dirty(tb, tbSh, 0);
@ -846,8 +857,8 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
insert_num -= k;
child_pos = 0;
}
} /* tb->lnum[h] > 0 */
}
/* tb->lnum[h] > 0 */
if (tb->rnum[h] > 0) {
/*shift rnum[h] items from S[h] to the right neighbor R[h] */
/* check how many of new items fall into R or CFR after shifting */
@ -855,26 +866,28 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
if (n - tb->rnum[h] >= child_pos)
/* new items fall into S[h] */
/*internal_shift_right(tb,h,tbSh,tb->CFR[h],tb->rkey[h],tb->R[h],tb->rnum[h]); */
internal_shift_right (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, tb->rnum[h]);
else
if ( n + insert_num - tb->rnum[h] < child_pos )
{
internal_shift_right(INTERNAL_SHIFT_FROM_S_TO_R, tb, h,
tb->rnum[h]);
else if (n + insert_num - tb->rnum[h] < child_pos) {
/* all new items fall into R[h] */
/*internal_shift_right(tb,h,tbSh,tb->CFR[h],tb->rkey[h],tb->R[h],
tb->rnum[h] - insert_num); */
internal_shift_right (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, tb->rnum[h] - insert_num);
internal_shift_right(INTERNAL_SHIFT_FROM_S_TO_R, tb, h,
tb->rnum[h] - insert_num);
/* insert insert_num keys and node-pointers into R[h] */
bi.tb = tb;
bi.bi_bh = tb->R[h];
bi.bi_parent = tb->FR[h];
bi.bi_position = get_right_neighbor_position(tb, h);
internal_insert_childs (&bi, /*tb->R[h],tb->S[h-1]->b_next*/ child_pos - n - insert_num + tb->rnum[h] - 1,
insert_num,insert_key,insert_ptr);
internal_insert_childs(&bi,
/*tb->R[h],tb->S[h-1]->b_next */
child_pos - n - insert_num +
tb->rnum[h] - 1,
insert_num, insert_key,
insert_ptr);
insert_num = 0;
}
else
{
} else {
struct disk_child *dc;
/* one of the items falls into CFR[h] */
@ -885,15 +898,23 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
bi.bi_bh = tb->R[h];
bi.bi_parent = tb->FR[h];
bi.bi_position = get_right_neighbor_position(tb, h);
internal_insert_childs (&bi, /*tb->R[h], tb->R[h]->b_child,*/ 0, k, insert_key + 1, insert_ptr + 1);
internal_insert_childs(&bi,
/*tb->R[h], tb->R[h]->b_child, */
0, k, insert_key + 1,
insert_ptr + 1);
replace_rkey(tb, h, insert_key + insert_num - k - 1);
/* replace the first node-ptr in R[h] by node-ptr insert_ptr[insert_num-k-1] */
dc = B_N_CHILD(tb->R[h], 0);
put_dc_size( dc, MAX_CHILD_SIZE(insert_ptr[insert_num-k-1]) -
B_FREE_SPACE (insert_ptr[insert_num-k-1]));
put_dc_block_number( dc, insert_ptr[insert_num-k-1]->b_blocknr );
put_dc_size(dc,
MAX_CHILD_SIZE(insert_ptr
[insert_num - k - 1]) -
B_FREE_SPACE(insert_ptr
[insert_num - k - 1]));
put_dc_block_number(dc,
insert_ptr[insert_num - k -
1]->b_blocknr);
do_balance_mark_internal_dirty(tb, tb->R[h], 0);
@ -905,8 +926,7 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
RFALSE(tb->blknum[h] > 2, "blknum can not be > 2 for internal level");
RFALSE(tb->blknum[h] < 0, "blknum can not be < 0");
if ( ! tb->blknum[h] )
{ /* node S[h] is empty now */
if (!tb->blknum[h]) { /* node S[h] is empty now */
RFALSE(!tbSh, "S[h] is equal NULL");
/* do what is needed for buffer thrown from tree */
@ -920,9 +940,9 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
struct buffer_head *tbSh_1 = PATH_H_PBUFFER(tb->tb_path, h - 1);
struct block_head *blkh;
if (tb->blknum[h] != 1)
reiserfs_panic(NULL, "balance_internal: One new node required for creating the new root");
reiserfs_panic(NULL,
"balance_internal: One new node required for creating the new root");
/* S[h] = empty buffer from the list FEB. */
tbSh = get_FEB(tb);
blkh = B_BLK_HEAD(tbSh);
@ -932,7 +952,8 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
dc = B_N_CHILD(tbSh, 0);
put_dc_block_number(dc, tbSh_1->b_blocknr);
put_dc_size( dc, (MAX_CHILD_SIZE (tbSh_1) - B_FREE_SPACE (tbSh_1)));
put_dc_size(dc,
(MAX_CHILD_SIZE(tbSh_1) - B_FREE_SPACE(tbSh_1)));
tb->insert_size[h] -= DC_SIZE;
set_blkh_free_space(blkh, blkh_free_space(blkh) - DC_SIZE);
@ -944,7 +965,8 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
/*&&&&&&&&&&&&&&&&&&&&&&&& */
/* put new root into path structure */
PATH_OFFSET_PBUFFER(tb->tb_path, ILLEGAL_PATH_ELEMENT_OFFSET) = tbSh;
PATH_OFFSET_PBUFFER(tb->tb_path, ILLEGAL_PATH_ELEMENT_OFFSET) =
tbSh;
/* Change root in structure super block. */
PUT_SB_ROOT_BLOCK(tb->tb_sb, tbSh->b_blocknr);
@ -956,7 +978,6 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
int snum;
struct buffer_info dest_bi, src_bi;
/* S_new = free buffer from list FEB */
S_new = get_FEB(tb);
@ -980,21 +1001,29 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
memcpy(&new_insert_key, B_N_PDELIM_KEY(tbSh, n - snum),
KEY_SIZE);
/* last parameter is del_par */
internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, snum, 0);
internal_move_pointers_items(&dest_bi, &src_bi,
LAST_TO_FIRST, snum, 0);
/* internal_move_pointers_items(S_new, tbSh, LAST_TO_FIRST, snum, 0); */
} else if (n + insert_num - snum < child_pos) {
/* all new items fall into S_new */
/* store the delimiting key for the next level */
/* new_insert_key = (n + insert_item - snum)'th key in S[h] */
memcpy(&new_insert_key,B_N_PDELIM_KEY(tbSh,n + insert_num - snum),
memcpy(&new_insert_key,
B_N_PDELIM_KEY(tbSh, n + insert_num - snum),
KEY_SIZE);
/* last parameter is del_par */
internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, snum - insert_num, 0);
internal_move_pointers_items(&dest_bi, &src_bi,
LAST_TO_FIRST,
snum - insert_num, 0);
/* internal_move_pointers_items(S_new,tbSh,1,snum - insert_num,0); */
/* insert insert_num keys and node-pointers into S_new */
internal_insert_childs (&dest_bi, /*S_new,tb->S[h-1]->b_next,*/child_pos - n - insert_num + snum - 1,
insert_num,insert_key,insert_ptr);
internal_insert_childs(&dest_bi,
/*S_new,tb->S[h-1]->b_next, */
child_pos - n - insert_num +
snum - 1,
insert_num, insert_key,
insert_ptr);
insert_num = 0;
} else {
@ -1002,12 +1031,15 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
/* some items fall into S_new, but some don't fall */
/* last parameter is del_par */
internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, n - child_pos + 1, 1);
internal_move_pointers_items(&dest_bi, &src_bi,
LAST_TO_FIRST,
n - child_pos + 1, 1);
/* internal_move_pointers_items(S_new,tbSh,1,n - child_pos + 1,1); */
/* calculate number of new items that fall into S_new */
k = snum - n + child_pos - 1;
internal_insert_childs (&dest_bi, /*S_new,*/ 0, k, insert_key + 1, insert_ptr+1);
internal_insert_childs(&dest_bi, /*S_new, */ 0, k,
insert_key + 1, insert_ptr + 1);
/* new_insert_key = insert_key[insert_num - k - 1] */
memcpy(&new_insert_key, insert_key + insert_num - k - 1,
@ -1015,9 +1047,14 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
/* replace first node-ptr in S_new by node-ptr to insert_ptr[insert_num-k-1] */
dc = B_N_CHILD(S_new, 0);
put_dc_size( dc, (MAX_CHILD_SIZE(insert_ptr[insert_num-k-1]) -
B_FREE_SPACE(insert_ptr[insert_num-k-1])) );
put_dc_block_number( dc, insert_ptr[insert_num-k-1]->b_blocknr );
put_dc_size(dc,
(MAX_CHILD_SIZE
(insert_ptr[insert_num - k - 1]) -
B_FREE_SPACE(insert_ptr
[insert_num - k - 1])));
put_dc_block_number(dc,
insert_ptr[insert_num - k -
1]->b_blocknr);
do_balance_mark_internal_dirty(tb, S_new, 0);
@ -1026,9 +1063,9 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
/* new_insert_ptr = node_pointer to S_new */
new_insert_ptr = S_new;
RFALSE (!buffer_journaled(S_new) || buffer_journal_dirty(S_new) ||
buffer_dirty (S_new),
"cm-00001: bad S_new (%b)", S_new);
RFALSE(!buffer_journaled(S_new) || buffer_journal_dirty(S_new)
|| buffer_dirty(S_new), "cm-00001: bad S_new (%b)",
S_new);
// S_new is released in unfix_nodes
}
@ -1040,19 +1077,14 @@ int balance_internal (struct tree_balance * tb, /* tree_balance structure */
bi.bi_bh = tbSh;
bi.bi_parent = PATH_H_PPARENT(tb->tb_path, h);
bi.bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
internal_insert_childs (
&bi,/*tbSh,*/
internal_insert_childs(&bi, /*tbSh, */
/* ( tb->S[h-1]->b_parent == tb->S[h] ) ? tb->S[h-1]->b_next : tb->S[h]->b_child->b_next, */
child_pos,insert_num,insert_key,insert_ptr
);
child_pos, insert_num, insert_key,
insert_ptr);
}
memcpy(new_insert_key_addr, &new_insert_key, KEY_SIZE);
insert_ptr[0] = new_insert_ptr;
return order;
}

File diff suppressed because it is too large Load diff

View file

@ -49,14 +49,17 @@ int reiserfs_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
if (IS_RDONLY(inode))
return -EROFS;
if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
if ((current->fsuid != inode->i_uid)
&& !capable(CAP_FOWNER))
return -EPERM;
if (get_user(flags, (int __user *)arg))
return -EFAULT;
if ( ( ( flags ^ REISERFS_I(inode) -> i_attrs) & ( REISERFS_IMMUTABLE_FL | REISERFS_APPEND_FL)) &&
!capable( CAP_LINUX_IMMUTABLE ) )
if (((flags ^ REISERFS_I(inode)->
i_attrs) & (REISERFS_IMMUTABLE_FL |
REISERFS_APPEND_FL))
&& !capable(CAP_LINUX_IMMUTABLE))
return -EPERM;
if ((flags & REISERFS_NOTAIL_FL) &&
@ -137,13 +140,15 @@ static int reiserfs_unpack (struct inode * inode, struct file * filp)
if (!page) {
goto out;
}
retval = mapping->a_ops->prepare_write(NULL, page, write_from, write_from) ;
retval =
mapping->a_ops->prepare_write(NULL, page, write_from, write_from);
if (retval)
goto out_unlock;
/* conversion can change page contents, must flush */
flush_dcache_page(page);
retval = mapping->a_ops->commit_write(NULL, page, write_from, write_from) ;
retval =
mapping->a_ops->commit_write(NULL, page, write_from, write_from);
REISERFS_I(inode)->i_flags |= i_nopack_mask;
out_unlock:

View file

@ -31,8 +31,6 @@ static int sd_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
return 0;
}
static char *print_time(time_t t)
{
static char timebuf[256];
@ -41,7 +39,6 @@ static char * print_time (time_t t)
return timebuf;
}
static void sd_print_item(struct item_head *ih, char *item)
{
printk("\tmode | size | nlinks | first direct | mtime\n");
@ -49,7 +46,8 @@ static void sd_print_item (struct item_head * ih, char * item)
struct stat_data_v1 *sd = (struct stat_data_v1 *)item;
printk("\t0%-6o | %6u | %2u | %d | %s\n", sd_v1_mode(sd),
sd_v1_size(sd), sd_v1_nlink(sd), sd_v1_first_direct_byte(sd),
sd_v1_size(sd), sd_v1_nlink(sd),
sd_v1_first_direct_byte(sd),
print_time(sd_v1_mtime(sd)));
} else {
struct stat_data *sd = (struct stat_data *)item;
@ -65,18 +63,15 @@ static void sd_check_item (struct item_head * ih, char * item)
// FIXME: type something here!
}
static int sd_create_vi(struct virtual_node *vn,
struct virtual_item *vi,
int is_affected,
int insert_size)
int is_affected, int insert_size)
{
vi->vi_index = TYPE_STAT_DATA;
//vi->vi_type |= VI_TYPE_STAT_DATA;// not needed?
return 0;
}
static int sd_check_left(struct virtual_item *vi, int free,
int start_skip, int end_skip)
{
@ -85,7 +80,6 @@ static int sd_check_left (struct virtual_item * vi, int free,
return -1;
}
static int sd_check_right(struct virtual_item *vi, int free)
{
return -1;
@ -103,7 +97,6 @@ static int sd_unit_num (struct virtual_item * vi)
return vi->vi_item_len - IH_SIZE;
}
static void sd_print_vi(struct virtual_item *vi)
{
reiserfs_warning(NULL, "STATDATA, index %d, type 0x%x, %h",
@ -125,8 +118,6 @@ static struct item_operations stat_data_ops = {
.print_vi = sd_print_vi
};
//////////////////////////////////////////////////////////////////////////////
// direct item functions
//
@ -135,7 +126,6 @@ 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
static void direct_decrement_key(struct cpu_key *key)
{
@ -144,14 +134,13 @@ static void direct_decrement_key (struct cpu_key * key)
set_cpu_key_k_type(key, TYPE_STAT_DATA);
}
static int direct_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
static int direct_is_left_mergeable(struct reiserfs_key *key,
unsigned long bsize)
{
int version = le_key_version(key);
return ((le_key_k_offset(version, key) & (bsize - 1)) != 1);
}
static void direct_print_item(struct item_head *ih, char *item)
{
int j = 0;
@ -163,17 +152,14 @@ static void direct_print_item (struct item_head * ih, char * item)
printk("\"\n");
}
static void direct_check_item(struct item_head *ih, char *item)
{
// FIXME: type something here!
}
static int direct_create_vi(struct virtual_node *vn,
struct virtual_item *vi,
int is_affected,
int insert_size)
int is_affected, int insert_size)
{
vi->vi_index = TYPE_DIRECT;
//vi->vi_type |= VI_TYPE_DIRECT;
@ -189,7 +175,6 @@ static int direct_check_left (struct virtual_item * vi, int free,
return bytes ? : -1;
}
static int direct_check_right(struct virtual_item *vi, int free)
{
return direct_check_left(vi, free, 0, 0);
@ -200,13 +185,11 @@ static int direct_part_size (struct virtual_item * vi, int first, int count)
return count;
}
static int direct_unit_num(struct virtual_item *vi)
{
return vi->vi_item_len - IH_SIZE;
}
static void direct_print_vi(struct virtual_item *vi)
{
reiserfs_warning(NULL, "DIRECT, index %d, type 0x%x, %h",
@ -228,8 +211,6 @@ static struct item_operations direct_ops = {
.print_vi = direct_print_vi
};
//////////////////////////////////////////////////////////////////////////////
// indirect item functions
//
@ -239,7 +220,6 @@ 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);
}
// decrease offset, if it becomes 0, change type to stat data
static void indirect_decrement_key(struct cpu_key *key)
{
@ -248,15 +228,14 @@ 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
static int indirect_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
static int indirect_is_left_mergeable(struct reiserfs_key *key,
unsigned long bsize)
{
int version = le_key_version(key);
return (le_key_k_offset(version, key) != 1);
}
// printing of indirect item
static void start_new_sequence(__u32 * start, int *len, __u32 new)
{
@ -264,7 +243,6 @@ static void start_new_sequence (__u32 * start, int * len, __u32 new)
*len = 1;
}
static int sequence_finished(__u32 start, int *len, __u32 new)
{
if (start == INT_MAX)
@ -292,7 +270,6 @@ static void print_sequence (__u32 start, int len)
printk(" %d(%d)", start, len);
}
static void indirect_print_item(struct item_head *ih, char *item)
{
int j;
@ -321,11 +298,9 @@ static void indirect_check_item (struct item_head * ih, char * item)
// FIXME: type something here!
}
static int indirect_create_vi(struct virtual_node *vn,
struct virtual_item *vi,
int is_affected,
int insert_size)
int is_affected, int insert_size)
{
vi->vi_index = TYPE_INDIRECT;
//vi->vi_type |= VI_TYPE_INDIRECT;
@ -341,14 +316,11 @@ static int indirect_check_left (struct virtual_item * vi, int free,
return bytes ? : -1;
}
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)
static int indirect_part_size(struct virtual_item *vi, int first, int units)
{
@ -383,12 +355,10 @@ static struct item_operations indirect_ops = {
.print_vi = indirect_print_vi
};
//////////////////////////////////////////////////////////////////////////////
// direntry functions
//
static int direntry_bytes_number(struct item_head *ih, int block_size)
{
reiserfs_warning(NULL, "vs-16090: direntry_bytes_number: "
@ -403,8 +373,8 @@ static void direntry_decrement_key (struct cpu_key * key)
set_cpu_key_k_type(key, TYPE_STAT_DATA);
}
static int direntry_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
static int direntry_is_left_mergeable(struct reiserfs_key *key,
unsigned long bsize)
{
if (le32_to_cpu(key->u.k_offset_v1.k_offset) == DOT_OFFSET)
return 0;
@ -412,7 +382,6 @@ static int direntry_is_left_mergeable (struct reiserfs_key * key, unsigned long
}
static void direntry_print_item(struct item_head *ih, char *item)
{
int i;
@ -421,13 +390,15 @@ static void direntry_print_item (struct item_head * ih, char * item)
char *name;
static char namebuf[80];
printk ("\n # %-15s%-30s%-15s%-15s%-15s\n", "Name", "Key of pointed object", "Hash", "Gen number", "Status");
printk("\n # %-15s%-30s%-15s%-15s%-15s\n", "Name",
"Key of pointed object", "Hash", "Gen number", "Status");
deh = (struct reiserfs_de_head *)item;
for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) {
namelen = (i ? (deh_location(deh - 1)) : ih_item_len(ih)) - deh_location(deh);
namelen =
(i ? (deh_location(deh - 1)) : ih_item_len(ih)) -
deh_location(deh);
name = item + deh_location(deh);
if (name[namelen - 1] == 0)
namelen = strlen(name);
@ -445,12 +416,12 @@ static void direntry_print_item (struct item_head * ih, char * item)
printk("%d: %-15s%-15d%-15d%-15Ld%-15Ld(%s)\n",
i, namebuf,
deh_dir_id(deh), deh_objectid(deh),
GET_HASH_VALUE (deh_offset (deh)), GET_GENERATION_NUMBER ((deh_offset (deh))),
GET_HASH_VALUE(deh_offset(deh)),
GET_GENERATION_NUMBER((deh_offset(deh))),
(de_hidden(deh)) ? "HIDDEN" : "VISIBLE");
}
}
static void direntry_check_item(struct item_head *ih, char *item)
{
int i;
@ -463,14 +434,13 @@ static void direntry_check_item (struct item_head * ih, char * item)
}
}
#define DIRENTRY_VI_FIRST_DIRENTRY_ITEM 1
/*
* function returns old entry number in directory item in real 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)
static inline int old_entry_num(int is_affected, int virtual_entry_num,
int pos_in_item, int mode)
{
if (mode == M_INSERT || mode == M_DELETE)
return virtual_entry_num;
@ -486,21 +456,18 @@ static inline int old_entry_num (int is_affected, int virtual_entry_num, int pos
return virtual_entry_num + 1;
RFALSE(mode != M_PASTE || virtual_entry_num == 0,
"vs-8015: old_entry_num: mode must be M_PASTE (mode = \'%c\'", mode);
"vs-8015: old_entry_num: mode must be M_PASTE (mode = \'%c\'",
mode);
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 */
static int direntry_create_vi(struct virtual_node *vn,
struct virtual_item *vi,
int is_affected,
int insert_size)
int is_affected, int insert_size)
{
struct direntry_uarea *dir_u = vi->vi_uarea;
int i, j;
@ -512,23 +479,22 @@ static int direntry_create_vi (struct virtual_node * vn,
if (!(vi->vi_ih) || !vi->vi_item)
BUG();
dir_u->flags = 0;
if (le_ih_k_offset(vi->vi_ih) == DOT_OFFSET)
dir_u->flags |= DIRENTRY_VI_FIRST_DIRENTRY_ITEM;
deh = (struct reiserfs_de_head *)(vi->vi_item);
/* virtual directory item have this amount of entry after */
dir_u->entry_count = ih_entry_count(vi->vi_ih) +
((is_affected) ? ((vn->vn_mode == M_CUT) ? -1 :
(vn->vn_mode == M_PASTE ? 1 : 0)) : 0);
for (i = 0; i < dir_u->entry_count; i++) {
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)) -
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;
}
@ -538,7 +504,6 @@ static int direntry_create_vi (struct virtual_node * vn,
if (is_affected && vn->vn_mode == M_PASTE)
dir_u->entry_sizes[vn->vn_pos_in_item] = insert_size;
#ifdef CONFIG_REISERFS_CHECK
/* compare total size of entries with item length */
{
@ -549,8 +514,11 @@ static int direntry_create_vi (struct virtual_node * vn,
l += dir_u->entry_sizes[k];
if (l + IH_SIZE != vi->vi_item_len +
((is_affected && (vn->vn_mode == M_PASTE || vn->vn_mode == M_CUT)) ? insert_size : 0) ) {
reiserfs_panic (NULL, "vs-8025: set_entry_sizes: (mode==%c, insert_size==%d), invalid length of directory item",
((is_affected
&& (vn->vn_mode == M_PASTE
|| vn->vn_mode == M_CUT)) ? insert_size : 0)) {
reiserfs_panic(NULL,
"vs-8025: set_entry_sizes: (mode==%c, insert_size==%d), invalid length of directory item",
vn->vn_mode, insert_size);
}
}
@ -558,10 +526,8 @@ static int direntry_create_vi (struct virtual_node * vn,
return size;
}
//
// 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
@ -583,17 +549,18 @@ static int direntry_check_left (struct virtual_item * vi, int free,
}
if (entries == dir_u->entry_count) {
reiserfs_panic (NULL, "free space %d, entry_count %d\n", free, dir_u->entry_count);
reiserfs_panic(NULL, "free space %d, entry_count %d\n", free,
dir_u->entry_count);
}
/* "." and ".." can not be separated from each other */
if (start_skip == 0 && (dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM) && entries < 2)
if (start_skip == 0 && (dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM)
&& entries < 2)
entries = 0;
return entries ? : -1;
}
static int direntry_check_right(struct virtual_item *vi, int free)
{
int i;
@ -612,13 +579,13 @@ static int direntry_check_right (struct virtual_item * vi, int free)
BUG();
/* "." and ".." can not be separated from each other */
if ((dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM) && entries > dir_u->entry_count - 2)
if ((dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM)
&& entries > dir_u->entry_count - 2)
entries = dir_u->entry_count - 2;
return entries ? : -1;
}
/* sum of entry sizes between from-th and to-th entries including both edges */
static int direntry_part_size(struct virtual_item *vi, int first, int count)
{
@ -646,8 +613,6 @@ static int direntry_unit_num (struct virtual_item * vi)
return dir_u->entry_count;
}
static void direntry_print_vi(struct virtual_item *vi)
{
int i;
@ -676,46 +641,48 @@ static struct item_operations direntry_ops = {
.print_vi = direntry_print_vi
};
//////////////////////////////////////////////////////////////////////////////
// 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: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16001: Invalid item type observed, run fsck ASAP");
return 0;
}
static void errcatch_decrement_key(struct cpu_key *key)
{
reiserfs_warning (NULL, "green-16002: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16002: Invalid item type observed, run fsck ASAP");
}
static int errcatch_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
static int errcatch_is_left_mergeable(struct reiserfs_key *key,
unsigned long bsize)
{
reiserfs_warning (NULL, "green-16003: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16003: Invalid item type observed, run fsck ASAP");
return 0;
}
static void errcatch_print_item(struct item_head *ih, char *item)
{
reiserfs_warning (NULL, "green-16004: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16004: Invalid item type observed, run fsck ASAP");
}
static void errcatch_check_item(struct item_head *ih, char *item)
{
reiserfs_warning (NULL, "green-16005: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16005: Invalid item type observed, run fsck ASAP");
}
static int errcatch_create_vi(struct virtual_node *vn,
struct virtual_item *vi,
int is_affected,
int insert_size)
int is_affected, int insert_size)
{
reiserfs_warning (NULL, "green-16006: Invalid item type observed, run fsck ASAP");
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.
}
@ -723,32 +690,36 @@ static int errcatch_create_vi (struct virtual_node * vn,
static int errcatch_check_left(struct virtual_item *vi, int free,
int start_skip, int end_skip)
{
reiserfs_warning (NULL, "green-16007: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16007: Invalid item type observed, run fsck ASAP");
return -1;
}
static int errcatch_check_right(struct virtual_item *vi, int free)
{
reiserfs_warning (NULL, "green-16008: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16008: Invalid item type observed, run fsck ASAP");
return -1;
}
static int errcatch_part_size(struct virtual_item *vi, int first, int count)
{
reiserfs_warning (NULL, "green-16009: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16009: Invalid item type observed, run fsck ASAP");
return 0;
}
static int errcatch_unit_num(struct virtual_item *vi)
{
reiserfs_warning (NULL, "green-16010: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16010: Invalid item type observed, run fsck ASAP");
return 0;
}
static void errcatch_print_vi(struct virtual_item *vi)
{
reiserfs_warning (NULL, "green-16011: Invalid item type observed, run fsck ASAP");
reiserfs_warning(NULL,
"green-16011: Invalid item type observed, run fsck ASAP");
}
static struct item_operations errcatch_ops = {
@ -766,8 +737,6 @@ static struct item_operations errcatch_ops = {
errcatch_print_vi
};
//////////////////////////////////////////////////////////////////////////////
//
//
@ -783,7 +752,3 @@ struct item_operations * item_ops [TYPE_ANY + 1] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
&errcatch_ops /* This is to catch errors with invalid type (15th entry for TYPE_ANY) */
};

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -34,7 +34,8 @@ static int bin_search_in_dir_item (struct reiserfs_dir_entry * de, loff_t off)
lbound = 0;
rbound = I_ENTRY_COUNT(ih) - 1;
for (j = (rbound + lbound) / 2; lbound <= rbound; j = (rbound + lbound) / 2) {
for (j = (rbound + lbound) / 2; lbound <= rbound;
j = (rbound + lbound) / 2) {
if (off < deh_offset(deh + j)) {
rbound = j - 1;
continue;
@ -52,9 +53,9 @@ static int bin_search_in_dir_item (struct reiserfs_dir_entry * de, loff_t off)
return NAME_NOT_FOUND;
}
// comment? maybe something like set de to point to what the path points to?
static inline void set_de_item_location (struct reiserfs_dir_entry * de, struct path * path)
static inline void set_de_item_location(struct reiserfs_dir_entry *de,
struct path *path)
{
de->de_bh = get_last_bh(path);
de->de_ih = get_ih(path);
@ -62,7 +63,6 @@ static inline void set_de_item_location (struct reiserfs_dir_entry * de, struct
de->de_item_num = PATH_LAST_POSITION(path);
}
// de_bh, de_ih, de_deh (points to first element of array), de_item_num is set
inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
{
@ -78,7 +78,6 @@ inline void set_de_name_and_namelen (struct reiserfs_dir_entry * de)
de->de_namelen = strlen(de->de_name);
}
// what entry points to
static inline void set_de_object_key(struct reiserfs_dir_entry *de)
{
@ -88,7 +87,6 @@ static inline void set_de_object_key (struct reiserfs_dir_entry * de)
de->de_objectid = deh_objectid(&(de->de_deh[de->de_entry_num]));
}
static inline void store_de_entry_key(struct reiserfs_dir_entry *de)
{
struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
@ -98,13 +96,14 @@ static inline void store_de_entry_key (struct reiserfs_dir_entry * de)
/* store key of the found entry */
de->de_entry_key.version = KEY_FORMAT_3_5;
de->de_entry_key.on_disk_key.k_dir_id = le32_to_cpu (de->de_ih->ih_key.k_dir_id);
de->de_entry_key.on_disk_key.k_objectid = le32_to_cpu (de->de_ih->ih_key.k_objectid);
de->de_entry_key.on_disk_key.k_dir_id =
le32_to_cpu(de->de_ih->ih_key.k_dir_id);
de->de_entry_key.on_disk_key.k_objectid =
le32_to_cpu(de->de_ih->ih_key.k_objectid);
set_cpu_key_k_offset(&(de->de_entry_key), deh_offset(deh));
set_cpu_key_k_type(&(de->de_entry_key), TYPE_DIRENTRY);
}
/* We assign a key to each directory item, and place multiple entries
in a single directory item. A directory item has a key equal to the
key of the first directory entry in it.
@ -126,7 +125,8 @@ int search_by_entry_key (struct super_block * sb, const struct cpu_key * key,
switch (retval) {
case ITEM_NOT_FOUND:
if (!PATH_LAST_POSITION(path)) {
reiserfs_warning (sb, "vs-7000: search_by_entry_key: search_by_key returned item position == 0");
reiserfs_warning(sb,
"vs-7000: search_by_entry_key: search_by_key returned item position == 0");
pathrelse(path);
return IO_ERROR;
}
@ -140,7 +140,8 @@ int search_by_entry_key (struct super_block * sb, const struct cpu_key * key,
default:
pathrelse(path);
reiserfs_warning (sb, "vs-7002: search_by_entry_key: no path to here");
reiserfs_warning(sb,
"vs-7002: search_by_entry_key: no path to here");
return IO_ERROR;
}
@ -150,8 +151,10 @@ int search_by_entry_key (struct super_block * sb, const struct cpu_key * key,
if (!is_direntry_le_ih(de->de_ih) ||
COMP_SHORT_KEYS(&(de->de_ih->ih_key), key)) {
print_block(de->de_bh, 0, -1, -1);
reiserfs_panic (sb, "vs-7005: search_by_entry_key: found item %h is not directory item or "
"does not belong to the same directory as key %K", de->de_ih, key);
reiserfs_panic(sb,
"vs-7005: search_by_entry_key: found item %h is not directory item or "
"does not belong to the same directory as key %K",
de->de_ih, key);
}
#endif /* CONFIG_REISERFS_CHECK */
@ -167,8 +170,6 @@ int search_by_entry_key (struct super_block * sb, const struct cpu_key * key,
return retval;
}
/* Keyed 32-bit hash function using TEA in a Davis-Meyer function */
/* The third component is hashed, and you can choose from more than
@ -197,7 +198,6 @@ static __u32 get_third_component (struct super_block * s,
return res + MAX_GENERATION_NUMBER;
}
static int reiserfs_match(struct reiserfs_dir_entry *de,
const char *name, int namelen)
{
@ -205,18 +205,19 @@ static int reiserfs_match (struct reiserfs_dir_entry * de,
if ((namelen == de->de_namelen) &&
!memcmp(de->de_name, name, de->de_namelen))
retval = (de_visible (de->de_deh + de->de_entry_num) ? NAME_FOUND : NAME_FOUND_INVISIBLE);
retval =
(de_visible(de->de_deh + de->de_entry_num) ? NAME_FOUND :
NAME_FOUND_INVISIBLE);
return retval;
}
/* de's de_bh, de_ih, de_deh, de_item_num, de_entry_num are set already */
/* used when hash collisions exist */
static int linear_search_in_dir_item (struct cpu_key * key, struct reiserfs_dir_entry * de,
static int linear_search_in_dir_item(struct cpu_key *key,
struct reiserfs_dir_entry *de,
const char *name, int namelen)
{
struct reiserfs_de_head *deh = de->de_deh;
@ -226,7 +227,8 @@ static int linear_search_in_dir_item (struct cpu_key * key, struct reiserfs_dir_
i = de->de_entry_num;
if (i == I_ENTRY_COUNT(de->de_ih) ||
GET_HASH_VALUE (deh_offset (deh + i)) != GET_HASH_VALUE (cpu_key_k_offset (key))) {
GET_HASH_VALUE(deh_offset(deh + i)) !=
GET_HASH_VALUE(cpu_key_k_offset(key))) {
i--;
}
@ -244,13 +246,15 @@ static int linear_search_in_dir_item (struct cpu_key * key, struct reiserfs_dir_
/* mark, that this generation number is used */
if (de->de_gen_number_bit_string)
set_bit (GET_GENERATION_NUMBER (deh_offset (deh)), (unsigned long *)de->de_gen_number_bit_string);
set_bit(GET_GENERATION_NUMBER(deh_offset(deh)),
(unsigned long *)de->de_gen_number_bit_string);
// calculate pointer to name and namelen
de->de_entry_num = i;
set_de_name_and_namelen(de);
if ((retval = reiserfs_match (de, name, namelen)) != NAME_NOT_FOUND) {
if ((retval =
reiserfs_match(de, name, namelen)) != NAME_NOT_FOUND) {
// de's de_name, de_namelen, de_recordlen are set. Fill the rest:
// key of pointed object
@ -279,25 +283,27 @@ static int linear_search_in_dir_item (struct cpu_key * key, struct reiserfs_dir_
return GOTO_PREVIOUS_ITEM;
}
// may return NAME_FOUND, NAME_FOUND_INVISIBLE, NAME_NOT_FOUND
// FIXME: should add something like IOERROR
static int reiserfs_find_entry(struct inode *dir, const char *name, int namelen,
struct path * path_to_entry, struct reiserfs_dir_entry * de)
struct path *path_to_entry,
struct reiserfs_dir_entry *de)
{
struct cpu_key key_to_search;
int retval;
if (namelen > REISERFS_MAX_NAME(dir->i_sb->s_blocksize))
return NAME_NOT_FOUND;
/* we will search for this key in the tree */
make_cpu_key(&key_to_search, dir,
get_third_component (dir->i_sb, name, namelen), TYPE_DIRENTRY, 3);
get_third_component(dir->i_sb, name, namelen),
TYPE_DIRENTRY, 3);
while (1) {
retval = search_by_entry_key (dir->i_sb, &key_to_search, path_to_entry, de);
retval =
search_by_entry_key(dir->i_sb, &key_to_search,
path_to_entry, de);
if (retval == IO_ERROR) {
reiserfs_warning(dir->i_sb, "zam-7001: io error in %s",
__FUNCTION__);
@ -305,7 +311,9 @@ static int reiserfs_find_entry (struct inode * dir, const char * name, int namel
}
/* compare names for all entries having given hash value */
retval = linear_search_in_dir_item (&key_to_search, de, name, namelen);
retval =
linear_search_in_dir_item(&key_to_search, de, name,
namelen);
if (retval != GOTO_PREVIOUS_ITEM) {
/* there is no need to scan directory anymore. Given entry found or does not exist */
path_to_entry->pos_in_item = de->de_entry_num;
@ -313,14 +321,15 @@ static int reiserfs_find_entry (struct inode * dir, const char * name, int namel
}
/* there is left neighboring item of this directory and given entry can be there */
set_cpu_key_k_offset (&key_to_search, le_ih_k_offset (de->de_ih) - 1);
set_cpu_key_k_offset(&key_to_search,
le_ih_k_offset(de->de_ih) - 1);
pathrelse(path_to_entry);
} /* while (1) */
}
static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dentry, struct nameidata *nd)
static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{
int retval;
struct inode *inode = NULL;
@ -332,7 +341,9 @@ static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dent
reiserfs_write_lock(dir->i_sb);
de.de_gen_number_bit_string = NULL;
retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path_to_entry, &de);
retval =
reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
&path_to_entry, &de);
pathrelse(&path_to_entry);
if (retval == NAME_FOUND) {
/* Hide the .reiserfs_priv directory */
@ -340,12 +351,16 @@ static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dent
!old_format_only(dir->i_sb) &&
REISERFS_SB(dir->i_sb)->priv_root &&
REISERFS_SB(dir->i_sb)->priv_root->d_inode &&
de.de_objectid == le32_to_cpu (INODE_PKEY(REISERFS_SB(dir->i_sb)->priv_root->d_inode)->k_objectid)) {
de.de_objectid ==
le32_to_cpu(INODE_PKEY
(REISERFS_SB(dir->i_sb)->priv_root->d_inode)->
k_objectid)) {
reiserfs_write_unlock(dir->i_sb);
return ERR_PTR(-EACCES);
}
inode = reiserfs_iget (dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
inode =
reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
if (!inode || IS_ERR(inode)) {
reiserfs_write_unlock(dir->i_sb);
return ERR_PTR(-EACCES);
@ -367,7 +382,6 @@ static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dent
return NULL;
}
/*
** looks up the dentry of the parent directory for child.
** taken from ext2_get_parent
@ -381,7 +395,6 @@ struct dentry *reiserfs_get_parent(struct dentry *child)
struct dentry *parent;
struct inode *dir = child->d_inode;
if (dir->i_nlink == 0) {
return ERR_PTR(-ENOENT);
}
@ -408,16 +421,15 @@ struct dentry *reiserfs_get_parent(struct dentry *child)
return parent;
}
/* add entry to the directory (entry can be hidden).
insert definition of when hidden directories are used here -Hans
Does not mark dir inode dirty, do it after successesfull call to it */
static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct inode * dir,
const char * name, int namelen, struct inode * inode,
int visible)
static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
struct inode *dir, const char *name, int namelen,
struct inode *inode, int visible)
{
struct cpu_key entry_key;
struct reiserfs_de_head *deh;
@ -442,7 +454,8 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
/* each entry has unique key. compose it */
make_cpu_key(&entry_key, dir,
get_third_component (dir->i_sb, name, namelen), TYPE_DIRENTRY, 3);
get_third_component(dir->i_sb, name, namelen),
TYPE_DIRENTRY, 3);
/* get memory for composing the entry */
buflen = DEH_SIZE + ROUND_UP(namelen);
@ -453,7 +466,9 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
} else
buffer = small_buf;
paste_size = (get_inode_sd_version (dir) == STAT_DATA_V1) ? (DEH_SIZE + namelen) : buflen;
paste_size =
(get_inode_sd_version(dir) ==
STAT_DATA_V1) ? (DEH_SIZE + namelen) : buflen;
/* fill buffer : directory entry head, name[, dir objectid | , stat data | ,stat data, dir objectid ] */
deh = (struct reiserfs_de_head *)buffer;
@ -487,7 +502,8 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
}
if (retval != NAME_FOUND) {
reiserfs_warning (dir->i_sb, "zam-7002:%s: \"reiserfs_find_entry\" "
reiserfs_warning(dir->i_sb,
"zam-7002:%s: \"reiserfs_find_entry\" "
"has returned unexpected value (%d)",
__FUNCTION__, retval);
}
@ -495,10 +511,13 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
return -EEXIST;
}
gen_number = find_first_zero_bit ((unsigned long *)bit_string, MAX_GENERATION_NUMBER + 1);
gen_number =
find_first_zero_bit((unsigned long *)bit_string,
MAX_GENERATION_NUMBER + 1);
if (gen_number > MAX_GENERATION_NUMBER) {
/* there is no free generation number */
reiserfs_warning (dir->i_sb, "reiserfs_add_entry: Congratulations! we have got hash function screwed up");
reiserfs_warning(dir->i_sb,
"reiserfs_add_entry: Congratulations! we have got hash function screwed up");
if (buffer != small_buf)
reiserfs_kfree(buffer, buflen, dir->i_sb);
pathrelse(&path);
@ -512,8 +531,10 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
PROC_INFO_MAX(th->t_super, max_hash_collisions, gen_number);
if (gen_number != 0) { /* we need to re-search for the insertion point */
if (search_by_entry_key (dir->i_sb, &entry_key, &path, &de) != NAME_NOT_FOUND) {
reiserfs_warning (dir->i_sb, "vs-7032: reiserfs_add_entry: "
if (search_by_entry_key(dir->i_sb, &entry_key, &path, &de) !=
NAME_NOT_FOUND) {
reiserfs_warning(dir->i_sb,
"vs-7032: reiserfs_add_entry: "
"entry with this key (%K) already exists",
&entry_key);
@ -525,7 +546,9 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
}
/* perform the insertion of the entry that we have prepared */
retval = reiserfs_paste_into_item (th, &path, &entry_key, dir, buffer, paste_size);
retval =
reiserfs_paste_into_item(th, &path, &entry_key, dir, buffer,
paste_size);
if (buffer != small_buf)
reiserfs_kfree(buffer, buflen, dir->i_sb);
if (retval) {
@ -548,7 +571,8 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
** This should only be called on inodes that do not have stat data
** inserted into the tree yet.
*/
static int drop_new_inode(struct inode *inode) {
static int drop_new_inode(struct inode *inode)
{
DQUOT_DROP(inode);
make_bad_inode(inode);
inode->i_flags |= S_NOQUOTA;
@ -561,7 +585,8 @@ static int drop_new_inode(struct inode *inode) {
** outside of a transaction, so we had to pull some bits of
** reiserfs_new_inode out into this func.
*/
static int new_inode_init(struct inode *inode, struct inode *dir, int mode) {
static int new_inode_init(struct inode *inode, struct inode *dir, int mode)
{
/* the quota init calls have to know who to charge the quota to, so
** we have to set uid and gid here
@ -586,7 +611,10 @@ static int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode,
int retval;
struct inode *inode;
/* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
int jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb)+REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
int jbegin_count =
JOURNAL_PER_BALANCE_CNT * 2 +
2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
struct reiserfs_transaction_handle th;
int locked;
@ -608,7 +636,9 @@ static int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode,
goto out_failed;
}
retval = reiserfs_new_inode (&th, dir, mode, NULL, 0/*i_size*/, dentry, inode);
retval =
reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
inode);
if (retval)
goto out_failed;
@ -621,8 +651,9 @@ static int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode,
inode->i_fop = &reiserfs_file_operations;
inode->i_mapping->a_ops = &reiserfs_address_space_operations;
retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
inode, 1/*visible*/);
retval =
reiserfs_add_entry(&th, dir, dentry->d_name.name,
dentry->d_name.len, inode, 1 /*visible */ );
if (retval) {
int err;
inode->i_nlink--;
@ -646,14 +677,17 @@ out_failed:
return retval;
}
static int reiserfs_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev)
static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
dev_t rdev)
{
int retval;
struct inode *inode;
struct reiserfs_transaction_handle th;
/* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb)+REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
int jbegin_count =
JOURNAL_PER_BALANCE_CNT * 3 +
2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
int locked;
if (!new_valid_dev(rdev))
@ -677,7 +711,9 @@ static int reiserfs_mknod (struct inode * dir, struct dentry *dentry, int mode,
goto out_failed;
}
retval = reiserfs_new_inode (&th, dir, mode, NULL, 0/*i_size*/, dentry, inode);
retval =
reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
inode);
if (retval) {
goto out_failed;
}
@ -687,7 +723,6 @@ static int reiserfs_mknod (struct inode * dir, struct dentry *dentry, int mode,
locked = 0;
}
inode->i_op = &reiserfs_special_inode_operations;
init_special_inode(inode, inode->i_mode, rdev);
@ -697,8 +732,9 @@ static int reiserfs_mknod (struct inode * dir, struct dentry *dentry, int mode,
reiserfs_update_inode_transaction(inode);
reiserfs_update_inode_transaction(dir);
retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
inode, 1/*visible*/);
retval =
reiserfs_add_entry(&th, dir, dentry->d_name.name,
dentry->d_name.len, inode, 1 /*visible */ );
if (retval) {
int err;
inode->i_nlink--;
@ -720,14 +756,16 @@ out_failed:
return retval;
}
static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{
int retval;
struct inode *inode;
struct reiserfs_transaction_handle th;
/* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb)+REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
int jbegin_count =
JOURNAL_PER_BALANCE_CNT * 3 +
2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
int locked;
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
@ -752,7 +790,6 @@ static int reiserfs_mkdir (struct inode * dir, struct dentry *dentry, int mode)
goto out_failed;
}
/* inc the link count now, so another writer doesn't overflow it while
** we sleep later on.
*/
@ -779,8 +816,9 @@ static int reiserfs_mkdir (struct inode * dir, struct dentry *dentry, int mode)
inode->i_fop = &reiserfs_dir_operations;
// note, _this_ add_entry will not update dir's stat data
retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
inode, 1/*visible*/);
retval =
reiserfs_add_entry(&th, dir, dentry->d_name.name,
dentry->d_name.len, inode, 1 /*visible */ );
if (retval) {
int err;
inode->i_nlink = 0;
@ -792,7 +830,6 @@ static int reiserfs_mkdir (struct inode * dir, struct dentry *dentry, int mode)
iput(inode);
goto out_failed;
}
// the above add_entry did not update dir's stat data
reiserfs_update_sd(&th, dir);
@ -805,7 +842,8 @@ out_failed:
return retval;
}
static inline int reiserfs_empty_dir(struct inode *inode) {
static inline int reiserfs_empty_dir(struct inode *inode)
{
/* we can cheat because an old format dir cannot have
** EMPTY_DIR_SIZE, and a new format dir cannot have
** EMPTY_DIR_SIZE_V1. So, if the inode is either size,
@ -827,12 +865,13 @@ static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry)
INITIALIZE_PATH(path);
struct reiserfs_dir_entry de;
/* we will be doing 2 balancings and update 2 stat data, we change quotas
* of the owner of the directory and of the owner of the parent directory.
* The quota structure is possibly deleted only on last iput => outside
* of this transaction */
jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 + 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
jbegin_count =
JOURNAL_PER_BALANCE_CNT * 2 + 2 +
4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
reiserfs_write_lock(dir->i_sb);
retval = journal_begin(&th, dir->i_sb, jbegin_count);
@ -840,7 +879,9 @@ static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry)
goto out_rmdir;
de.de_gen_number_bit_string = NULL;
if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
if ((retval =
reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
&path, &de)) == NAME_NOT_FOUND) {
retval = -ENOENT;
goto end_rmdir;
} else if (retval == IO_ERROR) {
@ -865,8 +906,7 @@ static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry)
}
/* cut entry from dir directory */
retval = reiserfs_cut_from_item (&th, &path, &(de.de_entry_key), dir,
NULL, /* page */
retval = reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL, /* page */
0 /*new file size - not used here */ );
if (retval < 0)
goto end_rmdir;
@ -918,7 +958,9 @@ static int reiserfs_unlink (struct inode * dir, struct dentry *dentry)
* two stat datas, we change quotas of the owner of the directory and of
* the owner of the parent directory. The quota structure is possibly
* deleted only on iput => outside of this transaction */
jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 + 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
jbegin_count =
JOURNAL_PER_BALANCE_CNT * 2 + 2 +
4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
reiserfs_write_lock(dir->i_sb);
retval = journal_begin(&th, dir->i_sb, jbegin_count);
@ -926,7 +968,9 @@ static int reiserfs_unlink (struct inode * dir, struct dentry *dentry)
goto out_unlink;
de.de_gen_number_bit_string = NULL;
if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
if ((retval =
reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
&path, &de)) == NAME_NOT_FOUND) {
retval = -ENOENT;
goto end_unlink;
} else if (retval == IO_ERROR) {
@ -960,8 +1004,9 @@ static int reiserfs_unlink (struct inode * dir, struct dentry *dentry)
*/
savelink = inode->i_nlink;
retval = reiserfs_cut_from_item (&th, &path, &(de.de_entry_key), dir, NULL, 0);
retval =
reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL,
0);
if (retval < 0) {
inode->i_nlink++;
goto end_unlink;
@ -1003,7 +1048,10 @@ static int reiserfs_symlink (struct inode * parent_dir,
struct reiserfs_transaction_handle th;
int mode = S_IFLNK | S_IRWXUGO;
/* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb)+REISERFS_QUOTA_TRANS_BLOCKS(parent_dir->i_sb));
int jbegin_count =
JOURNAL_PER_BALANCE_CNT * 3 +
2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb) +
REISERFS_QUOTA_TRANS_BLOCKS(parent_dir->i_sb));
if (!(inode = new_inode(parent_dir->i_sb))) {
return -ENOMEM;
@ -1036,7 +1084,8 @@ static int reiserfs_symlink (struct inode * parent_dir,
goto out_failed;
}
retval = reiserfs_new_inode (&th, parent_dir, mode, name, strlen (symname),
retval =
reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname),
dentry, inode);
reiserfs_kfree(name, item_len, parent_dir->i_sb);
if (retval) { /* reiserfs_new_inode iputs for us */
@ -1073,13 +1122,16 @@ out_failed:
return retval;
}
static int reiserfs_link (struct dentry * old_dentry, struct inode * dir, struct dentry * dentry)
static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
struct dentry *dentry)
{
int retval;
struct inode *inode = old_dentry->d_inode;
struct reiserfs_transaction_handle th;
/* We need blocks for transaction + update of quotas for the owners of the directory */
int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
int jbegin_count =
JOURNAL_PER_BALANCE_CNT * 3 +
2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
reiserfs_write_lock(dir->i_sb);
if (inode->i_nlink >= REISERFS_LINK_MAX) {
@ -1103,8 +1155,9 @@ static int reiserfs_link (struct dentry * old_dentry, struct inode * dir, struct
}
/* create new entry */
retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
inode, 1/*visible*/);
retval =
reiserfs_add_entry(&th, dir, dentry->d_name.name,
dentry->d_name.len, inode, 1 /*visible */ );
reiserfs_update_inode_transaction(inode);
reiserfs_update_inode_transaction(dir);
@ -1127,9 +1180,9 @@ static int reiserfs_link (struct dentry * old_dentry, struct inode * dir, struct
return retval;
}
// de contains information pointing to an entry which
static int de_still_valid (const char * name, int len, struct reiserfs_dir_entry * de)
static int de_still_valid(const char *name, int len,
struct reiserfs_dir_entry *de)
{
struct reiserfs_dir_entry tmp = *de;
@ -1141,35 +1194,37 @@ static int de_still_valid (const char * name, int len, struct reiserfs_dir_entry
return 1;
}
static int entry_points_to_object (const char * name, int len, struct reiserfs_dir_entry * de, struct inode * inode)
static int entry_points_to_object(const char *name, int len,
struct reiserfs_dir_entry *de,
struct inode *inode)
{
if (!de_still_valid(name, len, de))
return 0;
if (inode) {
if (!de_visible(de->de_deh + de->de_entry_num))
reiserfs_panic (NULL, "vs-7042: entry_points_to_object: entry must be visible");
reiserfs_panic(NULL,
"vs-7042: entry_points_to_object: entry must be visible");
return (de->de_objectid == inode->i_ino) ? 1 : 0;
}
/* this must be added hidden entry */
if (de_visible(de->de_deh + de->de_entry_num))
reiserfs_panic (NULL, "vs-7043: entry_points_to_object: entry must be visible");
reiserfs_panic(NULL,
"vs-7043: entry_points_to_object: entry must be visible");
return 1;
}
/* sets key of objectid the entry has to point to */
static void set_ino_in_dir_entry (struct reiserfs_dir_entry * de, struct reiserfs_key * key)
static void set_ino_in_dir_entry(struct reiserfs_dir_entry *de,
struct reiserfs_key *key)
{
/* JDM These operations are endian safe - both are le */
de->de_deh[de->de_entry_num].deh_dir_id = key->k_dir_id;
de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
}
/*
* process, that is going to call fix_nodes/do_balance must hold only
* one path. If it holds 2 or more, it can get into endless waiting in
@ -1199,7 +1254,9 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
pointed initially and (5) maybe block containing ".." of
renamed directory
quota updates: two parent directories */
jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 5 + 4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
jbegin_count =
JOURNAL_PER_BALANCE_CNT * 3 + 5 +
4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
old_inode = old_dentry->d_inode;
new_dentry_inode = new_dentry->d_inode;
@ -1208,8 +1265,10 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
// are going to rename
old_de.de_gen_number_bit_string = NULL;
reiserfs_write_lock(old_dir->i_sb);
retval = reiserfs_find_entry (old_dir, old_dentry->d_name.name, old_dentry->d_name.len,
&old_entry_path, &old_de);
retval =
reiserfs_find_entry(old_dir, old_dentry->d_name.name,
old_dentry->d_name.len, &old_entry_path,
&old_de);
pathrelse(&old_entry_path);
if (retval == IO_ERROR) {
reiserfs_write_unlock(old_dir->i_sb);
@ -1238,7 +1297,9 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
** so find ".." entry
*/
dot_dot_de.de_gen_number_bit_string = NULL;
retval = reiserfs_find_entry (old_inode, "..", 2, &dot_dot_entry_path, &dot_dot_de);
retval =
reiserfs_find_entry(old_inode, "..", 2, &dot_dot_entry_path,
&dot_dot_de);
pathrelse(&dot_dot_entry_path);
if (retval != NAME_FOUND) {
reiserfs_write_unlock(old_dir->i_sb);
@ -1259,8 +1320,9 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
}
/* add new entry (or find the existing one) */
retval = reiserfs_add_entry (&th, new_dir, new_dentry->d_name.name, new_dentry->d_name.len,
old_inode, 0);
retval =
reiserfs_add_entry(&th, new_dir, new_dentry->d_name.name,
new_dentry->d_name.len, old_inode, 0);
if (retval == -EEXIST) {
if (!new_dentry_inode) {
reiserfs_panic(old_dir->i_sb,
@ -1285,8 +1347,10 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
while (1) {
// look for old name using corresponding entry key (found by reiserfs_find_entry)
if ((retval = search_by_entry_key (new_dir->i_sb, &old_de.de_entry_key,
&old_entry_path, &old_de)) != NAME_FOUND) {
if ((retval =
search_by_entry_key(new_dir->i_sb, &old_de.de_entry_key,
&old_entry_path,
&old_de)) != NAME_FOUND) {
pathrelse(&old_entry_path);
journal_end(&th, old_dir->i_sb, jbegin_count);
reiserfs_write_unlock(old_dir->i_sb);
@ -1299,8 +1363,10 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
// look for new name by reiserfs_find_entry
new_de.de_gen_number_bit_string = NULL;
retval = reiserfs_find_entry (new_dir, new_dentry->d_name.name, new_dentry->d_name.len,
&new_entry_path, &new_de);
retval =
reiserfs_find_entry(new_dir, new_dentry->d_name.name,
new_dentry->d_name.len, &new_entry_path,
&new_de);
// reiserfs_add_entry should not return IO_ERROR, because it is called with essentially same parameters from
// reiserfs_add_entry above, and we'll catch any i/o errors before we get here.
if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND) {
@ -1316,8 +1382,11 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1);
if (S_ISDIR(old_inode->i_mode)) {
if ((retval = search_by_entry_key (new_dir->i_sb, &dot_dot_de.de_entry_key,
&dot_dot_entry_path, &dot_dot_de)) != NAME_FOUND) {
if ((retval =
search_by_entry_key(new_dir->i_sb,
&dot_dot_de.de_entry_key,
&dot_dot_entry_path,
&dot_dot_de)) != NAME_FOUND) {
pathrelse(&dot_dot_entry_path);
pathrelse(&new_entry_path);
pathrelse(&old_entry_path);
@ -1325,9 +1394,11 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
reiserfs_write_unlock(old_dir->i_sb);
return -EIO;
}
copy_item_head(&dot_dot_ih, get_ih(&dot_dot_entry_path)) ;
copy_item_head(&dot_dot_ih,
get_ih(&dot_dot_entry_path));
// node containing ".." gets into transaction
reiserfs_prepare_for_journal(old_inode->i_sb, dot_dot_de.de_bh, 1) ;
reiserfs_prepare_for_journal(old_inode->i_sb,
dot_dot_de.de_bh, 1);
}
/* we should check seals here, not do
this stuff, yes? Then, having
@ -1350,18 +1421,31 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
!entry_points_to_object(old_dentry->d_name.name,
old_dentry->d_name.len,
&old_de, old_inode)) {
reiserfs_restore_prepared_buffer (old_inode->i_sb, new_de.de_bh);
reiserfs_restore_prepared_buffer (old_inode->i_sb, old_de.de_bh);
reiserfs_restore_prepared_buffer(old_inode->i_sb,
new_de.de_bh);
reiserfs_restore_prepared_buffer(old_inode->i_sb,
old_de.de_bh);
if (S_ISDIR(old_inode_mode))
reiserfs_restore_prepared_buffer (old_inode->i_sb, dot_dot_de.de_bh);
reiserfs_restore_prepared_buffer(old_inode->
i_sb,
dot_dot_de.
de_bh);
continue;
}
if (S_ISDIR(old_inode_mode)) {
if (item_moved(&dot_dot_ih, &dot_dot_entry_path) ||
!entry_points_to_object ( "..", 2, &dot_dot_de, old_dir) ) {
reiserfs_restore_prepared_buffer (old_inode->i_sb, old_de.de_bh);
reiserfs_restore_prepared_buffer (old_inode->i_sb, new_de.de_bh);
reiserfs_restore_prepared_buffer (old_inode->i_sb, dot_dot_de.de_bh);
!entry_points_to_object("..", 2, &dot_dot_de,
old_dir)) {
reiserfs_restore_prepared_buffer(old_inode->
i_sb,
old_de.de_bh);
reiserfs_restore_prepared_buffer(old_inode->
i_sb,
new_de.de_bh);
reiserfs_restore_prepared_buffer(old_inode->
i_sb,
dot_dot_de.
de_bh);
continue;
}
}
@ -1412,7 +1496,6 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
/* old directory lost one link - ".. " of renamed directory */
DEC_DIR_INODE_NLINK(old_dir);
}
// looks like in 2.3.99pre3 brelse is atomic. so we can use pathrelse
pathrelse(&new_entry_path);
pathrelse(&dot_dot_entry_path);
@ -1420,8 +1503,11 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
// FIXME: this reiserfs_cut_from_item's return value may screw up
// anybody, but it will panic if will not be able to find the
// entry. This needs one more clean up
if (reiserfs_cut_from_item (&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL, 0) < 0)
reiserfs_warning (old_dir->i_sb, "vs-7060: reiserfs_rename: couldn't not cut old name. Fsck later?");
if (reiserfs_cut_from_item
(&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL,
0) < 0)
reiserfs_warning(old_dir->i_sb,
"vs-7060: reiserfs_rename: couldn't not cut old name. Fsck later?");
old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;
@ -1431,7 +1517,8 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
if (new_dentry_inode) {
if (savelink == 0)
add_save_link (&th, new_dentry_inode, 0/* not truncate */);
add_save_link(&th, new_dentry_inode,
0 /* not truncate */ );
reiserfs_update_sd(&th, new_dentry_inode);
}
@ -1479,7 +1566,6 @@ struct inode_operations reiserfs_symlink_inode_operations = {
};
/*
* special file operations.. just xattr/acl stuff
*/

View file

@ -14,13 +14,13 @@
(__le32 *)((struct reiserfs_super_block_v1 *)(rs) + 1) :\
(__le32 *)((rs) + 1))
#ifdef CONFIG_REISERFS_CHECK
static void check_objectid_map(struct super_block *s, __le32 * map)
{
if (le32_to_cpu(map[0]) != 1)
reiserfs_panic (s, "vs-15010: check_objectid_map: map corrupted: %lx",
reiserfs_panic(s,
"vs-15010: check_objectid_map: map corrupted: %lx",
(long unsigned int)le32_to_cpu(map[0]));
// FIXME: add something else here
@ -28,10 +28,10 @@ static void check_objectid_map (struct super_block * s, __le32 * map)
#else
static void check_objectid_map(struct super_block *s, __le32 * map)
{;}
{;
}
#endif
/* When we allocate objectids we allocate the first unused objectid.
Each sequence of objectids in use (the odd sequences) is followed
by a sequence of objectids not in use (the even sequences). We
@ -46,7 +46,6 @@ static void check_objectid_map (struct super_block * s, __le32 * map)
interesting optimizations of layout could result from complicating
objectid assignment, but we have deferred making them for now. */
/* get unique object identifier */
__u32 reiserfs_get_unused_objectid(struct reiserfs_transaction_handle *th)
{
@ -82,7 +81,8 @@ __u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th)
result is to eliminate a pair of objectids from oids. We do this
by shifting the entire map to the left. */
if (sb_oid_cursize(rs) > 2 && map[1] == map[2]) {
memmove (map + 1, map + 3, (sb_oid_cursize(rs) - 3) * sizeof(__u32));
memmove(map + 1, map + 3,
(sb_oid_cursize(rs) - 3) * sizeof(__u32));
set_sb_oid_cursize(rs, sb_oid_cursize(rs) - 2);
}
@ -90,7 +90,6 @@ __u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th)
return unused_objectid;
}
/* makes object identifier unused */
void reiserfs_release_objectid(struct reiserfs_transaction_handle *th,
__u32 objectid_to_release)
@ -122,7 +121,8 @@ void reiserfs_release_objectid (struct reiserfs_transaction_handle *th,
if (map[i] == map[i + 1]) {
/* shrink objectid map */
memmove(map + i, map + i + 2,
(sb_oid_cursize(rs) - i - 2) * sizeof (__u32));
(sb_oid_cursize(rs) - i -
2) * sizeof(__u32));
//disk_sb->s_oid_cursize -= 2;
set_sb_oid_cursize(rs, sb_oid_cursize(rs) - 2);
@ -139,7 +139,8 @@ void reiserfs_release_objectid (struct reiserfs_transaction_handle *th,
/* size of objectid map is not changed */
if (objectid_to_release + 1 == le32_to_cpu(map[i + 1])) {
//objectid_map[i+1]--;
map[i + 1] = cpu_to_le32 (le32_to_cpu (map[i + 1]) - 1);
map[i + 1] =
cpu_to_le32(le32_to_cpu(map[i + 1]) - 1);
return;
}
@ -161,12 +162,13 @@ void reiserfs_release_objectid (struct reiserfs_transaction_handle *th,
i += 2;
}
reiserfs_warning (s, "vs-15011: reiserfs_release_objectid: tried to free free object id (%lu)",
reiserfs_warning(s,
"vs-15011: reiserfs_release_objectid: tried to free free object id (%lu)",
(long unsigned)objectid_to_release);
}
int reiserfs_convert_objectid_map_v1(struct super_block *s) {
int reiserfs_convert_objectid_map_v1(struct super_block *s)
{
struct reiserfs_super_block *disk_sb = SB_DISK_SUPER_BLOCK(s);
int cur_size = sb_oid_cursize(disk_sb);
int new_size = (s->s_blocksize - SB_SIZE) / sizeof(__u32) / 2 * 2;
@ -175,7 +177,8 @@ int reiserfs_convert_objectid_map_v1(struct super_block *s) {
__le32 *objectid_map, *new_objectid_map;
int i;
disk_sb_v1=(struct reiserfs_super_block_v1 *)(SB_BUFFER_WITH_SB(s)->b_data);
disk_sb_v1 =
(struct reiserfs_super_block_v1 *)(SB_BUFFER_WITH_SB(s)->b_data);
objectid_map = (__le32 *) (disk_sb_v1 + 1);
new_objectid_map = (__le32 *) (disk_sb + 1);
@ -191,7 +194,6 @@ int reiserfs_convert_objectid_map_v1(struct super_block *s) {
objectid_map[i + (old_max - new_size)] = objectid_map[i];
}
/* set the max size so we don't overflow later */
set_sb_oid_maxsize(disk_sb, new_size);
@ -203,4 +205,3 @@ int reiserfs_convert_objectid_map_v1(struct super_block *s) {
memset(disk_sb->s_unused, 0, sizeof(disk_sb->s_unused));
return 0;
}

View file

@ -15,19 +15,20 @@ static char error_buf[1024];
static char fmt_buf[1024];
static char off_buf[80];
static char *reiserfs_cpu_offset(struct cpu_key *key)
{
if (cpu_key_k_type(key) == TYPE_DIRENTRY)
sprintf(off_buf, "%Lu(%Lu)",
(unsigned long long)GET_HASH_VALUE (cpu_key_k_offset (key)),
(unsigned long long)GET_GENERATION_NUMBER (cpu_key_k_offset (key)));
(unsigned long long)
GET_HASH_VALUE(cpu_key_k_offset(key)),
(unsigned long long)
GET_GENERATION_NUMBER(cpu_key_k_offset(key)));
else
sprintf (off_buf, "0x%Lx", (unsigned long long)cpu_key_k_offset (key));
sprintf(off_buf, "0x%Lx",
(unsigned long long)cpu_key_k_offset(key));
return off_buf;
}
static char *le_offset(struct reiserfs_key *key)
{
int version;
@ -35,14 +36,16 @@ static char * le_offset (struct reiserfs_key * key)
version = le_key_version(key);
if (le_key_k_type(version, key) == TYPE_DIRENTRY)
sprintf(off_buf, "%Lu(%Lu)",
(unsigned long long)GET_HASH_VALUE (le_key_k_offset (version, key)),
(unsigned long long)GET_GENERATION_NUMBER (le_key_k_offset (version, key)));
(unsigned long long)
GET_HASH_VALUE(le_key_k_offset(version, key)),
(unsigned long long)
GET_GENERATION_NUMBER(le_key_k_offset(version, key)));
else
sprintf (off_buf, "0x%Lx", (unsigned long long)le_key_k_offset (version, key));
sprintf(off_buf, "0x%Lx",
(unsigned long long)le_key_k_offset(version, key));
return off_buf;
}
static char *cpu_type(struct cpu_key *key)
{
if (cpu_key_k_type(key) == TYPE_STAT_DATA)
@ -56,7 +59,6 @@ static char * cpu_type (struct cpu_key * key)
return "UNKNOWN";
}
static char *le_type(struct reiserfs_key *key)
{
int version;
@ -74,18 +76,17 @@ static char * le_type (struct reiserfs_key * key)
return "UNKNOWN";
}
/* %k */
static void sprintf_le_key(char *buf, struct reiserfs_key *key)
{
if (key)
sprintf(buf, "[%d %d %s %s]", le32_to_cpu(key->k_dir_id),
le32_to_cpu (key->k_objectid), le_offset (key), le_type (key));
le32_to_cpu(key->k_objectid), le_offset(key),
le_type(key));
else
sprintf(buf, "[NULL]");
}
/* %K */
static void sprintf_cpu_key(char *buf, struct cpu_key *key)
{
@ -100,8 +101,10 @@ static void sprintf_cpu_key (char * buf, struct cpu_key * key)
static void sprintf_de_head(char *buf, struct reiserfs_de_head *deh)
{
if (deh)
sprintf( buf, "[offset=%d dir_id=%d objectid=%d location=%d state=%04x]", deh_offset(deh), deh_dir_id(deh),
deh_objectid(deh), deh_location(deh), deh_state(deh) );
sprintf(buf,
"[offset=%d dir_id=%d objectid=%d location=%d state=%04x]",
deh_offset(deh), deh_dir_id(deh), deh_objectid(deh),
deh_location(deh), deh_state(deh));
else
sprintf(buf, "[NULL]");
@ -110,7 +113,8 @@ static void sprintf_de_head( char *buf, struct reiserfs_de_head *deh )
static void sprintf_item_head(char *buf, struct item_head *ih)
{
if (ih) {
strcpy (buf, (ih_version (ih) == KEY_FORMAT_3_6) ? "*3.6* " : "*3.5*");
strcpy(buf,
(ih_version(ih) == KEY_FORMAT_3_6) ? "*3.6* " : "*3.5*");
sprintf_le_key(buf + strlen(buf), &(ih->ih_key));
sprintf(buf + strlen(buf), ", item_len %d, item_location %d, "
"free_space(entry_count) %d",
@ -119,7 +123,6 @@ static void sprintf_item_head (char * buf, struct item_head * ih)
sprintf(buf, "[NULL]");
}
static void sprintf_direntry(char *buf, struct reiserfs_dir_entry *de)
{
char name[20];
@ -129,43 +132,39 @@ static void sprintf_direntry (char * buf, struct reiserfs_dir_entry * de)
sprintf(buf, "\"%s\"==>[%d %d]", name, de->de_dir_id, de->de_objectid);
}
static void sprintf_block_head(char *buf, struct buffer_head *bh)
{
sprintf(buf, "level=%d, nr_items=%d, free_space=%d rdkey ",
B_LEVEL(bh), B_NR_ITEMS(bh), B_FREE_SPACE(bh));
}
static void sprintf_buffer_head(char *buf, struct buffer_head *bh)
{
char b[BDEVNAME_SIZE];
sprintf (buf, "dev %s, size %d, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)",
sprintf(buf,
"dev %s, size %d, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)",
bdevname(bh->b_bdev, b), bh->b_size,
(unsigned long long)bh->b_blocknr,
atomic_read (&(bh->b_count)),
(unsigned long long)bh->b_blocknr, atomic_read(&(bh->b_count)),
bh->b_state, bh->b_page,
buffer_uptodate(bh) ? "UPTODATE" : "!UPTODATE",
buffer_dirty(bh) ? "DIRTY" : "CLEAN",
buffer_locked(bh) ? "LOCKED" : "UNLOCKED");
}
static void sprintf_disk_child(char *buf, struct disk_child *dc)
{
sprintf (buf, "[dc_number=%d, dc_size=%u]", dc_block_number(dc), dc_size(dc));
sprintf(buf, "[dc_number=%d, dc_size=%u]", dc_block_number(dc),
dc_size(dc));
}
static char *is_there_reiserfs_struct(char *fmt, int *what, int *skip)
{
char *k = fmt;
*skip = 0;
while ((k = strchr (k, '%')) != NULL)
{
while ((k = strchr(k, '%')) != NULL) {
if (k[1] == 'k' || k[1] == 'K' || k[1] == 'h' || k[1] == 't' ||
k[1] == 'z' || k[1] == 'b' || k[1] == 'y' || k[1] == 'a') {
*what = k[1];
@ -177,7 +176,6 @@ static char * is_there_reiserfs_struct (char * fmt, int * what, int * skip)
return k;
}
/* debugging reiserfs we used to print out a lot of different
variables, like keys, item headers, buffer heads etc. Values of
most fields matter. So it took a long time just to write
@ -191,9 +189,7 @@ static char * is_there_reiserfs_struct (char * fmt, int * what, int * skip)
key->k_offset, key->k_uniqueness);
*/
static void
prepare_error_buf( const char *fmt, va_list args )
static void prepare_error_buf(const char *fmt, va_list args)
{
char *fmt1 = fmt_buf;
char *k;
@ -202,8 +198,7 @@ prepare_error_buf( const char *fmt, va_list args )
strcpy(fmt1, fmt);
while( (k = is_there_reiserfs_struct( fmt1, &what, &skip )) != NULL )
{
while ((k = is_there_reiserfs_struct(fmt1, &what, &skip)) != NULL) {
*k = 0;
p += vsprintf(p, fmt1, args);
@ -222,19 +217,26 @@ prepare_error_buf( const char *fmt, va_list args )
sprintf_item_head(p, va_arg(args, struct item_head *));
break;
case 't':
sprintf_direntry (p, va_arg(args, struct reiserfs_dir_entry *));
sprintf_direntry(p,
va_arg(args,
struct reiserfs_dir_entry *));
break;
case 'y':
sprintf_disk_child (p, va_arg(args, struct disk_child *));
sprintf_disk_child(p,
va_arg(args, struct disk_child *));
break;
case 'z':
sprintf_block_head (p, va_arg(args, struct buffer_head *));
sprintf_block_head(p,
va_arg(args, struct buffer_head *));
break;
case 'b':
sprintf_buffer_head (p, va_arg(args, struct buffer_head *));
sprintf_buffer_head(p,
va_arg(args, struct buffer_head *));
break;
case 'a':
sprintf_de_head (p, va_arg(args, struct reiserfs_de_head *));
sprintf_de_head(p,
va_arg(args,
struct reiserfs_de_head *));
break;
}
@ -245,7 +247,6 @@ prepare_error_buf( const char *fmt, va_list args )
}
/* in addition to usual conversion specifiers this accepts reiserfs
specific conversion specifiers:
%k to print little endian key,
@ -349,7 +350,6 @@ void reiserfs_debug (struct super_block *s, int level, const char * fmt, ...)
. */
#ifdef CONFIG_REISERFS_CHECK
extern struct tree_balance *cur_tb;
#endif
@ -366,8 +366,7 @@ void reiserfs_panic (struct super_block * sb, const char * fmt, ...)
reiserfs_bdevname(sb), error_buf);
}
void
reiserfs_abort (struct super_block *sb, int errno, const char *fmt, ...)
void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...)
{
do_reiserfs_warning(fmt);
@ -414,7 +413,8 @@ static int print_internal (struct buffer_head * bh, int first, int last)
dc = B_N_CHILD(bh, from);
reiserfs_printk("PTR %d: %y ", from, dc);
for (i = from, key = B_N_PDELIM_KEY (bh, from), dc ++; i < to; i ++, key ++, dc ++) {
for (i = from, key = B_N_PDELIM_KEY(bh, from), dc++; i < to;
i++, key++, dc++) {
reiserfs_printk("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc);
if (i && i % 4 == 0)
printk("\n");
@ -423,11 +423,8 @@ static int print_internal (struct buffer_head * bh, int first, int last)
return 0;
}
static int print_leaf (struct buffer_head * bh, int print_mode, int first, int last)
static int print_leaf(struct buffer_head *bh, int print_mode, int first,
int last)
{
struct block_head *blkh;
struct item_head *ih;
@ -443,7 +440,8 @@ static int print_leaf (struct buffer_head * bh, int print_mode, int first, int l
ih = B_N_PITEM_HEAD(bh, 0);
nr = blkh_nr_item(blkh);
printk ("\n===================================================================\n");
printk
("\n===================================================================\n");
reiserfs_printk("LEAF NODE (%ld) contains %z\n", bh->b_blocknr, bh);
if (!(print_mode & PRINT_LEAF_ITEMS)) {
@ -463,16 +461,20 @@ static int print_leaf (struct buffer_head * bh, int print_mode, int first, int l
to = last;
ih += from;
printk ("-------------------------------------------------------------------------------\n");
printk ("|##| type | key | ilen | free_space | version | loc |\n");
printk
("-------------------------------------------------------------------------------\n");
printk
("|##| type | key | ilen | free_space | version | loc |\n");
for (i = from; i < to; i++, ih++) {
printk ("-------------------------------------------------------------------------------\n");
printk
("-------------------------------------------------------------------------------\n");
reiserfs_printk("|%2d| %h |\n", i, ih);
if (print_mode & PRINT_LEAF_ITEMS)
op_print_item(ih, B_I_PITEM(bh, ih));
}
printk ("===================================================================\n");
printk
("===================================================================\n");
return 0;
}
@ -492,7 +494,8 @@ char * reiserfs_hashname(int code)
/* return 1 if this is not super block */
static int print_super_block(struct buffer_head *bh)
{
struct reiserfs_super_block * rs = (struct reiserfs_super_block *)(bh->b_data);
struct reiserfs_super_block *rs =
(struct reiserfs_super_block *)(bh->b_data);
int skipped, data_blocks;
char *version;
char b[BDEVNAME_SIZE];
@ -519,11 +522,12 @@ static int print_super_block (struct buffer_head * bh)
// skipped = (bh->b_blocknr * bh->b_size) / sb_blocksize(rs);
skipped = bh->b_blocknr;
data_blocks = sb_block_count(rs) - skipped - 1 - sb_bmap_nr(rs) -
(!is_reiserfs_jr(rs) ? sb_jp_journal_size(rs) + 1 : sb_reserved_for_journal(rs)) -
sb_free_blocks(rs);
printk ("Busy blocks (skipped %d, bitmaps - %d, journal (or reserved) blocks - %d\n"
"1 super block, %d data blocks\n",
skipped, sb_bmap_nr(rs), (!is_reiserfs_jr(rs) ? (sb_jp_journal_size(rs) + 1) :
(!is_reiserfs_jr(rs) ? sb_jp_journal_size(rs) +
1 : sb_reserved_for_journal(rs)) - sb_free_blocks(rs);
printk
("Busy blocks (skipped %d, bitmaps - %d, journal (or reserved) blocks - %d\n"
"1 super block, %d data blocks\n", skipped, sb_bmap_nr(rs),
(!is_reiserfs_jr(rs) ? (sb_jp_journal_size(rs) + 1) :
sb_reserved_for_journal(rs)), data_blocks);
printk("Root block %u\n", sb_root_block(rs));
printk("Journal block (first) %d\n", sb_jp_journal_1st_block(rs));
@ -546,13 +550,12 @@ static int print_desc_block (struct buffer_head * bh)
desc = (struct reiserfs_journal_desc *)(bh->b_data);
printk("Desc block %llu (j_trans_id %d, j_mount_id %d, j_len %d)",
(unsigned long long)bh->b_blocknr, get_desc_trans_id (desc), get_desc_mount_id (desc),
get_desc_trans_len (desc));
(unsigned long long)bh->b_blocknr, get_desc_trans_id(desc),
get_desc_mount_id(desc), get_desc_trans_len(desc));
return 0;
}
void print_block(struct buffer_head *bh, ...) //int print_mode, int first, int last)
{
va_list args;
@ -572,11 +575,11 @@ void print_block (struct buffer_head * bh, ...)//int print_mode, int first, int
if (print_internal(bh, first, last))
if (print_super_block(bh))
if (print_desc_block(bh))
printk ("Block %llu contains unformatted data\n", (unsigned long long)bh->b_blocknr);
printk
("Block %llu contains unformatted data\n",
(unsigned long long)bh->b_blocknr);
}
static char print_tb_buf[2048];
/* this stores initial state of tree balance in the print_tb_buf */
@ -595,11 +598,15 @@ void store_print_tb (struct tree_balance * tb)
"=====================================================================\n"
"* h * S * L * R * F * FL * FR * CFL * CFR *\n",
REISERFS_SB(tb->tb_sb)->s_do_balance,
tb->tb_mode, PATH_LAST_POSITION (tb->tb_path), tb->tb_path->pos_in_item);
tb->tb_mode, PATH_LAST_POSITION(tb->tb_path),
tb->tb_path->pos_in_item);
for (h = 0; h < sizeof(tb->insert_size) / sizeof (tb->insert_size[0]); h ++) {
if (PATH_H_PATH_OFFSET (tb->tb_path, h) <= tb->tb_path->path_length &&
PATH_H_PATH_OFFSET (tb->tb_path, h) > ILLEGAL_PATH_ELEMENT_OFFSET) {
for (h = 0; h < sizeof(tb->insert_size) / sizeof(tb->insert_size[0]);
h++) {
if (PATH_H_PATH_OFFSET(tb->tb_path, h) <=
tb->tb_path->path_length
&& PATH_H_PATH_OFFSET(tb->tb_path,
h) > ILLEGAL_PATH_ELEMENT_OFFSET) {
tbSh = PATH_H_PBUFFER(tb->tb_path, h);
tbFh = PATH_H_PPARENT(tb->tb_path, h);
} else {
@ -616,18 +623,24 @@ void store_print_tb (struct tree_balance * tb)
(tb->R[h]) ? (long long)(tb->R[h]->b_blocknr) : (-1LL),
(tb->R[h]) ? atomic_read(&(tb->R[h]->b_count)) : -1,
(tbFh) ? (long long)(tbFh->b_blocknr) : (-1LL),
(tb->FL[h]) ? (long long)(tb->FL[h]->b_blocknr):(-1LL),
(tb->FR[h]) ? (long long)(tb->FR[h]->b_blocknr):(-1LL),
(tb->CFL[h]) ? (long long)(tb->CFL[h]->b_blocknr):(-1LL),
(tb->CFR[h]) ? (long long)(tb->CFR[h]->b_blocknr):(-1LL));
(tb->FL[h]) ? (long long)(tb->FL[h]->
b_blocknr) : (-1LL),
(tb->FR[h]) ? (long long)(tb->FR[h]->
b_blocknr) : (-1LL),
(tb->CFL[h]) ? (long long)(tb->CFL[h]->
b_blocknr) : (-1LL),
(tb->CFR[h]) ? (long long)(tb->CFR[h]->
b_blocknr) : (-1LL));
}
sprintf(print_tb_buf + strlen(print_tb_buf),
"=====================================================================\n"
"* h * size * ln * lb * rn * rb * blkn * s0 * s1 * s1b * s2 * s2b * curb * lk * rk *\n"
"* 0 * %4d * %2d * %2d * %2d * %2d * %4d * %2d * %2d * %3d * %2d * %3d * %4d * %2d * %2d *\n",
tb->insert_size[0], tb->lnum[0], tb->lbytes, tb->rnum[0],tb->rbytes, tb->blknum[0],
tb->s0num, tb->s1num,tb->s1bytes, tb->s2num, tb->s2bytes, tb->cur_blknum, tb->lkey[0], tb->rkey[0]);
tb->insert_size[0], tb->lnum[0], tb->lbytes, tb->rnum[0],
tb->rbytes, tb->blknum[0], tb->s0num, tb->s1num, tb->s1bytes,
tb->s2num, tb->s2bytes, tb->cur_blknum, tb->lkey[0],
tb->rkey[0]);
/* this prints balance parameters for non-leaf levels */
h = 0;
@ -635,7 +648,8 @@ void store_print_tb (struct tree_balance * tb)
h++;
sprintf(print_tb_buf + strlen(print_tb_buf),
"* %d * %4d * %2d * * %2d * * %2d *\n",
h, tb->insert_size[h], tb->lnum[h], tb->rnum[h], tb->blknum[h]);
h, tb->insert_size[h], tb->lnum[h], tb->rnum[h],
tb->blknum[h]);
} while (tb->insert_size[h]);
sprintf(print_tb_buf + strlen(print_tb_buf),
@ -646,9 +660,13 @@ void store_print_tb (struct tree_balance * tb)
h = 0;
for (i = 0; i < sizeof(tb->FEB) / sizeof(tb->FEB[0]); i++)
sprintf(print_tb_buf + strlen(print_tb_buf),
"%p (%llu %d)%s", tb->FEB[i], tb->FEB[i] ? (unsigned long long)tb->FEB[i]->b_blocknr : 0ULL,
"%p (%llu %d)%s", tb->FEB[i],
tb->FEB[i] ? (unsigned long long)tb->FEB[i]->
b_blocknr : 0ULL,
tb->FEB[i] ? atomic_read(&(tb->FEB[i]->b_count)) : 0,
(i == sizeof (tb->FEB) / sizeof (tb->FEB[0]) - 1) ? "\n" : ", ");
(i ==
sizeof(tb->FEB) / sizeof(tb->FEB[0]) -
1) ? "\n" : ", ");
sprintf(print_tb_buf + strlen(print_tb_buf),
"======================== the end ====================================\n");
@ -667,10 +685,13 @@ static void check_leaf_block_head (struct buffer_head * bh)
blkh = B_BLK_HEAD(bh);
nr = blkh_nr_item(blkh);
if (nr > (bh->b_size - BLKH_SIZE) / IH_SIZE)
reiserfs_panic (NULL, "vs-6010: check_leaf_block_head: invalid item number %z", bh);
if ( blkh_free_space(blkh) >
bh->b_size - BLKH_SIZE - IH_SIZE * nr )
reiserfs_panic (NULL, "vs-6020: check_leaf_block_head: invalid free space %z", bh);
reiserfs_panic(NULL,
"vs-6010: check_leaf_block_head: invalid item number %z",
bh);
if (blkh_free_space(blkh) > bh->b_size - BLKH_SIZE - IH_SIZE * nr)
reiserfs_panic(NULL,
"vs-6020: check_leaf_block_head: invalid free space %z",
bh);
}
@ -680,18 +701,24 @@ static void check_internal_block_head (struct buffer_head * bh)
blkh = B_BLK_HEAD(bh);
if (!(B_LEVEL(bh) > DISK_LEAF_NODE_LEVEL && B_LEVEL(bh) <= MAX_HEIGHT))
reiserfs_panic (NULL, "vs-6025: check_internal_block_head: invalid level %z", bh);
reiserfs_panic(NULL,
"vs-6025: check_internal_block_head: invalid level %z",
bh);
if (B_NR_ITEMS(bh) > (bh->b_size - BLKH_SIZE) / IH_SIZE)
reiserfs_panic (NULL, "vs-6030: check_internal_block_head: invalid item number %z", bh);
reiserfs_panic(NULL,
"vs-6030: check_internal_block_head: invalid item number %z",
bh);
if (B_FREE_SPACE(bh) !=
bh->b_size - BLKH_SIZE - KEY_SIZE * B_NR_ITEMS (bh) - DC_SIZE * (B_NR_ITEMS (bh) + 1))
reiserfs_panic (NULL, "vs-6040: check_internal_block_head: invalid free space %z", bh);
bh->b_size - BLKH_SIZE - KEY_SIZE * B_NR_ITEMS(bh) -
DC_SIZE * (B_NR_ITEMS(bh) + 1))
reiserfs_panic(NULL,
"vs-6040: check_internal_block_head: invalid free space %z",
bh);
}
void check_leaf(struct buffer_head *bh)
{
int i;
@ -704,7 +731,6 @@ void check_leaf (struct buffer_head * bh)
op_check_item(ih, B_I_PITEM(bh, ih));
}
void check_internal(struct buffer_head *bh)
{
if (!bh)
@ -712,7 +738,6 @@ void check_internal (struct buffer_head * bh)
check_internal_block_head(bh);
}
void print_statistics(struct super_block *s)
{

View file

@ -42,8 +42,7 @@ static int show_version(struct seq_file *m, struct super_block *sb)
format = "unknown";
}
seq_printf(m, "%s format\twith checks %s\n",
format,
seq_printf(m, "%s format\twith checks %s\n", format,
#if defined( CONFIG_REISERFS_CHECK )
"on"
#else
@ -102,23 +101,18 @@ static int show_super(struct seq_file *m, struct super_block *sb)
"s_indirect2direct: \t%i\n"
"\n"
"max_hash_collisions: \t%i\n"
"breads: \t%lu\n"
"bread_misses: \t%lu\n"
"search_by_key: \t%lu\n"
"search_by_key_fs_changed: \t%lu\n"
"search_by_key_restarted: \t%lu\n"
"insert_item_restarted: \t%lu\n"
"paste_into_item_restarted: \t%lu\n"
"cut_from_item_restarted: \t%lu\n"
"delete_solid_item_restarted: \t%lu\n"
"delete_item_restarted: \t%lu\n"
"leaked_oid: \t%lu\n"
"leaves_removable: \t%lu\n",
SF(s_mount_state) == REISERFS_VALID_FS ?
"REISERFS_VALID_FS" : "REISERFS_ERROR_FS",
reiserfs_r5_hash(sb) ? "FORCE_R5 " : "",
@ -126,40 +120,26 @@ static int show_super(struct seq_file *m, struct super_block *sb)
reiserfs_tea_hash(sb) ? "FORCE_TEA " : "",
reiserfs_hash_detect(sb) ? "DETECT_HASH " : "",
reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ",
reiserfs_no_unhashed_relocation( sb ) ? "NO_UNHASHED_RELOCATION " : "",
reiserfs_no_unhashed_relocation(sb) ?
"NO_UNHASHED_RELOCATION " : "",
reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "",
reiserfs_test4(sb) ? "TEST4 " : "",
have_large_tails( sb ) ? "TAILS " : have_small_tails(sb)?"SMALL_TAILS ":"NO_TAILS ",
have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ?
"SMALL_TAILS " : "NO_TAILS ",
replay_only(sb) ? "REPLAY_ONLY " : "",
convert_reiserfs(sb) ? "CONV " : "",
atomic_read( &r -> s_generation_counter ),
SF( s_kmallocs ),
SF( s_disk_reads ),
SF( s_disk_writes ),
SF( s_fix_nodes ),
SF( s_do_balance ),
SF( s_unneeded_left_neighbor ),
SF( s_good_search_by_key_reada ),
SF( s_bmaps ),
SF( s_bmaps_without_search ),
SF( s_direct2indirect ),
SF( s_indirect2direct ),
SFP( max_hash_collisions ),
SFP( breads ),
SFP( bread_miss ),
SFP( search_by_key ),
SFP( search_by_key_fs_changed ),
SFP( search_by_key_restarted ),
SFP( insert_item_restarted ),
SFP( paste_into_item_restarted ),
atomic_read(&r->s_generation_counter), SF(s_kmallocs),
SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
SF(s_do_balance), SF(s_unneeded_left_neighbor),
SF(s_good_search_by_key_reada), SF(s_bmaps),
SF(s_bmaps_without_search), SF(s_direct2indirect),
SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads),
SFP(bread_miss), SFP(search_by_key),
SFP(search_by_key_fs_changed), SFP(search_by_key_restarted),
SFP(insert_item_restarted), SFP(paste_into_item_restarted),
SFP(cut_from_item_restarted),
SFP( delete_solid_item_restarted ),
SFP( delete_item_restarted ),
SFP( leaked_oid ),
SFP( leaves_removable ) );
SFP(delete_solid_item_restarted), SFP(delete_item_restarted),
SFP(leaked_oid), SFP(leaves_removable));
return 0;
}
@ -182,12 +162,7 @@ static int show_per_level(struct seq_file *m, struct super_block *sb)
" lbytes"
" rbytes"
" get_neig"
" get_neig_res"
" need_l_neig"
" need_r_neig"
"\n"
);
" get_neig_res" " need_l_neig" " need_r_neig" "\n");
for (level = 0; level < MAX_HEIGHT; ++level) {
seq_printf(m, "%i\t"
@ -221,8 +196,7 @@ static int show_per_level(struct seq_file *m, struct super_block *sb)
SFPL(rbytes),
SFPL(get_neighbors),
SFPL(get_neighbors_restart),
SFPL( need_l_neighbor ),
SFPL( need_r_neighbor )
SFPL(need_l_neighbor), SFPL(need_r_neighbor)
);
}
return 0;
@ -255,8 +229,7 @@ static int show_bitmap(struct seq_file *m, struct super_block *sb)
SFPF(bmap),
SFPF(retry),
SFPF(stolen),
SFPF( in_journal_hint ),
SFPF( in_journal_nohint ) );
SFPF(in_journal_hint), SFPF(in_journal_nohint));
return 0;
}
@ -283,7 +256,6 @@ static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
"version: \t%i\n"
"flags: \t%x[%s]\n"
"reserved_for_journal: \t%i\n",
DFL(s_block_count),
DFL(s_free_blocks),
DFL(s_root_block),
@ -299,11 +271,8 @@ static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
(hash_code == UNSET_HASH) ? "unset" : "unknown",
DF(s_tree_height),
DF(s_bmap_nr),
DF( s_version ),
flags,
( flags & reiserfs_attrs_cleared )
? "attrs_cleared" : "",
DF (s_reserved_for_journal));
DF(s_version), flags, (flags & reiserfs_attrs_cleared)
? "attrs_cleared" : "", DF(s_reserved_for_journal));
return 0;
}
@ -334,8 +303,7 @@ static int show_oidmap(struct seq_file *m, struct super_block *sb)
#endif
seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n",
mapsize,
mapsize, le16_to_cpu( rs -> s_v1.s_oid_maxsize ),
total_used);
mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used);
return 0;
}
@ -346,7 +314,6 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
struct journal_params *jp = &rs->s_v1.s_journal;
char b[BDEVNAME_SIZE];
seq_printf(m, /* on-disk fields */
"jp_journal_1st_block: \t%i\n"
"jp_journal_dev: \t%s[%x]\n"
@ -373,9 +340,7 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
"j_must_wait: \t%i\n"
"j_next_full_flush: \t%i\n"
"j_next_async_flush: \t%i\n"
"j_cnode_used: \t%i\n"
"j_cnode_free: \t%i\n"
"\n"
"j_cnode_used: \t%i\n" "j_cnode_free: \t%i\n" "\n"
/* reiserfs_proc_info_data_t.journal fields */
"in_journal: \t%12lu\n"
"in_journal_bitmap: \t%12lu\n"
@ -391,7 +356,6 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
"restore_prepared: \t%12lu\n"
"prepare: \t%12lu\n"
"prepare_retry: \t%12lu\n",
DJP(jp_journal_1st_block),
bdevname(SB_JOURNAL(sb)->j_dev_bd, b),
DJP(jp_journal_dev),
@ -401,7 +365,6 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
DJP(jp_journal_max_batch),
SB_JOURNAL(sb)->j_max_commit_age,
DJP(jp_journal_max_trans_age),
JF(j_1st_reserved_block),
JF(j_state),
JF(j_trans_id),
@ -420,7 +383,6 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
JF(j_next_async_flush),
JF(j_cnode_used),
JF(j_cnode_free),
SFPJ(in_journal),
SFPJ(in_journal_bitmap),
SFPJ(in_journal_reusable),
@ -432,9 +394,7 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
SFPJ(mark_dirty),
SFPJ(mark_dirty_already),
SFPJ(mark_dirty_notjournal),
SFPJ( restore_prepared ),
SFPJ( prepare ),
SFPJ( prepare_retry )
SFPJ(restore_prepared), SFPJ(prepare), SFPJ(prepare_retry)
);
return 0;
}
@ -535,7 +495,8 @@ static void add_file(struct super_block *sb, char *name,
int reiserfs_proc_info_init(struct super_block *sb)
{
spin_lock_init(&__PINFO(sb).lock);
REISERFS_SB(sb)->procdir = proc_mkdir(reiserfs_bdevname (sb), proc_info_root);
REISERFS_SB(sb)->procdir =
proc_mkdir(reiserfs_bdevname(sb), proc_info_root);
if (REISERFS_SB(sb)->procdir) {
REISERFS_SB(sb)->procdir->owner = THIS_MODULE;
REISERFS_SB(sb)->procdir->data = sb;
@ -616,22 +577,40 @@ int reiserfs_proc_info_global_done( void )
/* REISERFS_PROC_INFO */
#else
int reiserfs_proc_info_init( struct super_block *sb ) { return 0; }
int reiserfs_proc_info_done( struct super_block *sb ) { return 0; }
int reiserfs_proc_info_init(struct super_block *sb)
{
return 0;
}
int reiserfs_proc_info_done(struct super_block *sb)
{
return 0;
}
struct proc_dir_entry *reiserfs_proc_register_global(char *name,
read_proc_t * func)
{ return NULL; }
{
return NULL;
}
void reiserfs_proc_unregister_global( const char *name ) {;}
void reiserfs_proc_unregister_global(const char *name)
{;
}
int reiserfs_proc_info_global_init( void ) { return 0; }
int reiserfs_proc_info_global_done( void ) { return 0; }
int reiserfs_proc_info_global_init(void)
{
return 0;
}
int reiserfs_proc_info_global_done(void)
{
return 0;
}
int reiserfs_global_version_in_proc(char *buffer, char **start,
off_t offset,
int count, int *eof, void *data)
{ return 0; }
{
return 0;
}
/* REISERFS_PROC_INFO */
#endif

View file

@ -54,13 +54,13 @@ int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
* cannot be resized */
if (SB_BUFFER_WITH_SB(s)->b_blocknr * SB_BUFFER_WITH_SB(s)->b_size
!= REISERFS_DISK_OFFSET_IN_BYTES) {
printk("reiserfs_resize: unable to resize a reiserfs without distributed bitmap (fs version < 3.5.12)\n");
printk
("reiserfs_resize: unable to resize a reiserfs without distributed bitmap (fs version < 3.5.12)\n");
return -ENOTSUPP;
}
/* count used bits in last bitmap block */
block_r = SB_BLOCK_COUNT(s) -
(SB_BMAP_NR(s) - 1) * s->s_blocksize * 8;
block_r = SB_BLOCK_COUNT(s) - (SB_BMAP_NR(s) - 1) * s->s_blocksize * 8;
/* count bitmap blocks in new fs */
bmap_nr_new = block_count_new / (s->s_blocksize * 8);
@ -78,7 +78,8 @@ int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
if (bmap_nr_new > bmap_nr) {
/* reallocate journal bitmaps */
if (reiserfs_allocate_list_bitmaps(s, jbitmap, bmap_nr_new) < 0) {
printk("reiserfs_resize: unable to allocate memory for journal bitmaps\n");
printk
("reiserfs_resize: unable to allocate memory for journal bitmaps\n");
unlock_super(s);
return -ENOMEM;
}
@ -90,7 +91,8 @@ int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
** both shrinking and expanding the FS.
*/
copy_size = bmap_nr_new < bmap_nr ? bmap_nr_new : bmap_nr;
copy_size = copy_size * sizeof(struct reiserfs_list_bitmap_node *) ;
copy_size =
copy_size * sizeof(struct reiserfs_list_bitmap_node *);
for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
struct reiserfs_bitmap_node **node_tmp;
jb = SB_JOURNAL(s)->j_list_bitmap + i;
@ -107,14 +109,16 @@ int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
/* allocate additional bitmap blocks, reallocate array of bitmap
* block pointers */
bitmap = vmalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
bitmap =
vmalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
if (!bitmap) {
/* Journal bitmaps are still supersized, but the memory isn't
* leaked, so I guess it's ok */
printk("reiserfs_resize: unable to allocate memory.\n");
return -ENOMEM;
}
memset (bitmap, 0, sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
memset(bitmap, 0,
sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
for (i = 0; i < bmap_nr; i++)
bitmap[i] = old_bitmap[i];
@ -150,7 +154,8 @@ int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
reiserfs_prepare_for_journal(s, SB_AP_BITMAP(s)[bmap_nr - 1].bh, 1);
for (i = block_r; i < s->s_blocksize * 8; i++)
reiserfs_test_and_clear_le_bit(i,
SB_AP_BITMAP(s)[bmap_nr - 1].bh->b_data);
SB_AP_BITMAP(s)[bmap_nr -
1].bh->b_data);
SB_AP_BITMAP(s)[bmap_nr - 1].free_count += s->s_blocksize * 8 - block_r;
if (!SB_AP_BITMAP(s)[bmap_nr - 1].first_zero_hint)
SB_AP_BITMAP(s)[bmap_nr - 1].first_zero_hint = block_r;
@ -160,17 +165,21 @@ int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
reiserfs_prepare_for_journal(s, SB_AP_BITMAP(s)[bmap_nr_new - 1].bh, 1);
for (i = block_r_new; i < s->s_blocksize * 8; i++)
reiserfs_test_and_set_le_bit(i,
SB_AP_BITMAP(s)[bmap_nr_new - 1].bh->b_data);
SB_AP_BITMAP(s)[bmap_nr_new -
1].bh->b_data);
journal_mark_dirty(&th, s, SB_AP_BITMAP(s)[bmap_nr_new - 1].bh);
SB_AP_BITMAP(s)[bmap_nr_new - 1].free_count -= s->s_blocksize * 8 - block_r_new;
SB_AP_BITMAP(s)[bmap_nr_new - 1].free_count -=
s->s_blocksize * 8 - block_r_new;
/* Extreme case where last bitmap is the only valid block in itself. */
if (!SB_AP_BITMAP(s)[bmap_nr_new - 1].free_count)
SB_AP_BITMAP(s)[bmap_nr_new - 1].first_zero_hint = 0;
/* update super */
reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
free_blocks = SB_FREE_BLOCKS(s);
PUT_SB_FREE_BLOCKS(s, free_blocks + (block_count_new - block_count - (bmap_nr_new - bmap_nr)));
PUT_SB_FREE_BLOCKS(s,
free_blocks + (block_count_new - block_count -
(bmap_nr_new - bmap_nr)));
PUT_SB_BLOCK_COUNT(s, block_count_new);
PUT_SB_BMAP_NR(s, bmap_nr_new);
s->s_dirt = 1;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -11,7 +11,6 @@
/* access to tail : when one is going to read tail it must make sure, that is not running.
direct2indirect and indirect2direct can not run concurrently */
/* Converts direct items to an unformatted node. Panics if file has no
tail. -ENOSPC if no disk space for conversion */
/* path points to first direct item of the file regarless of how many of
@ -28,8 +27,7 @@ int direct2indirect (struct reiserfs_transaction_handle *th, struct inode * inod
converted item. */
struct item_head ind_ih; /* new indirect item to be inserted or
key of unfm pointer to be pasted */
int n_blk_size,
n_retval; /* returned value for reiserfs_insert_item and clones */
int n_blk_size, n_retval; /* returned value for reiserfs_insert_item and clones */
unp_t unfm_ptr; /* Handle on an unformatted node
that will be inserted in the
tree. */
@ -67,23 +65,24 @@ int direct2indirect (struct reiserfs_transaction_handle *th, struct inode * inod
set_ih_free_space(&ind_ih, 0); /* delete at nearest future */
put_ih_item_len(&ind_ih, UNFM_P_SIZE);
PATH_LAST_POSITION(path)++;
n_retval = reiserfs_insert_item (th, path, &end_key, &ind_ih, inode,
n_retval =
reiserfs_insert_item(th, path, &end_key, &ind_ih, inode,
(char *)&unfm_ptr);
} else {
/* Paste into last indirect item of an object. */
n_retval = reiserfs_paste_into_item(th, path, &end_key, inode,
(char *)&unfm_ptr, UNFM_P_SIZE);
(char *)&unfm_ptr,
UNFM_P_SIZE);
}
if (n_retval) {
return n_retval;
}
// note: from here there are two keys which have matching first
// three key components. They only differ by the fourth one.
/* Set the key to search for the direct items of the file */
make_cpu_key (&end_key, inode, max_reiserfs_offset (inode), TYPE_DIRECT, 4);
make_cpu_key(&end_key, inode, max_reiserfs_offset(inode), TYPE_DIRECT,
4);
/* Move bytes from the direct items to the new unformatted node
and delete them. */
@ -92,8 +91,10 @@ int direct2indirect (struct reiserfs_transaction_handle *th, struct inode * inod
/* end_key.k_offset is set so, that we will always have found
last item of the file */
if ( search_for_position_by_key (sb, &end_key, path) == POSITION_FOUND )
reiserfs_panic (sb, "PAP-14050: direct2indirect: "
if (search_for_position_by_key(sb, &end_key, path) ==
POSITION_FOUND)
reiserfs_panic(sb,
"PAP-14050: direct2indirect: "
"direct item (%K) not found", &end_key);
p_le_ih = PATH_PITEM_HEAD(path);
RFALSE(!is_direct_le_ih(p_le_ih),
@ -108,7 +109,8 @@ int direct2indirect (struct reiserfs_transaction_handle *th, struct inode * inod
** Special case: unbh->b_page will be NULL if we are coming through
** DIRECT_IO handler here.
*/
if (!unbh->b_page || buffer_uptodate(unbh) || PageUptodate(unbh->b_page)) {
if (!unbh->b_page || buffer_uptodate(unbh)
|| PageUptodate(unbh->b_page)) {
up_to_date_bh = NULL;
} else {
up_to_date_bh = unbh;
@ -126,7 +128,8 @@ int direct2indirect (struct reiserfs_transaction_handle *th, struct inode * inod
** out the unused part of the block (it was not up to date before)
*/
if (up_to_date_bh) {
unsigned pgoff = (tail_offset + total_tail - 1) & (PAGE_CACHE_SIZE - 1);
unsigned pgoff =
(tail_offset + total_tail - 1) & (PAGE_CACHE_SIZE - 1);
char *kaddr = kmap_atomic(up_to_date_bh->b_page, KM_USER0);
memset(kaddr + pgoff, 0, n_blk_size - total_tail);
kunmap_atomic(kaddr, KM_USER0);
@ -137,9 +140,9 @@ int direct2indirect (struct reiserfs_transaction_handle *th, struct inode * inod
return 0;
}
/* stolen from fs/buffer.c */
void reiserfs_unmap_buffer(struct buffer_head *bh) {
void reiserfs_unmap_buffer(struct buffer_head *bh)
{
lock_buffer(bh);
if (buffer_journaled(bh) || buffer_journal_dirty(bh)) {
BUG();
@ -169,10 +172,7 @@ void reiserfs_unmap_buffer(struct buffer_head *bh) {
what we expect from it (number of cut bytes). But when tail remains
in the unformatted node, we set mode to SKIP_BALANCING and unlock
inode */
int indirect2direct (struct reiserfs_transaction_handle *th,
struct inode * p_s_inode,
struct page *page,
struct path * p_s_path, /* path to the indirect item. */
int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *p_s_inode, struct page *page, struct path *p_s_path, /* path to the indirect item. */
const struct cpu_key *p_s_item_key, /* Key to look for unformatted node pointer to be cut. */
loff_t n_new_file_size, /* New file size. */
char *p_c_mode)
@ -200,7 +200,9 @@ int indirect2direct (struct reiserfs_transaction_handle *th,
else
round_tail_len = tail_len;
pos = le_ih_k_offset (&s_ih) - 1 + (ih_item_len(&s_ih) / UNFM_P_SIZE - 1) * p_s_sb->s_blocksize;
pos =
le_ih_k_offset(&s_ih) - 1 + (ih_item_len(&s_ih) / UNFM_P_SIZE -
1) * p_s_sb->s_blocksize;
pos1 = pos;
// we are protected by i_sem. The tail can not disapper, not
@ -211,23 +213,27 @@ int indirect2direct (struct reiserfs_transaction_handle *th,
if (path_changed(&s_ih, p_s_path)) {
/* re-search indirect item */
if ( search_for_position_by_key (p_s_sb, p_s_item_key, p_s_path) == POSITION_NOT_FOUND )
reiserfs_panic(p_s_sb, "PAP-5520: indirect2direct: "
"item to be converted %K does not exist", p_s_item_key);
if (search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path)
== POSITION_NOT_FOUND)
reiserfs_panic(p_s_sb,
"PAP-5520: indirect2direct: "
"item to be converted %K does not exist",
p_s_item_key);
copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
#ifdef CONFIG_REISERFS_CHECK
pos = le_ih_k_offset(&s_ih) - 1 +
(ih_item_len(&s_ih) / UNFM_P_SIZE - 1) * p_s_sb->s_blocksize;
(ih_item_len(&s_ih) / UNFM_P_SIZE -
1) * p_s_sb->s_blocksize;
if (pos != pos1)
reiserfs_panic(p_s_sb, "vs-5530: indirect2direct: "
"tail position changed while we were reading it");
#endif
}
/* Set direct item header to insert. */
make_le_item_head (&s_ih, NULL, get_inode_item_key_version (p_s_inode), pos1 + 1,
TYPE_DIRECT, round_tail_len, 0xffff/*ih_free_space*/);
make_le_item_head(&s_ih, NULL, get_inode_item_key_version(p_s_inode),
pos1 + 1, TYPE_DIRECT, round_tail_len,
0xffff /*ih_free_space */ );
/* we want a pointer to the first byte of the tail in the page.
** the page was locked and this part of the page was up to date when
@ -271,6 +277,3 @@ int indirect2direct (struct reiserfs_transaction_handle *th,
return n_block_size - round_tail_len;
}

View file

@ -51,10 +51,10 @@
#define PRIVROOT_NAME ".reiserfs_priv"
#define XAROOT_NAME "xattrs"
static struct reiserfs_xattr_handler *find_xattr_handler_prefix (const char *prefix);
static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
*prefix);
static struct dentry *
create_xa_root (struct super_block *sb)
static struct dentry *create_xa_root(struct super_block *sb)
{
struct dentry *privroot = dget(REISERFS_SB(sb)->priv_root);
struct dentry *xaroot;
@ -69,7 +69,9 @@ create_xa_root (struct super_block *sb)
} else if (!xaroot->d_inode) {
int err;
down(&privroot->d_inode->i_sem);
err = privroot->d_inode->i_op->mkdir (privroot->d_inode, xaroot, 0700);
err =
privroot->d_inode->i_op->mkdir(privroot->d_inode, xaroot,
0700);
up(&privroot->d_inode->i_sem);
if (err) {
@ -89,8 +91,7 @@ out:
* If the xa root doesn't exist yet, the dentry will be returned without
* an associated inode. This dentry can be used with ->mkdir to create
* the xa directory. */
static struct dentry *
__get_xa_root (struct super_block *s)
static struct dentry *__get_xa_root(struct super_block *s)
{
struct dentry *privroot = dget(REISERFS_SB(s)->priv_root);
struct dentry *xaroot = NULL;
@ -119,8 +120,7 @@ out:
* Otherwise, we attempt to retreive it from disk. It may also return
* a pointer-encoded error.
*/
static inline struct dentry *
get_xa_root (struct super_block *s)
static inline struct dentry *get_xa_root(struct super_block *s)
{
struct dentry *dentry = dget(REISERFS_SB(s)->xattr_root);
@ -133,8 +133,7 @@ get_xa_root (struct super_block *s)
/* Opens the directory corresponding to the inode's extended attribute store.
* If flags allow, the tree to the directory may be created. If creation is
* prohibited, -ENODATA is returned. */
static struct dentry *
open_xa_dir (const struct inode *inode, int flags)
static struct dentry *open_xa_dir(const struct inode *inode, int flags)
{
struct dentry *xaroot, *xadir;
char namebuf[17];
@ -169,7 +168,9 @@ open_xa_dir (const struct inode *inode, int flags)
/* Although there is nothing else trying to create this directory,
* another directory with the same hash may be created, so we need
* to protect against that */
err = xaroot->d_inode->i_op->mkdir (xaroot->d_inode, xadir, 0700);
err =
xaroot->d_inode->i_op->mkdir(xaroot->d_inode, xadir,
0700);
if (err) {
dput(xaroot);
dput(xadir);
@ -190,8 +191,8 @@ open_xa_dir (const struct inode *inode, int flags)
/* Returns a dentry corresponding to a specific extended attribute file
* for the inode. If flags allow, the file is created. Otherwise, a
* valid or negative dentry, or an error is returned. */
static struct dentry *
get_xa_file_dentry (const struct inode *inode, const char *name, int flags)
static struct dentry *get_xa_file_dentry(const struct inode *inode,
const char *name, int flags)
{
struct dentry *xadir, *xafile;
int err = 0;
@ -237,10 +238,9 @@ out:
return xafile;
}
/* Opens a file pointer to the attribute associated with inode */
static struct file *
open_xa_file (const struct inode *inode, const char *name, int flags)
static struct file *open_xa_file(const struct inode *inode, const char *name,
int flags)
{
struct dentry *xafile;
struct file *fp;
@ -259,7 +259,6 @@ open_xa_file (const struct inode *inode, const char *name, int flags)
return fp;
}
/*
* this is very similar to fs/reiserfs/dir.c:reiserfs_readdir, but
* we need to drop the path before calling the filldir struct. That
@ -292,7 +291,6 @@ static int __xattr_readdir(struct file * filp, void * dirent, filldir_t filldir)
ino_t d_ino;
struct reiserfs_dir_entry de;
/* form key for search the next directory entry using f_pos field of
file structure */
next_pos = max_reiserfs_offset(inode);
@ -303,7 +301,9 @@ research:
break;
make_cpu_key(&pos_key, inode, next_pos, TYPE_DIRENTRY, 3);
search_res = search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry, &de);
search_res =
search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
&de);
if (search_res == IO_ERROR) {
// FIXME: we could just skip part of directory which could
// not be read
@ -359,19 +359,24 @@ research:
/* Ignore the .reiserfs_priv entry */
if (reiserfs_xattrs(inode->i_sb) &&
!old_format_only(inode->i_sb) &&
deh_objectid (deh) == le32_to_cpu (INODE_PKEY(REISERFS_SB(inode->i_sb)->priv_root->d_inode)->k_objectid))
deh_objectid(deh) ==
le32_to_cpu(INODE_PKEY
(REISERFS_SB(inode->i_sb)->priv_root->d_inode)->
k_objectid))
continue;
if (d_reclen <= 32) {
local_buf = small_buf;
} else {
local_buf = reiserfs_kmalloc(d_reclen, GFP_NOFS, inode->i_sb) ;
local_buf =
reiserfs_kmalloc(d_reclen, GFP_NOFS, inode->i_sb);
if (!local_buf) {
pathrelse(&path_to_entry);
return -ENOMEM;
}
if (item_moved(&tmp_ih, &path_to_entry)) {
reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
reiserfs_kfree(local_buf, d_reclen,
inode->i_sb);
/* sigh, must retry. Do this same offset again */
next_pos = d_off;
@ -394,7 +399,8 @@ research:
if (filldir(dirent, local_buf, d_reclen, d_off, d_ino,
DT_UNKNOWN) < 0) {
if (local_buf != small_buf) {
reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
reiserfs_kfree(local_buf, d_reclen,
inode->i_sb);
}
goto end;
}
@ -435,17 +441,14 @@ out:
return res;
}
/* Internal operations on file data */
static inline void
reiserfs_put_page(struct page *page)
static inline void reiserfs_put_page(struct page *page)
{
kunmap(page);
page_cache_release(page);
}
static struct page *
reiserfs_get_page(struct inode *dir, unsigned long n)
static struct page *reiserfs_get_page(struct inode *dir, unsigned long n)
{
struct address_space *mapping = dir->i_mapping;
struct page *page;
@ -470,8 +473,7 @@ fail:
return ERR_PTR(-EIO);
}
static inline __u32
xattr_hash (const char *msg, int len)
static inline __u32 xattr_hash(const char *msg, int len)
{
return csum_partial(msg, len, 0);
}
@ -573,8 +575,10 @@ open_file:
if (!err) {
if (buffer)
memcpy(data + skip, buffer + buffer_pos, chunk);
err = mapping->a_ops->commit_write (fp, page, page_offset,
page_offset + chunk + skip);
err =
mapping->a_ops->commit_write(fp, page, page_offset,
page_offset + chunk +
skip);
}
unlock_page(page);
reiserfs_put_page(page);
@ -673,7 +677,8 @@ reiserfs_xattr_get (const struct inode *inode, const char *name, void *buffer,
if (rxh->h_magic != cpu_to_le32(REISERFS_XATTR_MAGIC)) {
unlock_page(page);
reiserfs_put_page(page);
reiserfs_warning (inode->i_sb, "Invalid magic for xattr (%s) "
reiserfs_warning(inode->i_sb,
"Invalid magic for xattr (%s) "
"associated with %k", name,
INODE_PKEY(inode));
err = -EIO;
@ -690,8 +695,10 @@ reiserfs_xattr_get (const struct inode *inode, const char *name, void *buffer,
}
err = isize - sizeof(struct reiserfs_xattr_header);
if (xattr_hash (buffer, isize - sizeof (struct reiserfs_xattr_header)) != hash) {
reiserfs_warning (inode->i_sb, "Invalid hash for xattr (%s) associated "
if (xattr_hash(buffer, isize - sizeof(struct reiserfs_xattr_header)) !=
hash) {
reiserfs_warning(inode->i_sb,
"Invalid hash for xattr (%s) associated "
"with %k", name, INODE_PKEY(inode));
err = -EIO;
}
@ -726,9 +733,12 @@ __reiserfs_xattr_del (struct dentry *xadir, const char *name, int namelen)
if (!is_reiserfs_priv_object(dentry->d_inode)) {
reiserfs_warning(dir->i_sb, "OID %08x [%.*s/%.*s] doesn't have "
"priv flag set [parent is %sset].",
le32_to_cpu (INODE_PKEY (dentry->d_inode)->k_objectid),
xadir->d_name.len, xadir->d_name.name, namelen, name,
is_reiserfs_priv_object (xadir->d_inode) ? "" : "not ");
le32_to_cpu(INODE_PKEY(dentry->d_inode)->
k_objectid), xadir->d_name.len,
xadir->d_name.name, namelen, name,
is_reiserfs_priv_object(xadir->
d_inode) ? "" :
"not ");
dput(dentry);
return -EIO;
}
@ -744,9 +754,7 @@ out:
return err;
}
int
reiserfs_xattr_del (struct inode *inode, const char *name)
int reiserfs_xattr_del(struct inode *inode, const char *name)
{
struct dentry *dir;
int err;
@ -787,8 +795,7 @@ reiserfs_delete_xattrs_filler (void *buf, const char *name, int namelen,
}
/* This is called w/ inode->i_sem downed */
int
reiserfs_delete_xattrs (struct inode *inode)
int reiserfs_delete_xattrs(struct inode *inode)
{
struct file *fp;
struct dentry *dir, *root;
@ -797,8 +804,7 @@ reiserfs_delete_xattrs (struct inode *inode)
/* Skip out, an xattr has no xattrs associated with it */
if (is_reiserfs_priv_object(inode) ||
get_inode_sd_version(inode) == STAT_DATA_V1 ||
!reiserfs_xattrs(inode->i_sb))
{
!reiserfs_xattrs(inode->i_sb)) {
return 0;
}
reiserfs_read_lock_xattrs(inode->i_sb);
@ -844,7 +850,8 @@ out_dir:
out:
if (!err)
REISERFS_I(inode)->i_flags = REISERFS_I(inode)->i_flags & ~i_has_xattr_dir;
REISERFS_I(inode)->i_flags =
REISERFS_I(inode)->i_flags & ~i_has_xattr_dir;
return err;
}
@ -879,8 +886,7 @@ reiserfs_chown_xattrs_filler (void *buf, const char *name, int namelen,
return err;
}
int
reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs)
int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
{
struct file *fp;
struct dentry *dir;
@ -891,8 +897,7 @@ reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs)
/* Skip out, an xattr has no xattrs associated with it */
if (is_reiserfs_priv_object(inode) ||
get_inode_sd_version(inode) == STAT_DATA_V1 ||
!reiserfs_xattrs(inode->i_sb))
{
!reiserfs_xattrs(inode->i_sb)) {
return 0;
}
reiserfs_read_lock_xattrs(inode->i_sb);
@ -938,7 +943,6 @@ out:
return err;
}
/* Actual operations that are exported to VFS-land */
/*
@ -964,7 +968,6 @@ reiserfs_getxattr (struct dentry *dentry, const char *name, void *buffer,
return err;
}
/*
* Inode operation setxattr()
*
@ -1008,8 +1011,7 @@ reiserfs_setxattr (struct dentry *dentry, const char *name, const void *value,
*
* dentry->d_inode->i_sem down
*/
int
reiserfs_removexattr (struct dentry *dentry, const char *name)
int reiserfs_removexattr(struct dentry *dentry, const char *name)
{
int err;
struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
@ -1045,7 +1047,6 @@ out:
return err;
}
/* This is what filldir will use:
* r_pos will always contain the amount of space required for the entire
* list. If r_pos becomes larger than r_size, we need more space and we
@ -1064,9 +1065,12 @@ reiserfs_listxattr_filler (void *buf, const char *name, int namelen,
{
struct reiserfs_listxattr_buf *b = (struct reiserfs_listxattr_buf *)buf;
int len = 0;
if (name[0] != '.' || (namelen != 1 && (name[1] != '.' || namelen != 2))) {
struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix (name);
if (!xah) return 0; /* Unsupported xattr name, skip it */
if (name[0] != '.'
|| (namelen != 1 && (name[1] != '.' || namelen != 2))) {
struct reiserfs_xattr_handler *xah =
find_xattr_handler_prefix(name);
if (!xah)
return 0; /* Unsupported xattr name, skip it */
/* We call ->list() twice because the operation isn't required to just
* return the name back - we want to make sure we have enough space */
@ -1084,13 +1088,13 @@ reiserfs_listxattr_filler (void *buf, const char *name, int namelen,
return 0;
}
/*
* Inode operation listxattr()
*
* Preliminary locking: we down dentry->d_inode->i_sem
*/
ssize_t
reiserfs_listxattr (struct dentry *dentry, char *buffer, size_t size)
ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
{
struct file *fp;
struct dentry *dir;
@ -1150,8 +1154,8 @@ out:
static struct list_head xattr_handlers = LIST_HEAD_INIT(xattr_handlers);
static DEFINE_RWLOCK(handler_lock);
static struct reiserfs_xattr_handler *
find_xattr_handler_prefix (const char *prefix)
static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
*prefix)
{
struct reiserfs_xattr_handler *xah = NULL;
struct list_head *p;
@ -1168,8 +1172,7 @@ find_xattr_handler_prefix (const char *prefix)
return xah;
}
static void
__unregister_handlers (void)
static void __unregister_handlers(void)
{
struct reiserfs_xattr_handler *xah;
struct list_head *p, *tmp;
@ -1184,8 +1187,7 @@ __unregister_handlers (void)
INIT_LIST_HEAD(&xattr_handlers);
}
int __init
reiserfs_xattr_register_handlers (void)
int __init reiserfs_xattr_register_handlers(void)
{
int err = 0;
struct reiserfs_xattr_handler *xah;
@ -1230,8 +1232,7 @@ reiserfs_xattr_register_handlers (void)
return err;
}
void
reiserfs_xattr_unregister_handlers (void)
void reiserfs_xattr_unregister_handlers(void)
{
write_lock(&handler_lock);
__unregister_handlers();
@ -1257,12 +1258,10 @@ static struct dentry_operations xattr_lookup_poison_ops = {
.d_compare = xattr_lookup_poison,
};
/* We need to take a copy of the mount flags since things like
* MS_RDONLY don't get set until *after* we're called.
* mount_flags != mount_options */
int
reiserfs_xattr_init (struct super_block *s, int mount_flags)
int reiserfs_xattr_init(struct super_block *s, int mount_flags)
{
int err = 0;
@ -1300,9 +1299,12 @@ reiserfs_xattr_init (struct super_block *s, int mount_flags)
}
if (dentry && dentry->d_inode)
reiserfs_warning (s, "Created %s on %s - reserved for "
"xattr storage.", PRIVROOT_NAME,
reiserfs_bdevname (inode->i_sb));
reiserfs_warning(s,
"Created %s on %s - reserved for "
"xattr storage.",
PRIVROOT_NAME,
reiserfs_bdevname
(inode->i_sb));
} else if (!dentry->d_inode) {
dput(dentry);
dentry = NULL;
@ -1437,8 +1439,7 @@ check_capabilities:
return -EACCES;
}
int
reiserfs_permission (struct inode *inode, int mask, struct nameidata *nd)
int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd)
{
return __reiserfs_permission(inode, mask, nd, 1);
}

View file

@ -9,7 +9,8 @@
#include <linux/reiserfs_acl.h>
#include <asm/uaccess.h>
static int reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl);
static int reiserfs_set_acl(struct inode *inode, int type,
struct posix_acl *acl);
static int
xattr_set_acl(struct inode *inode, int type, const void *value, size_t size)
@ -41,7 +42,6 @@ release_and_out:
return error;
}
static int
xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
{
@ -62,12 +62,10 @@ xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
return error;
}
/*
* Convert from filesystem to in-memory representation.
*/
static struct posix_acl *
posix_acl_from_disk(const void *value, size_t size)
static struct posix_acl *posix_acl_from_disk(const void *value, size_t size)
{
const char *end = (char *)value + size;
int n, count;
@ -90,8 +88,7 @@ posix_acl_from_disk(const void *value, size_t size)
if (!acl)
return ERR_PTR(-ENOMEM);
for (n = 0; n < count; n++) {
reiserfs_acl_entry *entry =
(reiserfs_acl_entry *)value;
reiserfs_acl_entry *entry = (reiserfs_acl_entry *) value;
if ((char *)value + sizeof(reiserfs_acl_entry_short) > end)
goto fail;
acl->a_entries[n].e_tag = le16_to_cpu(entry->e_tag);
@ -111,8 +108,7 @@ posix_acl_from_disk(const void *value, size_t size)
value = (char *)value + sizeof(reiserfs_acl_entry);
if ((char *)value > end)
goto fail;
acl->a_entries[n].e_id =
le32_to_cpu(entry->e_id);
acl->a_entries[n].e_id = le32_to_cpu(entry->e_id);
break;
default:
@ -131,8 +127,7 @@ fail:
/*
* Convert from in-memory to filesystem representation.
*/
static void *
posix_acl_to_disk(const struct posix_acl *acl, size_t *size)
static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
{
reiserfs_acl_header *ext_acl;
char *e;
@ -140,7 +135,9 @@ posix_acl_to_disk(const struct posix_acl *acl, size_t *size)
*size = reiserfs_acl_size(acl->a_count);
ext_acl = (reiserfs_acl_header *) kmalloc(sizeof(reiserfs_acl_header) +
acl->a_count * sizeof(reiserfs_acl_entry), GFP_NOFS);
acl->a_count *
sizeof(reiserfs_acl_entry),
GFP_NOFS);
if (!ext_acl)
return ERR_PTR(-ENOMEM);
ext_acl->a_version = cpu_to_le32(REISERFS_ACL_VERSION);
@ -152,8 +149,7 @@ posix_acl_to_disk(const struct posix_acl *acl, size_t *size)
switch (acl->a_entries[n].e_tag) {
case ACL_USER:
case ACL_GROUP:
entry->e_id =
cpu_to_le32(acl->a_entries[n].e_id);
entry->e_id = cpu_to_le32(acl->a_entries[n].e_id);
e += sizeof(reiserfs_acl_entry);
break;
@ -181,8 +177,7 @@ fail:
* inode->i_sem: down
* BKL held [before 2.5.x]
*/
struct posix_acl *
reiserfs_get_acl(struct inode *inode, int type)
struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
{
char *name, *value;
struct posix_acl *acl, **p_acl;
@ -321,7 +316,8 @@ reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
/* dir->i_sem: down,
* inode is new and not released into the wild yet */
int
reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct inode *inode)
reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry,
struct inode *inode)
{
struct posix_acl *acl;
int err = 0;
@ -370,7 +366,6 @@ reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct i
goto cleanup;
}
need_acl = posix_acl_create_masq(acl_copy, &mode);
if (need_acl >= 0) {
if (mode != inode->i_mode) {
@ -379,7 +374,9 @@ reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct i
/* If we need an ACL.. */
if (need_acl > 0) {
err = reiserfs_set_acl (inode, ACL_TYPE_ACCESS, acl_copy);
err =
reiserfs_set_acl(inode, ACL_TYPE_ACCESS,
acl_copy);
if (err)
goto cleanup_copy;
}
@ -400,12 +397,10 @@ apply_umask:
/* Looks up and caches the result of the default ACL.
* We do this so that we don't need to carry the xattr_sem into
* reiserfs_new_inode if we don't need to */
int
reiserfs_cache_default_acl (struct inode *inode)
int reiserfs_cache_default_acl(struct inode *inode)
{
int ret = 0;
if (reiserfs_posixacl (inode->i_sb) &&
!is_reiserfs_priv_object (inode)) {
if (reiserfs_posixacl(inode->i_sb) && !is_reiserfs_priv_object(inode)) {
struct posix_acl *acl;
reiserfs_read_lock_xattr_i(inode);
reiserfs_read_lock_xattrs(inode->i_sb);
@ -419,8 +414,7 @@ reiserfs_cache_default_acl (struct inode *inode)
return ret;
}
int
reiserfs_acl_chmod (struct inode *inode)
int reiserfs_acl_chmod(struct inode *inode)
{
struct posix_acl *acl, *clone;
int error;
@ -429,8 +423,7 @@ reiserfs_acl_chmod (struct inode *inode)
return -EOPNOTSUPP;
if (get_inode_sd_version(inode) == STAT_DATA_V1 ||
!reiserfs_posixacl(inode->i_sb))
{
!reiserfs_posixacl(inode->i_sb)) {
return 0;
}
@ -482,8 +475,7 @@ posix_acl_access_set(struct inode *inode, const char *name,
return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
}
static int
posix_acl_access_del (struct inode *inode, const char *name)
static int posix_acl_access_del(struct inode *inode, const char *name)
{
struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
struct posix_acl **acl = &reiserfs_i->i_acl_access;
@ -498,7 +490,8 @@ posix_acl_access_del (struct inode *inode, const char *name)
}
static int
posix_acl_access_list (struct inode *inode, const char *name, int namelen, char *out)
posix_acl_access_list(struct inode *inode, const char *name, int namelen,
char *out)
{
int len = namelen;
if (!reiserfs_posixacl(inode->i_sb))
@ -535,8 +528,7 @@ posix_acl_default_set(struct inode *inode, const char *name,
return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
}
static int
posix_acl_default_del (struct inode *inode, const char *name)
static int posix_acl_default_del(struct inode *inode, const char *name)
{
struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
struct posix_acl **acl = &reiserfs_i->i_acl_default;
@ -551,7 +543,8 @@ posix_acl_default_del (struct inode *inode, const char *name)
}
static int
posix_acl_default_list (struct inode *inode, const char *name, int namelen, char *out)
posix_acl_default_list(struct inode *inode, const char *name, int namelen,
char *out)
{
int len = namelen;
if (!reiserfs_posixacl(inode->i_sb))

View file

@ -33,8 +33,7 @@ security_set (struct inode *inode, const char *name, const void *buffer,
return reiserfs_xattr_set(inode, name, buffer, size, flags);
}
static int
security_del (struct inode *inode, const char *name)
static int security_del(struct inode *inode, const char *name)
{
if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
return -EINVAL;
@ -59,7 +58,6 @@ security_list (struct inode *inode, const char *name, int namelen, char *out)
return len;
}
struct reiserfs_xattr_handler security_handler = {
.prefix = XATTR_SECURITY_PREFIX,
.get = security_get,

View file

@ -39,8 +39,7 @@ trusted_set (struct inode *inode, const char *name, const void *buffer,
return reiserfs_xattr_set(inode, name, buffer, size, flags);
}
static int
trusted_del (struct inode *inode, const char *name)
static int trusted_del(struct inode *inode, const char *name)
{
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
return -EINVAL;
@ -71,7 +70,6 @@ trusted_list (struct inode *inode, const char *name, int namelen, char *out)
return len;
}
struct reiserfs_xattr_handler trusted_handler = {
.prefix = XATTR_TRUSTED_PREFIX,
.get = trusted_get,

View file

@ -55,8 +55,7 @@ user_set (struct inode *inode, const char *name, const void *buffer,
return reiserfs_xattr_set(inode, name, buffer, size, flags);
}
static int
user_del (struct inode *inode, const char *name)
static int user_del(struct inode *inode, const char *name)
{
int error;

View file

@ -46,11 +46,11 @@ static inline int reiserfs_acl_count(size_t size)
}
}
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
struct posix_acl *reiserfs_get_acl(struct inode *inode, int type);
int reiserfs_acl_chmod(struct inode *inode);
int reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct inode *inode);
int reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry,
struct inode *inode);
int reiserfs_cache_default_acl(struct inode *dir);
extern int reiserfs_xattr_posix_acl_init(void) __init;
extern int reiserfs_xattr_posix_acl_exit(void);
@ -61,26 +61,24 @@ extern struct reiserfs_xattr_handler posix_acl_access_handler;
#define reiserfs_get_acl NULL
#define reiserfs_cache_default_acl(inode) 0
static inline int
reiserfs_xattr_posix_acl_init (void)
static inline int reiserfs_xattr_posix_acl_init(void)
{
return 0;
}
static inline int reiserfs_xattr_posix_acl_exit(void)
{
return 0;
}
static inline int reiserfs_acl_chmod(struct inode *inode)
{
return 0;
}
static inline int
reiserfs_xattr_posix_acl_exit (void)
{
return 0;
}
static inline int
reiserfs_acl_chmod (struct inode *inode)
{
return 0;
}
static inline int
reiserfs_inherit_default_acl (const struct inode *dir, struct dentry *dentry, struct inode *inode)
reiserfs_inherit_default_acl(const struct inode *dir, struct dentry *dentry,
struct inode *inode)
{
return 0;
}

View file

@ -8,7 +8,6 @@
of our .h files that are in this
directory into it. */
#ifndef _LINUX_REISER_FS_H
#define _LINUX_REISER_FS_H
@ -112,7 +111,6 @@ if( !( cond ) ) \
#define R5_HASH 3
#define DEFAULT_HASH R5_HASH
struct journal_params {
__le32 jp_journal_1st_block; /* where does journal start from on its
* device */
@ -130,8 +128,7 @@ struct journal_params {
};
/* this is the super from 3.5.X, where X >= 10 */
struct reiserfs_super_block_v1
{
struct reiserfs_super_block_v1 {
__le32 s_block_count; /* blocks count */
__le32 s_free_blocks; /* free blocks count */
__le32 s_root_block; /* root block number */
@ -162,8 +159,7 @@ struct reiserfs_super_block_v1
#define SB_SIZE_V1 (sizeof(struct reiserfs_super_block_v1))
/* this is the on disk super block */
struct reiserfs_super_block
{
struct reiserfs_super_block {
struct reiserfs_super_block_v1 s_v1;
__le32 s_inode_generation;
__le32 s_flags; /* Right now used only by inode-attributes, if enabled */
@ -180,7 +176,6 @@ struct reiserfs_super_block
#define REISERFS_VERSION_1 0
#define REISERFS_VERSION_2 2
// on-disk super block fields converted to cpu form
#define SB_DISK_SUPER_BLOCK(s) (REISERFS_SB(s)->s_rs)
#define SB_V1_DISK_SUPER_BLOCK(s) (&(SB_DISK_SUPER_BLOCK(s)->s_v1))
@ -216,7 +211,6 @@ struct reiserfs_super_block
#define PUT_SB_BMAP_NR(s, val) \
do { SB_V1_DISK_SUPER_BLOCK(s)->s_bmap_nr = cpu_to_le16 (val); } while (0)
#define SB_ONDISK_JP(s) (&SB_V1_DISK_SUPER_BLOCK(s)->s_journal)
#define SB_ONDISK_JOURNAL_SIZE(s) \
le32_to_cpu ((SB_ONDISK_JP(s)->jp_journal_size))
@ -233,8 +227,6 @@ struct reiserfs_super_block
((!is_reiserfs_jr(SB_DISK_SUPER_BLOCK(s)) ? \
SB_ONDISK_JOURNAL_SIZE(s) + 1 : SB_ONDISK_RESERVED_FOR_JOURNAL(s)))
/* used by gcc */
#define REISERFS_SUPER_MAGIC 0x52654973
/* used by file system utilities that
@ -285,7 +277,6 @@ struct unfm_nodeinfo {
#define STAT_DATA_V1 0
#define STAT_DATA_V2 1
static inline struct reiserfs_inode_info *REISERFS_I(const struct inode *inode)
{
return container_of(inode, struct reiserfs_inode_info, vfs_inode);
@ -350,8 +341,6 @@ static inline struct reiserfs_sb_info *REISERFS_SB(const struct super_block *sb)
(((n_file_size) > MAX_DIRECT_ITEM_LEN(n_block_size)) ) \
)
/*
* values for s_umount_state field
*/
@ -392,7 +381,8 @@ static inline __u16 offset_v2_k_type( const struct offset_v2 *v2 )
static inline void set_offset_v2_k_type(struct offset_v2 *v2, int type)
{
v2->v = (v2->v & cpu_to_le64(~0ULL>>4)) | cpu_to_le64((__u64)type<<60);
v2->v =
(v2->v & cpu_to_le64(~0ULL >> 4)) | cpu_to_le64((__u64) type << 60);
}
static inline loff_t offset_v2_k_offset(const struct offset_v2 *v2)
@ -400,7 +390,8 @@ static inline loff_t offset_v2_k_offset( const struct offset_v2 *v2 )
return le64_to_cpu(v2->v) & (~0ULL >> 4);
}
static inline void set_offset_v2_k_offset( struct offset_v2 *v2, loff_t offset ){
static inline void set_offset_v2_k_offset(struct offset_v2 *v2, loff_t offset)
{
offset &= (~0ULL >> 4);
v2->v = (v2->v & cpu_to_le64(15ULL << 60)) | cpu_to_le64(offset);
}
@ -475,8 +466,7 @@ struct cpu_key {
indirect items) and specifies the location of the item itself
within the block. */
struct item_head
{
struct item_head {
/* Everything in the tree is found by searching for it based on
* its key.*/
struct reiserfs_key ih_key;
@ -515,7 +505,6 @@ struct item_head
#define put_ih_location(ih, val) do { (ih)->ih_item_location = cpu_to_le16(val); } while (0)
#define put_ih_item_len(ih, val) do { (ih)->ih_item_len = cpu_to_le16(val); } while (0)
#define unreachable_item(ih) (ih_version(ih) & (1 << 15))
#define get_ih_free_space(ih) (ih_version (ih) == KEY_FORMAT_3_6 ? 0 : ih_free_space (ih))
@ -546,10 +535,14 @@ static inline int uniqueness2type (__u32 uniqueness) CONSTF;
static inline int uniqueness2type(__u32 uniqueness)
{
switch ((int)uniqueness) {
case V1_SD_UNIQUENESS: return TYPE_STAT_DATA;
case V1_INDIRECT_UNIQUENESS: return TYPE_INDIRECT;
case V1_DIRECT_UNIQUENESS: return TYPE_DIRECT;
case V1_DIRENTRY_UNIQUENESS: return TYPE_DIRENTRY;
case V1_SD_UNIQUENESS:
return TYPE_STAT_DATA;
case V1_INDIRECT_UNIQUENESS:
return TYPE_INDIRECT;
case V1_DIRECT_UNIQUENESS:
return TYPE_DIRECT;
case V1_DIRENTRY_UNIQUENESS:
return TYPE_DIRENTRY;
default:
reiserfs_warning(NULL, "vs-500: unknown uniqueness %d",
uniqueness);
@ -562,10 +555,14 @@ static inline __u32 type2uniqueness (int type) CONSTF;
static inline __u32 type2uniqueness(int type)
{
switch (type) {
case TYPE_STAT_DATA: return V1_SD_UNIQUENESS;
case TYPE_INDIRECT: return V1_INDIRECT_UNIQUENESS;
case TYPE_DIRECT: return V1_DIRECT_UNIQUENESS;
case TYPE_DIRENTRY: return V1_DIRENTRY_UNIQUENESS;
case TYPE_STAT_DATA:
return V1_SD_UNIQUENESS;
case TYPE_INDIRECT:
return V1_INDIRECT_UNIQUENESS;
case TYPE_DIRECT:
return V1_DIRECT_UNIQUENESS;
case TYPE_DIRENTRY:
return V1_DIRENTRY_UNIQUENESS;
default:
reiserfs_warning(NULL, "vs-501: unknown type %d", type);
case TYPE_ANY:
@ -578,7 +575,8 @@ static inline __u32 type2uniqueness (int type)
// there is no way to get version of object from key, so, provide
// version to these defines
//
static inline loff_t le_key_k_offset (int version, const struct reiserfs_key * key)
static inline loff_t le_key_k_offset(int version,
const struct reiserfs_key *key)
{
return (version == KEY_FORMAT_3_5) ?
le32_to_cpu(key->u.k_offset_v1.k_offset) :
@ -602,33 +600,31 @@ static inline loff_t le_ih_k_type (const struct item_head * ih)
return le_key_k_type(ih_version(ih), &(ih->ih_key));
}
static inline void set_le_key_k_offset (int version, struct reiserfs_key * key, loff_t offset)
static inline void set_le_key_k_offset(int version, struct reiserfs_key *key,
loff_t offset)
{
(version == KEY_FORMAT_3_5) ?
(void)(key->u.k_offset_v1.k_offset = cpu_to_le32 (offset)) : /* jdm check */
(version == KEY_FORMAT_3_5) ? (void)(key->u.k_offset_v1.k_offset = cpu_to_le32(offset)) : /* jdm check */
(void)(set_offset_v2_k_offset(&(key->u.k_offset_v2), offset));
}
static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset)
{
set_le_key_k_offset(ih_version(ih), &(ih->ih_key), offset);
}
static inline void set_le_key_k_type (int version, struct reiserfs_key * key, int type)
static inline void set_le_key_k_type(int version, struct reiserfs_key *key,
int type)
{
(version == KEY_FORMAT_3_5) ?
(void)(key->u.k_offset_v1.k_uniqueness = cpu_to_le32(type2uniqueness(type))):
(void)(set_offset_v2_k_type( &(key->u.k_offset_v2), type ));
(void)(key->u.k_offset_v1.k_uniqueness =
cpu_to_le32(type2uniqueness(type)))
: (void)(set_offset_v2_k_type(&(key->u.k_offset_v2), type));
}
static inline void set_le_ih_k_type(struct item_head *ih, int type)
{
set_le_key_k_type(ih_version(ih), &(ih->ih_key), type);
}
#define is_direntry_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRENTRY)
#define is_direct_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRECT)
#define is_indirect_le_key(version,key) (le_key_k_type (version, key) == TYPE_INDIRECT)
@ -642,8 +638,6 @@ static inline void set_le_ih_k_type (struct item_head * ih, int type)
#define is_indirect_le_ih(ih) is_indirect_le_key (ih_version(ih), &((ih)->ih_key))
#define is_statdata_le_ih(ih) is_statdata_le_key (ih_version (ih), &((ih)->ih_key))
//
// key is pointer to cpu key, result is cpu
//
@ -677,17 +671,12 @@ static inline void cpu_key_k_offset_dec (struct cpu_key * key)
#define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT)
#define is_statdata_cpu_key(key) (cpu_key_k_type (key) == TYPE_STAT_DATA)
/* are these used ? */
#define is_direntry_cpu_ih(ih) (is_direntry_cpu_key (&((ih)->ih_key)))
#define is_direct_cpu_ih(ih) (is_direct_cpu_key (&((ih)->ih_key)))
#define is_indirect_cpu_ih(ih) (is_indirect_cpu_key (&((ih)->ih_key)))
#define is_statdata_cpu_ih(ih) (is_statdata_cpu_key (&((ih)->ih_key)))
#define I_K_KEY_IN_ITEM(p_s_ih, p_s_key, n_blocksize) \
( ! COMP_SHORT_KEYS(p_s_ih, p_s_key) && \
I_OFF_BYTE_IN_ITEM(p_s_ih, k_offset (p_s_key), n_blocksize) )
@ -696,15 +685,11 @@ static inline void cpu_key_k_offset_dec (struct cpu_key * key)
#define MAX_ITEM_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE)
#define MIN_ITEM_LEN 1
/* object identifier for root dir */
#define REISERFS_ROOT_OBJECTID 2
#define REISERFS_ROOT_PARENT_OBJECTID 1
extern struct reiserfs_key root_key;
/*
* Picture represents a leaf of the S+tree
* ______________________________________________________
@ -759,7 +744,6 @@ struct block_head {
#define PUT_B_LEVEL(p_s_bh,val) do { set_blkh_level(B_BLK_HEAD(p_s_bh),val); } while (0)
#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)
/* Get right delimiting key. -- little endian */
#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))
@ -770,20 +754,15 @@ struct block_head {
#define B_IS_KEYS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) > DISK_LEAF_NODE_LEVEL \
&& B_LEVEL(p_s_bh) <= MAX_HEIGHT)
/***************************************************************************/
/* STAT DATA */
/***************************************************************************/
//
// old stat data is 32 bytes long. We are going to distinguish new one by
// different size
//
struct stat_data_v1
{
struct stat_data_v1 {
__le16 sd_mode; /* file type, permissions */
__le16 sd_nlink; /* number of hard links */
__le16 sd_uid; /* owner */
@ -919,7 +898,6 @@ struct stat_data {
#define sd_v2_attrs(sdp) (le16_to_cpu((sdp)->sd_attrs))
#define set_sd_v2_attrs(sdp,v) ((sdp)->sd_attrs = cpu_to_le16(v))
/***************************************************************************/
/* DIRECTORY STRUCTURE */
/***************************************************************************/
@ -954,10 +932,7 @@ struct stat_data {
/* NOT IMPLEMENTED:
Directory will someday contain stat data of object */
struct reiserfs_de_head
{
struct reiserfs_de_head {
__le32 deh_offset; /* third component of the directory entry key */
__le32 deh_dir_id; /* objectid of the parent directory of the object, that is referenced
by directory entry */
@ -1055,25 +1030,20 @@ static inline int entry_length (const struct buffer_head * bh,
return ih_item_len(ih) - deh_location(deh);
}
/* number of entries in the directory item, depends on ENTRY_COUNT being at the start of directory dynamic data. */
#define I_ENTRY_COUNT(ih) (ih_entry_count((ih)))
/* name by bh, ih and entry_num */
#define B_I_E_NAME(bh,ih,entry_num) ((char *)(bh->b_data + ih_location(ih) + deh_location(B_I_DEH(bh,ih)+(entry_num))))
// two entries per block (at least)
#define REISERFS_MAX_NAME(block_size) 255
/* this structure is used for operations on directory entries. It is
not a disk structure. */
/* When reiserfs_find_entry or search_by_entry_key find directory
entry, they return filled reiserfs_dir_entry structure */
struct reiserfs_dir_entry
{
struct reiserfs_dir_entry {
struct buffer_head *de_bh;
int de_item_num;
struct item_head *de_ih;
@ -1099,8 +1069,6 @@ struct reiserfs_dir_entry
#define I_DEH_N_ENTRY_FILE_NAME_LENGTH(ih,deh,entry_num) \
(I_DEH_N_ENTRY_LENGTH (ih, deh, entry_num) - (de_with_sd (deh) ? SD_SIZE : 0))
/* hash value occupies bits from 7 up to 30 */
#define GET_HASH_VALUE(offset) ((offset) & 0x7fffff80LL)
/* generation number occupies 7 bits starting from 0 up to 6 */
@ -1109,7 +1077,6 @@ struct reiserfs_dir_entry
#define SET_GENERATION_NUMBER(offset,gen_number) (GET_HASH_VALUE(offset)|(gen_number))
/*
* Picture represents an internal node of the reiserfs tree
* ______________________________________________________
@ -1159,7 +1126,6 @@ struct disk_child {
/* PATH STRUCTURES AND DEFINES */
/***************************************************************************/
/* Search_by_key fills up the path from the root to the leaf as it descends the tree looking for the
key. It uses reiserfs_bread to try to find buffers in the cache given their block number. If it
does not find them in the cache it reads them from disk. For each node search_by_key finds using
@ -1181,8 +1147,6 @@ struct path_element {
#define ILLEGAL_PATH_ELEMENT_OFFSET 1 /* Must be equal to FIRST_PATH_ELEMENT_OFFSET - 1 */
#define MAX_FEB_SIZE 6 /* this MUST be MAX_HEIGHT + 1. See about FEB below */
/* We need to keep track of who the ancestors of nodes are. When we
perform a search we record which nodes were visited while
descending the tree looking for the node we searched for. This list
@ -1224,7 +1188,6 @@ struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
/* Get position in the element at the path by path and path position. */
#define PATH_OFFSET_POSITION(p_s_path,n_offset) (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_position)
#define PATH_PLAST_BUFFER(p_s_path) (PATH_OFFSET_PBUFFER((p_s_path), (p_s_path)->path_length))
/* you know, to the person who didn't
write this the macro name does not
@ -1234,7 +1197,6 @@ struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
dumping paths... -Hans */
#define PATH_LAST_POSITION(p_s_path) (PATH_OFFSET_POSITION((p_s_path), (p_s_path)->path_length))
#define PATH_PITEM_HEAD(p_s_path) B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_path),PATH_LAST_POSITION(p_s_path))
/* in do_balance leaf has h == 0 in contrast with path structure,
@ -1253,7 +1215,6 @@ struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
#define item_moved(ih,path) comp_items(ih, path)
#define path_changed(ih,path) comp_items (ih, path)
/***************************************************************************/
/* MISC */
/***************************************************************************/
@ -1280,19 +1241,15 @@ static inline loff_t max_reiserfs_offset (struct inode * inode)
return (loff_t) ((~(__u64) 0) >> 4);
}
/*#define MAX_KEY_UNIQUENESS MAX_UL_INT*/
#define MAX_KEY_OBJECTID MAX_UL_INT
#define MAX_B_NUM MAX_UL_INT
#define MAX_FC_NUM MAX_US_INT
/* the purpose is to detect overflow of an unsigned short */
#define REISERFS_LINK_MAX (MAX_US_INT - 1000)
/* The following defines are used in reiserfs_insert_item and reiserfs_append_item */
#define REISERFS_KERNEL_MEM 0 /* reiserfs kernel memory mode */
#define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
@ -1303,7 +1260,6 @@ static inline loff_t max_reiserfs_offset (struct inode * inode)
#define __fs_changed(gen,s) (gen != get_generation (s))
#define fs_changed(gen,s) ({cond_resched(); __fs_changed(gen, s);})
/***************************************************************************/
/* FIXATE NODES */
/***************************************************************************/
@ -1324,8 +1280,7 @@ static inline loff_t max_reiserfs_offset (struct inode * inode)
calculating what we can shift to neighbors and how many nodes we
have to have if we do not any shiftings, if we shift to left/right
neighbor or to both. */
struct virtual_item
{
struct virtual_item {
int vi_index; // index in the array of item operations
unsigned short vi_type; // left/right mergeability
unsigned short vi_item_len; /* length of item that it will have after balancing */
@ -1335,9 +1290,7 @@ struct virtual_item
void *vi_uarea; // item specific area
};
struct virtual_node
{
struct virtual_node {
char *vn_free_ptr; /* this is a pointer to the free space in the buffer */
unsigned short vn_nr_item; /* number of items in virtual node */
short vn_size; /* size of node , that node would have if it has unlimited size and no balancing is performed */
@ -1356,7 +1309,6 @@ struct direntry_uarea {
__u16 entry_sizes[1];
} __attribute__ ((__packed__));
/***************************************************************************/
/* TREE BALANCE */
/***************************************************************************/
@ -1378,8 +1330,7 @@ struct direntry_uarea {
#define MAX_AMOUNT_NEEDED 2
/* someday somebody will prefix every field in this struct with tb_ */
struct tree_balance
{
struct tree_balance {
int tb_mode;
int need_balance_dirty;
struct super_block *tb_sb;
@ -1485,7 +1436,6 @@ struct buffer_info {
int bi_position;
};
/* there are 4 types of items: stat data, directory item, indirect, direct.
+-------------------+------------+--------------+------------+
| | k_offset | k_uniqueness | mergeable? |
@ -1505,7 +1455,8 @@ struct buffer_info {
struct item_operations {
int (*bytes_number) (struct item_head * ih, int block_size);
void (*decrement_key) (struct cpu_key *);
int (*is_left_mergeable) (struct reiserfs_key * ih, unsigned long bsize);
int (*is_left_mergeable) (struct reiserfs_key * ih,
unsigned long bsize);
void (*print_item) (struct item_head *, char *item);
void (*check_item) (struct item_head *, char *item);
@ -1519,7 +1470,6 @@ struct item_operations {
void (*print_vi) (struct virtual_item * vi);
};
extern struct item_operations *item_ops[TYPE_ANY + 1];
#define op_bytes_number(ih,bsize) item_ops[le_ih_k_type (ih)]->bytes_number (ih, bsize)
@ -1533,8 +1483,6 @@ extern struct item_operations * item_ops [TYPE_ANY + 1];
#define op_unit_num(vi) item_ops[(vi)->vi_index]->unit_num (vi)
#define op_print_vi(vi) item_ops[(vi)->vi_index]->print_vi (vi)
#define COMP_SHORT_KEYS comp_short_keys
/* number of blocks pointed to by the indirect item */
@ -1545,7 +1493,6 @@ extern struct item_operations * item_ops [TYPE_ANY + 1];
/* number of bytes contained by the direct item or the unformatted nodes the indirect item points to */
/* get the item header */
#define B_N_PITEM_HEAD(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) )
@ -1736,17 +1683,19 @@ struct reiserfs_jh {
void reiserfs_free_jh(struct buffer_head *bh);
int reiserfs_add_tail_list(struct inode *inode, struct buffer_head *bh);
int reiserfs_add_ordered_list(struct inode *inode, struct buffer_head *bh);
int journal_mark_dirty(struct reiserfs_transaction_handle *, struct super_block *, struct buffer_head *bh) ;
int journal_mark_dirty(struct reiserfs_transaction_handle *,
struct super_block *, struct buffer_head *bh);
static inline int
reiserfs_file_data_log(struct inode *inode) {
static inline int reiserfs_file_data_log(struct inode *inode)
{
if (reiserfs_data_log(inode->i_sb) ||
(REISERFS_I(inode)->i_flags & i_data_log))
return 1;
return 0;
}
static inline int reiserfs_transaction_running(struct super_block *s) {
static inline int reiserfs_transaction_running(struct super_block *s)
{
struct reiserfs_transaction_handle *th = current->journal_info;
if (th && th->t_super == s)
return 1;
@ -1757,8 +1706,10 @@ static inline int reiserfs_transaction_running(struct super_block *s) {
int reiserfs_async_progress_wait(struct super_block *s);
struct reiserfs_transaction_handle *
reiserfs_persistent_transaction(struct super_block *, int count);
struct reiserfs_transaction_handle *reiserfs_persistent_transaction(struct
super_block
*,
int count);
int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *);
int reiserfs_commit_page(struct inode *inode, struct page *page,
unsigned from, unsigned to);
@ -1770,21 +1721,32 @@ void reiserfs_wait_on_write_block(struct super_block *s) ;
void reiserfs_block_writes(struct reiserfs_transaction_handle *th);
void reiserfs_allow_writes(struct super_block *s);
void reiserfs_check_lock_depth(struct super_block *s, char *caller);
int reiserfs_prepare_for_journal(struct super_block *, struct buffer_head *bh, int wait) ;
void reiserfs_restore_prepared_buffer(struct super_block *, struct buffer_head *bh) ;
int journal_init(struct super_block *, const char * j_dev_name, int old_format, unsigned int) ;
int reiserfs_prepare_for_journal(struct super_block *, struct buffer_head *bh,
int wait);
void reiserfs_restore_prepared_buffer(struct super_block *,
struct buffer_head *bh);
int journal_init(struct super_block *, const char *j_dev_name, int old_format,
unsigned int);
int journal_release(struct reiserfs_transaction_handle *, struct super_block *);
int journal_release_error(struct reiserfs_transaction_handle*, struct super_block *) ;
int journal_end(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ;
int journal_end_sync(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ;
int journal_mark_freed(struct reiserfs_transaction_handle *, struct super_block *, b_blocknr_t blocknr) ;
int journal_release_error(struct reiserfs_transaction_handle *,
struct super_block *);
int journal_end(struct reiserfs_transaction_handle *, struct super_block *,
unsigned long);
int journal_end_sync(struct reiserfs_transaction_handle *, struct super_block *,
unsigned long);
int journal_mark_freed(struct reiserfs_transaction_handle *,
struct super_block *, b_blocknr_t blocknr);
int journal_transaction_should_end(struct reiserfs_transaction_handle *, int);
int reiserfs_in_journal(struct super_block *p_s_sb, int bmap_nr, int bit_nr, int searchall, b_blocknr_t *next) ;
int journal_begin(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ;
int journal_join_abort(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ;
int reiserfs_in_journal(struct super_block *p_s_sb, int bmap_nr, int bit_nr,
int searchall, b_blocknr_t * next);
int journal_begin(struct reiserfs_transaction_handle *,
struct super_block *p_s_sb, unsigned long);
int journal_join_abort(struct reiserfs_transaction_handle *,
struct super_block *p_s_sb, unsigned long);
void reiserfs_journal_abort(struct super_block *sb, int errno);
void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...);
int reiserfs_allocate_list_bitmaps(struct super_block *s, struct reiserfs_list_bitmap *, int) ;
int reiserfs_allocate_list_bitmaps(struct super_block *s,
struct reiserfs_list_bitmap *, int);
void add_save_link(struct reiserfs_transaction_handle *th,
struct inode *inode, int truncate);
@ -1792,7 +1754,8 @@ int remove_save_link (struct inode * inode, int truncate);
/* objectid.c */
__u32 reiserfs_get_unused_objectid(struct reiserfs_transaction_handle *th);
void reiserfs_release_objectid (struct reiserfs_transaction_handle *th, __u32 objectid_to_release);
void reiserfs_release_objectid(struct reiserfs_transaction_handle *th,
__u32 objectid_to_release);
int reiserfs_convert_objectid_map_v1(struct super_block *);
/* stree.c */
@ -1806,8 +1769,10 @@ extern int comp_short_keys (const struct reiserfs_key * le_key,
extern void le_key2cpu_key(struct cpu_key *to, const struct reiserfs_key *from);
// both are in le form
extern int comp_le_keys (const struct reiserfs_key *, const struct reiserfs_key *);
extern int comp_short_le_keys (const struct reiserfs_key *, const struct reiserfs_key *);
extern int comp_le_keys(const struct reiserfs_key *,
const struct reiserfs_key *);
extern int comp_short_le_keys(const struct reiserfs_key *,
const struct reiserfs_key *);
//
// get key version from on disk key - kludge
@ -1817,20 +1782,20 @@ static inline int le_key_version (const struct reiserfs_key * key)
int type;
type = offset_v2_k_type(&(key->u.k_offset_v2));
if (type != TYPE_DIRECT && type != TYPE_INDIRECT && type != TYPE_DIRENTRY)
if (type != TYPE_DIRECT && type != TYPE_INDIRECT
&& type != TYPE_DIRENTRY)
return KEY_FORMAT_3_5;
return KEY_FORMAT_3_6;
}
static inline void copy_key (struct reiserfs_key *to, const struct reiserfs_key *from)
static inline void copy_key(struct reiserfs_key *to,
const struct reiserfs_key *from)
{
memcpy(to, from, KEY_SIZE);
}
int comp_items(const struct item_head *stored_ih, const struct path *p_s_path);
const struct reiserfs_key *get_rkey(const struct path *p_s_chk_path,
const struct super_block *p_s_sb);
@ -1862,18 +1827,17 @@ int reiserfs_cut_from_item (struct reiserfs_transaction_handle *th,
struct path *path,
struct cpu_key *key,
struct inode *inode,
struct page *page,
loff_t new_file_size);
struct page *page, loff_t new_file_size);
int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
struct path *path,
const struct cpu_key *key,
struct inode * inode,
struct buffer_head * p_s_un_bh);
struct inode *inode, struct buffer_head *p_s_un_bh);
void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
struct inode *inode, struct reiserfs_key *key);
int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * p_s_inode);
int reiserfs_delete_object(struct reiserfs_transaction_handle *th,
struct inode *p_s_inode);
int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
struct inode *p_s_inode, struct page *,
int update_timestamps);
@ -1896,17 +1860,21 @@ void padd_item (char * item, int total_length, int length);
#define GET_BLOCK_NO_ISEM 8 /* i_sem is not held, don't preallocate */
#define GET_BLOCK_NO_DANGLE 16 /* don't leave any transactions running */
int restart_transaction(struct reiserfs_transaction_handle *th, struct inode *inode, struct path *path);
void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ;
int restart_transaction(struct reiserfs_transaction_handle *th,
struct inode *inode, struct path *path);
void reiserfs_read_locked_inode(struct inode *inode,
struct reiserfs_iget_args *args);
int reiserfs_find_actor(struct inode *inode, void *p);
int reiserfs_init_locked_inode(struct inode *inode, void *p);
void reiserfs_delete_inode(struct inode *inode);
int reiserfs_write_inode(struct inode *inode, int);
int reiserfs_get_block (struct inode * inode, sector_t block, struct buffer_head * bh_result, int create);
int reiserfs_get_block(struct inode *inode, sector_t block,
struct buffer_head *bh_result, int create);
struct dentry *reiserfs_get_dentry(struct super_block *, void *);
struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data,
int len, int fhtype,
int (*acceptable)(void *contect, struct dentry *de),
int (*acceptable) (void *contect,
struct dentry * de),
void *context);
int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp,
int connectable);
@ -1917,9 +1885,7 @@ void make_cpu_key (struct cpu_key * cpu_key, struct inode * inode, loff_t offset
void make_le_item_head(struct item_head *ih, const struct cpu_key *key,
int version,
loff_t offset, int type, int length, int entry_count);
struct inode * reiserfs_iget (struct super_block * s,
const struct cpu_key * key);
struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key);
int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
struct inode *dir, int mode,
@ -1942,8 +1908,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
/* namei.c */
void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
struct path * path,
struct reiserfs_dir_entry * de);
struct path *path, struct reiserfs_dir_entry *de);
struct dentry *reiserfs_get_parent(struct dentry *);
/* procfs.c */
@ -1993,11 +1958,13 @@ extern struct inode_operations reiserfs_special_inode_operations;
extern struct file_operations reiserfs_dir_operations;
/* tail_conversion.c */
int direct2indirect (struct reiserfs_transaction_handle *, struct inode *, struct path *, struct buffer_head *, loff_t);
int indirect2direct (struct reiserfs_transaction_handle *, struct inode *, struct page *, struct path *, const struct cpu_key *, loff_t, char *);
int direct2indirect(struct reiserfs_transaction_handle *, struct inode *,
struct path *, struct buffer_head *, loff_t);
int indirect2direct(struct reiserfs_transaction_handle *, struct inode *,
struct page *, struct path *, const struct cpu_key *,
loff_t, char *);
void reiserfs_unmap_buffer(struct buffer_head *);
/* file.c */
extern struct inode_operations reiserfs_file_inode_operations;
extern struct file_operations reiserfs_file_operations;
@ -2025,9 +1992,9 @@ int fix_nodes (int n_op_mode, struct tree_balance * p_s_tb,
struct item_head *p_s_ins_ih, const void *);
void unfix_nodes(struct tree_balance *);
/* prints.c */
void reiserfs_panic (struct super_block * s, const char * fmt, ...) __attribute__ ( ( noreturn ) );
void reiserfs_panic(struct super_block *s, const char *fmt, ...)
__attribute__ ((noreturn));
void reiserfs_info(struct super_block *s, const char *fmt, ...);
void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...);
void print_indirect_item(struct buffer_head *bh, int item_num);
@ -2050,18 +2017,23 @@ void print_statistics (struct super_block * s);
char *reiserfs_hashname(int code);
/* lbalance.c */
int leaf_move_items (int shift_mode, struct tree_balance * tb, int mov_num, int mov_bytes, struct buffer_head * Snew);
int leaf_move_items(int shift_mode, struct tree_balance *tb, int mov_num,
int mov_bytes, struct buffer_head *Snew);
int leaf_shift_left(struct tree_balance *tb, int shift_num, int shift_bytes);
int leaf_shift_right(struct tree_balance *tb, int shift_num, int shift_bytes);
void leaf_delete_items (struct buffer_info * cur_bi, int last_first, int first, int del_num, int del_bytes);
void leaf_delete_items(struct buffer_info *cur_bi, int last_first, int first,
int del_num, int del_bytes);
void leaf_insert_into_buf(struct buffer_info *bi, int before,
struct item_head * inserted_item_ih, const char * inserted_item_body, int zeros_number);
struct item_head *inserted_item_ih,
const char *inserted_item_body, int zeros_number);
void leaf_paste_in_buffer(struct buffer_info *bi, int pasted_item_num,
int pos_in_item, int paste_size, const char * body, int zeros_number);
void leaf_cut_from_buffer (struct buffer_info * bi, int cut_item_num, int pos_in_item,
int cut_size);
int pos_in_item, int paste_size, const char *body,
int zeros_number);
void leaf_cut_from_buffer(struct buffer_info *bi, int cut_item_num,
int pos_in_item, int cut_size);
void leaf_paste_entries(struct buffer_head *bh, int item_num, int before,
int new_entry_count, struct reiserfs_de_head * new_dehs, const char * records, int paste_size);
int new_entry_count, struct reiserfs_de_head *new_dehs,
const char *records, int paste_size);
/* ibalance.c */
int balance_internal(struct tree_balance *, int, int, struct item_head *,
struct buffer_head **);
@ -2074,11 +2046,13 @@ void do_balance_mark_leaf_dirty (struct tree_balance * tb,
void do_balance(struct tree_balance *tb, struct item_head *ih,
const char *body, int flag);
void reiserfs_invalidate_buffer (struct tree_balance * tb, struct buffer_head * bh);
void reiserfs_invalidate_buffer(struct tree_balance *tb,
struct buffer_head *bh);
int get_left_neighbor_position(struct tree_balance *tb, int h);
int get_right_neighbor_position(struct tree_balance *tb, int h);
void replace_key (struct tree_balance * tb, struct buffer_head *, int, struct buffer_head *, int);
void replace_key(struct tree_balance *tb, struct buffer_head *, int,
struct buffer_head *, int);
void make_empty_node(struct buffer_info *);
struct buffer_head *get_FEB(struct tree_balance *);
@ -2119,10 +2093,13 @@ void reiserfs_init_alloc_options (struct super_block *s);
__le32 reiserfs_choose_packing(struct inode *dir);
int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value);
void reiserfs_free_block (struct reiserfs_transaction_handle *th, struct inode *, b_blocknr_t, int for_unformatted);
int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t * , int, int);
void reiserfs_free_block(struct reiserfs_transaction_handle *th, struct inode *,
b_blocknr_t, int for_unformatted);
int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t *, int,
int);
extern inline int reiserfs_new_form_blocknrs(struct tree_balance *tb,
b_blocknr_t *new_blocknrs, int amount_needed)
b_blocknr_t * new_blocknrs,
int amount_needed)
{
reiserfs_blocknr_hint_t hint = {
.th = tb->transaction_handle,
@ -2132,11 +2109,12 @@ extern inline int reiserfs_new_form_blocknrs (struct tree_balance * tb,
.block = 0,
.formatted_node = 1
};
return reiserfs_allocate_blocknrs(&hint, new_blocknrs, amount_needed, 0);
return reiserfs_allocate_blocknrs(&hint, new_blocknrs, amount_needed,
0);
}
extern inline int reiserfs_new_unf_blocknrs (struct reiserfs_transaction_handle *th,
struct inode *inode,
extern inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle
*th, struct inode *inode,
b_blocknr_t * new_blocknrs,
struct path *path, long block)
{
@ -2152,8 +2130,8 @@ extern inline int reiserfs_new_unf_blocknrs (struct reiserfs_transaction_handle
}
#ifdef REISERFS_PREALLOCATE
extern inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle *th,
struct inode * inode,
extern inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle
*th, struct inode *inode,
b_blocknr_t * new_blocknrs,
struct path *path, long block)
{
@ -2199,7 +2177,6 @@ __u32 r5_hash (const signed char *msg, int len);
absolutely safe */
#define SPARE_SPACE 500
/* prototypes from ioctl.c */
int reiserfs_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
@ -2223,5 +2200,3 @@ int reiserfs_ioctl (struct inode * inode, struct file * filp,
#define REISERFS_XATTR_DIR_SEM(s) (REISERFS_SB(s)->xattr_dir_sem)
#endif /* _LINUX_REISER_FS_H */

View file

@ -27,7 +27,6 @@ typedef enum {
i_data_log = 0x0080,
} reiserfs_inode_flags;
struct reiserfs_inode_info {
__u32 i_key[4]; /* key is still 4 32 bit integers */
/** transient inode flags that are never stored on disk. Bitmasks

View file

@ -259,13 +259,11 @@ enum journal_state_bits {
J_ABORTED, /* set when log is aborted */
};
#define JOURNAL_DESC_MAGIC "ReIsErLB" /* ick. magic string to find desc blocks in the journal */
typedef __u32(*hashf_t) (const signed char *, int);
struct reiserfs_bitmap_info
{
struct reiserfs_bitmap_info {
// FIXME: Won't work with block sizes > 8K
__u16 first_zero_hint;
__u16 free_count;
@ -276,8 +274,7 @@ struct proc_dir_entry;
#if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO )
typedef unsigned long int stat_cnt_t;
typedef struct reiserfs_proc_info_data
{
typedef struct reiserfs_proc_info_data {
spinlock_t lock;
int exiting;
int max_hash_collisions;
@ -343,13 +340,12 @@ typedef struct reiserfs_proc_info_data
} journal;
} reiserfs_proc_info_data_t;
#else
typedef struct reiserfs_proc_info_data
{} reiserfs_proc_info_data_t;
typedef struct reiserfs_proc_info_data {
} reiserfs_proc_info_data_t;
#endif
/* reiserfs union of in-core super block data */
struct reiserfs_sb_info
{
struct reiserfs_sb_info {
struct buffer_head *s_sbh; /* Buffer containing the super block */
/* both the comment and the choice of
name are unclear for s_rs -Hans */
@ -511,7 +507,6 @@ int reiserfs_resize(struct super_block *, unsigned long) ;
#define CARRY_ON 0
#define SCHEDULE_OCCURRED 1
#define SB_BUFFER_WITH_SB(s) (REISERFS_SB(s)->s_sbh)
#define SB_JOURNAL(s) (REISERFS_SB(s)->s_journal)
#define SB_JOURNAL_1st_RESERVED_BLOCK(s) (SB_JOURNAL(s)->j_1st_reserved_block)
@ -529,7 +524,8 @@ static inline char *reiserfs_bdevname(struct super_block *s)
}
#define reiserfs_is_journal_aborted(journal) (unlikely (__reiserfs_is_journal_aborted (journal)))
static inline int __reiserfs_is_journal_aborted (struct reiserfs_journal *journal)
static inline int __reiserfs_is_journal_aborted(struct reiserfs_journal
*journal)
{
return test_bit(J_ABORTED, &journal->j_state);
}

View file

@ -25,11 +25,11 @@ struct reiserfs_xattr_handler {
int (*set) (struct inode * inode, const char *name, const void *buffer,
size_t size, int flags);
int (*del) (struct inode * inode, const char *name);
int (*list)(struct inode *inode, const char *name, int namelen, char *out);
int (*list) (struct inode * inode, const char *name, int namelen,
char *out);
struct list_head handlers;
};
#ifdef CONFIG_REISERFS_FS_XATTR
#define is_reiserfs_priv_object(inode) IS_PRIVATE(inode)
#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
@ -43,12 +43,12 @@ int reiserfs_delete_xattrs (struct inode *inode);
int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd);
int reiserfs_permission_locked (struct inode *inode, int mask, struct nameidata *nd);
int reiserfs_permission_locked(struct inode *inode, int mask,
struct nameidata *nd);
int reiserfs_xattr_del(struct inode *, const char *);
int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
int reiserfs_xattr_set (struct inode *, const char *, const void *,
size_t, int);
int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
extern struct reiserfs_xattr_handler user_handler;
extern struct reiserfs_xattr_handler trusted_handler;
@ -59,52 +59,43 @@ extern struct reiserfs_xattr_handler security_handler;
int reiserfs_xattr_register_handlers(void) __init;
void reiserfs_xattr_unregister_handlers(void);
static inline void
reiserfs_write_lock_xattrs(struct super_block *sb)
static inline void reiserfs_write_lock_xattrs(struct super_block *sb)
{
down_write(&REISERFS_XATTR_DIR_SEM(sb));
}
static inline void
reiserfs_write_unlock_xattrs(struct super_block *sb)
static inline void reiserfs_write_unlock_xattrs(struct super_block *sb)
{
up_write(&REISERFS_XATTR_DIR_SEM(sb));
}
static inline void
reiserfs_read_lock_xattrs(struct super_block *sb)
static inline void reiserfs_read_lock_xattrs(struct super_block *sb)
{
down_read(&REISERFS_XATTR_DIR_SEM(sb));
}
static inline void
reiserfs_read_unlock_xattrs(struct super_block *sb)
static inline void reiserfs_read_unlock_xattrs(struct super_block *sb)
{
up_read(&REISERFS_XATTR_DIR_SEM(sb));
}
static inline void
reiserfs_write_lock_xattr_i(struct inode *inode)
static inline void reiserfs_write_lock_xattr_i(struct inode *inode)
{
down_write(&REISERFS_I(inode)->xattr_sem);
}
static inline void
reiserfs_write_unlock_xattr_i(struct inode *inode)
static inline void reiserfs_write_unlock_xattr_i(struct inode *inode)
{
up_write(&REISERFS_I(inode)->xattr_sem);
}
static inline void
reiserfs_read_lock_xattr_i(struct inode *inode)
static inline void reiserfs_read_lock_xattr_i(struct inode *inode)
{
down_read(&REISERFS_I(inode)->xattr_sem);
}
static inline void
reiserfs_read_unlock_xattr_i(struct inode *inode)
static inline void reiserfs_read_unlock_xattr_i(struct inode *inode)
{
up_read(&REISERFS_I(inode)->xattr_sem);
}
static inline void
reiserfs_mark_inode_private(struct inode *inode)
static inline void reiserfs_mark_inode_private(struct inode *inode)
{
inode->i_flags |= S_PRIVATE;
}
@ -127,8 +118,15 @@ reiserfs_mark_inode_private(struct inode *inode)
#define reiserfs_xattr_register_handlers() 0
#define reiserfs_xattr_unregister_handlers()
static inline int reiserfs_delete_xattrs (struct inode *inode) { return 0; };
static inline int reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs) { return 0; };
static inline int reiserfs_delete_xattrs(struct inode *inode)
{
return 0;
};
static inline int reiserfs_chown_xattrs(struct inode *inode,
struct iattr *attrs)
{
return 0;
};
static inline int reiserfs_xattr_init(struct super_block *sb, int mount_flags)
{
sb->s_flags = (sb->s_flags & ~MS_POSIXACL); /* to be sure */