Hello: Can we modify it like this First: modify "return (n_free_chunks > 0) ? 1 : 0;" Second: In the function "yaffs_file_write" yaffs_gross_lock(dev); n_free_chunks = yaffs_get_n_free_chunks(dev); yaffs_gross_unlock(dev); if (n_free_chunks > 20 ) n_written = yaffs_wr_file(obj, buf, ipos, n, 0); else n_written = yaffs_wr_file(obj, buf, ipos, n, 1); So we can get through write_end() .The data will not be just in the cache when multiple processes simultaneously write. What do you think ? Thanks you Regards chenjie On 2015/8/4 18:40, chenjie wrote: > Hello: > Can we modify it like this > First: > modify "return (n_free_chunks > 0) ? 1 : 0;" > > Second: > In the function "yaffs_file_write" > > yaffs_gross_lock(dev); > n_free_chunks = yaffs_get_n_free_chunks(dev); > yaffs_gross_unlock(dev); > > if (n_free_chunks > 20 ) > n_written = yaffs_wr_file(obj, buf, ipos, n, 0); > else > n_written = yaffs_wr_file(obj, buf, ipos, n, 1); > > So we can get through write_end() .The data will not be just > in the cache when multiple processes simultaneously write. > > What do you think ? > > Thanks you > > Regards > > chenjie > > > > > > > > On 2015/8/4 6:50, Charles Manning wrote: >> I don't think that will work. >> >> Consider the case when multiple processes simultaneously write to the >> file system. If they all get past write_begin(), but have not yet got >> through write_end() then yaffs has committed to storing the data even >> if there is no space available. >> >> I do however see your point. An overwrite might be refused even though >> it really does not use any space. >> >> I will see if there are any page buffer flags we can use to determine >> if the page has already been written. >> >> That would allow us to do something like: >> >> if (page has previously been written) >> return OK; /* it is an overwrite so it does not consume space */ >> else >> return n_free_chunks > commit_count; /* Is there space to take more data */ >> >> >> On Mon, Aug 3, 2015 at 9:57 PM, chenjie wrote: >>> >>> >>> Hello >>> I think this is no need, just "return (n_free_chunks > 0) ? 1 : 0;" is OK. >>> >>> if not , we can not overwrite a file with an existent file >>> when the chunk was less than 20. >>> >>> What do you think ? >>> >>> >>> Thanks you >>> >>> Regards >>> >>> chenjie >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> On 2015/7/31 6:13, Charles Manning wrote: >>>> The purpose of yaffs_hold_space() is to support the write_begin VFS method. >>>> >>>> write_begin asks the file system to commit enough space to do the actual write in write_end. >>>> >>>> Strictly speaking this should really be handled with counter of committed space that is incremented on every write_begin and decremented on every write_end. >>>> >>>> However, it is workable to just not expect there to be more than n writes in progress at a time. n=20 seems rather conservative. >>>> >>>> -- Charles >>>> >>>> >>>> On Thu, Jul 30, 2015 at 3:04 PM, chenjie > wrote: >>>> >>>> >>>> Hi: >>>> why the yaffs_hold_space reserved 20 chunk? >>>> return (n_free_chunks > 20) ? 1 : 0; >>>> >>>> >>>> >>>> >>> >>> >> >> >