[PATCH] reiserfs: fix unaligned bitmap usage



The bitmaps associated with generation numbers for directory entries
are declared as an array of ints. On some platforms, this causes alignment
exceptions.

The following patch uses the standard bitmap declaration macros to
declare the bitmaps, fixing the problem.

Originally from Takashi Iwai.

Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
Acked-by: Jeff Mahoney <jeffm@xxxxxxxx>

--- linux-2.6.15/fs/reiserfs/namei.c 2006-02-14 18:57:32.000000000 +0100
+++ linux-2.6.15/fs/reiserfs/namei.c 2006-02-14 18:58:24.000000000 +0100
@@ -247,7 +247,7 @@ static int linear_search_in_dir_item(str
/* 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);
+ de->de_gen_number_bit_string);

// calculate pointer to name and namelen
de->de_entry_num = i;
@@ -431,7 +431,7 @@ static int reiserfs_add_entry(struct rei
struct reiserfs_de_head *deh;
INITIALIZE_PATH(path);
struct reiserfs_dir_entry de;
- int bit_string[MAX_GENERATION_NUMBER / (sizeof(int) * 8) + 1];
+ DECLARE_BITMAP(bit_string, MAX_GENERATION_NUMBER + 1);
int gen_number;
char small_buf[32 + DEH_SIZE]; /* 48 bytes now and we avoid kmalloc
if we create file with short name */
@@ -486,7 +486,7 @@ static int reiserfs_add_entry(struct rei

/* find the proper place for the new entry */
memset(bit_string, 0, sizeof(bit_string));
- de.de_gen_number_bit_string = (char *)bit_string;
+ de.de_gen_number_bit_string = bit_string;
retval = reiserfs_find_entry(dir, name, namelen, &path, &de);
if (retval != NAME_NOT_FOUND) {
if (buffer != small_buf)
@@ -508,7 +508,7 @@ static int reiserfs_add_entry(struct rei
}

gen_number =
- find_first_zero_bit((unsigned long *)bit_string,
+ find_first_zero_bit(bit_string,
MAX_GENERATION_NUMBER + 1);
if (gen_number > MAX_GENERATION_NUMBER) {
/* there is no free generation number */
--- linux-2.6.15/include/linux/reiserfs_fs.h 2006-02-14 18:57:10.000000000 +0100
+++ linux-2.6.15/include/linux/reiserfs_fs.h 2006-02-14 18:57:22.000000000 +0100
@@ -1052,7 +1052,7 @@ struct reiserfs_dir_entry {
int de_entrylen;
int de_namelen;
char *de_name;
- char *de_gen_number_bit_string;
+ unsigned long *de_gen_number_bit_string;

__u32 de_dir_id;
__u32 de_objectid;
--
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [PATCH] drivers/ide/ide-probe.c: uninitialized variable rc
    ... What about changing the declaration to ... int i, uninitialized_var; ... I'm an utter newbie to kernel ... Did I miss the final patch version? ...
    (Linux-Kernel)
  • [RESEND] [PATCH] drivers/acpi/asus_acpi.c unsigned comparison
    ... The return of parse_arg is an int, but count is declared as an unsigned int, and later checked versus zero, ... This patch fixes the declaration of count in both functions. ... To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • compiling kernel
    ... scripts/kconfig/qconf.h:51: error: `e' was not declared in this scope ... scripts/kconfig/qconf.h:73: error: `int updateList' redeclared as different ... scripts/kconfig/qconf.h:8: error: forward declaration of `class ConfigList' ... ConfigLineEdit' ...
    (alt.os.linux.suse)
  • DBI install problems
    ... before "bool" ... to `int' in declaration of `Perl_Gv_AMupdate' ... definition has no type or storage class ...
    (perl.dbi.users)
  • make Buildworld fails...why?
    ... type defaults to `int' in declaration of `_nc_tracing' ... data definition has no type or storage class ...
    (freebsd-questions)