[f2fs-dev] [PATCH] f2fs: disable f2fs_check_rb_tree_consistence

2018-06-20 Thread Chao Yu
If there is millions of discard entries cached in rb tree, each
sanity check of it can cause very long latency as held cmd_lock
blocking other lock grabbers.

In other aspect, we have enabled the check very long time, as
we see, there is no such inconsistent condition caused by bugs.

But still we do not choose to kill it directly, instead, adding
an flag to disable the check now, if there is related code change,
we can reuse it to detect bugs.

Signed-off-by: Yunlei He 
Signed-off-by: Chao Yu 
---
 fs/f2fs/f2fs.h|  1 +
 fs/f2fs/segment.c | 10 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 49c687173923..412e907920c2 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -309,6 +309,7 @@ struct discard_cmd_control {
atomic_t issing_discard;/* # of issing discard */
atomic_t discard_cmd_cnt;   /* # of cached cmd count */
struct rb_root root;/* root of discard rb-tree */
+   bool rbtree_check;  /* config for consistence check 
*/
 };
 
 /* for the list of fsync inodes, used only during recovery */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 6dbdf2c48fba..8c1d6c546fa0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1199,8 +1199,9 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
mutex_lock(>cmd_lock);
if (list_empty(pend_list))
goto next;
-   f2fs_bug_on(sbi,
-   !f2fs_check_rb_tree_consistence(sbi, >root));
+   if (dcc->rbtree_check)
+   f2fs_bug_on(sbi, !f2fs_check_rb_tree_consistence(sbi,
+   >root));
blk_start_plug();
list_for_each_entry_safe(dc, tmp, pend_list, list) {
f2fs_bug_on(sbi, dc->state != D_PREP);
@@ -1752,6 +1753,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info 
*sbi)
dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg;
dcc->undiscard_blks = 0;
dcc->root = RB_ROOT;
+   dcc->rbtree_check = false;
 
init_waitqueue_head(>discard_wait_queue);
SM_I(sbi)->dcc_info = dcc;
@@ -2381,7 +2383,9 @@ static void __issue_discard_cmd_range(struct f2fs_sb_info 
*sbi,
issued = 0;
 
mutex_lock(>cmd_lock);
-   f2fs_bug_on(sbi, !f2fs_check_rb_tree_consistence(sbi, >root));
+   if (dcc->rbtree_check)
+   f2fs_bug_on(sbi, !f2fs_check_rb_tree_consistence(sbi,
+   >root));
 
dc = (struct discard_cmd *)f2fs_lookup_rb_tree_ret(>root,
NULL, start,
-- 
2.18.0.rc1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] fsck.f2fs: show missing large_nat_bitmap flag in print_ckpt_info

2018-06-20 Thread Chao Yu
Previously, we forget to print large_nat_bitmap according to CP flag,
fix it.

Signed-off-by: Chao Yu 
---
 fsck/mount.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fsck/mount.c b/fsck/mount.c
index f830e9b1f72a..b4911506cddb 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -405,6 +405,8 @@ void print_ckpt_info(struct f2fs_sb_info *sbi)
 void print_cp_state(u32 flag)
 {
MSG(0, "Info: checkpoint state = %x : ", flag);
+   if (flag & CP_LARGE_NAT_BITMAP_FLAG)
+   MSG(0, "%s", " large_nat_bitmap");
if (flag & CP_NOCRC_RECOVERY_FLAG)
MSG(0, "%s", " allow_nocrc");
if (flag & CP_TRIMMED_FLAG)
-- 
2.18.0.rc1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs-tools: fix compile errors on AOSP

2018-06-20 Thread Junling Zheng
Include needed header files directly to fix compile errors on AOSP.

Signed-off-by: Junling Zheng 
---
 include/f2fs_fs.h | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 49ecee9..0a1ed84 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -13,6 +13,8 @@
 #define __F2FS_FS_H__
 
 #include 
+#include 
+#include 
 #ifdef HAVE_CONFIG_H
 #include 
 #endif
@@ -40,14 +42,6 @@
 #include 
 #endif
 
-#ifdef HAVE_STDLIB_H
-#include 
-#endif
-
-#ifdef HAVE_STRING_H
-#include 
-#endif
-
 #ifdef HAVE_LIBSELINUX
 #include 
 #include 
-- 
2.17.0


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2] fsck.f2fs: introduce fsck_chk_curseg_info

2018-06-20 Thread Sheng Yong
If curseg is an empty segment, it will not be checked. This patch
introduces fsck_chk_curseg_info() to check SIT/SSA type of cursegs
to avoid curseg corruption.

Signed-off-by: Sheng Yong 
---
v2: check c.fix_on and c.preen_mode before updating se->type

 fsck/fsck.c | 39 +++
 fsck/fsck.h |  1 +
 fsck/main.c |  2 ++
 3 files changed, 42 insertions(+)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 5b6dbc8..36b0b1d 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -2422,6 +2422,45 @@ out:
return cnt;
 }
 
