<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">To: Andrew Morton &lt;akpm@osdl.org&gt;
Cc: linux-kernel@vger.kernel.org, Bryn Reeves &lt;breeves@redhat.com&gt;
Subject: [PATCH 24/25] dm: extract device limit setting

From: Bryn Reeves &lt;breeves@redhat.com&gt;

Separate the setting of device I/O limits from dm_get_device().
dm-loop will use this.

Signed-off-by: Bryn Reeves &lt;breeves@redhat.com&gt;
Signed-off-by: Alasdair G Kergon &lt;agk@redhat.com&gt;

Index: linux-2.6.18-rc7/drivers/md/dm-table.c
===================================================================
--- linux-2.6.18-rc7.orig/drivers/md/dm-table.c	2006-10-13 17:10:13.000000000 +0100
+++ linux-2.6.18-rc7/drivers/md/dm-table.c	2006-10-13 17:10:16.000000000 +0100
@@ -522,56 +522,61 @@ static int __table_get_device(struct dm_
 	return 0;
 }
 
+void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev)
+{
+	request_queue_t *q = bdev_get_queue(bdev);
+	struct io_restrictions *rs = &amp;ti-&gt;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()
+	 */
+	rs-&gt;max_sectors =
+		min_not_zero(rs-&gt;max_sectors, q-&gt;max_sectors);
+
+	/* FIXME: Device-Mapper on top of RAID-0 breaks because DM
+	 *        currently doesn't honor MD's merge_bvec_fn routine.
+	 *        In this case, we'll force DM to use PAGE_SIZE or
+	 *        smaller I/O, just to be safe. A better fix is in the
+	 *        works, but add this for the time being so it will at
+	 *        least operate correctly.
+	 */
+	if (q-&gt;merge_bvec_fn)
+		rs-&gt;max_sectors =
+			min_not_zero(rs-&gt;max_sectors,
+				     (unsigned int) (PAGE_SIZE &gt;&gt; 9));
+
+	rs-&gt;max_phys_segments =
+		min_not_zero(rs-&gt;max_phys_segments,
+			     q-&gt;max_phys_segments);
+
+	rs-&gt;max_hw_segments =
+		min_not_zero(rs-&gt;max_hw_segments, q-&gt;max_hw_segments);
+
+	rs-&gt;hardsect_size = max(rs-&gt;hardsect_size, q-&gt;hardsect_size);
+
+	rs-&gt;max_segment_size =
+		min_not_zero(rs-&gt;max_segment_size, q-&gt;max_segment_size);
+
+	rs-&gt;seg_boundary_mask =
+		min_not_zero(rs-&gt;seg_boundary_mask,
+			     q-&gt;seg_boundary_mask);
+
+	rs-&gt;no_cluster |= !test_bit(QUEUE_FLAG_CLUSTER, &amp;q-&gt;queue_flags);
+}
+EXPORT_SYMBOL_GPL(dm_set_device_limits);
 
 int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
 		  sector_t len, int mode, struct dm_dev **result)
 {
 	int r = __table_get_device(ti-&gt;table, ti, path,
 				   start, len, mode, result);
-	if (!r) {
-		request_queue_t *q = bdev_get_queue((*result)-&gt;bdev);
-		struct io_restrictions *rs = &amp;ti-&gt;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()
-		 */
-		rs-&gt;max_sectors =
-			min_not_zero(rs-&gt;max_sectors, q-&gt;max_sectors);
 
-		/* FIXME: Device-Mapper on top of RAID-0 breaks because DM
-		 *        currently doesn't honor MD's merge_bvec_fn routine.
-		 *        In this case, we'll force DM to use PAGE_SIZE or
-		 *        smaller I/O, just to be safe. A better fix is in the
-		 *        works, but add this for the time being so it will at
-		 *        least operate correctly.
-		 */
-		if (q-&gt;merge_bvec_fn)
-			rs-&gt;max_sectors =
-				min_not_zero(rs-&gt;max_sectors,
-					     (unsigned int) (PAGE_SIZE &gt;&gt; 9));
-
-		rs-&gt;max_phys_segments =
-			min_not_zero(rs-&gt;max_phys_segments,
-				     q-&gt;max_phys_segments);
-
-		rs-&gt;max_hw_segments =
-			min_not_zero(rs-&gt;max_hw_segments, q-&gt;max_hw_segments);
-
-		rs-&gt;hardsect_size = max(rs-&gt;hardsect_size, q-&gt;hardsect_size);
-
-		rs-&gt;max_segment_size =
-			min_not_zero(rs-&gt;max_segment_size, q-&gt;max_segment_size);
-
-		rs-&gt;seg_boundary_mask =
-			min_not_zero(rs-&gt;seg_boundary_mask,
-				     q-&gt;seg_boundary_mask);
-
-		rs-&gt;no_cluster |= !test_bit(QUEUE_FLAG_CLUSTER, &amp;q-&gt;queue_flags);
-	}
+	if (!r)
+		dm_set_device_limits(ti, (*result)-&gt;bdev);
 
 	return r;
 }
Index: linux-2.6.18-rc7/include/linux/device-mapper.h
===================================================================
--- linux-2.6.18-rc7.orig/include/linux/device-mapper.h	2006-10-13 17:10:13.000000000 +0100
+++ linux-2.6.18-rc7/include/linux/device-mapper.h	2006-10-13 17:10:16.000000000 +0100
@@ -72,6 +72,11 @@ typedef int (*dm_ioctl_fn) (struct dm_ta
 void dm_error(const char *message);
 
 /*
+ * Combine device limits.
+ */
+void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev);
+
+/*
  * Constructors should call these functions to ensure destination devices
  * are opened/closed correctly.
  * FIXME: too many arguments.
</pre></body></html>