@nvlsianpu, I think I understand your proposed solution, and I believe it would 
indeed solve this problem.  However, I think there may be another issue that 
the solution does not address (this issue exists in the current implementation 
as well).

#### Key

| Symbol        | Meaning |
| ------------- | ------- |
| DEL x         | Deletion record for inode `x` |
| fx(p=y)       | File inode with ID `x`; parent directory has ID `y`   |
| bx(p=y)       | Data block with ID `x`; parent file has ID `y`   |

Say we have the following NFFS layout:

| Area 0        | Area 1        | Scratch       | Area 3        |
| ------------- | ------------- | ------------- | ------------- |
| f100(p=0)     | b3(p=100)     | ...           | b5(p=200)     |
| b1(p=100)     | b4(p=100)     | ...           | b6(p=200)     |
| b2(p=100)     | f200(p=0)     | ...           | DEL 100       |

In other words, we have two files, `100` and `200`.  Each file contains several 
data blocks.  Finally, file `100` has recently been deleted.

When garbage collection occurs, the disk will now look like this:

| Area 0        | Area 1        | Area 2        | Scratch       |
| ------------- | ------------- | ------------- | ------------- |
| f100(p=0)     | b3(p=100)     | b5(p=200)     | ...           |
| b1(p=100)     | b4(p=100)     | b6(p=200)     | ...           |
| b2(p=100)     | f200(p=0)     |               | ...           |

That is, the deletion record gets erased.

If the system reboots, file `100` now looks valid again; its deletion record 
was lost.

I might not be thinking hard enough, but I still believe we need some 
chronological ordering of records within the disk.

[ Full content available at: https://github.com/apache/mynewt-nffs/issues/10 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to