summaryrefslogtreecommitdiff
path: root/source3/lib
Commit message (Collapse)AuthorAgeFilesLines
* s3:lib/time: remove TIME_T_MIN/MAX definesBjörn Jacke2010-05-171-8/+0
| | | | | | | | we already get them from lib/util/time.h (cherry picked from commit f5729dbb6e720cb6076ea053f1ad0680259e6b39) The last two patches address bug #7352 (TIME_T_MAX defines inconsistent). (cherry picked from commit 3668914ce12d0dc5a2f84159a8bd3e82a2ca32a1)
* s3: Remove the unused parameter "persistent" from fetch_locked_internal ↵Volker Lendecke2010-04-011-8/+2
| | | | | | | (cherry picked from commit a5db27936e9c6aad99300ea46808481803f57e08) The last 32 patches address bug #7232 (CTDB persistent transactions are racy). (cherry picked from commit f3ade095089d242484afd0f7fdbcc7826c311368)
* s3: db->persistent==true was handled earlier, make this more obvious (cherry ↵Volker Lendecke2010-04-011-1/+1
| | | | | | picked from commit c7835a4845bbc7e4d340a75229866b2d4946f6eb) (cherry picked from commit a3b71fc3b903d23e0866d7c7779a96dc81450dca)
* s3: Add "g_lock_do" as a convenience wrapper function (cherry picked from ↵Volker Lendecke2010-04-011-0/+64
| | | | | | commit 79100c242153ea174a4405afd45cbf635da313aa) (cherry picked from commit 5423a2cc8138db852fefa133a7da53dc5abf1961)
* s3: Fix timeout calculation if g_lock_lock is given a timeout < 60sVolker Lendecke2010-04-011-1/+6
| | | | | | Detected while showing this code to obnox :-) (cherry picked from commit f8b246e44c819b909b23b4b98ef0999c84d2f4ff) (cherry picked from commit f73b306797f354d0a24ff8af40b05d6151e52a06)
* s3: Slightly increase parallelism in g_lockVolker Lendecke2010-04-011-1/+7
| | | | | | | There's no need to still hold the g_lock tdb-level lock while telling the waiters to retry (cherry picked from commit 83542d973ca771353109c7da4b0391d6ba910f53) (cherry picked from commit eb15655fe1fb71fb7145ce9f479cc112a459f72e)
* s3: Avoid starving locks when many processes die at the same timeVolker Lendecke2010-04-011-6/+4
| | | | | | | | | In g_lock_unlock we have a little race between the process_exists and messaging_send call: We only send to 5 waiters now, they all might have died between us checking their existence and sending the message. This change makes g_lock_lock retry at least once every minute. (cherry picked from commit be919d6faed198cdc29322a4d9491946c0b044b3) (cherry picked from commit c5babceaa95fd163f785e1dfe5521b93402e06a3)
* s3: Avoid a thundering herd in g_lock_unlockVolker Lendecke2010-04-011-1/+16
| | | | | | | | Only notify the first 5 pending lock waiters. This avoids a thundering herd problem that is really nasty in a cluster. It also makes acquiring a lock a bit more FIFO, lock waiters are added to the end of the array. (cherry picked from commit 725b3654f831fbe0388cc09f46269903c9eef1d7) (cherry picked from commit 7e787c513e47875e7dbfc195d8bd1cecec3f08ce)
* s3: Optimize g_lock_lock for a heavily contended caseVolker Lendecke2010-04-011-3/+36
| | | | | | | | Only check the existence of the lock owner in g_lock_parse, check the rest of the records only when we got the lock successfully. This reduces the load on process_exists which can involve a network roundtrip in the clustered case. (cherry picked from commit 07978bd175395e0dc770f68fff5b8bd8b0fdeb51) (cherry picked from commit 9673c93933624ae6e02e83dae3c19351edfd301a)
* s3: Fix handling of processes that died in g_lockVolker Lendecke2010-04-011-3/+5
| | | | | | | g_lock_parse might have thrown away entries from the locks array because the processes were not around anymore. Don't store the orphaned entries. (cherry picked from commit f3bdb163f461175c50b4930fa3464beaee30f4a8) (cherry picked from commit b2677d82dc5c6bc76b0343d90ec75972b5b2a8bf)
* s3: Fix a typo (cherry picked from commit ↵Volker Lendecke2010-04-011-1/+1
| | | | | | bac235dd302570850bb25194ff4bd39b6d653f0d) (cherry picked from commit 8d4a14f3aa04812cd81aa4d56b878169dc41899c)
* Fix warning messages on compile in g_lock.c Volker & Michael please check.Jeremy Allison2010-04-011-14/+4
| | | | | | Jeremy. (cherry picked from commit 10e54fb422d9f1ae6d33e5fabbf8c651b0e57a8c) (cherry picked from commit d0ce7072bd89d11bb63b1fa976305d7087dcb9af)
* s3:g_lock: remove a nested event loop, replacing the inner loop by selectMichael Adam2010-04-011-38/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This made smbd crash in g_lock_lock() when trying to start a transaction on a db with an already started transaction, e.g. in a tcon_and_X where the share_info.tdb was not yet initialized but share_info.tdb was already locked by another process or writing acces to the winreg rpc pipe where the registry tdb was already locked by another process. What we really _want_ to do here by design is to react to MSG_DBWRAP_G_LOCK_RETRY messages that are either sent by a client doing g_lock_unlock or by ourselves when we receive a CTDB_SRVID_SAMBA_NOTIFY or CTDB_SRVID_RECONFIGURE message from ctdbd, i.e. when either a client holding a lock or a complete node has died. Doing this properly involves calling tevent_loop_once(), but doing this here with the main ctdbd messaging context creates a nested event loop when g_lock_lock() is called from the main event loop. So as a quick fix, we act a little corasely here: we do a select on the ctdb connection fd and when it is readable or we get EINTR, then we retry without actually parsing any ctdb packages or dispatching messages. This means that we retry more often than necessary and intended by design, but this does not harm and it is unobtrusive. When we have finished, the main loop will pick up all the messages and ctdb packets. The only extra twist is that we cannot use timed events here but have to handcode a timeout for select. Michael (cherry picked from commit 83fffbeb44441a87569e543054af21d975eb20ae) (cherry picked from commit 0a030b0de66e84f35637699377e44a083c445fa2)
* s3:ctdb_conn: add ctdbd_conn_get_fd() to get the fd out of the ctdb connectionMichael Adam2010-04-011-0/+5
| | | | | | Michael (cherry picked from commit e4af0bc5af2c3ee025ca7fac251c3672ba2c8dd5) (cherry picked from commit 84505cb3157d23b6df170bf694cd6adecc1fe9f5)
* s3:g_lock: remove an unreached code path.Michael Adam2010-04-011-4/+0
| | | | | | Michael (cherry picked from commit 8e306b51b79d3dacd68be9f13aa8455e2eb4c03f) (cherry picked from commit 77e4a72902856cd6c1f635dc3a952f846522b7d0)
* s3:dbwrap_ctdb: fix reading/storing of special key __db_sequence_number__Michael Adam2010-04-011-4/+2
| | | | | | | | | The key for reading and writing was inconsistent due to a off by one data length. Michael (cherry picked from commit 1933214108d1a71bc6473a696ce35020a427d8f4) (cherry picked from commit c17daced42b3ea78fa8e6f6afc8c2550cac53ca0)
* s3:dbwrap_ctdb: exit early when nothing has been written in transaction_commit.Michael Adam2010-04-011-5/+9
| | | | | | | | | | | | | This skips update of the __db_sequence_number__ record when nothing else has been written. There are transactions that are just openend and then nothing is written until transaction_commit is called. This is for instance the case with registry initialization routines: They start a transaction and only write somthing when the registry has not been initialized yet. So this change will skip many db_seqnum bumps and TRANS3_COMMIT roundtrips. Michael (cherry picked from commit c311697aded87ce624d40cbf14e05d6e6377c257) (cherry picked from commit 6f325fb6b092da554180218d1cbb42181f90bbfa)
* s3:dbwrap_ctdb: fix brown paperbag bug in ctdb_transaction_commit.Michael Adam2010-04-011-1/+1
| | | | | | | | | | I carefully prepared the return value only to "return 0;" at the bottom. :-( This may well have hit us for instance in the nested cancel case and produced random errors. Michael (cherry picked from commit 1d594bd734a2f7146ed52872456a16c5e41816f1) (cherry picked from commit 7fc2b612b8f77751effadcd53800c96e83e76418)
* s3:dbwrap_ctdb: fix logic error in pull_newest_from_marshall_buffer().Michael Adam2010-04-011-1/+5
| | | | | | | | | | | | | The logic bug was that if a record was found in the marshall buffer, then always the ctdb header of tha last record in the marshall buffer was returned, and not the ctdb header of the last occurrence of the requested record. This is fixed by introducing an additional temporary variable. Michael (cherry picked from commit 524072b56bf659002410a817749bf86fe6f51e83) (cherry picked from commit e5cc0e718863d6cfaa59fbb4cac7d9b70fba0381)
* s3:dbwrap_ctdb: fix an uninitialized variable.Michael Adam2010-04-011-1/+1
| | | | | | Michael (cherry picked from commit 1505b69dea6044a13a59f672e22f5833256cb981) (cherry picked from commit 89cb10de5ec46384c5ae8d558ac29e4f9e00e8a1)
* s3:dbwrap_ctdb: fix two "may be used uninitialized" warningsMichael Adam2010-04-011-0/+3
| | | | | | Michael (cherry picked from commit fb981cdb8282d3b9b46d9ca515a5685add232a72) (cherry picked from commit dfbc45f6d6ef2fb99652992e291b1bf5276dec28)
* s3:dbwrap_ctdb: fix db_ctdb_fetch_db_seqnum_from_db() when NT_STATUS_NOT_FOUND.Michael Adam2010-04-011-1/+5
| | | | | | | | Don't treat this as an error but return seqnum 0 instead. Michael (cherry picked from commit 10a44ee6930bb51b4b20ce42f35bc455ac1b7293) (cherry picked from commit 8926082d096b2a6e8688b1668bd7293632ebb508)
* s3:dbwrap_ctdb: maintain a database sequence number that bumps in transactionsMichael Adam2010-04-011-5/+116
| | | | | | | | | | | | | | | | | | | | | | | | For persistent databases, 64bit integer is kept in a special record __db_sequence_number__. This record is incremented with each completed transaction. The retry mechanism for failing TRANS3_COMMIT controls inside the db_ctdb_transaction_commit() function now relies one a modified behaviour of ctdbd's treatment of persistent databases in recoveries. Recently, a special treatment for persistent databases had been introduced in ctdb (1.0.108) to work around the problems with the orinal design of persistent transactions. Now with the rewrite we need to revert to the old behaviour that ctdb always takes the newest copies of all records. This change also paves the way for a next step, which will make recovery use the db seqnum to tell which node has the newest copy of a persistent db and use that node's copy. This will greatly reduce the amount of data transferred with each recovery. Michael (cherry picked from commit 3fe7ce141d6afe3825b06c5feb90558911e4df1e) (cherry picked from commit cfdf2d76878ee1ba32b2cb89f9ed740386990530)
* s3:dbwrap_ctdb: change db_ctdb_transaction_store() to return NTSTATUS.Michael Adam2010-04-011-18/+12
| | | | | | | | | The return values calculated by the callers were wrong anyways since the new marshalling code does not set the local tdbs tdb error code. Michael (cherry picked from commit 26225d3e798892b39b3c238b0bee465bffac6550) (cherry picked from commit 06943fe1e6982c9df4886ee0a17572e502726897)
* s3:dbwrap_ctdb: update (C)Michael Adam2010-04-011-1/+2
| | | | | | Michael (cherry picked from commit 5a0c42770b349877928a2b3fd8316903dd62e5b7) (cherry picked from commit 60aabc946ed981efe7e37bb2b39307e82dd20fcc)
* s3:dbwrap_ctdb: start rewrite of transactions using the global lock (g_lock)Michael Adam2010-04-011-320/+160
| | | | | | | | | | | | | | | | | | This simplifies the transaction code a lot: * transaction_start essentially consists of acquiring a global lock. * No write operations at all are performed on the local database until the transaction is committed: Every store operation is just going into the marshall buffer. * The commit operation calls a new simplified TRANS3_COMMIT control in ctdb which rolls out thae changes to all nodes including the node that is performing the transaction. Michael (cherry picked from commit 16bc6ba2268e3660d026076264de8666356e00bf) (cherry picked from commit c2354aa193617ffc3e4036fe0b9034c2664901fd)
* s3: Add ctdb_conn_msg_ctx() (cherry picked from commit ↵Volker Lendecke2010-04-011-0/+5
| | | | | | 12abab711b58237ddccfa1d9bb526f8c7dbb6e9f) (cherry picked from commit 803cf6da0bb93760902e6118952d73967d6fcdff)
* s3: Implement global locks in a g_lock tdbVolker Lendecke2010-04-012-5/+662
| | | | | | | | This is the basis to implement global locks in ctdb without depending on a shared file system. The initial goal is to make ctdb persistent transactions deterministic without too many timeouts. (cherry picked from commit 4c1c3f2549f32fd069e0e7bf3aec299213f1e85b) (cherry picked from commit 98873e0d6a38abdcaed48af6504a9a39a23ae027)
* s3-brlock: we don't need these MSG_SMB_UNLOCK calls nowAndrew Tridgell2010-04-011-8/+0
| | | | | | These have been replaced with the min timeout in blocking.c (cherry picked from commit 74267d652485cdcb711f734f0d80da0fb1495867) (cherry picked from commit 6a78929fd0543e027912346c30e6208b4a1f4362)
* s3-events: make the old timed events compatible with teventAndrew Tridgell2010-04-011-2/+19
| | | | | | | | | | | | | | tevent ensures that a timed event is only called once. The old events code relied on the called handler removing the event itself. If the handler removed the event after calling a function which invoked the event loop then the timed event could loop forever. This change makes the two timed event systems more compatible, by allowing the handler to free the te if it wants to, but ensuring it is off the linked list of events before the handler is called, and ensuring it is freed even if the handler doesn't free it. (cherry picked from commit 5dbf175c75bd6139f3238f36665000641f7f7f79) (cherry picked from commit 380e86e0f9c9314f4f69528227668dbbb222b144)
* Revert "Fix bug #7067 - Linux asynchronous IO (aio) can cause smbd to fail ↵samba-3.5.1Karolin Seeger2010-03-081-61/+4
| | | | | | | | to respond to a read or write." This reverts commit a6ae7a552f851a399991262377cc0e062e40ac20. This fixes bug #7222 (All users have full rigths on all shares) (CVE-2010-0728).
* Fix bug #7067 - Linux asynchronous IO (aio) can cause smbd to fail to ↵Jeremy Allison2010-02-101-4/+61
| | | | | | | | | | | respond to a read or write. Only works on Linux kernels 2.6.26 and above. Grants CAP_KILL capability to allow Linux threads under different euids to send signals to each other. Jeremy. (cherry picked from commit 899bd0005f56dcc1e95c3988d41ab3f628bb15db) (cherry picked from commit b30792299e8fc2057c4e825c2f9457a54096852a)
* s3: add libnetapi_set_use_ccache()Volker Lendecke2010-01-263-0/+16
| | | | (cherry picked from commit b99ab82ebab598b45eb6729498c9e67b195e698d)
* s3: Add -C (--use-ccache) to popt_common_credentialsVolker Lendecke2010-01-262-1/+16
| | | | (cherry picked from commit 58ebc50663a299e16684aa24cfae95954d5a14f0)
* s3:smbldap: add smbldap_talloc_first_attribute()Stefan Metzmacher2010-01-251-0/+34
| | | | | | | | | metze Signed-off-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit c992127f8a96c37940a6d298c7c6859c47f83d9b) (cherry picked from commit 915b7552b71904baf6a452bdc1649e76d8286a14) (cherry picked from commit 009877922e65e5872218e83fba0d0f2a230dec2e)
* s3: add LDAP Alias Dereferencing supportBjörn Jacke2009-12-141-0/+11
| | | | | | | | | Thanks to Dan Cox for initial patch for 3.0. This closes #2350. The default for "ldap deref" is "auto" which means the LDAP library's default behaviour will be used and samba does not set any dereferencing parameter by itself. (cherry picked from commit 8adbc166b230b37ff18ba70f2280a9a729240ff1)
* s3: make sys_posix_fallocate more genericBjörn Jacke2009-12-141-4/+4
| | | | | this is in preparation for other preallocation methods to be introduced. (cherry picked from commit 39be2d18a24176b9300834a0552180cdfb11ca5f)
* s3: check if glibc has broken posix_fallocateBjörn Jacke2009-12-081-1/+1
| | | | (cherry picked from commit 5062e190ed27e16145d9275533b6dd5bcb10209e)
* s3: let gencache_init() use tdb_check()Stefan Metzmacher2009-12-081-0/+25
| | | | | | | | | | | If the check fails we try to clear the tdb and start with an empty cache. metze (cherry picked from commit 909cd2617fa1c170183664af1fc4253af2dc2f21) Signed-off-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit 1a17c8ffe0f17138e45b57a82d5b4a3c73628bca)
* s3: let tdb_validate_child() use tdb_check()Stefan Metzmacher2009-12-081-0/+11
| | | | | | | | metze (cherry picked from commit 6f6608c2aa6122c87ea1e8a937708d08e6c5785e) Signed-off-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit 66847adf072606e6519a1de1ede3aa26d9e041ba)
* s3:dbwrap_ctdb: increase the number of commit retries 5-->100Michael Adam2009-12-081-1/+1
| | | | | | | | | This is to cope with timeouts when recoveries and transactions collide. Maybe 100 is too hight, but 10 or even 20 have been too low in a very busy environment. Michael (cherry picked from commit 97eb53b432e8b16e55b0dccac7acbb2e40467dc6)
* s3:dbwrap_ctdb: increase the rsn of the __transaction_lock__ when storingMichael Adam2009-12-081-0/+2
| | | | | | | | so that it is correctly handled by recoveries. Also set the dmaster explicitly. Michael (cherry picked from commit 8e4f774bff9926567006cdc263fa76fd8b703b63)
* s3: Fix explicit stat64 supportVolker Lendecke2009-12-081-3/+12
| | | | (cherry picked from commit c81f6e519e1f976fce0896fa7b9e29c412411e13)
* Restructure the ACL code some more, get the internal semanticsJeremy Allison2009-12-081-0/+20
| | | | | | | | | | | | | | | | | | | right. The previous bugs were due to the fact that get_nt_acl_internal() could return an NTSTATUS error if there was no stored ACL blob, but otherwise would return the underlying ACL from the filysystem. Fix this so it always returns a valid acl if it can, and if it does not its an error to be reported back to the client. This then changes the inherit acl code. Previously we were trying to match Windows by setting a minimal ACL on a new file that didn't inherit anything from a parent directory. This is silly - the returned ACL wouldn't match the underlying UNIX permissions. The current code will correctly inherit from a parent if a parent has any inheritable ACE entries that apply to the new object, but will return a mapping from the underlying UNIX permissions if the parent has no inheritable entries. This makes much more sense for new files/directories. Jeremy. (cherry picked from commit 365c6b4ce0bd84bfb1d9cec03bc835b92b1c5af7) (cherry picked from commit 3e1afbbae79ee23c6f3b701ae3bcb57156049787)
* s3: prefer posix_fallocate for doing "strict allocate"Björn Jacke2009-12-081-0/+14
| | | | | | | | | | | | | | | | | posix_fallocate is more efficient than manual zero'ing the file. When preallocation in kernel space is supported it's extremely fast. Support for preallocation at fs layer via posix_fallocate and fallocate at kernel site can be found in Linux kernel 2.6.23/glibc 2.10 with ext4, XFS and OCFS2. Other systems that I know of which support fast preallocation in kernel space are AIX 6.1 with JFS2 and recent Solaris versions with ZFS maybe UFS2, too. People who have a system with preallocation in kernel space might want to set "strict allocate = yes". This reduces file fragentation and it's also safer for setups with quota being turned on. As of today most systems still don't have preallocation in kernel space, and that's why "strict allocate = no" will stay the default for now. (cherry picked from commit a1991b17cdb38b1bffa32d2386132ae01f827cd0)
* s3: Move directory_exist_stat to testparm.c, it only looks at the modeVolker Lendecke2009-12-081-21/+0
| | | | (cherry picked from commit f216509a4004cc3d7920e9ef25160222166299a6)
* s3: Pass fake_dir_create_times down to file_exist_stat, none of the callers ↵Volker Lendecke2009-12-081-2/+3
| | | | | | look at the mtime (cherry picked from commit 6d432d4db84427345c03438eb656b3f387288988)
* s3: "get_file_size" only looks at the sizeVolker Lendecke2009-12-081-1/+1
| | | | (cherry picked from commit dd82e9d503a1547aaef8ef600cb6224440234c1d)
* s3: "socket_exist" only looks at the modeVolker Lendecke2009-12-081-1/+1
| | | | (cherry picked from commit 581a33494ae98282238d069c2874a0a46c3624be)
* s3: "sys_path_to_bdev" only looks at the devicenumberVolker Lendecke2009-12-081-4/+3
| | | | (cherry picked from commit 8a79bc673c5ee980a2389f47e32306848989af2a)