<feed xmlns='http://www.w3.org/2005/Atom'>
<title>glusterfs.git/libglusterfs/src/refcount.h, branch v3.7.9</title>
<subtitle></subtitle>
<link rel='alternate' type='text/html' href='http://dev.gluster.org/cgit/glusterfs.git/'/>
<entry>
<title>refcount: correct the documentation</title>
<updated>2015-07-14T10:16:51+00:00</updated>
<author>
<name>Niels de Vos</name>
<email>ndevos@redhat.com</email>
</author>
<published>2015-07-13T10:16:33+00:00</published>
<link rel='alternate' type='text/html' href='http://dev.gluster.org/cgit/glusterfs.git/commit/?id=dd66dd9d6c249282711d56678bdfe22c2a8d0975'/>
<id>dd66dd9d6c249282711d56678bdfe22c2a8d0975</id>
<content type='text'>
The only check that _gf_ref_get() needs is "== 0" for detecting a
failure. The actual return value is not guaranteed to be the number of
active refences (they can change in other threads anyway).

Cherry picked from commit c7f309116d8fa62f6b9fd6ff2902e8ce4bfa192d:
&gt; BUG: 1163543
&gt; Change-Id: I8801601eab37046f5a5ee0bce5a62606115ca151
&gt; Signed-off-by: Niels de Vos &lt;ndevos@redhat.com&gt;
&gt; Reviewed-on: http://review.gluster.org/11328
&gt; Tested-by: NetBSD Build System &lt;jenkins@build.gluster.org&gt;
&gt; Tested-by: Gluster Build System &lt;jenkins@build.gluster.com&gt;
&gt; Reviewed-by: Kaleb KEITHLEY &lt;kkeithle@redhat.com&gt;

Change-Id: I8801601eab37046f5a5ee0bce5a62606115ca151
BUG: 1242515
Signed-off-by: Niels de Vos &lt;ndevos@redhat.com&gt;
Reviewed-on: http://review.gluster.org/11647
Tested-by: NetBSD Build System &lt;jenkins@build.gluster.org&gt;
Tested-by: Gluster Build System &lt;jenkins@build.gluster.com&gt;
Reviewed-by: Krishnan Parthasarathi &lt;kparthas@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The only check that _gf_ref_get() needs is "== 0" for detecting a
failure. The actual return value is not guaranteed to be the number of
active refences (they can change in other threads anyway).

Cherry picked from commit c7f309116d8fa62f6b9fd6ff2902e8ce4bfa192d:
&gt; BUG: 1163543
&gt; Change-Id: I8801601eab37046f5a5ee0bce5a62606115ca151
&gt; Signed-off-by: Niels de Vos &lt;ndevos@redhat.com&gt;
&gt; Reviewed-on: http://review.gluster.org/11328
&gt; Tested-by: NetBSD Build System &lt;jenkins@build.gluster.org&gt;
&gt; Tested-by: Gluster Build System &lt;jenkins@build.gluster.com&gt;
&gt; Reviewed-by: Kaleb KEITHLEY &lt;kkeithle@redhat.com&gt;

Change-Id: I8801601eab37046f5a5ee0bce5a62606115ca151
BUG: 1242515
Signed-off-by: Niels de Vos &lt;ndevos@redhat.com&gt;
Reviewed-on: http://review.gluster.org/11647
Tested-by: NetBSD Build System &lt;jenkins@build.gluster.org&gt;
Tested-by: Gluster Build System &lt;jenkins@build.gluster.com&gt;
Reviewed-by: Krishnan Parthasarathi &lt;kparthas@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>core: add "gf_ref_t" for common refcounting structures</title>
<updated>2015-06-27T05:26:24+00:00</updated>
<author>
<name>Niels de Vos</name>
<email>ndevos@redhat.com</email>
</author>
<published>2015-05-31T13:16:41+00:00</published>
<link rel='alternate' type='text/html' href='http://dev.gluster.org/cgit/glusterfs.git/commit/?id=d1cfdc873e9c50c0ada8e57b646f14bbeb3c2ef3'/>
<id>d1cfdc873e9c50c0ada8e57b646f14bbeb3c2ef3</id>
<content type='text'>
Checks for compiler supported atomic operations comes from client_t.h.

