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
55157dfb
Commit
55157dfb
authored
Feb 28, 2012
by
Pavel Shilovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CIFS: Separate protocol specific part from getlk
Signed-off-by:
Pavel Shilovsky
<
piastry@etersoft.ru
>
parent
106dc538
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
22 deletions
+39
-22
fs/cifs/cifsglob.h
fs/cifs/cifsglob.h
+2
-0
fs/cifs/file.c
fs/cifs/file.c
+30
-22
fs/cifs/smb1ops.c
fs/cifs/smb1ops.c
+7
-0
No files found.
fs/cifs/cifsglob.h
View file @
55157dfb
...
...
@@ -156,10 +156,12 @@ enum smb_version {
struct
mid_q_entry
;
struct
TCP_Server_Info
;
struct
cifsFileInfo
;
struct
smb_version_operations
{
int
(
*
send_cancel
)(
struct
TCP_Server_Info
*
,
void
*
,
struct
mid_q_entry
*
);
bool
(
*
compare_fids
)(
struct
cifsFileInfo
*
,
struct
cifsFileInfo
*
);
};
struct
smb_version_values
{
...
...
fs/cifs/file.c
View file @
55157dfb
...
...
@@ -671,7 +671,7 @@ cifs_del_lock_waiters(struct cifsLockInfo *lock)
static
bool
cifs_find_fid_lock_conflict
(
struct
cifsFileInfo
*
cfile
,
__u64
offset
,
__u64
length
,
__u8
type
,
__u16
netfid
,
__u64
length
,
__u8
type
,
struct
cifsFileInfo
*
cur
,
struct
cifsLockInfo
**
conf_lock
)
{
struct
cifsLockInfo
*
li
;
...
...
@@ -682,8 +682,8 @@ cifs_find_fid_lock_conflict(struct cifsFileInfo *cfile, __u64 offset,
offset
>=
li
->
offset
+
li
->
length
)
continue
;
else
if
((
type
&
server
->
vals
->
shared_lock_type
)
&&
((
netfid
==
cfile
->
netfid
&&
current
->
tgid
==
li
->
pid
)
||
type
==
li
->
type
))
((
server
->
ops
->
compare_fids
(
cur
,
cfile
)
&&
current
->
tgid
==
li
->
pid
)
||
type
==
li
->
type
))
continue
;
else
{
*
conf_lock
=
li
;
...
...
@@ -694,17 +694,17 @@ cifs_find_fid_lock_conflict(struct cifsFileInfo *cfile, __u64 offset,
}
static
bool
cifs_find_lock_conflict
(
struct
cifsInodeInfo
*
cinode
,
__u64
offset
,
__u64
length
,
__u8
type
,
__u16
netfid
,
struct
cifsLockInfo
**
conf_lock
)
cifs_find_lock_conflict
(
struct
cifsFileInfo
*
cfile
,
__u64
offset
,
__u64
length
,
__u8
type
,
struct
cifsLockInfo
**
conf_lock
)
{
bool
rc
=
false
;
struct
cifsFileInfo
*
fid
,
*
tmp
;
struct
cifsInodeInfo
*
cinode
=
CIFS_I
(
cfile
->
dentry
->
d_inode
);
spin_lock
(
&
cifs_file_list_lock
);
list_for_each_entry_safe
(
fid
,
tmp
,
&
cinode
->
openFileList
,
flist
)
{
rc
=
cifs_find_fid_lock_conflict
(
fid
,
offset
,
length
,
type
,
netfid
,
conf_lock
);
cfile
,
conf_lock
);
if
(
rc
)
break
;
}
...
...
@@ -732,8 +732,8 @@ cifs_lock_test(struct cifsFileInfo *cfile, __u64 offset, __u64 length,
mutex_lock
(
&
cinode
->
lock_mutex
);
exist
=
cifs_find_lock_conflict
(
c
inod
e
,
offset
,
length
,
type
,
cfile
->
netfid
,
&
conf_lock
);
exist
=
cifs_find_lock_conflict
(
c
fil
e
,
offset
,
length
,
type
,
&
conf_lock
);
if
(
exist
)
{
flock
->
fl_start
=
conf_lock
->
offset
;
flock
->
fl_end
=
conf_lock
->
offset
+
conf_lock
->
length
-
1
;
...
...
@@ -779,8 +779,8 @@ cifs_lock_add_if(struct cifsFileInfo *cfile, struct cifsLockInfo *lock,
exist
=
false
;
mutex_lock
(
&
cinode
->
lock_mutex
);
exist
=
cifs_find_lock_conflict
(
c
inod
e
,
lock
->
offset
,
lock
->
length
,
lock
->
type
,
cfile
->
netfid
,
&
conf_lock
);
exist
=
cifs_find_lock_conflict
(
c
fil
e
,
lock
->
offset
,
lock
->
length
,
lock
->
type
,
&
conf_lock
);
if
(
!
exist
&&
cinode
->
can_cache_brlcks
)
{
list_add_tail
(
&
lock
->
llist
,
&
cfile
->
llist
);
mutex_unlock
(
&
cinode
->
lock_mutex
);
...
...
@@ -1116,6 +1116,15 @@ cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock,
cFYI
(
1
,
"Unknown type of lock"
);
}
static
int
cifs_mandatory_lock
(
int
xid
,
struct
cifsFileInfo
*
cfile
,
__u64
offset
,
__u64
length
,
__u32
type
,
int
lock
,
int
unlock
,
bool
wait
)
{
return
CIFSSMBLock
(
xid
,
tlink_tcon
(
cfile
->
tlink
),
cfile
->
netfid
,
current
->
tgid
,
length
,
offset
,
unlock
,
lock
,
(
__u8
)
type
,
wait
,
0
);
}
static
int
cifs_getlk
(
struct
file
*
file
,
struct
file_lock
*
flock
,
__u32
type
,
bool
wait_flag
,
bool
posix_lck
,
int
xid
)
...
...
@@ -1149,12 +1158,11 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
return
rc
;
/* BB we could chain these into one lock request BB */
rc
=
CIFSSMBLock
(
xid
,
tcon
,
netfid
,
current
->
tgid
,
length
,
flock
->
fl_start
,
0
,
1
,
type
,
0
,
0
);
rc
=
cifs_mandatory_lock
(
xid
,
cfile
,
flock
->
fl_start
,
length
,
type
,
1
,
0
,
false
);
if
(
rc
==
0
)
{
rc
=
CIFSSMBLock
(
xid
,
tcon
,
netfid
,
current
->
tgid
,
length
,
flock
->
fl_start
,
1
,
0
,
type
,
0
,
0
);
rc
=
cifs_mandatory_lock
(
xid
,
cfile
,
flock
->
fl_start
,
length
,
type
,
0
,
1
,
false
);
flock
->
fl_type
=
F_UNLCK
;
if
(
rc
!=
0
)
cERROR
(
1
,
"Error unlocking previously locked "
...
...
@@ -1167,13 +1175,13 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
return
0
;
}
rc
=
CIFSSMBLock
(
xid
,
tcon
,
netfid
,
current
->
tgid
,
length
,
flock
->
fl_start
,
0
,
1
,
type
|
server
->
vals
->
shared_lock_type
,
0
,
0
);
rc
=
cifs_mandatory_lock
(
xid
,
cfile
,
flock
->
fl_start
,
length
,
type
|
server
->
vals
->
shared_lock_type
,
1
,
0
,
false
);
if
(
rc
==
0
)
{
rc
=
CIFSSMBLock
(
xid
,
tcon
,
netfid
,
current
->
tgid
,
length
,
flock
->
fl_start
,
1
,
0
,
type
|
server
->
vals
->
shared_lock_type
,
0
,
0
);
rc
=
cifs_mandatory_lock
(
xid
,
cfile
,
flock
->
fl_start
,
length
,
type
|
server
->
vals
->
shared_lock_type
,
0
,
1
,
false
);
flock
->
fl_type
=
F_RDLCK
;
if
(
rc
!=
0
)
cERROR
(
1
,
"Error unlocking previously locked "
...
...
fs/cifs/smb1ops.c
View file @
55157dfb
...
...
@@ -60,8 +60,15 @@ send_nt_cancel(struct TCP_Server_Info *server, void *buf,
return
rc
;
}
static
bool
cifs_compare_fids
(
struct
cifsFileInfo
*
ob1
,
struct
cifsFileInfo
*
ob2
)
{
return
ob1
->
netfid
==
ob2
->
netfid
;
}
struct
smb_version_operations
smb1_operations
=
{
.
send_cancel
=
send_nt_cancel
,
.
compare_fids
=
cifs_compare_fids
,
};
struct
smb_version_values
smb1_values
=
{
...
...
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