Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d68f735b authored by Jaegeuk Kim's avatar Jaegeuk Kim
Browse files

f2fs: check io submission more precisely



This patch check IO submission more precisely than previous rough check.

Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent f566bae8
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -379,6 +379,9 @@ int f2fs_submit_page_mbio(struct f2fs_io_info *fio)

	bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;

	/* set submitted = 1 as a return value */
	fio->submitted = 1;

	if (!is_read)
		inc_page_count(sbi, WB_DATA_TYPE(bio_page));

@@ -1346,7 +1349,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
	return err;
}

static int __write_data_page(struct page *page,
static int __write_data_page(struct page *page, bool *submitted,
				struct writeback_control *wbc)
{
	struct inode *inode = page->mapping->host;
@@ -1365,6 +1368,7 @@ static int __write_data_page(struct page *page,
		.op_flags = wbc_to_write_flags(wbc),
		.page = page,
		.encrypted_page = NULL,
		.submitted = false,
	};

	trace_f2fs_writepage(page, DATA);
@@ -1430,13 +1434,19 @@ static int __write_data_page(struct page *page,
	if (wbc->for_reclaim) {
		f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, DATA, WRITE);
		remove_dirty_inode(inode);
		submitted = NULL;
	}

	unlock_page(page);
	f2fs_balance_fs(sbi, need_balance_fs);

	if (unlikely(f2fs_cp_error(sbi)))
	if (unlikely(f2fs_cp_error(sbi))) {
		f2fs_submit_merged_bio(sbi, DATA, WRITE);
		submitted = NULL;
	}

	if (submitted)
		*submitted = fio.submitted;

	return 0;

@@ -1451,7 +1461,7 @@ static int __write_data_page(struct page *page,
static int f2fs_write_data_page(struct page *page,
					struct writeback_control *wbc)
{
	return __write_data_page(page, wbc);
	return __write_data_page(page, NULL, wbc);
}

/*
@@ -1510,6 +1520,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,

		for (i = 0; i < nr_pages; i++) {
			struct page *page = pvec.pages[i];
			bool submitted = false;

			if (page->index > end) {
				done = 1;
@@ -1543,7 +1554,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
			if (!clear_page_dirty_for_io(page))
				goto continue_unlock;

			ret = __write_data_page(page, wbc);
			ret = __write_data_page(page, &submitted, wbc);
			if (unlikely(ret)) {
				/*
				 * keep nr_to_write, since vfs uses this to
@@ -1557,7 +1568,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
				done_index = page->index + 1;
				done = 1;
				break;
			} else {
			} else if (submitted) {
				nwritten++;
			}

+1 −0
Original line number Diff line number Diff line
@@ -728,6 +728,7 @@ struct f2fs_io_info {
	block_t old_blkaddr;	/* old block address before Cow */
	struct page *page;	/* page to be written */
	struct page *encrypted_page;	/* encrypted page */
	bool submitted;		/* indicate IO submission */
};

#define is_read_io(rw) (rw == READ)
+19 −8
Original line number Diff line number Diff line
@@ -1318,7 +1318,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
	return last_page;
}

static int __write_node_page(struct page *page, bool atomic,
static int __write_node_page(struct page *page, bool atomic, bool *submitted,
				struct writeback_control *wbc)
{
	struct f2fs_sb_info *sbi = F2FS_P_SB(page);
@@ -1331,6 +1331,7 @@ static int __write_node_page(struct page *page, bool atomic,
		.op_flags = wbc_to_write_flags(wbc),
		.page = page,
		.encrypted_page = NULL,
		.submitted = false,
	};

	trace_f2fs_writepage(page, NODE);
@@ -1372,13 +1373,19 @@ static int __write_node_page(struct page *page, bool atomic,
	dec_page_count(sbi, F2FS_DIRTY_NODES);
	up_read(&sbi->node_write);

	if (wbc->for_reclaim)
	if (wbc->for_reclaim) {
		f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, NODE, WRITE);
		submitted = NULL;
	}

	unlock_page(page);

	if (unlikely(f2fs_cp_error(sbi)))
	if (unlikely(f2fs_cp_error(sbi))) {
		f2fs_submit_merged_bio(sbi, NODE, WRITE);
		submitted = NULL;
	}
	if (submitted)
		*submitted = fio.submitted;

	return 0;

@@ -1390,7 +1397,7 @@ static int __write_node_page(struct page *page, bool atomic,
static int f2fs_write_node_page(struct page *page,
				struct writeback_control *wbc)
{
	return __write_node_page(page, false, wbc);
	return __write_node_page(page, false, NULL, wbc);
}

int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
@@ -1424,6 +1431,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,

		for (i = 0; i < nr_pages; i++) {
			struct page *page = pvec.pages[i];
			bool submitted = false;

			if (unlikely(f2fs_cp_error(sbi))) {
				f2fs_put_page(last_page, 0);
@@ -1473,12 +1481,13 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
				goto continue_unlock;

			ret = __write_node_page(page, atomic &&
						page == last_page, wbc);
						page == last_page,
						&submitted, wbc);
			if (ret) {
				unlock_page(page);
				f2fs_put_page(last_page, 0);
				break;
			} else {
			} else if (submitted) {
				nwritten++;
			}

@@ -1534,6 +1543,7 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)

		for (i = 0; i < nr_pages; i++) {
			struct page *page = pvec.pages[i];
			bool submitted = false;

			if (unlikely(f2fs_cp_error(sbi))) {
				pagevec_release(&pvec);
@@ -1587,9 +1597,10 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)
			set_fsync_mark(page, 0);
			set_dentry_mark(page, 0);

			if (NODE_MAPPING(sbi)->a_ops->writepage(page, wbc))
			ret = __write_node_page(page, false, &submitted, wbc);
			if (ret)
				unlock_page(page);
			else
			else if (submitted)
				nwritten++;

			if (--wbc->nr_to_write == 0)