Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1286079
| From | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/3] f2fs: refactor f2fs_commit_super |
| Date | 2015-12-08 00:00 +0100 |
| Message-ID | <qDcVc-2rG-11@gated-at.bofh.it> (permalink) |
| References | <qDcVc-2rG-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Previously, f2fs_commit_super hacks the bh->blocknr to write the broken
alternate superblock.
Instead of it, we should use the correct logic to retrieve its buffer head
with locking it appropriately.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/super.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index bd7e9c6..dbf16ad 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1099,27 +1099,35 @@ out:
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;
+ struct buffer_head *bh;
int err;
/* write back-up superblock first */
- sbh->b_blocknr = block ? 0 : 1;
- mark_buffer_dirty(sbh);
- err = sync_dirty_buffer(sbh);
+ bh = sb_getblk(sbi->sb, sbh->b_blocknr ? 0 : 1);
+ if (!bh)
+ return -EIO;
- sbh->b_blocknr = block;
+ lock_buffer(bh);
+ memcpy(bh->b_data, sbh->b_data, sbh->b_size);
+ WARN_ON(sbh->b_size != F2FS_BLKSIZE);
+ set_buffer_uptodate(bh);
+ set_buffer_dirty(bh);
+ unlock_buffer(bh);
+
+ /* it's rare case, we can do fua all the time */
+ err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
+ brelse(bh);
/* if we are in recovery path, skip writing valid superblock */
if (recover || err)
- goto out;
+ return err;
/* write current valid superblock */
- mark_buffer_dirty(sbh);
- err = sync_dirty_buffer(sbh);
-out:
- clear_buffer_write_io_error(sbh);
- set_buffer_uptodate(sbh);
- return err;
+ lock_buffer(sbh);
+ set_buffer_dirty(sbh);
+ unlock_buffer(sbh);
+
+ return __sync_dirty_buffer(sbh, WRITE_FLUSH_FUA);
}
static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
--
2.4.9 (Apple Git-60)
--
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/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/3] f2fs: enhance the bit operation for SSR Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-08 00:00 +0100
[PATCH 3/3] f2fs: use lock_buffer when changing superblock Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-08 00:00 +0100
RE: [f2fs-dev] [PATCH 3/3] f2fs: use lock_buffer when changing superblock Chao Yu <chao2.yu@samsung.com> - 2015-12-09 07:20 +0100
Re: [f2fs-dev] [PATCH 3/3 v2] f2fs: use lock_buffer when changing superblock Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-09 19:00 +0100
[PATCH 2/3] f2fs: refactor f2fs_commit_super Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-08 00:00 +0100
RE: [f2fs-dev] [PATCH 2/3] f2fs: refactor f2fs_commit_super Chao Yu <chao2.yu@samsung.com> - 2015-12-09 07:10 +0100
RE: [f2fs-dev] [PATCH 1/3] f2fs: enhance the bit operation for SSR Chao Yu <chao2.yu@samsung.com> - 2015-12-09 07:10 +0100
csiph-web