summaryrefslogtreecommitdiff
path: root/source3/locking/locking.c
AgeCommit message (Collapse)AuthorFilesLines
2010-05-07This patch looks bigger than it is. It does 2 things. 1). Renames smbpid -> ↵Jeremy Allison1-15/+15
smblctx in our locking code. 2). Widens smblctx to 64-bits internally. Preparing to use the SMB2 handle as the locking context. Jeremy.
2010-05-07Make us pass all SMB2 lock tests except MULTIPLE-UNLOCK and CONTEXT. Them ↵Jeremy Allison1-2/+3
next :-). Jeremy.
2010-05-06s3: only include gen_ndr headers where needed.Günther Deschner1-0/+1
This shrinks include/includes.h.gch by the size of 7 MB and reduces build time as follows: ccache build w/o patch real 4m21.529s ccache build with patch real 3m6.402s pch build w/o patch real 4m26.318s pch build with patch real 3m6.932s Guenther
2010-04-30smbd: move printfile_offset() within write_file()Simo Sorce1-0/+6
2010-04-12Move to using 64-bit mid values in our internal open file database.Jeremy Allison1-7/+8
This will allow us to share logic much easier between SMB1 and SMB2 servers. Jeremy
2010-03-15We don't need to treat the token differently in the conn->admin_user case, ↵Jeremy Allison1-11/+0
it should already be pointing to a token with uid == 0. Jeremy.
2010-03-15Rever e80ceb1d7355c8c46a2ed90d5721cf367640f4e8 "Remove more uses of "extern ↵Jeremy Allison1-0/+10
struct current_user current_user;"." As requested by Volker, split this into smaller commits. Jeremy.
2010-03-12Remove more uses of "extern struct current_user current_user;".Jeremy Allison1-10/+0
Use accessor functions to get to this value. Tidies up much of the user context code. Volker, please look at the changes in smbd/uid.c to familiarize yourself with these changes as I think they make the logic in there cleaner. Cause smbd/posix_acls.c code to look at current user context, not stored context on the conn struct - allows correct use of these function calls under a become_root()/unbecome_root() pair. Jeremy.
2010-03-10s3: Fix a long-standing problem with recycled PIDsVolker Lendecke1-1/+1
When a samba server process dies hard, it has no chance to clean up its entries in locking.tdb, brlock.tdb, connections.tdb and sessionid.tdb. For locking.tdb and brlock.tdb Samba is robust by checking every time we read an entry from the database if the corresponding process still exists. If it does not exist anymore, the entry is deleted. This is not 100% failsafe though: On systems with a limited PID space there is a non-zero chance that between the smbd's death and the fresh access, the PID is recycled by another long-running process. This renders all files that had been locked by the killed smbd potentially unusable until the new process also dies. This patch is supposed to fix the problem the following way: Every process ID in every database is augmented by a random 64-bit number that is stored in a serverid.tdb. Whenever we need to check if a process still exists we know its PID and the 64-bit number. We look up the PID in serverid.tdb and compare the 64-bit number. If it's the same, the process still is a valid smbd holding the lock. If it is different, a new smbd has taken over. I believe this is safe against an smbd that has died hard and the PID has been taken over by a non-samba process. This process would not have registered itself with a fresh 64-bit number in serverid.tdb, so the old one still exists in serverid.tdb. We protect against this case by the parent smbd taking care of deregistering PIDs from serverid.tdb and the fact that serverid.tdb is CLEAR_IF_FIRST. CLEAR_IF_FIRST does not work in a cluster, so the automatic cleanup does not work when all smbds are restarted. For this, "net serverid wipe" has to be run before smbd starts up. As a convenience, "net serverid wipedbs" also cleans up sessionid.tdb and connections.tdb. While there, this also cleans up overloading connections.tdb with all the process entries just for messaging_send_all(). Volker
2010-01-12Fix bug #6876 - Delete of an object whose parent folder does not have delete ↵Jeremy Allison1-0/+3
rights fails even if the delete right is set on the object. Final fix for the vfs_acl_xattr and vfs_acl_tdb code. Ensure we can delete a file even if the underlying POSIX permissions don't allow it, if the Windows permissions do. Jeremy.
2009-12-02Remove unneeded argument from can_set_delete_on_close(). EnsureJeremy Allison1-9/+2
can_set_delete_on_close() is correctly called before any setting of the disposition bit (clean up the do_unlink() call). Jeremy.
2009-11-21s3: Cache brlock.tdb entries for the fast read&write strict locking code pathVolker Lendecke1-10/+8
For a netbench run this gains around 2% user-space CPU, fetching a 100MB file takes around 4% less.
2009-11-03s3: Remove debug_ctx()Volker Lendecke1-6/+6
smbd just crashed on me: In a debug message I called a routine preparing a string that itself used debug_ctx. The outer routine also used it after the inner routine had returned. It was still referencing the talloc context that the outer debug_ctx() had given us, which the inner DEBUG had already freed.
2009-09-07s3:smbd: Add the ntstatus to the smb_panic in share_mode_lock_destructorVolker Lendecke1-2/+18
This might help finding why bug 6518 happens
2009-07-20s3: Change fsp->fsp_name to be an smb_filename struct!Tim Prouty1-12/+17
2009-07-08s3: Change the share_mode_lock struct to store a base_name and stream_nameTim Prouty1-29/+64
2009-07-08s3: Make some arguments to (parse|unparse)_share_modes() constTim Prouty1-2/+2
2009-07-07s3: Remove unnecessary const qualifiersTim Prouty1-2/+1
2009-07-06s3 sticky write time: Removed unused args and tighten up a function by ↵Tim Prouty1-1/+2
making an arg const
2009-05-06Fix Coverity ID 897: REVERSE_INULLVolker Lendecke1-1/+1
2009-03-26Fix a scary "fill_share_mode_lock failed" messageVolker Lendecke1-1/+2
To me "fill_share_mode_lock failed" is a "can't happen" alert. There is however a perfectly valid case in get_file_infos() when the file is not open. Change the corresponding debug message to level 10 and explain more.
2009-03-13s3: Add strict lock/unlock calls to the vfs layer to replace is_lockedDave Richards1-35/+55
2009-03-05Last part of fix for #6154 - zfs does not honor admin users.Jeremy Allison1-4/+15
Jeremy.
2009-02-19s3: Add extid to the dev/inode pairTim Prouty1-3/+3
This extends the file_id struct to add an additional generic uint64_t field: extid. For backwards compatibility with dev/inodes stored in xattr_tdbs and acl_tdbs, the ext id is ignored for these databases. This patch should cause no functional change on systems that don't use SMB_VFS_FILE_ID_CREATE to set the extid. Existing code that uses the smb_share_mode library will need to be updated to be compatibile with the new extid.
2009-02-13s3: Fix uninitialized variable warning (and bug).Zack Kirsch1-2/+0
2009-02-13Add VFS ops for Windows BRL: Lock, Unlock and Cancel:Zack Kirsch1-33/+48
This patch adds 3 new VFS OPs for Windows byte range locking: BRL_LOCK_WINDOWS, BRL_UNLOCK_WINDOWS and BRL_CANCEL_WINDOWS. Specifically: * I renamed brl_lock_windows, brl_unlock_windows and brl_lock_cancel to *_default as the default implementations of the VFS ops. * The blocking_lock_record (BLR) is now passed into the brl_lock_windows and brl_cancel_windows paths. The Onefs implementation uses it - future implementations may find it useful too. * Created brl_lock_cancel to do what brl_lock/brl_unlock do: set up a lock_struct and call either the Posix or Windows lock function. These happen to be the same for the default implementation. * Added helper functions: increment_current_lock_count() and decrement_current_lock_count(). * Minor spelling correction in brl_timeout_fn: brl -> blr. * Changed blocking_lock_cancel() to return the BLR that it has cancelled. This allows us to assert its the lock that we wanted to cancel. If this assert ever fires, this path will need to take in the BLR to cancel, rather than choosing on its own. * Adds a small helper function: find_blocking_lock_record_by_id(). Used by the OneFS implementation, but could be useful for others.
2008-12-17Fix bug #5979 - Level 2 oplocks being granted improperly,Jeremy Allison1-1/+10
Jeremy.
2008-12-09s3: [3/3]: Fix a delete on close divergence from windows and the associated ↵Tim Prouty1-45/+1
torture test This third patch cleans up by removing all of the code that is made obsolete by the first patch. It should cause no functional changes.
2008-10-14Use {u,}int64_t instead of SMB_BIG_{U,}INT.Jelmer Vernooij1-10/+10
2008-09-05Fix debug message to show correct function name.Jeremy Allison1-1/+1
Jeremy. (This used to be commit 079c75ef3c169c7a5d81bcaa0b70b6e0df2c464d)
2008-09-05Write times code update.Jeremy Allison1-5/+28
Ok, here's the fix for the write times breakage with the new tests in S4 smbtorture. The key is keeping in the share mode struct the "old_file_time" as the real write time, set by all the write and allocation calls, and the "changed_write_time" as the "sticky" write time - set by the SET_FILE_TIME calls. We can set them independently (although I kept the optimization of not setting the "old_file_time" is a "changed_write_time" was already set, as we'll never see it. This allows us to update the write time immediately on the SMBwrite truncate case, SET_END_OF_FILE and SET_ALLOCATION_SIZE calls, whilst still have the 2 second delay on the "normal" SMBwrite, SMBwriteX calls. I think in a subsequent patch I'd like to change the name of these from "old_file_time" to "write_time" and "changed_write_time" to "sticky_write_time" to make this clearer. I think I also fixed a bug in Metze's original code in that once a write timestamp had been set from a "normal" SMBwriteX call the fsp->update_write_time_triggered variable was set and then never reset - thus meaning the write timestamp would never get updated again on subsequent SMBwriteX's. The new code checks the update_write_time_event event instead, and doesn't update is there's an event already scheduled. Metze especially, please check this over for your understanding. Jeremy. (This used to be commit 6f20585419046c4aca1f7d6c863cf79eb6ae53b0)
2008-07-09Fix alignment problems on sparc, bug 5512Volker Lendecke1-19/+20
Patch successfully tested by Christoph Kaegi <kaph@zhaw.ch>, thanks. (cherry picked from commit 9f8df16f476c49da85000b7365c8a6e33b8b71fc) (This used to be commit 82ed19ff64fc815a8ca9fbd7d3331671ecf5d12b)
2008-05-27Allow server manager to close open files selected by id.Jeremy Allison1-1/+1
Jeremy. (This used to be commit 7eeed8bb41059ec2bddedb6a71deddeec7f33af2)
2008-05-02Remove the "stat_open()" function, flag, and all associated code. It was onlyJeremy Allison1-4/+0
being (correctly) used in the can_read/can_write checks for hide unreadable/unwritable and this is more properly done using the functions in smbd/file_access.c. Preparing to do NT access checks on all file access. Jeremy. (This used to be commit 6bfb06ad95963ae2acb67c4694a98282d3b29faa)
2008-04-07locking: combine get_delete_on_close_flag() and get_write_time() into ↵Stefan Metzmacher1-19/+22
get_file_infos() This means we need to fetch the record only once. metze (This used to be commit 4130b873291d39e363184fe4e38dc1f24ebe5056)
2008-04-07locking: store the write time in the locking.tdbStefan Metzmacher1-14/+82
This is needed to implement the strange write time update logic later. We need to store 2 time timestamps to distinguish between the time the file system had before the first client opened the file and a forced timestamp update. metze (This used to be commit 6aaa2ce0eeb46f6735ec984a2e7aadde7a7f456d)
2008-03-17Merge leftovers of 0e1a86bc845 in 3-0-ctdbVolker Lendecke1-4/+3
(This used to be commit 64b1625f8e3bca43504871747bef6631e1b18f44)
2008-01-12Don't early delete the share mode tdb dataVolker Lendecke1-2/+0
We now refer directly to the file name in the tdb data, so don't delete it. (This used to be commit 71de4946cf00cf8b7bb2f2d92832166bee12e84a)
2008-01-12Trivial simplificationVolker Lendecke1-5/+1
(This used to be commit 616bc34744487450edd47e212a29c0f57eabb722)
2008-01-10Some more talloc_tos()Volker Lendecke1-7/+7
(This used to be commit 444e35e7df1f13fc285183da8fb41b30ad99a3fa)
2008-01-10use talloc_tos in a few more placesVolker Lendecke1-2/+2
(This used to be commit 65dd869bea351010c67f02046ae4134bdada1a4c)
2008-01-07Do not talloc_strdup filename and servicepathVolker Lendecke1-16/+8
(This used to be commit 66be770993acf4e1673e9615bcddb21768c33e62)
2008-01-04allocate share_mode_str only when neededVolker Lendecke1-1/+4
(This used to be commit a98693bfa7bfe72ffa164d21b3e9636e268708aa)
2007-12-10Tiny simplificationsVolker Lendecke1-10/+14
locking.c:open_read_only was unused don't export the silly boolean flag locking_init(bool read_only) (This used to be commit 2f3c865707010bc7c463a02782dbee3dc2479da1)
2007-12-10Remove a staticVolker Lendecke1-11/+9
(This used to be commit 1f317f471af72f8bbc6c9fdd3e79a27c59e6fb6e)
2007-11-18Add a commentVolker Lendecke1-1/+7
(This used to be commit 144014096a41de293ce7ec15f82681a469dd3aa1)
2007-11-18Fix a valgrind errorVolker Lendecke1-3/+4
(This used to be commit b82120f9b7f5aad83d8b4ece0261e9693eedca0c)
2007-11-15Add MAX_DNS_NAME_LENGTH, remove more pstrings.Jeremy Allison1-9/+9
Jeremy. (This used to be commit a1725f4ff7ed375808c78ac661b539557748d0a5)
2007-10-18RIP BOOL. Convert BOOL -> bool. I found a few interestingJeremy Allison1-26/+26
bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f)
2007-10-10r25055: Add file_id_string_tosVolker Lendecke1-2/+2
This removes file_id_string_static and file_id_string_static2 (This used to be commit 638c848c9afe374feb30e34c494f89b2a6c64f7b)