Deleted Added
full compact
ctl_backend_block.c (287760) ctl_backend_block.c (287868)
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 * All rights reserved.
6 *
7 * Portions of this software were developed by Edward Tomasz Napierala
8 * under sponsorship from the FreeBSD Foundation.

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

35 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $
36 */
37/*
38 * CAM Target Layer driver backend for block devices.
39 *
40 * Author: Ken Merry <ken@FreeBSD.org>
41 */
42#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 * All rights reserved.
6 *
7 * Portions of this software were developed by Edward Tomasz Napierala
8 * under sponsorship from the FreeBSD Foundation.

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

35 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $
36 */
37/*
38 * CAM Target Layer driver backend for block devices.
39 *
40 * Author: Ken Merry <ken@FreeBSD.org>
41 */
42#include <sys/cdefs.h>
43__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_backend_block.c 287760 2015-09-13 16:49:41Z mav $");
43__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_backend_block.c 287868 2015-09-16 18:33:04Z mav $");
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/kernel.h>
48#include <sys/types.h>
49#include <sys/kthread.h>
50#include <sys/bio.h>
51#include <sys/fcntl.h>

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

346 if (beio->beio_cont != NULL) {
347 beio->beio_cont(beio);
348 } else {
349 ctl_free_beio(beio);
350 ctl_data_submit_done(io);
351 }
352}
353
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/kernel.h>
48#include <sys/types.h>
49#include <sys/kthread.h>
50#include <sys/bio.h>
51#include <sys/fcntl.h>

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

346 if (beio->beio_cont != NULL) {
347 beio->beio_cont(beio);
348 } else {
349 ctl_free_beio(beio);
350 ctl_data_submit_done(io);
351 }
352}
353
354static size_t
355cmp(uint8_t *a, uint8_t *b, size_t size)
356{
357 size_t i;
358
359 for (i = 0; i < size; i++) {
360 if (a[i] != b[i])
361 break;
362 }
363 return (i);
364}
365
366static void
367ctl_be_block_compare(union ctl_io *io)
368{
369 struct ctl_be_block_io *beio;
370 uint64_t off, res;
371 int i;
372 uint8_t info[8];
373
374 beio = (struct ctl_be_block_io *)PRIV(io)->ptr;
375 off = 0;
376 for (i = 0; i < beio->num_segs; i++) {
377 res = cmp(beio->sg_segs[i].addr,
378 beio->sg_segs[i + CTLBLK_HALF_SEGS].addr,
379 beio->sg_segs[i].len);
380 off += res;
381 if (res < beio->sg_segs[i].len)
382 break;
383 }
384 if (i < beio->num_segs) {
385 scsi_u64to8b(off, info);
386 ctl_set_sense(&io->scsiio, /*current_error*/ 1,
387 /*sense_key*/ SSD_KEY_MISCOMPARE,
388 /*asc*/ 0x1D, /*ascq*/ 0x00,
389 /*type*/ SSD_ELEM_INFO,
390 /*size*/ sizeof(info), /*data*/ &info,
391 /*type*/ SSD_ELEM_NONE);
392 } else
393 ctl_set_success(&io->scsiio);
394}
395
354static int
355ctl_be_block_move_done(union ctl_io *io)
356{
357 struct ctl_be_block_io *beio;
358 struct ctl_be_block_lun *be_lun;
359 struct ctl_lba_len_flags *lbalen;
360#ifdef CTL_TIME_IO
361 struct bintime cur_bt;
362#endif
396static int
397ctl_be_block_move_done(union ctl_io *io)
398{
399 struct ctl_be_block_io *beio;
400 struct ctl_be_block_lun *be_lun;
401 struct ctl_lba_len_flags *lbalen;
402#ifdef CTL_TIME_IO
403 struct bintime cur_bt;
404#endif
363 int i;
364
365 beio = (struct ctl_be_block_io *)PRIV(io)->ptr;
366 be_lun = beio->lun;
367
368 DPRINTF("entered\n");
369
370#ifdef CTL_TIME_IO
371 getbintime(&cur_bt);

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

383 ;
384 } else if ((io->io_hdr.port_status == 0) &&
385 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE)) {
386 lbalen = ARGS(beio->io);
387 if (lbalen->flags & CTL_LLF_READ) {
388 ctl_set_success(&io->scsiio);
389 } else if (lbalen->flags & CTL_LLF_COMPARE) {
390 /* We have two data blocks ready for comparison. */
405
406 beio = (struct ctl_be_block_io *)PRIV(io)->ptr;
407 be_lun = beio->lun;
408
409 DPRINTF("entered\n");
410
411#ifdef CTL_TIME_IO
412 getbintime(&cur_bt);

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

424 ;
425 } else if ((io->io_hdr.port_status == 0) &&
426 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE)) {
427 lbalen = ARGS(beio->io);
428 if (lbalen->flags & CTL_LLF_READ) {
429 ctl_set_success(&io->scsiio);
430 } else if (lbalen->flags & CTL_LLF_COMPARE) {
431 /* We have two data blocks ready for comparison. */
391 for (i = 0; i < beio->num_segs; i++) {
392 if (memcmp(beio->sg_segs[i].addr,
393 beio->sg_segs[i + CTLBLK_HALF_SEGS].addr,
394 beio->sg_segs[i].len) != 0)
395 break;
396 }
397 if (i < beio->num_segs)
398 ctl_set_sense(&io->scsiio,
399 /*current_error*/ 1,
400 /*sense_key*/ SSD_KEY_MISCOMPARE,
401 /*asc*/ 0x1D,
402 /*ascq*/ 0x00,
403 SSD_ELEM_NONE);
404 else
405 ctl_set_success(&io->scsiio);
432 ctl_be_block_compare(io);
406 }
407 } else if ((io->io_hdr.port_status != 0) &&
408 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE ||
409 (io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) {
410 /*
411 * For hardware error sense keys, the sense key
412 * specific value is defined to be a retry count,
413 * but we use it to pass back an internal FETD

--- 2532 unchanged lines hidden ---
433 }
434 } else if ((io->io_hdr.port_status != 0) &&
435 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE ||
436 (io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) {
437 /*
438 * For hardware error sense keys, the sense key
439 * specific value is defined to be a retry count,
440 * but we use it to pass back an internal FETD

--- 2532 unchanged lines hidden ---