Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Linux-御风守护者
linux
提交
134e9731
L
linux
项目概览
Linux-御风守护者
/
linux
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
134e9731
编写于
3月 25, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
3月 25, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: unlink and delete_inode
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
78fae27e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
114 addition
and
3 deletion
+114
-3
fs/btrfs/super.c
fs/btrfs/super.c
+114
-3
未找到文件。
fs/btrfs/super.c
浏览文件 @
134e9731
...
@@ -187,6 +187,104 @@ static void btrfs_read_locked_inode(struct inode *inode)
...
@@ -187,6 +187,104 @@ static void btrfs_read_locked_inode(struct inode *inode)
return
;
return
;
}
}
static
int
btrfs_unlink
(
struct
inode
*
dir
,
struct
dentry
*
dentry
)
{
struct
btrfs_path
path
;
struct
btrfs_root
*
root
;
struct
btrfs_trans_handle
*
trans
;
const
char
*
name
=
dentry
->
d_name
.
name
;
int
name_len
=
dentry
->
d_name
.
len
;
int
ret
;
u64
objectid
;
struct
btrfs_dir_item
*
di
;
btrfs_init_path
(
&
path
);
root
=
btrfs_sb
(
dir
->
i_sb
);
mutex_lock
(
&
root
->
fs_info
->
fs_mutex
);
trans
=
btrfs_start_transaction
(
root
,
1
);
ret
=
btrfs_lookup_dir_item
(
trans
,
root
,
&
path
,
dir
->
i_ino
,
name
,
name_len
,
-
1
);
if
(
ret
<
0
)
goto
err
;
if
(
ret
>
0
)
{
ret
=
-
ENOENT
;
goto
err
;
}
di
=
btrfs_item_ptr
(
btrfs_buffer_leaf
(
path
.
nodes
[
0
]),
path
.
slots
[
0
],
struct
btrfs_dir_item
);
objectid
=
btrfs_dir_objectid
(
di
);
ret
=
btrfs_del_item
(
trans
,
root
,
&
path
);
BUG_ON
(
ret
);
dentry
->
d_inode
->
i_ctime
=
dir
->
i_ctime
;
err:
btrfs_release_path
(
root
,
&
path
);
btrfs_end_transaction
(
trans
,
root
);
mutex_unlock
(
&
root
->
fs_info
->
fs_mutex
);
if
(
ret
==
0
)
inode_dec_link_count
(
dentry
->
d_inode
);
return
ret
;
}
static
int
btrfs_free_inode
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
root
,
struct
inode
*
inode
)
{
u64
objectid
=
inode
->
i_ino
;
struct
btrfs_path
path
;
struct
btrfs_inode_map_item
*
map
;
struct
btrfs_key
stat_data_key
;
int
ret
;
clear_inode
(
inode
);
btrfs_init_path
(
&
path
);
ret
=
btrfs_lookup_inode_map
(
trans
,
root
,
&
path
,
objectid
,
-
1
);
if
(
ret
)
{
if
(
ret
>
0
)
ret
=
-
ENOENT
;
btrfs_release_path
(
root
,
&
path
);
goto
error
;
}
map
=
btrfs_item_ptr
(
btrfs_buffer_leaf
(
path
.
nodes
[
0
]),
path
.
slots
[
0
],
struct
btrfs_inode_map_item
);
btrfs_disk_key_to_cpu
(
&
stat_data_key
,
&
map
->
key
);
ret
=
btrfs_del_item
(
trans
,
root
->
fs_info
->
inode_root
,
&
path
);
BUG_ON
(
ret
);
btrfs_release_path
(
root
,
&
path
);
btrfs_init_path
(
&
path
);
ret
=
btrfs_lookup_inode
(
trans
,
root
,
&
path
,
objectid
,
-
1
);
BUG_ON
(
ret
);
ret
=
btrfs_del_item
(
trans
,
root
,
&
path
);
BUG_ON
(
ret
);
btrfs_release_path
(
root
,
&
path
);
error:
return
ret
;
}
static
void
btrfs_delete_inode
(
struct
inode
*
inode
)
{
struct
btrfs_trans_handle
*
trans
;
struct
btrfs_root
*
root
=
btrfs_sb
(
inode
->
i_sb
);
truncate_inode_pages
(
&
inode
->
i_data
,
0
);
if
(
is_bad_inode
(
inode
))
{
goto
no_delete
;
}
inode
->
i_size
=
0
;
if
(
inode
->
i_blocks
)
WARN_ON
(
1
);
mutex_lock
(
&
root
->
fs_info
->
fs_mutex
);
trans
=
btrfs_start_transaction
(
root
,
1
);
btrfs_free_inode
(
trans
,
root
,
inode
);
btrfs_end_transaction
(
trans
,
root
);
mutex_unlock
(
&
root
->
fs_info
->
fs_mutex
);
return
;
no_delete:
clear_inode
(
inode
);
}
static
int
btrfs_inode_by_name
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
static
int
btrfs_inode_by_name
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
ino_t
*
ino
)
ino_t
*
ino
)
{
{
...
@@ -272,6 +370,13 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
...
@@ -272,6 +370,13 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
leaf
=
btrfs_buffer_leaf
(
path
.
nodes
[
0
]);
leaf
=
btrfs_buffer_leaf
(
path
.
nodes
[
0
]);
nritems
=
btrfs_header_nritems
(
&
leaf
->
header
);
nritems
=
btrfs_header_nritems
(
&
leaf
->
header
);
slot
=
path
.
slots
[
0
];
slot
=
path
.
slots
[
0
];
#if 0
page_cache_readahead(
inode->i_sb->s_bdev->bd_inode->i_mapping,
&filp->f_ra, filp,
path.nodes[0]->b_blocknr >>
(PAGE_CACHE_SHIFT - inode->i_blkbits), 1);
#endif
}
else
{
}
else
{
slot
++
;
slot
++
;
path
.
slots
[
0
]
++
;
path
.
slots
[
0
]
++
;
...
@@ -441,8 +546,6 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
...
@@ -441,8 +546,6 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
d_instantiate
(
dentry
,
inode
);
d_instantiate
(
dentry
,
inode
);
return
0
;
return
0
;
}
}
inode_dec_link_count
(
inode
);
iput
(
inode
);
return
err
;
return
err
;
}
}
...
@@ -453,6 +556,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
...
@@ -453,6 +556,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
struct
btrfs_root
*
root
=
btrfs_sb
(
dir
->
i_sb
);
struct
btrfs_root
*
root
=
btrfs_sb
(
dir
->
i_sb
);
struct
inode
*
inode
;
struct
inode
*
inode
;
int
err
;
int
err
;
int
drop_inode
=
0
;
mutex_lock
(
&
root
->
fs_info
->
fs_mutex
);
mutex_lock
(
&
root
->
fs_info
->
fs_mutex
);
trans
=
btrfs_start_transaction
(
root
,
1
);
trans
=
btrfs_start_transaction
(
root
,
1
);
...
@@ -462,10 +566,16 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
...
@@ -462,10 +566,16 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
goto
out_unlock
;
goto
out_unlock
;
// FIXME mark the inode dirty
// FIXME mark the inode dirty
err
=
btrfs_add_nondir
(
trans
,
dentry
,
inode
);
err
=
btrfs_add_nondir
(
trans
,
dentry
,
inode
);
if
(
err
)
drop_inode
=
1
;
dir
->
i_sb
->
s_dirt
=
1
;
dir
->
i_sb
->
s_dirt
=
1
;
btrfs_end_transaction
(
trans
,
root
);
btrfs_end_transaction
(
trans
,
root
);
out_unlock:
out_unlock:
mutex_unlock
(
&
root
->
fs_info
->
fs_mutex
);
mutex_unlock
(
&
root
->
fs_info
->
fs_mutex
);
if
(
drop_inode
)
{
inode_dec_link_count
(
inode
);
iput
(
inode
);
}
return
err
;
return
err
;
}
}
...
@@ -516,7 +626,7 @@ static struct file_system_type btrfs_fs_type = {
...
@@ -516,7 +626,7 @@ static struct file_system_type btrfs_fs_type = {
static
struct
super_operations
btrfs_super_ops
=
{
static
struct
super_operations
btrfs_super_ops
=
{
.
statfs
=
simple_statfs
,
.
statfs
=
simple_statfs
,
.
d
rop_inode
=
generic
_delete_inode
,
.
d
elete_inode
=
btrfs
_delete_inode
,
.
put_super
=
btrfs_put_super
,
.
put_super
=
btrfs_put_super
,
.
read_inode
=
btrfs_read_locked_inode
,
.
read_inode
=
btrfs_read_locked_inode
,
.
write_super
=
btrfs_write_super
,
.
write_super
=
btrfs_write_super
,
...
@@ -526,6 +636,7 @@ static struct super_operations btrfs_super_ops = {
...
@@ -526,6 +636,7 @@ static struct super_operations btrfs_super_ops = {
static
struct
inode_operations
btrfs_dir_inode_operations
=
{
static
struct
inode_operations
btrfs_dir_inode_operations
=
{
.
lookup
=
btrfs_lookup
,
.
lookup
=
btrfs_lookup
,
.
create
=
btrfs_create
,
.
create
=
btrfs_create
,
.
unlink
=
btrfs_unlink
,
};
};
static
struct
file_operations
btrfs_dir_file_operations
=
{
static
struct
file_operations
btrfs_dir_file_operations
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录