Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp796903lqs; Tue, 5 Mar 2024 17:52:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVJt9fVkMrCuJ1phQBmCeDgmpS3CwXKdLUeCO+ZYI6XGfDRKwxmwgGkLAEUT9gfy1Zki88ImMyRgRcptd7oJbNq5TMKYjD9xbawB1hDqQ== X-Google-Smtp-Source: AGHT+IF6csx8rd65cHjF1BtAu6EjCybOP0dkQ5k3pyXxNGf4RXR/+cbJ2P+fXKEhC7gqrgCKi3u+ X-Received: by 2002:a81:9c02:0:b0:609:782a:d89a with SMTP id m2-20020a819c02000000b00609782ad89amr12803990ywa.38.1709689928855; Tue, 05 Mar 2024 17:52:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709689928; cv=pass; d=google.com; s=arc-20160816; b=w350/+PB2wzY9fwJUTQU4PxIAgDKbKB6YKoQDtwBnD5T0JoJZzg/CqWq/Ze55srFHw YhJ2eJDsPXfCtL1FxmML3KQP9VWArEgrcLHFm4pjJ71lSCkrSypIJhp3aOGpJlsyXbKN PP98PVT+M7U8WwcziHrfJ6gadj9Zo5477059iQetO9TGgu0TapR6qG7GC+lQtaCNVBi0 UUXjIqbGAl1EeVAkVhk4JmkFVskKHXZcPVzGlFp1rQBeoeQ7Lc6dtf+mpyJEtyhFAfiE 6BNfEObSGGxyZwG4imRvkhBEcH665l5pLWuVcJK8DcEfLhuA9gd88zMGFlGEuLuDPwSG r/Lg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=TnRNOU9nKba7ba887pjqIui41IKr2WrMUgD097id/+k=; fh=QhT4AewQ/l4mQgtzqs75wC7f0rfn0bZrrPkyy+yxAho=; b=JOshEWzvUTTkjHZUgYl03SS5xE5PJCzDoScRcD9gmAu+LSAKdRn+h3volb+DmdH3KX DL+ZZSg2Zdj3Ld2Ck9w8IH6jPGEFajuvXTYzBf+9ZfZH/mcDKcMbHBTykdku2v83R27H wEPpezF/5FeQaTTzXBLPE6ellGaVBqJ77Z3MzenzEkpaOtCnXiP2BHO0LCnizcTtX3un cWD2gbqNfMxLBGlLTkgpapHgCzVS0TeoXDN8QYz0j/X55/jV9muobUhYJS4vaAA82xTW VrNH2yb+gAS8mqSjSn5D83Je+DnUbNcz1f75iOalQXL0wP8GpY4BnL0uXKOWdtuj/XYY fPjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mEfbDRIV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93208-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93208-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o7-20020a05622a008700b0042ee0332b2dsi8037117qtw.217.2024.03.05.17.52.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 17:52:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93208-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mEfbDRIV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93208-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93208-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4AEFF1C21757 for ; Wed, 6 Mar 2024 01:52:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 137F279E4; Wed, 6 Mar 2024 01:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mEfbDRIV" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 362256FBD for ; Wed, 6 Mar 2024 01:52:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709689923; cv=none; b=Vy4tfDzXvguHUycyndLczq9BrgEOUBPHZsfhj+qGeKLrLSerltFgBEpJggtuSBD97A1wFJvdmkan8oDgv6RqZeJdJQeg1wbs+cFP5MQbPPovmHaVTWa7fhMPvW6uU/S16/OSXG2wyx39qnYBZZDEnqbXYeUpGxttCCr+AOEniE0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709689923; c=relaxed/simple; bh=pjR8YIBGq1VNa51QiHXbbJg32nHSnWWaN8QomRREMxg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sFK0XL5RXKs1z8mGn/G1czPdc5LIkmweML7pIZtAaFYWdMoo9Sm7nuPENRvvhy7FUQ02Pp65LsjrrY8wky5H2cdBDBdRYwgD7gU1vat8Rx66zYyH7sE4A4CcjfT1oK+2FGAMXpANTaoVZJN+v5ggfXf+yiVAPFjrRt8h+1FR0n4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mEfbDRIV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A360EC433F1; Wed, 6 Mar 2024 01:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709689922; bh=pjR8YIBGq1VNa51QiHXbbJg32nHSnWWaN8QomRREMxg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=mEfbDRIVBOG3N/to2d9M9OyD8pavLacY7xA6M0dCBYF3+yCwNfpKJHE6PZY9aSkyK fxOg3yMuv9s6UwhwvaRHtz7NcMpxGTFX0yJRb3F0GqjdGT/As8DLtfzP1XUwnbzf7M abS0A2sQH5ZHwcUPJu99IfhR31tYhQe5lJk5MCUVx/a9g0Of21GX2fMb9+S2hiG3cU 6Iiby7rxMELga0D8EgoYLg3n28/cqAx0a3sMruRb7oC6KdypIyF0+cWz/5nElMqfW0 5IJXL14zQJsqo3g0FziOt2u0dXLUStgqxeR5QESaB0pz93VzENEzJIdnNdTJfx6Qrd yHYRhP//SuDmQ== Message-ID: <61637917-440e-4ed1-8820-fc7af8b8b4f3@kernel.org> Date: Wed, 6 Mar 2024 09:51:56 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] f2fs: compress: relocate some judgments in f2fs_reserve_compress_blocks Content-Language: en-US To: Xiuhong Wang , jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: hongyu.jin.cn@gmail.com, niuzhiguo84@gmail.com, ke.wang@unisoc.com, xiuhong.wang.cn@gmail.com References: <20240305084023.3686070-1-xiuhong.wang@unisoc.com> From: Chao Yu In-Reply-To: <20240305084023.3686070-1-xiuhong.wang@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/3/5 16:40, Xiuhong Wang wrote: > The following f2fs_io test will get a "0" result instead of -EINVAL, > unisoc # ./f2fs_io compress file > unisoc # ./f2fs_io reserve_cblocks file > 0 > it's not reasonable, so the judgement of > atomic_read(&F2FS_I(inode)->i_compr_blocks) should be placed after > the judgement of is_inode_flag_set(inode, FI_COMPRESS_RELEASED). > > Fixes: c75488fb4d82 ("f2fs: introduce F2FS_IOC_RESERVE_COMPRESS_BLOCKS") > Signed-off-by: Xiuhong Wang > Signed-off-by: Zhiguo Niu > --- > fs/f2fs/file.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 4ca6c693b33a..572d7bd4d161 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -3720,18 +3720,18 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) > if (ret) > return ret; > > - if (atomic_read(&F2FS_I(inode)->i_compr_blocks)) > - goto out; > - > f2fs_balance_fs(sbi, true); > > inode_lock(inode); > > if (!is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) { > ret = -EINVAL; > - goto unlock_inode; Nitpick, maybe keep unlock_inode label is better. > + goto out; > } > > + if (atomic_read(&F2FS_I(inode)->i_compr_blocks)) > + goto out; goto unlock_inode Thanks, > + > f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); > filemap_invalidate_lock(inode->i_mapping); > > @@ -3776,9 +3776,8 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) > inode_set_ctime_current(inode); > f2fs_mark_inode_dirty_sync(inode, true); > } > -unlock_inode: > - inode_unlock(inode); > out: > + inode_unlock(inode); > mnt_drop_write_file(filp); > > if (ret >= 0) {