Skip to contentSkip to conversation

2.6.4-rc1 oops on HPFS filesystem file rename

DISCUSSION Maurice van der Stee 2 participants 6 messages Feb 28, 2004 – Feb 29, 2004 Hpfs filesystem

lore
Share & tools
lore
#0 lore raw

Thanks, looks like it fixes my problem.

Quoted 12 lines
Quoted 11 lines · Maurice van der Stee

When saving an edited file residing on a HPFS filesystem I get the following
oops.
Kernel is 2.6.4-rc1, compiled with gcc 3.3.2. After this any access to
the
filesystem hangs the session. Kernel 2.6.3 has the same behavior. Don't
know
about earlier ones.

Quoted 3 lines

<stares at the code>
<blinks>
<wonders whereTF do we assign hpfs1_i and hpfs2_i if both inodes are

non-NULL>

fs/hpfs/buffer.c

Quoted 10 lines

<finds the patch in question>
<stares at jgarzik>

Fix follows. That, BTW, means that *nobody* had ever tried to use hpfs r/w since 2.5.3-pre3.

diff -urN RC4-rc1/fs/hpfs/buffer.c RC4-rc1-current/fs/hpfs/buffer.c

fs/hpfs/buffer.c +0 -0
@@ -62,56 +62,28 @@

<

fs/hpfs/buffer.c line 62

Quoted 1 line
fs/hpfs/buffer.c +0 -0
 void hpfs_lock_2inodes(struct inode *i1, struct inode *i2)

< {

Quoted 69 lines
fs/hpfs/buffer.c +14 -42
-	struct hpfs_inode_info *hpfs_i1 = NULL, *hpfs_i2 = NULL;
-
-	if (!i1) {
-		if (i2) {
-			hpfs_i2 = hpfs_i(i2);
+	if (!i2 || i1 == i2) {
+		hpfs_lock_inode(i1);
+	} else if (!i1) {
+		hpfs_lock_inode(i2);
+	} else {
+		struct hpfs_inode_info *hpfs_i1 = hpfs_i(i1);
+		struct hpfs_inode_info *hpfs_i2 = hpfs_i(i2);
+		if (i1->i_ino < i2->i_ino) {
+			down(&hpfs_i1->i_sem);
+			down(&hpfs_i2->i_sem);
+		} else {
 			down(&hpfs_i2->i_sem);
-		}
-		return;
-	}
-	if (!i2) {
-		if (i1) {
-			hpfs_i1 = hpfs_i(i1);
 			down(&hpfs_i1->i_sem);
 		}
-		return;
 	}
-	if (i1->i_ino < i2->i_ino) {
-		down(&hpfs_i1->i_sem);
-		down(&hpfs_i2->i_sem);
-	} else if (i1->i_ino > i2->i_ino) {
-		down(&hpfs_i2->i_sem);
-		down(&hpfs_i1->i_sem);
-	} else down(&hpfs_i1->i_sem);
 }
 
 void hpfs_unlock_2inodes(struct inode *i1, struct inode *i2)
 {
-	struct hpfs_inode_info *hpfs_i1 = NULL, *hpfs_i2 = NULL;
-
-	if (!i1) {
-		if (i2) {
-			hpfs_i2 = hpfs_i(i2);
-			up(&hpfs_i2->i_sem);
-		}
-		return;
-	}
-	if (!i2) {
-		if (i1) {
-			hpfs_i1 = hpfs_i(i1);
-			up(&hpfs_i1->i_sem);
-		}
-		return;
-	}
-	if (i1->i_ino < i2->i_ino) {
-		up(&hpfs_i2->i_sem);
-		up(&hpfs_i1->i_sem);
-	} else if (i1->i_ino > i2->i_ino) {
-		up(&hpfs_i1->i_sem);
-		up(&hpfs_i2->i_sem);
-	} else up(&hpfs_i1->i_sem);
+	/* order of up() doesn't matter here */
+	hpfs_unlock_inode(i1);
+	hpfs_unlock_inode(i2);
 }
 

void hpfs_lock_3inodes(struct inode *i1, struct inode *i2, struct inode *i3)
-

Signature · 2 lines
Maurice van der Stee
[email protected]
#1 lore raw
Quoted 1 line · Maurice van der Stee

Thanks, looks like it fixes my problem.

BTW, while we are at it, patch below kills the hpfs_lock_{2,3}inodes() monstrosities completely. We can always use parents-first ordering on the inodes, since these guys would only see contention with plain hpfs_lock_inode() and never with each other (all inodes involved already had semaphores held by callers in VFS).

See if that patch (on top of the previous one) works for you...

fs/hpfs/buffer.c +0 -68
diff -urN RC4-rc1-hpfs1/fs/hpfs/buffer.c RC4-rc1-current/fs/hpfs/buffer.c
@@ -60,74 +60,6 @@
 	}
 }
 
-void hpfs_lock_2inodes(struct inode *i1, struct inode *i2)
-{
-	if (!i2 || i1 == i2) {
-		hpfs_lock_inode(i1);
-	} else if (!i1) {
-		hpfs_lock_inode(i2);
-	} else {
-		struct hpfs_inode_info *hpfs_i1 = hpfs_i(i1);
-		struct hpfs_inode_info *hpfs_i2 = hpfs_i(i2);
-		if (i1->i_ino < i2->i_ino) {
-			down(&hpfs_i1->i_sem);
-			down(&hpfs_i2->i_sem);
-		} else {
-			down(&hpfs_i2->i_sem);
-			down(&hpfs_i1->i_sem);
-		}
-	}
-}
-
-void hpfs_unlock_2inodes(struct inode *i1, struct inode *i2)
-{
-	/* order of up() doesn't matter here */
-	hpfs_unlock_inode(i1);
-	hpfs_unlock_inode(i2);
-}
-
-void hpfs_lock_3inodes(struct inode *i1, struct inode *i2, struct inode *i3)
-{
-	if (!i1) { hpfs_lock_2inodes(i2, i3); return; }
-	if (!i2) { hpfs_lock_2inodes(i1, i3); return; }
-	if (!i3) { hpfs_lock_2inodes(i1, i2); return; }
-	if (i1->i_ino < i2->i_ino && i1->i_ino < i3->i_ino) {
-		struct hpfs_inode_info *hpfs_i1 = hpfs_i(i1);
-		down(&hpfs_i1->i_sem);
-		hpfs_lock_2inodes(i2, i3);
-	} else if (i2->i_ino < i1->i_ino && i2->i_ino < i3->i_ino) {
-		struct hpfs_inode_info *hpfs_i2 = hpfs_i(i2);
-		down(&hpfs_i2->i_sem);
-		hpfs_lock_2inodes(i1, i3);
-	} else if (i3->i_ino < i1->i_ino && i3->i_ino < i2->i_ino) {
-		struct hpfs_inode_info *hpfs_i3 = hpfs_i(i3);
-		down(&hpfs_i3->i_sem);
-		hpfs_lock_2inodes(i1, i2);
-	} else if (i1->i_ino != i2->i_ino) hpfs_lock_2inodes(i1, i2);
-	else hpfs_lock_2inodes(i1, i3);
-}
-		
-void hpfs_unlock_3inodes(struct inode *i1, struct inode *i2, struct inode *i3)
-{
-	if (!i1) { hpfs_unlock_2inodes(i2, i3); return; }
-	if (!i2) { hpfs_unlock_2inodes(i1, i3); return; }
-	if (!i3) { hpfs_unlock_2inodes(i1, i2); return; }
-	if (i1->i_ino < i2->i_ino && i1->i_ino < i3->i_ino) {
-		struct hpfs_inode_info *hpfs_i1 = hpfs_i(i1);
-		hpfs_unlock_2inodes(i2, i3);
-		up(&hpfs_i1->i_sem);
-	} else if (i2->i_ino < i1->i_ino && i2->i_ino < i3->i_ino) {
-		struct hpfs_inode_info *hpfs_i2 = hpfs_i(i2);
-		hpfs_unlock_2inodes(i1, i3);
-		up(&hpfs_i2->i_sem);
-	} else if (i3->i_ino < i1->i_ino && i3->i_ino < i2->i_ino) {
-		struct hpfs_inode_info *hpfs_i3 = hpfs_i(i3);
-		hpfs_unlock_2inodes(i1, i2);
-		up(&hpfs_i3->i_sem);
-	} else if (i1->i_ino != i2->i_ino) hpfs_unlock_2inodes(i1, i2);
-	else hpfs_unlock_2inodes(i1, i3);
-}
-
 /* Map a sector into a buffer and return pointers to it and to the buffer. */
 
 void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp,
fs/hpfs/hpfs_fn.h +0 -4
diff -urN RC4-rc1-hpfs1/fs/hpfs/hpfs_fn.h RC4-rc1-current/fs/hpfs/hpfs_fn.h
@@ -196,10 +196,6 @@
 void hpfs_unlock_iget(struct super_block *);
 void hpfs_lock_inode(struct inode *);
 void hpfs_unlock_inode(struct inode *);
-void hpfs_lock_2inodes(struct inode *, struct inode *);
-void hpfs_unlock_2inodes(struct inode *, struct inode *);
-void hpfs_lock_3inodes(struct inode *, struct inode *, struct inode *);
-void hpfs_unlock_3inodes(struct inode *, struct inode *, struct inode *);
 void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int);
 void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **);
 void *hpfs_map_4sectors(struct super_block *, unsigned, struct quad_buffer_head *, int);
fs/hpfs/namei.c +100 -72

219 lines not on this page · raw message

#2 lore raw

I think I tested most of the basic file system operations, rename, move, copy, edit, truncate etc. and found no problems with the second patch applied..

Signature · 2 lines
Maurice van der Stee
[email protected]
Quoted 358 lines · On 28-02-04 20:06:49, [email protected] wrote:
Quoted 1 line · Maurice van der Stee

Thanks, looks like it fixes my problem.

BTW, while we are at it, patch below kills the hpfs_lock_{2,3}inodes() monstrosities completely. We can always use parents-first ordering on the inodes, since these guys would only see contention with plain hpfs_lock_inode() and never with each other (all inodes involved already
had semaphores held by callers in VFS).

See if that patch (on top of the previous one) works for you...

diff -urN RC4-rc1-hpfs1/fs/hpfs/buffer.c
RC4-rc1-current/fs/hpfs/buffer.c

fs/hpfs/buffer.c +0 -68
@@ -60,74 +60,6 @@
 	}
 }
 
-void hpfs_lock_2inodes(struct inode *i1, struct inode *i2)
-{
-	if (!i2 || i1 == i2) {
-		hpfs_lock_inode(i1);
-	} else if (!i1) {
-		hpfs_lock_inode(i2);
-	} else {
-		struct hpfs_inode_info *hpfs_i1 = hpfs_i(i1);
-		struct hpfs_inode_info *hpfs_i2 = hpfs_i(i2);
-		if (i1->i_ino < i2->i_ino) {
-			down(&hpfs_i1->i_sem);
-			down(&hpfs_i2->i_sem);
-		} else {
-			down(&hpfs_i2->i_sem);
-			down(&hpfs_i1->i_sem);
-		}
-	}
-}
-
-void hpfs_unlock_2inodes(struct inode *i1, struct inode *i2)
-{
-	/* order of up() doesn't matter here */
-	hpfs_unlock_inode(i1);
-	hpfs_unlock_inode(i2);
-}
-
-void hpfs_lock_3inodes(struct inode *i1, struct inode *i2, struct
 inode *i3)
-{
-	if (!i1) { hpfs_lock_2inodes(i2, i3); return; }
-	if (!i2) { hpfs_lock_2inodes(i1, i3); return; }
-	if (!i3) { hpfs_lock_2inodes(i1, i2); return; }
-	if (i1->i_ino < i2->i_ino && i1->i_ino < i3->i_ino) {
-		struct hpfs_inode_info *hpfs_i1 = hpfs_i(i1);
-		down(&hpfs_i1->i_sem);
-		hpfs_lock_2inodes(i2, i3);
-	} else if (i2->i_ino < i1->i_ino && i2->i_ino < i3->i_ino) {
-		struct hpfs_inode_info *hpfs_i2 = hpfs_i(i2);
-		down(&hpfs_i2->i_sem);
-		hpfs_lock_2inodes(i1, i3);
-	} else if (i3->i_ino < i1->i_ino && i3->i_ino < i2->i_ino) {
-		struct hpfs_inode_info *hpfs_i3 = hpfs_i(i3);
-		down(&hpfs_i3->i_sem);
-		hpfs_lock_2inodes(i1, i2);
-	} else if (i1->i_ino != i2->i_ino) hpfs_lock_2inodes(i1, i2);
-	else hpfs_lock_2inodes(i1, i3);
-}
-		
-void hpfs_unlock_3inodes(struct inode *i1, struct inode *i2, struct
 inode *i3)
-{
-	if (!i1) { hpfs_unlock_2inodes(i2, i3); return; }
-	if (!i2) { hpfs_unlock_2inodes(i1, i3); return; }
-	if (!i3) { hpfs_unlock_2inodes(i1, i2); return; }
-	if (i1->i_ino < i2->i_ino && i1->i_ino < i3->i_ino) {
-		struct hpfs_inode_info *hpfs_i1 = hpfs_i(i1);
-		hpfs_unlock_2inodes(i2, i3);
-		up(&hpfs_i1->i_sem);
-	} else if (i2->i_ino < i1->i_ino && i2->i_ino < i3->i_ino) {
-		struct hpfs_inode_info *hpfs_i2 = hpfs_i(i2);
-		hpfs_unlock_2inodes(i1, i3);
-		up(&hpfs_i2->i_sem);
-	} else if (i3->i_ino < i1->i_ino && i3->i_ino < i2->i_ino) {
-		struct hpfs_inode_info *hpfs_i3 = hpfs_i(i3);
-		hpfs_unlock_2inodes(i1, i2);
-		up(&hpfs_i3->i_sem);
-	} else if (i1->i_ino != i2->i_ino) hpfs_unlock_2inodes(i1,
 i2);
-	else hpfs_unlock_2inodes(i1, i3);
-}
-

/* Map a sector into a buffer and return pointers to it and to the
buffer. */

void *hpfs_map_sector(struct super_block *s, unsigned secno, struct
buffer_head **bhp,
diff -urN RC4-rc1-hpfs1/fs/hpfs/hpfs_fn.h RC4-rc1-current/fs/hpfs/hpfs_fn.h

fs/hpfs/hpfs_fn.h +0 -4
@@ -196,10 +196,6 @@
 void hpfs_unlock_iget(struct super_block *);
 void hpfs_lock_inode(struct inode *);
 void hpfs_unlock_inode(struct inode *);
-void hpfs_lock_2inodes(struct inode *, struct inode *);
-void hpfs_unlock_2inodes(struct inode *, struct inode *);
-void hpfs_lock_3inodes(struct inode *, struct inode *, struct inode
 *);
-void hpfs_unlock_3inodes(struct inode *, struct inode *, struct  

inode
*);
void *hpfs_map_sector(struct super_block *, unsigned, struct
buffer_head **, int);
void *hpfs_get_sector(struct super_block *, unsigned, struct
buffer_head **);
void *hpfs_map_4sectors(struct super_block *, unsigned, struct
quad_buffer_head *, int);
diff -urN RC4-rc1-hpfs1/fs/hpfs/namei.c RC4-rc1-current/fs/hpfs/namei.c

fs/hpfs/namei.c +16 -23
@@ -340,39 +340,41 @@
 	fnode_secno fno;
 	int r;
 	int rep = 0;
+	int err;
 
 	lock_kernel();
 	hpfs_adjust_length((char *)name, &len);
 again:
-	hpfs_lock_2inodes(dir, inode);
-	if (!(de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name,
 len, &dno, &qbh))) {
-		hpfs_unlock_2inodes(dir, inode);
-		unlock_kernel();
-		return -ENOENT;
-	}
-	if (de->first) {
-		hpfs_brelse4(&qbh);
-		hpfs_unlock_2inodes(dir, inode);
-		unlock_kernel();
-		return -EPERM;
-	}
-	if (de->directory) {
-		hpfs_brelse4(&qbh);
-		hpfs_unlock_2inodes(dir, inode);
-		unlock_kernel();
-		return -EISDIR;
-	}
+	hpfs_lock_inode(dir);
+	hpfs_lock_inode(inode);
+	de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len,
 &dno, &qbh);
+	err = -ENOENT;
+	if (!de)
+		goto out;
+
+	err = -EPERM;
+	if (de->first)
+		goto out1;
+
+	err = -EISDIR;
+	if (de->directory)
+		goto out1;
+
 	fno = de->fnode;
-	if ((r = hpfs_remove_dirent(dir, dno, de, &qbh, 1)) == 1)
 hpfs_error(dir->i_sb, "there was error when removing dirent");
-	if (r != 2) {
-		inode->i_nlink--;
-		hpfs_unlock_2inodes(dir, inode);
-	} else {	/* no space for deleting, try to truncate

file */

fs/hpfs/namei.c +4 -5
-		struct iattr newattrs;
-		int err;
-		hpfs_unlock_2inodes(dir, inode);
-		if (rep)
-			goto ret;
+	r = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
+	switch (r) {
+	case 1:
+		hpfs_error(dir->i_sb, "there was error when removing

dirent");

fs/hpfs/namei.c +3 -0
+		err = -EFSERROR;
+		break;
+	case 2:		/* no space for deleting, try to

truncate file */

fs/hpfs/namei.c +11 -1
+
+		err = -ENOSPC;
+		if (rep++)
+			break;
+
+		hpfs_unlock_inode(inode);
+		hpfs_unlock_inode(dir);
 		d_drop(dentry);
 		spin_lock(&dentry->d_lock);
 		if (atomic_read(&dentry->d_count) > 1 ||
@@ -381,22 +383,32 @@
 		    get_write_access(inode)) {
 			spin_unlock(&dentry->d_lock);
 			d_rehash(dentry);
-			goto ret;
+		} else {
+			struct iattr newattrs;
+			spin_unlock(&dentry->d_lock);
+			/*printk("HPFS: truncating file before

delete.\n");*/

fs/hpfs/namei.c +62 -42
+			newattrs.ia_size = 0;
+			newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
+			err = notify_change(dentry, &newattrs);
+			put_write_access(inode);
+			if (!err)
+				goto again;
 		}
-		spin_unlock(&dentry->d_lock);
-		/*printk("HPFS: truncating file before delete.\n");*/
-		newattrs.ia_size = 0;
-		newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
-		err = notify_change(dentry, &newattrs);
-		put_write_access(inode);
-		if (err)
-			goto ret;
-		rep = 1;
-		goto again;
+		unlock_kernel();
+		return -ENOSPC;
+	default:
+		inode->i_nlink--;
+		err = 0;
 	}
-ret:
+	goto out;
+
+out1:
+	hpfs_brelse4(&qbh);
+out:
+	hpfs_unlock_inode(inode);
+	hpfs_unlock_inode(dir);
 	unlock_kernel();
-	return r == 2 ? -ENOSPC : r == 1 ? -EFSERROR : 0;
+	return err;
 }
 
 int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
@@ -409,44 +421,54 @@
 	dnode_secno dno;
 	fnode_secno fno;
 	int n_items = 0;
+	int err;
 	int r;
+
 	hpfs_adjust_length((char *)name, &len);
 	lock_kernel();
-	hpfs_lock_2inodes(dir, inode);
-	if (!(de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name,
 len, &dno, &qbh))) {
-		hpfs_unlock_2inodes(dir, inode);
-		unlock_kernel();
-		return -ENOENT;
-	}	
-	if (de->first) {
-		hpfs_brelse4(&qbh);
-		hpfs_unlock_2inodes(dir, inode);
-		unlock_kernel();
-		return -EPERM;
-	}
-	if (!de->directory) {
-		hpfs_brelse4(&qbh);
-		hpfs_unlock_2inodes(dir, inode);
-		unlock_kernel();
-		return -ENOTDIR;
-	}
+	hpfs_lock_inode(dir);
+	hpfs_lock_inode(inode);
+	err = -ENOENT;
+	de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len,
 &dno, &qbh);
+	if (!de)
+		goto out;
+
+	err = -EPERM;
+	if (de->first)
+		goto out1;
+
+	err = -ENOTDIR;
+	if (!de->directory)
+		goto out1;
+
 	hpfs_count_dnodes(dir->i_sb, hpfs_i(inode)->i_dno, NULL,
 NULL, &n_items);
-	if (n_items) {
-		hpfs_brelse4(&qbh);
-		hpfs_unlock_2inodes(dir, inode);
-		unlock_kernel();
-		return -ENOTEMPTY;
-	}
+	err = -ENOTEMPTY;
+	if (n_items)
+		goto out1;
+
 	fno = de->fnode;
-	if ((r = hpfs_remove_dirent(dir, dno, de, &qbh, 1)) == 1)
+	r = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
+	switch (r) {
+	case 1:
 		hpfs_error(dir->i_sb, "there was error when removing
 dirent");
-	if (r != 2) {
+		err = -EFSERROR;
+		break;
+	case 2:
+		err = -ENOSPC;
+		break;
+	default:
 		dir->i_nlink--;
 		inode->i_nlink = 0;
-		hpfs_unlock_2inodes(dir, inode);
-	} else hpfs_unlock_2inodes(dir, inode);
+		err = 0;
+	}
+	goto out;
+out1:
+	hpfs_brelse4(&qbh);
+out:
+	hpfs_unlock_inode(inode);
+	hpfs_unlock_inode(dir);
 	unlock_kernel();
-	return r == 2 ? -ENOSPC : r == 1 ? -EFSERROR : 0;
+	return err;
 }
 
 int hpfs_symlink_readpage(struct file *file, struct page *page)
