Skip to contentSkip to conversation

4.1.2 blktap2 cleanup fixes.

PATCH In review Dr. Greg Wettstein 3 participants 5 messages Nov 7, 2012 – Dec 13, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 4.1.2 blktap2 cleanup fixes.

---------------------------------------------------------------------------
The following patch when applied on top of:

libxl: attempt to cleanup tapdisk processes on disk backend destroy.

Establishes correct cleanup behavior for blktap devices. This patch implements the release of the backend device before calling for the destruction of the userspace component of the blktap device.

Without this patch the kernel xen-blkback driver deadlocks with the blktap2 user control plane until the IPC channel is terminated by the timeout on the select() call. This results in a noticeable delay in the termination of the guest and causes the blktap minor number which had been allocated to be orphaned.

tools/libxl/libxl_blktap2.c +7 -0
diff -r b184698e0893 tools/libxl/libxl_blktap2.c
@@ -59,6 +59,7 @@ void libxl__device_destroy_tapdisk(libxl
     char *path, *params, *type, *disk;
     int err;
     tap_list_t tap;
+    libxl_ctx *ctx = libxl__gc_owner(gc);
 
     path = libxl__sprintf(gc, "%s/tapdisk-params", be_path);
     if (!path) return;
@@ -75,5 +76,11 @@ void libxl__device_destroy_tapdisk(libxl
     err = tap_ctl_find(type, disk, &tap);
     if (err < 0) return;
 
+    /*
+     * Remove the instance of the backend device to avoid a deadlock with the
+     * removal of the tap device.
+     */
+    xs_rm(ctx->xsh, XBT_NULL, be_path);
+
     tap_ctl_destroy(tap.id, tap.minor);
 }
tools/libxl/libxl_device.c +1 -2
diff -r b184698e0893 tools/libxl/libxl_device.c
@@ -250,8 +250,7 @@ int libxl__device_destroy(libxl_ctx *ctx
     if (!state)
         goto out;
     if (atoi(state) != 4) {
-        libxl__device_destroy_tapdisk(&gc, be_path);
-        xs_rm(ctx->xsh, XBT_NULL, be_path);
+	libxl__device_destroy_tapdisk(&gc, be_path);
         goto out;
     }
 

---------------------------------------------------------------------------

As always,

Dr. G.W. Wettstein, Ph.D.   Enjellic Systems Development, LLC.
4206 N. 19th Ave.           Specializing in information infra-structure
Fargo, ND  58102            development.

PH: 701-281-1686
FAX: 701-281-3949 EMAIL: [email protected]
------------------------------------------------------------------------------
"Fungus doesn't take a vacation."
-- Rob Pike

Acked-by on v1 2/2
#1 lore raw
Quoted 9 lines · Dr. Greg Wettstein

---------------------------------------------------------------------------
The following patch when applied on top of:

libxl: attempt to cleanup tapdisk processes on disk backend destroy.

Establishes correct cleanup behavior for blktap devices. This patch implements the release of the backend device before calling for the destruction of the userspace component of the blktap device.

Quoted 7 lines

Without this patch the kernel xen-blkback driver deadlocks with the blktap2 user control plane until the IPC channel is terminated by the timeout on the select() call. This results in a noticeable delay in the termination of the guest and causes the blktap minor number which had been allocated to be orphaned.

Quoted 52 lines

diff -r b184698e0893 tools/libxl/libxl_blktap2.c

tools/libxl/libxl_blktap2.c +7 -0
@@ -59,6 +59,7 @@ void libxl__device_destroy_tapdisk(libxl
     char *path, *params, *type, *disk;
     int err;
     tap_list_t tap;
+    libxl_ctx *ctx = libxl__gc_owner(gc);
 
     path = libxl__sprintf(gc, "%s/tapdisk-params", be_path);
     if (!path) return;
@@ -75,5 +76,11 @@ void libxl__device_destroy_tapdisk(libxl
     err = tap_ctl_find(type, disk, &tap);
     if (err < 0) return;
 
+    /*
+     * Remove the instance of the backend device to avoid a deadlock with the
+     * removal of the tap device.
+     */
+    xs_rm(ctx->xsh, XBT_NULL, be_path);
+
     tap_ctl_destroy(tap.id, tap.minor);
 }

diff -r b184698e0893 tools/libxl/libxl_device.c

tools/libxl/libxl_device.c +1 -3
@@ -250,8 +250,7 @@ int libxl__device_destroy(libxl_ctx *ctx
     if (!state)
         goto out;
     if (atoi(state) != 4) {
-        libxl__device_destroy_tapdisk(&gc, be_path);
-        xs_rm(ctx->xsh, XBT_NULL, be_path);
+	libxl__device_destroy_tapdisk(&gc, be_path);
         goto out;
     }
 
---------------------------------------------------------------------------

As always,

Dr. G.W. Wettstein, Ph.D.   Enjellic Systems Development, LLC.
4206 N. 19th Ave.           Specializing in information infra-structure
Fargo, ND  58102            development.

PH: 701-281-1686
FAX: 701-281-3949 EMAIL: [email protected]
------------------------------------------------------------------------------
"Fungus doesn't take a vacation."
-- Rob Pike

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw

Ian Campbell writes ("Re: [Xen-devel] [PATCH 2/2] 4.1.2 blktap2 cleanup fixes."):

Quoted 16 lines · Dr. Greg Wettstein
Quoted 15 lines

---------------------------------------------------------------------------
The following patch when applied on top of:

libxl: attempt to cleanup tapdisk processes on disk backend destroy.

Establishes correct cleanup behavior for blktap devices. This patch implements the release of the backend device before calling for the destruction of the userspace component of the blktap device.

Without this patch the kernel xen-blkback driver deadlocks with the blktap2 user control plane until the IPC channel is terminated by the timeout on the select() call. This results in a noticeable delay in the termination of the guest and causes the blktap minor number which had been allocated to be orphaned.

Quoted 3 lines
Quoted 1 line

I have fixed up the whitespace error and committed this to 4.1.

Ian.

#3 lore raw
In reply to Dr. Greg Wettstein

Dr. Greg Wettstein writes ("[PATCH 2/2] 4.1.2 blktap2 cleanup fixes."):

Quoted 9 lines

---------------------------------------------------------------------------
The following patch when applied on top of:

libxl: attempt to cleanup tapdisk processes on disk backend destroy.

Establishes correct cleanup behavior for blktap devices. This patch implements the release of the backend device before calling for the destruction of the userspace component of the blktap device.

Quoted 5 lines

Without this patch the kernel xen-blkback driver deadlocks with the blktap2 user control plane until the IPC channel is terminated by the timeout on the select() call. This results in a noticeable delay in the termination of the guest and causes the blktap minor number which had been allocated to be orphaned.

This looks plausible. But shouldn't it be applied to xen-unstable and Xen 4.2 too ?

tools/libxl/libxl_device.c int libxl__device_destroy(libxl_ctx *ctx · line 254

Quoted 5 lines
     if (atoi(state) != 4) {
tools/libxl/libxl_device.c +1 -2
-        libxl__device_destroy_tapdisk(&gc, be_path);
-        xs_rm(ctx->xsh, XBT_NULL, be_path);
+	libxl__device_destroy_tapdisk(&gc, be_path);
         goto out;

And this contains a whitespace change.

Ian.

#4 lore raw
Quoted 10 lines · Ian Jackson

Dr. Greg Wettstein writes ("[PATCH 2/2] 4.1.2 blktap2 cleanup fixes."):

Quoted 9 lines

---------------------------------------------------------------------------
The following patch when applied on top of:

libxl: attempt to cleanup tapdisk processes on disk backend destroy.

Establishes correct cleanup behavior for blktap devices. This patch implements the release of the backend device before calling for the destruction of the userspace component of the blktap device.

Quoted 8 lines
Quoted 5 lines

Without this patch the kernel xen-blkback driver deadlocks with the blktap2 user control plane until the IPC channel is terminated by the timeout on the select() call. This results in a noticeable delay in the termination of the guest and causes the blktap minor number which had been allocated to be orphaned.

This looks plausible. But shouldn't it be applied to xen-unstable and Xen 4.2 too ?

Xen unstable and 4.2 changed in other ways which included fixing this issue as a side effect. I can't remember which change it was but I think it was either your asyncing up of the interfaces or the block script stuff which I did. You can probably find out which by looking at previous postings of this series.

So this is a fix for the code as it was in 4.1.x

Ian.