LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Kernel 6.6 from block_device how to get the superblock? (https://www.linuxquestions.org/questions/linux-kernel-70/kernel-6-6-from-block_device-how-to-get-the-superblock-4175735064/)

akhurange 03-19-2024 06:43 AM

Kernel 6.6 from block_device how to get the superblock?
 
Prior to kernel 6.6, struct block_device had member variable:

Code:

struct super_block *    bd_super;
One could check if the block device had a mounted file system or not by checking:

Code:

struct super_block *sb = bdev->bd_super;
if (!sb) {
      // block device is not mounted.
}

But from kernel 6.6., struct block_device doesnt has the member variable: bd_super. Now how to check if the block _device has a mounted file system or not?

harry.hycc 03-20-2024 12:44 AM

You can use
struct *super_block;
sb = (struct super_block*)(bdev)->bd_holder

in https://www.kernel.org/doc/html/v6.6...s/porting.html
you can find that
The holder of a block device is now the superblock.

The holder of a block device used to be the file_system_type which wasn't particularly useful. It wasn't possible to go from block device to owning superblock without matching on the device pointer stored in the superblock. This mechanism would only work for a single device so the block layer couldn't find the owning superblock of any additional devices.


All times are GMT -5. The time now is 01:53 AM.