mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Filesystem & mutex
@ 2006-04-24  4:54 Joshua Hudson
  2006-04-24 11:19 ` Pekka Enberg
  0 siblings, 1 reply; 3+ messages in thread
From: Joshua Hudson @ 2006-04-24  4:54 UTC (permalink / raw)
  To: linux-kernel

My filesystem has need of an extra mutex in the extended inode data area.
>From what I understand, the mutex can be initalized in inode_init_once, but
I cannot determine how to free it.

It looks wrong to destroy the mutex by just destroying the slab.
It is wrong to destroy the inode in destroy_inode. Badness when
an inode is reused.

I really don't want to go back to semaphores. The mutex code just *looks* so
much cleaner.

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

* Re: Filesystem & mutex
  2006-04-24  4:54 Filesystem & mutex Joshua Hudson
@ 2006-04-24 11:19 ` Pekka Enberg
  2006-04-24 21:24   ` Joshua Hudson
  0 siblings, 1 reply; 3+ messages in thread
From: Pekka Enberg @ 2006-04-24 11:19 UTC (permalink / raw)
  To: Joshua Hudson; +Cc: linux-kernel

Hi,

On 4/24/06, Joshua Hudson <joshudson@gmail.com> wrote:
> My filesystem has need of an extra mutex in the extended inode data area.
> From what I understand, the mutex can be initalized in inode_init_once, but
> I cannot determine how to free it.
>
> It looks wrong to destroy the mutex by just destroying the slab.
> It is wrong to destroy the inode in destroy_inode. Badness when
> an inode is reused.

There's no need to 'release' a mutex. If the mutex is unlocked, you
can do kmem_cache_free() on the owning inode. You need to do
mutex_init() in the object cache constructor (init_once) only because
the memory given to you can be arbitrary state. After the mutex has
been initialized, it will never go into an illegal state on its own
assuming you remember to unlock it before freeing the inode.

                                            Pekka

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

* Re: Filesystem & mutex
  2006-04-24 11:19 ` Pekka Enberg
@ 2006-04-24 21:24   ` Joshua Hudson
  0 siblings, 0 replies; 3+ messages in thread
From: Joshua Hudson @ 2006-04-24 21:24 UTC (permalink / raw)
  To: Pekka Enberg, linux-kernel

On 4/24/06, Pekka Enberg <penberg@cs.helsinki.fi> wrote:
> Hi,
>
> On 4/24/06, Joshua Hudson <joshudson@gmail.com> wrote:
> > My filesystem has need of an extra mutex in the extended inode data area.
> > From what I understand, the mutex can be initalized in inode_init_once, but
> > I cannot determine how to free it.
> >
> > It looks wrong to destroy the mutex by just destroying the slab.
> > It is wrong to destroy the inode in destroy_inode. Badness when
> > an inode is reused.
>
> There's no need to 'release' a mutex. If the mutex is unlocked, you
> can do kmem_cache_free() on the owning inode. You need to do
> mutex_init() in the object cache constructor (init_once) only because
> the memory given to you can be arbitrary state. After the mutex has
> been initialized, it will never go into an illegal state on its own
> assuming you remember to unlock it before freeing the inode.
>
>                                             Pekka
Tx. Your solution worked.

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

end of thread, other threads:[~2006-04-24 21:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-24  4:54 Filesystem & mutex Joshua Hudson
2006-04-24 11:19 ` Pekka Enberg
2006-04-24 21:24   ` Joshua Hudson

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

all inboxes | Powered by JetHome®