From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Jens Axboe <axboe@kernel.dk>, Jaegeuk Kim <jaegeuk.kim@samsung.com>
Cc: linux-next@vger.kernel.org, linux-kernel@vger.kernel.org,
Kent Overstreet <kmo@daterainc.com>
Subject: linux-next: manual merge of the block tree with the f2fs tree
Date: Mon, 2 Dec 2013 15:04:22 +1100 [thread overview]
Message-ID: <20131202150422.f3c9db7e38f91f92d67c3149@canb.auug.org.au> (raw)
[-- Attachment #1: Type: text/plain, Size: 6772 bytes --]
Hi Jens,
Today's linux-next merge of the block tree got conflicts in
fs/f2fs/data.c and fs/f2fs/segment.c between commits 0626804cd9a6 ("f2fs:
remove the own bi_private allocation") and 899d7625d85a ("f2fs: refactor
bio-related operations") from the f2fs tree and commits 2c30c71bd653
("block: Convert various code to bio_for_each_segment()") and ("block:
Abstract out bvec iterator") from the block tree.
I fixed it up (hopefully - see below - the handling of sbi in
f2fs_end_io_write is not the best) and can carry the fix as necessary (no
action is required).
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
diff --cc fs/f2fs/data.c
index 53e3bbbba7ed,a2c8de8ba6ce..b62a99cf6561
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@@ -25,205 -25,6 +25,201 @@@
#include <trace/events/f2fs.h>
/*
+ * Low-level block read/write IO operations.
+ */
+static struct bio *__bio_alloc(struct block_device *bdev, int npages)
+{
+ struct bio *bio;
+
+ /* No failure on bio allocation */
+ bio = bio_alloc(GFP_NOIO, npages);
+ bio->bi_bdev = bdev;
+ bio->bi_private = NULL;
+ return bio;
+}
+
+static void f2fs_read_end_io(struct bio *bio, int err)
+{
- const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
- struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
++ struct bio_vec *bvec;
++ int i;
+
- do {
++ bio_for_each_segment_all(bvec, bio, i) {
+ struct page *page = bvec->bv_page;
+
- if (--bvec >= bio->bi_io_vec)
- prefetchw(&bvec->bv_page->flags);
-
- if (uptodate) {
++ if (!err) {
+ SetPageUptodate(page);
+ } else {
+ ClearPageUptodate(page);
+ SetPageError(page);
+ }
+ unlock_page(page);
- } while (bvec >= bio->bi_io_vec);
++ }
+
+ bio_put(bio);
+}
+
+static void f2fs_write_end_io(struct bio *bio, int err)
+{
- const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
- struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
- struct f2fs_sb_info *sbi = F2FS_SB(bvec->bv_page->mapping->host->i_sb);
++ struct f2fs_sb_info *sbi = NULL;
++ struct bio_vec *bvec;
++ int i;
+
- do {
++ bio_for_each_segment_all(bvec, bio, i) {
+ struct page *page = bvec->bv_page;
+
- if (--bvec >= bio->bi_io_vec)
- prefetchw(&bvec->bv_page->flags);
-
- if (!uptodate) {
++ if (!sbi)
++ sbi = F2FS_SB(bvec->bv_page->mapping->host->i_sb);
++ if (err) {
+ SetPageError(page);
+ set_bit(AS_EIO, &page->mapping->flags);
+ set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
+ sbi->sb->s_flags |= MS_RDONLY;
+ }
+ end_page_writeback(page);
+ dec_page_count(sbi, F2FS_WRITEBACK);
- } while (bvec >= bio->bi_io_vec);
++ }
+
+ if (bio->bi_private)
+ complete(bio->bi_private);
+
+ if (!get_pages(sbi, F2FS_WRITEBACK) &&
+ !list_empty(&sbi->cp_wait.task_list))
+ wake_up(&sbi->cp_wait);
+
+ bio_put(bio);
+}
+
+static void __submit_merged_bio(struct f2fs_sb_info *sbi,
+ struct f2fs_bio_info *io,
+ enum page_type type, bool sync, int rw)
+{
+ enum page_type btype = PAGE_TYPE_OF_BIO(type);
+
+ if (!io->bio)
+ return;
+
+ if (btype == META)
+ rw |= REQ_META;
+
+ if (is_read_io(rw)) {
+ if (sync)
+ rw |= READ_SYNC;
+ submit_bio(rw, io->bio);
+ trace_f2fs_submit_read_bio(sbi->sb, rw, type, io->bio);
+ io->bio = NULL;
+ return;
+ }
+
+ if (sync)
+ rw |= WRITE_SYNC;
+ if (type >= META_FLUSH)
+ rw |= WRITE_FLUSH_FUA;
+
+ /*
+ * META_FLUSH is only from the checkpoint procedure, and we should wait
+ * this metadata bio for FS consistency.
+ */
+ if (type == META_FLUSH) {
+ DECLARE_COMPLETION_ONSTACK(wait);
+ io->bio->bi_private = &wait;
+ submit_bio(rw, io->bio);
+ wait_for_completion(&wait);
+ } else {
+ submit_bio(rw, io->bio);
+ }
+ trace_f2fs_submit_write_bio(sbi->sb, rw, btype, io->bio);
+ io->bio = NULL;
+}
+
+void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
+ enum page_type type, bool sync, int rw)
+{
+ enum page_type btype = PAGE_TYPE_OF_BIO(type);
+ struct f2fs_bio_info *io;
+
+ io = is_read_io(rw) ? &sbi->read_io : &sbi->write_io[btype];
+
+ mutex_lock(&io->io_mutex);
+ __submit_merged_bio(sbi, io, type, sync, rw);
+ mutex_unlock(&io->io_mutex);
+}
+
+/*
+ * Fill the locked page with data located in the block address.
+ * Return unlocked page.
+ */
+int f2fs_submit_page_bio(struct f2fs_sb_info *sbi, struct page *page,
+ block_t blk_addr, int rw)
+{
+ struct block_device *bdev = sbi->sb->s_bdev;
+ struct bio *bio;
+
+ trace_f2fs_submit_page_bio(page, blk_addr, rw);
+
+ /* Allocate a new bio */
+ bio = __bio_alloc(bdev, 1);
+
+ /* Initialize the bio */
- bio->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
++ bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
+ bio->bi_end_io = is_read_io(rw) ? f2fs_read_end_io : f2fs_write_end_io;
+
+ if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) {
+ bio_put(bio);
+ f2fs_put_page(page, 1);
+ return -EFAULT;
+ }
+
+ submit_bio(rw, bio);
+ return 0;
+}
+
+void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page,
+ block_t blk_addr, enum page_type type, int rw)
+{
+ enum page_type btype = PAGE_TYPE_OF_BIO(type);
+ struct block_device *bdev = sbi->sb->s_bdev;
+ struct f2fs_bio_info *io;
+ int bio_blocks;
+
+ io = is_read_io(rw) ? &sbi->read_io : &sbi->write_io[btype];
+
+ verify_block_addr(sbi, blk_addr);
+
+ mutex_lock(&io->io_mutex);
+
+ if (!is_read_io(rw))
+ inc_page_count(sbi, F2FS_WRITEBACK);
+
+ if (io->bio && io->last_block_in_bio != blk_addr - 1)
+ __submit_merged_bio(sbi, io, type, true, rw);
+alloc_new:
+ if (io->bio == NULL) {
+ bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+ io->bio = __bio_alloc(bdev, bio_blocks);
- io->bio->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
++ io->bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
+ io->bio->bi_end_io = is_read_io(rw) ? f2fs_read_end_io :
+ f2fs_write_end_io;
+ /*
+ * The end_io will be assigned at the sumbission phase.
+ * Until then, let bio_add_page() merge consecutive IOs as much
+ * as possible.
+ */
+ }
+
+ if (bio_add_page(io->bio, page, PAGE_CACHE_SIZE, 0) <
+ PAGE_CACHE_SIZE) {
+ __submit_merged_bio(sbi, io, type, true, rw);
+ io->bio = NULL;
+ goto alloc_new;
+ }
+
+ io->last_block_in_bio = blk_addr;
+
+ mutex_unlock(&io->io_mutex);
+ trace_f2fs_submit_page_mbio(page, rw, type, blk_addr);
+}
+
+/*
* Lock ordering for the change of data block address:
* ->data_page
* ->node_page
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next reply other threads:[~2013-12-02 4:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-02 4:04 Stephen Rothwell [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-12-03 3:43 linux-next: manual merge of the block tree with the f2fs tree Stephen Rothwell
2020-12-03 3:47 ` Chao Yu
2020-12-03 3:57 ` Stephen Rothwell
2020-12-14 20:12 ` Stephen Rothwell
2020-12-17 1:50 ` Stephen Rothwell
2016-11-22 3:42 Stephen Rothwell
2016-07-11 4:52 Stephen Rothwell
2016-06-20 2:37 Stephen Rothwell
2016-06-09 3:26 Stephen Rothwell
2016-06-09 3:34 ` Stephen Rothwell
2015-07-30 3:19 Stephen Rothwell
2014-01-06 6:03 Stephen Rothwell
2013-12-18 3:57 Stephen Rothwell
2013-12-12 2:57 Stephen Rothwell
2013-11-26 1:00 Stephen Rothwell
2013-11-26 0:56 Stephen Rothwell
2013-11-01 3:29 Stephen Rothwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131202150422.f3c9db7e38f91f92d67c3149@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=axboe@kernel.dk \
--cc=jaegeuk.kim@samsung.com \
--cc=kmo@daterainc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).