[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-fsdevel
Subject:    Re: VFS question...
From:       Erez Zadok <ezk () cs ! columbia ! edu>
Date:       1999-06-30 20:29:04
[Download RAW message or body]

In message <19990630174125.C18849@compapp.dcu.ie>, "John P. Looney" writes:
>  I'm trying to write a program that would gather statistics on filesystem
> usage, over a long period of time.
> 
>  I *think* the best way of doing this is to write a kernel module that
> could replace some VFS functions, perhaps sys_write and the like, with
> a function that writes a "what happened" message to a userspace program,
> and then calls the original function.

This is called stacking... :-)

>  Has something like this been done already ? If not, is it clean enough
> to work ? If I wished to log just:
> 
>  When a file is created/deleted/modified/read from
> 
>  what's are the VFS functions of most use ?

Off the top of my head: create, open, unlink, read, write, putpage, getpage.
But there's more.

> Can a module override functions
> in the kernel proper ?

No, but it can intercept f/s fuctions right below the VFS and before the VFS
calls the lower level f/s (ext2fs, nfs, etc.)

> Kate
> 
> -- 
> Microsoft - the best reason in the world to drink beer

You can use my wrapfs/lofs template for linux.  They are stackable f/s
modules.  They wrap on top of any directory and can modify f/s behavior, or
in your case, just observe it.  That way you can measure any f/s and you
don't need to modify the VFS or other file systems.

In fact I've done something similar to what you've done already a while back
when I needed to count the number of lookups, unlinks, and create's on a
news spool.  I used my template and put in simple integer counters at the
entry point to several VFS functions.  Then I added an ioctl that returned
the values of those counters back to a user process that polled them every
few minutes.  Unfortunately I didn't save that code b/c it was so simple; I
didn't think someone else might find it useful... :-(

Anyway, the idea is simple and you can extend it to any number of integer
counters and VFS ops.  The performance overhead of lofs on 2.2 is only
2--4%, and adding the counters should not add more than 1--2%.

I would not recommend that you do a printk from the kernel and count it from
syslog or something; that will harm performance significantly and will fill
up your logs quickly.  My templates come with a lot of debugging messages
that you can turn on/off or set to a given level.  (Yes I have printfs on
entry/exit to every VFS function.)

You can get source code for these in

	http://www.cs.columbia.edu/~ezk/research/software/

The code is for earlier 2.2.x kernels.  I've updated the code for all
kernels up to 2.2.10 and I'm am testing it now.  I'll release this within a
few days.

I've also been working on porting my templates to 2.3 kernels.  So far 2.3.8
is giving me trouble but I suspect the kernel itself has problems.
2.3.9-pre8 seems more stable.  Once I get wrapfs/lofs to work on 2.3
kernels, I'll release that too.

My code requires small kernel patches.  I've been working on getting those
cleaned and submitted to Linus, who agreed in principal to incorporate them.
I will make all such announcements on linux-fsdevel.  Stay tuned.

If you use my code, let me know if you have any questions.  I'd like to
help.

Cheers,
Erez.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic