<s>
In	O
computing	O
,	O
file	B-Application
system	I-Application
fragmentation	O
,	O
sometimes	O
called	O
file	B-Application
system	I-Application
aging	O
,	O
is	O
the	O
tendency	O
of	O
a	O
file	B-Application
system	I-Application
to	O
lay	O
out	O
the	O
contents	O
of	O
files	B-Operating_System
non-continuously	O
to	O
allow	O
in-place	O
modification	O
of	O
their	O
contents	O
.	O
</s>
<s>
File	B-Application
system	I-Application
fragmentation	O
negatively	O
impacts	O
seek	O
time	O
in	O
spinning	O
storage	O
media	O
,	O
which	O
is	O
known	O
to	O
hinder	O
throughput	O
.	O
</s>
<s>
Fragmentation	O
can	O
be	O
remedied	O
by	O
re-organizing	O
files	B-Operating_System
and	O
free	O
space	O
back	O
into	O
contiguous	O
areas	O
,	O
a	O
process	O
called	O
defragmentation	B-Application
.	O
</s>
<s>
Solid-state	B-Device
drives	I-Device
do	O
not	O
physically	O
seek	O
,	O
so	O
their	O
non-sequential	O
data	O
access	O
is	O
hundreds	O
of	O
times	O
faster	O
than	O
moving	O
drives	O
 '	O
