mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-21 06:36:27 +00:00
Reading from /sys/kernel/scst_tgt/devices/*/filename can (at
least in theory) fail with -EAGAIN. Make sure that scstadmin
retries reading from a sysfs variable if that happens. This
patch has been tested by adding the following error injection
code in scst_sysfs.c:
--------------------------- scst/src/scst_sysfs.c ----------------------------
index 0509703..69efd80 100644
@@ -523,6 +523,22 @@ int scst_sysfs_queue_wait_work(struct scst_sysfs_work_item *work)
"failed: %d", atomic_read(&uid_thread_name),
(int)PTR_ERR(t));
+#if 1
+ {
+ static int cnt;
+ if (!work->read_only_action || cnt++ % 4 < 3) {
+ /*
+ * Helps testing user space code that writes to or
+ * reads from SCST sysfs variables.
+ */
+ timeout = 0;
+ rc = 0;
+ res = -EAGAIN;
+ goto out_put;
+ }
+ }
+#endif
+
while (1) {
rc = wait_for_completion_interruptible_timeout(
&work->sysfs_work_done, timeout);
------------------------------------------------------------------------------
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4498 d57e44dd-8a1f-0410-8b47-8ef2f437770f