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

Commit 71368511 authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Linus Torvalds
Browse files

mm: make snapshotting pages for stable writes a per-bio operation



Walking a bio's page mappings has proved problematic, so create a new
bio flag to indicate that a bio's data needs to be snapshotted in order
to guarantee stable pages during writeback.  Next, for the one user
(ext3/jbd) of snapshotting, hook all the places where writes can be
initiated without PG_writeback set, and set BIO_SNAP_STABLE there.

We must also flag journal "metadata" bios for stable writeout, since
file data can be written through the journal.  Finally, the
MS_SNAP_STABLE mount flag (only used by ext3) is now superfluous, so get
rid of it.

[akpm@linux-foundation.org: rename _submit_bh()'s `flags' to `bio_flags', delobotomize the _submit_bh declaration]
[akpm@linux-foundation.org: teeny cleanup]
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 106c992a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -2949,7 +2949,7 @@ static void guard_bh_eod(int rw, struct bio *bio, struct buffer_head *bh)
	}
}

int submit_bh(int rw, struct buffer_head * bh)
int _submit_bh(int rw, struct buffer_head *bh, unsigned long bio_flags)
{
	struct bio *bio;
	int ret = 0;
@@ -2984,6 +2984,7 @@ int submit_bh(int rw, struct buffer_head * bh)

	bio->bi_end_io = end_bio_bh_io_sync;
	bio->bi_private = bh;
	bio->bi_flags |= bio_flags;

	/* Take care of bh's that straddle the end of the device */
	guard_bh_eod(rw, bio, bh);
@@ -2997,6 +2998,12 @@ int submit_bh(int rw, struct buffer_head * bh)
	bio_put(bio);
	return ret;
}
EXPORT_SYMBOL_GPL(_submit_bh);

int submit_bh(int rw, struct buffer_head *bh)
{
	return _submit_bh(rw, bh, 0);
}
EXPORT_SYMBOL(submit_bh);

/**
+0 −1
Original line number Diff line number Diff line
@@ -2067,7 +2067,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
		test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal":
		test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
		"writeback");
	sb->s_flags |= MS_SNAP_STABLE;

	return 0;

+22 −3
Original line number Diff line number Diff line
@@ -162,8 +162,17 @@ static void journal_do_submit_data(struct buffer_head **wbuf, int bufs,

	for (i = 0; i < bufs; i++) {
		wbuf[i]->b_end_io = end_buffer_write_sync;
		/* We use-up our safety reference in submit_bh() */
		submit_bh(write_op, wbuf[i]);
		/*
		 * Here we write back pagecache data that may be mmaped. Since
		 * we cannot afford to clean the page and set PageWriteback
		 * here due to lock ordering (page lock ranks above transaction
		 * start), the data can change while IO is in flight. Tell the
		 * block layer it should bounce the bio pages if stable data
		 * during write is required.
		 *
		 * We use up our safety reference in submit_bh().
		 */
		_submit_bh(write_op, wbuf[i], 1 << BIO_SNAP_STABLE);
	}
}

@@ -667,7 +676,17 @@ start_journal_io:
				clear_buffer_dirty(bh);
				set_buffer_uptodate(bh);
				bh->b_end_io = journal_end_buffer_io_sync;
				submit_bh(write_op, bh);
				/*
				 * In data=journal mode, here we can end up
				 * writing pagecache data that might be
				 * mmapped. Since we can't afford to clean the
				 * page and set PageWriteback (see the comment
				 * near the other use of _submit_bh()), the
				 * data can change while the write is in
				 * flight.  Tell the block layer to bounce the
				 * bio pages if stable pages are required.
				 */
				_submit_bh(write_op, bh, 1 << BIO_SNAP_STABLE);
			}
			cond_resched();

+2 −1
Original line number Diff line number Diff line
@@ -111,12 +111,13 @@ struct bio {
#define BIO_FS_INTEGRITY 9	/* fs owns integrity data, not block layer */
#define BIO_QUIET	10	/* Make BIO Quiet */
#define BIO_MAPPED_INTEGRITY 11/* integrity metadata has been remapped */
#define BIO_SNAP_STABLE	12	/* bio data must be snapshotted during write */

/*
 * Flags starting here get preserved by bio_reset() - this includes
 * BIO_POOL_IDX()
 */
#define BIO_RESET_BITS	12
#define BIO_RESET_BITS	13

#define bio_flagged(bio, flag)	((bio)->bi_flags & (1 << (flag)))

+1 −0
Original line number Diff line number Diff line
@@ -181,6 +181,7 @@ void ll_rw_block(int, int, struct buffer_head * bh[]);
int sync_dirty_buffer(struct buffer_head *bh);
int __sync_dirty_buffer(struct buffer_head *bh, int rw);
void write_dirty_buffer(struct buffer_head *bh, int rw);
int _submit_bh(int rw, struct buffer_head *bh, unsigned long bio_flags);
int submit_bh(int, struct buffer_head *);
void write_boundary_block(struct block_device *bdev,
			sector_t bblock, unsigned blocksize);
Loading