linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, Theodore Tso <tytso@mit.edu>,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH RFC 1/4] kactive: introduce generic "active"-refcounts
Date: Mon, 18 Aug 2014 16:03:33 -0500	[thread overview]
Message-ID: <20140818210333.GC24023@mtj.dyndns.org> (raw)
In-Reply-To: <1407869648-1449-2-git-send-email-dh.herrmann@gmail.com>

Hello,

On Tue, Aug 12, 2014 at 08:54:05PM +0200, David Herrmann wrote:
> This introduces a new reference-type "struct kactive". Unlike kref, this
> type manages "active references". That means, references can only be
> acquired if the object is active. At any time the object can be
> deactivated, causing any new attempt to acquire an active reference to
> fail. Furthermore, after disabling an object, you can wait for all active
> references to be dropped. This allows synchronous object removal without
> dangling _active_ objects.
> 
> This obivously does NOT replace the usual ref-count. Moreover, it is meant
> to be used in combination with normal ref-counts. This way, you can get
> active references and normal references to the object.
> 
> Active references are usually required for callbacks. That is, if an
> object has callbacks that can be entered by user-space, you usually want
> an active reference to the object as long as you are _inside_ the
> callback. This way the object cannot be removed while you work on it.
> Normal references, on the other hand, are required by the underlying
> file/device to make sure the object with its callback-pointer can be
> accessed at all.
> 
> kernfs implements an active-reference type with spin-locks. This patch is
> very loosely based on kernfs but avoids spin-locks.

Yeah, this is very similar to kernfs's [de]activation support which is
pretty much a revocation mechanism.  I have two comments.

* Is it necessary to make this a library?  Should it just be embedded
  into revoke(2) implementation?

* I struggled a lot with self-draining support in kernfs.  Ultimately,
  what worked is the ability to just put the reference which is held
  for the current invocation, fully delegating the responsibility of
  keeping the current object accessible to whoever requested to put
  that reference.  Self-draining can be implemented on top of it but
  that in itself is a bit too rigid for dynamic filesystems.

I'd love to see this in vfs layer.  A lot of kernfs's complexities
come from revocation support and using something common would be nice.
If this gets in, do you plan to convert kernfs to use it?

Thanks.

-- 
tejun

  reply	other threads:[~2014-08-18 21:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12 18:54 [PATCH RFC 0/4] VFS revoke() David Herrmann
2014-08-12 18:54 ` [PATCH RFC 1/4] kactive: introduce generic "active"-refcounts David Herrmann
2014-08-18 21:03   ` Tejun Heo [this message]
2014-08-19  8:29     ` David Herrmann
2014-08-12 18:54 ` [PATCH RFC 2/4] vfs: add revoke() helpers David Herrmann
2014-08-19 12:27   ` Christoph Hellwig
2014-08-12 18:54 ` [PATCH RFC 3/4] Input: evdev - switch to revoke helpers David Herrmann
2014-08-12 18:54 ` [PATCH RFC 4/4] Input: evdev - drop redundant client_list David Herrmann
2014-08-12 19:14 ` [PATCH RFC 0/4] VFS revoke() Al Viro

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=20140818210333.GC24023@mtj.dyndns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dh.herrmann@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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).