[dm-devel] [RFC][PATCH] Simplify dm_get_device restriction combining

Christophe Saout christophe at saout.de
Tue Jan 20 10:39:01 UTC 2004


Hi,

I know this doesn't make the problem go away, but it looks much simpler
this way and removes unnecessary code duplication:


Copy the restrictions from the request queue into a temporary local
variable and use combine_restrictions_low() instead of duplicating the
code.
--- linux.orig/drivers/md/dm-table.c	2004-01-20 14:12:29.000000000 +0100
+++ linux/drivers/md/dm-table.c	2004-01-20 16:31:14.627515048 +0100
@@ -482,17 +482,19 @@
 				   start, len, mode, result);
 	if (!r) {
 		request_queue_t *q = bdev_get_queue((*result)->bdev);
-		struct io_restrictions *rs = &ti->limits;
-
+		struct io_restrictions *lrs = &ti->limits;
 		/*
-		 * Combine the device limits low.
-		 *
-		 * FIXME: if we move an io_restriction struct
-		 *        into q this would just be a call to
-		 *        combine_restrictions_low()
+		 * FIXME: If we move an io_restriction struct into q we wouldn't
+		 *        need to copy the restrictions to a temporary variable.
 		 */
-		rs->max_sectors =
-			min_not_zero(rs->max_sectors, q->max_sectors);
+		struct io_restrictions hrs = {
+			.max_sectors = q->max_sectors,
+			.max_phys_segments = q->max_phys_segments,
+			.max_hw_segments = q->max_hw_segments,
+			.hardsect_size = q->hardsect_size,
+			.max_segment_size = q->max_segment_size,
+			.seg_boundary_mask = q->seg_boundary_mask
+		};
 
 		/* FIXME: Device-Mapper on top of RAID-0 breaks because DM
 		 *        currently doesn't honor MD's merge_bvec_fn routine.
@@ -502,25 +504,14 @@
 		 *        least operate correctly.
 		 */
 		if (q->merge_bvec_fn)
-			rs->max_sectors =
-				min_not_zero(rs->max_sectors,
+			hrs.max_sectors =
+				min_not_zero(hrs.max_sectors,
 					     (unsigned short)(PAGE_SIZE >> 9));
 
-		rs->max_phys_segments =
-			min_not_zero(rs->max_phys_segments,
-				     q->max_phys_segments);
-
-		rs->max_hw_segments =
-			min_not_zero(rs->max_hw_segments, q->max_hw_segments);
-
-		rs->hardsect_size = max(rs->hardsect_size, q->hardsect_size);
-
-		rs->max_segment_size =
-			min_not_zero(rs->max_segment_size, q->max_segment_size);
-
-		rs->seg_boundary_mask =
-			min_not_zero(rs->seg_boundary_mask,
-				     q->seg_boundary_mask);
+		/*
+		 * Combine the device limits low.
+		 */
+		combine_restrictions_low(lrs, &hrs);
 	}
 
 	return r;





More information about the dm-devel mailing list