Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6661873rwb; Mon, 12 Dec 2022 05:02:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7uE1pJVfXc42t1llwE/Wk8RusrAh5dqwsmEl01Pjsz5jSQPBxM976sN0tPw/TLOBsSiZr4 X-Received: by 2002:a62:de04:0:b0:577:3885:9d43 with SMTP id h4-20020a62de04000000b0057738859d43mr16115978pfg.18.1670850176930; Mon, 12 Dec 2022 05:02:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670850176; cv=none; d=google.com; s=arc-20160816; b=Ftmb27hdcdvdnzjgMmltVLWpWPvp2mgKcFsS4xv+VstnHsAe7naQraGpN/YqS2t1vF CTIP3mOF9BwC/sV71Z990CidrSbsDeYkEMJzcq5pr/0k90JIsCXIMiVvYfEV4/+D6q6C I/D0pyFysCM0mnPYYxfOlWtOVvxHk+Ude+3i4FQ+37YARKjUSjIIwQk3Jj5OSuEOL1uN JmjJ4r9gYtO4AVC8u3eE66PYWzPO501qv7SwOcChyAUgedLk76p9BrJy31RC+C+SiSFB 8QI4BvLPLH3Z4aVDhORxg0t2zTQNhS2Ye5PFAwDJiQNeYLMvXWZgRT+7MnmUhtgCX/oR +leA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=LEWp755Os4/0qi4b30VgoFWsVz2LwWPN7YmA0/U0gi0=; b=zQ8hZ4kTqfgwqyUdvylgEwH7pOKcFUMBodZqddFZlLUoDX2GuxzvsrZiNisMAzalD/ BpLaivjsZgDvliGTV8/K1NsZNkW7/JoGYcud8rLN/dvlP/1UtkVtY5TySpgwzNcty3e4 fgMUrvlkkcsgB9NacA1Z0x2NQMnRYEUPVA1osjN19LwWUh2+iYJZYwxdbx4VkMiBsL6c SjzNx/P6ztxko+AbYrEDoWlavCrffg6RLfIGbL87fXIIZC3a2P7Bk4AFBt3On24Rq/z2 C+xXGSPP9CUIXY6jwcu0LRP19R6QbEc0l5LAxSpfGZ8gfJ2/z1iLzX2/ODIAE32FpXSe qfNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cjliJuA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020a056a0014ce00b0056c0a9e09f0si10194949pfu.292.2022.12.12.05.02.43; Mon, 12 Dec 2022 05:02:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cjliJuA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbiLLMkQ (ORCPT + 75 others); Mon, 12 Dec 2022 07:40:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232200AbiLLMjy (ORCPT ); Mon, 12 Dec 2022 07:39:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2848955AE for ; Mon, 12 Dec 2022 04:38:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D2BA1B80D20 for ; Mon, 12 Dec 2022 12:38:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10685C433EF; Mon, 12 Dec 2022 12:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670848721; bh=hVzoOsyhwS9evjgtcwkNyUUi5Ga7nvRZ83iWkuubvr4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=cjliJuA9RtYf4AvLwNw9qsB8Sbzrx1Q/eDqyJh6qUnVpcBn7rdf5w5kcTBmuRxuzm rOf5nlY6Ef8Vr5GioJ2JHqPtqqIrmq+AfB27xAlgol1eNXN6V1m2a5rthDAy5Y4rMo p0fXPN7YxcJXzD43KIKFbT6j44whIaU49Etn7pV8f6GkA9thkFkEcMb/j7/6mvcA3W 6XrzXDjgDNUgAPkYC2t5l9gzTuNhDtwzqp1rpthxhv3ntc/Yc56YvzJ7fZAkydDToA /mQAtXLI9KFRxVjI+choL4MrXDulpbzwfC55uGai9jHpXlLNj5WzWPOvid67Ae94/j 130NHknOVWE4A== Message-ID: Date: Mon, 12 Dec 2022 20:38:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH] f2fs: don't set FI_COMPRESS_RELEASED if file is not compressed Content-Language: en-US To: Jaegeuk Kim , zhoudan8 Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, zhoudan8 References: <20221208050808.2448146-1-zhoudan8@xiaomi.com> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/12/10 4:19, Jaegeuk Kim wrote: > On 12/08, zhoudan8 wrote: >> In compress_mode=user, f2fs_release_compress_blocks() >> does not verify whether it has been compressed and >> sets FI_COMPRESS_RELEASED directly. which will lead to >> return -EINVAL after calling compress. >> To fix it,let's do not set FI_COMPRESS_RELEASED if file >> is not compressed. > > Do you mean you want to avoid EINVAL on a file having FI_COMPRESS_RELEASED > with zero i_compr_blokcs? > > I think the current logic is giving the error on a released file already. IMO, if i_compr_blocks is zero, it's better to return -EINVAL in f2fs_release_compress_blocks(), as there will be no benefit after the conversion. Thanks, > >> >> Signed-off-by: zhoudan8 >> --- >> fs/f2fs/file.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >> index 82cda1258227..f32910077df6 100644 >> --- a/fs/f2fs/file.c >> +++ b/fs/f2fs/file.c >> @@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) >> ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX); >> if (ret) >> goto out; >> - >> - set_inode_flag(inode, FI_COMPRESS_RELEASED); >> inode->i_ctime = current_time(inode); >> f2fs_mark_inode_dirty_sync(inode, true); >> >> if (!atomic_read(&F2FS_I(inode)->i_compr_blocks)) >> goto out; >> >> + set_inode_flag(inode, FI_COMPRESS_RELEASED); >> f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); >> filemap_invalidate_lock(inode->i_mapping); >> >> -- >> 2.38.1