diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-25 07:39:03 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-25 07:46:43 -0400 |
commit | 6cda9fa2575ec0869fe77b0bdf295c0e51868cab (patch) | |
tree | 09f160f79f2ab135cd0c9ce0a2099d96423e5e00 /include/linux/nilfs2_fs.h | |
parent | c28e69d9332aab739920082a0a5677d861390824 (diff) |
nilfs2: avoid rec_len overflow with 64KB block size
With 64KB blocksize, a directory entry can have size 64KB which does
not fit into 16 bits we have for entry length. So this patch stores
0xffff instead and converts value when read from / written to disk.
Nilfs derives its directory implementation from ext2 filesystem, and
this draws upon the corresponding change on ext2.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'include/linux/nilfs2_fs.h')
-rw-r--r-- | include/linux/nilfs2_fs.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h index 7dd4cd494490..970828a5ffc5 100644 --- a/include/linux/nilfs2_fs.h +++ b/include/linux/nilfs2_fs.h | |||
@@ -326,7 +326,25 @@ enum { | |||
326 | #define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1) | 326 | #define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1) |
327 | #define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \ | 327 | #define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \ |
328 | ~NILFS_DIR_ROUND) | 328 | ~NILFS_DIR_ROUND) |
329 | #define NILFS_MAX_REC_LEN ((1<<16)-1) | ||
329 | 330 | ||
331 | static inline unsigned nilfs_rec_len_from_disk(__le16 dlen) | ||
332 | { | ||
333 | unsigned len = le16_to_cpu(dlen); | ||
334 | |||
335 | if (len == NILFS_MAX_REC_LEN) | ||
336 | return 1 << 16; | ||
337 | return len; | ||
338 | } | ||
339 | |||
340 | static inline __le16 nilfs_rec_len_to_disk(unsigned len) | ||
341 | { | ||
342 | if (len == (1 << 16)) | ||
343 | return cpu_to_le16(NILFS_MAX_REC_LEN); | ||
344 | else if (len > (1 << 16)) | ||
345 | BUG(); | ||
346 | return cpu_to_le16(len); | ||
347 | } | ||
330 | 348 | ||
331 | /** | 349 | /** |
332 | * struct nilfs_finfo - file information | 350 | * struct nilfs_finfo - file information |