Merge ^/head r278005 through r278109.

This commit is contained in:
Dimitry Andric 2015-02-02 20:18:47 +00:00
commit 73ee00cef5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/clang360-import/; revision=278110
73 changed files with 3192 additions and 715 deletions

View File

@ -31,7 +31,6 @@ if [ $# != 1 ]; then
fi
dtrace=$1
CC=/usr/bin/gcc
CFLAGS=
doit()
@ -47,7 +46,7 @@ void
main()
{}
EOF
if $CC $CFLAGS -o $cofile $cfile >/dev/null 2>&1; then
if cc $CFLAGS -o $cofile $cfile >/dev/null 2>&1; then
$dtrace -xerrtags -C -s /dev/stdin \
>/dev/null 2>$errfile <<EOF
#include <sys/$file>
@ -67,11 +66,6 @@ EOF
rm -f $cofile $cfile 2>/dev/null
}
if [ ! -x $CC ]; then
echo "$0: bad compiler: $CC" >& 2
exit 1
fi
concurrency=`psrinfo | wc -l`
let concurrency=concurrency*4
let i=0

View File

@ -54,7 +54,7 @@ pid$1:a.out:go:
exit(1);
}
syscall::rexit:entry
syscall::exit:entry
/pid == $1/
{
exit(0);

View File

@ -37,7 +37,8 @@ script()
$dtrace -s /dev/stdin <<EOF
proc:::signal-discard
/args[1]->p_pid == $child &&
args[1]->pr_psargs == "$longsleep" && args[2] == SIGHUP/
xlate<psinfo_t *>(args[1])->pr_psargs == "$longsleep" &&
args[2] == SIGHUP/
{
exit(0);
}
@ -48,7 +49,7 @@ killer()
{
while true; do
sleep 1
/usr/bin/kill -HUP $child
kill -HUP $child
done
}
@ -58,7 +59,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
longsleep="/usr/bin/sleep 10000"
longsleep="/bin/sleep 10000"
/usr/bin/nohup $longsleep &
child=$!

View File

@ -48,7 +48,7 @@ sleeper()
{
while true; do
$longsleep &
/usr/bin/sleep 1
sleep 1
kill -9 $!
done
}
@ -59,7 +59,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
longsleep="/usr/bin/sleep 10000"
longsleep="/bin/sleep 10000"
sleeper &
child=$!
@ -67,9 +67,9 @@ child=$!
script
status=$?
pstop $child
kill -STOP $child
pkill -P $child
kill $child
prun $child
kill -CONT $child
exit $status

View File

@ -37,7 +37,8 @@ script()
$dtrace -s /dev/stdin <<EOF
proc:::signal-send
/execname == "kill" && curpsinfo->pr_ppid == $child &&
args[1]->pr_psargs == "$longsleep" && args[2] == SIGUSR1/
xlate<psinfo_t *>(args[1])->pr_psargs == "$longsleep" &&
args[2] == SIGUSR1/
{
/*
* This is guaranteed to not race with signal-handle.
@ -58,7 +59,7 @@ sleeper()
while true; do
$longsleep &
sleep 1
/usr/bin/kill -USR1 $!
kill -USR1 $!
done
}
@ -68,7 +69,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
longsleep="/usr/bin/sleep 10000"
longsleep="/bin/sleep 10000"
sleeper &
child=$!
@ -76,9 +77,9 @@ child=$!
script
status=$?
pstop $child
kill -STOP $child
pkill -P $child
kill $child
prun $child
kill -CONT $child
exit $status

View File

@ -41,7 +41,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$.d
## Create .d file

View File

@ -42,7 +42,7 @@ fi
dtrace=$1
bname=`/usr/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$

View File

@ -43,7 +43,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/usr/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$.d
## Create .d file
@ -77,7 +77,7 @@ fi
#Get the groupid of the calling process using ps
groupid=`ps -o pid,pgid | grep "$$ " | awk '{print $2}' 2>/dev/null`
groupid=`ps -x -o pid,egid | grep "$$ " | awk '{print $2}' 2>/dev/null`
if [ $? -ne 0 ]; then
print -u2 "unable to get uid of the current process with pid = $$"
exit 1
@ -93,5 +93,5 @@ fi
#Cleanup leftovers
/bin/rm -f $dfilename
rm -f $dfilename
exit 0

View File

@ -41,7 +41,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$
## Create .d file
@ -69,7 +69,7 @@ EOF
chmod 555 $dfilename
userid=`ps -o pid,uid | grep "$$ " | awk '{print $2}' 2>/dev/null`
userid=`ps -x -o pid,uid | grep "$$ " | awk '{print $2}' 2>/dev/null`
if [ $? -ne 0 ]; then
print -u2 "unable to get uid of the current process with pid = $$"
exit 1
@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/bin/rm -f $dfilename
rm -f $dfilename
exit 0

View File

@ -41,7 +41,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$
## Create .d file
@ -69,7 +69,7 @@ EOF
chmod 555 $dfilename
groupid=`ps -o pid,gid | grep "$$ " | awk '{print $2}' 2>/dev/null`
groupid=`ps -x -o pid,gid | grep "$$ " | awk '{print $2}' 2>/dev/null`
if [ $? -ne 0 ]; then
print -u2 "unable to get uid of the current process with pid = $$"
exit 1
@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/bin/rm -f $dfilename
rm -f $dfilename
exit 0

View File

@ -41,7 +41,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$.d
## Create .d file
@ -75,12 +75,12 @@ fi
#Pass current pid (I mean parent pid for .d script).
$dfilename $$ >/dev/null 2>&1
$dfilename $$ #>/dev/null 2>&1
if [ $? -ne 0 ]; then
print -u2 "Error in executing $dfilename"
exit 1
fi
#/bin/rm -f $dfilename
rm -f $dfilename
exit 0

View File

@ -41,7 +41,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$
## Create .d file
@ -69,7 +69,7 @@ EOF
chmod 555 $dfilename
projectid=`ps -o pid,projid | grep "$$ " | awk '{print $2}' 2>/dev/null`
projectid=`ps -x -o pid,projid | grep "$$ " | awk '{print $2}' 2>/dev/null`
if [ $? -ne 0 ]; then
print -u2 "unable to get uid of the current process with pid = $$"
exit 1
@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/bin/rm -f $dfilename
rm -f $dfilename
exit 0

View File

@ -41,7 +41,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$
## Create .d file
@ -69,7 +69,7 @@ EOF
chmod 555 $dfilename
sessionid=`ps -o pid,sid | grep "$$ " | awk '{print $2}' 2>/dev/null`
sessionid=`ps -x -o pid,sid | grep "$$ " | awk '{print $2}' 2>/dev/null`
if [ $? -ne 0 ]; then
print -u2 "unable to get sid of the current process with pid = $$"
exit 1
@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/bin/rm -f $dfilename
rm -f $dfilename
exit 0

View File

@ -41,7 +41,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$.d
## Create .d file

View File

@ -41,7 +41,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$
## Create .d file
@ -69,7 +69,7 @@ EOF
chmod 555 $dfilename
taskidval=`ps -o pid,taskid | grep "$$ " | awk '{print $2}' 2>/dev/null`
taskidval=`ps -x -o pid,taskid | grep "$$ " | awk '{print $2}' 2>/dev/null`
if [ $? -ne 0 ]; then
print -u2 "unable to get uid of the current process with pid = $$"
exit 1
@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/bin/rm -f $dfilename
rm -f $dfilename
exit 0

View File

@ -41,7 +41,7 @@ if [ $# != 1 ]; then
fi
dtrace=$1
bname=`/bin/basename $0`
bname=`basename $0`
dfilename=/var/tmp/$bname.$$
## Create .d file
@ -69,7 +69,7 @@ EOF
chmod 555 $dfilename
userid=`ps -o pid,uid | grep "$$ " | awk '{print $2}' 2>/dev/null`
userid=`ps -x -o pid,uid | grep "$$ " | awk '{print $2}' 2>/dev/null`
if [ $? -ne 0 ]; then
print -u2 "unable to get uid of the current process with pid = $$"
exit 1
@ -82,5 +82,5 @@ if [ $? -ne 0 ]; then
exit 1
fi
#/bin/rm -f $dfilename
rm -f $dfilename
exit 0

View File

@ -1,13 +0,0 @@
all: main
main: main.o prov.o
$(CC) -o main main.o prov.o
main.o: main.c prov.h
$(CC) -c main.c
prov.h: prov.d
/usr/sbin/dtrace -h -s prov.d
prov.o: prov.d main.o
/usr/sbin/dtrace -G -32 -s prov.d main.o

View File

@ -48,7 +48,7 @@ fi
dtrace="$1"
startdir="$PWD"
dir=$(mktemp -td drtiXXXXXX)
dir=$(mktemp -d -t drtiXXXXXX)
if (( $? != 0 )); then
print -u2 'Could not create safe temporary directory'
exit 2

View File

@ -51,7 +51,7 @@ provider test_prov {
};
EOF
gcc -c test.c
cc -c test.c
if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
@ -61,7 +61,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1
fi
gcc -o test test.o prov.o
cc -o test test.o prov.o
if [ $? -ne 0 ]; then
print -u2 "failed to link final executable"
exit 1

View File

@ -51,7 +51,7 @@ provider test_prov {
};
EOF
gcc -c test.c
cc -c test.c
if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
@ -61,7 +61,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1
fi
gcc -o test test.o prov.o
cc -o test test.o prov.o
if [ $? -ne 0 ]; then
print -u2 "failed to link final executable"
exit 1

View File

@ -51,7 +51,7 @@ provider test_prov {
};
EOF
gcc -c test.c
cc -c test.c
if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
@ -61,7 +61,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1
fi
gcc -o test test.o prov.o
cc -o test test.o prov.o
if [ $? -ne 0 ]; then
print -u2 "failed to link final executable"
exit 1

View File

@ -25,6 +25,7 @@
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
#define __ARM_STATIC_INLINE
#include "unwind.h"
/* We add a prototype for abort here to avoid creating a dependency on
@ -1089,4 +1090,11 @@ _Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn)
*ip_before_insn = 0;
return _Unwind_GetGR (context, 15) & ~(_Unwind_Word)1;
}
void
_Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr val)
{
_Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1));
}
#endif

View File

@ -34,6 +34,10 @@
#define __ARM_EABI_UNWINDER__ 1
#ifndef __ARM_STATIC_INLINE
#define __ARM_STATIC_INLINE static inline
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -245,7 +249,7 @@ extern "C" {
return tmp;
}
static inline _Unwind_Word
__ARM_STATIC_INLINE _Unwind_Word
_Unwind_GetGR (_Unwind_Context *context, int regno)
{
_uw val;
@ -253,6 +257,12 @@ extern "C" {
return val;
}
__ARM_STATIC_INLINE void
_Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
{
_Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
}
#ifndef __FreeBSD__
/* Return the address of the instruction, not the actual IP value. */
#define _Unwind_GetIP(context) \
@ -260,21 +270,16 @@ extern "C" {
#define _Unwind_GetIPInfo(context, ip_before_insn) \
(*ip_before_insn = 0, _Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
#else
_Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
_Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
#endif
static inline void
_Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
{
_Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
}
/* The dwarf unwinder doesn't understand arm/thumb state. We assume the
landing pad uses the same instruction set as the call site. */
#define _Unwind_SetIP(context, val) \
_Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
#else
_Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
_Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
#endif
#ifdef __cplusplus
} /* extern "C" */

View File

@ -673,7 +673,7 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c)
* If the failure happened by falling off the end of the stack without finding
* a handler, prints a back trace before aborting.
*/
#if __GNUC__ > 3 && __GNUC_MINOR__ > 2
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
extern "C" void *__cxa_begin_catch(void *e) throw();
#else
extern "C" void *__cxa_begin_catch(void *e);
@ -1191,7 +1191,7 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
* pointer to the caught exception, which is either the adjusted pointer (for
* C++ exceptions) of the unadjusted pointer (for foreign exceptions).
*/
#if __GNUC__ > 3 && __GNUC_MINOR__ > 2
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
extern "C" void *__cxa_begin_catch(void *e) throw()
#else
extern "C" void *__cxa_begin_catch(void *e)

View File

@ -35,23 +35,15 @@ type_info::~type_info() {}
bool type_info::operator==(const type_info &other) const
{
#ifdef LIBCXXRT_MERGED_TYPEINFO
return __type_name == other.__type_name;
#else
return __type_name == other.__type_name || strcmp(__type_name, other.__type_name) == 0;
#endif
}
bool type_info::operator!=(const type_info &other) const
{
return !operator==(other);
return __type_name != other.__type_name;
}
bool type_info::before(const type_info &other) const
{
#ifdef LIBCXXRT_MERGED_TYPEINFO
return __type_name < other.__type_name;
#else
return strcmp(__type_name, other.__type_name) < 0;
#endif
}
const char* type_info::name() const
{

View File

@ -0,0 +1,33 @@
Allow clang to be built for mips/mips64 backend types by adding our mips
triple ids
This only allows testing and does not change the defaults for mips/mips64.
They still build/use gcc by default.
Differential Revision: https://reviews.freebsd.org/D1190
Reviewed by: dim
Introduced here: http://svnweb.freebsd.org/changeset/base/277423
Index: tools/clang/lib/Driver/Tools.cpp
===================================================================
--- tools/clang/lib/Driver/Tools.cpp
+++ tools/clang/lib/Driver/Tools.cpp
@@ -6651,6 +6651,17 @@ void freebsd::Link::ConstructJob(Compilation &C, c
CmdArgs.push_back("elf32ppc_fbsd");
}
+ if (Arg *A = Args.getLastArg(options::OPT_G)) {
+ if (ToolChain.getArch() == llvm::Triple::mips ||
+ ToolChain.getArch() == llvm::Triple::mipsel ||
+ ToolChain.getArch() == llvm::Triple::mips64 ||
+ ToolChain.getArch() == llvm::Triple::mips64el) {
+ StringRef v = A->getValue();
+ CmdArgs.push_back(Args.MakeArgString("-G" + v));
+ A->claim();
+ }
+ }
+
if (Output.isFilename()) {
CmdArgs.push_back("-o");
CmdArgs.push_back(Output.getFilename());

View File

@ -107,9 +107,6 @@ ATF_TC_BODY(ttyname_r_err, tc)
ATF_REQUIRE(rv == ERANGE);
}
#ifdef __FreeBSD__
atf_tc_expect_fail("FreeBSD returns ENOTTY instead of EBADF; see bin/191936");
#endif
rv = ttyname_r(-1, buf, ttymax);
ATF_REQUIRE(rv == EBADF);

View File

@ -43,7 +43,6 @@ FILES= DAEMON \
growfs \
gssd \
${_hcsecd} \
hostapd \
hostid \
hostid_save \
hostname \
@ -137,7 +136,6 @@ FILES= DAEMON \
var \
virecover \
watchdogd \
wpa_supplicant \
ypbind \
yppasswdd \
ypserv \

View File

@ -65,7 +65,7 @@ ttyname_r(int fd, char *buf, size_t len)
/* Must be a terminal. */
if (!isatty(fd))
return (ENOTTY);
return (errno);
/* Must have enough room */
if (len <= sizeof(_PATH_DEV))
return (ERANGE);
@ -73,7 +73,7 @@ ttyname_r(int fd, char *buf, size_t len)
strcpy(buf, _PATH_DEV);
used = strlen(buf);
if (fdevname_r(fd, buf + used, len - used) == NULL)
return (ENOTTY);
return (errno == EINVAL ? ERANGE : errno);
return (0);
}

View File

@ -64,6 +64,7 @@ _des_crypt_call(buf, len, dparms)
}
if (nconf == NULL) {
warnx("getnetconfig: %s", nc_sperror());
endnetconfig(localhandle);
return(DESERR_HWERROR);
}
clnt = clnt_tp_create(NULL, CRYPT_PROG, CRYPT_VERS, nconf);

View File

@ -128,7 +128,7 @@ svc_vc_create(fd, sendsize, recvsize)
u_int sendsize;
u_int recvsize;
{
SVCXPRT *xprt;
SVCXPRT *xprt = NULL;
struct cf_rendezvous *r = NULL;
struct __rpc_sockinfo si;
struct sockaddr_storage sslocal;

View File

@ -17,6 +17,7 @@ PROFILING+= --param profile.attribute "'releasetype'" --param profile.value "'re
XSLTPROCFLAGS+= --param release.url "'${RELEASEURL}'"
XSLTPROCFLAGS+= --param release.branch "'${RELEASEBRANCH}'"
XSLTPROCFLAGS+= --param release.maillist "'${RELEASEMAILLIST}'"
XSLTPROCFLAGS+= --param toc.section.depth "'3'"
# Find the RELNOTESng document catalogs
EXTRA_CATALOGS+= file://${RELN_ROOT}/${LANGCODE}/share/xml/catalog.xml \

View File

@ -91,6 +91,11 @@ SUBDIR+= hastctl
SUBDIR+= hastd
.endif
.if ${MK_INET6} != "no"
SUBDIR+= ping6
SUBDIR+= rtsol
.endif
.if ${MK_IPFILTER} != "no"
SUBDIR+= ipf
.endif
@ -114,15 +119,6 @@ SUBDIR+= pfctl
SUBDIR+= pflogd
.endif
.if ${MK_INET6} != "no"
SUBDIR+= ping6
SUBDIR+= rtsol
.endif
.if ${MK_ISCSI} != "no"
SUBDIR+= iscontrol
.endif
.if ${MK_QUOTAS} != "no"
SUBDIR+= quotacheck
.endif

View File

@ -58,8 +58,8 @@ static const char rcsid[] =
#include "ifconfig.h"
static struct in6_ifreq in6_ridreq;
static struct in6_aliasreq in6_addreq =
{ .ifra_flags = 0,
static struct in6_aliasreq in6_addreq =
{ .ifra_flags = 0,
.ifra_lifetime = { 0, 0, ND6_INFINITE_LIFETIME, ND6_INFINITE_LIFETIME } };
static int ip6lifetime;
@ -265,14 +265,16 @@ in6_status(int s __unused, const struct ifaddrs *ifa)
printf("pltime ");
if (lifetime.ia6t_preferred) {
printf("%s ", lifetime.ia6t_preferred < now.tv_sec
? "0" : sec2str(lifetime.ia6t_preferred - now.tv_sec));
? "0" :
sec2str(lifetime.ia6t_preferred - now.tv_sec));
} else
printf("infty ");
printf("vltime ");
if (lifetime.ia6t_expire) {
printf("%s ", lifetime.ia6t_expire < now.tv_sec
? "0" : sec2str(lifetime.ia6t_expire - now.tv_sec));
? "0" :
sec2str(lifetime.ia6t_expire - now.tv_sec));
} else
printf("infty ");
}
@ -347,25 +349,25 @@ in6_getaddr(const char *s, int which)
static int
prefix(void *val, int size)
{
u_char *name = (u_char *)val;
int byte, bit, plen = 0;
u_char *name = (u_char *)val;
int byte, bit, plen = 0;
for (byte = 0; byte < size; byte++, plen += 8)
if (name[byte] != 0xff)
break;
for (byte = 0; byte < size; byte++, plen += 8)
if (name[byte] != 0xff)
break;
if (byte == size)
return (plen);
for (bit = 7; bit != 0; bit--, plen++)
if (!(name[byte] & (1 << bit)))
break;
for (; bit != 0; bit--)
if (name[byte] & (1 << bit))
return(0);
byte++;
for (; byte < size; byte++)
if (name[byte])
return(0);
return (plen);
if (!(name[byte] & (1 << bit)))
break;
for (; bit != 0; bit--)
if (name[byte] & (1 << bit))
return(0);
byte++;
for (; byte < size; byte++)
if (name[byte])
return(0);
return (plen);
}
static char *
@ -509,7 +511,11 @@ in6_Lopt_cb(const char *optarg __unused)
{
ip6lifetime++; /* print IPv6 address lifetime */
}
static struct option in6_Lopt = { .opt = "L", .opt_usage = "[-L]", .cb = in6_Lopt_cb };
static struct option in6_Lopt = {
.opt = "L",
.opt_usage = "[-L]",
.cb = in6_Lopt_cb
};
static __constructor void
inet6_ctor(void)

