bcache: comment on direct access to bvec table
authorMing Lei <ming.lei@redhat.com>
Mon, 18 Dec 2017 12:22:09 +0000 (20:22 +0800)
committerJens Axboe <axboe@kernel.dk>
Sat, 6 Jan 2018 16:18:00 +0000 (09:18 -0700)
All direct access to bvec table are safe even after multipage bvec is
supported.

Cc: linux-bcache@vger.kernel.org
Acked-by: Coly Li <colyli@suse.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/btree.c
drivers/md/bcache/util.c

index 81e8dc3dbe5e30604438ca0658d39900cde7e2c8..02a4cf646fdcee32a436c442adddfebb6f03a6c9 100644 (file)
@@ -432,6 +432,7 @@ static void do_btree_node_write(struct btree *b)
 
                continue_at(cl, btree_node_write_done, NULL);
        } else {
+               /* No problem for multipage bvec since the bio is just allocated */
                b->bio->bi_vcnt = 0;
                bch_bio_map(b->bio, i);
 
index e548b8b513227fcc8ffe7409eb85145fddc953da..61813d23001543932b05857b6f9143be908242b4 100644 (file)
@@ -249,6 +249,13 @@ uint64_t bch_next_delay(struct bch_ratelimit *d, uint64_t done)
                : 0;
 }
 
+/*
+ * Generally it isn't good to access .bi_io_vec and .bi_vcnt directly,
+ * the preferred way is bio_add_page, but in this case, bch_bio_map()
+ * supposes that the bvec table is empty, so it is safe to access
+ * .bi_vcnt & .bi_io_vec in this way even after multipage bvec is
+ * supported.
+ */
 void bch_bio_map(struct bio *bio, void *base)
 {
        size_t size = bio->bi_iter.bi_size;