From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03349C636D4 for ; Mon, 13 Feb 2023 20:15:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229802AbjBMUO7 (ORCPT ); Mon, 13 Feb 2023 15:14:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230509AbjBMUOs (ORCPT ); Mon, 13 Feb 2023 15:14:48 -0500 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E17A2558B for ; Mon, 13 Feb 2023 12:14:46 -0800 (PST) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-52f1b1d08c2so54144137b3.5 for ; Mon, 13 Feb 2023 12:14:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=DVBZe7FHVHxsSQIXf3WpSgVuZprABFUjQYlhoNVCR64=; b=DXYXMqkm9VM+ixvfhyWjwEU7GB98j2w3mIeX9aKCNqrfnONjizGGw2SdHddg8N5tl2 E00LrwudUDCFtOPc0zaWWLwicR7UrqVht+HK+GRWItmnZjBW4llgaIGym59BdZTGXqOJ e9EnkR5F8L8fUGjaTiN9/IPXVLCuku46pLbcXOkWiidFwHUrCwal3eo+tahWe9fjmCOg xm27drN0CQYRtQcCskcmeSAmnDeXv7J9AZPOIyL7vWsz81xG5zyNBT1ldsXNADD0eZOv 6Pk3rj9F69fAsWajh1bXsI4+yiDErEaOz0GgUsM6qZlA8UlZmr/uud9aWeF5a2TkpKjQ ztMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DVBZe7FHVHxsSQIXf3WpSgVuZprABFUjQYlhoNVCR64=; b=jYHcQTeWn2gAiwQ9zmaezLwR0BvU+aWpdNautOMyUTT5XGVANO0n7tIUPuXHN2JkEd cmSpZkEw0ZHKpyvpB5wCzxLNBJPIHQl+kzIPxcH1wBgi4QfaOOMfHneuu+HuWBaYG+a0 MmuhXKFG7VNK6CEc3oFtftSZrUexslwxvTyoBkJzwf7xxOlnvjGSTPTkLCKh3AMPXj1u 8Ss5iCkkeyMDVEA2FDr1acqgw1dJnxPWaPtsku5RLe3h7RCPqRS0TsCvGsfWVRudoAO2 Cgb/zhUESjGoJBMq1CY5m40weCz62fzitgVN3VSLsVVt+1oozBxCKI6MZp5Botos5a6D sitw== X-Gm-Message-State: AO0yUKXj/V53QpyWE+eZ0pgpF7D3qEiLcxIDKcDUltQQSbNSQ7JFaVPv vSv4frixFUgPxlKqHuE5NuT2HIQ41V7K63L6WJw= X-Google-Smtp-Source: AK7set+r5/WDZDUysolD6CVwopt5Ni7Zs7kVqgz/wqaChX0iJ5QDirFJk362e+g/2RSK1kXsahvaBzfaO+ig/BwhnzA= X-Received: by 2002:a0d:d48e:0:b0:52f:b76:e21d with SMTP id w136-20020a0dd48e000000b0052f0b76e21dmr857600ywd.493.1676319286021; Mon, 13 Feb 2023 12:14:46 -0800 (PST) MIME-Version: 1.0 References: <20230209181819.2333522-1-daeho43@gmail.com> <18916dd5-67cc-fe21-f78b-8a6dfbcb1c97@kernel.org> In-Reply-To: <18916dd5-67cc-fe21-f78b-8a6dfbcb1c97@kernel.org> From: Daeho Jeong Date: Mon, 13 Feb 2023 12:14:34 -0800 Message-ID: Subject: Re: [f2fs-dev] [PATCH] f2fs: synchronize atomic write aborts To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong , syzbot+823000d23b3400619f7c@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 13, 2023 at 1:47 AM Chao Yu wrote: > > On 2023/2/10 2:18, Daeho Jeong wrote: > > From: Daeho Jeong > > > > To fix a race condition between atomic write aborts, I use the inode > > lock and make COW inode to be re-usable thoroughout the whole > > atomic file inode lifetime. > > > > Reported-by: syzbot+823000d23b3400619f7c@syzkaller.appspotmail.com > > Fixes: 3db1de0e582c ("f2fs: change the current atomic write way") > > Signed-off-by: Daeho Jeong > > --- > > fs/f2fs/file.c | 44 +++++++++++++++++++++++++++++--------------- > > fs/f2fs/inode.c | 11 +++++++++-- > > fs/f2fs/segment.c | 3 --- > > fs/f2fs/super.c | 2 -- > > 4 files changed, 38 insertions(+), 22 deletions(-) > > > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > > index 300eae8b5415..6436c52e7913 100644 > > --- a/fs/f2fs/file.c > > +++ b/fs/f2fs/file.c > > @@ -1863,7 +1863,10 @@ static int f2fs_release_file(struct inode *inode, struct file *filp) > > atomic_read(&inode->i_writecount) != 1) > > return 0; > > > > + inode_lock(inode); > > f2fs_abort_atomic_write(inode, true); > > + inode_unlock(inode); > > + > > return 0; > > } > > > > @@ -1878,8 +1881,12 @@ static int f2fs_file_flush(struct file *file, fl_owner_t id) > > * before dropping file lock, it needs to do in ->flush. > > */ > > if (F2FS_I(inode)->atomic_write_task == current && > > - (current->flags & PF_EXITING)) > > + (current->flags & PF_EXITING)) { > > + inode_lock(inode); > > f2fs_abort_atomic_write(inode, true); > > + inode_unlock(inode); > > + } > > + > > return 0; > > } > > > > @@ -2085,19 +2092,28 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) > > goto out; > > } > > > > - /* Create a COW inode for atomic write */ > > - pinode = f2fs_iget(inode->i_sb, fi->i_pino); > > - if (IS_ERR(pinode)) { > > - f2fs_up_write(&fi->i_gc_rwsem[WRITE]); > > - ret = PTR_ERR(pinode); > > - goto out; > > - } > > + /* Check if the inode already has a COW inode */ > > + if (fi->cow_inode == NULL) { > > + /* Create a COW inode for atomic write */ > > + pinode = f2fs_iget(inode->i_sb, fi->i_pino); > > + if (IS_ERR(pinode)) { > > + f2fs_up_write(&fi->i_gc_rwsem[WRITE]); > > + ret = PTR_ERR(pinode); > > + goto out; > > + } > > > > - ret = f2fs_get_tmpfile(mnt_userns, pinode, &fi->cow_inode); > > - iput(pinode); > > - if (ret) { > > - f2fs_up_write(&fi->i_gc_rwsem[WRITE]); > > - goto out; > > + ret = f2fs_get_tmpfile(mnt_userns, pinode, &fi->cow_inode); > > + iput(pinode); > > + if (ret) { > > + f2fs_up_write(&fi->i_gc_rwsem[WRITE]); > > + goto out; > > + } > > + > > + set_inode_flag(fi->cow_inode, FI_COW_FILE); > > + clear_inode_flag(fi->cow_inode, FI_INLINE_DATA); > > + } else { > > + /* Reuse the already created COW inode */ > > + f2fs_do_truncate_blocks(fi->cow_inode, 0, true); > > } > > > > f2fs_write_inode(inode, NULL); > > @@ -2105,8 +2121,6 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) > > stat_inc_atomic_inode(inode); > > > > set_inode_flag(inode, FI_ATOMIC_FILE); > > - set_inode_flag(fi->cow_inode, FI_COW_FILE); > > - clear_inode_flag(fi->cow_inode, FI_INLINE_DATA); > > > > isize = i_size_read(inode); > > fi->original_i_size = isize; > > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c > > index 28c9c72dda2a..7bf660d4cad9 100644 > > --- a/fs/f2fs/inode.c > > +++ b/fs/f2fs/inode.c > > @@ -777,11 +777,18 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) > > void f2fs_evict_inode(struct inode *inode) > > { > > struct f2fs_sb_info *sbi = F2FS_I_SB(inode); > > - nid_t xnid = F2FS_I(inode)->i_xattr_nid; > > + struct f2fs_inode_info *fi = F2FS_I(inode); > > + nid_t xnid = fi->i_xattr_nid; > > int err = 0; > > > > f2fs_abort_atomic_write(inode, true); > > > > + if (fi->cow_inode) { > > + clear_inode_flag(fi->cow_inode, FI_COW_FILE); > > + iput(fi->cow_inode); > > + fi->cow_inode = NULL; > > + } > > It looks "fi->cow_inode = NULL" here may race w/ cow_inode allocation in > f2fs_ioc_start_atomic_write due to f2fs_write_inode() has not been covered > by inode_lock()? IIUC. Sorry, I couldn't understand it, since I couldn't find any relation between f2fs_ioc_start_atomic_write and f2fs_write_inode. Could you elaborate more on this? I thought the code might be safe, since it happens in the inode eviction phase. > > Thanks, > > > + > > trace_f2fs_evict_inode(inode); > > truncate_inode_pages_final(&inode->i_data); > > > > @@ -866,7 +873,7 @@ void f2fs_evict_inode(struct inode *inode) > > stat_dec_inline_inode(inode); > > stat_dec_compr_inode(inode); > > stat_sub_compr_blocks(inode, > > - atomic_read(&F2FS_I(inode)->i_compr_blocks)); > > + atomic_read(&fi->i_compr_blocks)); > > > > if (likely(!f2fs_cp_error(sbi) && > > !is_sbi_flag_set(sbi, SBI_CP_DISABLED))) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > > index ead3f35f501d..719329c1808c 100644 > > --- a/fs/f2fs/segment.c > > +++ b/fs/f2fs/segment.c > > @@ -192,9 +192,6 @@ void f2fs_abort_atomic_write(struct inode *inode, bool clean) > > if (!f2fs_is_atomic_file(inode)) > > return; > > > > - clear_inode_flag(fi->cow_inode, FI_COW_FILE); > > - iput(fi->cow_inode); > > - fi->cow_inode = NULL; > > release_atomic_write_cnt(inode); > > clear_inode_flag(inode, FI_ATOMIC_COMMITTED); > > clear_inode_flag(inode, FI_ATOMIC_REPLACE); > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > > index c11a161ba5be..aa55dc12aff2 100644 > > --- a/fs/f2fs/super.c > > +++ b/fs/f2fs/super.c > > @@ -1427,8 +1427,6 @@ static int f2fs_drop_inode(struct inode *inode) > > atomic_inc(&inode->i_count); > > spin_unlock(&inode->i_lock); > > > > - f2fs_abort_atomic_write(inode, true); > > - > > /* should remain fi->extent_tree for writepage */ > > f2fs_destroy_extent_node(inode); > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC4FDC636D4 for ; Mon, 13 Feb 2023 20:14:54 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pRfDx-0007Ld-T0; Mon, 13 Feb 2023 20:14:53 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pRfDx-0007LX-DQ for linux-f2fs-devel@lists.sourceforge.net; Mon, 13 Feb 2023 20:14:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DVBZe7FHVHxsSQIXf3WpSgVuZprABFUjQYlhoNVCR64=; b=CRen21IMZftk1mRqcPxaunnDjI h/xxGZ2enS6lbCL8d47zpVsq+flf//wEQ5uPir7KxZ4Z3W14Li7LnVC1X88T5GQRI3nIXChp+tg+Q 1gWKDxqZmvWowZbla1WwF6+wGF2WoMQnh/jSXrWmKMahcUat2YU4qTOqV1M98eNW1P/k=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DVBZe7FHVHxsSQIXf3WpSgVuZprABFUjQYlhoNVCR64=; b=SxoBAVhaEQmhkf2TTB3HeZYru4 sDlsR//A2DArVUQu4Gs4PtuwT/8oDhcQ67ehJ1jFAuUCH8EeKOzrB/yh4gO+W5tcgd2pEBV5U/9Qi 10kBgV8Ym9dm1LBxjfCa1QrXcLo0npMSevs1/fEEHkdcgvfV12zobZ9B+Zo7TdPapmJs=; Received: from mail-yw1-f171.google.com ([209.85.128.171]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pRfDv-003QmM-Qw for linux-f2fs-devel@lists.sourceforge.net; Mon, 13 Feb 2023 20:14:52 +0000 Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-52ecd867d89so130665367b3.8 for ; Mon, 13 Feb 2023 12:14:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=DVBZe7FHVHxsSQIXf3WpSgVuZprABFUjQYlhoNVCR64=; b=DXYXMqkm9VM+ixvfhyWjwEU7GB98j2w3mIeX9aKCNqrfnONjizGGw2SdHddg8N5tl2 E00LrwudUDCFtOPc0zaWWLwicR7UrqVht+HK+GRWItmnZjBW4llgaIGym59BdZTGXqOJ e9EnkR5F8L8fUGjaTiN9/IPXVLCuku46pLbcXOkWiidFwHUrCwal3eo+tahWe9fjmCOg xm27drN0CQYRtQcCskcmeSAmnDeXv7J9AZPOIyL7vWsz81xG5zyNBT1ldsXNADD0eZOv 6Pk3rj9F69fAsWajh1bXsI4+yiDErEaOz0GgUsM6qZlA8UlZmr/uud9aWeF5a2TkpKjQ ztMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DVBZe7FHVHxsSQIXf3WpSgVuZprABFUjQYlhoNVCR64=; b=ze9SC4Y0A6Cn/cA55bmkL4q9beMI3NifXZ3UNu+M8DWuGF55JS9fRTx8i+8mMxkPB2 7vC9MclyqtWuqYDudPsB2Kvnf1Utx92XLbGnlHW+8kkUfHiVVuJUQA0q9KSB6UdJE6V2 hINxc30woWvyL/1yTA3Y8aMcXynyRIWgIKI+cemhxXYHMInDJ7VbC/XV80SGi70+1wmE 3S/XfmcPGSzygyEB80svYD+pqDmAwWONhG45E0/qtiV3Co3+0yxD0kAmhvRV3EipN6aO tI19TpOnf1EecZAUY0zn148WNdYtSPP+VgLz/hb6QViD4U2Q8cVEaF+QfZaPgyyCvTc5 Z0BA== X-Gm-Message-State: AO0yUKVO0l0cZJr9G/xhEoyulNMi+UTGTGdhulfVG7M8h5+SLQpyENk/ y/uCQQyeT/4PxnNlH5/byXZwxFrxcvrjzqj/EDA= X-Google-Smtp-Source: AK7set+r5/WDZDUysolD6CVwopt5Ni7Zs7kVqgz/wqaChX0iJ5QDirFJk362e+g/2RSK1kXsahvaBzfaO+ig/BwhnzA= X-Received: by 2002:a0d:d48e:0:b0:52f:b76:e21d with SMTP id w136-20020a0dd48e000000b0052f0b76e21dmr857600ywd.493.1676319286021; Mon, 13 Feb 2023 12:14:46 -0800 (PST) MIME-Version: 1.0 References: <20230209181819.2333522-1-daeho43@gmail.com> <18916dd5-67cc-fe21-f78b-8a6dfbcb1c97@kernel.org> In-Reply-To: <18916dd5-67cc-fe21-f78b-8a6dfbcb1c97@kernel.org> From: Daeho Jeong Date: Mon, 13 Feb 2023 12:14:34 -0800 Message-ID: To: Chao Yu X-Headers-End: 1pRfDv-003QmM-Qw Subject: Re: [f2fs-dev] [PATCH] f2fs: synchronize atomic write aborts X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daeho Jeong , kernel-team@android.com, linux-kernel@vger.kernel.org, syzbot+823000d23b3400619f7c@syzkaller.appspotmail.com, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Mon, Feb 13, 2023 at 1:47 AM Chao Yu wrote: > > On 2023/2/10 2:18, Daeho Jeong wrote: > > From: Daeho Jeong > > > > To fix a race condition between atomic write aborts, I use the inode > > lock and make COW inode to be re-usable thoroughout the whole > > atomic file inode lifetime. > > > > Reported-by: syzbot+823000d23b3400619f7c@syzkaller.appspotmail.com > > Fixes: 3db1de0e582c ("f2fs: change the current atomic write way") > > Signed-off-by: Daeho Jeong > > --- > > fs/f2fs/file.c | 44 +++++++++++++++++++++++++++++--------------- > > fs/f2fs/inode.c | 11 +++++++++-- > > fs/f2fs/segment.c | 3 --- > > fs/f2fs/super.c | 2 -- > > 4 files changed, 38 insertions(+), 22 deletions(-) > > > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > > index 300eae8b5415..6436c52e7913 100644 > > --- a/fs/f2fs/file.c > > +++ b/fs/f2fs/file.c > > @@ -1863,7 +1863,10 @@ static int f2fs_release_file(struct inode *inode, struct file *filp) > > atomic_read(&inode->i_writecount) != 1) > > return 0; > > > > + inode_lock(inode); > > f2fs_abort_atomic_write(inode, true); > > + inode_unlock(inode); > > + > > return 0; > > } > > > > @@ -1878,8 +1881,12 @@ static int f2fs_file_flush(struct file *file, fl_owner_t id) > > * before dropping file lock, it needs to do in ->flush. > > */ > > if (F2FS_I(inode)->atomic_write_task == current && > > - (current->flags & PF_EXITING)) > > + (current->flags & PF_EXITING)) { > > + inode_lock(inode); > > f2fs_abort_atomic_write(inode, true); > > + inode_unlock(inode); > > + } > > + > > return 0; > > } > > > > @@ -2085,19 +2092,28 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) > > goto out; > > } > > > > - /* Create a COW inode for atomic write */ > > - pinode = f2fs_iget(inode->i_sb, fi->i_pino); > > - if (IS_ERR(pinode)) { > > - f2fs_up_write(&fi->i_gc_rwsem[WRITE]); > > - ret = PTR_ERR(pinode); > > - goto out; > > - } > > + /* Check if the inode already has a COW inode */ > > + if (fi->cow_inode == NULL) { > > + /* Create a COW inode for atomic write */ > > + pinode = f2fs_iget(inode->i_sb, fi->i_pino); > > + if (IS_ERR(pinode)) { > > + f2fs_up_write(&fi->i_gc_rwsem[WRITE]); > > + ret = PTR_ERR(pinode); > > + goto out; > > + } > > > > - ret = f2fs_get_tmpfile(mnt_userns, pinode, &fi->cow_inode); > > - iput(pinode); > > - if (ret) { > > - f2fs_up_write(&fi->i_gc_rwsem[WRITE]); > > - goto out; > > + ret = f2fs_get_tmpfile(mnt_userns, pinode, &fi->cow_inode); > > + iput(pinode); > > + if (ret) { > > + f2fs_up_write(&fi->i_gc_rwsem[WRITE]); > > + goto out; > > + } > > + > > + set_inode_flag(fi->cow_inode, FI_COW_FILE); > > + clear_inode_flag(fi->cow_inode, FI_INLINE_DATA); > > + } else { > > + /* Reuse the already created COW inode */ > > + f2fs_do_truncate_blocks(fi->cow_inode, 0, true); > > } > > > > f2fs_write_inode(inode, NULL); > > @@ -2105,8 +2121,6 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) > > stat_inc_atomic_inode(inode); > > > > set_inode_flag(inode, FI_ATOMIC_FILE); > > - set_inode_flag(fi->cow_inode, FI_COW_FILE); > > - clear_inode_flag(fi->cow_inode, FI_INLINE_DATA); > > > > isize = i_size_read(inode); > > fi->original_i_size = isize; > > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c > > index 28c9c72dda2a..7bf660d4cad9 100644 > > --- a/fs/f2fs/inode.c > > +++ b/fs/f2fs/inode.c > > @@ -777,11 +777,18 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) > > void f2fs_evict_inode(struct inode *inode) > > { > > struct f2fs_sb_info *sbi = F2FS_I_SB(inode); > > - nid_t xnid = F2FS_I(inode)->i_xattr_nid; > > + struct f2fs_inode_info *fi = F2FS_I(inode); > > + nid_t xnid = fi->i_xattr_nid; > > int err = 0; > > > > f2fs_abort_atomic_write(inode, true); > > > > + if (fi->cow_inode) { > > + clear_inode_flag(fi->cow_inode, FI_COW_FILE); > > + iput(fi->cow_inode); > > + fi->cow_inode = NULL; > > + } > > It looks "fi->cow_inode = NULL" here may race w/ cow_inode allocation in > f2fs_ioc_start_atomic_write due to f2fs_write_inode() has not been covered > by inode_lock()? IIUC. Sorry, I couldn't understand it, since I couldn't find any relation between f2fs_ioc_start_atomic_write and f2fs_write_inode. Could you elaborate more on this? I thought the code might be safe, since it happens in the inode eviction phase. > > Thanks, > > > + > > trace_f2fs_evict_inode(inode); > > truncate_inode_pages_final(&inode->i_data); > > > > @@ -866,7 +873,7 @@ void f2fs_evict_inode(struct inode *inode) > > stat_dec_inline_inode(inode); > > stat_dec_compr_inode(inode); > > stat_sub_compr_blocks(inode, > > - atomic_read(&F2FS_I(inode)->i_compr_blocks)); > > + atomic_read(&fi->i_compr_blocks)); > > > > if (likely(!f2fs_cp_error(sbi) && > > !is_sbi_flag_set(sbi, SBI_CP_DISABLED))) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > > index ead3f35f501d..719329c1808c 100644 > > --- a/fs/f2fs/segment.c > > +++ b/fs/f2fs/segment.c > > @@ -192,9 +192,6 @@ void f2fs_abort_atomic_write(struct inode *inode, bool clean) > > if (!f2fs_is_atomic_file(inode)) > > return; > > > > - clear_inode_flag(fi->cow_inode, FI_COW_FILE); > > - iput(fi->cow_inode); > > - fi->cow_inode = NULL; > > release_atomic_write_cnt(inode); > > clear_inode_flag(inode, FI_ATOMIC_COMMITTED); > > clear_inode_flag(inode, FI_ATOMIC_REPLACE); > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > > index c11a161ba5be..aa55dc12aff2 100644 > > --- a/fs/f2fs/super.c > > +++ b/fs/f2fs/super.c > > @@ -1427,8 +1427,6 @@ static int f2fs_drop_inode(struct inode *inode) > > atomic_inc(&inode->i_count); > > spin_unlock(&inode->i_lock); > > > > - f2fs_abort_atomic_write(inode, true); > > - > > /* should remain fi->extent_tree for writepage */ > > f2fs_destroy_extent_node(inode); > > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel