summaryrefslogtreecommitdiff
path: root/debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-05-06 20:11:04 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-05-06 20:11:04 +0200
commitfa85aba08e005ba948a52b7bc1ac815366c6c84f (patch)
tree88d688da9e161a0621dfa5fc82ba73ecf746f623 /debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch
parentae0724fa46e440015984a6fa213cd26306f55868 (diff)
new lockless refcount patches, disable the old ones
Diffstat (limited to 'debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch')
-rw-r--r--debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch133
1 files changed, 133 insertions, 0 deletions
diff --git a/debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch b/debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch
new file mode 100644
index 00000000..04a9210c
--- /dev/null
+++ b/debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch
@@ -0,0 +1,133 @@
+From 124fef363dfd2326799dc884e4960a14f20b1e09 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Tue, 6 May 2014 18:58:10 +0200
+Subject: [PATCH 3/4] libdiskfs: lock-less reference counting for peropen
+ objects
+
+* libdiskfs/diskfs.h (struct peropen): Use refcount_t for field refcnt.
+* libdiskfs/peropen-make.c (diskfs_make_peropen): Initialize refcnt.
+* libdiskfs/peropen-rele.c (diskfs_release_peropen): Adjust accordingly.
+* libdiskfs/protid-make.c (diskfs_start_protid): Likewise. Also, the
+node must no longer be locked, adjust comment accordingly.
+(diskfs_create_protid): Likewise.
+---
+ libdiskfs/diskfs.h | 7 ++++---
+ libdiskfs/peropen-make.c | 2 +-
+ libdiskfs/peropen-rele.c | 11 +++--------
+ libdiskfs/protid-make.c | 8 ++++----
+ 4 files changed, 12 insertions(+), 16 deletions(-)
+
+diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
+index 8151ddc..ae1a150 100644
+--- a/libdiskfs/diskfs.h
++++ b/libdiskfs/diskfs.h
+@@ -28,6 +28,7 @@
+ #include <hurd/iohelp.h>
+ #include <idvec.h>
+ #include <features.h>
++#include <refcount.h>
+
+ #ifdef DISKFS_DEFINE_EXTERN_INLINE
+ #define DISKFS_EXTERN_INLINE
+@@ -57,7 +58,7 @@ struct peropen
+ {
+ int filepointer;
+ int lock_status;
+- int refcnt;
++ refcount_t refcnt;
+ int openstat;
+
+ struct node *np;
+@@ -792,12 +793,12 @@ diskfs_create_node (struct node *dir, const char *name, mode_t mode,
+ struct dirstat *ds);
+
+ /* Create and return a protid for an existing peropen PO in CRED,
+- referring to user USER. The node PO->np must be locked. */
++ referring to user USER. */
+ error_t diskfs_create_protid (struct peropen *po, struct iouser *user,
+ struct protid **cred);
+
+ /* Build and return in CRED a protid which has no user identification, for
+- peropen PO. The node PO->np must be locked. */
++ peropen PO. */
+ error_t diskfs_start_protid (struct peropen *po, struct protid **cred);
+
+ /* Finish building protid CRED started with diskfs_start_protid;
+diff --git a/libdiskfs/peropen-make.c b/libdiskfs/peropen-make.c
+index eba037f..6d5ca01 100644
+--- a/libdiskfs/peropen-make.c
++++ b/libdiskfs/peropen-make.c
+@@ -31,7 +31,7 @@ diskfs_make_peropen (struct node *np, int flags, struct peropen *context,
+
+ po->filepointer = 0;
+ po->lock_status = LOCK_UN;
+- po->refcnt = 0;
++ refcount_init (&po->refcnt, 0);
+ po->openstat = flags;
+ po->np = np;
+ po->path = NULL;
+diff --git a/libdiskfs/peropen-rele.c b/libdiskfs/peropen-rele.c
+index d3f7492..64cea18 100644
+--- a/libdiskfs/peropen-rele.c
++++ b/libdiskfs/peropen-rele.c
+@@ -22,13 +22,8 @@
+ void
+ diskfs_release_peropen (struct peropen *po)
+ {
+- pthread_mutex_lock (&po->np->lock);
+-
+- if (--po->refcnt)
+- {
+- pthread_mutex_unlock (&po->np->lock);
+- return;
+- }
++ if (refcount_deref (&po->refcnt) > 0)
++ return;
+
+ if (po->root_parent)
+ mach_port_deallocate (mach_task_self (), po->root_parent);
+@@ -43,7 +38,7 @@ diskfs_release_peropen (struct peropen *po)
+ fshelp_acquire_lock (&po->np->userlock, &po->lock_status,
+ &po->np->lock, LOCK_UN);
+
+- diskfs_nput (po->np);
++ diskfs_nrele (po->np);
+
+ free (po->path);
+ free (po);
+diff --git a/libdiskfs/protid-make.c b/libdiskfs/protid-make.c
+index b39b92a..22aaa2e 100644
+--- a/libdiskfs/protid-make.c
++++ b/libdiskfs/protid-make.c
+@@ -20,7 +20,7 @@
+ #include <assert.h>
+
+ /* Build and return in CRED a protid which has no user identification, for
+- peropen PO. The node PO->np must be locked. */
++ peropen PO. */
+ error_t
+ diskfs_start_protid (struct peropen *po, struct protid **cred)
+ {
+@@ -29,7 +29,7 @@ diskfs_start_protid (struct peropen *po, struct protid **cred)
+ sizeof (struct protid), cred);
+ if (! err)
+ {
+- po->refcnt++;
++ refcount_ref (&po->refcnt);
+ (*cred)->po = po;
+ (*cred)->shared_object = MACH_PORT_NULL;
+ (*cred)->mapped = 0;
+@@ -55,8 +55,8 @@ diskfs_finish_protid (struct protid *cred, struct iouser *user)
+ assert_perror (err);
+ }
+
+-/* Create and return a protid for an existing peropen PO in CRED for USER.
+- The node PO->np must be locked. */
++/* Create and return a protid for an existing peropen PO in CRED for
++ USER. */
+ error_t
+ diskfs_create_protid (struct peropen *po, struct iouser *user,
+ struct protid **cred)
+--
+2.0.0.rc0
+