From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Neil Brown <neilb@suse.de>, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 04/10] sysfs: sysfs poll keep the poll rule of regular file.
Date: Fri, 17 Apr 2009 12:04:28 -0700 [thread overview]
Message-ID: <1239995074-4065-4-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20090417190144.GB3548@kroah.com>
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Currently, following test programs don't finished.
% ruby -e '
Thread.new { sleep }
File.read("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies")
'
strace expose the reason.
...
open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies", O_RDONLY|O_LARGEFILE) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbf9fa6b8) = -1 ENOTTY (Inappropriate ioctl for device)
fstat64(3, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
_llseek(3, 0, [0], SEEK_CUR) = 0
select(4, [3], NULL, NULL, NULL) = 1 (in [3])
read(3, "1400000 1300000 1200000 1100000 1"..., 4096) = 62
select(4, [3], NULL, NULL, NULL
Because Ruby (the scripting language) VM assume select system-call
against regular file don't block. it because SUSv3 says "Regular files
shall always poll TRUE for reading and writing". see
http://www.opengroup.org/onlinepubs/009695399/functions/poll.html it
seems valid assumption.
But sysfs_poll() don't keep this rule although sysfs file can read and
write always.
This patch restore proper poll behavior to sysfs.
/sys/block/md*/md/sync_action polling application and another sysfs
updating sensitive application still can use POLLERR and POLLPRI.
Cc: Neil Brown <neilb@suse.de>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/sysfs/file.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 979e937..b1606e0 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -446,11 +446,11 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
if (buffer->event != atomic_read(&od->event))
goto trigger;
- return 0;
+ return DEFAULT_POLLMASK;
trigger:
buffer->needs_read_fill = 1;
- return POLLERR|POLLPRI;
+ return DEFAULT_POLLMASK|POLLERR|POLLPRI;
}
void sysfs_notify_dirent(struct sysfs_dirent *sd)
--
1.6.2
next prev parent reply other threads:[~2009-04-17 19:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-17 19:01 [GIT PATCH] driver core patches for 2.6.31-rc2 Greg KH
2009-04-17 19:04 ` [PATCH 01/10] sysfs: don't use global workqueue in sysfs_schedule_callback() Greg Kroah-Hartman
2009-04-22 20:14 ` Andrew Morton
2009-04-28 5:15 ` Alex Chiang
2009-04-17 19:04 ` [PATCH 02/10] driver core: fix driver_match_device Greg Kroah-Hartman
2009-04-17 19:04 ` [PATCH 03/10] driver core: allow non-root users to listen to uevents Greg Kroah-Hartman
2009-04-17 19:04 ` Greg Kroah-Hartman [this message]
2009-04-17 19:04 ` [PATCH 05/10] proc: mounts_poll() make consistent to mdstat_poll Greg Kroah-Hartman
2009-04-17 19:04 ` [PATCH 06/10] Driver Core: early platform driver Greg Kroah-Hartman
2009-04-17 19:04 ` [PATCH 07/10] dynamic debug: resurrect old pr_debug() semantics as pr_devel() Greg Kroah-Hartman
2009-04-17 19:04 ` [PATCH 08/10] driver core: prevent device_for_each_child from oopsing Greg Kroah-Hartman
2009-04-17 19:04 ` [PATCH 09/10] Driver core: remove pr_fmt() from dynamic_dev_dbg() printk Greg Kroah-Hartman
2009-04-17 19:04 ` [PATCH 10/10] UIO: fix specific device driver missing statement for depmod Greg Kroah-Hartman
2009-04-18 3:57 ` [GIT PATCH] driver core patches for 2.6.31-rc2 KOSAKI Motohiro
2009-04-18 16:50 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1239995074-4065-4-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome