f2fs: add node_io_flag for bio flags likewise data_io_flag
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 4 Jun 2020 18:49:43 +0000 (11:49 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 9 Jun 2020 03:37:54 +0000 (20:37 -0700)
This patch adds another way to attach bio flags to node writes.

Description:   Give a way to attach REQ_META|FUA to node writes
               given temperature-based bits. Now the bits indicate:
               *      REQ_META     |      REQ_FUA      |
               *    5 |    4 |   3 |    2 |    1 |   0 |
               * Cold | Warm | Hot | Cold | Warm | Hot |

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Documentation/ABI/testing/sysfs-fs-f2fs
fs/f2fs/data.c
fs/f2fs/f2fs.h
fs/f2fs/sysfs.c

index 427f5b45c67f132f32f70badec5e1bc92cde6323..4bb93a06d8abc52bb3cc6e5bc38005c202294d10 100644 (file)
@@ -333,6 +333,15 @@ Description:       Give a way to attach REQ_META|FUA to data writes
                *    5 |    4 |   3 |    2 |    1 |   0 |
                * Cold | Warm | Hot | Cold | Warm | Hot |
 
+What:          /sys/fs/f2fs/<disk>/node_io_flag
+Date:          June 2020
+Contact:       "Jaegeuk Kim" <jaegeuk@kernel.org>
+Description:   Give a way to attach REQ_META|FUA to node writes
+               given temperature-based bits. Now the bits indicate:
+               *      REQ_META     |      REQ_FUA      |
+               *    5 |    4 |   3 |    2 |    1 |   0 |
+               * Cold | Warm | Hot | Cold | Warm | Hot |
+
 What:          /sys/fs/f2fs/<disk>/iostat_period_ms
 Date:          April 2020
 Contact:       "Daeho Jeong" <daehojeong@google.com>
index a65bfc07ddb97125b4d994b7c59d2eb5a245a49c..798c325a820dc4bef55fc070fef27a4b7d924bff 100644 (file)
@@ -514,22 +514,28 @@ void f2fs_submit_bio(struct f2fs_sb_info *sbi,
        __submit_bio(sbi, bio, type);
 }
 
-static void __attach_data_io_flag(struct f2fs_io_info *fio)
+static void __attach_io_flag(struct f2fs_io_info *fio)
 {
        struct f2fs_sb_info *sbi = fio->sbi;
        unsigned int temp_mask = (1 << NR_TEMP_TYPE) - 1;
-       unsigned int fua_flag = sbi->data_io_flag & temp_mask;
-       unsigned int meta_flag = (sbi->data_io_flag >> NR_TEMP_TYPE) &
-                                                               temp_mask;
+       unsigned int io_flag, fua_flag, meta_flag;
+
+       if (fio->type == DATA)
+               io_flag = sbi->data_io_flag;
+       else if (fio->type == NODE)
+               io_flag = sbi->node_io_flag;
+       else
+               return;
+
+       fua_flag = io_flag & temp_mask;
+       meta_flag = (io_flag >> NR_TEMP_TYPE) & temp_mask;
+
        /*
-        * data io flag bits per temp:
+        * data/node io flag bits per temp:
         *      REQ_META     |      REQ_FUA      |
         *    5 |    4 |   3 |    2 |    1 |   0 |
         * Cold | Warm | Hot | Cold | Warm | Hot |
         */
-       if (fio->type != DATA)
-               return;
-
        if ((1 << fio->temp) & meta_flag)
                fio->op_flags |= REQ_META;
        if ((1 << fio->temp) & fua_flag)
@@ -543,7 +549,7 @@ static void __submit_merged_bio(struct f2fs_bio_info *io)
        if (!io->bio)
                return;
 
-       __attach_data_io_flag(fio);
+       __attach_io_flag(fio);
        bio_set_op_attrs(io->bio, fio->op, fio->op_flags);
 
        if (is_read_io(fio->op))
index 7794e2f0d6e8a70d613c4acb242c5e5fc433a45c..c812fb8e2d9c7a59888da1b6381fcd7299b6b8fc 100644 (file)
@@ -1568,6 +1568,7 @@ struct f2fs_sb_info {
 
        /* to attach REQ_META|REQ_FUA flags */
        unsigned int data_io_flag;
+       unsigned int node_io_flag;
 
        /* For sysfs suppport */
        struct kobject s_kobj;
index a117ae1f9d5f1357f2a27567bfcdf0304f563a91..fc4a46b6890407f0b64cfcafa5d60a4e47b5ba7a 100644 (file)
@@ -554,6 +554,7 @@ F2FS_RW_ATTR(FAULT_INFO_RATE, f2fs_fault_info, inject_rate, inject_rate);
 F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
 #endif
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
+F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
 F2FS_GENERAL_RO_ATTR(dirty_segments);
 F2FS_GENERAL_RO_ATTR(free_segments);
 F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes);
@@ -635,6 +636,7 @@ static struct attribute *f2fs_attrs[] = {
        ATTR_LIST(inject_type),
 #endif
        ATTR_LIST(data_io_flag),
+       ATTR_LIST(node_io_flag),
        ATTR_LIST(dirty_segments),
        ATTR_LIST(free_segments),
        ATTR_LIST(unusable),