[Yaffs] Possible soft deletes issue

Top Page
Attachments:
Message as email
+ (text/plain)
+ soft-deletes.patch (text/x-patch)
Delete this message
Reply to this message
Author: Ross Younger
Date:  
To: yaffs
Subject: [Yaffs] Possible soft deletes issue
Hi all,

I've recently synched up with the latest from the git repo and am trying out
multiple code paths.

I'm seeing an issue with file deletion in one particular case:
* small page (synthetic) flash, so yaffs1 mode
* soft deletes are enabled
* my driver (eCos) is not using the cached inode facility, i.e. myInode is
NULL for all objects

The issue seems to arise as yaffs_DeleteFile calls yaffs_UnlinkFileIfNeeded.
In UnlinkFileIfNeeded, immediateDeletion becomes 1 and (amongst other
things) in->deleted is set. However, DeleteFile then goes on to look only at
its own on-stack `deleted' variable in determining whether or not the
operation has succeeded - which has not been updated in this case, so it
returns what appears to be a spurious failure.

Patch attached for your consideration; it passes my test cases which were
failing, and I'm running a soak test as I type this.


Ross

-- 
Embedded Software Engineer, eCosCentric Limited.
Barnwell House, Barnwell Drive, Cambridge CB5 8UU, UK.
Registered in England no. 4422071.                  www.ecoscentric.com

diff --git a/yaffs_guts.c b/yaffs_guts.c
index d55aa95..d466fe7 100644
--- a/yaffs_guts.c
+++ b/yaffs_guts.c
@@ -5624,7 +5624,6 @@ static int yaffs_UnlinkFileIfNeeded(yaffs_Object *in)
 int yaffs_DeleteFile(yaffs_Object *in)
 {
     int retVal = YAFFS_OK;
-    int deleted = in->deleted;
     yaffs_Device *dev = in->myDev;


     if (dev->param.disableSoftDelete || dev->param.isYaffs2)
@@ -5639,11 +5638,10 @@ int yaffs_DeleteFile(yaffs_Object *in)


         if (retVal == YAFFS_OK && in->unlinked && !in->deleted) {
             in->deleted = 1;
-            deleted = 1;
             in->myDev->nDeletedFiles++;
             yaffs_SoftDeleteFile(in);
         }
-        return deleted ? YAFFS_OK : YAFFS_FAIL;
+        return in->deleted ? YAFFS_OK : YAFFS_FAIL;
     } else {
         /* The file has no data chunks so we toss it immediately */
         yaffs_FreeTnode(in->myDev, in->variant.fileVariant.top);