dm.c (06a426cee9b35505aeb7516a67bd26496ca7ed08) dm.c (56a67df766039666f61fb15b079f713e44a735ae)
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.h"

--- 1016 unchanged lines hidden (view full) ---

1025 * - another request may be submitted by the upper level driver
1026 * of the stacking during the completion
1027 * - the submission which requires queue lock may be done
1028 * against this queue
1029 */
1030 dm_complete_request(clone, error);
1031}
1032
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.h"

--- 1016 unchanged lines hidden (view full) ---

1025 * - another request may be submitted by the upper level driver
1026 * of the stacking during the completion
1027 * - the submission which requires queue lock may be done
1028 * against this queue
1029 */
1030 dm_complete_request(clone, error);
1031}
1032
1033static sector_t max_io_len(struct mapped_device *md,
1034 sector_t sector, struct dm_target *ti)
1033/*
1034 * Return maximum size of I/O possible at the supplied sector up to the current
1035 * target boundary.
1036 */
1037static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti)
1035{
1038{
1036 sector_t offset = sector - ti->begin;
1037 sector_t len = ti->len - offset;
1039 sector_t target_offset = dm_target_offset(ti, sector);
1038
1040
1041 return ti->len - target_offset;
1042}
1043
1044static sector_t max_io_len(sector_t sector, struct dm_target *ti)
1045{
1046 sector_t len = max_io_len_target_boundary(sector, ti);
1047
1039 /*
1040 * Does the target need to split even further ?
1041 */
1042 if (ti->split_io) {
1043 sector_t boundary;
1048 /*
1049 * Does the target need to split even further ?
1050 */
1051 if (ti->split_io) {
1052 sector_t boundary;
1053 sector_t offset = dm_target_offset(ti, sector);
1044 boundary = ((offset + ti->split_io) & ~(ti->split_io - 1))
1045 - offset;
1046 if (len > boundary)
1047 len = boundary;
1048 }
1049
1050 return len;
1051}

--- 201 unchanged lines hidden (view full) ---

1253 * Even though the device advertised discard support,
1254 * reconfiguration might have changed that since the
1255 * check was performed.
1256 */
1257
1258 if (!ti->num_discard_requests)
1259 return -EOPNOTSUPP;
1260
1054 boundary = ((offset + ti->split_io) & ~(ti->split_io - 1))
1055 - offset;
1056 if (len > boundary)
1057 len = boundary;
1058 }
1059
1060 return len;
1061}

--- 201 unchanged lines hidden (view full) ---

1263 * Even though the device advertised discard support,
1264 * reconfiguration might have changed that since the
1265 * check was performed.
1266 */
1267
1268 if (!ti->num_discard_requests)
1269 return -EOPNOTSUPP;
1270
1261 max = max_io_len(ci->md, ci->sector, ti);
1271 max = max_io_len(ci->sector, ti);
1262
1263 if (ci->sector_count > max)
1264 /*
1265 * FIXME: Handle a discard that spans two or more targets.
1266 */
1267 return -EOPNOTSUPP;
1268
1269 __issue_target_requests(ci, ti, ti->num_discard_requests);

--- 15 unchanged lines hidden (view full) ---

1285
1286 if (unlikely(bio->bi_rw & REQ_DISCARD))
1287 return __clone_and_map_discard(ci);
1288
1289 ti = dm_table_find_target(ci->map, ci->sector);
1290 if (!dm_target_is_valid(ti))
1291 return -EIO;
1292
1272
1273 if (ci->sector_count > max)
1274 /*
1275 * FIXME: Handle a discard that spans two or more targets.
1276 */
1277 return -EOPNOTSUPP;
1278
1279 __issue_target_requests(ci, ti, ti->num_discard_requests);

--- 15 unchanged lines hidden (view full) ---

1295
1296 if (unlikely(bio->bi_rw & REQ_DISCARD))
1297 return __clone_and_map_discard(ci);
1298
1299 ti = dm_table_find_target(ci->map, ci->sector);
1300 if (!dm_target_is_valid(ti))
1301 return -EIO;
1302
1293 max = max_io_len(ci->md, ci->sector, ti);
1303 max = max_io_len(ci->sector, ti);
1294
1295 if (ci->sector_count <= max) {
1296 /*
1297 * Optimise for the simple case where we can do all of
1298 * the remaining io with a single clone.
1299 */
1300 __clone_and_map_simple(ci, ti);
1301

--- 34 unchanged lines hidden (view full) ---

1336 unsigned int offset = 0;
1337
1338 do {
1339 if (offset) {
1340 ti = dm_table_find_target(ci->map, ci->sector);
1341 if (!dm_target_is_valid(ti))
1342 return -EIO;
1343
1304
1305 if (ci->sector_count <= max) {
1306 /*
1307 * Optimise for the simple case where we can do all of
1308 * the remaining io with a single clone.
1309 */
1310 __clone_and_map_simple(ci, ti);
1311

--- 34 unchanged lines hidden (view full) ---

1346 unsigned int offset = 0;
1347
1348 do {
1349 if (offset) {
1350 ti = dm_table_find_target(ci->map, ci->sector);
1351 if (!dm_target_is_valid(ti))
1352 return -EIO;
1353
1344 max = max_io_len(ci->md, ci->sector, ti);
1354 max = max_io_len(ci->sector, ti);
1345 }
1346
1347 len = min(remaining, max);
1348
1349 tio = alloc_tio(ci, ti);
1350 clone = split_bvec(bio, ci->sector, ci->idx,
1351 bv->bv_offset + offset, len,
1352 ci->md->bs);

--- 70 unchanged lines hidden (view full) ---

1423
1424 ti = dm_table_find_target(map, bvm->bi_sector);
1425 if (!dm_target_is_valid(ti))
1426 goto out_table;
1427
1428 /*
1429 * Find maximum amount of I/O that won't need splitting
1430 */
1355 }
1356
1357 len = min(remaining, max);
1358
1359 tio = alloc_tio(ci, ti);
1360 clone = split_bvec(bio, ci->sector, ci->idx,
1361 bv->bv_offset + offset, len,
1362 ci->md->bs);

--- 70 unchanged lines hidden (view full) ---

1433
1434 ti = dm_table_find_target(map, bvm->bi_sector);
1435 if (!dm_target_is_valid(ti))
1436 goto out_table;
1437
1438 /*
1439 * Find maximum amount of I/O that won't need splitting
1440 */
1431 max_sectors = min(max_io_len(md, bvm->bi_sector, ti),
1441 max_sectors = min(max_io_len(bvm->bi_sector, ti),
1432 (sector_t) BIO_MAX_SECTORS);
1433 max_size = (max_sectors << SECTOR_SHIFT) - bvm->bi_size;
1434 if (max_size < 0)
1435 max_size = 0;
1436
1437 /*
1438 * merge_bvec_fn() returns number of bytes
1439 * it can accept at this offset

--- 1506 unchanged lines hidden ---
1442 (sector_t) BIO_MAX_SECTORS);
1443 max_size = (max_sectors << SECTOR_SHIFT) - bvm->bi_size;
1444 if (max_size < 0)
1445 max_size = 0;
1446
1447 /*
1448 * merge_bvec_fn() returns number of bytes
1449 * it can accept at this offset

--- 1506 unchanged lines hidden ---