0

I am trying to understand the linux kernel path walk. How is the below case resolved:

For the Path,

"/ext3_dir/ext4_dir"

Lets say we have following mounted filesystems, ext4_dir is root of ext4 filesystem, mounted on ext3 directory ext3_dir.

Q1: Is it possible that at any time dentry for ext4_dir is not present on dentry cache or it will always be there after ext4 mounted on top of ext3 ?

Q2: If dcache miss case is possible then in the slow path below:

link_path_walk->walk_component->lookup_slow()

first dentry is allocated

dentry = d_alloc_parallel(dir, name, &wq);

and then we call

inode->i_op->lookup(inode, dentry, flags);

which calls the actual filesystem function to read the component inside the data blocks of inode of the parent directory, here ext3_dir. Since ext3_dir is in ext3 filesystem, how does the ext4 filesystem is accessed in this case to read the data of ext4_dir into dentry?

Thanks, Kapil

Kapil
  • 836
  • 2
  • 8
  • 20

1 Answers1

1

Dentry represented mount point of a filesystem is always in the cache. Also, root inode for a filesystem always exists.

So, no filesystem's function is required to navigate to "/ext3_dir/ext4_dir": both dentry and inode are extracted with use of VFS cache.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
  • Thanks Tsyvarev for the answer. do you also know how is it mandated, I mean how do we pin the root dentry to dcache. – Kapil Sep 15 '17 at 03:26
  • I am not sure, but dentry has reference counter field `d_lockref`. So, by incrementing this counter, VFS prevent dentry to leave the cache. In any case, pinning root dentry is a task for VFS, filesystem drivers are not involved in this. – Tsyvarev Sep 15 '17 at 07:00