Re: [PATCH] f2fs: fix out-of-free problem caused by atomic write
From: Jaegeuk Kim
Date: Fri Oct 27 2017 - 07:23:38 EST
On 10/26, Christoph Hellwig wrote:
> On Thu, Oct 26, 2017 at 04:30:19PM +0200, Jaegeuk Kim wrote:
> > On 10/26, Yunlong Song wrote:
> > > f2fs_balance_fs only actives once in the commit_inmem_pages, but there
> > > are more than one page to commit, so all the other pages will miss the
> > > check. This will lead to out-of-free problem when commit a very large
> > > file. To fix it, we should do f2fs_balance_fs for each inmem page.
> >
> > NAK, this breaks atomicity.
>
> Can someone please explain (and write down in e.g. manpages) these
> atomicy rules?
The basic idea is to provide atomicity of blocks written by write(2) given
period managed by user. For example, user can do 1) ioctl to start a period,
2) write(2) calls, 3) ioctl to commit all the blocks. Then, filesystem will
guarantee committed blocks should be recovered all or nothing after power-cut.
Scenario #1:
- ioctl(fd, F2FS_IOC_START_ATOMIC_WRITE)
- 0 = write(2)
- ...
- 0 = write(2)
- ioctl(fd, F2FS_IOC_COMMIT_ATOMIC_WRITE)
Scenario #2:
- ioctl(fd, F2FS_IOC_START_ATOMIC_WRITE)
- 0 = write(2)
- ...
- err = write(2)
- ioctl(fd, F2FS_IOC_ABORT_ATOMIC_WRITE)
Scenario #3:
- ioctl(fd, F2FS_IOC_START_ATOMIC_WRITE)
- 0 = write(2)
- ...
- process crashed or close(fd)
Thanks,