f2fs: show the max number of atomic operations
authorJaegeuk Kim <jaegeuk@kernel.org>
Wed, 28 Dec 2016 21:55:09 +0000 (13:55 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sun, 29 Jan 2017 03:46:01 +0000 (12:46 +0900)
This patch adds to show the max number of atomic operations which are
conducting concurrently.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/debug.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/segment.c

index fbd5184140d086df541a2583ccc5d1de74054e58..29cdf0c1da1d7f8bda6baeaad4cd0586ded01c3b 100644 (file)
@@ -50,6 +50,8 @@ static void update_general_status(struct f2fs_sb_info *sbi)
        si->ndirty_files = sbi->ndirty_inode[FILE_INODE];
        si->ndirty_all = sbi->ndirty_inode[DIRTY_META];
        si->inmem_pages = get_pages(sbi, F2FS_INMEM_PAGES);
+       si->aw_cnt = atomic_read(&sbi->aw_cnt);
+       si->max_aw_cnt = atomic_read(&sbi->max_aw_cnt);
        si->nr_wb_cp_data = get_pages(sbi, F2FS_WB_CP_DATA);
        si->nr_wb_data = get_pages(sbi, F2FS_WB_DATA);
        si->total_count = (int)sbi->user_block_count / sbi->blocks_per_seg;
@@ -256,6 +258,8 @@ static int stat_show(struct seq_file *s, void *v)
                           si->inline_dir);
                seq_printf(s, "  - Orphan Inode: %u\n",
                           si->orphans);
+               seq_printf(s, "  - Atomic write count: %4d (Max. %4d)\n",
+                          si->aw_cnt, si->max_aw_cnt);
                seq_printf(s, "\nMain area: %d segs, %d secs %d zones\n",
                           si->main_area_segs, si->main_area_sections,
                           si->main_area_zones);
@@ -414,6 +418,9 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
        atomic_set(&sbi->inline_dir, 0);
        atomic_set(&sbi->inplace_count, 0);
 
+       atomic_set(&sbi->aw_cnt, 0);
+       atomic_set(&sbi->max_aw_cnt, 0);
+
        mutex_lock(&f2fs_stat_mutex);
        list_add_tail(&si->stat_list, &f2fs_stat_list);
        mutex_unlock(&f2fs_stat_mutex);
index 0d7eaddef4a0b265a769c8fadb648dfa9d65ff7e..bdcfe2a9b532256d37e7ae567d071e4aa952c3a2 100644 (file)
@@ -884,6 +884,8 @@ struct f2fs_sb_info {
        atomic_t inline_xattr;                  /* # of inline_xattr inodes */
        atomic_t inline_inode;                  /* # of inline_data inodes */
        atomic_t inline_dir;                    /* # of inline_dentry inodes */
+       atomic_t aw_cnt;                        /* # of atomic writes */
+       atomic_t max_aw_cnt;                    /* max # of atomic writes */
        int bg_gc;                              /* background gc calls */
        unsigned int ndirty_inode[NR_INODE_TYPE];       /* # of dirty inodes */
 #endif
@@ -2236,6 +2238,7 @@ struct f2fs_stat_info {
        int total_count, utilization;
        int bg_gc, nr_wb_cp_data, nr_wb_data;
        int inline_xattr, inline_inode, inline_dir, orphans;
+       int aw_cnt, max_aw_cnt;
        unsigned int valid_count, valid_node_count, valid_inode_count, discard_blks;
        unsigned int bimodal, avg_vblocks;
        int util_free, util_valid, util_invalid;
@@ -2307,6 +2310,17 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
                ((sbi)->block_count[(curseg)->alloc_type]++)
 #define stat_inc_inplace_blocks(sbi)                                   \
                (atomic_inc(&(sbi)->inplace_count))
+#define stat_inc_atomic_write(inode)                                   \
+               (atomic_inc(&F2FS_I_SB(inode)->aw_cnt));
+#define stat_dec_atomic_write(inode)                                   \
+               (atomic_dec(&F2FS_I_SB(inode)->aw_cnt));
+#define stat_update_max_atomic_write(inode)                            \
+       do {                                                            \
+               int cur = atomic_read(&F2FS_I_SB(inode)->aw_cnt);       \
+               int max = atomic_read(&F2FS_I_SB(inode)->max_aw_cnt);   \
+               if (cur > max)                                          \
+                       atomic_set(&F2FS_I_SB(inode)->max_aw_cnt, cur); \
+       } while (0)
 #define stat_inc_seg_count(sbi, type, gc_type)                         \
        do {                                                            \
                struct f2fs_stat_info *si = F2FS_STAT(sbi);             \
@@ -2360,6 +2374,9 @@ void f2fs_destroy_root_stats(void);
 #define stat_dec_inline_inode(inode)
 #define stat_inc_inline_dir(inode)
 #define stat_dec_inline_dir(inode)
+#define stat_inc_atomic_write(inode)
+#define stat_dec_atomic_write(inode)
+#define stat_update_max_atomic_write(inode)
 #define stat_inc_seg_type(sbi, curseg)
 #define stat_inc_block_count(sbi, curseg)
 #define stat_inc_inplace_blocks(sbi)
index 49f10dce817dc9e4806b6a417b96391a1c794fd1..291d2ca53a4cdc108c6014b7e588329b68af6dba 100644 (file)
@@ -1542,6 +1542,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
        if (ret)
                clear_inode_flag(inode, FI_ATOMIC_FILE);
 out:
+       stat_inc_atomic_write(inode);
+       stat_update_max_atomic_write(inode);
        inode_unlock(inode);
        mnt_drop_write_file(filp);
        return ret;
@@ -1571,9 +1573,11 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)
                        set_inode_flag(inode, FI_ATOMIC_FILE);
                        goto err_out;
                }
+               ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
+               stat_dec_atomic_write(inode);
+       } else {
+               ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
        }
-
-       ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
 err_out:
        inode_unlock(inode);
        mnt_drop_write_file(filp);
index 2e8d12e9cae9f56df67a587fde28e46099589b99..9cabe935afc7c06e73ebd90a80857ffbf6d7c793 100644 (file)
@@ -243,6 +243,7 @@ void drop_inmem_pages(struct inode *inode)
        struct f2fs_inode_info *fi = F2FS_I(inode);
 
        clear_inode_flag(inode, FI_ATOMIC_FILE);
+       stat_dec_atomic_write(inode);
 
        mutex_lock(&fi->inmem_lock);
        __revoke_inmem_pages(inode, &fi->inmem_pages, true, false);