Skip to content

Commit bd1fb29

Browse files
author
Vladimir Kotal
committed
translate more ways for filesystem consistency check and repair slide
1 parent 64801ca commit bd1fb29

File tree

1 file changed

+68
-66
lines changed

1 file changed

+68
-66
lines changed

files.tex

Lines changed: 68 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -555,89 +555,91 @@
555555

556556
%%%%%
557557

558-
\pdfbookmark[1]{more ways to for ensuring filesystem consistency}{fsconsistency}
558+
\pdfbookmark[1]{more ways for ensuring filesystem consistency}{fsconsistency}
559559

560560
\begin{slide}
561-
\sltitle{Další způsoby zajištění konzistence filesystému}
561+
\sltitle{More ways for ensuring filesystem consistency}
562562
\setlength{\baselineskip}{0.8\baselineskip}
563563
\begin{itemize}
564564
\setlength{\itemsep}{0ex}
565-
\item tradiční UFS -- synchronní zápis metadat
565+
\item traditional UFS -- synchronous metadata writes
566566
\begin{itemize}
567567
\setlength{\itemsep}{0ex}
568-
\item aplikace vytvářející nový soubor čeká na inicializaci inode na
569-
disku; tyto operace pracují rychlostí disku a ne rychlostí CPU
570-
\item asynchronní zápis ale častěji způsobí nekontistenci metadat
568+
\item an application creating new file is waiting till the inode is
569+
initialized on disk; these operations are done with disk speed, not CPU
570+
speed
571+
\item however asynchronous writes more often cause metadata inconsistencies
571572
\end{itemize}
572-
\item řešení problémů s nekonzistencí metadat na disku:
573+
\item solutions to metadata inconsistency problem:
573574
\begin{itemize}
574575
\setlength{\itemsep}{0ex}
575-
\item \emph{journalling} -- skupina na sobě závislých operací se
576-
nejdříve atomicky uloží do žurnálu; při problémech se pak žurnál
577-
může ``přehrát''
578-
\item bloky metadat se nejdříve zapíší do non-volatile paměti
579-
\item \emph{soft-updates} -- sleduje závislosti mezi ukazately
580-
na diskové struktury a zapisuje data na disk metodou
581-
\emph{write-back} tak, že data na disku jsou vždy konzistentní
582-
\item \emph{ZFS} je nový filesystém v Solarisu, který používá
583-
\emph{copy-on-write} transakční model
576+
\item \emph{journalling} -- one group of operations dependent on each other
577+
is written to a journal first; if a problem is encountered the journal can
578+
be ``replayed''
579+
\item metadata blocks are written to non-volatile memory first
580+
\item \emph{soft-updates} -- follows dependencies between pointers to disk
581+
structures and writes the data using the \emph{write-back} method so that
582+
the data are always consistent on disk.
583+
\item \emph{transactions}
584584
\end{itemize}
585585
\end{itemize}
586586
\end{slide}
587587

