tgt 1.0.39

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Fix isns to handle multiple portals

See https://bugzilla.redhat.com/show_bug.cgi?id=865739

Report all portals to iSNS. If listening on an INADDR_ANY (0.0.0.0) or
INADDR6_ANY (::) then report the IP that we're using to connect to the
iSNS server as the one to use. If listening on both v4 and v6 ANY
addresses, only report one.

Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Add support for modular backends

Link tgtd with -E so all symbols are available for runtime linking
by dynamically loaded objects.
Build some modules, such as bs_{aio|rbd} as shared objects and
install them under /usr/lib/tgtd/backing-store
Add support so that when tgtd is started and initializes the backends
it will traverse /usr/lib/tgtd/backing-store and dynamically load
all object files.

This allows to build and distribute backends as separate packages than tgtd.
TGTD can be shipped with only base dependencies and basic backend support
and then those backends that include extra dependencies can be shipped
and installed separately.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Enhance the iser readme

Enhance the iser readme  to contain more details on the RDMA
libraries needed for building and running tgt with iser.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
add support of sheepdog backing store

Hi tgt list,
(Cc-ing sheepdog list),

This patch implements a new backing store support for sheepdog, distributed
storage system initially designed for QEMU
(https://github.com/sheepdog/sheepdog). With this patch, sheepdog can support
iSCSI protocol, so hypervisors other than QEMU/KVM and native OSes can use
sheepdog as their block devices. The new --bstype is "sheepdog".
(This patch is a refinement of tgt's sheepdog branch.)

This patch still has some todos and would have bugs, but I'd like to post it for
keeping this patch small and getting feedback in early stage.

Major todos:
 - exploiting multithread support of tgt
 - support sheep processes running on different host and using pots other than
   7000
 - support unix domain socket for communicating between sheep process
 - support reconnection for safe upgrade of sheepdog

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
tgt 1.0.40

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
usr/Makefile: fix typo in bs_aio so filename

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: partial update of inode object for optimizing COW

Current bs_sheepdog.c updates whole inode object (metadata of
sheepdog) when COW occurs. This patch reduces the traffic of update.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: use multithread for scsi command submission

Current bs_sheepdog.c uses only one thread per logical unit. This
patch let it use nr_iothreads as a number of threads per logical
unit by per thread connection and rwlocking inode object. This change
is effective in the case of reading one logical unit by many clients.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: support reconnection for updating sheepdog

Current bs_sheepdog.c rises error when connection for sheep daemon is
closed. This is not suitable when administrators want to update
sheepdog. This patch implements reconnection functionality in
bs_sheepdog.c for this purpose.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Fix redefinition of _GNU_SOURCE

Already defined on the commandline by the Makefile.

Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Fix make install when no modules

If no modules, the 'install -m' will generate an error.

Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
De-modularize aio

Per list discussion, go back to compiling bs_aio into tgtd instead of
a separate object. libaio is a small enough dependency that it does not
merit a separate module just to keep the dependency off tgtd.

AIO support will still only be included if libaio headers are present.

Reported-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: support various VDI options in --backing-store option

Current bs_sheepdog.c only supports connections to sheep process which
listen on localhost:7000 (tcp). This patch makes the address, port,
and protocol specifiable via --backing-store option of tgtadm. In
addition, snapshots of VDIs can be logical units when tag or snapshot
ID is passed to the option.

The form of --backing-store option:
 - unix:<path_of_unix_domain_socket>:<vdi>
 - unix:<path_of_unix_domain_socket>:<vdi>:<tag>
 - unix:<path_of_unix_domain_socket>:<vdi>:<snapid>
 - tcp:<host>:<port>:<vdi>
 - tcp:<host>:<port>:<vdi>:<tag>
 - tcp:<host>:<port>:<vdi>:<snapid>
 - tcp:<port>:<vdi>
 - tcp:<port>:<vdi>:<tag>
 - tcp:<port>:<vdi>:<snapid>

Example of the option: -b unix:/sheep_store/sock:tgt0:1
(connect via unix domain socket, the path of socket is
/sheep_store/sock, VDI name is tgt0, use snapshot of ID 1)

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_rbd.c: store active_rbd info in addition to struct scsi_lu

Use bs_datasize feature to allocate bs_rbd-private data on the end
of scsi_lu, and then access it with pointer arithmetic; no need to
manage an array indexed by fd, so no fixed number of devices anymore.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_rbd.c: carry cluster connection along with rbd/lu

Allow each mapped image to also contain its own private cluster
connection.  This will allow one tgtd to serve multiple clients
with potentially different authentication rights.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: mock the behavior of QEMU's sheepdog driver in a correct manner

Current bs_sheepdog.c doesn't mock the behavior of QEMU's sheepdog
driver in a correct manner when it opens snapshot VDIs. It treats the
snapshot VDIs as read-only disks, but this behavior is different from
the QEMU's driver. This patch lets bs_sheepdog.c mock the original
behavior (delete an original VDI of the snapshot -> create a new non
snapshot VDI based on the snapshot and open it). This patch also
removes confusing notations of --backing-store option of
bs_sheepdog.c.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: fix segmentation fault caused by deleting logical unit

This patch removes a bug in bs_exit() of bs_sheepdog.c which caused
segmentation fault.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: test connection when new logical unit is created

This patch adds creation of a test connection in the process of making
logical unit. This is required for validating --backing-store option
and avoid forever trying of reconnection.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
tgt-admin: avoid zsh-specific syntax in system() call

"lsof &> /dev/null" is apparently zsh (and maybe some other shells,
but not bash) for "redirect both stderr and stdout".  Under bash,
I believe what this means is "execute the prior command in the
background, and then execute the meaningless "> /dev/null" command".
That wouldn't be a problem except that the return code becomes the
return code of the "> /dev/null", hiding the return code of the
'lsof' command.

Fix: use the more-standard "lsof >/dev/null 2>&1" syntax.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>