linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] some optimization & code cleanup
@ 2013-06-13  8:59 Haicheng Li
  2013-06-13  8:59 ` [PATCH 1/3] f2fs: remove unnecessary parameter "offset" from __add_sum_entry() Haicheng Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Haicheng Li @ 2013-06-13  8:59 UTC (permalink / raw)
  To: linux-fsdevel, linux-f2fs-devel, Jaegeuk Kim
  Cc: linux-kernel, Haicheng Li, Haicheng Li

Fix some issues found by code review.

Haicheng Li (3):
  f2fs: remove unnecessary parameter "offset" from __add_sum_entry()
  f2fs: make locate_dirty_segment() as static
  f2fs: optimize do_write_data_page()

 fs/f2fs/data.c    |    5 +++--
 fs/f2fs/f2fs.h    |    1 -
 fs/f2fs/segment.c |   12 ++++++------
 3 files changed, 9 insertions(+), 9 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] f2fs: remove unnecessary parameter "offset" from __add_sum_entry()
  2013-06-13  8:59 [PATCH 0/3] some optimization & code cleanup Haicheng Li
@ 2013-06-13  8:59 ` Haicheng Li
  2013-06-13  8:59 ` [f2fs-dev] [PATCH 2/3] f2fs: make locate_dirty_segment() as static Haicheng Li
  2013-06-13  8:59 ` [PATCH 3/3] f2fs: optimize do_write_data_page() Haicheng Li
  2 siblings, 0 replies; 4+ messages in thread
From: Haicheng Li @ 2013-06-13  8:59 UTC (permalink / raw)
  To: linux-fsdevel, linux-f2fs-devel, Jaegeuk Kim
  Cc: linux-kernel, Haicheng Li, Haicheng Li

We can get the value directly from pointer "curseg".

Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
---
 fs/f2fs/segment.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index be668ff..77f31c0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -255,11 +255,11 @@ void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr)
  * This function should be resided under the curseg_mutex lock
  */
 static void __add_sum_entry(struct f2fs_sb_info *sbi, int type,
-		struct f2fs_summary *sum, unsigned short offset)
+					struct f2fs_summary *sum)
 {
 	struct curseg_info *curseg = CURSEG_I(sbi, type);
 	void *addr = curseg->sum_blk;
-	addr += offset * sizeof(struct f2fs_summary);
+	addr += curseg->next_blkoff * sizeof(struct f2fs_summary);
 	memcpy(addr, sum, sizeof(struct f2fs_summary));
 	return;
 }
