From: Hans Reiser This patch contains two reiser4 cleanups: __le types are used instead of d* kthread* is used instead of kernel_thread Signed-off-by: Vladimir V. Saveliev Signed-off-by: Andrew Morton --- dev/null | 3 fs/reiser4/dformat.h | 136 +++++--------------------- fs/reiser4/dscale.c | 13 +- fs/reiser4/entd.c | 74 +++----------- fs/reiser4/entd.h | 7 - fs/reiser4/flush_queue.c | 20 +-- fs/reiser4/forward.h | 6 - fs/reiser4/init_super.c | 10 + fs/reiser4/jnode.c | 4 fs/reiser4/kassign.c | 6 - fs/reiser4/key.c | 18 +-- fs/reiser4/key.h | 6 - fs/reiser4/ktxnmgrd.c | 114 +++------------------ fs/reiser4/ktxnmgrd.h | 4 fs/reiser4/lock.c | 36 +----- fs/reiser4/plugin/disk_format/disk_format40.c | 44 ++++---- fs/reiser4/plugin/file/cryptcompress.c | 12 +- fs/reiser4/plugin/file/file.c | 24 ++++ fs/reiser4/plugin/file_ops.c | 99 ------------------ fs/reiser4/plugin/file_ops_readdir.c | 5 fs/reiser4/plugin/item/cde.c | 20 +-- fs/reiser4/plugin/item/ctail.c | 6 - fs/reiser4/plugin/item/extent.h | 8 - fs/reiser4/plugin/item/extent_flush_ops.c | 4 fs/reiser4/plugin/item/internal.c | 4 fs/reiser4/plugin/item/item.h | 2 fs/reiser4/plugin/item/sde.c | 2 fs/reiser4/plugin/item/static_stat.c | 85 ++++++++-------- fs/reiser4/plugin/item/static_stat.h | 34 +++--- fs/reiser4/plugin/node/node.h | 26 ++-- fs/reiser4/plugin/node/node40.c | 107 +++++--------------- fs/reiser4/plugin/object.h | 2 fs/reiser4/plugin/plugin.c | 16 ++- fs/reiser4/plugin/plugin_header.h | 51 ++++----- fs/reiser4/plugin/space/bitmap.c | 4 fs/reiser4/reiser4.h | 2 fs/reiser4/safe_link.c | 4 fs/reiser4/spin_macros.h | 1 fs/reiser4/status_flags.c | 30 +---- fs/reiser4/super_ops.c | 8 + fs/reiser4/txnmgr.c | 52 ++------- fs/reiser4/wander.c | 82 +++++++-------- fs/reiser4/znode.c | 2 43 files changed, 399 insertions(+), 794 deletions(-) diff -puN fs/reiser4/dformat.h~reiser4-fix-endianess fs/reiser4/dformat.h --- devel/fs/reiser4/dformat.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/dformat.h 2005-09-28 22:53:11.000000000 -0700 @@ -17,111 +17,29 @@ #include #include -/* our default disk byteorder is little endian */ -#if defined( __LITTLE_ENDIAN ) -#define CPU_IN_DISK_ORDER (1) -#else -#define CPU_IN_DISK_ORDER (0) -#endif - -/* code on-disk data-types as structs with a single field - to rely on compiler type-checking. Like include/asm-i386/page.h */ -typedef struct d8 { - __u8 datum; -} d8 __attribute__ ((aligned(1))); -typedef struct d16 { - __u16 datum; -} d16 __attribute__ ((aligned(2))); -typedef struct d32 { - __u32 datum; -} d32 __attribute__ ((aligned(4))); -typedef struct d64 { - __u64 datum; -} d64 __attribute__ ((aligned(8))); +typedef __u8 d8; +typedef __le16 d16; +typedef __le32 d32; +typedef __le64 d64; #define PACKED __attribute__((packed)) -static inline __u8 d8tocpu(const d8 * ondisk /* on-disk value to convert */ ) -{ - return ondisk->datum; -} - -static inline __u16 d16tocpu(const d16 * ondisk /* on-disk value to convert */ ) -{ - return __le16_to_cpu(get_unaligned(&ondisk->datum)); -} - -static inline __u32 d32tocpu(const d32 * ondisk /* on-disk value to convert */ ) -{ - return __le32_to_cpu(get_unaligned(&ondisk->datum)); -} - -static inline __u64 d64tocpu(const d64 * ondisk /* on-disk value to convert */ ) -{ - return __le64_to_cpu(get_unaligned(&ondisk->datum)); -} - -static inline d8 *cputod8(unsigned int oncpu /* CPU value to convert */ , - d8 * ondisk /* result */ ) -{ - assert("nikita-1264", oncpu < 0x100); - put_unaligned(oncpu, &ondisk->datum); - return ondisk; -} - -static inline d16 *cputod16(unsigned int oncpu /* CPU value to convert */ , - d16 * ondisk /* result */ ) -{ - assert("nikita-1265", oncpu < 0x10000); - put_unaligned(__cpu_to_le16(oncpu), &ondisk->datum); - return ondisk; -} - -static inline d32 *cputod32(__u32 oncpu /* CPU value to convert */ , - d32 * ondisk /* result */ ) -{ - put_unaligned(__cpu_to_le32(oncpu), &ondisk->datum); - return ondisk; -} - -static inline d64 *cputod64(__u64 oncpu /* CPU value to convert */ , - d64 * ondisk /* result */ ) -{ - put_unaligned(__cpu_to_le64(oncpu), &ondisk->datum); - return ondisk; -} - -/* data-type for block number on disk: these types enable changing the block - size to other sizes, but they are only a start. Suppose we wanted to - support 48bit block numbers. The dblock_nr blk would be changed to "short - blk[3]". The block_nr type should remain an integral type greater or equal - to the dblock_nr type in size so that CPU arithmetic operations work. */ +/* data-type for block number */ typedef __u64 reiser4_block_nr; /* data-type for block number on disk, disk format */ -union reiser4_dblock_nr { - d64 blk; -}; - -static inline reiser4_block_nr dblock_to_cpu(const reiser4_dblock_nr * dblock) -{ - return d64tocpu(&dblock->blk); -} - -static inline void -cpu_to_dblock(reiser4_block_nr block, reiser4_dblock_nr * dblock) -{ - cputod64(block, &dblock->blk); -} +typedef __le64 reiser4_dblock_nr; -/* true if disk addresses are the same */ -static inline int disk_addr_eq(const reiser4_block_nr * b1 /* first block - * number to - * compare */ , - const reiser4_block_nr * b2 /* second block - * number to - * compare */ ) +/** + * disk_addr_eq - compare disk addresses + * @b1: pointer to block number ot compare + * @b2: pointer to block number ot compare + * + * Returns true if if disk addresses are the same + */ +static inline int disk_addr_eq(const reiser4_block_nr *b1, + const reiser4_block_nr * b2) { assert("nikita-1033", b1 != NULL); assert("nikita-1266", b2 != NULL); @@ -132,22 +50,22 @@ static inline int disk_addr_eq(const rei /* structure of master reiser4 super block */ typedef struct reiser4_master_sb { char magic[16]; /* "ReIsEr4" */ - d16 disk_plugin_id; /* id of disk layout plugin */ - d16 blocksize; + __le16 disk_plugin_id; /* id of disk layout plugin */ + __le16 blocksize; char uuid[16]; /* unique id */ char label[16]; /* filesystem label */ - d64 diskmap; /* location of the diskmap. 0 if not present */ + __le64 diskmap; /* location of the diskmap. 0 if not present */ } reiser4_master_sb; /* __FS_REISER4_DFORMAT_H__ */ #endif -/* Make Linus happy. - Local variables: - c-indentation-style: "K&R" - mode-name: "LC" - c-basic-offset: 8 - tab-width: 8 - fill-column: 120 - End: -*/ +/* + * Local variables: + * c-indentation-style: "K&R" + * mode-name: "LC" + * c-basic-offset: 8 + * tab-width: 8 + * fill-column: 79 + * End: + */ diff -puN fs/reiser4/dscale.c~reiser4-fix-endianess fs/reiser4/dscale.c --- devel/fs/reiser4/dscale.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/dscale.c 2005-09-28 22:53:11.000000000 -0700 @@ -104,7 +104,7 @@ int dscale_read(unsigned char *address, case 3: /* In this case tag is stored in an extra byte, skip this byte * and decode value stored in the next 8 bytes.*/ - *value = __be64_to_cpu(get_unaligned((__u64 *) (address + 1))); + *value = __be64_to_cpu(get_unaligned((__be64 *)(address + 1))); /* worst case: 8 bytes for value itself plus one byte for * tag. */ return 9; @@ -112,10 +112,10 @@ int dscale_read(unsigned char *address, *value = get_unaligned(address); break; case 1: - *value = __be16_to_cpu(get_unaligned((__u16 *) address)); + *value = __be16_to_cpu(get_unaligned((__be16 *)address)); break; case 2: - *value = __be32_to_cpu(get_unaligned((__u32 *) address)); + *value = __be32_to_cpu(get_unaligned((__be32 *)address)); break; default: return RETERR(-EIO); @@ -131,13 +131,14 @@ int dscale_write(unsigned char *address, { int tag; int shift; + __be64 v; unsigned char *valarr; tag = dscale_range(value); - value = __cpu_to_be64(value); - valarr = (unsigned char *)&value; + v = __cpu_to_be64(value); + valarr = (unsigned char *)&v; shift = (tag == 3) ? 1 : 0; - memcpy(address + shift, valarr + sizeof value - (1 << tag), 1 << tag); + memcpy(address + shift, valarr + sizeof v - (1 << tag), 1 << tag); *address |= (tag << 6); return shift + (1 << tag); } diff -puN fs/reiser4/entd.c~reiser4-fix-endianess fs/reiser4/entd.c --- devel/fs/reiser4/entd.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/entd.c 2005-09-28 22:53:11.000000000 -0700 @@ -21,6 +21,7 @@ #include /* INITIAL_JIFFIES */ #include /* bdi_write_congested */ #include +#include #define DEF_PRIORITY 12 #define MAX_ENTD_ITERS 10 @@ -49,7 +50,7 @@ static inline entd_context *get_entd_con * Creates entd contexts, starts kernel thread and waits until it * initializes. */ -void init_entd(struct super_block *super) +int init_entd(struct super_block *super) { entd_context *ctx; @@ -60,23 +61,15 @@ void init_entd(struct super_block *super memset(ctx, 0, sizeof *ctx); spin_lock_init(&ctx->guard); init_waitqueue_head(&ctx->wait); - - /* - * prepare synchronization object to synchronize with ent thread - * initialization - */ - init_completion(&ctx->start_finish_completion); - - /* start entd */ - kernel_thread(entd, super, CLONE_VM | CLONE_FS | CLONE_FILES); - - /* wait for entd initialization */ - wait_for_completion(&ctx->start_finish_completion); - #if REISER4_DEBUG INIT_LIST_HEAD(&ctx->flushers_list); #endif INIT_LIST_HEAD(&ctx->wbq_list); + /* start entd */ + ctx->tsk = kthread_run(entd, super, "ent:%s", super->s_id); + if (IS_ERR(ctx->tsk)) + return PTR_ERR(ctx->tsk); + return 0; } static void __put_wbq(entd_context * ent, struct wbq *rq) @@ -135,31 +128,19 @@ static void wakeup_all_wbq(entd_context static int entd(void *arg) { struct super_block *super; - struct task_struct *me; entd_context *ent; + int done = 0; super = arg; - /* standard kernel thread prologue */ - me = current; - /* reparent_to_init() is done by daemonize() */ - daemonize("ent:%s", super->s_id); - /* do_fork() just copies task_struct into the new thread. ->fs_context shouldn't be copied of course. This shouldn't be a problem for the rest of the code though. */ - me->journal_info = NULL; + current->journal_info = NULL; ent = get_entd_context(super); - spin_lock(&ent->guard); - ent->tsk = me; - spin_unlock(&ent->guard); - - /* initialization is done */ - complete(&ent->start_finish_completion); - - while (!ent->done) { + while (!done) { try_to_freeze(); spin_lock(&ent->guard); @@ -192,23 +173,20 @@ static int entd(void *arg) { DEFINE_WAIT(__wait); - for (;;) { - int dontsleep; - - prepare_to_wait(&ent->wait, &__wait, TASK_UNINTERRUPTIBLE); - spin_lock(&ent->guard); - dontsleep = ent->done || ent->nr_all_requests != 0; - spin_unlock(&ent->guard); - if (dontsleep) + do { + prepare_to_wait(&ent->wait, &__wait, TASK_INTERRUPTIBLE); + if (kthread_should_stop()) { + done = 1; + break; + } + if (ent->nr_all_requests != 0) break; schedule(); - } + } while (0); finish_wait(&ent->wait, &__wait); } } wakeup_all_wbq(ent); - complete_and_exit(&ent->start_finish_completion, 0); - /* not reached. */ return 0; } @@ -226,20 +204,8 @@ void done_entd(struct super_block *super assert("nikita-3103", super != NULL); ent = get_entd_context(super); - - /* - * prepare synchronization object to synchronize with entd - * completion - */ - init_completion(&ent->start_finish_completion); - - spin_lock(&ent->guard); - ent->done = 1; - spin_unlock(&ent->guard); - wake_up(&ent->wait); - - /* wait until entd finishes */ - wait_for_completion(&ent->start_finish_completion); + assert("zam-1055", ent->tsk != NULL); + kthread_stop(ent->tsk); } /* called at the beginning of jnode_flush to register flusher thread with ent diff -puN fs/reiser4/entd.h~reiser4-fix-endianess fs/reiser4/entd.h --- devel/fs/reiser4/entd.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/entd.h 2005-09-28 22:53:11.000000000 -0700 @@ -26,11 +26,6 @@ struct wbq { /* ent-thread context. This is used to synchronize starting/stopping ent * threads. */ typedef struct entd_context { - /* - * completion that is signaled by ent thread just before it - * terminates. - */ - struct completion start_finish_completion; /* wait queue that ent thread waits on for more work. It's * signaled by write_page_by_ent(). */ wait_queue_head_t wait; @@ -51,7 +46,7 @@ typedef struct entd_context { struct list_head wbq_list; /* struct wbq are elements of this list */ } entd_context; -extern void init_entd(struct super_block *); +extern int init_entd(struct super_block *); extern void done_entd(struct super_block *); extern void enter_flush(struct super_block *); diff -puN fs/reiser4/flush_queue.c~reiser4-fix-endianess fs/reiser4/flush_queue.c --- devel/fs/reiser4/flush_queue.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/flush_queue.c 2005-09-28 22:53:11.000000000 -0700 @@ -282,15 +282,13 @@ static int finish_fq(flush_queue_t * fq, static int finish_all_fq(txn_atom * atom, int *nr_io_errors) { flush_queue_t *fq; - struct list_head *pos; assert("zam-730", spin_atom_is_locked(atom)); if (list_empty_careful(&atom->flush_queues)) return 0; - list_for_each(pos, &atom->flush_queues) { - fq = list_entry(pos, flush_queue_t, alink); + list_for_each_entry(fq, &atom->flush_queues, alink) { if (fq_ready(fq)) { int ret; @@ -356,10 +354,8 @@ static void scan_fq_and_update_atom_ref(struct list_head *list, txn_atom *atom) { jnode *cur; - struct list_head *pos; - list_for_each(pos, list) { - cur = list_entry(pos, jnode, capture_link); + list_for_each_entry(cur, list, capture_link) { LOCK_JNODE(cur); cur->atom = atom; UNLOCK_JNODE(cur); @@ -370,13 +366,11 @@ scan_fq_and_update_atom_ref(struct list_ void fuse_fq(txn_atom *to, txn_atom *from) { flush_queue_t *fq; - struct list_head *pos; assert("zam-720", spin_atom_is_locked(to)); assert("zam-721", spin_atom_is_locked(from)); - list_for_each(pos, &from->flush_queues) { - fq = list_entry(pos, flush_queue_t, alink); + list_for_each_entry(fq, &from->flush_queues, alink) { scan_fq_and_update_atom_ref(ATOM_FQ_LIST(fq), to); spin_lock_fq(fq); fq->atom = to; @@ -723,13 +717,13 @@ void check_fq(const txn_atom *atom) /* check number of nodes on all atom's flush queues */ flush_queue_t *fq; int count; - struct list_head *pos1, *pos2; + struct list_head *pos; count = 0; - list_for_each(pos1, &atom->flush_queues) { - fq = list_entry(pos1, flush_queue_t, alink); + list_for_each_entry(fq, &atom->flush_queues, alink) { spin_lock_fq(fq); - list_for_each(pos2, ATOM_FQ_LIST(fq)) + /* calculate number of jnodes on fq' list of prepped jnodes */ + list_for_each(pos, ATOM_FQ_LIST(fq)) count++; spin_unlock_fq(fq); } diff -puN fs/reiser4/forward.h~reiser4-fix-endianess fs/reiser4/forward.h --- devel/fs/reiser4/forward.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/forward.h 2005-09-28 22:53:11.000000000 -0700 @@ -6,6 +6,7 @@ #define __REISER4_FORWARD_H__ #include +#include typedef struct zlock zlock; typedef struct lock_stack lock_stack; @@ -18,12 +19,11 @@ typedef struct item_coord item_coord; typedef struct shift_params shift_params; typedef struct reiser4_object_create_data reiser4_object_create_data; typedef union reiser4_plugin reiser4_plugin; -typedef int reiser4_plugin_id; +typedef __u16 reiser4_plugin_id; typedef struct item_plugin item_plugin; typedef struct jnode_plugin jnode_plugin; typedef struct reiser4_item_data reiser4_item_data; typedef union reiser4_key reiser4_key; -typedef union reiser4_dblock_nr reiser4_dblock_nr; typedef struct reiser4_tree reiser4_tree; typedef struct carry_cut_data carry_cut_data; typedef struct carry_kill_data carry_kill_data; @@ -243,6 +243,8 @@ typedef enum { PROTECT_LIST } atom_list; + + /* __REISER4_FORWARD_H__ */ #endif diff -puN fs/reiser4/init_super.c~reiser4-fix-endianess fs/reiser4/init_super.c --- devel/fs/reiser4/init_super.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/init_super.c 2005-09-28 22:53:11.000000000 -0700 @@ -552,7 +552,7 @@ int init_read_super(struct super_block * if (!strncmp(master_sb->magic, REISER4_SUPER_MAGIC_STRING, sizeof(REISER4_SUPER_MAGIC_STRING))) { /* reiser4 master super block contains filesystem blocksize */ - blocksize = d16tocpu(&master_sb->blocksize); + blocksize = le16_to_cpu(get_unaligned(&master_sb->blocksize)); if (blocksize != PAGE_CACHE_SIZE) { /* @@ -577,17 +577,19 @@ int init_read_super(struct super_block * goto read_super_block; } - sbinfo->df_plug = disk_format_plugin_by_id(d16tocpu(&master_sb->disk_plugin_id)); + sbinfo->df_plug = + disk_format_plugin_by_id( + le16_to_cpu(get_unaligned(&master_sb->disk_plugin_id))); if (sbinfo->df_plug == NULL) { if (!silent) warning("nikita-26091", "%s: unknown disk format plugin %d\n", super->s_id, - d16tocpu(&master_sb->disk_plugin_id)); + le16_to_cpu(get_unaligned(&master_sb->disk_plugin_id))); brelse(super_bh); return RETERR(-EINVAL); } - sbinfo->diskmap_block = d64tocpu(&master_sb->diskmap); + sbinfo->diskmap_block = le64_to_cpu(get_unaligned(&master_sb->diskmap)); brelse(super_bh); return 0; } diff -L fs/reiser4/init_super.h -puN fs/reiser4/init_super.h~reiser4-fix-endianess /dev/null --- devel/fs/reiser4/init_super.h +++ /dev/null 2003-09-15 06:40:47.000000000 -0700 @@ -1,3 +0,0 @@ -/* Copyright by Hans Reiser, 2003 */ - - diff -puN fs/reiser4/jnode.c~reiser4-fix-endianess fs/reiser4/jnode.c --- devel/fs/reiser4/jnode.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/jnode.c 2005-09-28 22:53:11.000000000 -0700 @@ -308,8 +308,6 @@ inline void jfree(jnode * node) /* not yet phash_jnode_destroy(node); */ - /* poison memory. */ - ON_DEBUG(memset(node, 0xad, sizeof *node)); kmem_cache_free(_jnode_slab, node); } @@ -845,7 +843,7 @@ static void check_jload(jnode * node, st /* this only works for node40-only file systems. For * debugging. */ assert("nikita-3253", - z->nr_items == d16tocpu(&nh->nr_items)); + z->nr_items == le16_to_cpu(get_unaligned(&nh->nr_items))); kunmap(page); } assert("nikita-3565", znode_invariant(z)); diff -puN fs/reiser4/kassign.c~reiser4-fix-endianess fs/reiser4/kassign.c --- devel/fs/reiser4/kassign.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/kassign.c 2005-09-28 22:53:11.000000000 -0700 @@ -623,7 +623,7 @@ char *build_inode_onwire(const struct in start += dscale_write(start, get_inode_oid(inode)); if (REISER4_LARGE_KEY) { - cputod64(get_inode_ordering(inode), (d64 *) start); + put_unaligned(cpu_to_le64(get_inode_ordering(inode)), (__le64 *)start); start += sizeof(get_inode_ordering(inode)); } return start; @@ -638,9 +638,9 @@ char *extract_obj_key_id_from_onwire(cha addr += dscale_read(addr, &val); val = (val << KEY_LOCALITY_SHIFT) | KEY_SD_MINOR; - cputod64(val, (d64 *) key_id->locality); + put_unaligned(cpu_to_le64(val), (__le64 *)key_id->locality); addr += dscale_read(addr, &val); - cputod64(val, (d64 *) key_id->objectid); + put_unaligned(cpu_to_le64(val), (__le64 *)key_id->objectid); #if REISER4_LARGE_KEY memcpy(&key_id->ordering, addr, sizeof key_id->ordering); addr += sizeof key_id->ordering; diff -puN fs/reiser4/key.c~reiser4-fix-endianess fs/reiser4/key.c --- devel/fs/reiser4/key.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/key.c 2005-09-28 22:53:11.000000000 -0700 @@ -13,10 +13,10 @@ independent of key scheme. */ static const reiser4_key MINIMAL_KEY = { .el = { - {0ull}, - ON_LARGE_KEY({0ull},) - {0ull}, - {0ull} + 0ull, + ON_LARGE_KEY(0ull,) + 0ull, + 0ull } }; @@ -24,14 +24,14 @@ static const reiser4_key MINIMAL_KEY = { independent of key scheme. */ static const reiser4_key MAXIMAL_KEY = { .el = { - {~0ull}, - ON_LARGE_KEY({~0ull},) - {~0ull}, - {~0ull} + cpu_to_le64(~0ull), + ON_LARGE_KEY(cpu_to_le64(~0ull),) + cpu_to_le64(~0ull), + cpu_to_le64(~0ull) } }; -/* Initialise key. */ +/* Initialize key. */ void reiser4_key_init(reiser4_key * key /* key to init */ ) { assert("nikita-1169", key != NULL); diff -puN fs/reiser4/key.h~reiser4-fix-endianess fs/reiser4/key.h --- devel/fs/reiser4/key.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/key.h 2005-09-28 22:53:11.000000000 -0700 @@ -104,7 +104,7 @@ typedef enum { We declare this as union with second component dummy to suppress inconvenient array<->pointer casts implied in C. */ union reiser4_key { - d64 el[KEY_LAST_INDEX]; + __le64 el[KEY_LAST_INDEX]; int pad; }; @@ -146,7 +146,7 @@ get_key_el(const reiser4_key * key, reis { assert("nikita-753", key != NULL); assert("nikita-754", off < KEY_LAST_INDEX); - return d64tocpu(&key->el[off]); + return le64_to_cpu(get_unaligned(&key->el[off])); } static inline void @@ -154,7 +154,7 @@ set_key_el(reiser4_key * key, reiser4_ke { assert("nikita-755", key != NULL); assert("nikita-756", off < KEY_LAST_INDEX); - cputod64(value, &key->el[off]); + put_unaligned(cpu_to_le64(value), &key->el[off]); } /* macro to define getter and setter functions for field F with type T */ diff -puN fs/reiser4/ktxnmgrd.c~reiser4-fix-endianess fs/reiser4/ktxnmgrd.c --- devel/fs/reiser4/ktxnmgrd.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/ktxnmgrd.c 2005-09-28 22:53:11.000000000 -0700 @@ -34,6 +34,7 @@ #include #include #include +#include static int scan_mgr(struct super_block *); @@ -55,32 +56,21 @@ static int scan_mgr(struct super_block * */ static int ktxnmgrd(void *arg) { - struct task_struct *me; struct super_block *super; ktxnmgrd_context *ctx; txn_mgr *mgr; + int done = 0; super = arg; mgr = &get_super_private(super)->tmgr; - /* standard kernel thread prologue */ - me = current; - /* reparent_to_init() is done by daemonize() */ - daemonize(__FUNCTION__); - /* * do_fork() just copies task_struct into the new thread. ->fs_context * shouldn't be copied of course. This shouldn't be a problem for the * rest of the code though. */ - me->journal_info = NULL; - + current->journal_info = NULL; ctx = mgr->daemon; - ctx->tsk = me; - - /* initialization is done */ - complete(&ctx->start_finish_completion); - while (1) { try_to_freeze(); set_comm("wait"); @@ -88,14 +78,15 @@ static int ktxnmgrd(void *arg) DEFINE_WAIT(__wait); prepare_to_wait(&ctx->wait, &__wait, TASK_INTERRUPTIBLE); - /* we are asked to exit */ - if (ctx->done) - break; - schedule_timeout(ctx->timeout); + if (kthread_should_stop()) { + done = 1; + } else + schedule_timeout(ctx->timeout); finish_wait(&ctx->wait, &__wait); } + if (done) + break; set_comm("run"); - spin_lock(&ctx->guard); /* * wait timed out or ktxnmgrd was woken up by explicit request @@ -117,53 +108,12 @@ static int ktxnmgrd(void *arg) } while (ctx->rescan); spin_unlock(&ctx->guard); } - - complete_and_exit(&ctx->start_finish_completion, 0); - /* not reached. */ return 0; } #undef set_comm /** - * start_ktxnmgrd - start txnmgr daemon - * @mgr: pointer to transaction manager embedded in reiser4 super block - * - * Starts ktxnmgrd and wait untils it initializes. - */ -static int start_ktxnmgrd(struct super_block *super) -{ - txn_mgr *mgr; - ktxnmgrd_context *ctx; - - mgr = &get_super_private(super)->tmgr; - assert("zam-1015", mgr->daemon != NULL); - - ctx = mgr->daemon; - - spin_lock(&ctx->guard); - ctx->rescan = 1; - ctx->done = 0; - spin_unlock(&ctx->guard); - - /* - * prepare synchronization object to synchronize with ktxnmgrd - * initialization - */ - init_completion(&ctx->start_finish_completion); - - /* start ktxnmgrd */ - kernel_thread(ktxnmgrd, super, CLONE_KERNEL); - - /* wait for ktxnmgrd initialization */ - wait_for_completion(&ctx->start_finish_completion); - - assert("nikita-2452", ctx->tsk != NULL); - - return 0; -} - -/** * init_ktxnmgrd - initialize ktxnmgrd context and start kernel daemon * @super: pointer to super block * @@ -191,11 +141,16 @@ int init_ktxnmgrd(struct super_block *su /*kcond_init(&ctx->startup);*/ spin_lock_init(&ctx->guard); ctx->timeout = REISER4_TXNMGR_TIMEOUT; + ctx->rescan = 1; mgr->daemon = ctx; - /* start txnmgr daemon */ - start_ktxnmgrd(super); - + ctx->tsk = kthread_run(ktxnmgrd, super, "ktxnmgrd"); + if (IS_ERR(ctx->tsk)) { + int ret = PTR_ERR(ctx->tsk); + mgr->daemon = NULL; + kfree(ctx); + return RETERR(ret); + } return 0; } @@ -231,38 +186,6 @@ static int scan_mgr(struct super_block * } /** - * stop_ktxnmgrd - ktxnmgrd stop kernel thread - * @mgr: pointer to transaction manager embedded in reiser4 super block - * - * Sends stop signal to ktxnmgrd and wait until it handles it. - */ -static void stop_ktxnmgrd(txn_mgr *mgr) -{ - ktxnmgrd_context *ctx; - - assert("zam-1016", mgr != NULL); - assert("zam-1017", mgr->daemon != NULL); - - ctx = mgr->daemon; - - /* - * prepare synchronization object to synchronize with ktxnmgrd - * completion - */ - init_completion(&ctx->start_finish_completion); - - spin_lock(&ctx->guard); - ctx->tsk = NULL; - ctx->done = 1; - spin_unlock(&ctx->guard); - - wake_up(&ctx->wait); - - /* wait until ktxnmgrd finishes */ - wait_for_completion(&ctx->start_finish_completion); -} - -/** * done_ktxnmgrd - stop kernel thread and frees ktxnmgrd context * @mgr: * @@ -275,8 +198,7 @@ void done_ktxnmgrd(struct super_block *s mgr = &get_super_private(super)->tmgr; assert("zam-1012", mgr->daemon != NULL); - stop_ktxnmgrd(mgr); - + kthread_stop(mgr->daemon->tsk); kfree(mgr->daemon); mgr->daemon = NULL; } diff -puN fs/reiser4/ktxnmgrd.h~reiser4-fix-endianess fs/reiser4/ktxnmgrd.h --- devel/fs/reiser4/ktxnmgrd.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/ktxnmgrd.h 2005-09-28 22:53:11.000000000 -0700 @@ -19,8 +19,6 @@ /* in this structure all data necessary to start up, shut down and communicate * with ktxnmgrd are kept. */ struct ktxnmgrd_context { - /* completion used to synchronize shut down of ktxnmgrd */ - struct completion start_finish_completion; /* wait queue head on which ktxnmgrd sleeps */ wait_queue_head_t wait; /* spin lock protecting all fields of this structure */ @@ -31,8 +29,6 @@ struct ktxnmgrd_context { struct task_struct *tsk; /* list of all file systems served by this ktxnmgrd */ struct list_head queue; - /* is ktxnmgrd being shut down? */ - unsigned int done:1; /* should ktxnmgrd repeat scanning of atoms? */ unsigned int rescan:1; }; diff -puN fs/reiser4/lock.c~reiser4-fix-endianess fs/reiser4/lock.c --- devel/fs/reiser4/lock.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/lock.c 2005-09-28 22:53:11.000000000 -0700 @@ -230,11 +230,9 @@ lock_stack *get_current_lock_stack(void) static void wake_up_all_lopri_owners(znode * node) { lock_handle *handle; - struct list_head *pos; assert("nikita-1824", rw_zlock_is_locked(&node->lock)); - list_for_each(pos, &node->lock.owners) { - handle = list_entry(pos, lock_handle, owners_link); + list_for_each_entry(handle, &node->lock.owners, owners_link) { spin_lock_stack(handle->owner); assert("nikita-1832", handle->node == node); @@ -360,7 +358,6 @@ int znode_is_any_locked(const znode * no lock_handle *handle; lock_stack *stack; int ret; - struct list_head *pos; if (!znode_is_locked(node)) { return 0; @@ -372,8 +369,7 @@ int znode_is_any_locked(const znode * no ret = 0; - list_for_each(pos, &stack->locks) { - handle = list_entry(pos, lock_handle, locks_link); + list_for_each_entry(handle, &stack->locks, locks_link) { if (handle->node == node) { ret = 1; break; @@ -430,7 +426,7 @@ static inline int check_deadlock_conditi } /* checks lock/request compatibility */ -static int check_lock_object(lock_stack * owner) +static int can_lock_object(lock_stack * owner) { znode *node = owner->request.node; @@ -456,15 +452,6 @@ static int check_lock_object(lock_stack return 0; } -/* check for lock/request compatibility and update tree statistics */ -static int can_lock_object(lock_stack * owner) -{ - int result; - - result = check_lock_object(owner); - return result; -} - /* Setting of a high priority to the process. It clears "signaled" flags because znode locked by high-priority process can't satisfy our "deadlock condition". */ @@ -1072,7 +1059,6 @@ void invalidate_lock(lock_handle * handl znode *node = handle->node; lock_stack *owner = handle->owner; lock_stack *rq; - struct list_head *pos; assert("zam-325", owner == get_current_lock_stack()); assert("zam-103", znode_is_write_locked(node)); @@ -1090,10 +1076,8 @@ void invalidate_lock(lock_handle * handl node->lock.nr_readers = 0; /* all requestors will be informed that lock is invalidated. */ - list_for_each(pos, &node->lock.requestors) { - rq = list_entry(pos, lock_stack, requestors_link); + list_for_each_entry(rq, &node->lock.requestors, requestors_link) reiser4_wake_up(rq); - } /* We use that each unlock() will wakeup first item from requestors list; our lock stack is the last one. */ @@ -1279,7 +1263,6 @@ int lock_stack_isclean(lock_stack * owne void print_lock_stack(const char *prefix, lock_stack * owner) { lock_handle *handle; - struct list_head *pos; spin_lock_stack(owner); @@ -1296,8 +1279,7 @@ void print_lock_stack(const char *prefix printk(".... current locks:\n"); - list_for_each(pos, &owner->locks) { - handle = list_entry(pos, lock_handle, locks_link); + list_for_each_entry(handle, &owner->locks, locks_link) { if (handle->node != NULL) print_address(znode_is_rlocked(handle->node) ? "...... read" : "...... write", @@ -1311,11 +1293,11 @@ void print_lock_stack(const char *prefix * debugging functions */ -void list_check(struct list_head *head) +static void list_check(struct list_head *head) { struct list_head *pos; - list_for_each (pos, head) + list_for_each(pos, head) assert("", (pos->prev != NULL && pos->next != NULL && pos->prev->next == pos && pos->next->prev == pos)); } @@ -1351,7 +1333,6 @@ request_is_deadlock_safe(znode * node, z znode_lock_request request) { lock_stack *owner; - struct list_head *pos; owner = get_current_lock_stack(); /* @@ -1362,10 +1343,9 @@ request_is_deadlock_safe(znode * node, z znode_get_level(node) != 0) { lock_handle *item; - list_for_each(pos, &owner->locks) { + list_for_each_entry(item, &owner->locks, locks_link) { znode *other; - item = list_entry(pos, lock_handle, locks_link); other = item->node; if (znode_get_level(other) == 0) diff -puN fs/reiser4/plugin/disk_format/disk_format40.c~reiser4-fix-endianess fs/reiser4/plugin/disk_format/disk_format40.c --- devel/fs/reiser4/plugin/disk_format/disk_format40.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/disk_format/disk_format40.c 2005-09-28 22:53:11.000000000 -0700 @@ -30,42 +30,42 @@ /* functions to access fields of format40_disk_super_block */ static __u64 get_format40_block_count(const format40_disk_super_block * sb) { - return d64tocpu(&sb->block_count); + return le64_to_cpu(get_unaligned(&sb->block_count)); } static __u64 get_format40_free_blocks(const format40_disk_super_block * sb) { - return d64tocpu(&sb->free_blocks); + return le64_to_cpu(get_unaligned(&sb->free_blocks)); } static __u64 get_format40_root_block(const format40_disk_super_block * sb) { - return d64tocpu(&sb->root_block); + return le64_to_cpu(get_unaligned(&sb->root_block)); } static __u16 get_format40_tree_height(const format40_disk_super_block * sb) { - return d16tocpu(&sb->tree_height); + return le16_to_cpu(get_unaligned(&sb->tree_height)); } static __u64 get_format40_file_count(const format40_disk_super_block * sb) { - return d64tocpu(&sb->file_count); + return le64_to_cpu(get_unaligned(&sb->file_count)); } static __u64 get_format40_oid(const format40_disk_super_block * sb) { - return d64tocpu(&sb->oid); + return le64_to_cpu(get_unaligned(&sb->oid)); } static __u32 get_format40_mkfs_id(const format40_disk_super_block * sb) { - return d32tocpu(&sb->mkfs_id); + return le32_to_cpu(get_unaligned(&sb->mkfs_id)); } static __u64 get_format40_flags(const format40_disk_super_block * sb) { - return d64tocpu(&sb->flags); + return le64_to_cpu(get_unaligned(&sb->flags)); } static format40_super_info *get_sb_info(struct super_block *super) @@ -120,10 +120,10 @@ static struct buffer_head *find_a_disk_f return ERR_PTR(RETERR(-EINVAL)); } - reiser4_set_block_count(s, d64tocpu(&disk_sb->block_count)); - reiser4_set_data_blocks(s, d64tocpu(&disk_sb->block_count) - - d64tocpu(&disk_sb->free_blocks)); - reiser4_set_free_blocks(s, (d64tocpu(&disk_sb->free_blocks))); + reiser4_set_block_count(s, le64_to_cpu(get_unaligned(&disk_sb->block_count))); + reiser4_set_data_blocks(s, le64_to_cpu(get_unaligned(&disk_sb->block_count)) - + le64_to_cpu(get_unaligned(&disk_sb->free_blocks))); + reiser4_set_free_blocks(s, le64_to_cpu(get_unaligned(&disk_sb->free_blocks))); return super_bh; } @@ -436,13 +436,14 @@ static void pack_format40_super(const st assert("zam-591", data != NULL); - cputod64(reiser4_free_committed_blocks(s), &super_data->free_blocks); - cputod64(sbinfo->tree.root_block, &super_data->root_block); + put_unaligned(cpu_to_le64(reiser4_free_committed_blocks(s)), + &super_data->free_blocks); + put_unaligned(cpu_to_le64(sbinfo->tree.root_block), &super_data->root_block); - cputod64(oid_next(s), &super_data->oid); - cputod64(oids_used(s), &super_data->file_count); + put_unaligned(cpu_to_le64(oid_next(s)), &super_data->oid); + put_unaligned(cpu_to_le64(oids_used(s)), &super_data->file_count); - cputod16(sbinfo->tree.height, &super_data->tree_height); + put_unaligned(cpu_to_le16(sbinfo->tree.height), &super_data->tree_height); } /* plugin->u.format.log_super @@ -507,11 +508,14 @@ const reiser4_key *root_dir_key_format40 UNUSED_ARG) { static const reiser4_key FORMAT40_ROOT_DIR_KEY = { - .el = {{(FORMAT40_ROOT_LOCALITY << 4) | KEY_SD_MINOR}, + .el = { + cpu_to_le64((FORMAT40_ROOT_LOCALITY << 4) | KEY_SD_MINOR), #if REISER4_LARGE_KEY - {0ull}, + ON_LARGE_KEY(0ull,) #endif - {FORMAT40_ROOT_OBJECTID}, {0ull}} + cpu_to_le64(FORMAT40_ROOT_OBJECTID), + 0ull + } }; return &FORMAT40_ROOT_DIR_KEY; diff -puN fs/reiser4/plugin/file/cryptcompress.c~reiser4-fix-endianess fs/reiser4/plugin/file/cryptcompress.c --- devel/fs/reiser4/plugin/file/cryptcompress.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/file/cryptcompress.c 2005-09-28 22:53:11.000000000 -0700 @@ -739,8 +739,8 @@ static void dc_set_checksum(compression_ assert("edward-1311", cplug->checksum != NULL); checksum = cplug->checksum(tfm_stream_data(tc, OUTPUT_STREAM), tc->len); - cputod32(checksum, - (d32 *) (tfm_stream_data(tc, OUTPUT_STREAM) + tc->len)); + put_unaligned(cpu_to_le32(checksum), + (d32 *)(tfm_stream_data(tc, OUTPUT_STREAM) + tc->len)); tc->len += (int)DC_CHECKSUM_SIZE; } @@ -755,13 +755,13 @@ static int dc_check_checksum(compression if (cplug-> checksum(tfm_stream_data(tc, INPUT_STREAM), tc->len - (int)DC_CHECKSUM_SIZE) != - d32tocpu((d32 *) (tfm_stream_data(tc, INPUT_STREAM) + tc->len - - (int)DC_CHECKSUM_SIZE))) { + le32_to_cpu(get_unaligned((d32 *) (tfm_stream_data(tc, INPUT_STREAM) + tc->len - + (int)DC_CHECKSUM_SIZE)))) { warning("edward-156", "bad disk cluster checksum %d, (should be %d)\n", (int) - d32tocpu((d32 *) (tfm_stream_data(tc, INPUT_STREAM) + - tc->len - (int)DC_CHECKSUM_SIZE)), + le32_to_cpu(get_unaligned((d32 *) (tfm_stream_data(tc, INPUT_STREAM) + + tc->len - (int)DC_CHECKSUM_SIZE))), (int)cplug->checksum(tfm_stream_data(tc, INPUT_STREAM), tc->len - (int)DC_CHECKSUM_SIZE)); return 1; diff -puN fs/reiser4/plugin/file/file.c~reiser4-fix-endianess fs/reiser4/plugin/file/file.c --- devel/fs/reiser4/plugin/file/file.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/file/file.c 2005-09-28 22:53:11.000000000 -0700 @@ -2995,8 +2995,17 @@ int delete_object_unix_file(struct inode return delete_object_common(inode); } -/* Reads @count bytes from @file and calls @actor for every page read. This is - needed for loop back devices support. */ +/** + * sendfile_unix_file - sendfile of struct file_operations + * @file: file to be sent + * @ppos: position to start from + * @count: number of bytes to send + * @actor: function to copy data + * @target: where to copy read data + * + * Reads @count bytes from @file and calls @actor for every page read. This is + * needed for loop back devices support. + */ ssize_t sendfile_unix_file(struct file *file, loff_t *ppos, size_t count, read_actor_t actor, void *target) @@ -3011,14 +3020,23 @@ sendfile_unix_file(struct file *file, lo if (IS_ERR(ctx)) return PTR_ERR(ctx); + /* + * generic_file_sndfile may want to call update_atime. Grab space for + * stat data update + */ + result = reiser4_grab_space(estimate_update_common(inode), + BA_CAN_COMMIT); + if (result) + goto error; down(&inode->i_sem); inode_set_flag(inode, REISER4_HAS_MMAP); up(&inode->i_sem); uf_info = unix_file_inode_data(inode); get_nonexclusive_access(uf_info, 0); - result = do_sendfile(file, ppos, count, actor, target); + result = generic_file_sendfile(file, ppos, count, actor, target); drop_nonexclusive_access(uf_info); + error: reiser4_exit_context(ctx); return result; } diff -puN fs/reiser4/plugin/file_ops.c~reiser4-fix-endianess fs/reiser4/plugin/file_ops.c --- devel/fs/reiser4/plugin/file_ops.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/file_ops.c 2005-09-28 22:53:11.000000000 -0700 @@ -63,108 +63,11 @@ sendfile_common(struct file *file, loff_ ctx = init_context(file->f_dentry->d_inode->i_sb); if (IS_ERR(ctx)) return PTR_ERR(ctx); - result = do_sendfile(file, ppos, count, actor, target); + result = generic_file_sendfile(file, ppos, count, actor, target); reiser4_exit_context(ctx); return result; } -/* this is helper for sendfile_common and sendfile_unix_file - */ -ssize_t -do_sendfile(struct file *file, loff_t *ppos, size_t count, - read_actor_t actor, void *target) -{ - struct inode *inode; - read_descriptor_t desc; - struct page *page = NULL; - int ret = 0; - - assert("umka-3108", file != NULL); - - inode = file->f_dentry->d_inode; - - desc.error = 0; - desc.written = 0; - desc.arg.data = target; - desc.count = count; - - if (inode->i_mapping->a_ops->readpage) - return RETERR(-EINVAL); - - while (desc.count != 0) { - unsigned long read_request_size; - unsigned long index; - unsigned long offset; - loff_t file_size = i_size_read(inode); - - if (*ppos >= file_size) - break; - - index = *ppos >> PAGE_CACHE_SHIFT; - offset = *ppos & ~PAGE_CACHE_MASK; - - page_cache_readahead(inode->i_mapping, &file->f_ra, file, - offset, - (file_size + PAGE_CACHE_SIZE - - 1) >> PAGE_CACHE_SHIFT); - - /* determine valid read request size. */ - read_request_size = PAGE_CACHE_SIZE - offset; - if (read_request_size > desc.count) - read_request_size = desc.count; - if (*ppos + read_request_size >= file_size) { - read_request_size = file_size - *ppos; - if (read_request_size == 0) - break; - } - page = grab_cache_page(inode->i_mapping, index); - if (unlikely(page == NULL)) { - desc.error = RETERR(-ENOMEM); - break; - } - - if (PageUptodate(page)) - /* process locked, up-to-date page by read actor */ - goto actor; - - ret = inode->i_mapping->a_ops->readpage(file, page); - if (ret != 0) { - SetPageError(page); - ClearPageUptodate(page); - desc.error = ret; - goto fail_locked_page; - } - - lock_page(page); - if (!PageUptodate(page)) { - desc.error = RETERR(-EIO); - goto fail_locked_page; - } - - actor: - ret = actor(&desc, page, offset, read_request_size); - unlock_page(page); - page_cache_release(page); - - (*ppos) += ret; - - if (ret != read_request_size) - break; - } - - if (0) { - fail_locked_page: - unlock_page(page); - page_cache_release(page); - } - - update_atime(inode); - - if (desc.written) - return desc.written; - return desc.error; -} - /* address space operations */ /* this is common implementation of vfs's prepare_write method of struct diff -puN fs/reiser4/plugin/file_ops_readdir.c~reiser4-fix-endianess fs/reiser4/plugin/file_ops_readdir.c --- devel/fs/reiser4/plugin/file_ops_readdir.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/file_ops_readdir.c 2005-09-28 22:53:11.000000000 -0700 @@ -103,7 +103,6 @@ adjust_dir_file(struct inode *dir, const { reiser4_file_fsdata *scan; dir_pos mod_point; - struct list_head *pos; assert("nikita-2536", dir != NULL); assert("nikita-2538", de != NULL); @@ -120,10 +119,8 @@ adjust_dir_file(struct inode *dir, const * update them. */ - list_for_each(pos, get_readdir_list(dir)) { - scan = list_entry(pos, reiser4_file_fsdata, dir.linkage); + list_for_each_entry(scan, get_readdir_list(dir), dir.linkage) adjust_dir_pos(scan->back, &scan->dir.readdir, &mod_point, adj); - } spin_unlock_inode(dir); } diff -puN fs/reiser4/plugin/item/cde.c~reiser4-fix-endianess fs/reiser4/plugin/item/cde.c --- devel/fs/reiser4/plugin/item/cde.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/item/cde.c 2005-09-28 22:53:11.000000000 -0700 @@ -105,7 +105,7 @@ static inline cde_unit_header *header_at /* return number of units in compound directory item at @coord */ static int units(const coord_t * coord /* coord of item */ ) { - return d16tocpu(&formatted_at(coord)->num_of_entries); + return le16_to_cpu(get_unaligned(&formatted_at(coord)->num_of_entries)); } /* return offset of the body of @idx-th entry in @coord */ @@ -113,7 +113,7 @@ static unsigned int offset_of(const coor int idx /* index of unit */ ) { if (idx < units(coord)) - return d16tocpu(&header_at(coord, idx)->offset); + return le16_to_cpu(get_unaligned(&header_at(coord, idx)->offset)); else if (idx == units(coord)) return item_length_by_coord(coord); else @@ -126,7 +126,7 @@ static void set_offset(const coord_t * c int idx /* index of unit */ , unsigned int offset /* new offset */ ) { - cputod16((__u16) offset, &header_at(coord, idx)->offset); + put_unaligned(cpu_to_le16((__u16) offset), &header_at(coord, idx)->offset); } static void adj_offset(const coord_t * coord /* coord of item */ , @@ -137,9 +137,9 @@ static void adj_offset(const coord_t * c __u16 offset; doffset = &header_at(coord, idx)->offset; - offset = d16tocpu(doffset); + offset = le16_to_cpu(get_unaligned(doffset)); offset += delta; - cputod16((__u16) offset, doffset); + put_unaligned(cpu_to_le16((__u16) offset), doffset); } /* return pointer to @offset-th byte from the beginning of @coord */ @@ -270,7 +270,7 @@ static int expand_item(const coord_t * c /* increase counter */ entries += no; - cputod16((__u16) entries, &formatted_at(coord)->num_of_entries); + put_unaligned(cpu_to_le16((__u16) entries), &formatted_at(coord)->num_of_entries); /* [ 0 ... pos ] entries were shifted by no * ( sizeof *header ) bytes. */ @@ -335,7 +335,7 @@ static int paste_entry(const coord_t * c len = entry->name->len; if (is_longname(name, len)) { strcpy((unsigned char *)dent->name, name); - cputod8(0, &dent->name[len]); + put_unaligned(0, &dent->name[len]); } return 0; } @@ -514,7 +514,7 @@ int init_cde(coord_t * coord /* coord of coord_t * from UNUSED_ARG, reiser4_item_data * data /* structure used for insertion */ UNUSED_ARG) { - cputod16(0u, &formatted_at(coord)->num_of_entries); + put_unaligned(cpu_to_le16(0), &formatted_at(coord)->num_of_entries); return 0; } @@ -815,8 +815,8 @@ int cut_units_cde(coord_t * coord /* coo for (i = from; i < units(coord) - (int)count; ++i) adj_offset(coord, i, -header_delta - entry_delta); - cputod16((__u16) units(coord) - count, - &formatted_at(coord)->num_of_entries); + put_unaligned(cpu_to_le16((__u16) units(coord) - count), + &formatted_at(coord)->num_of_entries); if (from == 0) { /* entries from head was removed - move remaining to right */ diff -puN fs/reiser4/plugin/item/ctail.c~reiser4-fix-endianess fs/reiser4/plugin/item/ctail.c --- devel/fs/reiser4/plugin/item/ctail.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/item/ctail.c 2005-09-28 22:53:11.000000000 -0700 @@ -48,7 +48,7 @@ static ctail_item_format *ctail_formatte int cluster_shift_by_coord(const coord_t * coord) { - return d8tocpu(&ctail_formatted_at(coord)->cluster_shift); + return get_unaligned(&ctail_formatted_at(coord)->cluster_shift); } static unsigned long off_by_coord(const coord_t * coord) @@ -205,7 +205,7 @@ int init_ctail(coord_t * to /* coord of assert("edward-855", ctail_ok(from)); cluster_shift = (int)(cluster_shift_by_coord(from)); } - cputod8(cluster_shift, &ctail_formatted_at(to)->cluster_shift); + put_unaligned((d8)cluster_shift, &ctail_formatted_at(to)->cluster_shift); assert("edward-856", ctail_ok(to)); return 0; } @@ -1608,7 +1608,7 @@ int convert_ctail(flush_pos_t * pos) shift = inode_cluster_shift(item_convert_data(pos)->inode); assert("edward-1259", cluster_shift_ok(shift)); - cputod8(shift, + put_unaligned((d8)shift, &ctail_formatted_at(&pos->coord)-> cluster_shift); } diff -puN fs/reiser4/plugin/item/extent_flush_ops.c~reiser4-fix-endianess fs/reiser4/plugin/item/extent_flush_ops.c --- devel/fs/reiser4/plugin/item/extent_flush_ops.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/item/extent_flush_ops.c 2005-09-28 22:53:11.000000000 -0700 @@ -699,7 +699,6 @@ assign_real_blocknrs(flush_pos_t *flush_ jnode *node; txn_atom *atom; flush_queue_t *fq; - struct list_head *pos; int i; fq = pos_fq(flush_pos); @@ -707,8 +706,7 @@ assign_real_blocknrs(flush_pos_t *flush_ assert("vs-1468", atom); i = 0; - list_for_each(pos, protected_nodes) { - node = list_entry(pos, jnode, capture_link); + list_for_each_entry(node, protected_nodes, capture_link) { LOCK_JNODE(node); assert("vs-1132", ergo(state == UNALLOCATED_EXTENT, diff -puN fs/reiser4/plugin/item/extent.h~reiser4-fix-endianess fs/reiser4/plugin/item/extent.h --- devel/fs/reiser4/plugin/item/extent.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/item/extent.h 2005-09-28 22:53:11.000000000 -0700 @@ -44,12 +44,12 @@ typedef struct { /* macros to set/get fields of on-disk extent */ static inline reiser4_block_nr extent_get_start(const reiser4_extent * ext) { - return dblock_to_cpu(&ext->start); + return le64_to_cpu(ext->start); } static inline reiser4_block_nr extent_get_width(const reiser4_extent * ext) { - return dblock_to_cpu(&ext->width); + return le64_to_cpu(ext->width); } extern __u64 reiser4_current_block_count(void); @@ -60,14 +60,14 @@ extent_set_start(reiser4_extent * ext, r cassert(sizeof(ext->start) == 8); assert("nikita-2510", ergo(start > 1, start < reiser4_current_block_count())); - cpu_to_dblock(start, &ext->start); + put_unaligned(cpu_to_le64(start), &ext->start); } static inline void extent_set_width(reiser4_extent * ext, reiser4_block_nr width) { cassert(sizeof(ext->width) == 8); - cpu_to_dblock(width, &ext->width); + put_unaligned(cpu_to_le64(width), &ext->width); assert("nikita-2511", ergo(extent_get_start(ext) > 1, extent_get_start(ext) + width <= diff -puN fs/reiser4/plugin/item/internal.c~reiser4-fix-endianess fs/reiser4/plugin/item/internal.c --- devel/fs/reiser4/plugin/item/internal.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/item/internal.c 2005-09-28 22:53:11.000000000 -0700 @@ -67,14 +67,14 @@ void update_internal(const coord_t * coo internal_item_layout *item = internal_at(coord); assert("nikita-2959", reiser4_blocknr_is_sane(blocknr)); - cpu_to_dblock(*blocknr, &item->pointer); + put_unaligned(cpu_to_le64(*blocknr), &item->pointer); } /* return child block number stored in the internal item at @coord */ static reiser4_block_nr pointer_at(const coord_t * coord /* coord of item */ ) { assert("nikita-608", coord != NULL); - return dblock_to_cpu(&internal_at(coord)->pointer); + return le64_to_cpu(get_unaligned(&internal_at(coord)->pointer)); } /* get znode pointed to by internal @item */ diff -puN fs/reiser4/plugin/item/item.h~reiser4-fix-endianess fs/reiser4/plugin/item/item.h --- devel/fs/reiser4/plugin/item/item.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/item/item.h 2005-09-28 22:53:11.000000000 -0700 @@ -299,7 +299,7 @@ static inline item_id item_id_by_plugin( static inline char get_iplugid(item_plugin * iplug) { assert("nikita-2838", iplug != NULL); - assert("nikita-2839", 0 <= iplug->h.id && iplug->h.id < 0xff); + assert("nikita-2839", iplug->h.id < 0xff); return (char)item_id_by_plugin(iplug); } diff -puN fs/reiser4/plugin/item/sde.c~reiser4-fix-endianess fs/reiser4/plugin/item/sde.c --- devel/fs/reiser4/plugin/item/sde.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/item/sde.c 2005-09-28 22:53:11.000000000 -0700 @@ -131,7 +131,7 @@ int add_entry_de(struct inode *dir /* di build_inode_key_id(entry->obj, &dent->id); if (longname) { memcpy(dent->name, name, len); - cputod8(0, &dent->name[len]); + put_unaligned(0, &dent->name[len]); } return 0; } diff -puN fs/reiser4/plugin/item/static_stat.c~reiser4-fix-endianess fs/reiser4/plugin/item/static_stat.c --- devel/fs/reiser4/plugin/item/static_stat.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/item/static_stat.c 2005-09-28 22:53:11.000000000 -0700 @@ -83,7 +83,7 @@ int init_inode_static_sd(struct inode *i result = 0; sd_base = (reiser4_stat_data_base *) sd; state = reiser4_inode_data(inode); - mask = d16tocpu(&sd_base->extmask); + mask = le16_to_cpu(get_unaligned(&sd_base->extmask)); bigmask = mask; inode_set_flag(inode, REISER4_SDLEN_KNOWN); @@ -132,7 +132,7 @@ int init_inode_static_sd(struct inode *i result = RETERR(-EINVAL); break; } - mask = d16tocpu((d16 *) sd); + mask = le16_to_cpu(get_unaligned((d16 *)sd)); bigmask <<= 16; bigmask |= mask; move_on(&len, &sd, sizeof(d16)); @@ -218,7 +218,8 @@ int save_static_sd(struct inode *inode / result = 0; emask = reiser4_inode_data(inode)->extmask; sd_base = (reiser4_stat_data_base *) * area; - cputod16((unsigned)(emask & 0xffff), &sd_base->extmask); + put_unaligned(cpu_to_le16((__u16)(emask & 0xffff)), &sd_base->extmask); + /*cputod16((unsigned)(emask & 0xffff), &sd_base->extmask);*/ *area += sizeof *sd_base; len = 0xffffffffu; @@ -235,8 +236,10 @@ int save_static_sd(struct inode *inode / if (result) break; } else { - cputod16((unsigned)(emask & 0xffff), - (d16 *) * area); + put_unaligned(cpu_to_le16((__u16)(emask & 0xffff)), + (d16 *)(*area)); + /*cputod16((unsigned)(emask & 0xffff), + (d16 *) * area);*/ *area += sizeof(d16); } } @@ -255,9 +258,9 @@ static int present_lw_sd(struct inode *i sd_lw = (reiser4_light_weight_stat *) * area; - inode->i_mode = d16tocpu(&sd_lw->mode); - inode->i_nlink = d32tocpu(&sd_lw->nlink); - inode->i_size = d64tocpu(&sd_lw->size); + inode->i_mode = le16_to_cpu(get_unaligned(&sd_lw->mode)); + inode->i_nlink = le32_to_cpu(get_unaligned(&sd_lw->nlink)); + inode->i_size = le64_to_cpu(get_unaligned(&sd_lw->size)); if ((inode->i_mode & S_IFMT) == (S_IFREG | S_IFIFO)) { inode->i_mode &= ~S_IFIFO; inode_set_flag(inode, REISER4_PART_CONV); @@ -287,9 +290,9 @@ static int save_lw_sd(struct inode *inod sd = (reiser4_light_weight_stat *) * area; delta = inode_get_flag(inode, REISER4_PART_CONV) ? S_IFIFO : 0; - cputod16(inode->i_mode | delta, &sd->mode); - cputod32(inode->i_nlink, &sd->nlink); - cputod64((__u64) inode->i_size, &sd->size); + put_unaligned(cpu_to_le16(inode->i_mode | delta), &sd->mode); + put_unaligned(cpu_to_le32(inode->i_nlink), &sd->nlink); + put_unaligned(cpu_to_le64((__u64) inode->i_size), &sd->size); *area += sizeof *sd; return 0; } @@ -309,15 +312,15 @@ static int present_unix_sd(struct inode sd = (reiser4_unix_stat *) * area; - inode->i_uid = d32tocpu(&sd->uid); - inode->i_gid = d32tocpu(&sd->gid); - inode->i_atime.tv_sec = d32tocpu(&sd->atime); - inode->i_mtime.tv_sec = d32tocpu(&sd->mtime); - inode->i_ctime.tv_sec = d32tocpu(&sd->ctime); + inode->i_uid = le32_to_cpu(get_unaligned(&sd->uid)); + inode->i_gid = le32_to_cpu(get_unaligned(&sd->gid)); + inode->i_atime.tv_sec = le32_to_cpu(get_unaligned(&sd->atime)); + inode->i_mtime.tv_sec = le32_to_cpu(get_unaligned(&sd->mtime)); + inode->i_ctime.tv_sec = le32_to_cpu(get_unaligned(&sd->ctime)); if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) - inode->i_rdev = d64tocpu(&sd->u.rdev); + inode->i_rdev = le64_to_cpu(get_unaligned(&sd->u.rdev)); else - inode_set_bytes(inode, (loff_t) d64tocpu(&sd->u.bytes)); + inode_set_bytes(inode, (loff_t) le64_to_cpu(get_unaligned(&sd->u.bytes))); move_on(len, area, sizeof *sd); return 0; } else @@ -353,15 +356,15 @@ static int save_unix_sd(struct inode *in assert("nikita-644", *area != NULL); sd = (reiser4_unix_stat *) * area; - cputod32(inode->i_uid, &sd->uid); - cputod32(inode->i_gid, &sd->gid); - cputod32((__u32) inode->i_atime.tv_sec, &sd->atime); - cputod32((__u32) inode->i_ctime.tv_sec, &sd->ctime); - cputod32((__u32) inode->i_mtime.tv_sec, &sd->mtime); + put_unaligned(cpu_to_le32(inode->i_uid), &sd->uid); + put_unaligned(cpu_to_le32(inode->i_gid), &sd->gid); + put_unaligned(cpu_to_le32((__u32) inode->i_atime.tv_sec), &sd->atime); + put_unaligned(cpu_to_le32((__u32) inode->i_ctime.tv_sec), &sd->ctime); + put_unaligned(cpu_to_le32((__u32) inode->i_mtime.tv_sec), &sd->mtime); if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) - cputod64(inode->i_rdev, &sd->u.rdev); + put_unaligned(cpu_to_le64(inode->i_rdev), &sd->u.rdev); else - cputod64((__u64) inode_get_bytes(inode), &sd->u.bytes); + put_unaligned(cpu_to_le64((__u64) inode_get_bytes(inode)), &sd->u.bytes); *area += sizeof *sd; return 0; } @@ -376,9 +379,9 @@ present_large_times_sd(struct inode *ino sd_lt = (reiser4_large_times_stat *) * area; - inode->i_atime.tv_nsec = d32tocpu(&sd_lt->atime); - inode->i_mtime.tv_nsec = d32tocpu(&sd_lt->mtime); - inode->i_ctime.tv_nsec = d32tocpu(&sd_lt->ctime); + inode->i_atime.tv_nsec = le32_to_cpu(get_unaligned(&sd_lt->atime)); + inode->i_mtime.tv_nsec = le32_to_cpu(get_unaligned(&sd_lt->mtime)); + inode->i_ctime.tv_nsec = le32_to_cpu(get_unaligned(&sd_lt->ctime)); move_on(len, area, sizeof *sd_lt); return 0; @@ -405,9 +408,9 @@ save_large_times_sd(struct inode *inode sd = (reiser4_large_times_stat *) * area; - cputod32((__u32) inode->i_atime.tv_nsec, &sd->atime); - cputod32((__u32) inode->i_ctime.tv_nsec, &sd->ctime); - cputod32((__u32) inode->i_mtime.tv_nsec, &sd->mtime); + put_unaligned(cpu_to_le32((__u32) inode->i_atime.tv_nsec), &sd->atime); + put_unaligned(cpu_to_le32((__u32) inode->i_ctime.tv_nsec), &sd->ctime); + put_unaligned(cpu_to_le32((__u32) inode->i_mtime.tv_nsec), &sd->mtime); *area += sizeof *sd; return 0; @@ -517,7 +520,7 @@ static int present_flags_sd(struct inode reiser4_flags_stat *sd; sd = (reiser4_flags_stat *) * area; - inode->i_flags = d32tocpu(&sd->flags); + inode->i_flags = le32_to_cpu(get_unaligned(&sd->flags)); move_on(len, area, sizeof *sd); return 0; } else @@ -541,7 +544,7 @@ static int save_flags_sd(struct inode *i assert("nikita-652", *area != NULL); sd = (reiser4_flags_stat *) * area; - cputod32(inode->i_flags, &sd->flags); + put_unaligned(cpu_to_le32(inode->i_flags), &sd->flags); *area += sizeof *sd; return 0; } @@ -570,7 +573,7 @@ static int present_plugin_sd(struct inod sd = (reiser4_plugin_stat *) * area; mask = 0; - num_of_plugins = d16tocpu(&sd->plugins_no); + num_of_plugins = le16_to_cpu(get_unaligned(&sd->plugins_no)); move_on(len, area, sizeof *sd); result = 0; for (i = 0; i < num_of_plugins; ++i) { @@ -582,7 +585,7 @@ static int present_plugin_sd(struct inod if (*len < (int)sizeof *slot) return not_enough_space(inode, "additional plugin"); - memb = d16tocpu(&slot->pset_memb); + memb = le16_to_cpu(get_unaligned(&slot->pset_memb)); type = pset_member_to_type_unsafe(memb); if (type == REISER4_PLUGIN_TYPES) { warning("nikita-3502", @@ -593,7 +596,7 @@ static int present_plugin_sd(struct inod plugin = plugin_by_disk_id(tree_by_inode(inode), type, &slot->id); if (plugin == NULL) - return unknown_plugin(d16tocpu(&slot->id), inode); + return unknown_plugin(le16_to_cpu(get_unaligned(&slot->id)), inode); /* plugin is loaded into inode, mark this into inode's bitmask of loaded non-standard plugins */ @@ -755,8 +758,8 @@ static int save_plug(reiser4_plugin * pl if (!(reiser4_inode_data(inode)->plugin_mask & (1 << memb))) return 0; slot = (reiser4_plugin_slot *) * area; - cputod16(memb, &slot->pset_memb); - cputod16((unsigned)plugin->h.id, &slot->id); + put_unaligned(cpu_to_le16(memb), &slot->pset_memb); + put_unaligned(cpu_to_le16(plugin->h.id), &slot->id); fake_len = (int)0xffff; move_on(&fake_len, area, sizeof *slot); ++*count; @@ -798,7 +801,7 @@ static int save_plugin_sd(struct inode * break; } - cputod16((unsigned)num_of_plugins, &sd->plugins_no); + put_unaligned(cpu_to_le16((__u16)num_of_plugins), &sd->plugins_no); return result; } @@ -824,7 +827,7 @@ static int crypto_stat_to_inode(struct i return RETERR(-ENOMEM); } /* load inode crypto-stat */ - stat->keysize = d16tocpu(&sd->keysize); + stat->keysize = le16_to_cpu(get_unaligned(&sd->keysize)); memcpy(stat->keyid, sd->keyid, (size_t) size); cryptcompress_inode_data(inode)->crypt = stat; @@ -894,7 +897,7 @@ static int save_crypto_sd(struct inode * assert("edward-15", stat != NULL); /* copy everything but private key to the disk stat-data */ - cputod16(stat->keysize, &sd->keysize); + put_unaligned(cpu_to_le16(stat->keysize), &sd->keysize); memcpy(sd->keyid, stat->keyid, (size_t) dplug->dsize); inode_set_flag(inode, REISER4_CRYPTO_STAT_LOADED); } else { diff -puN fs/reiser4/plugin/item/static_stat.h~reiser4-fix-endianess fs/reiser4/plugin/item/static_stat.h --- devel/fs/reiser4/plugin/item/static_stat.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/item/static_stat.h 2005-09-28 22:53:11.000000000 -0700 @@ -100,34 +100,34 @@ typedef enum { /* minimal stat-data. This allows to support light-weight files. */ typedef struct reiser4_stat_data_base { - /* 0 */ d16 extmask; + /* 0 */ __le16 extmask; /* 2 */ } PACKED reiser4_stat_data_base; typedef struct reiser4_light_weight_stat { - /* 0 */ d16 mode; - /* 2 */ d32 nlink; - /* 8 */ d64 size; + /* 0 */ __le16 mode; + /* 2 */ __le32 nlink; + /* 8 */ __le64 size; /* size in bytes */ /* 16 */ } PACKED reiser4_light_weight_stat; typedef struct reiser4_unix_stat { /* owner id */ - /* 0 */ d32 uid; + /* 0 */ __le32 uid; /* group id */ - /* 4 */ d32 gid; + /* 4 */ __le32 gid; /* access time */ - /* 8 */ d32 atime; + /* 8 */ __le32 atime; /* modification time */ - /* 12 */ d32 mtime; + /* 12 */ __le32 mtime; /* change time */ - /* 16 */ d32 ctime; + /* 16 */ __le32 ctime; union { /* minor:major for device files */ - /* 20 */ d64 rdev; + /* 20 */ __le64 rdev; /* bytes used by file */ - /* 20 */ d64 bytes; + /* 20 */ __le64 bytes; } u; /* 28 */ } PACKED reiser4_unix_stat; @@ -138,15 +138,15 @@ typedef struct reiser4_symlink_stat { } PACKED reiser4_symlink_stat; typedef struct reiser4_plugin_slot { - /* 0 */ d16 pset_memb; - /* 2 */ d16 id; + /* 0 */ __le16 pset_memb; + /* 2 */ __le16 id; /* 4 *//* here plugin stores its persistent state */ } PACKED reiser4_plugin_slot; /* stat-data extension for files with non-standard plugin. */ typedef struct reiser4_plugin_stat { /* number of additional plugins, associated with this object */ - /* 0 */ d16 plugins_no; + /* 0 */ __le16 plugins_no; /* 2 */ reiser4_plugin_slot slot[0]; /* 2 */ } PACKED reiser4_plugin_stat; @@ -155,13 +155,13 @@ typedef struct reiser4_plugin_stat { * bit mask. If need arise, this can be replaced with variable width * bitmask. */ typedef struct reiser4_flags_stat { - /* 0 */ d32 flags; + /* 0 */ __le32 flags; /* 4 */ } PACKED reiser4_flags_stat; typedef struct reiser4_capabilities_stat { - /* 0 */ d32 effective; - /* 8 */ d32 permitted; + /* 0 */ __le32 effective; + /* 8 */ __le32 permitted; /* 16 */ } PACKED reiser4_capabilities_stat; diff -puN fs/reiser4/plugin/node/node40.c~reiser4-fix-endianess fs/reiser4/plugin/node/node40.c --- devel/fs/reiser4/plugin/node/node40.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/node/node40.c 2005-09-28 22:53:11.000000000 -0700 @@ -50,67 +50,20 @@ static inline node40_header *node40_node } /* functions to get/set fields of node40_header */ +#define nh40_get_magic(nh) le32_to_cpu(get_unaligned(&(nh)->magic)) +#define nh40_get_free_space(nh) le16_to_cpu(get_unaligned(&(nh)->free_space)) +#define nh40_get_free_space_start(nh) le16_to_cpu(get_unaligned(&(nh)->free_space_start)) +#define nh40_get_level(nh) get_unaligned(&(nh)->level) +#define nh40_get_num_items(nh) le16_to_cpu(get_unaligned(&(nh)->nr_items)) +#define nh40_get_flush_id(nh) le64_to_cpu(get_unaligned(&(nh)->flush_id)) + +#define nh40_set_magic(nh, value) put_unaligned(cpu_to_le32(value), &(nh)->magic) +#define nh40_set_free_space(nh, value) put_unaligned(cpu_to_le16(value), &(nh)->free_space) +#define nh40_set_free_space_start(nh, value) put_unaligned(cpu_to_le16(value), &(nh)->free_space_start) +#define nh40_set_level(nh, value) put_unaligned(value, &(nh)->level) +#define nh40_set_num_items(nh, value) put_unaligned(cpu_to_le16(value), &(nh)->nr_items) +#define nh40_set_mkfs_id(nh, value) put_unaligned(cpu_to_le32(value), &(nh)->mkfs_id) -static __u32 nh40_get_magic(node40_header * nh) -{ - return d32tocpu(&nh->magic); -} - -static void nh40_set_magic(node40_header * nh, __u32 magic) -{ - cputod32(magic, &nh->magic); -} - -static void nh40_set_free_space(node40_header * nh, unsigned value) -{ - cputod16(value, &nh->free_space); - /*node->free_space = value; */ -} - -static inline unsigned nh40_get_free_space(node40_header * nh) -{ - return d16tocpu(&nh->free_space); -} - -static void nh40_set_free_space_start(node40_header * nh, unsigned value) -{ - cputod16(value, &nh->free_space_start); -} - -static inline unsigned nh40_get_free_space_start(node40_header * nh) -{ - return d16tocpu(&nh->free_space_start); -} - -static inline void nh40_set_level(node40_header * nh, unsigned value) -{ - cputod8(value, &nh->level); -} - -static unsigned nh40_get_level(node40_header * nh) -{ - return d8tocpu(&nh->level); -} - -static void nh40_set_num_items(node40_header * nh, unsigned value) -{ - cputod16(value, &nh->nr_items); -} - -static inline unsigned nh40_get_num_items(node40_header * nh) -{ - return d16tocpu(&nh->nr_items); -} - -static void nh40_set_mkfs_id(node40_header * nh, __u32 id) -{ - cputod32(id, &nh->mkfs_id); -} - -static inline __u64 nh40_get_flush_id(node40_header * nh) -{ - return d64tocpu(&nh->flush_id); -} /* plugin field of node header should be read/set by plugin_by_disk_id/save_disk_plugin */ @@ -131,15 +84,9 @@ static inline item_header40 *node40_ih_a } /* functions to get/set fields of item_header40 */ -static void ih40_set_offset(item_header40 * ih, unsigned offset) -{ - cputod16(offset, &ih->offset); -} +#define ih40_get_offset(ih) le16_to_cpu(get_unaligned(&(ih)->offset)) -static inline unsigned ih40_get_offset(item_header40 * ih) -{ - return d16tocpu(&ih->offset); -} +#define ih40_set_offset(ih, value) put_unaligned(cpu_to_le16(value), &(ih)->offset) /* plugin field of item header should be read/set by plugin_by_disk_id/save_disk_plugin */ @@ -457,7 +404,7 @@ node_search_result lookup_node40(znode * if (unlikely(iplug == NULL)) { warning("nikita-588", "Unknown plugin %i", - d16tocpu(&bstop->plugin_id)); + le16_to_cpu(get_unaligned(&bstop->plugin_id))); print_key("key", key); print_znode("node", node); print_coord_content("coord", coord); @@ -716,12 +663,14 @@ int parse_node40(znode * node /* node to { node40_header *header; int result; + d8 level; header = node40_node_header((znode *) node); result = -EIO; - if (unlikely(((__u8) znode_get_level(node)) != nh40_get_level(header))) + level = nh40_get_level(header); + if (unlikely(((__u8) znode_get_level(node)) != level)) warning("nikita-494", "Wrong level found in node: %i != %i", - znode_get_level(node), nh40_get_level(header)); + znode_get_level(node), level); else if (unlikely(nh40_get_magic(header) != REISER4_NODE_MAGIC)) warning("nikita-495", "Wrong magic in tree node: want %x, got %x", @@ -2550,7 +2499,7 @@ void *shift_check_prepare(const znode * ih = node40_ih_at_coord(&coord); data[i].key = ih->key; - data[i].plugin_id = d16tocpu(&ih->plugin_id); + data[i].plugin_id = le16_to_cpu(get_unaligned(&ih->plugin_id)); switch (data[i].plugin_id) { case CTAIL_ID: case FORMATTING_ID: @@ -2580,7 +2529,7 @@ void *shift_check_prepare(const znode * assert("vs-1589", data[i - 1].plugin_id == - d16tocpu(&ih->plugin_id)); + le16_to_cpu(get_unaligned(&ih->plugin_id))); switch (data[i - 1].plugin_id) { case CTAIL_ID: case FORMATTING_ID: @@ -2610,7 +2559,7 @@ void *shift_check_prepare(const znode * ih = node40_ih_at_coord(&coord); data[i].key = ih->key; - data[i].plugin_id = d16tocpu(&ih->plugin_id); + data[i].plugin_id = le16_to_cpu(get_unaligned(&ih->plugin_id)); switch (data[i].plugin_id) { case CTAIL_ID: case FORMATTING_ID: @@ -2678,7 +2627,7 @@ void shift_check(void *vp, const znode * assert("vs-1611", i == item_pos); assert("vs-1590", keyeq(&ih->key, &data[i].key)); assert("vs-1591", - d16tocpu(&ih->plugin_id) == data[i].plugin_id); + le16_to_cpu(get_unaligned(&ih->plugin_id)) == data[i].plugin_id); if ((i < (node40_num_of_items_internal(left) - 1)) || !mergeable) { switch (data[i].plugin_id) { @@ -2731,7 +2680,7 @@ void shift_check(void *vp, const znode * ih = node40_ih_at_coord(&coord); assert("vs-1589", - data[i - 1].plugin_id == d16tocpu(&ih->plugin_id)); + data[i - 1].plugin_id == le16_to_cpu(get_unaligned(&ih->plugin_id))); assert("vs-1608", last_bytes != 0); switch (data[i - 1].plugin_id) { case CTAIL_ID: @@ -2769,7 +2718,7 @@ void shift_check(void *vp, const znode * assert("vs-1612", keyeq(&ih->key, &data[i].key)); assert("vs-1613", - d16tocpu(&ih->plugin_id) == data[i].plugin_id); + le16_to_cpu(get_unaligned(&ih->plugin_id)) == data[i].plugin_id); switch (data[i].plugin_id) { case CTAIL_ID: case FORMATTING_ID: @@ -2950,12 +2899,12 @@ int max_item_size_node40(void) } /* plugin->u.node.set_item_plugin */ -int set_item_plugin_node40(coord_t * coord, item_id id) +int set_item_plugin_node40(coord_t *coord, item_id id) { item_header40 *ih; ih = node40_ih_at_coord(coord); - cputod16(id, &ih->plugin_id); + put_unaligned(cpu_to_le16(id), &ih->plugin_id); coord->iplugid = id; return 0; } diff -puN fs/reiser4/plugin/node/node.h~reiser4-fix-endianess fs/reiser4/plugin/node/node.h --- devel/fs/reiser4/plugin/node/node.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/node/node.h 2005-09-28 22:53:11.000000000 -0700 @@ -251,20 +251,22 @@ extern void print_node_content(const cha extern void indent_znode(const znode * node); typedef struct common_node_header { - /* identifier of node plugin. Must be located at the very beginning - of a node. */ - d16 plugin_id; + /* + * identifier of node plugin. Must be located at the very beginning of + * a node. + */ + __le16 plugin_id; } common_node_header; /* __REISER4_NODE_H__ */ #endif /* - Local variables: - c-indentation-style: "K&R" - mode-name: "LC" - c-basic-offset: 8 - tab-width: 8 - fill-column: 120 - scroll-step: 1 - End: -*/ + * Local variables: + * c-indentation-style: "K&R" + * mode-name: "LC" + * c-basic-offset: 8 + * tab-width: 8 + * fill-column: 79 + * scroll-step: 1 + * End: + */ diff -puN fs/reiser4/plugin/object.h~reiser4-fix-endianess fs/reiser4/plugin/object.h --- devel/fs/reiser4/plugin/object.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/object.h 2005-09-28 22:53:11.000000000 -0700 @@ -100,8 +100,6 @@ reiser4_block_nr dir_estimate_unlink_com /* these are essential parts of common implementations, they are to make customized implementations easier */ -ssize_t do_sendfile(struct file *, loff_t *ppos, size_t count, - read_actor_t, void *target); int do_prepare_write(struct file *, struct page *, unsigned from, unsigned to); /* merely useful functions */ diff -puN fs/reiser4/plugin/plugin.c~reiser4-fix-endianess fs/reiser4/plugin/plugin.c --- devel/fs/reiser4/plugin/plugin.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/plugin.c 2005-09-28 22:53:11.000000000 -0700 @@ -254,7 +254,7 @@ int is_plugin_id_valid(reiser4_plugin_ty reiser4_plugin_id id /* plugin id */ ) { assert("nikita-1653", is_type_id_valid(type_id)); - return ((id < plugins[type_id].builtin_num) && (id >= 0)); + return id < plugins[type_id].builtin_num; } /* lookup plugin by scanning tables */ @@ -304,14 +304,20 @@ reiser4_plugin *plugin_by_unsafe_id(reis return NULL; } -/* convert plugin id to the disk format */ -int save_plugin_id(reiser4_plugin * plugin /* plugin to convert */ , - d16 * area /* where to store result */ ) +/** + * save_plugin_id - store plugin id in disk format + * @plugin: plugin to convert + * @area: where to store result + * + * Puts id of @plugin in little endian format to address @area. + */ +int save_plugin_id(reiser4_plugin *plugin /* plugin to convert */ , + d16 *area /* where to store result */ ) { assert("nikita-1261", plugin != NULL); assert("nikita-1262", area != NULL); - cputod16((__u16) plugin->h.id, area); + put_unaligned(cpu_to_le16(plugin->h.id), area); return 0; } diff -puN fs/reiser4/plugin/plugin_header.h~reiser4-fix-endianess fs/reiser4/plugin/plugin_header.h --- devel/fs/reiser4/plugin/plugin_header.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/plugin_header.h 2005-09-28 22:53:11.000000000 -0700 @@ -102,34 +102,35 @@ static inline reiser4_plugin *plugin_by_ extern reiser4_plugin *plugin_by_unsafe_id(reiser4_plugin_type type_id, reiser4_plugin_id id); -/* get plugin whose id is stored in disk format */ -static inline reiser4_plugin *plugin_by_disk_id(reiser4_tree * tree UNUSED_ARG /* tree, - * plugin - * belongs - * to */ , - reiser4_plugin_type type_id /* plugin type - * id */ , - d16 * - did - /* plugin id in disk format */ ) +/** + * plugin_by_disk_id - get reiser4_plugin + * @type_id: plugin type id + * @did: plugin id in disk format + * + * Returns reiser4_plugin by plugin type id an dplugin_id. + */ +static inline reiser4_plugin *plugin_by_disk_id(reiser4_tree * tree UNUSED_ARG, + reiser4_plugin_type type_id, + __le16 *plugin_id) { - /* what we should do properly is to maintain within each - file-system a dictionary that maps on-disk plugin ids to - "universal" ids. This dictionary will be resolved on mount - time, so that this function will perform just one additional - array lookup. */ - return plugin_by_unsafe_id(type_id, d16tocpu(did)); + /* + * what we should do properly is to maintain within each file-system a + * dictionary that maps on-disk plugin ids to "universal" ids. This + * dictionary will be resolved on mount time, so that this function + * will perform just one additional array lookup. + */ + return plugin_by_unsafe_id(type_id, le16_to_cpu(*plugin_id)); } /* __PLUGIN_HEADER_H__ */ #endif -/* Make Linus happy. - Local variables: - c-indentation-style: "K&R" - mode-name: "LC" - c-basic-offset: 8 - tab-width: 8 - fill-column: 120 - End: -*/ +/* + * Local variables: + * c-indentation-style: "K&R" + * mode-name: "LC" + * c-basic-offset: 8 + * tab-width: 8 + * fill-column: 79 + * End: + */ diff -puN fs/reiser4/plugin/space/bitmap.c~reiser4-fix-endianess fs/reiser4/plugin/space/bitmap.c --- devel/fs/reiser4/plugin/space/bitmap.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/plugin/space/bitmap.c 2005-09-28 22:53:11.000000000 -0700 @@ -110,7 +110,7 @@ static inline __u32 bnode_commit_crc(con data = jdata(bnode->cjnode); assert("vpf-261", data != NULL); - return d32tocpu((d32 *) data); + return le32_to_cpu(get_unaligned((d32 *)data)); } static inline void bnode_set_commit_crc(struct bitmap_node *bnode, __u32 crc) @@ -120,7 +120,7 @@ static inline void bnode_set_commit_crc( data = jdata(bnode->cjnode); assert("vpf-261", data != NULL); - cputod32(crc, (d32 *) data); + put_unaligned(cpu_to_le32(crc), (d32 *)data); } /* ZAM-FIXME-HANS: is the idea that this might be a union someday? having diff -puN fs/reiser4/reiser4.h~reiser4-fix-endianess fs/reiser4/reiser4.h --- devel/fs/reiser4/reiser4.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/reiser4.h 2005-09-28 22:53:11.000000000 -0700 @@ -97,7 +97,7 @@ extern const int REISER4_MAGIC_OFFSET; / #define REISER4_USE_ENTD (1) /* Using of emergency flush is an option. */ -#define REISER4_USE_EFLUSH (0) +#define REISER4_USE_EFLUSH (1) /* key allocation is Plan-A */ #define REISER4_PLANA_KEY_ALLOCATION (1) diff -puN fs/reiser4/safe_link.c~reiser4-fix-endianess fs/reiser4/safe_link.c --- devel/fs/reiser4/safe_link.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/safe_link.c 2005-09-28 22:53:11.000000000 -0700 @@ -168,7 +168,7 @@ int safe_link_add(struct inode *inode, r * expand item. */ length += sizeof(sl.size); - cputod64(inode->i_size, &sl.size); + put_unaligned(cpu_to_le64(inode->i_size), &sl.size); } tree = tree_by_inode(inode); build_link_key(tree, get_inode_oid(inode), link, &key); @@ -229,7 +229,7 @@ static int safe_link_iter_next(safe_link ctx->link = get_key_offset(&ctx->key); ctx->sdkey = sl.sdkey; if (ctx->link == SAFE_TRUNCATE) - ctx->size = d64tocpu(&sl.size); + ctx->size = le64_to_cpu(get_unaligned(&sl.size)); } return result; } diff -puN fs/reiser4/spin_macros.h~reiser4-fix-endianess fs/reiser4/spin_macros.h --- devel/fs/reiser4/spin_macros.h~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/spin_macros.h 2005-09-28 22:53:11.000000000 -0700 @@ -82,6 +82,7 @@ typedef struct reiser4_rw_data { static inline void spin_ ## NAME ## _init(TYPE *x) \ { \ __ODCA("nikita-2987", x != NULL); \ + cassert(sizeof(x->FIELD) != 0); \ memset(& x->FIELD, 0, sizeof x->FIELD); \ spin_lock_init(& x->FIELD.lock); \ } \ diff -puN fs/reiser4/status_flags.c~reiser4-fix-endianess fs/reiser4/status_flags.c --- devel/fs/reiser4/status_flags.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/status_flags.c 2005-09-28 22:53:11.000000000 -0700 @@ -104,7 +104,7 @@ int reiser4_status_query(u64 * status, u } statuspage = (struct reiser4_status *) kmap_atomic(get_super_private(sb)->status_page, KM_USER0); - switch ((long)d64tocpu(&statuspage->status)) { // FIXME: this cast is a hack for 32 bit arches to work. + switch ((long)le64_to_cpu(get_unaligned(&statuspage->status))) { // FIXME: this cast is a hack for 32 bit arches to work. case REISER4_STATUS_OK: retval = REISER4_STATUS_MOUNT_OK; break; @@ -122,9 +122,9 @@ int reiser4_status_query(u64 * status, u } if (status) - *status = d64tocpu(&statuspage->status); + *status = le64_to_cpu(get_unaligned(&statuspage->status)); if (extended) - *extended = d64tocpu(&statuspage->extended_status); + *extended = le64_to_cpu(get_unaligned(&statuspage->extended_status)); kunmap_atomic((char *)statuspage, KM_USER0); return retval; @@ -132,7 +132,7 @@ int reiser4_status_query(u64 * status, u /* This function should be called when something bad happens (e.g. from reiser4_panic). It fills the status structure and tries to push it to disk. */ -int reiser4_status_write(u64 status, u64 extended_status, char *message) +int reiser4_status_write(__u64 status, __u64 extended_status, char *message) { struct super_block *sb = reiser4_get_current_sb(); struct reiser4_status *statuspage; @@ -144,28 +144,10 @@ int reiser4_status_write(u64 status, u64 statuspage = (struct reiser4_status *) kmap_atomic(get_super_private(sb)->status_page, KM_USER0); - cputod64(status, &statuspage->status); - cputod64(extended_status, &statuspage->extended_status); + put_unaligned(cpu_to_le64(status), &statuspage->status); + put_unaligned(cpu_to_le64(extended_status), &statuspage->extended_status); strncpy(statuspage->texterror, message, REISER4_TEXTERROR_LEN); -#ifdef CONFIG_FRAME_POINTER -#define GETFRAME(no) \ - cputod64((unsigned long)__builtin_return_address(no), \ - &statuspage->stacktrace[no]) - - GETFRAME(0); - GETFRAME(1); - GETFRAME(2); - GETFRAME(3); - GETFRAME(4); - GETFRAME(5); - GETFRAME(6); - GETFRAME(7); - GETFRAME(8); - GETFRAME(9); - -#undef GETFRAME -#endif kunmap_atomic((char *)statuspage, KM_USER0); bio->bi_bdev = sb->s_bdev; bio->bi_io_vec[0].bv_page = get_super_private(sb)->status_page; diff -puN fs/reiser4/super_ops.c~reiser4-fix-endianess fs/reiser4/super_ops.c --- devel/fs/reiser4/super_ops.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/super_ops.c 2005-09-28 22:53:11.000000000 -0700 @@ -489,10 +489,12 @@ static int fill_super(struct super_block init_txnmgr(&sbinfo->tmgr); /* initialize ktxnmgrd context and start kernel thread ktxnmrgd */ - init_ktxnmgrd(super); + if ((result = init_ktxnmgrd(super)) != 0) + goto failed_init_ktxnmgrd; /* initialize entd context and start kernel thread entd */ - init_entd(super); + if ((result = init_entd(super)) != 0) + goto failed_init_entd; /* initialize address spaces for formatted nodes and bitmaps */ if ((result = init_formatted_fake(super)) != 0) @@ -525,7 +527,9 @@ static int fill_super(struct super_block done_formatted_fake(super); failed_init_formatted_fake: done_entd(super); + failed_init_entd: done_ktxnmgrd(super); + failed_init_ktxnmgrd: done_txnmgr(&sbinfo->tmgr); failed_init_read_super: failed_init_super_data: diff -puN fs/reiser4/txnmgr.c~reiser4-fix-endianess fs/reiser4/txnmgr.c --- devel/fs/reiser4/txnmgr.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/txnmgr.c 2005-09-28 22:53:11.000000000 -0700 @@ -883,10 +883,8 @@ static int atom_should_commit_asap(const static jnode *find_first_dirty_in_list(struct list_head *head, int flags) { jnode *first_dirty; - struct list_head *pos; - list_for_each(pos, head) { - first_dirty = list_entry(pos, jnode, capture_link); + list_for_each_entry(first_dirty, head, capture_link) { if (!(flags & JNODE_FLUSH_COMMIT)) { /* * skip jnodes which "heard banshee" or having active @@ -1227,7 +1225,6 @@ int txnmgr_force_commit_all(struct super txn_handle *txnh; unsigned long start_time = jiffies; reiser4_context *ctx = get_current_context(); - struct list_head *pos; assert("nikita-2965", lock_stack_isclean(get_current_lock_stack())); assert("nikita-3058", commit_check_locks()); @@ -1242,8 +1239,7 @@ int txnmgr_force_commit_all(struct super spin_lock_txnmgr(mgr); - list_for_each(pos, &mgr->atoms_list) { - atom = list_entry(pos, txn_atom, atom_link); + list_for_each_entry(atom, &mgr->atoms_list, atom_link) { LOCK_ATOM(atom); /* Commit any atom which can be committed. If @commit_new_atoms @@ -1369,7 +1365,6 @@ static int txn_try_to_fuse_small_atom(tx int atom_stage; txn_atom *atom_2; int repeat; - struct list_head *pos; assert("zam-1051", atom->stage < ASTAGE_PRE_COMMIT); @@ -1385,8 +1380,7 @@ static int txn_try_to_fuse_small_atom(tx goto out; } - list_for_each(pos, &tmgr->atoms_list) { - atom_2 = list_entry(pos, txn_atom, atom_link); + list_for_each_entry(atom_2, &tmgr->atoms_list, atom_link) { if (atom == atom_2) continue; /* @@ -1435,7 +1429,6 @@ flush_some_atom(jnode * start, long *nr_ txn_handle *txnh = ctx->trans; txn_atom *atom; int ret; - struct list_head *pos; BUG_ON(wbc->nr_to_write == 0); BUG_ON(*nr_submitted != 0); @@ -1446,8 +1439,7 @@ flush_some_atom(jnode * start, long *nr_ spin_lock_txnmgr(tmgr); /* traverse the list of all atoms */ - list_for_each(pos, &tmgr->atoms_list) { - atom = list_entry(pos, txn_atom, atom_link); + list_for_each_entry(atom, &tmgr->atoms_list, atom_link) { /* lock atom before checking its state */ LOCK_ATOM(atom); @@ -1473,8 +1465,7 @@ flush_some_atom(jnode * start, long *nr_ * flushed/committed. */ if (!current_is_pdflush() && !wbc->nonblocking) { - list_for_each(pos, &tmgr->atoms_list) { - atom = list_entry(pos, txn_atom, atom_link); + list_for_each_entry(atom, &tmgr->atoms_list, atom_link) { LOCK_ATOM(atom); /* Repeat the check from the above. */ if (atom->stage < ASTAGE_PRE_COMMIT @@ -2208,7 +2199,6 @@ static int fuse_not_fused_lock_owners(tx lock_handle *lh; int repeat = 0; txn_atom *atomh = txnh->atom; - struct list_head *pos; /* assert ("zam-689", znode_is_rlocked (node));*/ assert("zam-690", spin_znode_is_locked(node)); @@ -2223,11 +2213,10 @@ static int fuse_not_fused_lock_owners(tx } /* inspect list of lock owners */ - list_for_each(pos, &node->lock.owners) { + list_for_each_entry(lh, &node->lock.owners, owners_link) { reiser4_context *ctx; txn_atom *atomf; - lh = list_entry(pos, lock_handle, owners_link); ctx = get_context_by_lock_stack(lh->owner); if (ctx == get_current_context()) @@ -3110,13 +3099,11 @@ int capture_super_block(struct super_blo static void wakeup_atom_waitfor_list(txn_atom * atom) { txn_wait_links *wlinks; - struct list_head *pos; assert("umka-210", atom != NULL); /* atom is locked */ - list_for_each(pos, &atom->fwaitfor_list) { - wlinks = list_entry(pos, txn_wait_links, _fwaitfor_link); + list_for_each_entry(wlinks, &atom->fwaitfor_list, _fwaitfor_link) { if (wlinks->waitfor_cb == NULL || wlinks->waitfor_cb(atom, wlinks)) /* Wake up. */ @@ -3128,13 +3115,11 @@ static void wakeup_atom_waitfor_list(txn static void wakeup_atom_waiting_list(txn_atom * atom) { txn_wait_links *wlinks; - struct list_head *pos; assert("umka-211", atom != NULL); /* atom is locked */ - list_for_each(pos, &atom->fwaiting_list) { - wlinks = list_entry(pos, txn_wait_links, _fwaiting_link); + list_for_each_entry(wlinks, &atom->fwaiting_list, _fwaiting_link) { if (wlinks->waiting_cb == NULL || wlinks->waiting_cb(atom, wlinks)) /* Wake up. */ @@ -3343,7 +3328,6 @@ capture_fuse_jnode_lists(txn_atom *large { int count = 0; jnode *node; - struct list_head *pos; assert("umka-218", large != NULL); assert("umka-219", large_head != NULL); @@ -3352,8 +3336,7 @@ capture_fuse_jnode_lists(txn_atom *large assert("zam-968", spin_atom_is_locked(large)); /* For every jnode on small's capture list... */ - list_for_each(pos, small_head) { - node = list_entry(pos, jnode, capture_link); + list_for_each_entry(node, small_head, capture_link) { count += 1; /* With the jnode lock held, update atom pointer. */ @@ -3376,15 +3359,13 @@ capture_fuse_txnh_lists(txn_atom *large, { int count = 0; txn_handle *txnh; - struct list_head *pos; assert("umka-221", large != NULL); assert("umka-222", large_head != NULL); assert("umka-223", small_head != NULL); /* Adjust every txnh to the new atom. */ - list_for_each(pos, small_head) { - txnh = list_entry(pos, txn_handle, txnh_link); + list_for_each_entry(txnh, small_head, txnh_link) { count += 1; /* With the txnh lock held, update atom pointer. */ @@ -3410,7 +3391,6 @@ static void capture_fuse_into(txn_atom * unsigned zcount = 0; unsigned tcount = 0; protected_jnodes *prot_list; - struct list_head *pos1, *pos2; assert("umka-224", small != NULL); assert("umka-225", small != NULL); @@ -3445,14 +3425,10 @@ static void capture_fuse_into(txn_atom * capture_fuse_txnh_lists(large, &large->txnh_list, &small->txnh_list); - - list_for_each(pos1, &small->protected) { + list_for_each_entry(prot_list, &small->protected, inatom) { jnode *node; - prot_list = list_entry(pos1, protected_jnodes, inatom); - - list_for_each(pos2, &prot_list->nodes) { - node = list_entry(pos2, jnode, capture_link); + list_for_each_entry(node, &prot_list->nodes, capture_link) { zcount += 1; LOCK_JNODE(node); @@ -4228,13 +4204,11 @@ reiser4_block_nr txnmgr_count_deleted_bl reiser4_block_nr result; txn_mgr *tmgr = &get_super_private(reiser4_get_current_sb())->tmgr; txn_atom *atom; - struct list_head *pos; result = 0; spin_lock_txnmgr(tmgr); - list_for_each(pos, &tmgr->atoms_list) { - atom = list_entry(pos, txn_atom, atom_link); + list_for_each_entry(atom, &tmgr->atoms_list, atom_link) { LOCK_ATOM(atom); blocknr_set_iterator(atom, &atom->delete_set, count_deleted_blocks_actor, &result, 0); diff -puN fs/reiser4/wander.c~reiser4-fix-endianess fs/reiser4/wander.c --- devel/fs/reiser4/wander.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/wander.c 2005-09-28 22:53:11.000000000 -0700 @@ -196,7 +196,7 @@ struct commit_handle { /* jnodes for wander record blocks */ struct list_head tx_list; /* number of wander records */ - int tx_size; + __u32 tx_size; /* 'committed' sb counters are saved here until atom is completely flushed */ __u64 free_blocks; @@ -242,7 +242,8 @@ static void format_journal_header(struct header = (struct journal_header *)jdata(sbinfo->journal_header); assert("zam-484", header != NULL); - cputod64(*jnode_get_block(txhead), &header->last_committed_tx); + put_unaligned(cpu_to_le64(*jnode_get_block(txhead)), + &header->last_committed_tx); jrelse(sbinfo->journal_header); } @@ -266,11 +267,12 @@ static void format_journal_footer(struct footer = (struct journal_footer *)jdata(sbinfo->journal_footer); assert("zam-495", footer != NULL); - cputod64(*jnode_get_block(tx_head), &footer->last_flushed_tx); - cputod64(ch->free_blocks, &footer->free_blocks); + put_unaligned(cpu_to_le64(*jnode_get_block(tx_head)), + &footer->last_flushed_tx); + put_unaligned(cpu_to_le64(ch->free_blocks), &footer->free_blocks); - cputod64(ch->nr_files, &footer->nr_files); - cputod64(ch->next_oid, &footer->next_oid); + put_unaligned(cpu_to_le64(ch->nr_files), &footer->nr_files); + put_unaligned(cpu_to_le64(ch->next_oid), &footer->next_oid); jrelse(sbinfo->journal_footer); } @@ -305,19 +307,18 @@ static void format_tx_head(struct commit memset(jdata(tx_head), 0, (size_t) ch->super->s_blocksize); memcpy(jdata(tx_head), TX_HEADER_MAGIC, TX_HEADER_MAGIC_SIZE); - cputod32((__u32) ch->tx_size, &header->total); - cputod64(get_super_private(ch->super)->last_committed_tx, - &header->prev_tx); - cputod64(*jnode_get_block(next), &header->next_block); - - cputod64(ch->free_blocks, &header->free_blocks); - cputod64(ch->nr_files, &header->nr_files); - cputod64(ch->next_oid, &header->next_oid); + put_unaligned(cpu_to_le32(ch->tx_size), &header->total); + put_unaligned(cpu_to_le64(get_super_private(ch->super)->last_committed_tx), + &header->prev_tx); + put_unaligned(cpu_to_le64(*jnode_get_block(next)), &header->next_block); + put_unaligned(cpu_to_le64(ch->free_blocks), &header->free_blocks); + put_unaligned(cpu_to_le64(ch->nr_files), &header->nr_files); + put_unaligned(cpu_to_le64(ch->next_oid), &header->next_oid); } /* prepare ordinary wander record block (fill all service fields) */ static void -format_wander_record(struct commit_handle *ch, jnode *node, int serial) +format_wander_record(struct commit_handle *ch, jnode *node, __u32 serial) { struct wander_record_header *LRH; jnode *next; @@ -337,9 +338,9 @@ format_wander_record(struct commit_handl memset(jdata(node), 0, (size_t) ch->super->s_blocksize); memcpy(jdata(node), WANDER_RECORD_MAGIC, WANDER_RECORD_MAGIC_SIZE); - cputod32((__u32) ch->tx_size, &LRH->total); - cputod32((__u32) serial, &LRH->serial); - cputod64((__u64) * jnode_get_block(next), &LRH->next_block); + put_unaligned(cpu_to_le32(ch->tx_size), &LRH->total); + put_unaligned(cpu_to_le32(serial), &LRH->serial); + put_unaligned(cpu_to_le64(*jnode_get_block(next)), &LRH->next_block); } /* add one wandered map entry to formatted wander record */ @@ -356,8 +357,8 @@ store_entry(jnode * node, int index, con pairs = (struct wander_entry *)(data + sizeof(struct wander_record_header)); - cputod64(*a, &pairs[index].original); - cputod64(*b, &pairs[index].wandered); + put_unaligned(cpu_to_le64(*a), &pairs[index].original); + put_unaligned(cpu_to_le64(*b), &pairs[index].wandered); } /* currently, wander records contains contain only wandered map, which depend on @@ -1074,12 +1075,9 @@ static int alloc_wandered_blocks(struct static void put_overwrite_set(struct commit_handle *ch) { jnode *cur; - struct list_head *pos; - list_for_each(pos, ch->overwrite_set) { - cur = list_entry(pos, jnode, capture_link); + list_for_each_entry(cur, ch->overwrite_set, capture_link) jrelse_tail(cur); - } } /* Count overwrite set size, grab disk space for wandered blocks allocation. @@ -1750,11 +1748,10 @@ static int check_journal_header(const jn /* wait for write completion for all jnodes from given list */ static int wait_on_jnode_list(struct list_head *head) { - struct list_head *pos; + jnode *scan; int ret = 0; - list_for_each(pos, head) { - jnode *scan = list_entry(pos, jnode, capture_link); + list_for_each_entry(scan, head, capture_link) { struct page *pg = jnode_page(scan); if (pg) { @@ -1815,9 +1812,9 @@ static int restore_commit_handle(struct TXH = (struct tx_header *)jdata(tx_head); - ch->free_blocks = d64tocpu(&TXH->free_blocks); - ch->nr_files = d64tocpu(&TXH->nr_files); - ch->next_oid = d64tocpu(&TXH->next_oid); + ch->free_blocks = le64_to_cpu(get_unaligned(&TXH->free_blocks)); + ch->nr_files = le64_to_cpu(get_unaligned(&TXH->nr_files)); + ch->next_oid = le64_to_cpu(get_unaligned(&TXH->next_oid)); jrelse(tx_head); @@ -1876,7 +1873,7 @@ static int replay_transaction(const stru } header = (struct wander_record_header *)jdata(log); - log_rec_block = d64tocpu(&header->next_block); + log_rec_block = le64_to_cpu(get_unaligned(&header->next_block)); entry = (struct wander_entry *)(header + 1); @@ -1885,8 +1882,7 @@ static int replay_transaction(const stru reiser4_block_nr block; jnode *node; - block = d64tocpu(&entry->wandered); - + block = le64_to_cpu(get_unaligned(&entry->wandered)); if (block == 0) break; @@ -1913,7 +1909,7 @@ static int replay_transaction(const stru goto free_ow_set; } - block = d64tocpu(&entry->original); + block = le64_to_cpu(get_unaligned(&entry->original)); assert("zam-603", block != 0); @@ -1992,7 +1988,7 @@ static int replay_oldest_transaction(str F = (struct journal_footer *)jdata(jf); - last_flushed_tx = d64tocpu(&F->last_flushed_tx); + last_flushed_tx = le64_to_cpu(get_unaligned(&F->last_flushed_tx)); jrelse(jf); @@ -2024,7 +2020,7 @@ static int replay_oldest_transaction(str T = (struct tx_header *)jdata(tx_head); - prev_tx = d64tocpu(&T->prev_tx); + prev_tx = le64_to_cpu(get_unaligned(&T->prev_tx)); if (prev_tx == last_flushed_tx) break; @@ -2033,8 +2029,8 @@ static int replay_oldest_transaction(str drop_io_head(tx_head); } - total = d32tocpu(&T->total); - log_rec_block = d64tocpu(&T->next_block); + total = le32_to_cpu(get_unaligned(&T->total)); + log_rec_block = le64_to_cpu(get_unaligned(&T->next_block)); pin_jnode_data(tx_head); jrelse(tx_head); @@ -2082,15 +2078,15 @@ int reiser4_journal_recover_sb_data(stru jf = (struct journal_footer *)jdata(sbinfo->journal_footer); /* was there at least one flushed transaction? */ - if (d64tocpu(&jf->last_flushed_tx)) { + if (jf->last_flushed_tx) { /* restore free block counter logged in this transaction */ - reiser4_set_free_blocks(s, d64tocpu(&jf->free_blocks)); + reiser4_set_free_blocks(s, le64_to_cpu(get_unaligned(&jf->free_blocks))); /* restore oid allocator state */ oid_init_allocator(s, - d64tocpu(&jf->nr_files), - d64tocpu(&jf->next_oid)); + le64_to_cpu(get_unaligned(&jf->nr_files)), + le64_to_cpu(get_unaligned(&jf->next_oid))); } out: jrelse(sbinfo->journal_footer); @@ -2147,7 +2143,7 @@ int reiser4_journal_replay(struct super_ } header = (struct journal_header *)jdata(jh); - sbinfo->last_committed_tx = d64tocpu(&header->last_committed_tx); + sbinfo->last_committed_tx = le64_to_cpu(get_unaligned(&header->last_committed_tx)); jrelse(jh); diff -puN fs/reiser4/znode.c~reiser4-fix-endianess fs/reiser4/znode.c --- devel/fs/reiser4/znode.c~reiser4-fix-endianess 2005-09-28 22:53:11.000000000 -0700 +++ devel-akpm/fs/reiser4/znode.c 2005-09-28 22:53:11.000000000 -0700 @@ -262,8 +262,6 @@ void zfree(znode * node /* znode to free /* not yet phash_jnode_destroy(ZJNODE(node)); */ - /* poison memory. */ - ON_DEBUG(memset(node, 0xde, sizeof *node)); kmem_cache_free(znode_cache, node); } _