View File

@ -47,6 +47,7 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/module.h>
#include <sys/linker.h>
#include <sys/queue.h>
#include <net/ethernet.h>
#include <net/if.h>
@ -110,6 +111,15 @@ static void af_other_status(int);
static struct option *opts = NULL;
struct ifa_order_elt {
int if_order;
int af_orders[255];
struct ifaddrs *ifa;
TAILQ_ENTRY(ifa_order_elt) link;
};
TAILQ_HEAD(ifa_queue, ifa_order_elt);
void
opt_register(struct option *p)
{
@ -141,16 +151,165 @@ usage(void)
exit(1);
}
#define ORDERS_SIZE(x) sizeof(x) / sizeof(x[0])
static int
calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
{
struct ifaddrs *prev;
struct ifa_order_elt *cur;
unsigned int ord, af, ifa_ord;
prev = NULL;
cur = NULL;
ord = 0;
ifa_ord = 0;
while (ifa != NULL) {
if (prev == NULL ||
strcmp(ifa->ifa_name, prev->ifa_name) != 0) {
cur = calloc(1, sizeof(*cur));
if (cur == NULL)
return (-1);
TAILQ_INSERT_TAIL(q, cur, link);
cur->if_order = ifa_ord ++;
cur->ifa = ifa;
ord = 0;
}
if (ifa->ifa_addr) {
af = ifa->ifa_addr->sa_family;
if (af < ORDERS_SIZE(cur->af_orders) &&
cur->af_orders[af] == 0)
cur->af_orders[af] = ++ord;
}
prev = ifa;
ifa = ifa->ifa_next;
}
return (0);
}
static int
cmpifaddrs(struct ifaddrs *a, struct ifaddrs *b, struct ifa_queue *q)
{
struct ifa_order_elt *cur, *e1, *e2;
unsigned int af1, af2;
int ret;
e1 = e2 = NULL;
ret = strcmp(a->ifa_name, b->ifa_name);
if (ret != 0) {
TAILQ_FOREACH(cur, q, link) {
if (e1 && e2)
break;
if (strcmp(cur->ifa->ifa_name, a->ifa_name) == 0)
e1 = cur;
else if (strcmp(cur->ifa->ifa_name, b->ifa_name) == 0)
e2 = cur;
}
if (!e1 || !e2)
return (0);
else
return (e1->if_order - e2->if_order);
} else if (a->ifa_addr != NULL && b->ifa_addr != NULL) {
TAILQ_FOREACH(cur, q, link) {
if (strcmp(cur->ifa->ifa_name, a->ifa_name) == 0) {
e1 = cur;
break;
}
}
if (!e1)
return (0);
af1 = a->ifa_addr->sa_family;
af2 = b->ifa_addr->sa_family;
if (af1 < ORDERS_SIZE(e1->af_orders) &&
af2 < ORDERS_SIZE(e1->af_orders))
return (e1->af_orders[af1] - e1->af_orders[af2]);
}
return (0);
}
#undef ORDERS_SIZE
static struct ifaddrs *
sortifaddrs(struct ifaddrs *list,
int (*compare)(struct ifaddrs *, struct ifaddrs *, struct ifa_queue *),
struct ifa_queue *q)
{
struct ifaddrs *right, *temp, *last, *result, *next, *tail;
right = list;
temp = list;
last = list;
result = NULL;
next = NULL;
tail = NULL;
if (!list || !list->ifa_next)
return (list);
while (temp && temp->ifa_next) {
last = right;
right = right->ifa_next;
temp = temp->ifa_next->ifa_next;
}
last->ifa_next = NULL;
list = sortifaddrs(list, compare, q);
right = sortifaddrs(right, compare, q);
while (list || right) {
if (!right) {
next = list;
list = list->ifa_next;
} else if (!list) {
next = right;
right = right->ifa_next;
} else if (compare(list, right, q) <= 0) {
next = list;
list = list->ifa_next;
} else {
next = right;
right = right->ifa_next;
}
if (!result)
result = next;
else
tail->ifa_next = next;
tail = next;
}
return (result);
}
int
main(int argc, char *argv[])
{
int c, all, namesonly, downonly, uponly;
const struct afswtch *afp = NULL;
int ifindex;
struct ifaddrs *ifap, *ifa;
struct ifaddrs *ifap, *sifap, *ifa;
struct ifreq paifr;
const struct sockaddr_dl *sdl;
char options[1024], *cp, *namecp = NULL;
struct ifa_queue q = TAILQ_HEAD_INITIALIZER(q);
struct ifa_order_elt *cur, *tmp;
const char *ifname;
struct option *p;
size_t iflen;
@ -285,9 +444,19 @@ main(int argc, char *argv[])
if (getifaddrs(&ifap) != 0)
err(EXIT_FAILURE, "getifaddrs");
cp = NULL;
if (calcorders(ifap, &q) != 0)
err(EXIT_FAILURE, "calcorders");
sifap = sortifaddrs(ifap, cmpifaddrs, &q);
TAILQ_FOREACH_SAFE(cur, &q, link, tmp)
free(cur);
ifindex = 0;
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
for (ifa = sifap; ifa; ifa = ifa->ifa_next) {
memset(&paifr, 0, sizeof(paifr));
strncpy(paifr.ifr_name, ifa->ifa_name, sizeof(paifr.ifr_name));
if (sizeof(paifr.ifr_addr) >= ifa->ifa_addr->sa_len) {
@ -333,7 +502,8 @@ main(int argc, char *argv[])
sdl->sdl_alen != ETHER_ADDR_LEN)
continue;
} else {
if (ifa->ifa_addr->sa_family != afp->af_af)
if (ifa->ifa_addr->sa_family
!= afp->af_af)
continue;
}
}
@ -669,7 +839,7 @@ settunnel(const char *src, const char *dst, int s, const struct afswtch *afp)
errx(1, "error in parsing address string: %s",
gai_strerror(ecode));
if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0)
if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0)
errx(1, "error in parsing address string: %s",
gai_strerror(ecode));

View File

