Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 358977
b: refs/heads/master
c: 577e349
h: refs/heads/master
i:
  358975: 4a16621
v: v3
  • Loading branch information
Jaegeuk Kim committed Feb 11, 2013
1 parent d58ea55 commit 6673f01
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7d79e75f6420fc13cfe72554b3ea5afad24c8625
refs/heads/master: 577e349514452fa3fcd99fd06e587b02d3d1cf28
36 changes: 19 additions & 17 deletions trunk/fs/f2fs/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ static int f2fs_write_meta_page(struct page *page,
{
struct inode *inode = page->mapping->host;
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
int err;

wait_on_page_writeback(page);

err = write_meta_page(sbi, page, wbc);
if (err) {
/* Should not write any meta pages, if any IO error was occurred */
if (wbc->for_reclaim ||
is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)) {
dec_page_count(sbi, F2FS_DIRTY_META);
wbc->pages_skipped++;
set_page_dirty(page);
return AOP_WRITEPAGE_ACTIVATE;
}

dec_page_count(sbi, F2FS_DIRTY_META);
wait_on_page_writeback(page);

/* In this case, we should not unlock this page */
if (err != AOP_WRITEPAGE_ACTIVATE)
unlock_page(page);
return err;
write_meta_page(sbi, page);
dec_page_count(sbi, F2FS_DIRTY_META);
unlock_page(page);
return 0;
}

static int f2fs_write_meta_pages(struct address_space *mapping,
Expand Down Expand Up @@ -138,7 +138,10 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
BUG_ON(page->mapping != mapping);
BUG_ON(!PageDirty(page));
clear_page_dirty_for_io(page);
f2fs_write_meta_page(page, &wbc);
if (f2fs_write_meta_page(page, &wbc)) {
unlock_page(page);
break;
}
if (nwritten++ >= nr_to_write)
break;
}
Expand Down Expand Up @@ -717,13 +720,12 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
sbi->alloc_valid_block_count = 0;

/* Here, we only have one bio having CP pack */
if (is_set_ckpt_flags(ckpt, CP_ERROR_FLAG))
sbi->sb->s_flags |= MS_RDONLY;
else
sync_meta_pages(sbi, META_FLUSH, LONG_MAX);
sync_meta_pages(sbi, META_FLUSH, LONG_MAX);

clear_prefree_segments(sbi);
F2FS_RESET_SB_DIRT(sbi);
if (!is_set_ckpt_flags(ckpt, CP_ERROR_FLAG)) {
clear_prefree_segments(sbi);
F2FS_RESET_SB_DIRT(sbi);
}
}

/*
Expand Down
3 changes: 1 addition & 2 deletions trunk/fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,7 @@ void allocate_new_segments(struct f2fs_sb_info *);
struct page *get_sum_page(struct f2fs_sb_info *, unsigned int);
struct bio *f2fs_bio_alloc(struct block_device *, int);
void f2fs_submit_bio(struct f2fs_sb_info *, enum page_type, bool sync);
int write_meta_page(struct f2fs_sb_info *, struct page *,
struct writeback_control *);
void write_meta_page(struct f2fs_sb_info *, struct page *);
void write_node_page(struct f2fs_sb_info *, struct page *, unsigned int,
block_t, block_t *);
void write_data_page(struct inode *, struct page *, struct dnode_of_data*,
Expand Down
8 changes: 2 additions & 6 deletions trunk/fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ static void f2fs_end_io_write(struct bio *bio, int err)
if (page->mapping)
set_bit(AS_EIO, &page->mapping->flags);
set_ckpt_flags(p->sbi->ckpt, CP_ERROR_FLAG);
p->sbi->sb->s_flags |= MS_RDONLY;
}
end_page_writeback(page);
dec_page_count(p->sbi, F2FS_WRITEBACK);
Expand Down Expand Up @@ -815,15 +816,10 @@ static void do_write_page(struct f2fs_sb_info *sbi, struct page *page,
mutex_unlock(&curseg->curseg_mutex);
}

int write_meta_page(struct f2fs_sb_info *sbi, struct page *page,
struct writeback_control *wbc)
void write_meta_page(struct f2fs_sb_info *sbi, struct page *page)
{
if (wbc->for_reclaim)
return AOP_WRITEPAGE_ACTIVATE;

set_page_writeback(page);
submit_write_page(sbi, page, page->index, META);
return 0;
}

void write_node_page(struct f2fs_sb_info *sbi, struct page *page,
Expand Down
12 changes: 9 additions & 3 deletions trunk/fs/f2fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,11 @@ static int sanity_check_raw_super(struct super_block *sb,
return 0;
}

static int sanity_check_ckpt(struct f2fs_super_block *raw_super,
struct f2fs_checkpoint *ckpt)
static int sanity_check_ckpt(struct f2fs_sb_info *sbi)
{
unsigned int total, fsmeta;
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);

total = le32_to_cpu(raw_super->segment_count);
fsmeta = le32_to_cpu(raw_super->segment_count_ckpt);
Expand All @@ -401,6 +402,11 @@ static int sanity_check_ckpt(struct f2fs_super_block *raw_super,

if (fsmeta >= total)
return 1;

if (is_set_ckpt_flags(ckpt, CP_ERROR_FLAG)) {
f2fs_msg(sbi->sb, KERN_ERR, "A bug case: need to run fsck");
return 1;
}
return 0;
}

Expand Down Expand Up @@ -525,7 +531,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)

/* sanity checking of checkpoint */
err = -EINVAL;
if (sanity_check_ckpt(raw_super, sbi->ckpt)) {
if (sanity_check_ckpt(sbi)) {
f2fs_msg(sb, KERN_ERR, "Invalid F2FS checkpoint");
goto free_cp;
}
Expand Down

0 comments on commit 6673f01

Please sign in to comment.