Date: Tue, 6 May 2008 08:12:15 +0200 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: Kostik Belousov <kostikbel@gmail.com> Cc: arch@freebsd.org Subject: Re: Per-open file private data for the cdevs Message-ID: <20080506061215.GB2508@garage.freebsd.pl> In-Reply-To: <20080505145631.GT18958@deviant.kiev.zoral.com.ua> References: <20080504171002.GN18958@deviant.kiev.zoral.com.ua> <20080505081355.GB1628@garage.freebsd.pl> <20080505145631.GT18958@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] 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@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFIH/a/ForvXbEpPzQRAmQ5AJ4/4aNF7nbZSXibdtD76uUZVNR71wCfUAo5 dZ5C7dh9TDj5ey1w3cjad4M= =BKfz -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080506061215.GB2508>