@ -858,8 +858,6 @@ bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
else
ba = standard_allocator;
/* Be careful not to access map from here on. */
bufzone = busdma_bufalloc_findzone(ba, dmat->maxsize);
if (bufzone != NULL && dmat->alignment <= bufzone->size &&

View File

@ -502,7 +502,7 @@ am335x_clk_gpio_activate(struct ti_clock_dev *clkdev)
/* set *_CLKCTRL register MODULEMODE[1:0] to enable(2) */
/* set *_CLKCTRL register OPTFCLKEN_GPIO_1_G DBCLK[18] to FCLK_EN(1) */
prcm_write_4(clk_details->clkctrl_reg, 2 | (1 << 18));
while ((prcm_read_4(clk_details->clkctrl_reg) &
while ((prcm_read_4(clk_details->clkctrl_reg) &
(3 | (1 << 18) )) != (2 | (1 << 18)))
DELAY(10);
@ -724,11 +724,11 @@ am335x_clk_lcdc_activate(struct ti_clock_dev *clkdev)
prcm_write_4(CM_WKUP_CM_CLKMODE_DPLL_DISP, 0x4);
/* Make sure it's in bypass mode */
while (!(prcm_read_4(CM_WKUP_CM_IDLEST_DPLL_DISP)
while (!(prcm_read_4(CM_WKUP_CM_IDLEST_DPLL_DISP)
& (1 << 8)))
DELAY(10);
/*
/*
* For now set frequency to 99*SYSFREQ/8 which is twice as
* HDMI 1080p pixel clock (minimum LCDC freq divisor is 2)
*/
@ -738,7 +738,7 @@ am335x_clk_lcdc_activate(struct ti_clock_dev *clkdev)
prcm_write_4(CM_WKUP_CM_CLKMODE_DPLL_DISP, 0x7);
int timeout = 10000;
while ((!(prcm_read_4(CM_WKUP_CM_IDLEST_DPLL_DISP)
while ((!(prcm_read_4(CM_WKUP_CM_IDLEST_DPLL_DISP)
& (1 << 0))) && timeout--)
DELAY(10);
@ -786,9 +786,9 @@ am335x_clk_pruss_activate(struct ti_clock_dev *clkdev)
while ((prcm_read_4(CM_PER_PRUSS_CLKSTCTRL) & (1<<6)) == 0)
DELAY(10);
/* Select DISP DPLL as OCP clock */
prcm_write_4(CLKSEL_PRUSS_OCP_CLK, 1);
while ((prcm_read_4(CLKSEL_PRUSS_OCP_CLK) & 0x3) != 1)
/* Select L3F as OCP clock */
prcm_write_4(CLKSEL_PRUSS_OCP_CLK, 0);
while ((prcm_read_4(CLKSEL_PRUSS_OCP_CLK) & 0x3) != 0)
DELAY(10);
/* Clear the RESET bit */

View File

@ -566,17 +566,6 @@ fdt_fixup_memory(struct fdt_mem_region *region, size_t num)
return;
}
if ((reg = (uint32_t *)fdt_getprop(fdtp, memory, "reg",
&len)) != NULL) {
if (fdt_reg_valid(reg, len, addr_cells, size_cells) == 0)
/*
* Do not apply fixup if existing 'reg' property
* seems to be valid.
*/
return;
}
len = (addr_cells + size_cells) * realmrno * sizeof(uint32_t);
sb = buf = (uint8_t *)malloc(len);
if (!buf)

View File

@ -1,3 +1,8 @@
/*
*
* $FreeBSD$
*/
#include <machine/asm.h>
ENTRY(host_read)
@ -16,7 +21,10 @@ ENTRY(host_write)
blr
ENTRY(host_seek)
li %r0, 19 # SYS_lseek
mr %r4,%r5
mr %r5,%r6
mr %r6,%r7
li %r0, 140 # SYS_llseek
sc
blr

View File

@ -32,7 +32,7 @@
ssize_t host_read(int fd, void *buf, size_t nbyte);
ssize_t host_write(int fd, const void *buf, size_t nbyte);
ssize_t host_seek(int fd, int offset, int whence);
ssize_t host_seek(int fd, int64_t offset, int whence);
int host_open(char *path, int flags, int mode);
int host_close(int fd);
void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, int);

View File

@ -40,7 +40,7 @@ static int hostdisk_ioctl(struct open_file *f, u_long cmd, void *data);
static void hostdisk_print(int verbose);
struct devsw hostdisk = {
"s",
"/dev",
DEVT_DISK,
hostdisk_init,
hostdisk_strategy,
@ -67,8 +67,10 @@ hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size,
pos = dblk * 512;
if (host_seek(desc->d_unit, pos, 0) < 0)
if (host_seek(desc->d_unit, pos, 0) < 0) {
printf("Seek error\n");
return (EIO);
}
n = host_read(desc->d_unit, buf, size);
if (n < 0)
@ -82,22 +84,19 @@ static int
hostdisk_open(struct open_file *f, ...)
{
struct devdesc *desc;
char *path;
va_list vl;
va_start(vl, f);
desc = va_arg(vl, struct devdesc *);
va_end(vl);
path = malloc(strlen((char *)(desc->d_opendata)) + 6);
strcpy(path, "/dev/");
strcat(path, (char *)(desc->d_opendata));
desc->d_unit = host_open(desc->d_opendata, O_RDONLY, 0);
desc->d_unit = host_open(path, O_RDONLY, 0);
free(path);
if (desc->d_unit <= 0)
if (desc->d_unit <= 0) {
printf("hostdisk_open: couldn't open %s: %d\n",
desc->d_opendata, desc->d_unit);
return (ENOENT);
}
return (0);
}

View File

@ -398,12 +398,11 @@ static int ctl_ioctl_fill_ooa(struct ctl_lun *lun, uint32_t *cur_fill_num,
struct ctl_ooa_entry *kern_entries);
static int ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
struct thread *td);
static uint32_t ctl_map_lun(struct ctl_softc *softc, int port_num, uint32_t lun);
static uint32_t ctl_map_lun_back(struct ctl_softc *softc, int port_num, uint32_t lun);
static int ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *lun,
struct ctl_be_lun *be_lun, struct ctl_id target_id);
static int ctl_free_lun(struct ctl_lun *lun);
static void ctl_create_lun(struct ctl_be_lun *be_lun);
static struct ctl_port * ctl_io_port(struct ctl_io_hdr *io_hdr);
/**
static void ctl_failover_change_pages(struct ctl_softc *softc,
struct ctl_scsiio *ctsio, int master);
@ -3411,6 +3410,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
struct ctl_lun_list *list;
struct ctl_option *opt;
int j;
uint32_t plun;
list = (struct ctl_lun_list *)addr;
@ -3491,6 +3491,18 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
break;
}
if (port->lun_map != NULL) {
sbuf_printf(sb, "\t<lun_map>on</lun_map>\n");
for (j = 0; j < CTL_MAX_LUNS; j++) {
plun = ctl_lun_map_from_port(port, j);
if (plun >= CTL_MAX_LUNS)
continue;
sbuf_printf(sb,
"\t<lun id=\"%u\">%u</lun>\n",
j, plun);
}
}
for (j = 0; j < CTL_MAX_INIT_PER_PORT; j++) {
if (port->wwpn_iid[j].in_use == 0 ||
(port->wwpn_iid[j].wwpn == 0 &&
@ -3538,6 +3550,38 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
sbuf_delete(sb);
break;
}
case CTL_LUN_MAP: {
struct ctl_lun_map *lm = (struct ctl_lun_map *)addr;
struct ctl_port *port;
mtx_lock(&softc->ctl_lock);
if (lm->port >= CTL_MAX_PORTS ||
(port = softc->ctl_ports[lm->port]) == NULL) {
mtx_unlock(&softc->ctl_lock);
return (ENXIO);
}
if (lm->plun < CTL_MAX_LUNS) {
if (lm->lun == UINT32_MAX)
retval = ctl_lun_map_unset(port, lm->plun);
else if (lm->lun < CTL_MAX_LUNS &&
softc->ctl_luns[lm->lun] != NULL)
retval = ctl_lun_map_set(port, lm->plun, lm->lun);
else {
mtx_unlock(&softc->ctl_lock);
return (ENXIO);
}
} else if (lm->plun == UINT32_MAX) {
if (lm->lun == UINT32_MAX)
retval = ctl_lun_map_deinit(port);
else
retval = ctl_lun_map_init(port);
} else {
mtx_unlock(&softc->ctl_lock);
return (ENXIO);
}
mtx_unlock(&softc->ctl_lock);
break;
}
default: {
/* XXX KDM should we fix this? */
#if 0
@ -3602,35 +3646,106 @@ ctl_port_idx(int port_num)
return(port_num - CTL_MAX_PORTS);
}
static uint32_t
ctl_map_lun(struct ctl_softc *softc, int port_num, uint32_t lun_id)
int
ctl_lun_map_init(struct ctl_port *port)
{
struct ctl_port *port;
uint32_t i;
if (port->lun_map == NULL)
port->lun_map = malloc(sizeof(uint32_t) * CTL_MAX_LUNS,
M_CTL, M_NOWAIT);
if (port->lun_map == NULL)
return (ENOMEM);
for (i = 0; i < CTL_MAX_LUNS; i++)
port->lun_map[i] = UINT32_MAX;
return (0);
}
int
ctl_lun_map_deinit(struct ctl_port *port)
{
if (port->lun_map == NULL)
return (0);
free(port->lun_map, M_CTL);
port->lun_map = NULL;
return (0);
}
int
ctl_lun_map_set(struct ctl_port *port, uint32_t plun, uint32_t glun)
{
int status;
if (port->lun_map == NULL) {
status = ctl_lun_map_init(port);
if (status != 0)
return (status);
}
port->lun_map[plun] = glun;
return (0);
}
int
ctl_lun_map_unset(struct ctl_port *port, uint32_t plun)
{
if (port->lun_map == NULL)
return (0);
port->lun_map[plun] = UINT32_MAX;
return (0);
}
int
ctl_lun_map_unsetg(struct ctl_port *port, uint32_t glun)
{
int i;
if (port->lun_map == NULL)
return (0);
for (i = 0; i < CTL_MAX_LUNS; i++) {
if (port->lun_map[i] == glun)
port->lun_map[i] = UINT32_MAX;
}
return (0);
}
uint32_t
ctl_lun_map_from_port(struct ctl_port *port, uint32_t lun_id)
{
if (port == NULL)
return (UINT32_MAX);
if (port->lun_map == NULL || lun_id >= CTL_MAX_LUNS)
return (lun_id);
return (port->lun_map[lun_id]);
}
uint32_t
ctl_lun_map_to_port(struct ctl_port *port, uint32_t lun_id)
{
uint32_t i;
port = softc->ctl_ports[ctl_port_idx(port_num)];
if (port == NULL)
return (UINT32_MAX);
if (port->lun_map == NULL)
return (lun_id);
return (port->lun_map(port->targ_lun_arg, lun_id));
}
static uint32_t
ctl_map_lun_back(struct ctl_softc *softc, int port_num, uint32_t lun_id)
{
struct ctl_port *port;
uint32_t i;
port = softc->ctl_ports[ctl_port_idx(port_num)];
if (port->lun_map == NULL)
return (lun_id);
for (i = 0; i < CTL_MAX_LUNS; i++) {
if (port->lun_map(port->targ_lun_arg, i) == lun_id)
if (port->lun_map[i] == lun_id)
return (i);
}
return (UINT32_MAX);
}
static struct ctl_port *
ctl_io_port(struct ctl_io_hdr *io_hdr)
{
int port_num;
port_num = io_hdr->nexus.targ_port;
return (control_softc->ctl_ports[ctl_port_idx(port_num)]);
}
/*
* Note: This only works for bitmask sizes that are at least 32 bits, and
* that are a power of 2.
@ -4676,9 +4791,7 @@ static int
ctl_free_lun(struct ctl_lun *lun)
{
struct ctl_softc *softc;
#if 0
struct ctl_port *port;
#endif
struct ctl_lun *nlun;
int i;
@ -4686,6 +4799,9 @@ ctl_free_lun(struct ctl_lun *lun)
mtx_assert(&softc->ctl_lock, MA_OWNED);
STAILQ_FOREACH(port, &softc->port_list, links)
ctl_lun_map_unsetg(port, lun->lun);
STAILQ_REMOVE(&softc->lun_list, lun, ctl_lun, links);
ctl_clear_mask(softc->ctl_lun_mask, lun->lun);
@ -7343,8 +7459,7 @@ ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio)
STAILQ_FOREACH(port, &softc->port_list, links) {
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
continue;
if (ctl_map_lun_back(softc, port->targ_port, lun->lun) >=
CTL_MAX_LUNS)
if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
continue;
num_target_ports++;
}
@ -7417,8 +7532,7 @@ ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio)
STAILQ_FOREACH(port, &softc->port_list, links) {
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
continue;
if (ctl_map_lun_back(softc, port->targ_port, lun->lun)
>= CTL_MAX_LUNS)
if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
continue;
p = port->targ_port % CTL_MAX_PORTS + g * CTL_MAX_PORTS;
scsi_ulto2b(p, tpg_desc->descriptors[pc].
@ -9260,6 +9374,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio)
struct scsi_report_luns *cdb;
struct scsi_report_luns_data *lun_data;
struct ctl_lun *lun, *request_lun;
struct ctl_port *port;
int num_luns, retval;
uint32_t alloc_len, lun_datalen;
int num_filled, well_known;
@ -9316,6 +9431,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio)
request_lun = (struct ctl_lun *)
ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
port = ctl_io_port(&ctsio->io_hdr);
lun_datalen = sizeof(*lun_data) +
(num_luns * sizeof(struct scsi_report_luns_lundata));
@ -9328,8 +9444,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio)
mtx_lock(&softc->ctl_lock);
for (targ_lun_id = 0, num_filled = 0; targ_lun_id < CTL_MAX_LUNS && num_filled < num_luns; targ_lun_id++) {
lun_id = ctl_map_lun(softc, ctsio->io_hdr.nexus.targ_port,
targ_lun_id);
lun_id = ctl_lun_map_from_port(port, targ_lun_id);
if (lun_id >= CTL_MAX_LUNS)
continue;
lun = softc->ctl_luns[lun_id];
@ -10014,8 +10129,7 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len)
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
continue;
if (lun != NULL &&
ctl_map_lun_back(softc, port->targ_port, lun->lun) >=
CTL_MAX_LUNS)
ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
continue;
num_target_ports++;
if (port->init_devid)
@ -10068,8 +10182,7 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len)
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
continue;
if (lun != NULL &&
ctl_map_lun_back(softc, port->targ_port, lun->lun)
>= CTL_MAX_LUNS)
ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
continue;
p = port->targ_port % CTL_MAX_PORTS + g * CTL_MAX_PORTS;
scsi_ulto2b(p, pd->relative_port_id);
@ -13745,6 +13858,7 @@ int
ctl_queue_sense(union ctl_io *io)
{
struct ctl_lun *lun;
struct ctl_port *port;
struct ctl_softc *softc;
uint32_t initidx, targ_lun;
@ -13765,8 +13879,8 @@ ctl_queue_sense(union ctl_io *io)
* If we don't have a LUN for this, just toss the sense
* information.
*/
targ_lun = io->io_hdr.nexus.targ_lun;
targ_lun = ctl_map_lun(softc, io->io_hdr.nexus.targ_port, targ_lun);
port = ctl_io_port(&ctsio->io_hdr);
targ_lun = ctl_lun_map_from_port(port, io->io_hdr.nexus.targ_lun);
if ((targ_lun < CTL_MAX_LUNS)
&& (softc->ctl_luns[targ_lun] != NULL))
lun = softc->ctl_luns[targ_lun];
@ -13806,6 +13920,7 @@ ctl_queue_sense(union ctl_io *io)
int
ctl_queue(union ctl_io *io)
{
struct ctl_port *port;
CTL_DEBUG_PRINT(("ctl_queue cdb[0]=%02X\n", io->scsiio.cdb[0]));
@ -13815,9 +13930,9 @@ ctl_queue(union ctl_io *io)
#endif /* CTL_TIME_IO */
/* Map FE-specific LUN ID into global one. */
port = ctl_io_port(&io->io_hdr);
io->io_hdr.nexus.targ_mapped_lun =
ctl_map_lun(control_softc, io->io_hdr.nexus.targ_port,
io->io_hdr.nexus.targ_lun);
ctl_lun_map_from_port(port, io->io_hdr.nexus.targ_lun);
switch (io->io_hdr.io_type) {
case CTL_IO_SCSI:

View File

@ -234,6 +234,7 @@ ctl_port_deregister(struct ctl_port *port)
ctl_pool_free(pool);
ctl_free_opts(&port->options);
ctl_lun_map_deinit(port);
free(port->port_devid, M_CTL);
port->port_devid = NULL;
free(port->target_devid, M_CTL);

View File

@ -51,7 +51,6 @@ typedef void (*fe_shutdown_t)(void);
typedef void (*port_func_t)(void *onoff_arg);
typedef int (*port_info_func_t)(void *onoff_arg, struct sbuf *sb);
typedef int (*lun_func_t)(void *arg, struct ctl_id targ_id, int lun_id);
typedef uint32_t (*lun_map_func_t)(void *arg, uint32_t lun_id);
typedef int (*fe_ioctl_t)(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
struct thread *td);
@ -226,7 +225,7 @@ struct ctl_port {
void *onoff_arg; /* passed to CTL */
lun_func_t lun_enable; /* passed to CTL */
lun_func_t lun_disable; /* passed to CTL */
lun_map_func_t lun_map; /* passed to CTL */
uint32_t *lun_map; /* passed to CTL */
void *targ_lun_arg; /* passed to CTL */
void (*fe_datamove)(union ctl_io *io); /* passed to CTL */
void (*fe_done)(union ctl_io *io); /* passed to CTL */

View File

@ -151,7 +151,6 @@ static int cfiscsi_lun_enable(void *arg,
struct ctl_id target_id, int lun_id);
static int cfiscsi_lun_disable(void *arg,
struct ctl_id target_id, int lun_id);
static uint32_t cfiscsi_lun_map(void *arg, uint32_t lun);
static int cfiscsi_ioctl(struct cdev *dev,
u_long cmd, caddr_t addr, int flag, struct thread *td);
static void cfiscsi_datamove(union ctl_io *io);
@ -2031,7 +2030,6 @@ cfiscsi_ioctl_port_create(struct ctl_req *req)
port->onoff_arg = ct;
port->lun_enable = cfiscsi_lun_enable;
port->lun_disable = cfiscsi_lun_disable;
port->lun_map = cfiscsi_lun_map;
port->targ_lun_arg = ct;
port->fe_datamove = cfiscsi_datamove;
port->fe_done = cfiscsi_done;
@ -2081,7 +2079,7 @@ cfiscsi_ioctl_port_create(struct ctl_req *req)
free(port->target_devid, M_CFISCSI);
req->status = CTL_LUN_ERROR;
snprintf(req->error_str, sizeof(req->error_str),
"ctl_frontend_register() failed with error %d", retval);
"ctl_port_register() failed with error %d", retval);
return;
}
done:
@ -2259,7 +2257,6 @@ cfiscsi_target_find_or_create(struct cfiscsi_softc *softc, const char *name,
const char *alias)
{
struct cfiscsi_target *ct, *newct;
int i;
if (name[0] == '\0' || strlen(name) >= CTL_ISCSI_NAME_LEN)
return (NULL);
@ -2277,9 +2274,6 @@ cfiscsi_target_find_or_create(struct cfiscsi_softc *softc, const char *name,
return (ct);
}
for (i = 0; i < CTL_MAX_LUNS; i++)
newct->ct_luns[i] = UINT32_MAX;
strlcpy(newct->ct_name, name, sizeof(newct->ct_name));
if (alias != NULL)
strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias));
@ -2294,108 +2288,17 @@ cfiscsi_target_find_or_create(struct cfiscsi_softc *softc, const char *name,
return (newct);
}
/*
* Takes LUN from the target space and returns LUN from the CTL space.
*/
static uint32_t
cfiscsi_lun_map(void *arg, uint32_t lun)
{
struct cfiscsi_target *ct = arg;
if (lun >= CTL_MAX_LUNS) {
CFISCSI_DEBUG("requested lun number %d is higher "
"than maximum %d", lun, CTL_MAX_LUNS - 1);
return (UINT32_MAX);
}
return (ct->ct_luns[lun]);
}
static int
cfiscsi_target_set_lun(struct cfiscsi_target *ct,
unsigned long lun_id, unsigned long ctl_lun_id)
{
if (lun_id >= CTL_MAX_LUNS) {
CFISCSI_WARN("requested lun number %ld is higher "
"than maximum %d", lun_id, CTL_MAX_LUNS - 1);
return (-1);
}
if (ct->ct_luns[lun_id] < CTL_MAX_LUNS) {
/*
* CTL calls cfiscsi_lun_enable() twice for each LUN - once
* when the LUN is created, and a second time just before
* the port is brought online; don't emit warnings
* for that case.
*/
if (ct->ct_luns[lun_id] == ctl_lun_id)
return (0);
CFISCSI_WARN("lun %ld already allocated", lun_id);
return (-1);
}
#if 0
CFISCSI_DEBUG("adding mapping for lun %ld, target %s "
"to ctl lun %ld", lun_id, ct->ct_name, ctl_lun_id);
#endif
ct->ct_luns[lun_id] = ctl_lun_id;
return (0);
}
static int
cfiscsi_lun_enable(void *arg, struct ctl_id target_id, int lun_id)
{
struct cfiscsi_softc *softc;
struct cfiscsi_target *ct;
const char *target = NULL;
const char *lun = NULL;
unsigned long tmp;
ct = (struct cfiscsi_target *)arg;
softc = ct->ct_softc;
target = ctl_get_opt(&control_softc->ctl_luns[lun_id]->be_lun->options,
"cfiscsi_target");
lun = ctl_get_opt(&control_softc->ctl_luns[lun_id]->be_lun->options,
"cfiscsi_lun");
if (target == NULL && lun == NULL)
return (0);
if (target == NULL || lun == NULL) {
CFISCSI_WARN("lun added with cfiscsi_target, but without "
"cfiscsi_lun, or the other way around; ignoring");
return (0);
}
if (strcmp(target, ct->ct_name) != 0)
return (0);
tmp = strtoul(lun, NULL, 10);
cfiscsi_target_set_lun(ct, tmp, lun_id);
return (0);
}
static int
cfiscsi_lun_disable(void *arg, struct ctl_id target_id, int lun_id)
{
struct cfiscsi_softc *softc;
struct cfiscsi_target *ct;
int i;
ct = (struct cfiscsi_target *)arg;
softc = ct->ct_softc;
mtx_lock(&softc->lock);
for (i = 0; i < CTL_MAX_LUNS; i++) {
if (ct->ct_luns[i] != lun_id)
continue;
ct->ct_luns[i] = UINT32_MAX;
break;
}
mtx_unlock(&softc->lock);
return (0);
}

View File

@ -38,7 +38,6 @@
struct cfiscsi_target {
TAILQ_ENTRY(cfiscsi_target) ct_next;
uint32_t ct_luns[CTL_MAX_LUNS];
struct cfiscsi_softc *ct_softc;
volatile u_int ct_refcount;
char ct_name[CTL_ISCSI_NAME_LEN];

View File

@ -805,6 +805,12 @@ struct ctl_iscsi {
/* passed to userland */
};
struct ctl_lun_map {
uint32_t port;
uint32_t plun;
uint32_t lun;
};
#define CTL_IO _IOWR(CTL_MINOR, 0x00, union ctl_io)
#define CTL_ENABLE_PORT _IOW(CTL_MINOR, 0x04, struct ctl_port_entry)
#define CTL_DISABLE_PORT _IOW(CTL_MINOR, 0x05, struct ctl_port_entry)
@ -832,6 +838,7 @@ struct ctl_iscsi {
#define CTL_ISCSI _IOWR(CTL_MINOR, 0x25, struct ctl_iscsi)
#define CTL_PORT_REQ _IOWR(CTL_MINOR, 0x26, struct ctl_req)
#define CTL_PORT_LIST _IOWR(CTL_MINOR, 0x27, struct ctl_lun_list)
#define CTL_LUN_MAP _IOW(CTL_MINOR, 0x28, struct ctl_lun_map)
#endif /* _CTL_IOCTL_H_ */

View File

@ -492,6 +492,13 @@ extern const struct ctl_cmd_entry ctl_cmd_table[256];
uint32_t ctl_get_initindex(struct ctl_nexus *nexus);
uint32_t ctl_get_resindex(struct ctl_nexus *nexus);
uint32_t ctl_port_idx(int port_num);
int ctl_lun_map_init(struct ctl_port *port);
int ctl_lun_map_deinit(struct ctl_port *port);
int ctl_lun_map_set(struct ctl_port *port, uint32_t plun, uint32_t glun);
int ctl_lun_map_unset(struct ctl_port *port, uint32_t plun);
int ctl_lun_map_unsetg(struct ctl_port *port, uint32_t glun);
uint32_t ctl_lun_map_from_port(struct ctl_port *port, uint32_t plun);
uint32_t ctl_lun_map_to_port(struct ctl_port *port, uint32_t glun);
int ctl_pool_create(struct ctl_softc *ctl_softc, const char *pool_name,
uint32_t total_ctl_io, void **npool);
void ctl_pool_free(struct ctl_io_pool *pool);

View File

@ -314,48 +314,30 @@ tpcl_resolve(struct ctl_softc *softc, int init_port,
struct scsi_ec_cscd_id *cscdid;
struct ctl_port *port;
struct ctl_lun *lun;
uint64_t lunid = UINT64_MAX, l;
int i;
uint64_t lunid = UINT64_MAX;
if (cscd->type_code != EC_CSCD_ID)
return (lunid);
cscdid = (struct scsi_ec_cscd_id *)cscd;
mtx_lock(&softc->ctl_lock);
if (init_port >= 0) {
if (init_port >= 0)
port = softc->ctl_ports[ctl_port_idx(init_port)];
if (port == NULL || port->lun_map == NULL)
init_port = -1;
}
if (init_port < 0) {
STAILQ_FOREACH(lun, &softc->lun_list, links) {
if (lun->lun_devid == NULL)
continue;
if (scsi_devid_match(lun->lun_devid->data,
lun->lun_devid->len, &cscdid->codeset,
cscdid->length + 4) == 0) {
lunid = lun->lun;
if (ss && lun->be_lun)
*ss = lun->be_lun->blocksize;
break;
}
}
} else {
for (i = 0; i < CTL_MAX_LUNS; i++) {
l = port->lun_map(port->targ_lun_arg, i);
if (l >= CTL_MAX_LUNS)
continue;
lun = softc->ctl_luns[l];
if (lun == NULL || lun->lun_devid == NULL)
continue;
if (scsi_devid_match(lun->lun_devid->data,
lun->lun_devid->len, &cscdid->codeset,
cscdid->length + 4) == 0) {
lunid = lun->lun;
if (ss && lun->be_lun)
*ss = lun->be_lun->blocksize;
break;
}
else
port = NULL;
STAILQ_FOREACH(lun, &softc->lun_list, links) {
if (port != NULL &&
ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
continue;
if (lun->lun_devid == NULL)
continue;
if (scsi_devid_match(lun->lun_devid->data,
lun->lun_devid->len, &cscdid->codeset,
cscdid->length + 4) == 0) {
lunid = lun->lun;
if (ss && lun->be_lun)
*ss = lun->be_lun->blocksize;
break;
}
}
mtx_unlock(&softc->ctl_lock);

View File

@ -2677,7 +2677,7 @@ extern kmem_cache_t *zio_buf_cache[];
extern kmem_cache_t *zio_data_buf_cache[];
extern kmem_cache_t *range_seg_cache;
static void __noinline
static __noinline void
arc_kmem_reap_now(arc_reclaim_strategy_t strat)
{
size_t i;

View File

@ -353,7 +353,7 @@ txg_rele_to_sync(txg_handle_t *th)
* On return, the transaction group has reached a stable state in which it can
* then be passed off to the syncing context.
*/
static void
static __noinline void
txg_quiesce(dsl_pool_t *dp, uint64_t txg)
{
tx_state_t *tx = &dp->dp_tx;

View File

@ -651,6 +651,7 @@ USB_HOST_ALIGN opt_usb.h
USB_REQ_DEBUG opt_usb.h
USB_TEMPLATE opt_usb.h
USB_VERBOSE opt_usb.h
USB_DMA_SINGLE_ALLOC opt_usb.h
USB_EHCI_BIG_ENDIAN_DESC opt_usb.h
U3G_DEBUG opt_u3g.h
UKBD_DFLT_KEYMAP opt_ukbd.h

View File

@ -556,26 +556,27 @@ enum ahci_err_type {
bus_write_multi_stream_4((res), (offset), (addr), (count))
#define AHCI_Q_NOFORCE 1
#define AHCI_Q_NOPMP 2
#define AHCI_Q_NONCQ 4
#define AHCI_Q_1CH 8
#define AHCI_Q_2CH 0x10
#define AHCI_Q_4CH 0x20
#define AHCI_Q_EDGEIS 0x40
#define AHCI_Q_SATA2 0x80
#define AHCI_Q_NOBSYRES 0x100
#define AHCI_Q_NOAA 0x200
#define AHCI_Q_NOCOUNT 0x400
#define AHCI_Q_ALTSIG 0x800
#define AHCI_Q_NOMSI 0x1000
#define AHCI_Q_ATI_PMP_BUG 0x2000
#define AHCI_Q_MAXIO_64K 0x4000
#define AHCI_Q_SATA1_UNIT0 0x8000 /* need better method for this */
#define AHCI_Q_ABAR0 0x10000
#define AHCI_Q_NOFORCE 0x00000001
#define AHCI_Q_NOPMP 0x00000002
#define AHCI_Q_NONCQ 0x00000004
#define AHCI_Q_1CH 0x00000008
#define AHCI_Q_2CH 0x00000010
#define AHCI_Q_4CH 0x00000020
#define AHCI_Q_EDGEIS 0x00000040
#define AHCI_Q_SATA2 0x00000080
#define AHCI_Q_NOBSYRES 0x00000100
#define AHCI_Q_NOAA 0x00000200
#define AHCI_Q_NOCOUNT 0x00000400
#define AHCI_Q_ALTSIG 0x00000800
#define AHCI_Q_NOMSI 0x00001000
#define AHCI_Q_ATI_PMP_BUG 0x00002000
#define AHCI_Q_MAXIO_64K 0x00004000
#define AHCI_Q_SATA1_UNIT0 0x00008000 /* need better method for this */
#define AHCI_Q_ABAR0 0x00010000
#define AHCI_Q_1MSI 0x00020000
#define AHCI_Q_BIT_STRING \
"\020" \
"\021" \
"\001NOFORCE" \
"\002NOPMP" \
"\003NONCQ" \
@ -592,7 +593,8 @@ enum ahci_err_type {
"\016ATI_PMP_BUG" \
"\017MAXIO_64K" \
"\020SATA1_UNIT0" \
"\021ABAR0"
"\021ABAR0" \
"\0221MSI"
int ahci_attach(device_t dev);
int ahci_detach(device_t dev);

View File

@ -55,12 +55,17 @@ static const struct {
int quirks;
} ahci_ids[] = {
{0x43801002, 0x00, "AMD SB600",
AHCI_Q_NOMSI | AHCI_Q_ATI_PMP_BUG | AHCI_Q_MAXIO_64K},
{0x43901002, 0x00, "AMD SB7x0/SB8x0/SB9x0", AHCI_Q_ATI_PMP_BUG},
{0x43911002, 0x00, "AMD SB7x0/SB8x0/SB9x0", AHCI_Q_ATI_PMP_BUG},
{0x43921002, 0x00, "AMD SB7x0/SB8x0/SB9x0", AHCI_Q_ATI_PMP_BUG},
{0x43931002, 0x00, "AMD SB7x0/SB8x0/SB9x0", AHCI_Q_ATI_PMP_BUG},
{0x43941002, 0x00, "AMD SB7x0/SB8x0/SB9x0", AHCI_Q_ATI_PMP_BUG},
AHCI_Q_NOMSI | AHCI_Q_ATI_PMP_BUG | AHCI_Q_MAXIO_64K},
{0x43901002, 0x00, "AMD SB7x0/SB8x0/SB9x0",
AHCI_Q_ATI_PMP_BUG | AHCI_Q_1MSI},
{0x43911002, 0x00, "AMD SB7x0/SB8x0/SB9x0",
AHCI_Q_ATI_PMP_BUG | AHCI_Q_1MSI},
{0x43921002, 0x00, "AMD SB7x0/SB8x0/SB9x0",
AHCI_Q_ATI_PMP_BUG | AHCI_Q_1MSI},
{0x43931002, 0x00, "AMD SB7x0/SB8x0/SB9x0",
AHCI_Q_ATI_PMP_BUG | AHCI_Q_1MSI},
{0x43941002, 0x00, "AMD SB7x0/SB8x0/SB9x0",
AHCI_Q_ATI_PMP_BUG | AHCI_Q_1MSI},
/* Not sure SB8x0/SB9x0 needs this quirk. Be conservative though */
{0x43951002, 0x00, "AMD SB8x0/SB9x0", AHCI_Q_ATI_PMP_BUG},
{0x78001022, 0x00, "AMD Hudson-2", 0},
@ -137,7 +142,7 @@ static const struct {
{0x1f378086, 0x00, "Intel Avoton (RAID)", 0},
{0x1f3e8086, 0x00, "Intel Avoton (RAID)", 0},
{0x1f3f8086, 0x00, "Intel Avoton (RAID)", 0},
{0x23a38086, 0x00, "Intel Coleto Creek", 0},
{0x23a38086, 0x00, "Intel Coleto Creek", 0},
{0x28238086, 0x00, "Intel Wellsburg (RAID)", 0},
{0x28278086, 0x00, "Intel Wellsburg (RAID)", 0},
{0x8c028086, 0x00, "Intel Lynx Point", 0},
@ -410,10 +415,13 @@ ahci_pci_attach(device_t dev)
/* Setup interrupts. */
/* Setup MSI register parameters */
ctlr->msi = 2;
/* Process hints. */
if (ctlr->quirks & AHCI_Q_NOMSI)
ctlr->msi = 0;
else if (ctlr->quirks & AHCI_Q_1MSI)
ctlr->msi = 1;
else
ctlr->msi = 2;
resource_int_value(device_get_name(dev),
device_get_unit(dev), "msi", &ctlr->msi);
ctlr->numirqs = 1;

View File

@ -143,6 +143,9 @@ gpiobus_attach_bus(device_t dev)
device_delete_child(dev, busdev);
return (NULL);
}
#ifdef FDT
ofw_gpiobus_register_provider(dev);
#endif
bus_generic_attach(dev);
return (busdev);
@ -152,6 +155,10 @@ int
gpiobus_detach_bus(device_t dev)
{
#ifdef FDT
ofw_gpiobus_unregister_provider(dev);
#endif
return (bus_generic_detach(dev));
}

View File

@ -93,6 +93,8 @@ gpio_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells,
}
device_t ofw_gpiobus_add_fdt_child(device_t, phandle_t);
void ofw_gpiobus_register_provider(device_t);
void ofw_gpiobus_unregister_provider(device_t);
#endif
int gpio_check_flags(uint32_t, uint32_t);
device_t gpiobus_attach_bus(device_t);

View File

@ -217,6 +217,24 @@ ofw_gpiobus_parse_gpios(struct gpiobus_softc *sc, struct gpiobus_ivar *dinfo,
return (0);
}
void
ofw_gpiobus_register_provider(device_t provider)
{
phandle_t node;
node = ofw_bus_get_node(provider);
OF_device_register_xref(OF_xref_from_node(node), provider);
}
void
ofw_gpiobus_unregister_provider(device_t provider)
{
phandle_t node;
node = ofw_bus_get_node(provider);
OF_device_register_xref(OF_xref_from_node(node), NULL);
}
static struct ofw_gpiobus_devinfo *
ofw_gpiobus_setup_devinfo(device_t dev, phandle_t node)
{

View File

@ -115,7 +115,9 @@ struct iscsi_bhs_scsi_response {
uint8_t bhssr_status;
uint8_t bhssr_total_ahs_len;
uint8_t bhssr_data_segment_len[3];
uint64_t bhssr_reserved;
uint16_t bhssr_status_qualifier;
uint16_t bhssr_reserved;
uint32_t bhssr_reserved2;
uint32_t bhssr_initiator_task_tag;
uint32_t bhssr_snack_tag;
uint32_t bhssr_statsn;
@ -135,6 +137,10 @@ CTASSERT(sizeof(struct iscsi_bhs_scsi_response) == ISCSI_BHS_SIZE);
#define BHSTMR_FUNCTION_TARGET_WARM_RESET 6
#define BHSTMR_FUNCTION_TARGET_COLD_RESET 7
#define BHSTMR_FUNCTION_TASK_REASSIGN 8
#define BHSTMR_FUNCTION_QUERY_TASK 9
#define BHSTMR_FUNCTION_QUERY_TASK_SET 10
#define BHSTMR_FUNCTION_I_T_NEXUS_RESET 11
#define BHSTMR_FUNCTION_QUERY_ASYNC_EVENT 12
struct iscsi_bhs_task_management_request {
uint8_t bhstmr_opcode;
@ -154,7 +160,14 @@ struct iscsi_bhs_task_management_request {
CTASSERT(sizeof(struct iscsi_bhs_task_management_request) == ISCSI_BHS_SIZE);
#define BHSTMR_RESPONSE_FUNCTION_COMPLETE 0
#define BHSTMR_RESPONSE_TASK_DOES_NOT_EXIST 1
#define BHSTMR_RESPONSE_LUN_DOES_NOT_EXIST 2
#define BHSTMR_RESPONSE_TASK_STILL_ALLEGIANT 3
#define BHSTMR_RESPONSE_TASK_ALL_REASS_NOT_SUPP 4
#define BHSTMR_RESPONSE_FUNCTION_NOT_SUPPORTED 5
#define BHSTMR_RESPONSE_FUNCTION_AUTH_FAIL 6
#define BHSTMR_RESPONSE_FUNCTION_SUCCEEDED 7
#define BHSTMR_RESPONSE_FUNCTION_REJECTED 255
struct iscsi_bhs_task_management_response {
uint8_t bhstmr_opcode;
@ -163,7 +176,8 @@ struct iscsi_bhs_task_management_response {
uint8_t bhstmr_reserved;
uint8_t bhstmr_total_ahs_len;
uint8_t bhstmr_data_segment_len[3];
uint64_t bhstmr_reserved2;
uint8_t bhstmr_additional_reponse_information[3];
uint8_t bhstmr_reserved2[5];
uint32_t bhstmr_initiator_task_tag;
uint32_t bhstmr_reserved3;
uint32_t bhstmr_statsn;

View File

@ -1866,6 +1866,15 @@ xhci_setup_generic_chain_sub(struct xhci_std_temp *temp)
XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_DATA_STAGE);
if (temp->direction == UE_DIR_IN)
dword |= XHCI_TRB_3_DIR_IN | XHCI_TRB_3_ISP_BIT;
/*
* Section 3.2.9 in the XHCI
* specification about control
* transfers says that we should use a
* normal-TRB if there are more TRBs
* extending the data-stage
* TRB. Update the "trb_type".
*/
temp->trb_type = XHCI_TRB_TYPE_NORMAL;
break;
case XHCI_TRB_TYPE_STATUS_STAGE:
dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT |
@ -2106,7 +2115,8 @@ xhci_setup_generic_chain(struct usb_xfer *xfer)
mult = 1;
temp.isoc_delta = 0;
temp.isoc_frame = 0;
temp.trb_type = XHCI_TRB_TYPE_DATA_STAGE;
temp.trb_type = xfer->flags_int.control_did_data ?
XHCI_TRB_TYPE_NORMAL : XHCI_TRB_TYPE_DATA_STAGE;
} else {
x = 0;
mult = 1;

View File

@ -101,6 +101,7 @@ struct usb_xfer_flags_int {
* sent */
uint8_t control_act:1; /* set if control transfer is active */
uint8_t control_stall:1; /* set if control transfer should be stalled */
uint8_t control_did_data:1; /* set if control DATA has been transferred */
uint8_t short_frames_ok:1; /* filtered version */
uint8_t short_xfer_ok:1; /* filtered version */

View File

@ -113,6 +113,8 @@ static uint8_t scsi_request_sense[] = { 0x03, 0x00, 0x00, 0x00, 0x12, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static uint8_t scsi_read_capacity[] = { 0x25, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
static uint8_t scsi_prevent_removal[] = { 0x1e, 0, 0, 0, 1, 0 };
static uint8_t scsi_allow_removal[] = { 0x1e, 0, 0, 0, 0, 0 };
#ifndef USB_MSCTEST_BULK_SIZE
#define USB_MSCTEST_BULK_SIZE 64 /* dummy */
@ -702,10 +704,28 @@ usb_msc_auto_quirk(struct usb_device *udev, uint8_t iface_index)
USB_MS_HZ);
if (err != 0) {
if (err != ERR_CSW_FAILED)
goto error;
DPRINTF("Test unit ready failed\n");
}
err = bbb_command_start(sc, DIR_OUT, 0, NULL, 0,
&scsi_prevent_removal, sizeof(scsi_prevent_removal),
USB_MS_HZ);
if (err == 0) {
err = bbb_command_start(sc, DIR_OUT, 0, NULL, 0,
&scsi_allow_removal, sizeof(scsi_allow_removal),
USB_MS_HZ);
}
if (err != 0) {
if (err != ERR_CSW_FAILED)
goto error;
DPRINTF("Device doesn't handle prevent and allow removal\n");
usbd_add_dynamic_quirk(udev, UQ_MSC_NO_PREVENT_ALLOW);
}
timeout = 1;
retry_sync_cache:
@ -718,11 +738,9 @@ usb_msc_auto_quirk(struct usb_device *udev, uint8_t iface_index)
if (err != ERR_CSW_FAILED)
goto error;
DPRINTF("Device doesn't handle synchronize cache "
"and prevent allow medium removal\n");
DPRINTF("Device doesn't handle synchronize cache\n");
usbd_add_dynamic_quirk(udev, UQ_MSC_NO_SYNC_CACHE);
usbd_add_dynamic_quirk(udev, UQ_MSC_NO_PREVENT_ALLOW);
} else {
/*
@ -749,13 +767,10 @@ usb_msc_auto_quirk(struct usb_device *udev, uint8_t iface_index)
goto retry_sync_cache;
DPRINTF("Device most likely doesn't "
"handle synchronize cache nor"
"prevent allow medium removal\n");
"handle synchronize cache\n");
usbd_add_dynamic_quirk(udev,
UQ_MSC_NO_SYNC_CACHE);
usbd_add_dynamic_quirk(udev,
UQ_MSC_NO_PREVENT_ALLOW);
} else {
if (err != ERR_CSW_FAILED)
goto error;

View File

@ -237,7 +237,11 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm,
n_obj = 1;
} else {
/* compute number of objects per page */
#ifdef USB_DMA_SINGLE_ALLOC
n_obj = 1;
#else
n_obj = (USB_PAGE_SIZE / size);
#endif
/*
* Compute number of DMA chunks, rounded up
* to nearest one:
@ -273,15 +277,33 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm,
&parm->curr_xfer->xroot->dma_parent_tag;
}
if (ppc) {
*ppc = parm->xfer_page_cache_ptr;
if (ppc != NULL) {
if (n_obj != 1)
*ppc = parm->xfer_page_cache_ptr;
else
*ppc = parm->dma_page_cache_ptr;
}
r = count; /* set remainder count */
z = n_obj * size; /* set allocation size */
pc = parm->xfer_page_cache_ptr;
pg = parm->dma_page_ptr;
for (x = 0; x != n_dma_pc; x++) {
if (n_obj == 1) {
/*
* Avoid mapping memory twice if only a single object
* should be allocated per page cache:
*/
for (x = 0; x != n_dma_pc; x++) {
if (usb_pc_alloc_mem(parm->dma_page_cache_ptr,
pg, z, align)) {
return (1); /* failure */
}
/* Make room for one DMA page cache and "n_dma_pg" pages */
parm->dma_page_cache_ptr++;
pg += n_dma_pg;
}
} else {
for (x = 0; x != n_dma_pc; x++) {
if (r < n_obj) {
/* compute last remainder */
@ -294,7 +316,7 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm,
}
/* Set beginning of current buffer */
buf = parm->dma_page_cache_ptr->buffer;
/* Make room for one DMA page cache and one page */
/* Make room for one DMA page cache and "n_dma_pg" pages */
parm->dma_page_cache_ptr++;
pg += n_dma_pg;
@ -314,6 +336,7 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm,
}
mtx_unlock(pc->tag_parent->mtx);
}
}
}
parm->xfer_page_cache_ptr = pc;
@ -1408,6 +1431,29 @@ usbd_control_transfer_init(struct usb_xfer *xfer)
(req.bmRequestType & UT_READ) ? UE_DIR_IN : UE_DIR_OUT;
}
/*------------------------------------------------------------------------*
* usbd_control_transfer_did_data
*
* This function returns non-zero if a control endpoint has
* transferred the first DATA packet after the SETUP packet.
* Else it returns zero.
*------------------------------------------------------------------------*/
static uint8_t
usbd_control_transfer_did_data(struct usb_xfer *xfer)
{
struct usb_device_request req;
/* SETUP packet is not yet sent */
if (xfer->flags_int.control_hdr != 0)
return (0);
/* copy out the USB request header */
usbd_copy_out(xfer->frbuffers, 0, &req, sizeof(req));
/* compare remainder to the initial value */
return (xfer->flags_int.control_rem != UGETW(req.wLength));
}
/*------------------------------------------------------------------------*
* usbd_setup_ctrl_transfer
*
@ -1513,6 +1559,11 @@ usbd_setup_ctrl_transfer(struct usb_xfer *xfer)
len = (xfer->sumlen - sizeof(struct usb_device_request));
}
/* update did data flag */
xfer->flags_int.control_did_data =
usbd_control_transfer_did_data(xfer);
/* check if there is a length mismatch */
if (len > xfer->flags_int.control_rem) {

View File

@ -74,8 +74,20 @@
#define ARGE_CLEAR_BITS(sc, reg, bits) \
ARGE_WRITE(sc, reg, ARGE_READ(sc, (reg)) & ~(bits))
#define ARGE_MDIO_WRITE(_sc, _reg, _val) \
ARGE_WRITE((_sc), (_reg), (_val))
/*
* The linux driver code for the MDIO bus does a read-after-write
* which seems to be required on MIPS74k platforms for correct
* behaviour.
*
* So, ARGE_WRITE() does the write + barrier, and the following
* ARGE_READ() seems to flush the thing all the way through the device
* FIFO(s) before we continue issuing MDIO bus updates.
*/
#define ARGE_MDIO_WRITE(_sc, _reg, _val) \
do { \
ARGE_WRITE((_sc), (_reg), (_val)); \
ARGE_READ((_sc), (_reg)); \
} while (0)
#define ARGE_MDIO_READ(_sc, _reg) \
ARGE_READ((_sc), (_reg))
#define ARGE_MDIO_BARRIER_READ(_sc) ARGE_BARRIER_READ(_sc)

View File

@ -789,6 +789,10 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
IPSTAT_INC(ips_odropped);
goto done;
}
/* make sure the flowid is the same for the fragmented mbufs */
M_HASHTYPE_SET(m, M_HASHTYPE_GET(m0));
m->m_pkthdr.flowid = m0->m_pkthdr.flowid;
/* copy multicast flag, if any */
m->m_flags |= (m0->m_flags & M_MCAST);
/*
* In the first mbuf, leave room for the link header, then

View File

@ -143,7 +143,7 @@ SVCXPRT *
svc_vc_create(SVCPOOL *pool, struct socket *so, size_t sendsize,
size_t recvsize)
{
SVCXPRT *xprt;
SVCXPRT *xprt = NULL;
struct sockaddr* sa;
int error;

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@
.\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
.\" $FreeBSD$
.\"
.Dd December 17, 2014
.Dd February 1, 2015
.Dt CTLADM 8
.Os
.Sh NAME
@ -196,11 +196,17 @@
.Ic portlist
.Op Fl f Ar frontend
.Op Fl i
.Op Fl l
.Op Fl p Ar targ_port
.Op Fl q
.Op Fl v
.Op Fl x
.Nm
.Ic lunmap
.Aq Fl p Ar targ_port
.Op Fl l Ar pLUN
.Op Fl L Ar cLUN
.Nm
.Ic dumpooa
.Nm
.Ic dumpstructs
@ -782,7 +788,9 @@ List CTL frontend ports.
.It Fl f Ar frontend
Specify the frontend type.
.It Fl i
Report target and connected initiators addresses
Report target and connected initiators addresses.
.It Fl l
Report LUN mapping.
.It Fl p Ar targ_port
Specify the frontend port number.
.It Fl q
@ -792,6 +800,31 @@ Enable verbose output (report all port options).
.It Fl x
Output the port list in XML format.
.El
.It Ic lunmap
Change LUN mapping for specified port.
If both
.Ar pLUN
and
.Ar cLUN
are specified -- LUN will be mapped.
If
.Ar pLUN
is specified, but
.Ar cLUN
is not -- LUN will be unmapped.
If neither
.Ar pLUN
nor
.Ar cLUN
are specified -- LUN mapping will be disabled, exposing all CTL LUNs.
.Bl -tag -width 12n
.It Fl p Ar targ_port
Specify the frontend port number.
.It Fl l Ar pLUN
LUN number visible by specified port.
.It Fl L Ar cLUN
CTL LUN number.
.El
.It Ic dumpooa
Dump the OOA (Order Of Arrival) queue for each LUN registered with CTL.
.It Ic dumpstructs

View File

@ -121,7 +121,8 @@ typedef enum {
CTLADM_CMD_MODIFY,
CTLADM_CMD_ISLIST,
CTLADM_CMD_ISLOGOUT,
CTLADM_CMD_ISTERMINATE
CTLADM_CMD_ISTERMINATE,
CTLADM_CMD_LUNMAP
} ctladm_cmdfunction;
typedef enum {
@ -188,10 +189,11 @@ static struct ctladm_opts option_table[] = {
{"islogout", CTLADM_CMD_ISLOGOUT, CTLADM_ARG_NONE, "ac:i:p:"},
{"isterminate", CTLADM_CMD_ISTERMINATE, CTLADM_ARG_NONE, "ac:i:p:"},
{"lunlist", CTLADM_CMD_LUNLIST, CTLADM_ARG_NONE, NULL},
{"lunmap", CTLADM_CMD_LUNMAP, CTLADM_ARG_NONE, "p:l:L:"},
{"modesense", CTLADM_CMD_MODESENSE, CTLADM_ARG_NEED_TL, "P:S:dlm:c:"},
{"modify", CTLADM_CMD_MODIFY, CTLADM_ARG_NONE, "b:l:s:"},
{"port", CTLADM_CMD_PORT, CTLADM_ARG_NONE, "lo:p:qt:w:W:x"},
{"portlist", CTLADM_CMD_PORTLIST, CTLADM_ARG_NONE, "f:ip:qvx"},
{"portlist", CTLADM_CMD_PORTLIST, CTLADM_ARG_NONE, "f:ilp:qvx"},
{"prin", CTLADM_CMD_PRES_IN, CTLADM_ARG_NEED_TL, "a:"},
{"prout", CTLADM_CMD_PRES_OUT, CTLADM_ARG_NEED_TL, "a:k:r:s:"},
{"read", CTLADM_CMD_READ, CTLADM_ARG_NEED_TL, rw_opts},
@ -4106,8 +4108,9 @@ struct cctl_port {
char *frontend_type;
char *name;
int pp, vp;
char *target, *port;
char *target, *port, *lun_map;
STAILQ_HEAD(,cctl_lun_nv) init_list;
STAILQ_HEAD(,cctl_lun_nv) lun_list;
STAILQ_HEAD(,cctl_lun_nv) attr_list;
STAILQ_ENTRY(cctl_port) links;
};
@ -4161,6 +4164,7 @@ cctl_start_pelement(void *user_data, const char *name, const char **attr)
portlist->cur_port = cur_port;
STAILQ_INIT(&cur_port->init_list);
STAILQ_INIT(&cur_port->lun_list);
STAILQ_INIT(&cur_port->attr_list);
cur_port->port_id = portlist->cur_id;
STAILQ_INSERT_TAIL(&portlist->port_list, cur_port, links);
@ -4220,6 +4224,9 @@ cctl_end_pelement(void *user_data, const char *name)
} else if (strcmp(name, "port") == 0) {
cur_port->port = str;
str = NULL;
} else if (strcmp(name, "lun_map") == 0) {
cur_port->lun_map = str;
str = NULL;
} else if (strcmp(name, "targ_port") == 0) {
portlist->cur_port = NULL;
} else if (strcmp(name, "ctlportlist") == 0) {
@ -4232,7 +4239,8 @@ cctl_end_pelement(void *user_data, const char *name)
err(1, "%s: can't allocate %zd bytes for nv pair",
__func__, sizeof(*nv));
if (strcmp(name, "initiator") == 0)
if (strcmp(name, "initiator") == 0 ||
strcmp(name, "lun") == 0)
asprintf(&nv->name, "%ju", portlist->cur_id);
else
nv->name = strdup(name);
@ -4244,6 +4252,8 @@ cctl_end_pelement(void *user_data, const char *name)
str = NULL;
if (strcmp(name, "initiator") == 0)
STAILQ_INSERT_TAIL(&cur_port->init_list, nv, links);
else if (strcmp(name, "lun") == 0)
STAILQ_INSERT_TAIL(&cur_port->lun_list, nv, links);
else
STAILQ_INSERT_TAIL(&cur_port->attr_list, nv, links);
}
@ -4274,7 +4284,7 @@ cctl_portlist(int fd, int argc, char **argv, char *combinedopt)
int retval, c;
char *frontend = NULL;
uint64_t portarg = UINT64_MAX;
int verbose = 0, init = 0, quiet = 0;
int verbose = 0, init = 0, lun = 0, quiet = 0;
retval = 0;
port_len = 4096;
@ -4290,6 +4300,9 @@ cctl_portlist(int fd, int argc, char **argv, char *combinedopt)
case 'i':
init++;
break;
case 'l':
lun++;
break;
case 'p':
portarg = strtoll(optarg, NULL, 0);
break;
@ -4381,6 +4394,17 @@ cctl_portlist(int fd, int argc, char **argv, char *combinedopt)
}
}
if (lun || verbose) {
if (port->lun_map) {
STAILQ_FOREACH(nv, &port->lun_list, links)
printf(" LUN %s: %s\n",
nv->name, nv->value);
if (STAILQ_EMPTY(&port->lun_list))
printf(" No LUNs mapped\n");
} else
printf(" All LUNs mapped\n");
}
if (verbose) {
STAILQ_FOREACH(nv, &port->attr_list, links) {
printf(" %s=%s\n", nv->name, nv->value);
@ -4393,6 +4417,41 @@ cctl_portlist(int fd, int argc, char **argv, char *combinedopt)
return (retval);
}
static int
cctl_lunmap(int fd, int argc, char **argv, char *combinedopt)
{
struct ctl_lun_map lm;
int retval = 0, c;
retval = 0;
lm.port = UINT32_MAX;
lm.plun = UINT32_MAX;
lm.lun = UINT32_MAX;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
switch (c) {
case 'p':
lm.port = strtoll(optarg, NULL, 0);
break;
case 'l':
lm.plun = strtoll(optarg, NULL, 0);
break;
case 'L':
lm.lun = strtoll(optarg, NULL, 0);
break;
default:
break;
}
}
if (ioctl(fd, CTL_LUN_MAP, &lm) == -1) {
warn("%s: error issuing CTL_LUN_MAP ioctl", __func__);
retval = 1;
}
return (retval);
}
void
usage(int error)
{
@ -4430,6 +4489,7 @@ usage(int error)
" ctladm hardstop\n"
" ctladm hardstart\n"
" ctladm lunlist\n"
" ctladm lunmap -p targ_port [-l pLUN] [-L cLUN]\n"
" ctladm bbrread [dev_id] <-l lba> <-d datalen>\n"
" ctladm delay [dev_id] <-l datamove|done> [-T oneshot|cont]\n"
" [-t secs]\n"
@ -4529,10 +4589,15 @@ usage(int error)
"portlist options:\n"
"-f fronetnd : specify frontend type\n"
"-i : report target and initiators addresses\n"
"-l : report LUN mapping\n"
"-p targ_port : specify target port number\n"
"-q : omit header in list output\n"
"-v : verbose output (report all port options)\n"
"-x : output port list in XML format\n"
"lunmap options:\n"
"-p targ_port : specify target port number\n"
"-L pLUN : specify port-visible LUN\n"
"-L cLUN : specify CTL LUN\n"
"bbrread options:\n"
"-l lba : starting LBA\n"
"-d datalen : length, in bytes, to read\n",
@ -4760,6 +4825,9 @@ main(int argc, char **argv)
case CTLADM_CMD_PORTLIST:
retval = cctl_portlist(fd, argc, argv, combinedopt);
break;
case CTLADM_CMD_LUNMAP:
retval = cctl_lunmap(fd, argc, argv, combinedopt);
break;
case CTLADM_CMD_READCAPACITY:
retval = cctl_read_capacity(fd, target, lun, initid, retries,
argc, argv, combinedopt);

View File

@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd November 24, 2014
.Dd February 1, 2015
.Dt CTL.CONF 5
.Os
.Sh NAME
@ -60,9 +60,14 @@ file is:
.Dl ...
}
.No lun Ar name No {
.Dl path Ar path
}
.No target Ar name {
.Dl auth-group Ar name
.Dl portal-group Ar name
.Dl lun Ar number Ar name
.Dl lun Ar number No {
.Dl path Ar path
.Dl }
@ -95,6 +100,10 @@ Create a
configuration context,
defining a new portal-group,
which can then be assigned to any number of targets.
.It Ic lun Ar name
Create a
.Sy lun
configuration context, defining a LUN to be exported by some target(s).
.It Ic target Ar name
Create a
.Sy target
@ -312,6 +321,10 @@ IPv4 or IPv6 address to redirect initiators to.
When configured, all initiators attempting to connect to this target
will get redirected using "Target moved temporarily" login response.
Redirection happens after successful authentication.
.It Ic lun Ar number Ar name
Export previously defined
.Sy lun
by the parent target.
.It Ic lun Ar number
Create a
.Sy lun
@ -387,21 +400,21 @@ target iqn.2012-06.com.example:target0 {
}
}
lun example_1 {
path /dev/zvol/tank/example_1
}
target iqn.2012-06.com.example:target1 {
chap chapuser chapsecret
lun 0 {
path /dev/zvol/tank/example_1
}
lun 0 example_1
}
target iqn.2012-06.com.example:target2 {
auth-group ag0
portal-group pg0
lun 0 {
path /dev/zvol/tank/example2_0
}
lun 0 example_1
lun 1 {
path /dev/zvol/tank/example2_1
path /dev/zvol/tank/example_2
option foo bar
}
}

View File

@ -87,6 +87,7 @@ conf_new(void)
conf = calloc(1, sizeof(*conf));
if (conf == NULL)
log_err(1, "calloc");
TAILQ_INIT(&conf->conf_luns);
TAILQ_INIT(&conf->conf_targets);
TAILQ_INIT(&conf->conf_auth_groups);
TAILQ_INIT(&conf->conf_portal_groups);
@ -104,6 +105,7 @@ conf_new(void)
void
conf_delete(struct conf *conf)
{
struct lun *lun, *ltmp;
struct target *targ, *tmp;
struct auth_group *ag, *cagtmp;
struct portal_group *pg, *cpgtmp;
@ -111,6 +113,8 @@ conf_delete(struct conf *conf)
assert(conf->conf_pidfh == NULL);
TAILQ_FOREACH_SAFE(lun, &conf->conf_luns, l_next, ltmp)
lun_delete(lun);
TAILQ_FOREACH_SAFE(targ, &conf->conf_targets, t_next, tmp)
target_delete(targ);
TAILQ_FOREACH_SAFE(ag, &conf->conf_auth_groups, ag_next, cagtmp)
@ -1146,7 +1150,6 @@ target_new(struct conf *conf, const char *name)
for (i = 0; i < len; i++)
targ->t_name[i] = tolower(targ->t_name[i]);
TAILQ_INIT(&targ->t_luns);
targ->t_conf = conf;
TAILQ_INSERT_TAIL(&conf->conf_targets, targ, t_next);
@ -1156,12 +1159,9 @@ target_new(struct conf *conf, const char *name)
void
target_delete(struct target *targ)
{
struct lun *lun, *tmp;
TAILQ_REMOVE(&targ->t_conf->conf_targets, targ, t_next);
TAILQ_FOREACH_SAFE(lun, &targ->t_luns, l_next, tmp)
lun_delete(lun);
free(targ->t_name);
free(targ->t_redirection);
free(targ);
@ -1196,25 +1196,31 @@ target_set_redirection(struct target *target, const char *addr)
return (0);
}
void
target_set_ctl_port(struct target *target, uint32_t value)
{
target->t_ctl_port = value;
}
struct lun *
lun_new(struct target *targ, int lun_id)
lun_new(struct conf *conf, const char *name)
{
struct lun *lun;
lun = lun_find(targ, lun_id);
lun = lun_find(conf, name);
if (lun != NULL) {
log_warnx("duplicated lun %d for target \"%s\"",
lun_id, targ->t_name);
log_warnx("duplicated lun \"%s\"", name);
return (NULL);
}
lun = calloc(1, sizeof(*lun));
if (lun == NULL)
log_err(1, "calloc");
lun->l_lun = lun_id;
lun->l_conf = conf;
lun->l_name = checked_strdup(name);
TAILQ_INIT(&lun->l_options);
lun->l_target = targ;
TAILQ_INSERT_TAIL(&targ->t_luns, lun, l_next);
TAILQ_INSERT_TAIL(&conf->conf_luns, lun, l_next);
return (lun);
}
@ -1222,26 +1228,36 @@ lun_new(struct target *targ, int lun_id)
void
lun_delete(struct lun *lun)
{
struct target *targ;
struct lun_option *lo, *tmp;
int i;
TAILQ_REMOVE(&lun->l_target->t_luns, lun, l_next);
TAILQ_FOREACH(targ, &lun->l_conf->conf_targets, t_next) {
for (i = 0; i < MAX_LUNS; i++) {
if (targ->t_luns[i] == lun)
targ->t_luns[i] = NULL;
}
}
TAILQ_REMOVE(&lun->l_conf->conf_luns, lun, l_next);
TAILQ_FOREACH_SAFE(lo, &lun->l_options, lo_next, tmp)
lun_option_delete(lo);
free(lun->l_name);
free(lun->l_backend);
free(lun->l_device_id);
free(lun->l_path);
free(lun->l_scsiname);
free(lun->l_serial);
free(lun);
}
struct lun *
lun_find(const struct target *targ, int lun_id)
lun_find(const struct conf *conf, const char *name)
{
struct lun *lun;
TAILQ_FOREACH(lun, &targ->t_luns, l_next) {
if (lun->l_lun == lun_id)
TAILQ_FOREACH(lun, &conf->conf_luns, l_next) {
if (strcmp(lun->l_name, name) == 0)
return (lun);
}
@ -1276,6 +1292,13 @@ lun_set_path(struct lun *lun, const char *value)
lun->l_path = checked_strdup(value);
}
void
lun_set_scsiname(struct lun *lun, const char *value)
{
free(lun->l_scsiname);
lun->l_scsiname = checked_strdup(value);
}
void
lun_set_serial(struct lun *lun, const char *value)
{
@ -1304,8 +1327,8 @@ lun_option_new(struct lun *lun, const char *name, const char *value)
lo = lun_option_find(lun, name);
if (lo != NULL) {
log_warnx("duplicated lun option %s for lun %d, target \"%s\"",
name, lun->l_lun, lun->l_target->t_name);
log_warnx("duplicated lun option \"%s\" for lun \"%s\"",
name, lun->l_name);
return (NULL);
}
@ -1410,18 +1433,18 @@ conf_print(struct conf *conf)
fprintf(stderr, "\t listen %s\n", portal->p_listen);
fprintf(stderr, "}\n");
}
TAILQ_FOREACH(lun, &conf->conf_luns, l_next) {
fprintf(stderr, "\tlun %s {\n", lun->l_name);
fprintf(stderr, "\t\tpath %s\n", lun->l_path);
TAILQ_FOREACH(lo, &lun->l_options, lo_next)
fprintf(stderr, "\t\toption %s %s\n",
lo->lo_name, lo->lo_value);
fprintf(stderr, "\t}\n");
}
TAILQ_FOREACH(targ, &conf->conf_targets, t_next) {
fprintf(stderr, "target %s {\n", targ->t_name);
if (targ->t_alias != NULL)
fprintf(stderr, "\t alias %s\n", targ->t_alias);
TAILQ_FOREACH(lun, &targ->t_luns, l_next) {
fprintf(stderr, "\tlun %d {\n", lun->l_lun);
fprintf(stderr, "\t\tpath %s\n", lun->l_path);
TAILQ_FOREACH(lo, &lun->l_options, lo_next)
fprintf(stderr, "\t\toption %s %s\n",
lo->lo_name, lo->lo_value);
fprintf(stderr, "\t}\n");
}
fprintf(stderr, "}\n");
}
}
@ -1431,60 +1454,49 @@ static int
conf_verify_lun(struct lun *lun)
{
const struct lun *lun2;
const struct target *targ2;
if (lun->l_backend == NULL)
lun_set_backend(lun, "block");
if (strcmp(lun->l_backend, "block") == 0) {
if (lun->l_path == NULL) {
log_warnx("missing path for lun %d, target \"%s\"",
lun->l_lun, lun->l_target->t_name);
log_warnx("missing path for lun \"%s\"",
lun->l_name);
return (1);
}
} else if (strcmp(lun->l_backend, "ramdisk") == 0) {
if (lun->l_size == 0) {
log_warnx("missing size for ramdisk-backed lun %d, "
"target \"%s\"", lun->l_lun, lun->l_target->t_name);
log_warnx("missing size for ramdisk-backed lun \"%s\"",
lun->l_name);
return (1);
}
if (lun->l_path != NULL) {
log_warnx("path must not be specified "
"for ramdisk-backed lun %d, target \"%s\"",
lun->l_lun, lun->l_target->t_name);
"for ramdisk-backed lun \"%s\"",
lun->l_name);
return (1);
}
}
if (lun->l_lun < 0 || lun->l_lun > 255) {
log_warnx("invalid lun number for lun %d, target \"%s\"; "
"must be between 0 and 255", lun->l_lun,
lun->l_target->t_name);
return (1);
}
if (lun->l_blocksize == 0) {
lun_set_blocksize(lun, DEFAULT_BLOCKSIZE);
} else if (lun->l_blocksize < 0) {
log_warnx("invalid blocksize for lun %d, target \"%s\"; "
"must be larger than 0", lun->l_lun, lun->l_target->t_name);
log_warnx("invalid blocksize for lun \"%s\"; "
"must be larger than 0", lun->l_name);
return (1);
}
if (lun->l_size != 0 && lun->l_size % lun->l_blocksize != 0) {
log_warnx("invalid size for lun %d, target \"%s\"; "
"must be multiple of blocksize", lun->l_lun,
lun->l_target->t_name);
log_warnx("invalid size for lun \"%s\"; "
"must be multiple of blocksize", lun->l_name);
return (1);
}
TAILQ_FOREACH(targ2, &lun->l_target->t_conf->conf_targets, t_next) {
TAILQ_FOREACH(lun2, &targ2->t_luns, l_next) {
if (lun == lun2)
continue;
if (lun->l_path != NULL && lun2->l_path != NULL &&
strcmp(lun->l_path, lun2->l_path) == 0) {
log_debugx("WARNING: path \"%s\" duplicated "
"between lun %d, target \"%s\", and "
"lun %d, target \"%s\"", lun->l_path,
lun->l_lun, lun->l_target->t_name,
lun2->l_lun, lun2->l_target->t_name);
}
TAILQ_FOREACH(lun2, &lun->l_conf->conf_luns, l_next) {
if (lun == lun2)
continue;
if (lun->l_path != NULL && lun2->l_path != NULL &&
strcmp(lun->l_path, lun2->l_path) == 0) {
log_debugx("WARNING: path \"%s\" duplicated "
"between lun \"%s\", and "
"lun \"%s\"", lun->l_path,
lun->l_name, lun2->l_name);
}
}
@ -1499,11 +1511,16 @@ conf_verify(struct conf *conf)
struct target *targ;
struct lun *lun;
bool found;
int error;
int error, i;
if (conf->conf_pidfile_path == NULL)
conf->conf_pidfile_path = checked_strdup(DEFAULT_PIDFILE);
TAILQ_FOREACH(lun, &conf->conf_luns, l_next) {
error = conf_verify_lun(lun);
if (error != 0)
return (error);
}
TAILQ_FOREACH(targ, &conf->conf_targets, t_next) {
if (targ->t_auth_group == NULL) {
targ->t_auth_group = auth_group_find(conf,
@ -1516,11 +1533,9 @@ conf_verify(struct conf *conf)
assert(targ->t_portal_group != NULL);
}
found = false;
TAILQ_FOREACH(lun, &targ->t_luns, l_next) {
error = conf_verify_lun(lun);
if (error != 0)
return (error);
found = true;
for (i = 0; i < MAX_LUNS; i++) {
if (targ->t_luns[i] != NULL)
found = true;
}
if (!found && targ->t_redirection == NULL) {
log_warnx("no LUNs defined for target \"%s\"",
@ -1657,126 +1672,128 @@ conf_apply(struct conf *oldconf, struct conf *newconf)
* be somewhat hairy, though, and lun deletion failures don't
* really happen, so leave it as it is for now.
*/
/*
* First, remove any targets present in the old configuration
* and missing in the new one.
*/
TAILQ_FOREACH_SAFE(oldtarg, &oldconf->conf_targets, t_next, tmptarg) {
/*
* First, remove any targets present in the old configuration
* and missing in the new one.
*/
newtarg = target_find(newconf, oldtarg->t_name);
if (newtarg == NULL) {
error = kernel_port_remove(oldtarg);
if (newtarg != NULL)
continue;
error = kernel_port_remove(oldtarg);
if (error != 0) {
log_warnx("failed to remove target %s",
oldtarg->t_name);
/*
* XXX: Uncomment after fixing the root cause.
*
* cumulated_error++;
*/
}
}
/*
* Second, remove any LUNs present in the old configuration
* and missing in the new one.
*/
TAILQ_FOREACH_SAFE(oldlun, &oldconf->conf_luns, l_next, tmplun) {
newlun = lun_find(newconf, oldlun->l_name);
if (newlun == NULL) {
log_debugx("lun \"%s\", CTL lun %d "
"not found in new configuration; "
"removing", oldlun->l_name, oldlun->l_ctl_lun);
error = kernel_lun_remove(oldlun);
if (error != 0) {
log_warnx("failed to remove target %s",
oldtarg->t_name);
/*
* XXX: Uncomment after fixing the root cause.
*
* cumulated_error++;
*/
}
TAILQ_FOREACH_SAFE(oldlun, &oldtarg->t_luns, l_next,
tmplun) {
log_debugx("target %s not found in new "
"configuration; removing its lun %d, "
"backed by CTL lun %d",
oldtarg->t_name, oldlun->l_lun,
oldlun->l_ctl_lun);
error = kernel_lun_remove(oldlun);
if (error != 0) {
log_warnx("failed to remove lun %d, "
"target %s, CTL lun %d",
oldlun->l_lun, oldtarg->t_name,
oldlun->l_ctl_lun);
cumulated_error++;
}
log_warnx("failed to remove lun \"%s\", "
"CTL lun %d",
oldlun->l_name, oldlun->l_ctl_lun);
cumulated_error++;
}
continue;
}
/*
* Second, remove any LUNs present in the old target
* and missing in the new one.
* Also remove the LUNs changed by more than size.
*/
TAILQ_FOREACH_SAFE(oldlun, &oldtarg->t_luns, l_next, tmplun) {
newlun = lun_find(newtarg, oldlun->l_lun);
if (newlun == NULL) {
log_debugx("lun %d, target %s, CTL lun %d "
"not found in new configuration; "
"removing", oldlun->l_lun, oldtarg->t_name,
oldlun->l_ctl_lun);
error = kernel_lun_remove(oldlun);
changed = 0;
assert(oldlun->l_backend != NULL);
assert(newlun->l_backend != NULL);
if (strcmp(newlun->l_backend, oldlun->l_backend) != 0) {
log_debugx("backend for lun \"%s\", "
"CTL lun %d changed; removing",
oldlun->l_name, oldlun->l_ctl_lun);
changed = 1;
}
if (oldlun->l_blocksize != newlun->l_blocksize) {
log_debugx("blocksize for lun \"%s\", "
"CTL lun %d changed; removing",
oldlun->l_name, oldlun->l_ctl_lun);
changed = 1;
}
if (newlun->l_device_id != NULL &&
(oldlun->l_device_id == NULL ||
strcmp(oldlun->l_device_id, newlun->l_device_id) !=
0)) {
log_debugx("device-id for lun \"%s\", "
"CTL lun %d changed; removing",
oldlun->l_name, oldlun->l_ctl_lun);
changed = 1;
}
if (newlun->l_path != NULL &&
(oldlun->l_path == NULL ||
strcmp(oldlun->l_path, newlun->l_path) != 0)) {
log_debugx("path for lun \"%s\", "
"CTL lun %d, changed; removing",
oldlun->l_name, oldlun->l_ctl_lun);
changed = 1;
}
if (newlun->l_serial != NULL &&
(oldlun->l_serial == NULL ||
strcmp(oldlun->l_serial, newlun->l_serial) != 0)) {
log_debugx("serial for lun \"%s\", "
"CTL lun %d changed; removing",
oldlun->l_name, oldlun->l_ctl_lun);
changed = 1;
}
if (changed) {
error = kernel_lun_remove(oldlun);
if (error != 0) {
log_warnx("failed to remove lun \"%s\", "
"CTL lun %d",
oldlun->l_name, oldlun->l_ctl_lun);
cumulated_error++;
}
lun_delete(oldlun);
continue;
}
lun_set_ctl_lun(newlun, oldlun->l_ctl_lun);
}
TAILQ_FOREACH_SAFE(newlun, &newconf->conf_luns, l_next, tmplun) {
oldlun = lun_find(oldconf, newlun->l_name);
if (oldlun != NULL) {
if (newlun->l_size != oldlun->l_size ||
newlun->l_size == 0) {
log_debugx("resizing lun \"%s\", CTL lun %d",
newlun->l_name, newlun->l_ctl_lun);
error = kernel_lun_resize(newlun);
if (error != 0) {
log_warnx("failed to remove lun %d, "
"target %s, CTL lun %d",
oldlun->l_lun, oldtarg->t_name,
oldlun->l_ctl_lun);
log_warnx("failed to "
"resize lun \"%s\", CTL lun %d",
newlun->l_name,
newlun->l_ctl_lun);
cumulated_error++;
}
continue;
}
/*
* Also remove the LUNs changed by more than size.
*/
changed = 0;
assert(oldlun->l_backend != NULL);
assert(newlun->l_backend != NULL);
if (strcmp(newlun->l_backend, oldlun->l_backend) != 0) {
log_debugx("backend for lun %d, target %s, "
"CTL lun %d changed; removing",
oldlun->l_lun, oldtarg->t_name,
oldlun->l_ctl_lun);
changed = 1;
}
if (oldlun->l_blocksize != newlun->l_blocksize) {
log_debugx("blocksize for lun %d, target %s, "
"CTL lun %d changed; removing",
oldlun->l_lun, oldtarg->t_name,
oldlun->l_ctl_lun);
changed = 1;
}
if (newlun->l_device_id != NULL &&
(oldlun->l_device_id == NULL ||
strcmp(oldlun->l_device_id, newlun->l_device_id) !=
0)) {
log_debugx("device-id for lun %d, target %s, "
"CTL lun %d changed; removing",
oldlun->l_lun, oldtarg->t_name,
oldlun->l_ctl_lun);
changed = 1;
}
if (newlun->l_path != NULL &&
(oldlun->l_path == NULL ||
strcmp(oldlun->l_path, newlun->l_path) != 0)) {
log_debugx("path for lun %d, target %s, "
"CTL lun %d, changed; removing",
oldlun->l_lun, oldtarg->t_name,
oldlun->l_ctl_lun);
changed = 1;
}
if (newlun->l_serial != NULL &&
(oldlun->l_serial == NULL ||
strcmp(oldlun->l_serial, newlun->l_serial) != 0)) {
log_debugx("serial for lun %d, target %s, "
"CTL lun %d changed; removing",
oldlun->l_lun, oldtarg->t_name,
oldlun->l_ctl_lun);
changed = 1;
}
if (changed) {
error = kernel_lun_remove(oldlun);
if (error != 0) {
log_warnx("failed to remove lun %d, "
"target %s, CTL lun %d",
oldlun->l_lun, oldtarg->t_name,
oldlun->l_ctl_lun);
cumulated_error++;
}
lun_delete(oldlun);
continue;
}
lun_set_ctl_lun(newlun, oldlun->l_ctl_lun);
continue;
}
log_debugx("adding lun \"%s\"", newlun->l_name);
error = kernel_lun_add(newlun);
if (error != 0) {
log_warnx("failed to add lun \"%s\"", newlun->l_name);
lun_delete(newlun);
cumulated_error++;
}
}
@ -1786,54 +1803,21 @@ conf_apply(struct conf *oldconf, struct conf *newconf)
TAILQ_FOREACH(newtarg, &newconf->conf_targets, t_next) {
oldtarg = target_find(oldconf, newtarg->t_name);
TAILQ_FOREACH_SAFE(newlun, &newtarg->t_luns, l_next, tmplun) {
if (oldtarg != NULL) {
oldlun = lun_find(oldtarg, newlun->l_lun);
if (oldlun != NULL) {
if (newlun->l_size != oldlun->l_size ||
newlun->l_size == 0) {
log_debugx("resizing lun %d, "
"target %s, CTL lun %d",
newlun->l_lun,
newtarg->t_name,
newlun->l_ctl_lun);
error =
kernel_lun_resize(newlun);
if (error != 0) {
log_warnx("failed to "
"resize lun %d, "
"target %s, "
"CTL lun %d",
newlun->l_lun,
newtarg->t_name,
newlun->l_lun);
cumulated_error++;
}
}
continue;
}
}
log_debugx("adding lun %d, target %s",
newlun->l_lun, newtarg->t_name);
error = kernel_lun_add(newlun);
if (error != 0) {
log_warnx("failed to add lun %d, target %s",
newlun->l_lun, newtarg->t_name);
lun_delete(newlun);
cumulated_error++;
}
}
if (oldtarg == NULL) {
if (oldtarg == NULL)
error = kernel_port_add(newtarg);
if (error != 0) {
log_warnx("failed to add target %s",
newtarg->t_name);
/*
* XXX: Uncomment after fixing the root cause.
*
* cumulated_error++;
*/
}
else {
target_set_ctl_port(newtarg, oldtarg->t_ctl_port);
error = kernel_port_update(newtarg);
}
if (error != 0) {
log_warnx("failed to %s target %s",
(oldtarg == NULL) ? "add" : "update",
newtarg->t_name);
/*
* XXX: Uncomment after fixing the root cause.
*
* cumulated_error++;
*/
}
}

View File

@ -45,6 +45,7 @@
#define DEFAULT_PIDFILE "/var/run/ctld.pid"
#define DEFAULT_BLOCKSIZE 512
#define MAX_LUNS 1024
#define MAX_NAME_LEN 223
#define MAX_DATA_SEGMENT_LENGTH (128 * 1024)
#define MAX_BURST_LENGTH 16776192
@ -132,13 +133,14 @@ struct lun_option {
struct lun {
TAILQ_ENTRY(lun) l_next;
struct conf *l_conf;
TAILQ_HEAD(, lun_option) l_options;
struct target *l_target;
int l_lun;
char *l_name;
char *l_backend;
int l_blocksize;
char *l_device_id;
char *l_path;
char *l_scsiname;
char *l_serial;
int64_t l_size;
@ -147,13 +149,15 @@ struct lun {
struct target {
TAILQ_ENTRY(target) t_next;
TAILQ_HEAD(, lun) t_luns;
struct conf *t_conf;
struct lun *t_luns[MAX_LUNS];
struct auth_group *t_auth_group;
struct portal_group *t_portal_group;
char *t_name;
char *t_alias;
char *t_redirection;
uint32_t t_ctl_port;
};
struct isns {
@ -165,6 +169,7 @@ struct isns {
struct conf {
char *conf_pidfile_path;
TAILQ_HEAD(, lun) conf_luns;
TAILQ_HEAD(, target) conf_targets;
TAILQ_HEAD(, auth_group) conf_auth_groups;
TAILQ_HEAD(, portal_group) conf_portal_groups;
@ -319,14 +324,17 @@ struct target *target_find(struct conf *conf,
const char *name);
int target_set_redirection(struct target *target,
const char *addr);
void target_set_ctl_port(struct target *target,
uint32_t value);
struct lun *lun_new(struct target *target, int lun_id);
struct lun *lun_new(struct conf *conf, const char *name);
void lun_delete(struct lun *lun);
struct lun *lun_find(const struct target *target, int lun_id);
struct lun *lun_find(const struct conf *conf, const char *name);
void lun_set_backend(struct lun *lun, const char *value);
void lun_set_blocksize(struct lun *lun, size_t value);
void lun_set_device_id(struct lun *lun, const char *value);
void lun_set_path(struct lun *lun, const char *value);
void lun_set_scsiname(struct lun *lun, const char *value);
void lun_set_serial(struct lun *lun, const char *value);
void lun_set_size(struct lun *lun, size_t value);
void lun_set_ctl_lun(struct lun *lun, uint32_t value);
@ -345,6 +353,7 @@ int kernel_lun_resize(struct lun *lun);
int kernel_lun_remove(struct lun *lun);
void kernel_handoff(struct connection *conn);
int kernel_port_add(struct target *targ);
int kernel_port_update(struct target *targ);
int kernel_port_remove(struct target *targ);
void kernel_capsicate(void);

View File

@ -114,8 +114,7 @@ struct cctl_lun {
uint32_t blocksize;
char *serial_number;
char *device_id;
char *cfiscsi_target;
int cfiscsi_lun;
char *ctld_name;
STAILQ_HEAD(,cctl_lun_nv) attr_list;
STAILQ_ENTRY(cctl_lun) links;
};
@ -229,11 +228,9 @@ cctl_end_element(void *user_data, const char *name)
} else if (strcmp(name, "device_id") == 0) {
cur_lun->device_id = str;
str = NULL;
} else if (strcmp(name, "cfiscsi_target") == 0) {
cur_lun->cfiscsi_target = str;
} else if (strcmp(name, "ctld_name") == 0) {
cur_lun->ctld_name = str;
str = NULL;
} else if (strcmp(name, "cfiscsi_lun") == 0) {
cur_lun->cfiscsi_lun = strtoul(str, NULL, 0);
} else if (strcmp(name, "lun") == 0) {
devlist->cur_lun = NULL;
} else if (strcmp(name, "ctllunlist") == 0) {
@ -522,38 +519,25 @@ conf_new_from_kernel(void)
STAILQ_FOREACH(lun, &devlist.lun_list, links) {
struct cctl_lun_nv *nv;
if (lun->cfiscsi_target == NULL) {
if (lun->ctld_name == NULL) {
log_debugx("CTL lun %ju wasn't managed by ctld; "
"ignoring", (uintmax_t)lun->lun_id);
continue;
}
targ = target_find(conf, lun->cfiscsi_target);
if (targ == NULL) {
#if 0
log_debugx("found new kernel target %s for CTL lun %ld",
lun->cfiscsi_target, lun->lun_id);
#endif
targ = target_new(conf, lun->cfiscsi_target);
if (targ == NULL) {
log_warnx("target_new failed");
continue;
}
}
cl = lun_find(targ, lun->cfiscsi_lun);
cl = lun_find(conf, lun->ctld_name);
if (cl != NULL) {
log_warnx("found CTL lun %ju, backing lun %d, target "
"%s, also backed by CTL lun %d; ignoring",
(uintmax_t) lun->lun_id, cl->l_lun,
cl->l_target->t_name, cl->l_ctl_lun);
log_warnx("found CTL lun %ju \"%s\", "
"also backed by CTL lun %d; ignoring",
(uintmax_t)lun->lun_id, lun->ctld_name,
cl->l_ctl_lun);
continue;
}
log_debugx("found CTL lun %ju, backing lun %d, target %s",
(uintmax_t)lun->lun_id, lun->cfiscsi_lun, lun->cfiscsi_target);
log_debugx("found CTL lun %ju \"%s\"",
(uintmax_t)lun->lun_id, lun->ctld_name);
cl = lun_new(targ, lun->cfiscsi_lun);
cl = lun_new(conf, lun->ctld_name);
if (cl == NULL) {
log_warnx("lun_new failed");
continue;
@ -574,9 +558,9 @@ conf_new_from_kernel(void)
lo = lun_option_new(cl, nv->name, nv->value);
if (lo == NULL)
log_warnx("unable to add CTL lun option %s "
"for CTL lun %ju for lun %d, target %s",
"for CTL lun %ju \"%s\"",
nv->name, (uintmax_t) lun->lun_id,
cl->l_lun, cl->l_target->t_name);
cl->l_name);
}
}
@ -599,7 +583,6 @@ kernel_lun_add(struct lun *lun)
{
struct lun_option *lo;
struct ctl_lun_req req;
char *tmp;
int error, i, num_options;
bzero(&req, sizeof(req));
@ -637,38 +620,17 @@ kernel_lun_add(struct lun *lun)
}
}
lo = lun_option_find(lun, "cfiscsi_target");
lo = lun_option_find(lun, "ctld_name");
if (lo != NULL) {
lun_option_set(lo, lun->l_target->t_name);
lun_option_set(lo, lun->l_name);
} else {
lo = lun_option_new(lun, "cfiscsi_target",
lun->l_target->t_name);
lo = lun_option_new(lun, "ctld_name", lun->l_name);
assert(lo != NULL);
}
asprintf(&tmp, "%d", lun->l_lun);
if (tmp == NULL)
log_errx(1, "asprintf");
lo = lun_option_find(lun, "cfiscsi_lun");
if (lo != NULL) {
lun_option_set(lo, tmp);
free(tmp);
} else {
lo = lun_option_new(lun, "cfiscsi_lun", tmp);
free(tmp);
assert(lo != NULL);
}
asprintf(&tmp, "%s,lun,%d", lun->l_target->t_name, lun->l_lun);
if (tmp == NULL)
log_errx(1, "asprintf");
lo = lun_option_find(lun, "scsiname");
if (lo != NULL) {
lun_option_set(lo, tmp);
free(tmp);
} else {
lo = lun_option_new(lun, "scsiname", tmp);
free(tmp);
if (lo == NULL && lun->l_scsiname != NULL) {
lo = lun_option_new(lun, "scsiname", lun->l_scsiname);
assert(lo != NULL);
}
@ -846,10 +808,11 @@ kernel_port_add(struct target *targ)
{
struct ctl_port_entry entry;
struct ctl_req req;
struct ctl_lun_map lm;
char tagstr[16];
int error;
uint32_t port_id = -1;
int error, i;
/* Create iSCSI port. */
bzero(&req, sizeof(req));
strlcpy(req.driver, "iscsi", sizeof(req.driver));
req.reqtype = CTL_REQ_CREATE;
@ -857,8 +820,8 @@ kernel_port_add(struct target *targ)
req.args = malloc(req.num_args * sizeof(*req.args));
req.args[0].namelen = sizeof("port_id");
req.args[0].name = __DECONST(char *, "port_id");
req.args[0].vallen = sizeof(port_id);
req.args[0].value = &port_id;
req.args[0].vallen = sizeof(targ->t_ctl_port);
req.args[0].value = &targ->t_ctl_port;
req.args[0].flags = CTL_BEARG_WR;
str_arg(&req.args[1], "cfiscsi_target", targ->t_name);
snprintf(tagstr, sizeof(tagstr), "%d", targ->t_portal_group->pg_tag);
@ -867,29 +830,46 @@ kernel_port_add(struct target *targ)
str_arg(&req.args[3], "cfiscsi_target_alias", targ->t_alias);
else
req.num_args--;
error = ioctl(ctl_fd, CTL_PORT_REQ, &req);
free(req.args);
if (error != 0) {
log_warn("error issuing CTL_PORT_REQ ioctl");
return (1);
}
if (req.status == CTL_LUN_ERROR) {
log_warnx("error returned from port creation request: %s",
req.error_str);
return (1);
}
if (req.status != CTL_LUN_OK) {
log_warnx("unknown port creation request status %d",
req.status);
return (1);
}
bzero(&entry, sizeof(entry));
entry.targ_port = port_id;
/* Explicitly enable mapping to block any access except allowed. */
lm.port = targ->t_ctl_port;
lm.plun = UINT32_MAX;
lm.lun = 0;
error = ioctl(ctl_fd, CTL_LUN_MAP, &lm);
if (error != 0)
log_warn("CTL_LUN_MAP ioctl failed");
/* Map configured LUNs */
for (i = 0; i < MAX_LUNS; i++) {
if (targ->t_luns[i] == NULL)
continue;
lm.port = targ->t_ctl_port;
lm.plun = i;
lm.lun = targ->t_luns[i]->l_ctl_lun;
error = ioctl(ctl_fd, CTL_LUN_MAP, &lm);
if (error != 0)
log_warn("CTL_LUN_MAP ioctl failed");
}
/* Enable port */
bzero(&entry, sizeof(entry));
entry.targ_port = targ->t_ctl_port;
error = ioctl(ctl_fd, CTL_ENABLE_PORT, &entry);
if (error != 0) {
log_warn("CTL_ENABLE_PORT ioctl failed");
@ -899,6 +879,27 @@ kernel_port_add(struct target *targ)
return (0);
}
int
kernel_port_update(struct target *targ)
{
struct ctl_lun_map lm;
int error, i;
/* Map configured LUNs and unmap others */
for (i = 0; i < MAX_LUNS; i++) {
lm.port = targ->t_ctl_port;
lm.plun = i;
if (targ->t_luns[i] == NULL)
lm.lun = UINT32_MAX;
else
lm.lun = targ->t_luns[i]->l_ctl_lun;
error = ioctl(ctl_fd, CTL_LUN_MAP, &lm);
if (error != 0)
log_warn("CTL_LUN_MAP ioctl failed");
}
return (0);
}
int
kernel_port_remove(struct target *targ)
{

View File

@ -99,6 +99,8 @@ statement:
|
portal_group
|
lun
|
target
;
@ -407,6 +409,22 @@ portal_group_redirect: REDIRECT STR
}
;
lun: LUN lun_name
OPENING_BRACKET lun_entries CLOSING_BRACKET
{
lun = NULL;
}
;
lun_name: STR
{
lun = lun_new(conf, $1);
free($1);
if (lun == NULL)
return (1);
}
;
target: TARGET target_name
OPENING_BRACKET target_entries CLOSING_BRACKET
{
@ -450,6 +468,8 @@ target_entry:
target_redirect
|
target_lun
|
target_lun_ref
;
target_alias: ALIAS STR
@ -672,6 +692,7 @@ target_lun: LUN lun_number
lun_number: STR
{
uint64_t tmp;
char *name;
if (expand_number($1, &tmp) != 0) {
yyerror("invalid numeric value");
@ -679,9 +700,34 @@ lun_number: STR
return (1);
}
lun = lun_new(target, tmp);
asprintf(&name, "%s,lun,%ju", target->t_name, tmp);
lun = lun_new(conf, name);
if (lun == NULL)
return (1);
lun_set_scsiname(lun, name);
target->t_luns[tmp] = lun;
}
;
target_lun_ref: LUN STR STR
{
uint64_t tmp;
if (expand_number($2, &tmp) != 0) {
yyerror("invalid numeric value");
free($2);
free($3);
return (1);
}
free($2);
lun = lun_find(conf, $3);
free($3);
if (lun == NULL)
return (1);
target->t_luns[tmp] = lun;
}
;
@ -711,9 +757,9 @@ lun_entry:
lun_backend: BACKEND STR
{
if (lun->l_backend != NULL) {
log_warnx("backend for lun %d, target \"%s\" "
log_warnx("backend for lun \"%s\" "
"specified more than once",
lun->l_lun, target->t_name);
lun->l_name);
free($2);
return (1);
}
@ -733,9 +779,9 @@ lun_blocksize: BLOCKSIZE STR
}
if (lun->l_blocksize != 0) {
log_warnx("blocksize for lun %d, target \"%s\" "
log_warnx("blocksize for lun \"%s\" "
"specified more than once",
lun->l_lun, target->t_name);
lun->l_name);
return (1);
}
lun_set_blocksize(lun, tmp);
@ -745,9 +791,9 @@ lun_blocksize: BLOCKSIZE STR
lun_device_id: DEVICE_ID STR
{
if (lun->l_device_id != NULL) {
log_warnx("device_id for lun %d, target \"%s\" "
log_warnx("device_id for lun \"%s\" "
"specified more than once",
lun->l_lun, target->t_name);
lun->l_name);
free($2);
return (1);
}
@ -771,9 +817,9 @@ lun_option: OPTION STR STR
lun_path: PATH STR
{
if (lun->l_path != NULL) {
log_warnx("path for lun %d, target \"%s\" "
log_warnx("path for lun \"%s\" "
"specified more than once",
lun->l_lun, target->t_name);
lun->l_name);
free($2);
return (1);
}
@ -785,9 +831,9 @@ lun_path: PATH STR
lun_serial: SERIAL STR
{
if (lun->l_serial != NULL) {
log_warnx("serial for lun %d, target \"%s\" "
log_warnx("serial for lun \"%s\" "
"specified more than once",
lun->l_lun, target->t_name);
lun->l_name);
free($2);
return (1);
}
@ -807,9 +853,9 @@ lun_size: SIZE STR
}
if (lun->l_size != 0) {
log_warnx("size for lun %d, target \"%s\" "
log_warnx("size for lun \"%s\" "
"specified more than once",
lun->l_lun, target->t_name);
lun->l_name);
return (1);
}
lun_set_size(lun, tmp);