Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
23db8620
K
Kernel
项目概览
openeuler
/
Kernel
大约 1 年 前同步成功
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
23db8620
编写于
5月 17, 2013
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[readdir] convert nfs
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
725bebb2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
26 deletion
+25
-26
fs/nfs/dir.c
fs/nfs/dir.c
+25
-26
未找到文件。
fs/nfs/dir.c
浏览文件 @
23db8620
...
...
@@ -46,7 +46,7 @@
static
int
nfs_opendir
(
struct
inode
*
,
struct
file
*
);
static
int
nfs_closedir
(
struct
inode
*
,
struct
file
*
);
static
int
nfs_readdir
(
struct
file
*
,
void
*
,
filldir_t
);
static
int
nfs_readdir
(
struct
file
*
,
struct
dir_context
*
);
static
int
nfs_fsync_dir
(
struct
file
*
,
loff_t
,
loff_t
,
int
);
static
loff_t
nfs_llseek_dir
(
struct
file
*
,
loff_t
,
int
);
static
void
nfs_readdir_clear_array
(
struct
page
*
);
...
...
@@ -54,7 +54,7 @@ static void nfs_readdir_clear_array(struct page*);
const
struct
file_operations
nfs_dir_operations
=
{
.
llseek
=
nfs_llseek_dir
,
.
read
=
generic_read_dir
,
.
readdir
=
nfs_readdir
,
.
iterate
=
nfs_readdir
,
.
open
=
nfs_opendir
,
.
release
=
nfs_closedir
,
.
fsync
=
nfs_fsync_dir
,
...
...
@@ -147,6 +147,7 @@ typedef int (*decode_dirent_t)(struct xdr_stream *, struct nfs_entry *, int);
typedef
struct
{
struct
file
*
file
;
struct
page
*
page
;
struct
dir_context
*
ctx
;
unsigned
long
page_index
;
u64
*
dir_cookie
;
u64
last_cookie
;
...
...
@@ -252,7 +253,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page)
static
int
nfs_readdir_search_for_pos
(
struct
nfs_cache_array
*
array
,
nfs_readdir_descriptor_t
*
desc
)
{
loff_t
diff
=
desc
->
file
->
f_
pos
-
desc
->
current_index
;
loff_t
diff
=
desc
->
ctx
->
pos
-
desc
->
current_index
;
unsigned
int
index
;
if
(
diff
<
0
)
...
...
@@ -289,7 +290,7 @@ int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_des
||
(
nfsi
->
cache_validity
&
(
NFS_INO_INVALID_ATTR
|
NFS_INO_INVALID_DATA
)))
{
ctx
->
duped
=
0
;
ctx
->
attr_gencount
=
nfsi
->
attr_gencount
;
}
else
if
(
new_pos
<
desc
->
file
->
f_
pos
)
{
}
else
if
(
new_pos
<
desc
->
ctx
->
pos
)
{
if
(
ctx
->
duped
>
0
&&
ctx
->
dup_cookie
==
*
desc
->
dir_cookie
)
{
if
(
printk_ratelimit
())
{
...
...
@@ -307,7 +308,7 @@ int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_des
ctx
->
dup_cookie
=
*
desc
->
dir_cookie
;
ctx
->
duped
=
-
1
;
}
desc
->
file
->
f_
pos
=
new_pos
;
desc
->
ctx
->
pos
=
new_pos
;
desc
->
cache_entry_index
=
i
;
return
0
;
}
...
...
@@ -405,13 +406,13 @@ int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry)
}
static
bool
nfs_use_readdirplus
(
struct
inode
*
dir
,
struct
file
*
filp
)
bool
nfs_use_readdirplus
(
struct
inode
*
dir
,
struct
dir_context
*
ctx
)
{
if
(
!
nfs_server_capable
(
dir
,
NFS_CAP_READDIRPLUS
))
return
false
;
if
(
test_and_clear_bit
(
NFS_INO_ADVISE_RDPLUS
,
&
NFS_I
(
dir
)
->
flags
))
return
true
;
if
(
filp
->
f_
pos
==
0
)
if
(
ctx
->
pos
==
0
)
return
true
;
return
false
;
}
...
...
@@ -702,8 +703,7 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
* Once we've found the start of the dirent within a page: fill 'er up...
*/
static
int
nfs_do_filldir
(
nfs_readdir_descriptor_t
*
desc
,
void
*
dirent
,
filldir_t
filldir
)
int
nfs_do_filldir
(
nfs_readdir_descriptor_t
*
desc
)
{
struct
file
*
file
=
desc
->
file
;
int
i
=
0
;
...
...
@@ -721,13 +721,12 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
struct
nfs_cache_array_entry
*
ent
;
ent
=
&
array
->
array
[
i
];
if
(
filldir
(
dirent
,
ent
->
string
.
name
,
ent
->
string
.
len
,
file
->
f_pos
,
nfs_compat_user_ino64
(
ent
->
ino
),
ent
->
d_type
)
<
0
)
{
if
(
!
dir_emit
(
desc
->
ctx
,
ent
->
string
.
name
,
ent
->
string
.
len
,
nfs_compat_user_ino64
(
ent
->
ino
),
ent
->
d_type
))
{
desc
->
eof
=
1
;
break
;
}
file
->
f_
pos
++
;
desc
->
ctx
->
pos
++
;
if
(
i
<
(
array
->
size
-
1
))
*
desc
->
dir_cookie
=
array
->
array
[
i
+
1
].
cookie
;
else
...
...
@@ -759,8 +758,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
* directory in the page cache by the time we get here.
*/
static
inline
int
uncached_readdir
(
nfs_readdir_descriptor_t
*
desc
,
void
*
dirent
,
filldir_t
filldir
)
int
uncached_readdir
(
nfs_readdir_descriptor_t
*
desc
)
{
struct
page
*
page
=
NULL
;
int
status
;
...
...
@@ -785,7 +783,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
if
(
status
<
0
)
goto
out_release
;
status
=
nfs_do_filldir
(
desc
,
dirent
,
filldir
);
status
=
nfs_do_filldir
(
desc
);
out:
dfprintk
(
DIRCACHE
,
"NFS: %s: returns %d
\n
"
,
...
...
@@ -800,35 +798,36 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
last cookie cache takes care of the common case of reading the
whole directory.
*/
static
int
nfs_readdir
(
struct
file
*
fil
p
,
void
*
dirent
,
filldir_t
filldir
)
static
int
nfs_readdir
(
struct
file
*
fil
e
,
struct
dir_context
*
ctx
)
{
struct
dentry
*
dentry
=
fil
p
->
f_path
.
dentry
;
struct
dentry
*
dentry
=
fil
e
->
f_path
.
dentry
;
struct
inode
*
inode
=
dentry
->
d_inode
;
nfs_readdir_descriptor_t
my_desc
,
*
desc
=
&
my_desc
;
struct
nfs_open_dir_context
*
dir_ctx
=
fil
p
->
private_data
;
struct
nfs_open_dir_context
*
dir_ctx
=
fil
e
->
private_data
;
int
res
;
dfprintk
(
FILE
,
"NFS: readdir(%s/%s) starting at cookie %llu
\n
"
,
dentry
->
d_parent
->
d_name
.
name
,
dentry
->
d_name
.
name
,
(
long
long
)
filp
->
f_
pos
);
(
long
long
)
ctx
->
pos
);
nfs_inc_stats
(
inode
,
NFSIOS_VFSGETDENTS
);
/*
*
filp->f_
pos points to the dirent entry number.
*
ctx->
pos points to the dirent entry number.
* *desc->dir_cookie has the cookie for the next entry. We have
* to either find the entry with the appropriate number or
* revalidate the cookie.
*/
memset
(
desc
,
0
,
sizeof
(
*
desc
));
desc
->
file
=
filp
;
desc
->
file
=
file
;
desc
->
ctx
=
ctx
;
desc
->
dir_cookie
=
&
dir_ctx
->
dir_cookie
;
desc
->
decode
=
NFS_PROTO
(
inode
)
->
decode_dirent
;
desc
->
plus
=
nfs_use_readdirplus
(
inode
,
filp
)
?
1
:
0
;
desc
->
plus
=
nfs_use_readdirplus
(
inode
,
ctx
)
?
1
:
0
;
nfs_block_sillyrename
(
dentry
);
res
=
nfs_revalidate_mapping
(
inode
,
fil
p
->
f_mapping
);
res
=
nfs_revalidate_mapping
(
inode
,
fil
e
->
f_mapping
);
if
(
res
<
0
)
goto
out
;
...
...
@@ -840,7 +839,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* This means either end of directory */
if
(
*
desc
->
dir_cookie
&&
desc
->
eof
==
0
)
{
/* Or that the server has 'lost' a cookie */
res
=
uncached_readdir
(
desc
,
dirent
,
filldir
);
res
=
uncached_readdir
(
desc
);
if
(
res
==
0
)
continue
;
}
...
...
@@ -857,7 +856,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if
(
res
<
0
)
break
;
res
=
nfs_do_filldir
(
desc
,
dirent
,
filldir
);
res
=
nfs_do_filldir
(
desc
);
if
(
res
<
0
)
break
;
}
while
(
!
desc
->
eof
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录