Commit ea882f08 authored by Chris Mason's avatar Chris Mason Committed by Linus Torvalds

[PATCH] reiserfs 64 bit bug in get_virtual_node_size

This patch fixes a problem with reiserfs on 64 bit machines.  Our
struct virtual_item is a different size there, and some calculations
that assume otherwise lead to this panic create_virtual_node:

vs-8030: create_virtual_node: virtual node space consumed
parent 70e08a38
...@@ -2011,16 +2011,20 @@ void reiserfs_kfree (const void * vp, size_t size, struct super_block * s) ...@@ -2011,16 +2011,20 @@ void reiserfs_kfree (const void * vp, size_t size, struct super_block * s)
static int get_virtual_node_size (struct super_block * sb, struct buffer_head * bh) static int get_virtual_node_size (struct super_block * sb, struct buffer_head * bh)
{ {
// int size = sizeof (struct virtual_item); /* for new item in case of insert */ int max_num_of_items;
// int i, nr_items; int max_num_of_entries;
// struct item_head * ih; unsigned long blocksize = sb->s_blocksize;
// this is enough for _ALL_ currently possible cases. In 4 k block #define MIN_NAME_LEN 1
// one may put < 170 empty items. Each virtual item eats 12
// byte. The biggest direntry item may have < 256 entries. Each
// entry would eat 2 byte of virtual node space
return sb->s_blocksize;
max_num_of_items = (blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN);
max_num_of_entries = (blocksize - BLKH_SIZE - IH_SIZE) /
(DEH_SIZE + MIN_NAME_LEN);
return sizeof(struct virtual_node) +
max(max_num_of_items * sizeof (struct virtual_item),
sizeof (struct virtual_item) + sizeof(struct direntry_uarea) +
(max_num_of_entries - 1) * sizeof (__u16));
} }
......
...@@ -466,13 +466,6 @@ static void direntry_check_item (struct item_head * ih, char * item) ...@@ -466,13 +466,6 @@ static void direntry_check_item (struct item_head * ih, char * item)
#define DIRENTRY_VI_FIRST_DIRENTRY_ITEM 1 #define DIRENTRY_VI_FIRST_DIRENTRY_ITEM 1
struct direntry_uarea {
int flags;
__u16 entry_count;
__u16 entry_sizes[1];
} __attribute__ ((__packed__)) ;
/* /*
* function returns old entry number in directory item in real node * function returns old entry number in directory item in real node
* using new entry number in virtual item in virtual node */ * using new entry number in virtual item in virtual node */
......
...@@ -1342,6 +1342,13 @@ struct virtual_node ...@@ -1342,6 +1342,13 @@ struct virtual_node
struct virtual_item * vn_vi; /* array of items (including a new one, excluding item to be deleted) */ struct virtual_item * vn_vi; /* array of items (including a new one, excluding item to be deleted) */
}; };
/* used by directory items when creating virtual nodes */
struct direntry_uarea {
int flags;
__u16 entry_count;
__u16 entry_sizes[1];
} __attribute__ ((__packed__)) ;
/***************************************************************************/ /***************************************************************************/
/* TREE BALANCE */ /* TREE BALANCE */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment