public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* bug in ext3 htree rename: doesn't delete old name, leaves ino with bad nlink
@ 2002-11-05  4:47 Jeremy Fitzhardinge
  2002-11-05 21:24 ` [Ext2-devel] " chrisl
  0 siblings, 1 reply; 13+ messages in thread
From: Jeremy Fitzhardinge @ 2002-11-05  4:47 UTC (permalink / raw)
  To: Ext2 devel; +Cc: Linux Kernel List

I've isolated the problem to rename not removing the old name under some
circumstances, leaving two names for a file with an nlink of 1.  This
will reliably reproduce the problem for me, under 2.4.19-ac4 and 2.4.19
(stock) w/ patch-ext3-dxdir-2.4.19-4.

Generate a new filesystem: this will create htree-bug.fs
$ sh genfs

# mkdir m
# mount -o loop htree-bug.fs m

$ gcc -o tickle tickle.c
$ ./tickle m/test
*** rename("drivers/scsi/psi240i.h", "drivers/scsi/psi240i.h.orig") failure:
stating drivers/scsi/psi240i.h
  ino=294
  nlink=1
stating drivers/scsi/psi240i.h.orig
  ino=294
  nlink=1
*** rename("drivers/scsi/sun3_scsi.h", "drivers/scsi/sun3_scsi.h.orig") failure:
stating drivers/scsi/sun3_scsi.h
  ino=350
  nlink=1
stating drivers/scsi/sun3_scsi.h.orig
  ino=350
  nlink=1

# umount m

$ e2fsck -f htree-bug.fs
e2fsck 1.30-WIP (30-Sep-2002)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Inode 294 ref count is 1, should be 2.  Fix<y>? yes

Inode 350 ref count is 1, should be 2.  Fix<y>? yes

Pass 5: Checking group summary information

htree-bug.fs: ***** FILE SYSTEM WAS MODIFIED *****
htree-bug.fs: 541/10240 files (0.2% non-contiguous), 1369/10240 blocks
exit status 1
$ debugfs htree-bug.fs 
debugfs 1.30-WIP (30-Sep-2002)
debugfs:  ncheck 294
Inode   Pathname
294     /test/drivers/scsi/psi240i.h
debugfs:  ncheck 350
Inode   Pathname
350     /test/drivers/scsi/sun3_scsi.h


I've put all the bits needed to reproduce the bug (genfs, tickle) at
http://www.goop.org/~jeremy/htree/


        J


^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: [PATCH] Fix bug in ext3 htree rename: doesn't delete old name , leaves ino with bad nlink
@ 2002-11-07  5:40 Christopher Li
  0 siblings, 0 replies; 13+ messages in thread
From: Christopher Li @ 2002-11-07  5:40 UTC (permalink / raw)
  To: 'Theodore Ts'o ', 'Alexander Viro '
  Cc: Christopher Li, 'Jeremy Fitzhardinge ',
	'Ext2 devel ', 'Linux Kernel List '

The revised patch:

--- namei.c     2002/11/06 07:19:11     1.2
+++ namei.c     2002/11/07 05:24:46
@@ -2167,8 +2167,25 @@
        /*
         * ok, that's it
         */
-       ext3_delete_entry(handle, old_dir, old_de, old_bh);
-
+       retval = ext3_delete_entry(handle, old_dir, old_de, old_bh);
+       if (retval == -ENOENT) {
+               /*
+                * old_de can be moved during ext3_add_entry.
+                */
+               struct buffer_head * old_bh2;
+               struct ext3_dir_entry_2 * old_de2;
+               old_bh2 = ext3_find_entry (old_dentry, &old_de2);
+               if (old_bh2) {
+                       retval = ext3_delete_entry(handle, old_dir, old_de2,
+                                                  old_bh2);
+                       brelse(old_bh2);
+               }
+       }
+       if (retval) {
+               ext3_warning (old_dir->i_sb, "ext3_rename",
+                             "Deleting old file (%lu), %d, error=%d",
+                             old_dir->i_ino, old_dir->i_nlink, retval);
+       }
        if (new_inode) {
                new_inode->i_nlink--;
                new_inode->i_ctime = CURRENT_TIME;

Chris

-----Original Message-----
From: Theodore Ts'o
To: Alexander Viro
Cc: Christopher Li; Jeremy Fitzhardinge; Ext2 devel; Linux Kernel List
Sent: 11/6/02 6:44 PM
Subject: Re: [PATCH] Fix bug in ext3 htree rename: doesn't delete old name,
leaves ino with bad nlink

On Wed, Nov 06, 2002 at 05:47:40PM -0500, Alexander Viro wrote:
> 
> HUH?
> 
> ->rename() holds ->i_sem on both directories.  So do all other
directory
> methods.  What the hell is going on there?

What's going on is that had a brain-fart, and forgot about inode
semaphore that's held by the VFS layer.  Chris, sorry about that;
there is no need retry multiple times.  We only need to retry once, in
the case where the node gets split.

						- Ted



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-11-07  5:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-05  4:47 bug in ext3 htree rename: doesn't delete old name, leaves ino with bad nlink Jeremy Fitzhardinge
2002-11-05 21:24 ` [Ext2-devel] " chrisl
2002-11-06  5:02   ` Jeremy Fitzhardinge
2002-11-06  8:25   ` [PATCH] Fix " chrisl
2002-11-06  8:44     ` Andrew Morton
2002-11-06 21:40     ` Theodore Ts'o
2002-11-07  1:24       ` Christopher Li
2002-11-06 22:41         ` Theodore Ts'o
2002-11-06 22:47           ` Alexander Viro
2002-11-07  2:44             ` Theodore Ts'o
2002-11-07  1:58           ` Christopher Li
2002-11-06 23:27         ` [Ext2-devel] " Andreas Dilger
  -- strict thread matches above, loose matches on Subject: below --
2002-11-07  5:40 [PATCH] Fix bug in ext3 htree rename: doesn't delete old name , " Christopher Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox