操作系统--实现文件系统中篇

操作系统--实现文件系统中篇

自由空间管理

Bit vector (n blocks)

位向量(n个块)

bit[i] =678Þ block[i] free 1 Þ block[i] occupied

比特[i] =678Þ块[i]空闲1 Þ块[i]被占用

FreeSpace Management (Cont.)

自由空间管理(续。)

n Bit map requires extra space

位图需要额外的空间

l Example:

例子:

block size = 2 bytes

块大小= 2字节

disk size = 2 bytes (1 gigabyte)

磁盘大小= 2字节(1gb)

n = 2 /2 = 2 bits (or 32K bytes)

n = 2 /2 = 2位(或32K字节)

n Easy to get contiguous files ….00011111111000….

易于获取连续文件。00011111111000….

n Linked list (free list)

链表(自由列表)

l Cannot get contiguous space easily

不容易获得连续的空间

l No waste of space

不浪费空间

Linked Free Space List on Disk

磁盘上的链接可用空间列表

FreeSpace Management (Cont.)

自由空间管理(续。)

n Grouping: stores the addresses of n free blocks

分组:存储n个空闲块的地址

in the first free block.A block has n entries.

在第一个自由区。一个块有n个条目。

l The first n1 of these blocks are actually free.

这些区块的第一个n1实际上是免费的。

l The last block contains the addresses of

最后一个块包含以下地址

another n free blocks, and so on.

另外n个空闲块,以此类推。

n Counting: keep the address of the first free

计数:保留第一个空闲的地址

block and the number (n) of free contiguous blocks that follow the first block.

块和跟随第一块的空闲连续块的数量(n)。

l Address 1, n1 (2,3)

地址1,n1 (2,3)

l Address 2, n2, (8,5)

地址2,n2,(8,5)

l Address 3, n3, (17,2) …

地址3,n3,(17,2) …

FreeSpace Management (Cont.)

自由空间管理(续。)

n Need to protect:

需要保护:

l Pointer to free list

指向自由列表的指针

l Bit map

位图

4Must be kept on disk

4Must被保存在磁盘上

4Copy in memory and disk may differ

内存和磁盘中的4Copy可能不同

4Cannot allow for block[i] to have a situation where

4Cannot允许block[i]出现以下情况

bit[i] = 1 (occupied) in memory and bit[i] = 0 (free) on disk

内存中的位[i] = 1(已占用),磁盘上的位[i] = 0(空闲)

l Solution:

解决方案:

4Set bit[i] = 1 in disk

磁盘中的4Set位[i] = 1

4Allocate block[i]

4Allocate街区[i]

4Set bit[i] = 1 in memory

内存中的4Set位[i] = 1

Efficiency and Performance

效率和性能

n Efficiency

效率

l The Efficient use of disk space depends heavily on the

磁盘空间的有效利用在很大程度上取决于

disk allocation and directory algorithms

磁盘分配和目录算法

4UNIX inodes are preallocated on a volume.Even a

4UNIX信息节点预先分配在卷上。甚至一个

“empty” disk has a percentage of it space lost to

“空”磁盘有一定比例的it空间丢失给了

inodes.

索引节点。

4By preallocating, the inodes and spreading them

4By预分配信息节点并将其扩展

across the volume, we improve the file system’s performance.Try to keep a file’s data block near

在整个卷中,我们提高了文件系统的性能。尝试将文件的数据块放在附近

that file’s inode block to reduce the seek time.

该文件的索引节点块,以减少寻道时间。

l The type of data kept in file’s directory (or inode) entry

保存在文件目录(或索引节点)条目中的数据类型

also require consideration

也需要考虑

4"Last write date"

4"Last写日期”

4"Last access date"

4"Last访问日期”

Efficiency and Performance

效率和性能

n Performance

性能

l disk cache separate section of main memory for

磁盘缓存是主存的独立部分,用于

frequently used blocks

常用块

l freebehind and readahead techniques to optimize

自由风和预读技术优化

sequential access

顺序存取

4Freebehind removes a page from the buffer as soon

4Freebehind尽快从缓冲区中删除一页

as the next page is requested.

当请求下一页时。

4With readahead, a requested page and several

4With预读,一个请求页面和几个

subsequent pages are read and cached.

后续页面被读取和缓存。

l improve PC performance by dedicating section of memory as virtual disk, or RAM disk

通过将部分内存作为虚拟磁盘或内存磁盘来提高电脑性能

Page Cache

页面缓存

n A page cache caches pages rather than disk blocks using

页面缓存使用缓存页面而不是磁盘块

virtual memory techniques

虚拟存储技术

n Memorymapped I/O uses a page cache

内存映射输入/输出使用页面缓存

n Routine I/O through the file system uses the buffer (disk)

通过文件系统的常规输入/输出使用缓冲区(磁盘)

cache

高速缓存

n Double caching

双重缓存

I/O Without a Unified Buffer Cache

没有统一缓冲区缓存的输入/输出

Unified Buffer Cache

统一缓冲区缓存

n A unified buffer cache uses the same page cache to

统一缓冲区缓存使用相同的页面缓存来

cache both memorymapped pages and ordinary

缓存内存映射页面和普通页面

file system I/O

文件系统输入输出

I/O Using a Unified Buffer Cache

使用统一缓冲区缓存的输入/输出

Recovery

恢复

n Consistency checking compares data in

一致性检查比较数据

directory structure with data blocks on disk, and tries to fix inconsistencies

磁盘上有数据块的目录结构,并尝试修复不一致

n Use system programs to back up data from disk

使用系统程序从磁盘备份数据

to another storage device (floppy disk, magnetic

到另一个存储设备(软盘、磁盘

tape, other magnetic disk, optical)

磁带、其他磁盘、光盘)

n Recover lost file or disk by restoring data from

通过从以下位置恢复数据来恢复丢失的文件或磁盘

backup

支持

Log Structured File Systems

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑白极客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值