Author: manu
Date: Tue Aug  4 14:44:16 2020
New Revision: 363836
URL: https://svnweb.freebsd.org/changeset/base/363836

Log:
  linuxkpi: Add kref_put_lock
  
  Same as kref_put but in addition to calling the rel function it will
  acquire the lock first.
  
  Sponsored by: The FreeBSD Foundation
  Reviewed by:  hselasky, emaste
  Differential Revision:        https://reviews.freebsd.org/D25942

Modified:
  head/sys/compat/linuxkpi/common/include/linux/kref.h

Modified: head/sys/compat/linuxkpi/common/include/linux/kref.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/kref.h        Tue Aug  4 
14:42:38 2020        (r363835)
+++ head/sys/compat/linuxkpi/common/include/linux/kref.h        Tue Aug  4 
14:44:16 2020        (r363836)
@@ -38,6 +38,7 @@
 #include <linux/compiler.h>
 #include <linux/kernel.h>
 #include <linux/mutex.h>
+#include <linux/refcount.h>
 
 #include <asm/atomic.h>
 
@@ -76,6 +77,20 @@ kref_put(struct kref *kref, void (*rel)(struct kref *k
        }
        return 0;
 }
+
+static inline int
+kref_put_lock(struct kref *kref, void (*rel)(struct kref *kref),
+    spinlock_t *lock)
+{
+
+       if (refcount_release(&kref->refcount.counter)) {
+               spin_lock(lock);
+               rel(kref);
+               return (1);
+       }
+       return (0);
+}
+
 
 static inline int
 kref_sub(struct kref *kref, unsigned int count,
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to