1 Index: linux-stage/fs/ext4/dir.c
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/dir.c 2011-04-19 01:02:34.000000000 +0800
4 +++ linux-stage/fs/ext4/dir.c 2011-04-19 01:24:36.000000000 +0800
9 +static inline int is_32bit_api(void)
11 +#ifdef HAVE_IS_COMPAT_TASK
12 + return is_compat_task();
14 + return (BITS_PER_LONG == 32);
19 * These functions convert from the major/minor hash to an f_pos
22 - * Currently we only use major hash numer. This is unfortunate, but
23 - * on 32-bit machines, the same VFS interface is used for lseek and
24 - * llseek, so if we use the 64 bit offset, then the 32-bit versions of
25 - * lseek/telldir/seekdir will blow out spectacularly, and from within
26 - * the ext2 low-level routine, we don't know if we're being called by
27 - * a 64-bit version of the system call or the 32-bit version of the
28 - * system call. Worse yet, NFSv2 only allows for a 32-bit readdir
30 + * Up layer (OSD) should specify O_32BITHASH or O_64BITHASH explicitly.
31 + * On the other hand, we allow ldiskfs to be mounted directly on both 32-bit
32 + * and 64-bit nodes, under such case, neither O_32BITHASH nor O_64BITHASH is
35 -#define hash2pos(major, minor) (major >> 1)
36 -#define pos2maj_hash(pos) ((pos << 1) & 0xffffffff)
37 -#define pos2min_hash(pos) (0)
38 +static inline loff_t hash2pos(struct file *filp, __u32 major, __u32 minor)
40 + if ((filp->f_flags & O_32BITHASH) ||
41 + (!(filp->f_flags & O_64BITHASH) && is_32bit_api()))
42 + return (major >> 1);
44 + return (((__u64)(major >> 1) << 32) | (__u64)minor);
47 +static inline __u32 pos2maj_hash(struct file *filp, loff_t pos)
49 + if ((filp->f_flags & O_32BITHASH) ||
50 + (!(filp->f_flags & O_64BITHASH) && is_32bit_api()))
51 + return ((pos << 1) & 0xffffffff);
53 + return (((pos >> 32) << 1) & 0xffffffff);
56 +static inline __u32 pos2min_hash(struct file *filp, loff_t pos)
58 + if ((filp->f_flags & O_32BITHASH) ||
59 + (!(filp->f_flags & O_64BITHASH) && is_32bit_api()))
62 + return (pos & 0xffffffff);
66 * This structure holds the nodes of the red-black tree used to store
71 -static struct dir_private_info *ext4_htree_create_dir_info(loff_t pos)
72 +static struct dir_private_info *
73 +ext4_htree_create_dir_info(struct file *filp, loff_t pos)
75 struct dir_private_info *p;
77 p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL);
80 - p->curr_hash = pos2maj_hash(pos);
81 - p->curr_minor_hash = pos2min_hash(pos);
82 + p->curr_hash = pos2maj_hash(filp, pos);
83 + p->curr_minor_hash = pos2min_hash(filp, pos);
91 - curr_pos = hash2pos(fname->hash, fname->minor_hash);
92 + curr_pos = hash2pos(filp, fname->hash, fname->minor_hash);
94 error = filldir(dirent, fname->name,
95 fname->name_len, curr_pos,
100 - info = ext4_htree_create_dir_info(filp->f_pos);
101 + info = ext4_htree_create_dir_info(filp, filp->f_pos);
104 filp->private_data = info;
106 free_rb_tree_fname(&info->root);
107 info->curr_node = NULL;
108 info->extra_fname = NULL;
109 - info->curr_hash = pos2maj_hash(filp->f_pos);
110 - info->curr_minor_hash = pos2min_hash(filp->f_pos);
111 + info->curr_hash = pos2maj_hash(filp, filp->f_pos);
112 + info->curr_minor_hash = pos2min_hash(filp, filp->f_pos);
116 Index: linux-stage/fs/ext4/ext4.h
117 ===================================================================
118 --- linux-stage.orig/fs/ext4/ext4.h 2011-04-19 01:02:34.000000000 +0800
119 +++ linux-stage/fs/ext4/ext4.h 2011-04-19 01:02:34.000000000 +0800
121 #define ext4_debug(f, a...) do {} while (0)
125 +# define O_32BITHASH 0x10000000
129 +# define O_64BITHASH 0x20000000
132 #define HAVE_DISK_INODE_VERSION
134 /* data type for block offset of block group */