Bug 159418 - [tmpfs] [panic] [patch] tmpfs kernel panic: recursing on non recursive lockmgr tmpfs
Summary: [tmpfs] [panic] [patch] tmpfs kernel panic: recursing on non recursive lockmg...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 1.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: Ivan Voras
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-03 16:50 UTC by Gennady Proskurin
Modified: 2012-01-09 13:46 UTC (History)
0 users

See Also:


Attachments
file.txt (44.26 KB, text/plain)
2011-08-03 16:50 UTC, Gennady Proskurin
no flags Details
tmpfs-rename_lock.patch.txt (567 bytes, text/plain; charset=utf-8)
2011-08-05 07:55 UTC, Gleb Kurtsou
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gennady Proskurin 2011-08-03 16:50:08 UTC
My world and kernel are out of sync, I updated kernel to reproduce bug on new kernel, so some info (netstat, vmstat) is not available in crash info file. This bug is easily reproducible, so I don't think it is a problem.
If you need more information, or want crash info from synced kernel/world, feel free to ask.

Fix: Patch attached with submission follows:
How-To-Repeat: cd /tmp
mkdir -p a/a
mv a/a .
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-08-05 03:44:45 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 Gleb Kurtsou 2011-08-05 07:55:50 UTC
Could you test the patch attached.

Thanks,
Gleb.
Comment 3 Andrei Lavreniyuk 2011-08-05 09:36:45 UTC
Hi!

On a system FreeBSD 8.2-STABLE error is present. The patch works fine.

FreeBSD datacenter.technica-03.local 8.2-STABLE FreeBSD 8.2-STABLE #0:
Thu Aug  4 12:36:33 EEST 2011
root@datacenter.technica-03.local:/usr/obj/usr/src/sys/SMP64  amd64


# cd /tmp
# mkdir -p a/a
# mv a/a .
mv: rename a/a to ./a: Directory not empty

# df -h | egrep tmpfs
tmpfs                             1.0G     16k      1G     0%    /tmp




---
Best regards, Andrei Lavreniyuk.
Comment 4 g.proskurin 2011-08-05 11:16:46 UTC
Patch works for me, it fixes panic. Thanks.
Comment 5 dfilter service freebsd_committer freebsd_triage 2011-11-22 16:18:26 UTC
Author: ivoras
Date: Tue Nov 22 16:18:12 2011
New Revision: 227822
URL: http://svn.freebsd.org/changeset/base/227822

Log:
  Avoid panics from recursive rename operations. Not a perfect patch but
  good enough for now.
  
  PR:		kern/159418
  Submitted by:	Gleb Kurtsou
  Reviewed by:	kib
  MFC after:	1 month

Modified:
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Nov 22 16:08:12 2011	(r227821)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Nov 22 16:18:12 2011	(r227822)
@@ -965,11 +965,8 @@ tmpfs_rename(struct vop_rename_args *v)
 
 	/* If we need to move the directory between entries, lock the
 	 * source so that we can safely operate on it. */
-	if (tdvp != fdvp) {
-		error = vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
-		if (error != 0)
-			goto out;
-	}
+	if (fdvp != tdvp && fdvp != tvp)
+		vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
 	fdnode = VP_TO_TMPFS_DIR(fdvp);
 	fnode = VP_TO_TMPFS_NODE(fvp);
 	de = tmpfs_dir_lookup(fdnode, fnode, fcnp);
@@ -1143,7 +1140,7 @@ tmpfs_rename(struct vop_rename_args *v)
 	error = 0;
 
 out_locked:
-	if (fdnode != tdnode)
+	if (fdvp != tdvp && fdvp != tvp)
 		VOP_UNLOCK(fdvp, 0);
 
 out:
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 Mark Linimon freebsd_committer freebsd_triage 2011-12-04 00:17:03 UTC
State Changed
From-To: open->patched

Over to committer as MFC reminder. 


Comment 7 Mark Linimon freebsd_committer freebsd_triage 2011-12-04 00:17:03 UTC
Responsible Changed
From-To: freebsd-fs->ivoras
Comment 8 dfilter service freebsd_committer freebsd_triage 2012-01-09 13:35:43 UTC
Author: ivoras
Date: Mon Jan  9 13:35:10 2012
New Revision: 229855
URL: http://svn.freebsd.org/changeset/base/229855

Log:
  MFC r227822: Avoid panics from recursive rename operations.
  
  PR:		kern/159418

Modified:
  stable/9/sys/fs/tmpfs/tmpfs_vnops.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)

Modified: stable/9/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- stable/9/sys/fs/tmpfs/tmpfs_vnops.c	Mon Jan  9 12:06:09 2012	(r229854)
+++ stable/9/sys/fs/tmpfs/tmpfs_vnops.c	Mon Jan  9 13:35:10 2012	(r229855)
@@ -965,11 +965,8 @@ tmpfs_rename(struct vop_rename_args *v)
 
 	/* If we need to move the directory between entries, lock the
 	 * source so that we can safely operate on it. */
-	if (tdvp != fdvp) {
-		error = vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
-		if (error != 0)
-			goto out;
-	}
+	if (fdvp != tdvp && fdvp != tvp)
+		vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
 	fdnode = VP_TO_TMPFS_DIR(fdvp);
 	fnode = VP_TO_TMPFS_NODE(fvp);
 	de = tmpfs_dir_lookup(fdnode, fnode, fcnp);
@@ -1143,7 +1140,7 @@ tmpfs_rename(struct vop_rename_args *v)
 	error = 0;
 
 out_locked:
-	if (fdnode != tdnode)
+	if (fdvp != tdvp && fdvp != tvp)
 		VOP_UNLOCK(fdvp, 0);
 
 out:
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 9 Ivan Voras freebsd_committer freebsd_triage 2012-01-09 13:44:54 UTC
State Changed
From-To: patched->closed

Committed, MFC-ed to 9