Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933443AbbLOJVg (ORCPT ); Tue, 15 Dec 2015 04:21:36 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:41788 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933237AbbLOJVc (ORCPT ); Tue, 15 Dec 2015 04:21:32 -0500 X-AuditID: cbfee61a-f79266d000003652-e9-566fdb9a4ce2 From: Chao Yu To: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] f2fs: introduce __f2fs_commit_super Date: Tue, 15 Dec 2015 17:20:50 +0800 Message-id: <010601d13719$fb952260$f2bf6720$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdE3GchSeFj02r7BQyCzDlqmjve7fg== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsVy+t9jAd1Zt/PDDBZMM7N4sn4Ws8WlRe4W l3fNYXNg9ti0qpPNY/eCz0wenzfJBTBHcdmkpOZklqUW6dslcGV8OvaLpeAeb8WUvs9sDYzT uLsYOTkkBEwkbrT3sUHYYhIX7q0Hsrk4hASWMkr03ljKAuG8YpTon7edEaSKTUBFYnnHfyYQ WwTIPrToMjuIzSzgIdHY8Z0VxBYWsJBY/GoGC4jNIqAqcfvIPSCbg4NXwFLi6/VSkDCvgKDE j8n3WCBatSTW7zzOBGHLS2xe85YZ4iAFiR1nXzNCrNKTuLzqPtQqcYmNR26xTGAUmIVk1Cwk o2YhGTULScsCRpZVjBKpBckFxUnpuYZ5qeV6xYm5xaV56XrJ+bmbGMFB/ExqB+PBXe6HGAU4 GJV4eBcw54cJsSaWFVfmHmKU4GBWEuHNvgUU4k1JrKxKLcqPLyrNSS0+xCjNwaIkzlt7KTJM SCA9sSQ1OzW1ILUIJsvEwSnVwDj311mJXF/F3WX+zu4/586d9/6t3/0CxlfMIkHr7+z89H7/ h5Dmju9rHhYuuqq6NceE39Z7w7H6vbvE7xol+SXpJrlXljwxXXn/4aYHV0s49y14vEUzYoOx /RtzCX1vH6vlU7b+qmXtCjy8Y8fsIDeGzRdOfLrZ6lkzJ9ExOnZPZtG/fT8U+z8rsRRnJBpq MRcVJwIAMbEV0F4CAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1935 Lines: 73 Introduce __f2fs_commit_super to include duplicated codes in f2fs_commit_super for cleanup. Signed-off-by: Chao Yu --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/