,	O
making	O
fragmentation	O
a	O
non-issue	O
.	O
</s>
<s>
It	O
is	O
recommended	O
to	O
not	O
defragment	B-Application
solid-state	O
storage	O
,	O
because	O
this	O
can	O
prematurely	O
wear	O
drives	O
via	O
unnecessary	O
write	O
–	O
erase	O
operations	O
.	O
</s>
<s>
When	O
a	B-Application
file	I-Application
system	I-Application
is	I-Application
first	I-Application
initialized	I-Application
on	O
a	O
partition	B-Application
,	O
it	O
contains	O
only	O
a	O
few	O
small	O
internal	O
structures	O
and	O
is	O
otherwise	O
one	O
contiguous	O
block	O
of	O
empty	O
space	O
.	O
</s>
<s>
This	O
means	O
that	O
the	O
file	B-Application
system	I-Application
is	O
able	O
to	O
place	O
newly	O
created	O
files	B-Operating_System
anywhere	O
on	O
the	O
partition	B-Application
.	O
</s>
<s>
For	O
some	O
time	O
after	O
creation	O
,	O
files	B-Operating_System
can	O
be	O
laid	O
out	O
near-optimally	O
.	O
</s>
<s>
When	O
the	O
operating	B-General_Concept
system	I-General_Concept
and	O
applications	O
are	O
installed	O
or	O
archives	O
are	O
unpacked	O
,	O
separate	O
files	B-Operating_System
end	O
up	O
occurring	O
sequentially	O
so	O
related	O
files	B-Operating_System
are	O
positioned	O
close	O
to	O
each	O
other	O
.	O
</s>
<s>
As	O
existing	O
files	B-Operating_System
are	O
deleted	O
or	O
truncated	O
,	O
new	O
regions	O
of	O
free	O
space	O
are	O
created	O
.	O
</s>
<s>
When	O
existing	O
files	B-Operating_System
are	O
appended	O
to	O
,	O
it	O
is	O
often	O
impossible	O
to	O
resume	O
the	O
write	O
exactly	O
where	O
the	O
file	B-Operating_System
used	O
to	O
end	O
,	O
as	O
another	O
file	B-Operating_System
may	O
already	O
be	O
allocated	O
there	O
;	O
thus	O
,	O
a	O
new	O
fragment	O
has	O
to	O
be	O
allocated	O
.	O
</s>
<s>
As	O
time	O
goes	O
on	O
,	O
and	O
the	O
same	O
factors	O
are	O
continuously	O
present	O
,	O
free	O
space	O
as	O
well	O
as	O
frequently	O
appended	O
files	B-Operating_System
tend	O
to	O
fragment	O
more	O
.	O
</s>
<s>
Shorter	O
regions	O
of	O
free	O
space	O
also	O
mean	O
that	O
the	O
file	B-Application
system	I-Application
is	O
no	O
longer	O
able	O
to	O
allocate	O
new	O
files	B-Operating_System
contiguously	O
,	O
and	O
has	O
to	O
break	O
them	O
into	O
fragments	O
.	O
</s>
<s>
This	O
is	O
especially	O
true	O
when	O
the	O
file	B-Application
system	I-Application
becomes	O
full	O
and	O
large	O
contiguous	O
regions	O
of	O
free	O
space	O
are	O
unavailable	O
.	O
</s>
<s>
Consider	O
the	O
following	O
scenario	O
:	O
A	O
new	O
disk	B-Device
has	O
had	O
five	O
files	B-Operating_System
,	O
named	O
A	O
,	O
B	O
,	O
C	O
,	O
D	O
and	O
E	O
,	O
saved	O
continuously	O
and	O
sequentially	O
in	O
that	O
order	O
.	O
</s>
<s>
Each	O
file	B-Operating_System
is	O
using	O
10	O
blocks	O
of	O
space	O
.	O
</s>
<s>
The	O
remainder	O
of	O
the	O
disk	B-Device
space	O
is	O
one	O
free	O
block	O
.	O
</s>
<s>
Thus	O
,	O
additional	O
files	B-Operating_System
can	O
be	O
created	O
and	O
saved	O
after	O
the	O
file	B-Operating_System
E	O
.	O
</s>
<s>
If	O
the	O
file	B-Operating_System
B	O
is	O
deleted	O
,	O
a	O
second	O
region	O
of	O
ten	O
blocks	O
of	O
free	O
space	O
is	O
created	O
,	O
and	O
the	O
disk	B-Device
becomes	O
fragmented	O
.	O
</s>
<s>
The	O
file	B-Application
system	I-Application
could	O
defragment	B-Application
the	O
disk	B-Device
immediately	O
after	O
a	O
deletion	O
,	O
but	O
doing	O
so	O
would	O
incur	O
a	O
severe	O
performance	O
penalty	O
at	O
unpredictable	O
times	O
.	O
</s>
<s>
Now	O
,	O
a	O
new	O
file	B-Operating_System
called	O
F	O
,	O
which	O
requires	O
seven	O
blocks	O
of	O
space	O
,	O
can	O
be	O
placed	O
into	O
the	O
first	O
seven	O
blocks	O
of	O
the	O
newly	O
freed	O
space	O
formerly	O
holding	O
the	O
file	B-Operating_System
B	O
,	O
and	O
the	O
three	O
blocks	O
following	O
it	O
will	O
remain	O
available	O
.	O
</s>
<s>
If	O
another	O
new	O
file	B-Operating_System
called	O
G	O
,	O
which	O
needs	O
only	O
three	O
blocks	O
,	O
is	O
added	O
,	O
it	O
could	O
then	O
occupy	O
the	O
space	O
after	O
F	O
and	O
before	O
C	O
.	O
</s>
<s>
If	O
subsequently	O
F	O
needs	O
to	O
be	O
expanded	O
,	O
since	O
the	O
space	O
immediately	O
following	O
it	O
is	O
occupied	O
,	O
there	O
are	O
three	O
options	O
for	O
the	O
file	B-Application
system	I-Application
:	O
</s>
<s>
The	O
second	O
option	O
is	O
probably	O
impractical	O
for	O
performance	O
reasons	O
,	O
as	O
is	O
the	O
third	O
when	O
the	O
file	B-Operating_System
is	O
very	O
large	O
.	O
</s>
<s>
The	O
third	O
option	O
is	O
impossible	O
when	O
there	O
is	O
no	O
single	O
contiguous	O
free	O
space	O
large	O
enough	O
to	O
hold	O
the	O
new	O
file	B-Operating_System
.	O
</s>
<s>
Thus	O
the	O
usual	O
practice	O
is	O
simply	O
to	O
create	O
an	O
extent	B-Application
somewhere	O
else	O
and	O
chain	O
the	O
new	O
extent	B-Application
onto	O
the	O
old	O
one	O
.	O
</s>
<s>
Material	O
added	O
to	O
the	O
end	O
of	O
file	B-Operating_System
F	O
would	O
be	O
part	O
of	O
the	O
same	O
extent	B-Application
.	O
</s>
<s>
But	O
if	O
there	O
is	O
so	O
much	O
material	O
that	O
no	O
room	O
is	O
available	O
after	O
the	O
last	O
extent	B-Application
,	O
then	O
another	O
extent	B-Application
would	O
have	O
to	O
be	O
created	O
,	O
and	O
so	O
on	O
.	O
</s>
<s>
Eventually	O
the	O
file	B-Application
system	I-Application
has	O
free	O
segments	O
in	O
many	O
places	O
and	O
some	O
files	B-Operating_System
may	O
be	O
spread	O
over	O
many	O
extents	B-Application
.	O
</s>
<s>
Access	O
time	O
for	O
those	O
files	B-Operating_System
(	O
or	O
for	O
all	O
files	B-Operating_System
)	O
may	O
become	O
excessively	O
long	O
.	O
</s>
<s>
Some	O
early	O
file	B-Application
systems	I-Application
were	O
unable	O
to	O
fragment	O
files	B-Operating_System
.	O
</s>
<s>
One	O
such	O
example	O
was	O
the	O
Acorn	B-Application
DFS	I-Application
file	B-Application
system	I-Application
used	O
on	O
the	O
BBC	B-Device
Micro	I-Device
.	O
</s>
<s>
Due	O
to	O
its	O
inability	O
to	O
fragment	O
files	B-Operating_System
,	O
the	O
error	O
message	O
ca	B-Device
n't	I-Device
extend	I-Device
would	O
at	O
times	O
appear	O
,	O
and	O
the	O
user	O
would	O
often	O
be	O
unable	O
to	O
save	O
a	O
file	B-Operating_System
even	O
if	O
the	O
disk	B-Device
had	O
adequate	O
space	O
for	O
it	O
.	O
</s>
<s>
DFS	B-Application
used	O
a	O
very	O
simple	O
disk	B-Device
structure	I-Device
and	O
files	B-Operating_System
on	O
disk	B-Device
were	O
located	O
only	O
by	O
their	O
length	O
and	O
starting	O
sector	O
.	O
</s>
<s>
This	O
meant	O
that	O
all	O
files	B-Operating_System
had	O
to	O
exist	O
as	O
a	O
continuous	O
block	O
of	O
sectors	O
and	O
fragmentation	O
was	O
not	O
possible	O
.	O
</s>
<s>
Using	O
the	O
example	O
in	O
the	O
table	O
above	O
,	O
the	O
attempt	O
to	O
expand	O
file	B-Operating_System
F	O
in	O
step	O
five	O
would	O
have	O
failed	O
on	O
such	O
a	O
system	O
with	O
the	O
ca	B-Device
n't	I-Device
extend	I-Device
error	O
message	O
.	O
</s>
<s>
Regardless	O
of	O
how	O
much	O
free	O
space	O
might	O
remain	O
on	O
the	O
disk	B-Device
in	O
total	O
,	O
it	O
was	O
not	O
available	O
to	O
extend	O
the	O
data	O
file	B-Operating_System
.	O
</s>
<s>
Standards	O
of	O
error	B-General_Concept
handling	I-General_Concept
at	O
the	O
time	O
were	O
primitive	O
and	O
in	O
any	O
case	O
programs	O
squeezed	O
into	O
the	O
limited	O
memory	O
of	O
the	O
BBC	B-Device
Micro	I-Device
could	O
rarely	O
afford	O
to	O
waste	O
space	O
attempting	O
to	O
handle	O
errors	O
gracefully	O
.	O
</s>
<s>
Instead	O
,	O
the	O
user	O
would	O
find	O
themselves	O
dumped	O
back	O
at	O
the	O
command	O
prompt	O
with	O
the	O
Ca	B-Device
n't	I-Device
extend	I-Device
message	O
and	O
all	O
the	O
data	O
which	O
had	O
yet	O
to	O
be	O
appended	O
to	O
the	O
file	B-Operating_System
would	O
be	O
lost	O
.	O
</s>
<s>
The	O
problem	O
could	O
not	O
be	O
solved	O
by	O
simply	O
checking	O
the	O
free	O
space	O
on	O
the	O
disk	B-Device
beforehand	O
,	O
either	O
.	O
</s>
<s>
While	O
free	O
space	O
on	O
the	O
disk	B-Device
may	O
exist	O
,	O
the	O
size	O
of	O
the	O
largest	O
contiguous	O
block	O
of	O
free	O
space	O
was	O
not	O
immediately	O
apparent	O
without	O
analyzing	O
the	O
numbers	O
presented	O
by	O
the	O
disk	B-Device
catalog	O
and	O
so	O
would	O
escape	O
the	O
user	O
's	O
notice	O
.	O
</s>
<s>
In	O
addition	O
,	O
almost	O
all	O
DFS	B-Application
users	O
had	O
previously	O
used	O
cassette	O
file	B-Application
storage	I-Application
,	O
which	O
does	O
not	O
suffer	O
from	O
this	O
error	O
.	O
</s>
<s>
The	O
upgrade	O
to	O
a	O
floppy	B-Device
disk	I-Device
system	O
was	O
an	O
expensive	O
upgrade	O
,	O
and	O
it	O
was	O
a	O
shock	O
that	O
the	O
upgrade	O
might	O
without	O
warning	O
cause	O
data	B-General_Concept
loss	I-General_Concept
.	O
</s>
<s>
File	B-Application
system	I-Application
fragmentation	O
may	O
occur	O
on	O
several	O
levels	O
:	O
</s>
<s>
Individual	O
file	B-Operating_System
fragmentation	O
occurs	O
when	O
a	O
single	O
file	B-Operating_System
has	O
been	O
broken	O
into	O
multiple	O
pieces	O
(	O
called	O
extents	B-Application
on	O
extent-based	O
file	B-Application
systems	I-Application
)	O
.	O
</s>
<s>
While	O
disk	B-Application
file	I-Application
systems	I-Application
attempt	O
to	O
keep	O
individual	O
files	B-Operating_System
contiguous	O
,	O
this	O
is	O
not	O
often	O
possible	O
without	O
significant	O
performance	O
penalties	O
.	O
</s>
<s>
File	B-Application
system	I-Application
check	O
and	O
defragmentation	B-Application
tools	O
typically	O
only	O
account	O
for	O
file	B-Operating_System
fragmentation	O
in	O
their	O
"	O
fragmentation	O
percentage	O
"	O
statistic	O
.	O
</s>
<s>
Free	O
(	O
unallocated	O
)	O
space	O
fragmentation	O
occurs	O
when	O
there	O
are	O
several	O
unused	O
areas	O
of	O
the	O
file	B-Application
system	I-Application
where	O
new	O
files	B-Operating_System
or	O
metadata	O
can	O
be	O
written	O
to	O
.	O
</s>
<s>
Unwanted	O
free	O
space	O
fragmentation	O
is	O
generally	O
caused	O
by	O
deletion	O
or	O
truncation	O
of	O
files	B-Operating_System
,	O
but	O
file	B-Application
systems	I-Application
may	O
also	O
intentionally	O
insert	O
fragments	O
(	O
"	O
bubbles	O
"	O
)	O
of	O
free	O
space	O
in	O
order	O
to	O
facilitate	O
extending	O
nearby	O
files	B-Operating_System
(	O
see	O
preventing	O
fragmentation	O
below	O
)	O
.	O
</s>
<s>
File	B-Operating_System
segmentation	O
,	O
also	O
called	O
related-file	O
fragmentation	O
,	O
or	O
application-level	O
(	O
file	B-Operating_System
)	O
fragmentation	O
,	O
refers	O
to	O
the	O
lack	O
of	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
(	O
within	O
the	O
storing	O
medium	O
)	O
between	O
related	O
files	B-Operating_System
(	O
see	O
file	B-General_Concept
sequence	I-General_Concept
for	O
more	O
detail	O
)	O
.	O
</s>
<s>
Unlike	O
the	O
previous	O
two	O
types	O
of	O
fragmentation	O
,	O
file	B-Operating_System
scattering	O
is	O
a	O
much	O
more	O
vague	O
concept	O
,	O
as	O
it	O
heavily	O
depends	O
on	O
the	O
access	O
pattern	O
of	O
specific	O
applications	O
.	O
</s>
<s>
However	O
,	O
arguably	O
,	O
it	O
is	O
the	O
most	O
critical	O
type	O
of	O
fragmentation	O
,	O
as	O
studies	O
have	O
found	O
that	O
the	O
most	O
frequently	O
accessed	O
files	B-Operating_System
tend	O
to	O
be	O
small	O
compared	O
to	O
available	O
disk	B-Device
throughput	O
per	O
second	O
.	O
</s>
<s>
To	O
avoid	O
related	O
file	B-Operating_System
fragmentation	O
and	O
improve	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
(	O
in	O
this	O
case	O
called	O
file	B-Operating_System
contiguity	O
)	O
,	O
assumptions	O
or	O
active	O
observations	O
about	O
the	O
operation	O
of	O
applications	O
have	O
to	O
be	O
made	O
.	O
</s>
<s>
A	O
very	O
frequent	O
assumption	O
made	O
is	O
that	O
it	O
is	O
worthwhile	O
to	O
keep	O
smaller	O
files	B-Operating_System
within	O
a	O
single	O
directory	B-Application
together	O
,	O
and	O
lay	O
them	O
out	O
in	O
the	O
natural	O
file	B-Application
system	I-Application
order	O
.	O
</s>
<s>
For	O
example	O
,	O
an	O
application	B-Application
might	O
read	O
several	O
different	O
files	B-Operating_System
,	O
perhaps	O
in	O
different	O
directories	B-Application
,	O
in	O
exactly	O
the	O
same	O
order	O
they	O
were	O
written	O
.	O
</s>
<s>
Thus	O
,	O
a	O
file	B-Application
system	I-Application
that	O
simply	O
orders	O
all	O
writes	O
successively	O
,	O
might	O
work	O
faster	O
for	O
the	O
given	O
application	B-Application
.	O
</s>
<s>
The	O
catalogs	O
or	O
indices	O
used	O
by	O
a	O
file	B-Application
system	I-Application
itself	O
can	O
also	O
become	O
fragmented	O
over	O
time	O
,	O
as	O
the	O
entries	O
they	O
contain	O
are	O
created	O
,	O
changed	O
,	O
or	O
deleted	O
.	O
</s>
<s>
This	O
is	O
more	O
of	O
a	O
concern	O
when	O
the	O
volume	O
contains	O
a	O
multitude	O
of	O
very	O
small	O
files	B-Operating_System
than	O
when	O
a	O
volume	O
is	O
filled	O
with	O
fewer	O
larger	O
files	B-Operating_System
.	O
</s>
<s>
Depending	O
on	O
the	O
particular	O
file	B-Application
system	I-Application
design	O
,	O
the	O
files	B-Operating_System
or	O
regions	O
containing	O
that	O
data	O
may	O
also	O
become	O
fragmented	O
(	O
as	O
described	O
above	O
for	O
'	O
regular	O
 '	O
files	B-Operating_System
)	O
,	O
regardless	O
of	O
any	O
fragmentation	O
of	O
the	O
actual	O
data	O
records	O
maintained	O
within	O
those	O
files	B-Operating_System
or	O
regions	O
.	O
</s>
<s>
For	O
some	O
file	B-Application
systems	I-Application
(	O
such	O
as	O
NTFS	B-Application
and	O
HFS/HFS	O
Plus	O
)	O
,	O
the	O
collation/sorting/compaction	O
needed	O
to	O
optimize	O
this	O
data	O
cannot	O
easily	O
occur	O
while	O
the	O
file	B-Application
system	I-Application
is	O
in	O
use	O
.	O
</s>
<s>
File	B-Application
system	I-Application
fragmentation	O
is	O
more	O
problematic	O
with	O
consumer-grade	O
hard	B-Device
disk	I-Device
drives	I-Device
because	O
of	O
the	O
increasing	O
disparity	O
between	O
sequential	B-General_Concept
access	I-General_Concept
speed	O
and	O
rotational	O
latency	O
(	O
and	O
to	O
a	O
lesser	O
extent	B-Application
seek	O
time	O
)	O
on	O
which	O
file	B-Application
systems	I-Application
are	O
usually	O
placed	O
.	O
</s>
<s>
Thus	O
,	O
fragmentation	O
is	O
an	O
important	O
problem	O
in	O
file	B-Application
system	I-Application
research	O
and	O
design	O
.	O
</s>
<s>
The	O
containment	O
of	O
fragmentation	O
not	O
only	O
depends	O
on	O
the	O
on-disk	O
format	O
of	O
the	O
file	B-Application
system	I-Application
,	O
but	O
also	O
heavily	O
on	O
its	O
implementation	O
.	O
</s>
<s>
File	B-Application
system	I-Application
fragmentation	O
has	O
less	O
performance	O
impact	O
upon	O
solid-state	B-Device
drives	I-Device
,	O
as	O
there	O
is	O
no	O
mechanical	O
seek	O
time	O
involved	O
.	O
</s>
<s>
However	O
,	O
the	O
file	B-Application
system	I-Application
needs	O
to	O
store	O
additional	O
metadata	O
for	O
each	O
non-contiguous	O
part	O
of	O
the	O
file	B-Operating_System
.	O
</s>
<s>
In	O
simple	O
file	B-Application
system	I-Application
benchmarks	O
,	O
the	O
fragmentation	O
factor	O
is	O
often	O
omitted	O
,	O
as	O
realistic	O
aging	O
and	O
fragmentation	O
is	O
difficult	O
to	O
model	O
.	O
</s>
<s>
Rather	O
,	O
for	O
simplicity	O
of	O
comparison	O
,	O
file	B-Application
system	I-Application
benchmarks	O
are	O
often	O
run	O
on	O
empty	O
file	B-Application
systems	I-Application
.	O
</s>
<s>
Due	O
to	O
the	O
difficulty	O
of	O
predicting	O
access	O
patterns	O
these	O
techniques	O
are	O
most	O
often	O
heuristic	B-Algorithm
in	O
nature	O
and	O
may	O
degrade	O
performance	O
under	O
unexpected	O
workloads	O
.	O
</s>
<s>
Preemptive	O
techniques	O
attempt	O
to	O
keep	O
fragmentation	O
to	O
a	O
minimum	O
at	O
the	O
time	O
data	O
is	O
being	O
written	O
on	O
the	O
disk	B-Device
.	O
</s>
<s>
Many	O
of	O
today	O
's	O
file	B-Application
systems	I-Application
attempt	O
to	O
pre-allocate	O
longer	O
chunks	O
,	O
or	O
chunks	O
from	O
different	O
free	O
space	O
fragments	O
,	O
called	O
extents	B-Application
to	O
files	B-Operating_System
that	O
are	O
actively	O
appended	O
to	O
.	O
</s>
<s>
This	O
largely	O
avoids	O
file	B-Operating_System
fragmentation	O
when	O
several	O
files	B-Operating_System
are	O
concurrently	O
being	O
appended	O
to	O
,	O
thus	O
avoiding	O
their	O
becoming	O
excessively	O
intertwined	O
.	O
</s>
<s>
If	O
the	O
final	O
size	O
of	O
a	O
file	B-Operating_System
subject	O
to	O
modification	O
is	O
known	O
,	O
storage	O
for	O
the	O
entire	O
file	B-Operating_System
may	O
be	O
preallocated	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
Microsoft	B-Application
Windows	I-Application
swap	O
file	B-Operating_System
(	O
page	O
file	B-Operating_System
)	O
can	O
be	O
resized	O
dynamically	O
under	O
normal	O
operation	O
,	O
and	O
therefore	O
can	O
become	O
highly	O
fragmented	O
.	O
</s>
<s>
This	O
can	O
be	O
prevented	O
by	O
specifying	O
a	O
page	O
file	B-Operating_System
with	O
the	O
same	O
minimum	O
and	O
maximum	O
sizes	O
,	O
effectively	O
preallocating	O
the	O
entire	O
file	B-Operating_System
.	O
</s>
<s>
BitTorrent	B-Protocol
and	O
other	O
peer-to-peer	O
filesharing	O
applications	O
limit	O
fragmentation	O
by	O
preallocating	O
the	O
full	O
space	O
needed	O
for	O
a	O
file	B-Operating_System
when	O
initiating	O
downloads	B-Application
.	O
</s>
<s>
A	O
relatively	O
recent	O
technique	O
is	O
delayed	B-Application
allocation	I-Application
in	O
XFS	B-Application
,	O
HFS+	B-Application
and	O
ZFS	B-Application
;	O
the	O
same	O
technique	O
is	O
also	O
called	O
allocate-on-flush	B-Application
in	O
reiser4	B-Application
and	O
ext4	B-Application
.	O
</s>
<s>
When	O
the	O
file	B-Application
system	I-Application
is	O
being	O
written	O
to	O
,	O
file	B-Application
system	I-Application
blocks	O
are	O
reserved	O
,	O
but	O
the	O
locations	O
of	O
specific	O
files	B-Operating_System
are	O
not	O
laid	O
down	O
yet	O
.	O
</s>
<s>
Later	O
,	O
when	O
the	O
file	B-Application
system	I-Application
is	O
forced	O
to	O
flush	O
changes	O
as	O
a	O
result	O
of	O
memory	O
pressure	O
or	O
a	O
transaction	O
commit	O
,	O
the	O
allocator	O
will	O
have	O
much	O
better	O
knowledge	O
of	O
the	O
files	B-Operating_System
 '	O
