linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] f2fs: introduce __f2fs_commit_super
@ 2015-12-15  9:20 Chao Yu
  2015-12-15 22:19 ` Jaegeuk Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Chao Yu @ 2015-12-15  9:20 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

Introduce __f2fs_commit_super to include duplicated codes in
f2fs_commit_super for cleanup.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/f2fs/super.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2d4fed8..56a160a 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1201,14 +1201,13 @@ next:
 	return 0;
 }
 
-int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
+int __f2fs_commit_super(struct f2fs_sb_info *sbi, int block)
 {
 	struct f2fs_super_block *super = F2FS_RAW_SUPER(sbi);
 	struct buffer_head *bh;
 	int err;
 
-	/* write back-up superblock first */
-	bh = sb_getblk(sbi->sb, sbi->valid_super_block ? 0 : 1);
+	bh = sb_getblk(sbi->sb, block);
 	if (!bh)
 		return -EIO;
 
@@ -1222,23 +1221,22 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
 	err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
 	brelse(bh);
 
+	return err;
+}
+
+int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
+{
+	int err;
+
+	/* write back-up superblock first */
+	err = __f2fs_commit_super(sbi, sbi->valid_super_block ? 0 : 1);
+
 	/* if we are in recovery path, skip writing valid superblock */
 	if (recover || err)
 		return err;
 
-	bh = sb_getblk(sbi->sb, sbi->valid_super_block);
-	if (!bh)
-		return -EIO;
-
 	/* write current valid superblock */
-	lock_buffer(bh);
-	memcpy(bh->b_data + F2FS_SUPER_OFFSET, super, sizeof(*super));
-	set_buffer_uptodate(bh);
-	set_buffer_dirty(bh);
-	unlock_buffer(bh);
-
-	err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
-	brelse(bh);
+	err = __f2fs_commit_super(sbi, sbi->valid_super_block);
 
 	return err;
 }
-- 
2.6.3



------------------------------------------------------------------------------

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

* Re: [PATCH 3/3] f2fs: introduce __f2fs_commit_super
  2015-12-15  9:20 [PATCH 3/3] f2fs: introduce __f2fs_commit_super Chao Yu
@ 2015-12-15 22:19 ` Jaegeuk Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Jaegeuk Kim @ 2015-12-15 22:19 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel, linux-kernel

Hi Chao,

On Tue, Dec 15, 2015 at 05:20:50PM +0800, Chao Yu wrote:
> Introduce __f2fs_commit_super to include duplicated codes in
> f2fs_commit_super for cleanup.
> 
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
>  fs/f2fs/super.c | 28 +++++++++++++---------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 2d4fed8..56a160a 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -1201,14 +1201,13 @@ next:
>  	return 0;
>  }
>  
> -int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
> +int __f2fs_commit_super(struct f2fs_sb_info *sbi, int block)
>  {
>  	struct f2fs_super_block *super = F2FS_RAW_SUPER(sbi);
>  	struct buffer_head *bh;
>  	int err;
>  
> -	/* write back-up superblock first */
> -	bh = sb_getblk(sbi->sb, sbi->valid_super_block ? 0 : 1);
> +	bh = sb_getblk(sbi->sb, block);
>  	if (!bh)
>  		return -EIO;
>  
> @@ -1222,23 +1221,22 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
>  	err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
>  	brelse(bh);
>  
> +	return err;
> +}
> +
> +int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
> +{
> +	int err;
> +
> +	/* write back-up superblock first */
> +	err = __f2fs_commit_super(sbi, sbi->valid_super_block ? 0 : 1);
> +
>  	/* if we are in recovery path, skip writing valid superblock */
>  	if (recover || err)
>  		return err;
>  
> -	bh = sb_getblk(sbi->sb, sbi->valid_super_block);
> -	if (!bh)
> -		return -EIO;
> -
>  	/* write current valid superblock */
> -	lock_buffer(bh);
> -	memcpy(bh->b_data + F2FS_SUPER_OFFSET, super, sizeof(*super));
> -	set_buffer_uptodate(bh);
> -	set_buffer_dirty(bh);
> -	unlock_buffer(bh);
> -
> -	err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
> -	brelse(bh);
> +	err = __f2fs_commit_super(sbi, sbi->valid_super_block);

I just merged this patch with:

	return __f2fs_commit_super().

Thanks,

>  
>  	return err;
>  }
> -- 
> 2.6.3
> 

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

end of thread, other threads:[~2015-12-15 22:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-15  9:20 [PATCH 3/3] f2fs: introduce __f2fs_commit_super Chao Yu
2015-12-15 22:19 ` Jaegeuk Kim

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