Пример #1
0
void f2fs_invalidate_page(struct page *page, unsigned int offset,
                          unsigned int length)
{
    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 || length != 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);
    }

    /* This is atomic written page, keep Private */
    if (IS_ATOMIC_WRITTEN_PAGE(page))
        return;

    ClearPagePrivate(page);
}
Пример #2
0
/*
 * It only removes the dentry from the dentry page,corresponding name
 * entry in name page does not need to be touched during deletion.
 */
void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
						struct inode *inode)
{
	struct	f2fs_dentry_block *dentry_blk;
	unsigned int bit_pos;
	struct address_space *mapping = page->mapping;
	struct inode *dir = mapping->host;
	struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
	int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
	void *kaddr = page_address(page);
	int i;

	lock_page(page);
	wait_on_page_writeback(page);

	dentry_blk = (struct f2fs_dentry_block *)kaddr;
	bit_pos = dentry - (struct f2fs_dir_entry *)dentry_blk->dentry;
	for (i = 0; i < slots; i++)
		test_and_clear_bit_le(bit_pos + i, &dentry_blk->dentry_bitmap);

	/* Let's check and deallocate this dentry page */
	bit_pos = find_next_bit_le(&dentry_blk->dentry_bitmap,
			NR_DENTRY_IN_BLOCK,
			0);
	kunmap(page); /* kunmap - pair of f2fs_find_entry */
	set_page_dirty(page);

	dir->i_ctime = dir->i_mtime = CURRENT_TIME;

	if (inode && S_ISDIR(inode->i_mode)) {
		drop_nlink(dir);
		update_inode_page(dir);
	} else {
		mark_inode_dirty(dir);
	}

	if (inode) {
		inode->i_ctime = CURRENT_TIME;
		drop_nlink(inode);
		if (S_ISDIR(inode->i_mode)) {
			drop_nlink(inode);
			i_size_write(inode, 0);
		}
		update_inode_page(inode);

		if (inode->i_nlink == 0)
			add_orphan_inode(sbi, inode->i_ino);
		else
			release_orphan_inode(sbi);
	}

	if (bit_pos == NR_DENTRY_IN_BLOCK) {
		truncate_hole(dir, page->index, page->index + 1);
		clear_page_dirty_for_io(page);
		ClearPageUptodate(page);
		dec_page_count(sbi, F2FS_DIRTY_DENTS);
		inode_dec_dirty_dents(dir);
	}
	f2fs_put_page(page, 1);
}
Пример #3
0
static void f2fs_write_end_io(struct bio *bio)
{
    struct f2fs_sb_info *sbi = bio->bi_private;
    struct bio_vec *bvec;
    int i;

    bio_for_each_segment_all(bvec, bio, i) {
        struct page *page = bvec->bv_page;

        f2fs_restore_and_release_control_page(&page);

        if (unlikely(bio->bi_error)) {
            set_page_dirty(page);
            set_bit(AS_EIO, &page->mapping->flags);
            f2fs_stop_checkpoint(sbi);
        }
        end_page_writeback(page);
        dec_page_count(sbi, F2FS_WRITEBACK);
    }

    if (!get_pages(sbi, F2FS_WRITEBACK) &&
            !list_empty(&sbi->cp_wait.task_list))
        wake_up(&sbi->cp_wait);

    bio_put(bio);
}