+int fsck_chk_curseg_info(struct f2fs_sb_info *sbi)
+{
+   struct curseg_info *curseg;
+   struct seg_entry *se;
+   struct f2fs_summary_block *sum_blk;
+   int i, ret = 0;
+
+   for (i = 0; i < NO_CHECK_TYPE; i++) {
+   curseg = CURSEG_I(sbi, i);
+   se = get_seg_entry(sbi, curseg->segno);
+   sum_blk = curseg->sum_blk;
+
+   if (se->type != i) {
+   ASSERT_MSG("Incorrect curseg [%d]: segno [0x%x] "
+  "type(SIT) [%d]", i, curseg->segno,
+  se->type);
+   if (c.fix_on || c.preen_mode)
+   se->type = i;
+   ret = -1;
+   }
+   if (i <= CURSEG_COLD_DATA && IS_SUM_DATA_SEG(sum_blk->footer)) {
+   continue;
+   } else if (i > CURSEG_COLD_DATA && 
IS_SUM_NODE_SEG(sum_blk->footer)) {
+   continue;
+   } else {
+   ASSERT_MSG("Incorrect curseg [%d]: segno [0x%x] "
+  "type(SSA) [%d]", i, curseg->segno,
+  sum_blk->footer.entry_type);
+   if (c.fix_on || c.preen_mode)
+   sum_blk->footer.entry_type =
+   i <= CURSEG_COLD_DATA ?
+   SUM_TYPE_DATA : SUM_TYPE_NODE;
+   ret = -1;
+   }
+   }
+
+   return ret;
+}
+
 int fsck_verify(struct f2fs_sb_info *sbi)
 {
unsigned int i = 0;
diff --git a/fsck/fsck.h b/fsck/fsck.h
index cbe7fc4..5530aff 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -144,6 +144,7 @@ extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, u32, 
struct child_info *,
 int fsck_chk_inline_dentries(struct f2fs_sb_info *, struct f2fs_node *,
struct child_info *);
 int fsck_chk_meta(struct f2fs_sb_info *sbi);
+int fsck_chk_curseg_info(struct f2fs_sb_info *);
 int convert_encrypted_name(unsigned char *, int, unsigned char *, int);
 
 extern void update_free_segments(struct f2fs_sb_info *);
diff --git a/fsck/main.c b/fsck/main.c
index 09026c9..f6d12b0 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -578,6 +578,8 @@ static void do_fsck(struct f2fs_sb_info *sbi)
 
print_cp_state(flag);
 
+   fsck_chk_curseg_info(sbi);
+
if (!c.fix_on && !c.bug_on) {
switch (c.preen_mode) {
case PREEN_MODE_1:
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: Fix uninitialized return in f2fs_ioc_shutdown()

2018-06-20 Thread Dan Carpenter
"ret" can be uninitialized on the success path when "in ==
F2FS_GOING_DOWN_FULLSYNC".

Fixes: 60b2b4ee2bc0 ("f2fs: Fix deadlock in shutdown ioctl")
Signed-off-by: Dan Carpenter 

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 6880c6f78d58..73c875c81ed6 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1866,7 +1866,7 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned 
long arg)
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct super_block *sb = sbi->sb;
__u32 in;
-   int ret;
+   int ret = 0;
 
if (!capable(CAP_SYS_ADMIN))
return -EPERM;

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: use timespec64 for inode timestamps

2018-06-20 Thread Arnd Bergmann
The on-disk representation and the vfs both use 64-bit tv_sec values,
so let's change the last missing piece in the middle.

Signed-off-by: Arnd Bergmann 
---
 fs/f2fs/f2fs.h  | 16 ++--
 fs/f2fs/inode.c | 12 ++--
 fs/f2fs/namei.c |  2 +-
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 4d8b1de83143..8b519707433b 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -669,8 +669,8 @@ struct f2fs_inode_info {
int i_extra_isize;  /* size of extra space located in 
i_addr */
kprojid_t i_projid; /* id for project quota */
int i_inline_xattr_size;/* inline xattr size */
-   struct timespec i_crtime;   /* inode creation time */
-   struct timespec i_disk_time[4]; /* inode disk times */
+   struct timespec64 i_crtime; /* inode creation time */
+   struct timespec64 i_disk_time[4];/* inode disk times */
 };
 
 static inline void get_extent_info(struct extent_info *ext,
@@ -2518,7 +2518,6 @@ static inline void clear_file(struct inode *inode, int 
type)
 
 static inline bool f2fs_skip_inode_update(struct inode *inode, int dsync)
 {
-   struct timespec ts;
bool ret;
 
if (dsync) {
@@ -2534,16 +2533,13 @@ static inline bool f2fs_skip_inode_update(struct inode 
*inode, int dsync)
i_size_read(inode) & ~PAGE_MASK)
return false;
 
-   ts = timespec64_to_timespec(inode->i_atime);
-   if (!timespec_equal(F2FS_I(inode)->i_disk_time, ))
+   if (!timespec64_equal(F2FS_I(inode)->i_disk_time, >i_atime))
return false;
-   ts = timespec64_to_timespec(inode->i_ctime);
-   if (!timespec_equal(F2FS_I(inode)->i_disk_time + 1, ))
+   if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 1, >i_ctime))
return false;
-   ts = timespec64_to_timespec(inode->i_mtime);
-   if (!timespec_equal(F2FS_I(inode)->i_disk_time + 2, ))
+   if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 2, >i_mtime))
return false;
-   if (!timespec_equal(F2FS_I(inode)->i_disk_time + 3,
+   if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 3,
_I(inode)->i_crtime))
return false;
 
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index f121c864f4c0..30a777369d2b 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -297,9 +297,9 @@ static int do_read_inode(struct inode *inode)
fi->i_crtime.tv_nsec = le32_to_cpu(ri->i_crtime_nsec);
}
 
