Flash update during garbage collection

Hello,

I am performing garbage collection. During the garbage collection an event could be fired (from the softdevice) that causes updating of records.

My question is:

Will updating the record cause failure to the update process or failure to the garbage collection process?

Should I disable events that leads to updating of records?

Or will the update event be queued until the garbage collection has ended?

 

I have been trying to find the answer in your documentation, but no luck so far.

 

 

All the Best

Thomas

Parents
  • Hello Thomas,

    If you are using the softdevice, then your fds will use fstorage with the softdevice backend, so the softdevice will handle all reads and writes, and hence, it should be taken care of. 

    In addition, fds itself has a queue, so calling fds_gc() will not immediately start the garbage collection, but it will put that task in the queue:

    ret_code_t fds_gc(void)
    {
        fds_op_t * p_op;
        nrf_atfifo_item_put_t iput_ctx;
    
        if (!m_flags.initialized)
        {
            return FDS_ERR_NOT_INITIALIZED;
        }
    
        p_op = queue_buf_get(&iput_ctx);
        if (p_op == NULL)
        {
            return FDS_ERR_NO_SPACE_IN_QUEUES;
        }
    
        p_op->op_code = FDS_OP_GC;
    
        queue_buf_store(&iput_ctx);
    
        if (m_gc.state != GC_BEGIN)
        {
            // Resume GC by retrying the last step.
            m_gc.resume = true;
        }
    
        queue_start();
    
        return NRF_SUCCESS;
    }

    And as you can see, in the end it will start the queue. Similarly, when you write or update a record, it will not be executed immediately, but put on top of the queue, so that if you want to write something while a GC is ongoing, it will add that operation to the queue, and then resume the queue, in which it will finish the GC first.

    The only cases where operations are not queued is when they return FDS_ERR_NO_SPACE_IN_QUEUE, in which case you can increase FDS_OP_QUEUE_SIZE. For more info, see the Configuration section of the FDS documentation.

    I hope that cleared up some things. 

    Best regards,

    Edvin

Reply
  • Hello Thomas,

    If you are using the softdevice, then your fds will use fstorage with the softdevice backend, so the softdevice will handle all reads and writes, and hence, it should be taken care of. 

    In addition, fds itself has a queue, so calling fds_gc() will not immediately start the garbage collection, but it will put that task in the queue:

    ret_code_t fds_gc(void)
    {
        fds_op_t * p_op;
        nrf_atfifo_item_put_t iput_ctx;
    
        if (!m_flags.initialized)
        {
            return FDS_ERR_NOT_INITIALIZED;
        }
    
        p_op = queue_buf_get(&iput_ctx);
        if (p_op == NULL)
        {
            return FDS_ERR_NO_SPACE_IN_QUEUES;
        }
    
        p_op->op_code = FDS_OP_GC;
    
        queue_buf_store(&iput_ctx);
    
        if (m_gc.state != GC_BEGIN)
        {
            // Resume GC by retrying the last step.
            m_gc.resume = true;
        }
    
        queue_start();
    
        return NRF_SUCCESS;
    }

    And as you can see, in the end it will start the queue. Similarly, when you write or update a record, it will not be executed immediately, but put on top of the queue, so that if you want to write something while a GC is ongoing, it will add that operation to the queue, and then resume the queue, in which it will finish the GC first.

    The only cases where operations are not queued is when they return FDS_ERR_NO_SPACE_IN_QUEUE, in which case you can increase FDS_OP_QUEUE_SIZE. For more info, see the Configuration section of the FDS documentation.

    I hope that cleared up some things. 

    Best regards,

    Edvin

Children
No Data
Related