Accessing on-disk datastructures from a module
I would like to maintain some filesystem metadata as an on-disk datastructure that can be read and written to from within the filesystem module. I know file access from within the kernel is a bad idea; what is the recommended alternative for this? I'm thinking of reserving a bunch of blocks at the start of the partition and accessing them directly - is this the right approach? I'm not too sure how to do that either - I figured the way that ext3 maintains its journal would provide a hint, but I can find no documentation on this, and the code is hard to trace through for this one specific thing. martin
On Tue, Jan 18, 2011 at 11:23 PM, Martin DeMello <martindemello@gmail.com> wrote:
I would like to maintain some filesystem metadata as an on-disk datastructure that can be read and written to from within the filesystem module. I know file access from within the kernel is a bad idea; what is the recommended alternative for this?
I'm thinking of reserving a bunch of blocks at the start of the partition and accessing them directly - is this the right approach? I'm not too sure how to do that either - I figured the way that ext3 maintains its journal would provide a hint, but I can find no documentation on this, and the code is hard to trace through for this one specific thing.
You can try to have a reserved inode and use that. -- Thanks - Manish ================================== [$\*.^ -- I miss being one of them ==================================
On Wed, Jan 19, 2011 at 1:03 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
On Tue, Jan 18, 2011 at 11:23 PM, Martin DeMello <martindemello@gmail.com> wrote:
I would like to maintain some filesystem metadata as an on-disk datastructure that can be read and written to from within the filesystem module. I know file access from within the kernel is a bad idea; what is the recommended alternative for this?
You can try to have a reserved inode and use that.
That is what I was trying to do, but I can't find any documentation on how to read/write to it. Could you point me towards some docs or examples? martin
On Tue, Jan 18, 2011 at 11:40 PM, Martin DeMello <martindemello@gmail.com> wrote:
On Wed, Jan 19, 2011 at 1:03 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
On Tue, Jan 18, 2011 at 11:23 PM, Martin DeMello <martindemello@gmail.com> wrote:
I would like to maintain some filesystem metadata as an on-disk datastructure that can be read and written to from within the filesystem module. I know file access from within the kernel is a bad idea; what is the recommended alternative for this?
You can try to have a reserved inode and use that.
That is what I was trying to do, but I can't find any documentation on how to read/write to it. Could you point me towards some docs or examples?
Once you have your reserved inode, you can open it using iget to get the inode pointer. After that it would be same way as you would have done if you were allowed file ops in kernel. For eg.. If my reserved inode is 100 and I'm using ext2, it would be something like read_reserved_block(int blockno) { .... inodep = ext2_iget(sb, 100) err = ext2_get_block(inodep, blockno, &bh, 0); iput(inodep); ....... } Have a look at ext2_quota_read() for some hints. -- Thanks - Manish ================================== [$\*.^ -- I miss being one of them ==================================
On Wed, Jan 19, 2011 at 1:18 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
Once you have your reserved inode, you can open it using iget to get the inode pointer. After that it would be same way as you would have done if you were allowed file ops in kernel. For eg.. If my reserved inode is 100 and I'm using ext2, it would be something like [...]
Thanks a lot, that's really helpful! martin
On Wed, Jan 19, 2011 at 1:21 PM, Martin DeMello <martindemello@gmail.com>wrote:
On Wed, Jan 19, 2011 at 1:18 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
Once you have your reserved inode, you can open it using iget to get the inode pointer. After that it would be same way as you would have done if you were allowed file ops in kernel. For eg.. If my reserved inode is 100 and I'm using ext2, it would be something like [...]
Thanks a lot, that's really helpful!
hello guys, can anyone tell me how to make a disk based file reserved ? as manish said : buy making a file reserved for a file system the above task can be achieved.but how to make it reserved?
martin
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- ........................ *MOHIT VERMA*
On Wed, Jan 19, 2011 at 10:45 AM, mohit verma <mohit89mlnc@gmail.com> wrote:
On Wed, Jan 19, 2011 at 1:21 PM, Martin DeMello <martindemello@gmail.com> wrote:
On Wed, Jan 19, 2011 at 1:18 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
Once you have your reserved inode, you can open it using iget to get the inode pointer. After that it would be same way as you would have done if you were allowed file ops in kernel. For eg.. If my reserved inode is 100 and I'm using ext2, it would be something like [...]
Thanks a lot, that's really helpful!
hello guys, can anyone tell me how to make a disk based file reserved ? as manish said : buy making a file reserved for a file system the above task can be achieved.but how to make it reserved?
Just don't allocate that inode to anyone else and treat it specially in your code. Same was as ROOT_INODE (typically 2) is handled.
martin
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- ........................ MOHIT VERMA
-- Thanks - Manish ================================== [$\*.^ -- I miss being one of them ==================================
participants (3)
-
Manish Katiyar -
Martin DeMello -
mohit verma