[PATCH] Fix for swapoff after re-creating device files

Linux Kernel Mailing List <[email protected]> Sat, 26 Feb 2005 12:28:54 +0000
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
ChangeSet 1.1556, 2005/02/26 09:28:54-03:00, [email protected]

	[PATCH] Fix for swapoff after re-creating device files
	
	$SUBJECT says it all - if device is recreated the current dentry-only
	comparison in sys_swapoff() might have problems.



 swapfile.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)


diff -Nru a/mm/swapfile.c b/mm/swapfile.c
--- a/mm/swapfile.c	2005-02-26 10:03:54 -08:00
+++ b/mm/swapfile.c	2005-02-26 10:03:54 -08:00
@@ -738,8 +738,10 @@
 	for (type = swap_list.head; type >= 0; type = swap_info[type].next) {
 		p = swap_info + type;
 		if ((p->flags & SWP_WRITEOK) == SWP_WRITEOK) {
-			if (p->swap_file == nd.dentry)
-			  break;
+			if (p->swap_file == nd.dentry ||
+			    (S_ISBLK(nd.dentry->d_inode->i_mode) &&
+			    p->swap_device == nd.dentry->d_inode->i_rdev))
+				break;
 		}
 		prev = type;
 	}