Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.
Hello! Accidentally we need to use software developed to old linux distribution. We cannot upgrade entire distribution but can upgrade kernel. But because of some kernel API changes, drbd-0.7.x can't be compiled again. So, if someone still interested, here is the patch since last git: -------------------------------------------- diff -ur drbd-0.7.25/drbd/drbd_actlog.c drbd/drbd/drbd_actlog.c --- drbd-0.7.25/drbd/drbd_actlog.c 2007-10-10 18:41:13.000000000 +0400 +++ drbd/drbd/drbd_actlog.c 2008-12-18 05:42:52.000000000 +0300 @@ -115,9 +115,9 @@ struct page *page = alloc_page(GFP_NOIO); if(!page) return 0; - WARN("Meta data's bdev hardsect_size != %d\n", + drbd_WARN("Meta data's bdev hardsect_size != %d\n", MD_HARDSECT); - WARN("Workaround engaged (has performace impact).\n"); + drbd_WARN("Workaround engaged (has performace impact).\n"); mdev->md_io_tmpp = page; } @@ -225,9 +225,9 @@ /* if (!al_ext) { if (al_flags & LC_STARVING) - WARN("Have to wait for LRU element (AL too small?)\n"); + drbd_WARN("Have to wait for LRU element (AL too small?)\n"); if (al_flags & LC_DIRTY) - WARN("Ongoing AL update (AL device too slow?)\n"); + drbd_WARN("Ongoing AL update (AL device too slow?)\n"); } */ @@ -449,7 +449,7 @@ } if(from == -1 || to == -1) { - WARN("No usable activity log found.\n"); + drbd_WARN("No usable activity log found.\n"); up(&mdev->md_io_mutex); return 1; @@ -614,7 +614,7 @@ if( !inc_local_md_only(mdev) ) { if (DRBD_ratelimit(5*HZ,5)) - WARN("Can not update on disk bitmap, local IO disabled.\n"); + drbd_WARN("Can not update on disk bitmap, local IO disabled.\n"); return 1; } @@ -670,12 +670,12 @@ return; } } else { - //WARN("Recounting sectors in %d (resync LRU too small?)\n", enr); + //drbd_WARN("Recounting sectors in %d (resync LRU too small?)\n", enr); // This element should be in the cache // since drbd_rs_begin_io() pulled it already in. int rs_left = drbd_bm_e_weight(mdev,enr); if (ext->flags != 0) { - WARN("changing resync lce: %d[%u;%02lx]" + drbd_WARN("changing resync lce: %d[%u;%02lx]" " -> %d[%u;00]\n", ext->lce.lc_number, ext->rs_left, ext->flags, enr, rs_left); @@ -698,14 +698,14 @@ if(ext->rs_left == 0) { udw=kmalloc(sizeof(*udw),GFP_ATOMIC); if(!udw) { - WARN("Could not kmalloc an udw\n"); + drbd_WARN("Could not kmalloc an udw\n"); break; } udw->enr = ext->lce.lc_number; udw->w.cb = w_update_odbm; drbd_queue_work_front(mdev,&mdev->data.work,&udw->w); if (ext->flags != 0) { - WARN("deleting resync lce: %d[%u;%02lx]\n", + drbd_WARN("deleting resync lce: %d[%u;%02lx]\n", ext->lce.lc_number, ext->rs_left, ext->flags); ext->flags = 0; @@ -851,7 +851,7 @@ unsigned long rs_flags; if(atomic_read(&mdev->resync_locked) > mdev->resync->nr_elements-3 ) { - //WARN("bme_get() does not lock all elements\n"); + //drbd_WARN("bme_get() does not lock all elements\n"); return 0; } @@ -872,11 +872,11 @@ if(!bm_ext) { if (rs_flags & LC_STARVING) { - WARN("Have to wait for element" + drbd_WARN("Have to wait for element" " (resync LRU too small?)\n"); } if (rs_flags & LC_DIRTY) { - BUG(); // WARN("Ongoing RS update (???)\n"); + BUG(); // drbd_WARN("Ongoing RS update (???)\n"); } } 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 2008-12-18 08:12:44.000000000 +0300 +++ drbd/drbd/drbd_compat_wrappers.h 2008-12-18 07:59:10.000000000 +0300 @@ -331,13 +331,6 @@ /* see get_sb_bdev and bd_claim */ extern char* drbd_sec_holder; -// bi_end_io handlers -// int (bio_end_io_t) (struct bio *, unsigned int, int); -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); -extern int drbd_read_bi_end_io (struct bio *bio, unsigned int bytes_done, int error); - static inline sector_t drbd_get_hardsect(struct block_device *bdev) { return bdev->bd_disk->queue->hardsect_size; @@ -383,6 +376,10 @@ // bi_end_io handlers extern BIO_ENDIO_FN(drbd_md_io_complete); +extern BIO_ENDIO_FN(enslaved_read_bi_end_io); +extern BIO_ENDIO_FN(drbd_dio_end_sec); +extern BIO_ENDIO_FN(drbd_dio_end); +extern BIO_ENDIO_FN(drbd_read_bi_end_io); extern BIO_ENDIO_FN(drbd_endio_read_sec); extern BIO_ENDIO_FN(drbd_endio_write_sec); diff -ur drbd-0.7.25/drbd/drbd_fs.c drbd/drbd/drbd_fs.c --- drbd-0.7.25/drbd/drbd_fs.c 2007-10-10 18:41:13.000000000 +0400 +++ drbd/drbd/drbd_fs.c 2008-12-18 05:43:58.000000000 +0300 @@ -136,7 +136,7 @@ md_moved = pmdss != drbd_md_ss(mdev) /* && mdev->md_index == -1 */; if ( md_moved ) { - WARN("Moving meta-data.\n"); + drbd_WARN("Moving meta-data.\n"); D_ASSERT(mdev->md_index == -1); } @@ -378,7 +378,7 @@ } if (drbd_is_mounted(inode->i_rdev)) { - WARN("can not configure %d:%d, has active inodes!\n", + drbd_WARN("can not configure %d:%d, has active inodes!\n", MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); retcode=LDMounted; goto fail_ioctl; @@ -881,7 +881,7 @@ // drbd_dump_md(mdev,0,0); for (i=HumanCnt; i < GEN_CNT_SIZE ; i++) { if (mdev->gen_cnt[i] != 1) { - WARN("Forcefully set consistent! " + drbd_WARN("Forcefully set consistent! " "If this screws your data, don't blame DRBD!\n"); break; } @@ -956,7 +956,7 @@ if ( test_bit(USE_DEGR_WFC_T,&mdev->flags) ) { time=p.degr_wfc_timeout; - if (time) WARN("using degr_wfc_timeout=%ld seconds\n", time); + if (time) drbd_WARN("using degr_wfc_timeout=%ld seconds\n", time); } else { time=p.wfc_timeout; } @@ -1230,7 +1230,7 @@ // if we have a connection. // this does not avoid the race completely, though. if (mdev->cstate > WFConnection) { - WARN("race avoidance: did not set " + drbd_WARN("race avoidance: did not set " "the state flags (%s), cstate=%s\n", arg == (Human|TimeoutExpired) ? "Human|TimeoutExpired" diff -ur drbd-0.7.25/drbd/drbd_int.h drbd/drbd/drbd_int.h --- drbd-0.7.25/drbd/drbd_int.h 2007-10-10 18:41:13.000000000 +0400 +++ drbd/drbd/drbd_int.h 2008-12-18 05:44:27.000000000 +0300 @@ -181,7 +181,8 @@ #define ALERT(fmt,args...) PRINTK(KERN_ALERT, fmt , ##args) #define ERR(fmt,args...) PRINTK(KERN_ERR, fmt , ##args) -#define WARN(fmt,args...) PRINTK(KERN_WARNING, fmt , ##args) +/* nowadays, WARN() is defined as BUG() without crash in bug.h */ +#define drbd_WARN(fmt,args...) PRINTK(KERN_WARNING, fmt , ##args) #define INFO(fmt,args...) PRINTK(KERN_INFO, fmt , ##args) #define DBG(fmt,args...) PRINTK(KERN_DEBUG, fmt , ##args) @@ -206,7 +207,7 @@ missed = 0; \ toks -= ratelimit_jiffies; \ if (lost) \ - WARN("%d messages suppressed in %s:%d.\n",\ + drbd_WARN("%d messages suppressed in %s:%d.\n",\ lost , __FILE__ , __LINE__ ); \ __ret=1; \ } else { \ @@ -724,6 +725,10 @@ Drbd_Polymorph_Packet rbuf; // send/receive buffers off the stack }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) + typedef struct request_queue request_queue_t; +#endif + struct Drbd_Conf { #ifdef PARANOIA long magic; diff -ur drbd-0.7.25/drbd/drbd_main.c drbd/drbd/drbd_main.c --- drbd-0.7.25/drbd/drbd_main.c 2008-12-18 08:12:44.000000000 +0300 +++ drbd/drbd/drbd_main.c 2008-12-18 07:36:58.000000000 +0300 @@ -400,7 +400,7 @@ D_ASSERT(test_bit(DISKLESS,&mdev->flags)); ok = drbd_send_param(mdev,0); - WARN("Notified peer that my disk is broken.\n"); + drbd_WARN("Notified peer that my disk is broken.\n"); D_ASSERT(drbd_md_test_flag(mdev,MDF_FullSync)); D_ASSERT(!drbd_md_test_flag(mdev,MDF_Consistent)); @@ -410,13 +410,13 @@ } if(mdev->cstate > Connected ) { - WARN("Resync aborted.\n"); + drbd_WARN("Resync aborted.\n"); set_cstate(mdev,Connected); mdev->rs_total = 0; } if ( wait_event_interruptible_timeout(mdev->cstate_wait, atomic_read(&mdev->local_cnt) == 0 , HZ ) <= 0) { - WARN("Not releasing backing storage device.\n"); + drbd_WARN("Not releasing backing storage device.\n"); /* FIXME if there *are* still references, * we should be here again soon enough. * but what if not? @@ -425,7 +425,7 @@ /* no race. since the DISKLESS bit is set first, * further references to local_cnt are shortlived, * and no real references on the device. */ - WARN("Releasing backing storage device.\n"); + drbd_WARN("Releasing backing storage device.\n"); drbd_free_ll_dev(mdev); mdev->la_size=0; } @@ -502,7 +502,7 @@ } if( ns <= StandAlone && test_bit(IO_FROZEN, &mdev->flags)) { - WARN("Going to thaw IO, setting out of sync %d requests.\n", + drbd_WARN("Going to thaw IO, setting out of sync %d requests.\n", atomic_read(&mdev->ap_pending_cnt)); tl_clear(mdev); clear_bit(IO_FROZEN, &mdev->flags); @@ -1048,7 +1048,7 @@ continue; } if (sent <= 0) { - WARN("%s: size=%d len=%d sent=%d\n", + drbd_WARN("%s: size=%d len=%d sent=%d\n", __func__,(int)size,len,sent); break; } @@ -1670,7 +1670,7 @@ return -ENOMEM; } -static void __exit drbd_cleanup(void) +static void drbd_cleanup(void) { int i, rr; @@ -1690,7 +1690,11 @@ } if (drbd_proc) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) remove_proc_entry("drbd",&proc_root); +#else + remove_proc_entry("drbd",NULL); +#endif i=minor_count; while (i--) { drbd_dev *mdev = drbd_conf+i; @@ -1707,7 +1711,11 @@ put_disk(*disk); *disk = NULL; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) if (*q) blk_put_queue(*q); +#else + if (*q) blk_cleanup_queue(*q); +#endif *q = NULL; if (mdev->this_bdev->bd_holder == drbd_sec_holder) { @@ -1929,7 +1937,7 @@ mdev->this_bdev->bd_contains = mdev->this_bdev; if (bd_claim(mdev->this_bdev,drbd_sec_holder)) { // Initial we are Secondary -> should claim myself. - WARN("Could not bd_claim() myself."); + drbd_WARN("Could not bd_claim() myself."); } else if (disable_bd_claim) { bd_release(mdev->this_bdev); } @@ -1976,7 +1984,11 @@ /* * register with procfs */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) drbd_proc = create_proc_entry("drbd", S_IFREG | S_IRUGO , &proc_root); +#else + drbd_proc = create_proc_entry("drbd", S_IFREG | S_IRUGO , NULL); +#endif if (!drbd_proc) { printk(KERN_ERR DEVICE_NAME": unable to register proc file\n"); diff -ur drbd-0.7.25/drbd/drbd_receiver.c drbd/drbd/drbd_receiver.c --- drbd-0.7.25/drbd/drbd_receiver.c 2007-10-10 18:41:14.000000000 +0400 +++ drbd/drbd/drbd_receiver.c 2008-12-18 05:45:11.000000000 +0300 @@ -336,7 +336,7 @@ spin_lock_irq(&mdev->ee_lock); if (signal_pending(current)) { - WARN("drbd_get_ee interrupted!\n"); + drbd_WARN("drbd_get_ee interrupted!\n"); return NULL; } @@ -895,7 +895,7 @@ spin_lock_irq(&mdev->ee_lock); drbd_put_ee(mdev,e); spin_unlock_irq(&mdev->ee_lock); - WARN("short read receiving data block: read %d expected %d\n", + drbd_WARN("short read receiving data block: read %d expected %d\n", rr, data_size); return 0; } @@ -1382,7 +1382,7 @@ drbd_bm_clear_all(mdev); drbd_bm_write(mdev); } else { - WARN("I am inconsistent, but there is no sync? BOTH nodes inconsistent!\n"); + drbd_WARN("I am inconsistent, but there is no sync? BOTH nodes inconsistent!\n"); } } drbd_bm_unlock(mdev); // } @@ -1556,7 +1556,7 @@ * we have the MDF_FullSync bit on disk. * on the next _drbd_send_bitmap this will be done. */ - WARN("PARTNER DISKLESS\n"); + drbd_WARN("PARTNER DISKLESS\n"); mdev->rs_total = 0; } if(mdev->cstate >= Connected ) { @@ -1567,12 +1567,12 @@ } } if(mdev->cstate > Connected ) { - WARN("Resync aborted.\n"); + drbd_WARN("Resync aborted.\n"); set_cstate(mdev,Connected); } } else { if (test_and_clear_bit(PARTNER_DISKLESS, &mdev->flags)) { - WARN("Partner no longer diskless\n"); + drbd_WARN("Partner no longer diskless\n"); D_ASSERT(consider_sync); } } @@ -1587,7 +1587,7 @@ INFO("Connection established.\n"); if(test_bit(IO_FROZEN, &mdev->flags)) { - WARN("Going to thaw IO, resending %d requests.\n", + drbd_WARN("Going to thaw IO, resending %d requests.\n", atomic_read(&mdev->ap_pending_cnt)); tl_resend(mdev); set_bit(ISSUE_BARRIER,&mdev->flags); @@ -1737,7 +1737,7 @@ static char sink[128]; int size,want,r; - WARN("skipping unknown optional packet type %d, l: %d!\n", + drbd_WARN("skipping unknown optional packet type %d, l: %d!\n", h->command, h->length ); size = h->length; @@ -1889,7 +1889,7 @@ drbd_clear_done_ee(mdev); if(test_bit(IO_FROZEN, &mdev->flags)) { - WARN("IO frozen with ap_pending_cnt = %d\n", + drbd_WARN("IO frozen with ap_pending_cnt = %d\n", atomic_read(&mdev->ap_pending_cnt)); } else { tl_clear(mdev); @@ -2047,7 +2047,7 @@ if ( p->protocol_version == PRO_VERSION || p->protocol_version == (PRO_VERSION+1) ) { if (p->protocol_version == (PRO_VERSION+1)) { - WARN( "You should upgrade me! " + drbd_WARN( "You should upgrade me! " "Peer wants protocol version: %u\n", p->protocol_version ); } @@ -2068,7 +2068,7 @@ return 1; break_c_loop: - WARN( "Network error during initial handshake. I'll try again.\n"); + drbd_WARN( "Network error during initial handshake. I'll try again.\n"); /* In case a tcp connection set-up takes longer than connect-int, we might get into the situation that this node's msock gets connected to the peer's sock! @@ -2108,7 +2108,7 @@ continue; } - WARN("Discarding network configuration.\n"); + drbd_WARN("Discarding network configuration.\n"); set_cstate(mdev,StandAlone); break; } @@ -2223,7 +2223,7 @@ } #endif if (DRBD_ratelimit(5*HZ,5)) - WARN("Got NegAck packet. Peer is in troubles?\n"); + drbd_WARN("Got NegAck packet. Peer is in troubles?\n"); return TRUE; } diff -ur drbd-0.7.25/drbd/drbd_req.c drbd/drbd/drbd_req.c --- drbd-0.7.25/drbd/drbd_req.c 2008-12-18 08:12:44.000000000 +0300 +++ drbd/drbd/drbd_req.c 2008-12-18 05:43:04.000000000 +0300 @@ -464,6 +464,6 @@ bio = bio->REQ_NEXT; reqs++; } - WARN("Continued %d requests (which where issued after IO-freeze).\n", + drbd_WARN("Continued %d requests (which where issued after IO-freeze).\n", reqs); } diff -ur drbd-0.7.25/drbd/drbd_worker.c drbd/drbd/drbd_worker.c --- drbd-0.7.25/drbd/drbd_worker.c 2008-12-18 08:12:44.000000000 +0300 +++ drbd/drbd/drbd_worker.c 2008-12-18 08:07:46.000000000 +0300 @@ -197,17 +197,16 @@ */ BIO_ENDIO_FN(drbd_md_io_complete) { - if (bio->bi_size) - return 1; + BIO_ENDIO_FN_START; complete((struct completion*)bio->bi_private); - return 0; + BIO_ENDIO_FN_RETURN; } /* reads on behalf of the partner, * "submitted" by the receiver */ -int enslaved_read_bi_end_io(struct bio *bio, unsigned int bytes_done, int error) +BIO_ENDIO_FN(enslaved_read_bi_end_io) { unsigned long flags=0; struct Tl_epoch_entry *e=NULL; @@ -219,8 +218,8 @@ /* we should be called via bio_endio, so this should never be the case * but "everyone else does it", and so do we ;) -lge */ - ERR_IF (bio->bi_size) - return 1; + ERR_IF (bio->bi_size); + BIO_ENDIO_FN_START; e = container_of(bio,struct Tl_epoch_entry,private_bio); PARANOIA_BUG_ON(!VALID_POINTER(e)); @@ -234,13 +233,13 @@ drbd_chk_io_error(mdev,error); drbd_queue_work(mdev,&mdev->data.work,&e->w); dec_local(mdev); - return 0; + BIO_ENDIO_FN_RETURN; } /* writes on behalf of the partner, or resync writes, * "submitted" by the receiver. */ -int drbd_dio_end_sec(struct bio *bio, unsigned int bytes_done, int error) +BIO_ENDIO_FN(drbd_dio_end_sec) { unsigned long flags=0; struct Tl_epoch_entry *e=NULL; @@ -250,8 +249,8 @@ PARANOIA_BUG_ON(!IS_VALID_MDEV(mdev)); // see above - ERR_IF (bio->bi_size) - return 1; + ERR_IF (bio->bi_size); + BIO_ENDIO_FN_START; e = container_of(bio,struct Tl_epoch_entry,private_bio); PARANOIA_BUG_ON(!VALID_POINTER(e)); @@ -271,20 +270,20 @@ drbd_chk_io_error(mdev,error); wake_asender(mdev); dec_local(mdev); - return 0; + BIO_ENDIO_FN_RETURN; } /* writes on Primary comming from drbd_make_request */ -int drbd_dio_end(struct bio *bio, unsigned int bytes_done, int error) +BIO_ENDIO_FN(drbd_dio_end) { drbd_request_t *req=bio->bi_private; struct Drbd_Conf* mdev=req->mdev; sector_t rsector; // see above - ERR_IF (bio->bi_size) - return 1; + ERR_IF (bio->bi_size); + BIO_ENDIO_FN_START; if(error) DUMPI(error); @@ -295,19 +294,19 @@ drbd_al_complete_io(mdev,rsector); dec_local(mdev); bio_put(bio); - return 0; + BIO_ENDIO_FN_RETURN; } /* reads on Primary comming from drbd_make_request */ -int drbd_read_bi_end_io(struct bio *bio, unsigned int bytes_done, int error) +BIO_ENDIO_FN(drbd_read_bi_end_io) { drbd_request_t *req=bio->bi_private; struct Drbd_Conf* mdev=req->mdev; // see above - ERR_IF (bio->bi_size) - return 1; + ERR_IF (bio->bi_size); + BIO_ENDIO_FN_START; /* READAs may fail. * upper layers need to be able to handle that themselves */ @@ -332,7 +331,7 @@ bio_put(bio); dec_local(mdev); - return 0; + BIO_ENDIO_FN_RETURN; } #endif @@ -981,7 +980,7 @@ spin_unlock_irq(&mdev->req_lock); if(!w->cb(mdev,w, mdev->cstate < Connected )) { - //WARN("worker: a callback failed! \n"); + //drbd_WARN("worker: a callback failed! \n"); if (mdev->cstate >= Connected) set_cstate(mdev,NetworkFailure); drbd_thread_restart_nowait(&mdev->receiver); -------------------------------------------- and here is complete patch since 0.7.25: -------------------------------------------- diff -ur drbd-0.7.25/drbd/drbd_actlog.c drbd/drbd/drbd_actlog.c --- drbd-0.7.25/drbd/drbd_actlog.c 2007-10-10 18:41:13.000000000 +0400 +++ drbd/drbd/drbd_actlog.c 2008-12-18 05:42:52.000000000 +0300 @@ -115,9 +115,9 @@ struct page *page = alloc_page(GFP_NOIO); if(!page) return 0; - WARN("Meta data's bdev hardsect_size != %d\n", + drbd_WARN("Meta data's bdev hardsect_size != %d\n", MD_HARDSECT); - WARN("Workaround engaged (has performace impact).\n"); + drbd_WARN("Workaround engaged (has performace impact).\n"); mdev->md_io_tmpp = page; } @@ -225,9 +225,9 @@ /* if (!al_ext) { if (al_flags & LC_STARVING) - WARN("Have to wait for LRU element (AL too small?)\n"); + drbd_WARN("Have to wait for LRU element (AL too small?)\n"); if (al_flags & LC_DIRTY) - WARN("Ongoing AL update (AL device too slow?)\n"); + drbd_WARN("Ongoing AL update (AL device too slow?)\n"); } */ @@ -449,7 +449,7 @@ } if(from == -1 || to == -1) { - WARN("No usable activity log found.\n"); + drbd_WARN("No usable activity log found.\n"); up(&mdev->md_io_mutex); return 1; @@ -614,7 +614,7 @@ if( !inc_local_md_only(mdev) ) { if (DRBD_ratelimit(5*HZ,5)) - WARN("Can not update on disk bitmap, local IO disabled.\n"); + drbd_WARN("Can not update on disk bitmap, local IO disabled.\n"); return 1; } @@ -670,12 +670,12 @@ return; } } else { - //WARN("Recounting sectors in %d (resync LRU too small?)\n", enr); + //drbd_WARN("Recounting sectors in %d (resync LRU too small?)\n", enr); // This element should be in the cache // since drbd_rs_begin_io() pulled it already in. int rs_left = drbd_bm_e_weight(mdev,enr); if (ext->flags != 0) { - WARN("changing resync lce: %d[%u;%02lx]" + drbd_WARN("changing resync lce: %d[%u;%02lx]" " -> %d[%u;00]\n", ext->lce.lc_number, ext->rs_left, ext->flags, enr, rs_left); @@ -698,14 +698,14 @@ if(ext->rs_left == 0) { udw=kmalloc(sizeof(*udw),GFP_ATOMIC); if(!udw) { - WARN("Could not kmalloc an udw\n"); + drbd_WARN("Could not kmalloc an udw\n"); break; } udw->enr = ext->lce.lc_number; udw->w.cb = w_update_odbm; drbd_queue_work_front(mdev,&mdev->data.work,&udw->w); if (ext->flags != 0) { - WARN("deleting resync lce: %d[%u;%02lx]\n", + drbd_WARN("deleting resync lce: %d[%u;%02lx]\n", ext->lce.lc_number, ext->rs_left, ext->flags); ext->flags = 0; @@ -851,7 +851,7 @@ unsigned long rs_flags; if(atomic_read(&mdev->resync_locked) > mdev->resync->nr_elements-3 ) { - //WARN("bme_get() does not lock all elements\n"); + //drbd_WARN("bme_get() does not lock all elements\n"); return 0; } @@ -872,11 +872,11 @@ if(!bm_ext) { if (rs_flags & LC_STARVING) { - WARN("Have to wait for element" + drbd_WARN("Have to wait for element" " (resync LRU too small?)\n"); } if (rs_flags & LC_DIRTY) { - BUG(); // WARN("Ongoing RS update (???)\n"); + BUG(); // drbd_WARN("Ongoing RS update (???)\n"); } } 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-12-18 07:59:10.000000000 +0300 @@ -331,14 +331,6 @@ /* see get_sb_bdev and bd_claim */ extern char* drbd_sec_holder; -// 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); -extern int drbd_read_bi_end_io (struct bio *bio, unsigned int bytes_done, int error); - static inline sector_t drbd_get_hardsect(struct block_device *bdev) { return bdev->bd_disk->queue->hardsect_size; @@ -369,6 +361,45 @@ } } +#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(enslaved_read_bi_end_io); +extern BIO_ENDIO_FN(drbd_dio_end_sec); +extern BIO_ENDIO_FN(drbd_dio_end); +extern BIO_ENDIO_FN(drbd_read_bi_end_io); +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 +409,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_fs.c drbd/drbd/drbd_fs.c --- drbd-0.7.25/drbd/drbd_fs.c 2007-10-10 18:41:13.000000000 +0400 +++ drbd/drbd/drbd_fs.c 2008-12-18 05:43:58.000000000 +0300 @@ -136,7 +136,7 @@ md_moved = pmdss != drbd_md_ss(mdev) /* && mdev->md_index == -1 */; if ( md_moved ) { - WARN("Moving meta-data.\n"); + drbd_WARN("Moving meta-data.\n"); D_ASSERT(mdev->md_index == -1); } @@ -378,7 +378,7 @@ } if (drbd_is_mounted(inode->i_rdev)) { - WARN("can not configure %d:%d, has active inodes!\n", + drbd_WARN("can not configure %d:%d, has active inodes!\n", MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); retcode=LDMounted; goto fail_ioctl; @@ -881,7 +881,7 @@ // drbd_dump_md(mdev,0,0); for (i=HumanCnt; i < GEN_CNT_SIZE ; i++) { if (mdev->gen_cnt[i] != 1) { - WARN("Forcefully set consistent! " + drbd_WARN("Forcefully set consistent! " "If this screws your data, don't blame DRBD!\n"); break; } @@ -956,7 +956,7 @@ if ( test_bit(USE_DEGR_WFC_T,&mdev->flags) ) { time=p.degr_wfc_timeout; - if (time) WARN("using degr_wfc_timeout=%ld seconds\n", time); + if (time) drbd_WARN("using degr_wfc_timeout=%ld seconds\n", time); } else { time=p.wfc_timeout; } @@ -1230,7 +1230,7 @@ // if we have a connection. // this does not avoid the race completely, though. if (mdev->cstate > WFConnection) { - WARN("race avoidance: did not set " + drbd_WARN("race avoidance: did not set " "the state flags (%s), cstate=%s\n", arg == (Human|TimeoutExpired) ? "Human|TimeoutExpired" diff -ur drbd-0.7.25/drbd/drbd_int.h drbd/drbd/drbd_int.h --- drbd-0.7.25/drbd/drbd_int.h 2007-10-10 18:41:13.000000000 +0400 +++ drbd/drbd/drbd_int.h 2008-12-18 05:44:27.000000000 +0300 @@ -181,7 +181,8 @@ #define ALERT(fmt,args...) PRINTK(KERN_ALERT, fmt , ##args) #define ERR(fmt,args...) PRINTK(KERN_ERR, fmt , ##args) -#define WARN(fmt,args...) PRINTK(KERN_WARNING, fmt , ##args) +/* nowadays, WARN() is defined as BUG() without crash in bug.h */ +#define drbd_WARN(fmt,args...) PRINTK(KERN_WARNING, fmt , ##args) #define INFO(fmt,args...) PRINTK(KERN_INFO, fmt , ##args) #define DBG(fmt,args...) PRINTK(KERN_DEBUG, fmt , ##args) @@ -206,7 +207,7 @@ missed = 0; \ toks -= ratelimit_jiffies; \ if (lost) \ - WARN("%d messages suppressed in %s:%d.\n",\ + drbd_WARN("%d messages suppressed in %s:%d.\n",\ lost , __FILE__ , __LINE__ ); \ __ret=1; \ } else { \ @@ -724,6 +725,10 @@ Drbd_Polymorph_Packet rbuf; // send/receive buffers off the stack }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) + typedef struct request_queue request_queue_t; +#endif + struct Drbd_Conf { #ifdef PARANOIA long magic; ╨в╨╛╨╗╤М╨║╨╛ ╨▓ drbd/drbd: .drbd_kernelrelease 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-12-18 07:36:58.000000000 +0300 @@ -400,7 +400,7 @@ D_ASSERT(test_bit(DISKLESS,&mdev->flags)); ok = drbd_send_param(mdev,0); - WARN("Notified peer that my disk is broken.\n"); + drbd_WARN("Notified peer that my disk is broken.\n"); D_ASSERT(drbd_md_test_flag(mdev,MDF_FullSync)); D_ASSERT(!drbd_md_test_flag(mdev,MDF_Consistent)); @@ -410,13 +410,13 @@ } if(mdev->cstate > Connected ) { - WARN("Resync aborted.\n"); + drbd_WARN("Resync aborted.\n"); set_cstate(mdev,Connected); mdev->rs_total = 0; } if ( wait_event_interruptible_timeout(mdev->cstate_wait, atomic_read(&mdev->local_cnt) == 0 , HZ ) <= 0) { - WARN("Not releasing backing storage device.\n"); + drbd_WARN("Not releasing backing storage device.\n"); /* FIXME if there *are* still references, * we should be here again soon enough. * but what if not? @@ -425,7 +425,7 @@ /* no race. since the DISKLESS bit is set first, * further references to local_cnt are shortlived, * and no real references on the device. */ - WARN("Releasing backing storage device.\n"); + drbd_WARN("Releasing backing storage device.\n"); drbd_free_ll_dev(mdev); mdev->la_size=0; } @@ -502,7 +502,7 @@ } if( ns <= StandAlone && test_bit(IO_FROZEN, &mdev->flags)) { - WARN("Going to thaw IO, setting out of sync %d requests.\n", + drbd_WARN("Going to thaw IO, setting out of sync %d requests.\n", atomic_read(&mdev->ap_pending_cnt)); tl_clear(mdev); clear_bit(IO_FROZEN, &mdev->flags); @@ -1048,7 +1048,7 @@ continue; } if (sent <= 0) { - WARN("%s: size=%d len=%d sent=%d\n", + drbd_WARN("%s: size=%d len=%d sent=%d\n", __func__,(int)size,len,sent); break; } @@ -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; @@ -1670,7 +1670,7 @@ return -ENOMEM; } -static void __exit drbd_cleanup(void) +static void drbd_cleanup(void) { int i, rr; @@ -1690,7 +1690,11 @@ } if (drbd_proc) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) remove_proc_entry("drbd",&proc_root); +#else + remove_proc_entry("drbd",NULL); +#endif i=minor_count; while (i--) { drbd_dev *mdev = drbd_conf+i; @@ -1707,7 +1711,11 @@ put_disk(*disk); *disk = NULL; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) if (*q) blk_put_queue(*q); +#else + if (*q) blk_cleanup_queue(*q); +#endif *q = NULL; if (mdev->this_bdev->bd_holder == drbd_sec_holder) { @@ -1799,8 +1807,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"); } @@ -1930,7 +1937,7 @@ mdev->this_bdev->bd_contains = mdev->this_bdev; if (bd_claim(mdev->this_bdev,drbd_sec_holder)) { // Initial we are Secondary -> should claim myself. - WARN("Could not bd_claim() myself."); + drbd_WARN("Could not bd_claim() myself."); } else if (disable_bd_claim) { bd_release(mdev->this_bdev); } @@ -1977,7 +1984,11 @@ /* * register with procfs */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) drbd_proc = create_proc_entry("drbd", S_IFREG | S_IRUGO , &proc_root); +#else + drbd_proc = create_proc_entry("drbd", S_IFREG | S_IRUGO , NULL); +#endif if (!drbd_proc) { printk(KERN_ERR DEVICE_NAME": unable to register proc file\n"); diff -ur drbd-0.7.25/drbd/drbd_receiver.c drbd/drbd/drbd_receiver.c --- drbd-0.7.25/drbd/drbd_receiver.c 2007-10-10 18:41:14.000000000 +0400 +++ drbd/drbd/drbd_receiver.c 2008-12-18 05:45:11.000000000 +0300 @@ -336,7 +336,7 @@ spin_lock_irq(&mdev->ee_lock); if (signal_pending(current)) { - WARN("drbd_get_ee interrupted!\n"); + drbd_WARN("drbd_get_ee interrupted!\n"); return NULL; } @@ -895,7 +895,7 @@ spin_lock_irq(&mdev->ee_lock); drbd_put_ee(mdev,e); spin_unlock_irq(&mdev->ee_lock); - WARN("short read receiving data block: read %d expected %d\n", + drbd_WARN("short read receiving data block: read %d expected %d\n", rr, data_size); return 0; } @@ -1382,7 +1382,7 @@ drbd_bm_clear_all(mdev); drbd_bm_write(mdev); } else { - WARN("I am inconsistent, but there is no sync? BOTH nodes inconsistent!\n"); + drbd_WARN("I am inconsistent, but there is no sync? BOTH nodes inconsistent!\n"); } } drbd_bm_unlock(mdev); // } @@ -1556,7 +1556,7 @@ * we have the MDF_FullSync bit on disk. * on the next _drbd_send_bitmap this will be done. */ - WARN("PARTNER DISKLESS\n"); + drbd_WARN("PARTNER DISKLESS\n"); mdev->rs_total = 0; } if(mdev->cstate >= Connected ) { @@ -1567,12 +1567,12 @@ } } if(mdev->cstate > Connected ) { - WARN("Resync aborted.\n"); + drbd_WARN("Resync aborted.\n"); set_cstate(mdev,Connected); } } else { if (test_and_clear_bit(PARTNER_DISKLESS, &mdev->flags)) { - WARN("Partner no longer diskless\n"); + drbd_WARN("Partner no longer diskless\n"); D_ASSERT(consider_sync); } } @@ -1587,7 +1587,7 @@ INFO("Connection established.\n"); if(test_bit(IO_FROZEN, &mdev->flags)) { - WARN("Going to thaw IO, resending %d requests.\n", + drbd_WARN("Going to thaw IO, resending %d requests.\n", atomic_read(&mdev->ap_pending_cnt)); tl_resend(mdev); set_bit(ISSUE_BARRIER,&mdev->flags); @@ -1737,7 +1737,7 @@ static char sink[128]; int size,want,r; - WARN("skipping unknown optional packet type %d, l: %d!\n", + drbd_WARN("skipping unknown optional packet type %d, l: %d!\n", h->command, h->length ); size = h->length; @@ -1889,7 +1889,7 @@ drbd_clear_done_ee(mdev); if(test_bit(IO_FROZEN, &mdev->flags)) { - WARN("IO frozen with ap_pending_cnt = %d\n", + drbd_WARN("IO frozen with ap_pending_cnt = %d\n", atomic_read(&mdev->ap_pending_cnt)); } else { tl_clear(mdev); @@ -2047,7 +2047,7 @@ if ( p->protocol_version == PRO_VERSION || p->protocol_version == (PRO_VERSION+1) ) { if (p->protocol_version == (PRO_VERSION+1)) { - WARN( "You should upgrade me! " + drbd_WARN( "You should upgrade me! " "Peer wants protocol version: %u\n", p->protocol_version ); } @@ -2068,7 +2068,7 @@ return 1; break_c_loop: - WARN( "Network error during initial handshake. I'll try again.\n"); + drbd_WARN( "Network error during initial handshake. I'll try again.\n"); /* In case a tcp connection set-up takes longer than connect-int, we might get into the situation that this node's msock gets connected to the peer's sock! @@ -2108,7 +2108,7 @@ continue; } - WARN("Discarding network configuration.\n"); + drbd_WARN("Discarding network configuration.\n"); set_cstate(mdev,StandAlone); break; } @@ -2223,7 +2223,7 @@ } #endif if (DRBD_ratelimit(5*HZ,5)) - WARN("Got NegAck packet. Peer is in troubles?\n"); + drbd_WARN("Got NegAck packet. Peer is in troubles?\n"); return TRUE; } 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-12-18 05:43:04.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; } ) @@ -464,6 +464,6 @@ bio = bio->REQ_NEXT; reqs++; } - WARN("Continued %d requests (which where issued after IO-freeze).\n", + drbd_WARN("Continued %d requests (which where issued after IO-freeze).\n", reqs); } 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-12-18 08:07:46.000000000 +0300 @@ -195,19 +195,18 @@ /* 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; + BIO_ENDIO_FN_START; complete((struct completion*)bio->bi_private); - return 0; + BIO_ENDIO_FN_RETURN; } /* reads on behalf of the partner, * "submitted" by the receiver */ -int enslaved_read_bi_end_io(struct bio *bio, unsigned int bytes_done, int error) +BIO_ENDIO_FN(enslaved_read_bi_end_io) { unsigned long flags=0; struct Tl_epoch_entry *e=NULL; @@ -219,8 +218,8 @@ /* we should be called via bio_endio, so this should never be the case * but "everyone else does it", and so do we ;) -lge */ - ERR_IF (bio->bi_size) - return 1; + ERR_IF (bio->bi_size); + BIO_ENDIO_FN_START; e = container_of(bio,struct Tl_epoch_entry,private_bio); PARANOIA_BUG_ON(!VALID_POINTER(e)); @@ -234,13 +233,13 @@ drbd_chk_io_error(mdev,error); drbd_queue_work(mdev,&mdev->data.work,&e->w); dec_local(mdev); - return 0; + BIO_ENDIO_FN_RETURN; } /* writes on behalf of the partner, or resync writes, * "submitted" by the receiver. */ -int drbd_dio_end_sec(struct bio *bio, unsigned int bytes_done, int error) +BIO_ENDIO_FN(drbd_dio_end_sec) { unsigned long flags=0; struct Tl_epoch_entry *e=NULL; @@ -250,8 +249,8 @@ PARANOIA_BUG_ON(!IS_VALID_MDEV(mdev)); // see above - ERR_IF (bio->bi_size) - return 1; + ERR_IF (bio->bi_size); + BIO_ENDIO_FN_START; e = container_of(bio,struct Tl_epoch_entry,private_bio); PARANOIA_BUG_ON(!VALID_POINTER(e)); @@ -271,20 +270,20 @@ drbd_chk_io_error(mdev,error); wake_asender(mdev); dec_local(mdev); - return 0; + BIO_ENDIO_FN_RETURN; } /* writes on Primary comming from drbd_make_request */ -int drbd_dio_end(struct bio *bio, unsigned int bytes_done, int error) +BIO_ENDIO_FN(drbd_dio_end) { drbd_request_t *req=bio->bi_private; struct Drbd_Conf* mdev=req->mdev; sector_t rsector; // see above - ERR_IF (bio->bi_size) - return 1; + ERR_IF (bio->bi_size); + BIO_ENDIO_FN_START; if(error) DUMPI(error); @@ -295,19 +294,19 @@ drbd_al_complete_io(mdev,rsector); dec_local(mdev); bio_put(bio); - return 0; + BIO_ENDIO_FN_RETURN; } /* reads on Primary comming from drbd_make_request */ -int drbd_read_bi_end_io(struct bio *bio, unsigned int bytes_done, int error) +BIO_ENDIO_FN(drbd_read_bi_end_io) { drbd_request_t *req=bio->bi_private; struct Drbd_Conf* mdev=req->mdev; // see above - ERR_IF (bio->bi_size) - return 1; + ERR_IF (bio->bi_size); + BIO_ENDIO_FN_START; /* READAs may fail. * upper layers need to be able to handle that themselves */ @@ -323,7 +322,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); @@ -332,7 +331,7 @@ bio_put(bio); dec_local(mdev); - return 0; + BIO_ENDIO_FN_RETURN; } #endif @@ -981,7 +980,7 @@ spin_unlock_irq(&mdev->req_lock); if(!w->cb(mdev,w, mdev->cstate < Connected )) { - //WARN("worker: a callback failed! \n"); + //drbd_WARN("worker: a callback failed! \n"); if (mdev->cstate >= Connected) set_cstate(mdev,NetworkFailure); drbd_thread_restart_nowait(&mdev->receiver); 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-12-18 04:51:27.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 -------------------------------------------------------------