ctl_backend_block.c (312834) | ctl_backend_block.c (313364) |
---|---|
1/*- 2 * Copyright (c) 2003 Silicon Graphics International Corp. 3 * Copyright (c) 2009-2011 Spectra Logic Corporation 4 * Copyright (c) 2012 The FreeBSD Foundation 5 * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Edward Tomasz Napierala --- 27 unchanged lines hidden (view full) --- 36 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $ 37 */ 38/* 39 * CAM Target Layer driver backend for block devices. 40 * 41 * Author: Ken Merry <ken@FreeBSD.org> 42 */ 43#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003 Silicon Graphics International Corp. 3 * Copyright (c) 2009-2011 Spectra Logic Corporation 4 * Copyright (c) 2012 The FreeBSD Foundation 5 * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Edward Tomasz Napierala --- 27 unchanged lines hidden (view full) --- 36 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $ 37 */ 38/* 39 * CAM Target Layer driver backend for block devices. 40 * 41 * Author: Ken Merry <ken@FreeBSD.org> 42 */ 43#include <sys/cdefs.h> |
44__FBSDID("$FreeBSD: stable/11/sys/cam/ctl/ctl_backend_block.c 312834 2017-01-26 20:49:19Z mav $"); | 44__FBSDID("$FreeBSD: stable/11/sys/cam/ctl/ctl_backend_block.c 313364 2017-02-07 01:42:13Z mav $"); |
45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/kernel.h> 49#include <sys/types.h> 50#include <sys/kthread.h> 51#include <sys/bio.h> 52#include <sys/fcntl.h> --- 361 unchanged lines hidden (view full) --- 414 io->scsiio.kern_rel_offset += io->scsiio.kern_data_len; 415 416 /* 417 * We set status at this point for read commands, and write 418 * commands with errors. 419 */ 420 if (io->io_hdr.flags & CTL_FLAG_ABORT) { 421 ; | 45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/kernel.h> 49#include <sys/types.h> 50#include <sys/kthread.h> 51#include <sys/bio.h> 52#include <sys/fcntl.h> --- 361 unchanged lines hidden (view full) --- 414 io->scsiio.kern_rel_offset += io->scsiio.kern_data_len; 415 416 /* 417 * We set status at this point for read commands, and write 418 * commands with errors. 419 */ 420 if (io->io_hdr.flags & CTL_FLAG_ABORT) { 421 ; |
422 } else if ((io->io_hdr.port_status != 0) && 423 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE || 424 (io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) { 425 ctl_set_internal_failure(&io->scsiio, /*sks_valid*/ 1, 426 /*retry_count*/ io->io_hdr.port_status); 427 } else if (io->scsiio.kern_data_resid != 0 && 428 (io->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_OUT && 429 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE || 430 (io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) { 431 ctl_set_invalid_field_ciu(&io->scsiio); |
|
422 } else if ((io->io_hdr.port_status == 0) && 423 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE)) { 424 lbalen = ARGS(beio->io); 425 if (lbalen->flags & CTL_LLF_READ) { 426 ctl_set_success(&io->scsiio); 427 } else if (lbalen->flags & CTL_LLF_COMPARE) { 428 /* We have two data blocks ready for comparison. */ 429 ctl_be_block_compare(io); 430 } | 432 } else if ((io->io_hdr.port_status == 0) && 433 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE)) { 434 lbalen = ARGS(beio->io); 435 if (lbalen->flags & CTL_LLF_READ) { 436 ctl_set_success(&io->scsiio); 437 } else if (lbalen->flags & CTL_LLF_COMPARE) { 438 /* We have two data blocks ready for comparison. */ 439 ctl_be_block_compare(io); 440 } |
431 } else if ((io->io_hdr.port_status != 0) && 432 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE || 433 (io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) { 434 /* 435 * For hardware error sense keys, the sense key 436 * specific value is defined to be a retry count, 437 * but we use it to pass back an internal FETD 438 * error code. XXX KDM Hopefully the FETD is only 439 * using 16 bits for an error code, since that's 440 * all the space we have in the sks field. 441 */ 442 ctl_set_internal_failure(&io->scsiio, 443 /*sks_valid*/ 1, 444 /*retry_count*/ 445 io->io_hdr.port_status); | |
446 } 447 448 /* 449 * If this is a read, or a write with errors, it is done. 450 */ 451 if ((beio->bio_cmd == BIO_READ) 452 || ((io->io_hdr.flags & CTL_FLAG_ABORT) != 0) 453 || ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE)) { --- 1175 unchanged lines hidden (view full) --- 1629 beio->beio_cont = ctl_be_block_next; 1630 io->scsiio.be_move_done = ctl_be_block_move_done; 1631 /* For compare we have separate S/G lists for read and datamove. */ 1632 if (lbalen->flags & CTL_LLF_COMPARE) 1633 io->scsiio.kern_data_ptr = (uint8_t *)&beio->sg_segs[CTLBLK_HALF_SEGS]; 1634 else 1635 io->scsiio.kern_data_ptr = (uint8_t *)beio->sg_segs; 1636 io->scsiio.kern_data_len = beio->io_len; | 441 } 442 443 /* 444 * If this is a read, or a write with errors, it is done. 445 */ 446 if ((beio->bio_cmd == BIO_READ) 447 || ((io->io_hdr.flags & CTL_FLAG_ABORT) != 0) 448 || ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE)) { --- 1175 unchanged lines hidden (view full) --- 1624 beio->beio_cont = ctl_be_block_next; 1625 io->scsiio.be_move_done = ctl_be_block_move_done; 1626 /* For compare we have separate S/G lists for read and datamove. */ 1627 if (lbalen->flags & CTL_LLF_COMPARE) 1628 io->scsiio.kern_data_ptr = (uint8_t *)&beio->sg_segs[CTLBLK_HALF_SEGS]; 1629 else 1630 io->scsiio.kern_data_ptr = (uint8_t *)beio->sg_segs; 1631 io->scsiio.kern_data_len = beio->io_len; |
1637 io->scsiio.kern_data_resid = 0; | |
1638 io->scsiio.kern_sg_entries = beio->num_segs; 1639 io->io_hdr.flags |= CTL_FLAG_ALLOCATED; 1640 1641 /* 1642 * For the read case, we need to read the data into our buffers and 1643 * then we can send it back to the user. For the write case, we 1644 * need to get the data from the user first. 1645 */ --- 1238 unchanged lines hidden --- | 1632 io->scsiio.kern_sg_entries = beio->num_segs; 1633 io->io_hdr.flags |= CTL_FLAG_ALLOCATED; 1634 1635 /* 1636 * For the read case, we need to read the data into our buffers and 1637 * then we can send it back to the user. For the write case, we 1638 * need to get the data from the user first. 1639 */ --- 1238 unchanged lines hidden --- |