This simplifies code paths and makes memory leaks less likely. It
also makes memory ownership more explicit by requiring std::move.
This commit requires C++11. References #2179.
Previously pcfstat points to a raw pointer, and it may be leaked if
function returned before deleting it.
So use smart pointer to automatically release the object.
Note that currently s3fs only uses c++03, so we use auto_ptr here, not
unique_ptr, which requires c++11.
Fixes: 6ca5a24a7f ("Fix two inconsistency issues between stat cache and cache file (#2152)")
Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
* Fix inconsistency between stat cache file and cache file
We unlock stat cache file too early in FdEntity::Open(), and would
truncate cache file and update stat cache file, so there's a window that
stat cache doesn't reflect cache file status.
Suggested-by: Takeshi Nakatani <ggtakec@gmail.com>
Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
* Mark pagelist as unloaded if cache file has been truncated
If cache file size doesn't match object size, the cache file might be
corrupted, so invalidate it and save new cache stat file.
Suggested-by: Takeshi Nakatani <ggtakec@gmail.com>
Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
---------
Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
Changed s3fs_truncate function.
This change reduces the number of file uploads if the file size is changed.
On macOS, I have found that the truncate call when "size=0" cannot reflect the file size.(This reason is not understood...)
To avoid this, only when "size=0", the flush method is called as before.
Other than that, I found a bug in FdEntity::Open() and fixed it.
Fixes#1875.
Previously s3fs only created files that had dirty data and not those
with zero-bytes. Regression from
771bbfeac5. References #1013. Found
via pjdfstest. References #1589.
When the temporary storage was full, the old implementation started an
upload even if there was not enough data to completely fill the minimum
multipart size or fill the user-selected multipart size.
The new implementation ensures the minimum multipart size by forcing
the user-selected multipart size.
Fixes#1591