request.c (6f10f7d1b02b1bbc305f88d7696445dd38b13881) | request.c (1fae7cf05293d3a2c9e59c1bc59372322386467c) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Main bcache entry point - handle a read or a write request and decide what to 4 * do with it; the make_request functions are called by the block layer. 5 * 6 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com> 7 * Copyright 2012 Google, Inc. 8 */ --- 31 unchanged lines hidden (view full) --- 40static void bio_csum(struct bio *bio, struct bkey *k) 41{ 42 struct bio_vec bv; 43 struct bvec_iter iter; 44 uint64_t csum = 0; 45 46 bio_for_each_segment(bv, bio, iter) { 47 void *d = kmap(bv.bv_page) + bv.bv_offset; | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Main bcache entry point - handle a read or a write request and decide what to 4 * do with it; the make_request functions are called by the block layer. 5 * 6 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com> 7 * Copyright 2012 Google, Inc. 8 */ --- 31 unchanged lines hidden (view full) --- 40static void bio_csum(struct bio *bio, struct bkey *k) 41{ 42 struct bio_vec bv; 43 struct bvec_iter iter; 44 uint64_t csum = 0; 45 46 bio_for_each_segment(bv, bio, iter) { 47 void *d = kmap(bv.bv_page) + bv.bv_offset; |
48 |
|
48 csum = bch_crc64_update(csum, d, bv.bv_len); 49 kunmap(bv.bv_page); 50 } 51 52 k->ptr[KEY_PTRS(k)] = csum & (~0ULL >> 1); 53} 54 55/* Insert data into cache */ --- 465 unchanged lines hidden (view full) --- 521 522 if (KEY_INODE(k) != s->iop.inode || 523 KEY_START(k) > bio->bi_iter.bi_sector) { 524 unsigned int bio_sectors = bio_sectors(bio); 525 unsigned int sectors = KEY_INODE(k) == s->iop.inode 526 ? min_t(uint64_t, INT_MAX, 527 KEY_START(k) - bio->bi_iter.bi_sector) 528 : INT_MAX; | 49 csum = bch_crc64_update(csum, d, bv.bv_len); 50 kunmap(bv.bv_page); 51 } 52 53 k->ptr[KEY_PTRS(k)] = csum & (~0ULL >> 1); 54} 55 56/* Insert data into cache */ --- 465 unchanged lines hidden (view full) --- 522 523 if (KEY_INODE(k) != s->iop.inode || 524 KEY_START(k) > bio->bi_iter.bi_sector) { 525 unsigned int bio_sectors = bio_sectors(bio); 526 unsigned int sectors = KEY_INODE(k) == s->iop.inode 527 ? min_t(uint64_t, INT_MAX, 528 KEY_START(k) - bio->bi_iter.bi_sector) 529 : INT_MAX; |
529 | |
530 int ret = s->d->cache_miss(b, s, bio, sectors); | 530 int ret = s->d->cache_miss(b, s, bio, sectors); |
531 |
|
531 if (ret != MAP_CONTINUE) 532 return ret; 533 534 /* if this was a complete miss we shouldn't get here */ 535 BUG_ON(bio_sectors <= sectors); 536 } 537 538 if (!KEY_SIZE(k)) --- 79 unchanged lines hidden (view full) --- 618/* Common code for the make_request functions */ 619 620static void request_endio(struct bio *bio) 621{ 622 struct closure *cl = bio->bi_private; 623 624 if (bio->bi_status) { 625 struct search *s = container_of(cl, struct search, cl); | 532 if (ret != MAP_CONTINUE) 533 return ret; 534 535 /* if this was a complete miss we shouldn't get here */ 536 BUG_ON(bio_sectors <= sectors); 537 } 538 539 if (!KEY_SIZE(k)) --- 79 unchanged lines hidden (view full) --- 619/* Common code for the make_request functions */ 620 621static void request_endio(struct bio *bio) 622{ 623 struct closure *cl = bio->bi_private; 624 625 if (bio->bi_status) { 626 struct search *s = container_of(cl, struct search, cl); |
627 |
|
626 s->iop.status = bio->bi_status; 627 /* Only cache read errors are recoverable */ 628 s->recoverable = false; 629 } 630 631 bio_put(bio); 632 closure_put(cl); 633} --- 573 unchanged lines hidden (view full) --- 1207 1208 return BLK_QC_T_NONE; 1209} 1210 1211static int cached_dev_ioctl(struct bcache_device *d, fmode_t mode, 1212 unsigned int cmd, unsigned long arg) 1213{ 1214 struct cached_dev *dc = container_of(d, struct cached_dev, disk); | 628 s->iop.status = bio->bi_status; 629 /* Only cache read errors are recoverable */ 630 s->recoverable = false; 631 } 632 633 bio_put(bio); 634 closure_put(cl); 635} --- 573 unchanged lines hidden (view full) --- 1209 1210 return BLK_QC_T_NONE; 1211} 1212 1213static int cached_dev_ioctl(struct bcache_device *d, fmode_t mode, 1214 unsigned int cmd, unsigned long arg) 1215{ 1216 struct cached_dev *dc = container_of(d, struct cached_dev, disk); |
1217 |
|
1215 return __blkdev_driver_ioctl(dc->bdev, mode, cmd, arg); 1216} 1217 1218static int cached_dev_congested(void *data, int bits) 1219{ 1220 struct bcache_device *d = data; 1221 struct cached_dev *dc = container_of(d, struct cached_dev, disk); 1222 struct request_queue *q = bdev_get_queue(dc->bdev); --- 153 unchanged lines hidden --- | 1218 return __blkdev_driver_ioctl(dc->bdev, mode, cmd, arg); 1219} 1220 1221static int cached_dev_congested(void *data, int bits) 1222{ 1223 struct bcache_device *d = data; 1224 struct cached_dev *dc = container_of(d, struct cached_dev, disk); 1225 struct request_queue *q = bdev_get_queue(dc->bdev); --- 153 unchanged lines hidden --- |