[DRBD-cvs] r1738 - in branches/drbd-0.7/drbd: . linux
svn at svn.drbd.org
svn at svn.drbd.org
Thu Jan 27 14:46:57 CET 2005
Author: phil
Date: 2005-01-27 14:46:55 +0100 (Thu, 27 Jan 2005)
New Revision: 1738
Modified:
branches/drbd-0.7/drbd/drbd_compat_wrappers.h
branches/drbd-0.7/drbd/drbd_int.h
branches/drbd-0.7/drbd/drbd_main.c
branches/drbd-0.7/drbd/drbd_req.c
branches/drbd-0.7/drbd/drbd_worker.c
branches/drbd-0.7/drbd/linux/drbd_config.h
Log:
New way of using bio_clone() ... needs more testing
Modified: branches/drbd-0.7/drbd/drbd_compat_wrappers.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_compat_wrappers.h 2005-01-27 08:56:42 UTC (rev 1737)
+++ branches/drbd-0.7/drbd/drbd_compat_wrappers.h 2005-01-27 13:46:55 UTC (rev 1738)
@@ -93,6 +93,11 @@
return req->private_bio.b_size;
}
+static inline drbd_bio_t* drbd_req_private_bio(struct drbd_request *req)
+{
+ return &req->private_bio;
+}
+
static inline sector_t drbd_ee_get_sector(struct Tl_epoch_entry *ee)
{
return ee->private_bio.b_blocknr;
@@ -387,7 +392,7 @@
static inline drbd_dev* drbd_req_get_mdev(struct drbd_request *req)
{
- return (drbd_dev*) req->private_bio.bi_private;
+ return (drbd_dev*) req->mdev;
}
static inline sector_t drbd_req_get_sector(struct drbd_request *req)
@@ -397,11 +402,16 @@
static inline unsigned short drbd_req_get_size(struct drbd_request *req)
{
- drbd_dev* mdev = req->private_bio.bi_private;
+ drbd_dev* mdev = req->mdev;
D_ASSERT(req->master_bio->bi_size);
return req->master_bio->bi_size;
}
+static inline drbd_bio_t* drbd_req_private_bio(struct drbd_request *req)
+{
+ return req->private_bio;
+}
+
static inline sector_t drbd_ee_get_sector(struct Tl_epoch_entry *ee)
{
return ee->ee_sector;
@@ -531,45 +541,33 @@
static inline void
drbd_req_prepare_write(drbd_dev *mdev, struct drbd_request *req)
{
- struct bio * const bio = &req->private_bio;
- struct bio_vec * const bvec = &req->req_bvec;
- struct bio * const bio_src = req->master_bio;
+ struct bio *bio;
- bio_init(bio); // bio->bi_flags = 0;
- bio->bi_io_vec = bvec;
- bio->bi_max_vecs = 1;
-
- /* FIXME: __bio_clone() workaround, fix me properly later! */
- bio_src->bi_max_vecs = 1;
- __bio_clone(bio,bio_src);
+ bio = req->private_bio = bio_clone(req->master_bio, GFP_NOIO );
+ bio_get(bio);
bio->bi_bdev = mdev->backing_bdev;
- bio->bi_private = mdev;
+ bio->bi_private = req;
bio->bi_end_io = drbd_dio_end;
- bio->bi_next = NULL;
+ bio->bi_next = 0;
req->rq_status = RQ_DRBD_NOTHING;
+ req->mdev = mdev;
}
static inline void
drbd_req_prepare_read(drbd_dev *mdev, struct drbd_request *req)
{
- struct bio * const bio = &req->private_bio;
- struct bio_vec * const bvec = &req->req_bvec;
- struct bio * const bio_src = req->master_bio;
+ struct bio *bio;
- bio_init(bio); // bio->bi_flags = 0;
- bio->bi_io_vec = bvec;
- bio->bi_max_vecs = 1;
-
- /* FIXME: __bio_clone() workaround, fix me properly later! */
- bio_src->bi_max_vecs = 1;
- __bio_clone(bio,bio_src);
+ bio = req->private_bio = bio_clone(req->master_bio, GFP_NOIO );
+ bio_get(bio);
bio->bi_bdev = mdev->backing_bdev;
- bio->bi_private = mdev;
+ bio->bi_private = req;
bio->bi_end_io = drbd_read_bi_end_io; // <- only difference
- bio->bi_next = NULL;
+ bio->bi_next = 0;
req->rq_status = RQ_DRBD_NOTHING;
+ req->mdev = mdev;
}
static inline struct page* drbd_bio_get_page(struct bio *bio)
@@ -635,7 +633,7 @@
static inline int _drbd_send_zc_bio(drbd_dev *mdev, struct bio *bio)
{
- struct bio_vec *bvec = bio_iovec(bio);
+ struct bio_vec *bvec = bio_iovec_idx(bio, bio->bi_idx);
return _drbd_send_page(mdev,bvec->bv_page,bvec->bv_offset,bvec->bv_len);
}
Modified: branches/drbd-0.7/drbd/drbd_int.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_int.h 2005-01-27 08:56:42 UTC (rev 1737)
+++ branches/drbd-0.7/drbd/drbd_int.h 2005-01-27 13:46:55 UTC (rev 1738)
@@ -629,8 +629,12 @@
int rq_status;
struct drbd_barrier *barrier; // The next barrier.
drbd_bio_t *master_bio; // master bio pointer
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
drbd_bio_t private_bio; // private bio struct
- ONLY_IN_26(struct bio_vec req_bvec;)
+#else
+ struct bio *private_bio;
+ drbd_dev *mdev;
+#endif
};
struct drbd_barrier {
@@ -670,7 +674,7 @@
long magic;
ONLY_IN_26(unsigned int ee_size;)
ONLY_IN_26(sector_t ee_sector;)
- // TODO: we rather want bio_alloc(GFP_*,1) all through the code!
+ // THINK: maybe we rather want bio_alloc(GFP_*,1)
ONLY_IN_26(struct bio_vec ee_bvec;)
};
Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c 2005-01-27 08:56:42 UTC (rev 1737)
+++ branches/drbd-0.7/drbd/drbd_main.c 2005-01-27 13:46:55 UTC (rev 1738)
@@ -1064,9 +1064,9 @@
ok = sizeof(p) == drbd_send(mdev,mdev->data.socket,&p,sizeof(p),MSG_MORE);
if(ok) {
if(mdev->conf.wire_protocol == DRBD_PROT_A) {
- ok = _drbd_send_bio(mdev,&req->private_bio);
+ ok = _drbd_send_bio(mdev,drbd_req_private_bio(req));
} else {
- ok = _drbd_send_zc_bio(mdev,&req->private_bio);
+ ok = _drbd_send_zc_bio(mdev,drbd_req_private_bio(req));
}
}
if(!ok) tl_cancel(mdev,req);
Modified: branches/drbd-0.7/drbd/drbd_req.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_req.c 2005-01-27 08:56:42 UTC (rev 1737)
+++ branches/drbd-0.7/drbd/drbd_req.c 2005-01-27 13:46:55 UTC (rev 1738)
@@ -363,7 +363,7 @@
else mdev->read_cnt += size>>9;
// in 2.4.X, READA are submitted as READ.
- drbd_generic_make_request(rw,&req->private_bio);
+ drbd_generic_make_request(rw,drbd_req_private_bio(req));
}
// up_read(mdev->device_lock);
Modified: branches/drbd-0.7/drbd/drbd_worker.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_worker.c 2005-01-27 08:56:42 UTC (rev 1737)
+++ branches/drbd-0.7/drbd/drbd_worker.c 2005-01-27 13:46:55 UTC (rev 1738)
@@ -275,25 +275,21 @@
*/
int drbd_dio_end(struct bio *bio, unsigned int bytes_done, int error)
{
- struct Drbd_Conf* mdev=bio->bi_private;
- drbd_request_t *req;
+ 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;
- PARANOIA_BUG_ON(!IS_VALID_MDEV(mdev));
-
- req = container_of(bio,struct drbd_request,private_bio);
- PARANOIA_BUG_ON(!VALID_POINTER(req));
-
drbd_chk_io_error(mdev,error);
rsector = drbd_req_get_sector(req);
// the bi_sector of the bio gets modified somewhere in drbd_end_req()!
drbd_end_req(req, RQ_DRBD_LOCAL, (error == 0), rsector);
drbd_al_complete_io(mdev,rsector);
dec_local(mdev);
+ bio_put(bio);
return 0;
}
@@ -301,18 +297,13 @@
*/
int drbd_read_bi_end_io(struct bio *bio, unsigned int bytes_done, int error)
{
- struct Drbd_Conf* mdev = bio->bi_private;
- drbd_request_t *req;
+ drbd_request_t *req=bio->bi_private;
+ struct Drbd_Conf* mdev=req->mdev;
// see above
ERR_IF (bio->bi_size)
return 1;
- PARANOIA_BUG_ON(!IS_VALID_MDEV(mdev));
-
- req = container_of(bio,struct drbd_request,private_bio);
- PARANOIA_BUG_ON(!VALID_POINTER(req));
-
/* READAs may fail.
* upper layers need to be able to handle that themselves */
if (bio_rw(bio) == READA) goto pass_on;
@@ -334,6 +325,7 @@
mempool_free(req,drbd_request_mempool);
}
+ bio_put(bio);
dec_local(mdev);
return 0;
}
Modified: branches/drbd-0.7/drbd/linux/drbd_config.h
===================================================================
--- branches/drbd-0.7/drbd/linux/drbd_config.h 2005-01-27 08:56:42 UTC (rev 1737)
+++ branches/drbd-0.7/drbd/linux/drbd_config.h 2005-01-27 13:46:55 UTC (rev 1738)
@@ -22,7 +22,7 @@
extern const char * drbd_buildtag(void);
-#define REL_VERSION "0.7.9"
+#define REL_VERSION "0.7.10"
#define API_VERSION 77
#define PRO_VERSION 74
More information about the drbd-cvs
mailing list