Re: Re: [f2fs-dev][PATCH] f2fs: optimize fs_lock for better performance

2013-09-10 Thread Chao Yu
Hi Kim,

I did some tests as you mention of using random instead of spin_lock.
The test model is as following:
eight threads race to grab one of eight locks for one thousand times,
and I used four methods to generate lock num: 

1.atomic_add_return(1, sbi-next_lock_num) % NR_GLOBAL_LOCKS;
2.spin_lock(); next_lock_num++ % NR_GLOBAL_LOCKS; spin_unlock();
3.ktime_get().tv64 % NR_GLOBAL_LOCKS;
4.get_random_bytes(next_lock, sizeof(unsigned int));

the result indicate that:
max count of collide continuously: 4  3  2 = 1
max-min count of lock is grabbed: 4  3  2 = 1
elapsed time of generating: 3  2  4  1

So I think it's better to use atomic_add_return in round-robin method to
cost less time and reduce collide.
What's your opinion?

thanks

--- Original Message ---
Sender : ???jaegeuk@samsung.com S5(??)/??/?(???)/
Date : 九月 10, 2013 09:52 (GMT+09:00)
Title : Re: [f2fs-dev][PATCH] f2fs: optimize fs_lock for better performance

Hi,

At first, thank you for the report and please follow the email writing
rules. :)

Anyway, I agree to the below issue.
One thing that I can think of is that we don't need to use the
spin_lock, since we don't care about the exact lock number, but just
need to get any not-collided number.

So, how about removing the spin_lock?
And how about using a random number?
Thanks,

2013-09-06 (?), 09:48 +, Chao Yu:
 Hi Kim:
 
  I think there is a performance problem: when all sbi-fs_lock is
 holded, 
 
 then all other threads may get the same next_lock value from
 sbi-next_lock_num in function mutex_lock_op, 
 
 and wait to get the same lock at position fs_lock[next_lock], it
 unbalance the fs_lock usage. 
 
 It may lost performance when we do the multithread test.
 
  
 
 Here is the patch to fix this problem:
 
  
 
 Signed-off-by: Yu Chao 
 
 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
 
 old mode 100644
 
 new mode 100755
 
 index 467d42d..983bb45
 
 --- a/fs/f2fs/f2fs.h
 
 +++ b/fs/f2fs/f2fs.h
 
 @@ -371,6 +371,7 @@ struct f2fs_sb_info {
 
 struct mutex fs_lock[NR_GLOBAL_LOCKS];  /* blocking FS
 operations */
 
 struct mutex node_write;/* locking node writes
 */
 
 struct mutex writepages;/* mutex for
 writepages() */
 
 +   spinlock_t spin_lock;   /* lock for
 next_lock_num */
 
 unsigned char next_lock_num;/* round-robin global
 locks */
 
 int por_doing;  /* recovery is doing
 or not */
 
 int on_build_free_nids; /* build_free_nids is
 doing */
 
 @@ -533,15 +534,19 @@ static inline void mutex_unlock_all(struct
 f2fs_sb_info *sbi)
 
  
 
  static inline int mutex_lock_op(struct f2fs_sb_info *sbi)
 
  {
 
 -   unsigned char next_lock = sbi-next_lock_num %
 NR_GLOBAL_LOCKS;
 
 +   unsigned char next_lock;
 
 int i = 0;
 
  
 
 for (; i  NR_GLOBAL_LOCKS; i++)
 
 if (mutex_trylock(sbi-fs_lock[i]))
 
 return i;
 
  
 
 -   mutex_lock(sbi-fs_lock[next_lock]);
 
 +   spin_lock(sbi-spin_lock);
 
 +   next_lock = sbi-next_lock_num % NR_GLOBAL_LOCKS;
 
 sbi-next_lock_num++;
 
 +   spin_unlock(sbi-spin_lock);
 
 +
 
 +   mutex_lock(sbi-fs_lock[next_lock]);
 
 return next_lock;
 
  }
 
  
 
 diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
 
 old mode 100644
 
 new mode 100755
 
 index 75c7dc3..4f27596
 
 --- a/fs/f2fs/super.c
 
 +++ b/fs/f2fs/super.c
 
 @@ -657,6 +657,7 @@ static int f2fs_fill_super(struct super_block *sb,
 void *data, int silent)
 
 mutex_init(sbi-cp_mutex);
 
 for (i = 0; i  NR_GLOBAL_LOCKS; i++)
 
 mutex_init(sbi-fs_lock[i]);
 
 +   spin_lock_init(sbi-spin_lock);
 
 mutex_init(sbi-node_write);
 
 sbi-por_doing = 0;
 
 spin_lock_init(sbi-stat_lock);
 
 (END)
 
  
 
 
 
 

-- 
Jaegeuk Kim
SamsungN�Р骒r��yb�X�肚�v�^�)藓{.n�+�伐�{��赙zXФ�≤�}��财�z�j:+v�����赙zZ+��+zf"�h���~i���z��wア�?�ㄨ���)撷f��^j谦y�m��@A�a囤�
0鹅h���i

[f2fs-dev][PATCH] f2fs: limit nr_iovecs in bio_alloc

2013-09-13 Thread Chao Yu
This patch add macro MAX_BIO_BLOCKS to limit value of npages in
f2fs_bio_alloc,
it can avoid to return NULL in bio_alloc caused by npages is larger than
UIO_MAXIOV.

Signed-off-by: Yu Chao chao2...@samsung.com
 ---
 fs/f2fs/segment.c |4 +++-
 fs/f2fs/segment.h |3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 09af9c7..bd79bbe 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -657,6 +657,7 @@ static void submit_write_page(struct f2fs_sb_info *sbi,
struct page *page,
block_t blk_addr, enum page_type type)
 {
struct block_device *bdev = sbi-sb-s_bdev;
+   int bio_blocks;
 
verify_block_addr(sbi, blk_addr);
 
@@ -676,7 +677,8 @@ retry:
goto retry;
}
 
-   sbi-bio[type] = f2fs_bio_alloc(bdev, max_hw_blocks(sbi));
+   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   sbi-bio[type] = f2fs_bio_alloc(bdev, bio_blocks);
sbi-bio[type]-bi_sector = SECTOR_FROM_BLOCK(sbi,
blk_addr);
sbi-bio[type]-bi_private = priv;
/*
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index bdd10ea..9cc95eb 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 #include linux/blkdev.h
+#include linux/uio.h
 
 /* constant macro */
 #define NULL_SEGNO ((unsigned int)(~0))
@@ -90,6 +91,8 @@
(blk_addr  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
 #define SECTOR_TO_BLOCK(sbi, sectors)  \
(sectors  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
+#define MAX_BIO_BLOCK(max_hw_blocks)   \
+   (min((int)max_hw_blocks, UIO_MAXIOV))
 
 /* during checkpoint, bio_private is used to synchronize the last bio */
 struct bio_private {
---

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev][PATCH] f2fs: limit nr_iovecs in bio_alloc

2013-09-13 Thread Chao Yu
 -Original Message-
 From: Jin Xu [mailto:linuxclim...@gmail.com]
 Sent: Friday, September 13, 2013 7:49 PM
 To: Chao Yu
 Cc: ???; linux-f2fs-de...@lists.sourceforge.net;
linux-fsde...@vger.kernel.org;
 linux-kernel@vger.kernel.org; 谭姝
 Subject: Re: [f2fs-dev][PATCH] f2fs: limit nr_iovecs in bio_alloc
 
 Did this patch pass the basic build? There seems have a typo regarding
 MAX_BIO_BLOCK.
 

I am so sorry about that.I miss the 'S' when merging the code by handwriting
from build path to git branch path.
I will check the patch carefully and resubmit it.

Thanks for reminding!

 --
 Jin
 
 On 13/09/2013 18:07, Chao Yu wrote:
  This patch add macro MAX_BIO_BLOCKS to limit value of npages in
  f2fs_bio_alloc, it can avoid to return NULL in bio_alloc caused by
  npages is larger than UIO_MAXIOV.
 
  Signed-off-by: Yu Chao chao2...@samsung.com
   ---
   fs/f2fs/segment.c |4 +++-
   fs/f2fs/segment.h |3 +++
   2 files changed, 6 insertions(+), 1 deletion(-)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index
  09af9c7..bd79bbe 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -657,6 +657,7 @@ static void submit_write_page(struct f2fs_sb_info
  *sbi, struct page *page,
  block_t blk_addr, enum page_type
 type)
  {
  struct block_device *bdev = sbi-sb-s_bdev;
  +   int bio_blocks;
 
  verify_block_addr(sbi, blk_addr);
 
  @@ -676,7 +677,8 @@ retry:
  goto retry;
  }
 
  -   sbi-bio[type] = f2fs_bio_alloc(bdev,
max_hw_blocks(sbi));
  +   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
  +   sbi-bio[type] = f2fs_bio_alloc(bdev, bio_blocks);
  sbi-bio[type]-bi_sector = SECTOR_FROM_BLOCK(sbi,
  blk_addr);
  sbi-bio[type]-bi_private = priv;
  /*
  diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index
  bdd10ea..9cc95eb 100644
  --- a/fs/f2fs/segment.h
  +++ b/fs/f2fs/segment.h
  @@ -9,6 +9,7 @@
* published by the Free Software Foundation.
*/
   #include linux/blkdev.h
  +#include linux/uio.h
 
   /* constant macro */
   #define NULL_SEGNO ((unsigned int)(~0))
  @@ -90,6 +91,8 @@
  (blk_addr  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
   #define SECTOR_TO_BLOCK(sbi, sectors)
 \
  (sectors  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
  +#define MAX_BIO_BLOCK(max_hw_blocks)
 \
  +   (min((int)max_hw_blocks, UIO_MAXIOV))
 
   /* during checkpoint, bio_private is used to synchronize the last bio
  */  struct bio_private {
  ---
 
  --
  To unsubscribe from this list: send the line unsubscribe
  linux-kernel in the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: avoid to use a NULL point in destroy_segment_manager

2013-11-05 Thread Chao Yu
A NULL point should avoid to be used in destroy_segment_manager after 
allocating memory fail for f2fs_sm_info.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/segment.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 3d4d5fc..ff363e6
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1744,6 +1744,8 @@ static void destroy_sit_info(struct f2fs_sb_info *sbi)
 void destroy_segment_manager(struct f2fs_sb_info *sbi)
 {
struct f2fs_sm_info *sm_info = SM_I(sbi);
+   if (!sm_info)
+   return;
destroy_dirty_segmap(sbi);
destroy_curseg(sbi);
destroy_free_segmap(sbi);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: avoid to use a NULL point in destroy_segment_manager

2013-11-05 Thread Chao Yu
Hi Gu,

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Wednesday, November 06, 2013 11:41 AM
 To: Chao Yu
 Cc: ???; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid to use a NULL point in 
 destroy_segment_manager
 
 On 11/06/2013 09:12 AM, Chao Yu wrote:
 
  A NULL point should avoid to be used in destroy_segment_manager after 
  allocating memory fail for f2fs_sm_info.
 
 Though without this patch it still can work well, because if it failed
 to allocate f2fs_sm_info, the sit_info, free_info... all were NULL, and
 the destory path(e.g. destroy_dirty_segmap) can deal with them well.

I think it could not work well. Without this patch we may got a segment 
fault in DIRTY_I(sbi) at the following code if it failed to allocate 
f2fs_sm_info memory(sbi-sm_info). Right?

static void destroy_dirty_segmap(struct f2fs_sb_info *sbi)
{
struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);

 IMO, this patch is still a good catch.
 
 Regards,
 Gu
 
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/segment.c |2 ++
   1 file changed, 2 insertions(+)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
  index 3d4d5fc..ff363e6
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -1744,6 +1744,8 @@ static void destroy_sit_info(struct f2fs_sb_info *sbi)
   void destroy_segment_manager(struct f2fs_sb_info *sbi)
   {
  struct f2fs_sm_info *sm_info = SM_I(sbi);
  +   if (!sm_info)
  +   return;
  destroy_dirty_segmap(sbi);
  destroy_curseg(sbi);
  destroy_free_segmap(sbi);


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: avoid to use a NULL point in destroy_segment_manager

2013-11-05 Thread Chao Yu
Hi Gu, 

Thanks for your reviewing!

Regards
Yu

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Wednesday, November 06, 2013 1:16 PM
 To: Chao Yu
 Cc: '???'; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; '谭姝'
 Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid to use a NULL point in 
 destroy_segment_manager
 
 On 11/06/2013 01:10 PM, Chao Yu wrote:
 
  Hi Gu,
 
  -Original Message-
  From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
  Sent: Wednesday, November 06, 2013 11:41 AM
  To: Chao Yu
  Cc: ???; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
  linux-f2fs-de...@lists.sourceforge.net; 谭姝
  Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid to use a NULL point in 
  destroy_segment_manager
 
  On 11/06/2013 09:12 AM, Chao Yu wrote:
 
  A NULL point should avoid to be used in destroy_segment_manager after 
  allocating memory fail for f2fs_sm_info.
 
  Though without this patch it still can work well, because if it failed
  to allocate f2fs_sm_info, the sit_info, free_info... all were NULL, and
  the destory path(e.g. destroy_dirty_segmap) can deal with them well.
 
  I think it could not work well. Without this patch we may got a segment
  fault in DIRTY_I(sbi) at the following code if it failed to allocate
  f2fs_sm_info memory(sbi-sm_info). Right?
 
 Yes, you're right. SIT_I generates sit_info from f2fs_sm_info.
 Sorry for my mistake.:(
 
 Regards,
 Gu
 
 
  static void destroy_dirty_segmap(struct f2fs_sb_info *sbi)
  {
  struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
 
  IMO, this patch is still a good catch.
 
  Regards,
  Gu
 
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/segment.c |2 ++
   1 file changed, 2 insertions(+)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
  index 3d4d5fc..ff363e6
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -1744,6 +1744,8 @@ static void destroy_sit_info(struct f2fs_sb_info 
  *sbi)
   void destroy_segment_manager(struct f2fs_sb_info *sbi)
   {
struct f2fs_sm_info *sm_info = SM_I(sbi);
  + if (!sm_info)
  + return;
destroy_dirty_segmap(sbi);
destroy_curseg(sbi);
destroy_free_segmap(sbi);
 
 
 
 
 
 =

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: fix memory leak after kobject init failed in fill_super

2013-11-06 Thread Chao Yu
If we failed to initadd kobject when fill_super, stats info and proc object of 
f2fs will not be released.
We should free them before we finish fill_super.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/super.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index e42351c..a754d14 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -974,12 +974,12 @@ static int f2fs_fill_super(struct super_block *sb, void 
*data, int silent)
/* After POR, we can run background GC thread.*/
err = start_gc_thread(sbi);
if (err)
-   goto fail;
+   goto free_gc;
}
 
err = f2fs_build_stats(sbi);
if (err)
-   goto fail;
+   goto free_gc;
 
if (f2fs_proc_root)
sbi-s_proc = proc_mkdir(sb-s_id, f2fs_proc_root);
@@ -1005,6 +1005,12 @@ static int f2fs_fill_super(struct super_block *sb, void 
*data, int silent)
 
return 0;
 fail:
+   if (sbi-s_proc) {
+   remove_proc_entry(segment_info, sbi-s_proc);
+   remove_proc_entry(sb-s_id, f2fs_proc_root);
+   }
+   f2fs_destroy_stats(sbi);
+free_gc:
stop_gc_thread(sbi);
 free_root_inode:
dput(sb-s_root);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure in bio_alloc

2013-09-13 Thread Chao Yu
This patch add macro MAX_BIO_BLOCKS to limit value of npages in
f2fs_bio_alloc,
it can avoid allocating failure in bio_alloc caused by npages is larger than
UIO_MAXIOV.

Signed-off-by: Yu Chao chao2...@samsung.com
 ---
 fs/f2fs/segment.c |4 +++-
 fs/f2fs/segment.h |3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 09af9c7..bd79bbe 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -657,6 +657,7 @@ static void submit_write_page(struct f2fs_sb_info *sbi,
struct page *page,
block_t blk_addr, enum page_type type)
 {
struct block_device *bdev = sbi-sb-s_bdev;
+   int bio_blocks;
 
verify_block_addr(sbi, blk_addr);
 
@@ -676,7 +677,8 @@ retry:
goto retry;
}
 
-   sbi-bio[type] = f2fs_bio_alloc(bdev, max_hw_blocks(sbi));
+   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   sbi-bio[type] = f2fs_bio_alloc(bdev, bio_blocks);
sbi-bio[type]-bi_sector = SECTOR_FROM_BLOCK(sbi,
blk_addr);
sbi-bio[type]-bi_private = priv;
/*
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index bdd10ea..6352af1 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 #include linux/blkdev.h
+#include linux/uio.h
 
 /* constant macro */
 #define NULL_SEGNO ((unsigned int)(~0))
@@ -90,6 +91,8 @@
(blk_addr  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
 #define SECTOR_TO_BLOCK(sbi, sectors)  \
(sectors  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
+#define MAX_BIO_BLOCKS(max_hw_blocks)  \
+   (min((int)max_hw_blocks, UIO_MAXIOV))
 
 /* during checkpoint, bio_private is used to synchronize the last bio */
 struct bio_private {
---

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure in bio_alloc

2013-09-15 Thread Chao Yu
Hi Gu

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Monday, September 16, 2013 10:09 AM
 To: Chao Yu
 Cc: Kim Jaegeuk; linux-f2fs-de...@lists.sourceforge.net;
 linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 谭姝
 Subject: Re: [f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure in
bio_alloc
 
 Hi Chao,
 
 On 09/13/2013 09:27 PM, Chao Yu wrote:
 
  This patch add macro MAX_BIO_BLOCKS to limit value of npages in
  f2fs_bio_alloc, it can avoid allocating failure in bio_alloc caused by
  npages is larger than UIO_MAXIOV.
 
 As I know bio_alloc is based of *fs_bio_set* pool, without the limitation
of
 UIO_MAXIOV, am I missing something?

Here is the code in bio.c, fs_bio_set is as the actual parameter pass to bs
without being inited.
So it may have opportunity to return NULL in this function.
---
Bio.c 
struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set
*bs)
{
..
if (!bs) {
if (nr_iovecs  UIO_MAXIOV)
return NULL;
---
I did the abnormal test: modify the max_sectors_kb in /sys/block/sdx/queue
to 32767 for a disk with f2fs format,
and I got a segfualt in f2fs_bio_alloc after the img mounted.
Is there anyting I missed?

 
 Thanks,
 Gu
 
 
  Signed-off-by: Yu Chao chao2...@samsung.com
   ---
   fs/f2fs/segment.c |4 +++-
   fs/f2fs/segment.h |3 +++
   2 files changed, 6 insertions(+), 1 deletion(-)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index
  09af9c7..bd79bbe 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -657,6 +657,7 @@ static void submit_write_page(struct f2fs_sb_info
  *sbi, struct page *page,
  block_t blk_addr, enum page_type
 type)
  {
  struct block_device *bdev = sbi-sb-s_bdev;
  +   int bio_blocks;
 
  verify_block_addr(sbi, blk_addr);
 
  @@ -676,7 +677,8 @@ retry:
  goto retry;
  }
 
  -   sbi-bio[type] = f2fs_bio_alloc(bdev,
max_hw_blocks(sbi));
  +   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
  +   sbi-bio[type] = f2fs_bio_alloc(bdev, bio_blocks);
  sbi-bio[type]-bi_sector = SECTOR_FROM_BLOCK(sbi,
  blk_addr);
  sbi-bio[type]-bi_private = priv;
  /*
  diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index
  bdd10ea..6352af1 100644
  --- a/fs/f2fs/segment.h
  +++ b/fs/f2fs/segment.h
  @@ -9,6 +9,7 @@
* published by the Free Software Foundation.
*/
   #include linux/blkdev.h
  +#include linux/uio.h
 
   /* constant macro */
   #define NULL_SEGNO ((unsigned int)(~0))
  @@ -90,6 +91,8 @@
  (blk_addr  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
   #define SECTOR_TO_BLOCK(sbi, sectors)
 \
  (sectors  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
  +#define MAX_BIO_BLOCKS(max_hw_blocks)
 \
  +   (min((int)max_hw_blocks, UIO_MAXIOV))
 
   /* during checkpoint, bio_private is used to synchronize the last bio
  */  struct bio_private {
  ---
 
  --
  To unsubscribe from this list: send the line unsubscribe
  linux-kernel in the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/
 


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure in bio_alloc

2013-09-16 Thread Chao Yu
Hi Gu

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Monday, September 16, 2013 12:40 PM
 To: Chao Yu
 Cc: 'Kim Jaegeuk'; linux-f2fs-de...@lists.sourceforge.net;
 linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; '谭姝'
 Subject: Re: [f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure in
bio_alloc
 
 Hi Chao,
 
 On 09/16/2013 11:26 AM, Chao Yu wrote:
 
  Hi Gu
 
  -Original Message-
  From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
  Sent: Monday, September 16, 2013 10:09 AM
  To: Chao Yu
  Cc: Kim Jaegeuk; linux-f2fs-de...@lists.sourceforge.net;
  linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 谭姝
  Subject: Re: [f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure
  in
  bio_alloc
 
  Hi Chao,
 
  On 09/13/2013 09:27 PM, Chao Yu wrote:
 
  This patch add macro MAX_BIO_BLOCKS to limit value of npages in
  f2fs_bio_alloc, it can avoid allocating failure in bio_alloc caused
  by npages is larger than UIO_MAXIOV.
 
  As I know bio_alloc is based of *fs_bio_set* pool, without the
  limitation
  of
  UIO_MAXIOV, am I missing something?
 
  Here is the code in bio.c, fs_bio_set is as the actual parameter pass
  to bs without being inited.
 
 fs_bio_set was initiated early in the bio subsystem init.
 
  So it may have opportunity to return NULL in this function.
 
 It may be, but may not be the thread you mentioned below.
 
  ---
  Bio.c
  struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct
  bio_set
  *bs)
  {
  ..
  if (!bs) {
  if (nr_iovecs  UIO_MAXIOV)
  return NULL;
  ---
  I did the abnormal test: modify the max_sectors_kb in
  /sys/block/sdx/queue to 32767 for a disk with f2fs format, and I got a
  segfualt in f2fs_bio_alloc after the img mounted.
  Is there anyting I missed?
 
 Hmm, this change will also trigger bvec_alloc failed, did you add some
traces to
 debug this?

I reviewed the code in bio_alloc, and then trace the process of bio_alloc
for verification.
It indicate that bvec_alloc() will fail on the condition that nr_iovecs is
greater than BIO_MAX_PAGES.
The patch should be updated for that.

I am sorry about the mistake in this patch, and thanks for the reviewing and
reminding.

 
 Regards,
 Gu
 
 
 
  Thanks,
  Gu
 
 
  Signed-off-by: Yu Chao chao2...@samsung.com
   ---
   fs/f2fs/segment.c |4 +++-
   fs/f2fs/segment.h |3 +++
   2 files changed, 6 insertions(+), 1 deletion(-)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index
  09af9c7..bd79bbe 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -657,6 +657,7 @@ static void submit_write_page(struct
  f2fs_sb_info *sbi, struct page *page,
  block_t blk_addr, enum page_type
  type)
  {
  struct block_device *bdev = sbi-sb-s_bdev;
  +   int bio_blocks;
 
  verify_block_addr(sbi, blk_addr);
 
  @@ -676,7 +677,8 @@ retry:
  goto retry;
  }
 
  -   sbi-bio[type] = f2fs_bio_alloc(bdev,
  max_hw_blocks(sbi));
  +   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
  +   sbi-bio[type] = f2fs_bio_alloc(bdev, bio_blocks);
  sbi-bio[type]-bi_sector =
 SECTOR_FROM_BLOCK(sbi,
  blk_addr);
  sbi-bio[type]-bi_private = priv;
  /*
  diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index
  bdd10ea..6352af1 100644
  --- a/fs/f2fs/segment.h
  +++ b/fs/f2fs/segment.h
  @@ -9,6 +9,7 @@
* published by the Free Software Foundation.
*/
   #include linux/blkdev.h
  +#include linux/uio.h
 
   /* constant macro */
   #define NULL_SEGNO ((unsigned int)(~0))
  @@ -90,6 +91,8 @@
  (blk_addr  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
  #define SECTOR_TO_BLOCK(sbi, sectors)
  \
  (sectors  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
  +#define MAX_BIO_BLOCKS(max_hw_blocks)
  \
  +   (min((int)max_hw_blocks, UIO_MAXIOV))
 
   /* during checkpoint, bio_private is used to synchronize the last
  bio */  struct bio_private {
  ---
 
  --
  To unsubscribe from this list: send the line unsubscribe
  linux-kernel in the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/
 
 
 
  --
  To unsubscribe from this list: send the line unsubscribe
  linux-kernel in the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/
 
 
 
 =

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: readahead contiguous pages for restore_node_summary

2013-11-21 Thread Chao Yu
If cp has no CP_UMOUNT_FLAG, we will read all pages in whole node segment 
one by one, it makes low performance. So let's merge contiguous pages and 
readahead for better performance.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/node.c |   89 +++-
 1 file changed, 63 insertions(+), 26 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 4ac4150..81e704a 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1572,47 +1572,84 @@ int recover_inode_page(struct f2fs_sb_info *sbi, struct 
page *page)
return 0;
 }
 
+/*
+ * ra_sum_pages() merge contiguous pages into one bio and submit.
+ * these pre-readed pages are linked in pages list.
+ */
+static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,
+   int start, int nrpages)
+{
+   struct page *page;
+   int page_idx = start;
+
+   for (; page_idx  start + nrpages; page_idx++) {
+   /* alloc temporal page for read node summary info*/
+   page = alloc_page(GFP_NOFS | __GFP_ZERO);
+   if (!page) {
+   struct page *tmp;
+   list_for_each_entry_safe(page, tmp, pages, lru) {
+   list_del(page-lru);
+   unlock_page(page);
+   __free_pages(page, 0);
+   }
+   return -ENOMEM;
+   }
+
+   lock_page(page);
+   page-index = page_idx;
+   list_add_tail(page-lru, pages);
+   }
+
+   list_for_each_entry(page, pages, lru)
+   submit_read_page(sbi, page, page-index, READ_SYNC);
+
+   f2fs_submit_read_bio(sbi, READ_SYNC);
+   return 0;
+}
+
 int restore_node_summary(struct f2fs_sb_info *sbi,
unsigned int segno, struct f2fs_summary_block *sum)
 {
struct f2fs_node *rn;
struct f2fs_summary *sum_entry;
-   struct page *page;
+   struct page *page, *tmp;
block_t addr;
-   int i, last_offset;
-
-   /* alloc temporal page for read node */
-   page = alloc_page(GFP_NOFS | __GFP_ZERO);
-   if (!page)
-   return -ENOMEM;
-   lock_page(page);
+   int bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   int i, last_offset, nrpages, err = 0;
+   LIST_HEAD(page_list);
 
/* scan the node segment */
last_offset = sbi-blocks_per_seg;
addr = START_BLOCK(sbi, segno);
sum_entry = sum-entries[0];
 
-   for (i = 0; i  last_offset; i++, sum_entry++) {
-   /*
-* In order to read next node page,
-* we must clear PageUptodate flag.
-*/
-   ClearPageUptodate(page);
+   for (i = 0; i  last_offset; i += nrpages, addr += nrpages) {
 
-   if (f2fs_readpage(sbi, page, addr, READ_SYNC))
-   goto out;
+   nrpages = min(last_offset - i, bio_blocks);
+   /* read ahead node pages */
+   err = ra_sum_pages(sbi, page_list, addr, nrpages);
+   if (err)
+   return err;
 
-   lock_page(page);
-   rn = F2FS_NODE(page);
-   sum_entry-nid = rn-footer.nid;
-   sum_entry-version = 0;
-   sum_entry-ofs_in_node = 0;
-   addr++;
+   list_for_each_entry_safe(page, tmp, page_list, lru) {
+
+   lock_page(page);
+   if(PageUptodate(page)) {
+   rn = F2FS_NODE(page);
+   sum_entry-nid = rn-footer.nid;
+   sum_entry-version = 0;
+   sum_entry-ofs_in_node = 0;
+   sum_entry++;
+   } else {
+   err = -EIO;
+   }
+
+   list_del(page-lru);
+   unlock_page(page);
+   __free_pages(page, 0);
+   }
}
-   unlock_page(page);
-out:
-   __free_pages(page, 0);
-   return 0;
+   return err;
 }
 
 static bool flush_nats_in_journal(struct f2fs_sb_info *sbi)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: remove unneeded code in punch_hole

2013-11-22 Thread Chao Yu
Because FALLOC_FL_PUNCH_HOLE flag must be ORed with FALLOC_FL_KEEP_SIZE 
in fallocate, so we could remove the useless 'keep size' branch code which 
will never be excuted in punch_hole.

Signed-off-by: Chao Yu chao2...@samsung.com
Signed-off-by: Fan Li fanofcode...@samsung.com
---
 fs/f2fs/file.c |6 --
 1 file changed, 6 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 7d714f4..0087d2a 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -499,12 +499,6 @@ static int punch_hole(struct inode *inode, loff_t offset, 
loff_t len, int mode)
}
}
 
-   if (!(mode  FALLOC_FL_KEEP_SIZE) 
-   i_size_read(inode) = (offset + len)) {
-   i_size_write(inode, offset);
-   mark_inode_dirty(inode);
-   }
-
return ret;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-22 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Friday, November 22, 2013 5:11 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages 
 by merging for mount performance
 
 Hi,
 
 Just one niptick.
 
 2013-11-22 (금), 09:09 +0800, Chao Yu:
  Previously we read sit entries page one by one, this method lost the chance
  of reading contiguous page together. So we read pages as contiguous as
  possible for better mount performance.
 
  change log:
   o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng
 suggested.
   o add mark_page_accessed() before release page to delay VM reclaiming.
   o remove '*order' for simplification of function as Jaegeuk Kim suggested.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/segment.c |  103 
  +++--
   fs/f2fs/segment.h |2 ++
   2 files changed, 78 insertions(+), 27 deletions(-)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
  index 8149eba..998e7d3 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -14,6 +14,7 @@
   #include linux/blkdev.h
   #include linux/prefetch.h
   #include linux/vmalloc.h
  +#include linux/swap.h
 
   #include f2fs.h
   #include segment.h
  @@ -1488,41 +1489,89 @@ static int build_curseg(struct f2fs_sb_info *sbi)
  return restore_curseg_summaries(sbi);
   }
 
  +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages)
  +{
  +   struct address_space *mapping = sbi-meta_inode-i_mapping;
  +   struct page *page;
  +   block_t blk_addr, prev_blk_addr = 0;
  +   int sit_blk_cnt = SIT_BLK_CNT(sbi);
 
 Can we remove SIT_BLK_CNT by replacing with sit_i-sit_blocks?

Because sit_i-sit_blocks is a multiple of segment size(i.e. 512/1024),
but we may use part of sit_blocks, not all of them. So it's waste to read 
all of them.
What's your opinion?

Regards,
Yu

 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 1/2] f2fs: adds a tracepoint for submit_read_page

2013-11-24 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Sunday, November 24, 2013 11:09 AM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH 1/2] f2fs: adds a tracepoint for 
 submit_read_page
 
 Hi,
 
 We need to avoid redundancy as much as possible.
 So, how about this patch?

Ah, It's more neat!
Thanks. :)


 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Sunday, November 24, 2013 11:51 AM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: adds a tracepoint for 
 f2fs_submit_read_bio
 
 Hi,
 
 Again, this tracepoint alos can be integrated with write_bios like this.

Alright, Thanks!

Regards,
Yu

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-24 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Sunday, November 24, 2013 12:26 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages 
 by merging for mount performance
 
 Hi,
 
 2013-11-22 (금), 09:09 +0800, Chao Yu:
  Previously we read sit entries page one by one, this method lost the chance
  of reading contiguous page together. So we read pages as contiguous as
  possible for better mount performance.
 
  change log:
   o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng
 suggested.
   o add mark_page_accessed() before release page to delay VM reclaiming.
   o remove '*order' for simplification of function as Jaegeuk Kim suggested.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/segment.c |  103 
  +++--
   fs/f2fs/segment.h |2 ++
   2 files changed, 78 insertions(+), 27 deletions(-)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
  index 8149eba..998e7d3 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -14,6 +14,7 @@
   #include linux/blkdev.h
   #include linux/prefetch.h
   #include linux/vmalloc.h
  +#include linux/swap.h
 
   #include f2fs.h
   #include segment.h
  @@ -1488,41 +1489,89 @@ static int build_curseg(struct f2fs_sb_info *sbi)
  return restore_curseg_summaries(sbi);
   }
 
  +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages)
  +{
  +   struct address_space *mapping = sbi-meta_inode-i_mapping;
  +   struct page *page;
  +   block_t blk_addr, prev_blk_addr = 0;
  +   int sit_blk_cnt = SIT_BLK_CNT(sbi);
  +   int blkno = start;
  +
  +   for (; blkno  start + nrpages  blkno  sit_blk_cnt; blkno++) {
  +
  +   blk_addr = current_sit_addr(sbi, start * SIT_ENTRY_PER_BLOCK);
 
 Should be:
   blk_addr = current_sit_addr(sbi, blkno * SIT_ENTRY_PER_BLOCK);
   ---
 I'll fix this and merge the patch though.
 Thanks,

Oh, It's my mistake, sorry for that.
Thanks for your review! :)

 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: remove unneeded code in punch_hole

2013-11-26 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Wednesday, November 27, 2013 1:14 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝; fanofcode...@samsung.com
 Subject: Re: [f2fs-dev] [PATCH] f2fs: remove unneeded code in punch_hole
 
 Got it.
 
 But, with this patch, we can also remove the parameter, int mode, in
 punch_hole().
 If no objection, I'll fix that in your patch.
 Thanks,

Right, we should remove it.
Thanks!

 
 2013-11-22 (금), 16:52 +0800, Chao Yu:
  Because FALLOC_FL_PUNCH_HOLE flag must be ORed with FALLOC_FL_KEEP_SIZE
  in fallocate, so we could remove the useless 'keep size' branch code which
  will never be excuted in punch_hole.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  Signed-off-by: Fan Li fanofcode...@samsung.com
  ---
   fs/f2fs/file.c |6 --
   1 file changed, 6 deletions(-)
 
  diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
  index 7d714f4..0087d2a 100644
  --- a/fs/f2fs/file.c
  +++ b/fs/f2fs/file.c
  @@ -499,12 +499,6 @@ static int punch_hole(struct inode *inode, loff_t 
  offset, loff_t len, int mode)
  }
  }
 
  -   if (!(mode  FALLOC_FL_KEEP_SIZE) 
  -   i_size_read(inode) = (offset + len)) {
  -   i_size_write(inode, offset);
  -   mark_inode_dirty(inode);
  -   }
  -
  return ret;
   }
 
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: readahead contiguous pages for restore_node_summary

2013-11-27 Thread Chao Yu
Hi Kim,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Wednesday, November 27, 2013 1:30 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH] f2fs: readahead contiguous pages for 
 restore_node_summary
 
 Hi Chao,
 
 It seems that we already have a readahed function for node pages,
 ra_node_page().
 So, we don't make a page list for this, but can use the node_inode's
 page cache.

So you mean it's waste to release page list with updated data after we
finish work in restore_node_summary, right?

 
 So how about writing ra_node_pages() which use the node_inode's page
 cache?

Hmm, so ra_node_pages is introduced for read node_inode's pages which are 
logical contiguously? and it also could take place of ra_node_page?


 
 Thanks,
 
 2013-11-22 (금), 15:48 +0800, Chao Yu:
  If cp has no CP_UMOUNT_FLAG, we will read all pages in whole node segment
  one by one, it makes low performance. So let's merge contiguous pages and
  readahead for better performance.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/node.c |   89 
  +++-
   1 file changed, 63 insertions(+), 26 deletions(-)
 
  diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
  index 4ac4150..81e704a 100644
  --- a/fs/f2fs/node.c
  +++ b/fs/f2fs/node.c
  @@ -1572,47 +1572,84 @@ int recover_inode_page(struct f2fs_sb_info *sbi, 
  struct page *page)
  return 0;
   }
 
  +/*
  + * ra_sum_pages() merge contiguous pages into one bio and submit.
  + * these pre-readed pages are linked in pages list.
  + */
  +static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,
  +   int start, int nrpages)
  +{
  +   struct page *page;
  +   int page_idx = start;
  +
  +   for (; page_idx  start + nrpages; page_idx++) {
  +   /* alloc temporal page for read node summary info*/
  +   page = alloc_page(GFP_NOFS | __GFP_ZERO);
  +   if (!page) {
  +   struct page *tmp;
  +   list_for_each_entry_safe(page, tmp, pages, lru) {
  +   list_del(page-lru);
  +   unlock_page(page);
  +   __free_pages(page, 0);
  +   }
  +   return -ENOMEM;
  +   }
  +
  +   lock_page(page);
  +   page-index = page_idx;
  +   list_add_tail(page-lru, pages);
  +   }
  +
  +   list_for_each_entry(page, pages, lru)
  +   submit_read_page(sbi, page, page-index, READ_SYNC);
  +
  +   f2fs_submit_read_bio(sbi, READ_SYNC);
  +   return 0;
  +}
  +
   int restore_node_summary(struct f2fs_sb_info *sbi,
  unsigned int segno, struct f2fs_summary_block *sum)
   {
  struct f2fs_node *rn;
  struct f2fs_summary *sum_entry;
  -   struct page *page;
  +   struct page *page, *tmp;
  block_t addr;
  -   int i, last_offset;
  -
  -   /* alloc temporal page for read node */
  -   page = alloc_page(GFP_NOFS | __GFP_ZERO);
  -   if (!page)
  -   return -ENOMEM;
  -   lock_page(page);
  +   int bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
  +   int i, last_offset, nrpages, err = 0;
  +   LIST_HEAD(page_list);
 
  /* scan the node segment */
  last_offset = sbi-blocks_per_seg;
  addr = START_BLOCK(sbi, segno);
  sum_entry = sum-entries[0];
 
  -   for (i = 0; i  last_offset; i++, sum_entry++) {
  -   /*
  -* In order to read next node page,
  -* we must clear PageUptodate flag.
  -*/
  -   ClearPageUptodate(page);
  +   for (i = 0; i  last_offset; i += nrpages, addr += nrpages) {
 
  -   if (f2fs_readpage(sbi, page, addr, READ_SYNC))
  -   goto out;
  +   nrpages = min(last_offset - i, bio_blocks);
  +   /* read ahead node pages */
  +   err = ra_sum_pages(sbi, page_list, addr, nrpages);
  +   if (err)
  +   return err;
 
  -   lock_page(page);
  -   rn = F2FS_NODE(page);
  -   sum_entry-nid = rn-footer.nid;
  -   sum_entry-version = 0;
  -   sum_entry-ofs_in_node = 0;
  -   addr++;
  +   list_for_each_entry_safe(page, tmp, page_list, lru) {
  +
  +   lock_page(page);
  +   if(PageUptodate(page)) {
  +   rn = F2FS_NODE(page);
  +   sum_entry-nid = rn-footer.nid;
  +   sum_entry-version = 0;
  +   sum_entry-ofs_in_node = 0;
  +   sum_entry++;
  +   } else {
  +   err = -EIO;
  +   }
  +
  +   list_del(page-lru);
  +   unlock_page(page);
  +   __free_pages(page, 0

RE: [f2fs-dev] [PATCH] f2fs: readahead contiguous pages for restore_node_summary

2013-11-27 Thread Chao Yu
Hi Kim,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Wednesday, November 27, 2013 4:19 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; '谭姝'
 Subject: RE: [f2fs-dev] [PATCH] f2fs: readahead contiguous pages for 
 restore_node_summary
 
 Hi,
 
 2013-11-27 (수), 15:58 +0800, Chao Yu:
  Hi Kim,
 
   -Original Message-
   From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
   Sent: Wednesday, November 27, 2013 1:30 PM
   To: Chao Yu
   Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
   linux-f2fs-de...@lists.sourceforge.net; 谭姝
   Subject: Re: [f2fs-dev] [PATCH] f2fs: readahead contiguous pages for 
   restore_node_summary
  
   Hi Chao,
  
   It seems that we already have a readahed function for node pages,
   ra_node_page().
   So, we don't make a page list for this, but can use the node_inode's
   page cache.
 
  So you mean it's waste to release page list with updated data after we
  finish work in restore_node_summary, right?
 
 Right.

So how about add all pages of page list to node_inode's address space by
add_to_page_cache_lru() with arg sum_entry-nid?

 
 
  
   So how about writing ra_node_pages() which use the node_inode's page
   cache?
 
  Hmm, so ra_node_pages is introduced for read node_inode's pages which are
  logical contiguously? and it also could take place of ra_node_page?
 
 Ah. The ra_node_page() read a node page ahead for a given node id.
 So it doesn't match exactly between ra_node_page() and ra_node_pages()
 that I suggested.
 So how about reading node pages and then caching some of them in the
 page cache, node_inode's address space?

Got it,
If we do not use the method above, we should search the NAT for nid number
as the index of node_inode's page by the specified node page blkaddr, that costs
a lot.
How do you think?

 
 Thanks,
 
 
 
  
   Thanks,
  
   2013-11-22 (금), 15:48 +0800, Chao Yu:
If cp has no CP_UMOUNT_FLAG, we will read all pages in whole node 
segment
one by one, it makes low performance. So let's merge contiguous pages 
and
readahead for better performance.
   
Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/node.c |   89 
+++-
 1 file changed, 63 insertions(+), 26 deletions(-)
   
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 4ac4150..81e704a 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1572,47 +1572,84 @@ int recover_inode_page(struct f2fs_sb_info 
*sbi, struct page *page)
return 0;
 }
   
+/*
+ * ra_sum_pages() merge contiguous pages into one bio and submit.
+ * these pre-readed pages are linked in pages list.
+ */
+static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head 
*pages,
+   int start, int nrpages)
+{
+   struct page *page;
+   int page_idx = start;
+
+   for (; page_idx  start + nrpages; page_idx++) {
+   /* alloc temporal page for read node summary info*/
+   page = alloc_page(GFP_NOFS | __GFP_ZERO);
+   if (!page) {
+   struct page *tmp;
+   list_for_each_entry_safe(page, tmp, pages, lru) 
{
+   list_del(page-lru);
+   unlock_page(page);
+   __free_pages(page, 0);
+   }
+   return -ENOMEM;
+   }
+
+   lock_page(page);
+   page-index = page_idx;
+   list_add_tail(page-lru, pages);
+   }
+
+   list_for_each_entry(page, pages, lru)
+   submit_read_page(sbi, page, page-index, READ_SYNC);
+
+   f2fs_submit_read_bio(sbi, READ_SYNC);
+   return 0;
+}
+
 int restore_node_summary(struct f2fs_sb_info *sbi,
unsigned int segno, struct f2fs_summary_block 
*sum)
 {
struct f2fs_node *rn;
struct f2fs_summary *sum_entry;
-   struct page *page;
+   struct page *page, *tmp;
block_t addr;
-   int i, last_offset;
-
-   /* alloc temporal page for read node */
-   page = alloc_page(GFP_NOFS | __GFP_ZERO);
-   if (!page)
-   return -ENOMEM;
-   lock_page(page);
+   int bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   int i, last_offset, nrpages, err = 0;
+   LIST_HEAD(page_list);
   
/* scan the node segment */
last_offset = sbi-blocks_per_seg;
addr = START_BLOCK(sbi, segno);
sum_entry = sum-entries[0];
   
-   for (i = 0; i  last_offset; i++, sum_entry

RE: [f2fs-dev] [PATCH] f2fs: readahead contiguous pages for restore_node_summary

2013-11-27 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Thursday, November 28, 2013 11:33 AM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; '谭姝'
 Subject: RE: [f2fs-dev] [PATCH] f2fs: readahead contiguous pages for 
 restore_node_summary
 
 Hi,
 
 2013-11-28 (목), 09:26 +0800, Chao Yu:
  Hi Kim,
 
   -Original Message-
   From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
   Sent: Wednesday, November 27, 2013 4:19 PM
   To: Chao Yu
   Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
   linux-f2fs-de...@lists.sourceforge.net; '谭姝'
   Subject: RE: [f2fs-dev] [PATCH] f2fs: readahead contiguous pages for 
   restore_node_summary
  
   Hi,
  
   2013-11-27 (수), 15:58 +0800, Chao Yu:
Hi Kim,
   
 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Wednesday, November 27, 2013 1:30 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH] f2fs: readahead contiguous pages for 
 restore_node_summary

 Hi Chao,

 It seems that we already have a readahed function for node pages,
 ra_node_page().
 So, we don't make a page list for this, but can use the node_inode's
 page cache.
   
So you mean it's waste to release page list with updated data after we
finish work in restore_node_summary, right?
  
   Right.
 
  So how about add all pages of page list to node_inode's address space by
  add_to_page_cache_lru() with arg sum_entry-nid?
 
 I don't think it's proper way to use add_to_page_cache_lru() directly.

This is the way used in VM readahead(i.e. read_pages/mpage_readpages/
read_cache_pages).
So what you worry about is that using lonely add_to_page_cache_lru()
may cause exception, is it?

 
 
  
   

 So how about writing ra_node_pages() which use the node_inode's page
 cache?
   
Hmm, so ra_node_pages is introduced for read node_inode's pages which 
are
logical contiguously? and it also could take place of ra_node_page?
  
   Ah. The ra_node_page() read a node page ahead for a given node id.
   So it doesn't match exactly between ra_node_page() and ra_node_pages()
   that I suggested.
   So how about reading node pages and then caching some of them in the
   page cache, node_inode's address space?
 
  Got it,
  If we do not use the method above, we should search the NAT for nid number
  as the index of node_inode's page by the specified node page blkaddr, that 
  costs
  a lot.
  How do you think?
 
 1. grab_cache_page(node_footer-nid);
 2. memcpy();
 3. SetPageUptodate();
 4. f2fs_put_page();

It could be.

This make ra_node_pages() synchronized, because we should read node_footer-nid
from updated node page before we cache node pages, and we will still use page 
list to
pass the updated page.

Why not introduce f2fs_cache_node_pages() include your code to cache node pages 
after
ra_node_pages()?

Thanks,
Yu

 
 Thanks,
 
 
  
   Thanks,
  
   
   

 Thanks,

 2013-11-22 (금), 15:48 +0800, Chao Yu:
  If cp has no CP_UMOUNT_FLAG, we will read all pages in whole node 
  segment
  one by one, it makes low performance. So let's merge contiguous 
  pages and
  readahead for better performance.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/node.c |   89 
  +++-
   1 file changed, 63 insertions(+), 26 deletions(-)
 
  diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
  index 4ac4150..81e704a 100644
  --- a/fs/f2fs/node.c
  +++ b/fs/f2fs/node.c
  @@ -1572,47 +1572,84 @@ int recover_inode_page(struct f2fs_sb_info 
  *sbi, struct page *page)
  return 0;
   }
 
  +/*
  + * ra_sum_pages() merge contiguous pages into one bio and submit.
  + * these pre-readed pages are linked in pages list.
  + */
  +static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head 
  *pages,
  +   int start, int nrpages)
  +{
  +   struct page *page;
  +   int page_idx = start;
  +
  +   for (; page_idx  start + nrpages; page_idx++) {
  +   /* alloc temporal page for read node summary info*/
  +   page = alloc_page(GFP_NOFS | __GFP_ZERO);
  +   if (!page) {
  +   struct page *tmp;
  +   list_for_each_entry_safe(page, tmp, pages, lru) 
  {
  +   list_del(page-lru);
  +   unlock_page(page);
  +   __free_pages(page, 0);
  +   }
  +   return -ENOMEM;
  +   }
  +
  +   lock_page(page);
  +   page-index = page_idx

[f2fs-dev] [PATCH 1/5] f2fs: correct type of wait in struct bio_private

2013-11-27 Thread Chao Yu
Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/segment.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index b84dd23..5f733ec 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -96,7 +96,7 @@
 struct bio_private {
struct f2fs_sb_info *sbi;
bool is_sync;
-   void *wait;
+   struct completion *wait;
 };
 
 /*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 2/5] f2fs: add unlikely macro for compiler optimization

2013-11-27 Thread Chao Yu
Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/node.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 0fe9a97..954155b 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1160,7 +1160,7 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info 
*sbi, nid_t ino)
struct page *page = pvec.pages[i];
 
/* until radix tree lookup accepts end_index */
-   if (page-index  end)
+   if (unlikely(page-index  end))
continue;
 
if (ino  ino_of_node(page) == ino) {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 3/5] f2fs: use true and false for boolean variable

2013-11-27 Thread Chao Yu
Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/node.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 954155b..daf8ee8 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -791,7 +791,7 @@ int truncate_xattr_node(struct inode *inode, struct page 
*page)
set_new_dnode(dn, inode, page, npage, nid);
 
if (page)
-   dn.inode_page_locked = 1;
+   dn.inode_page_locked = true;
truncate_node(dn);
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 5/5] f2fs: convert recover_orphan_inodes to void

2013-11-27 Thread Chao Yu
Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/checkpoint.c |6 +++---
 fs/f2fs/f2fs.h   |2 +-
 fs/f2fs/super.c  |8 
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 7fe69ff..b28e61b 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -270,12 +270,12 @@ static void recover_orphan_inode(struct f2fs_sb_info 
*sbi, nid_t ino)
iput(inode);
 }
 
-int recover_orphan_inodes(struct f2fs_sb_info *sbi)
+void recover_orphan_inodes(struct f2fs_sb_info *sbi)
 {
block_t start_blk, orphan_blkaddr, i, j;
 
if (!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG))
-   return 0;
+   return;
 
sbi-por_doing = true;
start_blk = __start_cp_addr(sbi) + 1;
@@ -295,7 +295,7 @@ int recover_orphan_inodes(struct f2fs_sb_info *sbi)
/* clear Orphan Flag */
clear_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG);
sbi-por_doing = false;
-   return 0;
+   return;
 }
 
 static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index c8eb37e..bb96b64 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1114,7 +1114,7 @@ int acquire_orphan_inode(struct f2fs_sb_info *);
 void release_orphan_inode(struct f2fs_sb_info *);
 void add_orphan_inode(struct f2fs_sb_info *, nid_t);
 void remove_orphan_inode(struct f2fs_sb_info *, nid_t);
-int recover_orphan_inodes(struct f2fs_sb_info *);
+void recover_orphan_inodes(struct f2fs_sb_info *);
 int get_valid_checkpoint(struct f2fs_sb_info *);
 void set_dirty_dir_page(struct inode *, struct page *);
 void add_dirty_dir_inode(struct inode *);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 9981b28..09a2b07 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -946,9 +946,7 @@ static int f2fs_fill_super(struct super_block *sb, void 
*data, int silent)
}
 
/* if there are nt orphan nodes free them */
-   err = -EINVAL;
-   if (recover_orphan_inodes(sbi))
-   goto free_node_inode;
+   recover_orphan_inodes(sbi);
 
/* read root inode and dentry */
root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));
@@ -957,8 +955,10 @@ static int f2fs_fill_super(struct super_block *sb, void 
*data, int silent)
err = PTR_ERR(root);
goto free_node_inode;
}
-   if (!S_ISDIR(root-i_mode) || !root-i_blocks || !root-i_size)
+   if (!S_ISDIR(root-i_mode) || !root-i_blocks || !root-i_size) {
+   err = -EINVAL;
goto free_root_inode;
+   }
 
sb-s_root = d_make_root(root); /* allocate root dentry */
if (!sb-s_root) {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 4/5] f2fs: check return value of f2fs_readpage in find_data_page

2013-11-27 Thread Chao Yu
We should return error if we do not get an updated page in find_date_page
when f2fs_readpage failed.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/data.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 2d02cf3..85071d6 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -240,6 +240,9 @@ struct page *find_data_page(struct inode *inode, pgoff_t 
index, bool sync)
 
err = f2fs_readpage(sbi, page, dn.data_blkaddr,
sync ? READ_SYNC : READA);
+   if (err)
+   return ERR_PTR(err);
+
if (sync) {
wait_on_page_locked(page);
if (!PageUptodate(page)) {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: avoid to calculate incorrect max orphan number

2013-11-29 Thread Chao Yu
Because we will write node summaries when do_checkpoint with umount flag,
our number of max orphan blocks should minus NR_CURSEG_NODE_TYPE additional.

Signed-off-by: Chao Yu chao2...@samsung.com
Signed-off-by: Shu Tan shu@samsung.com
---
 fs/f2fs/checkpoint.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index b28e61b..32178f3 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -190,12 +190,13 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi)
int err = 0;
 
/*
-* considering 512 blocks in a segment 5 blocks are needed for cp
+* considering 512 blocks in a segment 8 blocks are needed for cp
 * and log segment summaries. Remaining blocks are used to keep
 * orphan entries with the limitation one reserved segment
-* for cp pack we can have max 1020*507 orphan entries
+* for cp pack we can have max 1020*504 orphan entries
 */
-   max_orphans = (sbi-blocks_per_seg - 5) * F2FS_ORPHANS_PER_BLOCK;
+   max_orphans = (sbi-blocks_per_seg - 2 - NR_CURSEG_TYPE)
+   * F2FS_ORPHANS_PER_BLOCK;
mutex_lock(sbi-orphan_inode_mutex);
if (sbi-n_orphans = max_orphans)
err = -ENOSPC;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 2/5] f2fs: add unlikely macro for compiler optimization

2013-12-01 Thread Chao Yu
Hi Kim,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Friday, November 29, 2013 6:14 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH 2/5] f2fs: add unlikely macro for compiler 
 optimization
 
 Hi,
 
 Could you make a patch to add *unlikely* as many as possible across the
 whole source files at once?
 It is wasteful to add it with a bunch of patches at multiple times.

Alright, I will work on this.

 
 And please write descriptions for all the patches even if nothing is
 special.
 In this case, why should we set *unlikely* for checking this condition?

Got it.

Regards,
Yu

 
 Thanks,
 
 2013-11-28 (목), 15:42 +0800, Chao Yu:
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/node.c |2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
 
  diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
  index 0fe9a97..954155b 100644
  --- a/fs/f2fs/node.c
  +++ b/fs/f2fs/node.c
  @@ -1160,7 +1160,7 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info 
  *sbi, nid_t ino)
  struct page *page = pvec.pages[i];
 
  /* until radix tree lookup accepts end_index */
  -   if (page-index  end)
  +   if (unlikely(page-index  end))
  continue;
 
  if (ino  ino_of_node(page) == ino) {
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: refactor bio-related operations

2013-12-01 Thread Chao Yu
Hi,

Some comments as following.

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Saturday, November 30, 2013 2:26 PM
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net
 Subject: [f2fs-dev] [PATCH] f2fs: refactor bio-related operations
 

[snip]

 +void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page,
 + block_t blk_addr, enum page_type type, int rw)
 +{
 + enum page_type btype = PAGE_TYPE_OF_BIO(type);
 + struct block_device *bdev = sbi-sb-s_bdev;
 + struct f2fs_bio_info *io;
 + int bio_blocks;
 +
 + io = is_read_io(rw) ? sbi-read_io : sbi-write_io[btype];
 +
 + verify_block_addr(sbi, blk_addr);
 +
 + mutex_lock(io-io_mutex);
 +
 + if (!is_read_io(rw))
 + inc_page_count(sbi, F2FS_WRITEBACK);
 +
 + if (io-bio  io-last_block_in_bio != blk_addr - 1)
 + __submit_merged_bio(sbi, io, type, true, rw);
 +alloc_new:
 + if (io-bio == NULL) {
 + bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
 + io-bio = __bio_alloc(bdev, bio_blocks);
 + io-bio-bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
 + io-bio-bi_end_io = is_read_io(rw) ? f2fs_read_end_io :
 + f2fs_write_end_io;
 + /*
 +  * The end_io will be assigned at the sumbission phase.
 +  * Until then, let bio_add_page() merge consecutive IOs as much
 +  * as possible.
 +  */
 + }
 +
 + if (bio_add_page(io-bio, page, PAGE_CACHE_SIZE, 0) 
 + PAGE_CACHE_SIZE) {
 + __submit_merged_bio(sbi, io, type, true, rw);
 + io-bio = NULL;

We should remove the redundant code  io-bio = NULL; here,
because __submit_merged_bio does the same job.

[snip]

  /*
   * data.c
   */
 +void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, bool, 
 int);
 +int f2fs_submit_page_bio(struct f2fs_sb_info *, struct page *, block_t, int);

Redundant to the following code.

 +void f2fs_submit_page_mbio(struct f2fs_sb_info *, struct page *, block_t,
 + enum page_type, int);
  int reserve_new_block(struct dnode_of_data *);
  int f2fs_reserve_block(struct dnode_of_data *, pgoff_t);
  void update_extent_cache(block_t, struct dnode_of_data *);
  struct page *find_data_page(struct inode *, pgoff_t, bool);
  struct page *get_lock_data_page(struct inode *, pgoff_t);
  struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
 -int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
 -void f2fs_submit_read_bio(struct f2fs_sb_info *, int);
 -void submit_read_page(struct f2fs_sb_info *, struct page *, block_t, int);
 +int f2fs_submit_page_bio(struct f2fs_sb_info *, struct page *, block_t, int);

Here.

[snip]

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: remove the own bi_private allocation

2013-12-01 Thread Chao Yu
Hi Kim,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Saturday, November 30, 2013 9:48 AM
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net
 Subject: [f2fs-dev] [PATCH] f2fs: remove the own bi_private allocation
 
 Previously f2fs allocates its own bi_private data structure all the time even
 though we don't use it. But, can we remove this bi_private allocation?
 
 This patch removes such the additional bi_private allocation.
 
 1. Retrieve f2fs_sb_info from its page-mapping-host-i_sb.
  - This removes the usecases of bi_private in end_io.
 
 2. Use bi_private only when we really need it.
  - The bi_private is used only when the checkpoint procedure is conducted.
  - When conducting the checkpoint, f2fs submits a META_FLUSH bio to wait its 
 bio
 completion.
  - Since we have no dependancies to remove bi_private now, let's just use
  bi_private pointer as the completion pointer.
 
 Signed-off-by: Jaegeuk Kim jaegeuk@samsung.com
 ---
  fs/f2fs/segment.c | 43 ---
  fs/f2fs/segment.h |  7 ---
  2 files changed, 16 insertions(+), 34 deletions(-)
 
 diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
 index 0387863..0db4027 100644
 --- a/fs/f2fs/segment.c
 +++ b/fs/f2fs/segment.c
 @@ -791,7 +791,7 @@ static void f2fs_end_io_write(struct bio *bio, int err)
  {
   const int uptodate = test_bit(BIO_UPTODATE, bio-bi_flags);
   struct bio_vec *bvec = bio-bi_io_vec + bio-bi_vcnt - 1;
 - struct bio_private *p = bio-bi_private;
 + struct f2fs_sb_info *sbi = F2FS_SB(bvec-bv_page-mapping-host-i_sb);

I'm not sure whether bvec-bv_page-mapping will be set to NULL in the flow
where may not check WRITEBACK flag of page. Is it possible?

 
   do {
   struct page *page = bvec-bv_page;
 @@ -802,21 +802,21 @@ static void f2fs_end_io_write(struct bio *bio, int err)
   SetPageError(page);
   if (page-mapping)
   set_bit(AS_EIO, page-mapping-flags);
 - set_ckpt_flags(p-sbi-ckpt, CP_ERROR_FLAG);
 - p-sbi-sb-s_flags |= MS_RDONLY;
 +
 + set_ckpt_flags(sbi-ckpt, CP_ERROR_FLAG);
 + sbi-sb-s_flags |= MS_RDONLY;
   }
   end_page_writeback(page);
 - dec_page_count(p-sbi, F2FS_WRITEBACK);
 + dec_page_count(sbi, F2FS_WRITEBACK);
   } while (bvec = bio-bi_io_vec);
 
 - if (p-is_sync)
 - complete(p-wait);
 + if (bio-bi_private)
 + complete(bio-bi_private);
 
 - if (!get_pages(p-sbi, F2FS_WRITEBACK) 
 - !list_empty(p-sbi-cp_wait.task_list))
 - wake_up(p-sbi-cp_wait);
 + if (!get_pages(sbi, F2FS_WRITEBACK) 
 + !list_empty(sbi-cp_wait.task_list))
 + wake_up(sbi-cp_wait);
 
 - kfree(p);
   bio_put(bio);
  }
 
 @@ -838,7 +838,6 @@ static void do_submit_bio(struct f2fs_sb_info *sbi,
   int rw = sync ? WRITE_SYNC : WRITE;
   enum page_type btype = PAGE_TYPE_OF_BIO(type);
   struct f2fs_bio_info *io = sbi-write_io[btype];
 - struct bio_private *p;
 
   if (!io-bio)
   return;
 @@ -851,18 +850,16 @@ static void do_submit_bio(struct f2fs_sb_info *sbi,
 
   trace_f2fs_submit_write_bio(sbi-sb, rw, btype, io-bio);
 
 - p = io-bio-bi_private;
 - p-sbi = sbi;
 - io-bio-bi_end_io = f2fs_end_io_write;
 -
 + /*
 +  * META_FLUSH is only from the checkpoint procedure, and we should wait
 +  * this metadata bio for FS consistency.
 +  */
   if (type == META_FLUSH) {
   DECLARE_COMPLETION_ONSTACK(wait);
 - p-is_sync = true;
 - p-wait = wait;
 + io-bio-bi_private = wait;
   submit_bio(rw, io-bio);
   wait_for_completion(wait);
   } else {
 - p-is_sync = false;
   submit_bio(rw, io-bio);
   }
   io-bio = NULL;
 @@ -897,18 +894,10 @@ static void submit_write_page(struct f2fs_sb_info *sbi, 
 struct page *page,
   do_submit_bio(sbi, type, false);
  alloc_new:
   if (io-bio == NULL) {
 - struct bio_private *priv;
 -retry:
 - priv = kmalloc(sizeof(struct bio_private), GFP_NOFS);
 - if (!priv) {
 - cond_resched();
 - goto retry;
 - }
 -
   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
   io-bio = f2fs_bio_alloc(bdev, bio_blocks);
   io-bio-bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
 - io-bio-bi_private = priv;
 + io-bio-bi_end_io = f2fs_end_io_write;
   /*
* The end_io will be assigned at the sumbission phase.
* Until then, let bio_add_page() merge consecutive IOs as much
 diff --git a/fs/f2fs/segment.h 

RE: [f2fs-dev] [PATCH] f2fs: remove the own bi_private allocation

2013-12-02 Thread Chao Yu
Hi Kim,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Monday, December 02, 2013 4:15 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: RE: [f2fs-dev] [PATCH] f2fs: remove the own bi_private allocation
 
 2013-12-02 (월), 14:14 +0800, Chao Yu:
  Hi Kim,
 
   -Original Message-
   From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
   Sent: Saturday, November 30, 2013 9:48 AM
   Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
   linux-f2fs-de...@lists.sourceforge.net
   Subject: [f2fs-dev] [PATCH] f2fs: remove the own bi_private allocation
  
   Previously f2fs allocates its own bi_private data structure all the time 
   even
   though we don't use it. But, can we remove this bi_private allocation?
  
   This patch removes such the additional bi_private allocation.
  
   1. Retrieve f2fs_sb_info from its page-mapping-host-i_sb.
- This removes the usecases of bi_private in end_io.
  
   2. Use bi_private only when we really need it.
- The bi_private is used only when the checkpoint procedure is conducted.
- When conducting the checkpoint, f2fs submits a META_FLUSH bio to wait 
   its bio
   completion.
- Since we have no dependancies to remove bi_private now, let's just use
bi_private pointer as the completion pointer.
  
   Signed-off-by: Jaegeuk Kim jaegeuk@samsung.com
   ---
fs/f2fs/segment.c | 43 ---
fs/f2fs/segment.h |  7 ---
2 files changed, 16 insertions(+), 34 deletions(-)
  
   diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
   index 0387863..0db4027 100644
   --- a/fs/f2fs/segment.c
   +++ b/fs/f2fs/segment.c
   @@ -791,7 +791,7 @@ static void f2fs_end_io_write(struct bio *bio, int 
   err)
{
 const int uptodate = test_bit(BIO_UPTODATE, bio-bi_flags);
 struct bio_vec *bvec = bio-bi_io_vec + bio-bi_vcnt - 1;
   - struct bio_private *p = bio-bi_private;

f2fs_bug_on(unlikely(!bvec-bv_page-mapping));

   + struct f2fs_sb_info *sbi = F2FS_SB(bvec-bv_page-mapping-host-i_sb);
 
  I'm not sure whether bvec-bv_page-mapping will be set to NULL in the flow
  where may not check WRITEBACK flag of page. Is it possible?
 
 The mapping should be not NULL cause it is a writebacking page.
 Otherwise, it's a bug.

If so, should we add additional code as above?

Regards,
Yu

 Thanks,
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH v2] f2fs: refactor bio-related operations

2013-12-02 Thread Chao Yu
 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Monday, December 02, 2013 4:27 PM
 To: linux-fsde...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org; linux-f2fs-de...@lists.sourceforge.net
 Subject: Re: [f2fs-dev] [PATCH v2] f2fs: refactor bio-related operations
 
 Change log from v1:
  o remove redundant codes
 
 From a480dfc915490f4bca7275f6fbb44fa34aa00eaa Mon Sep 17 00:00:00 2001
 From: Jaegeuk Kim jaegeuk@samsung.com
 Date: Sat, 30 Nov 2013 12:51:14 +0900
 Subject: [PATCH] f2fs: refactor bio-related operations
 Cc: linux-fsde...@vger.kernel.org, linux-kernel@vger.kernel.org, 
 linux-f2fs-de...@lists.sourceforge.net
 
 This patch integrates redundant bio operations on read and write IOs.
 
 1. Move bio-related codes to the top of data.c.
 2. Replace f2fs_submit_bio with f2fs_submit_merged_bio, which handles read
bios additionally.
 3. Introduce __submit_merged_bio to submit the merged bio.
 4. Change f2fs_readpage to f2fs_submit_page_bio.
 5. Introduce f2fs_submit_page_mbio to integrate previous submit_read_page and
submit_write_page.

Good job!

 
 Reviewed-by: Gu Zheng guz.f...@cn.fujitsu.com
 Signed-off-by: Jaegeuk Kim jaegeuk@samsung.com

Reviewed-by: Chao Yu chao2...@samsung.com 

 ---
  fs/f2fs/checkpoint.c|  14 +-
  fs/f2fs/data.c  | 316 
 +---
  fs/f2fs/f2fs.h  |  12 +-
  fs/f2fs/gc.c|   2 +-
  fs/f2fs/node.c  |  14 +-
  fs/f2fs/recovery.c  |   4 +-
  fs/f2fs/segment.c   | 164 +++
  include/trace/events/f2fs.h |  30 ++---
  8 files changed, 257 insertions(+), 299 deletions(-)
 
 diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
 index 40eea42..38f4a224 100644
 --- a/fs/f2fs/checkpoint.c
 +++ b/fs/f2fs/checkpoint.c
 @@ -61,7 +61,8 @@ repeat:
   if (PageUptodate(page))
   goto out;
 
 - if (f2fs_readpage(sbi, page, index, READ_SYNC | REQ_META | REQ_PRIO))
 + if (f2fs_submit_page_bio(sbi, page, index,
 + READ_SYNC | REQ_META | REQ_PRIO))
   goto repeat;
 
   lock_page(page);
 @@ -157,7 +158,8 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum 
 page_type type,
   }
 
   if (nwritten)
 - f2fs_submit_bio(sbi, type, nr_to_write == LONG_MAX);
 + f2fs_submit_merged_bio(sbi, type, nr_to_write == LONG_MAX,
 + WRITE);
 
   return nwritten;
  }
 @@ -590,7 +592,7 @@ retry:
* We should submit bio, since it exists several
* wribacking dentry pages in the freeing inode.
*/
 - f2fs_submit_bio(sbi, DATA, true);
 + f2fs_submit_merged_bio(sbi, DATA, true, WRITE);
   }
   goto retry;
  }
 @@ -796,9 +798,9 @@ void write_checkpoint(struct f2fs_sb_info *sbi, bool 
 is_umount)
 
   trace_f2fs_write_checkpoint(sbi-sb, is_umount, finish block_ops);
 
 - f2fs_submit_bio(sbi, DATA, true);
 - f2fs_submit_bio(sbi, NODE, true);
 - f2fs_submit_bio(sbi, META, true);
 + f2fs_submit_merged_bio(sbi, DATA, true, WRITE);
 + f2fs_submit_merged_bio(sbi, NODE, true, WRITE);
 + f2fs_submit_merged_bio(sbi, META, true, WRITE);
 
   /*
* update checkpoint pack index
 diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
 index c9a76f8..4e2fc09 100644
 --- a/fs/f2fs/data.c
 +++ b/fs/f2fs/data.c
 @@ -25,6 +25,204 @@
  #include trace/events/f2fs.h
 
  /*
 + * Low-level block read/write IO operations.
 + */
 +static struct bio *__bio_alloc(struct block_device *bdev, int npages)
 +{
 + struct bio *bio;
 +
 + /* No failure on bio allocation */
 + bio = bio_alloc(GFP_NOIO, npages);
 + bio-bi_bdev = bdev;
 + bio-bi_private = NULL;
 + return bio;
 +}
 +
 +static void f2fs_read_end_io(struct bio *bio, int err)
 +{
 + const int uptodate = test_bit(BIO_UPTODATE, bio-bi_flags);
 + struct bio_vec *bvec = bio-bi_io_vec + bio-bi_vcnt - 1;
 +
 + do {
 + struct page *page = bvec-bv_page;
 +
 + if (--bvec = bio-bi_io_vec)
 + prefetchw(bvec-bv_page-flags);
 +
 + if (uptodate) {
 + SetPageUptodate(page);
 + } else {
 + ClearPageUptodate(page);
 + SetPageError(page);
 + }
 + unlock_page(page);
 + } while (bvec = bio-bi_io_vec);
 +
 + bio_put(bio);
 +}
 +
 +static void f2fs_write_end_io(struct bio *bio, int err)
 +{
 + const int uptodate = test_bit(BIO_UPTODATE, bio-bi_flags);
 + struct bio_vec *bvec = bio-bi_io_vec + bio-bi_vcnt - 1;
 + struct f2fs_sb_info *sbi = F2FS_SB(bvec-bv_page-mapping-host-i_sb);
 +
 + do {
 + struct page *page = bvec-bv_page;
 +
 + if (--bvec = bio-bi_io_vec)
 + prefetchw(bvec-bv_page-flags

[f2fs-dev] [PATCH 1/2] f2fs: add a new function to support for merging contiguous read

2013-11-11 Thread Chao Yu
For better read performance, we add a new function to support for merging 
contiguous read as the one for write.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/data.c |   45 +
 fs/f2fs/f2fs.h |2 ++
 2 files changed, 47 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index aa3438c..f30060b 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -404,6 +404,51 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct page 
*page,
return 0;
 }
 
+void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, int rw)
+{
+   down_read(sbi-bio_sem);
+   if (sbi-read_bio) {
+   submit_bio(rw, sbi-read_bio);
+   sbi-read_bio = NULL;
+   }
+   up_read(sbi-bio_sem);
+}
+
+void submit_read_page(struct f2fs_sb_info *sbi, struct page *page,
+   block_t blk_addr, int rw)
+{
+   struct block_device *bdev = sbi-sb-s_bdev;
+   int bio_blocks;
+
+   verify_block_addr(sbi, blk_addr);
+
+   down_read(sbi-bio_sem);
+
+   if (sbi-read_bio  sbi-last_read_block != blk_addr - 1) {
+   submit_bio(rw, sbi-read_bio);
+   sbi-read_bio = NULL;
+   }
+
+alloc_new:
+   if (sbi-read_bio == NULL) {
+   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   sbi-read_bio = f2fs_bio_alloc(bdev, bio_blocks);
+   sbi-read_bio-bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
+   sbi-read_bio-bi_end_io = read_end_io;
+   }
+
+   if (bio_add_page(sbi-read_bio, page, PAGE_CACHE_SIZE, 0) 
+   PAGE_CACHE_SIZE) {
+   submit_bio(rw, sbi-read_bio);
+   sbi-read_bio = NULL;
+   goto alloc_new;
+   }
+
+   sbi-last_read_block = blk_addr;
+
+   up_read(sbi-bio_sem);
+}
+
 /*
  * This function should be used by the data read flow only where it
  * does not check the create flag that indicates block allocation.
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 89dc750..0afdcec 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -359,6 +359,8 @@ struct f2fs_sb_info {
 
/* for segment-related operations */
struct f2fs_sm_info *sm_info;   /* segment manager */
+   struct bio *read_bio;   /* read bios to merge */
+   sector_t last_read_block;   /* last read block number */
struct bio *bio[NR_PAGE_TYPE];  /* bios to merge */
sector_t last_block_in_bio[NR_PAGE_TYPE];   /* last block number */
struct rw_semaphore bio_sem;/* IO semaphore */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 2/2] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-11 Thread Chao Yu
Previously we read sit entries page one by one, this method lost the chance of 
reading contiguous page together.
So we read pages as contiguous as possible for better mount performance.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/f2fs.h|2 ++
 fs/f2fs/segment.c |   65 ++---
 fs/f2fs/segment.h |2 ++
 3 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 0afdcec..bfe9d87 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1113,6 +1113,8 @@ struct page *find_data_page(struct inode *, pgoff_t, 
bool);
 struct page *get_lock_data_page(struct inode *, pgoff_t);
 struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
 int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
+void f2fs_submit_read_bio(struct f2fs_sb_info *, int);
+void submit_read_page(struct f2fs_sb_info *, struct page *, block_t, int);
 int do_write_data_page(struct page *);
 
 /*
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 86dc289..414c351 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1474,19 +1474,72 @@ static int build_curseg(struct f2fs_sb_info *sbi)
return restore_curseg_summaries(sbi);
 }
 
+static int ra_sit_pages(struct f2fs_sb_info *sbi, int start,
+   int nrpages, bool *is_order)
+{
+   struct address_space *mapping = sbi-meta_inode-i_mapping;
+   struct sit_info *sit_i = SIT_I(sbi);
+   struct page *page;
+   block_t blk_addr;
+   int blkno, readcnt = 0;
+   int sit_blk_cnt = SIT_BLK_CNT(sbi);
+
+   for (blkno = start; blkno  start + nrpages; blkno++) {
+
+   if (blkno = sit_blk_cnt)
+   goto out;
+   if ((!f2fs_test_bit(blkno, sit_i-sit_bitmap) ^ !*is_order)) {
+   *is_order = !*is_order;
+   goto out;
+   }
+
+   blk_addr = sit_i-sit_base_addr + blkno;
+   if (*is_order)
+   blk_addr += sit_i-sit_blocks;
+repeat:
+   page = grab_cache_page(mapping, blk_addr);
+   if (!page) {
+   cond_resched();
+   goto repeat;
+   }
+   if (PageUptodate(page)) {
+   f2fs_put_page(page, 1);
+   readcnt++;
+   goto out;
+   }
+
+   submit_read_page(sbi, page, blk_addr, READ_SYNC);
+
+   page_cache_release(page);
+   readcnt++;
+   }
+out:
+   f2fs_submit_read_bio(sbi, READ_SYNC);
+   return readcnt;
+}
+
 static void build_sit_entries(struct f2fs_sb_info *sbi)
 {
struct sit_info *sit_i = SIT_I(sbi);
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
struct f2fs_summary_block *sum = curseg-sum_blk;
-   unsigned int start;
+   bool is_order = f2fs_test_bit(0, sit_i-sit_bitmap) ? true : false;
+   int sit_blk_cnt = SIT_BLK_CNT(sbi);
+   int bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   unsigned int i, start, end;
+   unsigned int readed, start_blk = 0;
 
-   for (start = 0; start  TOTAL_SEGS(sbi); start++) {
+next:
+   readed = ra_sit_pages(sbi, start_blk, bio_blocks, is_order);
+
+   start = start_blk * sit_i-sents_per_block;
+   end = (start_blk + readed) * sit_i-sents_per_block;
+
+   for (; start  end  start  TOTAL_SEGS(sbi); start++) {
struct seg_entry *se = sit_i-sentries[start];
struct f2fs_sit_block *sit_blk;
struct f2fs_sit_entry sit;
struct page *page;
-   int i;
 
mutex_lock(curseg-curseg_mutex);
for (i = 0; i  sits_in_cursum(sum); i++) {
@@ -1497,6 +1550,7 @@ static void build_sit_entries(struct f2fs_sb_info *sbi)
}
}
mutex_unlock(curseg-curseg_mutex);
+
page = get_current_sit_page(sbi, start);
sit_blk = (struct f2fs_sit_block *)page_address(page);
sit = sit_blk-entries[SIT_ENTRY_OFFSET(sit_i, start)];
@@ -1509,6 +1563,11 @@ got_it:
e-valid_blocks += se-valid_blocks;
}
}
+
+   start_blk += readed;
+   if (start_blk = sit_blk_cnt)
+   return;
+   goto next;
 }
 
 static void init_free_segmap(struct f2fs_sb_info *sbi)
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 269f690..ad5b9f1 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -83,6 +83,8 @@
(segno / SIT_ENTRY_PER_BLOCK)
 #defineSTART_SEGNO(sit_i, segno)   \
(SIT_BLOCK_OFFSET(sit_i, segno) * SIT_ENTRY_PER_BLOCK)
+#define SIT_BLK_CNT(sbi)   \
+   ((TOTAL_SEGS(sbi) + SIT_ENTRY_PER_BLOCK - 1) / SIT_ENTRY_PER_BLOCK)
 #define f2fs_bitmap_size(nr

RE: [f2fs-dev] [PATCH 2/2] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-13 Thread Chao Yu
Hi Gu,

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Wednesday, November 13, 2013 11:39 AM
 To: Chao Yu
 Cc: ???; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: read contiguous sit entry pages by 
 merging for mount performance
 
 Hi Yu,
 On 11/12/2013 01:18 PM, Chao Yu wrote:
 
  Previously we read sit entries page one by one, this method lost the chance 
  of reading contiguous page together.
  So we read pages as contiguous as possible for better mount performance.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/f2fs.h|2 ++
   fs/f2fs/segment.c |   65 
  ++---
   fs/f2fs/segment.h |2 ++
   3 files changed, 66 insertions(+), 3 deletions(-)
 
  diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
  index 0afdcec..bfe9d87 100644
  --- a/fs/f2fs/f2fs.h
  +++ b/fs/f2fs/f2fs.h
  @@ -1113,6 +1113,8 @@ struct page *find_data_page(struct inode *, pgoff_t, 
  bool);
   struct page *get_lock_data_page(struct inode *, pgoff_t);
   struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, 
  bool);
   int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
  +void f2fs_submit_read_bio(struct f2fs_sb_info *, int);
  +void submit_read_page(struct f2fs_sb_info *, struct page *, block_t, int);
 
 Better to move these declarations into PATCH 1/2.

Okay, I will move it to the right place.

 
   int do_write_data_page(struct page *);
 
   /*
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
  index 86dc289..414c351 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -1474,19 +1474,72 @@ static int build_curseg(struct f2fs_sb_info *sbi)
  return restore_curseg_summaries(sbi);
   }
 
  +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start,
  +   int nrpages, bool *is_order)
  +{
  +   struct address_space *mapping = sbi-meta_inode-i_mapping;
  +   struct sit_info *sit_i = SIT_I(sbi);
  +   struct page *page;
  +   block_t blk_addr;
  +   int blkno, readcnt = 0;
  +   int sit_blk_cnt = SIT_BLK_CNT(sbi);
  +
  +   for (blkno = start; blkno  start + nrpages; blkno++) {
  +
  +   if (blkno = sit_blk_cnt)
 
 Merge these two judgements:
 for (blkno = start; blkno  start + nrpages  blkno  sit_blk_cnt; blkno++)

Right, but the line may over 80 characters, if we split this line, it seems not 
suitable.
So how about this?
int blkno = start, readcnt = 0;
int sit_blk_cnt = SIT_BLK_CNT(sbi);

for (; blkno  start + nrpages  blkno  sit_blk_cnt; blkno++) {

 
  +   goto out;
 
  +   if ((!f2fs_test_bit(blkno, sit_i-sit_bitmap) ^ !*is_order)) {
  +   *is_order = !*is_order;
  +   goto out;
 
 'Break' seems more suitable.

Yes, you are right.

 
  +   }
  +
  +   blk_addr = sit_i-sit_base_addr + blkno;
  +   if (*is_order)
  +   blk_addr += sit_i-sit_blocks;
  +repeat:
  +   page = grab_cache_page(mapping, blk_addr);
  +   if (!page) {
  +   cond_resched();
  +   goto repeat;
  +   }
  +   if (PageUptodate(page)) {
  +   f2fs_put_page(page, 1);
  +   readcnt++;
  +   goto out;
 
 Here may be 'Continue'.

'Out' label could be removed after this modification.
It seems more neat.

 
  +   }
  +
  +   submit_read_page(sbi, page, blk_addr, READ_SYNC);
  +
  +   page_cache_release(page);
 
 Put page here seems not a good idea, otherwise all your work may be in vain.

You mean that pages could be reclaimed by VM when out of memory?
IMO, it is designed more like VM read ahead because we should concern 
memory state of system, and still we have second chance to read these pages.

Could we use mark_page_accessed () to delay VM reclaimed them?

 
  +   readcnt++;
  +   }
  +out:
  +   f2fs_submit_read_bio(sbi, READ_SYNC);
  +   return readcnt;
  +}
  +
   static void build_sit_entries(struct f2fs_sb_info *sbi)
   {
  struct sit_info *sit_i = SIT_I(sbi);
  struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
  struct f2fs_summary_block *sum = curseg-sum_blk;
  -   unsigned int start;
  +   bool is_order = f2fs_test_bit(0, sit_i-sit_bitmap) ? true : false;
  +   int sit_blk_cnt = SIT_BLK_CNT(sbi);
  +   int bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
  +   unsigned int i, start, end;
  +   unsigned int readed, start_blk = 0;
 
  -   for (start = 0; start  TOTAL_SEGS(sbi); start++) {
  +next:
  +   readed = ra_sit_pages(sbi, start_blk, bio_blocks, is_order);
 
 In fact, you know how many blocks that you want to read(SIT_BLK_CNT(sbi)),
 so here sit_blk_cnt is more suitable than a MAX one, and it also can make
 the logic of ra_sit_pages more simple.

Right.

BTW, I am

[f2fs-dev] [PATCH V2 2/2] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-15 Thread Chao Yu
Previously we read sit entries page one by one, this method lost the chance of 
reading contiguous page together.
So we read pages as contiguous as possible for better mount performance.

v1--v2:
 o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng 
suggested.
 o add mark_page_accessed () before release page to delay VM reclaiming them.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/segment.c |  108 -
 fs/f2fs/segment.h |2 +
 2 files changed, 84 insertions(+), 26 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index fa284d3..656fe40 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -14,6 +14,7 @@
 #include linux/blkdev.h
 #include linux/prefetch.h
 #include linux/vmalloc.h
+#include linux/swap.h
 
 #include f2fs.h
 #include segment.h
@@ -1480,41 +1481,96 @@ static int build_curseg(struct f2fs_sb_info *sbi)
return restore_curseg_summaries(sbi);
 }
 
+static int ra_sit_pages(struct f2fs_sb_info *sbi, int start,
+   int nrpages, bool *is_order)
+{
+   struct address_space *mapping = sbi-meta_inode-i_mapping;
+   struct sit_info *sit_i = SIT_I(sbi);
+   struct page *page;
+   block_t blk_addr;
+   int blkno = start, readcnt = 0;
+   int sit_blk_cnt = SIT_BLK_CNT(sbi);
+
+   for (; blkno  start + nrpages  blkno  sit_blk_cnt; blkno++) {
+
+   if ((!f2fs_test_bit(blkno, sit_i-sit_bitmap) ^ !*is_order)) {
+   *is_order = !*is_order;
+   break;
+   }
+
+   blk_addr = sit_i-sit_base_addr + blkno;
+   if (*is_order)
+   blk_addr += sit_i-sit_blocks;
+repeat:
+   page = grab_cache_page(mapping, blk_addr);
+   if (!page) {
+   cond_resched();
+   goto repeat;
+   }
+   if (PageUptodate(page)) {
+   mark_page_accessed(page);
+   f2fs_put_page(page, 1);
+   readcnt++;
+   continue;
+   }
+
+   submit_read_page(sbi, page, blk_addr, READ_SYNC);
+
+   mark_page_accessed(page);
+   f2fs_put_page(page, 0);
+   readcnt++;
+   }
+
+   f2fs_submit_read_bio(sbi, READ_SYNC);
+   return readcnt;
+}
+
 static void build_sit_entries(struct f2fs_sb_info *sbi)
 {
struct sit_info *sit_i = SIT_I(sbi);
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
struct f2fs_summary_block *sum = curseg-sum_blk;
-   unsigned int start;
-
-   for (start = 0; start  TOTAL_SEGS(sbi); start++) {
-   struct seg_entry *se = sit_i-sentries[start];
-   struct f2fs_sit_block *sit_blk;
-   struct f2fs_sit_entry sit;
-   struct page *page;
-   int i;
+   bool is_order = f2fs_test_bit(0, sit_i-sit_bitmap) ? true : false;
+   int sit_blk_cnt = SIT_BLK_CNT(sbi);
+   unsigned int i, start, end;
+   unsigned int readed, start_blk = 0;
 
-   mutex_lock(curseg-curseg_mutex);
-   for (i = 0; i  sits_in_cursum(sum); i++) {
-   if (le32_to_cpu(segno_in_journal(sum, i)) == start) {
-   sit = sit_in_journal(sum, i);
-   mutex_unlock(curseg-curseg_mutex);
-   goto got_it;
+   do {
+   readed = ra_sit_pages(sbi, start_blk, sit_blk_cnt, is_order);
+
+   start = start_blk * sit_i-sents_per_block;
+   end = (start_blk + readed) * sit_i-sents_per_block;
+
+   for (; start  end  start  TOTAL_SEGS(sbi); start++) {
+   struct seg_entry *se = sit_i-sentries[start];
+   struct f2fs_sit_block *sit_blk;
+   struct f2fs_sit_entry sit;
+   struct page *page;
+
+   mutex_lock(curseg-curseg_mutex);
+   for (i = 0; i  sits_in_cursum(sum); i++) {
+   if (le32_to_cpu(segno_in_journal(sum, i)) == 
start) {
+   sit = sit_in_journal(sum, i);
+   mutex_unlock(curseg-curseg_mutex);
+   goto got_it;
+   }
}
-   }
-   mutex_unlock(curseg-curseg_mutex);
-   page = get_current_sit_page(sbi, start);
-   sit_blk = (struct f2fs_sit_block *)page_address(page);
-   sit = sit_blk-entries[SIT_ENTRY_OFFSET(sit_i, start)];
-   f2fs_put_page(page, 1);
+   mutex_unlock(curseg-curseg_mutex);
+
+   page = get_current_sit_page(sbi, start);
+   sit_blk = (struct

[f2fs-dev] [PATCH V2 1/2] f2fs: add a new function to support for merging contiguous read

2013-11-15 Thread Chao Yu
For better read performance, we add a new function to support for merging 
contiguous read as the one for write.

v1--v2:
 o add declarations here as Gu Zheng suggested.

Signed-off-by: Chao Yu chao2...@samsung.com
Acked-by: Gu Zheng guz.f...@cn.fujitsu.com
---
 fs/f2fs/data.c |   45 +
 fs/f2fs/f2fs.h |4 
 2 files changed, 49 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index aa3438c..18107cb 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -404,6 +404,51 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct page 
*page,
return 0;
 }
 
+void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, int rw)
+{
+   down_read(sbi-bio_sem);
+   if (sbi-read_bio) {
+   submit_bio(rw, sbi-read_bio);
+   sbi-read_bio = NULL;
+   }
+   up_read(sbi-bio_sem);
+}
+
+void submit_read_page(struct f2fs_sb_info *sbi, struct page *page,
+   block_t blk_addr, int rw)
+{
+   struct block_device *bdev = sbi-sb-s_bdev;
+   int bio_blocks;
+
+   verify_block_addr(sbi, blk_addr);
+
+   down_read(sbi-bio_sem);
+
+   if (sbi-read_bio  sbi-last_read_block != blk_addr - 1) {
+   submit_bio(rw, sbi-read_bio);
+   sbi-read_bio = NULL;
+   }
+
+alloc_new:
+   if (sbi-read_bio == NULL) {
+   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   sbi-read_bio = f2fs_bio_alloc(bdev, bio_blocks);
+   sbi-read_bio-bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
+   sbi-read_bio-bi_end_io = read_end_io;
+   }
+
+   if (bio_add_page(sbi-read_bio, page, PAGE_CACHE_SIZE, 0) 
+   PAGE_CACHE_SIZE) {
+   submit_bio(rw, sbi-read_bio);
+   sbi-read_bio = NULL;
+   goto alloc_new;
+   }
+
+   sbi-last_read_block = blk_addr;
+
+   up_read(sbi-bio_sem);
+}
+
 /*
  * This function should be used by the data read flow only where it
  * does not check the create flag that indicates block allocation.
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 89dc750..bfe9d87 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -359,6 +359,8 @@ struct f2fs_sb_info {
 
/* for segment-related operations */
struct f2fs_sm_info *sm_info;   /* segment manager */
+   struct bio *read_bio;   /* read bios to merge */
+   sector_t last_read_block;   /* last read block number */
struct bio *bio[NR_PAGE_TYPE];  /* bios to merge */
sector_t last_block_in_bio[NR_PAGE_TYPE];   /* last block number */
struct rw_semaphore bio_sem;/* IO semaphore */
@@ -,6 +1113,8 @@ struct page *find_data_page(struct inode *, pgoff_t, 
bool);
 struct page *get_lock_data_page(struct inode *, pgoff_t);
 struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
 int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
+void f2fs_submit_read_bio(struct f2fs_sb_info *, int);
+void submit_read_page(struct f2fs_sb_info *, struct page *, block_t, int);
 int do_write_data_page(struct page *);
 
 /*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: use f2fs_put_page to release page for uniform style

2013-11-15 Thread Chao Yu
We should use f2fs_put_page to release page for uniform style of f2fs code.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/data.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index aa3438c..076a60c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -714,8 +714,7 @@ static int f2fs_write_end(struct file *file,
update_inode_page(inode);
}
 
-   unlock_page(page);
-   page_cache_release(page);
+   f2fs_put_page(page, 1);
return copied;
 }
 
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2 1/2] f2fs: add a new function to support for merging contiguous read

2013-11-17 Thread Chao Yu
Hi Kim,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Monday, November 18, 2013 8:29 AM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH V2 1/2] f2fs: add a new function to support 
 for merging contiguous read
 
 Hi Chao,
 
 2013-11-16 (토), 14:14 +0800, Chao Yu:
  For better read performance, we add a new function to support for merging 
  contiguous read as the one for write.
 
 Please consider 80 columns for the description.
 I cannot fix this at every time though. :(

Got it, sorry about my carelessness in previous patch.

 
 
  v1--v2:
   o add declarations here as Gu Zheng suggested.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  Acked-by: Gu Zheng guz.f...@cn.fujitsu.com
  ---
   fs/f2fs/data.c |   45 +
   fs/f2fs/f2fs.h |4 
   2 files changed, 49 insertions(+)
 
  diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
  index aa3438c..18107cb 100644
  --- a/fs/f2fs/data.c
  +++ b/fs/f2fs/data.c
  @@ -404,6 +404,51 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct 
  page *page,
  return 0;
   }
 
  +void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, int rw)
  +{
  +   down_read(sbi-bio_sem);
 
 Is there any reason to use down_read()?

Isn't that we use bio_sem to let w/r or w/w submitting be mutex?

 It seems that we need to declare sbi-bio_read and sbi-bio_write
 instead of sbi-bio_sem.
 In addition to that, we need to use down_write(sbi-bio_read) here.

If so, it looks similar between (struct rw_semaphore) sbi-bio_read 
and (struct bio *) sbi-read_bio.
How about using read_bio_sem/rbio_sem to differentiate 
from sbi-read_bio?

 
  +   if (sbi-read_bio) {
  +   submit_bio(rw, sbi-read_bio);
  +   sbi-read_bio = NULL;
  +   }
  +   up_read(sbi-bio_sem);
 
 up_write(sbi-bio_read);
 
  +}
  +
  +void submit_read_page(struct f2fs_sb_info *sbi, struct page *page,
  +   block_t blk_addr, int rw)
  +{
  +   struct block_device *bdev = sbi-sb-s_bdev;
  +   int bio_blocks;
  +
  +   verify_block_addr(sbi, blk_addr);
  +
  +   down_read(sbi-bio_sem);
 
 down_write(sbi-bio_read);
 
  +
  +   if (sbi-read_bio  sbi-last_read_block != blk_addr - 1) {
  +   submit_bio(rw, sbi-read_bio);
  +   sbi-read_bio = NULL;
  +   }
  +
  +alloc_new:
  +   if (sbi-read_bio == NULL) {
  +   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
  +   sbi-read_bio = f2fs_bio_alloc(bdev, bio_blocks);
  +   sbi-read_bio-bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
  +   sbi-read_bio-bi_end_io = read_end_io;
  +   }
  +
  +   if (bio_add_page(sbi-read_bio, page, PAGE_CACHE_SIZE, 0) 
  +   PAGE_CACHE_SIZE) {
  +   submit_bio(rw, sbi-read_bio);
  +   sbi-read_bio = NULL;
  +   goto alloc_new;
  +   }
  +
  +   sbi-last_read_block = blk_addr;
  +
  +   up_read(sbi-bio_sem);
 
 up_write(sbi-bio_read);
 
  +}
  +
   /*
* This function should be used by the data read flow only where it
* does not check the create flag that indicates block allocation.
  diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
  index 89dc750..bfe9d87 100644
  --- a/fs/f2fs/f2fs.h
  +++ b/fs/f2fs/f2fs.h
  @@ -359,6 +359,8 @@ struct f2fs_sb_info {
 
  /* for segment-related operations */
  struct f2fs_sm_info *sm_info;   /* segment manager */
  +   struct bio *read_bio;   /* read bios to merge */
  +   sector_t last_read_block;   /* last read block number */
  struct bio *bio[NR_PAGE_TYPE];  /* bios to merge */
  sector_t last_block_in_bio[NR_PAGE_TYPE];   /* last block number */
  struct rw_semaphore bio_sem;/* IO semaphore */
  @@ -,6 +1113,8 @@ struct page *find_data_page(struct inode *, pgoff_t, 
  bool);
   struct page *get_lock_data_page(struct inode *, pgoff_t);
   struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, 
  bool);
   int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
  +void f2fs_submit_read_bio(struct f2fs_sb_info *, int);
  +void submit_read_page(struct f2fs_sb_info *, struct page *, block_t, int);
   int do_write_data_page(struct page *);
 
   /*
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 1/2] f2fs: clean up the do_submit_bio flow

2013-11-18 Thread Chao Yu
Hi

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Monday, November 18, 2013 5:12 PM
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: [f2fs-dev] [PATCH 1/2] f2fs: clean up the do_submit_bio flow
 
 This patch introduces PAGE_TYPE_OF_BIO() and cleans up do_submit_bio() with
it.
 
 Signed-off-by: Jaegeuk Kim jaegeuk@samsung.com
 ---
  fs/f2fs/f2fs.h|  1 +
  fs/f2fs/segment.c | 39 +--
  2 files changed, 22 insertions(+), 18 deletions(-)
 
 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
 index fe5c2fc..1c783fd 100644
 --- a/fs/f2fs/f2fs.h
 +++ b/fs/f2fs/f2fs.h
 @@ -351,6 +351,7 @@ enum count_type {
   *   with waiting the bio's completion
   * ...   Only can be used with META.
   */
 +#define PAGE_TYPE_OF_BIO(type)   (type)  META ? META : (type)

We'd better to add parentheses for macro to avoid style problem.:)

#define PAGE_TYPE_OF_BIO(type)  ((type)  META ? META : (type))

  enum page_type {
   DATA,
   NODE,
 diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
 index 1f83999..dad5f1a 100644
 --- a/fs/f2fs/segment.c
 +++ b/fs/f2fs/segment.c
 @@ -837,32 +837,35 @@ static void do_submit_bio(struct f2fs_sb_info *sbi,
   enum page_type type, bool sync)
  {
   int rw = sync ? WRITE_SYNC : WRITE;
 - enum page_type btype = type  META ? META : type;
 + enum page_type btype = PAGE_TYPE_OF_BIO(type);
 + struct bio *bio = sbi-bio[btype];
 + struct bio_private *p;
 +
 + if (!bio)
 + return;
 +
 + sbi-bio[btype] = NULL;
 
   if (type = META_FLUSH)
   rw = WRITE_FLUSH_FUA;
 -
   if (btype == META)
   rw |= REQ_META;
 
 - if (sbi-bio[btype]) {
 - struct bio_private *p = sbi-bio[btype]-bi_private;
 - p-sbi = sbi;
 - sbi-bio[btype]-bi_end_io = f2fs_end_io_write;
 + p = bio-bi_private;
 + p-sbi = sbi;
 + bio-bi_end_io = f2fs_end_io_write;
 
 - trace_f2fs_do_submit_bio(sbi-sb, btype, sync, sbi-bio[btype]);
 + trace_f2fs_do_submit_bio(sbi-sb, btype, sync, bio);
 
 - if (type == META_FLUSH) {
 - DECLARE_COMPLETION_ONSTACK(wait);
 - p-is_sync = true;
 - p-wait = wait;
 - submit_bio(rw, sbi-bio[btype]);
 - wait_for_completion(wait);
 - } else {
 - p-is_sync = false;
 - submit_bio(rw, sbi-bio[btype]);
 - }
 - sbi-bio[btype] = NULL;
 + if (type == META_FLUSH) {
 + DECLARE_COMPLETION_ONSTACK(wait);
 + p-is_sync = true;
 + p-wait = wait;
 + submit_bio(rw, bio);
 + wait_for_completion(wait);
 + } else {
 + p-is_sync = false;
 + submit_bio(rw, bio);
   }
  }
 
 --
 1.8.4.474.g128a96c
 
 
 --
 DreamFactory - Open Source REST  JSON Services for HTML5  Native Apps
 OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
 Free app hosting. Or install the open source package on any LAMP server.
 Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
 http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk
 ___
 Linux-f2fs-devel mailing list
 linux-f2fs-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2 1/2] f2fs: add a new function to support for merging contiguous read

2013-11-18 Thread Chao Yu
Hi

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Monday, November 18, 2013 5:11 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net; '谭姝'
 Subject: RE: [f2fs-dev] [PATCH V2 1/2] f2fs: add a new function to support for
 merging contiguous read
 
 Hi,
 
 2013-11-18 (월), 09:37 +0800, Chao Yu:
  Hi Kim,
 
   -Original Message-
   From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
   Sent: Monday, November 18, 2013 8:29 AM
   To: Chao Yu
   Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
   Subject: Re: [f2fs-dev] [PATCH V2 1/2] f2fs: add a new function to 
   support for
 merging contiguous read
  
   Hi Chao,
  
   2013-11-16 (토), 14:14 +0800, Chao Yu:
For better read performance, we add a new function to support for 
merging
 contiguous read as the one for write.
  
   Please consider 80 columns for the description.
   I cannot fix this at every time though. :(
 
  Got it, sorry about my carelessness in previous patch.
 
  
   
v1--v2:
 o add declarations here as Gu Zheng suggested.
   
Signed-off-by: Chao Yu chao2...@samsung.com
Acked-by: Gu Zheng guz.f...@cn.fujitsu.com
---
 fs/f2fs/data.c |   45
 +
 fs/f2fs/f2fs.h |4 
 2 files changed, 49 insertions(+)
   
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index aa3438c..18107cb 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -404,6 +404,51 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct
 page *page,
return 0;
 }
   
+void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, int rw)
+{
+   down_read(sbi-bio_sem);
  
   Is there any reason to use down_read()?
 
  Isn't that we use bio_sem to let w/r or w/w submitting be mutex?
 
 As I examined the bio_sem, I think we don't need to use a semaphore for
 read and write IOs.
 Just it is enough to use a mutex for writes only.

Agreed, it could also improve efficiency of read/write request concurrent.

 
 
   It seems that we need to declare sbi-bio_read and sbi-bio_write
   instead of sbi-bio_sem.
   In addition to that, we need to use down_write(sbi-bio_read) here.
 
  If so, it looks similar between (struct rw_semaphore) sbi-bio_read
  and (struct bio *) sbi-read_bio.
  How about using read_bio_sem/rbio_sem to differentiate
  from sbi-read_bio?
 
 I think sbi-write_mutex and sbi-read_mutex are much better.
 
 Could you refer the following patches?

It's better, I will refer your patch.
And how about this following patch to reduce race of write_mutex 
between DATA/NODE/META writer?

 Thanks,
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: split sbi-write_mutex for DATA/NODE/META to avoid unnecessary race

2013-11-18 Thread Chao Yu
All DATA/NODE/META bio buffers in superblock is protected by 
'sbi-write_mutex', but each bio buffer area is independent, So we 
should split write_mutex to three for DATA/NODE/META.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/f2fs.h|2 +-
 fs/f2fs/segment.c |8 
 fs/f2fs/super.c   |4 +++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 2df1e61..1c67521 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -362,7 +362,7 @@ struct f2fs_sb_info {
struct f2fs_sm_info *sm_info;   /* segment manager */
struct bio *bio[NR_PAGE_TYPE];  /* bios to merge */
sector_t last_block_in_bio[NR_PAGE_TYPE];   /* last block number */
-   struct mutex write_mutex;   /* mutex for writing IOs */
+   struct mutex write_mutex[NR_PAGE_TYPE]; /* mutex for writing IOs */
 
/* for checkpoint */
struct f2fs_checkpoint *ckpt;   /* raw checkpoint pointer */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 556965f..a36713ae 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -661,9 +661,9 @@ void f2fs_submit_bio(struct f2fs_sb_info *sbi, enum
page_type type, bool sync)
if (!sbi-bio[btype])
return;
 
-   mutex_lock(sbi-write_mutex);
+   mutex_lock(sbi-write_mutex[type]);
do_submit_bio(sbi, type, sync);
-   mutex_unlock(sbi-write_mutex);
+   mutex_unlock(sbi-write_mutex[type]);
 }
 
 static void submit_write_page(struct f2fs_sb_info *sbi, struct page *page,
@@ -674,7 +674,7 @@ static void submit_write_page(struct f2fs_sb_info *sbi,
struct page *page,
 
verify_block_addr(sbi, blk_addr);
 
-   mutex_lock(sbi-write_mutex);
+   mutex_lock(sbi-write_mutex[type]);
 
inc_page_count(sbi, F2FS_WRITEBACK);
 
@@ -709,7 +709,7 @@ retry:
 
sbi-last_block_in_bio[type] = blk_addr;
 
-   mutex_unlock(sbi-write_mutex);
+   mutex_unlock(sbi-write_mutex[type]);
trace_f2fs_submit_write_page(page, blk_addr, type);
 }
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f56941c..6928c0a 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -874,7 +874,9 @@ static int f2fs_fill_super(struct super_block *sb, void
*data, int silent)
mutex_init(sbi-node_write);
sbi-por_doing = false;
spin_lock_init(sbi-stat_lock);
-   mutex_init(sbi-write_mutex);
+   mutex_init(sbi-write_mutex[DATA]);
+   mutex_init(sbi-write_mutex[NODE]);
+   mutex_init(sbi-write_mutex[META]);
init_rwsem(sbi-cp_rwsem);
init_waitqueue_head(sbi-cp_wait);
init_sb_info(sbi);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: split sbi-write_mutex for DATA/NODE/META to avoid unnecessary race

2013-11-18 Thread Chao Yu
Hi

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Tuesday, November 19, 2013 11:36 AM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: Re: [f2fs-dev] [PATCH] f2fs: split sbi-write_mutex for 
 DATA/NODE/META to
 avoid unnecessary race
 
 Hi,
 
 I think we don't need to make two patches for this.
 How about this?

This could be reasonable,
And I will refer to this patch.

 
 From 71c27f78e72d680edcd7b1c0917842343044653c Mon Sep 17 00:00:00 2001
 From: Jaegeuk Kim jaegeuk@samsung.com
 Date: Mon, 18 Nov 2013 17:16:17 +0900
 Subject: [PATCH] f2fs: use sbi-write_mutex for write bios
 
 This patch removes an unnecessary semaphore (i.e., sbi-bio_sem).
 There is no reason to use the semaphore when f2fs submits read and write
 IOs.
 Instead, let's use a write mutex and cover the sbi-bio[] by the lock.
 
 Change log from v1:
  o split write_mutex suggested by Chao Yu
 
 Chao described,
 All DATA/NODE/META bio buffers in superblock is protected by
 'sbi-write_mutex', but each bio buffer area is independent, So we
 should split write_mutex to three for DATA/NODE/META.
 
 Signed-off-by: Chao Yu chao2...@samsung.com
 Signed-off-by: Jaegeuk Kim jaegeuk@samsung.com
 ---
  fs/f2fs/data.c|  4 
  fs/f2fs/f2fs.h|  2 +-
  fs/f2fs/segment.c | 13 +
  fs/f2fs/super.c   |  6 +-
  4 files changed, 15 insertions(+), 10 deletions(-)
 
 diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
 index 076a60c..5920639 100644
 --- a/fs/f2fs/data.c
 +++ b/fs/f2fs/data.c
 @@ -383,8 +383,6 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct
 page *page,
 
   trace_f2fs_readpage(page, blk_addr, type);
 
 - down_read(sbi-bio_sem);
 -
   /* Allocate a new bio */
   bio = f2fs_bio_alloc(bdev, 1);
 
 @@ -394,13 +392,11 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct
 page *page,
 
   if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0)  PAGE_CACHE_SIZE) {
   bio_put(bio);
 - up_read(sbi-bio_sem);
   f2fs_put_page(page, 1);
   return -EFAULT;
   }
 
   submit_bio(type, bio);
 - up_read(sbi-bio_sem);
   return 0;
  }
 
 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
 index 6a49554..6e67f28 100644
 --- a/fs/f2fs/f2fs.h
 +++ b/fs/f2fs/f2fs.h
 @@ -374,7 +374,7 @@ struct f2fs_sb_info {
   struct f2fs_sm_info *sm_info;   /* segment manager */
   struct bio *bio[NR_PAGE_TYPE];  /* bios to merge */
   sector_t last_block_in_bio[NR_PAGE_TYPE];   /* last block number */
 - struct rw_semaphore bio_sem;/* IO semaphore */
 + struct mutex write_mutex[NR_PAGE_TYPE]; /* mutex for writing IOs */
 
   /* for checkpoint */
   struct f2fs_checkpoint *ckpt;   /* raw checkpoint pointer */
 diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
 index dad5f1a..119af0b 100644
 --- a/fs/f2fs/segment.c
 +++ b/fs/f2fs/segment.c
 @@ -871,9 +871,14 @@ static void do_submit_bio(struct f2fs_sb_info *sbi,
 
  void f2fs_submit_bio(struct f2fs_sb_info *sbi, enum page_type type,
 bool sync)
  {
 - down_write(sbi-bio_sem);
 + enum page_type btype = PAGE_TYPE_OF_BIO(type);
 +
 + if (!sbi-bio[btype])
 + return;
 +
 + mutex_lock(sbi-write_mutex[btype]);
   do_submit_bio(sbi, type, sync);
 - up_write(sbi-bio_sem);
 + mutex_unlock(sbi-write_mutex[btype]);
  }
 
  static void submit_write_page(struct f2fs_sb_info *sbi, struct page
 *page,
 @@ -884,7 +889,7 @@ static void submit_write_page(struct f2fs_sb_info
 *sbi, struct page *page,
 
   verify_block_addr(sbi, blk_addr);
 
 - down_write(sbi-bio_sem);
 + mutex_lock(sbi-write_mutex[type]);
 
   inc_page_count(sbi, F2FS_WRITEBACK);
 
 @@ -919,7 +924,7 @@ retry:
 
   sbi-last_block_in_bio[type] = blk_addr;
 
 - up_write(sbi-bio_sem);
 + mutex_unlock(sbi-write_mutex[type]);
   trace_f2fs_submit_write_page(page, blk_addr, type);
  }
 
 diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
 index a022412..e194578 100644
 --- a/fs/f2fs/super.c
 +++ b/fs/f2fs/super.c
 @@ -820,6 +820,7 @@ static int f2fs_fill_super(struct super_block *sb,
 void *data, int silent)
   struct buffer_head *raw_super_buf;
   struct inode *root;
   long err = -EINVAL;
 + int i;
 
   /* allocate memory for f2fs-specific super block info */
   sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL);
 @@ -876,7 +877,10 @@ static int f2fs_fill_super(struct super_block *sb,
 void *data, int silent)
   mutex_init(sbi-node_write);
   sbi-por_doing = false;
   spin_lock_init(sbi-stat_lock);
 - init_rwsem(sbi-bio_sem);
 +
 + for (i = 0; i  NR_PAGE_TYPE; i++)
 + mutex_init(sbi-write_mutex[i]);
 +
   init_rwsem(sbi-cp_rwsem);
   init_waitqueue_head(sbi-cp_wait);
   init_sb_info(sbi);
 --
 1.8.4.474.g128a96c
 
 
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from

RE: [f2fs-dev] [PATCH 1/2] f2fs: clean up the do_submit_bio flow

2013-11-18 Thread Chao Yu
Hi

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Monday, November 18, 2013 5:12 PM
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net
 Subject: [f2fs-dev] [PATCH 1/2] f2fs: clean up the do_submit_bio flow
 
 This patch introduces PAGE_TYPE_OF_BIO() and cleans up do_submit_bio() with 
 it.
 
 Signed-off-by: Jaegeuk Kim jaegeuk@samsung.com
 ---
  fs/f2fs/f2fs.h|  1 +
  fs/f2fs/segment.c | 39 +--
  2 files changed, 22 insertions(+), 18 deletions(-)
 
 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
 index fe5c2fc..1c783fd 100644
 --- a/fs/f2fs/f2fs.h
 +++ b/fs/f2fs/f2fs.h
 @@ -351,6 +351,7 @@ enum count_type {
   *   with waiting the bio's completion
   * ...   Only can be used with META.
   */
 +#define PAGE_TYPE_OF_BIO(type)   (type)  META ? META : (type)
  enum page_type {
   DATA,
   NODE,
 diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
 index 1f83999..dad5f1a 100644
 --- a/fs/f2fs/segment.c
 +++ b/fs/f2fs/segment.c
 @@ -837,32 +837,35 @@ static void do_submit_bio(struct f2fs_sb_info *sbi,
   enum page_type type, bool sync)
  {
   int rw = sync ? WRITE_SYNC : WRITE;
 - enum page_type btype = type  META ? META : type;
 + enum page_type btype = PAGE_TYPE_OF_BIO(type);

-f2fs_submit_bio()
: enum page_type btype = PAGE_TYPE_OF_BIO(type);
-do_submit_bio()
: enum page_type btype = PAGE_TYPE_OF_BIO(type);

Could we remove PAGE_TYPE_OF_BIO or use f2fs_bug_on to instead
in do_submit_bio()? because it looks redundant , and also 
submit_write_page() will not pass the type which is larger than META.

 + struct bio *bio = sbi-bio[btype];
 + struct bio_private *p;
 +
 + if (!bio)
 + return;
 +
 + sbi-bio[btype] = NULL;
 
   if (type = META_FLUSH)
   rw = WRITE_FLUSH_FUA;
 -
   if (btype == META)
   rw |= REQ_META;
 
 - if (sbi-bio[btype]) {
 - struct bio_private *p = sbi-bio[btype]-bi_private;
 - p-sbi = sbi;
 - sbi-bio[btype]-bi_end_io = f2fs_end_io_write;
 + p = bio-bi_private;
 + p-sbi = sbi;
 + bio-bi_end_io = f2fs_end_io_write;
 
 - trace_f2fs_do_submit_bio(sbi-sb, btype, sync, sbi-bio[btype]);
 + trace_f2fs_do_submit_bio(sbi-sb, btype, sync, bio);
 
 - if (type == META_FLUSH) {
 - DECLARE_COMPLETION_ONSTACK(wait);
 - p-is_sync = true;
 - p-wait = wait;
 - submit_bio(rw, sbi-bio[btype]);
 - wait_for_completion(wait);
 - } else {
 - p-is_sync = false;
 - submit_bio(rw, sbi-bio[btype]);
 - }
 - sbi-bio[btype] = NULL;
 + if (type == META_FLUSH) {
 + DECLARE_COMPLETION_ONSTACK(wait);
 + p-is_sync = true;
 + p-wait = wait;
 + submit_bio(rw, bio);
 + wait_for_completion(wait);
 + } else {
 + p-is_sync = false;
 + submit_bio(rw, bio);
   }
  }
 
 --
 1.8.4.474.g128a96c
 
 
 --
 DreamFactory - Open Source REST  JSON Services for HTML5  Native Apps
 OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
 Free app hosting. Or install the open source package on any LAMP server.
 Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
 http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk
 ___
 Linux-f2fs-devel mailing list
 linux-f2fs-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2 2/2] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-19 Thread Chao Yu
Hi Gu,

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Monday, November 18, 2013 7:16 PM
 To: Chao Yu
 Cc: '???'; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH V2 2/2] f2fs: read contiguous sit entry pages 
 by merging for mount performance
 
 Hi Yu,
 One more comment, please refer to inline.
 On 11/16/2013 02:15 PM, Chao Yu wrote:
 
  Previously we read sit entries page one by one, this method lost the chance 
  of reading contiguous page together.
  So we read pages as contiguous as possible for better mount performance.
 
  v1--v2:
   o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng 
  suggested.
   o add mark_page_accessed () before release page to delay VM reclaiming 
  them.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/segment.c |  108 
  -
   fs/f2fs/segment.h |2 +
   2 files changed, 84 insertions(+), 26 deletions(-)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
  index fa284d3..656fe40 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -14,6 +14,7 @@
   #include linux/blkdev.h
   #include linux/prefetch.h
   #include linux/vmalloc.h
  +#include linux/swap.h
 
   #include f2fs.h
   #include segment.h
  @@ -1480,41 +1481,96 @@ static int build_curseg(struct f2fs_sb_info *sbi)
  return restore_curseg_summaries(sbi);
   }
 
  +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start,
  +   int nrpages, bool *is_order)
  +{
  +   struct address_space *mapping = sbi-meta_inode-i_mapping;
  +   struct sit_info *sit_i = SIT_I(sbi);
  +   struct page *page;
  +   block_t blk_addr;
  +   int blkno = start, readcnt = 0;
  +   int sit_blk_cnt = SIT_BLK_CNT(sbi);
  +
  +   for (; blkno  start + nrpages  blkno  sit_blk_cnt; blkno++) {
  +
  +   if ((!f2fs_test_bit(blkno, sit_i-sit_bitmap) ^ !*is_order)) {
  +   *is_order = !*is_order;
  +   break;
  +   }
  +
  +   blk_addr = sit_i-sit_base_addr + blkno;
  +   if (*is_order)
  +   blk_addr += sit_i-sit_blocks;
  +repeat:
  +   page = grab_cache_page(mapping, blk_addr);
  +   if (!page) {
  +   cond_resched();
  +   goto repeat;
  +   }
  +   if (PageUptodate(page)) {
  +   mark_page_accessed(page);
  +   f2fs_put_page(page, 1);
  +   readcnt++;
  +   continue;
  +   }
  +
  +   submit_read_page(sbi, page, blk_addr, READ_SYNC);
  +
  +   mark_page_accessed(page);
  +   f2fs_put_page(page, 0);
  +   readcnt++;
  +   }
  +
  +   f2fs_submit_read_bio(sbi, READ_SYNC);
  +   return readcnt;
  +}
  +
   static void build_sit_entries(struct f2fs_sb_info *sbi)
   {
  struct sit_info *sit_i = SIT_I(sbi);
  struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
  struct f2fs_summary_block *sum = curseg-sum_blk;
  -   unsigned int start;
  -
  -   for (start = 0; start  TOTAL_SEGS(sbi); start++) {
  -   struct seg_entry *se = sit_i-sentries[start];
  -   struct f2fs_sit_block *sit_blk;
  -   struct f2fs_sit_entry sit;
  -   struct page *page;
  -   int i;
  +   bool is_order = f2fs_test_bit(0, sit_i-sit_bitmap) ? true : false;
  +   int sit_blk_cnt = SIT_BLK_CNT(sbi);
  +   unsigned int i, start, end;
  +   unsigned int readed, start_blk = 0;
 
  -   mutex_lock(curseg-curseg_mutex);
  -   for (i = 0; i  sits_in_cursum(sum); i++) {
  -   if (le32_to_cpu(segno_in_journal(sum, i)) == start) {
  -   sit = sit_in_journal(sum, i);
  -   mutex_unlock(curseg-curseg_mutex);
  -   goto got_it;
  +   do {
 
 How about using find_next_bit to get the suitable start_blk if the next blk
 is not ordered here? And it also can simplify the logic of ra_sit_pages().

That's a good idea.
But I thought there maybe endianness problem between test_bit and 
f2fs_test_bit, so find_next_bit may get wrong result. Am I right?

Thanks,
Yu
 
 Thanks,
 Gu
 
  +   readed = ra_sit_pages(sbi, start_blk, sit_blk_cnt, is_order);
  +
  +   start = start_blk * sit_i-sents_per_block;
  +   end = (start_blk + readed) * sit_i-sents_per_block;
  +
  +   for (; start  end  start  TOTAL_SEGS(sbi); start++) {
  +   struct seg_entry *se = sit_i-sentries[start];
  +   struct f2fs_sit_block *sit_blk;
  +   struct f2fs_sit_entry sit;
  +   struct page *page;
  +
  +   mutex_lock(curseg-curseg_mutex);
  +   for (i = 0; i  sits_in_cursum(sum); i++) {
  +   if (le32_to_cpu

[f2fs-dev] [PATCH V2 2/2 RESEND] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-19 Thread Chao Yu
Previously we read sit entries page one by one, this method lost the chance of 
reading contiguous page together.
So we read pages as contiguous as possible for better mount performance.

v1--v2:
 o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng 
suggested.
 o add mark_page_accessed () before release page to delay VM reclaiming them.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/segment.c |  108 -
 fs/f2fs/segment.h |2 +
 2 files changed, 84 insertions(+), 26 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8149eba..52c88de 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -14,6 +14,7 @@
 #include linux/blkdev.h
 #include linux/prefetch.h
 #include linux/vmalloc.h
+#include linux/swap.h
 
 #include f2fs.h
 #include segment.h
@@ -1488,41 +1489,96 @@ static int build_curseg(struct f2fs_sb_info *sbi)
return restore_curseg_summaries(sbi);
 }
 
+static int ra_sit_pages(struct f2fs_sb_info *sbi, int start,
+   int nrpages, bool *is_order)
+{
+   struct address_space *mapping = sbi-meta_inode-i_mapping;
+   struct sit_info *sit_i = SIT_I(sbi);
+   struct page *page;
+   block_t blk_addr;
+   int blkno = start, readcnt = 0;
+   int sit_blk_cnt = SIT_BLK_CNT(sbi);
+
+   for (; blkno  start + nrpages  blkno  sit_blk_cnt; blkno++) {
+
+   if ((!f2fs_test_bit(blkno, sit_i-sit_bitmap) ^ !*is_order)) {
+   *is_order = !*is_order;
+   break;
+   }
+
+   blk_addr = sit_i-sit_base_addr + blkno;
+   if (*is_order)
+   blk_addr += sit_i-sit_blocks;
+repeat:
+   page = grab_cache_page(mapping, blk_addr);
+   if (!page) {
+   cond_resched();
+   goto repeat;
+   }
+   if (PageUptodate(page)) {
+   mark_page_accessed(page);
+   f2fs_put_page(page, 1);
+   readcnt++;
+   continue;
+   }
+
+   submit_read_page(sbi, page, blk_addr, READ_SYNC);
+
+   mark_page_accessed(page);
+   f2fs_put_page(page, 0);
+   readcnt++;
+   }
+
+   f2fs_submit_read_bio(sbi, READ_SYNC);
+   return readcnt;
+}
+
 static void build_sit_entries(struct f2fs_sb_info *sbi)
 {
struct sit_info *sit_i = SIT_I(sbi);
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
struct f2fs_summary_block *sum = curseg-sum_blk;
-   unsigned int start;
-
-   for (start = 0; start  TOTAL_SEGS(sbi); start++) {
-   struct seg_entry *se = sit_i-sentries[start];
-   struct f2fs_sit_block *sit_blk;
-   struct f2fs_sit_entry sit;
-   struct page *page;
-   int i;
+   bool is_order = f2fs_test_bit(0, sit_i-sit_bitmap) ? true : false;
+   int sit_blk_cnt = SIT_BLK_CNT(sbi);
+   unsigned int i, start, end;
+   unsigned int readed, start_blk = 0;
 
-   mutex_lock(curseg-curseg_mutex);
-   for (i = 0; i  sits_in_cursum(sum); i++) {
-   if (le32_to_cpu(segno_in_journal(sum, i)) == start) {
-   sit = sit_in_journal(sum, i);
-   mutex_unlock(curseg-curseg_mutex);
-   goto got_it;
+   do {
+   readed = ra_sit_pages(sbi, start_blk, sit_blk_cnt, is_order);
+
+   start = start_blk * sit_i-sents_per_block;
+   end = (start_blk + readed) * sit_i-sents_per_block;
+
+   for (; start  end  start  TOTAL_SEGS(sbi); start++) {
+   struct seg_entry *se = sit_i-sentries[start];
+   struct f2fs_sit_block *sit_blk;
+   struct f2fs_sit_entry sit;
+   struct page *page;
+
+   mutex_lock(curseg-curseg_mutex);
+   for (i = 0; i  sits_in_cursum(sum); i++) {
+   if (le32_to_cpu(segno_in_journal(sum, i)) == 
start) {
+   sit = sit_in_journal(sum, i);
+   mutex_unlock(curseg-curseg_mutex);
+   goto got_it;
+   }
}
-   }
-   mutex_unlock(curseg-curseg_mutex);
-   page = get_current_sit_page(sbi, start);
-   sit_blk = (struct f2fs_sit_block *)page_address(page);
-   sit = sit_blk-entries[SIT_ENTRY_OFFSET(sit_i, start)];
-   f2fs_put_page(page, 1);
+   mutex_unlock(curseg-curseg_mutex);
+
+   page = get_current_sit_page(sbi, start);
+   sit_blk = (struct

[f2fs-dev] [PATCH V2 1/2 RESEND] f2fs: add a new function to support for merging contiguous read

2013-11-19 Thread Chao Yu
For better read performance, we add a new function to support for merging 
contiguous read as the one for write.

v1--v2:
 o add declarations here as Gu Zheng suggested.
 o use new structure f2fs_bio_info introduced by Jaegeuk Kim.

Signed-off-by: Chao Yu chao2...@samsung.com
Acked-by: Gu Zheng guz.f...@cn.fujitsu.com
---
 fs/f2fs/data.c  |   50 ++
 fs/f2fs/f2fs.h  |3 +++
 fs/f2fs/super.c |1 +
 3 files changed, 54 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b4e4c7e..9cf3f6c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -400,6 +400,56 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct page 
*page,
return 0;
 }
 
+void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, int rw)
+{
+   struct f2fs_bio_info *io = sbi-read_io;
+
+   if (!io-bio)
+   return;
+
+   mutex_lock(io-io_mutex);
+   if (io-bio) {
+   submit_bio(rw, io-bio);
+   io-bio = NULL;
+   }
+   mutex_unlock(io-io_mutex);
+}
+
+void submit_read_page(struct f2fs_sb_info *sbi, struct page *page,
+   block_t blk_addr, int rw)
+{
+   struct block_device *bdev = sbi-sb-s_bdev;
+   struct f2fs_bio_info *io = sbi-read_io;
+   int bio_blocks;
+
+   verify_block_addr(sbi, blk_addr);
+
+   mutex_lock(io-io_mutex);
+
+   if (io-bio  io-last_block_in_bio != blk_addr - 1) {
+   submit_bio(rw, io-bio);
+   io-bio = NULL;
+   }
+alloc_new:
+   if (io-bio == NULL) {
+   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   io-bio = f2fs_bio_alloc(bdev, bio_blocks);
+   io-bio-bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
+   io-bio-bi_end_io = read_end_io;
+   }
+
+   if (bio_add_page(io-bio, page, PAGE_CACHE_SIZE, 0) 
+   PAGE_CACHE_SIZE) {
+   submit_bio(rw, io-bio);
+   io-bio = NULL;
+   goto alloc_new;
+   }
+
+   io-last_block_in_bio = blk_addr;
+
+   mutex_unlock(io-io_mutex);
+}
+
 /*
  * This function should be used by the data read flow only where it
  * does not check the create flag that indicates block allocation.
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a54fac2..e2cb920 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -368,6 +368,7 @@ struct f2fs_sb_info {
struct f2fs_sm_info *sm_info;   /* segment manager */
 
/* for bio operations */
+   struct f2fs_bio_info read_io;   /* for read bios */
struct f2fs_bio_info write_io[NR_PAGE_TYPE];/* for write bios */
 
/* for checkpoint */
@@ -1118,6 +1119,8 @@ struct page *find_data_page(struct inode *, pgoff_t, 
bool);
 struct page *get_lock_data_page(struct inode *, pgoff_t);
 struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
 int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
+void f2fs_submit_read_bio(struct f2fs_sb_info *, int);
+void submit_read_page(struct f2fs_sb_info *, struct page *, block_t, int);
 int do_write_data_page(struct page *);
 
 /*
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 344fb86..6d78fff 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -876,6 +876,7 @@ static int f2fs_fill_super(struct super_block *sb, void 
*data, int silent)
sbi-por_doing = false;
spin_lock_init(sbi-stat_lock);
 
+   mutex_init(sbi-read_io.io_mutex);
for (i = 0; i  NR_PAGE_TYPE; i++)
mutex_init(sbi-write_io[i].io_mutex);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2 1/2 RESEND] f2fs: add a new function to support for merging contiguous read

2013-11-19 Thread Chao Yu
Hi Kim,

No considering 80 columns for the description, :(
I will resend the patches.

 -Original Message-
 From: Chao Yu [mailto:chao2...@samsung.com]
 Sent: Wednesday, November 20, 2013 1:55 PM
 To: ??? (jaegeuk@samsung.com)
 Cc: 'linux-fsde...@vger.kernel.org'; 'linux-kernel@vger.kernel.org'; 
 'linux-f2fs-de...@lists.sourceforge.net'; 谭姝
 (shu@samsung.com)
 Subject: [f2fs-dev] [PATCH V2 1/2 RESEND] f2fs: add a new function to support 
 for merging contiguous read
 
 For better read performance, we add a new function to support for merging 
 contiguous read as the one for write.
 
 v1--v2:
  o add declarations here as Gu Zheng suggested.
  o use new structure f2fs_bio_info introduced by Jaegeuk Kim.
 
 Signed-off-by: Chao Yu chao2...@samsung.com
 Acked-by: Gu Zheng guz.f...@cn.fujitsu.com
 ---
  fs/f2fs/data.c  |   50 ++
  fs/f2fs/f2fs.h  |3 +++
  fs/f2fs/super.c |1 +
  3 files changed, 54 insertions(+)
 
 diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
 index b4e4c7e..9cf3f6c 100644
 --- a/fs/f2fs/data.c
 +++ b/fs/f2fs/data.c
 @@ -400,6 +400,56 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct page 
 *page,
   return 0;
  }
 
 +void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, int rw)
 +{
 + struct f2fs_bio_info *io = sbi-read_io;
 +
 + if (!io-bio)
 + return;
 +
 + mutex_lock(io-io_mutex);
 + if (io-bio) {
 + submit_bio(rw, io-bio);
 + io-bio = NULL;
 + }
 + mutex_unlock(io-io_mutex);
 +}
 +
 +void submit_read_page(struct f2fs_sb_info *sbi, struct page *page,
 + block_t blk_addr, int rw)
 +{
 + struct block_device *bdev = sbi-sb-s_bdev;
 + struct f2fs_bio_info *io = sbi-read_io;
 + int bio_blocks;
 +
 + verify_block_addr(sbi, blk_addr);
 +
 + mutex_lock(io-io_mutex);
 +
 + if (io-bio  io-last_block_in_bio != blk_addr - 1) {
 + submit_bio(rw, io-bio);
 + io-bio = NULL;
 + }
 +alloc_new:
 + if (io-bio == NULL) {
 + bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
 + io-bio = f2fs_bio_alloc(bdev, bio_blocks);
 + io-bio-bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
 + io-bio-bi_end_io = read_end_io;
 + }
 +
 + if (bio_add_page(io-bio, page, PAGE_CACHE_SIZE, 0) 
 + PAGE_CACHE_SIZE) {
 + submit_bio(rw, io-bio);
 + io-bio = NULL;
 + goto alloc_new;
 + }
 +
 + io-last_block_in_bio = blk_addr;
 +
 + mutex_unlock(io-io_mutex);
 +}
 +
  /*
   * This function should be used by the data read flow only where it
   * does not check the create flag that indicates block allocation.
 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
 index a54fac2..e2cb920 100644
 --- a/fs/f2fs/f2fs.h
 +++ b/fs/f2fs/f2fs.h
 @@ -368,6 +368,7 @@ struct f2fs_sb_info {
   struct f2fs_sm_info *sm_info;   /* segment manager */
 
   /* for bio operations */
 + struct f2fs_bio_info read_io;   /* for read bios */
   struct f2fs_bio_info write_io[NR_PAGE_TYPE];/* for write bios */
 
   /* for checkpoint */
 @@ -1118,6 +1119,8 @@ struct page *find_data_page(struct inode *, pgoff_t, 
 bool);
  struct page *get_lock_data_page(struct inode *, pgoff_t);
  struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
  int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
 +void f2fs_submit_read_bio(struct f2fs_sb_info *, int);
 +void submit_read_page(struct f2fs_sb_info *, struct page *, block_t, int);
  int do_write_data_page(struct page *);
 
  /*
 diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
 index 344fb86..6d78fff 100644
 --- a/fs/f2fs/super.c
 +++ b/fs/f2fs/super.c
 @@ -876,6 +876,7 @@ static int f2fs_fill_super(struct super_block *sb, void 
 *data, int silent)
   sbi-por_doing = false;
   spin_lock_init(sbi-stat_lock);
 
 + mutex_init(sbi-read_io.io_mutex);
   for (i = 0; i  NR_PAGE_TYPE; i++)
   mutex_init(sbi-write_io[i].io_mutex);
 
 --
 1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH V2 1/2 RESEND] f2fs: add a new function to support for merging contiguous read

2013-11-19 Thread Chao Yu
For better read performance, we add a new function to support for merging 
contiguous read as the one for write.

v1--v2:
 o add declarations here as Gu Zheng suggested.
 o use new structure f2fs_bio_info introduced by Jaegeuk Kim.

Signed-off-by: Chao Yu chao2...@samsung.com
Acked-by: Gu Zheng guz.f...@cn.fujitsu.com
---
 fs/f2fs/data.c  |   50 ++
 fs/f2fs/f2fs.h  |3 +++
 fs/f2fs/super.c |1 +
 3 files changed, 54 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b4e4c7e..9cf3f6c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -400,6 +400,56 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct page 
*page,
return 0;
 }
 
+void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, int rw)
+{
+   struct f2fs_bio_info *io = sbi-read_io;
+
+   if (!io-bio)
+   return;
+
+   mutex_lock(io-io_mutex);
+   if (io-bio) {
+   submit_bio(rw, io-bio);
+   io-bio = NULL;
+   }
+   mutex_unlock(io-io_mutex);
+}
+
+void submit_read_page(struct f2fs_sb_info *sbi, struct page *page,
+   block_t blk_addr, int rw)
+{
+   struct block_device *bdev = sbi-sb-s_bdev;
+   struct f2fs_bio_info *io = sbi-read_io;
+   int bio_blocks;
+
+   verify_block_addr(sbi, blk_addr);
+
+   mutex_lock(io-io_mutex);
+
+   if (io-bio  io-last_block_in_bio != blk_addr - 1) {
+   submit_bio(rw, io-bio);
+   io-bio = NULL;
+   }
+alloc_new:
+   if (io-bio == NULL) {
+   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   io-bio = f2fs_bio_alloc(bdev, bio_blocks);
+   io-bio-bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
+   io-bio-bi_end_io = read_end_io;
+   }
+
+   if (bio_add_page(io-bio, page, PAGE_CACHE_SIZE, 0) 
+   PAGE_CACHE_SIZE) {
+   submit_bio(rw, io-bio);
+   io-bio = NULL;
+   goto alloc_new;
+   }
+
+   io-last_block_in_bio = blk_addr;
+
+   mutex_unlock(io-io_mutex);
+}
+
 /*
  * This function should be used by the data read flow only where it
  * does not check the create flag that indicates block allocation.
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a54fac2..e2cb920 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -368,6 +368,7 @@ struct f2fs_sb_info {
struct f2fs_sm_info *sm_info;   /* segment manager */
 
/* for bio operations */
+   struct f2fs_bio_info read_io;   /* for read bios */
struct f2fs_bio_info write_io[NR_PAGE_TYPE];/* for write bios */
 
/* for checkpoint */
@@ -1118,6 +1119,8 @@ struct page *find_data_page(struct inode *, pgoff_t, 
bool);
 struct page *get_lock_data_page(struct inode *, pgoff_t);
 struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
 int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
+void f2fs_submit_read_bio(struct f2fs_sb_info *, int);
+void submit_read_page(struct f2fs_sb_info *, struct page *, block_t, int);
 int do_write_data_page(struct page *);
 
 /*
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 344fb86..6d78fff 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -876,6 +876,7 @@ static int f2fs_fill_super(struct super_block *sb, void 
*data, int silent)
sbi-por_doing = false;
spin_lock_init(sbi-stat_lock);
 
+   mutex_init(sbi-read_io.io_mutex);
for (i = 0; i  NR_PAGE_TYPE; i++)
mutex_init(sbi-write_io[i].io_mutex);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH V2 2/2 RESEND] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-19 Thread Chao Yu
Previously we read sit entries page one by one, this method lost the chance 
of reading contiguous page together. So we read pages as contiguous as 
possible for better mount performance.

v1--v2:
 o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng 
suggested.
 o add mark_page_accessed() before release page to delay VM reclaiming them.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/segment.c |  108 -
 fs/f2fs/segment.h |2 +
 2 files changed, 84 insertions(+), 26 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8149eba..52c88de 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -14,6 +14,7 @@
 #include linux/blkdev.h
 #include linux/prefetch.h
 #include linux/vmalloc.h
+#include linux/swap.h
 
 #include f2fs.h
 #include segment.h
@@ -1488,41 +1489,96 @@ static int build_curseg(struct f2fs_sb_info *sbi)
return restore_curseg_summaries(sbi);
 }
 
+static int ra_sit_pages(struct f2fs_sb_info *sbi, int start,
+   int nrpages, bool *is_order)
+{
+   struct address_space *mapping = sbi-meta_inode-i_mapping;
+   struct sit_info *sit_i = SIT_I(sbi);
+   struct page *page;
+   block_t blk_addr;
+   int blkno = start, readcnt = 0;
+   int sit_blk_cnt = SIT_BLK_CNT(sbi);
+
+   for (; blkno  start + nrpages  blkno  sit_blk_cnt; blkno++) {
+
+   if ((!f2fs_test_bit(blkno, sit_i-sit_bitmap) ^ !*is_order)) {
+   *is_order = !*is_order;
+   break;
+   }
+
+   blk_addr = sit_i-sit_base_addr + blkno;
+   if (*is_order)
+   blk_addr += sit_i-sit_blocks;
+repeat:
+   page = grab_cache_page(mapping, blk_addr);
+   if (!page) {
+   cond_resched();
+   goto repeat;
+   }
+   if (PageUptodate(page)) {
+   mark_page_accessed(page);
+   f2fs_put_page(page, 1);
+   readcnt++;
+   continue;
+   }
+
+   submit_read_page(sbi, page, blk_addr, READ_SYNC);
+
+   mark_page_accessed(page);
+   f2fs_put_page(page, 0);
+   readcnt++;
+   }
+
+   f2fs_submit_read_bio(sbi, READ_SYNC);
+   return readcnt;
+}
+
 static void build_sit_entries(struct f2fs_sb_info *sbi)
 {
struct sit_info *sit_i = SIT_I(sbi);
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
struct f2fs_summary_block *sum = curseg-sum_blk;
-   unsigned int start;
-
-   for (start = 0; start  TOTAL_SEGS(sbi); start++) {
-   struct seg_entry *se = sit_i-sentries[start];
-   struct f2fs_sit_block *sit_blk;
-   struct f2fs_sit_entry sit;
-   struct page *page;
-   int i;
+   bool is_order = f2fs_test_bit(0, sit_i-sit_bitmap) ? true : false;
+   int sit_blk_cnt = SIT_BLK_CNT(sbi);
+   unsigned int i, start, end;
+   unsigned int readed, start_blk = 0;
 
-   mutex_lock(curseg-curseg_mutex);
-   for (i = 0; i  sits_in_cursum(sum); i++) {
-   if (le32_to_cpu(segno_in_journal(sum, i)) == start) {
-   sit = sit_in_journal(sum, i);
-   mutex_unlock(curseg-curseg_mutex);
-   goto got_it;
+   do {
+   readed = ra_sit_pages(sbi, start_blk, sit_blk_cnt, is_order);
+
+   start = start_blk * sit_i-sents_per_block;
+   end = (start_blk + readed) * sit_i-sents_per_block;
+
+   for (; start  end  start  TOTAL_SEGS(sbi); start++) {
+   struct seg_entry *se = sit_i-sentries[start];
+   struct f2fs_sit_block *sit_blk;
+   struct f2fs_sit_entry sit;
+   struct page *page;
+
+   mutex_lock(curseg-curseg_mutex);
+   for (i = 0; i  sits_in_cursum(sum); i++) {
+   if (le32_to_cpu(segno_in_journal(sum, i)) == 
start) {
+   sit = sit_in_journal(sum, i);
+   mutex_unlock(curseg-curseg_mutex);
+   goto got_it;
+   }
}
-   }
-   mutex_unlock(curseg-curseg_mutex);
-   page = get_current_sit_page(sbi, start);
-   sit_blk = (struct f2fs_sit_block *)page_address(page);
-   sit = sit_blk-entries[SIT_ENTRY_OFFSET(sit_i, start)];
-   f2fs_put_page(page, 1);
+   mutex_unlock(curseg-curseg_mutex);
+
+   page = get_current_sit_page(sbi, start);
+   sit_blk = (struct

[f2fs-dev] [PATCH 2/2] f2fs: adds a tracepoint for f2fs_submit_read_bio

2013-11-20 Thread Chao Yu
This patch adds a tracepoint for f2fs_submit_read_bio.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/data.c  |2 ++
 include/trace/events/f2fs.h |   27 +++
 2 files changed, 29 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 0ca93be..c9e9d79 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -407,6 +407,8 @@ void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, int rw)
if (!io-bio)
return;
 
+   trace_f2fs_submit_read_bio(sbi-sb, rw, io-bio);
+
mutex_lock(io-io_mutex);
if (io-bio) {
submit_bio(rw, io-bio);
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 571f39a..ac970e3 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -453,6 +453,33 @@ TRACE_EVENT_CONDITION(f2fs_readpage,
show_bio_type(__entry-type))
 );
 
+TRACE_EVENT(f2fs_submit_read_bio,
+
+   TP_PROTO(struct super_block *sb, int rw, struct bio *bio),
+
+   TP_ARGS(sb, rw, bio),
+
+   TP_STRUCT__entry(
+   __field(dev_t,  dev)
+   __field(int,rw)
+   __field(sector_t,   sector)
+   __field(unsigned int,   size)
+   ),
+
+   TP_fast_assign(
+   __entry-dev= sb-s_dev;
+   __entry-rw = rw;
+   __entry-sector = bio-bi_sector;
+   __entry-size   = bio-bi_size;
+   ),
+
+   TP_printk(dev = (%d,%d), bio_type = %s, sector = %lld, size = %u,
+   show_dev(__entry),
+   show_bio_type(__entry-rw),
+   (unsigned long long)__entry-sector,
+   __entry-size)
+);
+
 TRACE_EVENT(f2fs_submit_read_page,
 
TP_PROTO(struct page *page, block_t blk_addr, int rw),
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 1/2] f2fs: adds a tracepoint for submit_read_page

2013-11-20 Thread Chao Yu
This patch adds a tracepoint for submit_read_page.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/data.c  |1 +
 include/trace/events/f2fs.h |   30 ++
 2 files changed, 31 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9cf3f6c..0ca93be 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -448,6 +448,7 @@ alloc_new:
io-last_block_in_bio = blk_addr;
 
mutex_unlock(io-io_mutex);
+   trace_f2fs_submit_read_page(page, blk_addr, rw);
 }
 
 /*
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index e0dc355..571f39a 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -453,6 +453,36 @@ TRACE_EVENT_CONDITION(f2fs_readpage,
show_bio_type(__entry-type))
 );
 
+TRACE_EVENT(f2fs_submit_read_page,
+
+   TP_PROTO(struct page *page, block_t blk_addr, int rw),
+
+   TP_ARGS(page, blk_addr, rw),
+
+   TP_STRUCT__entry(
+   __field(dev_t,  dev)
+   __field(ino_t,  ino)
+   __field(int, rw)
+   __field(pgoff_t, index)
+   __field(block_t, block)
+   ),
+
+   TP_fast_assign(
+   __entry-dev= page-mapping-host-i_sb-s_dev;
+   __entry-ino= page-mapping-host-i_ino;
+   __entry-rw = rw;
+   __entry-index  = page-index;
+   __entry-block  = blk_addr;
+   ),
+
+   TP_printk(dev = (%d,%d), ino = %lu, bio_type = %s, 
+   index = %lu, blkaddr = 0x%llx,
+   show_dev_ino(__entry),
+   show_bio_type(__entry-rw),
+   (unsigned long)__entry-index,
+   (unsigned long long)__entry-block)
+);
+
 TRACE_EVENT(f2fs_get_data_block,
TP_PROTO(struct inode *inode, sector_t iblock,
struct buffer_head *bh, int ret),
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2 2/2 RESEND] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-20 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Thursday, November 21, 2013 9:32 AM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH V2 2/2 RESEND] f2fs: read contiguous sit entry 
 pages by merging for mount performance
 
 Hi,
 
 It seems that ra_sit_pages() is too tightly coupled with
 build_sit_entries().

This code could be improved.

 Is there another way not to use *is_order?

Previously the code is like this:
 -build_sit_entries()
 next_setp:
for(start = 0; start  TOTAL_SEGS(sbi); start++)
/*step#1 readahead all sit entries blocks*/
if(start % SIT_ENTRY_PER_BLOCK == 0) {
blk_addr = current_sit_addr(sbi, start);
/* grab and submit_read_page */
}
if(start == TOTAL_SEGS(sbi) - 1)
f2fs_submit_read_bio();
continue;
/*step#2 fill sit entries info*/
/*step#3 cover sit entries with journal*/

But I think its weakness is that it will cost lots of memory to read 
ahead all sit entry pages when f2fs mount, and also it's serious waste 
that we read them again after these pages are released by VM when 
out of memory.

 
 The ra_sit_pages() tries to read consecutive sit pages as many as
 possible.
 So then, what about just checking whether its block address is
 contiguous or not?
 
 Something like this:
  -ra_sit_pages()
   blkno = start;
   while (blkno  sit_i-sit_blocks) {
   blk_addr = current_sit_addr(sbi, blkno);
   if (blkno != start  prev_blk_addr + 1 != blk_addr)
   break;
 
   /* grab and submit_read_page */
 
   prev_blk_addr = blk_addr;
   blkno++;
   }

Agreed, this method could remove *order.
Shouldn't we add nrpages for readahead policy as VM?

 
 Thanks,
 
 2013-11-20 (수), 14:47 +0800, Chao Yu:
  Previously we read sit entries page one by one, this method lost the chance
  of reading contiguous page together. So we read pages as contiguous as
  possible for better mount performance.
 
  v1--v2:
   o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng
  suggested.
   o add mark_page_accessed() before release page to delay VM reclaiming them.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/segment.c |  108 
  -
   fs/f2fs/segment.h |2 +
   2 files changed, 84 insertions(+), 26 deletions(-)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
  index 8149eba..52c88de 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -14,6 +14,7 @@
   #include linux/blkdev.h
   #include linux/prefetch.h
   #include linux/vmalloc.h
  +#include linux/swap.h
 
   #include f2fs.h
   #include segment.h
  @@ -1488,41 +1489,96 @@ static int build_curseg(struct f2fs_sb_info *sbi)
  return restore_curseg_summaries(sbi);
   }
 
  +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start,
  +   int nrpages, bool *is_order)
 
 Why do you use nrpages?

nrpages point out expectation of caller, caller cloud control how many 
pages want to read this time. It solves the weakness of previous coed I 
give above.

 
  +{
  +   struct address_space *mapping = sbi-meta_inode-i_mapping;
  +   struct sit_info *sit_i = SIT_I(sbi);
  +   struct page *page;
  +   block_t blk_addr;
  +   int blkno = start, readcnt = 0;
  +   int sit_blk_cnt = SIT_BLK_CNT(sbi);
  +
  +   for (; blkno  start + nrpages  blkno  sit_blk_cnt; blkno++) {
  +
  +   if ((!f2fs_test_bit(blkno, sit_i-sit_bitmap) ^ !*is_order)) {
  +   *is_order = !*is_order;
  +   break;
  +   }
  +
  +   blk_addr = sit_i-sit_base_addr + blkno;
  +   if (*is_order)
  +   blk_addr += sit_i-sit_blocks;
  +repeat:
  +   page = grab_cache_page(mapping, blk_addr);
  +   if (!page) {
  +   cond_resched();
  +   goto repeat;
  +   }
  +   if (PageUptodate(page)) {
  +   mark_page_accessed(page);
  +   f2fs_put_page(page, 1);
  +   readcnt++;
  +   continue;
  +   }
  +
  +   submit_read_page(sbi, page, blk_addr, READ_SYNC);
  +
  +   mark_page_accessed(page);
  +   f2fs_put_page(page, 0);
  +   readcnt++;
  +   }
  +
  +   f2fs_submit_read_bio(sbi, READ_SYNC);
  +   return readcnt;
  +}
  +
   static void build_sit_entries(struct f2fs_sb_info *sbi)
   {
  struct sit_info *sit_i = SIT_I(sbi);
  struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
  struct f2fs_summary_block *sum = curseg-sum_blk

RE: [f2fs-dev] [PATCH V2 2/2] f2fs: read contiguous sit entry pages by merging for mount performance

2013-11-20 Thread Chao Yu
Hi Gu,

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Wednesday, November 20, 2013 5:38 PM
 To: Chao Yu
 Cc: '???'; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; '谭姝'
 Subject: Re: [f2fs-dev] [PATCH V2 2/2] f2fs: read contiguous sit entry pages 
 by merging for mount performance
 
 Hi Yu,
 On 11/20/2013 01:37 PM, Chao Yu wrote:
 
  Hi Gu,
 
  -Original Message-
  From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
  Sent: Monday, November 18, 2013 7:16 PM
  To: Chao Yu
  Cc: '???'; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
  linux-f2fs-de...@lists.sourceforge.net; 谭
姝
  Subject: Re: [f2fs-dev] [PATCH V2 2/2] f2fs: read contiguous sit entry 
  pages by merging for mount performance
 
  Hi Yu,
  One more comment, please refer to inline.
  On 11/16/2013 02:15 PM, Chao Yu wrote:
 
  Previously we read sit entries page one by one, this method lost the 
  chance of reading contiguous page together.
  So we read pages as contiguous as possible for better mount performance.
 
  v1--v2:
   o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu 
  Zheng suggested.
   o add mark_page_accessed () before release page to delay VM reclaiming 
  them.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/segment.c |  108 
  -
   fs/f2fs/segment.h |2 +
   2 files changed, 84 insertions(+), 26 deletions(-)
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
  index fa284d3..656fe40 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -14,6 +14,7 @@
   #include linux/blkdev.h
   #include linux/prefetch.h
   #include linux/vmalloc.h
  +#include linux/swap.h
 
   #include f2fs.h
   #include segment.h
  @@ -1480,41 +1481,96 @@ static int build_curseg(struct f2fs_sb_info *sbi)
return restore_curseg_summaries(sbi);
   }
 
  +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start,
  + int nrpages, bool *is_order)
  +{
  + struct address_space *mapping = sbi-meta_inode-i_mapping;
  + struct sit_info *sit_i = SIT_I(sbi);
  + struct page *page;
  + block_t blk_addr;
  + int blkno = start, readcnt = 0;
  + int sit_blk_cnt = SIT_BLK_CNT(sbi);
  +
  + for (; blkno  start + nrpages  blkno  sit_blk_cnt; blkno++) {
  +
  + if ((!f2fs_test_bit(blkno, sit_i-sit_bitmap) ^ !*is_order)) {
  + *is_order = !*is_order;
  + break;
  + }
  +
  + blk_addr = sit_i-sit_base_addr + blkno;
  + if (*is_order)
  + blk_addr += sit_i-sit_blocks;
  +repeat:
  + page = grab_cache_page(mapping, blk_addr);
  + if (!page) {
  + cond_resched();
  + goto repeat;
  + }
  + if (PageUptodate(page)) {
  + mark_page_accessed(page);
  + f2fs_put_page(page, 1);
  + readcnt++;
  + continue;
  + }
  +
  + submit_read_page(sbi, page, blk_addr, READ_SYNC);
  +
  + mark_page_accessed(page);
  + f2fs_put_page(page, 0);
  + readcnt++;
  + }
  +
  + f2fs_submit_read_bio(sbi, READ_SYNC);
  + return readcnt;
  +}
  +
   static void build_sit_entries(struct f2fs_sb_info *sbi)
   {
struct sit_info *sit_i = SIT_I(sbi);
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
struct f2fs_summary_block *sum = curseg-sum_blk;
  - unsigned int start;
  -
  - for (start = 0; start  TOTAL_SEGS(sbi); start++) {
  - struct seg_entry *se = sit_i-sentries[start];
  - struct f2fs_sit_block *sit_blk;
  - struct f2fs_sit_entry sit;
  - struct page *page;
  - int i;
  + bool is_order = f2fs_test_bit(0, sit_i-sit_bitmap) ? true : false;
  + int sit_blk_cnt = SIT_BLK_CNT(sbi);
  + unsigned int i, start, end;
  + unsigned int readed, start_blk = 0;
 
  - mutex_lock(curseg-curseg_mutex);
  - for (i = 0; i  sits_in_cursum(sum); i++) {
  - if (le32_to_cpu(segno_in_journal(sum, i)) == start) {
  - sit = sit_in_journal(sum, i);
  - mutex_unlock(curseg-curseg_mutex);
  - goto got_it;
  + do {
 
  How about using find_next_bit to get the suitable start_blk if the next blk
  is not ordered here? And it also can simplify the logic of ra_sit_pages().
 
  That's a good idea.
  But I thought there maybe endianness problem between test_bit and
  f2fs_test_bit, so find_next_bit may get wrong result. Am I right?
 
 IMO, find_next_bit can do well with endianness issue internally, if
 it's not so, that may be a weakness.

Right, I mean that if we want to set first position in bitmap, 
we cloud use f2fs_set_bit(0, bitmap) or set_bit(7, bitmap).
Two types of interface could not be used mixedly.

So could we use {set,test,clear}_bit intead of f2fs_{set,test,clear}_bit

RE: [f2fs-dev] [PATCH 0/2] f2fs: remove debufs dir if debugfs_create_file() failed

2013-12-02 Thread Chao Yu
Hi Liu,

You're right, we should release it instead of holding the resource
with no use. And here are some comments as following.

BTW, your patch is out of format. You'd better not let remote
terminal or editor to instead tab with blanks in the patch.

Thanks,
Yu

 -Original Message-
 From: Younger Liu [mailto:younger.li...@gmail.com]
 Sent: Monday, December 02, 2013 9:16 PM
 To: Jaegeuk Kim
 Cc: fs-devel; kernel; f2fs
 Subject: [f2fs-dev] [PATCH 0/2] f2fs: remove debufs dir if 
 debugfs_create_file() failed
 
 From: Younger Liu liuyiy...@hisense.com
 
 When debugfs_create_file() failed in f2fs_create_root_stats(),
 debugfs_root should be removed.
 
 Signed-off-by: Younger Liu liuyiy...@hisense.com
 Cc: Younger Liu younger.li...@gmail.com
 Cc: Jaegeuk Kim jaegeuk@samsung.com
 ---
  fs/f2fs/debug.c |   20 +---
  1 file changed, 17 insertions(+), 3 deletions(-)
 
 diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
 index a84b0a8..d27b689 100644
 --- a/fs/f2fs/debug.c
 +++ b/fs/f2fs/debug.c
 @@ -340,10 +340,24 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
 
  void __init f2fs_create_root_stats(void)
  {
 +struct dentry *file;
 +
  debugfs_root = debugfs_create_dir(f2fs, NULL);
 -if (debugfs_root)
 -debugfs_create_file(status, S_IRUGO, debugfs_root,
 - NULL, stat_fops);
 +if (!debugfs_root)
 +goto bail;
 +
 +file = debugfs_create_file(status, S_IRUGO,
 +debugfs_root, NULL, stat_fops);
 +if (!file)
 +goto free_debugfs_dir;
 +
 +return;
 +
 +free_debugfs_dir:
 +debugfs_remove(debugfs_root);

debugfs_root = NULL;

 +
 +bail:
 +return;
  }
 
  void f2fs_destroy_root_stats(void)

You should judge debugfs_root value in f2fs_destroy_root_stats
to decide free or not.

 --
 1.7.9.5
 
 
 
 --
 Rapidly troubleshoot problems before they affect your business. Most IT
 organizations don't have a clear picture of how application performance
 affects their revenue. With AppDynamics, you get 100% visibility into your
 Java,.NET,  PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
 http://pubads.g.doubleclick.net/gampad/clk?id=84349351iu=/4140/ostg.clktrk
 ___
 Linux-f2fs-devel mailing list
 linux-f2fs-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH v2] f2fs: refactor bio-related operations

2013-12-03 Thread Chao Yu
Hi,

Comment as following.

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Monday, December 02, 2013 4:27 PM
 To: linux-fsde...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org; linux-f2fs-de...@lists.sourceforge.net
 Subject: Re: [f2fs-dev] [PATCH v2] f2fs: refactor bio-related operations
 
 Change log from v1:
  o remove redundant codes
 
 From a480dfc915490f4bca7275f6fbb44fa34aa00eaa Mon Sep 17 00:00:00 2001
 From: Jaegeuk Kim jaegeuk@samsung.com
 Date: Sat, 30 Nov 2013 12:51:14 +0900
 Subject: [PATCH] f2fs: refactor bio-related operations
 Cc: linux-fsde...@vger.kernel.org, linux-kernel@vger.kernel.org, 
 linux-f2fs-de...@lists.sourceforge.net
 
 This patch integrates redundant bio operations on read and write IOs.
 
 1. Move bio-related codes to the top of data.c.
 2. Replace f2fs_submit_bio with f2fs_submit_merged_bio, which handles read
bios additionally.
 3. Introduce __submit_merged_bio to submit the merged bio.
 4. Change f2fs_readpage to f2fs_submit_page_bio.
 5. Introduce f2fs_submit_page_mbio to integrate previous submit_read_page and
submit_write_page.

[snip]

 +static void __submit_merged_bio(struct f2fs_sb_info *sbi,
 + struct f2fs_bio_info *io,
 + enum page_type type, bool sync, int rw)
 +{
 + enum page_type btype = PAGE_TYPE_OF_BIO(type);
 +
 + if (!io-bio)
 + return;
 +
 + if (btype == META)
 + rw |= REQ_META;
 +
 + if (is_read_io(rw)) {
 + if (sync)
 + rw |= READ_SYNC;
 + submit_bio(rw, io-bio);
 + trace_f2fs_submit_read_bio(sbi-sb, rw, type, io-bio);
 + io-bio = NULL;
 + return;
 + }
 +
 + if (sync)
 + rw |= WRITE_SYNC;

rw = WRITE_SYNC; ?

 + if (type = META_FLUSH)
 + rw |= WRITE_FLUSH_FUA;

rw = WRITE_FLUSH_FUA; ?

 +
 + /*
 +  * META_FLUSH is only from the checkpoint procedure, and we should wait
 +  * this metadata bio for FS consistency.
 +  */
 + if (type == META_FLUSH) {
 + DECLARE_COMPLETION_ONSTACK(wait);
 + io-bio-bi_private = wait;
 + submit_bio(rw, io-bio);
 + wait_for_completion(wait);
 + } else {
 + submit_bio(rw, io-bio);
 + }
 + trace_f2fs_submit_write_bio(sbi-sb, rw, btype, io-bio);
 + io-bio = NULL;
 +}

[snip]

Thanks,
Yu

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH v2] f2fs: refactor bio-related operations

2013-12-04 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Wednesday, December 04, 2013 4:11 PM
 To: Chao Yu
 Cc: linux-kernel@vger.kernel.org; linux-f2fs-de...@lists.sourceforge.net; 
 linux-fsde...@vger.kernel.org; 谭姝
 Subject: RE: [f2fs-dev] [PATCH v2] f2fs: refactor bio-related operations
 
 Hi,
 
   + if (btype == META)
   + rw |= REQ_META;
   +
   + if (is_read_io(rw)) {
   + if (sync)
   + rw |= READ_SYNC;
   + submit_bio(rw, io-bio);
   + trace_f2fs_submit_read_bio(sbi-sb, rw, type, io-bio);
   + io-bio = NULL;
   + return;
   + }
   +
   + if (sync)
   + rw |= WRITE_SYNC;
 
  rw = WRITE_SYNC; ?
 
 No, since it removes the REQ_META.
 See above.

Ah, you're right, Thanks.

 
 
   + if (type = META_FLUSH)
   + rw |= WRITE_FLUSH_FUA;
 
  rw = WRITE_FLUSH_FUA; ?
 
   +
   + /*
   +  * META_FLUSH is only from the checkpoint procedure, and we should wait
   +  * this metadata bio for FS consistency.
   +  */
   + if (type == META_FLUSH) {
   + DECLARE_COMPLETION_ONSTACK(wait);
   + io-bio-bi_private = wait;
   + submit_bio(rw, io-bio);
   + wait_for_completion(wait);
   + } else {
   + submit_bio(rw, io-bio);
   + }
   + trace_f2fs_submit_write_bio(sbi-sb, rw, btype, io-bio);
   + io-bio = NULL;
   +}
 
  [snip]
 
  Thanks,
  Yu
 
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 1/3] f2fs: use inner macro GFP_F2FS_ZERO for simplification

2013-12-04 Thread Chao Yu
Use inner macro GFP_F2FS_ZERO to instead of GFP_NOFS | __GFP_ZERO for
simplification of code.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/node.c |2 +-
 fs/f2fs/recovery.c |2 +-
 fs/f2fs/super.c|2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 0855168..099f06f 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1577,7 +1577,7 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct 
list_head *pages,
 
for (; page_idx  start + nrpages; page_idx++) {
/* alloc temporal page for read node summary info*/
-   page = alloc_page(GFP_NOFS | __GFP_ZERO);
+   page = alloc_page(GFP_F2FS_ZERO);
if (!page) {
struct page *tmp;
list_for_each_entry_safe(page, tmp, pages, lru) {
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index c209b86..7dda1f28 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -377,7 +377,7 @@ static int recover_data(struct f2fs_sb_info *sbi,
blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);
 
/* read node page */
-   page = alloc_page(GFP_NOFS | __GFP_ZERO);
+   page = alloc_page(GFP_F2FS_ZERO);
if (!page)
return -ENOMEM;
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index dd55074..22b07c3 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -332,7 +332,7 @@ static struct inode *f2fs_alloc_inode(struct super_block 
*sb)
 {
struct f2fs_inode_info *fi;
 
-   fi = kmem_cache_alloc(f2fs_inode_cachep, GFP_NOFS | __GFP_ZERO);
+   fi = kmem_cache_alloc(f2fs_inode_cachep, GFP_F2FS_ZERO);
if (!fi)
return NULL;
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache

2013-12-04 Thread Chao Yu
This patch introduces f2fs_cache_node_page(), in this function, page which is
readed ahead will be copy to node_inode's mapping cache.
It will avoid rereading these node pages.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/node.c |   30 ++
 1 file changed, 30 insertions(+)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 099f06f..5e2588f 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1600,6 +1600,34 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct 
list_head *pages,
return 0;
 }
 
+/*
+ * f2fs_cache_node_page() copy updated page data to node_inode cache page.
+ */
+void f2fs_cache_node_page(struct f2fs_sb_info *sbi, struct page *page,
+   nid_t nid)
+{
+   struct address_space *mapping = sbi-node_inode-i_mapping;
+   struct page *npage;
+
+   npage = find_get_page(mapping, nid);
+   if (npage  PageUptodate(npage)) {
+   f2fs_put_page(npage, 0);
+   return;
+   }
+   f2fs_put_page(npage, 0);
+
+   npage = grab_cache_page(mapping, nid);
+   if (!npage)
+   return;
+
+   memcpy(page_address(npage), page_address(page), PAGE_CACHE_SIZE);
+
+   SetPageUptodate(npage);
+   f2fs_put_page(npage, 1);
+
+   return;
+}
+
 int restore_node_summary(struct f2fs_sb_info *sbi,
unsigned int segno, struct f2fs_summary_block *sum)
 {
@@ -1633,6 +1661,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
sum_entry-version = 0;
sum_entry-ofs_in_node = 0;
sum_entry++;
+   f2fs_cache_node_page(sbi, page,
+   le32_to_cpu(rn-footer.nid));
} else {
err = -EIO;
}
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 2/3] f2fs: avoid unneeded page release for correct _count of page

2013-12-04 Thread Chao Yu
In find_fsync_dnodes() and recover_data(), our flow is like this:

-f2fs_submit_page_bio()
- f2fs_put_page()
- page_cache_release()  page-_count declined to zero.
-__free_pages()
- put_page_testzero()  page-_count will be declined again.

We will get a segment fault in put_page_testzero when CONFIG_DEBUG_VM
is on, or return MM with a bad page with wrong _count num.

So let's just release this page.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/recovery.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 7dda1f28..d075465 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -145,7 +145,7 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, 
struct list_head *head)
 
err = f2fs_submit_page_bio(sbi, page, blkaddr, READ_SYNC);
if (err)
-   goto out;
+   return err;
 
lock_page(page);
 
@@ -191,9 +191,10 @@ next:
/* check next segment */
blkaddr = next_blkaddr_of_node(page);
}
+
unlock_page(page);
-out:
__free_pages(page, 0);
+
return err;
 }
 
@@ -388,7 +389,7 @@ static int recover_data(struct f2fs_sb_info *sbi,
 
err = f2fs_submit_page_bio(sbi, page, blkaddr, READ_SYNC);
if (err)
-   goto out;
+   return err;
 
lock_page(page);
 
@@ -412,8 +413,8 @@ next:
/* check next segment */
blkaddr = next_blkaddr_of_node(page);
}
+
unlock_page(page);
-out:
__free_pages(page, 0);
 
if (!err)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache

2013-12-04 Thread Chao Yu
 -Original Message-
 From: Chao Yu [mailto:chao2...@samsung.com]
 Sent: Thursday, December 05, 2013 9:55 AM
 To: ???
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net
 Subject: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add 
 page into node_inode cache
 
 This patch introduces f2fs_cache_node_page(), in this function, page which is
 readed ahead will be copy to node_inode's mapping cache.
 It will avoid rereading these node pages.
 
 Signed-off-by: Chao Yu chao2...@samsung.com

Suggested-by: Jaegeuk Kim jaegeuk@samsung.com

I miss that, my mistake.

 ---
  fs/f2fs/node.c |   30 ++
  1 file changed, 30 insertions(+)
 
 diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
 index 099f06f..5e2588f 100644
 --- a/fs/f2fs/node.c
 +++ b/fs/f2fs/node.c
 @@ -1600,6 +1600,34 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, 
 struct list_head *pages,
   return 0;
  }
 
 +/*
 + * f2fs_cache_node_page() copy updated page data to node_inode cache page.
 + */
 +void f2fs_cache_node_page(struct f2fs_sb_info *sbi, struct page *page,
 + nid_t nid)
 +{
 + struct address_space *mapping = sbi-node_inode-i_mapping;
 + struct page *npage;
 +
 + npage = find_get_page(mapping, nid);
 + if (npage  PageUptodate(npage)) {
 + f2fs_put_page(npage, 0);
 + return;
 + }
 + f2fs_put_page(npage, 0);
 +
 + npage = grab_cache_page(mapping, nid);
 + if (!npage)
 + return;
 +
 + memcpy(page_address(npage), page_address(page), PAGE_CACHE_SIZE);
 +
 + SetPageUptodate(npage);
 + f2fs_put_page(npage, 1);
 +
 + return;
 +}
 +
  int restore_node_summary(struct f2fs_sb_info *sbi,
   unsigned int segno, struct f2fs_summary_block *sum)
  {
 @@ -1633,6 +1661,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
   sum_entry-version = 0;
   sum_entry-ofs_in_node = 0;
   sum_entry++;
 + f2fs_cache_node_page(sbi, page,
 + le32_to_cpu(rn-footer.nid));
   } else {
   err = -EIO;
   }
 --
 1.7.9.5
 
 
 --
 Sponsored by Intel(R) XDK
 Develop, test and display web and hybrid apps with a single code base.
 Download it for free now!
 http://pubads.g.doubleclick.net/gampad/clk?id=111408631iu=/4140/ostg.clktrk
 ___
 Linux-f2fs-devel mailing list
 linux-f2fs-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 2/5 V2] f2fs: add unlikely() macro for compiler optimization

2013-12-05 Thread Chao Yu
As we know, some of our branch condition will rarely be true. So we could add
'unlikely' to let compiler optimize these code, by this way we could drop
unneeded 'jump' assemble code to improve performance.

change log:
 o add *unlikely* as many as possible across the whole source files at once
   suggested by Jaegeuk Kim.

Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/checkpoint.c |   10 +-
 fs/f2fs/data.c   |4 ++--
 fs/f2fs/dir.c|4 ++--
 fs/f2fs/f2fs.h   |8 
 fs/f2fs/node.c   |   16 
 fs/f2fs/segment.h|2 +-
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 38f4a224..6580808 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -82,8 +82,8 @@ static int f2fs_write_meta_page(struct page *page,
struct f2fs_sb_info *sbi = F2FS_SB(inode-i_sb);
 
/* Should not write any meta pages, if any IO error was occurred */
-   if (wbc-for_reclaim || sbi-por_doing ||
-   is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)) {
+   if (unlikely(wbc-for_reclaim || sbi-por_doing ||
+   is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG))) {
dec_page_count(sbi, F2FS_DIRTY_META);
wbc-pages_skipped++;
set_page_dirty(page);
@@ -137,7 +137,7 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum 
page_type type,
nr_pages = pagevec_lookup_tag(pvec, mapping, index,
PAGECACHE_TAG_DIRTY,
min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
-   if (nr_pages == 0)
+   if (unlikely(nr_pages == 0))
break;
 
for (i = 0; i  nr_pages; i++) {
@@ -150,7 +150,7 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum 
page_type type,
unlock_page(page);
break;
}
-   if (nwritten++ = nr_to_write)
+   if (unlikely(nwritten++ = nr_to_write))
break;
}
pagevec_release(pvec);
@@ -200,7 +200,7 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi)
max_orphans = (sbi-blocks_per_seg - 2 - NR_CURSEG_TYPE)
* F2FS_ORPHANS_PER_BLOCK;
mutex_lock(sbi-orphan_inode_mutex);
-   if (sbi-n_orphans = max_orphans)
+   if (unlikely(sbi-n_orphans = max_orphans))
err = -ENOSPC;
else
sbi-n_orphans++;
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 4e2fc09..2ce5a9e 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -251,7 +251,7 @@ int reserve_new_block(struct dnode_of_data *dn)
 
if (is_inode_flag_set(F2FS_I(dn-inode), FI_NO_ALLOC))
return -EPERM;
-   if (!inc_valid_block_count(sbi, dn-inode, 1))
+   if (unlikely(!inc_valid_block_count(sbi, dn-inode, 1)))
return -ENOSPC;
 
trace_f2fs_reserve_new_block(dn-inode, dn-nid, dn-ofs_in_node);
@@ -711,7 +711,7 @@ static int f2fs_write_data_page(struct page *page,
 
zero_user_segment(page, offset, PAGE_CACHE_SIZE);
 write:
-   if (sbi-por_doing) {
+   if (unlikely(sbi-por_doing)) {
err = AOP_WRITEPAGE_ACTIVATE;
goto redirty_out;
}
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 594fc1b..0cc26ba 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -190,7 +190,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
unsigned int max_depth;
unsigned int level;
 
-   if (namelen  F2FS_NAME_LEN)
+   if (unlikely(namelen  F2FS_NAME_LEN))
return NULL;
 
if (npages == 0)
@@ -461,7 +461,7 @@ int __f2fs_add_link(struct inode *dir, const struct qstr 
*name, struct inode *in
}
 
 start:
-   if (current_depth == MAX_DIR_HASH_DEPTH)
+   if (unlikely(current_depth == MAX_DIR_HASH_DEPTH))
return -ENOSPC;
 
/* Increase the depth, if required */
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 10eca02..dca18b3 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -574,7 +574,7 @@ static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi)
 static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
 {
WARN_ON((nid = NM_I(sbi)-max_nid));
-   if (nid = NM_I(sbi)-max_nid)
+   if (unlikely(nid = NM_I(sbi)-max_nid))
return -EINVAL;
return 0;
 }
@@ -600,7 +600,7 @@ static inline bool inc_valid_block_count(struct 
f2fs_sb_info *sbi,
spin_lock(sbi-stat_lock);
valid_block_count =
sbi-total_valid_block_count + (block_t)count;
-   if (valid_block_count  sbi-user_block_count) {
+   if (unlikely(valid_block_count  sbi-user_block_count

RE: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache

2013-12-05 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Friday, December 06, 2013 9:43 AM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: RE: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to 
 add page into node_inode cache
 
 Hi,
 
 2013-12-05 (목), 10:10 +0800, Chao Yu:
   -Original Message-
   From: Chao Yu [mailto:chao2...@samsung.com]
   Sent: Thursday, December 05, 2013 9:55 AM
   To: ???
   Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
   linux-f2fs-de...@lists.sourceforge.net
   Subject: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to 
   add page into node_inode cache
  
   This patch introduces f2fs_cache_node_page(), in this function, page 
   which is
   readed ahead will be copy to node_inode's mapping cache.
   It will avoid rereading these node pages.
  
   Signed-off-by: Chao Yu chao2...@samsung.com
 
  Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
 
  I miss that, my mistake.
 
   ---
fs/f2fs/node.c |   30 ++
1 file changed, 30 insertions(+)
  
   diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
   index 099f06f..5e2588f 100644
   --- a/fs/f2fs/node.c
   +++ b/fs/f2fs/node.c
   @@ -1600,6 +1600,34 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, 
   struct list_head *pages,
 return 0;
}
  
   +/*
   + * f2fs_cache_node_page() copy updated page data to node_inode cache 
   page.
   + */
   +void f2fs_cache_node_page(struct f2fs_sb_info *sbi, struct page *page,
   + nid_t nid)
   +{
   + struct address_space *mapping = sbi-node_inode-i_mapping;
   + struct page *npage;
   +
   + npage = find_get_page(mapping, nid);
   + if (npage  PageUptodate(npage)) {
   + f2fs_put_page(npage, 0);
   + return;
   + }
   + f2fs_put_page(npage, 0);
   +
   + npage = grab_cache_page(mapping, nid);
   + if (!npage)
   + return;
   +
 
 I forgot to tell you that we need to check its validity here.
 We should not cache this page all the time.
 So, let's consider this approach a little bit more.
 Thank you, :)

Ah, agreed.

I think we should check whether this page is uptodate or not.
And find_lock_page() will check value of 'mapping',
so we do not check here.

Anyway, I will send patch V2.
Thanks for your review. :)

 
   + memcpy(page_address(npage), page_address(page), PAGE_CACHE_SIZE);
   +
   + SetPageUptodate(npage);
   + f2fs_put_page(npage, 1);
   +
   + return;
   +}
   +
int restore_node_summary(struct f2fs_sb_info *sbi,
 unsigned int segno, struct f2fs_summary_block *sum)
{
   @@ -1633,6 +1661,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
 sum_entry-version = 0;
 sum_entry-ofs_in_node = 0;
 sum_entry++;
   + f2fs_cache_node_page(sbi, page,
   + le32_to_cpu(rn-footer.nid));
 } else {
 err = -EIO;
 }
   --
   1.7.9.5
  
  
   --
   Sponsored by Intel(R) XDK
   Develop, test and display web and hybrid apps with a single code base.
   Download it for free now!
   http://pubads.g.doubleclick.net/gampad/clk?id=111408631iu=/4140/ostg.clktrk
   ___
   Linux-f2fs-devel mailing list
   linux-f2fs-de...@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
 
  --
  To unsubscribe from this list: send the line unsubscribe linux-kernel in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 2/5 V2] f2fs: add unlikely() macro for compiler optimization

2013-12-05 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Friday, December 06, 2013 12:12 PM
 To: Chao Yu
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; 谭姝
 Subject: Re: [f2fs-dev] [PATCH 2/5 V2] f2fs: add unlikely() macro for 
 compiler optimization
 
 Hi,
 
 Just in case, if you agreed the following comments, I'll fix those and
 merge the patch by myself.
 Thanks,

Agreed, thanks.

 
 2013-12-05 (목), 17:15 +0800, Chao Yu:
  As we know, some of our branch condition will rarely be true. So we could 
  add
  'unlikely' to let compiler optimize these code, by this way we could drop
  unneeded 'jump' assemble code to improve performance.
 
  change log:
   o add *unlikely* as many as possible across the whole source files at once
 suggested by Jaegeuk Kim.
 
  Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/checkpoint.c |   10 +-
   fs/f2fs/data.c   |4 ++--
   fs/f2fs/dir.c|4 ++--
   fs/f2fs/f2fs.h   |8 
   fs/f2fs/node.c   |   16 
   fs/f2fs/segment.h|2 +-
   6 files changed, 22 insertions(+), 22 deletions(-)
 
  diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
  index 38f4a224..6580808 100644
  --- a/fs/f2fs/checkpoint.c
  +++ b/fs/f2fs/checkpoint.c
  @@ -82,8 +82,8 @@ static int f2fs_write_meta_page(struct page *page,
  struct f2fs_sb_info *sbi = F2FS_SB(inode-i_sb);
 
  /* Should not write any meta pages, if any IO error was occurred */
  -   if (wbc-for_reclaim || sbi-por_doing ||
  -   is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)) {
  +   if (unlikely(wbc-for_reclaim || sbi-por_doing ||
  +   is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG))) {
 
   if (unlikely(sbi-por_doing || is_set_ckpt_flags(F2FS_CKPT(sbi),
 CP_ERROR_FLAG)))
   goto redirty_out;
   if (wbc-for_reclaim)
   goto redirty_out;
 
 redirty_out:
  dec_page_count(sbi, F2FS_DIRTY_META);
  wbc-pages_skipped++;
  set_page_dirty(page);
  @@ -137,7 +137,7 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum 
  page_type type,
  nr_pages = pagevec_lookup_tag(pvec, mapping, index,
  PAGECACHE_TAG_DIRTY,
  min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
  -   if (nr_pages == 0)
  +   if (unlikely(nr_pages == 0))
  break;
 
  for (i = 0; i  nr_pages; i++) {
  @@ -150,7 +150,7 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum 
  page_type type,
  unlock_page(page);
  break;
  }
  -   if (nwritten++ = nr_to_write)
  +   if (unlikely(nwritten++ = nr_to_write))
 
 nwritten++;
 
 if (unlikely(nwritten = nr_to_write))
 
 
  break;
  }
  pagevec_release(pvec);
  @@ -200,7 +200,7 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi)
  max_orphans = (sbi-blocks_per_seg - 2 - NR_CURSEG_TYPE)
  * F2FS_ORPHANS_PER_BLOCK;
  mutex_lock(sbi-orphan_inode_mutex);
  -   if (sbi-n_orphans = max_orphans)
  +   if (unlikely(sbi-n_orphans = max_orphans))
  err = -ENOSPC;
  else
  sbi-n_orphans++;
  diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
  index 4e2fc09..2ce5a9e 100644
  --- a/fs/f2fs/data.c
  +++ b/fs/f2fs/data.c
  @@ -251,7 +251,7 @@ int reserve_new_block(struct dnode_of_data *dn)
 
  if (is_inode_flag_set(F2FS_I(dn-inode), FI_NO_ALLOC))
  return -EPERM;
  -   if (!inc_valid_block_count(sbi, dn-inode, 1))
  +   if (unlikely(!inc_valid_block_count(sbi, dn-inode, 1)))
  return -ENOSPC;
 
  trace_f2fs_reserve_new_block(dn-inode, dn-nid, dn-ofs_in_node);
  @@ -711,7 +711,7 @@ static int f2fs_write_data_page(struct page *page,
 
  zero_user_segment(page, offset, PAGE_CACHE_SIZE);
   write:
  -   if (sbi-por_doing) {
  +   if (unlikely(sbi-por_doing)) {
  err = AOP_WRITEPAGE_ACTIVATE;
  goto redirty_out;
  }
  diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
  index 594fc1b..0cc26ba 100644
  --- a/fs/f2fs/dir.c
  +++ b/fs/f2fs/dir.c
  @@ -190,7 +190,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode 
  *dir,
  unsigned int max_depth;
  unsigned int level;
 
  -   if (namelen  F2FS_NAME_LEN)
  +   if (unlikely(namelen  F2FS_NAME_LEN))
  return NULL;
 
  if (npages == 0)
  @@ -461,7 +461,7 @@ int __f2fs_add_link(struct inode *dir, const struct 
  qstr *name, struct inode *in
  }
 
   start:
  -   if (current_depth == MAX_DIR_HASH_DEPTH)
  +   if (unlikely(current_depth == MAX_DIR_HASH_DEPTH))
  return -ENOSPC;
 
  /* Increase the depth, if required */
  diff --git a/fs/f2fs

RE: [PATCH] f2fs: add unlikely() macro for compiler more aggressively

2013-12-06 Thread Chao Yu
 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Friday, December 06, 2013 2:15 PM
 Cc: Jaegeuk Kim; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 
 linux-f2fs-de...@lists.sourceforge.net; Chao Yu
 Subject: [PATCH] f2fs: add unlikely() macro for compiler more aggressively
 
 This patch adds unlikely() macro into the most of codes.
 The basic rule is to add that when:
 - checking unusual errors,
 - checking page mappings,
 - and the other unlikely conditions.

Looks nice to me!

 
 Cc: Chao Yu chao2...@samsung.com
 Signed-off-by: Jaegeuk Kim jaegeuk@samsung.com

Reviewed-by: Chao Yu chao2...@samsung.com

 ---
  fs/f2fs/checkpoint.c |  22 ++
  fs/f2fs/data.c   |  63 +--
  fs/f2fs/dir.c|  10 ++---
  fs/f2fs/file.c   |  23 +-
  fs/f2fs/gc.c |  19 -
  fs/f2fs/inode.c  |  12 +++---
  fs/f2fs/namei.c  |  24 ++-
  fs/f2fs/node.c   | 117 
 +++
  fs/f2fs/recovery.c   |  10 ++---
  fs/f2fs/segment.c|  42 +-
  fs/f2fs/super.c  |  83 ++--
  fs/f2fs/xattr.c  |  28 ++--
  12 files changed, 234 insertions(+), 219 deletions(-)

[snip]

 @@ -808,11 +808,11 @@ retry:
   brelse(*raw_super_buf);
   f2fs_msg(sb, KERN_ERR, Can't find a valid F2FS filesystem 
   in %dth superblock, block + 1);
 - if(block == 0) {
 + if(unlikely(block != 0)) {

Original code has style problem:
Space is required before the open parenthesis '('.
Thanks.


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 3/3 V2] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache

2013-12-06 Thread Chao Yu
This patch introduces f2fs_cache_node_page(), in this function, page which is
readed ahead will be copy to node_inode's mapping cache.
It will avoid rereading these node pages.

change log:
 o check validity of grabbed page suggested by Jaegeuk Kim.

Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/node.c |   35 +++
 1 file changed, 35 insertions(+)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 099f06f..3ff98fa 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1600,6 +1600,39 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct 
list_head *pages,
return 0;
 }
 
+/*
+ * f2fs_cache_node_page() copy updated page data to node_inode cache page.
+ */
+void f2fs_cache_node_page(struct f2fs_sb_info *sbi, struct page *page,
+   nid_t nid)
+{
+   struct address_space *mapping = sbi-node_inode-i_mapping;
+   struct page *npage;
+
+   npage = find_get_page(mapping, nid);
+   if (unlikely(npage  PageUptodate(npage))) {
+   f2fs_put_page(npage, 0);
+   return;
+   }
+   f2fs_put_page(npage, 0);
+
+   npage = grab_cache_page(mapping, nid);
+   if (unlikely(!npage))
+   return;
+
+   if (unlikely(PageUptodate(npage))) {
+   f2fs_put_page(npage, 1);
+   return;
+   }
+
+   memcpy(page_address(npage), page_address(page), PAGE_CACHE_SIZE);
+
+   SetPageUptodate(npage);
+   f2fs_put_page(npage, 1);
+
+   return;
+}
+
 int restore_node_summary(struct f2fs_sb_info *sbi,
unsigned int segno, struct f2fs_summary_block *sum)
 {
@@ -1633,6 +1666,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
sum_entry-version = 0;
sum_entry-ofs_in_node = 0;
sum_entry++;
+   f2fs_cache_node_page(sbi, page,
+   le32_to_cpu(rn-footer.nid));
} else {
err = -EIO;
}
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 3/5] f2fs: format segment_info's show for better legibility

2014-03-13 Thread Chao Yu
Hi Gu,

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Friday, March 07, 2014 6:44 PM
 To: Kim
 Cc: linux-kernel; f2fs
 Subject: [f2fs-dev] [PATCH 3/5] f2fs: format segment_info's show for better 
 legibility
 
 The original segment_info's show is a bit out-of-format:
 
 [root@guz Demoes]# cat /proc/fs/f2fs/loop0/segment_info
 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 ..
 0 0 0 0 0 0 0 0 0 0
 0 0 1 0 0 1 [root@guz Demoes]#
 
 so we fix it here for better legibility.
 [root@guz Demoes]# cat /proc/fs/f2fs/loop0/segment_info
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 ..
 0 0 0 0 0 0 0 0 0 0
 0 0 1 0 0 1
 [root@guz Demoes]#

Here is one case, this looks not legible.

0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 509 512 512 512
512 512 512 512 512 512 512 512 512 512
512 512 512 512 331 278 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 512 512 512
512 512 512 512 512 512 512 512 512 512
0 512 512 512 512 512 512 1 0 512

So how about modifying code as following?

 
 Signed-off-by: Gu Zheng guz.f...@cn.fujitsu.com

Reviewed-by: Chao Yu chao2...@samsung.com

 ---
  fs/f2fs/super.c |7 ---
  1 files changed, 4 insertions(+), 3 deletions(-)
 
 diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
 index 72df734..6e4851c 100644
 --- a/fs/f2fs/super.c
 +++ b/fs/f2fs/super.c
 @@ -546,11 +546,12 @@ static int segment_info_seq_show(struct seq_file *seq, 
 void *offset)
 
   for (i = 0; i  total_segs; i++) {
   seq_printf(seq, %u, get_valid_blocks(sbi, i, 1));

seq_printf(seq, %-3u , get_valid_blocks(sbi, i, 1));

 - if (i != 0  (i % 10) == 0)
 - seq_puts(seq, \n);
 + if ((i % 10) == 9 || i == (total_segs - 1))
 + seq_putc(seq, '\n');
   else
 - seq_puts(seq,  );
 + seq_putc(seq, ' ');
   }
 +
   return 0;
  }
 
 --
 1.7.7
 
 
 --
 Subversion Kills Productivity. Get off Subversion  Make the Move to Perforce.
 With Perforce, you get hassle-free workflows. Merge that actually works.
 Faster operations. Version large binaries.  Built-in WAN optimization and the
 freedom to use Git, Perforce or both. Make the move to Perforce.
 http://pubads.g.doubleclick.net/gampad/clk?id=122218951iu=/4140/ostg.clktrk
 ___
 Linux-f2fs-devel mailing list
 linux-f2fs-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 3/5] f2fs: format segment_info's show for better legibility

2014-03-16 Thread Chao Yu
Hi Gu,

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Thursday, March 13, 2014 5:58 PM
 To: Chao Yu
 Cc: 'Kim'; 'linux-kernel'; 'f2fs'
 Subject: Re: [f2fs-dev] [PATCH 3/5] f2fs: format segment_info's show for 
 better legibility
 
 Hi,
 On 03/13/2014 05:13 PM, Chao Yu wrote:
 
  Hi Gu,
 
  -Original Message-
  From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
  Sent: Friday, March 07, 2014 6:44 PM
  To: Kim
  Cc: linux-kernel; f2fs
  Subject: [f2fs-dev] [PATCH 3/5] f2fs: format segment_info's show for 
  better legibility
 
  The original segment_info's show is a bit out-of-format:
 
  [root@guz Demoes]# cat /proc/fs/f2fs/loop0/segment_info
  0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0
  ..
  0 0 0 0 0 0 0 0 0 0
  0 0 1 0 0 1 [root@guz Demoes]#
 
  so we fix it here for better legibility.
  [root@guz Demoes]# cat /proc/fs/f2fs/loop0/segment_info
  0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0
  ..
  0 0 0 0 0 0 0 0 0 0
  0 0 1 0 0 1
  [root@guz Demoes]#
 
  Here is one case, this looks not legible.
 
  0 0 0 0 0 0 0 0 0 0
  1 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 509 512 512 512
  512 512 512 512 512 512 512 512 512 512
  512 512 512 512 331 278 0 0 0 0
  0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 512 512 512
  512 512 512 512 512 512 512 512 512 512
  0 512 512 512 512 512 512 1 0 512
 
  So how about modifying code as following?
 
 
 
  Signed-off-by: Gu Zheng guz.f...@cn.fujitsu.com
 
  Reviewed-by: Chao Yu chao2...@samsung.com
 
  ---
   fs/f2fs/super.c |7 ---
   1 files changed, 4 insertions(+), 3 deletions(-)
 
  diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
  index 72df734..6e4851c 100644
  --- a/fs/f2fs/super.c
  +++ b/fs/f2fs/super.c
  @@ -546,11 +546,12 @@ static int segment_info_seq_show(struct seq_file 
  *seq, void *offset)
 
 for (i = 0; i  total_segs; i++) {
 seq_printf(seq, %u, get_valid_blocks(sbi, i, 1));
 
  seq_printf(seq, %-3u , get_valid_blocks(sbi, i, 1));
 
 Hmm, this patch has been applied to f2fs-dev tree, so maybe you can send a
 patch to enhance it directly!:)

Alright, I will send another patch to fix it. :)
Thanks.

 
 Regards,
 Gu
 
 
  -  if (i != 0  (i % 10) == 0)
  -  seq_puts(seq, \n);
  +  if ((i % 10) == 9 || i == (total_segs - 1))
  +  seq_putc(seq, '\n');
 else
  -  seq_puts(seq,  );
  +  seq_putc(seq, ' ');
 }
  +
 return 0;
   }
 
  --
  1.7.7
 
 
  --
  Subversion Kills Productivity. Get off Subversion  Make the Move to 
  Perforce.
  With Perforce, you get hassle-free workflows. Merge that actually works.
  Faster operations. Version large binaries.  Built-in WAN optimization and 
  the
  freedom to use Git, Perforce or both. Make the move to Perforce.
  http://pubads.g.doubleclick.net/gampad/clk?id=122218951iu=/4140/ostg.clktrk
  ___
  Linux-f2fs-devel mailing list
  linux-f2fs-de...@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
 
 


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: print type for each segment in segment_info's show

2014-03-16 Thread Chao Yu
The original segment_info's show looks out-of-format:
cat /proc/fs/f2fs/loop0/segment_info
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 512
512 512 512 512 512 512 512 0 0 512
348 0 263 0 0 512 0 0 512 512
512 512 0 512 512 512 512 512 512 512
512 512 511 328 512 512 512 512 512 512
512 512 512 512 512 512 512 0 0 175

Let's fix this and show type for each segment.
cat /proc/fs/f2fs/loop0/segment_info
format: segment_type|valid_blocks
segment_type(0:HD, 1:WD, 2:CD, 3:HN, 4:WN, 5:CN)
02|0   1|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0
10   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0
20   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0
30   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0
40   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0   0|0
50   3|0   3|0   3|0   3|0   3|0   3|0   3|0   0|0   3|0   3|0
60   3|0   3|0   3|0   3|0   3|0   3|0   3|0   3|0   3|0   3|512
70   3|512 3|512 3|512 3|512 3|512 3|512 3|512 3|0   3|0   3|512
80   3|0   3|0   3|0   3|0   3|0   3|512 3|0   3|0   3|512 3|512
90   3|512 0|512 3|274 0|512 0|512 0|512 0|512 0|512 0|512 3|512
100  3|512 0|512 3|511 0|328 3|512 0|512 0|512 3|512 0|512 0|512
110  0|512 0|512 0|512 0|512 0|512 0|512 0|512 5|0   4|0   3|512

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/super.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 3a51d7a..057a3ef 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -544,8 +544,16 @@ static int segment_info_seq_show(struct seq_file *seq, 
void *offset)
le32_to_cpu(sbi-raw_super-segment_count_main);
int i;
 
+   seq_puts(seq, format: segment_type|valid_blocks\n
+   segment_type(0:HD, 1:WD, 2:CD, 3:HN, 4:WN, 5:CN)\n);
+
for (i = 0; i  total_segs; i++) {
-   seq_printf(seq, %u, get_valid_blocks(sbi, i, 1));
+   struct seg_entry *se = get_seg_entry(sbi, i);
+
+   if ((i % 10) == 0)
+   seq_printf(seq, %-5d, i);
+   seq_printf(seq, %d|%-3u, se-type,
+   get_valid_blocks(sbi, i, 1));
if ((i % 10) == 9 || i == (total_segs - 1))
seq_putc(seq, '\n');
else
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 1/2] f2fs: introduce f2fs_has_xattr_block for better readability

2014-03-17 Thread Chao Yu
This patch introduces a help function f2fs_has_xattr_block for better
readability.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/f2fs.h |5 +
 fs/f2fs/node.c |4 ++--
 fs/f2fs/node.h |2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 1f87a04..292cc3c 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -637,6 +637,11 @@ static inline int F2FS_HAS_BLOCKS(struct inode *inode)
return inode-i_blocks  F2FS_DEFAULT_ALLOCATED_BLOCKS;
 }
 
+static inline bool f2fs_has_xattr_block(unsigned int ofs)
+{
+   return ofs == XATTR_NODE_OFFSET;
+}
+
 static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
 struct inode *inode, blkcnt_t count)
 {
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index c618fad..3e36240 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -836,7 +836,7 @@ struct page *new_node_page(struct dnode_of_data *dn,
SetPageUptodate(page);
set_page_dirty(page);
 
-   if (ofs == XATTR_NODE_OFFSET)
+   if (f2fs_has_xattr_block(ofs))
F2FS_I(dn-inode)-i_xattr_nid = dn-nid;
 
dn-node_page = page;
@@ -1533,7 +1533,7 @@ bool recover_xattr_data(struct inode *inode, struct page 
*page, block_t blkaddr)
 
recover_inline_xattr(inode, page);
 
-   if (ofs_of_node(page) != XATTR_NODE_OFFSET)
+   if (!f2fs_has_xattr_block(ofs_of_node(page)))
return false;
 
/* 1: invalidate the previous xattr nid */
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 4dea719..ee6d286 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -242,7 +242,7 @@ static inline bool IS_DNODE(struct page *node_page)
 {
unsigned int ofs = ofs_of_node(node_page);
 
-   if (ofs == XATTR_NODE_OFFSET)
+   if (f2fs_has_xattr_block(ofs))
return false;
 
if (ofs == 3 || ofs == 4 + NIDS_PER_BLOCK ||
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 2/2] f2fs: avoid to return incorrect errno of read_normal_summaries

2014-03-17 Thread Chao Yu
We should return error number of read_normal_summaries instead of -EINVAL when
read_normal_summaries failed.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/segment.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index b3f8431..6c5a4f0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1186,6 +1186,7 @@ static int read_normal_summaries(struct f2fs_sb_info 
*sbi, int type)
 static int restore_curseg_summaries(struct f2fs_sb_info *sbi)
 {
int type = CURSEG_HOT_DATA;
+   int err;
 
if (is_set_ckpt_flags(F2FS_CKPT(sbi), CP_COMPACT_SUM_FLAG)) {
/* restore for compacted data summary */
@@ -1194,9 +1195,12 @@ static int restore_curseg_summaries(struct f2fs_sb_info 
*sbi)
type = CURSEG_HOT_NODE;
}
 
-   for (; type = CURSEG_COLD_NODE; type++)
-   if (read_normal_summaries(sbi, type))
-   return -EINVAL;
+   for (; type = CURSEG_COLD_NODE; type++) {
+   err = read_normal_summaries(sbi, type);
+   if (err)
+   return err;
+   }
+
return 0;
 }
 
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: fix incorrect parsing with option string

2014-03-17 Thread Chao Yu
Previously 'background_gc={on***,off***}' is being parsed as correct option,
with this patch we cloud fix the trivial bug in mount process.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/super.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 057a3ef..6597290 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -258,9 +258,9 @@ static int parse_options(struct super_block *sb, char 
*options)
 
if (!name)
return -ENOMEM;
-   if (!strncmp(name, on, 2))
+   if (!strncmp(name, on, strlen(name)))
set_opt(sbi, BG_GC);
-   else if (!strncmp(name, off, 3))
+   else if (!strncmp(name, off, strlen(name)))
clear_opt(sbi, BG_GC);
else {
kfree(name);
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: fix incorrect parsing with option string

2014-03-17 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Tuesday, March 18, 2014 8:33 AM
 To: Chao Yu
 Cc: linux-f2fs-de...@lists.sourceforge.net; linux-fsde...@vger.kernel.org;
 linux-kernel@vger.kernel.org
 Subject: Re: [f2fs-dev] [PATCH] f2fs: fix incorrect parsing with option string
 
 Hi,
 
 2014-03-17 (월), 17:40 +0800, Chao Yu:
  Previously 'background_gc={on***,off***}' is being parsed as correct option,
  with this patch we cloud fix the trivial bug in mount process.
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/super.c |4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
 
  diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
  index 057a3ef..6597290 100644
  --- a/fs/f2fs/super.c
  +++ b/fs/f2fs/super.c
  @@ -258,9 +258,9 @@ static int parse_options(struct super_block *sb, char 
  *options)
 
  if (!name)
  return -ENOMEM;
  -   if (!strncmp(name, on, 2))
  +   if (!strncmp(name, on, strlen(name)))
 
 What about 'background_gc=o'?
 Need to check strlen(name) == 2...

Oh, you're right. I will fix it and send v2 patch.
Thanks for your review. :)

 Thanks,
 
  set_opt(sbi, BG_GC);
  -   else if (!strncmp(name, off, 3))
  +   else if (!strncmp(name, off, strlen(name)))
  clear_opt(sbi, BG_GC);
  else {
  kfree(name);
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH v2] f2fs: fix incorrect parsing with option string

2014-03-17 Thread Chao Yu
Previously 'background_gc={on***,off***}' is being parsed as correct option,
with this patch we cloud fix the trivial bug in mount process.

Change log from v1:
 o need to check length of parameter suggested by Jaegeuk Kim.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/super.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 057a3ef..dbe402b 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -258,9 +258,9 @@ static int parse_options(struct super_block *sb, char 
*options)
 
if (!name)
return -ENOMEM;
-   if (!strncmp(name, on, 2))
+   if (strlen(name) == 2  !strncmp(name, on, 2))
set_opt(sbi, BG_GC);
-   else if (!strncmp(name, off, 3))
+   else if (strlen(name) == 3  !strncmp(name, off, 3))
clear_opt(sbi, BG_GC);
else {
kfree(name);
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: readahead contiguous SSA blocks for f2fs_gc

2014-02-27 Thread Chao Yu
If there are multi segments in one section, we will read those SSA blocks which
have contiguous address one by one in f2fs_gc. It may lost performance, let's
read ahead SSA blocks by merge multi read request.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/checkpoint.c |6 --
 fs/f2fs/f2fs.h   |5 +++--
 fs/f2fs/gc.c |5 +
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 757b77b..c8516ee 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -82,6 +82,7 @@ inline int get_max_meta_blks(struct f2fs_sb_info *sbi, int 
type)
return NM_I(sbi)-max_nid / NAT_ENTRY_PER_BLOCK;
case META_SIT:
return SIT_BLK_CNT(sbi);
+   case META_SSA:
case META_CP:
return 0;
default:
@@ -90,7 +91,7 @@ inline int get_max_meta_blks(struct f2fs_sb_info *sbi, int 
type)
 }
 
 /*
- * Readahead CP/NAT/SIT pages
+ * Readahead CP/NAT/SIT/SSA pages
  */
 int ra_meta_pages(struct f2fs_sb_info *sbi, int start, int nrpages, int type)
 {
@@ -125,8 +126,9 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, int start, int 
nrpages, int type)
goto out;
prev_blk_addr = blk_addr;
break;
+   case META_SSA:
case META_CP:
-   /* get cp block addr */
+   /* get ssa/cp block addr */
blk_addr = blkno;
break;
default:
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 4beedcc..cc0b27f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -89,12 +89,13 @@ enum {
 };
 
 /*
- * For CP/NAT/SIT readahead
+ * For CP/NAT/SIT/SSA readahead
  */
 enum {
META_CP,
META_NAT,
-   META_SIT
+   META_SIT,
+   META_SSA
 };
 
 /* for the list of orphan inodes */
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index b161db4..d94acbc 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -708,6 +708,11 @@ gc_more:
goto stop;
ret = 0;
 
+   /* readahead multi ssa blocks those have contiguous address */
+   if (sbi-segs_per_sec  1)
+   ra_meta_pages(sbi, GET_SUM_BLOCK(sbi, segno), sbi-segs_per_sec,
+   META_SSA);
+
for (i = 0; i  sbi-segs_per_sec; i++)
do_garbage_collect(sbi, segno + i, ilist, gc_type);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: use existing macro to clean up some codes

2014-02-27 Thread Chao Yu
This patch use existing macro F2FS_INODE/NEXT_FREE_BLKADDR to clean up some
codes.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/f2fs.h |6 ++
 fs/f2fs/recovery.c |2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index cc0b27f..459078b 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -996,8 +996,7 @@ static inline unsigned int addrs_per_inode(struct 
f2fs_inode_info *fi)
 
 static inline void *inline_xattr_addr(struct page *page)
 {
-   struct f2fs_inode *ri;
-   ri = (struct f2fs_inode *)page_address(page);
+   struct f2fs_inode *ri = F2FS_INODE(page);
return (void *)(ri-i_addr[DEF_ADDRS_PER_INODE -
F2FS_INLINE_XATTR_ADDRS]);
 }
@@ -1017,8 +1016,7 @@ static inline int f2fs_has_inline_data(struct inode 
*inode)
 
 static inline void *inline_data_addr(struct page *page)
 {
-   struct f2fs_inode *ri;
-   ri = (struct f2fs_inode *)page_address(page);
+   struct f2fs_inode *ri = F2FS_INODE(page);
return (void *)(ri-i_addr[1]);
 }
 
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 72adbbf..aef7768 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -136,7 +136,7 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, 
struct list_head *head)
 
/* get node pages in the current segment */
curseg = CURSEG_I(sbi, CURSEG_WARM_NODE);
-   blkaddr = START_BLOCK(sbi, curseg-segno) + curseg-next_blkoff;
+   blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);
 
/* read node page */
page = alloc_page(GFP_F2FS_ZERO);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: fix dirty page accounting when redirty

2014-02-27 Thread Chao Yu
We should de-account dirty counters for page when redirty in -writepage().

Wu Fengguang described in 'commit 971767caf632190f77a40b4011c19948232eed75':
writeback: fix dirtied pages accounting on redirty
De-account the accumulative dirty counters on page redirty.

Page redirties (very common in ext4) will introduce mismatch between
counters (a) and (b)

a) NR_DIRTIED, BDI_DIRTIED, tsk-nr_dirtied
b) NR_WRITTEN, BDI_WRITTEN

This will introduce systematic errors in balanced_rate and result in
dirty page position errors (ie. the dirty pages are no longer balanced
around the global/bdi setpoints).

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/checkpoint.c |1 +
 fs/f2fs/data.c   |1 +
 fs/f2fs/node.c   |1 +
 3 files changed, 3 insertions(+)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index c8516ee..f069249 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -178,6 +178,7 @@ no_write:
 redirty_out:
dec_page_count(sbi, F2FS_DIRTY_META);
wbc-pages_skipped++;
+   account_page_redirty(page);
set_page_dirty(page);
return AOP_WRITEPAGE_ACTIVATE;
 }
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 93d80ea..101b4cd 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -839,6 +839,7 @@ out:
 
 redirty_out:
wbc-pages_skipped++;
+   account_page_redirty(page);
set_page_dirty(page);
return AOP_WRITEPAGE_ACTIVATE;
 }
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 1f9cf21..8c14110 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1193,6 +1193,7 @@ static int f2fs_write_node_page(struct page *page,
 redirty_out:
dec_page_count(sbi, F2FS_DIRTY_NODES);
wbc-pages_skipped++;
+   account_page_redirty(page);
set_page_dirty(page);
return AOP_WRITEPAGE_ACTIVATE;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: fix dirty page accounting when redirty

2014-02-28 Thread Chao Yu
Hi,

 -Original Message-
 From: Dave Chinner [mailto:da...@fromorbit.com]
 Sent: Saturday, March 01, 2014 8:27 AM
 To: Chao Yu
 Cc: ???; linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: Re: [f2fs-dev] [PATCH] f2fs: fix dirty page accounting when redirty
 
 On Fri, Feb 28, 2014 at 10:12:05AM +0800, Chao Yu wrote:
  We should de-account dirty counters for page when redirty in -writepage().
 
  Wu Fengguang described in 'commit 971767caf632190f77a40b4011c19948232eed75':
  writeback: fix dirtied pages accounting on redirty
  De-account the accumulative dirty counters on page redirty.
 
  Page redirties (very common in ext4) will introduce mismatch between
  counters (a) and (b)
 
  a) NR_DIRTIED, BDI_DIRTIED, tsk-nr_dirtied
  b) NR_WRITTEN, BDI_WRITTEN
 
  This will introduce systematic errors in balanced_rate and result in
  dirty page position errors (ie. the dirty pages are no longer balanced
  around the global/bdi setpoints).
 
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/checkpoint.c |1 +
   fs/f2fs/data.c   |1 +
   fs/f2fs/node.c   |1 +
   3 files changed, 3 insertions(+)
 
  diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
  index c8516ee..f069249 100644
  --- a/fs/f2fs/checkpoint.c
  +++ b/fs/f2fs/checkpoint.c
  @@ -178,6 +178,7 @@ no_write:
   redirty_out:
  dec_page_count(sbi, F2FS_DIRTY_META);
  wbc-pages_skipped++;
  +   account_page_redirty(page);
  set_page_dirty(page);
  return AOP_WRITEPAGE_ACTIVATE;
 
 redirty_page_for_writepage()?

set_page_dirty() in a_ops of f2fs not only call __set_page_dirty_nobuffers(),
but also set some private data of page and print trace info.
So it seems we could not easily replace with redirty_page_for_writepage().

Thanks.

 
 Cheers,
 
 Dave.
 --
 Dave Chinner
 da...@fromorbit.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 1/5] f2fs: update start nid only once each circle

2014-03-08 Thread Chao Yu
Hi Gu,

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Friday, March 07, 2014 6:43 PM
 To: Kim
 Cc: linux-kernel; f2fs
 Subject: [f2fs-dev] [PATCH 1/5] f2fs: update start nid only once each circle
 
 
 Signed-off-by: Gu Zheng guz.f...@cn.fujitsu.com

Reviewed-by: Chao Yu chao2...@samsung.com

 ---
  fs/f2fs/node.c |6 +-
  1 files changed, 5 insertions(+), 1 deletions(-)
 
 diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
 index 8c14110..9653096 100644
 --- a/fs/f2fs/node.c
 +++ b/fs/f2fs/node.c
 @@ -1875,11 +1875,15 @@ void destroy_node_manager(struct f2fs_sb_info *sbi)
   while ((found = __gang_lookup_nat_cache(nm_i,
   nid, NATVEC_SIZE, natvec))) {
   unsigned idx;
 +
 + nid = nat_get_nid(natvec[found - 1]) + 1;
 +
   for (idx = 0; idx  found; idx++) {
   struct nat_entry *e = natvec[idx];

Could we replace argument 'e' with 'natvec[idx]'? then we could remove 'e' and
brace here.

Thanks.

 - nid = nat_get_nid(e) + 1;
 +
   __del_from_nat_cache(nm_i, e);
   }
 +
   }
   f2fs_bug_on(nm_i-nat_cnt);
   write_unlock(nm_i-nat_tree_lock);
 --
 1.7.7
 
 
 --
 Subversion Kills Productivity. Get off Subversion  Make the Move to Perforce.
 With Perforce, you get hassle-free workflows. Merge that actually works.
 Faster operations. Version large binaries.  Built-in WAN optimization and the
 freedom to use Git, Perforce or both. Make the move to Perforce.
 http://pubads.g.doubleclick.net/gampad/clk?id=122218951iu=/4140/ostg.clktrk
 ___
 Linux-f2fs-devel mailing list
 linux-f2fs-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 4/5] f2fs: optimize restore_node_summary slightly

