* [f2fs-dev] [PATCH] sload.f2fs: fix to set temperature during sload
@ 2019-07-31 13:00 Chao Yu
0 siblings, 0 replies; only message in thread
From: Chao Yu @ 2019-07-31 13:00 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: jaegeuk
This patch enable to set file's temperature while loading files
to image.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fsck/dir.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++
include/f2fs_fs.h | 1 +
mkfs/f2fs_format.c | 2 +-
3 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/fsck/dir.c b/fsck/dir.c
index b3957d6..92d7e05 100644
--- a/fsck/dir.c
+++ b/fsck/dir.c
@@ -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;
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 9f7717e..2dda901 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -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
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index c9c4fe5..9402619 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -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;
}
--
2.18.0.rc1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-07-31 13:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-31 13:00 [f2fs-dev] [PATCH] sload.f2fs: fix to set temperature during sload Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).