Skip to contentSkip to conversation

Mapping anomalous blocksizes blksize

DISCUSSION Dan Luedtke 1 participant 1 message Jun 21, 2012 VFS

lore
Share & tools
lore
#0 lore raw

Hallo everyone,

another question regarding filesystem implementation, sorry for bugging you again. I wrote myfs_read() and myfs_write() with simple copy_from_user() and copy_to_user() calls and I am trying to "upgrade" them to the way other filesystems are doing it (paging, get_blk() and stuff, still reading and understanding...). Currently I am facing problems when it comes to blocksizes. The filesystem's blocksizes are multiples of 512 bytes minus 2 bytes for header information. All blocks on the same device have the same blocksize, the size is determined by the module at mounting time and stored in superblock private data. So blocksizes can be e.g. 510+2 or maybe 4094+2 bytes. If I understood correctly how struct inode stores the blocksizes, I have doubts that it is even possible to map 4094 [sic!] bytes of data into a page.

include/linux/fs.h:
761 struct inode {
762 umode_t i_mode;
...

821         atomic_t                i_count;
822         unsigned int            i_blkbits; <---
823         u64                     i_version;

And in various other locations I found lines like:
blksize = 1 << inode->i_blkbits;
or like:
inode->i_blkbits = ilog2(blksize);

There is no way to express 4094 correctly this way, is it? But 2**12 is 4096, and then the two header-bytes would be included :/

Don't hesitate to ask for further information, I might sound confused right now. Any help is appreciated, you are free to direct me to files in Documentation/ if I overlooked something.

Thanks!

Dan

Signature · 2 lines
Dan Luedtke
http://www.danrl.de