f2fs: add flags for inline xattrs
authorJaegeuk Kim <jaegeuk.kim@samsung.com>
Thu, 8 Aug 2013 06:16:22 +0000 (15:16 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Mon, 26 Aug 2013 11:02:12 +0000 (20:02 +0900)
This patch adds basic inode flags for inline xattrs, F2FS_INLINE_XATTR,
and add a mount option, inline_xattr, which is enabled when xattr is set.

If the mount option is enabled, all the files are marked with the inline_xattrs
flag.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/f2fs.h
fs/f2fs/inode.c
fs/f2fs/super.c
include/linux/f2fs_fs.h

index 5348b63adbe9b17a681352a6c582572bd76e7a44..b82f14199921ae4386b3ddc05b841230f25ea3a7 100644 (file)
@@ -29,6 +29,7 @@
 #define F2FS_MOUNT_XATTR_USER          0x00000010
 #define F2FS_MOUNT_POSIX_ACL           0x00000020
 #define F2FS_MOUNT_DISABLE_EXT_IDENTIFY        0x00000040
+#define F2FS_MOUNT_INLINE_XATTR                0x00000080
 
 #define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option)
 #define set_opt(sbi, option)   (sbi->mount_opt.opt |= F2FS_MOUNT_##option)
@@ -892,6 +893,7 @@ enum {
        FI_NO_ALLOC,            /* should not allocate any blocks */
        FI_UPDATE_DIR,          /* should update inode block for consistency */
        FI_DELAY_IPUT,          /* used for the recovery */
+       FI_INLINE_XATTR,        /* used for inline xattr */
 };
 
 static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)
@@ -924,6 +926,22 @@ static inline int cond_clear_inode_flag(struct f2fs_inode_info *fi, int flag)
        return 0;
 }
 
+static inline void get_inline_info(struct f2fs_inode_info *fi,
+                                       struct f2fs_inode *ri)
+{
+       if (ri->i_inline & F2FS_INLINE_XATTR)
+               set_inode_flag(fi, FI_INLINE_XATTR);
+}
+
+static inline void set_raw_inline(struct f2fs_inode_info *fi,
+                                       struct f2fs_inode *ri)
+{
+       ri->i_inline = 0;
+
+       if (is_inode_flag_set(fi, FI_INLINE_XATTR))
+               ri->i_inline |= F2FS_INLINE_XATTR;
+}
+
 static inline int f2fs_readonly(struct super_block *sb)
 {
        return sb->s_flags & MS_RDONLY;
index 7f8569bd875906bbbbbbb3fd7fef222d10243520..9339cd292047b897bbc7bb0c5ef5ff337f9190ab 100644 (file)
@@ -85,6 +85,7 @@ static int do_read_inode(struct inode *inode)
        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);
        f2fs_put_page(node_page, 1);
        return 0;
 }
@@ -164,6 +165,7 @@ void update_inode(struct inode *inode, struct page *node_page)
        ri->i_size = cpu_to_le64(i_size_read(inode));
        ri->i_blocks = cpu_to_le64(inode->i_blocks);
        set_raw_extent(&F2FS_I(inode)->ext, &ri->i_ext);
+       set_raw_inline(F2FS_I(inode), ri);
 
        ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
        ri->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
index d28c4528eff8599491c3726e3dd5f7e7937b4801..70ecf484e7e52eeebff3eb6b3f9c0cc17db44522 100644 (file)
@@ -47,6 +47,7 @@ enum {
        Opt_noacl,
        Opt_active_logs,
        Opt_disable_ext_identify,
+       Opt_inline_xattr,
        Opt_err,
 };
 
@@ -59,6 +60,7 @@ static match_table_t f2fs_tokens = {
        {Opt_noacl, "noacl"},
        {Opt_active_logs, "active_logs=%u"},
        {Opt_disable_ext_identify, "disable_ext_identify"},
+       {Opt_inline_xattr, "inline_xattr"},
        {Opt_err, NULL},
 };
 
@@ -238,11 +240,18 @@ static int parse_options(struct super_block *sb, char *options)
                case Opt_nouser_xattr:
                        clear_opt(sbi, XATTR_USER);
                        break;
+               case Opt_inline_xattr:
+                       set_opt(sbi, INLINE_XATTR);
+                       break;
 #else
                case Opt_nouser_xattr:
                        f2fs_msg(sb, KERN_INFO,
                                "nouser_xattr options not supported");
                        break;
+               case Opt_inline_xattr:
+                       f2fs_msg(sb, KERN_INFO,
+                               "inline_xattr options not supported");
+                       break;
 #endif
 #ifdef CONFIG_F2FS_FS_POSIX_ACL
                case Opt_noacl:
@@ -292,6 +301,9 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)
 
        set_inode_flag(fi, FI_NEW_INODE);
 
+       if (test_opt(F2FS_SB(sb), INLINE_XATTR))
+               set_inode_flag(fi, FI_INLINE_XATTR);
+
        return &fi->vfs_inode;
 }
 
@@ -444,6 +456,8 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
                seq_puts(seq, ",user_xattr");
        else
                seq_puts(seq, ",nouser_xattr");
+       if (test_opt(sbi, INLINE_XATTR))
+               seq_puts(seq, ",inline_xattr");
 #endif
 #ifdef CONFIG_F2FS_FS_POSIX_ACL
        if (test_opt(sbi, POSIX_ACL))
index 383d5e39b280a1eeb2dc2d60d37446112624a493..10ab11f8f99d46b323e01159eb8fe78eebaf381d 100644 (file)
@@ -144,10 +144,12 @@ struct f2fs_extent {
 #define ADDRS_PER_BLOCK         1018   /* Address Pointers in a Direct Block */
 #define NIDS_PER_BLOCK          1018   /* Node IDs in an Indirect Block */
 
+#define F2FS_INLINE_XATTR      0x01    /* file inline xattr flag */
+
 struct f2fs_inode {
        __le16 i_mode;                  /* file mode */
        __u8 i_advise;                  /* file hints */
-       __u8 i_reserved;                /* reserved */
+       __u8 i_inline;                  /* file inline flags */
        __le32 i_uid;                   /* user ID */
        __le32 i_gid;                   /* group ID */
        __le32 i_links;                 /* links count */
This page took 0.030331 seconds and 5 git commands to generate.