File system Query

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Sun Jun 16 19:10:10 EDT 2013


On Sat, 15 Jun 2013 18:53:22 +0530, Dibyayan Chakraborty said:

> But I cant understand the following things.

Thanks... Specific questions are *much* easier to answer. ;)

> 1. Why mutex lock is used in the code ? I know it is used for process
> synchronisation but why that section of the code is critical ?

I'll answer this in just a moment...

> 2. What is the purpose of the "sget()" function ?

It looks for a superblock for a filesystem, and if it doesn't find one that
matches, it allocates it.

The mutex is so that code executing on another CPU can't call put_super()
or other code that screws around with the linked list (If you have a linked
list A- -> B -> C, and smebody is removing B while you're finding the next
one after A, you can end up going to where B *used* to be (and memory may
be re-used for something totally different) instead of C.

> 3. And what is the job of the function mount_bdev() ?

It basically does a "given a block device and an indicator of what filesystem
type, mount the filesystem" (Basically, the top-level routine for doing stuff
like 'mount -t ext4 /dev/sdb5 /mnt" - if you look, you can see where all 3
parameters are passed to mount_bdev().  This is in contrast to mount_nodev(),
which is called when a block device isn't involved (for instance, for procfs
or other pseudo filesystems, and I think network FS like CIFS and NFS but
I could be wrong on that last).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130616/0694d541/attachment.bin 


More information about the Kernelnewbies mailing list