J.Tiberghien Chapitre 9 Organisation des disques et gestion des fichiers.
-
Upload
johnny-brasseur -
Category
Documents
-
view
218 -
download
1
Transcript of J.Tiberghien Chapitre 9 Organisation des disques et gestion des fichiers.
J.Tiberghien
Chapitre 9
Organisation des disques
et gestion des fichiers
J.Tiberghien
Disk organization& File
Management• Physical data recording on magnetic disks• Physical organization of data on magnetic disks• Logical disk organization
– Contiguous blocks
– Random blocks: MS/DOS, UNIX, MS/NT
• Directories• System Calls
J.Tiberghien
Disk organization& File
Management• Physical data recording on magnetic disks• Physical organization of data on magnetic disks• Logical disk organization
– Contiguous blocks
– Random blocks: MS/DOS, UNIX, MS/NT
• Directories• System Calls
J.Tiberghien
Writing on magnetic memories
i
0 0 0 0 011 11
J.Tiberghien
Manchester Code
0 00 0 1 11 11i
t
J.Tiberghien
Reading from magnetic memory
e
0 0 0 0 011 11 0 0 0 0 011 11
J.Tiberghien
Data blocks
Header Data Block Check
0101010101...010101XXXXXXXXX
Check = f(data block)
Synchronization sequence
J.Tiberghien
Disk organization& File
Management• Physical data recording on magnetic disks• Physical organization of data on magnetic disks• Logical disk organization
– Contiguous blocks
– Random blocks: MS/DOS, UNIX, MS/NT
• Directories• System Calls
J.Tiberghien
Disk Organization
Sector
Track
Cylinder
J.Tiberghien
Tracks/cylinder
Cylinders
Sectors/track
Bytes/sector
Total Capacity(in bytes)
Double Density
2
80
9
512
737 280
High density
2
80
18
512
1 474 560
Format of 3.5” diskettes for PC’s.
Sectors/Cluster 2 1
J.Tiberghien
Tracks/cylinder
Cylinders
Sectors/track
Bytes/sector
Total Capacity(in bytes)
15
899
62
512
428 067 840
Format of 428 MBytes Hard Disk.
Sectors/Cluster (16 bit fat) 16
J.Tiberghien
Minimum Cluster Size(with a 16 bit FAT)
Disk Size
128 MB256 MB512 MB
1 GB2 GB4 GB
Cluster Size
2 kB4 kB8 kB
16 kB32 kB64 kB
Sectors/Cluster
48
163264
128
J.Tiberghien
Space lost to Slack
Block Size Used Space “Slack”
(Bytes) (MBytes) (%)
1 775.2 0.0
512 828.7 6.9
1024 866.5 11.8
2048 948.5 22.4
4096 1128.3 45.6
J.Tiberghien
Disk organization& File
Management• Physical data recording on magnetic disks• Physical organization of data on magnetic disks• Logical disk organization
– Contiguous blocks
– Random blocks: MS/DOS, UNIX, MS/NT
• Directories• System Calls
J.Tiberghien
Mapping the Files on the Disk
• Contiguous Block Allocation– When throughput is critical– When almost no file creation or deletion– Regular space reorganizations required
• Random Block Allocation– When disk space is critical– When lots of file creations and deletions– Disk space optimizations beneficial for
performance
J.Tiberghien
Contiguous Block Allocation
FreeF7F1 F5F3.1F3F2 F6F4
Del F1, F5
F8Save F8
Sorry, Insufficient Disk Space !
Pack
FreeF7Free FreeF3.1F3F2 F6F4
FreeF7F6F3F2 F4
Save F8
F8 FreeF7F6F3F2 F4
J.Tiberghien
Mapping the Files on the Disk
• Contiguous Block Allocation– When throughput is critical– When almost no file creation or deletion– Regular space reorganizations required
• Random Block Allocation– When disk space is critical– When lots of file creations and deletions– Disk space optimizations beneficial for
performance
J.Tiberghien
File Access Table
(MS/DOS)
DISK
FAT
Cluster 0
Cluster x
One entry per Logical Cluster Number
J.Tiberghien
Conceptual FAT model
Stream a
Stream b
Stream c
Stream d
...
Free
8 12 13
0 1 2 9 10
3 54
1615 17 18 19 ...
6 7 11 14 ...
VCN = 0 1 2 3
LCN
J.Tiberghien
Partial view of FATDirectory Pointer LCN FAT contents Disk contents
Stream a > 0 1 Stream a, cluster 01 2 Stream a, cluster 12 9 Stream a, cluster 2
Stream b > 3 4 Stream b, cluster 04 5 Stream b, cluster 15 END Stream b, cluster 2
Free Space > 6 7 Free7 11 Free
Stream c > 8 12 Stream c, cluster 09 10 Stream a, cluster 310 END Stream a, cluster 411 14 Free12 13 Stream c, cluster 113 END Stream c, cluster 214 23 Free
Stream d > 15 16 Stream d, cluster 016 17 Stream d, cluster 117 18 Stream d, cluster 218 19 Stream d, cluster 3... ... ...
J.Tiberghien
UNIX Inode
Logical clustersof data on disk
(up to 256)
...256
...256
...256
Logical clusters of data on disk(up to 256*256)
...256
10 Logical clustersof data on disk
...256
...256
...256
...256
...256
...256
...256
Logical clusters of data on disk(up to 256*256*256)
J.Tiberghien
VCN to LCN mapping in MS/NT
startingVCN
startingLCN
no.ofclusters
0 1355 4
4 1588 5
VCN=
LCN=
0 1 2 3
1355 1356 1357 1358
4 5 6 7 8
1588 1589 1590 1591 1592
J.Tiberghien
Disk organization& File
Management• Physical data recording on magnetic disks• Physical organization of data on magnetic disks• Logical disk organization
– Contiguous blocks
– Random blocks: MS/DOS, UNIX, MS/NT
• Directories• System Calls
J.Tiberghien
Directory Tree
\
info
ex
1k 2k asti 3E
\info\ex\3E
J.Tiberghien
MS/DOS Directory Entry
bit 0: read onlybit 1: hiddenbit 2: system filebit 3: volume labelbit 4: subdirectorybit 5: archive bit
Base NameExtensionAttributes
Time of creationDate of creationStarting FAT entryFile size
8 bytes3 bytes1 byte
2 bytes2 bytes2 bytes4 bytes
J.Tiberghien
Unix Directories
\
info
ex
3E
\info\ex\3E
txt
\txt\new
new
J.Tiberghien
MS/NT Master File Table
SecurityDescriptor
FileName
StandardInformation
Data
1,2 or 4 KBytes
J.Tiberghien
MS/NT Data Files
SecurityDescriptor
FileName
StandardInformation Actual Data
SecurityDescriptor
FileName
StandardInformation
VCN to LCN mappings
Small file:
Large file:
VCN=
LCN=
0 1 2 3
1355 1356 1357 1358
4 5 6 7 8
1588 1589 1590 1591 1592
J.Tiberghien
MS/NT Directories
SecurityDescriptor
FileName
StandardInformation
Index of files in MFTf1,f2,f3
Small directory:
Large directory (organized as a Btree):
SecurityDescriptor
FileName
StandardInformation
VCN to LCN mappings + bitmap
VCN=
LCN=
0 1 2 3
1355 1356 1357 1358
4 5 6 7
1588 1589 1590 1591
f1 f2 f4 f5 f6
f3 f7
8 9 10 11
1648 1649 1650 1651
f8 f9
J.Tiberghien
Disk organization& File
Management• Physical data recording on magnetic disks• Physical organization of data on magnetic disks• Logical disk organization
– Contiguous blocks
– Random blocks: MS/DOS, UNIX, MS/NT
• Directories• System Calls
J.Tiberghien
System Calls
File Manipulation
• create file, delete file
• open, close
• read, write, reposition
• get file attributes, set file attributes