[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

jffs garbage collection and signal handling



Hi,

While debugging an application which heavily uses signals, I noticed
that write calls sometimes returned -EINTR even though the signal
handlers were registered with the SA_RESTART flag. Looking at
jffs2/nodemgmt.c and jffs2/gc.c I noticed jffs2_reserve_space,
jffs2_reserve_space and jffs2_garbage_collect_pass return -EINTR when a
signal is pending or a garbage collect is already running. I changed
this to return -ERESTARTSYS (see patch). This seems to solve the
problem. Why returns jffs2 -EINTR instead of -ERESTARTSYS ? Is there
some side effect of -ERESTARTSYS overlooked ?

Thanks,

Peter.
--- mtd/fs/jffs2/nodemgmt.c.orig	Fri Oct 11 11:28:35 2002
+++ mtd/fs/jffs2/nodemgmt.c	Fri Oct 11 11:34:29 2002
@@ -82,7 +82,7 @@
 			cond_resched();
 
 			if (signal_pending(current))
-				return -EINTR;
+				return -ERESTARTSYS;
 
 			down(&c->alloc_sem);
 			spin_lock_bh(&c->erase_completion_lock);
@@ -217,7 +217,7 @@
 			remove_wait_queue(&c->erase_wait, &wait);
 			spin_lock_bh(&c->erase_completion_lock);
 			if (signal_pending(current)) {
-				return -EINTR;
+				return -ERESTARTSYS;
 			}
 			/* An erase may have failed, decreasing the
 			   amount of free space available. So we must
--- mtd/fs/jffs2/gc.c.orig	Fri Oct 11 11:37:41 2002
+++ mtd/fs/jffs2/gc.c	Fri Oct 11 11:35:14 2002
@@ -119,7 +119,7 @@
 	int ret = 0;
 
 	if (down_interruptible(&c->alloc_sem))
-		return -EINTR;
+		return -ERESTARTSYS;
 
 	spin_lock_bh(&c->erase_completion_lock);