2.1.105 knfsd hoses dcache on mkdir . (patch included)

Anders Hammarquist (iko@iko.pp.se)
Wed, 10 Jun 1998 02:52:48 +0200


Hi!

I just booted 2.1.105 (Linus version) and found a rather interesting
misfeature with knfs. My client (sun sparcclassic running linux 2.0.33) did
mkdir . in a nfsmounted directory (tar extracting an archive). This caused
knfsd to make a new directory of the same name as the old, in the old
directory, but link it in to the dcache where the old directory had been. A
bit frightening until I ran debugfs on the filesystem to find out what really
happened...

Anyway, attached is a short patch that makes attempts to create existing
directories over nfs fail with -EEXIST. Tested here and is working fine so far.

Regards,
/Anders

Debug from knfs:
Jun 10 00:36:54 twoflower kernel: nfsd_dispatch: proc 14
Jun 10 00:36:54 twoflower kernel: nfsd: MKDIR 00000000 .
Jun 10 00:36:54 twoflower kernel: nfsd: fh_verify(exp 808/2 cookie c271fc80)
Jun 10 00:36:54 twoflower kernel: nfsd: fh_compose(exp 808/2 iko/tape,
ino=51490)
Jun 10 00:36:54 twoflower kernel: nfsd_create: dentry iko/tape not negative!
Jun 10 00:36:54 twoflower kernel: nfsd: fh_verify(exp 808/2 cookie c271fc80)
Jun 10 00:36:54 twoflower kernel: nfsd: ressize_check p c3210080 base c3210000
len 2304
Jun 10 00:36:54 twoflower kernel: nfsd_dispatch: proc 4
Jun 10 00:36:54 twoflower kernel: nfsd: LOOKUP 2056/51490
ScriptKit-0.1.5.tar.gz
Jun 10 00:36:54 twoflower kernel: nfsd: nfsd_lookup(fh 00000000,
ScriptKit-0.1.5.tar.gz)
Jun 10 00:36:54 twoflower kernel: nfsd: fh_verify(exp 808/2 cookie c271fc80)
Jun 10 00:36:54 twoflower kernel: find_fh_dentry: iko/tape lookup mismatch!
Jun 10 00:36:54 twoflower kernel: lookup_by_inode: found tape
Jun 10 00:36:54 twoflower kernel: lookup_by_inode: iko/tape inode mismatch??
Jun 10 00:36:54 twoflower kernel: find_fh_dentry: 08:08, 36865/51490 not found
-- need full search!
Jun 10 00:36:54 twoflower kernel: nfsd_dispatch: proc 9
Jun 10 00:36:54 twoflower kernel: nfsd: CREATE 2056/51490
ScriptKit-0.1.5.tar.gz
Jun 10 00:36:54 twoflower kernel: nfsd: fh_verify(exp 808/2 cookie c271fc80)
Jun 10 00:36:54 twoflower kernel: find_fh_dentry: iko/tape lookup mismatch!
Jun 10 00:36:54 twoflower kernel: lookup_by_inode: found tape
Jun 10 00:36:54 twoflower kernel: lookup_by_inode: iko/tape inode mismatch??
Jun 10 00:36:54 twoflower kernel: find_fh_dentry: 08:08, 36865/51490 not found
-- need full search!

--->8---
--- /home/vger/linux-vger/fs/nfsd/vfs.c Sun Feb 8 10:33:50 1998
+++ fs/nfsd/vfs.c Wed Jun 10 01:34:30 1998
@@ -616,12 +616,15 @@
err = dirp->i_op->create(dirp, dchild, iap->ia_mode);
break;
case S_IFDIR:
- err = dirp->i_op->mkdir(dirp, dchild, iap->ia_mode);
+ if (dchild->d_inode)
+ err = -EEXIST;
+ else
+ err = dirp->i_op->mkdir(dirp, dchild, iap->ia_mode);
break;
case S_IFCHR:
case S_IFBLK:
--->8---

-- 
 -- This message specially handmade by the imps of the Couterweight Continent
Anders Hammarquist, Mandolingatan 5, S-421 40 Västra Frölunda
iko@iko.pp.se

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu