Re: [f2fs-dev] [PATCH v3] dump.f2fs: only dump nat inside the specified nid range

2018-07-02 Thread Chao Yu
On 2018/7/2 17:22, Junling Zheng wrote:
> Only dump nat info of nids inside the specified range.
> 
> Signed-off-by: Junling Zheng 

Looks good to me. :)

Reviewed-by: Chao Yu 

Thanks,



--
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 v3] dump.f2fs: only dump nat inside the specified nid range

2018-07-02 Thread Junling Zheng
Only dump nat info of nids inside the specified range.

Signed-off-by: Junling Zheng 
---
v2 -> v3:
 1) add a parameter to current_nat_addr() to get the correct nat pack
 2) use current_nat_addr() to get block_addr and nat pack in nat_dump
v1 -> v2:
 1) change {start,end}_nat type into nid_t
 2) put ASSERT() sentence close up to malloc
 3) use F2FS_NODE_INO and F2FS_META_INO instead of ino 1 and 2
 4) update man page of dump.f2fs

 fsck/dump.c | 94 +++--
 fsck/fsck.h |  7 ++--
 fsck/main.c |  4 +--
 fsck/mount.c| 19 ++
 man/dump.f2fs.8 | 13 +--
 5 files changed, 65 insertions(+), 72 deletions(-)

diff --git a/fsck/dump.c b/fsck/dump.c
index 9236a43..8cf431c 100644
--- a/fsck/dump.c
+++ b/fsck/dump.c
@@ -31,78 +31,38 @@ const char *seg_type_name[SEG_TYPE_MAX + 1] = {
"SEG_TYPE_NONE",
 };
 
