Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp275766ybg; Wed, 3 Jun 2020 00:03:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5tmhS9cyoWxp3Efy4tIBA1UafScd0BYm2u7u4Yo9idDfV+3iMpvJhG7kl6MhcEwocCgTs X-Received: by 2002:aa7:cd16:: with SMTP id b22mr460294edw.308.1591167802094; Wed, 03 Jun 2020 00:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591167802; cv=none; d=google.com; s=arc-20160816; b=I5b8dcLn/ZHrDfMi4BWYq+57DfL3HFBShkoVZ2RfjfXONyHKakZfGA5DoYu4TU8yA+ nwK1KmH/2Aw9COJl5PaFLi6bCHnObBsT01lbc44zk4QPOqXpjzETp0KEgH1j+JDR1uGq 2UewG6CfdBpclbNsxRIEcf7uCo+McAqX7bWyrLbbU7j0Js+E8DxJaYlbTk6faXqtWiZQ 7MUE5q7L0dKJA8yJkcFWnRqY6wh1aXiKzJaejmWvhbWIkU6rAqBVhpLxSidzjN5Y7vr+ fSbN4IO6bnlfdzNlT8So32Ew5WgWKRxwVPSFpOkDsSytbPGyE2jdL9t5bNCHdh5LEehY PomA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=+EG+4fgRfrmwvdJ0nqUCJ9b0uPw2VCPX7Y2FIBOKePc=; b=cwkuBNj3fs23yYWAbomz1p2SZQVVPfq59rhOvZ+z47LoHGAPjRFiLeGpeE2rHYEQAo Z21infTI6XDfq9V4FEm0LEYIBmULDA7VBA5CkNomR9zva8h3up1fFch/I185t0kDQOBi lFKS+fz8//1pf1zFdSMa+AJ2xFgdiw7JAU4nTHl4X4CzpQX+izQRrIforX9FsTReS8vk jZ+2HKzMbARJ4NGY5AtUuKcuqeRM9AVkZkxMm6n9YCNfnDsWZZoT57CR6xrsewBEt+89 Kkymvecwg49cjYxTyK/bCAjvtxZUIX3FSf+qMiJgEVMUd/ztSNJPiLa1ytn7ASLKrx+2 6z+g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o3si627359edb.156.2020.06.03.00.02.56; Wed, 03 Jun 2020 00:03:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726074AbgFCG6z (ORCPT + 99 others); Wed, 3 Jun 2020 02:58:55 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5846 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725275AbgFCG6y (ORCPT ); Wed, 3 Jun 2020 02:58:54 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2F0F931527F4F3D44C1C; Wed, 3 Jun 2020 14:58:53 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.209) with Microsoft SMTP Server (TLS) id 14.3.487.0; Wed, 3 Jun 2020 14:58:47 +0800 Subject: Re: [PATCH] f2fs: protect new segment allocation in expand_inode_data To: Daeho Jeong , , , CC: Daeho Jeong References: <20200601030347.112984-1-daeho43@gmail.com> From: Chao Yu Message-ID: Date: Wed, 3 Jun 2020 14:58:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200601030347.112984-1-daeho43@gmail.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/6/1 11:03, Daeho Jeong wrote: > 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 Daeho, I guess Jaegeuk could add the tag when merging this patch, we don't have to resend the patch if there is no updates on code and message. Thanks, > --- > 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); > >