@@ -845,7 +845,7 @@ static void do_write_page(struct f2fs_sb_info *sbi, struct page *page,
 	 * because, this function updates a summary entry in the
 	 * current summary block.
 	 */
-	__add_sum_entry(sbi, type, sum, curseg->next_blkoff);
+	__add_sum_entry(sbi, type, sum);
 
 	mutex_lock(&sit_i->sentry_lock);
 	__refresh_next_blkoff(sbi, curseg);
@@ -946,7 +946,7 @@ void recover_data_page(struct f2fs_sb_info *sbi,
 
 	curseg->next_blkoff = GET_SEGOFF_FROM_SEG0(sbi, new_blkaddr) &
 					(sbi->blocks_per_seg - 1);
-	__add_sum_entry(sbi, type, sum, curseg->next_blkoff);
+	__add_sum_entry(sbi, type, sum);
 
 	refresh_sit_entry(sbi, old_blkaddr, new_blkaddr);
 
@@ -983,7 +983,7 @@ void rewrite_node_page(struct f2fs_sb_info *sbi,
 	}
 	curseg->next_blkoff = GET_SEGOFF_FROM_SEG0(sbi, new_blkaddr) &
 					(sbi->blocks_per_seg - 1);
-	__add_sum_entry(sbi, type, sum, curseg->next_blkoff);
+	__add_sum_entry(sbi, type, sum);
 
 	/* change the current log to the next block addr in advance */
 	if (next_segno != segno) {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [f2fs-dev] [PATCH 2/3] f2fs: make locate_dirty_segment() as static
  2013-06-13  8:59 [PATCH 0/3] some optimization & code cleanup Haicheng Li
  2013-06-13  8:59 ` [PATCH 1/3] f2fs: remove unnecessary parameter "offset" from __add_sum_entry() Haicheng Li
@ 2013-06-13  8:59 ` Haicheng Li
  2013-06-13  8:59 ` [PATCH 3/3] f2fs: optimize do_write_data_page() Haicheng Li
  2 siblings, 0 replies; 4+ messages in thread
From: Haicheng Li @ 2013-06-13  8:59 UTC (permalink / raw)
  To: linux-fsdevel, linux-f2fs-devel, Jaegeuk Kim; +Cc: Haicheng Li, linux-kernel

It's used only locally and could be static.

Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
---
 fs/f2fs/f2fs.h    |    1 -
 fs/f2fs/segment.c |    2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a05aa65..3e7cb33 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -996,7 +996,6 @@ void destroy_node_manager_caches(void);
  */
 void f2fs_balance_fs(struct f2fs_sb_info *);
 void invalidate_blocks(struct f2fs_sb_info *, block_t);
-void locate_dirty_segment(struct f2fs_sb_info *, unsigned int);
 void clear_prefree_segments(struct f2fs_sb_info *);
 int npages_for_summary_flush(struct f2fs_sb_info *);
 void allocate_new_segments(struct f2fs_sb_info *);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 77f31c0..b15debc 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -94,7 +94,7 @@ static void __remove_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
  * Adding dirty entry into seglist is not critical operation.
  * If a given segment is one of current working segments, it won't be added.
  */
-void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno)
+static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno)
 {
 	struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
 	unsigned short valid_blocks;
-- 
1.7.9.5


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] f2fs: optimize do_write_data_page()
  2013-06-13  8:59 [PATCH 0/3] some optimization & code cleanup Haicheng Li
  2013-06-13  8:59 ` [PATCH 1/3] f2fs: remove unnecessary parameter "offset" from __add_sum_entry() Haicheng Li
  2013-06-13  8:59 ` [f2fs-dev] [PATCH 2/3] f2fs: make locate_dirty_segment() as static Haicheng Li
@ 2013-06-13  8:59 ` Haicheng Li
  2 siblings, 0 replies; 4+ messages in thread
From: Haicheng Li @ 2013-06-13  8:59 UTC (permalink / raw)
  To: linux-fsdevel, linux-f2fs-devel, Jaegeuk Kim
  Cc: linux-kernel, Haicheng Li, Haicheng Li

Since "need_inplace_update() == true" is a very rare case, using unlikely()
to give compiler a chance to optimize the code.

Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
---
 fs/f2fs/data.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 5b145fc..6d4a743 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -497,8 +497,9 @@ int do_write_data_page(struct page *page)
 	 * If current allocation needs SSR,
 	 * it had better in-place writes for updated data.
 	 */
-	if (old_blk_addr != NEW_ADDR && !is_cold_data(page) &&
-				need_inplace_update(inode)) {
+	if (unlikely(old_blk_addr != NEW_ADDR &&
+			!is_cold_data(page) &&
+			need_inplace_update(inode))) {
 		rewrite_data_page(F2FS_SB(inode->i_sb), page,
 						old_blk_addr);
 	} else {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-13  8:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13  8:59 [PATCH 0/3] some optimization & code cleanup Haicheng Li
2013-06-13  8:59 ` [PATCH 1/3] f2fs: remove unnecessary parameter "offset" from __add_sum_entry() Haicheng Li
2013-06-13  8:59 ` [f2fs-dev] [PATCH 2/3] f2fs: make locate_dirty_segment() as static Haicheng Li
2013-06-13  8:59 ` [PATCH 3/3] f2fs: optimize do_write_data_page() Haicheng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).