Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


If the destination mount point is a shared mount, then the new mount and all its submounts need to
become shared as well:

fs/namespace.c
if (IS_MNT_SHARED(dest_mnt)) {
for (p = source_mnt; p; p = next_mnt(p, source_mnt))
set_mnt_shared(p);
}
...

Finally, the kernel needs to finish the mount process by callingmnt_set_mountpointandcommit_treeto
introduce the changes into the data structures as discussed for regular mounts. Note, however, that
commit_treeneeds to be called for every mount that has been propagated to shared peers or slave
mounts (mnt_set_mountpointfor these mounts has already been called inpropagate_mnt):

fs/namespace.c
mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
commit_tree(source_mnt);

list_for_each_entry_safe(child, p, &tree_list, mnt_hash) {
list_del_init(&child->mnt_hash);
commit_tree(child);
}

return 0;
}

TheumountSystem Call


Filesystems are unmounted by theumountsystem call, whose entry point issys_umountfrom
fs/namespace.c. Figure 8-8 shows the associated code flow diagram.

return-EBUSY

Yes

No

sys_umount

__user_walk

do_umount

sb->s_op->umount_begin

umount_tree

release_mounts

MNT_DETACH set or
entry not used anymore?

Figure 8-8: Code flow diagram forsys_umount.

First,__user_walkfinds thevfsmntinstance and thedentryinstance of the mount point, which are
packed in anameidatastructure.^19

(^19) __user_walkinvokes thepath_walkfunction after the pathname has been copied into kernel space.

Free download pdf