ffs_alloc panic patch

From: Pavel Merdine (fbsdlist_at_merdin.com)
Date: 08/27/04

  • Next message: Antony Mawer: "Re: ffs_alloc panic patch"
    Date: Fri, 27 Aug 2004 21:52:45 +0400
    To: freebsd-stable@freebsd.org
    
    

    Hello,

    I'd like to propose the following patch:

    ------------------------------------------------------------------
    --- ffs_alloc.c.orig Fri May 14 19:03:50 2004
    +++ ffs_alloc.c Sat Aug 7 03:36:32 2004
    @@ -712,7 +712,7 @@
                    minbfree = 1;
            cgsize = fs->fs_fsize * fs->fs_fpg;
            dirsize = fs->fs_avgfilesize * fs->fs_avgfpdir;
    - curdirsize = avgndir ? (cgsize - avgbfree * fs->fs_bsize) / avgndir : 0;
    + curdirsize = avgndir ? (cgsize - avgbfree * fs->fs_bsize) / avgndir : 512;
            if (dirsize < curdirsize)
                    dirsize = curdirsize;
            maxcontigdirs = min((avgbfree * fs->fs_bsize) / dirsize, 255);
    ------------------------------------------------------------------

    It should solve the problem of "panic: integer divide fault" on the
    last line of the code above. The panic happens on:
    1. directory creation
    2. when disk is empty
    3. when avg_dir_size avg_file_size are set to values, so
      avg_dir_size * avg_file_size is negative in integer.
      example: avg_dir_size = 8000, avf_file_size = 375000.
    (curdirsize == 0 and dirsize < 0, so dirsize = 0)

    I'm sure it's very old bug.

    I know that maybe those params are wrong. And maybe newfs or tunefs
    should check them.
    But I'm sure that there should be some check in the code above to
    eliminate ANY possibility of panic.
    Panic is VERY undesirable situation. And I'm in doubt why those people
    who wrote ffs like panics so devotedly:

    # grep -c "panic" ffs_alloc.c ffs_softdep.c
    ffs_alloc.c:37
    ffs_softdep.c:108

    I think such things are not acceptable in production environment. Why
    those functions cannot just return a failure state and leave system
    working?

    -- 
    / Pavel Merdine
    _______________________________________________
    freebsd-stable@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-stable
    To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"
    

  • Next message: Antony Mawer: "Re: ffs_alloc panic patch"

    Relevant Pages

    • Re: panic: getnewvnode: free vnode isnt
      ... >> Could people seeing this panic try the following patch? ... >> callers of vcleanensure that the vnode is not on the free list, ... > The patch hasn't stopped the panics, but I've tracked down a series of ... I've just started using USB keyboard/mouse and a KVM. ...
      (freebsd-current)
    • [PATCH] Dump partition list on inability to mount /
      ... The attached patch dumps a list of partitions (in a similar ... One of the annoying things about the fail to mount / panics is that you ... can no longer scroll up to find out what errors came from device driver ...
      (Linux-Kernel)
    • Re: panic: System call lstat returning with 1 locks held
      ... >>> I'm committing my WITNESS patch now to perforce so that other people ... >> I use it to get more debug info on my panics? ... I disabled the mounting of the NTFS filesystems. ... Rebuilt/installed kernel and rebooted. ...
      (freebsd-current)
    • Re: usb-serial ipaq kernel problem
      ... |> I know exits in the write URB callback if the URB got an error. ... | The machine is now running with this patch (and my ipaq_open patch, ... just after the control message has succeeded. ... panics as soon as an ipaq reboots. ...
      (Linux-Kernel)
    • Re: panic: System call lstat returning with 1 locks held
      ... I'm committing my WITNESS patch now to perforce so that other people ... I use it to get more debug info on my panics? ... Also mounting/unmounting a NTFS filesystem will cause a panic. ... Rebuilt/installed kernel and rebooted. ...
      (freebsd-current)