dm.c (094ee64d7de8ab72b495ff9c03d86a60272da56d) | dm.c (3720281db9ad4905c3afc1bf389314d64e145093) |
---|---|
1/* 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include "dm-core.h" --- 1027 unchanged lines hidden (view full) --- 1036 free_tio(tio); 1037 dec_pending(io, error); 1038} 1039 1040/* 1041 * Return maximum size of I/O possible at the supplied sector up to the current 1042 * target boundary. 1043 */ | 1/* 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include "dm-core.h" --- 1027 unchanged lines hidden (view full) --- 1036 free_tio(tio); 1037 dec_pending(io, error); 1038} 1039 1040/* 1041 * Return maximum size of I/O possible at the supplied sector up to the current 1042 * target boundary. 1043 */ |
1044static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti) | 1044static inline sector_t max_io_len_target_boundary(struct dm_target *ti, 1045 sector_t target_offset) |
1045{ | 1046{ |
1046 sector_t target_offset = dm_target_offset(ti, sector); 1047 | |
1048 return ti->len - target_offset; 1049} 1050 | 1047 return ti->len - target_offset; 1048} 1049 |
1051static sector_t max_io_len(sector_t sector, struct dm_target *ti) | 1050static sector_t max_io_len(struct dm_target *ti, sector_t sector) |
1052{ | 1051{ |
1053 sector_t len = max_io_len_target_boundary(sector, ti); | 1052 sector_t target_offset = dm_target_offset(ti, sector); 1053 sector_t len = max_io_len_target_boundary(ti, target_offset); |
1054 sector_t max_len; 1055 1056 /* 1057 * Does the target need to split even further? 1058 * - q->limits.chunk_sectors reflects ti->max_io_len so 1059 * blk_max_size_offset() provides required splitting. 1060 * - blk_max_size_offset() also respects q->limits.max_sectors 1061 */ 1062 max_len = blk_max_size_offset(dm_table_get_md(ti->table)->queue, | 1054 sector_t max_len; 1055 1056 /* 1057 * Does the target need to split even further? 1058 * - q->limits.chunk_sectors reflects ti->max_io_len so 1059 * blk_max_size_offset() provides required splitting. 1060 * - blk_max_size_offset() also respects q->limits.max_sectors 1061 */ 1062 max_len = blk_max_size_offset(dm_table_get_md(ti->table)->queue, |
1063 dm_target_offset(ti, sector)); | 1063 target_offset); |
1064 if (len > max_len) 1065 len = max_len; 1066 1067 return len; 1068} 1069 1070int dm_set_target_max_io_len(struct dm_target *ti, sector_t len) 1071{ --- 38 unchanged lines hidden (view full) --- 1110 int srcu_idx; 1111 1112 ti = dm_dax_get_live_target(md, sector, &srcu_idx); 1113 1114 if (!ti) 1115 goto out; 1116 if (!ti->type->direct_access) 1117 goto out; | 1064 if (len > max_len) 1065 len = max_len; 1066 1067 return len; 1068} 1069 1070int dm_set_target_max_io_len(struct dm_target *ti, sector_t len) 1071{ --- 38 unchanged lines hidden (view full) --- 1110 int srcu_idx; 1111 1112 ti = dm_dax_get_live_target(md, sector, &srcu_idx); 1113 1114 if (!ti) 1115 goto out; 1116 if (!ti->type->direct_access) 1117 goto out; |
1118 len = max_io_len(sector, ti) / PAGE_SECTORS; | 1118 len = max_io_len(ti, sector) / PAGE_SECTORS; |
1119 if (len < 1) 1120 goto out; 1121 nr_pages = min(len, nr_pages); 1122 ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); 1123 1124 out: 1125 dm_put_live_table(md, srcu_idx); 1126 --- 365 unchanged lines hidden (view full) --- 1492 * Even though the device advertised support for this type of 1493 * request, that does not mean every target supports it, and 1494 * reconfiguration might also have changed that since the 1495 * check was performed. 1496 */ 1497 if (!num_bios) 1498 return -EOPNOTSUPP; 1499 | 1119 if (len < 1) 1120 goto out; 1121 nr_pages = min(len, nr_pages); 1122 ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); 1123 1124 out: 1125 dm_put_live_table(md, srcu_idx); 1126 --- 365 unchanged lines hidden (view full) --- 1492 * Even though the device advertised support for this type of 1493 * request, that does not mean every target supports it, and 1494 * reconfiguration might also have changed that since the 1495 * check was performed. 1496 */ 1497 if (!num_bios) 1498 return -EOPNOTSUPP; 1499 |
1500 len = min((sector_t)ci->sector_count, max_io_len_target_boundary(ci->sector, ti)); | 1500 len = min_t(sector_t, ci->sector_count, 1501 max_io_len_target_boundary(ti, dm_target_offset(ti, ci->sector))); |
1501 1502 __send_duplicate_bios(ci, ti, num_bios, &len); 1503 1504 ci->sector += len; 1505 ci->sector_count -= len; 1506 1507 return 0; 1508} --- 64 unchanged lines hidden (view full) --- 1573 1574 ti = dm_table_find_target(ci->map, ci->sector); 1575 if (!ti) 1576 return -EIO; 1577 1578 if (__process_abnormal_io(ci, ti, &r)) 1579 return r; 1580 | 1502 1503 __send_duplicate_bios(ci, ti, num_bios, &len); 1504 1505 ci->sector += len; 1506 ci->sector_count -= len; 1507 1508 return 0; 1509} --- 64 unchanged lines hidden (view full) --- 1574 1575 ti = dm_table_find_target(ci->map, ci->sector); 1576 if (!ti) 1577 return -EIO; 1578 1579 if (__process_abnormal_io(ci, ti, &r)) 1580 return r; 1581 |
1581 len = min_t(sector_t, max_io_len(ci->sector, ti), ci->sector_count); | 1582 len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count); |
1582 1583 r = __clone_and_map_data_bio(ci, ti, ci->sector, &len); 1584 if (r < 0) 1585 return r; 1586 1587 ci->sector += len; 1588 ci->sector_count -= len; 1589 --- 1665 unchanged lines hidden --- | 1583 1584 r = __clone_and_map_data_bio(ci, ti, ci->sector, &len); 1585 if (r < 0) 1586 return r; 1587 1588 ci->sector += len; 1589 ci->sector_count -= len; 1590 --- 1665 unchanged lines hidden --- |