Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2900399pxb; Sun, 8 Nov 2020 18:19:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpqWy/G/wouetTjTSkEzv8NjVEVLZ9RAojB7tcZ7Ey4LPlE6dA36IQ9xqBt2j5rsocEEyx X-Received: by 2002:a17:906:3a02:: with SMTP id z2mr12604289eje.452.1604888361095; Sun, 08 Nov 2020 18:19:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604888361; cv=none; d=google.com; s=arc-20160816; b=RPqtEUfk1fZ+8pDrMqC6asq3XDhxfdv9HyAUzYVI9ugxRoacxIPCbicuGaCtshsRhn WKnQ7fmFRTs6LaLcHmOG/hpcvGbMvdCtHM3NRjO9nPgneHnUuLZvrnbHb5a2cVMoCHxC X1zP1BXH9tlmDHeXrMWI8xmnaOJYxUTyWCjsZSGtJdHXLcnCYD+4sZ/aig9fLupmTwMu O82dmV+se2ZvcgzdUvrtw2idhnFj+llMhy83APU/J4pNPrXgzkCRHE6bTCPsx1MK73Z8 4RijfW2YFCc6KhTjkvCXp++oOfTD2D8OQhwVw0h+rzcIh1ATBPHOaab8LU58UbNgd1AI Srzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=BAnkqjGdFE+5tebj+Uxnz2HOtcwb2FlSwUKBl8Fx274=; b=X6mRZBdkwNm8B2d1WtmG6gVy16flJjvKFre6LFmpgFWrdk/0lbb7tvq5PwpEmhD6no ctkK1hX/R8xGTIqB+X0wI1yuOC+uZ3X2MBXZLtmGCDVmfB9HDKAQhSRD35IHmYZHYu2G Hurns8fZyUMXHJctBXKnBOny/hQTG4vVMNH2Y1EUQIvtNhquxvHUh90bZMZRyMSgeWpp kUXJAvqohU2+Ll3MXDx9x3LQjdKn0fvQk95xCaPDOXWQPiBUKM4CSQF9+1cTcRyMOZIM Kz8AY8awgHqN19qPgNV3VD6u+hZyB0yXjM31Xsx0YDkjvqBum5ik1hsugJgBzd7aoXjo ayTQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dh19si5978032edb.148.2020.11.08.18.18.58; Sun, 08 Nov 2020 18:19:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729140AbgKICO7 (ORCPT + 99 others); Sun, 8 Nov 2020 21:14:59 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:7467 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728006AbgKICO6 (ORCPT ); Sun, 8 Nov 2020 21:14:58 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4CTvhY092Qzhj9x; Mon, 9 Nov 2020 10:14:53 +0800 (CST) Received: from [10.136.114.67] (10.136.114.67) by smtp.huawei.com (10.3.19.204) with Microsoft SMTP Server (TLS) id 14.3.487.0; Mon, 9 Nov 2020 10:14:56 +0800 Subject: Re: [f2fs-dev] [PATCH v3 2/2] f2fs: fix compat F2FS_IOC_{MOVE, GARBAGE_COLLECT}_RANGE To: Jaegeuk Kim , CC: Eric Biggers , , References: <20201105010934.16018-1-yuchao0@huawei.com> <20201106000550.GD2555324@gmail.com> <07454135-539d-a159-deb8-ff29df7e22de@huawei.com> <20201106214028.GC1474936@google.com> From: Chao Yu Message-ID: <3108fbd8-94c2-31e6-cbaf-ec4756f3dd88@huawei.com> Date: Mon, 9 Nov 2020 10:14:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20201106214028.GC1474936@google.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.114.67] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/11/7 5:40, Jaegeuk Kim wrote: > On 11/06, Chao Yu wrote: >> On 2020/11/6 8:05, Eric Biggers wrote: >>> This patch is marked 2/2, but it seems you sent it out on its own. Patch series >>> are supposed to be resend in full; otherwise people can see just one patch and >>> have no context. >> >> That's a historical problem, as in last many years, we (f2fs community) don't have >> other long-term reviewers except Jaegeuk and me, so we have unwritten rule: only >> resending changed patch in patchset. >> >> IMO, that helps to skip traversing unchanged patches, and focusing reviewing on the >> real change lines, and certainly we have its context in mind. >> >> Personally, I prefer to revise, resend or review patch{,es} of patchset have real >> change line in f2fs mailing list, anyway we can discuss about the rule here. > > Chao, I think we need to change this to resend whole patch-set again, since > it's a bit difficult to catch which part of patches were the latest one. Oh, I've no objection, if it really helps you. +Daeho, Thanks, > >> >>> >>> On Thu, Nov 05, 2020 at 09:09:34AM +0800, Chao Yu wrote: >>>> Eric reported a ioctl bug in below link: >>>> >>>> https://lore.kernel.org/linux-f2fs-devel/20201103032234.GB2875@sol.localdomain/ >>>> >>>> That said, on some 32-bit architectures, u64 has only 32-bit alignment, >>>> notably i386 and x86_32, so that size of struct f2fs_gc_range compiled >>>> in x86_32 is 20 bytes, however the size in x86_64 is 24 bytes, binary >>>> compiled in x86_32 can not call F2FS_IOC_GARBAGE_COLLECT_RANGE successfully >>>> due to mismatched value of ioctl command in between binary and f2fs >>>> module, similarly, F2FS_IOC_MOVE_RANGE will fail too. >>>> >>>> In this patch we introduce two ioctls for compatibility of above special >>>> 32-bit binary: >>>> - F2FS_IOC32_GARBAGE_COLLECT_RANGE >>>> - F2FS_IOC32_MOVE_RANGE >>>> >>> >>> It would be good to add a proper reported-by line, otherwise it's not clear who >>> "Eric" is (there are lots of Erics): >>> >>> Reported-by: Eric Biggers >> Sure, although I attached the link includes original report email, in where it >> points out who "Eric" is. >> >>> >>>> +static int __f2fs_ioc_gc_range(struct file *filp, struct f2fs_gc_range *range) >>>> { >>>> - struct inode *inode = file_inode(filp); >>>> - struct f2fs_sb_info *sbi = F2FS_I_SB(inode); >>>> - struct f2fs_gc_range range; >>>> + struct f2fs_sb_info *sbi = F2FS_I_SB(file_inode(filp)); >>>> u64 end; >>>> int ret; >>>> + if (unlikely(f2fs_cp_error(sbi))) >>>> + return -EIO; >>>> + if (!f2fs_is_checkpoint_ready(sbi)) >>>> + return -ENOSPC; >>> >>> These two checkpoint-related checks weren't present in the original version. >>> Is that intentional? >> >> Quoted >> >>> It would be better to have __f2fs_ioc_gc_range() handle the f2fs_cp_error(), >>> f2fs_is_checkpoint_ready(), capable(), and f2fs_readonly() checks, so that they >>> don't have to be duplicated in the native and compat cases. >> >>> Similarly for "move range". >> >> I missed to check the detail, and just follow, I can clean up it. >> >>> >>>> +static int __f2fs_ioc_move_range(struct file *filp, >>>> + struct f2fs_move_range *range) >>>> { >>>> - struct f2fs_move_range range; >>>> + struct f2fs_sb_info *sbi = F2FS_I_SB(file_inode(filp)); >>>> struct fd dst; >>>> int err; >>>> + if (unlikely(f2fs_cp_error(sbi))) >>>> + return -EIO; >>>> + if (!f2fs_is_checkpoint_ready(sbi)) >>>> + return -ENOSPC; >>>> + >>> >>> Likewise here. >>> >>>> diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h >>>> index f00199a2e38b..8c14e88a9645 100644 >>>> --- a/include/uapi/linux/f2fs.h >>>> +++ b/include/uapi/linux/f2fs.h >>>> @@ -5,6 +5,10 @@ >>>> #include >>>> #include >>>> +#ifdef __KERNEL__ >>>> +#include >>>> +#endif >>>> + >>>> /* >>>> * f2fs-specific ioctl commands >>>> */ >>>> @@ -65,6 +69,16 @@ struct f2fs_gc_range { >>>> __u64 len; >>>> }; >>>> +#if defined(__KERNEL__) && defined(CONFIG_COMPAT) >>>> +struct compat_f2fs_gc_range { >>>> + u32 sync; >>>> + compat_u64 start; >>>> + compat_u64 len; >>>> +}; >>>> +#define F2FS_IOC32_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11,\ >>>> + struct compat_f2fs_gc_range) >>>> +#endif >>>> + >>>> struct f2fs_defragment { >>>> __u64 start; >>>> __u64 len; >>>> @@ -77,6 +91,17 @@ struct f2fs_move_range { >>>> __u64 len; /* size to move */ >>>> }; >>>> +#if defined(__KERNEL__) && defined(CONFIG_COMPAT) >>>> +struct compat_f2fs_move_range { >>>> + u32 dst_fd; >>>> + compat_u64 pos_in; >>>> + compat_u64 pos_out; >>>> + compat_u64 len; >>>> +}; >>>> +#define F2FS_IOC32_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \ >>>> + struct compat_f2fs_move_range) >>>> +#endif >>>> + >>>> struct f2fs_flush_device { >>>> __u32 dev_num; /* device number to flush */ >>>> __u32 segments; /* # of segments to flush */ >>>> -- >>> >>> Did you consider instead putting these compat definitions in an internal kernel >>> header, or even just in the .c file, to avoid cluttering up the UAPI header? >> >> Better. >> >> I can move them before their use. >> >>> >>> - Eric >>> . >>> > . >