2014-03-09 Thread Chao Yu
Hi Gu, Kim:

One more comment.

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Monday, March 10, 2014 12:46 PM
 To: Gu Zheng
 Cc: linux-kernel; f2fs
 Subject: Re: [f2fs-dev] [PATCH 4/5] f2fs: optimize restore_node_summary 
 slightly
 
 Hi Gu,
 
 2014-03-07 (금), 18:43 +0800, Gu Zheng:
  Previously, we ra_sum_pages to pre-read contiguous pages as more
  as possible, and if we fail to alloc more pages, an ENOMEM error
  will be reported upstream, even though we have alloced some pages
  yet. In fact, we can use the available pages to do the job partly,
  and continue the rest in the following circle. Only reporting ENOMEM
  upstream if we really can not alloc any available page.
 
  And another fix is ignoring dealing with the following pages if an
  EIO occurs when reading page from page_list.
 
  Signed-off-by: Gu Zheng guz.f...@cn.fujitsu.com

Reviewed-by: Chao Yu chao2...@samsung.com

  ---
   fs/f2fs/node.c|   44 
   fs/f2fs/segment.c |7 +--
   2 files changed, 25 insertions(+), 26 deletions(-)
 
  diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
  index 8787469..4b7861d 100644
  --- a/fs/f2fs/node.c
  +++ b/fs/f2fs/node.c
  @@ -1588,15 +1588,8 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, 
  struct list_head
 *pages,
  for (; page_idx  start + nrpages; page_idx++) {
  /* alloc temporal page for read node summary info*/
  page = alloc_page(GFP_F2FS_ZERO);
  -   if (!page) {
  -   struct page *tmp;
  -   list_for_each_entry_safe(page, tmp, pages, lru) {
  -   list_del(page-lru);
  -   unlock_page(page);
  -   __free_pages(page, 0);
  -   }
  -   return -ENOMEM;
  -   }
  +   if (!page)
  +   break;
 
  lock_page(page);
  page-index = page_idx;
  @@ -1607,7 +1600,8 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, 
  struct list_head
 *pages,
  f2fs_submit_page_mbio(sbi, page, page-index, fio);
 
  f2fs_submit_merged_bio(sbi, META, READ);
  -   return 0;
  +
  +   return page_idx - start;
   }
 
   int restore_node_summary(struct f2fs_sb_info *sbi,
  @@ -1630,28 +1624,30 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
  nrpages = min(last_offset - i, bio_blocks);
 
  /* read ahead node pages */
  -   err = ra_sum_pages(sbi, page_list, addr, nrpages);
  -   if (err)
  -   return err;
  +   nrpages = ra_sum_pages(sbi, page_list, addr, nrpages);
  +   if (!nrpages)
  +   return -ENOMEM;
 
  list_for_each_entry_safe(page, tmp, page_list, lru) {
  -
 
 Here we can just add:
   if (err)
   goto skip;
   lock_page();
   ...
   unlock_page();
   skip:
   list_del();
   __free_pages();
 
 IMO, it's more neat, so if you have any objection, let me know.
 Otherwise, I'll handle this by myself. :)
 Thanks,
 
  -   lock_page(page);
  -   if (unlikely(!PageUptodate(page))) {
  -   err = -EIO;
  -   } else {
  -   rn = F2FS_NODE(page);
  -   sum_entry-nid = rn-footer.nid;
  -   sum_entry-version = 0;
  -   sum_entry-ofs_in_node = 0;
  -   sum_entry++;
  +   if (!err) {

If we skip here, next round we will fill these summary page entries with
wrong info because we skip the code 'sum_entry++;'.

  +   lock_page(page);
  +   if (unlikely(!PageUptodate(page))) {
  +   err = -EIO;
  +   } else {
  +   rn = F2FS_NODE(page);
  +   sum_entry-nid = rn-footer.nid;
  +   sum_entry-version = 0;
  +   sum_entry-ofs_in_node = 0;
  +   sum_entry++;
  +   }
  +   unlock_page(page);
  }
 
  list_del(page-lru);
  -   unlock_page(page);
  __free_pages(page, 0);
  }

Maybe we should add code here.
if (err)
return err;

  }
  +
  return err;
   }
 
  diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
  index 199c964..b3f8431 100644
  --- a/fs/f2fs/segment.c
  +++ b/fs/f2fs/segment.c
  @@ -1160,9 +1160,12 @@ static int read_normal_summaries(struct f2fs_sb_info 
  *sbi, int type

RE: [f2fs-dev] [PATCH 4/5] f2fs: optimize restore_node_summary slightly

2014-03-10 Thread Chao Yu
Hi,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Monday, March 10, 2014 1:38 PM
 To: Chao Yu
 Cc: 'Gu Zheng'; 'linux-kernel'; 'f2fs'
 Subject: RE: [f2fs-dev] [PATCH 4/5] f2fs: optimize restore_node_summary 
 slightly
 
 Hi,
 
 2014-03-10 (월), 13:13 +0800, Chao Yu:
  Hi Gu, Kim:
 
  One more comment.
 
   -Original Message-
   From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
   Sent: Monday, March 10, 2014 12:46 PM
   To: Gu Zheng
   Cc: linux-kernel; f2fs
   Subject: Re: [f2fs-dev] [PATCH 4/5] f2fs: optimize restore_node_summary 
   slightly
  
   Hi Gu,
  
   2014-03-07 (금), 18:43 +0800, Gu Zheng:
Previously, we ra_sum_pages to pre-read contiguous pages as more
as possible, and if we fail to alloc more pages, an ENOMEM error
will be reported upstream, even though we have alloced some pages
yet. In fact, we can use the available pages to do the job partly,
and continue the rest in the following circle. Only reporting ENOMEM
upstream if we really can not alloc any available page.
   
And another fix is ignoring dealing with the following pages if an
EIO occurs when reading page from page_list.
   
Signed-off-by: Gu Zheng guz.f...@cn.fujitsu.com
 
  Reviewed-by: Chao Yu chao2...@samsung.com
 
---
 fs/f2fs/node.c|   44 
 fs/f2fs/segment.c |7 +--
 2 files changed, 25 insertions(+), 26 deletions(-)
   
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 8787469..4b7861d 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1588,15 +1588,8 @@ static int ra_sum_pages(struct f2fs_sb_info 
*sbi, struct list_head
   *pages,
for (; page_idx  start + nrpages; page_idx++) {
/* alloc temporal page for read node summary info*/
page = alloc_page(GFP_F2FS_ZERO);
-   if (!page) {
-   struct page *tmp;
-   list_for_each_entry_safe(page, tmp, pages, lru) 
{
-   list_del(page-lru);
-   unlock_page(page);
-   __free_pages(page, 0);
-   }
-   return -ENOMEM;
-   }
+   if (!page)
+   break;
   
lock_page(page);
page-index = page_idx;
@@ -1607,7 +1600,8 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, 
struct list_head
   *pages,
f2fs_submit_page_mbio(sbi, page, page-index, fio);
   
f2fs_submit_merged_bio(sbi, META, READ);
-   return 0;
+
+   return page_idx - start;
 }
   
 int restore_node_summary(struct f2fs_sb_info *sbi,
@@ -1630,28 +1624,30 @@ int restore_node_summary(struct f2fs_sb_info 
*sbi,
nrpages = min(last_offset - i, bio_blocks);
   
/* read ahead node pages */
-   err = ra_sum_pages(sbi, page_list, addr, nrpages);
-   if (err)
-   return err;
+   nrpages = ra_sum_pages(sbi, page_list, addr, nrpages);
+   if (!nrpages)
+   return -ENOMEM;
   
list_for_each_entry_safe(page, tmp, page_list, lru) {
-
  
   Here we can just add:
 if (err)
 goto skip;
 lock_page();
 ...
 unlock_page();
 skip:
 list_del();
 __free_pages();
  
   IMO, it's more neat, so if you have any objection, let me know.
   Otherwise, I'll handle this by myself. :)
   Thanks,
  
-   lock_page(page);
-   if (unlikely(!PageUptodate(page))) {
-   err = -EIO;
-   } else {
-   rn = F2FS_NODE(page);
-   sum_entry-nid = rn-footer.nid;
-   sum_entry-version = 0;
-   sum_entry-ofs_in_node = 0;
-   sum_entry++;
+   if (!err) {
 
  If we skip here, next round we will fill these summary page entries with
  wrong info because we skip the code 'sum_entry++;'.
 
 There is no next round. Once err = -EIO, there's no route to make err =
 0.

Ah, you're right. Only old code has this problem, this new patch can fix it 
well.
Thanks for the mention. :)

Thanks.

 
 
+   lock_page(page);
+   if (unlikely(!PageUptodate(page))) {
+   err = -EIO;
+   } else {
+   rn = F2FS_NODE

[f2fs-dev] [PATCH] f2fs: recover inline xattr data in roll-forward process

2014-03-10 Thread Chao Yu
Previously we do not recover inline xattr data of inode after power-cut, so
inline xattr data may be lost.
We should recover the data during the roll-forward process.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/node.c |   33 +
 1 file changed, 33 insertions(+)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index c415cec..e72b258 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1493,6 +1493,37 @@ void recover_node_page(struct f2fs_sb_info *sbi, struct 
page *page,
clear_node_page_dirty(page);
 }
 
+void recover_inline_xattr(struct inode *inode, struct page *page)
+{
+   struct f2fs_sb_info *sbi = F2FS_SB(inode-i_sb);
+   void *src_addr, *dst_addr;
+   size_t inline_size;
+   struct page *ipage;
+   struct f2fs_inode *ri;
+
+   if (!is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR))
+   return;
+
+   if (!IS_INODE(page))
+   return;
+
+   ri = F2FS_INODE(page);
+   if (!(ri-i_inline  F2FS_INLINE_XATTR))
+   return;
+
+   ipage = get_node_page(sbi, inode-i_ino);
+   f2fs_bug_on(IS_ERR(ipage));
+
+   dst_addr = inline_xattr_addr(ipage);
+   src_addr = inline_xattr_addr(page);
+   inline_size = inline_xattr_size(inode);
+
+   memcpy(dst_addr, src_addr, inline_size);
+
+   update_inode(inode, ipage);
+   f2fs_put_page(ipage, 1);
+}
+
 bool recover_xattr_data(struct inode *inode, struct page *page, block_t 
blkaddr)
 {
struct f2fs_sb_info *sbi = F2FS_SB(inode-i_sb);
@@ -1500,6 +1531,8 @@ bool recover_xattr_data(struct inode *inode, struct page 
*page, block_t blkaddr)
nid_t new_xnid = nid_of_node(page);
struct node_info ni;
 
+   recover_inline_xattr(inode, page);
+
if (ofs_of_node(page) != XATTR_NODE_OFFSET)
return false;
 
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: introduce f2fs_has_inline_xattr for better readability

2014-03-12 Thread Chao Yu
This patch introduces a help function f2fs_has_inline_xattr for better
readability.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/f2fs.h |9 +++--
 fs/f2fs/node.c |2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f845e92..1f87a04 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -991,9 +991,14 @@ static inline void set_raw_inline(struct f2fs_inode_info 
*fi,
ri-i_inline |= F2FS_INLINE_DATA;
 }
 
+static inline int f2fs_has_inline_xattr(struct inode *inode)
+{
+   return is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR);
+}
+
 static inline unsigned int addrs_per_inode(struct f2fs_inode_info *fi)
 {
-   if (is_inode_flag_set(fi, FI_INLINE_XATTR))
+   if (f2fs_has_inline_xattr(fi-vfs_inode))
return DEF_ADDRS_PER_INODE - F2FS_INLINE_XATTR_ADDRS;
return DEF_ADDRS_PER_INODE;
 }
@@ -1007,7 +1012,7 @@ static inline void *inline_xattr_addr(struct page *page)
 
 static inline int inline_xattr_size(struct inode *inode)
 {
-   if (is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR))
+   if (f2fs_has_inline_xattr(inode))
return F2FS_INLINE_XATTR_ADDRS  2;
else
return 0;
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index e72b258..c618fad 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1501,7 +1501,7 @@ void recover_inline_xattr(struct inode *inode, struct 
page *page)
struct page *ipage;
struct f2fs_inode *ri;
 
-   if (!is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR))
+   if (!f2fs_has_inline_xattr(inode))
return;
 
if (!IS_INODE(page))
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: check upper bound of ino value in f2fs_nfs_get_inode

2014-03-12 Thread Chao Yu
Upper bound checking of ino should be added to f2fs_nfs_get_inode, so unneeded
process before do_read_inode in f2fs_iget could be avoided when ino is invalid.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/super.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 6e4851c..3a51d7a 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -644,6 +644,8 @@ static struct inode *f2fs_nfs_get_inode(struct super_block 
*sb,
 
if (unlikely(ino  F2FS_ROOT_INO(sbi)))
return ERR_PTR(-ESTALE);
+   if (unlikely(ino = NM_I(sbi)-max_nid))
+   return ERR_PTR(-ESTALE);
 
/*
 * f2fs_iget isn't quite right if the inode is currently unallocated!
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 1/3] f2fs: move grabing orphan pages out of protection region

2014-01-10 Thread Chao Yu
Hi Gu,

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Friday, January 10, 2014 6:09 PM
 To: Kim
 Cc: fsdevel; linux-kernel; f2fs
 Subject: [f2fs-dev] [PATCH 1/3] f2fs: move grabing orphan pages out of 
 protection region
 
 Move grabing orphan block page out of protection region, and grab all
 the orphan block pages ahead.
 
 Signed-off-by: Gu Zheng guz.f...@cn.fujitsu.com

Reviewed-by: Chao Yu chao2...@samsung.com

 ---
  fs/f2fs/checkpoint.c |   15 +--
  1 files changed, 9 insertions(+), 6 deletions(-)
 
 diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
 index 0d78bbe..af92c74 100644
 --- a/fs/f2fs/checkpoint.c
 +++ b/fs/f2fs/checkpoint.c
 @@ -303,22 +303,25 @@ static void write_orphan_inodes(struct f2fs_sb_info 
 *sbi, block_t
 start_blk)
  {
   struct list_head *head;
   struct f2fs_orphan_block *orphan_blk = NULL;
 - struct page *page = NULL;
   unsigned int nentries = 0;
 - unsigned short index = 1;
 - unsigned short orphan_blocks;
 + unsigned short index;
 + unsigned short orphan_blocks = (unsigned short)((sbi-n_orphans +
 + (F2FS_ORPHANS_PER_BLOCK - 1)) / F2FS_ORPHANS_PER_BLOCK);
 + struct page *page = NULL;
 + struct page *pages[orphan_blocks];
   struct orphan_inode_entry *orphan = NULL;
 
 - orphan_blocks = (unsigned short)((sbi-n_orphans +
 - (F2FS_ORPHANS_PER_BLOCK - 1)) / F2FS_ORPHANS_PER_BLOCK);
 + for (index = 0; index  orphan_blocks; index++)
 + pages[index] = grab_meta_page(sbi, start_blk + index);
 
 + index = 1;
   mutex_lock(sbi-orphan_inode_mutex);
   head = sbi-orphan_inode_list;
 
   /* loop for each orphan inode entry and write them in Jornal block */
   list_for_each_entry(orphan, head, list) {
   if (!page) {
 - page = grab_meta_page(sbi, start_blk);
 + page = pages[index - 1];
   orphan_blk =
   (struct f2fs_orphan_block *)page_address(page);
   memset(orphan_blk, 0, sizeof(*orphan_blk));

It seems that we could remove the following code in write_orphan_inodes.
start_blk++;

 --
 1.7.7
 
 
 --
 CenturyLink Cloud: The Leader in Enterprise Cloud Services.
 Learn Why More Businesses Are Choosing CenturyLink Cloud For
 Critical Workloads, Development Environments  Everything In Between.
 Get a Quote or Start a Free Trial Today.
 http://pubads.g.doubleclick.net/gampad/clk?id=119420431iu=/4140/ostg.clktrk
 ___
 Linux-f2fs-devel mailing list
 linux-f2fs-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 1/2] f2fs: avoid unnecessary bio submit when wait page writeback

2014-03-22 Thread Chao Yu
This patch introduce is_merged_page() to check whether current page is merged
in f2fs bio cache. When page is not in cache, we can avoid submitting bio cache,
resulting in having more chance to merge pages.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/data.c|8 
 fs/f2fs/f2fs.h|2 +-
 fs/f2fs/segment.c |   28 +++-
 fs/f2fs/super.c   |4 ++--
 4 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b0c923a..598bfa6 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -134,7 +134,7 @@ void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
 
io = is_read_io(rw) ? sbi-read_io : sbi-write_io[btype];
 
-   mutex_lock(io-io_mutex);
+   down_write(io-io_rwsem);
 
/* change META to META_FLUSH in the checkpoint procedure */
if (type = META_FLUSH) {
@@ -142,7 +142,7 @@ void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
io-fio.rw = WRITE_FLUSH_FUA | REQ_META | REQ_PRIO;
}
__submit_merged_bio(io);
-   mutex_unlock(io-io_mutex);
+   up_write(io-io_rwsem);
 }
 
 /*
@@ -180,7 +180,7 @@ void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct 
page *page,
 
verify_block_addr(sbi, blk_addr);
 
-   mutex_lock(io-io_mutex);
+   down_write(io-io_rwsem);
 
if (!is_read)
inc_page_count(sbi, F2FS_WRITEBACK);
@@ -204,7 +204,7 @@ alloc_new:
 
io-last_block_in_bio = blk_addr;
 
-   mutex_unlock(io-io_mutex);
+   up_write(io-io_rwsem);
trace_f2fs_submit_page_mbio(page, fio-rw, fio-type, blk_addr);
 }
 
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f83433e..1e3d869 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -394,7 +394,7 @@ struct f2fs_bio_info {
struct bio *bio;/* bios to merge */
sector_t last_block_in_bio; /* last block number */
struct f2fs_io_info fio;/* store buffered io info. */
-   struct mutex io_mutex;  /* mutex for bio */
+   struct rw_semaphore io_rwsem;   /* blocking op for bio */
 };
 
 struct f2fs_sb_info {
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index e7ff23a..570ab9a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1046,12 +1046,38 @@ void rewrite_node_page(struct f2fs_sb_info *sbi,
mutex_unlock(curseg-curseg_mutex);
 }
 
+static inline bool is_merged_page(struct f2fs_sb_info *sbi,
+   struct page *page, enum page_type type)
+{
+   enum page_type btype = PAGE_TYPE_OF_BIO(type);
+   struct f2fs_bio_info *io = sbi-write_io[btype];
+   struct bio *bio = io-bio;
+   struct bio_vec *bvec;
+   int i;
+
+   down_read(io-io_rwsem);
+   if (!bio)
+   goto out;
+
+   bio_for_each_segment_all(bvec, bio, i) {
+   if (page == bvec-bv_page) {
+   up_read(io-io_rwsem);
+   return true;
+   }
+   }
+
+out:
+   up_read(io-io_rwsem);
+   return false;
+}
+
 void f2fs_wait_on_page_writeback(struct page *page,
enum page_type type)
 {
struct f2fs_sb_info *sbi = F2FS_SB(page-mapping-host-i_sb);
if (PageWriteback(page)) {
-   f2fs_submit_merged_bio(sbi, type, WRITE);
+   if (is_merged_page(sbi, page, type))
+   f2fs_submit_merged_bio(sbi, type, WRITE);
wait_on_page_writeback(page);
}
 }
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 89ea046..9598340 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -920,11 +920,11 @@ static int f2fs_fill_super(struct super_block *sb, void 
*data, int silent)
sbi-por_doing = false;
spin_lock_init(sbi-stat_lock);
 
-   mutex_init(sbi-read_io.io_mutex);
+   init_rwsem(sbi-read_io.io_rwsem);
sbi-read_io.sbi = sbi;
sbi-read_io.bio = NULL;
for (i = 0; i  NR_PAGE_TYPE; i++) {
-   mutex_init(sbi-write_io[i].io_mutex);
+   init_rwsem(sbi-write_io[i].io_rwsem);
sbi-write_io[i].sbi = sbi;
sbi-write_io[i].bio = NULL;
}
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH 2/2] f2fs: avoid unneeded lookup when xattr name length is too long

2014-03-22 Thread Chao Yu
In f2fs_setxattr we have limit this attribute name length, so we should also
check it in f2fs_getxattr to avoid useless lookup caused by invalid name length.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/xattr.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 0121e45..503c245 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -407,6 +407,8 @@ int f2fs_getxattr(struct inode *inode, int name_index, 
const char *name,
if (name == NULL)
return -EINVAL;
name_len = strlen(name);
+   if (name_len  F2FS_NAME_LEN)
+   return -ERANGE;
 
base_addr = read_all_xattrs(inode, NULL);
if (!base_addr)
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: fix calculating incorrect free size when update xattr in __f2fs_setxattr

2013-10-29 Thread Chao Yu
During xattr updating, free size should be corrected to remainder free size
+ old entry size.
It can avoid ENOSPC error when we update old entry with the same size new
entry at fully filled xattr.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/xattr.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index f685138..35eb478 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -520,7 +520,7 @@ static int __f2fs_setxattr(struct inode *inode, int
name_index,
 */
free = MIN_OFFSET(inode) - ((char *)last - (char
*)base_addr);
if (found)
-   free = free - ENTRY_SIZE(here);
+   free = free + ENTRY_SIZE(here);
 
if (free  newsize) {
error = -ENOSPC;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros bitmap with bitops for better mount performance

2013-10-29 Thread Chao Yu
Previously, check_block_count check valid_map with bit data type in common 
scenario that sit has all ones or zeros bitmap, it makes low mount performance.
So let's check the special bitmap with integer data type instead of the bit one.

v1--v2:
use find_next_{zero_}bit_le for better performance and readable as Jaegeuk 
suggested.
use neat logogram in comment as Gu Zheng suggested.
search continuous ones or zeros for better performance when checking 
mixed bitmap.

Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
Signed-off-by: Shu Tan shu@samsung.com
Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/segment.h |   19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index abe7094..a7abfa8 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -550,8 +550,9 @@ static inline void check_block_count(struct f2fs_sb_info 
*sbi,
 {
struct f2fs_sm_info *sm_info = SM_I(sbi);
unsigned int end_segno = sm_info-segment_count - 1;
+   bool is_valid  = test_bit_le(0, raw_sit-valid_map) ? true : false;
int valid_blocks = 0;
-   int i;
+   int cur_pos = 0, next_pos;
 
/* check segment usage */
BUG_ON(GET_SIT_VBLOCKS(raw_sit)  sbi-blocks_per_seg);
@@ -560,9 +561,19 @@ static inline void check_block_count(struct f2fs_sb_info 
*sbi,
BUG_ON(segno  end_segno);
 
/* check bitmap with valid block count */
-   for (i = 0; i  sbi-blocks_per_seg; i++)
-   if (f2fs_test_bit(i, raw_sit-valid_map))
-   valid_blocks++;
+   do {
+   if (is_valid) {
+   next_pos = find_next_zero_bit_le(raw_sit-valid_map,
+   sbi-blocks_per_seg,
+   cur_pos);
+   valid_blocks += next_pos - cur_pos;
+   } else
+   next_pos = find_next_bit_le(raw_sit-valid_map,
+   sbi-blocks_per_seg,
+   cur_pos);
+   cur_pos = next_pos;
+   is_valid = !is_valid;
+   } while (cur_pos  sbi-blocks_per_seg);
BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros bitmap with bitops for better mount performance

2013-10-29 Thread Chao Yu
Hi Lee,

It's a good point.

Firstly, In your patch:
/* check bitmap with valid block count */
for (i = 0; i  sbi-blocks_per_seg; i++)
-   if (f2fs_test_bit(i, raw_sit-valid_map))
-   valid_blocks++;
+   valid_blocks += bit_count_byte(raw_sit-valid_map[i]);
+
BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);
 }

for (i = 0; i  sbi-blocks_per_seg; i++)
should be replace with
for (i = 0; i  SIT_VBLOCK_MAP_SIZE; i++)

Secondly, I tested your patch and mine
with SD and emmc with all zeros bitmap.
It shows my patch takes litter time.
Could you test and compare the performance of two patches.

-- 
1.7.10.4


 -Original Message-
 From: Changman Lee [mailto:cm224@samsung.com]
 Sent: Tuesday, October 29, 2013 3:36 PM
 To: 'Chao Yu'; jaegeuk@samsung.com
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: RE: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros
bitmap
 with bitops for better mount performance
 
 Review attached patch, please.
 
 -Original Message-
 From: Chao Yu [mailto:chao2...@samsung.com]
 Sent: Tuesday, October 29, 2013 3:51 PM
 To: jaegeuk@samsung.com
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros bitmap
with
 bitops for better mount performance
 
 Previously, check_block_count check valid_map with bit data type in common
 scenario that sit has all ones or zeros bitmap, it makes low mount
 performance.
 So let's check the special bitmap with integer data type instead of the
bit one.
 
 v1--v2:
 use find_next_{zero_}bit_le for better performance and readable as
 Jaegeuk suggested.
   use neat logogram in comment as Gu Zheng suggested.
   search continuous ones or zeros for better performance when checking
 mixed bitmap.
 
 Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
 Signed-off-by: Shu Tan shu@samsung.com
 Signed-off-by: Chao Yu chao2...@samsung.com
 ---
  fs/f2fs/segment.h |   19 +++
  1 file changed, 15 insertions(+), 4 deletions(-)
 
 diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index abe7094..a7abfa8
 100644
 --- a/fs/f2fs/segment.h
 +++ b/fs/f2fs/segment.h
 @@ -550,8 +550,9 @@ static inline void check_block_count(struct
 f2fs_sb_info *sbi,  {
   struct f2fs_sm_info *sm_info = SM_I(sbi);
   unsigned int end_segno = sm_info-segment_count - 1;
 + bool is_valid  = test_bit_le(0, raw_sit-valid_map) ? true : false;
   int valid_blocks = 0;
 - int i;
 + int cur_pos = 0, next_pos;
 
   /* check segment usage */
   BUG_ON(GET_SIT_VBLOCKS(raw_sit)  sbi-blocks_per_seg); @@ -560,9
 +561,19 @@ static inline void check_block_count(struct f2fs_sb_info
 +*sbi,
   BUG_ON(segno  end_segno);
 
   /* check bitmap with valid block count */
 - for (i = 0; i  sbi-blocks_per_seg; i++)
 - if (f2fs_test_bit(i, raw_sit-valid_map))
 - valid_blocks++;
 + do {
 + if (is_valid) {
 + next_pos =
 find_next_zero_bit_le(raw_sit-valid_map,
 + sbi-blocks_per_seg,
 + cur_pos);
 + valid_blocks += next_pos - cur_pos;
 + } else
 + next_pos = find_next_bit_le(raw_sit-valid_map,
 + sbi-blocks_per_seg,
 + cur_pos);
 + cur_pos = next_pos;
 + is_valid = !is_valid;
 + } while (cur_pos  sbi-blocks_per_seg);
   BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);  }
 
 --
 1.7.9.5
 
 


 --
 Android is increasing in popularity, but the open development platform
that
 developers love is also attractive to malware creators. Download this
white
 paper to learn more about secure code signing practices that can help keep
 Android apps secure.
 http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktr
 k
 ___
 Linux-f2fs-devel mailing list
 linux-f2fs-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros bitmap with bitops for better mount performance

2013-10-29 Thread Chao Yu
Hi Lee,

 -Original Message-
 From: Changman Lee [mailto:cm224@samsung.com]
 Sent: Tuesday, October 29, 2013 3:36 PM
 To: 'Chao Yu'; jaegeuk@samsung.com
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: RE: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros
bitmap
 with bitops for better mount performance
 
 Review attached patch, please.

Could we hide the pre calculated value by generating it in allocated memory
by func,
because the value will be no use after build_sit_entries();

Regards
Yu

 
 -Original Message-
 From: Chao Yu [mailto:chao2...@samsung.com]
 Sent: Tuesday, October 29, 2013 3:51 PM
 To: jaegeuk@samsung.com
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros bitmap
with
 bitops for better mount performance
 
 Previously, check_block_count check valid_map with bit data type in common
 scenario that sit has all ones or zeros bitmap, it makes low mount
 performance.
 So let's check the special bitmap with integer data type instead of the
bit one.
 
 v1--v2:
 use find_next_{zero_}bit_le for better performance and readable as
 Jaegeuk suggested.
   use neat logogram in comment as Gu Zheng suggested.
   search continuous ones or zeros for better performance when checking
 mixed bitmap.
 
 Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
 Signed-off-by: Shu Tan shu@samsung.com
 Signed-off-by: Chao Yu chao2...@samsung.com
 ---
  fs/f2fs/segment.h |   19 +++
  1 file changed, 15 insertions(+), 4 deletions(-)
 
 diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index abe7094..a7abfa8
 100644
 --- a/fs/f2fs/segment.h
 +++ b/fs/f2fs/segment.h
 @@ -550,8 +550,9 @@ static inline void check_block_count(struct
 f2fs_sb_info *sbi,  {
   struct f2fs_sm_info *sm_info = SM_I(sbi);
   unsigned int end_segno = sm_info-segment_count - 1;
 + bool is_valid  = test_bit_le(0, raw_sit-valid_map) ? true : false;
   int valid_blocks = 0;
 - int i;
 + int cur_pos = 0, next_pos;
 
   /* check segment usage */
   BUG_ON(GET_SIT_VBLOCKS(raw_sit)  sbi-blocks_per_seg); @@ -560,9
 +561,19 @@ static inline void check_block_count(struct f2fs_sb_info
 +*sbi,
   BUG_ON(segno  end_segno);
 
   /* check bitmap with valid block count */
 - for (i = 0; i  sbi-blocks_per_seg; i++)
 - if (f2fs_test_bit(i, raw_sit-valid_map))
 - valid_blocks++;
 + do {
 + if (is_valid) {
 + next_pos =
 find_next_zero_bit_le(raw_sit-valid_map,
 + sbi-blocks_per_seg,
 + cur_pos);
 + valid_blocks += next_pos - cur_pos;
 + } else
 + next_pos = find_next_bit_le(raw_sit-valid_map,
 + sbi-blocks_per_seg,
 + cur_pos);
 + cur_pos = next_pos;
 + is_valid = !is_valid;
 + } while (cur_pos  sbi-blocks_per_seg);
   BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);  }
 
 --
 1.7.9.5
 
 


 --
 Android is increasing in popularity, but the open development platform
that
 developers love is also attractive to malware creators. Download this
white
 paper to learn more about secure code signing practices that can help keep
 Android apps secure.
 http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktr
 k
 ___
 Linux-f2fs-devel mailing list
 linux-f2fs-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros bitmap with bitops for better mount performance

2013-10-29 Thread Chao Yu
Hi Lee,

 -Original Message-
 From: Changman Lee [mailto:cm224@samsung.com]
 Sent: Wednesday, October 30, 2013 7:25 AM
 To: 'Chao Yu'; jaegeuk@samsung.com
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: RE: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros 
 bitmap with
bitops for
 better mount performance
 
 
 As you know, if any data or function are used once, we can use some keywords
 like __initdata for data and __init for function.

Thanks for reminding me that.
I just think of that generating tmp data by func could save memory use or keep 
program
size small.

Regards
Yu

 
 
 -Original Message-
 From: Chao Yu [mailto:chao2...@samsung.com]
 Sent: Tuesday, October 29, 2013 7:52 PM
 To: 'Changman Lee'; jaegeuk@samsung.com
 Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: RE: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros
 bitmap with bitops for better mount performance
 
 Hi Lee,
 
  -Original Message-
  From: Changman Lee [mailto:cm224@samsung.com]
  Sent: Tuesday, October 29, 2013 3:36 PM
  To: 'Chao Yu'; jaegeuk@samsung.com
  Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
  linux-f2fs-de...@lists.sourceforge.net
  Subject: RE: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or
  zeros
 bitmap
  with bitops for better mount performance
 
  Review attached patch, please.
 
 Could we hide the pre calculated value by generating it in allocated memory
 by func, because the value will be no use after build_sit_entries();
 
 Regards
 Yu
 
 
  -Original Message-
  From: Chao Yu [mailto:chao2...@samsung.com]
  Sent: Tuesday, October 29, 2013 3:51 PM
  To: jaegeuk@samsung.com
  Cc: linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org;
  linux-f2fs-de...@lists.sourceforge.net
  Subject: [f2fs-dev] [PATCH V2 RESEND] f2fs: check all ones or zeros
  bitmap
 with
  bitops for better mount performance
 
  Previously, check_block_count check valid_map with bit data type in
  common scenario that sit has all ones or zeros bitmap, it makes low
  mount performance.
  So let's check the special bitmap with integer data type instead of
  the
 bit one.
 
  v1--v2:
  use find_next_{zero_}bit_le for better performance and readable as
  Jaegeuk suggested.
  use neat logogram in comment as Gu Zheng suggested.
  search continuous ones or zeros for better performance when checking
 
  mixed bitmap.
 
  Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
  Signed-off-by: Shu Tan shu@samsung.com
  Signed-off-by: Chao Yu chao2...@samsung.com
  ---
   fs/f2fs/segment.h |   19 +++
   1 file changed, 15 insertions(+), 4 deletions(-)
 
  diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index
  abe7094..a7abfa8
  100644
  --- a/fs/f2fs/segment.h
  +++ b/fs/f2fs/segment.h
  @@ -550,8 +550,9 @@ static inline void check_block_count(struct
  f2fs_sb_info *sbi,  {
  struct f2fs_sm_info *sm_info = SM_I(sbi);
  unsigned int end_segno = sm_info-segment_count - 1;
  +   bool is_valid  = test_bit_le(0, raw_sit-valid_map) ? true : false;
  int valid_blocks = 0;
  -   int i;
  +   int cur_pos = 0, next_pos;
 
  /* check segment usage */
  BUG_ON(GET_SIT_VBLOCKS(raw_sit)  sbi-blocks_per_seg); @@ -560,9
  +561,19 @@ static inline void check_block_count(struct f2fs_sb_info
  +*sbi,
  BUG_ON(segno  end_segno);
 
  /* check bitmap with valid block count */
  -   for (i = 0; i  sbi-blocks_per_seg; i++)
  -   if (f2fs_test_bit(i, raw_sit-valid_map))
  -   valid_blocks++;
  +   do {
  +   if (is_valid) {
  +   next_pos =
  find_next_zero_bit_le(raw_sit-valid_map,
  +   sbi-blocks_per_seg,
  +   cur_pos);
  +   valid_blocks += next_pos - cur_pos;
  +   } else
  +   next_pos = find_next_bit_le(raw_sit-valid_map,
  +   sbi-blocks_per_seg,
  +   cur_pos);
  +   cur_pos = next_pos;
  +   is_valid = !is_valid;
  +   } while (cur_pos  sbi-blocks_per_seg);
  BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);  }
 
  --
  1.7.9.5
 
 
 
 
  --
  Android is increasing in popularity, but the open development platform
 that
  developers love is also attractive to malware creators. Download this
 white
  paper to learn more about secure code signing practices that can help
  keep Android apps secure.
  http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.c
  lktr
  k
  ___
  Linux-f2fs-devel mailing list
  linux-f2fs-de...@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

[f2fs-dev] [PATCH] f2fs: remove unnecessary TestClearPageError when wait pages writeback

2013-11-03 Thread Chao Yu
In wait_on_node_pages_writeback we will test and clear error flag for all pages 
in radix tree, but not necessary.
So we only do this for pages belong to the specified inode.

Signed-off-by: Chao Yu chao2...@samsung.com
---
 fs/f2fs/node.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index b527ed4..4ac4150 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1170,10 +1170,11 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info 
*sbi, nid_t ino)
if (page-index  end)
continue;
 
-   if (ino  ino_of_node(page) == ino)
+   if (ino  ino_of_node(page) == ino) {
wait_on_page_writeback(page);
-   if (TestClearPageError(page))
-   ret = -EIO;
+   if (TestClearPageError(page))
+   ret = -EIO;
+   }
}
pagevec_release(pvec);
cond_resched();
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: check all ones or zeros bitmap with integer data type for better mount performance

2013-10-22 Thread Chao Yu
Previously, check_block_count check valid_map with bit data type in common
scenario that sit has all ones or zeros bitmap, it makes low mount
performance.
So let's check the special bitmap with integer data type instead of the bit
one.

Signed-off-by: Tan Shu shu@samsung.com
Signed-off-by: Yu Chao chao2...@samsung.com
---
 fs/f2fs/segment.h |   13 +
 1 file changed, 13 insertions(+)

diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 7f94d78..d43ab9f 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -543,6 +543,7 @@ static inline void check_block_count(struct f2fs_sb_info
*sbi,
 {
struct f2fs_sm_info *sm_info = SM_I(sbi);
unsigned int end_segno = sm_info-segment_count - 1;
+   int *valid_map = (int *)raw_sit-valid_map;
int valid_blocks = 0;
int i;
 
@@ -552,6 +553,19 @@ static inline void check_block_count(struct
f2fs_sb_info *sbi,
/* check boundary of a given segment number */
BUG_ON(segno  end_segno);
 
+   /* check all ones or zeros valid_map */
+   if (GET_SIT_VBLOCKS(raw_sit) == 0) {
+   for (i = 0; i  SIT_VBLOCK_MAP_SIZE / sizeof(int); i++)
+   if (unlikely(valid_map[i] != 0))
+   BUG();
+   return;
+   } else if (GET_SIT_VBLOCKS(raw_sit) == sbi-blocks_per_seg) {
+   for (i = 0; i  SIT_VBLOCK_MAP_SIZE / sizeof(int); i++)
+   if (unlikely(valid_map[i] != -1))
+   BUG();
+   return;
+   }
+
/* check bitmap with valid block count */
for (i = 0; i  sbi-blocks_per_seg; i++)
if (f2fs_test_bit(i, raw_sit-valid_map))
---

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: check all ones or zeros bitmap with integer data type for better mount performance

2013-10-22 Thread Chao Yu
Hi, Kim:

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Tuesday, October 22, 2013 8:24 PM
 To: Chao Yu
 Cc: linux-f2fs-de...@lists.sourceforge.net; linux-fsde...@vger.kernel.org;
 linux-kernel@vger.kernel.org; 谭姝
 Subject: Re: [f2fs-dev] [PATCH] f2fs: check all ones or zeros bitmap with 
 integer
 data type for better mount performance
 
 Hi,
 
 2013-10-22 (화), 17:28 +0800, Chao Yu:
  Previously, check_block_count check valid_map with bit data type in
  common scenario that sit has all ones or zeros bitmap, it makes low
  mount performance.
  So let's check the special bitmap with integer data type instead of
  the bit one.
 
  Signed-off-by: Tan Shu shu@samsung.com
  Signed-off-by: Yu Chao chao2...@samsung.com
  ---
   fs/f2fs/segment.h |   13 +
   1 file changed, 13 insertions(+)
 
  diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index
  7f94d78..d43ab9f 100644
  --- a/fs/f2fs/segment.h
  +++ b/fs/f2fs/segment.h
  @@ -543,6 +543,7 @@ static inline void check_block_count(struct
  f2fs_sb_info *sbi,  {
  struct f2fs_sm_info *sm_info = SM_I(sbi);
  unsigned int end_segno = sm_info-segment_count - 1;
  +   int *valid_map = (int *)raw_sit-valid_map;
  int valid_blocks = 0;
  int i;
 
  @@ -552,6 +553,19 @@ static inline void check_block_count(struct
  f2fs_sb_info *sbi,
  /* check boundary of a given segment number */
  BUG_ON(segno  end_segno);
 
  +   /* check all ones or zeros valid_map */
  +   if (GET_SIT_VBLOCKS(raw_sit) == 0) {
  +   for (i = 0; i  SIT_VBLOCK_MAP_SIZE / sizeof(int); i++)
 
 We cannot guarantee all the time that SIT_VBLOCK_MAP_SIZE is multiple of
 sizeof(int).
Well, It's really large changes for f2fs if SIT_VBLOCK_MAP_SIZE value is being 
modified.

 How about using memcmp() with __u8?
Do you mean that we can alloc all zeros or ones memory in SIT_VBLOCK_MAP_SIZE 
size,
then memcmp() it with sit bitmap by __u8?

 
  +   if (unlikely(valid_map[i] != 0))
  +   BUG();
  +   return;
  +   } else if (GET_SIT_VBLOCKS(raw_sit) == sbi-blocks_per_seg) {
  +   for (i = 0; i  SIT_VBLOCK_MAP_SIZE / sizeof(int); i++)
  +   if (unlikely(valid_map[i] != -1))
  +   BUG();
  +   return;
  +   }
  +
  /* check bitmap with valid block count */
  for (i = 0; i  sbi-blocks_per_seg; i++)
  if (f2fs_test_bit(i, raw_sit-valid_map))
  ---
 
  --
  To unsubscribe from this list: send the line unsubscribe
  linux-fsdevel in the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH] f2fs: check all ones or zeros bitmap with integer data type for better mount performance

2013-10-23 Thread Chao Yu
Hi Kim,

 -Original Message-
 From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
 Sent: Wednesday, October 23, 2013 5:32 PM
 To: Chao Yu
 Cc: linux-f2fs-de...@lists.sourceforge.net; linux-fsde...@vger.kernel.org;
 linux-kernel@vger.kernel.org; '谭姝'
 Subject: RE: [f2fs-dev] [PATCH] f2fs: check all ones or zeros bitmap with 
 integer
 data type for better mount performance
 
 Hi,
 
 2013-10-23 (수), 11:23 +0800, Chao Yu:
  Hi, Kim:
 
   -Original Message-
   From: Jaegeuk Kim [mailto:jaegeuk@samsung.com]
   Sent: Tuesday, October 22, 2013 8:24 PM
   To: Chao Yu
   Cc: linux-f2fs-de...@lists.sourceforge.net;
   linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org; 谭姝
   Subject: Re: [f2fs-dev] [PATCH] f2fs: check all ones or zeros bitmap
   with integer data type for better mount performance
  
   Hi,
  
   2013-10-22 (화), 17:28 +0800, Chao Yu:
Previously, check_block_count check valid_map with bit data type
in common scenario that sit has all ones or zeros bitmap, it makes
low mount performance.
So let's check the special bitmap with integer data type instead
of the bit one.
   
Signed-off-by: Tan Shu shu@samsung.com
Signed-off-by: Yu Chao chao2...@samsung.com
---
 fs/f2fs/segment.h |   13 +
 1 file changed, 13 insertions(+)
   
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index
7f94d78..d43ab9f 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -543,6 +543,7 @@ static inline void check_block_count(struct
f2fs_sb_info *sbi,  {
struct f2fs_sm_info *sm_info = SM_I(sbi);
unsigned int end_segno = sm_info-segment_count - 1;
+   int *valid_map = (int *)raw_sit-valid_map;
int valid_blocks = 0;
int i;
   
@@ -552,6 +553,19 @@ static inline void check_block_count(struct
f2fs_sb_info *sbi,
/* check boundary of a given segment number */
BUG_ON(segno  end_segno);
   
+   /* check all ones or zeros valid_map */
+   if (GET_SIT_VBLOCKS(raw_sit) == 0) {
+   for (i = 0; i  SIT_VBLOCK_MAP_SIZE / sizeof(int); i++)
  
   We cannot guarantee all the time that SIT_VBLOCK_MAP_SIZE is
   multiple of sizeof(int).
  Well, It's really large changes for f2fs if SIT_VBLOCK_MAP_SIZE value is 
  being
 modified.
 
 But, it can be changed.
 Please do not add any unnecessary assumption.
Got it, sorry for the unmeaning assumption.

 
 
   How about using memcmp() with __u8?
  Do you mean that we can alloc all zeros or ones memory in
  SIT_VBLOCK_MAP_SIZE size, then memcmp() it with sit bitmap by __u8?
 
 Yap.
 Ah, but there is another one.
 It would be better to use find_next_bit_le() and find_next_zero_bit_le().
 Any idea?
Good point.
I try to use memcmp(bitmap, bitmap+1, size-1) and bitmap[0], 
But yours got better performance and readable.
Thanks.

 
 
  
+   if (unlikely(valid_map[i] != 0))
+   BUG();
+   return;
+   } else if (GET_SIT_VBLOCKS(raw_sit) == sbi-blocks_per_seg) {
+   for (i = 0; i  SIT_VBLOCK_MAP_SIZE / sizeof(int); i++)
+   if (unlikely(valid_map[i] != -1))
+   BUG();
+   return;
+   }
+
/* check bitmap with valid block count */
for (i = 0; i  sbi-blocks_per_seg; i++)
if (f2fs_test_bit(i, raw_sit-valid_map))
---
   
--
To unsubscribe from this list: send the line unsubscribe
linux-fsdevel in the body of a message to
majord...@vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html
  
   --
   Jaegeuk Kim
   Samsung
 
 
 --
 Jaegeuk Kim
 Samsung

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: remove redundant set_page_dirty from write_compacted_summaries

2013-10-24 Thread Chao Yu
Previously, set_page_dirty is called every time after writting one summary info 
into compacted summary page,
To avoid redundant set_page_dirty, we only call set_page_dirty before release 
page.

Signed-off-by: Yu Chao chao2...@samsung.com
---
 fs/f2fs/segment.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 3b20359..bdd53d0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1128,8 +1128,6 @@ static void write_compacted_summaries(struct f2fs_sb_info 
*sbi, block_t blkaddr)
SUM_JOURNAL_SIZE);
written_size += SUM_JOURNAL_SIZE;
 
-   set_page_dirty(page);
-
/* Step 3: write summary entries */
for (i = CURSEG_HOT_DATA; i = CURSEG_COLD_DATA; i++) {
unsigned short blkoff;
@@ -1148,18 +1146,20 @@ static void write_compacted_summaries(struct 
f2fs_sb_info *sbi, block_t blkaddr)
summary = (struct f2fs_summary *)(kaddr + written_size);
*summary = seg_i-sum_blk-entries[j];
written_size += SUMMARY_SIZE;
-   set_page_dirty(page);
 
if (written_size + SUMMARY_SIZE = PAGE_CACHE_SIZE -
SUM_FOOTER_SIZE)
continue;
 
+   set_page_dirty(page);
f2fs_put_page(page, 1);
page = NULL;
}
}
-   if (page)
+   if (page) {
+   set_page_dirty(page);
f2fs_put_page(page, 1);
+   }
 }
 
 static void write_normal_summaries(struct f2fs_sb_info *sbi,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH V2] f2fs: check all ones or zeros bitmap with bitops for better mount performance

2013-10-24 Thread Chao Yu
Previously, check_block_count check valid_map with bit data type in common 
scenario that sit has all ones or zeros bitmap, it makes low mount performance.
So let's check the special bitmap with integer data type instead of the bit one.

v2:
use find_next_bit_le/find_next_zero_bit_le for better performance and 
readable as Jaegeuk suggested.

Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
Signed-off-by: Tan Shu shu@samsung.com
Signed-off-by: Yu Chao chao2...@samsung.com
---
 fs/f2fs/segment.h |   17 +
 1 file changed, 17 insertions(+)

diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 7f94d78..d25b6af 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -552,6 +552,23 @@ static inline void check_block_count(struct f2fs_sb_info 
*sbi,
/* check boundary of a given segment number */
BUG_ON(segno  end_segno);
 
+   /* check all ones or zeros valid_map */
+   if (GET_SIT_VBLOCKS(raw_sit) == 0) {
+   int pos = find_next_bit_le(raw_sit-valid_map,
+   sbi-blocks_per_seg,
+   0);
+   if (pos != sbi-blocks_per_seg)
+   BUG();
+   return;
+   } else if (GET_SIT_VBLOCKS(raw_sit) == sbi-blocks_per_seg) {
+   int pos = find_next_zero_bit_le(raw_sit-valid_map,
+   sbi-blocks_per_seg,
+   0);
+   if (pos != sbi-blocks_per_seg)
+   BUG();
+   return;
+   }
+
/* check bitmap with valid block count */
for (i = 0; i  sbi-blocks_per_seg; i++)
if (f2fs_test_bit(i, raw_sit-valid_map))
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2] f2fs: check all ones or zeros bitmap with bitops for better mount performance

2013-10-24 Thread Chao Yu
Hi Gu,

 -Original Message-
 From: Gu Zheng [mailto:guz.f...@cn.fujitsu.com]
 Sent: Thursday, October 24, 2013 6:04 PM
 To: Chao Yu
 Cc: jaegeuk@samsung.com; linux-fsde...@vger.kernel.org;
 linux-kernel@vger.kernel.org; linux-f2fs-de...@lists.sourceforge.net; '谭姝'
 Subject: Re: [f2fs-dev] [PATCH V2] f2fs: check all ones or zeros bitmap with
 bitops for better mount performance
 
 Hi Yu,
 On 10/24/2013 04:21 PM, Chao Yu wrote:
 
  Previously, check_block_count check valid_map with bit data type in common
 scenario that sit has all ones or zeros bitmap, it makes low mount
 performance.
  So let's check the special bitmap with integer data type instead of the bit 
  one.
 
  v2:
  use find_next_bit_le/find_next_zero_bit_le for better performance and
 readable as Jaegeuk suggested.
 
 If so, how about using find_first_{zero_}bit_le instead? It's more neat.
It seems more neat. I will take it, thanks.

 
 Regards,
 Gu
 
 
  Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
  Signed-off-by: Tan Shu shu@samsung.com
  Signed-off-by: Yu Chao chao2...@samsung.com
  ---
   fs/f2fs/segment.h |   17 +
   1 file changed, 17 insertions(+)
 
  diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index
  7f94d78..d25b6af 100644
  --- a/fs/f2fs/segment.h
  +++ b/fs/f2fs/segment.h
  @@ -552,6 +552,23 @@ static inline void check_block_count(struct
 f2fs_sb_info *sbi,
  /* check boundary of a given segment number */
  BUG_ON(segno  end_segno);
 
  +   /* check all ones or zeros valid_map */
  +   if (GET_SIT_VBLOCKS(raw_sit) == 0) {
  +   int pos = find_next_bit_le(raw_sit-valid_map,
  +   sbi-blocks_per_seg,
  +   0);
  +   if (pos != sbi-blocks_per_seg)
  +   BUG();
  +   return;
  +   } else if (GET_SIT_VBLOCKS(raw_sit) == sbi-blocks_per_seg) {
  +   int pos = find_next_zero_bit_le(raw_sit-valid_map,
  +   sbi-blocks_per_seg,
  +   0);
  +   if (pos != sbi-blocks_per_seg)
  +   BUG();
  +   return;
  +   }
  +
  /* check bitmap with valid block count */
  for (i = 0; i  sbi-blocks_per_seg; i++)
  if (f2fs_test_bit(i, raw_sit-valid_map))


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH V2] f2fs: check all ones or zeros bitmap with bitops for better mount performance

2013-10-28 Thread Chao Yu
Hi Lee,

 -Original Message-
 From: 이창만 [mailto:cm224@samsung.com]
 Sent: Monday, October 28, 2013 10:20 AM
 To: 'Chao Yu'; jaegeuk@samsung.com
 Cc: linux-fsde...@vger.kernel.org; '谭姝'; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: RE: [f2fs-dev] [PATCH V2] f2fs: check all ones or zeros bitmap with
 bitops for better mount performance
 
 To check whether bitmap are all zeros or all ones, I think memcmp is more
 neat.
 But I don't know exactly performance gap between memcmp and
 find_next_bit.

With the result of my test, find_next_bit takes less time than memcmp.
If we could use {test, set, clear}_bit_le intead of f2fs_{test, set, 
clear}_bit, the following patch
could be used for better performance.
This one is better than the V2 patch for performance with mixed bitmap in my 
test.

diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 7f94d78..32153eb
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -544,7 +544,8 @@ static inline void check_block_count(struct f2fs_sb_info 
*sbi,
struct f2fs_sm_info *sm_info = SM_I(sbi);
unsigned int end_segno = sm_info-segment_count - 1;
int valid_blocks = 0;
-   int i;
+   int i, cur_pos = 0, next_pos;
+   bool is_valid;
 
/* check segment usage */
BUG_ON(GET_SIT_VBLOCKS(raw_sit)  sbi-blocks_per_seg);
@@ -553,9 +554,21 @@ static inline void check_block_count(struct f2fs_sb_info 
*sbi,
BUG_ON(segno  end_segno);
 
/* check bitmap with valid block count */
-   for (i = 0; i  sbi-blocks_per_seg; i++)
-   if (f2fs_test_bit(i, raw_sit-valid_map))
-   valid_blocks++;
+   cur_pos = 0;
+   is_valid = test_bit_le(0, raw_sit-valid_map) ? true : false;
+   do {
+   if (is_valid) {
+   next_pos = find_next_zero_bit_le(raw_sit-valid_map,
+   sbi-blocks_per_seg,
+   cur_pos);
+   valid_blocks += next_pos - cur_pos;
+   } else
+   next_pos = find_next_bit_le(raw_sit-valid_map,
+   sbi-blocks_per_seg,
+   cur_pos);
+   cur_pos = next_pos;
+   is_valid = !is_valid;
+   } while (cur_pos  sbi-blocks_per_seg);
BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);
 }
 
 
 -Original Message-
 From: Chao Yu [mailto:chao2...@samsung.com]
 Sent: Thursday, October 24, 2013 5:21 PM
 To: jaegeuk@samsung.com
 Cc: linux-fsde...@vger.kernel.org; '谭姝'; linux-kernel@vger.kernel.org;
 linux-f2fs-de...@lists.sourceforge.net
 Subject: [f2fs-dev] [PATCH V2] f2fs: check all ones or zeros bitmap with 
 bitops
 for better mount performance
 
 Previously, check_block_count check valid_map with bit data type in common
 scenario that sit has all ones or zeros bitmap, it makes low mount
 performance.
 So let's check the special bitmap with integer data type instead of the bit 
 one.
 
 v2:
 use find_next_bit_le/find_next_zero_bit_le for better performance and
 readable as Jaegeuk suggested.
 
 Suggested-by: Jaegeuk Kim jaegeuk@samsung.com
 Signed-off-by: Tan Shu shu@samsung.com
 Signed-off-by: Yu Chao chao2...@samsung.com
 ---
  fs/f2fs/segment.h |   17 +
  1 file changed, 17 insertions(+)
 
 diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 7f94d78..d25b6af
 100644
 --- a/fs/f2fs/segment.h
 +++ b/fs/f2fs/segment.h
 @@ -552,6 +552,23 @@ static inline void check_block_count(struct
 f2fs_sb_info *sbi,
   /* check boundary of a given segment number */
   BUG_ON(segno  end_segno);
 
 + /* check all ones or zeros valid_map */
 + if (GET_SIT_VBLOCKS(raw_sit) == 0) {
 + int pos = find_next_bit_le(raw_sit-valid_map,
 + sbi-blocks_per_seg,
 + 0);
 + if (pos != sbi-blocks_per_seg)
 + BUG();
 + return;
 + } else if (GET_SIT_VBLOCKS(raw_sit) == sbi-blocks_per_seg) {
 + int pos = find_next_zero_bit_le(raw_sit-valid_map,
 + sbi-blocks_per_seg,
 + 0);
 + if (pos != sbi-blocks_per_seg)
 + BUG();
 + return;
 + }
 +
   /* check bitmap with valid block count */
   for (i = 0; i  sbi-blocks_per_seg; i++)
   if (f2fs_test_bit(i, raw_sit-valid_map))
 --
 1.7.9.5
 
 
 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140

[f2fs-dev] [PATCH] f2fs: avoid allocating failure in bio_alloc

2013-09-22 Thread Chao Yu
This patch add macro MAX_BIO_BLOCKS to limit value of npages in
f2fs_bio_alloc, it can avoid allocating failure in bio_alloc caused by
npages is larger than BIO_MAX_PAGES.

Signed-off-by: Yu Chao chao2...@samsung.com
---
 fs/f2fs/segment.c |4 +++-
 fs/f2fs/segment.h |2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 09af9c7..bd79bbe 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -657,6 +657,7 @@ static void submit_write_page(struct f2fs_sb_info *sbi,
struct page *page,
block_t blk_addr, enum page_type type)
 {
struct block_device *bdev = sbi-sb-s_bdev;
+   int bio_blocks;
 
verify_block_addr(sbi, blk_addr);
 
@@ -676,7 +677,8 @@ retry:
goto retry;
}
 
-   sbi-bio[type] = f2fs_bio_alloc(bdev, max_hw_blocks(sbi));
+   bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+   sbi-bio[type] = f2fs_bio_alloc(bdev, bio_blocks);
sbi-bio[type]-bi_sector = SECTOR_FROM_BLOCK(sbi,
blk_addr);
sbi-bio[type]-bi_private = priv;
/*
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index bdd10ea..7f94d78 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -90,6 +90,8 @@
(blk_addr  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
 #define SECTOR_TO_BLOCK(sbi, sectors)  \
(sectors  ((sbi)-log_blocksize - F2FS_LOG_SECTOR_SIZE))
+#define MAX_BIO_BLOCKS(max_hw_blocks)  \
+   (min((int)max_hw_blocks, BIO_MAX_PAGES))
 
 /* during checkpoint, bio_private is used to synchronize the last bio */
 struct bio_private {
---

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[f2fs-dev] [PATCH] f2fs: remove unneeded write checkpoint in recover_fsync_data

2013-09-22 Thread Chao Yu
Previously, recover_fsync_data still to write checkpoint when there is
nothing to recover with normal umount image.
It may reduce mount performance and flash memory lifetime, so let's remove
it.

Signed-off-by: Tan Shu shu@samsung.com
Signed-off-by: Yu Chao chao2...@samsung.com
---
 fs/f2fs/recovery.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 51ef5ee..6988e1b 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -419,6 +419,7 @@ int recover_fsync_data(struct f2fs_sb_info *sbi)
 {
struct list_head inode_list;
int err;
+   int is_writecp = 0;
 
fsync_entry_slab = f2fs_kmem_cache_create(f2fs_fsync_inode_entry,
sizeof(struct fsync_inode_entry), NULL);
@@ -436,6 +437,8 @@ int recover_fsync_data(struct f2fs_sb_info *sbi)
if (list_empty(inode_list))
goto out;
 
+   is_writecp = 1;
+
/* step #2: recover data */
err = recover_data(sbi, inode_list, CURSEG_WARM_NODE);
BUG_ON(!list_empty(inode_list));
@@ -443,7 +446,7 @@ out:
destroy_fsync_dnodes(inode_list);
kmem_cache_destroy(fsync_entry_slab);
sbi-por_doing = 0;
-   if (!err)
+   if (!err  is_writecp)
write_checkpoint(sbi, false);
return err;
 }
---

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >