sload.f2fs: fix to set temperature during sload
PATCH 1/1 sload.f2fs: fix to set temperature during sload
This patch enable to set file's temperature while loading files to image.
Signed-off-by Chao Yu <[email protected]>
--- fsck/dir.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ include/f2fs_fs.h | 1 + mkfs/f2fs_format.c | 2 +- 3 files changed, 53 insertions(+), 1 deletion(-)
fsck/dir.c +51 -0
@@ -409,6 +409,55 @@ static void page_symlink(struct f2fs_sb_info *sbi, struct f2fs_node *inode,free (data_blk); } +static inline int is_extension_exist (const char *s, +const char *sub) +{ +unsigned int slen =strlen (s); +unsigned int sublen =strlen (sub); +int i; + +/* +* filename format of multimedia file should be defined as: +* "filename + '.' + extension + (optional: '.' + temp extension)". +*/ +if (slen < sublen +2 ) +return 0 ; + +for (i =1 ; i < slen - sublen; i++) { +if (s[i] !='.' ) +continue ; +if (!strncasecmp (s + i +1 , sub, sublen)) +return 1 ; + } + +return 0 ; +} + +static void set_file_temperature (struct f2fs_sb_info *sbi, +struct f2fs_node *node_blk, +const unsigned char *name) +{ +__u8 (*extlist)[F2FS_EXTENSION_LEN ] = sbi->raw_super->extension_list; +int i, cold_count, hot_count; + + cold_count =le32_to_cpu (sbi->raw_super->extension_count); + hot_count = sbi->raw_super->hot_ext_count; + +for (i =0 ; i < cold_count + hot_count; i++) { +if (is_extension_exist ((const char *)name, + (const char *)extlist[i])) +break ; + } + +if (i == cold_count + hot_count) +return ; + +if (i < cold_count) + node_blk->i.i_advise |=FADVISE_COLD_BIT ; +else + node_blk->i.i_advise |=FADVISE_HOT_BIT ; +} +static void init_inode_block (struct f2fs_sb_info *sbi,struct f2fs_node *node_blk,struct dentry *de) {
@@ -467,6 +516,8 @@ static void init_inode_block(struct f2fs_sb_info *sbi, node_blk->i.i_extra_isize =cpu_to_le16 (calc_extra_isize ()); } +set_file_temperature (sbi, node_blk, de->name); + node_blk->footer.ino =cpu_to_le32 (de->ino); node_blk->footer.nid =cpu_to_le32 (de->ino); node_blk->footer.flag =0 ;
include/f2fs_fs.h +1 -0
@@ -550,6 +550,7 @@ enum {#define F2FS_MAX_LOG_SECTOR_SIZE 12/* 12 bits for 4096 bytes */ #define F2FS_BLKSIZE 4096/* support only 4KB block */ #define F2FS_MAX_EXTENSION 64/* # of extension entries */ +#define F2FS_EXTENSION_LEN 8/* max size of extension */ #define F2FS_BLK_ALIGN (x) (((x) + F2FS_BLKSIZE - 1) / F2FS_BLKSIZE)#define NULL_ADDR 0x0U
mkfs/f2fs_format.c +1 -1
@@ -146,7 +146,7 @@ static void cure_extension_list(void) ue =strtok (ext_str,", " );while (ue !=NULL ) { name_len =strlen (ue); -if (name_len >=8 ) { +if (name_len >=F2FS_EXTENSION_LEN ) {MSG (0 ,"\tWarn: Extension name (%s) is too long\n" , ue); goto next; }
Signature · 8 lines
2.18.0.rc1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel