summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/md/bcache/fs-io.c6
-rw-r--r--drivers/md/bcache/io.c13
-rw-r--r--drivers/md/bcache/request.c13
3 files changed, 14 insertions, 18 deletions
diff --git a/drivers/md/bcache/fs-io.c b/drivers/md/bcache/fs-io.c
index bb9bdd4ba41a..a8895481eec5 100644
--- a/drivers/md/bcache/fs-io.c
+++ b/drivers/md/bcache/fs-io.c
@@ -839,10 +839,8 @@ static void bch_writepage_io_done(struct closure *cl)
static void bch_writepage_do_io(struct bch_writepage_io *io)
{
- pr_debug("writing %u sectors to %llu:%llu",
- bio_sectors(&io->bio.bio.bio),
- io->op.op.insert_key.k.p.inode,
- (u64) io->bio.bio.bio.bi_iter.bi_sector);
+ io->op.op.insert_key.k.p.offset = bio_end_sector(&io->bio.bio.bio);
+ io->op.op.insert_key.k.size = bio_sectors(&io->bio.bio.bio);
closure_call(&io->op.op.cl, bch_write, NULL, &io->cl);
continue_at(&io->cl, bch_writepage_io_done, NULL);
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
index aaeb95d684e0..c99d5ca0962d 100644
--- a/drivers/md/bcache/io.c
+++ b/drivers/md/bcache/io.c
@@ -1185,16 +1185,14 @@ void bch_write(struct closure *cl)
struct cache_set *c = op->c;
u64 inode = op->insert_key.k.p.inode;
+ BUG_ON(op->insert_key.k.p.offset != bio_end_sector(bio));
+ BUG_ON(op->insert_key.k.size != bio_sectors(bio));
+ BUG_ON(!bio_sectors(bio));
+
trace_bcache_write(c, inode, bio,
!bkey_extent_is_cached(&op->insert_key.k),
op->flags & BCH_WRITE_DISCARD);
- if (!bio_sectors(bio)) {
- WARN_ONCE(1, "bch_write() called with empty bio");
- bch_disk_reservation_put(op->c, &op->res);
- closure_return(cl);
- }
-
if (!percpu_ref_tryget(&c->writes)) {
__bcache_io_error(c, "read only");
op->error = -EROFS;
@@ -1220,9 +1218,6 @@ void bch_write(struct closure *cl)
else
bch_mark_discard(c, bio_sectors(bio));
- op->insert_key.k.p.offset = bio_end_sector(bio);
- op->insert_key.k.size = bio_sectors(bio);
-
/* Don't call bch_next_delay() if rate is >= 1 GB/sec */
if (c->foreground_write_ratelimit_enabled &&
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index f4ec2f3185ea..066eb585ed94 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -482,16 +482,17 @@ static void cached_dev_write(struct cached_dev *dc, struct search *s)
{
struct closure *cl = &s->cl;
struct bio *bio = &s->wbio.bio.bio;
- unsigned inode = bcache_dev_inum(&dc->disk);
bool writeback = false;
bool bypass = s->bypass;
- struct bkey insert_key = KEY(s->inode, 0, 0);
+ struct bkey insert_key = KEY(s->inode,
+ bio_end_sector(bio),
+ bio_sectors(bio));
unsigned flags = BCH_WRITE_DISCARD_ON_ERROR;
down_read_non_owner(&dc->writeback_lock);
if (bch_keybuf_check_overlapping(&dc->writeback_keys,
- POS(inode, bio->bi_iter.bi_sector),
- POS(inode, bio_end_sector(bio)))) {
+ bkey_start_pos(&insert_key),
+ insert_key.p)) {
/*
* We overlap with some dirty data undergoing background
* writeback, force this write to writeback
@@ -703,7 +704,9 @@ static void __blockdev_volume_make_request(struct request_queue *q,
flags |= BCH_WRITE_DISCARD;
bch_write_op_init(&s->iop, d->c, &s->wbio, res, NULL,
- bkey_to_s_c(&KEY(s->inode, 0, 0)),
+ bkey_to_s_c(&KEY(s->inode,
+ bio_end_sector(&s->wbio.bio.bio),
+ bio_sectors(&s->wbio.bio.bio))),
NULL, NULL, flags);
closure_call(&s->iop.cl, bch_write, NULL, &s->cl);