This pull request fixes a 2.9 regression and a long standing bug that can

cause 9p clients to hang. Other patches are minor enhancements.
 -----BEGIN PGP SIGNATURE-----
 
 iEYEABECAAYFAliIegsACgkQAvw66wEB28LjzwCeIKbBFC/hbc43UqaNX82OGd2v
 soYAn0YYXJUAykyjNEMLdhhNp+rABzNk
 =1PaE
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging

This pull request fixes a 2.9 regression and a long standing bug that can
cause 9p clients to hang. Other patches are minor enhancements.

# gpg: Signature made Wed 25 Jan 2017 10:12:27 GMT
# gpg:                using DSA key 0x02FC3AEB0101DBC2
# gpg: Good signature from "Greg Kurz <groug@kaod.org>"
# gpg:                 aka "Greg Kurz <groug@free.fr>"
# gpg:                 aka "Greg Kurz <gkurz@fr.ibm.com>"
# gpg:                 aka "Greg Kurz <gkurz@linux.vnet.ibm.com>"
# gpg:                 aka "Gregory Kurz (Groug) <groug@free.fr>"
# gpg:                 aka "Gregory Kurz (Cimai Technology) <gkurz@cimai.com>"
# gpg:                 aka "Gregory Kurz (Meiosys Technology) <gkurz@meiosys.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 2BD4 3B44 535E C0A7 9894  DBA2 02FC 3AEB 0101 DBC2

* remotes/gkurz/tags/for-upstream:
  9pfs: fix offset error in v9fs_xattr_read()
  9pfs: local: trivial cosmetic fix in pwritev op
  9pfs: fix off-by-one error in PDU free list
  tests: virtio-9p: improve error reporting
  9pfs: add missing coroutine_fn annotations

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2017-01-25 17:54:14 +00:00
commit c7f1cf01b8
3 changed files with 26 additions and 13 deletions

View File

@ -436,8 +436,7 @@ static ssize_t local_pwritev(FsContext *ctx, V9fsFidOpenState *fs,
const struct iovec *iov, const struct iovec *iov,
int iovcnt, off_t offset) int iovcnt, off_t offset)
{ {
ssize_t ret ssize_t ret;
;
#ifdef CONFIG_PREADV #ifdef CONFIG_PREADV
ret = pwritev(fs->fd, iov, iovcnt, offset); ret = pwritev(fs->fd, iov, iovcnt, offset);
#else #else

View File

@ -1582,7 +1582,7 @@ out_nofid:
v9fs_string_free(&name); v9fs_string_free(&name);
} }
static void v9fs_fsync(void *opaque) static void coroutine_fn v9fs_fsync(void *opaque)
{ {
int err; int err;
int32_t fid; int32_t fid;
@ -1666,7 +1666,7 @@ static void v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu,
if (is_write) { if (is_write) {
pdu->s->transport->init_out_iov_from_pdu(pdu, &iov, &niov); pdu->s->transport->init_out_iov_from_pdu(pdu, &iov, &niov);
} else { } else {
pdu->s->transport->init_in_iov_from_pdu(pdu, &iov, &niov, size); pdu->s->transport->init_in_iov_from_pdu(pdu, &iov, &niov, size + skip);
} }
qemu_iovec_init_external(&elem, iov, niov); qemu_iovec_init_external(&elem, iov, niov);
@ -1696,8 +1696,8 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
} }
offset += err; offset += err;
v9fs_init_qiov_from_pdu(&qiov_full, pdu, 0, read_count, false); v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, read_count, false);
err = v9fs_pack(qiov_full.iov, qiov_full.niov, offset, err = v9fs_pack(qiov_full.iov, qiov_full.niov, 0,
((char *)fidp->fs.xattr.value) + off, ((char *)fidp->fs.xattr.value) + off,
read_count); read_count);
qemu_iovec_destroy(&qiov_full); qemu_iovec_destroy(&qiov_full);
@ -2348,7 +2348,7 @@ out_nofid:
v9fs_string_free(&symname); v9fs_string_free(&symname);
} }
static void v9fs_flush(void *opaque) static void coroutine_fn v9fs_flush(void *opaque)
{ {
ssize_t err; ssize_t err;
int16_t tag; int16_t tag;
@ -3465,7 +3465,7 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)
/* initialize pdu allocator */ /* initialize pdu allocator */
QLIST_INIT(&s->free_list); QLIST_INIT(&s->free_list);
QLIST_INIT(&s->active_list); QLIST_INIT(&s->active_list);
for (i = 0; i < (MAX_REQ - 1); i++) { for (i = 0; i < MAX_REQ; i++) {
QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next); QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
s->pdus[i].s = s; s->pdus[i].s = s;
s->pdus[i].idx = i; s->pdus[i].idx = i;

View File

@ -236,6 +236,16 @@ static void v9fs_req_send(P9Req *req)
req->t_off = 0; req->t_off = 0;
} }
static const char *rmessage_name(uint8_t id)
{
return
id == P9_RLERROR ? "RLERROR" :
id == P9_RVERSION ? "RVERSION" :
id == P9_RATTACH ? "RATTACH" :
id == P9_RWALK ? "RWALK" :
"<unknown>";
}
static void v9fs_req_recv(P9Req *req, uint8_t id) static void v9fs_req_recv(P9Req *req, uint8_t id)
{ {
QVirtIO9P *v9p = req->v9p; QVirtIO9P *v9p = req->v9p;
@ -258,11 +268,15 @@ static void v9fs_req_recv(P9Req *req, uint8_t id)
g_assert_cmpint(hdr.size, <=, P9_MAX_SIZE); g_assert_cmpint(hdr.size, <=, P9_MAX_SIZE);
g_assert_cmpint(hdr.tag, ==, req->tag); g_assert_cmpint(hdr.tag, ==, req->tag);
if (hdr.id != id && hdr.id == P9_RLERROR) { if (hdr.id != id) {
uint32_t err; g_printerr("Received response %d (%s) instead of %d (%s)\n",
v9fs_uint32_read(req, &err); hdr.id, rmessage_name(hdr.id), id, rmessage_name(id));
g_printerr("Received Rlerror (%d) instead of Response %d\n", err, id);
g_assert_not_reached(); if (hdr.id == P9_RLERROR) {
uint32_t err;
v9fs_uint32_read(req, &err);
g_printerr("Rlerror has errno %d (%s)\n", err, strerror(err));
}
} }
g_assert_cmpint(hdr.id, ==, id); g_assert_cmpint(hdr.id, ==, id);
} }