Christopher Collins created MYNEWT-160:
------------------------------------------

             Summary: NFFS - Files with scattered data blocks can cause restore 
failures
                 Key: MYNEWT-160
                 URL: https://issues.apache.org/jira/browse/MYNEWT-160
             Project: Mynewt
          Issue Type: Bug
          Components: NFFS
            Reporter: Christopher Collins
            Assignee: Christopher Collins
             Fix For: v0_8_0_beta2


If a file's data blocks are written to disk in an "unexpected" order, the 
subsequent restore operation can fail in a few ways:

1. The restore fails with an FS_ECORRUPT error code.
2. The file is only partially restored; the end of the file will be 
inaccessible.

This bug is rooted in the inconvenient data structure that NFFS uses for 
chained data blocks (reverse singly-linked list).  The data structure is 
inconvenient, but it is used to minimize RAM and flash usage.

On disk, each data block indicates the ID of the preceding data block in the 
parent file.  In RAM, a file inode provides access to all the constituent data 
blocks by maintaining a pointer to the last data block.

The bug is that the NFFS code does not always ensure that a file inode points 
to its last data block.  The code assumes that data blocks will be restored in 
order of increasing file offset.  If data blocks are restored in any other 
order, this bug occurs.

The correct fix will be quite involved.  I am going to implement a quick fix 
for 0.8.0 which fixes the bug, but introduces some horrible inefficiencies when 
large files are restored.  I will schedule a proper fix for 0.9.0.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to