public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Alexander Larsson <alex@cendio.se>
Cc: mtd@infradead.org
Subject: Re: get_mtd_device()
Date: Fri, 07 Apr 2000 16:11:58 +0100	[thread overview]
Message-ID: <8078.955120318@devel2.axiom.internal> (raw)
In-Reply-To: <Pine.LNX.4.10.10004071300060.10428-100000@tammy.signum.se>


alex@cendio.se said:
> Why was get_mtd_device() removed?

Locking issues.

I need to change the __MOD_INC_USE_COUNT(mtd->module) calls in the user 
modules to use try_inc_mod_count() on 2.3, and to deal appropriately with 
failure. This will make me mostly happy about the race conditions which
currently exist with drivers being unloaded at the same time as a user
module's open() function is being called on a different CPU.

This means that the driver module unload path goes...

  Acquire unload_lock in kernel/module.c
  call cleanup_module()
  ->	Acquire mtd_table_mutex
	Remove the mtd_info from the list
	Drop mtd_table_mutex
  Drop unload_lock
  
Now, I'm unhappy that I've just noticed that the unload_lock is a spinlock and 
hence perhaps cleanup_module() shouldn't be allowed to sleep, and hence can't 
try to acquire the mtd_table_mutex semaphore.

But besides this problem, which is going to bite a _lot_ of things, the
behaviour of get_mtd_device would have to be something like...

  Acquire mtd_table_mutex
  go through the mtd_table to get the one we want
  call try_inc_mod_count()
  -->	Acquire unload_lock
	increase the use count
	Drop unload_lock
  Drop mtd_table_mutex


Spot the deadlock. If you can tell me how to fix it, you can have 
get_mtd_device() back :)

>  I need it or something like it in jffs to get the mtd device from the
> minor device of the mtdblock device i shall mount. 

Could we add an ioctl() to mtdblock instead, to allow jffs to get direct 
access to the mtd_info struct that way? 

Actually, I'd prefer in the end that mtdblock not be required for jffs to work 
- after all, it's not really necessary except to keep mount(8) happy. 
We ought to be able to use 'mount /dev/mtd0 -tjffs /mnt/wherever' 



--
dwmw2




To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

  reply	other threads:[~2000-04-07 15:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-07 11:15 get_mtd_device() Alexander Larsson
2000-04-07 15:11 ` David Woodhouse [this message]
2000-04-07 15:54   ` get_mtd_device() Alexander Larsson
  -- strict thread matches above, loose matches on Subject: below --
2000-04-10  9:58 get_mtd_device() David Woodhouse

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=8078.955120318@devel2.axiom.internal \
    --to=dwmw2@infradead.org \
    --cc=alex@cendio.se \
    --cc=mtd@infradead.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