anchao opened a new pull request, #21064:
URL: https://github.com/apache/nuttx/pull/21064

   ## Summary                                                                   
   
                                                                                
   
   Fix rwbuffer write-buffer flushing so dirty data is preserved when a flush   
   
   operation fails.                                                             
   
                                                                                
   
   Previously, `rwb_wrflush()` only logged failed or short write-buffer 
flushes,   
   then reset the write buffer anyway. This could drop dirty buffered data 
while   
   `rwb_flush()` still reported success to the caller.                          
   
                                                                                
   
   This change makes `rwb_wrflush()` return an error when:                      
   
                                                                                
   
   - padding reads fail                                                         
   
   - padding reads return fewer blocks than requested                           
   
   - the underlying write-buffer flush fails                                    
   
   - the underlying flush writes fewer blocks than requested                    
   
                                                                                
   
   On failure, the write buffer is not reset, so the dirty data remains 
available  
   for a later retry.                                                           
   
                                                                                
   
   ## Impact                                                                    
   
                                                                                
   
   This fixes a data-loss risk in the rwbuffer write-buffer path.               
   
                                                                                
   
   Expected impact:                                                             
   
                                                                                
   
   - failed flushes are now reported to callers                                 
   
   - dirty buffered data is preserved when flush or padding-read errors occur   
   
   - short reads/writes are treated as `-EIO`                                   
   
   - successful flush behavior is unchanged                                     
   
   - no API, ABI, build-system, documentation, or security impact is expected   
   
                                                                                
   
   ## Testing                                                                   
   
   
   sim/nsh


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to