Skip to content

Commit

Permalink
Revert "f2fs: update"
Browse files Browse the repository at this point in the history
This reverts commit 8addd86.
  • Loading branch information
neobuddy89 committed Feb 24, 2015
1 parent 7b33fbd commit ad7be67
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 344 deletions.
48 changes: 18 additions & 30 deletions fs/f2fs/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int f2fs_write_meta_page(struct page *page,

trace_f2fs_writepage(page, META);

if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
if (unlikely(sbi->por_doing))
goto redirty_out;
if (wbc->for_reclaim && page->index < GET_SUM_BLOCK(sbi, 0))
goto redirty_out;
Expand Down Expand Up @@ -303,7 +303,6 @@ static int f2fs_set_meta_page_dirty(struct page *page)
if (!PageDirty(page)) {
__set_page_dirty_nobuffers(page);
inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_META);
SetPagePrivate(page);
f2fs_trace_pid(page);
return 1;
}
Expand All @@ -314,8 +313,6 @@ const struct address_space_operations f2fs_meta_aops = {
.writepage = f2fs_write_meta_page,
.writepages = f2fs_write_meta_pages,
.set_page_dirty = f2fs_set_meta_page_dirty,
.invalidatepage = f2fs_invalidate_page,
.releasepage = f2fs_release_page,
};

static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
Expand Down Expand Up @@ -470,7 +467,7 @@ void recover_orphan_inodes(struct f2fs_sb_info *sbi)
if (!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG))
return;

set_sbi_flag(sbi, SBI_POR_DOING);
sbi->por_doing = true;

start_blk = __start_cp_addr(sbi) + 1 +
le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_payload);
Expand All @@ -491,7 +488,7 @@ void recover_orphan_inodes(struct f2fs_sb_info *sbi)
}
/* clear Orphan Flag */
clear_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG);
clear_sbi_flag(sbi, SBI_POR_DOING);
sbi->por_doing = false;
return;
}

Expand Down Expand Up @@ -575,7 +572,7 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
if (crc_offset >= blk_size)
goto invalid_cp1;

crc = le32_to_cpu(*((__le32 *)((unsigned char *)cp_block + crc_offset)));
crc = le32_to_cpu(*((__u32 *)((unsigned char *)cp_block + crc_offset)));
if (!f2fs_crc_valid(crc, cp_block, crc_offset))
goto invalid_cp1;

Expand All @@ -590,7 +587,7 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
if (crc_offset >= blk_size)
goto invalid_cp2;

crc = le32_to_cpu(*((__le32 *)((unsigned char *)cp_block + crc_offset)));
crc = le32_to_cpu(*((__u32 *)((unsigned char *)cp_block + crc_offset)));
if (!f2fs_crc_valid(crc, cp_block, crc_offset))
goto invalid_cp2;

Expand Down Expand Up @@ -941,31 +938,24 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
ckpt->cp_pack_start_sum = cpu_to_le32(1 + cp_payload_blks +
orphan_blocks);

if (__remain_node_summaries(cpc->reason))
if (cpc->reason == CP_UMOUNT) {
set_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
ckpt->cp_pack_total_block_count = cpu_to_le32(F2FS_CP_PACKS+
cp_payload_blks + data_sum_blocks +
orphan_blocks + NR_CURSEG_NODE_TYPE);
else
} else {
clear_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
ckpt->cp_pack_total_block_count = cpu_to_le32(F2FS_CP_PACKS +
cp_payload_blks + data_sum_blocks +
orphan_blocks);

if (cpc->reason == CP_UMOUNT)
set_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
else
clear_ckpt_flags(ckpt, CP_UMOUNT_FLAG);

if (cpc->reason == CP_FASTBOOT)
set_ckpt_flags(ckpt, CP_FASTBOOT_FLAG);
else
clear_ckpt_flags(ckpt, CP_FASTBOOT_FLAG);
}

if (orphan_num)
set_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG);
else
clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG);

if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
if (sbi->need_fsck)
set_ckpt_flags(ckpt, CP_FSCK_FLAG);

/* update SIT/NAT bitmap */
Expand All @@ -982,14 +972,15 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
/* write out checkpoint buffer at block 0 */
cp_page = grab_meta_page(sbi, start_blk++);
kaddr = page_address(cp_page);
memcpy(kaddr, ckpt, F2FS_BLKSIZE);
memcpy(kaddr, ckpt, (1 << sbi->log_blocksize));
set_page_dirty(cp_page);
f2fs_put_page(cp_page, 1);

for (i = 1; i < 1 + cp_payload_blks; i++) {
cp_page = grab_meta_page(sbi, start_blk++);
kaddr = page_address(cp_page);
memcpy(kaddr, (char *)ckpt + i * F2FS_BLKSIZE, F2FS_BLKSIZE);
memcpy(kaddr, (char *)ckpt + i * F2FS_BLKSIZE,
(1 << sbi->log_blocksize));
set_page_dirty(cp_page);
f2fs_put_page(cp_page, 1);
}
Expand All @@ -1001,15 +992,15 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)

write_data_summaries(sbi, start_blk);
start_blk += data_sum_blocks;
if (__remain_node_summaries(cpc->reason)) {
if (cpc->reason == CP_UMOUNT) {
write_node_summaries(sbi, start_blk);
start_blk += NR_CURSEG_NODE_TYPE;
}

/* writeout checkpoint block */
cp_page = grab_meta_page(sbi, start_blk);
kaddr = page_address(cp_page);
memcpy(kaddr, ckpt, F2FS_BLKSIZE);
memcpy(kaddr, ckpt, (1 << sbi->log_blocksize));
set_page_dirty(cp_page);
f2fs_put_page(cp_page, 1);

Expand Down Expand Up @@ -1038,7 +1029,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
return;

clear_prefree_segments(sbi);
clear_sbi_flag(sbi, SBI_IS_DIRTY);
F2FS_RESET_SB_DIRT(sbi);
}

/*
Expand All @@ -1053,13 +1044,10 @@ void write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)

mutex_lock(&sbi->cp_mutex);

if (!is_sbi_flag_set(sbi, SBI_IS_DIRTY) &&
cpc->reason != CP_DISCARD && cpc->reason != CP_UMOUNT)
if (!sbi->s_dirty && cpc->reason != CP_DISCARD)
goto out;
if (unlikely(f2fs_cp_error(sbi)))
goto out;
if (f2fs_readonly(sbi->sb))
goto out;
if (block_operations(sbi))
goto out;

Expand Down
92 changes: 15 additions & 77 deletions fs/f2fs/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
unsigned int blkbits = inode->i_sb->s_blocksize_bits;
size_t count;

set_buffer_new(bh_result);
clear_buffer_new(bh_result);
map_bh(bh_result, inode->i_sb,
start_blkaddr + pgofs - start_fofs);
count = end_fofs - pgofs + 1;
Expand Down Expand Up @@ -592,56 +592,6 @@ static int __allocate_data_block(struct dnode_of_data *dn)
return 0;
}

static void __allocate_data_blocks(struct inode *inode, loff_t offset,
size_t count)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct dnode_of_data dn;
u64 start = F2FS_BYTES_TO_BLK(offset);
u64 len = F2FS_BYTES_TO_BLK(count);
bool allocated;
u64 end_offset;

while (len) {
f2fs_balance_fs(sbi);
f2fs_lock_op(sbi);

/* When reading holes, we need its node page */
set_new_dnode(&dn, inode, NULL, NULL, 0);
if (get_dnode_of_data(&dn, start, ALLOC_NODE))
goto out;

allocated = false;
end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode));

while (dn.ofs_in_node < end_offset && len) {
if (dn.data_blkaddr == NULL_ADDR) {
if (__allocate_data_block(&dn))
goto sync_out;
allocated = true;
}
len--;
start++;
dn.ofs_in_node++;
}

if (allocated)
sync_inode_page(&dn);

f2fs_put_dnode(&dn);
f2fs_unlock_op(sbi);
}
return;

sync_out:
if (allocated)
sync_inode_page(&dn);
f2fs_put_dnode(&dn);
out:
f2fs_unlock_op(sbi);
return;
}

/*
* get_data_block() now supported readahead/bmap/rw direct_IO with mapped bh.
* If original data blocks are allocated, then give them to blockdev.
Expand All @@ -667,8 +617,10 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
if (check_extent_cache(inode, pgofs, bh_result))
goto out;

if (create)
if (create) {
f2fs_balance_fs(F2FS_I_SB(inode));
f2fs_lock_op(F2FS_I_SB(inode));
}

/* When reading holes, we need its node page */
set_new_dnode(&dn, inode, NULL, NULL, 0);
Expand All @@ -682,14 +634,12 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
goto put_out;

