aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2008-01-28 23:58:27 -0500
committerTheodore Ts'o <tytso@mit.edu>2008-01-28 23:58:27 -0500
commita72d7f834e1afa08421938d7eb06bd8e56b0e58c (patch)
tree21c6fbbf4187fa8ba56878ea2d5e576e123e1f95 /include
parentafc7cbca5bfd556c3e12d3acefbee5ab0cbd4670 (diff)
ext4: 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 lenght. So we store 0xffff instead and convert value when read from / written to disk. The patch also converts some places to use ext4_next_entry() when we are changing them anyway. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/ext4_fs.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
index dfe4487fc739..fb31c1aba989 100644
--- a/include/linux/ext4_fs.h
+++ b/include/linux/ext4_fs.h
@@ -767,6 +767,26 @@ struct ext4_dir_entry_2 {
767#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1) 767#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
768#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \ 768#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \
769 ~EXT4_DIR_ROUND) 769 ~EXT4_DIR_ROUND)
770#define EXT4_MAX_REC_LEN ((1<<16)-1)
771
772static inline unsigned ext4_rec_len_from_disk(__le16 dlen)
773{
774 unsigned len = le16_to_cpu(dlen);
775
776 if (len == EXT4_MAX_REC_LEN)
777 return 1 << 16;
778 return len;
779}
780
781static inline __le16 ext4_rec_len_to_disk(unsigned len)
782{
783 if (len == (1 << 16))
784 return cpu_to_le16(EXT4_MAX_REC_LEN);
785 else if (len > (1 << 16))
786 BUG();
787 return cpu_to_le16(len);
788}
789
770/* 790/*
771 * Hash Tree Directory indexing 791 * Hash Tree Directory indexing
772 * (c) Daniel Phillips, 2001 792 * (c) Daniel Phillips, 2001