summaryrefslogtreecommitdiff
path: root/apidoc
diff options
context:
space:
mode:
authorDan Nicholson <nicholson@endlessm.com>2017-10-05 15:25:11 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-12-05 02:32:47 +0000
commit4e78ddd2da4c0a2ced9527ef20a30f8e3b8567b8 (patch)
tree9c3dbf8d1f38461367e39ed56f905f342789be9d /apidoc
parente48262c659722ecac4d46ad6a1e1d8e82cd565cd (diff)
downloadostree-4e78ddd2da4c0a2ced9527ef20a30f8e3b8567b8.tar.gz
lib/repo: Add repo locking mechanism
Currently ostree has no method of guarding against concurrent pruning. When there are multiple repo writers, it's possible to have a pull or commit race against a prune and end up with missing objects. This adds a file based repo locking mechanism. The intention is to take a shared lock when writing objects and an exclusive lock when deleting them. In order to make use of the locking throughout the library in a fine grained fashion, the lock acts recursively with a stack of lock states. If the lock becomes exclusive, it will stay in that state until the stack is unwound past the initial exclusive push. The file locking is similar to GLnxLockFile in that it uses open file descriptor locks but falls back to flock when needed. The lock also attempts to be thread safe by storing the lock state in thread local storage with GPrivate. This means that each thread will have an independent lock for each repository it opens. There are some drawbacks to that, but it seemed impossible to manage the lock state coherently in the face of multithreaded access. The API is a push/pop interface in accordance with the recursive nature of the locking. The push interface uses an enum that's translated to LOCK_SH or LOCK_EX as needed. Both interfaces use an internal timeout field to decide whether to manage the lock in a blocking or non-blocking fashion. The intention is to allow ostree applications as well as administrators to control this timeout. For now, the default is a 30 second timeout. Note that the timeout is handled synchronously in thread since the lock is maintained in thread local storage. I.e., the thread that acquires the lock needs to be the same thread that runs the operation. There may be a way to offer an asynchronous version, but it's not clear exactly how that would work since it would likely involve a separate thread that invokes a callback when the locking operation completes. https://bugzilla.gnome.org/show_bug.cgi?id=759442 Closes: #1343 Approved by: cgwalters
Diffstat (limited to 'apidoc')
-rw-r--r--apidoc/ostree-experimental-sections.txt3
1 files changed, 3 insertions, 0 deletions
diff --git a/apidoc/ostree-experimental-sections.txt b/apidoc/ostree-experimental-sections.txt
index 60daaca5..61f43f28 100644
--- a/apidoc/ostree-experimental-sections.txt
+++ b/apidoc/ostree-experimental-sections.txt
@@ -90,6 +90,9 @@ ostree_repo_finder_override_get_type
<SECTION>
<FILE>ostree-misc-experimental</FILE>
+OstreeRepoLockType
+ostree_repo_lock_push
+ostree_repo_lock_pop
ostree_repo_get_collection_id
ostree_repo_set_collection_id
ostree_validate_collection_id