CA-144882: don't complain about ENOENT when cleaning up the stats file

And ignore, but do log, errors when cleaning up the stats file.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>

GitHub: closes #123 on xapi-project/blktap
CA-136792: produce raw blkback-style stats

Produce I/O statistics in /dev/shm/vbd3-domid-devid. We use one file for
all seven counters as otherwise we're wasting too much memory. Unlike
blkback, the metric are in raw binary format, as this is the most
efficient way for producing them. The format of the statistics is
defined in /usr/include/blktap/blktap3.h.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>

GitHub: closes #97 on xapi-project/blktap
CA-145596: variable 'vreq' set but not used

vreq is not used at all, so removing it.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #129 on xapi-project/blktap
CA-139733: Stop vhd false alarm

Stop complaining the primary footer is invalid during storage motion
since the backup one will be read. Warning messages when reading backup
one is kept.

Signed-off-by: Kaifeng Zhu <kaifeng.zhu@citrix.com>
Reviewed-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>

GitHub: closes #118 on xapi-project/blktap
CA-142264: use errno as the error for the grant-copy ioctl

And improve error reporting.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CP-9459: don't retry request on EFAULT

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-142434: don't double free request buffer

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: documentation and debug

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: simplify ring suspend/resume interface

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: use accessor for determining whether there are pending requests

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: allow negative time outs to indicate infinity

Allow negative time outs in order to set an event's deadline to infinity.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: check ring unmap return value

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: introduce check ring event

This patch introduces the check ring event. This allows scheduling an
event for checking the ring for new requests independent of event
channel notifications.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: break on barrier request

This patch introduces part of write I/O barrier functionality. When we
check the ring for requests, if we encounter a barrier request we
immediately stop extracting requests from the ring and mask the event
associated with checking the ring in order to avoid submitting new I/O
requests.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: complete barrier when all pending requests complete

This patch adds the rest of the functionality required for write I/O
barriers. When a request completes, we check whether there is a pending
barrier request and if so we complete it and schedule the event that
checks the ring for requests.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-144705: use correct depth when destroying dead rings

Take care when completing a barrier request of dead ring because the
completion function is recursively called.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: advertise write I/O barriers in Xenbus

blkback advertises I/O write barriers for CD-ROM devices as well, and so
do we.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-141611: command line option to enable/disable write I/O barrier support

This can be useful for globally disabling write I/O barriers for
whatever reason (e.g. debugging).

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
CA-141611: write I/O barriers might contain data

Write I/O barriers might contain data to be written, so they must be
treated as a special kind of write.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Signed-off-by: Felipe Franciosi <felipe.franciosi@citrix.com>