Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
3375df50
提交
3375df50
8月 08, 2017
创建
作者:
Robert Morris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change ip->flags&I_VALID to ip->valid
上级
14270288
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
12 行删除
+11
-12
file.h
file.h
+1
-2
fs.c
fs.c
+10
-10
没有找到文件。
file.h
浏览文件 @
3375df50
...
@@ -15,7 +15,7 @@ struct inode {
...
@@ -15,7 +15,7 @@ struct inode {
uint
inum
;
// Inode number
uint
inum
;
// Inode number
int
ref
;
// Reference count
int
ref
;
// Reference count
struct
sleeplock
lock
;
struct
sleeplock
lock
;
int
flags
;
// I_VALID
int
valid
;
// remainder has been read from disk?
short
type
;
// copy of disk inode
short
type
;
// copy of disk inode
short
major
;
short
major
;
...
@@ -24,7 +24,6 @@ struct inode {
...
@@ -24,7 +24,6 @@ struct inode {
uint
size
;
uint
size
;
uint
addrs
[
NDIRECT
+
1
];
uint
addrs
[
NDIRECT
+
1
];
};
};
#define I_VALID 0x2
// table mapping major device number to
// table mapping major device number to
// device functions
// device functions
...
...
fs.c
浏览文件 @
3375df50
...
@@ -110,7 +110,7 @@ bfree(int dev, uint b)
...
@@ -110,7 +110,7 @@ bfree(int dev, uint b)
// to provide a place for synchronizing access
// to provide a place for synchronizing access
// to inodes used by multiple processes. The cached
// to inodes used by multiple processes. The cached
// inodes include book-keeping information that is
// inodes include book-keeping information that is
// not stored on disk: ip->ref and ip->
flags
.
// not stored on disk: ip->ref and ip->
valid
.
//
//
// An inode and its in-memory representation go through a
// An inode and its in-memory representation go through a
// sequence of states before they can be used by the
// sequence of states before they can be used by the
...
@@ -128,10 +128,10 @@ bfree(int dev, uint b)
...
@@ -128,10 +128,10 @@ bfree(int dev, uint b)
// decrements ref.
// decrements ref.
//
//
// * Valid: the information (type, size, &c) in an inode
// * Valid: the information (type, size, &c) in an inode
// cache entry is only correct when
the I_VALID bit
// cache entry is only correct when
ip->valid is 1.
// i
s set in ip->flags. i
lock() reads the inode from
// ilock() reads the inode from
// the disk and sets
I_VALID
, while iput() clears
// the disk and sets
ip->valid
, while iput() clears
//
I_VALID
if ip->ref has fallen to zero.
//
ip->valid
if ip->ref has fallen to zero.
//
//
// * Locked: file system code may only examine and modify
// * Locked: file system code may only examine and modify
// the information in an inode and its content if it
// the information in an inode and its content if it
...
@@ -253,7 +253,7 @@ iget(uint dev, uint inum)
...
@@ -253,7 +253,7 @@ iget(uint dev, uint inum)
ip
->
dev
=
dev
;
ip
->
dev
=
dev
;
ip
->
inum
=
inum
;
ip
->
inum
=
inum
;
ip
->
ref
=
1
;
ip
->
ref
=
1
;
ip
->
flags
=
0
;
ip
->
valid
=
0
;
release
(
&
icache
.
lock
);
release
(
&
icache
.
lock
);
return
ip
;
return
ip
;
...
@@ -283,7 +283,7 @@ ilock(struct inode *ip)
...
@@ -283,7 +283,7 @@ ilock(struct inode *ip)
acquiresleep
(
&
ip
->
lock
);
acquiresleep
(
&
ip
->
lock
);
if
(
(
ip
->
flags
&
I_VALID
)
==
0
){
if
(
ip
->
valid
==
0
){
bp
=
bread
(
ip
->
dev
,
IBLOCK
(
ip
->
inum
,
sb
));
bp
=
bread
(
ip
->
dev
,
IBLOCK
(
ip
->
inum
,
sb
));
dip
=
(
struct
dinode
*
)
bp
->
data
+
ip
->
inum
%
IPB
;
dip
=
(
struct
dinode
*
)
bp
->
data
+
ip
->
inum
%
IPB
;
ip
->
type
=
dip
->
type
;
ip
->
type
=
dip
->
type
;
...
@@ -293,7 +293,7 @@ ilock(struct inode *ip)
...
@@ -293,7 +293,7 @@ ilock(struct inode *ip)
ip
->
size
=
dip
->
size
;
ip
->
size
=
dip
->
size
;
memmove
(
ip
->
addrs
,
dip
->
addrs
,
sizeof
(
ip
->
addrs
));
memmove
(
ip
->
addrs
,
dip
->
addrs
,
sizeof
(
ip
->
addrs
));
brelse
(
bp
);
brelse
(
bp
);
ip
->
flags
|=
I_VALID
;
ip
->
valid
=
1
;
if
(
ip
->
type
==
0
)
if
(
ip
->
type
==
0
)
panic
(
"ilock: no type"
);
panic
(
"ilock: no type"
);
}
}
...
@@ -320,7 +320,7 @@ void
...
@@ -320,7 +320,7 @@ void
iput
(
struct
inode
*
ip
)
iput
(
struct
inode
*
ip
)
{
{
acquire
(
&
icache
.
lock
);
acquire
(
&
icache
.
lock
);
if
(
ip
->
ref
==
1
&&
(
ip
->
flags
&
I_VALID
)
&&
ip
->
nlink
==
0
){
if
(
ip
->
ref
==
1
&&
ip
->
valid
&&
ip
->
nlink
==
0
){
// inode has no links and no other references: truncate and free.
// inode has no links and no other references: truncate and free.
acquiresleep
(
&
ip
->
lock
);
acquiresleep
(
&
ip
->
lock
);
release
(
&
icache
.
lock
);
release
(
&
icache
.
lock
);
...
@@ -328,7 +328,7 @@ iput(struct inode *ip)
...
@@ -328,7 +328,7 @@ iput(struct inode *ip)
ip
->
type
=
0
;
ip
->
type
=
0
;
iupdate
(
ip
);
iupdate
(
ip
);
acquire
(
&
icache
.
lock
);
acquire
(
&
icache
.
lock
);
ip
->
flags
=
0
;
ip
->
valid
=
0
;
releasesleep
(
&
ip
->
lock
);
releasesleep
(
&
ip
->
lock
);
}
}
ip
->
ref
--
;
ip
->
ref
--
;
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论