fix failure with new bi_error field of bio
PATCH 1/1 fix failure with new bi_error field of bio
drbd fail to build with new bio structure and interface after 4.3.0, see 4246a0b63bd8f56a1469b12eafeb875b1041a451 A new bi_error field to store an errno value directly in struct bio and remove the existing mechanisms to clean all this up.
With 8ae126660fddbeebb9251a174e6fa45b6ad8f932, generic_make_request() is now able to handle arbitrarily sized bios,it's no longer need to define its merge_bvec_fn.
This patch delete merge_bvec_fn and support new bio struct.
--- drbd/drbd_actlog.c | 4 ++ drbd/drbd_bitmap.c | 46 +++++++++++++++++++++ drbd/drbd_int.h | 2 + drbd/drbd_main.c | 2 + drbd/drbd_req.c | 4 +- drbd/drbd_worker.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++ drbd/drbd_wrappers.h | 31 +++++++++++++- 7 files changed, 201 insertions(+), 2 deletions(-)
drbd/drbd_actlog.c +4 -0
@@ -184,7 +184,11 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,else submit_bio (rw, bio);wait_until_done_or_force_detached (device, bdev, &device->md_io.done); +#ifdef NO_ERROR_BIO_END_IO +if (bio->bi_error) +#else if (bio_flagged(bio, BIO_UPTODATE)) +#endif err = device->md_io.error;#ifndef REQ_FLUSH
drbd/drbd_bitmap.c +46 -0
58 lines not on this page · raw message
drbd/drbd_int.h +2 -0
@@ -1563,6 +1563,7 @@ extern void do_submit(struct work_struct *ws);extern void __drbd_make_request (struct drbd_device *,struct bio *,unsigned long );extern MAKE_REQUEST_TYPE drbd_make_request (struct request_queue *q,struct bio *bio);extern int drbd_read_remote (struct drbd_device *device,struct drbd_request *req); +#ifndef NO_ERROR_BIO_END_IO extern int drbd_merge_bvec(struct request_queue *q, #ifdef HAVE_bvec_merge_data struct bvec_merge_data *bvm,
@@ -1570,6 +1571,7 @@ extern int drbd_merge_bvec(struct request_queue *q, struct bio *bvm,#endif struct bio_vec *bvec); +#endif extern int is_valid_ar_handle (struct drbd_request *,sector_t );
drbd/drbd_main.c +2 -0
@@ -2855,7 +2855,9 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsigThis triggers a max_bio_size message upon first attach or connect */ blk_queue_max_hw_sectors (q,DRBD_MAX_BIO_SIZE_SAFE >>8 );blk_queue_bounce_limit (q,BLK_BOUNCE_ANY ); +#ifndef NO_ERROR_BIO_END_IO blk_queue_merge_bvec (q, drbd_merge_bvec); +#endif q->queue_lock = &resource->req_lock;#ifdef blk_queue_plugged/* plugging on a queue, that actually has no requests! */
drbd/drbd_req.c +3 -1
@@ -1573,6 +1573,7 @@ MAKE_REQUEST_TYPE drbd_make_request(struct request_queue *q, struct bio *bio)* As long as the BIO is empty we have to allow at least one bvec, * regardless of size and offset, so no need to ask lower levels. */ +#ifndef NO_ERROR_BIO_END_IO #ifdef HAVE_bvec_merge_data int drbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bvm,
@@ -1604,7 +1605,7 @@ int drbd_merge_bvec(struct request_queue *q, struct bio_vec *bvec) {struct drbd_device *device = (struct drbd_device *) q->queuedata; -unsigned int bio_size = bvm->bi_size; +unsigned int bio_size = bvm->bi_iter.bi_size;int limit =DRBD_MAX_BIO_SIZE ;int backing_limit;
@@ -1626,6 +1627,7 @@ int drbd_merge_bvec(struct request_queue *q,return limit; }#endif +#endif /* END NO_ERROR_BIO_END_IO*/ static bool net_timeout_reached(struct drbd_request *net_req, struct drbd_connection *connection,
drbd/drbd_worker.c +114 -0
152 lines not on this page · raw message
drbd/drbd_wrappers.h +30 -1
@@ -195,16 +195,38 @@ static inline int drbd_blkdev_put(struct block_device *bdev, fmode_t mode)#define BIO_ENDIO_FN_START if (bio->bi_size) return 1#define BIO_ENDIO_FN_RETURN return 0#else +#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,3 ,0 ) +/* After Linux-4.3 a new bi_error field to store an errno value in struct bio. +See 4246a0b63bd8f56a1469b12eafeb875b1041a451 */ +#define bio_endio (B ,E ) \ + do { \ + (B)->bi_error = (E); \ + bio_endio(B); \ + } while (0) +#define BIO_ENDIO_ARGS (b) (b) +#else +#define BIO_ENDIO_ARGS (b,e) (b,e) +#endif #define BIO_ENDIO_TYPE void -#define BIO_ENDIO_ARGS (b,e) (b,e)#define BIO_ENDIO_FN_START do {} while (0)#define BIO_ENDIO_FN_RETURN return#endif /* bi_end_io handlers */ +#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,3 ,0 ) +#undef NO_ERROR_BIO_END_IO +#define NO_ERROR_BIO_END_IO 1 +#endif + +#ifdef NO_ERROR_BIO_END_IO +extern BIO_ENDIO_TYPE drbd_md_endio BIO_ENDIO_ARGS(struct bio *bio); +extern BIO_ENDIO_TYPE drbd_peer_request_endio BIO_ENDIO_ARGS(struct bio *bio); +extern BIO_ENDIO_TYPE drbd_request_endio BIO_ENDIO_ARGS(struct bio *bio); +#else extern BIO_ENDIO_TYPE drbd_md_endio BIO_ENDIO_ARGS(struct bio *bio, int error); extern BIO_ENDIO_TYPE drbd_peer_request_endio BIO_ENDIO_ARGS(struct bio *bio, int error); extern BIO_ENDIO_TYPE drbd_request_endio BIO_ENDIO_ARGS(struct bio *bio, int error); +#endif #if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,32 )#define part_inc_in_flight (A ,B ) part_inc_in_flight(A)
@@ -222,6 +244,13 @@ extern BIO_ENDIO_TYPE drbd_request_endio BIO_ENDIO_ARGS(struct bio *bio, int err# define HAVE_bvec_merge_data 1#endif +/* After 4.3.0 (with 8ae126660fddbeebb9251a174e6fa45b6ad8f932) +bvec_merge_data was killed. */ +#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,3 ,0 ) +# undef HAVE_bvec_merge_data +#endif + +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,24 )static inline void sg_set_page (struct scatterlist *sg,struct page *page,unsigned int len,unsigned int offset)
Signature · 1 line
2.1.4
Lars Ellenberg
maintainerQuoted 2 lines · Nick Wang
drbd fail to build with new bio structure and interface after 4.3.0, see
4246a0b63bd8f56a1469b12eafeb875b1041a451
Yes.
*out-of-tree* drbd, as is in public git right now, that is.
Quoted 1 line
No reason to CC linux-kernel, they won't care for out-of-tree drivers. And the in-tree ones are adjusted to new infrastructure on-the-go, whenever infrastructure changes. So that's all been done already.
But thanks.
Lars
Signature · 5 lines
: Lars Ellenberg : http://www.LINBIT.com | Your Way to High Availability : DRBD, Linux-HA and Pacemaker support and consulting DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.
Hi Lars,
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Lars Ellenberg <[email protected]> 2015-10-16 下午 19:32 >>>
Quoted 2 lines · Nick Wang
drbd fail to build with new bio structure and interface after 4.3.0, see
4246a0b63bd8f56a1469b12eafeb875b1041a451Yes.
*out-of-tree* drbd, as is in public git right now, that is.
Does the *out-of-tree* drbd also need to be updated? Since the "in-tree"
drbd only need to take care the current kernel, the one "out-of-tree" should work with different kernel version with conditions.
Quoted 5 lines
Quoted 1 line
No reason to CC linux-kernel, they won't care for out-of-tree drivers. And the in-tree ones are adjusted to new infrastructure on-the-go, whenever infrastructure changes. So that's all been done already.
Got it.
Best regards,
Nick