Skip to content

Commit 9121250

Browse files
neilbrownkergon
authored andcommitted
dm: merge max_hw_sector
Make sure dm honours max_hw_sectors of underlying devices We still have no firm testing evidence in support of this patch but believe it may help to resolve some bug reports. - agk Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
1 parent 69267a3 commit 9121250

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drivers/md/dm-table.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ static void combine_restrictions_low(struct io_restrictions *lhs,
9999
lhs->max_segment_size =
100100
min_not_zero(lhs->max_segment_size, rhs->max_segment_size);
101101

102+
lhs->max_hw_sectors =
103+
min_not_zero(lhs->max_hw_sectors, rhs->max_hw_sectors);
104+
102105
lhs->seg_boundary_mask =
103106
min_not_zero(lhs->seg_boundary_mask, rhs->seg_boundary_mask);
104107

@@ -566,6 +569,9 @@ void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev)
566569
rs->max_segment_size =
567570
min_not_zero(rs->max_segment_size, q->max_segment_size);
568571

572+
rs->max_hw_sectors =
573+
min_not_zero(rs->max_hw_sectors, q->max_hw_sectors);
574+
569575
rs->seg_boundary_mask =
570576
min_not_zero(rs->seg_boundary_mask,
571577
q->seg_boundary_mask);
@@ -703,6 +709,8 @@ static void check_for_valid_limits(struct io_restrictions *rs)
703709
{
704710
if (!rs->max_sectors)
705711
rs->max_sectors = SAFE_MAX_SECTORS;
712+
if (!rs->max_hw_sectors)
713+
rs->max_hw_sectors = SAFE_MAX_SECTORS;
706714
if (!rs->max_phys_segments)
707715
rs->max_phys_segments = MAX_PHYS_SEGMENTS;
708716
if (!rs->max_hw_segments)
@@ -901,6 +909,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q)
901909
q->max_hw_segments = t->limits.max_hw_segments;
902910
q->hardsect_size = t->limits.hardsect_size;
903911
q->max_segment_size = t->limits.max_segment_size;
912+
q->max_hw_sectors = t->limits.max_hw_sectors;
904913
q->seg_boundary_mask = t->limits.seg_boundary_mask;
905914
q->bounce_pfn = t->limits.bounce_pfn;
906915
if (t->limits.no_cluster)

include/linux/device-mapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct io_restrictions {
115115
unsigned short max_hw_segments;
116116
unsigned short hardsect_size;
117117
unsigned int max_segment_size;
118+
unsigned int max_hw_sectors;
118119
unsigned long seg_boundary_mask;
119120
unsigned long bounce_pfn;
120121
unsigned char no_cluster; /* inverted so that 0 is default */

0 commit comments

Comments
 (0)