Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp149482ybg; Sun, 31 May 2020 20:06:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWzobfdiClbv3NyX5oV2w6nFBQ8OG2mtYj3Av90yDoPP7hKfvAdt7It8o5aazsyXqCx5BZ X-Received: by 2002:a17:906:695a:: with SMTP id c26mr898028ejs.214.1590980788947; Sun, 31 May 2020 20:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590980788; cv=none; d=google.com; s=arc-20160816; b=I7jHSlZ6asFIE9WFKMpsUtFY1p1qITQJgWq3jp0hoNy9zC0Tw2Vuq7eCt2wAoVG5K5 MFooeGFwaQ2xj64JOOTslT73uhA6ejjlwK9onvjA6s9dxPZKD2Vg6I4GkOhuXdAc5x6Y rR8FAw8naGV6qlN5/LOlrCiCL6SssbYq72S/XcW6Ttk8BGfv3ZHwVYscxIe7M7+k0Jzi zmVIm83aoopASbz82igDh0hxvHM/P3tB2h2jGVCPY7xLF1tQvoyfniOrzGuw80fPaqds 0VCEoY/azDPkbD6/lBPYb6CnnQkId9tTW1K3gdIwaIMoG9oHhxBdt/SIrWLT/5i7/obD KDJw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=HadkBgfXSvOfA9Fsm3GngQ/GKJaEcnZZDK/WEOwrtLQ=; b=iXeAFe/CglLbE3Sti5mVEkcWIx+OWl24ELZVZ8NEB+3IVeicyacB0/4LagGJgJw1Xx NPqoxbQiNvHae39HZGGFMMnKwOofnPNtmDawqWAmmdS7SCJmCgJsEDE8rjVOmgC8PG8n +ouNLYvUYP3B1bb0Uy3Z/tGFuIXmynYOYDgm//bO87t2DfTi0J8aWz0HZCOAdl76KLTk GvUddkuY/vECSBPiNXj+c5MNtF5Fjw6tNKHaWehzmlWdvytIuCucZt2ZuBvlWaemIeUJ 1sYrc9TKKBkXeijQb8ylx/aQcT24+7tu66N5cCY9Sv6oZcJlwJ3hl6uZXIz8+h0phSrE 6/jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E+nVziuP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o60si8735528edd.190.2020.05.31.20.06.06; Sun, 31 May 2020 20:06:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E+nVziuP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727779AbgFADDz (ORCPT + 99 others); Sun, 31 May 2020 23:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbgFADDy (ORCPT ); Sun, 31 May 2020 23:03:54 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94978C061A0E for ; Sun, 31 May 2020 20:03:54 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id h95so3403005pje.4 for ; Sun, 31 May 2020 20:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HadkBgfXSvOfA9Fsm3GngQ/GKJaEcnZZDK/WEOwrtLQ=; b=E+nVziuPYFDx9OPuREfXXWQ3zM3OZkXI7nyBKlK2dCE83jGCQ6GM9qdl9YCy6hkQme VKD9VQFLWtaG0H98z3XMEnsunY32HRSyHk1vTuWd07zz/8XIZgbkGTbJZOYIELO1PQlq v7Iy+E4/LPQN5AM2F81SFoDbieOULD0hbLQHKHQ26Cj0Qx7nysTZJAm8esDTIfhbWFqC YuVYE1yGiPEjE/kME1raCRwcxcPoDdmft/9Lia9J4DheGLuJxpDpGRem/0KHR2Kss8GA mFu5iufKaxRW8EmtdofajikX+qtPyQsHykLO0NghYpsmrX5D1ee+dddcjBQCV0ODp0Hc MHow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HadkBgfXSvOfA9Fsm3GngQ/GKJaEcnZZDK/WEOwrtLQ=; b=sZVGjOMVClzz9IXRrBsaEk63qtSpmtGoD4XFTuQfzKIR5dsYyz1teJVgagIpoyBueB XfJMM4gWdbZpKNjEQZ7CAL9lSKrbWNNLcaIqMj4JyFWukiVUV7iQGSlg5cCjN7g0Hjfj 8tpKaTkSxX0IC9DDVpJ/3IXEFrrfPbLwHl49xMAch0CDP7H8iQf1px/t0sN+vDW39KK0 wD8Wg1RKGByn4wZPmEiRxXLlMlFsx/J+y/3TSMUvowtgZuHNWstZbVy5u5rdKcxtX3PG iXtFtsUAdZz94MA7T4eTuxsKRizUMsjXNhrmu+NlrjdLlGdBaeyV0AIopV8i0/JnWewC HIhA== X-Gm-Message-State: AOAM532iBGeeVyhIXPvPiNBXTNL3k7tHrCDyIjQdlGn2OpjWcBEsDepn Mrw9B8dRBbStMyZPRTETgt/mn6tz8kephQ== X-Received: by 2002:a17:90a:64ce:: with SMTP id i14mr20986083pjm.48.1590980633691; Sun, 31 May 2020 20:03:53 -0700 (PDT) Received: from daehojeong1.seo.corp.google.com ([2401:fa00:d:1:b8f4:bbde:37ba:20bd]) by smtp.gmail.com with ESMTPSA id l23sm12589084pff.80.2020.05.31.20.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 May 2020 20:03:53 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong , Chao Yu Subject: [PATCH] f2fs: protect new segment allocation in expand_inode_data Date: Mon, 1 Jun 2020 12:03:47 +0900 Message-Id: <20200601030347.112984-1-daeho43@gmail.com> X-Mailer: git-send-email 2.27.0.rc0.183.gde8f92d652-goog 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 From: Daeho Jeong Found a new segemnt allocation without f2fs_lock_op() in expand_inode_data(). So, when we do fallocate() for a pinned file and trigger checkpoint very frequently and simultaneously. F2FS gets stuck in the below code of do_checkpoint() forever. f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO); /* Wait for all dirty meta pages to be submitted for IO */ <= if fallocate() here, f2fs_wait_on_all_pages(sbi, F2FS_DIRTY_META); <= it'll wait forever. Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu --- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index f7de2a1da528..14ace885baa9 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1660,7 +1660,11 @@ static int expand_inode_data(struct inode *inode, loff_t offset, down_write(&sbi->pin_sem); map.m_seg_type = CURSEG_COLD_DATA_PINNED; + + f2fs_lock_op(sbi); f2fs_allocate_new_segments(sbi, CURSEG_COLD_DATA); + f2fs_unlock_op(sbi); + err = f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_DIO); up_write(&sbi->pin_sem); -- 2.27.0.rc0.183.gde8f92d652-goog