Zbr's days.
December
Sun Mon Tue Wed Thu Fri Sat
           
11
         
2007
Months
Dec

About TODO Blog RSS Old blog Projects Gallery Notes

Tue, 11 Dec 2007

First pohmelfs dmesg and bits of Linux VFS internals.

[ 9941.748766] pohmelfs_alloc_inode, inode: ffff81003bc83ac8.
[ 9941.755070] pohmelfs_read_inode, inode: ffff81003bc83ae0, num: 12,
	inode is regular: 0, dir: 1, link: 0.
[ 9947.667710] pohmelfs_readdir: filp: ffff81003c5ad6a8, inode: ffff81003bc83ae0,
	dirent: ffff81003c5aff38, filldir: ffffffff8027f274.
[ 9950.283976] pohmelfs_readdir: filp: ffff81003e82faa8, inode: ffff81003bc83ae0,
	dirent: ffff81003a00ff38, filldir: ffffffff8027f274.
[10028.705354] pohmelfs_readdir: filp: ffff81003d4f1068, inode: ffff81003bc83ae0,
	dirent: ffff81003e10ff38, filldir: ffffffff8027f274.
[10095.745022] pohmelfs_lookup: dir: ffff81003bc83ae0, dentry: ffff81003b5343a0,
	nameidata: ffff81003e10fe88.
[10095.754922] pohmelfs_lookup: dir: ffff81003bc83ae0, dentry: ffff81003b5343a0,
	nameidata: ffff81003e10fdf8.

uganda:~# mount | grep pohmel
/dev/hdb1 on /mnt type pohmel (rw)

uganda:~# ls -la /mnt/
total 0
It is about 12kb of code just to register own filesystem and provide number of VFS callbacks, so that filesystem could be mounted.
It is not possible to create files or directories since directory lookup method is not implemented (it returns NULL), ls -l does not show any data since ->readdir() callback does not fill directory entries, since there are no such objects in the filesystem at all.

As you understood, this is fairly trivial implementation, which was created just as a reference point. So far it includes stubs for the following VFS methods:
  • basic address space operationsL
    • ->readpage() which reads a page, usually implemented as a generic mpage_readpage(), which uses per-filesystem get_block() callback. This is called via read path, when file's page is not in the page cache yet.
    • ->writepage() - writes a page usually via generic block_write_full_page() helper, which uses per-filesystem get_block() callback. This is called by the VFS core when there is a need to write page from the cache to disk. This happens for example when you call sync and friends.
    • ->prepare_write()/->commit_write() - they are called via write path (for example from generic_file_buffered_write()), this functions has to reserve a space on disk, update related metadata and perform other private filesystem steps for given page, which will be flushed to that on-disk area in ->writepage().
  • basic directory inode and file operations:
    • file operations include ->read() callback, which has to return -EISDIR, and ->readdir(), which has to read directory entries for given inode into provided buffer. Right now it is empty.
    • inode operations are used to create/remote/lookup and perform other tasks on directory content. Readonly filesystems only have to provide ->lookup() callback, which is used to lookup inode for given directory entry. Others have to implement lot more operations: create, lookup, link, unlink, symlink, mkdir, rmdir, mknod, rename, setattr, set of extended attributes operations and so on... Pohmelfs currently does not perform anything at all, but already provide an empty lookpup callback.
  • basic file operations (file operations itself and inode operations for regular files):
    • file operations for regular files are those provided by generic_ro_fops currenly, it includes:
      • ->llseek() - generic_file_llseek() - seek inside file mapping, it just updates files current position and performs some checks, so it does not include anything filesystem specific.
      • ->read() - do_sync_read() - a helper used by read syscall, it will eventually call ->aio_read(), which is generic_file_aio_read() for this file operations, it will call ->readpage() for pages, which are not yet in the page cache
      • ->aio_read(), described above.
      • ->mmap() - generic_file_readonly_mmap() - it will setup a mapping file operations, which include only a fault handler, which in turn will call page_cache_read(), which ends up with ->readpage() calls. Of course mapping is a bit more complex tasks, but from the filesystem point of view that all what we have to know.
      • ->splice_read() - generic_file_splice_read() - this callback is used for splice system calls, which ends up calling the same ->readpage() callback for the set of pages, which are put into spliced buffer of pages.
    • inode operations for regular files is not needed, if it is readonly filesystem (although it can provide some useful callbacks like getting extending and usual attributes), for usual filesystem at least ->truncate() and ->getattr() callbacks are required.

/devel/fs :: Link / Comments (0)