Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etercifs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etercifs
Commits
f930818f
Commit
f930818f
authored
Jul 27, 2009
by
Evgeny Sinelnikov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
centos52: revert POSIX locks behavior during close using storage_lock
parent
e576cc68
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
253 deletions
+50
-253
Makefile
sources/centos52/Makefile
+1
-1
cifs_lock_storage.c
sources/centos52/cifs_lock_storage.c
+0
-211
cifs_lock_storage.h
sources/centos52/cifs_lock_storage.h
+0
-36
cifsfs.c
sources/centos52/cifsfs.c
+0
-2
file.c
sources/centos52/file.c
+49
-3
No files found.
sources/centos52/Makefile
View file @
f930818f
...
...
@@ -3,4 +3,4 @@
#
obj-$(CONFIG_CIFS)
+=
etercifs.o
etercifs-objs
:=
cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o readdir.o ioctl.o sess.o export.o
cifs_lock_storage.o
etercifs-objs
:=
cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o readdir.o ioctl.o sess.o export.o
sources/centos52/cifs_lock_storage.c
deleted
100644 → 0
View file @
e576cc68
/*
* fs/cifs/cifs_lock_storage.c
*
* lock tree operations that provide posix behaviour on windows server
*
* Author(s): Pavel Shilovsky (piastryyy@gmail.com), Copyright (C) 2009.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <linux/ctype.h>
#include <linux/kthread.h>
#include <linux/random.h>
#include "cifspdu.h"
#include "cifsglob.h"
#include "cifsproto.h"
#include "cifs_unicode.h"
#include "cifs_debug.h"
#include "cifs_fs_sb.h"
#include "cifs_lock_storage.h"
struct
cifsPidTreeLock
{
struct
list_head
lock_list
;
__u8
type
;
__u64
offset
;
__u64
len
;
__u16
fid
;
unsigned
long
inodeId
;
};
struct
cifsPidTree
{
struct
cifsPidTree
*
left
,
*
right
;
__u64
priority
;
__u32
pid
;
struct
list_head
lock_list
;
};
static
struct
cifsPidTree
*
LOCK_STORAGE
;
static
struct
mutex
storage_mutex
;
static
__u32
cifsRandStart
;
static
__u32
cifs_random
(
void
)
{
return
cifsRandStart
=
(
8253729
*
cifsRandStart
+
2396403
);
}
void
cifs_lock_storage_init
(
void
)
{
mutex_init
(
&
storage_mutex
);
LOCK_STORAGE
=
NULL
;
cifsRandStart
=
jiffies
;
}
static
int
vertex_init
(
struct
cifsPidTree
**
root
,
__u32
pid
)
{
(
*
root
)
=
kmalloc
(
sizeof
(
struct
cifsPidTree
),
GFP_KERNEL
);
if
((
*
root
)
==
NULL
)
{
return
-
ENOMEM
;
}
(
*
root
)
->
pid
=
pid
;
(
*
root
)
->
left
=
(
*
root
)
->
right
=
NULL
;
(
*
root
)
->
priority
=
((
cifs_random
()
<<
16
)
^
cifs_random
());
INIT_LIST_HEAD
(
&
(
*
root
)
->
lock_list
);
return
0
;
}
static
void
cifs_pid_tree_split
(
struct
cifsPidTree
*
root
,
struct
cifsPidTree
**
left
,
struct
cifsPidTree
**
right
,
__u32
pid
)
{
if
(
!
root
)
{
(
*
left
)
=
(
*
right
)
=
NULL
;
return
;
}
if
(
pid
<=
root
->
pid
)
{
(
*
right
)
=
root
;
cifs_pid_tree_split
(
root
->
left
,
left
,
&
((
*
right
)
->
left
),
pid
);
}
else
{
(
*
left
)
=
root
;
cifs_pid_tree_split
(
root
->
right
,
&
((
*
left
)
->
right
),
right
,
pid
);
}
}
static
struct
cifsPidTree
*
cifs_pid_tree_merge
(
struct
cifsPidTree
*
left
,
struct
cifsPidTree
*
right
)
{
struct
cifsPidTree
*
result
=
NULL
;
if
(
!
left
)
{
return
right
;
}
if
(
!
right
)
{
return
left
;
}
if
(
left
->
priority
<=
right
->
priority
)
{
result
=
right
;
result
->
left
=
cifs_pid_tree_merge
(
left
,
right
->
left
);
}
else
{
result
=
left
;
result
->
right
=
cifs_pid_tree_merge
(
left
->
right
,
right
);
}
return
result
;
}
static
struct
cifsPidTree
**
cifs_pid_tree_find_pid
(
struct
cifsPidTree
**
root
,
__u32
pid
)
{
if
(
!
(
*
root
))
{
return
root
;
}
if
(
pid
==
(
*
root
)
->
pid
)
{
return
root
;
}
else
if
(
pid
<
(
*
root
)
->
pid
)
{
return
cifs_pid_tree_find_pid
(
&
((
*
root
)
->
left
),
pid
);
}
else
{
return
cifs_pid_tree_find_pid
(
&
((
*
root
)
->
right
),
pid
);
}
}
static
int
__cifs_lock_storage_add_lock
(
struct
cifsPidTree
**
root
,
__u32
pid
,
unsigned
long
inodeId
,
__u16
fid
,
__u64
offset
,
__u64
len
,
__u8
type
)
{
struct
cifsPidTreeLock
*
new_lock
=
NULL
;
int
rc
=
0
;
struct
cifsPidTree
**
exist
=
NULL
;
exist
=
cifs_pid_tree_find_pid
(
root
,
pid
);
new_lock
=
kmalloc
(
sizeof
(
struct
cifsPidTreeLock
),
GFP_KERNEL
);
if
(
new_lock
==
NULL
)
{
return
-
ENOMEM
;
}
new_lock
->
offset
=
offset
;
new_lock
->
len
=
len
;
new_lock
->
type
=
type
;
new_lock
->
fid
=
fid
;
new_lock
->
inodeId
=
inodeId
;
if
(
!
(
*
exist
))
{
struct
cifsPidTree
*
left
=
NULL
,
*
right
=
NULL
,
*
new_item
=
NULL
;
rc
=
vertex_init
(
&
new_item
,
pid
);
if
(
rc
)
{
kfree
(
&
new_lock
);
return
rc
;
}
list_add
(
&
new_lock
->
lock_list
,
&
new_item
->
lock_list
);
cifs_pid_tree_split
((
*
root
),
&
left
,
&
right
,
pid
);
(
*
root
)
=
cifs_pid_tree_merge
(
left
,
new_item
);
(
*
root
)
=
cifs_pid_tree_merge
((
*
root
),
right
);
}
else
{
list_add
(
&
new_lock
->
lock_list
,
&
(
*
exist
)
->
lock_list
);
}
return
rc
;
}
static
int
__cifs_lock_storage_del_lock
(
int
xid
,
struct
cifsTconInfo
*
pTcon
,
struct
cifsPidTree
**
root
,
__u32
pid
,
unsigned
long
inodeId
,
__u64
offset
,
__u64
len
,
__u8
type
)
{
struct
cifsPidTree
**
exist
;
int
rc
=
0
;
struct
cifsPidTreeLock
*
li
,
*
tmp
;
exist
=
cifs_pid_tree_find_pid
(
root
,
pid
);
if
(
!
(
*
exist
))
{
return
-
1
;
}
list_for_each_entry_safe
(
li
,
tmp
,
&
(
*
exist
)
->
lock_list
,
lock_list
)
{
if
(
li
->
offset
>=
offset
&&
(
li
->
offset
+
li
->
len
<=
offset
+
len
)
&&
(
inodeId
==
li
->
inodeId
))
{
int
tmp_rc
=
CIFSSMBLock
(
xid
,
pTcon
,
li
->
fid
,
li
->
len
,
li
->
offset
,
1
,
0
,
li
->
type
,
FALSE
);
if
(
tmp_rc
)
{
rc
=
tmp_rc
;
}
else
{
list_del
(
&
li
->
lock_list
);
kfree
(
li
);
}
}
}
if
(
list_empty
(
&
((
*
exist
)
->
lock_list
)))
{
struct
cifsPidTree
*
temp
;
temp
=
(
*
exist
);
(
*
exist
)
=
cifs_pid_tree_merge
((
*
exist
)
->
left
,
(
*
exist
)
->
right
);
kfree
(
temp
);
}
return
rc
;
}
int
cifs_lock_storage_add_lock
(
__u32
pid
,
unsigned
long
inodeId
,
__u16
fid
,
__u64
offset
,
__u64
len
,
__u8
type
)
{
int
rc
;
mutex_lock
(
&
storage_mutex
);
rc
=
__cifs_lock_storage_add_lock
(
&
LOCK_STORAGE
,
pid
,
inodeId
,
fid
,
offset
,
len
,
type
);
mutex_unlock
(
&
storage_mutex
);
return
rc
;
}
int
cifs_lock_storage_del_lock
(
int
xid
,
struct
cifsTconInfo
*
pTcon
,
__u32
pid
,
unsigned
long
inodeId
,
__u64
offset
,
__u64
len
,
__u8
type
)
{
int
rc
;
mutex_lock
(
&
storage_mutex
);
rc
=
__cifs_lock_storage_del_lock
(
xid
,
pTcon
,
&
LOCK_STORAGE
,
pid
,
inodeId
,
offset
,
len
,
type
);
mutex_unlock
(
&
storage_mutex
);
return
rc
;
}
sources/centos52/cifs_lock_storage.h
deleted
100644 → 0
View file @
e576cc68
/*
* fs/cifs/cifs_lock_storage.h
*
* lock tree operations that provide posix behaviour on windows server
*
* Author(s): Pavel Shilovsky (piastryyy@gmail.com), Copyright (C) 2009.
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef CIFS_LOCK_STORAGE
#define CIFS_LOCK_STORAGE
/* creating lock tree */
void
cifs_lock_storage_init
(
void
);
/* inserting lock */
int
cifs_lock_storage_add_lock
(
__u32
pid
,
unsigned
long
inodeId
,
__u16
fid
,
__u64
offset
,
__u64
len
,
__u8
type
);
/* deleting lock */
int
cifs_lock_storage_del_lock
(
int
xid
,
struct
cifsTconInfo
*
pTcon
,
__u32
pid
,
unsigned
long
inodeId
,
__u64
offset
,
__u64
len
,
__u8
type
);
#endif
sources/centos52/cifsfs.c
View file @
f930818f
...
...
@@ -41,7 +41,6 @@
#include "cifsproto.h"
#include "cifs_debug.h"
#include "cifs_fs_sb.h"
#include "cifs_lock_storage.h"
#include <linux/mm.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
#include <linux/moduleparam.h>
...
...
@@ -1144,7 +1143,6 @@ init_cifs(void)
memset
(
Local_System_Name
,
0
,
15
);
rwlock_init
(
&
GlobalSMBSeslock
);
spin_lock_init
(
&
GlobalMid_Lock
);
cifs_lock_storage_init
();
if
(
cifs_max_pending
<
2
)
{
cifs_max_pending
=
2
;
...
...
sources/centos52/file.c
View file @
f930818f
...
...
@@ -47,7 +47,6 @@
#include "cifs_unicode.h"
#include "cifs_debug.h"
#include "cifs_fs_sb.h"
#include "cifs_lock_storage.h"
static
inline
struct
cifsFileInfo
*
cifs_init_private
(
struct
cifsFileInfo
*
private_data
,
struct
inode
*
inode
,
...
...
@@ -590,6 +589,7 @@ int cifs_close(struct inode *inode, struct file *file)
cifs_sb
=
CIFS_SB
(
inode
->
i_sb
);
pTcon
=
cifs_sb
->
tcon
;
if
(
pSMBFile
)
{
struct
cifsLockInfo
*
li
,
*
tmp
;
pSMBFile
->
closePend
=
TRUE
;
if
(
pTcon
)
{
/* no sense reconnecting to close a file that is
...
...
@@ -619,6 +619,15 @@ int cifs_close(struct inode *inode, struct file *file)
}
}
/* Delete any outstanding lock records.
We'll lose them when the file is closed anyway. */
mutex_lock
(
&
pSMBFile
->
lock_mutex
);
list_for_each_entry_safe
(
li
,
tmp
,
&
pSMBFile
->
llist
,
llist
)
{
list_del
(
&
li
->
llist
);
kfree
(
li
);
}
mutex_unlock
(
&
pSMBFile
->
lock_mutex
);
write_lock
(
&
GlobalSMBSeslock
);
list_del
(
&
pSMBFile
->
flist
);
list_del
(
&
pSMBFile
->
tlist
);
...
...
@@ -717,6 +726,22 @@ int cifs_closedir(struct inode *inode, struct file *file)
return
rc
;
}
static
int
store_file_lock
(
struct
cifsFileInfo
*
fid
,
__u64
len
,
__u64
offset
,
__u8
lockType
)
{
struct
cifsLockInfo
*
li
=
kmalloc
(
sizeof
(
struct
cifsLockInfo
),
GFP_KERNEL
);
if
(
li
==
NULL
)
return
-
ENOMEM
;
li
->
offset
=
offset
;
li
->
length
=
len
;
li
->
type
=
lockType
;
mutex_lock
(
&
fid
->
lock_mutex
);
list_add
(
&
li
->
llist
,
&
fid
->
llist
);
mutex_unlock
(
&
fid
->
lock_mutex
);
return
0
;
}
int
cifs_lock
(
struct
file
*
file
,
int
cmd
,
struct
file_lock
*
pfLock
)
{
int
rc
,
xid
;
...
...
@@ -868,12 +893,33 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
if
(
rc
==
0
)
{
/* For Windows locks we must store them. */
rc
=
cifs_lock_storage_add_lock
(
fid
->
pid
,
fid
->
pInode
->
i_ino
,
fid
->
netfid
,
pfLock
->
fl_start
,
length
,
lockType
);
rc
=
store_file_lock
(
fid
,
length
,
pfLock
->
fl_start
,
lockType
);
}
}
else
if
(
numUnlock
)
{
/* For each stored lock that this unlock overlaps
completely, unlock it. */
rc
=
cifs_lock_storage_del_lock
(
xid
,
pTcon
,
fid
->
pid
,
fid
->
pInode
->
i_ino
,
pfLock
->
fl_start
,
length
,
lockType
);
int
stored_rc
=
0
;
struct
cifsLockInfo
*
li
,
*
tmp
;
rc
=
0
;
mutex_lock
(
&
fid
->
lock_mutex
);
list_for_each_entry_safe
(
li
,
tmp
,
&
fid
->
llist
,
llist
)
{
if
(
pfLock
->
fl_start
<=
li
->
offset
&&
(
pfLock
->
fl_start
+
length
)
>=
(
li
->
offset
+
li
->
length
))
{
stored_rc
=
CIFSSMBLock
(
xid
,
pTcon
,
netfid
,
li
->
length
,
li
->
offset
,
1
,
0
,
li
->
type
,
false
);
if
(
stored_rc
)
rc
=
stored_rc
;
list_del
(
&
li
->
llist
);
kfree
(
li
);
}
}
mutex_unlock
(
&
fid
->
lock_mutex
);
}
}
...
...
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