mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Releasing resources with children
@ 2005-03-14 17:49 Matthew Wilcox
  2005-03-14 18:11 ` Russell King
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2005-03-14 17:49 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, matthew

Releasing resources with children

What does it mean to release a resource with children?  Should the
children become children of the released resource's parent?  Should they
be released too?  Should we fail the release?

I bet we have no callers who expect this right now, but with
insert_resource() we may get some.  At the point where someone hits this
BUG we can figure out what semantics we want.

Signed-off-by: Matthew Wilcox <willy@parisc-linux.org>

diff -urpNX dontdiff linux-2.6.11-bk10/kernel/resource.c parisc-2.6-bk/kernel/resource.c
--- linux-2.6.11-bk10/kernel/resource.c	2005-03-14 06:44:08.205342005 -0700
+++ parisc-2.6-bk/kernel/resource.c	2005-03-14 07:07:54.000000000 -0700
@@ -181,6 +181,8 @@ static int __release_resource(struct res
 {
 	struct resource *tmp, **p;
 
+	BUG_ON(old->child);
+
 	p = &old->parent->child;
 	for (;;) {
 		tmp = *p;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Releasing resources with children
  2005-03-14 17:49 [PATCH] Releasing resources with children Matthew Wilcox
@ 2005-03-14 18:11 ` Russell King
  2005-03-14 21:49   ` Ingo Oeser
  0 siblings, 1 reply; 3+ messages in thread
From: Russell King @ 2005-03-14 18:11 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: akpm, linux-kernel, matthew

On Mon, Mar 14, 2005 at 10:49:16AM -0700, Matthew Wilcox wrote:
> What does it mean to release a resource with children?  Should the
> children become children of the released resource's parent?  Should they
> be released too?  Should we fail the release?

I've been running kernels with:

+       if (old->child) {
+               printk("Resource %p still has children: %s\n", old, old->name);
+               return -EINVAL;
+       }
+

here and it hasn't triggered once.  I suspect the reason it hasn't is
because no one does release a resource with children, but I suspect
that's just by mere luck than design.

The only thing I'd question is whether we really need to BUG_ON() here.
ISTR Linus' policy for BUG()/BUG_ON() was only if the condition lead
directly to a filesystem-corrupting bug.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Releasing resources with children
  2005-03-14 18:11 ` Russell King
@ 2005-03-14 21:49   ` Ingo Oeser
  0 siblings, 0 replies; 3+ messages in thread
From: Ingo Oeser @ 2005-03-14 21:49 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: akpm, linux-kernel, matthew

Russell King wrote:
> The only thing I'd question is whether we really need to BUG_ON() here.
> ISTR Linus' policy for BUG()/BUG_ON() was only if the condition lead
> directly to a filesystem-corrupting bug.

I consider it quite effective to flag interface violations.
Programming by contract anyone? ;-)

Regards

Ingo Oeser


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-14 22:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-14 17:49 [PATCH] Releasing resources with children Matthew Wilcox
2005-03-14 18:11 ` Russell King
2005-03-14 21:49   ` Ingo Oeser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome