Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp724830lqe; Sun, 7 Apr 2024 00:29:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWY3ir7MCp8WUOB8/GiKU0fQyRvwZor60qVpkuWJEHqWNDNk2RL4MyBqsG4ouM8zwHFoguCPAVwMn83Ne6yI+vxnVYaM5scG6wBFUcAAQ== X-Google-Smtp-Source: AGHT+IGt/QJGv6oi51mmOrv9+dT0Gqe+Zck0K6J3qIohrp++Ii1ZAr+r/pGcrOffbhyifQYqSbPC X-Received: by 2002:a50:8ad1:0:b0:56b:d1c2:9b42 with SMTP id k17-20020a508ad1000000b0056bd1c29b42mr5708972edk.29.1712474973958; Sun, 07 Apr 2024 00:29:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712474973; cv=pass; d=google.com; s=arc-20160816; b=Qm4YVIZ9eskyREJGkl2luuAHf5jgJLI0auVHXDUQFAs+sMF0G/j/40ekMAlnhXLKbn 9uPPz1yJFZz1XdCJqCpkEKX+x9ubIlo31VT1FZjzdnKgauwHZlwi3fbw3EE64F3wRJGR 4s0NDxWHE9P1m4ON2cVltyr73DAZBEKOnfMLLQvtOvV5XI4I6jSgcStFDlVgEfHmAMMi aMS9wUzJIS8XDV662myx0UB1B9XhqTDm67INCY0diTA0xPmu0sAcbW0xjGRqZ4uxyXoD c5/g6jgySpIjQyvMI3IhVP6Te5cXP1IsBPen9fZYY/h9IyNXj+NSSD1eIqpm5COHOKgJ qwFA== 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:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=0LgOyS1TRM/uP23jtucXc5fiEJFgH+5DfHGysuGOTUc=; fh=H5v+CjkY1nRWdftDHNboMCIe1nH85PkL3QB3W/+Szvo=; b=KEdKf8rVegbOY6JmtbyGlTXlZbiSVE1rc9KhVVlrKH61RV/2jwxAtkQwTzbz/Im3o1 3RDh7GcWt8KHKz85yc652DEEHB8uORHMLuZI+OycvLNWefeTuLoC3/M4/+X/klYr1ccF fpGlFCAxhzKeX0lGS9MsctWvySQTznOt8kz7BT1RFGQxtRORrOWqPo7XfXjgNK/40V0a 1FI8Ku4lHacj+GYtGamxEcKFe5CHLb2eP/yWDiOe3wGv3u/73q0V+eXC7jYPAR8RM8tz 5R3Gkfu1JN0xZ3T4hnEqXUESENTRSTvrwzpMiuas0nfJL7jnbzSvfc/8mpug0PRX8GE+ ybkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m+es7zhb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134222-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134222-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o13-20020a1709061b0d00b00a519d903787si2497596ejg.754.2024.04.07.00.29.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 00:29:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134222-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m+es7zhb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134222-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134222-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A3B191F23A83 for ; Sun, 7 Apr 2024 07:29:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00F9DDDBD; Sun, 7 Apr 2024 07:29:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m+es7zhb" 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 2E2416AB9 for ; Sun, 7 Apr 2024 07:29:26 +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=1712474966; cv=none; b=qycwoyLDn9Q4j4Hq5ttrJT49aWfvn4OxsjEW/bKxxoJvBWa5mq/r91wTMGPhfiRxKs7ZjmL2b+R1DiLlO4EDluBPdhslMBBdCFtwHWMfwlDKiuMJEc5uz2WGjfuj+E8m7HD/ZVi0kI36dvuMHVMWlIBsyTJk0rmuzXy5bzsiVeo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712474966; c=relaxed/simple; bh=29YP5x/Os973Sl32/dIiO+nQ4l2sbAEznxA8GpsSHS8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=k/pKgY6FdgyO0DLnhbP8qMGgcd0DWcuxHbmiNr4dnnkmEIDKO+kMpb/MKzg3wTiqhW5ynyr/CFNMwcZzPezP59/PWWQAmSzuZW4Sp3Ibo0HppxG8sqS0H+KeNeyi/Q3OPraWxk8oJ1CIjQvO11SNYFgHoVbIpT5VdXzR9xUeKAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m+es7zhb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B265C433F1; Sun, 7 Apr 2024 07:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712474966; bh=29YP5x/Os973Sl32/dIiO+nQ4l2sbAEznxA8GpsSHS8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=m+es7zhb6d8kBBprLCV3fRWapkeqAnZHqpxDTSeZbFtIoUOOlZXIT/Kc/0f55Yl/H XtRGjpcNfI7X81yaP/o9u0BrfwkoifSpVMke7s6cjaUUPDabSzw4MG+EkHppR+RHLo 5XssEb8U7UZ1y+0NTm15xbxYC+9icWnGuWZVU0AQ5ulUX77GW0HA4I/9gLNF5pq+B0 axw1ck0U4/yJL7s4mlpjX2v0bDEORK/2sktFwaaWKgiCZWPJ/gb6K9MYLx5MGI6xVh 3Z6Ky5fG+7vhym7mITs1cBF6pkUniF6CrC6jGk8aiReOxefYLIYQjywCTkEhPJMEdo Hi8BywgbNXwMQ== Message-ID: <6a50a23e-8975-43cb-9496-38b6a083c703@kernel.org> Date: Sun, 7 Apr 2024 15:29:21 +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: [f2fs-dev] [PATCH 1/2] f2fs: fix to relocate check condition in f2fs_fallocate() To: Zhiguo Niu Cc: jaegeuk@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20240403142420.2042498-1-chao@kernel.org> Content-Language: en-US From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/4/7 10:11, Zhiguo Niu wrote: > On Wed, Apr 3, 2024 at 10:26 PM Chao Yu wrote: >> >> compress and pinfile flag should be checked after inode lock held to >> avoid race condition, fix it. >> >> Fixes: 4c8ff7095bef ("f2fs: support data compression") >> Fixes: 5fed0be8583f ("f2fs: do not allow partial truncation on pinned file") >> Signed-off-by: Chao Yu >> --- >> fs/f2fs/file.c | 20 +++++++++++--------- >> 1 file changed, 11 insertions(+), 9 deletions(-) >> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >> index 148bfe3effdf..83a807e25e31 100644 >> --- a/fs/f2fs/file.c >> +++ b/fs/f2fs/file.c >> @@ -1820,15 +1820,6 @@ static long f2fs_fallocate(struct file *file, int mode, >> (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE))) >> return -EOPNOTSUPP; >> >> - /* >> - * Pinned file should not support partial truncation since the block >> - * can be used by applications. >> - */ >> - if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) && >> - (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE | >> - FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE))) >> - return -EOPNOTSUPP; >> - >> if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | >> FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE | >> FALLOC_FL_INSERT_RANGE)) >> @@ -1836,6 +1827,17 @@ static long f2fs_fallocate(struct file *file, int mode, >> >> inode_lock(inode); >> >> + /* >> + * Pinned file should not support partial truncation since the block >> + * can be used by applications. >> + */ >> + if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) && >> + (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE | >> + FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE))) { >> + ret = -EOPNOTSUPP; >> + goto out; >> + } >> + > Dear Chao, > I see the judgment code "if(!f2fs_compressed_file(inode))" also is > before inode_lock in functions > f2fs_ioc_decompress_file/f2fs_ioc_compress_file/f2fs_reserve_compress_blocks/f2fs_release_compress_blocks. > should they are changed together? Zhiguo, Thanks for noticing that, I've submitted separated patches for fixing because those bugs were introduced by separated commits. Thanks, > thanks! >> ret = file_modified(file); >> if (ret) >> goto out; >> -- >> 2.40.1 >> >> >> >> _______________________________________________ >> Linux-f2fs-devel mailing list >> Linux-f2fs-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel