Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp577325ybm; Wed, 27 May 2020 02:49:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpVbF4HOUomgA10RX/LrWUpgEw8QdLUGZWeC0f+ebIfnwCTse9qWF28zMiS2/bwGEAywq2 X-Received: by 2002:a05:6402:3076:: with SMTP id bs22mr23936696edb.161.1590572964800; Wed, 27 May 2020 02:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590572964; cv=none; d=google.com; s=arc-20160816; b=X3rqaSDew3qO75/DA+4yEendQkEJ3TJGQzO+dIFp2HYkIUawquh6ybye64lAikEQhx NuHkmSegwZf9SWsnqlgQ66T8gQ4brxB9afaCMjCcq9sPZYHmTXV1ukESlSxfzz1lRTHZ PEQY2sWK9zlkFgnHKvIIIX6cF6qw85JSUeWizmZyfT+bF9OWU6eF6vzvM77mRVYfo2CI RITPUuTFnOSwIcxlqAbSEpRVVIse85ciDyCqAqLJpDx1WkiRfY2g3odKSfNlqAHk1lri 6PeGW8tetsHJbN3SgxXc0SF5VzSOTixpbCzPYgu6YqC4jUzJrlTnMeoYAh5rkHZ46IOe DlBw== 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=DyZwm58RJro1kic/9IoyyoaUkdPO3Lyg3bl6Kx/XiJU=; b=HYku9s4WtvgnEOtmNsCbFDltfxoWSuKKdZ2mu9DDrp0CvYr34cn8G3OxjX6ZGwbnPr GHEudb9GH73uYAAHkY2SYzYTaAKFmZ6cl+XY53Q1sd4g/23Xc/ODU+SEBeAhTkjnT3bb 0jg8NdcfxIK7l5J5ifCntBKjx6ncEBLR0w/Q4/Clz09xqCjMNM25gBQlczGojOa6OJzT tsqm3h6j+hO5Y2PSCMgYq2BfzrytkXLXjULsFfeZMIdbRXTPunHfcncKN2/nqUTkvQwt OgNAu5dMwfa4AowDpHmUr3WjyWzCES+eFpJAGZqOkNegYBN9Pjn9fEkb7MMqy1G5op2M dbvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ea5b/yOr"; 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 x22si1617225eje.542.2020.05.27.02.49.01; Wed, 27 May 2020 02:49:24 -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="Ea5b/yOr"; 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 S1725850AbgE0ECn (ORCPT + 99 others); Wed, 27 May 2020 00:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbgE0ECn (ORCPT ); Wed, 27 May 2020 00:02:43 -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 553E9C061A0F for ; Tue, 26 May 2020 21:02:43 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id cx22so930163pjb.1 for ; Tue, 26 May 2020 21:02:43 -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=DyZwm58RJro1kic/9IoyyoaUkdPO3Lyg3bl6Kx/XiJU=; b=Ea5b/yOr0ZEjDMlwSBwK+l5ZsIJ+PqMFEO5MA6TfdyDCcSENA+WOIflT3B1Cw10fPh 5sYGtgm8uMBE1czEC+5Q6RLS0zaBKiqdE9iidYWuF5MzBuNa/zGyLan6r6Yj7JOAul0o 8oxwT7bfUiv3s6hXNHqdx5Ww8LPIN2YGVVH1uF/Gcdf55Yl7252/xsI9umtSJKpEQVYF ur+ZElsaZjcmPCG9nvmfFaIsBCOoo1mhZjc+RxnXlWXAb2ojz/40Kn7cb2Jfe1RI9VPG UHwdBSuDqL3qhWbxHm9NMp3VZaSxzFJps7F/tY/jhPTW6pSWbxUw9m1Zu4Nw2QmiFX2n 6GRA== 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=DyZwm58RJro1kic/9IoyyoaUkdPO3Lyg3bl6Kx/XiJU=; b=DhpYpJcoUU/HVIKNew2qPdrJu6hDi5GDCksxiTvIG5VX2fA5dntND0R0jG3WxOqA3J HU3Z1XbZn6lR2EsLze45YWTghEperFM5sei2YrwQFCXQvtWAXoGT49Raky4mwjJO5nYa tKdmJ6MXNic2GAJ0EaPlIgOuSKHtnA4XftFhHVrPOzYJv5/6bv0vR0llmUfGzxqo7FxK 6lEtFlmK4FRzZ8ocZTX2Z03NucvCbmwSeUK2bbW+nDvGqQbZAPhY4s7WKyyBOGGDmM+y CXuycggbmKENGDKzhyV0roOPNRKufArTxU2YPLr8MN4WJZyi8AOVOvsLYvUmc9TnW1as 0XkA== X-Gm-Message-State: AOAM532R0Ja/0DGxhBwkWjda3tz3KRfzb+8GoDHS6HAB6ZOASvkDh9DJ B3H5qYIX64QtR6WqzCfbU46VjJ7fil+yVFRX X-Received: by 2002:a17:902:7c16:: with SMTP id x22mr4072964pll.244.1590552162218; Tue, 26 May 2020 21:02:42 -0700 (PDT) Received: from daehojeong1.seo.corp.google.com ([2401:fa00:d:1:b8f4:bbde:37ba:20bd]) by smtp.gmail.com with ESMTPSA id e5sm797494pfe.121.2020.05.26.21.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 21:02:41 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong Subject: [PATCH] f2fs: protect new segment allocation in expand_inode_data Date: Wed, 27 May 2020 13:02:31 +0900 Message-Id: <20200527040231.70891-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 --- 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