-void nat_dump(struct f2fs_sb_info *sbi)
+void nat_dump(struct f2fs_sb_info *sbi, nid_t start_nat, nid_t end_nat)
 {
-   struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
-   struct f2fs_nm_info *nm_i = NM_I(sbi);
struct f2fs_nat_block *nat_block;
struct f2fs_node *node_block;
-   u32 nr_nat_blks, nid;
-   pgoff_t block_off;
+   nid_t nid;
pgoff_t block_addr;
char buf[BUF_SZ];
-   int seg_off;
int fd, ret, pack;
-   unsigned int i;
 
nat_block = (struct f2fs_nat_block *)calloc(BLOCK_SZ, 1);
-   node_block = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
ASSERT(nat_block);
-
-   nr_nat_blks = get_sb(segment_count_nat) <<
-   (sbi->log_blocks_per_seg - 1);
+   node_block = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
+   ASSERT(node_block);
 
fd = open("dump_nat", O_CREAT|O_WRONLY|O_TRUNC, 0666);
ASSERT(fd >= 0);
 
-   for (block_off = 0; block_off < nr_nat_blks; pack = 1, block_off++) {
-
-   seg_off = block_off >> sbi->log_blocks_per_seg;
-   block_addr = (pgoff_t)(nm_i->nat_blkaddr +
-   (seg_off << sbi->log_blocks_per_seg << 1) +
-   (block_off & ((1 << sbi->log_blocks_per_seg) - 1)));
-
-   if (f2fs_test_bit(block_off, nm_i->nat_bitmap)) {
-   block_addr += sbi->blocks_per_seg;
-   pack = 2;
-   }
-
-   ret = dev_read_block(nat_block, block_addr);
-   ASSERT(ret >= 0);
+   for (nid = start_nat; nid < end_nat; nid++) {
+   struct f2fs_nat_entry raw_nat;
+   struct node_info ni;
+   if(nid == 0 || nid == F2FS_NODE_INO(sbi) ||
+   nid == F2FS_META_INO(sbi))
+   continue;
 
-   nid = block_off * NAT_ENTRY_PER_BLOCK;
-   for (i = 0; i < NAT_ENTRY_PER_BLOCK; i++) {
-   struct f2fs_nat_entry raw_nat;
-   struct node_info ni;
-   ni.nid = nid + i;
+   ni.nid = nid;
+   block_addr = current_nat_addr(sbi, nid, );
 
-   if(nid + i  == 0 || nid + i  == 1 || nid + i == 2 )
-   continue;
-   if (lookup_nat_in_journal(sbi, nid + i,
-   _nat) >= 0) {
-   node_info_from_raw_nat(, _nat);
-   ret = dev_read_block(node_block, ni.blk_addr);
-   ASSERT(ret >= 0);
-   if (ni.blk_addr != 0x0) {
-   memset(buf, 0, BUF_SZ);
-   snprintf(buf, BUF_SZ,
-   "nid:%5u\tino:%5u\toffset:%5u"
-   "\tblkaddr:%10u\tpack:%d\n",
-   ni.nid, ni.ino,
-   
le32_to_cpu(node_block->footer.flag) >>
-   OFFSET_BIT_SHIFT,
-   ni.blk_addr, pack);
-   ret = write(fd, buf, strlen(buf));
-   ASSERT(ret >= 0);
-   }
-   } else {
-   node_info_from_raw_nat(,
-   _block->entries[i]);
-   if (ni.blk_addr == 0)
-   continue;
-
-   ret = dev_read_block(node_block, ni.blk_addr);
-   ASSERT(ret >= 0);
+   if (lookup_nat_in_journal(sbi, nid, _nat) >= 0) {
+   node_info_from_raw_nat(, _nat);
+   ret = dev_read_block(node_block, ni.blk_addr);
+   ASSERT(ret >= 0);
+ 

Re: [f2fs-dev] [PATCH] f2fs: show the fsync_mode=nobarrier mount option

2018-07-02 Thread Chao Yu
On 2018/7/2 14:07, Sahitya Tummala wrote:
> This patch shows the fsync_mode=nobarrier mount option in
> f2fs_show_options().
> 
> Signed-off-by: Sahitya Tummala 

Reviewed-by: Chao Yu 

Thanks,


--
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


Re: [f2fs-dev] [PATCH v2] dump.f2fs: only dump nat inside the specified nid range

2018-07-02 Thread Chao Yu
On 2018/7/2 11:59, Junling Zheng wrote:
> Only dump nat info of nids inside the specified range.
> 
> Signed-off-by: Junling Zheng 
> ---
> v1 -> v2:
>  1) change {start,end}_nat type into nid_t
>  2) put ASSERT() sentence close up to malloc
>  3) use F2FS_NODE_INO and F2FS_META_INO instead of ino 1 and 2
>  4) update man page of dump.f2fs
> 
>  fsck/dump.c | 82 ++---
>  fsck/fsck.h |  6 ++--
>  fsck/main.c |  4 +--
>  man/dump.f2fs.8 | 13 ++--
>  4 files changed, 52 insertions(+), 53 deletions(-)
> 
> diff --git a/fsck/dump.c b/fsck/dump.c
> index 9236a43..942e874 100644
> --- a/fsck/dump.c
> +++ b/fsck/dump.c
> @@ -31,32 +31,35 @@ const char *seg_type_name[SEG_TYPE_MAX + 1] = {
>   "SEG_TYPE_NONE",
>  };
>  
> -void nat_dump(struct f2fs_sb_info *sbi)
> +void nat_dump(struct f2fs_sb_info *sbi, nid_t start_nat, nid_t end_nat)
>  {
> - struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
>   struct f2fs_nm_info *nm_i = NM_I(sbi);
>   struct f2fs_nat_block *nat_block;
>   struct f2fs_node *node_block;
> - u32 nr_nat_blks, nid;
> + nid_t nid;
>   pgoff_t block_off;
>   pgoff_t block_addr;
>   char buf[BUF_SZ];
>   int seg_off;
>   int fd, ret, pack;

pack = 1;

> - unsigned int i;
>  
>   nat_block = (struct f2fs_nat_block *)calloc(BLOCK_SZ, 1);
> - node_block = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
>   ASSERT(nat_block);
> -
> - nr_nat_blks = get_sb(segment_count_nat) <<
> - (sbi->log_blocks_per_seg - 1);
> + node_block = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
> + ASSERT(node_block);
>  
>   fd = open("dump_nat", O_CREAT|O_WRONLY|O_TRUNC, 0666);
>   ASSERT(fd >= 0);
>  
> - for (block_off = 0; block_off < nr_nat_blks; pack = 1, block_off++) {
> + for (nid = start_nat; nid < end_nat; pack = 1, nid++) {
> + struct f2fs_nat_entry raw_nat;
> + struct node_info ni;
> + if(nid == 0 || nid == F2FS_NODE_INO(sbi) ||
> + nid == F2FS_META_INO(sbi))
> + continue;
>  
> + ni.nid = nid;
> + block_off = nid / NAT_ENTRY_PER_BLOCK;
>   seg_off = block_off >> sbi->log_blocks_per_seg;
>   block_addr = (pgoff_t)(nm_i->nat_blkaddr +
>   (seg_off << sbi->log_blocks_per_seg << 1) +
> @@ -67,42 +70,11 @@ void nat_dump(struct f2fs_sb_info *sbi)
>   pack = 2;

Nitpick,

How about replacing above codes with existed function current_nat_addr() to
avoid calculation bug, and since we need to set @pack, so we can add one
parameter to do that?

Thanks,

>   }
>  
> - ret = dev_read_block(nat_block, block_addr);
> - ASSERT(ret >= 0);
> -
> - nid = block_off * NAT_ENTRY_PER_BLOCK;
> - for (i = 0; i < NAT_ENTRY_PER_BLOCK; i++) {
> - struct f2fs_nat_entry raw_nat;
> - struct node_info ni;
> - ni.nid = nid + i;
> -
> - if(nid + i  == 0 || nid + i  == 1 || nid + i == 2 )
> - continue;
> - if (lookup_nat_in_journal(sbi, nid + i,
> - _nat) >= 0) {
> - node_info_from_raw_nat(, _nat);
> - ret = dev_read_block(node_block, ni.blk_addr);
> - ASSERT(ret >= 0);
> - if (ni.blk_addr != 0x0) {
> - memset(buf, 0, BUF_SZ);
> - snprintf(buf, BUF_SZ,
> - "nid:%5u\tino:%5u\toffset:%5u"
> - "\tblkaddr:%10u\tpack:%d\n",
> - ni.nid, ni.ino,
> - 
> le32_to_cpu(node_block->footer.flag) >>
> - OFFSET_BIT_SHIFT,
> - ni.blk_addr, pack);
> - ret = write(fd, buf, strlen(buf));
> - ASSERT(ret >= 0);
> - }
> - } else {
> - node_info_from_raw_nat(,
> - _block->entries[i]);
> - if (ni.blk_addr == 0)
> - continue;
> -
> - ret = dev_read_block(node_block, ni.blk_addr);
> - ASSERT(ret >= 0);
> + if (lookup_nat_in_journal(sbi, nid, _nat) >= 0) {
> + node_info_from_raw_nat(, _nat);
> + ret = dev_read_block(node_block, ni.blk_addr);
> + ASSERT(ret >= 0);
> + 

[f2fs-dev] [PATCH] f2fs: show the fsync_mode=nobarrier mount option

2018-07-02 Thread Sahitya Tummala
This patch shows the fsync_mode=nobarrier mount option in
f2fs_show_options().

Signed-off-by: Sahitya Tummala 
---
 fs/f2fs/super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 3995e92..12e3d2d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1343,6 +1343,8 @@ static int f2fs_show_options(struct seq_file *seq, struct 
dentry *root)
seq_printf(seq, ",fsync_mode=%s", "posix");
else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT)
seq_printf(seq, ",fsync_mode=%s", "strict");
+   else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_NOBARRIER)
+   seq_printf(seq, ",fsync_mode=%s", "nobarrier");
return 0;
 }
 
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project.


--
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