Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856AbbFHF3R (ORCPT ); Mon, 8 Jun 2015 01:29:17 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:57252 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752174AbbFHF3H (ORCPT ); Mon, 8 Jun 2015 01:29:07 -0400 X-AuditID: cbfee61a-f79516d000006302-db-5575282285b7 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] f2fs: skip committing valid superblock Date: Mon, 08 Jun 2015 13:28:03 +0800 Message-id: <004601d0a1ac$07f97460$17ec5d20$@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: AdChqvBpP2l5Fz3gSC2ol/SnMVIzAg== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t9jAV0ljdJQg/OLeSyu7Wtksniyfhaz xaVF7haXd81hc2Dx2LSqk81j94LPTB59W1YxenzeJBfAEsVlk5Kak1mWWqRvl8CVcWzxZOaC o0IV3VNvMjcwzuDvYuTkkBAwkfj47ygjhC0mceHeerYuRi4OIYFFjBLLp7xnhnBeMUrc397O BFLFJqAisbzjP5gtIuAlMWn/CRYQm1nAQ6Kx4zsriC0sYC3xtfcRO4jNIqAq0X/8OFg9r4Cl xJQTj6BsQYkfk+9B9WpJrN8JUcMsIC+xec1bZoiLFCR2nH3NCLFLT+Le78+sEDXiEhuP3GKZ wCgwC8moWUhGzUIyahaSlgWMLKsYRVMLkguKk9JzDfWKE3OLS/PS9ZLzczcxgoP6mdQOxpUN FocYBTgYlXh4JZaWhAqxJpYVV+YeYpTgYFYS4Q0UKQ0V4k1JrKxKLcqPLyrNSS0+xCjNwaIk znsy3ydUSCA9sSQ1OzW1ILUIJsvEwSnVwLjA1PQdn3rtxxUFxe3nPTP/1OmlKNQExUx33/Ze 54rTXAXpoDCLh79nz8vqffj89LnPC7Ss52qtmFPGvUCzoMK1/PXeeovQa2wTizLjsnPeG8+s uTw3v/pemdDex7xGB08mbeyYU3q36dwh1re2uu7dmZYZF+qTVyTXmy3tbSnd0eEv1Tj7oRJL cUaioRZzUXEiAH/z6HNmAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2543 Lines: 80 In recovery procedure for superblock, we try to write data of valid superblock into invalid one for recovery, work should be finished here, but then still we will write the valid one with its original data. This operation is not needed. Let's skip doing this unnecessary work. Signed-off-by: Chao Yu --- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 2 +- fs/f2fs/super.c | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 1a0716c..a8327ed 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1624,7 +1624,7 @@ static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode) /* * super.c */ -int f2fs_commit_super(struct f2fs_sb_info *); +int f2fs_commit_super(struct f2fs_sb_info *, bool); int f2fs_sync_fs(struct super_block *, int); extern __printf(3, 4) void f2fs_msg(struct super_block *, const char *, const char *, ...); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 85f97af..4c8885d 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1530,7 +1530,7 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg) /* update superblock with uuid */ generate_random_uuid(sbi->raw_super->encrypt_pw_salt); - err = f2fs_commit_super(sbi); + err = f2fs_commit_super(sbi, false); mnt_drop_write_file(filp); if (err) { diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index f0be6a6..fbbf785 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1035,7 +1035,7 @@ out: return 0; } -int f2fs_commit_super(struct f2fs_sb_info *sbi) +int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover) { struct buffer_head *sbh = sbi->raw_super_buf; sector_t block = sbh->b_blocknr; @@ -1047,7 +1047,9 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi) err = sync_dirty_buffer(sbh); sbh->b_blocknr = block; - if (err) + + /* if we are in recovery path, skip writing valid superblock */ + if (recover || err) goto out; /* write current valid superblock */ @@ -1291,7 +1293,7 @@ try_onemore: /* recover broken superblock */ if (recovery && !f2fs_readonly(sb) && !bdev_read_only(sb->s_bdev)) { f2fs_msg(sb, KERN_INFO, "Recover invalid superblock"); - f2fs_commit_super(sbi); + f2fs_commit_super(sbi, true); } return 0; -- 2.4.2 -- 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/