-   F2FS_I(inode)->i_disk_time[0] = timespec64_to_timespec(inode->i_atime);
-   F2FS_I(inode)->i_disk_time[1] = timespec64_to_timespec(inode->i_ctime);
-   F2FS_I(inode)->i_disk_time[2] = timespec64_to_timespec(inode->i_mtime);
+   F2FS_I(inode)->i_disk_time[0] = inode->i_atime;
+   F2FS_I(inode)->i_disk_time[1] = inode->i_ctime;
+   F2FS_I(inode)->i_disk_time[2] = inode->i_mtime;
F2FS_I(inode)->i_disk_time[3] = F2FS_I(inode)->i_crtime;
f2fs_put_page(node_page, 1);
 
@@ -470,9 +470,9 @@ void f2fs_update_inode(struct inode *inode, struct page 
*node_page)
if (inode->i_nlink == 0)
clear_inline_node(node_page);
 
-   F2FS_I(inode)->i_disk_time[0] = timespec64_to_timespec(inode->i_atime);
-   F2FS_I(inode)->i_disk_time[1] = timespec64_to_timespec(inode->i_ctime);
-   F2FS_I(inode)->i_disk_time[2] = timespec64_to_timespec(inode->i_mtime);
+   F2FS_I(inode)->i_disk_time[0] = inode->i_atime;
+   F2FS_I(inode)->i_disk_time[1] = inode->i_ctime;
+   F2FS_I(inode)->i_disk_time[2] = inode->i_mtime;
F2FS_I(inode)->i_disk_time[3] = F2FS_I(inode)->i_crtime;
 }
 
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 231b7f3ea7d3..2ea0de4cbe76 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -51,7 +51,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, 
umode_t mode)
inode->i_ino = ino;
inode->i_blocks = 0;
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
-   F2FS_I(inode)->i_crtime = timespec64_to_timespec(inode->i_mtime);
+   F2FS_I(inode)->i_crtime = inode->i_mtime;
inode->i_generation = sbi->s_next_generation++;
 
if (S_ISDIR(inode->i_mode))
-- 
2.9.0


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel