From owner-svn-src-all@FreeBSD.ORG Mon Sep 7 23:16:27 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EBED81065672; Mon, 7 Sep 2009 23:16:27 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C0A7A8FC0A; Mon, 7 Sep 2009 23:16:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n87NGRIm029453; Mon, 7 Sep 2009 23:16:27 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n87NGRRm029450; Mon, 7 Sep 2009 23:16:27 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <200909072316.n87NGRRm029450@svn.freebsd.org> From: Sean Bruno Date: Mon, 7 Sep 2009 23:16:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196955 - head/share/examples/scsi_target X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2009 23:16:28 -0000 Author: sbruno Date: Mon Sep 7 23:16:27 2009 New Revision: 196955 URL: http://svn.freebsd.org/changeset/base/196955 Log: A few enhancements I made while working on the Firewire target (sbp_targ). Update the error handling in a couple of cases to exit gracefully if certain mandatory conditions aren't met. Reduce the maximum number of initiators to 8 for this example code. While 1024 is more correct, this example code would act like it was stalled out even though it was merely allocating the needed structures in init_ccbs() Reviewed by: scottl@freebsd.org Modified: head/share/examples/scsi_target/scsi_target.c head/share/examples/scsi_target/scsi_target.h Modified: head/share/examples/scsi_target/scsi_target.c ============================================================================== --- head/share/examples/scsi_target/scsi_target.c Mon Sep 7 21:58:54 2009 (r196954) +++ head/share/examples/scsi_target/scsi_target.c Mon Sep 7 23:16:27 2009 (r196955) @@ -226,7 +226,7 @@ main(int argc, char *argv[]) /* Open backing store for IO */ file_fd = open(file_name, O_RDWR); if (file_fd < 0) - err(1, "open backing store file"); + errx(EX_NOINPUT, "open backing store file"); /* Check backing store size or use the size user gave us */ if (user_size == 0) { @@ -291,7 +291,9 @@ main(int argc, char *argv[]) } while (targ_fd < 0 && errno == EBUSY); if (targ_fd < 0) - err(1, "Tried to open %d devices, none available", unit); + errx(1, "Tried to open %d devices, none available", unit); + else + warnx("opened /dev/targ%d", unit); /* The first three are handled by kevent() later */ signal(SIGHUP, SIG_IGN); @@ -318,6 +320,7 @@ main(int argc, char *argv[]) /* Set up inquiry data according to what SIM supports */ if (get_sim_flags(&sim_flags) != CAM_REQ_CMP) errx(1, "get_sim_flags"); + if (tcmd_init(req_flags, sim_flags) != 0) errx(1, "Initializing tcmd subsystem failed"); @@ -327,6 +330,7 @@ main(int argc, char *argv[]) if (debug) warnx("main loop beginning"); + request_loop(); exit(0); Modified: head/share/examples/scsi_target/scsi_target.h ============================================================================== --- head/share/examples/scsi_target/scsi_target.h Mon Sep 7 21:58:54 2009 (r196954) +++ head/share/examples/scsi_target/scsi_target.h Mon Sep 7 23:16:27 2009 (r196955) @@ -35,7 +35,7 @@ * Maximum number of parallel commands to accept, * 1024 for Fibre Channel (SPI is 16). */ -#define MAX_INITIATORS 1024 +#define MAX_INITIATORS 8 #define SECTOR_SIZE 512 #define MAX_EVENTS (MAX_INITIATORS + 5) /* kqueue for AIO, signals */