Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2106723pxb; Sat, 7 Nov 2020 09:23:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNLZP/024S8mKHWzbO6mp+JnHlkr1Dh2/ba/SZzUBiCHqJXdd9eOd7gYk0Xe9L7fTti3Ml X-Received: by 2002:a17:906:3c13:: with SMTP id h19mr7723911ejg.117.1604769828417; Sat, 07 Nov 2020 09:23:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604769828; cv=none; d=google.com; s=arc-20160816; b=jJq73df3b1iYL4lOMQFiryAMXIZzSX7VnPIN22O0dOW3wnaDjD4YrRf5/smolNfhjO BJ1bup87dbT8GRcfFAxFglBj3WzLxB6RKf08xyAiPtMp9BoMf/P4SsKKfwNJbM5zXEj+ B9zXmM6+YCtUvmgDvSa9MUVigsXKKR33c0rkKUX2X4s+ZP7cLhkAP3AoT333xyATyVRg WgWXGHVRKhenzYc8UUPjrFRij9nfFghpzF7HyvaX9iULZzGwUpwBmeabQlkEQsjpVITn WJjzmL5Q24dTIcN950dOjloV0JDsJXz9xxFy0Jfe4p5rYPm4c8V9sMCuEDcg2yU7eYmx kp0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C4lQpV/c1bF5WWl58x7Te9DBvP/DX6Mdw9Z4cvospjY=; b=oxr84M4A8WhAWjPzhhCQMkBXJRDklKMeubKG608GHo1ISfkMrYRKgBw56sb3vRBuWh n+6VAxSoO0x9pZOs4zs7AtdwwBma4MtQ4Q8NvGn0uYEL9xdaN3M2W4JGDm9kC8T4Q7pC NVWjvh0QTDTxfU271dGKeG/Oe8hS1J04vwIwJcCgSHlfQgjpn9ab45+3lYq+wMg45g51 qDTqwBxu8BQ6RzZqMdtE87I1jSGNJemyA/JwH2HzJeRGrDTHzy/7vvyyYDTWA15VUZnS KFG2yVv/m4rPIfJObWkpPBfyRQ50MZ36Q/cSBGt1o9h0nFmsWN8UYEzlXzeR7f4844ZB 34Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2ui2PMqz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w15si3416708ejk.62.2020.11.07.09.23.10; Sat, 07 Nov 2020 09:23:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2ui2PMqz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727332AbgKGRQh (ORCPT + 99 others); Sat, 7 Nov 2020 12:16:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:54126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726284AbgKGRQh (ORCPT ); Sat, 7 Nov 2020 12:16:37 -0500 Received: from sol.localdomain (172-10-235-113.lightspeed.sntcca.sbcglobal.net [172.10.235.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DA66920878; Sat, 7 Nov 2020 17:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604769397; bh=VMqMnbjzVosHlpvEbYLFq0+HfLfBtdYGJjT4bgAoHwE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2ui2PMqzN7ca8Nvf247liiW9Wo9Ev9y9RKgduhAAE7ePQEy/9u/ZCaeqZo1TEG3Hn 2ppqn5AxFu2mu8oB0jzJIzyI68sr3m6vuJSfiRrdBbDURRJ9A8biG/YMQZU7a72gAF tudE7+nsHEas5RborIZ10LGVZLpKlJu3BblKxiRA= Date: Sat, 7 Nov 2020 09:16:35 -0800 From: Eric Biggers To: Chao Yu Cc: Chao Yu , jaegeuk@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH v4 2/2] f2fs: fix compat F2FS_IOC_{MOVE, GARBAGE_COLLECT}_RANGE Message-ID: <20201107171635.GA841@sol.localdomain> References: <20201106065331.76236-1-yuchao0@huawei.com> <20201106180324.GA78548@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 07, 2020 at 05:25:23PM +0800, Chao Yu wrote: > On 2020/11/7 2:03, Eric Biggers wrote: > > On Fri, Nov 06, 2020 at 02:53:31PM +0800, Chao Yu wrote: > > > +#if defined(__KERNEL__) > > > +struct compat_f2fs_gc_range { > > > + u32 sync; > > > + compat_u64 start; > > > + compat_u64 len; > > > +}; > > > > There's no need to use '#if defined(__KERNEL__)' in kernel source files. > > > > Likewise for compat_f2fs_move_range. > > Correct. > > > > > > +static int f2fs_compat_ioc_gc_range(struct file *file, unsigned long arg) > > > +{ > > > + struct f2fs_sb_info *sbi = F2FS_I_SB(file_inode(file)); > > > + struct compat_f2fs_gc_range __user *urange; > > > + struct f2fs_gc_range range; > > > + int err; > > > + > > > + if (unlikely(f2fs_cp_error(sbi))) > > > + return -EIO; > > > + if (!f2fs_is_checkpoint_ready(sbi)) > > > + return -ENOSPC; > > > > I still don't understand why this checkpoint-related stuff is getting added > > here, and only to the compat versions of the ioctls. It wasn't in the original > > version. If they are needed then they should be added to __f2fs_ioc_gc_range() > > and __f2fs_ioc_move_range() (preferably by a separate patch) so that they are > > If so, cp-related stuff will be checked redundantly in both f2fs_ioctl() and > __f2fs_ioc_xxx() function for native GC_RANGE and MOVE_RANGE ioctls, it's > not needed. > Oh I see, the cp-related checks are at the beginning of f2fs_ioctl() too. In that case a much better approach would be to add __f2fs_ioctl() which is called by f2fs_ioctl() and f2fs_compat_ioctl(), and have f2fs_ioctl() and f2fs_compat_ioctl() do the cp-related checks but not __f2fs_ioctl(). I feel that's still not entirely correct, because ENOTTY should take precedence over EIO or ENOSPC from the cp-related stuff. But at least it would be consistent between the native and compat ioctls, and the cp-related checks wouldn't have to be duplicated in random ioctls... - Eric