summaryrefslogtreecommitdiffstats
path: root/include/linux/nilfs2_fs.h
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-07-25 20:39:03 +0900
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-07-25 20:46:43 +0900
commit6cda9fa2575ec0869fe77b0bdf295c0e51868cab (patch)
tree09f160f79f2ab135cd0c9ce0a2099d96423e5e00 /include/linux/nilfs2_fs.h
parentc28e69d9332aab739920082a0a5677d861390824 (diff)
downloadlinux-6cda9fa2575ec0869fe77b0bdf295c0e51868cab.tar.gz
linux-6cda9fa2575ec0869fe77b0bdf295c0e51868cab.tar.bz2
linux-6cda9fa2575ec0869fe77b0bdf295c0e51868cab.zip
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.h18
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 {
#define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1)
#define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \
~NILFS_DIR_ROUND)
+#define NILFS_MAX_REC_LEN ((1<<16)-1)
+static inline unsigned nilfs_rec_len_from_disk(__le16 dlen)
+{
+ unsigned len = le16_to_cpu(dlen);
+
+ if (len == NILFS_MAX_REC_LEN)
+ return 1 << 16;
+ return len;
+}
+
+static inline __le16 nilfs_rec_len_to_disk(unsigned len)
+{
+ if (len == (1 << 16))
+ return cpu_to_le16(NILFS_MAX_REC_LEN);
+ else if (len > (1 << 16))
+ BUG();
+ return cpu_to_le16(len);
+}
/**
* struct nilfs_finfo - file information