mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-14 03:44:58 +08:00
cpukit/jffs2/gc.c: Prevent live lock for split reads
In some cases a file read is not completed in a single call into the JFFS2 layer and the inode is left in the READING state. When this happens, it's possible for a garbage collection pass to be initiated before completion of the read. In some such cases, the garbage collection pass is executed in a tight loop that expects granular locking to allow forward progress of the read between collection passes. With RTEMS monolithic locking of the JFFS2 layer, forward progress is not possible in this situation since the monolithic lock is never released inside the loop. The solution is to have the garbage collection pass return failure when no progress is possible due to a bad inode state. This allows the read to complete and the collection pass can be attempted at a later time.
This commit is contained in:
committed by
Kinsey Moore
parent
38e8e5c286
commit
f34f2e0bf9
@@ -417,7 +417,17 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
|
||||
|
||||
A: Small enough that I don't care :)
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
return 0;
|
||||
#else
|
||||
/*
|
||||
* Since RTEMS uses monolithic locking around JFFS2, returning 0
|
||||
* here results in a livelock since no other progress will ever
|
||||
* be made as some callers are in a tight loop with no relevant
|
||||
* lock modification.
|
||||
*/
|
||||
return -EIO;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* OK. Now if the inode is in state INO_STATE_GC, we are going to copy the
|
||||
|
||||
Reference in New Issue
Block a user