@@ -501,7 +523,10 @@
 	hpfs_adjust_length((char *)old_name, &old_len);
 
 	lock_kernel();
-	hpfs_lock_3inodes(old_dir, new_dir, i);
+	hpfs_lock_inode(old_dir);
+	if (new_dir != old_dir)
+		hpfs_lock_inode(new_dir);
+	hpfs_lock_inode(i);
 
 	/* Erm? Moving over the empty non-busy directory is perfectly

legal */

fs/hpfs/namei.c +4 -1
 	if (new_inode && S_ISDIR(new_inode->i_mode)) {
@@ -580,7 +605,10 @@
 	hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv;
 	hpfs_decide_conv(i, (char *)new_name, new_len);
 	end1:
-	hpfs_unlock_3inodes(old_dir, new_dir, i);
+	hpfs_unlock_inode(i);
+	if (old_dir != new_dir)
+		hpfs_unlock_inode(new_dir);
+	hpfs_unlock_inode(old_dir);
 	unlock_kernel();
 	return err;
 }
#3 lore raw
Quoted 3 lines · Maurice van der Stee

I think I tested most of the basic file system operations, rename, move, copy, edit, truncate etc. and found no problems with the second patch applied..

Actually, I've found a problem with the original - race between write_inode() and cross-directory rename(), of all things. Mind testing the patchset on ftp.linux.org.uk/pub/people/viro/HPFS*? First two patches were posted in this thread, the rest goes on top of them.

Race in question is funny, BTW - write_inode() might have to find and update directory entry in the parent, so it gets the parent inode and locks it (that's what hpfs-private lock was for - it gave exclusion between directory modifications and write_inode() directory entry update; directory entries can move on insertion/removal, so we need to make sure that it won't happen during that updating). The trouble being, it did not make sure that we lock the right directory - if rename() had moved the file in question while we were trying to lock the parent, we would end up with very confused write_inode().

Similar race exists for unlink() vs. write_inode() - the latter checks ->i_nlink, but there is no warranty that it won't become 0 between the check and locking the parent. Ditto for rmdir() and overwriting rename().

The fix is simple: we turn semaphore into sempahore + rwsem and
1) on mkdir/mknod/create/symlink grab rwsem on parent for writing
2) on rmdir/unlink/rename we grab semaphore on victim and object
being moved, then grab rwsem on parent(s) for writing.
3) on write_inode we grab semaphore on inode, then check that
it has non-zero ->i_nlink, get parent and grab rwsem on parent for reading.

Exclusion already provided by VFS makes order in rename() (there we might get two semaphores and two rwsems) a non-issue - we already have all ->rename() on given fs serialized. Order among semaphores and among rwsems, that is - semaphores are always taken first.

Aside of that, patchset switches from use of iget() to use of iget_locked(), which allows to kill the horrors in hpfs_lock_iget(), and does general cleanup.

Unless there are complaints and bug reports, it will go to Linus in a couple of days.

#4 lore raw
Quoted 2 lines · On Sun, Feb 29, 2004 at 01:14:25PM +0000…

Unless there are complaints and bug reports, it will go to Linus in a couple of days.

Oh, lovely - there's a deadlock (both in new and old code) too. The trouble being, we can get ->write_inode() *triggered* in the middle of btree rebalancing. Which leads to deadlock, since we really need the exclusion there (and would be very unhappy if search for directory entry would happen in the middle of that fun).

Fix is to switch the allocations done in that area to GFP_NOFS. However, there's an extra PITA caused by inode allocations - we'll need to take the inode allocation in hpfs_create() et.al. outside of lock on parent.

Potential inode allocation in ->write_inode() (done if parent inode is not in core - that can happen, unfortunately) is not a problem if we replace the "parent can change" semaphore to rwsem and hold it for read here. There's no risk of down_read()/somebody does down_write()/the first task gets recursive down_read() deadlock in that case, since all down_write() can happen only if parent inode is already in-core.

Sigh... Gotta love that code - deadlocks had been there since _way_ back...

Additional patch later today...

#5 lore raw
Quoted 1 line · On Sun, Feb 29, 2004 at 01:58:49PM +0000…

Additional patch later today...

Same place, HPFS9-hpfs_deadlock-RC4-rc1 (on top of the previous). It's obviously going to be reordered before it gets submitted, but for now I'd rather just drop incrmentals there...

I'll do reordering in a couple of hours.