Re: VFS: mount_bdev and fill_super
On 19-Jun-2017 10:38 AM, "Shrikant Giridhar" wrote: On Fri, 16 Jun 2017, Rohan Puri wrote: > If s_root is set it means the superblock is already filled up so call > fill_super() only if s_root is NULL meaning superblock is not filled yet. I tried looking at the d_name of the s_root dentry when mounting a device and its always '/'. I presume this is due to it being the root dentry of the subtree we're attaching to the main file hierarchy. Yes. Can the dentry of a superblock be something other than '/' on mounting it? Are you talking about s_root field of struct super_block ? Then it ideally should be of root. I checked some file systems implementation of fill_super(). fill_super() is the method that sets the s_root field of super_block. I found all of those file systems *rightly* calling d_make_root() API which actually makes root dentry with name '/'. So the question you should ask yourself is which file systems code are you referring too, how is it setting the s_root field of super_block in their fill_super method. You will get your answer. Unless some file system is doing some very weird thing, I believe it would be calling d_make_root() VFS API only which does the task for you. Apologies if my question is a little vague. Any documentation about this would help too. --- Shrikant - Rohan ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: VFS: mount_bdev and fill_super
On Fri, 16 Jun 2017, Rohan Puri wrote: > If s_root is set it means the superblock is already filled up so call > fill_super() only if s_root is NULL meaning superblock is not filled yet. I tried looking at the d_name of the s_root dentry when mounting a device and its always '/'. I presume this is due to it being the root dentry of the subtree we're attaching to the main file hierarchy. Can the dentry of a superblock be something other than '/' on mounting it? Apologies if my question is a little vague. Any documentation about this would help too. --- Shrikant ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: VFS: mount_bdev and fill_super
On 16-Jun-2017 11:44 AM, "Shrikant Giridhar" wrote: > I just had a quick look at mount_bdev() code for Linux v3.15, mount_bdev() > can return only root dentry or error. I'm sorry I should have been clearer. I was referring to the documentation mount() where it says that the call can return something other than the root dentry. I have not looked at the doc. More specifically, I don't understand how the what's the purpose of the if condition checking for s_root in mount_bdev(). Apologies if this is a trivial question. If s_root is set it means the superblock is already filled up so call fill_super() only if s_root is NULL meaning superblock is not filled yet. Tracking the calls all the way down didn't seem to make it clearer and I couldn't find specific documentation about the interface. > Also please include the kernel version to which you are referring. I have the 4.12-rc5 kernel. --- Shrikant - Rohan ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: VFS: mount_bdev and fill_super
> I just had a quick look at mount_bdev() code for Linux v3.15, mount_bdev() > can return only root dentry or error. I'm sorry I should have been clearer. I was referring to the documentation mount() where it says that the call can return something other than the root dentry. More specifically, I don't understand how the what's the purpose of the if condition checking for s_root in mount_bdev(). Apologies if this is a trivial question. Tracking the calls all the way down didn't seem to make it clearer and I couldn't find specific documentation about the interface. > Also please include the kernel version to which you are referring. I have the 4.12-rc5 kernel. --- Shrikant ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: VFS: mount_bdev and fill_super
On 16-Jun-2017 11:21 AM, "Shrikant Giridhar" wrote: I'm a little confused about how the mount_bdev() call works. The VFS documentation lists it as a generic method to mount a block device. Based on what I understood from the source, it seems to open a block device whose path is passed via the mount() syscall and later associates it with the superblock, finally returning the corresponding dentry to the caller. The documentation also mentions that mount() can return a subtree of an existing filesystem on the block device. However, in the very next line it mentions that the caller also receives a pointer to the dentry of the root node. I can see from the source (fs/super.c:1099) that the mount_bdev call does check if the superblock's s_root == NULL or not and proceeds to set a new superblock if it is. I know my question sounds a little vague but I'm having trouble understanding how mount() can return a dentry for something other than the root? --- Shrikant ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies Hi Shrikant, I just had a quick look at mount_bdev() code for Linux v3.15, mount_bdev() can return only root dentry or error. Also please include the kernel version to which you are referring. - Rohan ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
VFS: mount_bdev and fill_super
I'm a little confused about how the mount_bdev() call works. The VFS documentation lists it as a generic method to mount a block device. Based on what I understood from the source, it seems to open a block device whose path is passed via the mount() syscall and later associates it with the superblock, finally returning the corresponding dentry to the caller. The documentation also mentions that mount() can return a subtree of an existing filesystem on the block device. However, in the very next line it mentions that the caller also receives a pointer to the dentry of the root node. I can see from the source (fs/super.c:1099) that the mount_bdev call does check if the superblock's s_root == NULL or not and proceeds to set a new superblock if it is. I know my question sounds a little vague but I'm having trouble understanding how mount() can return a dentry for something other than the root? --- Shrikant ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies