diff options
author | Wei Yongjun <yjwei@cn.fujitsu.com> | 2009-02-14 23:01:36 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-02-14 23:01:36 -0500 |
commit | 3d0518f4758eca4339e75e5b9dbb7e06a5ce08b4 (patch) | |
tree | 30a45a1c82d830646a69591c470680573e14de07 /fs/ext4/dir.c | |
parent | 8bad4597c2d71365adfa846ea1ca6cf99161a455 (diff) |
ext4: New rec_len encoding for very large blocksizes
The rec_len field in the directory entry is 16 bits, so to encode
blocksizes larger than 64k becomes problematic. This patch allows us
to supprot block sizes up to 256k, by using the low 2 bits to extend
the range of rec_len to 2**18-1 (since valid rec_len sizes must be a
multiple of 4). We use the convention that a rec_len of 0 or 65535
means the filesystem block size, for compatibility with older kernels.
It's unlikely we'll see VM pages of up to 256k, but at some point we
might find that the Linux VM has been enhanced to support filesystem
block sizes > than the VM page size, at which point it might be useful
for some applications to allow very large filesystem block sizes.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/dir.c')
-rw-r--r-- | fs/ext4/dir.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index 2df2e40b01af..b64789929a65 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c | |||
@@ -67,7 +67,8 @@ int ext4_check_dir_entry(const char *function, struct inode *dir, | |||
67 | unsigned int offset) | 67 | unsigned int offset) |
68 | { | 68 | { |
69 | const char *error_msg = NULL; | 69 | const char *error_msg = NULL; |
70 | const int rlen = ext4_rec_len_from_disk(de->rec_len); | 70 | const int rlen = ext4_rec_len_from_disk(de->rec_len, |
71 | dir->i_sb->s_blocksize); | ||
71 | 72 | ||
72 | if (rlen < EXT4_DIR_REC_LEN(1)) | 73 | if (rlen < EXT4_DIR_REC_LEN(1)) |
73 | error_msg = "rec_len is smaller than minimal"; | 74 | error_msg = "rec_len is smaller than minimal"; |
@@ -178,10 +179,11 @@ revalidate: | |||
178 | * least that it is non-zero. A | 179 | * least that it is non-zero. A |
179 | * failure will be detected in the | 180 | * failure will be detected in the |
180 | * dirent test below. */ | 181 | * dirent test below. */ |
181 | if (ext4_rec_len_from_disk(de->rec_len) | 182 | if (ext4_rec_len_from_disk(de->rec_len, |
182 | < EXT4_DIR_REC_LEN(1)) | 183 | sb->s_blocksize) < EXT4_DIR_REC_LEN(1)) |
183 | break; | 184 | break; |
184 | i += ext4_rec_len_from_disk(de->rec_len); | 185 | i += ext4_rec_len_from_disk(de->rec_len, |
186 | sb->s_blocksize); | ||
185 | } | 187 | } |
186 | offset = i; | 188 | offset = i; |
187 | filp->f_pos = (filp->f_pos & ~(sb->s_blocksize - 1)) | 189 | filp->f_pos = (filp->f_pos & ~(sb->s_blocksize - 1)) |
@@ -203,7 +205,8 @@ revalidate: | |||
203 | ret = stored; | 205 | ret = stored; |
204 | goto out; | 206 | goto out; |
205 | } | 207 | } |
206 | offset += ext4_rec_len_from_disk(de->rec_len); | 208 | offset += ext4_rec_len_from_disk(de->rec_len, |
209 | sb->s_blocksize); | ||
207 | if (le32_to_cpu(de->inode)) { | 210 | if (le32_to_cpu(de->inode)) { |
208 | /* We might block in the next section | 211 | /* We might block in the next section |
209 | * if the data destination is | 212 | * if the data destination is |
@@ -225,7 +228,8 @@ revalidate: | |||
225 | goto revalidate; | 228 | goto revalidate; |
226 | stored++; | 229 | stored++; |
227 | } | 230 | } |
228 | filp->f_pos += ext4_rec_len_from_disk(de->rec_len); | 231 | filp->f_pos += ext4_rec_len_from_disk(de->rec_len, |
232 | sb->s_blocksize); | ||
229 | } | 233 | } |
230 | offset = 0; | 234 | offset = 0; |
231 | brelse(bh); | 235 | brelse(bh); |