Hello Chris
I have been out on vacation for the last two weeks, so please forgive my
tardiness in responding.
On Wed, Dec 24, 2014 at 9:45 AM, <
Chris.Gofforth@corp.rockwellcollins.com>
wrote:
>
> The following is the checkpt_close function, ( for yaffs2)
>
> I noticed that the values of dev*->*n_free_chunks and dev*->*
> n_erased_blocks are being modified each time this function is called.
> Should they only be modified if the checkpt was open for writing , not
> reading?
>
> Will this not cause an incorrect count value, as it occurs on a close for
> read operation?
>
I believe the code is correct.
At the time this code is called, the dev values that were snapshotted by
the yaffs2_wr_checkpt_dev() function have been restored by the
yaffs_rd_checkpt_dev() function and thus in both the read and write cases
this represents the pre-checkpoint state. In both cases, the read and
write cases, the current flash state has been reduced by the space taken up
by the checkpoint.
As soon as the checkpoint is invalidated, yaffs_checkpt_erase() is called
which will then free the space up again.
> Also: If the buffers are not freed, then the checkpt_open () function
> would not try to re-allocate memory, as the buffers would exist. Since the
> checkpoint size would not change for the given device, this should be OK.
>
>
> Does this sound valid?
>
That does sound valid, but the buffer is logically part of the "stream". If
it is created by xx_open, then it should be deleted by xx_close. IMHO a
better way to keep it live would be to allocate it as part of the device
initialisation with all the other buffers.
Regards
-- Charles
>
>
>
>
> * int* yaffs_checkpt_close*(**struct* yaffs_dev ***dev
> *) {*
> *int* i*;*
>
> *if* *(*dev*->*checkpt_open_write*)* *{*
> *if* *(*dev*->*checkpt_byte_offs *!=*
> *sizeof**(**sizeof**(**struct* yaffs_checkpt_chunk_hdr*)))*
> yaffs2_checkpt_flush_buffer*(*dev*);*
> *}* *else* *if* *(*dev*->*checkpt_block_list*)* *{*
> *for* *(*i *=* 0*;*
> i *<* dev*->*blocks_in_checkpt *&&*
> dev*->*checkpt_block_list*[*i*]* *>=* 0*;* i*++)* *{*
> *int* blk *=* dev*->*checkpt_block_list*[*i*];*
> *struct* yaffs_block_info ***bi *=* NULL*;*
>
> *if* *(*dev*->*internal_start_block *<=* blk *&&*
> blk *<=* dev*->*internal_end_block*)*
> bi *=* yaffs_get_block_info*(*dev*,* blk*);*
> *if* *(*bi *&&* bi*->*block_state *==* YAFFS_BLOCK_STATE_EMPTY
> *)*
> bi*->*block_state *=* YAFFS_BLOCK_STATE_CHECKPOINT*;*
> *}*
> yaffsfs_free*(*dev*->*checkpt_block_list*);* */* TODO: we do not
> want to free the buffer, but rather re-use it */*
> dev*->*checkpt_block_list *=* NULL*;*
> *}*
> */* TODO: following should only be applicable if it was open for
> writing */*
> dev*->*n_free_chunks *-=*
> dev*->*blocks_in_checkpt *** dev*->*param*.*chunks_per_block*;*
> dev*->*n_erased_blocks *-=* dev*->*blocks_in_checkpt*;*
>
> yaffs_trace*(*YAFFS_TRACE_CHECKPOINT*,* "checkpoint byte count %d"*,*
> dev*->*checkpt_byte_count*);*
>
> *if* *(*dev*->*checkpt_buffer*)* *{*
> */* free the buffer */*
> yaffsfs_free*(*dev*->*checkpt_buffer*);* */* TODO: we do not want
> to free the buffer, but rather re-use it */*
> dev*->*checkpt_buffer *=* NULL*;*
> *return* 1*;*
> *}* *else* *{*
> *return* 0*;*
>
> *} }*
>
>
>
>
>
> Thanks
>
> Chris
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> yaffs mailing list
> yaffs@lists.aleph1.co.uk
> http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs
>
>