Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.
Hello!
Few days ago I have realized that drbd-0.7.25 have compilation
problems on linux kernels newer than 2.6.22.x. I have posted a
question but there are still no answers So I have made a patch by
back-porting changes from drbd-8.x branch. Please test.
diff -ur drbd-0.7.25/drbd/drbd_compat_wrappers.h
drbd/drbd/drbd_compat_wrappers.h
--- drbd-0.7.25/drbd/drbd_compat_wrappers.h 2007-10-10 18:41:13.000000000 +0400
+++ drbd/drbd/drbd_compat_wrappers.h 2008-02-15 19:52:48.000000000 +0300
@@ -333,7 +333,6 @@
// bi_end_io handlers
// int (bio_end_io_t) (struct bio *, unsigned int, int);
-extern int drbd_md_io_complete (struct bio *bio, unsigned int
bytes_done, int error);
extern int enslaved_read_bi_end_io (struct bio *bio, unsigned int
bytes_done, int error);
extern int drbd_dio_end_sec (struct bio *bio, unsigned int
bytes_done, int error);
extern int drbd_dio_end (struct bio *bio, unsigned int
bytes_done, int error);
@@ -369,6 +368,41 @@
}
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+/* Before Linux-2.6.24 bie_endio() had the size of the bio as second argument.
+ See 6712ecf8f648118c3363c142196418f89a510b90 */
+#define bio_endio(B,E) bio_endio(B, (B)->bi_size, E)
+#define BIO_ENDIO_FN(name) int name(struct bio *bio, unsigned int
bytes_done, int error)
+#define BIO_ENDIO_FN_START if (bio->bi_size) return 1
+#define BIO_ENDIO_FN_RETURN return 0
+#else
+#define BIO_ENDIO_FN(name) void name(struct bio *bio, int error)
+#define BIO_ENDIO_FN_START while(0) {}
+#define BIO_ENDIO_FN_RETURN return
+#endif
+
+// bi_end_io handlers
+extern BIO_ENDIO_FN(drbd_md_io_complete);
+extern BIO_ENDIO_FN(drbd_endio_read_sec);
+extern BIO_ENDIO_FN(drbd_endio_write_sec);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+/* Before 2.6.23 (with 20c2df83d25c6a95affe6157a4c9cac4cf5ffaac)
kmem_cache_create had a
+ ctor and a dtor */
+#define kmem_cache_create(N,S,A,F,C) kmem_cache_create(N,S,A,F,C,NULL)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+static inline void drbd_unregister_blkdev(unsigned int major, const char *name)
+{
+ int ret = unregister_blkdev(major,name);
+ if (ret)
+ printk(KERN_ERR "drbd: unregister of device failed\n");
+}
+#else
+#define drbd_unregister_blkdev unregister_blkdev
+#endif
+
static inline int drbd_sync_me(drbd_dev *mdev)
{
return fsync_bdev(mdev->this_bdev);
@@ -378,12 +412,12 @@
static inline void drbd_bio_IO_error(struct bio *bio)
{
- bio_endio(bio,bio->bi_size,-EIO);
+ bio_endio(bio,-EIO);
}
static inline void drbd_bio_endio(struct bio *bio, int uptodate)
{
- bio_endio(bio,bio->bi_size,uptodate ? 0 : -EIO);
+ bio_endio(bio,uptodate ? 0 : -EIO);
}
static inline drbd_dev* drbd_req_get_mdev(struct drbd_request *req)
diff -ur drbd-0.7.25/drbd/drbd_main.c drbd/drbd/drbd_main.c
--- drbd-0.7.25/drbd/drbd_main.c 2007-10-10 18:41:14.000000000 +0400
+++ drbd/drbd/drbd_main.c 2008-02-15 19:33:56.000000000 +0300
@@ -1647,13 +1647,13 @@
// caches
drbd_request_cache = kmem_cache_create(
"drbd_req_cache", sizeof(drbd_request_t),
- 0, 0, NULL, NULL);
+ 0, 0, NULL);
if (drbd_request_cache == NULL)
goto Enomem;
drbd_ee_cache = kmem_cache_create(
"drbd_ee_cache", sizeof(struct Tl_epoch_entry),
- 0, 0, NULL, NULL);
+ 0, 0, NULL);
if (drbd_ee_cache == NULL)
goto Enomem;
@@ -1799,8 +1799,7 @@
#endif
#endif
- if (unregister_blkdev(MAJOR_NR, DEVICE_NAME) != 0)
- printk(KERN_ERR DEVICE_NAME": unregister of device failed\n");
+ drbd_unregister_blkdev(MAJOR_NR, DEVICE_NAME);
printk(KERN_INFO DEVICE_NAME": module cleanup done.\n");
}
diff -ur drbd-0.7.25/drbd/drbd_req.c drbd/drbd/drbd_req.c
--- drbd-0.7.25/drbd/drbd_req.c 2007-10-10 18:41:14.000000000 +0400
+++ drbd/drbd/drbd_req.c 2008-02-15 19:29:23.000000000 +0300
@@ -172,7 +172,7 @@
ONLY_IN_26(
/* Currently our BARRIER code is disabled. */
if(unlikely(bio_barrier(bio))) {
- bio_endio(bio, bio->bi_size, -EOPNOTSUPP);
+ bio_endio(bio, -EOPNOTSUPP);
return 0;
}
)
diff -ur drbd-0.7.25/drbd/drbd_worker.c drbd/drbd/drbd_worker.c
--- drbd-0.7.25/drbd/drbd_worker.c 2007-10-10 18:41:14.000000000 +0400
+++ drbd/drbd/drbd_worker.c 2008-02-15 19:45:08.000000000 +0300
@@ -195,7 +195,7 @@
/* used for synchronous meta data and bitmap IO
* submitted by drbd_md_sync_page_io()
*/
-int drbd_md_io_complete(struct bio *bio, unsigned int bytes_done, int error)
+BIO_ENDIO_FN(drbd_md_io_complete)
{
if (bio->bi_size)
return 1;
@@ -323,7 +323,7 @@
drbd_queue_work(mdev,&mdev->data.work,&req->w);
} else {
pass_on:
- bio_endio(req->master_bio,req->master_bio->bi_size,error);
+ bio_endio(req->master_bio,error);
dec_ap_bio(mdev);
INVALIDATE_MAGIC(req);
diff -ur drbd-0.7.25/drbd/Makefile drbd/drbd/Makefile
--- drbd-0.7.25/drbd/Makefile 2007-10-10 19:31:18.000000000 +0400
+++ drbd/drbd/Makefile 2008-02-08 19:07:54.000000000 +0300
@@ -41,7 +41,7 @@
$(error "won't compile with this kernel version")
endif
- override CFLAGS += -I$(DRBDSRC)
+ EXTRA_CFLAGS = -I$(DRBDSRC)
# remember KERNELRELEASE for install target
# .kernelversion can be included in Makefile as well as
# sourced from shell