public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andries.Brouwer@cwi.nl
To: Andries.Brouwer@cwi.nl, viro@math.psu.edu
Cc: alan@lxorguk.ukuu.org.uk, linux-kernel@vger.kernel.org,
	torvalds@transmeta.com
Subject: Re: [RFC] lazy allocation of struct block_device
Date: Sat, 1 Sep 2001 20:42:20 GMT	[thread overview]
Message-ID: <200109012042.UAA17644@vlet.cwi.nl> (raw)

    From viro@math.psu.edu Sat Sep  1 18:26:53 2001

    On Sat, 1 Sep 2001 Andries.Brouwer@cwi.nl wrote:

    > A kdev_t is a pointer to a struct that has the info now found in
    > the arrays (and major, minor fields, and a name function..).
    > This struct is allocated by the driver.

    Umm... Apply the arguments from the char_device thread - pointers to
    unions are rather bad idea.  IOW, kdev_t must die - kernel always
    knows which kind we are dealing with.

I don't mind.
Nothing really changes if you split it into kbdev_t and kcdev_t.

(Splitting is a lot of work, a large source edit,
but basically straightforward. I did similar things a few times,
splitting MKDEV into MKBDEV and MKCDEV [and MKXDEV].
However, a union is not so bad. It seems a pity to avoid unions
and waste 4 bytes for every inode with separate i_bdev and i_cdev
instead of a single i_bcdev.
Anyway, this has nothing to do with the present discussion.)

...
    > This "a refcount" is the openct field of the device struct,
    > somewhat like the present bd_openers.
    > 
    > The decrements of the refcount are done in kill_super() for s_dev
    > and at the close/umount corresponding to the open/mount that set it for i_bcdev.

    ??? So you decrement twice on umount?

Yes, and increment twice on mount.
That may be easiest since s_dev can also come from get_unnamed_dev().

...
    How do you tell when inode is not opened anymore?
...
    When do you reset it [i_bcdev]?

Now I see what you are asking - at first I thought you wondered
about the bookkeeping for the device struct, and there is no problem there,
but you ask about the bookkeeping for i_bcdev.

Since the refcount is for the device struct, we cannot do anything
until that count hits zero. Then the release method of the device struct
is called (which frees it, or decrements a refcount for the module).
After this i_bcdev cannot be used anymore.
Since we don't know whether this happened already, i_bcdev must be
recomputed on each open or mount.

(One might invent additional data structure to avoid this recomputation,
but data structures take memory and add the complication that they
must be kept consistent and up-to-date. Since mounting, or opening
a block device, are very infrequent operations, it does not matter
that we do a possibly superfluous bdopen().)

Andries

             reply	other threads:[~2001-09-01 20:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-01 20:42 Andries.Brouwer [this message]
2001-09-01 21:26 ` [RFC] lazy allocation of struct block_device Jamie Lokier
2001-09-01 23:41 ` Anton Altaparmakov
2001-09-01 23:54 ` Alexander Viro
  -- strict thread matches above, loose matches on Subject: below --
2001-09-02 20:05 Andries.Brouwer
2001-09-02 17:25 Andries.Brouwer
2001-09-02 18:46 ` Alexander Viro
2001-09-02 10:24 Andries.Brouwer
2001-09-02 11:38 ` Alexander Viro
2001-09-02 12:49   ` Alan Cox
2001-09-02 15:38   ` Richard Gooch
2001-09-02 16:07     ` Alexander Viro
2001-09-02 16:16       ` Richard Gooch
2001-09-01 13:30 Andries.Brouwer
2001-09-01 16:26 ` Alexander Viro
2001-08-31  4:43 Alexander 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=200109012042.UAA17644@vlet.cwi.nl \
    --to=andries.brouwer@cwi.nl \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    --cc=viro@math.psu.edu \
    /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