tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Possible issue with fsck_ffs ?

On Fri, Feb 07, 2014 at 05:50:53PM +0000, David Holland wrote:
> On Fri, Feb 07, 2014 at 08:39:39AM -0800, Paul Goyette wrote:
>  > I'm sure we have some experts who could figure this out a lot more
>  > quickly than me fumbling through the sources....  :)
>  > 
>  > At my $DAYJOB we have seen instances where newfs(8) can generate a
>  > filesystem with "fragments per cylinder-group" can exceed 0x10000.
>  > When newfs(8) stores the value in the file-system's superblock, it
>  > works correctly since fs_fpg is a 32-bit integer.  However,
>  > newfs(8) also stores the value in the partition table's p_cpg
>  > member, which is only 16-bits.  Values above 0x10000 will,
>  > obviously, get truncated.
>  > 
>  > fsck_ffs(8) works just fine as long as we are able to read the
>  > primary superblock.  But if we're unable to access the primary SB,
>  > we need to use the p_cpg value to find the alternate superblocks,
>  > and because of the truncation noted above the search for alternates
>  > will fail.

IMHO fsck should work without having to find the partition table.

One option is to assume that default parameters were used to create
the filesystem and the use the same algorithm as newfs to find the
alternate - maybe trying a few block/fragment sizes (there aren't
that many).
As a last resort a linear search wouldn't take that long.
Although it would be best to check that some later superblocks match,
and that the whole thing is consistent with the partition size.

I'd sometimes rather that fsck didn't actually do any disk writes
until the end (or interactively after asking a question).

IIRC the number of fragments in a 'cylinder group' is limited because the
allocation bitmap has to reside within a single FS block.
Since blocks are limited to 64kB this limits the is 0x80000 fragments.
(Any FS with blocks > 8k is likely to have > 0x10000 fragments/CG.)
So if you do have the p_cpg value there are only a few locations to try.


David Laight:

Home | Main Index | Thread Index | Old Index