PROBLEM: telldir() broken on large ext3 dir_index'd directories because getdents() gives d_off==0 for the first entry

From: r6144 (rainy6144_at_gmail.com)
Date: 11/09/04

  • Next message: Greg KH: "Re: [PATCH] I2C update for 2.6.10-rc1"
    Date:	Tue, 9 Nov 2004 14:18:32 +0800
    To: linux-kernel@vger.kernel.org
    
    
    

    [1.] One line summary of the problem:
    telldir() broken on large ext3 dir_index'd directories because
    getdents() gives d_off==0 for the first entry

    [2.] Full description of the problem/report:
    Create a large directory in an ext3 filesystem with dir_index enabled,
    and running getdents() on it sometimes gives d_off==0 for the first
    entry (usually "."), which seems to be wrong since lseek()'ing to that
    offset does not make subsequent getdents() calls skip that entry.
    This breaks programs that readdir() the first entry, call telldir() (which
    erroneously returns 0) then seekdir() with telldir()'s result, expecting the
    next readdir() to return the second entry.

    [3.] Keywords (i.e., modules, networking, kernel):
    fs,ext3

    [4.] Kernel version (from /proc/version):
    Linux version 2.6.9-skas3-v7 (root@Default) (gcc version 3.2.2
    20030222 (Red Hat Linux 3.2.2-5)) #1 Mon Nov 8 20:07:10 CST 2004

    The skas3-v7 patch comes from
    http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/,
    I don't think it will break things. Will you please try to reproduce
    the problem
    on vanilla 2.6.9?

    [6.] A small shell script or example program which triggers the
         problem (if possible)
    1. Bunzip2 the attached e2test.bz2 file, and loop-mount it using ext3
    onto e.g. /mnt/loop0
    2. Compile test_readdir1.c and test_readdir2.c.
    3. Run "./test_readdir1 /mnt/loop0/test4", which should run correctly,
    giving results like

    249e4711: ..
    393238f2: 1
    4a8ec49c: 6
    ...

    4. Run "./test_readdir1 /mnt/loop0/test3", which ends up in an infinite loop:

    00000000: .
    ...

    5. Run "./test_readdir2 /mnt/loop0/test3":

    d_ino=2052, d_off=0, d_name=.
    d_ino=2, d_off=800177, d_name=..
    d_ino=12, d_off=1177726, d_name=2662
    ...

    The d_off=0 looks wrong.

    6. Running e2fsck 1.34 on that filesystem does not reveal problems.

    [7.] Environment
    Mostly redhat 9. In particular the glibc is the version in redhat 9,
    which is glibc-2.3.2-27.9.

    [7.1.] Software (add the output of the ver_linux script here)
    Linux Default 2.6.9-skas3-v7 #1 Mon Nov 8 20:07:10 CST 2004 i686 i686
    i386 GNU/Linux
     
    Gnu C 3.2.2
    Gnu make 3.79.1
    binutils 2.13.90.0.18
    util-linux 2.11y
    mount 2.11y
    module-init-tools 2.4.25
    e2fsprogs 1.34
    reiserfsprogs 2002------------->
    reiser4progs line
    quota-tools 3.09.
    nfs-utils 1.0.5
    Linux C Library 2.3.2
    Dynamic linker (ldd) 2.3.2
    Linux C++ Library new..
    Linux C++ Library 5..
    Procps 2.0.14
    Net-tools 1.60
    Kbd 1.06
    Sh-utils 4.5.3
    Modules Loaded cramfs loop tun iptable_nat ip_conntrack
    ipt_multiport ipt_REJECT iptable_filter ip_tables snd_mixer_oss
    snd_intel8x0 snd_ac97_codec snd_pcm snd_timer snd_page_alloc
    snd_mpu401_uart snd_rawmidi snd_seq_device snd soundcore i830
    intel_agp agpgart usb_storage scsi_mod pcspkr w83627hf eeprom
    i2c_sensor i2c_isa i2c_i801 i2c_core binfmt_misc parport_pc lp parport
    autofs via_rhine 8139too mii crc32 md5 ipv6 microcode nls_cp936 vfat
    fat usbhid ehci_hcd uhci_hcd usbcore ext3 jbd

    [7.2.] Processor information (from /proc/cpuinfo):
    Intel Pentium 4

    [7.3.] Module information (from /proc/modules):
    [7.4.] Loaded driver and hardware information (/proc/ioports, /proc/iomem)
    [7.5.] PCI information ('lspci -vvv' as root)
    [7.6.] SCSI information (from /proc/scsi/scsi)
    [7.7.] Other information that might be relevant to the problem
           (please look in /proc and include all information that you
           think to be relevant):
    [X.] Other notes, patches, fixes, workarounds:

    Workaround: in test_readdir1.c, don't seekdir() if the offset is zero.

    Please CC me since I'm not subscribed.

    -- 
    "Everybody you meet will love you as long as you live." said the
    Story Girl.  "There that's the very nicest fortune I can tell you, 
    and it will come true whether the others do or not, and now we
    must go in."
                          --- L.M.Montgomery, "The Golden Road", Ch.30
    
    
    
    

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/





  • Next message: Greg KH: "Re: [PATCH] I2C update for 2.6.10-rc1"

    Relevant Pages

    • [POSSIBLE-BUG] telldir() broken on ext3 dir_indexd directories just after the first entry.
      ... Create a large directory in an ext3 filesystem with dir_index enabled, ... and running getdents() on it sometimes gives d_off==0 for the first ... entry, which seems to be wrong since lseek'ing to that ... This breaks programs that readdirthe first entry, ...
      (Linux-Kernel)
    • Re: Session problem
      ... I am having problems with sessions, first entry fine but next entry I am getting blanks, then next entry I am getting datafields back again, and this alternates. ... The .txt link is still rendering as PHP, can't see the source, bud. ... This causes a warning because if the session var isn't set, you have an undeclared variable you're using later. ...
      (comp.lang.php)
    • Re: Session problem
      ... I am having problems with sessions, first entry fine but next entry I ... The .txt link is still rendering as PHP, can't see the source, bud. ... Same here, if the session is not set, you have no variable, yet you use it ...
      (comp.lang.php)
    • Re: [PATCH] fix for htree corruption. Was: [2.6] Perl weirdness with ext3 and HTREE
      ... Hiya Chris ... > Coping out the index we assume the dirents start with the first entry ... > It can make the first previous deleted entry reappear. ... >> Martin Schlemmer ...
      (Linux-Kernel)
    • Re: corrupted dpkg?
      ... >> into some file and either delete or modify the entry for mozilla but I'm ... > though it may contains what miss from the crash ... (i had actually thought that it WAS ext3 but i was wrong.) ...
      (Debian-User)