Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
f0dd2136
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
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看板
提交
f0dd2136
编写于
6月 22, 2005
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[PATCH] NFS: Clean up readdir changes.
Signed-off-by:
N
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
上级
00a92642
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
39 deletion
+48
-39
fs/nfs/dir.c
fs/nfs/dir.c
+48
-37
fs/nfs/inode.c
fs/nfs/inode.c
+0
-1
include/linux/nfs_fs.h
include/linux/nfs_fs.h
+0
-1
未找到文件。
fs/nfs/dir.c
浏览文件 @
f0dd2136
...
@@ -51,8 +51,10 @@ static int nfs_mknod(struct inode *, struct dentry *, int, dev_t);
...
@@ -51,8 +51,10 @@ static int nfs_mknod(struct inode *, struct dentry *, int, dev_t);
static
int
nfs_rename
(
struct
inode
*
,
struct
dentry
*
,
static
int
nfs_rename
(
struct
inode
*
,
struct
dentry
*
,
struct
inode
*
,
struct
dentry
*
);
struct
inode
*
,
struct
dentry
*
);
static
int
nfs_fsync_dir
(
struct
file
*
,
struct
dentry
*
,
int
);
static
int
nfs_fsync_dir
(
struct
file
*
,
struct
dentry
*
,
int
);
static
loff_t
nfs_llseek_dir
(
struct
file
*
,
loff_t
,
int
);
struct
file_operations
nfs_dir_operations
=
{
struct
file_operations
nfs_dir_operations
=
{
.
llseek
=
nfs_llseek_dir
,
.
read
=
generic_read_dir
,
.
read
=
generic_read_dir
,
.
readdir
=
nfs_readdir
,
.
readdir
=
nfs_readdir
,
.
open
=
nfs_opendir
,
.
open
=
nfs_opendir
,
...
@@ -141,9 +143,8 @@ typedef struct {
...
@@ -141,9 +143,8 @@ typedef struct {
struct
page
*
page
;
struct
page
*
page
;
unsigned
long
page_index
;
unsigned
long
page_index
;
u32
*
ptr
;
u32
*
ptr
;
u64
target_cookie
;
u64
*
dir_cookie
;
int
target_index
;
loff_t
current_index
;
int
current_index
;
struct
nfs_entry
*
entry
;
struct
nfs_entry
*
entry
;
decode_dirent_t
decode
;
decode_dirent_t
decode
;
int
plus
;
int
plus
;
...
@@ -227,7 +228,7 @@ void dir_page_release(nfs_readdir_descriptor_t *desc)
...
@@ -227,7 +228,7 @@ void dir_page_release(nfs_readdir_descriptor_t *desc)
/*
/*
* Given a pointer to a buffer that has already been filled by a call
* Given a pointer to a buffer that has already been filled by a call
* to readdir, find the next entry with cookie '
desc->target
_cookie'.
* to readdir, find the next entry with cookie '
*desc->dir
_cookie'.
*
*
* If the end of the buffer has been reached, return -EAGAIN, if not,
* If the end of the buffer has been reached, return -EAGAIN, if not,
* return the offset within the buffer of the next entry to be
* return the offset within the buffer of the next entry to be
...
@@ -241,8 +242,8 @@ int find_dirent(nfs_readdir_descriptor_t *desc)
...
@@ -241,8 +242,8 @@ int find_dirent(nfs_readdir_descriptor_t *desc)
status
;
status
;
while
((
status
=
dir_decode
(
desc
))
==
0
)
{
while
((
status
=
dir_decode
(
desc
))
==
0
)
{
dfprintk
(
VFS
,
"NFS: found cookie %Lu
\n
"
,
(
long
long
)
entry
->
cookie
);
dfprintk
(
VFS
,
"NFS: found cookie %Lu
\n
"
,
(
unsigned
long
long
)
entry
->
cookie
);
if
(
entry
->
prev_cookie
==
desc
->
target
_cookie
)
if
(
entry
->
prev_cookie
==
*
desc
->
dir
_cookie
)
break
;
break
;
if
(
loop_count
++
>
200
)
{
if
(
loop_count
++
>
200
)
{
loop_count
=
0
;
loop_count
=
0
;
...
@@ -255,7 +256,7 @@ int find_dirent(nfs_readdir_descriptor_t *desc)
...
@@ -255,7 +256,7 @@ int find_dirent(nfs_readdir_descriptor_t *desc)
/*
/*
* Given a pointer to a buffer that has already been filled by a call
* Given a pointer to a buffer that has already been filled by a call
* to readdir, find the entry at offset 'desc->
target_index
'.
* to readdir, find the entry at offset 'desc->
file->f_pos
'.
*
*
* If the end of the buffer has been reached, return -EAGAIN, if not,
* If the end of the buffer has been reached, return -EAGAIN, if not,
* return the offset within the buffer of the next entry to be
* return the offset within the buffer of the next entry to be
...
@@ -273,10 +274,10 @@ int find_dirent_index(nfs_readdir_descriptor_t *desc)
...
@@ -273,10 +274,10 @@ int find_dirent_index(nfs_readdir_descriptor_t *desc)
if
(
status
)
if
(
status
)
break
;
break
;
dfprintk
(
VFS
,
"NFS: found cookie %Lu at index %
d
\n
"
,
(
long
long
)
entry
->
cookie
,
desc
->
current_index
);
dfprintk
(
VFS
,
"NFS: found cookie %Lu at index %
Ld
\n
"
,
(
unsigned
long
long
)
entry
->
cookie
,
desc
->
current_index
);
if
(
desc
->
target_index
==
desc
->
current_index
)
{
if
(
desc
->
file
->
f_pos
==
desc
->
current_index
)
{
desc
->
target
_cookie
=
entry
->
cookie
;
*
desc
->
dir
_cookie
=
entry
->
cookie
;
break
;
break
;
}
}
desc
->
current_index
++
;
desc
->
current_index
++
;
...
@@ -314,7 +315,7 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
...
@@ -314,7 +315,7 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
/* NOTE: Someone else may have changed the READDIRPLUS flag */
/* NOTE: Someone else may have changed the READDIRPLUS flag */
desc
->
page
=
page
;
desc
->
page
=
page
;
desc
->
ptr
=
kmap
(
page
);
/* matching kunmap in nfs_do_filldir */
desc
->
ptr
=
kmap
(
page
);
/* matching kunmap in nfs_do_filldir */
if
(
desc
->
target_cookie
)
if
(
*
desc
->
dir_cookie
!=
0
)
status
=
find_dirent
(
desc
);
status
=
find_dirent
(
desc
);
else
else
status
=
find_dirent_index
(
desc
);
status
=
find_dirent_index
(
desc
);
...
@@ -332,8 +333,8 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
...
@@ -332,8 +333,8 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
* Recurse through the page cache pages, and return a
* Recurse through the page cache pages, and return a
* filled nfs_entry structure of the next directory entry if possible.
* filled nfs_entry structure of the next directory entry if possible.
*
*
* The target for the search is '
desc->target
_cookie' if non-0,
* The target for the search is '
*desc->dir
_cookie' if non-0,
* 'desc->
target_index
' otherwise
* 'desc->
file->f_pos
' otherwise
*/
*/
static
inline
static
inline
int
readdir_search_pagecache
(
nfs_readdir_descriptor_t
*
desc
)
int
readdir_search_pagecache
(
nfs_readdir_descriptor_t
*
desc
)
...
@@ -341,18 +342,15 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
...
@@ -341,18 +342,15 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
int
loop_count
=
0
;
int
loop_count
=
0
;
int
res
;
int
res
;
if
(
desc
->
target_cookie
)
dfprintk
(
VFS
,
"NFS: readdir_search_pagecache() searching for cookie %Lu
\n
"
,
(
long
long
)
desc
->
target_cookie
);
else
dfprintk
(
VFS
,
"NFS: readdir_search_pagecache() searching for cookie number %d
\n
"
,
desc
->
target_index
);
/* Always search-by-index from the beginning of the cache */
/* Always search-by-index from the beginning of the cache */
if
(
!
(
desc
->
target_cookie
))
{
if
(
*
desc
->
dir_cookie
==
0
)
{
dfprintk
(
VFS
,
"NFS: readdir_search_pagecache() searching for offset %Ld
\n
"
,
(
long
long
)
desc
->
file
->
f_pos
);
desc
->
page_index
=
0
;
desc
->
page_index
=
0
;
desc
->
entry
->
cookie
=
desc
->
entry
->
prev_cookie
=
0
;
desc
->
entry
->
cookie
=
desc
->
entry
->
prev_cookie
=
0
;
desc
->
entry
->
eof
=
0
;
desc
->
entry
->
eof
=
0
;
desc
->
current_index
=
0
;
desc
->
current_index
=
0
;
}
}
else
dfprintk
(
VFS
,
"NFS: readdir_search_pagecache() searching for cookie %Lu
\n
"
,
(
unsigned
long
long
)
*
desc
->
dir_cookie
);
for
(;;)
{
for
(;;)
{
res
=
find_dirent_page
(
desc
);
res
=
find_dirent_page
(
desc
);
...
@@ -386,7 +384,6 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
...
@@ -386,7 +384,6 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
struct
file
*
file
=
desc
->
file
;
struct
file
*
file
=
desc
->
file
;
struct
nfs_entry
*
entry
=
desc
->
entry
;
struct
nfs_entry
*
entry
=
desc
->
entry
;
struct
dentry
*
dentry
=
NULL
;
struct
dentry
*
dentry
=
NULL
;
struct
nfs_open_context
*
ctx
=
file
->
private_data
;
unsigned
long
fileid
;
unsigned
long
fileid
;
int
loop_count
=
0
,
int
loop_count
=
0
,
res
;
res
;
...
@@ -415,7 +412,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
...
@@ -415,7 +412,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
if
(
res
<
0
)
if
(
res
<
0
)
break
;
break
;
file
->
f_pos
++
;
file
->
f_pos
++
;
desc
->
target
_cookie
=
entry
->
cookie
;
*
desc
->
dir
_cookie
=
entry
->
cookie
;
if
(
dir_decode
(
desc
)
!=
0
)
{
if
(
dir_decode
(
desc
)
!=
0
)
{
desc
->
page_index
++
;
desc
->
page_index
++
;
break
;
break
;
...
@@ -425,12 +422,10 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
...
@@ -425,12 +422,10 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
schedule
();
schedule
();
}
}
}
}
ctx
->
dir_pos
=
file
->
f_pos
;
ctx
->
dir_cookie
=
desc
->
target_cookie
;
dir_page_release
(
desc
);
dir_page_release
(
desc
);
if
(
dentry
!=
NULL
)
if
(
dentry
!=
NULL
)
dput
(
dentry
);
dput
(
dentry
);
dfprintk
(
VFS
,
"NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d
\n
"
,
(
long
long
)
desc
->
target
_cookie
,
res
);
dfprintk
(
VFS
,
"NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d
\n
"
,
(
unsigned
long
long
)
*
desc
->
dir
_cookie
,
res
);
return
res
;
return
res
;
}
}
...
@@ -456,14 +451,14 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
...
@@ -456,14 +451,14 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
struct
page
*
page
=
NULL
;
struct
page
*
page
=
NULL
;
int
status
;
int
status
;
dfprintk
(
VFS
,
"NFS: uncached_readdir() searching for cookie %Lu
\n
"
,
(
long
long
)
desc
->
target
_cookie
);
dfprintk
(
VFS
,
"NFS: uncached_readdir() searching for cookie %Lu
\n
"
,
(
unsigned
long
long
)
*
desc
->
dir
_cookie
);
page
=
alloc_page
(
GFP_HIGHUSER
);
page
=
alloc_page
(
GFP_HIGHUSER
);
if
(
!
page
)
{
if
(
!
page
)
{
status
=
-
ENOMEM
;
status
=
-
ENOMEM
;
goto
out
;
goto
out
;
}
}
desc
->
error
=
NFS_PROTO
(
inode
)
->
readdir
(
file
->
f_dentry
,
cred
,
desc
->
target
_cookie
,
desc
->
error
=
NFS_PROTO
(
inode
)
->
readdir
(
file
->
f_dentry
,
cred
,
*
desc
->
dir
_cookie
,
page
,
page
,
NFS_SERVER
(
inode
)
->
dtsize
,
NFS_SERVER
(
inode
)
->
dtsize
,
desc
->
plus
);
desc
->
plus
);
...
@@ -472,7 +467,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
...
@@ -472,7 +467,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
desc
->
ptr
=
kmap
(
page
);
/* matching kunmap in nfs_do_filldir */
desc
->
ptr
=
kmap
(
page
);
/* matching kunmap in nfs_do_filldir */
if
(
desc
->
error
>=
0
)
{
if
(
desc
->
error
>=
0
)
{
if
((
status
=
dir_decode
(
desc
))
==
0
)
if
((
status
=
dir_decode
(
desc
))
==
0
)
desc
->
entry
->
prev_cookie
=
desc
->
target
_cookie
;
desc
->
entry
->
prev_cookie
=
*
desc
->
dir
_cookie
;
}
else
}
else
status
=
-
EIO
;
status
=
-
EIO
;
if
(
status
<
0
)
if
(
status
<
0
)
...
@@ -501,7 +496,6 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
...
@@ -501,7 +496,6 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
{
struct
dentry
*
dentry
=
filp
->
f_dentry
;
struct
dentry
*
dentry
=
filp
->
f_dentry
;
struct
inode
*
inode
=
dentry
->
d_inode
;
struct
inode
*
inode
=
dentry
->
d_inode
;
struct
nfs_open_context
*
ctx
=
filp
->
private_data
;
nfs_readdir_descriptor_t
my_desc
,
nfs_readdir_descriptor_t
my_desc
,
*
desc
=
&
my_desc
;
*
desc
=
&
my_desc
;
struct
nfs_entry
my_entry
;
struct
nfs_entry
my_entry
;
...
@@ -519,21 +513,16 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
...
@@ -519,21 +513,16 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/*
/*
* filp->f_pos points to the dirent entry number.
* filp->f_pos points to the dirent entry number.
*
ctx->dir_pos has the number of the cached cookie.
We have
*
*desc->dir_cookie has the cookie for the next entry.
We have
* to either find the entry with the appropriate number or
* to either find the entry with the appropriate number or
* revalidate the cookie.
* revalidate the cookie.
*/
*/
memset
(
desc
,
0
,
sizeof
(
*
desc
));
memset
(
desc
,
0
,
sizeof
(
*
desc
));
desc
->
file
=
filp
;
desc
->
file
=
filp
;
desc
->
dir_cookie
=
&
((
struct
nfs_open_context
*
)
filp
->
private_data
)
->
dir_cookie
;
desc
->
decode
=
NFS_PROTO
(
inode
)
->
decode_dirent
;
desc
->
decode
=
NFS_PROTO
(
inode
)
->
decode_dirent
;
desc
->
plus
=
NFS_USE_READDIRPLUS
(
inode
);
desc
->
plus
=
NFS_USE_READDIRPLUS
(
inode
);
desc
->
target_index
=
filp
->
f_pos
;
if
(
filp
->
f_pos
==
ctx
->
dir_pos
)
desc
->
target_cookie
=
ctx
->
dir_cookie
;
else
desc
->
target_cookie
=
0
;
my_entry
.
cookie
=
my_entry
.
prev_cookie
=
0
;
my_entry
.
cookie
=
my_entry
.
prev_cookie
=
0
;
my_entry
.
eof
=
0
;
my_entry
.
eof
=
0
;
...
@@ -546,7 +535,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
...
@@ -546,7 +535,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if
(
res
==
-
EBADCOOKIE
)
{
if
(
res
==
-
EBADCOOKIE
)
{
/* This means either end of directory */
/* This means either end of directory */
if
(
desc
->
target_cookie
&&
desc
->
entry
->
cookie
!=
desc
->
target
_cookie
)
{
if
(
*
desc
->
dir_cookie
&&
desc
->
entry
->
cookie
!=
*
desc
->
dir
_cookie
)
{
/* Or that the server has 'lost' a cookie */
/* Or that the server has 'lost' a cookie */
res
=
uncached_readdir
(
desc
,
dirent
,
filldir
);
res
=
uncached_readdir
(
desc
,
dirent
,
filldir
);
if
(
res
>=
0
)
if
(
res
>=
0
)
...
@@ -579,6 +568,28 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
...
@@ -579,6 +568,28 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
return
0
;
return
0
;
}
}
loff_t
nfs_llseek_dir
(
struct
file
*
filp
,
loff_t
offset
,
int
origin
)
{
down
(
&
filp
->
f_dentry
->
d_inode
->
i_sem
);
switch
(
origin
)
{
case
1
:
offset
+=
filp
->
f_pos
;
case
0
:
if
(
offset
>=
0
)
break
;
default:
offset
=
-
EINVAL
;
goto
out
;
}
if
(
offset
!=
filp
->
f_pos
)
{
filp
->
f_pos
=
offset
;
((
struct
nfs_open_context
*
)
filp
->
private_data
)
->
dir_cookie
=
0
;
}
out:
up
(
&
filp
->
f_dentry
->
d_inode
->
i_sem
);
return
offset
;
}
/*
/*
* All directory operations under NFS are synchronous, so fsync()
* All directory operations under NFS are synchronous, so fsync()
* is a dummy operation.
* is a dummy operation.
...
...
fs/nfs/inode.c
浏览文件 @
f0dd2136
...
@@ -891,7 +891,6 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rp
...
@@ -891,7 +891,6 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rp
ctx
->
state
=
NULL
;
ctx
->
state
=
NULL
;
ctx
->
lockowner
=
current
->
files
;
ctx
->
lockowner
=
current
->
files
;
ctx
->
error
=
0
;
ctx
->
error
=
0
;
ctx
->
dir_pos
=
0
;
ctx
->
dir_cookie
=
0
;
ctx
->
dir_cookie
=
0
;
}
}
return
ctx
;
return
ctx
;
...
...
include/linux/nfs_fs.h
浏览文件 @
f0dd2136
...
@@ -85,7 +85,6 @@ struct nfs_open_context {
...
@@ -85,7 +85,6 @@ struct nfs_open_context {
struct
list_head
list
;
struct
list_head
list
;
int
dir_pos
;
/* Directory cookie cache */
__u64
dir_cookie
;
__u64
dir_cookie
;
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录