Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
a50d68bd
Commit
a50d68bd
authored
Sep 08, 2003
by
Steve French
Committed by
Steve French
Sep 08, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix various SMP/locking problems pointed out by Shoobhit Dayal and Arjan van de Ven
parent
3e753cea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
34 deletions
+119
-34
fs/cifs/AUTHORS
fs/cifs/AUTHORS
+1
-0
fs/cifs/file.c
fs/cifs/file.c
+118
-34
No files found.
fs/cifs/AUTHORS
View file @
a50d68bd
...
...
@@ -20,6 +20,7 @@ Patch Contributors
Zwane Mwaikambo
Andi Kleen
Amrut Joshi
Shobhit Dayal
Test case and Bug Report contributors
-------------------------------------
...
...
fs/cifs/file.c
View file @
a50d68bd
...
...
@@ -207,14 +207,106 @@ int relock_files(struct cifsFileInfo * cifsFile)
return
rc
;
}
static
int
cifs_reopen_file
(
struct
inode
*
inode
,
struct
file
*
file
)
{
int
rc
=
-
EACCES
;
int
xid
,
oplock
;
struct
cifs_sb_info
*
cifs_sb
;
struct
cifsTconInfo
*
pTcon
;
struct
cifsFileInfo
*
pCifsFile
;
struct
cifsInodeInfo
*
pCifsInode
;
char
*
full_path
=
NULL
;
int
desiredAccess
=
0x20197
;
int
disposition
=
FILE_OPEN
;
__u16
netfid
;
FILE_ALL_INFO
*
buf
=
NULL
;
xid
=
GetXid
();
cifs_sb
=
CIFS_SB
(
inode
->
i_sb
);
pTcon
=
cifs_sb
->
tcon
;
full_path
=
build_path_from_dentry
(
file
->
f_dentry
);
cFYI
(
1
,
(
" inode = 0x%p file flags are 0x%x for %s"
,
inode
,
file
->
f_flags
,
full_path
));
if
((
file
->
f_flags
&
O_ACCMODE
)
==
O_RDONLY
)
desiredAccess
=
GENERIC_READ
;
else
if
((
file
->
f_flags
&
O_ACCMODE
)
==
O_WRONLY
)
desiredAccess
=
GENERIC_WRITE
;
else
if
((
file
->
f_flags
&
O_ACCMODE
)
==
O_RDWR
)
desiredAccess
=
GENERIC_ALL
;
if
(
oplockEnabled
)
oplock
=
REQ_OPLOCK
;
else
oplock
=
FALSE
;
/* BB pass O_SYNC flag through on file attributes .. BB */
/* Also refresh inode by passing in file_info buf returned by SMBOpen
and calling get_inode_info with returned buf (at least
helps non-Unix server case */
buf
=
kmalloc
(
sizeof
(
FILE_ALL_INFO
),
GFP_KERNEL
);
if
(
buf
==
0
)
{
if
(
full_path
)
kfree
(
full_path
);
FreeXid
(
xid
);
return
-
ENOMEM
;
}
rc
=
CIFSSMBOpen
(
xid
,
pTcon
,
full_path
,
disposition
,
desiredAccess
,
CREATE_NOT_DIR
,
&
netfid
,
&
oplock
,
buf
,
cifs_sb
->
local_nls
);
if
(
rc
)
{
cFYI
(
1
,
(
"cifs_open returned 0x%x "
,
rc
));
cFYI
(
1
,
(
"oplock: %d "
,
oplock
));
}
else
{
if
(
file
->
private_data
)
{
pCifsFile
=
(
struct
cifsFileInfo
*
)
file
->
private_data
;
pCifsFile
->
netfid
=
netfid
;
pCifsFile
->
invalidHandle
=
FALSE
;
pCifsInode
=
CIFS_I
(
file
->
f_dentry
->
d_inode
);
if
(
pCifsInode
)
{
if
(
pTcon
->
ses
->
capabilities
&
CAP_UNIX
)
rc
=
cifs_get_inode_info_unix
(
&
file
->
f_dentry
->
d_inode
,
full_path
,
inode
->
i_sb
);
else
rc
=
cifs_get_inode_info
(
&
file
->
f_dentry
->
d_inode
,
full_path
,
buf
,
inode
->
i_sb
);
if
(
oplock
==
OPLOCK_EXCLUSIVE
)
{
pCifsInode
->
clientCanCacheAll
=
TRUE
;
pCifsInode
->
clientCanCacheRead
=
TRUE
;
cFYI
(
1
,(
"Exclusive Oplock granted on inode %p"
,
file
->
f_dentry
->
d_inode
));
}
else
if
(
oplock
==
OPLOCK_READ
)
{
pCifsInode
->
clientCanCacheRead
=
TRUE
;
pCifsInode
->
clientCanCacheAll
=
FALSE
;
}
else
{
pCifsInode
->
clientCanCacheRead
=
FALSE
;
pCifsInode
->
clientCanCacheAll
=
FALSE
;
}
}
}
else
rc
=
-
EBADF
;
}
if
(
buf
)
kfree
(
buf
);
if
(
full_path
)
kfree
(
full_path
);
FreeXid
(
xid
);
return
rc
;
}
/* Try to reopen files that were closed when session to server was lost */
int
reopen_files
(
struct
cifsTconInfo
*
pTcon
,
struct
nls_table
*
nlsinfo
)
{
int
rc
=
0
;
struct
cifsFileInfo
*
open_file
=
NULL
;
struct
file
*
file
=
NULL
;
struct
list_head
*
tmp
;
struct
list_head
*
tmp1
;
struct
list_head
invalid_file_list
;
struct
list_head
*
tmp
;
struct
list_head
*
tmp1
;
INIT_LIST_HEAD
(
&
invalid_file_list
);
/* list all files open on tree connection and mark them invalid */
write_lock
(
&
GlobalSMBSeslock
);
...
...
@@ -222,45 +314,37 @@ int reopen_files(struct cifsTconInfo * pTcon, struct nls_table * nlsinfo)
open_file
=
list_entry
(
tmp
,
struct
cifsFileInfo
,
tlist
);
if
(
open_file
)
{
open_file
->
invalidHandle
=
TRUE
;
list_move
(
&
open_file
->
tlist
,
&
invalid_file_list
);
}
}
/* reopen files */
for
(;;)
{
/* BB need to fix above to check list end and skip entries we do not need to reopen */
if
(
list_empty
(
&
pTcon
->
openFileList
))
{
break
;
list_for_each
(
tmp
,
&
invalid_file_list
)
{
/* BB need to fix above to check list end and skip entries we do not need to reopen */
open_file
=
list_entry
(
tmp
,
struct
cifsFileInfo
,
tlist
);
if
(
open_file
==
NULL
)
{
break
;
}
else
{
open_file
=
list_entry
(
tmp
,
struct
cifsFileInfo
,
tlist
);
if
(
open_file
)
{
if
(
open_file
->
invalidHandle
==
FALSE
)
continue
;
if
(
open_file
->
search_resume_name
)
{
kfree
(
open_file
->
search_resume_name
);
}
file
=
open_file
->
pfile
;
list_del
(
&
open_file
->
flist
);
list_del
(
&
open_file
->
tlist
);
kfree
(
open_file
);
if
(
file
)
{
file
->
private_data
=
NULL
;
if
(
file
->
f_dentry
==
0
)
{
cFYI
(
1
,(
"Null dentry for file %p"
,
file
));
}
else
{
write_unlock
(
&
GlobalSMBSeslock
);
rc
=
cifs_open
(
file
->
f_dentry
->
d_inode
,
file
);
write_lock
(
&
GlobalSMBSeslock
);
if
(
rc
)
{
cFYI
(
1
,(
"reconnecting file %s failed with %d"
,
file
->
f_dentry
->
d_name
.
name
,
rc
));
}
else
{
cFYI
(
1
,(
"reconnection of %s succeeded"
,
file
->
f_dentry
->
d_name
.
name
));
}
}
if
(
open_file
->
invalidHandle
==
FALSE
)
{
list_move
(
&
open_file
->
tlist
,
&
pTcon
->
openFileList
);
continue
;
}
file
=
open_file
->
pfile
;
if
(
file
->
f_dentry
==
0
)
{
cFYI
(
1
,(
"Null dentry for file %p"
,
file
));
}
else
{
write_unlock
(
&
GlobalSMBSeslock
);
rc
=
cifs_reopen_file
(
file
->
f_dentry
->
d_inode
,
file
);
write_lock
(
&
GlobalSMBSeslock
);
list_move
(
&
open_file
->
tlist
,
&
pTcon
->
openFileList
);
if
(
rc
)
{
cFYI
(
1
,(
"reconnecting file %s failed with %d"
,
file
->
f_dentry
->
d_name
.
name
,
rc
));
}
else
{
cFYI
(
1
,(
"reconnection of %s succeeded"
,
file
->
f_dentry
->
d_name
.
name
));
}
}
}
}
write_unlock
(
&
GlobalSMBSeslock
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment