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 70B3DC77B73 for ; Thu, 27 Apr 2023 09:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243380AbjD0Ji1 (ORCPT ); Thu, 27 Apr 2023 05:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242895AbjD0JiY (ORCPT ); Thu, 27 Apr 2023 05:38:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6254CE for ; Thu, 27 Apr 2023 02:38:23 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 6412C63C0F for ; Thu, 27 Apr 2023 09:38:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D922C433EF; Thu, 27 Apr 2023 09:38:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682588302; bh=8h3n++F1xXGmMbuOXjl1rR2J8pNfIheLahD5RfGRUfk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=EjKKegG6uccwvlOD9bx9j7Xn+WMIH5PPxpdO+uu48UeQLht6Kr97s95yJc74N1bcA 89kwt5mMhNjrBBysK467aa4QKFaIZW7wcSEDHK9V6ookjxXB5akAsu4ACKKeTABTg0 eqRC/vCgq81nCVej2DZeUer0J4lnFcUlhKZ/hY3THvKws4w1dVz36z7LuYu4hY8zLy 4TnG74khF3+ANXT0q/VYEbfFEZ1NZruqjQKFvbqUSbdUep/LhTlqtPyxrqaE/yg0r6 meeoQCi1d2clRoz/lYF3DTTfG+aPVEuTlHr2Yl0RSLxD5d8mDGyNVBfE9tQ6BXxPz4 BwxbGb0EtHhBA== Message-ID: <626404fe-3547-979f-f483-b43416f6f88a@kernel.org> Date: Thu, 27 Apr 2023 17:38:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED Content-Language: en-US To: Yangtao Li , Jaegeuk Kim , Daeho Jeong Cc: Qi Han , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20230425151126.50566-1-frank.li@vivo.com> From: Chao Yu In-Reply-To: <20230425151126.50566-1-frank.li@vivo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/4/25 23:11, Yangtao Li wrote: > If a file has FI_COMPRESS_RELEASED, all writes for it should not be > allowed. > > Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE") > Signed-off-by: Qi Han > Signed-off-by: Yangtao Li > --- > fs/f2fs/file.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 9c9c3f660e01..c21d6a829c4a 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -2734,6 +2734,9 @@ static int f2fs_ioc_defragment(struct file *filp, unsigned long arg) > if (f2fs_readonly(sbi->sb)) > return -EROFS; > > + if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) > + return -EINVAL; This flag should be checked w/ inode lock. Thanks, > + > if (copy_from_user(&range, (struct f2fs_defragment __user *)arg, > sizeof(range))) > return -EFAULT;