[<prev] [next>] [day] [month] [year] [list]
Message-id: <1381223500-6582-1-git-send-email-jaegeuk.kim@samsung.com>
Date: Tue, 08 Oct 2013 18:11:40 +0900
From: Jaegeuk Kim <jaegeuk.kim@...sung.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Jaegeuk Kim <jaegeuk.kim@...sung.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net
Subject: [PATCH] f2fs: fix to store and retrieve i_rdev correctly
Previously f2fs stores i_rdev information into i_addr.
But, if inline_xattr is set, f2fs should avoid using i_addr fields.
So, this patch adds to use i_nid fields instead of i_addrs when inline_xattr
is set.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@...sung.com>
---
fs/f2fs/inode.c | 63 +++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 46 insertions(+), 17 deletions(-)
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index c8c0580..fab657f 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -37,6 +37,45 @@ void f2fs_set_inode_flags(struct inode *inode)
inode->i_flags |= S_DIRSYNC;
}
+static void get_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
+{
+ if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
+ S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
+ __le32 *rdev;
+
+ if (is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR))
+ rdev = ri->i_nid;
+ else
+ rdev = ri->i_addr;
+
+ if (rdev[0])
+ inode->i_rdev = old_decode_dev(le32_to_cpu(rdev[0]));
+ else
+ inode->i_rdev = new_decode_dev(le32_to_cpu(rdev[1]));
+ }
+}
+
+static void set_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
+{
+ if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
+ __le32 *rdev;
+
+ if (is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR))
+ rdev = ri->i_nid;
+ else
+ rdev = ri->i_addr;
+
+ if (old_valid_dev(inode->i_rdev)) {
+ rdev[0] = cpu_to_le32(old_encode_dev(inode->i_rdev));
+ rdev[1] = 0;
+ } else {
+ rdev[0] = 0;
+ rdev[1] = cpu_to_le32(new_encode_dev(inode->i_rdev));
+ rdev[2] = 0;
+ }
+ }
+}
+
static int do_read_inode(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
@@ -73,10 +112,6 @@ static int do_read_inode(struct inode *inode)
inode->i_ctime.tv_nsec = le32_to_cpu(ri->i_ctime_nsec);
inode->i_mtime.tv_nsec = le32_to_cpu(ri->i_mtime_nsec);
inode->i_generation = le32_to_cpu(ri->i_generation);
- if (ri->i_addr[0])
- inode->i_rdev = old_decode_dev(le32_to_cpu(ri->i_addr[0]));
- else
- inode->i_rdev = new_decode_dev(le32_to_cpu(ri->i_addr[1]));
fi->i_current_depth = le32_to_cpu(ri->i_current_depth);
fi->i_xattr_nid = le32_to_cpu(ri->i_xattr_nid);
@@ -84,8 +119,13 @@ static int do_read_inode(struct inode *inode)
fi->flags = 0;
fi->i_advise = ri->i_advise;
fi->i_pino = le32_to_cpu(ri->i_pino);
+
get_extent_info(&fi->ext, ri->i_ext);
get_inline_info(fi, ri);
+
+ /* get rdev by using inline_info */
+ get_inode_rdev(inode, ri);
+
f2fs_put_page(node_page, 1);
return 0;
}
@@ -179,21 +219,10 @@ void update_inode(struct inode *inode, struct page *node_page)
ri->i_pino = cpu_to_le32(F2FS_I(inode)->i_pino);
ri->i_generation = cpu_to_le32(inode->i_generation);
- if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
- if (old_valid_dev(inode->i_rdev)) {
- ri->i_addr[0] =
- cpu_to_le32(old_encode_dev(inode->i_rdev));
- ri->i_addr[1] = 0;
- } else {
- ri->i_addr[0] = 0;
- ri->i_addr[1] =
- cpu_to_le32(new_encode_dev(inode->i_rdev));
- ri->i_addr[2] = 0;
- }
- }
-
+ set_inode_rdev(inode, ri);
set_cold_node(inode, node_page);
set_page_dirty(node_page);
+
clear_inode_flag(F2FS_I(inode), FI_DIRTY_INODE);
}
--
1.8.4.474.g128a96c
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists