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

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

f2fs: resolve op and op_flags confilcts



Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent d8a1d0c1
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -64,14 +64,15 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
	struct f2fs_io_info fio = {
		.sbi = sbi,
		.type = META,
		.rw = READ_SYNC | REQ_META | REQ_PRIO,
		.op = REQ_OP_READ,
		.op_flags = REQ_SYNC | REQ_META | REQ_PRIO,
		.old_blkaddr = index,
		.new_blkaddr = index,
		.encrypted_page = NULL,
	};

	if (unlikely(!is_meta))
		fio.rw &= ~REQ_META;
		fio.op_flags &= ~REQ_META;
repeat:
	page = f2fs_grab_cache_page(mapping, index, false);
	if (!page) {
@@ -158,13 +159,15 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
	struct f2fs_io_info fio = {
		.sbi = sbi,
		.type = META,
		.rw = sync ? (READ_SYNC | REQ_META | REQ_PRIO) : READA,
		.op = REQ_OP_READ,
		.op_flags = sync ? (REQ_SYNC | REQ_META | REQ_PRIO) :
						REQ_RAHEAD,
		.encrypted_page = NULL,
	};
	struct blk_plug plug;

	if (unlikely(type == META_POR))
		fio.rw &= ~REQ_META;
		fio.op_flags &= ~REQ_META;

	blk_start_plug(&plug);
	for (; nrpages-- > 0; blkno++) {
+30 −24
Original line number Diff line number Diff line
@@ -167,15 +167,15 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr,
	return bio;
}

static inline void __submit_bio(struct f2fs_sb_info *sbi, int rw,
static inline void __submit_bio(struct f2fs_sb_info *sbi,
				struct bio *bio, enum page_type type)
{
	if (!is_read_io(rw)) {
	if (!is_read_io(bio_op(bio))) {
		if (f2fs_sb_mounted_blkzoned(sbi->sb) &&
			current->plug && (type == DATA || type == NODE))
			blk_finish_plug(current->plug);
	}
	submit_bio(rw, bio);
	submit_bio(0, bio);
}

static void __submit_merged_bio(struct f2fs_bio_info *io)
@@ -185,12 +185,14 @@ static void __submit_merged_bio(struct f2fs_bio_info *io)
	if (!io->bio)
		return;

	if (is_read_io(fio->rw))
	if (is_read_io(fio->op))
		trace_f2fs_submit_read_bio(io->sbi->sb, fio, io->bio);
	else
		trace_f2fs_submit_write_bio(io->sbi->sb, fio, io->bio);

	__submit_bio(io->sbi, fio->rw, io->bio, fio->type);
	bio_set_op_attrs(io->bio, fio->op, fio->op_flags);

	__submit_bio(io->sbi, io->bio, fio->type);
	io->bio = NULL;
}

@@ -256,10 +258,10 @@ static void __f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
	/* change META to META_FLUSH in the checkpoint procedure */
	if (type >= META_FLUSH) {
		io->fio.type = META_FLUSH;
		if (test_opt(sbi, NOBARRIER))
			io->fio.rw = WRITE_FLUSH | REQ_META | REQ_PRIO;
		else
			io->fio.rw = WRITE_FLUSH_FUA | REQ_META | REQ_PRIO;
		io->fio.op = REQ_OP_WRITE;
		io->fio.op_flags = WRITE_FLUSH | REQ_META | REQ_PRIO;
		if (!test_opt(sbi, NOBARRIER))
			io->fio.op_flags |= REQ_FUA;
	}
	__submit_merged_bio(io);
out:
@@ -301,14 +303,15 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
	f2fs_trace_ios(fio, 0);

	/* Allocate a new bio */
	bio = __bio_alloc(fio->sbi, fio->new_blkaddr, 1, is_read_io(fio->rw));
	bio = __bio_alloc(fio->sbi, fio->new_blkaddr, 1, is_read_io(fio->op));

	if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
		bio_put(bio);
		return -EFAULT;
	}
	bio_set_op_attrs(bio, fio->op, fio->op_flags);

	__submit_bio(fio->sbi, fio->rw, bio, fio->type);
	__submit_bio(fio->sbi, bio, fio->type);
	return 0;
}

@@ -317,7 +320,7 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
	struct f2fs_sb_info *sbi = fio->sbi;
	enum page_type btype = PAGE_TYPE_OF_BIO(fio->type);
	struct f2fs_bio_info *io;
	bool is_read = is_read_io(fio->rw);
	bool is_read = is_read_io(fio->op);
	struct page *bio_page;

	io = is_read ? &sbi->read_io : &sbi->write_io[btype];
@@ -334,7 +337,7 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
	down_write(&io->io_rwsem);

	if (io->bio && (io->last_block_in_bio != fio->new_blkaddr - 1 ||
			(io->fio.rw != fio->rw) ||
	    (io->fio.op != fio->op || io->fio.op_flags != fio->op_flags) ||
			!__same_bdev(sbi, fio->new_blkaddr, io->bio)))
		__submit_merged_bio(io);
alloc_new:
@@ -462,7 +465,7 @@ int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index)
}

struct page *get_read_data_page(struct inode *inode, pgoff_t index,
						int rw, bool for_write)
						int op_flags, bool for_write)
{
	struct address_space *mapping = inode->i_mapping;
	struct dnode_of_data dn;
@@ -472,7 +475,8 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index,
	struct f2fs_io_info fio = {
		.sbi = F2FS_I_SB(inode),
		.type = DATA,
		.rw = rw,
		.op = REQ_OP_READ,
		.op_flags = op_flags,
		.encrypted_page = NULL,
	};

@@ -540,7 +544,7 @@ struct page *find_data_page(struct inode *inode, pgoff_t index)
		return page;
	f2fs_put_page(page, 0);

	page = get_read_data_page(inode, index, READ_SYNC, false);
	page = get_read_data_page(inode, index, REQ_SYNC, false);
	if (IS_ERR(page))
		return page;

@@ -566,7 +570,7 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index,
	struct address_space *mapping = inode->i_mapping;
	struct page *page;
repeat:
	page = get_read_data_page(inode, index, READ_SYNC, for_write);
	page = get_read_data_page(inode, index, REQ_SYNC, for_write);
	if (IS_ERR(page))
		return page;

@@ -1144,7 +1148,7 @@ got_it:
		if (bio && (last_block_in_bio != block_nr - 1 ||
			!__same_bdev(F2FS_I_SB(inode), block_nr, bio))) {
submit_and_realloc:
			__submit_bio(F2FS_I_SB(inode), READ, bio, DATA);
			__submit_bio(F2FS_I_SB(inode), bio, DATA);
			bio = NULL;
		}
		if (bio == NULL) {
@@ -1153,6 +1157,7 @@ submit_and_realloc:
				bio = NULL;
				goto set_error_page;
			}
			bio_set_op_attrs(bio, REQ_OP_READ, 0);
		}

		if (bio_add_page(bio, page, blocksize, 0) < blocksize)
@@ -1167,7 +1172,7 @@ set_error_page:
		goto next_page;
confused:
		if (bio) {
			__submit_bio(F2FS_I_SB(inode), READ, bio, DATA);
			__submit_bio(F2FS_I_SB(inode), bio, DATA);
			bio = NULL;
		}
		unlock_page(page);
@@ -1177,7 +1182,7 @@ next_page:
	}
	BUG_ON(pages && !list_empty(pages));
	if (bio)
		__submit_bio(F2FS_I_SB(inode), READ, bio, DATA);
		__submit_bio(F2FS_I_SB(inode), bio, DATA);
	return 0;
}

@@ -1295,7 +1300,8 @@ static int f2fs_write_data_page(struct page *page,
	struct f2fs_io_info fio = {
		.sbi = sbi,
		.type = DATA,
		.rw = (wbc->sync_mode == WB_SYNC_ALL) ? WRITE_SYNC : WRITE,
		.op = REQ_OP_WRITE,
		.op_flags = wbc_to_write_flags(wbc),
		.page = page,
		.encrypted_page = NULL,
	};
@@ -1717,14 +1723,14 @@ repeat:
			err = PTR_ERR(bio);
			goto fail;
		}

		bio->bi_rw = READ_SYNC;
		if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
			bio_put(bio);
			err = -EFAULT;
			goto fail;
		}

		__submit_bio(sbi, READ_SYNC, bio, DATA);
		__submit_bio(sbi, bio, DATA);

		lock_page(page);
		if (unlikely(page->mapping != mapping)) {
+22 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <linux/blkdev.h>
#include <linux/fscrypto.h>
#include <crypto/hash.h>
#include <linux/writeback.h>

#ifdef CONFIG_F2FS_CHECK_FS
#define f2fs_bug_on(sbi, condition)	BUG_ON(condition)
@@ -112,6 +113,24 @@ struct f2fs_mount_info {
#define F2FS_CLEAR_FEATURE(sb, mask)					\
	F2FS_SB(sb)->raw_super->feature &= ~cpu_to_le32(mask)

/* bio stuffs */
#define REQ_OP_READ	READ
#define REQ_OP_WRITE	WRITE
#define bio_op(bio)	((bio)->bi_rw & 1)

static inline void bio_set_op_attrs(struct bio *bio, unsigned op,
		unsigned op_flags)
{
	bio->bi_rw = op | op_flags;
}

static inline int wbc_to_write_flags(struct writeback_control *wbc)
{
	if (wbc->sync_mode == WB_SYNC_ALL)
		return REQ_SYNC;
	return 0;
}

/**
 * wq_has_sleeper - check if there are any waiting processes
 * @wq: wait queue head
@@ -746,14 +765,15 @@ enum page_type {
struct f2fs_io_info {
	struct f2fs_sb_info *sbi;	/* f2fs_sb_info pointer */
	enum page_type type;	/* contains DATA/NODE/META/META_FLUSH */
	int rw;			/* contains R/RS/W/WS with REQ_META/REQ_PRIO */
	int op;			/* contains REQ_OP_ */
	int op_flags;		/* req_flag_bits */
	block_t new_blkaddr;	/* new block address to be written */
	block_t old_blkaddr;	/* old block address before Cow */
	struct page *page;	/* page to be written */
	struct page *encrypted_page;	/* encrypted page */
};

#define is_read_io(rw)	(((rw) & 1) == READ)
#define is_read_io(rw) (rw == READ)
struct f2fs_bio_info {
	struct f2fs_sb_info *sbi;	/* f2fs superblock */
	struct bio *bio;		/* bios to merge */
+8 −4
Original line number Diff line number Diff line
@@ -550,7 +550,8 @@ static void move_encrypted_block(struct inode *inode, block_t bidx,
	struct f2fs_io_info fio = {
		.sbi = F2FS_I_SB(inode),
		.type = DATA,
		.rw = READ_SYNC,
		.op = REQ_OP_READ,
		.op_flags = REQ_SYNC,
		.encrypted_page = NULL,
	};
	struct dnode_of_data dn;
@@ -627,7 +628,8 @@ static void move_encrypted_block(struct inode *inode, block_t bidx,
	/* allocate block address */
	f2fs_wait_on_page_writeback(dn.node_page, NODE, true);

	fio.rw = WRITE_SYNC;
	fio.op = REQ_OP_WRITE;
	fio.op_flags = REQ_SYNC | REQ_NOIDLE;
	fio.new_blkaddr = newaddr;
	f2fs_submit_page_mbio(&fio);

@@ -668,7 +670,8 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type,
		struct f2fs_io_info fio = {
			.sbi = F2FS_I_SB(inode),
			.type = DATA,
			.rw = WRITE_SYNC,
			.op = REQ_OP_WRITE,
			.op_flags = REQ_SYNC | REQ_NOIDLE,
			.page = page,
			.encrypted_page = NULL,
		};
@@ -767,7 +770,8 @@ next_step:

			start_bidx = start_bidx_of_node(nofs, inode);
			data_page = get_read_data_page(inode,
					start_bidx + ofs_in_node, READA, true);
					start_bidx + ofs_in_node, REQ_RAHEAD,
					true);
			if (IS_ERR(data_page)) {
				iput(inode);
				continue;
+2 −1
Original line number Diff line number Diff line
@@ -110,7 +110,8 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
	struct f2fs_io_info fio = {
		.sbi = F2FS_I_SB(dn->inode),
		.type = DATA,
		.rw = WRITE_SYNC | REQ_PRIO,
		.op = REQ_OP_WRITE,
		.op_flags = REQ_SYNC | REQ_NOIDLE | REQ_PRIO,
		.page = page,
		.encrypted_page = NULL,
	};
Loading