From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752511AbdJ0LXd (ORCPT ); Fri, 27 Oct 2017 07:23:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:35748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752151AbdJ0LXb (ORCPT ); Fri, 27 Oct 2017 07:23:31 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 314BB21871 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jaegeuk@kernel.org Date: Fri, 27 Oct 2017 13:23:26 +0200 From: Jaegeuk Kim To: Christoph Hellwig Cc: Yunlong Song , chao@kernel.org, yuchao0@huawei.com, yunlong.song@icloud.com, miaoxie@huawei.com, bintian.wang@huawei.com, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] f2fs: fix out-of-free problem caused by atomic write Message-ID: <20171027112326.GC96994@jaegeuk-macbookpro.roam.corp.google.com> References: <1509027715-80477-1-git-send-email-yunlong.song@huawei.com> <20171026143019.GB67431@jaegeuk-macbookpro.roam.corp.google.com> <20171027063854.GA25279@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171027063854.GA25279@infradead.org> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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,