Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp214951ybh; Tue, 14 Jul 2020 23:27:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6u0Ur7QAQduYlYzMGk60NHP+CBuDu6uwzTVdWsG3i0KgDEREj/W1t8PaORDvSQ3of7oMi X-Received: by 2002:a50:cbcd:: with SMTP id l13mr7894053edi.384.1594794467826; Tue, 14 Jul 2020 23:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594794467; cv=none; d=google.com; s=arc-20160816; b=N1yAAM+BUX6kie/YyQ22UoC7Q1DbPaStOY/uTbpRQf+NZ7j9AdQBv8RuZV48pBmXmn CwckgJxg3p0+AFalk/aN0W8SE110cwyzjJ+uS/yLJLbFQIN09sqaH/Azi9bg3U/lcXgl eNmV2GzR2QcgpTPPr/JCSjuSv4AZAOQ+nhaZt4QHe52ZQnwBrpIrh3zyOL9o07GvuY3f rq1WcFjDMI3w1wLz8BtnFOWO8v1qmsEk+sBWy9oeCiWL1pR1q5K2KCmuOB5WZz/qPKrH by8bhlmEVdiuqAd1Uwx+8hgpTOVu7zX7UT230x4bH3ztf+Gvs8ONaesKArkZdLLwaS9P f2JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=+n9eE/3C5NzRJMCL6a+1ip1zGWoxWYKNJ+LTzIxA9rs=; b=0VwIkm4xt/akG1BblX85KxNIGbhgkjvckTNeHf6xOPDNluNCCBzMr1IECiV1GKGFrI 7sugVAyio5AjdfSiaxAKKR6YW2GYr0U7p/9btZont2F06W3HW6ZSvVphj6N2sVtPJark InaXgkKeOnZJMTVCaAWW+aBuVnJTubEydLgU8sfiZ+c3ttAqzO3gOJhU6YUtPD4G7Aw5 iIhWgheIpUGAta8pSmrzg2jEhUfJwjUdL6j/o2y3MImpKvo/BZBe32IhtzZYui1CAfh6 ONqz7Fyo0yfhxeE7L6Pog+rZ4zxGtJIf/+w7IDIWSjJVIU9IHA2SkIlt3bUB1Vu+0Ehf 1Rxg== 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 f12si676837ejx.143.2020.07.14.23.27.25; Tue, 14 Jul 2020 23:27:47 -0700 (PDT) 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 S1728409AbgGOGRB (ORCPT + 99 others); Wed, 15 Jul 2020 02:17:01 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:38938 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725866AbgGOGRB (ORCPT ); Wed, 15 Jul 2020 02:17:01 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D38F29671EBDBCF0AA7B; Wed, 15 Jul 2020 14:16:58 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.204) with Microsoft SMTP Server (TLS) id 14.3.487.0; Wed, 15 Jul 2020 14:16:57 +0800 Subject: Re: [f2fs-dev] [PATCH v2] f2fs: change the way of handling range.len in F2FS_IOC_SEC_TRIM_FILE To: Daeho Jeong CC: Jaegeuk Kim , Daeho Jeong , , , References: <20200713031252.3873546-1-daeho43@gmail.com> <20200713181152.GC2910046@google.com> <3b02263d-a5e1-136c-40ed-514d34e4c895@huawei.com> From: Chao Yu Message-ID: Date: Wed, 15 Jul 2020 14:16:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/7/15 12:06, Daeho Jeong wrote: > We could use fscrypt_zeroout_range() for an encrypted file. > But, one problem is fscrypt_zeroout_range() assumes that filesystems > only use a single block device. > It means it doesn't receive bdev as a parameter. > How about changing the interface of fscrypt_zeroout_range() first and using it? Yes, please limited to use fscrypt_zeroout_range() on non-multidevice f2fs image first, we can add a condition to check that in the beginning of ioctl interface, once fscrypt_zeroout_range() accepts bdev as parameter, we can remove that limitation. Thanks, > > 2020년 7월 14일 (화) 오후 9:36, Chao Yu 님이 작성: >> >> On 2020/7/14 2:11, Jaegeuk Kim wrote: >>> Hi Daeho, >>> >>> Please take a look at this. >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev&id=35245180459aebf6d70fde88a538f0400a794aa6 >> >> I'm curious about what will happen if we call >> sec_trim_file(F2FS_TRIM_FILE_ZEROOUT) on an encrypted file, will >> it use zero bits covering encrypted data on disk? >> >> Thanks, >> >>> >>> Thanks, >>> >>> On 07/13, Daeho Jeong wrote: >>>> From: Daeho Jeong >>>> >>>> Changed the way of handling range.len of F2FS_IOC_SEC_TRIM_FILE. >>>> 1. Added -1 value support for range.len to secure trim the whole blocks >>>> starting from range.start regardless of i_size. >>>> 2. If the end of the range passes over the end of file, it means until >>>> the end of file (i_size). >>>> 3. ignored the case of that range.len is zero to prevent the function >>>> from making end_addr zero and triggering different behaviour of >>>> the function. >>>> >>>> Signed-off-by: Daeho Jeong >>>> --- >>>> Changes in v2: >>>> - Changed -1 range.len option to mean the whole blocks starting from >>>> range.start regardless of i_size >>>> --- >>>> fs/f2fs/file.c | 23 ++++++++++++----------- >>>> 1 file changed, 12 insertions(+), 11 deletions(-) >>>> >>>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>>> index 368c80f8e2a1..2485841e3b2d 100644 >>>> --- a/fs/f2fs/file.c >>>> +++ b/fs/f2fs/file.c >>>> @@ -3792,7 +3792,7 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) >>>> pgoff_t index, pg_end; >>>> block_t prev_block = 0, len = 0; >>>> loff_t end_addr; >>>> - bool to_end; >>>> + bool to_end = false; >>>> int ret = 0; >>>> >>>> if (!(filp->f_mode & FMODE_WRITE)) >>>> @@ -3813,23 +3813,23 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) >>>> file_start_write(filp); >>>> inode_lock(inode); >>>> >>>> - if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) { >>>> + if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) || >>>> + range.start >= inode->i_size) { >>>> ret = -EINVAL; >>>> goto err; >>>> } >>>> >>>> - if (range.start >= inode->i_size) { >>>> - ret = -EINVAL; >>>> + if (range.len == 0) >>>> goto err; >>>> - } >>>> >>>> - if (inode->i_size - range.start < range.len) { >>>> - ret = -E2BIG; >>>> - goto err; >>>> + if (inode->i_size - range.start > range.len) { >>>> + end_addr = range.start + range.len; >>>> + } else { >>>> + end_addr = range.len == (u64)-1 ? >>>> + sbi->sb->s_maxbytes : inode->i_size; >>>> + to_end = true; >>>> } >>>> - end_addr = range.start + range.len; >>>> >>>> - to_end = (end_addr == inode->i_size); >>>> if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) || >>>> (!to_end && !IS_ALIGNED(end_addr, F2FS_BLKSIZE))) { >>>> ret = -EINVAL; >>>> @@ -3846,7 +3846,8 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) >>>> down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); >>>> down_write(&F2FS_I(inode)->i_mmap_sem); >>>> >>>> - ret = filemap_write_and_wait_range(mapping, range.start, end_addr - 1); >>>> + ret = filemap_write_and_wait_range(mapping, range.start, >>>> + to_end ? LLONG_MAX : end_addr - 1); >>>> if (ret) >>>> goto out; >>>> >>>> -- >>>> 2.27.0.383.g050319c2ae-goog >>> >>> >>> _______________________________________________ >>> Linux-f2fs-devel mailing list >>> Linux-f2fs-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel >>> . >>> > . >