Re: [Yaffs] questions about yaffs_WriteDataToFile

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: zheng shi
Date:  
To: YAFFS, Charles Manning
Subject: Re: [Yaffs] questions about yaffs_WriteDataToFile
There're many unnecessary reads for inband mode in yaffs_WriteDataToFile.


if (nToCopy != dev->nDataBytesPerChunk || dev->inbandTags) {
    /* An incomplete start or end chunk (or maybe both start and end chunk),
     * or we're using inband tags, so we want to use the cache buffers.
     */
    if (dev->nShortOpCaches > 0) {
        yaffs_ChunkCache *cache;
        /* If we can't find the data in the cache, then load the cache */
        cache = yaffs_FindChunkCache(in, chunk);


        if (!cache
            && yaffs_CheckSpaceForAllocation(in->
                             myDev)) {
            cache = yaffs_GrabChunkCache(in->myDev);
            cache->object = in;
            cache->chunkId = chunk;
            cache->dirty = 0;
            cache->locked = 0;
+        if (chunk<=in->nDataChunks)
            yaffs_ReadChunkDataFromObject(in, chunk,
                              cache->
                              data);
        } else if (cache &&
            !cache->dirty &&
            !yaffs_CheckSpaceForAllocation(in->myDev)) {
            /* Drop the cache if it was a read cache item and
             * no space check has been made for it.
             */
             cache = NULL;
        }


On Mon, Sep 14, 2009 at 3:41 PM, zheng shi <> wrote:
> 1. When written bytes are appended to the end of file,
>  there's no need to read the correspoding chunks.
> The overhead is unnecessary and was especially
> large before yaffs_guts.c version 1.89.


>
> 2. In yaffs_ReadChunkDataFromObject, the condition
> should be changed:
>
> static int yaffs_ReadChunkDataFromObject(yaffs_Object *in, int chunkInInode,
>                    __u8 *buffer)
> {
>    int chunkInNAND = yaffs_FindChunkInFile(in, chunkInInode, NULL);
>
> -    if (chunkInNAND >= 0)
> +   if (chunkInNAND > 0)
>        return yaffs_ReadChunkWithTagsFromNAND(in->myDev, chunkInNAND,
>                        buffer, NULL);
>    else {
>        T(YAFFS_TRACE_NANDACCESS,
>          (TSTR("Chunk %d not found zero instead" TENDSTR),
>           chunkInNAND));
>        /* get sane (zero) data if you read a hole */
>        memset(buffer, 0, in->myDev->nDataBytesPerChunk);
>        return 0;
>    }
>
> --
> Regards, Shizheng
>




--
Regards, Shizheng