From: "Jan Beulich" Subject: [PATCH] linux/blktap: fix cleanup after unclean application exit #2 Date: Wed, 21 Apr 2010 14:53:25 +0100 Message-ID: <4BCF1F75020000780003B317@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartAA802345.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartAA802345.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: blktap: fix cleanup after unclean application exit #2 When an application using blktap devices doesn't close the mmap-s of /dev/xen/blktapN and the frontend driver never connects, we cannot defer the mmput() on the stored mm until blktap_release() or the exit path of the worker thread, as the former will never be called without the mm's reference count dropping to zero, and the worker thread would never get started. Also remove a left-over from c/s 1013. Signed-off-by: Jan Beulich --- sle11sp1-2010-04-12.orig/drivers/xen/blktap/blktap.c 2010-04-21 = 13:43:49.000000000 +0200 +++ sle11sp1-2010-04-12/drivers/xen/blktap/blktap.c 2010-04-20 = 18:21:03.000000000 +0200 @@ -553,6 +553,7 @@ void signal_tapdisk(int idx)=20 { tap_blkif_t *info; struct task_struct *ptask; + struct mm_struct *mm; =20 /* * if the userland tools set things up wrong, this could be = negative; @@ -573,7 +574,9 @@ void signal_tapdisk(int idx)=20 } info->blkif =3D NULL; =20 - return; + mm =3D xchg(&info->mm, NULL); + if (mm) + mmput(mm); } =20 static int blktap_open(struct inode *inode, struct file *filp) @@ -653,7 +656,6 @@ static int blktap_release(struct inode * mm =3D xchg(&info->mm, NULL); if (mm) mmput(mm); - info->mm =3D NULL; kfree(info->foreign_map.map); info->foreign_map.map =3D NULL; =20 --=__PartAA802345.0__= Content-Type: text/plain; name="xen-blktap-teardown-hvm.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-blktap-teardown-hvm.patch" Subject: blktap: fix cleanup after unclean application exit #2=0A=0AWhen = an application using blktap devices doesn't close the mmap-s of=0A/dev/xen/= blktapN and the frontend driver never connects, we cannot=0Adefer the = mmput() on the stored mm until blktap_release() or the exit=0Apath of the = worker thread, as the former will never be called without=0Athe mm's = reference count dropping to zero, and the worker thread=0Awould never get = started.=0A=0AAlso remove a left-over from c/s 1013.=0A=0ASigned-off-by: = Jan Beulich =0A=0A--- sle11sp1-2010-04-12.orig/drivers= /xen/blktap/blktap.c 2010-04-21 13:43:49.000000000 +0200=0A+++ = sle11sp1-2010-04-12/drivers/xen/blktap/blktap.c 2010-04-20 18:21:03.0000000= 00 +0200=0A@@ -553,6 +553,7 @@ void signal_tapdisk(int idx) =0A {=0A = tap_blkif_t *info;=0A struct task_struct *ptask;=0A+ struct mm_struct = *mm;=0A =0A /*=0A * if the userland tools set things up wrong, this = could be negative;=0A@@ -573,7 +574,9 @@ void signal_tapdisk(int idx) =0A = }=0A info->blkif =3D NULL;=0A =0A- return;=0A+ mm =3D xchg(&info->= mm, NULL);=0A+ if (mm)=0A+ mmput(mm);=0A }=0A =0A static int = blktap_open(struct inode *inode, struct file *filp)=0A@@ -653,7 +656,6 @@ = static int blktap_release(struct inode *=0A mm =3D xchg(&info->mm, = NULL);=0A if (mm)=0A mmput(mm);=0A- info->mm =3D = NULL;=0A kfree(info->foreign_map.map);=0A info->foreign_map.m= ap =3D NULL;=0A =0A --=__PartAA802345.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartAA802345.0__=--