[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] [PATCH] manually set io_restrictions in dm-error



Since dm-error never calls dm_get_device, it must manually set up the
io_restrictions in the target structure. This code is copied from Christophe
Saout's dm-zero target (http://www.saout.de/misc/dm-zero.c).

--- a/drivers/md/dm-target.c	9 Oct 2003 16:47:44 -0000
+++ b/drivers/md/dm-target.c	3 Nov 2003 18:21:52 -0000
@@ -144,11 +144,36 @@
 }
 
 /*
+ * Combine the io_restrictions with the default restrictions
+ */
+static void combine_default_restrictions(struct io_restrictions *rs)
+{
+	rs->max_sectors = min_not_zero(rs->max_sectors,
+				       (unsigned short)MAX_SECTORS);
+	rs->max_phys_segments = min_not_zero(rs->max_phys_segments,
+					     (unsigned short)MAX_PHYS_SEGMENTS);
+	rs->max_hw_segments = min_not_zero(rs->max_hw_segments,
+					   (unsigned short)MAX_HW_SEGMENTS);
+	rs->hardsect_size = max(rs->hardsect_size,
+				(unsigned short)(1 << SECTOR_SHIFT));
+	rs->max_segment_size = min_not_zero(rs->max_segment_size,
+					    (unsigned int)MAX_SEGMENT_SIZE);
+	rs->seg_boundary_mask = min_not_zero(rs->seg_boundary_mask,
+					     (unsigned long)0xffffffff);
+}
+
+/*
  * io-err: always fails an io, useful for bringing
  * up LVs that have holes in them.
  */
 static int io_err_ctr(struct dm_target *ti, unsigned int argc, char **args)
 {
+	/*
+	 * Since dm-error doesn't call dm_get_device, it 
+	 * has to combine the device limits manually.
+	 */
+	combine_default_restrictions(&ti->limits);
+
 	return 0;
 }
 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]