ctl_backend_block.c (302408) | ctl_backend_block.c (311418) |
---|---|
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 292384 2015-12-16 23:39:27Z markj $"); | 44__FBSDID("$FreeBSD: stable/11/sys/cam/ctl/ctl_backend_block.c 311418 2017-01-05 11:37:46Z 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> --- 143 unchanged lines hidden (view full) --- 196 union ctl_io *io; 197 struct ctl_sg_entry sg_segs[CTLBLK_MAX_SEGS]; 198 struct iovec xiovecs[CTLBLK_MAX_SEGS]; 199 int bio_cmd; 200 int num_segs; 201 int num_bios_sent; 202 int num_bios_done; 203 int send_complete; | 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> --- 143 unchanged lines hidden (view full) --- 196 union ctl_io *io; 197 struct ctl_sg_entry sg_segs[CTLBLK_MAX_SEGS]; 198 struct iovec xiovecs[CTLBLK_MAX_SEGS]; 199 int bio_cmd; 200 int num_segs; 201 int num_bios_sent; 202 int num_bios_done; 203 int send_complete; |
204 int num_errors; | 204 int first_error; 205 uint64_t first_error_offset; |
205 struct bintime ds_t0; 206 devstat_tag_type ds_tag_type; 207 devstat_trans_flags ds_trans_type; 208 uint64_t io_len; 209 uint64_t io_offset; 210 int io_arg; 211 struct ctl_be_block_softc *softc; 212 struct ctl_be_block_lun *lun; --- 268 unchanged lines hidden (view full) --- 481 beio = bio->bio_caller1; 482 be_lun = beio->lun; 483 io = beio->io; 484 485 DPRINTF("entered\n"); 486 487 error = bio->bio_error; 488 mtx_lock(&be_lun->io_lock); | 206 struct bintime ds_t0; 207 devstat_tag_type ds_tag_type; 208 devstat_trans_flags ds_trans_type; 209 uint64_t io_len; 210 uint64_t io_offset; 211 int io_arg; 212 struct ctl_be_block_softc *softc; 213 struct ctl_be_block_lun *lun; --- 268 unchanged lines hidden (view full) --- 482 beio = bio->bio_caller1; 483 be_lun = beio->lun; 484 io = beio->io; 485 486 DPRINTF("entered\n"); 487 488 error = bio->bio_error; 489 mtx_lock(&be_lun->io_lock); |
489 if (error != 0) 490 beio->num_errors++; | 490 if (error != 0 && 491 (beio->first_error == 0 || 492 bio->bio_offset < beio->first_error_offset)) { 493 beio->first_error = error; 494 beio->first_error_offset = bio->bio_offset; 495 } |
491 492 beio->num_bios_done++; 493 494 /* 495 * XXX KDM will this cause WITNESS to complain? Holding a lock 496 * during the free might cause it to complain. 497 */ 498 g_destroy_bio(bio); --- 16 unchanged lines hidden (view full) --- 515 beio->ds_tag_type, beio->ds_trans_type, 516 /*now*/ NULL, /*then*/&beio->ds_t0); 517 mtx_unlock(&be_lun->io_lock); 518 519 /* 520 * If there are any errors from the backing device, we fail the 521 * entire I/O with a medium error. 522 */ | 496 497 beio->num_bios_done++; 498 499 /* 500 * XXX KDM will this cause WITNESS to complain? Holding a lock 501 * during the free might cause it to complain. 502 */ 503 g_destroy_bio(bio); --- 16 unchanged lines hidden (view full) --- 520 beio->ds_tag_type, beio->ds_trans_type, 521 /*now*/ NULL, /*then*/&beio->ds_t0); 522 mtx_unlock(&be_lun->io_lock); 523 524 /* 525 * If there are any errors from the backing device, we fail the 526 * entire I/O with a medium error. 527 */ |
523 if (beio->num_errors > 0) { | 528 error = beio->first_error; 529 if (error != 0) { |
524 if (error == EOPNOTSUPP) { 525 ctl_set_invalid_opcode(&io->scsiio); 526 } else if (error == ENOSPC || error == EDQUOT) { 527 ctl_set_space_alloc_fail(&io->scsiio); 528 } else if (error == EROFS || error == EACCES) { 529 ctl_set_hw_write_protected(&io->scsiio); 530 } else if (beio->bio_cmd == BIO_FLUSH) { 531 /* XXX KDM is there is a better error here? */ --- 2349 unchanged lines hidden --- | 530 if (error == EOPNOTSUPP) { 531 ctl_set_invalid_opcode(&io->scsiio); 532 } else if (error == ENOSPC || error == EDQUOT) { 533 ctl_set_space_alloc_fail(&io->scsiio); 534 } else if (error == EROFS || error == EACCES) { 535 ctl_set_hw_write_protected(&io->scsiio); 536 } else if (beio->bio_cmd == BIO_FLUSH) { 537 /* XXX KDM is there is a better error here? */ --- 2349 unchanged lines hidden --- |