summaryrefslogtreecommitdiffstats
path: root/src/server/uplink.c
Commit message (Collapse)AuthorAgeFilesLines
* [SERVER] Fix warning on clangSimon Rettberg2019-09-071-6/+1Star
|
* [SERVER] integrity checker: Improve flushing logicSimon Rettberg2019-09-051-1/+1
|
* [SERVER] Move signal init to uplink_initSimon Rettberg2019-09-021-10/+11
| | | | | | | Initializing the signal in the thread lead to a race where we would init the uplink and queue a request for it before the thread actually initialized it. This was not harmful but lead to spurious warnings in the server's log.
* [SERVER] uplink: Don't disable already disabled imageSimon Rettberg2019-09-021-1/+1
|
* [SERVER] uplink: Don't reinit uplink when freeing itSimon Rettberg2019-09-021-13/+3Star
|
* [SERVER] Less debug spam, fix RTT interval calculationSimon Rettberg2019-08-301-3/+5
|
* [SERVER] Introduce debug spamSimon Rettberg2019-08-301-8/+8
|
* [SERVER] No uplink_init when checking working state; improve loggingSimon Rettberg2019-08-301-0/+1
|
* [SERVER] Tear down whole uplink on idle timeoutSimon Rettberg2019-08-291-21/+19Star
| | | | | | Keeping the uplink thread around forever even though we disconnected from the upstream server seems wasteful. Get rid of this and rear down the uplink entirely.
* [SERVER] Use weakref for cache mapsSimon Rettberg2019-08-291-34/+30Star
| | | | | | Gets rid of a bunch of locking, especially the hot path in net.c where clients are requesting data. Many clients unsing the same incomplete image previously created a bottleneck here.
* [SERVER] Fix swapped assignmentSimon Rettberg2019-08-271-1/+1
|
* [SERVER] Use reference counting for uplinkSimon Rettberg2019-08-271-88/+126
| | | | First step towards less locking for proxy mode
* [SERVER] Fix warnings, simplify lockingSimon Rettberg2019-08-261-11/+12
|
* [SERVER] Get rid of alt-servers thread, per-uplink rtt historySimon Rettberg2019-08-221-56/+61
| | | | | | | | | | Alt-Server checks are now run using the threadpool, so we don't need a queue and dedicated thread anymore. The rtt history is now kept per uplink, so many uplinks won't overwhelm the history, making its time window very short. Also the fail counter is now split up; a global one for when the server actually isn't reachable, a local (per-uplink) one for when the server is reachable but doesn't serve the requested image.
* [SERVER] Add struct representing active connection to uplink serverSimon Rettberg2019-08-181-40/+38Star
|
* [SERVER] uplink: More consistent type/variable namingSimon Rettberg2019-08-181-277/+277
| | | | | * Change link to uplink everywhere * dnbd3_connection_t -> dnbd3_uplink_t
* [SERVER] Better lock debugging: Always check lock orderSimon Rettberg2019-08-071-3/+3
| | | | | | Lock order is predefined in locks.h. Immediately bail out if a lock with lower priority is obtained while the same thread already holds one with higher priority.
* [SERVER] Lock-free queue for altservers check threadSimon Rettberg2019-08-071-4/+4
|
* [SERVER] uplink: Improve attaching to existing requestsSimon Rettberg2019-08-061-23/+74
| | | | | Allow attaching in ULR_PROCESSING state, leave lower slots empty to increase chances attaching to ULR_PROCESSING.
* [SERVER] Fix: Client thread could destroy sendMutex while in useSimon Rettberg2019-08-061-0/+3
| | | | | | Fix a race condition where the client thread tears down the client struct including the sendMutex while the uplink thead is currently holding the lock, trying to send data to the client.
* [SERVER] Allow uplink shutdown if bgrMinClients > image->usersSimon Rettberg2019-08-051-1/+2
|
* [SERVER] Turn all spinlocks into mutexesSimon Rettberg2019-07-261-94/+94
| | | | | | | | Just assume sane platforms offer smart mutexes that have a fast-path with spinlocks internally for locks that have little to no congestion. In all other cases, mutexes should perform better anyways.
* [SERVER] uplink: Relay request in client's thread if possibleSimon Rettberg2019-07-231-3/+56
| | | | | Early benchmarking shows that this is faster, since we don't require another thread to wake up just to send out the request.
* [SERVER] Don't shutdown uplink if background replication is FULLSimon Rettberg2019-02-131-1/+1
|
* [SERVER] uplink: Dedicated function for handling link failureSimon Rettberg2019-02-081-31/+50
|
* [SERVER] Don't keep an uplink connection established foreverSimon Rettberg2019-01-311-38/+70
| | | | | | In case we don't use background replication a connection to an uplink server can potentially stay around forever. This in turn would prevent the uplink server from freeing the image as it appears to be in use.
* [SERVER] uplink: Check for _maxPayload when getting client requestSimon Rettberg2019-01-311-0/+4
| | | | | | It didn't make too much sense that we only checked _maxPayload when the reply arrived; simply don't forward a request where we already know we won't handle the reply.
* [SERVER] Fix last block replicating indefinitely in hasblock modeSimon Rettberg2018-08-141-5/+7
|
* [SERVER] Use atomic vars for uplink byte countersSimon Rettberg2018-08-131-26/+4Star
|
* [SERVER] Use atomic var for (total)bytesSent countersSimon Rettberg2018-08-081-2/+0Star
| | | | | | Gets rid of the lastBytesSent field as well as the stats lock per client. Cleaned and split up the messy net_clientsToJson function while at it.
* [SERVER] Add missing file mode to open() callSimon Rettberg2018-07-261-2/+2
|
* [SERVER] Fix use of wrong constant; increase queue len for hash checkerSimon Rettberg2018-07-101-1/+1
|
* [SERVER] Reduce spam some moreSimon Rettberg2018-07-091-1/+1
|
* [SERVER] Introduce backgroundReplication=hashblockSimon Rettberg2018-07-091-33/+121
| | | | | | | | This is a compromise; if you want to validate replicated data fairly quickly, using this option will make background replication only kick in when there's a "dirty" 16M block, i.e. some blocks within a 16M block are cached locally, but not all. Completing the block makes it possible to validate its CRC32 checksum.
* [SERVER] Don't keep bg replication blocks in fs cacheSimon Rettberg2018-07-051-1/+5
| | | | | | Further improving cache handling, don't keep blocks in cache that have been requested via background replication. It's likely these aren't needed in the near future.
* [SERVER] Always use fsync instead of fdatasyncSimon Rettberg2018-07-051-8/+2Star
| | | | | | | | Now that we support sparse files, using just fdatasync isn't safe anymore. Instead of handling both cases differently just drop fdatasync, the difference has probably been marginal all along anyways.
* [SERVER] Refactor uplink/cache handling, improve crc checkingSimon Rettberg2018-07-041-35/+182
| | | | | | | | | | | | | The cacheFd is now moved to the uplink data structure and will only be handled by the uplink thread. The integrity checker now supports checking all blocks of an image. This will be triggered automatically whenever a check for a single block failed. Also, if a crc check on startup fails, the image won't be discarded anymore, but rather a full check will be initiated. Furthermore, when calling image_updateCacheMap() on an image that was previously complete, the cache map will now be re-initialized, and a new uplink connection created.
* [SERVER] Use likely/unlikely in uplink disk writing loopSimon Rettberg2018-06-251-4/+4
|
* [SERVER] Try to re-open cacheFd if writing failsSimon Rettberg2018-06-251-6/+12
| | | | | | | In scenarios where the proxy is using an NFS server as storage (for whatever crazy reason) or when the cacheFd goes bad through e.g. a switchroot, try to re-open it instead of just disabling caching forever.
* [SERVER] Add bgrMinClients: Thresold to control when BGR startsSimon Rettberg2018-04-121-3/+6
| | | | | Background replication will not kick in if there aren't at least that many clients connected.
* [SERVER] More error handling and logging when caching received data to diskSimon Rettberg2018-04-101-4/+13
|
* [SERVER] Experimental support for sparse files in proxy modeSimon Rettberg2018-03-151-1/+10
| | | | | | | | | | | | Will not preallocate images in this mode. Old images are only deleted if the disk is full, determined by write() calls to the cache file yielding ENOSPC or EDQUOT. In such a case, the least recently used image(s) will be deleted to free up at least 256MiB, and then the write() call will be repeated. This *should* work somewhat reliably unless the cache partition is ridiculously small. Performance might suffer a little, and disk fragmentation might occur much faster than in prealloc mode. Testing is needed.
* [SERVER] altservers: Short timeout during RTT measurement, round request rangeSimon Rettberg2017-11-081-4/+7
| | | | | Rounding to 4k so caching works efficiently This should now close #3231
* [SERVER] Add multiple config options for limiting stuffSimon Rettberg2017-11-081-2/+2
| | | | | maxClients, maxImages, maxPayload, maxReplicationSize Refs #3231
* [SERVER] Use multiConnect() to find uplink for replicationSimon Rettberg2017-11-071-1/+1
| | | | | Just as in the fuse client, this will speed things up if we have several alt-servers in our list which are not reachable.
* [SERVER] uplink: Fix updating of global byte counter, fix incremental updatesSimon Rettberg2017-10-251-2/+7
| | | | | Incremental updating of the global byte counter would only work when background replication is disabled. Fix this.
* [SERVER] Improve handling of byte stats countersSimon Rettberg2017-10-251-4/+13
| | | | Less writes to variables, more up-to-date values for uplinks.
* [SERVER] Get rid of zlib dependencySimon Rettberg2017-10-241-3/+3
| | | | | | We only used it for CRC-32, so now the source tree includes a stripped down version of the crc32 code from the zlib project.
* [SERVER] Fix types or add explicit casts everywhere we might have type ↵Simon Rettberg2017-10-241-5/+5
| | | | conversion problems
* [SERVER] Use monotonic clock for measuring timeSimon Rettberg2017-10-191-16/+20
| | | | | Introduces new shared source unit timing.[ch] Closes #3214