* inotify/sysfs @ 2014-03-27 13:50 Quentin Glidic 2014-03-28 17:07 ` inotify/sysfs Jan Kara 2014-03-31 18:52 ` inotify/sysfs Al Viro 0 siblings, 2 replies; 7+ messages in thread From: Quentin Glidic @ 2014-03-27 13:50 UTC (permalink / raw) To: linux-fsdevel Hello, In GIO (GLib), the GFileMonitor[1] mechanism is using inotify for local files. To detect file creation and some other weird cases, they monitor the directory of the file and not the file directly (see get_basename/get_dirname[2] usage). With sysfs, it does not work as expected for some reason. From a quick discussion of IRC with GLib folks, it appears that it would be better fixed in sysfs directly. Would such a patch be accepted and if so, could I have some hints to where I should start hacking to fix that? Thanks, [1] https://developer.gnome.org/gio/unstable/GFileMonitor.html [2] https://git.gnome.org/browse/glib/tree/gio/inotify/ginotifyfilemonitor.c#n82 -- Quentin “Sardem FF7” Glidic -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: inotify/sysfs 2014-03-27 13:50 inotify/sysfs Quentin Glidic @ 2014-03-28 17:07 ` Jan Kara 2014-03-29 6:25 ` inotify/sysfs Greg KH 2014-03-31 18:52 ` inotify/sysfs Al Viro 1 sibling, 1 reply; 7+ messages in thread From: Jan Kara @ 2014-03-28 17:07 UTC (permalink / raw) To: Quentin Glidic; +Cc: linux-fsdevel Hello, On Thu 27-03-14 14:50:24, Quentin Glidic wrote: > In GIO (GLib), the GFileMonitor[1] mechanism is using inotify for > local files. To detect file creation and some other weird cases, > they monitor the directory of the file and not the file directly > (see get_basename/get_dirname[2] usage). > > With sysfs, it does not work as expected for some reason. Well, I'm rather surprised inotify works with sysfs at all ;) Why do you need to watch sysfs? Udev is the tool with which you should generally look for e.g. new devices... Anyway, if you'd like to add fsnotify() support into sysfs, sysfs maintainer (Greg - added to CC) is the one to ask. Honza -- Jan Kara <jack@suse.cz> SUSE Labs, CR ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: inotify/sysfs 2014-03-28 17:07 ` inotify/sysfs Jan Kara @ 2014-03-29 6:25 ` Greg KH 0 siblings, 0 replies; 7+ messages in thread From: Greg KH @ 2014-03-29 6:25 UTC (permalink / raw) To: Quentin Glidic, linux-fsdevel; +Cc: Jan Kara On Fri, Mar 28, 2014 at 06:07:13PM +0100, Jan Kara wrote: > Hello, > > On Thu 27-03-14 14:50:24, Quentin Glidic wrote: > > In GIO (GLib), the GFileMonitor[1] mechanism is using inotify for > > local files. To detect file creation and some other weird cases, > > they monitor the directory of the file and not the file directly > > (see get_basename/get_dirname[2] usage). > > > > With sysfs, it does not work as expected for some reason. > Well, I'm rather surprised inotify works with sysfs at all ;) Why do you > need to watch sysfs? Udev is the tool with which you should generally look > for e.g. new devices... Anyway, if you'd like to add fsnotify() support > into sysfs, sysfs maintainer (Greg - added to CC) is the one to ask. You forgot to cc: me :) No, inotify doesn't work on sysfs, or if it does, that's by "accident", and any data you are getting for this is probably totally wrong. This is because the system would have to be constantly "opening" the files to check for a value change in the kernel that represents the file information. That would be hell on memory and overhead and just doesn't make any sense at all. For specific sysfs files that are ment to tell userspace that their values changed, you can poll() on them, as they are set up to do this properly. If there are some specific sysfs files that you want to watch in this manner, that don't support poll(), please let us know. Also, if you are digging through sysfs files in the system, I'd recommend using libudev, as that provides a much easier interface to getting the data you need about the device you want. thanks, greg k-h ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: inotify/sysfs 2014-03-27 13:50 inotify/sysfs Quentin Glidic 2014-03-28 17:07 ` inotify/sysfs Jan Kara @ 2014-03-31 18:52 ` Al Viro 2014-03-31 19:13 ` inotify/sysfs Linus Torvalds 1 sibling, 1 reply; 7+ messages in thread From: Al Viro @ 2014-03-31 18:52 UTC (permalink / raw) To: Quentin Glidic; +Cc: linux-fsdevel, Linus Torvalds, Michael Kerrisk On Thu, Mar 27, 2014 at 02:50:24PM +0100, Quentin Glidic wrote: > Hello, > > In GIO (GLib), the GFileMonitor[1] mechanism is using inotify for > local files. To detect file creation and some other weird cases, > they monitor the directory of the file and not the file directly > (see get_basename/get_dirname[2] usage). > > With sysfs, it does not work as expected for some reason. > > From a quick discussion of IRC with GLib folks, it appears that it > would be better fixed in sysfs directly. inotify does not and will not work on sysfs. Or procfs. Or devpts. Or any number of network filesystems. No matter how hard somebody might wish it to work, that's simply not feasible. Linus, what do you think about flat-out refusing to create the watches on filesystems that can't support them? At inotify_add_watch(2)/fanotify_mark(2) time. Do you think that it would break syscall ABI warranties? As it is, the caller has no way to tell it needs to go for a fallback, short of getting ENOSYS on inotify_init(). And it *does* need to have fallback, simply because there's no way in hell to get notifications for a lot of places in synthetic filesystems, etc. If userland developers pull that kind of stunts (see above re GLib crowd trying to defend their garbage by suggesting that kernel must somehow make *notify work on all filesystems), we'd better push back before that behaviour spreads. BTW, inotify(7) and inotify_add_watch(2) need to be fixed - they do not mention these limitations at all. Assuming that reader has a clue and realizes that there's no magic is not a good idea... ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: inotify/sysfs 2014-03-31 18:52 ` inotify/sysfs Al Viro @ 2014-03-31 19:13 ` Linus Torvalds 2014-03-31 20:00 ` inotify/sysfs Al Viro 0 siblings, 1 reply; 7+ messages in thread From: Linus Torvalds @ 2014-03-31 19:13 UTC (permalink / raw) To: Al Viro; +Cc: Quentin Glidic, linux-fsdevel, Michael Kerrisk On Mon, Mar 31, 2014 at 11:52 AM, Al Viro <viro@zeniv.linux.org.uk> wrote: > > Linus, what do you think about flat-out refusing to create the watches on > filesystems that can't support them? Well, you seem to think that NFS and other network filesystems can't support them. But they can. It's just that they'll only trigger on *local* changes, not on remote changes. But if you're doing a file manager on a workstation, triggering on local changes is generally exactly what you want. But for /proc and /sys, I suspect you're right and we probably should make it an error to not make people think they can do it. Or we should specify some behavior (maybe it would be ok for certain subdirectories for hotplug detection if we specify exactly when that is ok). Linus ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: inotify/sysfs 2014-03-31 19:13 ` inotify/sysfs Linus Torvalds @ 2014-03-31 20:00 ` Al Viro 2014-03-31 20:10 ` inotify/sysfs Linus Torvalds 0 siblings, 1 reply; 7+ messages in thread From: Al Viro @ 2014-03-31 20:00 UTC (permalink / raw) To: Linus Torvalds; +Cc: Quentin Glidic, linux-fsdevel, Michael Kerrisk On Mon, Mar 31, 2014 at 12:13:10PM -0700, Linus Torvalds wrote: > On Mon, Mar 31, 2014 at 11:52 AM, Al Viro <viro@zeniv.linux.org.uk> wrote: > > > > Linus, what do you think about flat-out refusing to create the watches on > > filesystems that can't support them? > > Well, you seem to think that NFS and other network filesystems can't > support them. > > But they can. It's just that they'll only trigger on *local* changes, > not on remote changes. But if you're doing a file manager on a > workstation, triggering on local changes is generally exactly what you > want. ... except when that workstation has e.g. /var/spool/mail NFS-mounted, with MTA running on server. Or "wait until the job on server puts its results into this file". And yes, I've seen requests along those lines ;-/ Cluster filesystems have the same issue... ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: inotify/sysfs 2014-03-31 20:00 ` inotify/sysfs Al Viro @ 2014-03-31 20:10 ` Linus Torvalds 0 siblings, 0 replies; 7+ messages in thread From: Linus Torvalds @ 2014-03-31 20:10 UTC (permalink / raw) To: Al Viro; +Cc: Quentin Glidic, linux-fsdevel, Michael Kerrisk On Mon, Mar 31, 2014 at 1:00 PM, Al Viro <viro@zeniv.linux.org.uk> wrote: > > ... except when that workstation has e.g. /var/spool/mail NFS-mounted, with > MTA running on server. Or "wait until the job on server puts its results > into this file". And yes, I've seen requests along those lines ;-/ > Cluster filesystems have the same issue... None of that matters. A good file manager uses fsnotify to get efficient and timely local notifications, and also does polling to check by hand - much less timely, but covers the remote case. The point is, fsnotify is very much a valid thing to do even on networked filesystems, and even if you don't get full coverage. The fact that people then *also* may use it incorrectly and think that it is sufficient *without* the polling, that's not our problem. The fact that stupid uses exist is not a reason to disable something that _can_ be used intelligently. Linus ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-03-31 20:10 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-03-27 13:50 inotify/sysfs Quentin Glidic 2014-03-28 17:07 ` inotify/sysfs Jan Kara 2014-03-29 6:25 ` inotify/sysfs Greg KH 2014-03-31 18:52 ` inotify/sysfs Al Viro 2014-03-31 19:13 ` inotify/sysfs Linus Torvalds 2014-03-31 20:00 ` inotify/sysfs Al Viro 2014-03-31 20:10 ` inotify/sysfs Linus Torvalds
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).