Re: [f2fs-dev] [PATCH] fsck.f2fs: simplify fsck_chk_quota_node in PREEN_MODE_1

2018-03-27 Thread Chao Yu
On 2018/3/26 20:47, Junling Zheng wrote:
> Do not do fsck_chk_node_blk to simplify fsck_chk_quota_node in
> PREEN_MODE_1, as well as fsck_chk_orphan_node.
> 
> Signed-off-by: Junling Zheng 

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] resize.f2fs: fix access out-of memory boundary

2018-03-27 Thread Chao Yu
On 2018/3/24 0:32, Jaegeuk Kim wrote:
> This fixes out-of memory boundary on nat_bitmap, when resizing small to
> large partition.
> 
> Signed-off-by: Jaegeuk Kim 

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] libf2fs: reset wanted_total_sectors by new sector_size

2018-03-27 Thread Junling Zheng
Hi, Jaegeuk:

On 2018/3/28 1:19, Jaegeuk Kim wrote:
> From: katao 
> 
> The args of wanted_total_sectors is calculated based
> on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i)
> may be reset dev_sector_size, we should reset the number
> of wanted_total_sectors.
> 
> This bug was reported to Google Issue Tracker.
> Link: https://issuetracker.google.com/issues/76407663
> 

This fix is puzzling...

IMO, we should not recalculate wanted_total_sectors here.
c.wanted_total_sectors is got from user in f2fs_parse_options.
Users must know the sector size of device they use, and they need to
pass a correct wanted_total_sectors to mkfs.f2fs.

Thanks,
Junling

> Signed-off-by: katao 
> Signed-off-by: Jaegeuk Kim 
> ---
>  lib/libf2fs.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 0c684d5..5f11796 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -799,8 +799,15 @@ int get_device_info(int i)
>  #ifdef BLKSSZGET
>   if (ioctl(fd, BLKSSZGET, _size) < 0)
>   MSG(0, "\tError: Using the default sector size\n");
> - else if (dev->sector_size < sector_size)
> + else if (dev->sector_size < sector_size){
> + /*
> +  * wanted_total_sectors need to be reset by new
> +  * sector_size.
> +  */
> + c.wanted_total_sectors = (c.wanted_total_sectors *
> + dev->sector_size) / sector_size;
>   dev->sector_size = sector_size;
> + }
>  #endif
>  #ifdef BLKGETSIZE64
>   if (ioctl(fd, BLKGETSIZE64, >total_sectors) < 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


Re: [f2fs-dev] [PATCH 1/4] mkfs.f2fs: update extension lists

2018-03-27 Thread Chao Yu
Hi Park,

On 2018/3/24 14:55, Ju Hyung Park wrote:
> Hi Chao,
> 
> Sorry myself as well for the late reply :)
> Got caught up with something.
> 
>> Like .so?
> 
> Yeah, that makes sense.
> I've reran the command without the size limit.
> 
>>From Ubuntu, I think we can add '*.pyc' files as it's compiled Python
> bytecode format.
>>From Android, I saw some new '*.cnt' files which are just jpeg files.
> Notably, Facebook, Skype, Tumblr and Twitter uses it.
> 
> Everything else seemed not that much interesting.
> 
>> I agree that we'd better support the superset list of common static file, but
>> also I hope there is flexible usage of common list, old list and self defined
>> list, so I think we'd better leave enough free space of cold list to let user
>> define private cold file type extension as they wish, meanwhile support an
>> option to make user have a chance to choose the common list or old list.
> 
> If I understood you correctly, you want to leave an option for the old list
> so that users have more room to add many more extensions, correct?

Yup.

> 
> If so, how about just leaving the old list and move the new ones to
> the kernel code?

Do you mean we need add a new option to enable common list? e.g.

-o extlist=classic means we enable thin cold/hot file type list, mostly we
recommended enable this in android system.
-o extlist=full means we enable full cold/hot file type list, it is recommended
in other system, like server or pc.

Like this?

Thanks,

> As I said in the previous comment, I don't think it makes sense to
> ship new lists only to at the time of mkfs.
> We can ship new lists as we update f2fs kernel code.
> 
> While the new version of f2fs allows users to dynamically add or
> remove extensions,
> it doesn't ship the new common lists.
> 
> Thanks.
> 
> On Wed, Mar 21, 2018 at 9:00 PM, Chao Yu  wrote:
>> Hi Park,
>>
>> Sorry for late replying.
>>
>> On 2018/3/19 11:53, Ju Hyung Park wrote:
>>> Hi Chao,
>>>
 Do you run this script in android environment to get the cold type?
>>> Yes, both on Ubuntu and Android(on /data with root permission).
>>>
 Actually, I doubt that '+1M' condition can't indicate that the file is 
 cold or
 not, and after run this script in my cell phone,
>>> Would it make sense to set a file that's < 1M as cold?
>>
>> Like .so?
>>
>>> I didn't think so. Please let me know if I'm wrong.
>>>
 I didn't see so many type as your patch adds.
>>> Of course, most of those were added from vlc and p7zip.
>>> There are tons more, but I added ones that are most common.
>>> While I personally don't have that much many types myself as well,
>>> I can easily see one having those extensions stored under f2fs.
>>>
>>> Previous list was not enough, imo.
>>> (After running the command, I've added exo and ?dex files for Android.)
>>>
 If that is a common cold file type list that user may not do random 
 updates in
 the file after its creation,
>>> That's exactly what I intended.
>>>
 I suggest that we can add one common list instead
 of changing old one controlled by mkfs option
>>> The new list is superset of the old list.
>>> A few extensions were removed as those are mostly deprecated formats
>>> and to make room for much more important extensions to be added such as m4a.
>>
>> I agree that we'd better support the superset list of common static file, but
>> also I hope there is flexible usage of common list, old list and self defined
>> list, so I think we'd better leave enough free space of cold list to let user
>> define private cold file type extension as they wish, meanwhile support an
>> option to make user have a chance to choose the common list or old list.
>>
>> How do you think?
>>
>> Hi Jaegeuk, what's your opinion?
>>
>> Thanks,
>>
>>>
>>> Thanks.
>>>
>>>
>>> On Mon, Mar 19, 2018 at 12:42 PM, Chao Yu  wrote:
 Hi Park,

 On 2018/3/17 23:02, Park Ju Hyung wrote:
> Those formats are large in size and rarely updated.
>
> Formats such as tar and zip were intentionally excluded as
> those are capable of random updates.
>
> (Added from vlc, p7zip and running
> 'find . -type f -size +1M |
> while read FILE; do echo ${FILE##*.}; done |
> sort | uniq -c | sort -nr'
> manually)

 Do you run this script in android environment to get the cold type?

 Actually, I doubt that '+1M' condition can't indicate that the file is 
 cold or
 not, and after run this script in my cell phone, I didn't see so many type 
 as
 your patch adds.

 If that is a common cold file type list that user may not do random 
 updates in
 the file after its creation, I suggest that we can add one common list 
 instead
 of changing old one controlled by mkfs option, anyway, to use which one, 
 the
 option can be decided by user.

 Thanks,

>
> Signed-off-by: Park Ju Hyung 

Re: [f2fs-dev] [PATCH v2] f2fs: rebuild get_node_path function

2018-03-27 Thread Chao Yu
On 2018/3/28 9:46, heyunlei wrote:
> 
> 
>> -Original Message-
>> From: Yuchao (T)
>> Sent: Wednesday, March 28, 2018 9:41 AM
>> To: heyunlei; jaeg...@kernel.org; linux-f2fs-devel@lists.sourceforge.net
>> Cc: Wangbintian
>> Subject: Re: [f2fs-dev][PATCH v2] f2fs: rebuild get_node_path function
>>
>> On 2018/3/22 11:31, Yunlei He wrote:
>>> This patch rebuild get_node_path function, no logic changes.
>>>
>>> v1->v2: '<' has higher priority than '-='
>>
>> It looks that after the cleanup, the code logic would not be more 
>> understandable
>> than before, since we'd better to avoid doing calculation inside if 
>> condition.
>>
> 
> Here I just refer to code in function ext2_block_to_path

Got it, for better readability, let's just keep current code style.

Thanks,

> 
> Thanks,
> 
>> Thanks,
>>
>>>
>>> Signed-off-by: Yunlei He 
>>> ---
>>>  fs/f2fs/node.c | 28 ++--
>>>  1 file changed, 6 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>>> index c511ef6..b8f2577 100644
>>> --- a/fs/f2fs/node.c
>>> +++ b/fs/f2fs/node.c
>>> @@ -526,46 +526,31 @@ static int get_node_path(struct inode *inode, long 
>>> block,
>>>
>>> if (block < direct_index) {
>>> offset[n] = block;
>>> -   goto got;
>>> -   }
>>> -   block -= direct_index;
>>> -   if (block < direct_blks) {
>>> +   } else if ((block -= direct_index) < direct_blks) {
>>> offset[n++] = NODE_DIR1_BLOCK;
>>> noffset[n] = 1;
>>> offset[n] = block;
>>> level = 1;
>>> -   goto got;
>>> -   }
>>> -   block -= direct_blks;
>>> -   if (block < direct_blks) {
>>> +   } else if ((block -= direct_blks) < direct_blks) {
>>> offset[n++] = NODE_DIR2_BLOCK;
>>> noffset[n] = 2;
>>> offset[n] = block;
>>> level = 1;
>>> -   goto got;
>>> -   }
>>> -   block -= direct_blks;
>>> -   if (block < indirect_blks) {
>>> +   } else if ((block -= direct_blks) < indirect_blks) {
>>> offset[n++] = NODE_IND1_BLOCK;
>>> noffset[n] = 3;
>>> offset[n++] = block / direct_blks;
>>> noffset[n] = 4 + offset[n - 1];
>>> offset[n] = block % direct_blks;
>>> level = 2;
>>> -   goto got;
>>> -   }
>>> -   block -= indirect_blks;
>>> -   if (block < indirect_blks) {
>>> +   } else if ((block -= indirect_blks) < indirect_blks) {
>>> offset[n++] = NODE_IND2_BLOCK;
>>> noffset[n] = 4 + dptrs_per_blk;
>>> offset[n++] = block / direct_blks;
>>> noffset[n] = 5 + dptrs_per_blk + offset[n - 1];
>>> offset[n] = block % direct_blks;
>>> level = 2;
>>> -   goto got;
>>> -   }
>>> -   block -= indirect_blks;
>>> -   if (block < dindirect_blks) {
>>> +   } else if ((block -= indirect_blks) < dindirect_blks) {
>>> offset[n++] = NODE_DIND_BLOCK;
>>> noffset[n] = 5 + (dptrs_per_blk * 2);
>>> offset[n++] = block / indirect_blks;
>>> @@ -577,11 +562,10 @@ static int get_node_path(struct inode *inode, long 
>>> block,
>>>   offset[n - 1];
>>> offset[n] = block % direct_blks;
>>> level = 3;
>>> -   goto got;
>>> } else {
>>> return -E2BIG;
>>> }
>>> -got:
>>> +
>>> return level;
>>>  }
>>>
>>>
> 


--
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] f2fs: Add a segment type check in inplace write

2018-03-27 Thread Chao Yu
On 2018/3/26 17:32, Yunlei He wrote:
> This patch add a segment type check in IPU, in
> case of something wrong with blkadd in dnode.
> 
> Signed-off-by: Yunlei He 

Reviewed-by: Chao Yu 

Thanks,

> ---
>  fs/f2fs/segment.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index f61c77b..c55942c 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2790,10 +2790,15 @@ void write_data_page(struct dnode_of_data *dn, struct 
> f2fs_io_info *fio)
>  int rewrite_data_page(struct f2fs_io_info *fio)
>  {
>   int err;
> + struct f2fs_sb_info *sbi = fio->sbi;
>  
>   fio->new_blkaddr = fio->old_blkaddr;
>   /* i/o temperature is needed for passing down write hints */
>   __get_segment_type(fio);
> +
> + f2fs_bug_on(sbi, !IS_DATASEG(get_seg_entry(sbi,
> + GET_SEGNO(sbi, fio->new_blkaddr))->type));
> +
>   stat_inc_inplace_blocks(fio->sbi);
>  
>   err = f2fs_submit_page_bio(fio);
> 


--
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] f2fs: rebuild get_node_path function

2018-03-27 Thread heyunlei


>-Original Message-
>From: Yuchao (T)
>Sent: Wednesday, March 28, 2018 9:41 AM
>To: heyunlei; jaeg...@kernel.org; linux-f2fs-devel@lists.sourceforge.net
>Cc: Wangbintian
>Subject: Re: [f2fs-dev][PATCH v2] f2fs: rebuild get_node_path function
>
>On 2018/3/22 11:31, Yunlei He wrote:
>> This patch rebuild get_node_path function, no logic changes.
>>
>> v1->v2: '<' has higher priority than '-='
>
>It looks that after the cleanup, the code logic would not be more 
>understandable
>than before, since we'd better to avoid doing calculation inside if condition.
>

Here I just refer to code in function ext2_block_to_path

Thanks,

>Thanks,
>
>>
>> Signed-off-by: Yunlei He 
>> ---
>>  fs/f2fs/node.c | 28 ++--
>>  1 file changed, 6 insertions(+), 22 deletions(-)
>>
>> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>> index c511ef6..b8f2577 100644
>> --- a/fs/f2fs/node.c
>> +++ b/fs/f2fs/node.c
>> @@ -526,46 +526,31 @@ static int get_node_path(struct inode *inode, long 
>> block,
>>
>>  if (block < direct_index) {
>>  offset[n] = block;
>> -goto got;
>> -}
>> -block -= direct_index;
>> -if (block < direct_blks) {
>> +} else if ((block -= direct_index) < direct_blks) {
>>  offset[n++] = NODE_DIR1_BLOCK;
>>  noffset[n] = 1;
>>  offset[n] = block;
>>  level = 1;
>> -goto got;
>> -}
>> -block -= direct_blks;
>> -if (block < direct_blks) {
>> +} else if ((block -= direct_blks) < direct_blks) {
>>  offset[n++] = NODE_DIR2_BLOCK;
>>  noffset[n] = 2;
>>  offset[n] = block;
>>  level = 1;
>> -goto got;
>> -}
>> -block -= direct_blks;
>> -if (block < indirect_blks) {
>> +} else if ((block -= direct_blks) < indirect_blks) {
>>  offset[n++] = NODE_IND1_BLOCK;
>>  noffset[n] = 3;
>>  offset[n++] = block / direct_blks;
>>  noffset[n] = 4 + offset[n - 1];
>>  offset[n] = block % direct_blks;
>>  level = 2;
>> -goto got;
>> -}
>> -block -= indirect_blks;
>> -if (block < indirect_blks) {
>> +} else if ((block -= indirect_blks) < indirect_blks) {
>>  offset[n++] = NODE_IND2_BLOCK;
>>  noffset[n] = 4 + dptrs_per_blk;
>>  offset[n++] = block / direct_blks;
>>  noffset[n] = 5 + dptrs_per_blk + offset[n - 1];
>>  offset[n] = block % direct_blks;
>>  level = 2;
>> -goto got;
>> -}
>> -block -= indirect_blks;
>> -if (block < dindirect_blks) {
>> +} else if ((block -= indirect_blks) < dindirect_blks) {
>>  offset[n++] = NODE_DIND_BLOCK;
>>  noffset[n] = 5 + (dptrs_per_blk * 2);
>>  offset[n++] = block / indirect_blks;
>> @@ -577,11 +562,10 @@ static int get_node_path(struct inode *inode, long 
>> block,
>>offset[n - 1];
>>  offset[n] = block % direct_blks;
>>  level = 3;
>> -goto got;
>>  } else {
>>  return -E2BIG;
>>  }
>> -got:
>> +
>>  return level;
>>  }
>>
>>

--
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] f2fs: rebuild get_node_path function

2018-03-27 Thread Chao Yu
On 2018/3/22 11:31, Yunlei He wrote:
> This patch rebuild get_node_path function, no logic changes.
> 
> v1->v2: '<' has higher priority than '-='

It looks that after the cleanup, the code logic would not be more understandable
than before, since we'd better to avoid doing calculation inside if condition.

Thanks,

> 
> Signed-off-by: Yunlei He 
> ---
>  fs/f2fs/node.c | 28 ++--
>  1 file changed, 6 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index c511ef6..b8f2577 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -526,46 +526,31 @@ static int get_node_path(struct inode *inode, long 
> block,
>  
>   if (block < direct_index) {
>   offset[n] = block;
> - goto got;
> - }
> - block -= direct_index;
> - if (block < direct_blks) {
> + } else if ((block -= direct_index) < direct_blks) {
>   offset[n++] = NODE_DIR1_BLOCK;
>   noffset[n] = 1;
>   offset[n] = block;
>   level = 1;
> - goto got;
> - }
> - block -= direct_blks;
> - if (block < direct_blks) {
> + } else if ((block -= direct_blks) < direct_blks) {
>   offset[n++] = NODE_DIR2_BLOCK;
>   noffset[n] = 2;
>   offset[n] = block;
>   level = 1;
> - goto got;
> - }
> - block -= direct_blks;
> - if (block < indirect_blks) {
> + } else if ((block -= direct_blks) < indirect_blks) {
>   offset[n++] = NODE_IND1_BLOCK;
>   noffset[n] = 3;
>   offset[n++] = block / direct_blks;
>   noffset[n] = 4 + offset[n - 1];
>   offset[n] = block % direct_blks;
>   level = 2;
> - goto got;
> - }
> - block -= indirect_blks;
> - if (block < indirect_blks) {
> + } else if ((block -= indirect_blks) < indirect_blks) {
>   offset[n++] = NODE_IND2_BLOCK;
>   noffset[n] = 4 + dptrs_per_blk;
>   offset[n++] = block / direct_blks;
>   noffset[n] = 5 + dptrs_per_blk + offset[n - 1];
>   offset[n] = block % direct_blks;
>   level = 2;
> - goto got;
> - }
> - block -= indirect_blks;
> - if (block < dindirect_blks) {
> + } else if ((block -= indirect_blks) < dindirect_blks) {
>   offset[n++] = NODE_DIND_BLOCK;
>   noffset[n] = 5 + (dptrs_per_blk * 2);
>   offset[n++] = block / indirect_blks;
> @@ -577,11 +562,10 @@ static int get_node_path(struct inode *inode, long 
> block,
> offset[n - 1];
>   offset[n] = block % direct_blks;
>   level = 3;
> - goto got;
>   } else {
>   return -E2BIG;
>   }
> -got:
> +
>   return level;
>  }
>  
> 


--
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 v4] f2fs: introduce a method to make nat journal more fresh

2018-03-27 Thread Chao Yu
On 2018/3/16 18:24, Yunlei He wrote:
> This patch introduce a method to make nat journal more fresh:
> i.  sort set list using dirty entry number and cp version
> average value.
> ii. if meet with cache hit, update average version valus with
> current cp version.
> 
> With this patch, newly modified nat set will flush to journal,
> and flush old nat set with same dirty entry number to nat area.
> 
> Signed-off-by: Yunlei He 
> ---
>  fs/f2fs/node.c | 39 ---
>  fs/f2fs/node.h |  4 +++-
>  2 files changed, 27 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 177c438..c511ef6 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -193,8 +193,8 @@ static void __del_from_nat_cache(struct f2fs_nm_info 
> *nm_i, struct nat_entry *e)
>   __free_nat_entry(e);
>  }
>  
> -static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i,
> - struct nat_entry *ne)
> +static void __set_nat_cache_dirty(struct f2fs_sb_info *sbi, bool 
> remove_journal,
> + struct f2fs_nm_info *nm_i, struct nat_entry *ne)
>  {
>   nid_t set = NAT_BLOCK_OFFSET(ne->ni.nid);
>   struct nat_entry_set *head;
> @@ -207,12 +207,18 @@ static void __set_nat_cache_dirty(struct f2fs_nm_info 
> *nm_i,
>   INIT_LIST_HEAD(>set_list);
>   head->set = set;
>   head->entry_cnt = 0;
> + head->cp_ver = 0;

head->cp_ver = div_u64(cur_cp_version(F2FS_CKPT(sbi)), NAT_JOURNAL_ENTRIES)?

Thanks,

>   f2fs_radix_tree_insert(_i->nat_set_root, set, head);
>   }
>  
>   if (get_nat_flag(ne, IS_DIRTY))
>   goto refresh_list;
>  
> + /* journal hit case, try to locate set in journal */
> + if (!remove_journal && head->entry_cnt <= NAT_JOURNAL_ENTRIES)
> + head->cp_ver += div_u64(cur_cp_version(F2FS_CKPT(sbi)),
> + NAT_JOURNAL_ENTRIES);
> +
>   nm_i->dirty_nat_cnt++;
>   head->entry_cnt++;
>   set_nat_flag(ne, IS_DIRTY, true);
> @@ -357,7 +363,7 @@ static void set_node_addr(struct f2fs_sb_info *sbi, 
> struct node_info *ni,
>   nat_set_blkaddr(e, new_blkaddr);
>   if (new_blkaddr == NEW_ADDR || new_blkaddr == NULL_ADDR)
>   set_nat_flag(e, IS_CHECKPOINTED, false);
> - __set_nat_cache_dirty(nm_i, e);
> + __set_nat_cache_dirty(sbi, false, nm_i, e);
>  
>   /* update fsync_mark if its inode nat entry is still alive */
>   if (ni->nid != ni->ino)
> @@ -2395,14 +2401,14 @@ static void remove_nats_in_journal(struct 
> f2fs_sb_info *sbi)
>   spin_unlock(_i->nid_list_lock);
>   }
>  
> - __set_nat_cache_dirty(nm_i, ne);
> + __set_nat_cache_dirty(sbi, true, nm_i, ne);
>   }
>   update_nats_in_cursum(journal, -i);
>   up_write(>journal_rwsem);
>  }
>  
> -static void __adjust_nat_entry_set(struct nat_entry_set *nes,
> - struct list_head *head, int max)
> +static void __adjust_nat_entry_set(struct f2fs_sb_info *sbi,
> + struct nat_entry_set *nes, struct list_head *head, int max)
>  {
>   struct nat_entry_set *cur;
>  
> @@ -2410,7 +2416,9 @@ static void __adjust_nat_entry_set(struct nat_entry_set 
> *nes,
>   goto add_out;
>  
>   list_for_each_entry(cur, head, set_list) {
> - if (cur->entry_cnt >= nes->entry_cnt) {
> + if (cur->entry_cnt > nes->entry_cnt ||
> + (cur->entry_cnt == nes->entry_cnt &&
> + cur->cp_ver < nes->cp_ver)) {
>   list_add(>set_list, cur->set_list.prev);
>   return;
>   }
> @@ -2458,7 +2466,6 @@ static void __flush_nat_entry_set(struct f2fs_sb_info 
> *sbi,
>   struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
>   struct f2fs_journal *journal = curseg->journal;
>   nid_t start_nid = set->set * NAT_ENTRY_PER_BLOCK;
> - bool to_journal = true;
>   struct f2fs_nat_block *nat_blk;
>   struct nat_entry *ne, *cur;
>   struct page *page = NULL;
> @@ -2468,11 +2475,14 @@ static void __flush_nat_entry_set(struct f2fs_sb_info 
> *sbi,
>* #1, flush nat entries to journal in current hot data summary block.
>* #2, flush nat entries to nat page.
>*/
> +
> + set->to_journal = true;
> +
>   if (enabled_nat_bits(sbi, cpc) ||
>   !__has_cursum_space(journal, set->entry_cnt, NAT_JOURNAL))
> - to_journal = false;
> + set->to_journal = false;
>  
> - if (to_journal) {
> + if (set->to_journal) {
>   down_write(>journal_rwsem);
>   } else {
>   page = get_next_nat_page(sbi, start_nid);
> @@ -2488,7 +2498,7 @@ static void __flush_nat_entry_set(struct f2fs_sb_info 
> *sbi,
>  
>   f2fs_bug_on(sbi, 

[f2fs-dev] [PATCH] libf2fs: reset wanted_total_sectors by new sector_size

2018-03-27 Thread Jaegeuk Kim
From: katao 

The args of wanted_total_sectors is calculated based
on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i)
may be reset dev_sector_size, we should reset the number
of wanted_total_sectors.

This bug was reported to Google Issue Tracker.
Link: https://issuetracker.google.com/issues/76407663

Signed-off-by: katao 
Signed-off-by: Jaegeuk Kim 
---
 lib/libf2fs.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 0c684d5..5f11796 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -799,8 +799,15 @@ int get_device_info(int i)
 #ifdef BLKSSZGET
if (ioctl(fd, BLKSSZGET, _size) < 0)
MSG(0, "\tError: Using the default sector size\n");
-   else if (dev->sector_size < sector_size)
+   else if (dev->sector_size < sector_size){
+   /*
+* wanted_total_sectors need to be reset by new
+* sector_size.
+*/
+   c.wanted_total_sectors = (c.wanted_total_sectors *
+   dev->sector_size) / sector_size;
dev->sector_size = sector_size;
+   }
 #endif
 #ifdef BLKGETSIZE64
if (ioctl(fd, BLKGETSIZE64, >total_sectors) < 0) {
-- 
2.15.0.531.g2ccb3012c9-goog


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