An example usage of this change can be found in adding reference
counting to "struct auth_cache_entry" in http://review.gluster.org/11023

Basic usage looks like this:

   #include "refcount.h"

   struct my_struct {
       GF_REF_DECL;
       ... /* more members */
   }

   void my_destructor (void *data)
   {
       struct my_struct *my_ptr = (struct my_struct *) data;

       ... /* do some more cleanups */
       GF_FREE (my_ptr);
   }

   void init_ptr (struct parent *parent)
   {
       struct my_struct *my_ptr = malloc (sizeof (struct my_struct));

       GF_REF_INIT (my_ptr, my_destructor); /* refcount is set to 1 */

       ... /* my_ptr probably gets added to some parent structure */
       parent_add_ptr (parent, my_ptr);
   }

   void do_something (struct parent *parent)
   {
       struct my_struct *my_ptr = NULL;

       /* likely need to lock parent, depends on its access pattern */
       my_ptr = parent_remove_first_ptr (parent);
       /* unlock parent */

       ... /* do something */

       GF_REF_PUT (my_ptr); /* calls my_destructor on refcount = 0 */
   }

URL: http://thread.gmane.org/gmane.comp.file-systems.gluster.devel/11202
Change-Id: Idb98a5861a44c31676108ed8876db12c320912ef
BUG: 1235939
Signed-off-by: Niels de Vos &lt;ndevos@redhat.com&gt;
Reviewed-on: http://review.gluster.org/11022
Reviewed-by: Xavier Hernandez &lt;xhernandez@datalab.es&gt;
Reviewed-by: Krishnan Parthasarathi &lt;kparthas@redhat.com&gt;
Tested-by: Gluster Build System &lt;jenkins@build.gluster.com&gt;
Tested-by: NetBSD Build System &lt;jenkins@build.gluster.org&gt;
(cherry picked from commit ea1d2b0045e2c2ad82a2162a58f9fc36f9d07b20)
Reviewed-on: http://review.gluster.org/11421
Reviewed-by: Raghavendra G &lt;rgowdapp@redhat.com&gt;
Tested-by: Raghavendra G &lt;rgowdapp@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Checks for compiler supported atomic operations comes from client_t.h.

An example usage of this change can be found in adding reference
counting to "struct auth_cache_entry" in http://review.gluster.org/11023

Basic usage looks like this:

   #include "refcount.h"

   struct my_struct {
       GF_REF_DECL;
       ... /* more members */
   }

   void my_destructor (void *data)
   {
       struct my_struct *my_ptr = (struct my_struct *) data;

       ... /* do some more cleanups */
       GF_FREE (my_ptr);
   }

   void init_ptr (struct parent *parent)
   {
       struct my_struct *my_ptr = malloc (sizeof (struct my_struct));

       GF_REF_INIT (my_ptr, my_destructor); /* refcount is set to 1 */

       ... /* my_ptr probably gets added to some parent structure */
       parent_add_ptr (parent, my_ptr);
   }

   void do_something (struct parent *parent)
   {
       struct my_struct *my_ptr = NULL;

       /* likely need to lock parent, depends on its access pattern */
       my_ptr = parent_remove_first_ptr (parent);
       /* unlock parent */

       ... /* do something */

       GF_REF_PUT (my_ptr); /* calls my_destructor on refcount = 0 */
   }

URL: http://thread.gmane.org/gmane.comp.file-systems.gluster.devel/11202
Change-Id: Idb98a5861a44c31676108ed8876db12c320912ef
BUG: 1235939
Signed-off-by: Niels de Vos &lt;ndevos@redhat.com&gt;
Reviewed-on: http://review.gluster.org/11022
Reviewed-by: Xavier Hernandez &lt;xhernandez@datalab.es&gt;
Reviewed-by: Krishnan Parthasarathi &lt;kparthas@redhat.com&gt;
Tested-by: Gluster Build System &lt;jenkins@build.gluster.com&gt;
Tested-by: NetBSD Build System &lt;jenkins@build.gluster.org&gt;
(cherry picked from commit ea1d2b0045e2c2ad82a2162a58f9fc36f9d07b20)
Reviewed-on: http://review.gluster.org/11421
Reviewed-by: Raghavendra G &lt;rgowdapp@redhat.com&gt;
Tested-by: Raghavendra G &lt;rgowdapp@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
