Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
11183588
提交
11183588
8月 28, 2014
创建
作者:
Robert Morris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
nits
上级
48aa9174
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
24 行删除
+10
-24
log.c
log.c
+10
-24
没有找到文件。
log.c
浏览文件 @
11183588
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
// Simple logging that allows concurrent FS system calls.
// Simple logging that allows concurrent FS system calls.
//
//
// A log transaction contains the updates of
*multiple*
FS system
// A log transaction contains the updates of
multiple
FS system
// calls. The logging system
s
only commits when there are
// calls. The logging system only commits when there are
// no FS system calls active. Thus there is never
// no FS system calls active. Thus there is never
// any reasoning required about whether a commit might
// any reasoning required about whether a commit might
// write an uncommitted system call's updates to disk.
// write an uncommitted system call's updates to disk.
...
@@ -17,10 +17,7 @@
...
@@ -17,10 +17,7 @@
// its start and end. Usually begin_op() just increments
// its start and end. Usually begin_op() just increments
// the count of in-progress FS system calls and returns.
// the count of in-progress FS system calls and returns.
// But if it thinks the log is close to running out, it
// But if it thinks the log is close to running out, it
// blocks this system call, and causes the system to wait
// sleeps until the last outstanding end_op() commits.
// until end_op() indicates there are no executing FS
// system calls, at which point the last end_op() commits
// all the system calls' writes.
//
//
// The log is a physical re-do log containing disk blocks.
// The log is a physical re-do log containing disk blocks.
// The on-disk log format:
// The on-disk log format:
...
@@ -52,10 +49,6 @@ struct log log;
...
@@ -52,10 +49,6 @@ struct log log;
static
void
recover_from_log
(
void
);
static
void
recover_from_log
(
void
);
static
void
commit
();
static
void
commit
();
// statistics, delete eventually XXX.
static
int
maxsize
;
static
int
maxoutstanding
;
void
void
initlog
(
void
)
initlog
(
void
)
{
{
...
@@ -127,7 +120,7 @@ recover_from_log(void)
...
@@ -127,7 +120,7 @@ recover_from_log(void)
write_head
();
// clear the log
write_head
();
// clear the log
}
}
//
an FS system call should call begin_op() when it starts
.
//
called at the start of each FS system call
.
void
void
begin_op
(
void
)
begin_op
(
void
)
{
{
...
@@ -140,18 +133,14 @@ begin_op(void)
...
@@ -140,18 +133,14 @@ begin_op(void)
sleep
(
&
log
,
&
log
.
lock
);
sleep
(
&
log
,
&
log
.
lock
);
}
else
{
}
else
{
log
.
outstanding
+=
1
;
log
.
outstanding
+=
1
;
if
(
log
.
outstanding
>
maxoutstanding
){
maxoutstanding
=
log
.
outstanding
;
cprintf
(
"%d outstanding
\n
"
,
log
.
outstanding
);
}
release
(
&
log
.
lock
);
release
(
&
log
.
lock
);
break
;
break
;
}
}
}
}
}
}
//
an FS system call should call end_op() after it finishes
.
//
called at the end of each FS system call
.
// c
an't write the disk &c while holding locks, thus do_commit
.
// c
ommits if this was the last outstanding operation
.
void
void
end_op
(
void
)
end_op
(
void
)
{
{
...
@@ -171,6 +160,8 @@ end_op(void)
...
@@ -171,6 +160,8 @@ end_op(void)
release
(
&
log
.
lock
);
release
(
&
log
.
lock
);
if
(
do_commit
){
if
(
do_commit
){
// call commit w/o holding locks, since not allowed
// to sleep with locks.
commit
();
commit
();
acquire
(
&
log
.
lock
);
acquire
(
&
log
.
lock
);
log
.
committing
=
0
;
log
.
committing
=
0
;
...
@@ -209,7 +200,7 @@ log_write(struct buf *b)
...
@@ -209,7 +200,7 @@ log_write(struct buf *b)
panic
(
"write outside of trans"
);
panic
(
"write outside of trans"
);
for
(
i
=
0
;
i
<
log
.
lh
.
n
;
i
++
)
{
for
(
i
=
0
;
i
<
log
.
lh
.
n
;
i
++
)
{
if
(
log
.
lh
.
sector
[
i
]
==
b
->
sector
)
// log absorbtion
?
if
(
log
.
lh
.
sector
[
i
]
==
b
->
sector
)
// log absorbtion
break
;
break
;
}
}
log
.
lh
.
sector
[
i
]
=
b
->
sector
;
log
.
lh
.
sector
[
i
]
=
b
->
sector
;
...
@@ -219,12 +210,7 @@ log_write(struct buf *b)
...
@@ -219,12 +210,7 @@ log_write(struct buf *b)
brelse
(
lbuf
);
brelse
(
lbuf
);
if
(
i
==
log
.
lh
.
n
)
if
(
i
==
log
.
lh
.
n
)
log
.
lh
.
n
++
;
log
.
lh
.
n
++
;
b
->
flags
|=
B_DIRTY
;
// XXX prevent eviction
b
->
flags
|=
B_DIRTY
;
// prevent eviction
if
(
log
.
lh
.
n
>
maxsize
){
maxsize
=
log
.
lh
.
n
;
cprintf
(
"log size %d/%d
\n
"
,
log
.
lh
.
n
,
LOGSIZE
);
}
}
}
//PAGEBREAK!
//PAGEBREAK!
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论