Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4271801ybe; Mon, 9 Sep 2019 06:59:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6BEbWpkUeBdvlzCEGVpR5gWmM17/ymBRDE9cFX5U8kNdbW7eo+N1g1eMP3BlLFm48NJ3S X-Received: by 2002:a17:906:b2ca:: with SMTP id cf10mr19144975ejb.86.1568037561492; Mon, 09 Sep 2019 06:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568037561; cv=none; d=google.com; s=arc-20160816; b=DNpDBvmFjOuVb2jUWKfBdwQrD+OiT5Se5DvvRVb0PJHR+7/1slUeKJ30sLsRl800DC oLkEC+LtNfD9mrlLRy/vxjLgVaTPaGVelVkLDSAX6a77uU2SamvNKEFIH9H5sJiYe/0x h6Ez37FZY0HcKCoY59QYATXEM1zUHx13f96YNBgwOHP1jehsEtMtlASB/x3L5ocuDujy 1BTI8XnA09kpPvVFwQIeVtPBQ+G8bKERmQD3Q5OcWgkCvsoyIwrozwT+fo2FMRrLphls bvRBNMweN2WBvYimI51HWDOJlhz5yfEbJ/3U/mB98QB6crXcdRJXzuvH3JRPQXoGrGz9 DP9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UzSKnUF9CZP/jJLR7HNJFYe8k+sRYvpB9urhBh3Nwz4=; b=saGre5PfxGD17H7tMuvez/FcHDGWUVArHSFT/IWsDaYJl+l6Btm7YNyDzZrCjjzf0O kxCjc5vmG/h0M+j3inrg2uLXKEemgu6vF3AMeSKYZ6nWy/EwpTKLAEpLilLq0qPGJ01D rpMqPJLBDDi8nIpNrNf8I9hBOToBLU6TmcD1REwIxiIF4xIg0PwjhYFv1VmfIB4xxnS6 DeLC39dc7sVZCVerBzN3b2MVxlNPi1x88zZkafrlv66Ab6Qw0moQ/D1W6TpVlSLwzU27 IQ7NCDYQPJxXcTnrX4G5WQ/5y6CZULen9r1pjPhGqOTrlby6gQxRLXxy+4W6y6+kDlZW pBmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zcBrCtlo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11si4708044edr.307.2019.09.09.06.58.57; Mon, 09 Sep 2019 06:59:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zcBrCtlo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732152AbfIIBZk (ORCPT + 99 others); Sun, 8 Sep 2019 21:25:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:40904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731552AbfIIBZj (ORCPT ); Sun, 8 Sep 2019 21:25:39 -0400 Received: from localhost (unknown [148.69.85.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CCB5C216C8; Mon, 9 Sep 2019 01:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567992339; bh=c5iYQQVsV3m8rZv2AFPoJVLzj+j/X5goBLwITQhY718=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zcBrCtlof5t+yUkGL7CbY5BUnlu6NlVsEr+4tM4lhdyApaccv3hBYGyfrTtKPNXy+ J21mXiHumY44/sSGKnLEQ3MIy2tXZ6G9TKOwELvnaVuoe5GG6/DKKfdrE2+HVa5XO2 h4RcmlTjOFQK1+22GS2WSlJmOTPtK73rJWSWSltA= From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 2/2] f2fs: avoid infinite GC loop due to stale atomic files Date: Mon, 9 Sep 2019 02:25:32 +0100 Message-Id: <20190909012532.20454-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20190909012532.20454-1-jaegeuk@kernel.org> References: <20190909012532.20454-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If committing atomic pages is failed when doing f2fs_do_sync_file(), we can get commited pages but atomic_file being still set like: - inmem: 0, atomic IO: 4 (Max. 10), volatile IO: 0 (Max. 0) If GC selects this block, we can get an infinite loop like this: f2fs_submit_page_bio: dev = (253,7), ino = 2, page_index = 0x2359a8, oldaddr = 0x2359a8, newaddr = 0x2359a8, rw = READ(), type = COLD_DATA f2fs_submit_read_bio: dev = (253,7)/(253,7), rw = READ(), DATA, sector = 18533696, size = 4096 f2fs_get_victim: dev = (253,7), type = No TYPE, policy = (Foreground GC, LFS-mode, Greedy), victim = 4355, cost = 1, ofs_unit = 1, pre_victim_secno = 4355, prefree = 0, free = 234 f2fs_iget: dev = (253,7), ino = 6247, pino = 5845, i_mode = 0x81b0, i_size = 319488, i_nlink = 1, i_blocks = 624, i_advise = 0x2c f2fs_submit_page_bio: dev = (253,7), ino = 2, page_index = 0x2359a8, oldaddr = 0x2359a8, newaddr = 0x2359a8, rw = READ(), type = COLD_DATA f2fs_submit_read_bio: dev = (253,7)/(253,7), rw = READ(), DATA, sector = 18533696, size = 4096 f2fs_get_victim: dev = (253,7), type = No TYPE, policy = (Foreground GC, LFS-mode, Greedy), victim = 4355, cost = 1, ofs_unit = 1, pre_victim_secno = 4355, prefree = 0, free = 234 f2fs_iget: dev = (253,7), ino = 6247, pino = 5845, i_mode = 0x81b0, i_size = 319488, i_nlink = 1, i_blocks = 624, i_advise = 0x2c In that moment, we can observe: [Before] Try to move 5084219 blocks (BG: 384508) - data blocks : 4962373 (274483) - node blocks : 121846 (110025) Skipped : atomic write 4534686 (10) [After] Try to move 5088973 blocks (BG: 384508) - data blocks : 4967127 (274483) - node blocks : 121846 (110025) Skipped : atomic write 4539440 (10) Signed-off-by: Jaegeuk Kim --- fs/f2fs/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 7ae2f3bd8c2f..68b6da734e5f 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1997,11 +1997,11 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp) goto err_out; ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true); - if (!ret) { - clear_inode_flag(inode, FI_ATOMIC_FILE); - F2FS_I(inode)->i_gc_failures[GC_FAILURE_ATOMIC] = 0; - stat_dec_atomic_write(inode); - } + + /* doesn't need to check error */ + clear_inode_flag(inode, FI_ATOMIC_FILE); + F2FS_I(inode)->i_gc_failures[GC_FAILURE_ATOMIC] = 0; + stat_dec_atomic_write(inode); } else { ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 1, false); } -- 2.19.0.605.g01d371f741-goog