Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751966AbbLPFUT (ORCPT ); Wed, 16 Dec 2015 00:20:19 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:54940 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbbLPFUR (ORCPT ); Wed, 16 Dec 2015 00:20:17 -0500 X-AuditID: cbfee61b-f793c6d00000236c-39-5670f48f7e8a From: Chao Yu To: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] f2fs: introduce __f2fs_commit_super Date: Wed, 16 Dec 2015 13:19:35 +0800 Message-id: <014401d137c1$724252a0$56c6f7e0$@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: AdE3wVoR3yameEeXQlOwlUlawWMSzQ== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsVy+t9jQd3+LwVhBvvO8Fo8WT+L2eLSIneL y7vmsDkwe2xa1cnmsXvBZyaPz5vkApijuGxSUnMyy1KL9O0SuDIetT9hLTjPV/Hsfi9jA+Mn 7i5GTg4JAROJT1u6mSBsMYkL99azdTFycQgJzGKUOLpwIyNIQkjgFaPE4TsiIDabgIrE8o7/ YA0iQPahRZfZQWxmAQ+Jxo7vrCC2sIC1xK2VU8FsFgFViS2rHrN0MXJw8ApYSkyY7QYS5hUQ lPgx+R4LRKuWxPqdx5kgbHmJzWveMkPcoyCx4+xrRohVehI3dkxmhagRl9h45BbLBEagIxFG zUIyahaSUbOQtCxgZFnFKJFakFxQnJSea5SXWq5XnJhbXJqXrpecn7uJERzCz6R3MB7e5X6I UYCDUYmHVyOmIEyINbGsuDL3EKMEB7OSCK/BU6AQb0piZVVqUX58UWlOavEhRmkOFiVx3n2X IsOEBNITS1KzU1MLUotgskwcnFINjJK3jy0qW+KpN/GbyOJvzxad1p5Sv+Qu21PNpoViNosU tzMc7Xs8aZ1w8pk+7Y2sOYfWCC5imDpx/xyHdP9Qmyert73aYjmFw5rrrMISeT73U9vWmP1V 6n72MazPKGKyWZnitpvZDOU+a+vrQ6+Lpa7/4c2zIdTNKmLJPiaVyNXh/cbhPT1nnJVYijMS DbWYi4oTAe1kc4FdAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2043 Lines: 78 Introduce __f2fs_commit_super to include duplicated codes in f2fs_commit_super for cleanup. Signed-off-by: Chao Yu --- v2: - clean up codes. --- fs/f2fs/super.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 0d2d5c2..c3070c1 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1194,14 +1194,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; @@ -1215,25 +1214,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); - - return err; + return __f2fs_commit_super(sbi, sbi->valid_super_block); } static int f2fs_fill_super(struct super_block *sb, void *data, int silent) -- 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/