On Sun, 11 Apr 2004, Szakacsits Szabolcs wrote:
> On Fri, 9 Apr 2004, Anton Altaparmakov wrote:
> > True. Although the LFS drivers are quite happy to recognise any LFS
> > version including strange ones likes 0.-1...
>
> Hmmm, this also suggests the value isn't really used and LFS is tightened
> with the current driver (not even NTFS version).
Yes it is rather, especially since in both 2k and XP they are in the same
file ntfs.sys! The only thing the version matters for is during OS
upgrades or when you move a disk from one windows to another so the driver
knows how to deal with the logfile.
Something unrelated I noticed: In XP efs.sys no longer exists either and
it is part of ntfs.sys, too.
> > > True from pedantry point of view but I doubt even Microsoft cares. Show me
> > > an example when LFS is used outside of NTFS.
> >
> > I don't know any. I don't think anything other than NTFS uses LFS.
>
> My suspicion is that that LFS was overdesigned, then it was realised it
> doesn't work so great as it was expected (see tons of inconsistent NTFS)
> so its use got limited and this "volume clean" bit was added (if it indeed
> means that).
Quite possible.
> If the volume is marked clean, no need to try to recover thus there is
> less chance to screw up the filesystem.
>
> > I have to apologise at this point: I must have somehow managed to muddle
> > my logfile copies. I took a new copy just now and it is just like you say
> > and nothing like my old copy. So I must have been working with w2k rather
> > than xp logfile all along. )-:
>
> Yes, I also can not see this bit set on any w2k NTFS images I have.
>
> > I can confirm the same as you see.
>
> Great news! :)
>
> > This makes everything even more difficult.
>
> Yes and no.
>
> Special case handling, yes.
>
> But for now, we could ignore the minority unknown cases (Google Zeitgeist:
> XP 46%, W2K 18%, NT4 3%). Anyway, the time already working hard to solve
> the W2K and earlier cases :-)
>
> The project is huge and we are badly lacking development resources. We can
> not solve everybody's problem at once. If we ever want to get anywhere, we
> must cut corner cases.
>
> > We will need to parse the NTFS version and then deal with the logfile
> > depending on what we see there. So on NTFS 3.1 with LFS 1.1, we will
> > compare the restart pages (_not_ binary compare but logical compare)
>
> Plus we must extend the logical compare inasmuch as you noticed NTFS 3.1
> has more fields.
>
> > and if identical and flags = 2 we can say clean and dirty otherwise.
>
> Well, I hope so it's true :-)
>
> But I'd still prefer if somebody would check what's going on in the
> restart pages during NTFS use from Windows. Unfortunately Captive NTFS
> isn't ok because it doesn't journal continuously, that's one of the
> reasons people lose things when Captive crashes:
>
> http://www.jankratochvil.net/project/captive/doc/Details.html.pl#logfile
>
> I don't have the needed softwares to do this and disassembling would take
> too long compared to just sniffing.
Not true at all. Sniffing is inaccurate, non-exhaustive and can be
misleading and is not faster than disassembly with the right tools and
skills... (-; I ran the XPSP1 ntfs.sys through my somewhat out of date
IDA Pro 4.5.0.762 (http://www.datarescue.com/idabase/) and here is the
info:
btw. If anyone reading this wants to donate me an upgrade to the latest
4.6SP1 this would be greatly appreaciated!
The restart area flag bit 2 can indeed be taken to mean "clean umount of
ntfs volume". It was not necessarily intended to mean this by MS but it
in effect means just that for all intents and purposes. The flag is
affected in three places:
When a volume is mounted the code path is as follows:
NtfsMountVolume() -> NtfsStartLogFile() -> LfsOpenLogFile() ->
LfsRestartLogFile() -> LfsUpdateLfcbFromRestart()
1) LfsUpdateLfcbFromRestart() tests the flag bit 2 and if it is set, it
takes the $LogFile size passed in from the caller and uses this to set the
logfile size in the Lfcb. If the flag bit 2 is zero, it checks the
logfile size specified in the restart area against the one passed in from
the caller and uses the smaller one. I interpret this as that it means it
assumes that if the flag bit 2 is set, the logfile is consistent and there
is no need to check the file size specified in the restart area, it can be
assumed to be accurate. LfsUpdateLfcbFromRestart() later returns to the
caller.
2) Immediately after this happens, LfsRestartLogFile() sets the flag bit 2
to zero unconditionally and before it returns to the caller it writes out
the restart areas to disk, thus we now have the bit set to zero.
Note at this point no log replay or anything like this has happened at
all. This is the very first thing that happens so it cannot be that we
will see bit 2 set with something having been written to the volume that
would change the "clean shutdown" state.
When a volume is umounted the code path is as follows:
NtfsDismountVolume() -> NtfsPerformDismountOnVcb() -> NtfsStopLogFile() ->
LfsCloseLogFile() -> LfsWriteLfsRestart()
3) LfsCloseLogFile() sets bit 2 just before writing out the restart areas
to disk. Note this it the very last i/o on the logfile and i/o
completion is waited for (LfsWriteLfsRestart() is called with the
WaitForIo flag set to true), thus we know we have the bit 2 set on disk at
this point. Immediately after this happens, the Lfcb is deallocated and
all associated log file in memory structures are thrown away and
LfsCloseLogFile() returns to the caller.
I think the significance of flag bit 2 is pretty clear now. Now we just
need to give the flag a name. (-: Perhaps RESTART_VOLUME_IS_CLEAN?
> > And on NTFS 1.x, 2.x, and 3.0 with LFS 1.1 we need to check the
> > restart pages and if identical and the criteria I describe in
> > ntfs/logfile.h are met (i.e. the logfile is shut, no clients are
> > registered in use) it is clean
>
> If it's true, sounds ok.
>
> I can't investigate these at all either, I have only such metadata images
> and I know nothing about in what state they were imaged.
>
> But they must be clean because ntfsresize's consistency check passes
> otherwise all dirty cases I've ever seen failed the check.
>
> Well, actually ntfsclone won't clone if the consistency check doesn't
> pass. I'll enable cloning inconsistent NTFS for --metadata, when it's
> possible.
>
> > and assumed dirty otherwise (although it could still be clean in that
> > case but that is too complicated for us to figure out at this point as
> > it involves parsing the whole logfile and checking that all ops are
> > checkpointed). Anyway, it is better to be erring on the safe side
> > IMO.
>
> I agree.
>
> > We can always provide a force option for ignoring the fact that
> > we think the journal is dirty. Without the force we just work
> > read-only.
>
> I even don't like the "force" option in these cases:
>
> - most people aren't really aware of the consequences. They hope it will
> work but it won't. I'm not sure we want to debug these cases and
> hear about the crappy NTFS driver that corrupts data (you can read
> it anywhere anyway even if it isn't possible for years).
>
> - if the option is there it will be used. Some distributor will just
> configure it by default and people use it without knowing about it.
>
> Solution is very easy. No such option, no such problems. If one doesn't
> like it, he can modify the available, free source code and shot himself in
> the foot. Such fun definitely deserves some extra work ;)
Not sure I agree, e.g. we should at least have a "force_but_then_readonly"
option because we may be overzealous with our checks and we may be
flagging perfectly clean ntfs as dirty and user might want to mount the
volume anyway. Also perhaps the user wants to recover data from a damaged
volume. In that case cannot expect a clean fs.
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
|