3

Linux カーネル コード、特にファイル システム部分をいじっています。カーネルの起動時に、いくつかの dentry オブジェクトがルート ディレクトリ "/" に割り当てられることがわかりました。ルート ディレクトリの複数のコピーを RAM に割り当てる必要があるのはなぜですか? さらに、dcache (dentry キャッシュ、本質的には大きなハッシュ テーブル) がハッシュ関数 H(parent_dentry_address, name_hash) を使用して、dentry が抵抗したバケットを計算しているように見えるため、各ルート dentry "/" がdcache のハッシュ バケットへの異なる dentry マッピング?

ところで、上記の動作は Linux-3.3.0-rc4 で観察されました。

4

3 に答える 3

1

カーネル ソースの Documentation/initrd.txt を読んで、ブートストラップで何が起こっているかを確認します。

When using initrd, the system typically boots as follows:

  1) the boot loader loads the kernel and the initial RAM disk
  2) the kernel converts initrd into a "normal" RAM disk and
     frees the memory used by initrd
  3) if the root device is not /dev/ram0, the old (deprecated)
     change_root procedure is followed. see the "Obsolete root change
     mechanism" section below.
  4) root device is mounted. if it is /dev/ram0, the initrd image is
     then mounted as root
  5) /sbin/init is executed (this can be any valid executable, including
     shell scripts; it is run with uid 0 and can do basically everything
     init can do).
  6) init mounts the "real" root file system
  7) init places the root file system at the root directory using the
     pivot_root system call
  8) init execs the /sbin/init on the new root filesystem, performing
     the usual boot sequence
  9) the initrd file system is removed

Note that changing the root directory does not involve unmounting it.
It is therefore possible to leave processes running on initrd during that
procedure. Also note that file systems mounted under initrd continue to
be accessible.

これが、なぜカーネルが「/」にいくつかの dentry を割り当てるのかという質問に対する答えになることを願っています。

于 2012-04-14T22:02:48.187 に答える
1

私は目を閉じて、コードを見ずにぼんやりと言いました。これは、 、および複数回マウント/した結果でしょうか?/

の上に何かをマウントすると、下にあるものは umount によって公開される可能性があるため、単に消えることはありません//

于 2012-03-13T08:18:34.200 に答える
0

カーネルには 2 つのタイプ「/」があり、1 つはプロセス ルート ディレクトリ用で、もう 1 つはファイル システム ルート ディレクトリ用です。

ファイルシステムを登録してマウントすると、最初にこのファイルシステムのエントリとしてマウントルートのdentryが割り当てられます。通常、このdentryは「/」名を使用します.RAM fsはproc/devtmpfsのように...マウントされた内部カーネルなので、同じ名前 '/' を持ついくつかの dentry があります。

于 2015-12-08T16:41:36.423 に答える