Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cupnes/11150ad9676cd969bdd6ce497a3290ec to your computer and use it in GitHub Desktop.
Save cupnes/11150ad9676cd969bdd6ce497a3290ec to your computer and use it in GitHub Desktop.
From 96fa9f46cb8cfae504381ae428ee2d897aba66fd Mon Sep 17 00:00:00 2001
From: Yuma Ohgami <yuma@ohgami.jp>
Date: Sat, 16 Sep 2017 00:26:08 +0900
Subject: [PATCH] fix compile error due to Linux's d62e26b and 74d4699 commits
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
2017/09/16現在(4.14のmerge window)、Linus treeのmasterでwalb-driverを
ビルドしようとするとコンパイルエラーに陥る。
原因は以下の2つのパッチ
- d62e26b block: pass in queue to inflight accounting [*1]
- 74d4699 block: replace bi_bdev with a gendisk pointer and partitions
index [*2]
上記2つの修正内容に沿うようにwalb-driverの内容を修正する。
現状、walb-driverのコンパイルができることを確認したのみのWIPのパッチで
ある(未動作確認)。
[*1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d62e26b
[*2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=74d4699
---
module/bio_entry.c | 14 +++++++-------
module/bio_entry.h | 2 +-
module/bio_util.h | 8 ++++----
module/io.c | 16 ++++++++--------
module/redo.c | 6 +++---
module/sector_io.c | 2 +-
6 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/module/bio_entry.c b/module/bio_entry.c
index 78437ce..ea79fb1 100644
--- a/module/bio_entry.c
+++ b/module/bio_entry.c
@@ -106,12 +106,12 @@ void print_bio_entry(const char *level, const struct bio_entry *bioe)
static void bio_entry_end_io(struct bio *bio)
{
struct bio_entry *bioe = bio->bi_private;
+ ASSERT(bio);
ASSERT(bioe);
- ASSERT(bio->bi_bdev);
ASSERT(bioe->bio == bio);
if (bio->bi_status) {
- UNUSED const unsigned int devt = bio->bi_bdev->bd_dev;
+ UNUSED const unsigned int devt = bio_dev(bio);
LOG_("bio is error"
" (dev %u:%u opf %08x pos %" PRIu64 " len %u).\n"
, MAJOR(devt), MINOR(devt)
@@ -172,7 +172,7 @@ bool init_bio_entry_by_clone(
if (!clone)
return false;
- clone->bi_bdev = bdev;
+ bio_set_dev(clone, bdev);
init_bio_entry(bioe, clone);
return true;
@@ -210,10 +210,10 @@ retry:
*
* @size size in bytes.
*
- * You must set bi_bdev, bi_opf, bi_iter by yourself.
+ * You must set bi_disk, bi_opf, bi_iter by yourself.
* bi_iter.bi_size will be set to the specified size if size is not 0.
*/
-struct bio* bio_alloc_with_pages(uint size, struct block_device *bdev, gfp_t gfp_mask)
+struct bio* bio_alloc_with_pages(uint size, struct bio *src, gfp_t gfp_mask)
{
struct bio *bio;
uint i, nr_pages, remaining;
@@ -224,7 +224,7 @@ struct bio* bio_alloc_with_pages(uint size, struct block_device *bdev, gfp_t gfp
if (!bio)
return NULL;
- bio->bi_bdev = bdev; /* required to bio_add_page(). */
+ bio_copy_dev(bio, src); /* required to bio_add_page(). */
remaining = size;
for (i = 0; i < nr_pages; i++) {
@@ -281,7 +281,7 @@ struct bio* bio_deep_clone(struct bio *bio, gfp_t gfp_mask)
else
size = 0;
- clone = bio_alloc_with_pages(size, bio->bi_bdev, gfp_mask);
+ clone = bio_alloc_with_pages(size, bio, gfp_mask);
if (!clone)
return NULL;
diff --git a/module/bio_entry.h b/module/bio_entry.h
index a35aac6..9bd3432 100644
--- a/module/bio_entry.h
+++ b/module/bio_entry.h
@@ -57,7 +57,7 @@ void wait_for_bio_entry(struct bio_entry *bioe, ulong timeoutMs, uint dev_minor)
* with own pages.
*/
struct bio* bio_alloc_with_pages(
- uint sectors, struct block_device *bdev, gfp_t gfp_mask);
+ uint sectors, struct bio *src, gfp_t gfp_mask);
void bio_put_with_pages(struct bio *bio);
struct bio* bio_deep_clone(struct bio *bio, gfp_t gfp_mask);
diff --git a/module/bio_util.h b/module/bio_util.h
index 9cf2814..c5db5cc 100644
--- a/module/bio_util.h
+++ b/module/bio_util.h
@@ -241,8 +241,8 @@ static inline int snprint_bio(char *buf, size_t size, const struct bio *bio)
, bio->bi_vcnt
, bio->bi_max_vecs
, atomic_read(&bio->__bi_cnt)
- , MAJOR(bio->bi_bdev->bd_dev)
- , MINOR(bio->bi_bdev->bd_dev));
+ , MAJOR(bio_dev(bio))
+ , MINOR(bio_dev(bio)));
SNPRINT_BIO_PROCEED(buf, size, w, s);
s = snprint_bvec_iter(buf, size, &bio->bi_iter);
SNPRINT_BIO_PROCEED(buf, size, w, s);
@@ -288,8 +288,8 @@ static inline void print_bio_short(const char *prefix, const struct bio *bio)
pr_info("%sbio %p pos %" PRIu64 " len %u"
" bdev(%d:%d) opf %08x\n"
, prefix, bio, (u64)bio_begin_sector(bio), bio_sectors(bio)
- , MAJOR(bio->bi_bdev->bd_dev)
- , MINOR(bio->bi_bdev->bd_dev)
+ , MAJOR(bio_dev(bio))
+ , MINOR(bio_dev(bio))
, bio->bi_opf);
}
diff --git a/module/io.c b/module/io.c
index 5b5f36e..cce29c4 100644
--- a/module/io.c
+++ b/module/io.c
@@ -1228,7 +1228,7 @@ retry_bio:
page2 = virt_to_page((unsigned long)lhead + pbs - 1);
ASSERT(page == page2);
#endif
- bio->bi_bdev = ldev;
+ bio_set_dev(bio, ldev);
off_pb = get_offset_of_lsid(lhead->logpack_lsid, ring_buffer_off, ring_buffer_size);
off_lb = addr_lb(pbs, off_pb);
bio->bi_iter.bi_sector = off_lb;
@@ -1296,7 +1296,7 @@ static struct bio* logpack_create_bio(
if (!cbio)
return NULL;
- cbio->bi_bdev = ldev;
+ bio_set_dev(cbio, ldev);
cbio->bi_iter.bi_sector = addr_lb(pbs, ldev_off_pb) + bio_off_lb;
/* cbio->bi_end_io = NULL; */
/* cbio->bi_private = NULL; */
@@ -2384,7 +2384,7 @@ static bool submit_flush(struct bio_entry *bioe, struct block_device *bdev)
if (!bio)
return false;
- bio->bi_bdev = bdev;
+ bio_set_dev(bio, bdev);
bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_PREFLUSH);
init_bio_entry(bioe, bio);
@@ -2861,10 +2861,10 @@ static void io_acct_start(struct bio_wrapper *biow)
biow->start_time = jiffies;
cpu = part_stat_lock();
- part_round_stats(cpu, part0);
+ part_round_stats(biow->bio->bi_disk->queue, cpu, part0);
part_stat_inc(cpu, part0, ios[rw]);
part_stat_add(cpu, part0, sectors[rw], biow->len);
- part_inc_in_flight(part0, rw);
+ part_inc_in_flight(biow->bio->bi_disk->queue, part0, rw);
part_stat_unlock();
#ifdef WALB_DEBUG
@@ -2883,8 +2883,8 @@ static void io_acct_end(struct bio_wrapper *biow)
cpu = part_stat_lock();
part_stat_add(cpu, part0, ticks[rw], duration);
- part_round_stats(cpu, part0);
- part_dec_in_flight(part0, rw);
+ part_round_stats(biow->bio->bi_disk->queue, cpu, part0);
+ part_dec_in_flight(biow->bio->bi_disk->queue, part0, rw);
part_stat_unlock();
if (io_latency_threshold_ms_ > 0 && duration_ms > io_latency_threshold_ms_) {
@@ -3203,7 +3203,7 @@ void iocore_log_make_request(struct walb_dev *wdev, struct bio *bio)
bio_io_error(bio);
return;
}
- bio->bi_bdev = wdev->ldev;
+ bio_set_dev(bio, wdev->ldev);
generic_make_request(bio);
}
diff --git a/module/redo.c b/module/redo.c
index 2540c0e..3c2111c 100644
--- a/module/redo.c
+++ b/module/redo.c
@@ -336,7 +336,7 @@ static struct bio_wrapper* create_log_bio_wrapper_for_redo(
biow = alloc_bio_wrapper_inc(wdev, GFP_NOIO);
if (!biow) { goto error2; }
- bio->bi_bdev = wdev->ldev;
+ bio_set_dev(bio, wdev->ldev);
off_pb = get_offset_of_lsid(lsid, wdev->ring_buffer_off, wdev->ring_buffer_size);
WLOG_(wdev, "lsid: %" PRIu64 " off_pb: %" PRIu64 "\n", lsid, off_pb);
off_lb = addr_lb(pbs, off_pb);
@@ -392,7 +392,7 @@ static bool prepare_data_bio_for_redo(
bio = bio_alloc(GFP_NOIO, 1);
if (!bio) { return false; }
- bio->bi_bdev = wdev->ddev;
+ bio_set_dev(bio, wdev->ddev);
bio->bi_iter.bi_sector = pos;
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio->bi_end_io = bio_end_io_for_redo;
@@ -429,7 +429,7 @@ static struct bio_wrapper* create_discard_bio_wrapper_for_redo(
biow = alloc_bio_wrapper_inc(wdev, GFP_NOIO);
if (!biow) { goto error1; }
- bio->bi_bdev = wdev->ddev;
+ bio_set_dev(bio, wdev->ddev);
bio->bi_iter.bi_sector = pos;
bio->bi_iter.bi_size = len << 9;
bio_set_op_attrs(bio, REQ_OP_DISCARD, 0);
diff --git a/module/sector_io.c b/module/sector_io.c
index fcba455..38b743a 100644
--- a/module/sector_io.c
+++ b/module/sector_io.c
@@ -59,7 +59,7 @@ bool sector_io(
off = offset_in_page(buf);
bio_set_op_attrs(bio, op, op_flags);
- bio->bi_bdev = bdev;
+ bio_set_dev(bio, bdev);
bio->bi_iter.bi_sector = addr_lb(pbs, addr);
bio_add_page(bio, page, pbs, off);
--
2.1.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment