Per-open file private data for the cdevs
Pawel Jakub Dawidek
pjd at FreeBSD.org
Tue May 6 06:12:24 UTC 2008
On Mon, May 05, 2008 at 05:56:31PM +0300, Kostik Belousov wrote:
> On Mon, May 05, 2008 at 10:13:55AM +0200, Pawel Jakub Dawidek wrote:
> > Can you see if my OSD (Object-Specific-Data) KPI can be useful here?
> > I've it only in perforce for now, but I think it's what you are looking
> > for. I use it for jails and threads currently, but it is trivial to use
> > it for other objects. Take a look:
> >
> > http://perforce.freebsd.org/fileViewer.cgi?FSPC=//depot/user/pjd/zfs/sys/sys/osd.h&REV=3
> >
> > When your code is loaded/initialized you call:
> >
> > static int slot;
> >
> > slot = osd_file_register(mod_destroy);
> >
> > Where mod_destroy is a function which knows how to free your private
> > data. On unload:
> >
> > osd_file_deregister(slot);
> >
> > Now, when you want to attach private data:
> >
> > error = osd_file_set(fp, slot, ptr_to_your_data);
> >
> > You can get it with:
> >
> > ptr = osd_file_get(fp, slot);
> This is a nice feature, but I think that privdata is a fundamental
> internal operation of the kernel, and it would be wrong to use
> the OSD. [...]
OSD is there to be used mostly by optional modules. For example if ZFS
is not loaded there is no need to keep a pointer to its private data in
struct prison and struct thread.
> [...] In fact, the object we shall attach OSD to is the struct
> file, and we would need to export the struct file to the cdevsw operations.
> Since it both breaks current ABI and complicates the future changes to
> the struct file, I would much prefer to not engage this route.
Ok.
--
Pawel Jakub Dawidek http://www.wheel.pl
pjd at FreeBSD.org http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20080506/0e4d91de/attachment.pgp
More information about the freebsd-arch
mailing list