Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1063849ybt; Wed, 8 Jul 2020 20:06:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyucdAdXDZNtkQTZZfb1C7A45TWVOCooINKIEM3c4CMCFDHEiiHBQPd8JOpcr9r28ZHZTSH X-Received: by 2002:aa7:db4f:: with SMTP id n15mr53436156edt.193.1594264014488; Wed, 08 Jul 2020 20:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594264014; cv=none; d=google.com; s=arc-20160816; b=EyiiI035nM5/2edFCYGH/NgTvN15Shn/r61TIghNjoaKz72+LUcPS4e83GTu3iRine hMY+ZywQnb7lWZPIvJtbQTa25EgzXmPWeWKir/DcgAP3rqyKEP3gkJ2jfe9wnQl0a9Mj 10xQw6hg+n0t3J/oi2WlrmD6ZnIoaMo4pSBbKAuRYy6OVdils3jc7Bp+wfMqNiA0Gcst War3en4dmDPs6m5Ma0oL0dMnoe591/hCMUZZu2jLVajs1PX1YmMgtxngu0R+DK0qGrXt mf8PYCARiVjsnxlz0zP9dATI4uW6LVSbOn7uGQmIHY7noJaOgpOQPxY3ZflLMXEY+R1M AHyg== 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=9FiNnjyOP8GnRW/3u9MXqOWMSM/Par+LqhGagyhx9uY=; b=s5AN60De5Sk71Rd+we2dxQ+l/x+Uf7slVOT7mQgaC7qdDNKvvsEUoppaiQxHksZOr5 1kfVHzOMP4jzkzwRGbYxmkUI4WZ4tRvNt8hCvhxEIn4l56+svB7bRx3UlRYu9DABItYT ut1xg/jTXyrWcqoDC3LvxpSLCUMYOl7RfUQtJjg2NtglLavfUuBTft08K8t9mKxFq2NG BCH45LkKiSQ3aXarq7mkXX1B+R/rv0pZwilxzp9r6JM66hExVAZ/14z1JJnJ8wXzQkBh 7LJT5twwK9CquxIZqcw9AR6JUBuyfupfmVGsiZQJ9ENeoktKNP4hoYRutrE2CJKfUteq 4+SQ== 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 d14si1192794eds.574.2020.07.08.20.06.31; Wed, 08 Jul 2020 20:06:54 -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 S1726163AbgGIDFW (ORCPT + 99 others); Wed, 8 Jul 2020 23:05:22 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:34002 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726107AbgGIDFV (ORCPT ); Wed, 8 Jul 2020 23:05:21 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B75356259D08A9F78B28; Thu, 9 Jul 2020 11:05:18 +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; Thu, 9 Jul 2020 11:05:16 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero To: Daeho Jeong , , , CC: Daeho Jeong References: <20200709015739.1653668-1-daeho43@gmail.com> From: Chao Yu Message-ID: <619af72b-2f8a-4a84-f73e-ac49989ba79f@huawei.com> Date: Thu, 9 Jul 2020 11:05:15 +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: <20200709015739.1653668-1-daeho43@gmail.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit 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/9 9:57, Daeho Jeong wrote: > From: Daeho Jeong > > When end_addr comes to zero, it'll trigger different behaviour. > To prevent this, we need to ignore the case of that range.len is > zero in the function. > > Signed-off-by: Daeho Jeong > --- > fs/f2fs/file.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 368c80f8e2a1..98b0a8dbf669 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -3813,15 +3813,14 @@ 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; How about the case trimming last partial written block? i_size = 8000 range.start = 4096 range.len = 4096 Do we need to roundup(isize, PAGE_SIZE) before comparison? Thanks, >