if (dn.data_blkaddr != NULL_ADDR) {
set_buffer_new(bh_result);
map_bh(bh_result, inode->i_sb, dn.data_blkaddr);
} else if (create) {
err = __allocate_data_block(&dn);
if (err)
goto put_out;
allocated = true;
set_buffer_new(bh_result);
map_bh(bh_result, inode->i_sb, dn.data_blkaddr);
} else {
goto put_out;
Expand Down Expand Up @@ -868,7 +818,7 @@ static int f2fs_write_data_page(struct page *page,

zero_user_segment(page, offset, PAGE_CACHE_SIZE);
write:
if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
if (unlikely(sbi->por_doing))
goto redirty_out;
if (f2fs_is_drop_cache(inode))
goto out;
Expand Down Expand Up @@ -1158,11 +1108,10 @@ static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb,

trace_f2fs_direct_IO_enter(inode, offset, count, rw);

if (rw & WRITE)
__allocate_data_blocks(inode, offset, count);
err = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
get_data_block);

err = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
get_data_block);
trace_f2fs_direct_IO_enter(inode, offset, count, rw);

if (err < 0 && (rw & WRITE))
f2fs_write_failed(mapping, offset + count);
Expand All @@ -1172,31 +1121,20 @@ static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb,
return err;
}

void f2fs_invalidate_page(struct page *page, unsigned long offset)
static void f2fs_invalidate_data_page(struct page *page, unsigned long offset)
{
struct inode *inode = page->mapping->host;
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);

if (inode->i_ino >= F2FS_ROOT_INO(sbi) && (offset % PAGE_CACHE_SIZE))
if (offset % PAGE_CACHE_SIZE)
return;

if (PageDirty(page)) {
if (inode->i_ino == F2FS_META_INO(sbi))
dec_page_count(sbi, F2FS_DIRTY_META);
else if (inode->i_ino == F2FS_NODE_INO(sbi))
dec_page_count(sbi, F2FS_DIRTY_NODES);
else
inode_dec_dirty_pages(inode);
}
if (PageDirty(page))
inode_dec_dirty_pages(inode);
ClearPagePrivate(page);
}

int f2fs_release_page(struct page *page, gfp_t wait)
static int f2fs_release_data_page(struct page *page, gfp_t wait)
{
/* If this is dirty page, keep PagePrivate */
if (PageDirty(page))
return 0;

ClearPagePrivate(page);
return 1;
}
Expand Down Expand Up @@ -1246,8 +1184,8 @@ const struct address_space_operations f2fs_dblock_aops = {
.write_begin = f2fs_write_begin,
.write_end = f2fs_write_end,
.set_page_dirty = f2fs_set_data_page_dirty,
.invalidatepage = f2fs_invalidate_page,
.releasepage = f2fs_release_page,
.invalidatepage = f2fs_invalidate_data_page,
.releasepage = f2fs_release_data_page,
.direct_IO = f2fs_direct_IO,
.bmap = f2fs_bmap,
};
6 changes: 2 additions & 4 deletions fs/f2fs/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->ndirty_dirs = sbi->n_dirty_dirs;
si->ndirty_meta = get_pages(sbi, F2FS_DIRTY_META);
si->inmem_pages = get_pages(sbi, F2FS_INMEM_PAGES);
si->wb_pages = get_pages(sbi, F2FS_WRITEBACK);
si->total_count = (int)sbi->user_block_count / sbi->blocks_per_seg;
si->rsvd_segs = reserved_segments(sbi);
si->overp_segs = overprovision_segments(sbi);
Expand Down Expand Up @@ -142,7 +141,6 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
si->base_mem += MAIN_SEGS(sbi) * sizeof(struct seg_entry);
si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi));
si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi);
si->base_mem += SIT_VBLOCK_MAP_SIZE;
if (sbi->segs_per_sec > 1)
si->base_mem += MAIN_SECS(sbi) * sizeof(struct sec_entry);
si->base_mem += __bitmap_size(sbi, SIT_BITMAP);
Expand Down Expand Up @@ -268,8 +266,8 @@ static int stat_show(struct seq_file *s, void *v)
seq_printf(s, "\nExtent Hit Ratio: %d / %d\n",
si->hit_ext, si->total_ext);
seq_puts(s, "\nBalancing F2FS Async:\n");
seq_printf(s, " - inmem: %4d, wb: %4d\n",
si->inmem_pages, si->wb_pages);
seq_printf(s, " - inmem: %4d\n",
si->inmem_pages);
seq_printf(s, " - nodes: %4d in %4d\n",
si->ndirty_node, si->node_pages);
seq_printf(s, " - dents: %4d in dirs:%4d\n",
Expand Down
Loading

2 comments on commit ad7be67

@DerRomtester
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you already know why it does not boot?

@neobuddy89
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f2fs was not updated properly. so, reverted.

Please sign in to comment.