Ticket #1433: read_err.patch

File read_err.patch, 3.0 KB (added by Oleg, on 11/04/09 at 16:12:15)

This is the proposed patch

Line 
1Index: src/bdbuf.c
2===================================================================
3RCS file: /usr1/CVS/rtems/cpukit/libblock/src/bdbuf.c,v
4retrieving revision 1.42
5diff -r1.42 bdbuf.c
61472a1473
7> start:
81679a1681,1691
9>       case RTEMS_BDBUF_STATE_EMPTY:
10>         /*
11>          * Buffer transfer finished with an error and read procedure
12>          * (for another task) put this buffer into ready list and removed it
13>          * from AVL tree, so we need to start from the beginning - try to
14>          * re-read the buffer.
15>          */
16>         assert(rtems_bdbuf_avl_search (&pool->tree, device, block) == NULL);
17>         goto start;
18>         break;
19>
201800a1813,1830
21> /**
22>  * An auxiliary function that is used to put a buffer in ready
23>  * queue with EMPTY state.
24>  *
25>  * @param[in] bd    Pointer to a buffer that needs to be released.
26>  *
27>  * @return N/A
28>  */
29> static void
30> rtems_bdbuf_release_empty(rtems_bdbuf_buffer *bd)
31> {
32>   bd->state = RTEMS_BDBUF_STATE_EMPTY;
33>   rtems_chain_prepend (&bdbuf_cache.ready, &bd->link);
34>
35>   if (rtems_bdbuf_avl_remove (&bdbuf_cache.tree, bd) != 0)
36>     rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_CONSISTENCY_9);
37> }
38>
392009a2040,2053
40>     /*
41>      * Release requested buffer because it does not
42>      * keep valid data.
43>      */
44>     if (req->status != RTEMS_SUCCESSFUL)
45>     {
46>         bd = req->bufs[0].user;
47>
48>         if (bd->waiters)
49>           wake_transfer = true;
50>
51>         rtems_bdbuf_release_empty(bd);
52>     }
53>
542013c2057
55<       if (!bd->error)
56---
57>       if (req->status != RTEMS_SUCCESSFUL)
582015d2058
59<       bd->state = RTEMS_BDBUF_STATE_READ_AHEAD;
602022c2065,2066
61<       rtems_chain_prepend (&bdbuf_cache.ready, &bd->link);
62---
63>       if (bd->waiters)
64>         wake_transfer = true;
652024,2029c2068
66<       /*
67<        * If there is an error remove the BD from the AVL tree as it is invalid,
68<        * then wake any threads that may be waiting. A thread may have been
69<        * waiting for this block and assumed it was in the tree.
70<        */
71<       if (bd->error)
72---
73>       if (req->status != RTEMS_SUCCESSFUL)
742031,2033c2070,2080
75<         bd->state = RTEMS_BDBUF_STATE_EMPTY;
76<         if (rtems_bdbuf_avl_remove (&bdbuf_cache.tree, bd) != 0)
77<           rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_CONSISTENCY_9);
78---
79>         /*
80>          * If there is an error remove the BD from the AVL tree as it is invalid,
81>          * then wake any threads that may be waiting. A thread may have been
82>          * waiting for this block and assumed it was in the tree.
83>          */
84>         rtems_bdbuf_release_empty(bd);
85>       }
86>       else
87>       {
88>         bd->state = RTEMS_BDBUF_STATE_READ_AHEAD;
89>         rtems_chain_prepend (&bdbuf_cache.ready, &bd->link);
902035,2037d2081
91<
92<       if (bd->waiters)
93<         wake_transfer = true;
942044c2088,2095
95<     
96---
97>   
98>     if (req->status != RTEMS_SUCCESSFUL)
99>     {
100>         rtems_bdbuf_unlock_pool (pool);
101>         rtems_disk_release (dd);
102>         return req->status;
103>     }
104>