* [RFC,PATCH] dnotify: enhance or replace?
@ 2004-03-24 14:17 Rüdiger Klaehn
2004-03-24 15:40 ` Alexander Larsson
0 siblings, 1 reply; 11+ messages in thread
From: Rüdiger Klaehn @ 2004-03-24 14:17 UTC (permalink / raw)
To: linux-kernel; +Cc: ttb, jamie, tridge, viro, torvalds, alexl
Hi all,
I have been working on a dnotify enhancement to let it work recursively
and to store information about what exactly has changed.
My current code can be found here:
<http://www.lambda-computing.com/~rudi/dnotify/>
From reading the list, I got the impression that there is a general
consensus that the current dnotify mechanism is less than optimal, and
that something should be done about it. Is that correct?
My current implementation enhances the dnotify mechanism, but is
backwards compatible to the old mechanism. This is obviously the least
intrusive approach, but it is also less than optimal. For example it
still requires an open file handle to watch for changes in a tree, so it
will create problems when unmounting a device.
In an offline discussion, the issue came up wether it would not be
better to replace dnotify with a completely new mechanism like e.g. a
special netlink socket. Since most userspace programs (e.g. KDE and
gnome) do not use dnotify directly, but through the fam daemon, the
required changes in user space applications would not be that great.
So what is your take on this? Enhance or replace?
best regards,
Rüdiger
p.s.: I cc'ed everybody who I think might be interested in a dnotify
enhancement/replacement.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC,PATCH] dnotify: enhance or replace?
2004-03-24 14:17 [RFC,PATCH] dnotify: enhance or replace? Rüdiger Klaehn
@ 2004-03-24 15:40 ` Alexander Larsson
2004-03-24 16:15 ` Rüdiger Klaehn
2004-03-24 16:37 ` John McCutchan
0 siblings, 2 replies; 11+ messages in thread
From: Alexander Larsson @ 2004-03-24 15:40 UTC (permalink / raw)
To: rudi; +Cc: linux-kernel, ttb, jamie, tridge, viro, torvalds
On Wed, 2004-03-24 at 15:17, Rüdiger Klaehn wrote:
> Hi all,
>
> I have been working on a dnotify enhancement to let it work recursively
> and to store information about what exactly has changed.
>
> My current code can be found here:
> <http://www.lambda-computing.com/~rudi/dnotify/>
>
> From reading the list, I got the impression that there is a general
> consensus that the current dnotify mechanism is less than optimal, and
> that something should be done about it. Is that correct?
>
> My current implementation enhances the dnotify mechanism, but is
> backwards compatible to the old mechanism. This is obviously the least
> intrusive approach, but it is also less than optimal. For example it
> still requires an open file handle to watch for changes in a tree, so it
> will create problems when unmounting a device.
>
> In an offline discussion, the issue came up wether it would not be
> better to replace dnotify with a completely new mechanism like e.g. a
> special netlink socket. Since most userspace programs (e.g. KDE and
> gnome) do not use dnotify directly, but through the fam daemon, the
> required changes in user space applications would not be that great.
>
> So what is your take on this? Enhance or replace?
>
> best regards,
>
> Rüdiger
>
> p.s.: I cc'ed everybody who I think might be interested in a dnotify
> enhancement/replacement.
I think everyone agrees that dnotify is a POS that needs replacement,
however coming up with a good new API and implementation seems to be
hard (or at least uninteresting to kernel developers).
I for sure would welcome a sane file change notification API, i.e. one
that doesn't require the use of signals. However, I don't really care
about recursive monitors, and I'm actually unsure if you really want the
DN_EXTENDED functionallity in the kernel. It seems like a great way to
make the kernel use a lot of unswappable memory, unless you limit the
event queues, and if you do that you need to stat all files in userspace
anyway so you can correctly handle queue overflows.
I think the most important properties for a good dnotify replacement is:
* Don't use signals or any other global resource that makes it
impossible to use the API in a library thats supposed to be used by all
sorts of applications.
* Get sane semantics. i.e. if a hardlink changes notify a file change in
all directories the file is in. (This is hard though, it needs backlinks
from the inodes to the directories, at least for the directories with a
monitor, something i guess we don't have today.)
* Some way to get an event when the last open fd to the file is closed
after a file change. This means you won't get hundreds of write events
for a single file change. (Of course, you won't catch writes to e.g.
logs which aren't closed, so this has to be optional. But for a desktop,
this is often what you want.)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Alexander Larsson Red Hat, Inc
alexl@redhat.com alla@lysator.liu.se
He's a time-tossed guerilla cowboy who knows the secret of the alien invasion.
She's a cosmopolitan mutant mercenary living on borrowed time. They fight
crime!
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFC,PATCH] dnotify: enhance or replace?
2004-03-24 15:40 ` Alexander Larsson
@ 2004-03-24 16:15 ` Rüdiger Klaehn
[not found] ` <1080202140.8108.101.camel@localhost.localdomain>
2004-03-24 16:37 ` John McCutchan
1 sibling, 1 reply; 11+ messages in thread
From: Rüdiger Klaehn @ 2004-03-24 16:15 UTC (permalink / raw)
To: Alexander Larsson; +Cc: linux-kernel
Alexander Larsson wrote:
[snip]
> I think everyone agrees that dnotify is a POS that needs replacement,
> however coming up with a good new API and implementation seems to be
> hard (or at least uninteresting to kernel developers).
>
I want something like this, so I am willing to spend some time
implementing it.
> I for sure would welcome a sane file change notification API, i.e. one
> that doesn't require the use of signals. However, I don't really care
> about recursive monitors, and I'm actually unsure if you really want the
> DN_EXTENDED functionallity in the kernel. It seems like a great way to
> make the kernel use a lot of unswappable memory, unless you limit the
> event queues, and if you do that you need to stat all files in userspace
> anyway so you can correctly handle queue overflows.
>
About recursive notification:
Some way to watch for changes on a whole file system is a must.
Otherwise there is really no need to replace dnotify. When I start up
KDE it watches for 256 different directories in my /home directory. It
would probably watch even more directories if it could. With recursive
watching it would only need to watch two or three directories recursively.
About the buffer memory usage problem:
I have been testing the current approach for a few days continuously
now, and I don't get event buffer overflows even if I watch for all
events on "/". Of course the event buffer size should be limited. The
current implementation uses 10*4096 bytes, but in most cases starting
with a single 4096 byte page should be enough.
Note that the most common events (read and write) are quite small.
Currently they are 32 bytes, but it would not be that hard to get them
even smaller if nessecary. This is quite good compared to libraries like
dazuko that report the complete path for each change.
Extended information about the type of change has been requested by many
persons, and it is nessecary for many applications. People have been
writing ugly syscall table hacks for this, so they must be really
desperate to get this information...
It should be optional though.
> I think the most important properties for a good dnotify replacement is:
>
> * Don't use signals or any other global resource that makes it
> impossible to use the API in a library thats supposed to be used by all
> sorts of applications.
>
Agreed.
> * Get sane semantics. i.e. if a hardlink changes notify a file change in
> all directories the file is in. (This is hard though, it needs backlinks
> from the inodes to the directories, at least for the directories with a
> monitor, something i guess we don't have today.)
>
This would require large changes, and I think figuring out all aliases
to a path might as well be done in userspace. You don't gain much by
putting this in the kernel, and it requires a lot of complexity.
> * Some way to get an event when the last open fd to the file is closed
> after a file change. This means you won't get hundreds of write events
> for a single file change. (Of course, you won't catch writes to e.g.
> logs which aren't closed, so this has to be optional. But for a desktop,
> this is often what you want.)
>
Should be no problem to add this with the current approach. But it is
not that bad if you are getting hundreds of write events for a single
file. They are just 32 bytes, so you can just throw them away in the
userspace if you are not interested in them.
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFC,PATCH] dnotify: enhance or replace?
2004-03-24 15:40 ` Alexander Larsson
2004-03-24 16:15 ` Rüdiger Klaehn
@ 2004-03-24 16:37 ` John McCutchan
2004-03-24 16:54 ` Rüdiger Klaehn
1 sibling, 1 reply; 11+ messages in thread
From: John McCutchan @ 2004-03-24 16:37 UTC (permalink / raw)
To: Alexander Larsson; +Cc: rudi, linux-kernel, jamie, tridge, viro, torvalds
On Wed, 2004-03-24 at 10:40, Alexander Larsson wrote:
>
> I think everyone agrees that dnotify is a POS that needs replacement,
> however coming up with a good new API and implementation seems to be
> hard (or at least uninteresting to kernel developers).
>
> I for sure would welcome a sane file change notification API, i.e. one
> that doesn't require the use of signals. However, I don't really care
> about recursive monitors, and I'm actually unsure if you really want the
> DN_EXTENDED functionallity in the kernel. It seems like a great way to
> make the kernel use a lot of unswappable memory, unless you limit the
> event queues, and if you do that you need to stat all files in userspace
> anyway so you can correctly handle queue overflows.
>
> I think the most important properties for a good dnotify replacement is:
>
> * Don't use signals or any other global resource that makes it
> impossible to use the API in a library thats supposed to be used by all
> sorts of applications.
>
> * Get sane semantics. i.e. if a hardlink changes notify a file change in
> all directories the file is in. (This is hard though, it needs backlinks
> from the inodes to the directories, at least for the directories with a
> monitor, something i guess we don't have today.)
>
> * Some way to get an event when the last open fd to the file is closed
> after a file change. This means you won't get hundreds of write events
> for a single file change. (Of course, you won't catch writes to e.g.
> logs which aren't closed, so this has to be optional. But for a desktop,
> this is often what you want.)
Maybe adding a rate limiter on these write events would be a better
idea, live updates are usefull for the desktop. Also with a netlink
socket I think the overhead of many events would drop siginificantly.
Also a couple other items I think need to be on the list of features,
* Some way to not have an open file descriptor for each directory you
are monitoring. This causes so many problems when unmounting, and this
is really the most noticable problem for the user.
* Better event vocabulary, we should fire events for all VFS ops. I
think right now it is limited to delete,create,written to. It would be
good to tell the listener exactly what happened, moved,renamed, etc.
John
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC,PATCH] dnotify: enhance or replace?
2004-03-24 16:37 ` John McCutchan
@ 2004-03-24 16:54 ` Rüdiger Klaehn
2004-03-24 19:53 ` John McCutchan
0 siblings, 1 reply; 11+ messages in thread
From: Rüdiger Klaehn @ 2004-03-24 16:54 UTC (permalink / raw)
To: John McCutchan; +Cc: linux-kernel
John McCutchan wrote:
[snip]
> Maybe adding a rate limiter on these write events would be a better
> idea, live updates are usefull for the desktop. Also with a netlink
> socket I think the overhead of many events would drop siginificantly.
>
You could always merge read/write events if you get too many of them.
E.g. write [10,11] + write [11,12] => write [10,12]. But I never had
event buffer overflows with my tests. And a buffer of a few kbytes per
file system for fam won't be that bad, so I am not sure wether it is
nessecary to do something as complicated as rate limiting or merging.
> Also a couple other items I think need to be on the list of features,
>
> * Some way to not have an open file descriptor for each directory you
> are monitoring. This causes so many problems when unmounting, and this
> is really the most noticable problem for the user.
>
You can monitor a whole tree with a single file descriptor. But you need
at least one open fd per file system, so it would indeed be a problem
when unmounting.
> * Better event vocabulary, we should fire events for all VFS ops. I
> think right now it is limited to delete,create,written to. It would be
> good to tell the listener exactly what happened, moved,renamed, etc.
>
I had this for a short time, but I threw it away since I wanted to
concentrate on the event dispatch infrastructure first. It would not be
a big problem to add this again.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC,PATCH] dnotify: enhance or replace?
2004-03-24 16:54 ` Rüdiger Klaehn
@ 2004-03-24 19:53 ` John McCutchan
2004-03-24 20:00 ` Paul Rolland
2004-03-24 20:04 ` viro
0 siblings, 2 replies; 11+ messages in thread
From: John McCutchan @ 2004-03-24 19:53 UTC (permalink / raw)
To: rudi, linux-kernel, jamie, tridge, viro, torvalds, alexl, rml
One of the big requirements for a dnotify replacement is this
* Some way to not have an open file descriptor for each directory you
are monitoring. This causes so many problems when unmounting, and this
is really the most noticable problem for the user.
I wanted to get some possible ideas from kernel hackers about how this
could be done. Inode numbers are not unique, but is there any way to get
a unique identifier on a file without using an open file? I have come
up with a few ideas.. I don't think they are very good, but here is
goes,
- When user passes fd to kernel to watch, the kernel takes over this
fd, making it invalid in user space ( I know this is a terrible hack)
then when a volume is unmounted, the kernel can walk the list of
open fd's using for notifacation and close them, before attempting to
unmount.
- The user passes a path to the kernel, the kernel does some work so
that it can track anything to do with that path, and again when
an unmount is called the kernel cleans up anything used for
notification.
Both of these ideas are similar, does anyone have a better idea?
John
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC,PATCH] dnotify: enhance or replace?
2004-03-24 19:53 ` John McCutchan
@ 2004-03-24 20:00 ` Paul Rolland
2004-03-24 20:04 ` viro
1 sibling, 0 replies; 11+ messages in thread
From: Paul Rolland @ 2004-03-24 20:00 UTC (permalink / raw)
To: 'John McCutchan',
rudi, linux-kernel, jamie, tridge, viro, torvalds, alexl, rml
Hello,
> could be done. Inode numbers are not unique, but is there any
> way to get
> a unique identifier on a file without using an open file? I have come
I wonder if adding to the inode number something like the device
id is not enough to create some "unique key"...
> up with a few ideas.. I don't think they are very good, but here is
> goes,
>
> - When user passes fd to kernel to watch, the kernel takes over this
> fd, making it invalid in user space ( I know this is a
> terrible hack)
> then when a volume is unmounted, the kernel can walk the list of
> open fd's using for notifacation and close them, before
> attempting to
> unmount.
No, this is bad, because it would require to use dedicated fd for
dnotify. If I open a file/directory, give it to dnotify, I don't
want to re-open it to use it, read it, or anything else...
> - The user passes a path to the kernel, the kernel does some work so
> that it can track anything to do with that path, and again when
> an unmount is called the kernel cleans up anything used for
> notification.
That sounds much better to me...
Regards,
Paul
Paul Rolland, rol(at)as2917.net
ex-AS2917 Network administrator and Peering Coordinator
--
Please no HTML, I'm not a browser - Pas d'HTML, je ne suis pas un navigateur
"Some people dream of success... while others wake up and work hard at it"
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC,PATCH] dnotify: enhance or replace?
2004-03-24 19:53 ` John McCutchan
2004-03-24 20:00 ` Paul Rolland
@ 2004-03-24 20:04 ` viro
2004-03-26 10:12 ` Rüdiger Klaehn
1 sibling, 1 reply; 11+ messages in thread
From: viro @ 2004-03-24 20:04 UTC (permalink / raw)
To: John McCutchan; +Cc: rudi, linux-kernel, jamie, tridge, torvalds, alexl, rml
On Wed, Mar 24, 2004 at 02:53:52PM -0500, John McCutchan wrote:
> - When user passes fd to kernel to watch, the kernel takes over this
> fd, making it invalid in user space ( I know this is a terrible hack)
> then when a volume is unmounted, the kernel can walk the list of
> open fd's using for notifacation and close them, before attempting to
> unmount.
And if umount fails? BTW, _which_ umount? The sucker can be present
in more than one place in more than one namespace.
> - The user passes a path to the kernel, the kernel does some work so
> that it can track anything to do with that path, and again when
> an unmount is called the kernel cleans up anything used for
> notification.
Ditto.
> Both of these ideas are similar, does anyone have a better idea?
"Doctor, It Hurts When I Do It"
Seriously, dnotify sucks in a lot of ways, starting with the basic
premise - that userland can do notification-based maintainig of directory
tree image. It's racy by definition, so any attempts to use it for
"security improvements" are scam. Which leaves us with file manglers
and their ilk.
Note that any attempts to trace "aliases" in userland are hopelessly racy;
that mounting/unmounting doesn't even show on the radar; that different
users can see different parts of tree or, while we are at it, completely
different trees; that this crap is a DDoS on a server that exports any
sort of network filesystem to many clients - *especially* if you want
notifications on the entire tree.
IOW, idea is fundamentally flawed and IMO the real fix is to try and figure
out a decent UI that would provide what file managers are really used for.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC,PATCH] dnotify: enhance or replace?
2004-03-24 20:04 ` viro
@ 2004-03-26 10:12 ` Rüdiger Klaehn
0 siblings, 0 replies; 11+ messages in thread
From: Rüdiger Klaehn @ 2004-03-26 10:12 UTC (permalink / raw)
To: viro; +Cc: linux-kernel
viro@parcelfarce.linux.theplanet.co.uk wrote:
[snip]
> "Doctor, It Hurts When I Do It"
>
> Seriously, dnotify sucks in a lot of ways, starting with the basic
> premise - that userland can do notification-based maintainig of directory
> tree image. It's racy by definition, so any attempts to use it for
> "security improvements" are scam. Which leaves us with file manglers
> and their ilk.
>
I thought about this some more. If you watch for e.g. all writes on the
root of a file system you get a complete, correctly ordered log of all
file writes on that filesystem. So you can find out wether a certain
file has been changed or not. That could be relevant security information.
You would get changes to the file pointed to by the path /etc/shadow,
even if the file has been changed by a hard link from /tmp/bla.
I am assuming here that there is a way like inode numbers to uniquely
identify and persistently identify a file. If something like this does
not exist, you are out of luck.
> Note that any attempts to trace "aliases" in userland are hopelessly
racy;
You don't trace aliases in userland. All the relevant information is
logged in kernel space. The only thing you do in userspace is to convert
this information into a user readable form. You can take as long as you
want for that.
Btw: why did you put aliases in quotes? Is aliases not the correct term
when refering to multiple paths pointing to the same file?
> that mounting/unmounting doesn't even show on the radar;
There is an event for mounting and unmounting.
> hat different users can see different parts of tree or, while we are
> at it, completely different trees;
>
That is why the paths returned by the mechanism are relative to the
directory from which you watch.
> that this crap is a DDoS on a server that exports any
> sort of network filesystem to many clients - *especially* if you want
> notifications on the entire tree.
>
If you have 100 clients, and each client wants its own notification for
/home, you would indeed have a problem. But if a single process like fam
watches for changes in /home on behalf of all 100 clients, it would be
no problem.
> IOW, idea is fundamentally flawed and IMO the real fix is to try and
figure
> out a decent UI that would provide what file managers are really used
for.
>
File managers are just one application of an enhanced file change
notification mechanism. There are many much more interesting
applications. For file managers the current dnotify mechanism is OK.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-03-26 10:10 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-24 14:17 [RFC,PATCH] dnotify: enhance or replace? Rüdiger Klaehn
2004-03-24 15:40 ` Alexander Larsson
2004-03-24 16:15 ` Rüdiger Klaehn
[not found] ` <1080202140.8108.101.camel@localhost.localdomain>
2004-03-26 9:52 ` Rüdiger Klaehn
[not found] ` <4062C63F.6050907@gamemakers.de>
[not found] ` <1080219862.8108.138.camel@localhost.localdomain>
2004-03-26 9:59 ` Rüdiger Klaehn
2004-03-24 16:37 ` John McCutchan
2004-03-24 16:54 ` Rüdiger Klaehn
2004-03-24 19:53 ` John McCutchan
2004-03-24 20:00 ` Paul Rolland
2004-03-24 20:04 ` viro
2004-03-26 10:12 ` Rüdiger Klaehn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®