summaryrefslogtreecommitdiffstats
path: root/source/locking/locking.c
Commit message (Collapse)AuthorAgeFilesLines
* sync with SAMBA_2_2 for 2.2.6rc1Gerald Carter2002-10-091-1/+1
|
* beginning to sync up for 2.2.5 release....Gerald Carter2002-06-171-3/+4
|
* Start of merge to 2_2_RELEASE branch for release.Jeremy Allison2002-04-301-5/+41
| | | | Jeremy.
* Move over to RELEASE branch.Jeremy Allison2002-02-011-70/+155
| | | | Jeremy.
* Sync-up with SAMBA_2_2 branch.Jeremy Allison2001-10-111-88/+174
| | | | Jeremy.
* Syncup getting ready for release.Jeremy Allison2001-07-061-14/+105
| | | | Jeremy.
* This is a big, rather ugly patch. Whilst investigating the files not truncatedJeremy Allison2001-03-301-32/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | when copying to a full disk problem, I discovered that we were not allowing the delete on close flag to be set properly, this led to other things, and after investigation of the proper delete on close semantics and their relationship to the file_share_delete flag I discovered there were some cases where we weren't doing the deny modes properly. And this after only 5 years working on them..... :-) :-). So here's the latest attempt. I realised the delete on close flag needs to be set across all smbds with a dev/ino pair open - in addition, the delete on close flag, allow share delete and delete access requested all need to be stored in the share mode tdb. The "delete_on_close" entry in the fsp struct is now redundant and should really be removed. This may also mean we can get rid of the "iterate_fsp" calls that I didn't like adding in the first place. Whilst doing this patch, I also discovered we needed to do the se_map_generic() call for file opens and POSIX ACL mapping, so I added that also. This code, although ugly, now passes the deny mode torture tests plus the delete on close tests I added. I do need to add one more multiple connection delete on close test to make sure I got the semantics exactly right, plus we should also (as Andrew suggested) move to random testing here. The good news is that NT should now correctly delete the file on disk full error when copying to a disk :-). Jeremy.
* Dead code removal from SGI compiler.Jeremy Allison2001-03-091-7/+4
| | | | Jeremy.
* - Fix Makefile.in so that clisecdesc.o is in SMBCACLS_OBJ, not LIBSMB_OBJDavid O'Neill2000-12-061-4/+4
| | | | | | | | | Also, fix etags/ctags rules to work when srcdir != builddir - updated configure - compiler warning fixes from APPLIANCE_HEAD (source/lib/util_sec.c source/smbd/vfs-wrap.c) - tdb_chainlock() no longer returns a value. (source/locking/locking.c source/tdb/tdbutil.c source/include/proto.h)
* Changed to sourceforge tdb code. This includes spinlocks (so we now haveJeremy Allison2000-12-051-4/+4
| | | | | | | | a --with-spinlocks option to configure, this does mean the on-disk tdb format has changed, so 2.2alphaX sites will need to re-create their tdb's. The upside is no more tdb fragmentation and a +5% on netbench. Swings and roundabouts.... Jeremy.
* the first cut of the internal messaging system.Andrew Tridgell2000-09-111-1/+1
| | | | | The motivation for this system is to replace the UDP message for oplocks, but this commit only does the "set debug level" message.
* allow posix locking database to be opened read-only (for smbstatus)Andrew Tridgell2000-06-131-1/+1
|
* Using a structure for a tdb key can lead to insideous, hardHerb Lewis2000-05-101-0/+2
| | | | | | | | | | | | | | | | | to find bugs. On 64 bit IRIX, structure packing means that a struct { SMB_DEV_T dev /* 4 bytes */ SMB_INO_T ino /* 8 bytes */ } has 4 bytes of padding between the two members. If you don't null the memory before using it as a tdb key, you randomly can't find keys depending on what is in the padding. This caused me immense pain and was hard to track down.... :-) Jeremy.
* Fix for uninitialized memory read in brlock code. brl_locktest now needsJeremy Allison2000-05-051-1/+1
| | | | | to correctly set the fnum, as the brl_conflict code looks at it. Jeremy.
* Added sys_fork() and sys_getpid() functions to stop the overheadJeremy Allison2000-05-021-8/+8
| | | | | of doing a system call every time we want to just get our pid. Jeremy.
* Ok - this is the *third* implementation of this (third time's the charm :-).Jeremy Allison2000-04-281-628/+13
| | | | | | | | | | | | | | | | | This implementation keeps all POSIX lock records in a separate in memory tdb database only known about in locking/posix.c. In addition, the pending close fd's are also held in a tdb which has an array of fd's indexed by device and inode. The walk-split code uglyness has been moved to posix.c from brlock.c, which is the only place that needs to know about it, and the extra functions hacked into brlock to expose internal state have been removed. This implementation passes smbtorture locktest4, the only thing I need to check now for completeness is what to do about lock upgrade/downgrades which Win32 allows under some *very* strange circumstances. Jeremy.
* Forgot to close when "posix locking" is set to False.Jeremy Allison2000-04-281-2/+5
| | | | Jeremy.
* Added optimization where we are single opener (don't free POSIX locks).Jeremy Allison2000-04-281-1/+21
| | | | Jeremy.
* Made changes suggested by Andrew review.Jeremy Allison2000-04-281-37/+52
| | | | | | | fd_close now calls fd_close_posix() directly. set_posix_lock/release_posix_lock() now handle the reference counting. More changes due when this gets moved to the file locking/posix.c Jeremy.
* Ok - this is more subtle than it looks :-).Jeremy Allison2000-04-271-7/+13
| | | | | | | | | | | | | | | When a file is being closed, once it passes the fnum and tid tests then the locking context should be ignored when removing all locks. This is what is done in the brl close case, but when you have outstanding POSIX locks, then you cannot remove all the brl locks in one go, you have to get the lock list and call do_unlock individually. As this uses global_smbpid as the locking context, you need to make sure that this is set correctly for the specific lock being removed. I now do this by storing the smbpid in each entry in the unlock list returned from the query call. I removed the smbpid from fsp (not needed) and things seem ok (even with the stupid smbpid tricks that smbtorture plays :-). Jeremy.
* Fixed subtle unlocking bug when a file is closed. We need to store theJeremy Allison2000-04-271-6/+5
| | | | | | | | smbpid used when a file was opened in the files_struct. Else we use the wrong global_smbpid when we are closing the file and trying to remove the brl locks - this causes the brl locks to be left when the file is closed as the samba_context check fails. Jeremy.
* Did the rewrite Andrew wanted where all knowledge of POSIX locking isJeremy Allison2000-04-271-5/+179
| | | | | | | | | | removed from the smbd/open.c code. We now use a dlink list of structures indexed by dev/inode to store all pending fd's for close. This could be rewritten to use lib/hash.c if this is discovered to be too slow in use. Andrew, please take a look and let me know if this is what you had in mind. Jeremy.
* Fixed crash bugs Andrew pointed out with LOCK4 smbtortureJeremy Allison2000-04-271-10/+7
| | | | | | | test. Was miscounting posix locks, plus was not taking into account the case where other_fsp == fsp in the 'move locks' case. DOH ! This code will be re-written anyway :-). Jeremy.
* Added the hard code :-).Jeremy Allison2000-04-251-50/+121
| | | | | | | | | | HEAD should now map brl locks correctly into POSIX locks, including the really nasty case of large range unlock. There is a lot of pretty ASCII art in locking/brlock.c explaining exactly how this code works. If it is unclear, please ask me. Jeremy.
* Added the code that keeps fd's open across a close if there are other fsp'sJeremy Allison2000-04-241-36/+23
| | | | | | | | | | | | | | | open on the same dev/inode pair with existing POSIX locks. This is done at the smbd/open layer, so smbd just calls fd_close() and the transfer of any open fd's is done under the covers of fd_close(). When an fsp is closed and no other fsp's open on the same dev/inode pair have existing POSIX locks then all fd's associated with this fsp are closed. Now only the hard part of doing the POSIX range unlock code when read locks overlap remains for full POSIX/SMB lock integration.... Jeremy.
* fixed a locking database bug - it was actually harmless except thatAndrew Tridgell2000-04-231-2/+10
| | | | | smbstatus could display the wrong filename when files change dev/inum after a rename
* This is a *big* checkin that may break some things, but implements theJeremy Allison2000-04-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | new open mechanism Andrew & I discussed. config.sub: configure: Included the QNX patch. include/vfs.h: smbd/vfs-wrap.c: smbd/vfs.c: Added ftruncate vfs call (needed). Note that we will also need locking calls in the vfs (to be added). lib/util_unistr.c: nmbd/nmbd_processlogon.c: Fix for NT domain logons causing nmbd to core dump. Also fix for sidsize DOS bug. locking/locking.c: Check value of ret before using it for memdup. printing/printing.c: Convert print_fsp_open to return an allocated fsp. rpc_server/srv_lsa.c: Fix for NT domain logons. I have removed all use of lp_share_modes() from the code (although I left the parameter in the table for backwards compatibility). It no longer makes sense for this to exist. smbd/close.c: Removed lp_share_modes(). smbd/fileio.c: Fixed parameters to unlock_share_entry call in panic code. smbd/files.c: Correctly set the unix_ERR_code to ERRnofids on fsp allocation fail. smbd/nttrans.c: smbd/reply.c: smbd/trans2.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. smbd/open.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. In addition I have fixed a long standing race condition in the deny mode processing w.r.t. two smbd's creating a file. Andrew, please note that your original idea of using open with O_EXCL in this case would not work (I went over the races very carefully) and so we must re-check deny modes *after* the open() call returns. This is because there is a race between the open with O_EXCL and the lock of the share mode entry. Imagine the case where the first smbd does the open with O_EXCL and a deny mode of DENY_ALL, but is pre-empted before it locks the share modes and creates the deny mode entry for DENY_ALL. A second smbd could then come in with O_RDONLY and a deny mode of DENY_NONE and the two opens would be allowed. The *only* way to fix this race is to lock the share modes after the open and then do the deny mode checks *after* this lock in the case where the file did not originally exist. This code will need extensive testing but seems to initially work. Jeremy.
* locking/locking.c: Fixed placeholder code for POSIX locking.Jeremy Allison2000-04-181-17/+49
| | | | | | | | printing/printing.c: Cast tdb_delete to (tdb_traverse_func) to stop warning. tmpfile gives mirror warning. smbd/groupname.c: Remember to file_lines_free() on exit. tdb/tdb.h: Add tdb_traverse_func typedef. Jeremy
* Typo - missing '}'.Jeremy Allison2000-04-131-0/+1
| | | | Jeremy.
* Removed "ole locking compat" parameter (no longer used).Jeremy Allison2000-04-121-18/+113
| | | | | | We now get/set/check POSIX locks, but I still need to code up the close fd braindamage... Jeremy.
* Implmented mapping of lock offset/count from 64 bit MS rangesJeremy Allison2000-04-121-13/+157
| | | | | | to either 63 or 31 bit POSIX ranges. Code to get these locks not yet added. Jeremy.
* Code to map tdb locks onto POSIX. Mainly placeholder code at the moment,Jeremy Allison2000-04-121-9/+157
| | | | | | but the structure is done enough so that Andrew can look it over and give a yea/nay decision. Jeremy.
* include/byteorder.h: ALIGN4/ALIGN2 macros.Jeremy Allison2000-04-111-3/+3
| | | | | | | | | | | | include/includes.h: Added SMB_BIG_UINT_BITS. lib/util.c: Removed align2/align4 - use macros. libsmb/namequery.c: Use ALIGN2. locking/locking.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T. Needed to move to hiding POSIX locks at a lower layer. nmbd/nmbd_processlogon.c: Use ALIGN2/ALIGN4 macros. smbd/blocking.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T. smbd/reply.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T. Jeremy.
* the first of a bunch of changes to code with getting rid of the fd_ptrAndrew Tridgell2000-04-101-6/+23
| | | | | | element in the fsp pretty mechanical stuff, but it affects lots of files.
* Fixed compile warning in locking.c:traverse_fn()Tim Potter2000-02-071-1/+2
|
* 1) added void* state argument to tdb_traverse. guess what! there wereLuke Leighton2000-02-041-5/+5
| | | | | | | | | | | | | | | | | | two places i found where it was appropriate to _use_ that third argument, in locking.c and brlock.c! there was a static traverse_function and i removed the static variable, typecast it to a void*, passed it to tdb_traverse and re-cast it back to the traverse_function inside the tdb_traverse function. this makes the use of tdb_traverse() reentrant, which is never going to happen, i know, i just don't like to see statics lying about when there's no need for them. as i had to do in samba-tng, all uses of tdb_traverse modified to take the new void* state argument. 2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient. i don't know how the other samba team members would react if i deleted rpcclient from cvs main. damn, that code's so old, it's unreal. 20 rpcclient commands, instead of about 70 in SAMBA_TNG.
* added code to allow traversal of the byte range lock databaseAndrew Tridgell2000-01-161-1/+1
| | | | this is used with "smbstatus -B" to dump the lock list
* damn, Solaris already has a "enum lock_type"Andrew Tridgell2000-01-141-2/+2
| | | | changed it to "enum brl_type"
* we now pass all byte range locking testsAndrew Tridgell2000-01-141-2/+15
| | | | | the last piece was to use a smb timeout slightly larger than the locking timeout in bloking locks to prevent a race
* some more work on the byte range lockingAndrew Tridgell2000-01-141-6/+8
| | | | | | | | note the ugly global_smbpid - I hope that won't bethere for long, I just didn't want to do two lots of major surgery at the one time. Using global_smbpid avoids the big change of getting rid of our inbuf/outbuf interface to reply routines. I'll do that once the locking stuff passes all tests.
* the bulk of the new byte range locking coodeAndrew Tridgell2000-01-131-45/+21
| | | | it doesn't map to posix locks yet, that will come later.
* added the unexpected packet database (unexpected.tdb)Andrew Tridgell2000-01-031-1/+1
| | | | | | | | | | | | this means "nmblookup -S" now always works, even with broken servers the database stores all unexpected replies and these can be accessed by any client. while doing this I cleaned up a couple of functions, and put in place a better trn_id generator. in most places the code got quite a bit simpler due to the addition of simple helper functions. I haven't yet put the code in to take advantage of this for pdc replies - that will be next. Jeremys pdc finding code will then work :)
* - added tdb_flags option to tdb_open()Andrew Tridgell2000-01-021-1/+1
| | | | | | | | | - added TDB_CLEAR_IF_FIRST flag to clear the database if this is the first attached process. Useful for non-persistent databases like our locking area (this will also make upgrades to new database layouts easier) - use lock_path() in a couple of places - leave connections database open while smbd running - cleaned up some tdb code a little, using macros for constants
* when no shares are returned the *shares pointer must be set to nullAndrew Tridgell1999-12-221-0/+2
|
* converted all our existing shared memory code to use a tdb databaseAndrew Tridgell1999-12-211-128/+295
| | | | | | | | | | | | | instead of either sysv or mmap shared memory or lock files. this means we can now completely remove locking_shm.c locking_slow.c shmem.c shmem_sysv.c and lots of other things also got simpler locking.c got a bit larger, but is much better compartmentalised now
* first pass at updating head branch to be to be the same as the SAMBA_2_0 branchAndrew Tridgell1999-12-131-22/+62
|
* Use VFS operations for file I/O.Tim Potter1999-04-041-4/+5
|
* don't core dump in smbstatus if we can't open the shmem systemAndrew Tridgell1998-10-311-0/+1
|
* Reasonably large change to give us *exactly* correct NT delete on close ↵Jeremy Allison1998-10-231-2/+43
| | | | | | | | | | | | | | semantics. This was trickier than it looks :-). Check out the new DELETE_ON_CLOSE flag in the share modes and the new code that iterates through all open files on the same device and inode in files.c and trans2.c Also changed the code that modifies share mode entries to take generic function pointers rather than doing a specific thing so this sort of change should be easier in the future. Jeremy.
* ahh, the joy of deleting large chunks of code that someone else hasAndrew Tridgell1998-09-051-10/+0
| | | | | | | | painstakingly put in :) This gets rid of most of the #ifdef LARGE_SMB_INO_T ifdefs around DEBUG() statements. We just use %.0f in all cases. Makes the code a bit easier to read :)