characteristics	O
.	O
</s>
<s>
Most	O
file	B-Application
systems	I-Application
with	O
this	O
approach	O
try	O
to	O
flush	O
files	B-Operating_System
in	O
a	O
single	O
directory	B-Application
contiguously	O
.	O
</s>
<s>
Assuming	O
that	O
multiple	O
reads	O
from	O
a	O
single	O
directory	B-Application
are	O
common	O
,	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
is	O
improved	O
.	O
</s>
<s>
Reiser4	B-Application
also	O
orders	O
the	O
layout	O
of	O
files	B-Operating_System
according	O
to	O
the	O
directory	B-Application
hash	B-Algorithm
table	I-Algorithm
,	O
so	O
that	O
when	O
files	B-Operating_System
are	O
being	O
accessed	O
in	O
the	O
natural	O
file	B-Application
system	I-Application
order	O
(	O
as	O
dictated	O
by	O
readdir	O
)	O
,	O
they	O
are	O
always	O
read	O
sequentially	O
.	O
</s>
<s>
Many	O
file	B-Application
systems	I-Application
provide	O
defragmentation	B-Application
tools	O
,	O
which	O
attempt	O
to	O
reorder	O
fragments	O
of	O
files	B-Operating_System
,	O
and	O
sometimes	O
also	O
decrease	O
their	O
scattering	O
(	O
i.e.	O
</s>
<s>
improve	O
their	O
contiguity	O
,	O
or	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
)	O
by	O
keeping	O
either	O
smaller	O
files	B-Operating_System
in	O
directories	B-Application
,	O
or	O
directory	B-Application
trees	I-Application
,	O
or	O
even	O
file	B-General_Concept
sequences	I-General_Concept
close	O
to	O
each	O
other	O
on	O
the	O
disk	B-Device
.	O
</s>
<s>
The	O
HFS	B-Application
Plus	I-Application
file	B-Application
system	I-Application
transparently	O
defragments	B-Application
files	B-Operating_System
that	O
are	O
less	O
than	O
20	O
MiB	O
in	O
size	O
and	O
are	O
broken	O
into	O
8	O
or	O
more	O
fragments	O
,	O
when	O
the	O
file	B-Operating_System
is	O
being	O
opened	O
.	O
</s>
<s>
The	O
now	O
obsolete	O
Commodore	O
Amiga	O
Smart	B-Application
File	I-Application
System	I-Application
(	O
SFS	O
)	O
defragmented	O
itself	O
while	O
the	O
filesystem	B-Application
was	O
in	O
use	O
.	O
</s>
<s>
The	O
defragmentation	B-Application
process	O
is	O
almost	O
completely	O
stateless	O
(	O
apart	O
from	O
the	O
location	O
it	O
is	O
working	O
on	O
)	O
,	O
so	O
that	O
it	O
can	O
be	O
stopped	O
and	O
started	O
instantly	O
.	O
</s>
<s>
During	O
defragmentation	B-Application
data	O
integrity	O
is	O
ensured	O
for	O
both	O
metadata	O
and	O
normal	O
data	O
.	O
</s>
