[DRBD-cvs] r1772 - trunk/drbd
www-data
www-data at garcon.linbit.com
Tue Mar 22 14:03:48 CET 2005
Author: phil
Date: 2005-03-22 14:03:46 +0100 (Tue, 22 Mar 2005)
New Revision: 1772
Modified:
trunk/drbd/drbd_fs.c
trunk/drbd/drbd_int.h
trunk/drbd/drbd_main.c
trunk/drbd/drbd_receiver.c
trunk/drbd/drbd_req.c
Log:
- Now we take into account that a backing block device might
have a merge_bvec_fn(). If this is the case we fall back
to PAGE_SIZEd BIOs.
- Now find the right max_segment_size over both nodes.
Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c 2005-03-21 20:10:22 UTC (rev 1771)
+++ trunk/drbd/drbd_fs.c 2005-03-22 13:03:46 UTC (rev 1772)
@@ -210,9 +210,36 @@
return 0;
}
+void drbd_setup_queue_param(drbd_dev *mdev, unsigned int max_seg_s)
+{
+ request_queue_t * const q = mdev->rq_queue;
+ request_queue_t * const b = mdev->backing_bdev->bd_disk->queue;
+
+ unsigned int old_max_seg_s = q->max_segment_size;
+
+ if(b->merge_bvec_fn) {
+ max_seg_s = PAGE_SIZE;
+ }
+
+ q->max_sectors = max_seg_s >> 9;
+ q->max_phys_segments = max_seg_s >> PAGE_SHIFT;
+ q->max_hw_segments = max_seg_s >> PAGE_SHIFT;
+ q->max_segment_size = max_seg_s;
+ q->hardsect_size = 512;
+ q->seg_boundary_mask = PAGE_SIZE-1;
+ blk_queue_stack_limits(q, b);
+
+ if( old_max_seg_s != q->max_segment_size ) {
+ if(b->merge_bvec_fn) {
+ WARN("Backing device has merge_bvec_fn()!\n");
+ }
+ INFO("max_segment_size ( = BIO size ) = %u\n",
+ q->max_segment_size);
+ }
+}
+
STATIC
-int drbd_ioctl_set_disk(struct Drbd_Conf *mdev,
- struct ioctl_disk_config * arg)
+int drbd_ioctl_set_disk(drbd_dev *mdev, struct ioctl_disk_config * arg)
{
int i, md_gc_valid, minor;
enum ret_codes retcode;
@@ -365,26 +392,8 @@
mdev->read_cnt = 0;
mdev->writ_cnt = 0;
-/* FIXME unclutter the code again...
- * possibly rather use blk_queue_stack_limits
- */
-/*
- * Returns the minimum that is _not_ zero, unless both are zero.
- */
-#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
- request_queue_t * const q = mdev->rq_queue;
- request_queue_t * const b = bdev->bd_disk->queue;
+ drbd_setup_queue_param(mdev, DRBD_MAX_SEGMENT_SIZE);
- q->max_sectors = min_not_zero((unsigned short)(DRBD_MAX_SEGMENT_SIZE >> 9), b->max_sectors);
- q->max_phys_segments = DRBD_MAX_SEGMENT_SIZE/PAGE_SIZE;
- q->max_hw_segments = DRBD_MAX_SEGMENT_SIZE/PAGE_SIZE;
- q->max_segment_size = min_t(int,DRBD_MAX_SEGMENT_SIZE,b->max_segment_size);
- q->hardsect_size = max((unsigned short)512,b->hardsect_size);
- q->seg_boundary_mask = PAGE_SIZE-1;
- D_ASSERT(q->hardsect_size <= PAGE_SIZE); // or we are really screwed ;-)
- blk_queue_merge_bvec(q, drbd_merge_bvec);
-#undef min_not_zero
-
set_bit(MD_IO_ALLOWED,&mdev->flags);
md_gc_valid = drbd_md_read(mdev);
Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h 2005-03-21 20:10:22 UTC (rev 1771)
+++ trunk/drbd/drbd_int.h 2005-03-22 13:03:46 UTC (rev 1772)
@@ -475,6 +475,7 @@
u64 d_size; // size of disk
u64 u_size; // user requested size
u64 c_size; // current exported size
+ u32 max_segment_size; // Maximal size of a BIO
} __attribute((packed)) Drbd_Sizes_Packet;
typedef struct {
@@ -1010,6 +1011,7 @@
// drbd_fs.c
extern char* ppsize(char* buf, size_t size);
extern int drbd_determin_dev_size(drbd_dev*);
+extern void drbd_setup_queue_param(drbd_dev *mdev, unsigned int);
extern int drbd_set_role(drbd_dev *mdev,drbd_role_t newstate);
extern int drbd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c 2005-03-21 20:10:22 UTC (rev 1771)
+++ trunk/drbd/drbd_main.c 2005-03-22 13:03:46 UTC (rev 1772)
@@ -984,6 +984,7 @@
p.u_size = cpu_to_be64(mdev->lo_usize);
p.d_size = cpu_to_be64(d_size);
p.c_size = cpu_to_be64(drbd_get_capacity(mdev->this_bdev));
+ p.max_segment_size = cpu_to_be32(mdev->rq_queue->max_segment_size);
ok = drbd_send_cmd(mdev,mdev->data.socket,ReportSizes,
(Drbd_Header*)&p,sizeof(p));
@@ -2053,6 +2054,7 @@
if (!q) goto Enomem;
mdev->rq_queue = q;
q->queuedata = mdev;
+ q->max_segment_size = DRBD_MAX_SEGMENT_SIZE;
disk = alloc_disk(1);
if (!disk) goto Enomem;
@@ -2077,7 +2079,8 @@
WARN("Could not bd_claim() myself.");
}
- blk_queue_make_request(q,drbd_make_request_26);
+ blk_queue_make_request(q, drbd_make_request_26);
+ blk_queue_merge_bvec(q, drbd_merge_bvec);
q->queue_lock = &mdev->req_lock; // needed since we use
// plugging on a queue, that actually has no requests!
q->unplug_fn = drbd_unplug_fn;
Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c 2005-03-21 20:10:22 UTC (rev 1771)
+++ trunk/drbd/drbd_receiver.c 2005-03-22 13:03:46 UTC (rev 1772)
@@ -1432,6 +1432,7 @@
STATIC int receive_sizes(drbd_dev *mdev, Drbd_Header *h)
{
Drbd_Sizes_Packet *p = (Drbd_Sizes_Packet*)h;
+ unsigned int max_seg_s;
sector_t p_size;
drbd_conns_t nconn;
@@ -1471,6 +1472,11 @@
}
}
+ max_seg_s = be32_to_cpu(p->max_segment_size);
+ if( max_seg_s != mdev->rq_queue->max_segment_size ) {
+ drbd_setup_queue_param(mdev, max_seg_s);
+ }
+
if (mdev->state.s.conn > WFReportParams ) {
if( be64_to_cpu(p->c_size) !=
drbd_get_capacity(mdev->this_bdev) ) {
Modified: trunk/drbd/drbd_req.c
===================================================================
--- trunk/drbd/drbd_req.c 2005-03-21 20:10:22 UTC (rev 1771)
+++ trunk/drbd/drbd_req.c 2005-03-22 13:03:46 UTC (rev 1772)
@@ -416,10 +416,10 @@
PAGE_SIZE);
// As long as the BIO is emtpy we allow at least one page.
} else {
- t = s >> AL_EXTENT_SIZE_B;
+ t = s & ~(AL_EXTENT_SIZE-1);
s = (s + bio->bi_size);
- if( s >> AL_EXTENT_SIZE_B != t ) {
+ if( ( s & ~(AL_EXTENT_SIZE-1) ) != t ) {
s = 0;
// This BIO already spans over an AL_EXTENTs boundary.
} else {
More information about the drbd-cvs
mailing list