Deleted Added
full compact
ctl_backend_ramdisk.c (288259) ctl_backend_ramdisk.c (288310)
1/*-
2 * Copyright (c) 2003, 2008 Silicon Graphics International Corp.
3 * Copyright (c) 2012 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by Edward Tomasz Napierala
7 * under sponsorship from the FreeBSD Foundation.
8 *

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

35 */
36/*
37 * CAM Target Layer backend for a "fake" ramdisk.
38 *
39 * Author: Ken Merry <ken@FreeBSD.org>
40 */
41
42#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003, 2008 Silicon Graphics International Corp.
3 * Copyright (c) 2012 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by Edward Tomasz Napierala
7 * under sponsorship from the FreeBSD Foundation.
8 *

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

35 */
36/*
37 * CAM Target Layer backend for a "fake" ramdisk.
38 *
39 * Author: Ken Merry <ken@FreeBSD.org>
40 */
41
42#include <sys/cdefs.h>
43__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_backend_ramdisk.c 288259 2015-09-26 11:28:45Z mav $");
43__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_backend_ramdisk.c 288310 2015-09-27 13:47:28Z mav $");
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/kernel.h>
48#include <sys/condvar.h>
49#include <sys/types.h>
50#include <sys/lock.h>
51#include <sys/mutex.h>

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

525 cbe_lun->flags = 0;
526 value = ctl_get_opt(&cbe_lun->options, "ha_role");
527 if (value != NULL) {
528 if (strcmp(value, "primary") == 0)
529 cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY;
530 } else if (control_softc->flags & CTL_FLAG_ACTIVE_SHELF)
531 cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY;
532
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/kernel.h>
48#include <sys/condvar.h>
49#include <sys/types.h>
50#include <sys/lock.h>
51#include <sys/mutex.h>

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

525 cbe_lun->flags = 0;
526 value = ctl_get_opt(&cbe_lun->options, "ha_role");
527 if (value != NULL) {
528 if (strcmp(value, "primary") == 0)
529 cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY;
530 } else if (control_softc->flags & CTL_FLAG_ACTIVE_SHELF)
531 cbe_lun->flags |= CTL_LUN_FLAG_PRIMARY;
532
533 if (cbe_lun->lun_type == T_DIRECT) {
533 if (cbe_lun->lun_type == T_DIRECT ||
534 cbe_lun->lun_type == T_CDROM) {
534 if (params->blocksize_bytes != 0)
535 cbe_lun->blocksize = params->blocksize_bytes;
535 if (params->blocksize_bytes != 0)
536 cbe_lun->blocksize = params->blocksize_bytes;
537 else if (cbe_lun->lun_type == T_CDROM)
538 cbe_lun->blocksize = 2048;
536 else
537 cbe_lun->blocksize = 512;
538 if (params->lun_size_bytes < cbe_lun->blocksize) {
539 snprintf(req->error_str, sizeof(req->error_str),
540 "%s: LUN size %ju < blocksize %u", __func__,
541 params->lun_size_bytes, cbe_lun->blocksize);
542 goto bailout_error;
543 }

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

551 /* Tell the user the blocksize we ended up using */
552 params->blocksize_bytes = cbe_lun->blocksize;
553 params->lun_size_bytes = be_lun->size_bytes;
554
555 value = ctl_get_opt(&cbe_lun->options, "unmap");
556 if (value != NULL && strcmp(value, "on") == 0)
557 cbe_lun->flags |= CTL_LUN_FLAG_UNMAP;
558 value = ctl_get_opt(&cbe_lun->options, "readonly");
539 else
540 cbe_lun->blocksize = 512;
541 if (params->lun_size_bytes < cbe_lun->blocksize) {
542 snprintf(req->error_str, sizeof(req->error_str),
543 "%s: LUN size %ju < blocksize %u", __func__,
544 params->lun_size_bytes, cbe_lun->blocksize);
545 goto bailout_error;
546 }

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

554 /* Tell the user the blocksize we ended up using */
555 params->blocksize_bytes = cbe_lun->blocksize;
556 params->lun_size_bytes = be_lun->size_bytes;
557
558 value = ctl_get_opt(&cbe_lun->options, "unmap");
559 if (value != NULL && strcmp(value, "on") == 0)
560 cbe_lun->flags |= CTL_LUN_FLAG_UNMAP;
561 value = ctl_get_opt(&cbe_lun->options, "readonly");
559 if (value != NULL && strcmp(value, "on") == 0)
562 if (value != NULL) {
563 if (strcmp(value, "on") == 0)
564 cbe_lun->flags |= CTL_LUN_FLAG_READONLY;
565 } else if (cbe_lun->lun_type != T_DIRECT)
560 cbe_lun->flags |= CTL_LUN_FLAG_READONLY;
561 cbe_lun->serseq = CTL_LUN_SERSEQ_OFF;
562 value = ctl_get_opt(&cbe_lun->options, "serseq");
563 if (value != NULL && strcmp(value, "on") == 0)
564 cbe_lun->serseq = CTL_LUN_SERSEQ_ON;
565 else if (value != NULL && strcmp(value, "read") == 0)
566 cbe_lun->serseq = CTL_LUN_SERSEQ_READ;
567 else if (value != NULL && strcmp(value, "off") == 0)

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

891 /*retry_count*/ 0xf051);
892 retval = CTL_RETVAL_COMPLETE;
893 } else {
894 ctl_set_success(&io->scsiio);
895 }
896 ctl_config_write_done(io);
897 break;
898 }
566 cbe_lun->flags |= CTL_LUN_FLAG_READONLY;
567 cbe_lun->serseq = CTL_LUN_SERSEQ_OFF;
568 value = ctl_get_opt(&cbe_lun->options, "serseq");
569 if (value != NULL && strcmp(value, "on") == 0)
570 cbe_lun->serseq = CTL_LUN_SERSEQ_ON;
571 else if (value != NULL && strcmp(value, "read") == 0)
572 cbe_lun->serseq = CTL_LUN_SERSEQ_READ;
573 else if (value != NULL && strcmp(value, "off") == 0)

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

897 /*retry_count*/ 0xf051);
898 retval = CTL_RETVAL_COMPLETE;
899 } else {
900 ctl_set_success(&io->scsiio);
901 }
902 ctl_config_write_done(io);
903 break;
904 }
905 case PREVENT_ALLOW:
899 case WRITE_SAME_10:
900 case WRITE_SAME_16:
901 case UNMAP:
902 ctl_set_success(&io->scsiio);
903 ctl_config_write_done(io);
904 break;
905 default:
906 ctl_set_invalid_opcode(&io->scsiio);

--- 39 unchanged lines hidden ---
906 case WRITE_SAME_10:
907 case WRITE_SAME_16:
908 case UNMAP:
909 ctl_set_success(&io->scsiio);
910 ctl_config_write_done(io);
911 break;
912 default:
913 ctl_set_invalid_opcode(&io->scsiio);

--- 39 unchanged lines hidden ---