You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/11/20 02:08:47 UTC

[incubator-nuttx] branch master updated: Revert "fs/nxffs: Fix scan good block slowly and scan an invalid block"

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 9393572  Revert "fs/nxffs: Fix scan good block slowly and scan an invalid block"
9393572 is described below

commit 9393572aead2c92bc8948d5f4a92eead19b7fe96
Author: Brennan Ashton <ba...@brennanashton.com>
AuthorDate: Wed Nov 18 21:35:57 2020 -0800

    Revert "fs/nxffs: Fix scan good block slowly and scan an invalid block"
    
    This reverts commit 97be116a39fee62b8f7027fd93d93789a6d04abb.
    
    This commit broke nxffs.  This leaves the first block as empty which
    then exposes another bug where when the pack is called because we
    have reached the end of flash and need to look for deleted inodes
    we search the first block find no inode and assume that there
    are no more inodes.  This then results in corrupting the filesystem
    by writing over existing inodes.
    
    This can be seen by runing the sim:nxffs configuration.
    Prior to this commit the first pass of writing files would look like
    this:
    NXFFS Dump:
      BLOCK:OFFS  TYPE  STATE   LENGTH
          0:5     INODE OK       2680
          0:78    DATA  OK        424
          1:5     DATA  OK        497
          2:5     DATA  OK        497
          3:5     DATA  OK        497
          4:5     DATA  OK        497
          5:5     DATA  OK        268
          5:283   INODE OK       7410
          5:425   DATA  OK         77
          6:5     DATA  OK        497
    
    With this commit:
    NXFFS Dump:
      BLOCK:OFFS  TYPE  STATE   LENGTH
          0:0     BLOCK ERASED    512
          1:5     INODE OK       6394
          1:39    DATA  OK        463
          2:5     DATA  OK        497
          3:5     DATA  OK        497
    
    Signed-off-by: Brennan Ashton <ba...@brennanashton.com>
---
 fs/nxffs/nxffs_initialize.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/fs/nxffs/nxffs_initialize.c b/fs/nxffs/nxffs_initialize.c
index 8491d6c..5695a72 100644
--- a/fs/nxffs/nxffs_initialize.c
+++ b/fs/nxffs/nxffs_initialize.c
@@ -495,11 +495,7 @@ int nxffs_limits(FAR struct nxffs_volume_s *volume)
         }
       else
         {
-          volume->ioblock += 1;
-          volume->iooffset = SIZEOF_NXFFS_BLOCK_HDR;
-
-          offset = volume->ioblock * volume->geo.blocksize +
-                   volume->iooffset;
+          offset += nerased + 1;
           nerased = 0;
         }
     }