From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Kay Sievers <kay.sievers@vrfy.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Greg KH <greg@kroah.com>
Subject: Re: [1/4] DST: Distributed storage documentation.
Date: Mon, 10 Dec 2007 22:51:45 +0300 [thread overview]
Message-ID: <20071210195145.GA29132@2ka.mipt.ru> (raw)
In-Reply-To: <1197315895.6399.121.camel@lov.site>
On Mon, Dec 10, 2007 at 08:44:55PM +0100, Kay Sievers (kay.sievers@vrfy.org) wrote:
> > > > Actually not - I have to set reference counter to something other than 1
> > > > or +/- 1, and thus will have to call kref_get() in a loop, which is a
> > > > very ugly step. Is there kref_set() or somethinglike that? At least not
> > > > in 2.6.22 what I'm using for now.
> > >
> > > Yeah, a loop would look pretty ugly. How about just adding kref_set(),
> > > if you need it.
> >
> > Well, then it distributed storage will not be able to build as
> > standalone module, and kref_set() itself will not be accepted as a single
> > patch, since there are no in-kernel users :)
> > It is easily doable though.
>
> Most rules have exceptions. :) Send a patch, so we can see how it looks
> like.
It looks really non-trivial :)
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
diff --git a/include/linux/kref.h b/include/linux/kref.h
index 6fee353..5d18563 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -24,6 +24,7 @@ struct kref {
atomic_t refcount;
};
+void kref_set(struct kref *kref, int num);
void kref_init(struct kref *kref);
void kref_get(struct kref *kref);
int kref_put(struct kref *kref, void (*release) (struct kref *kref));
diff --git a/lib/kref.c b/lib/kref.c
index a6dc3ec..40aa9f9 100644
--- a/lib/kref.c
+++ b/lib/kref.c
@@ -15,13 +15,23 @@
#include <linux/module.h>
/**
+ * kref_set - initialize object and set refcount to requested number.
+ * @kref: object in question.
+ * @num: initial reference counter
+ */
+void kref_set(struct kref *kref, int num)
+{
+ atomic_set(&kref->refcount, num);
+ smp_mb();
+}
+
+/**
* kref_init - initialize object.
* @kref: object in question.
*/
void kref_init(struct kref *kref)
{
- atomic_set(&kref->refcount,1);
- smp_mb();
+ kref_set(kref, 1);
}
/**
--
Evgeniy Polyakov
next prev parent reply other threads:[~2007-12-10 19:52 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <11qqqasdzxczc036@2ka.mipt.ru>
2007-12-10 11:47 ` [0/4] DST: Distributed storage Evgeniy Polyakov
2007-12-10 11:47 ` [1/4] DST: Distributed storage documentation Evgeniy Polyakov
2007-12-10 11:47 ` [2/4] DST: Core distributed storage files Evgeniy Polyakov
2007-12-10 11:47 ` [3/4] DST: Network state machine Evgeniy Polyakov
2007-12-10 11:47 ` [4/4] DST: Algorithms used in distributed storage Evgeniy Polyakov
2007-12-12 9:12 ` Dmitry Monakhov
2007-12-12 10:20 ` Evgeniy Polyakov
2007-12-13 20:43 ` [3/4] DST: Network state machine Dmitry Monakhov
2007-12-14 6:35 ` Evgeniy Polyakov
2007-12-10 12:51 ` [1/4] DST: Distributed storage documentation Kay Sievers
2007-12-10 12:58 ` Evgeniy Polyakov
2007-12-10 14:31 ` Kay Sievers
2007-12-10 14:50 ` Evgeniy Polyakov
2007-12-10 15:12 ` Evgeniy Polyakov
2007-12-10 19:02 ` Kay Sievers
2007-12-10 19:33 ` Evgeniy Polyakov
2007-12-10 19:44 ` Kay Sievers
2007-12-10 19:51 ` Evgeniy Polyakov [this message]
2007-12-10 19:56 ` Kay Sievers
2007-12-10 20:03 ` Evgeniy Polyakov
2008-01-22 19:38 [0/4] DST: Distributed storage: Succumbed to live ant Evgeniy Polyakov
2008-01-22 19:38 ` [1/4] DST: Distributed storage documentation Evgeniy Polyakov
-- strict thread matches above, loose matches on Subject: below --
2007-12-26 11:22 [0/4] DST: Distributed storage: Groundhogs strike back: no New Year for humans Evgeniy Polyakov
2007-12-26 11:22 ` [1/4] DST: Distributed storage documentation Evgeniy Polyakov
2007-12-17 15:03 [0/4] DST: Distributed storage Evgeniy Polyakov
2007-12-17 15:03 ` [1/4] DST: Distributed storage documentation Evgeniy Polyakov
2007-12-17 16:27 ` Kay Sievers
2007-12-04 14:37 [0/4] DST: Distributed storage Evgeniy Polyakov
2007-12-04 14:37 ` [1/4] DST: Distributed storage documentation Evgeniy Polyakov
2007-11-29 12:53 [0/4] dst: Distributed storage Evgeniy Polyakov
2007-11-29 12:53 ` [1/4] dst: Distributed storage documentation Evgeniy Polyakov
2007-12-03 4:50 ` Matt Mackall
2007-12-03 11:16 ` Evgeniy Polyakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071210195145.GA29132@2ka.mipt.ru \
--to=johnpol@2ka.mipt.ru \
--cc=greg@kroah.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).