Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
5d9cd9ec
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5d9cd9ec
编写于
5月 05, 2008
作者:
C
Chris Mason
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: Fix clone ioctl to not hold the path over inserts
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
b9d86667
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
32 deletion
+47
-32
fs/btrfs/inode.c
fs/btrfs/inode.c
+47
-32
未找到文件。
fs/btrfs/inode.c
浏览文件 @
5d9cd9ec
...
...
@@ -3101,7 +3101,7 @@ long btrfs_ioctl_add_dev(struct btrfs_root *root, void __user *arg)
return
ret
;
}
void
dup_item_to_inode
(
struct
btrfs_trans_handle
*
trans
,
int
dup_item_to_inode
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
root
,
struct
btrfs_path
*
path
,
struct
extent_buffer
*
leaf
,
...
...
@@ -3109,19 +3109,22 @@ void dup_item_to_inode(struct btrfs_trans_handle *trans,
struct
btrfs_key
*
key
,
u64
destino
)
{
struct
btrfs_path
*
cpath
=
btrfs_alloc_path
()
;
char
*
dup
;
int
len
=
btrfs_item_size_nr
(
leaf
,
slot
);
int
dstoff
;
struct
btrfs_key
ckey
=
*
key
;
int
ret
;
int
ret
=
0
;
dup
=
kmalloc
(
len
,
GFP_NOFS
);
if
(
!
dup
)
return
-
ENOMEM
;
read_extent_buffer
(
leaf
,
dup
,
btrfs_item_ptr_offset
(
leaf
,
slot
),
len
);
btrfs_release_path
(
root
,
path
);
ckey
.
objectid
=
destino
;
ret
=
btrfs_insert_empty_item
(
trans
,
root
,
cpath
,
&
ckey
,
len
);
dstoff
=
btrfs_item_ptr_offset
(
cpath
->
nodes
[
0
],
cpath
->
slots
[
0
]);
copy_extent_buffer
(
cpath
->
nodes
[
0
],
leaf
,
dstoff
,
btrfs_item_ptr_offset
(
leaf
,
slot
),
len
);
btrfs_release_path
(
root
,
cpath
);
ret
=
btrfs_insert_item
(
trans
,
root
,
&
ckey
,
dup
,
len
);
kfree
(
dup
);
return
ret
;
}
long
btrfs_ioctl_clone
(
struct
file
*
file
,
unsigned
long
src_fd
)
...
...
@@ -3137,7 +3140,6 @@ long btrfs_ioctl_clone(struct file *file, unsigned long src_fd)
struct
btrfs_key
key
;
struct
extent_buffer
*
leaf
;
u32
nritems
;
int
nextret
;
int
slot
;
src_file
=
fget
(
src_fd
);
...
...
@@ -3174,20 +3176,32 @@ long btrfs_ioctl_clone(struct file *file, unsigned long src_fd)
mutex_lock
(
&
root
->
fs_info
->
fs_mutex
);
trans
=
btrfs_start_transaction
(
root
,
0
);
path
=
btrfs_alloc_path
();
if
(
!
path
)
{
ret
=
-
ENOMEM
;
goto
out
;
}
key
.
offset
=
0
;
key
.
type
=
BTRFS_EXTENT_DATA_KEY
;
key
.
objectid
=
src
->
i_ino
;
pos
=
0
;
path
->
reada
=
2
;
while
(
1
)
{
ret
=
btrfs_lookup_file_extent
(
trans
,
root
,
path
,
src
->
i_ino
,
pos
,
0
);
/*
* note the key will change type as we walk through the
* tree.
*/
ret
=
btrfs_search_slot
(
trans
,
root
,
&
key
,
path
,
0
,
0
);
if
(
ret
<
0
)
goto
out
;
if
(
ret
>
0
)
{
if
(
path
->
slots
[
0
]
==
0
)
{
ret
=
0
;
if
(
path
->
slots
[
0
]
>=
btrfs_header_nritems
(
path
->
nodes
[
0
]))
{
ret
=
btrfs_next_leaf
(
root
,
path
);
if
(
ret
<
0
)
goto
out
;
}
path
->
slots
[
0
]
--
;
if
(
ret
>
0
)
break
;
}
next_slot:
leaf
=
path
->
nodes
[
0
];
slot
=
path
->
slots
[
0
];
btrfs_item_key_to_cpu
(
leaf
,
&
key
,
slot
);
...
...
@@ -3195,7 +3209,8 @@ long btrfs_ioctl_clone(struct file *file, unsigned long src_fd)
if
(
btrfs_key_type
(
&
key
)
>
BTRFS_CSUM_ITEM_KEY
||
key
.
objectid
!=
src
->
i_ino
)
goto
out
;
break
;
if
(
btrfs_key_type
(
&
key
)
==
BTRFS_EXTENT_DATA_KEY
)
{
struct
btrfs_file_extent_item
*
extent
;
int
found_type
;
...
...
@@ -3225,28 +3240,28 @@ long btrfs_ioctl_clone(struct file *file, unsigned long src_fd)
}
pos
=
key
.
offset
+
len
;
}
else
if
(
found_type
==
BTRFS_FILE_EXTENT_INLINE
)
{
dup_item_to_inode
(
trans
,
root
,
path
,
leaf
,
slot
,
&
key
,
inode
->
i_ino
);
ret
=
dup_item_to_inode
(
trans
,
root
,
path
,
leaf
,
slot
,
&
key
,
inode
->
i_ino
);
if
(
ret
)
goto
out
;
pos
=
key
.
offset
+
btrfs_item_size_nr
(
leaf
,
slot
);
}
}
else
if
(
btrfs_key_type
(
&
key
)
==
BTRFS_CSUM_ITEM_KEY
)
dup_item_to_inode
(
trans
,
root
,
path
,
leaf
,
slot
,
&
key
,
inode
->
i_ino
);
}
else
if
(
btrfs_key_type
(
&
key
)
==
BTRFS_CSUM_ITEM_KEY
)
{
ret
=
dup_item_to_inode
(
trans
,
root
,
path
,
leaf
,
slot
,
&
key
,
inode
->
i_ino
);
if
(
slot
>=
nritems
-
1
)
{
nextret
=
btrfs_next_leaf
(
root
,
path
);
if
(
nextret
)
if
(
ret
)
goto
out
;
}
else
{
path
->
slots
[
0
]
++
;
}
goto
next_slot
;
key
.
offset
++
;
btrfs_release_path
(
root
,
path
);
}
ret
=
0
;
out:
btrfs_free_path
(
path
);
ret
=
0
;
inode
->
i_blocks
=
src
->
i_blocks
;
i_size_write
(
inode
,
src
->
i_size
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录