588588
\begin{itemize}
589589
\item filesystem \emph{metadata} = inodes, directories, free block
590590
maps
591-
\item \emph{ext2} dokonce defaultně používá asynchronní zápis metadat a je při
592-
použítí synchronního zápisu výrazně pomalejší než UFS
593-
\item závislé operace jsou například smazání položky z adresáře a smazání
594-
diskového inode. Pokud by se stalo, že se nejdříve smaže diskový inode a pak
595-
teprve položka v adresáři, při výpadku mezi těmito dvěmi operacemi vniká
596-
nekonzistence -- link ukazuje na diskový soubor, který neexistuje. Není
597-
problém se tomuto vyhnout při synchronním zápisu metadat (víme kdy a co
598-
zapisujeme, určujeme tedy pořadí zápisu), ale při metodě write-back je již
599-
nutné řešit závislosti jednotlivých bloků na sebe, protože při klasické
600-
synchronizaci vyrovnávacích pamětí na disk jádro nezajímá, který blok se
601-
zapíše dřív a který později.
602-
\item často jsou bloky na sobě závislé ve smyčce. Soft updates dokáže takovou
603-
smyčku rozbít tím, že provede \emph{roll-back} a po zápisu pak
604-
\emph{roll-forward}
605-
\item výkon soft updates je srovnatelný výkonu UFS filesystému s asynchronním
606-
zápisem metadat
607-
\item teoreticky soft updates zaručují, že po rebootu není potřeba použít
608-
\texttt{fsck}, tj. že filesystém bude v takovém stavu, že je možné nabootovat.
609-
Je však nutné použít tzv. \emph{background fsck} pro opravy nezávažných chyb
610-
-- to je považováno stále za velkou nevýhodu soft updates zvláště s tím, jak
611-
rostou velikosti běžně používaných disků. Takovou chybou, která nebrání
612-
nabootování, ale je nutné ji odstranit je například blok, který je označen
613-
jako použitý, ale žádný soubor ho nepoužívá.
614-
\item soft updates nejsou vždy doporučovány pro root filesystém. Problém je
615-
to, že ztráta metadat na root filesystému (viz 30-ti sekundová perioda zápisu)
616-
může být výrazně větší hrozbou zde než na \texttt{/usr}, \texttt{/home} atd.
617-
Další nevýhodou může být i to, že u soft updates mi smazání velkého souboru
618-
hned neuvolní místo.
619-
\item příklad: na bezpečnou operaci rename potřebuju při synchronním zápisu
620-
metadat 4 zápisy -- zvýšení počtu odkazů v inode, vytvoření nové
621-
a\-dre\-\-řo\-vé položky, smazání staré, a opětné snížení počtu odkazů v
622-
inode. Kdykoli by systém spadnul, nenastane nebezpečná situace. Například 2
623-
odkazy z adresářů na inode s referenčním počtem 1 je problém, protože po zrušení
624-
jednoho odkazu to bude vypadat, že soubor je stále na disku, když už byla jeho
625-
data dávno smazána. Není težké si asi představit, co by to mohlo znamenat v
626-
případě, že soubor obsahoval opravdu důležitá data -- například zálohu. Opačná
627-
situace, tj. jeden odkaz na inode s referencí 2 sice také není správná situace,
628-
ale neohrožuje to možnost filesystém namontovat a normálně používat. V nejhorším
629-
se stane, že soubor vypadá že již na disku není a přitom stále existuje. U soft
630-
updates operace rename vytvoří kružnici, protože nejdříve je potřeba zapsat
631-
zvýšení počtu referencí, pak adresářové bloky a poté snížení referencí. A
632-
protože zvýšení/snížení se týká stejného inode, tak je při zápisu třeba udělat
633-
roll-back na (řekněme) 2, zapsat inode na disk, zapsat bloky adresárů a pak
634-
roll-forward na počet referencí 1. Při této akci je nad inodem držen zámek,
635-
takže nikdo nenačte starší data. Je jednoduché ukázat, že nelze zapsat žádný z
636-
těch tří bloků v kružnici tak, jak to je na konci operace rename, že je opravdu
637-
nutný ten roll-back -- mohli bychom uvažovat, že inode se vlastně nezměnil a
638-
není třeba řešit zda se může/nemůže zapsat; zápis nového adresářového odkazu bez
639-
zvýšení počtu odkazů v inodu by nás totiž mohl dostat přesně do situace, která
640-
je popsána o pár řádků výše.
591+
\item \emph{ext2} uses asynchronous metadata writes even by default and when
592+
in synchronous mode it is much slower to UFS.
593+
\item Dependent operations are for example deleting an item from directory and
594+
deleting disk inode. If the inode is deleted first and then the directory entry
595+
then if there is outage between these two operations then inonsistency follows
596+
-- the link points to disk file that does not exist. It is not a problem to
597+
avoid this when using synchronous metadata writes (we know when a what is being
598+
written, the ordering of writes is therefore under our control) however when
599+
using the write-back method it is necessary to solve dependencies of the blocks
600+
because with classic synchronization of cache buffers the kernel is not
601+
interested in which blocks is written first.
602+
\item Often the block dependencies for a cycle. Soft updates can recognize sych
603+
cycle and break it by performing \emph{roll-back} and after the write is done it
604+
performs \emph{roll-forward}.
605+
\item The soft updates performance is comparable to that of UFS with
606+
asynchronous metadata writes.
607+
\item Theoreticall soft updates guratantee that it is not necessary to use
608+
\texttt{fsck} after the reboot, i.e. that the filesystem is in bootable state.
609+
It is however necessary to use so called \emph{background fsck} for correcting
610+
non-grave errors -- this is considered to be one of the big drawbacks of soft
611+
updates, especially given how sizes of disks grow over time. Example of an error
612+
that does not block booting would be a block that is marked as used however is
613+
not used by any file.
614+
\item soft updates are not always recommended for the root filesystem.
615+
The problem is that metadata loss on root file system (see the 30 second
616+
period of writes) can be more dangerous than in \texttt{/usr}, \texttt{/home}
617+
etc. Another disadvantage is that after deleting huge file soft updates do not
618+
free up the space immediately.
619+
\item Example: it is necessary 4 writes for secure rename operations when using
620+
synchronous writes -- increase the number of references in inode, create new
621+
directory entry, delete old entry, decrease the number of references.
622+
If a system goes down between each of these a dangerous situation will ensue.
623+
For example 2 references from directories to inode with reference count of 1 is
624+
a problem because after deleting one of the references it would look like the
625+
file is still on disk, when its data has been deleted already.
626+
It is not hard to imagine what would it mean if the file contained important
627+
data -- e.g. backup.
628+
Opposite situation, i.e. one reference to inode with reference count equal 2 is
629+
not correction situation either however it does not pose a threat to mount the
630+
filesystem and normally use it. In the worst case the file looks as it is no
631+
longer on disk while it still exists. For soft updates the rename operation will
632+
form a cycle because it is necessary to write the increased reference count
633+
first, then directory blocks and then decreased reference. And because
634+
increase/decrease is done for the same inode, then for the write it is necessary
635+
to do roll-back to (say) 2, write inode to disk, write directory blocks and then
636+
roll-forward to reference of 1. During this operation a lock is held for the
637+
inode so that no one will read older data. It is simple to show that it is not
638+
possible to write any of these 3 blocks in a cycle to match the end of the
639+
rename operation so that the roll-back is truly needed -- we could consider that
640+
the inode did not really change and it is not necessary to decide whether to
641+
write it or not; the write of directory reference without increasing reference
642+
count in the inode could get us into situation which is descibed above.
641643
\end{itemize}
642644

643645
\endinput

0 commit comments

Comments
 (0)