• Andrew Morton's avatar
    [PATCH] Fix signed use of i_blocks in ext3 truncate · 9a3e1a96
    Andrew Morton authored
    Patch from "Stephen C. Tweedie" <sct@redhat.com>
    
    Fix "h_buffer_credits<0" assert failure during truncate.
    
    The bug occurs when the "i_blocks" count in the file's inode overflows
    past 2^31.  That works fine most of the time, because i_blocks is an
    unsigned long, and should go up to 2^32; but there's a place in truncate
    where ext3 calculates the size of the next transaction chunk for the
    delete, and that mistakenly uses a signed long instead.  Because the
    huge i_blocks gets cast to a negative value, ext3 does not reserve
    enough credits for the transaction and the above error results.
    
    This is usually only possible on filesystems corrupted for other
    reasons, but it is reproducible if you create a single, non-sparse file
    larger than 1TB on ext3 and then try to delete it.
    9a3e1a96
inode.c 84.2 KB