|
@@ -110,9 +110,10 @@ struct f2fs_mount_info {
|
|
|
unsigned int opt;
|
|
|
};
|
|
|
|
|
|
-#define F2FS_FEATURE_ENCRYPT 0x0001
|
|
|
-#define F2FS_FEATURE_BLKZONED 0x0002
|
|
|
-#define F2FS_FEATURE_ATOMIC_WRITE 0x0004
|
|
|
+#define F2FS_FEATURE_ENCRYPT 0x0001
|
|
|
+#define F2FS_FEATURE_BLKZONED 0x0002
|
|
|
+#define F2FS_FEATURE_ATOMIC_WRITE 0x0004
|
|
|
+#define F2FS_FEATURE_EXTRA_ATTR 0x0008
|
|
|
|
|
|
#define F2FS_HAS_FEATURE(sb, mask) \
|
|
|
((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
|
|
@@ -359,10 +360,10 @@ struct f2fs_flush_device {
|
|
|
|
|
|
/* for inline stuff */
|
|
|
#define DEF_INLINE_RESERVED_SIZE 1
|
|
|
-
|
|
|
-static inline int get_inline_reserved_size(struct inode *inode);
|
|
|
-#define MAX_INLINE_DATA(inode) (sizeof(__le32) * (DEF_ADDRS_PER_INODE -\
|
|
|
- get_inline_reserved_size(inode) -\
|
|
|
+static inline int get_extra_isize(struct inode *inode);
|
|
|
+#define MAX_INLINE_DATA(inode) (sizeof(__le32) * \
|
|
|
+ (CUR_ADDRS_PER_INODE(inode) - \
|
|
|
+ DEF_INLINE_RESERVED_SIZE - \
|
|
|
F2FS_INLINE_XATTR_ADDRS))
|
|
|
|
|
|
/* for inline dir */
|
|
@@ -568,7 +569,7 @@ struct f2fs_inode_info {
|
|
|
struct rw_semaphore dio_rwsem[2];/* avoid racing between dio and gc */
|
|
|
struct rw_semaphore i_mmap_sem;
|
|
|
|
|
|
- int i_inline_reserved; /* reserved size in inline data */
|
|
|
+ int i_extra_isize; /* size of extra space located in i_addr */
|
|
|
};
|
|
|
|
|
|
static inline void get_extent_info(struct extent_info *ext,
|
|
@@ -1792,20 +1793,38 @@ static inline bool IS_INODE(struct page *page)
|
|
|
return RAW_IS_INODE(p);
|
|
|
}
|
|
|
|
|
|
+static inline int offset_in_addr(struct f2fs_inode *i)
|
|
|
+{
|
|
|
+ return (i->i_inline & F2FS_EXTRA_ATTR) ?
|
|
|
+ (le16_to_cpu(i->i_extra_isize) / sizeof(__le32)) : 0;
|
|
|
+}
|
|
|
+
|
|
|
static inline __le32 *blkaddr_in_node(struct f2fs_node *node)
|
|
|
{
|
|
|
return RAW_IS_INODE(node) ? node->i.i_addr : node->dn.addr;
|
|
|
}
|
|
|
|
|
|
-static inline block_t datablock_addr(struct page *node_page,
|
|
|
- unsigned int offset)
|
|
|
+static inline int f2fs_has_extra_attr(struct inode *inode);
|
|
|
+static inline block_t datablock_addr(struct inode *inode,
|
|
|
+ struct page *node_page, unsigned int offset)
|
|
|
{
|
|
|
struct f2fs_node *raw_node;
|
|
|
__le32 *addr_array;
|
|
|
+ int base = 0;
|
|
|
+ bool is_inode = IS_INODE(node_page);
|
|
|
|
|
|
raw_node = F2FS_NODE(node_page);
|
|
|
+
|
|
|
+ /* from GC path only */
|
|
|
+ if (!inode) {
|
|
|
+ if (is_inode)
|
|
|
+ base = offset_in_addr(&raw_node->i);
|
|
|
+ } else if (f2fs_has_extra_attr(inode) && is_inode) {
|
|
|
+ base = get_extra_isize(inode);
|
|
|
+ }
|
|
|
+
|
|
|
addr_array = blkaddr_in_node(raw_node);
|
|
|
- return le32_to_cpu(addr_array[offset]);
|
|
|
+ return le32_to_cpu(addr_array[base + offset]);
|
|
|
}
|
|
|
|
|
|
static inline int f2fs_test_bit(unsigned int nr, char *addr)
|
|
@@ -1896,6 +1915,7 @@ enum {
|
|
|
FI_DIRTY_FILE, /* indicate regular/symlink has dirty pages */
|
|
|
FI_NO_PREALLOC, /* indicate skipped preallocated blocks */
|
|
|
FI_HOT_DATA, /* indicate file is hot */
|
|
|
+ FI_EXTRA_ATTR, /* indicate file has extra attribute */
|
|
|
};
|
|
|
|
|
|
static inline void __mark_inode_dirty_flag(struct inode *inode,
|
|
@@ -2015,6 +2035,8 @@ static inline void get_inline_info(struct inode *inode, struct f2fs_inode *ri)
|
|
|
set_bit(FI_DATA_EXIST, &fi->flags);
|
|
|
if (ri->i_inline & F2FS_INLINE_DOTS)
|
|
|
set_bit(FI_INLINE_DOTS, &fi->flags);
|
|
|
+ if (ri->i_inline & F2FS_EXTRA_ATTR)
|
|
|
+ set_bit(FI_EXTRA_ATTR, &fi->flags);
|
|
|
}
|
|
|
|
|
|
static inline void set_raw_inline(struct inode *inode, struct f2fs_inode *ri)
|
|
@@ -2031,6 +2053,13 @@ static inline void set_raw_inline(struct inode *inode, struct f2fs_inode *ri)
|
|
|
ri->i_inline |= F2FS_DATA_EXIST;
|
|
|
if (is_inode_flag_set(inode, FI_INLINE_DOTS))
|
|
|
ri->i_inline |= F2FS_INLINE_DOTS;
|
|
|
+ if (is_inode_flag_set(inode, FI_EXTRA_ATTR))
|
|
|
+ ri->i_inline |= F2FS_EXTRA_ATTR;
|
|
|
+}
|
|
|
+
|
|
|
+static inline int f2fs_has_extra_attr(struct inode *inode)
|
|
|
+{
|
|
|
+ return is_inode_flag_set(inode, FI_EXTRA_ATTR);
|
|
|
}
|
|
|
|
|
|
static inline int f2fs_has_inline_xattr(struct inode *inode)
|
|
@@ -2041,8 +2070,8 @@ static inline int f2fs_has_inline_xattr(struct inode *inode)
|
|
|
static inline unsigned int addrs_per_inode(struct inode *inode)
|
|
|
{
|
|
|
if (f2fs_has_inline_xattr(inode))
|
|
|
- return DEF_ADDRS_PER_INODE - F2FS_INLINE_XATTR_ADDRS;
|
|
|
- return DEF_ADDRS_PER_INODE;
|
|
|
+ return CUR_ADDRS_PER_INODE(inode) - F2FS_INLINE_XATTR_ADDRS;
|
|
|
+ return CUR_ADDRS_PER_INODE(inode);
|
|
|
}
|
|
|
|
|
|
static inline void *inline_xattr_addr(struct page *page)
|
|
@@ -2104,9 +2133,9 @@ static inline bool f2fs_is_drop_cache(struct inode *inode)
|
|
|
static inline void *inline_data_addr(struct inode *inode, struct page *page)
|
|
|
{
|
|
|
struct f2fs_inode *ri = F2FS_INODE(page);
|
|
|
- int reserved_size = get_inline_reserved_size(inode);
|
|
|
+ int extra_size = get_extra_isize(inode);
|
|
|
|
|
|
- return (void *)&(ri->i_addr[reserved_size]);
|
|
|
+ return (void *)&(ri->i_addr[extra_size + DEF_INLINE_RESERVED_SIZE]);
|
|
|
}
|
|
|
|
|
|
static inline int f2fs_has_inline_dentry(struct inode *inode)
|
|
@@ -2197,15 +2226,19 @@ static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
|
|
|
return kmalloc(size, flags);
|
|
|
}
|
|
|
|
|
|
-static inline int get_inline_reserved_size(struct inode *inode)
|
|
|
+static inline int get_extra_isize(struct inode *inode)
|
|
|
{
|
|
|
- return F2FS_I(inode)->i_inline_reserved;
|
|
|
+ return F2FS_I(inode)->i_extra_isize / sizeof(__le32);
|
|
|
}
|
|
|
|
|
|
#define get_inode_mode(i) \
|
|
|
((is_inode_flag_set(i, FI_ACL_MODE)) ? \
|
|
|
(F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
|
|
|
|
|
|
+#define F2FS_TOTAL_EXTRA_ATTR_SIZE \
|
|
|
+ (offsetof(struct f2fs_inode, i_extra_end) - \
|
|
|
+ offsetof(struct f2fs_inode, i_extra_isize)) \
|
|
|
+
|
|
|
/*
|
|
|
* file.c
|
|
|
*/
|
|
@@ -2798,6 +2831,11 @@ static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb)
|
|
|
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
|
|
|
}
|
|
|
|
|
|
+static inline int f2fs_sb_has_extra_attr(struct super_block *sb)
|
|
|
+{
|
|
|
+ return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_EXTRA_ATTR);
|
|
|
+}
|
|
|
+
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
|
static inline int get_blkz_type(struct f2fs_sb_info *sbi,
|
|
|
struct block_device *bdev, block_t blkaddr)
|