tgt/tgt-git-update

1362 lines
41 KiB
Plaintext

diff -purN tgt-r849/.git/config ../git/tgt/.git/config
--- tgt-r849/.git/config 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/config 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,3 @@
+[core]
+ repositoryformatversion = 0
+ filemode = true
diff -purN tgt-r849/.git/description ../git/tgt/.git/description
--- tgt-r849/.git/description 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/description 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1 @@
+Unnamed repository; edit this file to name it for gitweb.
diff -purN tgt-r849/.git/HEAD ../git/tgt/.git/HEAD
--- tgt-r849/.git/HEAD 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/HEAD 2007-04-03 15:02:25.000000000 +0200
@@ -0,0 +1 @@
+ref: refs/heads/master
diff -purN tgt-r849/.git/hooks/applypatch-msg ../git/tgt/.git/hooks/applypatch-msg
--- tgt-r849/.git/hooks/applypatch-msg 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/hooks/applypatch-msg 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# An example hook script to check the commit log message taken by
+# applypatch from an e-mail message.
+#
+# The hook should exit with non-zero status after issuing an
+# appropriate message if it wants to stop the commit. The hook is
+# allowed to edit the commit message file.
+#
+# To enable this hook, make this file executable.
+
+. git-sh-setup
+test -x "$GIT_DIR/hooks/commit-msg" &&
+ exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
+:
diff -purN tgt-r849/.git/hooks/commit-msg ../git/tgt/.git/hooks/commit-msg
--- tgt-r849/.git/hooks/commit-msg 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/hooks/commit-msg 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# An example hook script to check the commit log message.
+# Called by git-commit with one argument, the name of the file
+# that has the commit message. The hook should exit with non-zero
+# status after issuing an appropriate message if it wants to stop the
+# commit. The hook is allowed to edit the commit message file.
+#
+# To enable this hook, make this file executable.
+
+# This example catches duplicate Signed-off-by lines.
+
+test "" = "$(grep '^Signed-off-by: ' "$1" |
+ sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
+ echo >&2 Duplicate Signed-off-by lines.
+ exit 1
+}
+
diff -purN tgt-r849/.git/hooks/post-commit ../git/tgt/.git/hooks/post-commit
--- tgt-r849/.git/hooks/post-commit 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/hooks/post-commit 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# An example hook script that is called after a successful
+# commit is made.
+#
+# To enable this hook, make this file executable.
+
+: Nothing
diff -purN tgt-r849/.git/hooks/post-update ../git/tgt/.git/hooks/post-update
--- tgt-r849/.git/hooks/post-update 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/hooks/post-update 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# An example hook script to prepare a packed repository for use over
+# dumb transports.
+#
+# To enable this hook, make this file executable by "chmod +x post-update".
+
+exec git-update-server-info
diff -purN tgt-r849/.git/hooks/pre-applypatch ../git/tgt/.git/hooks/pre-applypatch
--- tgt-r849/.git/hooks/pre-applypatch 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/hooks/pre-applypatch 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed
+# by applypatch from an e-mail message.
+#
+# The hook should exit with non-zero status after issuing an
+# appropriate message if it wants to stop the commit.
+#
+# To enable this hook, make this file executable.
+
+. git-sh-setup
+test -x "$GIT_DIR/hooks/pre-commit" &&
+ exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
+:
+
diff -purN tgt-r849/.git/hooks/pre-commit ../git/tgt/.git/hooks/pre-commit
--- tgt-r849/.git/hooks/pre-commit 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/hooks/pre-commit 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed.
+# Called by git-commit with no arguments. The hook should
+# exit with non-zero status after issuing an appropriate message if
+# it wants to stop the commit.
+#
+# To enable this hook, make this file executable.
+
+# This is slightly modified from Andrew Morton's Perfect Patch.
+# Lines you introduce should not have trailing whitespace.
+# Also check for an indentation that has SP before a TAB.
+
+if git-rev-parse --verify HEAD 2>/dev/null
+then
+ git-diff-index -p -M --cached HEAD
+else
+ # NEEDSWORK: we should produce a diff with an empty tree here
+ # if we want to do the same verification for the initial import.
+ :
+fi |
+perl -e '
+ my $found_bad = 0;
+ my $filename;
+ my $reported_filename = "";
+ my $lineno;
+ sub bad_line {
+ my ($why, $line) = @_;
+ if (!$found_bad) {
+ print STDERR "*\n";
+ print STDERR "* You have some suspicious patch lines:\n";
+ print STDERR "*\n";
+ $found_bad = 1;
+ }
+ if ($reported_filename ne $filename) {
+ print STDERR "* In $filename\n";
+ $reported_filename = $filename;
+ }
+ print STDERR "* $why (line $lineno)\n";
+ print STDERR "$filename:$lineno:$line\n";
+ }
+ while (<>) {
+ if (m|^diff --git a/(.*) b/\1$|) {
+ $filename = $1;
+ next;
+ }
+ if (/^@@ -\S+ \+(\d+)/) {
+ $lineno = $1 - 1;
+ next;
+ }
+ if (/^ /) {
+ $lineno++;
+ next;
+ }
+ if (s/^\+//) {
+ $lineno++;
+ chomp;
+ if (/\s$/) {
+ bad_line("trailing whitespace", $_);
+ }
+ if (/^\s* /) {
+ bad_line("indent SP followed by a TAB", $_);
+ }
+ if (/^(?:[<>=]){7}/) {
+ bad_line("unresolved merge conflict", $_);
+ }
+ }
+ }
+ exit($found_bad);
+'
+
diff -purN tgt-r849/.git/hooks/pre-rebase ../git/tgt/.git/hooks/pre-rebase
--- tgt-r849/.git/hooks/pre-rebase 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/hooks/pre-rebase 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,150 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Junio C Hamano
+#
+
+publish=next
+basebranch="$1"
+if test "$#" = 2
+then
+ topic="refs/heads/$2"
+else
+ topic=`git symbolic-ref HEAD`
+fi
+
+case "$basebranch,$topic" in
+master,refs/heads/??/*)
+ ;;
+*)
+ exit 0 ;# we do not interrupt others.
+ ;;
+esac
+
+# Now we are dealing with a topic branch being rebased
+# on top of master. Is it OK to rebase it?
+
+# Is topic fully merged to master?
+not_in_master=`git-rev-list --pretty=oneline ^master "$topic"`
+if test -z "$not_in_master"
+then
+ echo >&2 "$topic is fully merged to master; better remove it."
+ exit 1 ;# we could allow it, but there is no point.
+fi
+
+# Is topic ever merged to next? If so you should not be rebasing it.
+only_next_1=`git-rev-list ^master "^$topic" ${publish} | sort`
+only_next_2=`git-rev-list ^master ${publish} | sort`
+if test "$only_next_1" = "$only_next_2"
+then
+ not_in_topic=`git-rev-list "^$topic" master`
+ if test -z "$not_in_topic"
+ then
+ echo >&2 "$topic is already up-to-date with master"
+ exit 1 ;# we could allow it, but there is no point.
+ else
+ exit 0
+ fi
+else
+ not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"`
+ perl -e '
+ my $topic = $ARGV[0];
+ my $msg = "* $topic has commits already merged to public branch:\n";
+ my (%not_in_next) = map {
+ /^([0-9a-f]+) /;
+ ($1 => 1);
+ } split(/\n/, $ARGV[1]);
+ for my $elem (map {
+ /^([0-9a-f]+) (.*)$/;
+ [$1 => $2];
+ } split(/\n/, $ARGV[2])) {
+ if (!exists $not_in_next{$elem->[0]}) {
+ if ($msg) {
+ print STDERR $msg;
+ undef $msg;
+ }
+ print STDERR " $elem->[1]\n";
+ }
+ }
+ ' "$topic" "$not_in_next" "$not_in_master"
+ exit 1
+fi
+
+exit 0
+
+################################################################
+
+This sample hook safeguards topic branches that have been
+published from being rewound.
+
+The workflow assumed here is:
+
+ * Once a topic branch forks from "master", "master" is never
+ merged into it again (either directly or indirectly).
+
+ * Once a topic branch is fully cooked and merged into "master",
+ it is deleted. If you need to build on top of it to correct
+ earlier mistakes, a new topic branch is created by forking at
+ the tip of the "master". This is not strictly necessary, but
+ it makes it easier to keep your history simple.
+
+ * Whenever you need to test or publish your changes to topic
+ branches, merge them into "next" branch.
+
+The script, being an example, hardcodes the publish branch name
+to be "next", but it is trivial to make it configurable via
+$GIT_DIR/config mechanism.
+
+With this workflow, you would want to know:
+
+(1) ... if a topic branch has ever been merged to "next". Young
+ topic branches can have stupid mistakes you would rather
+ clean up before publishing, and things that have not been
+ merged into other branches can be easily rebased without
+ affecting other people. But once it is published, you would
+ not want to rewind it.
+
+(2) ... if a topic branch has been fully merged to "master".
+ Then you can delete it. More importantly, you should not
+ build on top of it -- other people may already want to
+ change things related to the topic as patches against your
+ "master", so if you need further changes, it is better to
+ fork the topic (perhaps with the same name) afresh from the
+ tip of "master".
+
+Let's look at this example:
+
+ o---o---o---o---o---o---o---o---o---o "next"
+ / / / /
+ / a---a---b A / /
+ / / / /
+ / / c---c---c---c B /
+ / / / \ /
+ / / / b---b C \ /
+ / / / / \ /
+ ---o---o---o---o---o---o---o---o---o---o---o "master"
+
+
+A, B and C are topic branches.
+
+ * A has one fix since it was merged up to "next".
+
+ * B has finished. It has been fully merged up to "master" and "next",
+ and is ready to be deleted.
+
+ * C has not merged to "next" at all.
+
+We would want to allow C to be rebased, refuse A, and encourage
+B to be deleted.
+
+To compute (1):
+
+ git-rev-list ^master ^topic next
+ git-rev-list ^master next
+
+ if these match, topic has not merged in next at all.
+
+To compute (2):
+
+ git-rev-list master..topic
+
+ if this is empty, it is fully merged to "master".
diff -purN tgt-r849/.git/hooks/update ../git/tgt/.git/hooks/update
--- tgt-r849/.git/hooks/update 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/hooks/update 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,89 @@
+#!/bin/sh
+#
+# An example hook script to mail out commit update information.
+# It also blocks tags that aren't annotated.
+# Called by git-receive-pack with arguments: refname sha1-old sha1-new
+#
+# To enable this hook:
+# (1) change the recipient e-mail address
+# (2) make this file executable by "chmod +x update".
+#
+
+project=$(cat $GIT_DIR/description)
+recipients="commit-list@somewhere.com commit-list@somewhereelse.com"
+
+ref_type=$(git cat-file -t "$3")
+
+# Only allow annotated tags in a shared repo
+# Remove this code to treat dumb tags the same as everything else
+case "$1","$ref_type" in
+refs/tags/*,commit)
+ echo "*** Un-annotated tags are not allowed in this repo" >&2
+ echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate."
+ exit 1;;
+refs/tags/*,tag)
+ echo "### Pushing version '${1##refs/tags/}' to the masses" >&2
+ # recipients="release-announce@somwehere.com announce@somewhereelse.com"
+ ;;
+esac
+
+# set this to 'cat' to get a very detailed listing.
+# short only kicks in when an annotated tag is added
+short='git shortlog'
+
+# see 'date --help' for info on how to write this
+# The default is a human-readable iso8601-like format with minute
+# precision ('2006-01-25 15:58 +0100' for example)
+date_format="%F %R %z"
+
+(if expr "$2" : '0*$' >/dev/null
+then
+ # new ref
+ case "$1" in
+ refs/tags/*)
+ # a pushed and annotated tag (usually) means a new version
+ tag="${1##refs/tags/}"
+ if [ "$ref_type" = tag ]; then
+ eval $(git cat-file tag $3 | \
+ sed -n '4s/tagger \([^>]*>\)[^0-9]*\([0-9]*\).*/tagger="\1" ts="\2"/p')
+ date=$(date --date="1970-01-01 00:00:00 $ts seconds" +"$date_format")
+ echo "Tag '$tag' created by $tagger at $date"
+ git cat-file tag $3 | sed -n '5,$p'
+ echo
+ fi
+ prev=$(git describe "$3^" | sed 's/-g.*//')
+ # the first tag in a repo will yield no $prev
+ if [ -z "$prev" ]; then
+ echo "Changes since the dawn of time:"
+ git rev-list --pretty $3 | $short
+ else
+ echo "Changes since $prev:"
+ git rev-list --pretty $prev..$3 | $short
+ echo ---
+ git diff --stat $prev..$3
+ echo ---
+ fi
+ ;;
+
+ refs/heads/*)
+ branch="${1##refs/heads/}"
+ echo "New branch '$branch' available with the following commits:"
+ git-rev-list --pretty "$3" $(git-rev-parse --not --all)
+ ;;
+ esac
+else
+ base=$(git-merge-base "$2" "$3")
+ case "$base" in
+ "$2")
+ git diff --stat "$3" "^$base"
+ echo
+ echo "New commits:"
+ ;;
+ *)
+ echo "Rebased ref, commits from common ancestor:"
+ ;;
+ esac
+ git-rev-list --pretty "$3" "^$base"
+fi) |
+mail -s "$project: Changes to '${1##refs/heads/}'" $recipients
+exit 0
Files tgt-r849/.git/index and ../git/tgt/.git/index differ
diff -purN tgt-r849/.git/info/exclude ../git/tgt/.git/info/exclude
--- tgt-r849/.git/info/exclude 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/info/exclude 2007-04-03 15:02:21.000000000 +0200
@@ -0,0 +1,6 @@
+# git-ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
Files tgt-r849/.git/objects/pack/pack-9a9a5f56366f6b0d7dd377fa1e6605953b356ae4.idx and ../git/tgt/.git/objects/pack/pack-9a9a5f56366f6b0d7dd377fa1e6605953b356ae4.idx differ
Files tgt-r849/.git/objects/pack/pack-9a9a5f56366f6b0d7dd377fa1e6605953b356ae4.pack and ../git/tgt/.git/objects/pack/pack-9a9a5f56366f6b0d7dd377fa1e6605953b356ae4.pack differ
diff -purN tgt-r849/.git/refs/heads/master ../git/tgt/.git/refs/heads/master
--- tgt-r849/.git/refs/heads/master 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/refs/heads/master 2007-04-03 15:02:25.000000000 +0200
@@ -0,0 +1 @@
+4ae01ba345c5593f5cdfc3d1ec1f35a605708ad4
diff -purN tgt-r849/.git/refs/heads/origin ../git/tgt/.git/refs/heads/origin
--- tgt-r849/.git/refs/heads/origin 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/refs/heads/origin 2007-04-03 15:02:25.000000000 +0200
@@ -0,0 +1 @@
+4ae01ba345c5593f5cdfc3d1ec1f35a605708ad4
diff -purN tgt-r849/.git/remotes/origin ../git/tgt/.git/remotes/origin
--- tgt-r849/.git/remotes/origin 1970-01-01 01:00:00.000000000 +0100
+++ ../git/tgt/.git/remotes/origin 2007-04-03 15:02:25.000000000 +0200
@@ -0,0 +1,2 @@
+URL: git://git.kernel.org/pub/scm/linux/kernel/git/tomo/tgt.git
+Pull: refs/heads/master:refs/heads/origin
diff -purN tgt-r849/usr/bs_aio.c ../git/tgt/usr/bs_aio.c
--- tgt-r849/usr/bs_aio.c 2007-03-18 05:10:23.944393000 +0100
+++ ../git/tgt/usr/bs_aio.c 2007-04-03 15:02:25.000000000 +0200
@@ -115,11 +115,11 @@ static void bs_aio_handler(int fd, int e
}
static int
-bs_aio_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size)
+bs_aio_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size)
{
int ret;
struct bs_aio_info *info =
- (struct bs_aio_info *) ((char *)dev + sizeof(*dev));
+ (struct bs_aio_info *) ((char *)lu + sizeof(*lu));
*fd = backed_file_open(path, O_RDWR| O_LARGEFILE, size);
if (*fd < 0)
@@ -166,36 +166,36 @@ close_dev_fd:
return -1;
}
-static void bs_aio_close(struct tgt_device *dev)
+static void bs_aio_close(struct scsi_lu *lu)
{
struct bs_aio_info *info;
- info = (struct bs_aio_info *) ((char *)dev + sizeof(*dev));
+ info = (struct bs_aio_info *) ((char *)lu + sizeof(*lu));
pthread_cancel(info->aio_thread);
pthread_join(info->aio_thread, NULL);
io_destroy(info->ctx);
- close(dev->fd);
+ close(lu->fd);
}
static int bs_aio_cmd_submit(struct scsi_cmd *cmd)
{
- struct tgt_device *dev = cmd->dev;
- struct bs_aio_info *info = (struct bs_aio_info *)((char *)dev + sizeof(*dev));
+ struct scsi_lu *lu = cmd->dev;
+ struct bs_aio_info *info = (struct bs_aio_info *)((char *)lu + sizeof(*lu));
struct iocb iocb, *io;
int ret;
io = &iocb;
memset(io, 0, sizeof(*io));
- dprintf("%d %d %u %" PRIx64 " %" PRIx64 " %p\n", dev->fd, cmd->rw, cmd->len,
+ dprintf("%d %d %u %" PRIx64 " %" PRIx64 " %p\n", lu->fd, cmd->rw, cmd->len,
cmd->uaddr, cmd->offset, cmd);
if (cmd->rw == READ)
- io_prep_pread(io, dev->fd, (void *)(unsigned long)cmd->uaddr,
+ io_prep_pread(io, lu->fd, (void *)(unsigned long)cmd->uaddr,
cmd->len, cmd->offset);
else
- io_prep_pwrite(io, dev->fd, (void *)(unsigned long)cmd->uaddr,
+ io_prep_pwrite(io, lu->fd, (void *)(unsigned long)cmd->uaddr,
cmd->len, cmd->offset);
io->data = cmd;
@@ -205,7 +205,7 @@ static int bs_aio_cmd_submit(struct scsi
cmd->async = 1;
return 0;
} else {
- dprintf("%d %d %u %" PRIx64 " %" PRIx64 " %p\n", dev->fd, cmd->rw, cmd->len,
+ dprintf("%d %d %u %" PRIx64 " %" PRIx64 " %p\n", lu->fd, cmd->rw, cmd->len,
cmd->uaddr, cmd->offset, cmd);
return 1;
}
diff -purN tgt-r849/usr/bs_mmap.c ../git/tgt/usr/bs_mmap.c
--- tgt-r849/usr/bs_mmap.c 2007-03-18 05:10:23.944393000 +0100
+++ ../git/tgt/usr/bs_mmap.c 2007-04-03 15:02:25.000000000 +0200
@@ -32,16 +32,16 @@
#include "util.h"
#include "tgtd.h"
-static int bs_mmap_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size)
+static int bs_mmap_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size)
{
*fd = backed_file_open(path, O_RDWR| O_LARGEFILE, size);
return *fd >= 0 ? 0 : *fd;
}
-static void bs_mmap_close(struct tgt_device *dev)
+static void bs_mmap_close(struct scsi_lu *lu)
{
- close(dev->fd);
+ close(lu->fd);
}
#define pgcnt(size, offset) ((((size) + ((offset) & (pagesize - 1))) + (pagesize - 1)) >> pageshift)
diff -purN tgt-r849/usr/bs_xen.c ../git/tgt/usr/bs_xen.c
--- tgt-r849/usr/bs_xen.c 2007-03-18 05:10:23.944393000 +0100
+++ ../git/tgt/usr/bs_xen.c 2007-04-03 15:02:25.000000000 +0200
@@ -37,22 +37,22 @@
#define O_DIRECT 040000 /* who defines this?*/
-static int bs_xen_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size)
+static int bs_xen_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size)
{
*fd = backed_file_open(path, O_RDWR| O_LARGEFILE | O_DIRECT, size);
return *fd >= 0 ? 0 : *fd;
}
-static void bs_xen_close(struct tgt_device *dev)
+static void bs_xen_close(struct scsi_lu *lu)
{
- close(dev->fd);
+ close(lu->fd);
}
/*
* Replace this with AIO readv/writev after 2.6.20.
*/
-static int bs_xen_cmd_submit(struct tgt_device *dev, uint8_t *scb, int rw,
+static int bs_xen_cmd_submit(struct scsi_lu *lu, uint8_t *scb, int rw,
uint32_t datalen, unsigned long *uaddr,
uint64_t offset, int *async, void *key)
{
@@ -65,12 +65,12 @@ static int bs_xen_cmd_submit(struct tgt_
total += iov[cnt++].iov_len;
} while (total < datalen);
- lseek64(dev->fd, offset, SEEK_SET);
+ lseek64(lu->fd, offset, SEEK_SET);
if (rw == READ)
- readv(dev->fd, iov, cnt);
+ readv(lu->fd, iov, cnt);
else
- writev(dev->fd, iov, cnt);
+ writev(lu->fd, iov, cnt);
return 0;
}
diff -purN tgt-r849/usr/ibmvio/ibmvio.c ../git/tgt/usr/ibmvio/ibmvio.c
--- tgt-r849/usr/ibmvio/ibmvio.c 2007-03-18 05:10:23.944393000 +0100
+++ ../git/tgt/usr/ibmvio/ibmvio.c 2007-04-03 15:02:25.000000000 +0200
@@ -185,7 +185,7 @@ static uint64_t make_lun(unsigned int bu
static int ibmvio_report_luns(int host_no, struct scsi_cmd *cmd)
{
- struct tgt_device *dev;
+ struct scsi_lu *lu;
struct list_head *dev_list = &cmd->c_target->device_list;
uint64_t lun, *data;
int idx, alen, oalen, nr_luns, rbuflen = 4096;
@@ -219,8 +219,8 @@ static int ibmvio_report_luns(int host_n
idx = 2;
nr_luns = 1;
- list_for_each_entry(dev, dev_list, device_siblings) {
- lun = dev->lun;
+ list_for_each_entry(lu, dev_list, device_siblings) {
+ lun = lu->lun;
lun = make_lun(0, lun & 0x003f, 0);
data[idx++] = __cpu_to_be64(lun);
if (!(alen -= 8))
diff -purN tgt-r849/usr/iscsi/iscsid.c ../git/tgt/usr/iscsi/iscsid.c
--- tgt-r849/usr/iscsi/iscsid.c 2007-03-18 05:10:23.944393000 +0100
+++ ../git/tgt/usr/iscsi/iscsid.c 2007-04-03 15:02:26.000000000 +0200
@@ -740,28 +740,12 @@ static void cmnd_finish(struct iscsi_con
}
}
-static int iscsi_cmd_rsp_build(struct iscsi_task *task)
+static void calc_residual(struct iscsi_cmd_rsp *rsp, struct iscsi_task *task)
{
- struct iscsi_connection *conn = task->conn;
- struct iscsi_cmd_rsp *rsp = (struct iscsi_cmd_rsp *) &conn->rsp.bhs;
- uint32_t residual;
-
- dprintf("%p %x\n", task, task->scmd.scb[0]);
-
- memset(rsp, 0, sizeof(*rsp));
- rsp->opcode = ISCSI_OP_SCSI_CMD_RSP;
- rsp->itt = task->tag;
- rsp->flags = ISCSI_FLAG_CMD_FINAL;
- rsp->response = ISCSI_STATUS_CMD_COMPLETED;
- rsp->cmd_status = task->result;
- rsp->statsn = cpu_to_be32(conn->stat_sn++);
- rsp->exp_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn);
- rsp->max_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn + MAX_QUEUE_CMD);
+ uint32_t residual = 0;
/* we never have write under/over flow, no way to signal that
* back from the target currently. */
-
- residual = 0;
if (task->dir == BIDIRECTIONAL) {
if (task->len < task->read_len) {
rsp->flags |= ISCSI_FLAG_CMD_BIDI_UNDERFLOW;
@@ -782,6 +766,26 @@ static int iscsi_cmd_rsp_build(struct is
}
rsp->residual_count = cpu_to_be32(residual);
}
+}
+
+static int iscsi_cmd_rsp_build(struct iscsi_task *task)
+{
+ struct iscsi_connection *conn = task->conn;
+ struct iscsi_cmd_rsp *rsp = (struct iscsi_cmd_rsp *) &conn->rsp.bhs;
+
+ dprintf("%p %x\n", task, task->scmd.scb[0]);
+
+ memset(rsp, 0, sizeof(*rsp));
+ rsp->opcode = ISCSI_OP_SCSI_CMD_RSP;
+ rsp->itt = task->tag;
+ rsp->flags = ISCSI_FLAG_CMD_FINAL;
+ rsp->response = ISCSI_STATUS_CMD_COMPLETED;
+ rsp->cmd_status = task->result;
+ rsp->statsn = cpu_to_be32(conn->stat_sn++);
+ rsp->exp_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn);
+ rsp->max_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn + MAX_QUEUE_CMD);
+
+ calc_residual(rsp, task);
return 0;
}
@@ -797,7 +801,6 @@ static int iscsi_sense_rsp_build(struct
struct iscsi_cmd_rsp *rsp = (struct iscsi_cmd_rsp *) &conn->rsp.bhs;
struct iscsi_sense_data *sense;
unsigned char sense_len;
- uint32_t residual;
memset(rsp, 0, sizeof(*rsp));
rsp->opcode = ISCSI_OP_SCSI_CMD_RSP;
@@ -809,28 +812,7 @@ static int iscsi_sense_rsp_build(struct
rsp->exp_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn);
rsp->max_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn + MAX_QUEUE_CMD);
- /* XXX: copied from above, consider merging these functions */
- residual = 0;
- if (task->dir == BIDIRECTIONAL) {
- if (task->len < task->read_len) {
- rsp->flags |= ISCSI_FLAG_CMD_BIDI_UNDERFLOW;
- residual = task->read_len - task->len;
- } else if (task->len > task->read_len) {
- rsp->flags |= ISCSI_FLAG_CMD_BIDI_OVERFLOW;
- residual = task->len - task->read_len;
- }
- rsp->bi_residual_count = cpu_to_be32(residual);
- rsp->residual_count = 0;
- } else {
- if (task->len < task->read_len) {
- rsp->flags |= ISCSI_FLAG_CMD_UNDERFLOW;
- residual = task->read_len - task->len;
- } else if (task->len > task->read_len) {
- rsp->flags |= ISCSI_FLAG_CMD_OVERFLOW;
- residual = task->len - task->read_len;
- }
- rsp->residual_count = cpu_to_be32(residual);
- }
+ calc_residual(rsp, task);
sense = (struct iscsi_sense_data *)task->scmd.sense_buffer;
sense_len = task->scmd.sense_len;
@@ -849,9 +831,8 @@ static int iscsi_data_rsp_build(struct i
{
struct iscsi_connection *conn = task->conn;
struct iscsi_data_rsp *rsp = (struct iscsi_data_rsp *) &conn->rsp.bhs;
- int datalen, exp_datalen = task->read_len;
+ int datalen;
int max_burst = conn->session_param[ISCSI_PARAM_MAX_XMIT_DLENGTH].val;
- uint32_t residual;
memset(rsp, 0, sizeof(*rsp));
rsp->opcode = ISCSI_OP_SCSI_DATA_IN;
@@ -861,10 +842,10 @@ static int iscsi_data_rsp_build(struct i
rsp->offset = cpu_to_be32(task->offset);
rsp->datasn = cpu_to_be32(task->exp_r2tsn++);
- datalen = min(exp_datalen, task->len);
+ datalen = min_t(uint32_t, task->read_len, task->len);
datalen -= task->offset;
- dprintf("%d %d %d %d %x\n", datalen, exp_datalen, task->len, max_burst, rsp->itt);
+ dprintf("%d %d %d %d %x\n", datalen, task->read_len, task->len, max_burst, rsp->itt);
if (datalen <= max_burst) {
rsp->flags = ISCSI_FLAG_CMD_FINAL;
@@ -872,17 +853,9 @@ static int iscsi_data_rsp_build(struct i
/* collapse status into final packet if successful */
if (task->result == 0 && task->dir != BIDIRECTIONAL) {
rsp->flags |= ISCSI_FLAG_DATA_STATUS;
- if (task->len < exp_datalen) {
- rsp->flags |= ISCSI_FLAG_CMD_UNDERFLOW;
- residual = exp_datalen - task->len;
- } else if (task->len > exp_datalen) {
- rsp->flags |= ISCSI_FLAG_CMD_OVERFLOW;
- residual = task->len - exp_datalen;
- } else
- residual = 0;
rsp->cmd_status = task->result;
rsp->statsn = cpu_to_be32(conn->stat_sn++);
- rsp->residual_count = cpu_to_be32(residual);
+ calc_residual((struct iscsi_cmd_rsp *) rsp, task);
}
} else
datalen = max_burst;
@@ -1044,7 +1017,7 @@ static int iscsi_target_cmd_queue(struct
if (ahs_extcdb->ahstype == ISCSI_AHSTYPE_CDB) {
int extcdb_len = ntohs(ahs_extcdb->ahslength) - 1;
- char *p = (void *)task->extdata;
+ unsigned char *p = (void *)task->extdata;
if (4 + extcdb_len > ahslen) {
eprintf("AHS len %d too short for extcdb %d\n",
@@ -1272,7 +1245,7 @@ found:
conn->rx_buffer = task->data;
conn->rx_buffer += be32_to_cpu(req->offset);
- conn->rx_size = ntoh24(req->dlength);
+ conn->rx_size = roundup(ntoh24(req->dlength), 4);
task->offset += ntoh24(req->dlength);
task->r2t_count -= ntoh24(req->dlength);
@@ -1386,7 +1359,7 @@ static int iscsi_noop_out_rx_start(struc
{
struct iscsi_hdr *req = (struct iscsi_hdr *) &conn->req.bhs;
struct iscsi_task *task;
- int len, err = -ENOMEM;
+ int len, err = 0;
dprintf("%x %x %u\n", req->ttt, req->itt, ntoh24(req->dlength));
if (req->ttt != cpu_to_be32(ISCSI_RESERVED_TAG)) {
@@ -1413,8 +1386,10 @@ static int iscsi_noop_out_rx_start(struc
task = iscsi_alloc_task(conn, len);
if (task)
conn->rx_task = task;
- else
+ else {
+ err = -ENOMEM;
goto out;
+ }
if (len) {
conn->rx_size = len;
@@ -1495,7 +1470,7 @@ static int iscsi_task_rx_start(struct is
break;
}
- return 0;
+ return err;
}
static int iscsi_scsi_cmd_tx_start(struct iscsi_task *task)
diff -purN tgt-r849/usr/osd.c ../git/tgt/usr/osd.c
--- tgt-r849/usr/osd.c 2007-03-18 12:09:13.438820000 +0100
+++ ../git/tgt/usr/osd.c 2007-04-03 15:02:26.000000000 +0200
@@ -133,9 +133,9 @@ static int osd_varlen_cdb(int host_no, s
return cmd->c_target->bst->bs_cmd_submit(cmd);
}
-static void device_osd_init(struct tgt_device *dev)
+static void device_osd_init(struct scsi_lu *lu)
{
- dev->d_sense = 1;
+ lu->d_sense = 1;
}
struct device_type_template osd_template = {
diff -purN tgt-r849/usr/spc.c ../git/tgt/usr/spc.c
--- tgt-r849/usr/spc.c 2007-03-17 05:57:45.700965000 +0100
+++ ../git/tgt/usr/spc.c 2007-04-03 15:02:26.000000000 +0200
@@ -63,9 +63,9 @@ int spc_inquiry(int host_no, struct scsi
data[4] = 59;
data[7] = 0x02;
memset(data + 8, 0x20, 28);
- strncpy(data + 8, VENDOR_ID, 8);
- strncpy(data + 16, product_id, 16);
- strncpy(data + 32, PRODUCT_REV, 4);
+ strncpy((char *)data + 8, VENDOR_ID, 8);
+ strncpy((char *)data + 16, product_id, 16);
+ strncpy((char *)data + 32, PRODUCT_REV, 4);
data[58] = 0x03;
data[59] = 0x20;
data[60] = 0x09;
@@ -145,7 +145,7 @@ sense:
int spc_report_luns(int host_no, struct scsi_cmd *cmd)
{
- struct tgt_device *dev;
+ struct scsi_lu *lu;
struct list_head *dev_list = &cmd->c_target->device_list;
uint64_t lun, *data;
int idx, alen, oalen, nr_luns, rbuflen = 4096, overflow;
@@ -172,13 +172,13 @@ int spc_report_luns(int host_no, struct
nr_luns = 0;
overflow = 0;
- list_for_each_entry(dev, dev_list, device_siblings) {
+ list_for_each_entry(lu, dev_list, device_siblings) {
nr_luns++;
if (overflow)
continue;
- lun = dev->lun;
+ lun = lu->lun;
lun = ((lun > 0xff) ? (0x1 << 30) : 0) | ((0x3ff & lun) << 16);
data[idx++] = __cpu_to_be64(lun << 32);
if (!(alen -= 8))
@@ -241,6 +241,6 @@ int spc_request_sense(int host_no, struc
int spc_illegal_op(int host_no, struct scsi_cmd *cmd)
{
cmd->len = 0;
- sense_data_build(cmd, ILLEGAL_REQUEST, 0x24, 0);
+ sense_data_build(cmd, ILLEGAL_REQUEST, 0x20, 0);
return SAM_STAT_CHECK_CONDITION;
}
diff -purN tgt-r849/usr/spt.c ../git/tgt/usr/spt.c
--- tgt-r849/usr/spt.c 2007-03-18 02:02:22.904616000 +0100
+++ ../git/tgt/usr/spt.c 2007-04-03 15:02:26.000000000 +0200
@@ -41,13 +41,13 @@
#include "scsi.h"
#include "spc.h"
-extern int spt_sg_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size);
+extern int spt_sg_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size);
extern int spt_sg_perform(struct scsi_cmd *cmd);
-static void spt_sg_close(struct tgt_device *dev)
+static void spt_sg_close(struct scsi_lu *lu)
{
- tgt_event_del(dev->fd);
- close(dev->fd);
+ tgt_event_del(lu->fd);
+ close(lu->fd);
}
static int spt_sg_cmd_done(int do_munmap, int do_free, uint64_t uaddr, int len)
diff -purN tgt-r849/usr/spt_sgv3.c ../git/tgt/usr/spt_sgv3.c
--- tgt-r849/usr/spt_sgv3.c 2007-03-04 05:34:38.896408000 +0100
+++ ../git/tgt/usr/spt_sgv3.c 2007-04-03 15:02:26.000000000 +0200
@@ -48,9 +48,9 @@ static void sgv3_handler(int fd, int eve
{
int i, err;
struct sg_io_hdr hdrs[64];
- struct tgt_device *dev = data;
+ struct scsi_lu *lu = data;
- err = read(dev->fd, hdrs, sizeof(struct sg_io_hdr));
+ err = read(lu->fd, hdrs, sizeof(struct sg_io_hdr));
if (err <= 0)
return;
@@ -71,7 +71,7 @@ static void sgv3_handler(int fd, int eve
}
}
-int spt_sg_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size)
+int spt_sg_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size)
{
int err;
int nr_queue_cmd;
@@ -89,9 +89,9 @@ int spt_sg_open(struct tgt_device *dev,
goto close_fd;
}
- err = tgt_event_add(*fd, EPOLLIN, sgv3_handler, dev);
+ err = tgt_event_add(*fd, EPOLLIN, sgv3_handler, lu);
if (err) {
- free(dev);
+ free(lu);
goto close_fd;
}
diff -purN tgt-r849/usr/spt_sgv4.c ../git/tgt/usr/spt_sgv4.c
--- tgt-r849/usr/spt_sgv4.c 2007-03-10 10:54:10.506520000 +0100
+++ ../git/tgt/usr/spt_sgv4.c 2007-04-03 15:02:26.000000000 +0200
@@ -50,9 +50,9 @@ static void sgv4_handler(int fd, int eve
{
int i, err;
struct sg_io_v4 hdrs[64];
- struct tgt_device *dev = data;
+ struct scsi_lu *lu = data;
- err = read(dev->fd, hdrs, sizeof(hdrs));
+ err = read(lu->fd, hdrs, sizeof(hdrs));
if (err < 0)
return;
@@ -75,7 +75,7 @@ static void sgv4_handler(int fd, int eve
}
}
-int spt_sg_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size)
+int spt_sg_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size)
{
int err, maj, min;
char *sd, buf[256];
@@ -166,9 +166,9 @@ int spt_sg_open(struct tgt_device *dev,
goto close_fd;
}
- err = tgt_event_add(*fd, EPOLLIN, sgv4_handler, dev);
+ err = tgt_event_add(*fd, EPOLLIN, sgv4_handler, lu);
if (err) {
- free(dev);
+ free(lu);
goto close_fd;
}
diff -purN tgt-r849/usr/target.c ../git/tgt/usr/target.c
--- tgt-r849/usr/target.c 2007-03-18 05:10:23.944393000 +0100
+++ ../git/tgt/usr/target.c 2007-04-03 15:02:26.000000000 +0200
@@ -117,13 +117,13 @@ int it_nexus_destroy(uint64_t nid)
return -ENOENT;
}
-static struct tgt_device *device_lookup(struct target *target, uint64_t lun)
+static struct scsi_lu *device_lookup(struct target *target, uint64_t lun)
{
- struct tgt_device *device;
+ struct scsi_lu *lu;
- list_for_each_entry(device, &target->device_list, device_siblings)
- if (device->lun == lun)
- return device;
+ list_for_each_entry(lu, &target->device_list, device_siblings)
+ if (lu->lun == lun)
+ return lu;
return NULL;
}
@@ -157,7 +157,7 @@ static void tgt_cmd_queue_init(struct tg
}
static int tgt_device_path_update(struct target *target,
- struct tgt_device *device, char *path)
+ struct scsi_lu *lu, char *path)
{
int err, dev_fd;
uint64_t size;
@@ -166,36 +166,36 @@ static int tgt_device_path_update(struct
if (!path)
return TGTADM_NOMEM;
- err = target->bst->bs_open(device, path, &dev_fd, &size);
+ err = target->bst->bs_open(lu, path, &dev_fd, &size);
if (err) {
free(path);
return TGTADM_INVALID_REQUEST;
}
- device->fd = dev_fd;
- device->addr = 0;
- device->size = size;
- device->path = path;
+ lu->fd = dev_fd;
+ lu->addr = 0;
+ lu->size = size;
+ lu->path = path;
return 0;
}
-static struct tgt_device *
+static struct scsi_lu *
__device_lookup(int tid, uint64_t lun, struct target **t)
{
struct target *target;
- struct tgt_device *device;
+ struct scsi_lu *lu;
target = target_lookup(tid);
if (!target)
return NULL;
- device = device_lookup(target, lun);
- if (!device)
+ lu = device_lookup(target, lun);
+ if (!lu)
return NULL;
*t = target;
- return device;
+ return lu;
}
int tgt_device_create(int tid, uint64_t lun, char *args)
@@ -203,7 +203,7 @@ int tgt_device_create(int tid, uint64_t
char *p;
int err;
struct target *target;
- struct tgt_device *device, *pos;
+ struct scsi_lu *lu, *pos;
dprintf("%d %" PRIu64 "\n", tid, lun);
@@ -211,8 +211,8 @@ int tgt_device_create(int tid, uint64_t
if (!target)
return TGTADM_NO_TARGET;
- device = device_lookup(target, lun);
- if (device) {
+ lu = device_lookup(target, lun);
+ if (lu) {
eprintf("device %" PRIu64 " already exists\n", lun);
return TGTADM_LUN_EXIST;
}
@@ -225,31 +225,32 @@ int tgt_device_create(int tid, uint64_t
return TGTADM_INVALID_REQUEST;
p++;
- device = zalloc(sizeof(*device) + target->bst->bs_datasize);
- if (!device)
+ lu = zalloc(sizeof(*lu) + target->bst->bs_datasize);
+ if (!lu)
return TGTADM_NOMEM;
- err = tgt_device_path_update(target, device, p);
+ err = tgt_device_path_update(target, lu, p);
if (err) {
- free(device);
+ free(lu);
return err;
}
- device->lun = lun;
+ lu->lun = lun;
+ lu->lu_state = SCSI_LU_RUNNING;
- snprintf(device->scsi_id, sizeof(device->scsi_id),
+ snprintf(lu->scsi_id, sizeof(lu->scsi_id),
"deadbeaf%d:%" PRIu64, tid, lun);
- tgt_cmd_queue_init(&device->cmd_queue);
+ tgt_cmd_queue_init(&lu->cmd_queue);
if (target->dev_type_template.device_init)
- target->dev_type_template.device_init(device);
+ target->dev_type_template.device_init(lu);
list_for_each_entry(pos, &target->device_list, device_siblings) {
- if (device->lun < pos->lun)
+ if (lu->lun < pos->lun)
break;
}
- list_add_tail(&device->device_siblings, &pos->device_siblings);
+ list_add_tail(&lu->device_siblings, &pos->device_siblings);
dprintf("Add a logical unit %" PRIu64 " to the target %d\n", lun, tid);
return 0;
@@ -258,57 +259,57 @@ int tgt_device_create(int tid, uint64_t
int tgt_device_destroy(int tid, uint64_t lun)
{
struct target *target;
- struct tgt_device *device;
+ struct scsi_lu *lu;
dprintf("%u %" PRIu64 "\n", tid, lun);
- device = __device_lookup(tid, lun, &target);
- if (!device) {
+ lu = __device_lookup(tid, lun, &target);
+ if (!lu) {
eprintf("device %" PRIu64 " not found\n", lun);
return TGTADM_NO_LUN;
}
- if (!list_empty(&device->cmd_queue.queue))
+ if (!list_empty(&lu->cmd_queue.queue) || lu->cmd_queue.active_cmd)
return TGTADM_LUN_ACTIVE;
- free(device->path);
- list_del(&device->device_siblings);
+ free(lu->path);
+ list_del(&lu->device_siblings);
- target->bst->bs_close(device);
- free(device);
+ target->bst->bs_close(lu);
+ free(lu);
return 0;
}
int device_reserve(uint64_t nid, uint64_t lun, uint64_t reserve_id)
{
struct target *target;
- struct tgt_device *device;
+ struct scsi_lu *lu;
- device = __device_lookup(NID2TID(nid), lun, &target);
- if (!device)
+ lu = __device_lookup(NID2TID(nid), lun, &target);
+ if (!lu)
return -EINVAL;
- if (device->reserve_id && device->reserve_id != reserve_id) {
+ if (lu->reserve_id && lu->reserve_id != reserve_id) {
dprintf("already reserved %" PRIu64 " %" PRIu64 "\n",
- device->reserve_id, reserve_id);
+ lu->reserve_id, reserve_id);
return -EBUSY;
}
- device->reserve_id = reserve_id;
+ lu->reserve_id = reserve_id;
return 0;
}
int device_release(uint64_t nid, uint64_t lun, uint64_t reserve_id, int force)
{
struct target *target;
- struct tgt_device *device;
+ struct scsi_lu *lu;
- device = __device_lookup(NID2TID(nid), lun, &target);
- if (!device)
+ lu = __device_lookup(NID2TID(nid), lun, &target);
+ if (!lu)
return 0;
- if (force || device->reserve_id == reserve_id) {
- device->reserve_id = 0;
+ if (force || lu->reserve_id == reserve_id) {
+ lu->reserve_id = 0;
return 0;
}
@@ -318,10 +319,10 @@ int device_release(uint64_t nid, uint64_
int device_reserved(uint64_t nid, uint64_t lun, uint64_t reserve_id)
{
struct target *target;
- struct tgt_device *device;
+ struct scsi_lu *lu;
- device = __device_lookup(NID2TID(nid), lun, &target);
- if (!device || !device->reserve_id || device->reserve_id == reserve_id)
+ lu = __device_lookup(NID2TID(nid), lun, &target);
+ if (!lu || !lu->reserve_id || lu->reserve_id == reserve_id)
return 0;
return -EBUSY;
}
@@ -330,22 +331,22 @@ int tgt_device_update(int tid, uint64_t
{
int err = 0;
struct target *target;
- struct tgt_device *device;
+ struct scsi_lu *lu;
target = target_lookup(tid);
if (!target)
return TGTADM_NO_TARGET;
- device = device_lookup(target, dev_id);
- if (!device) {
+ lu = device_lookup(target, dev_id);
+ if (!lu) {
eprintf("device %" PRIu64 " not found\n", dev_id);
return TGTADM_NO_LUN;
}
if (!strncmp(name, "scsi_id=", 8))
- memcpy(device->scsi_id, name + 8, sizeof(device->scsi_id) - 1);
+ memcpy(lu->scsi_id, name + 8, sizeof(lu->scsi_id) - 1);
else if (!strncmp(name, "scsi_sn=", 8))
- memcpy(device->scsi_sn, name + 8, sizeof(device->scsi_sn) - 1);
+ memcpy(lu->scsi_sn, name + 8, sizeof(lu->scsi_sn) - 1);
else
err = TGTADM_INVALID_REQUEST;
@@ -412,13 +413,18 @@ int target_cmd_queue(struct scsi_cmd *cm
cmd->c_target = target = nexus->nexus_target;
- cmd_hlist_insert(target, cmd);
-
dev_id = scsi_get_devid(target->lid, cmd->lun);
dprintf("%p %x %" PRIx64 "\n", cmd, cmd->scb[0], dev_id);
cmd->dev = device_lookup(target, dev_id);
+ /* service delivery or target failure */
+ if (target->target_state != SCSI_TARGET_RUNNING ||
+ (cmd->dev && cmd->dev->lu_state != SCSI_LU_RUNNING))
+ return -EBUSY;
+
+ cmd_hlist_insert(target, cmd);
+
if (cmd->dev)
q = &cmd->dev->cmd_queue;
else
@@ -998,7 +1004,7 @@ static struct {
enum scsi_target_state value;
char *name;
} target_state[] = {
- {SCSI_TARGET_SUSPENDED, "suspended"},
+ {SCSI_TARGET_OFFLINE, "offline"},
{SCSI_TARGET_RUNNING, "running"},
};
@@ -1054,7 +1060,7 @@ int tgt_target_show_all(char *buf, int r
{
int total = 0, max = rest;
struct target *target;
- struct tgt_device *device;
+ struct scsi_lu *lu;
struct acl_entry *acl;
struct it_nexus *nexus;
@@ -1081,18 +1087,18 @@ int tgt_target_show_all(char *buf, int r
}
shprintf(total, buf, rest, _TAB1 "LUN information:\n");
- list_for_each_entry(device, &target->device_list, device_siblings)
+ list_for_each_entry(lu, &target->device_list, device_siblings)
shprintf(total, buf, rest,
_TAB2 "LUN: %" PRIu64 "\n"
_TAB3 "SCSI ID: %s\n"
_TAB3 "SCSI SN: %s\n"
_TAB3 "Size: %s\n"
_TAB3 "Backing store: %s\n",
- device->lun,
- device->scsi_id,
- device->scsi_sn,
- print_disksize(device->size),
- device->path);
+ lu->lun,
+ lu->scsi_id,
+ lu->scsi_sn,
+ print_disksize(lu->size),
+ lu->path);
if (!strcmp(tgt_drivers[target->lid]->name, "iscsi")) {
int i, aid;
@@ -1260,7 +1266,7 @@ int tgt_target_destroy(int tid)
}
free(target->account.in_aids);
-
+ free(target->name);
free(target);
return 0;
diff -purN tgt-r849/usr/tgtd.h ../git/tgt/usr/tgtd.h
--- tgt-r849/usr/tgtd.h 2007-03-18 02:02:22.904616000 +0100
+++ ../git/tgt/usr/tgtd.h 2007-04-03 15:02:26.000000000 +0200
@@ -19,17 +19,22 @@
#define _TAB4 _TAB2 _TAB2
enum scsi_target_state {
- SCSI_TARGET_SUSPENDED = 1,
+ SCSI_TARGET_OFFLINE = 1,
SCSI_TARGET_RUNNING,
};
+enum scsi_lu_state {
+ SCSI_LU_OFFLINE = 1,
+ SCSI_LU_RUNNING,
+};
+
struct tgt_cmd_queue {
int active_cmd;
unsigned long state;
struct list_head queue;
};
-struct tgt_device {
+struct scsi_lu {
int fd;
uint64_t addr; /* persistent mapped address */
uint64_t size;
@@ -43,6 +48,8 @@ struct tgt_device {
struct tgt_cmd_queue cmd_queue;
+ enum scsi_lu_state lu_state;
+
uint64_t reserve_id;
/* TODO: needs a structure for lots of device parameters */
@@ -58,7 +65,7 @@ struct scsi_cmd {
uint64_t uaddr;
uint32_t len;
int mmapped;
- struct tgt_device *dev;
+ struct scsi_lu *dev;
unsigned long state;
uint64_t cmd_nexus_id;
@@ -80,8 +87,8 @@ struct scsi_cmd {
struct backingstore_template {
int bs_datasize;
- int (*bs_open)(struct tgt_device *dev, char *path, int *fd, uint64_t *size);
- void (*bs_close)(struct tgt_device *dev);
+ int (*bs_open)(struct scsi_lu *dev, char *path, int *fd, uint64_t *size);
+ void (*bs_close)(struct scsi_lu *dev);
int (*bs_cmd_submit)(struct scsi_cmd *cmd);
int (*bs_cmd_done) (int do_munmap, int do_free, uint64_t uaddr, int len);
};
@@ -104,7 +111,7 @@ struct device_type_template {
char *name;
char *pid;
- void (*device_init)(struct tgt_device *dev);
+ void (*device_init)(struct scsi_lu *dev);
struct device_type_operations ops[256];
};