Commit 8164c571 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus-5.2b-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen fixes from Juergen Gross:
 "One minor cleanup patch and a fix for handling of live migration when
  running as Xen guest"

* tag 'for-linus-5.2b-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  xenbus: Avoid deadlock during suspend due to open transactions
  xen/pvcalls: Remove set but not used variable
parents 27a03b1a d10e0cc1
...@@ -531,7 +531,6 @@ static int __write_ring(struct pvcalls_data_intf *intf, ...@@ -531,7 +531,6 @@ static int __write_ring(struct pvcalls_data_intf *intf,
int pvcalls_front_sendmsg(struct socket *sock, struct msghdr *msg, int pvcalls_front_sendmsg(struct socket *sock, struct msghdr *msg,
size_t len) size_t len)
{ {
struct pvcalls_bedata *bedata;
struct sock_mapping *map; struct sock_mapping *map;
int sent, tot_sent = 0; int sent, tot_sent = 0;
int count = 0, flags; int count = 0, flags;
...@@ -543,7 +542,6 @@ int pvcalls_front_sendmsg(struct socket *sock, struct msghdr *msg, ...@@ -543,7 +542,6 @@ int pvcalls_front_sendmsg(struct socket *sock, struct msghdr *msg,
map = pvcalls_enter_sock(sock); map = pvcalls_enter_sock(sock);
if (IS_ERR(map)) if (IS_ERR(map))
return PTR_ERR(map); return PTR_ERR(map);
bedata = dev_get_drvdata(&pvcalls_front_dev->dev);
mutex_lock(&map->active.out_mutex); mutex_lock(&map->active.out_mutex);
if ((flags & MSG_DONTWAIT) && !pvcalls_front_write_todo(map)) { if ((flags & MSG_DONTWAIT) && !pvcalls_front_write_todo(map)) {
...@@ -626,7 +624,6 @@ static int __read_ring(struct pvcalls_data_intf *intf, ...@@ -626,7 +624,6 @@ static int __read_ring(struct pvcalls_data_intf *intf,
int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
int flags) int flags)
{ {
struct pvcalls_bedata *bedata;
int ret; int ret;
struct sock_mapping *map; struct sock_mapping *map;
...@@ -636,7 +633,6 @@ int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, ...@@ -636,7 +633,6 @@ int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
map = pvcalls_enter_sock(sock); map = pvcalls_enter_sock(sock);
if (IS_ERR(map)) if (IS_ERR(map))
return PTR_ERR(map); return PTR_ERR(map);
bedata = dev_get_drvdata(&pvcalls_front_dev->dev);
mutex_lock(&map->active.in_mutex); mutex_lock(&map->active.in_mutex);
if (len > XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER)) if (len > XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER))
......
...@@ -83,6 +83,7 @@ struct xb_req_data { ...@@ -83,6 +83,7 @@ struct xb_req_data {
int num_vecs; int num_vecs;
int err; int err;
enum xb_req_state state; enum xb_req_state state;
bool user_req;
void (*cb)(struct xb_req_data *); void (*cb)(struct xb_req_data *);
void *par; void *par;
}; };
...@@ -133,4 +134,6 @@ void xenbus_ring_ops_init(void); ...@@ -133,4 +134,6 @@ void xenbus_ring_ops_init(void);
int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par); int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par);
void xenbus_dev_queue_reply(struct xb_req_data *req); void xenbus_dev_queue_reply(struct xb_req_data *req);
extern unsigned int xb_dev_generation_id;
#endif #endif
...@@ -62,6 +62,8 @@ ...@@ -62,6 +62,8 @@
#include "xenbus.h" #include "xenbus.h"
unsigned int xb_dev_generation_id;
/* /*
* An element of a list of outstanding transactions, for which we're * An element of a list of outstanding transactions, for which we're
* still waiting a reply. * still waiting a reply.
...@@ -69,6 +71,7 @@ ...@@ -69,6 +71,7 @@
struct xenbus_transaction_holder { struct xenbus_transaction_holder {
struct list_head list; struct list_head list;
struct xenbus_transaction handle; struct xenbus_transaction handle;
unsigned int generation_id;
}; };
/* /*
...@@ -441,6 +444,7 @@ static int xenbus_write_transaction(unsigned msg_type, ...@@ -441,6 +444,7 @@ static int xenbus_write_transaction(unsigned msg_type,
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
trans->generation_id = xb_dev_generation_id;
list_add(&trans->list, &u->transactions); list_add(&trans->list, &u->transactions);
} else if (msg->hdr.tx_id != 0 && } else if (msg->hdr.tx_id != 0 &&
!xenbus_get_transaction(u, msg->hdr.tx_id)) !xenbus_get_transaction(u, msg->hdr.tx_id))
...@@ -449,6 +453,20 @@ static int xenbus_write_transaction(unsigned msg_type, ...@@ -449,6 +453,20 @@ static int xenbus_write_transaction(unsigned msg_type,
!(msg->hdr.len == 2 && !(msg->hdr.len == 2 &&
(!strcmp(msg->body, "T") || !strcmp(msg->body, "F")))) (!strcmp(msg->body, "T") || !strcmp(msg->body, "F"))))
return xenbus_command_reply(u, XS_ERROR, "EINVAL"); return xenbus_command_reply(u, XS_ERROR, "EINVAL");
else if (msg_type == XS_TRANSACTION_END) {
trans = xenbus_get_transaction(u, msg->hdr.tx_id);
if (trans && trans->generation_id != xb_dev_generation_id) {
list_del(&trans->list);
kfree(trans);
if (!strcmp(msg->body, "T"))
return xenbus_command_reply(u, XS_ERROR,
"EAGAIN");
else
return xenbus_command_reply(u,
XS_TRANSACTION_END,
"OK");
}
}
rc = xenbus_dev_request_and_reply(&msg->hdr, u); rc = xenbus_dev_request_and_reply(&msg->hdr, u);
if (rc && trans) { if (rc && trans) {
......
...@@ -105,6 +105,7 @@ static void xs_suspend_enter(void) ...@@ -105,6 +105,7 @@ static void xs_suspend_enter(void)
static void xs_suspend_exit(void) static void xs_suspend_exit(void)
{ {
xb_dev_generation_id++;
spin_lock(&xs_state_lock); spin_lock(&xs_state_lock);
xs_suspend_active--; xs_suspend_active--;
spin_unlock(&xs_state_lock); spin_unlock(&xs_state_lock);
...@@ -125,7 +126,7 @@ static uint32_t xs_request_enter(struct xb_req_data *req) ...@@ -125,7 +126,7 @@ static uint32_t xs_request_enter(struct xb_req_data *req)
spin_lock(&xs_state_lock); spin_lock(&xs_state_lock);
} }
if (req->type == XS_TRANSACTION_START) if (req->type == XS_TRANSACTION_START && !req->user_req)
xs_state_users++; xs_state_users++;
xs_state_users++; xs_state_users++;
rq_id = xs_request_id++; rq_id = xs_request_id++;
...@@ -140,7 +141,7 @@ void xs_request_exit(struct xb_req_data *req) ...@@ -140,7 +141,7 @@ void xs_request_exit(struct xb_req_data *req)
spin_lock(&xs_state_lock); spin_lock(&xs_state_lock);
xs_state_users--; xs_state_users--;
if ((req->type == XS_TRANSACTION_START && req->msg.type == XS_ERROR) || if ((req->type == XS_TRANSACTION_START && req->msg.type == XS_ERROR) ||
(req->type == XS_TRANSACTION_END && (req->type == XS_TRANSACTION_END && !req->user_req &&
!WARN_ON_ONCE(req->msg.type == XS_ERROR && !WARN_ON_ONCE(req->msg.type == XS_ERROR &&
!strcmp(req->body, "ENOENT")))) !strcmp(req->body, "ENOENT"))))
xs_state_users--; xs_state_users--;
...@@ -286,6 +287,7 @@ int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par) ...@@ -286,6 +287,7 @@ int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par)
req->num_vecs = 1; req->num_vecs = 1;
req->cb = xenbus_dev_queue_reply; req->cb = xenbus_dev_queue_reply;
req->par = par; req->par = par;
req->user_req = true;
xs_send(req, msg); xs_send(req, msg);
...@@ -313,6 +315,7 @@ static void *xs_talkv(struct xenbus_transaction t, ...@@ -313,6 +315,7 @@ static void *xs_talkv(struct xenbus_transaction t,
req->vec = iovec; req->vec = iovec;
req->num_vecs = num_vecs; req->num_vecs = num_vecs;
req->cb = xs_wake_up; req->cb = xs_wake_up;
req->user_req = false;
msg.req_id = 0; msg.req_id = 0;
msg.tx_id = t.id; msg.tx_id = t.id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment