Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2346004ybx; Fri, 8 Nov 2019 03:06:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwLTHYfhe+3lC0+tg60U5pNmqUfPApEBe64yiERGOgG4BLWey8FuMP7awmMbH15+oGOcMXK X-Received: by 2002:a17:906:4d93:: with SMTP id s19mr8049851eju.285.1573211193363; Fri, 08 Nov 2019 03:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573211193; cv=none; d=google.com; s=arc-20160816; b=f2kgkKap4cEXv/ifERJ87nSs8iLffZ+r1wuyhTv7DwSjeMPi8ps/dx9Uhg4oj8d1Jm ZMVaGvbMUb5R1wdlCPf3URSnThoFP22f7qm40t+vfh4KuOble4M5DyqMCMrJEASCis8l /sCpwRbIk3Oh/Efy6sMdG2RkqVu9XxDoXXEp9+c+M2tul89Zo1btkdV7V4/xER9rWdPX BG6ejB90AVJogDJXhvIMXfe2FrfTm9M6v8OA21Q/wumBYRlFP8/wc+oN5QiXmQyKLGHs M1Qemr+/a5AYLHyZP/S7X19uofiDXxo4tzK04HVnL/Cf5Qfj+INltTLd1C0y45xJGdze I3og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature; bh=ZzNNsQ5c9TM7d+IZjGjTXCYk41ZZBnW8X6NIN3je2cI=; b=qD1EO3D86zQqFd6uhJNdCocckl13wjcpHS2uxF268C5niadgDoSFTliU5DjxRlXRAi ofRwjFsAcCwgvB3tOaFBAP72vgA2SI89JZ/cZihDitgdC62wsfOS/FRsZ6a8qVeoa47/ hJO/AuO+Zu/IIBznA+uKkPnOqBGLIJooDfacLdz11fJJNJpFCVSC62c0Gt14mWn0TL+A lXnig7Kd4Tg3hcwae1Qa7zmGzXg/EF1wMulyIjCCCQr9r4HDazAGWum38/15O6zAiOyY 11IBCenJQyEWX4oI+X7Bno4FCLWAmbZczGYqI/MJNYlFNScWu8jbdvmfwbuSh+dEdldG VCAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=A8NLIWCi; dkim=pass header.i=@codeaurora.org header.s=default header.b=GfWqVwQo; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b27si3941390ede.204.2019.11.08.03.06.08; Fri, 08 Nov 2019 03:06:33 -0800 (PST) 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=@codeaurora.org header.s=default header.b=A8NLIWCi; dkim=pass header.i=@codeaurora.org header.s=default header.b=GfWqVwQo; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731463AbfKHLEN (ORCPT + 99 others); Fri, 8 Nov 2019 06:04:13 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:41226 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbfKHLEN (ORCPT ); Fri, 8 Nov 2019 06:04:13 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2887460913; Fri, 8 Nov 2019 11:04:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573211052; bh=d85PiEzTKZnD4rW8ooec1lt7MpOUj9J4ixcs+n0zX9I=; h=From:To:Cc:Subject:Date:From; b=A8NLIWCigNLq8rWL3fhGp8qYpPpfNAQsUDH6Hvor1IKXBZPHwGOhrOidC9+NaUj3Y wm8NMY5+5Doi+ApMxd+ZACQjGn4gi08HpKJL/PHWzLWQmPyIbomje1uYeUcuB94hX/ ESnVYf4t9g/3qAMHPly5aFHlg6d2cAQitpaGXSRE= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from codeaurora.org (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: stummala@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5021A602BD; Fri, 8 Nov 2019 11:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573211050; bh=d85PiEzTKZnD4rW8ooec1lt7MpOUj9J4ixcs+n0zX9I=; h=From:To:Cc:Subject:Date:From; b=GfWqVwQoV9Amr3ZDWp0foiRawDLhM6EebifTzZYdkktLhfYQGun36efBNw3/s58BF Y2X2HnRxr7fjM1Yh+rax2UK3bW0Q09eAZPIQ56QOCTlWR9dm5RmZVfnOYeZUin5WYt Dm7rjxmKbcgR36Ig1Tg597wOO7kCvFKb7Vt6idyk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5021A602BD Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=stummala@codeaurora.org From: Sahitya Tummala To: Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Cc: Sahitya Tummala , linux-kernel@vger.kernel.org Subject: [PATCH] f2fs: Fix deadlock under storage almost full/dirty condition Date: Fri, 8 Nov 2019 16:33:47 +0530 Message-Id: <1573211027-30785-1-git-send-email-stummala@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There could be a potential deadlock when the storage capacity is almost full and theren't enough free segments available, due to which FG_GC is needed in the atomic commit ioctl as shown in the below callstack - schedule_timeout io_schedule_timeout congestion_wait f2fs_drop_inmem_pages_all f2fs_gc f2fs_balance_fs __write_node_page f2fs_fsync_node_pages f2fs_do_sync_file f2fs_ioctl If this inode doesn't have i_gc_failures[GC_FAILURE_ATOMIC] set, then it waits forever in f2fs_drop_inmem_pages_all(), for this atomic inode to be dropped. And the rest of the system is stuck waiting for sbi->gc_mutex lock, which is acquired by f2fs_balance_fs() in the stack above. Signed-off-by: Sahitya Tummala --- fs/f2fs/segment.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index da830fc..335ec09 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -300,7 +300,8 @@ void f2fs_drop_inmem_pages_all(struct f2fs_sb_info *sbi, bool gc_failure) if (inode) { if (gc_failure) { - if (fi->i_gc_failures[GC_FAILURE_ATOMIC]) + if (fi->i_gc_failures[GC_FAILURE_ATOMIC] || + F2FS_I(inode)->inmem_task == current) goto drop; goto skip; } -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.