Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1134214ybt; Wed, 8 Jul 2020 22:40:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz58xQlNGF41jVv9zI+AGQ7REAA1BAyu7Hf5tjfXjqlH3UP8J+rCr+KWV7SbFkoyBF+02zn X-Received: by 2002:a05:6402:234b:: with SMTP id r11mr43168880eda.5.1594273227708; Wed, 08 Jul 2020 22:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594273227; cv=none; d=google.com; s=arc-20160816; b=D4JB31xwM++mNUpQgEbRhApcSicpxVCPvFDj6/3uf8kE9tlIuZfryGOR2jqesfxZ3u nlYSJb+ZhFSbgp/Z9FHAYd8GNfLZbIUaBXh7+n7qLBY/aRxjU1i/V+zGEUDpSfUWyuf3 nfGwnQtoP4E8ny8LiQCATVI5lRldo661rXxJzuZD3Ck6BXIXV5ZVWpkjSwMsQrUgDIpK 9wlFpc4w976TRNcxoO9seTGGkR5GR4TekZ2Xyw5dRNb4RScFL8xIrlTZnXMDFt25Je1H nCw/1BvDsB7QQkuKrU13Te8SGliBqTJGzHrgzghNczEo1lC3Zm4U1v6/HYLu1FsQ2hSo i9Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ybPb9YGpS26jLz7d9whzYvLJneH+JoiXowC+GvOHffc=; b=UxvdRAgm3FznkpodxneN7os34/tKXMwViVhA+RIIoIc8pvVdEENDBVinq9Jw2EKR7B FSnMOfCBQO10SK3krKK/F/u8Ovc3j+F07H+lDWNSyEU+zLAsxuM+m4DAfcj0zyRAhWSd oThIrO/DJJ4yiPVg8rj4QRkuuDY6dtPu7rL+5HwaXEFyWSXg/U5mur4+UY/myRRPD20O pTQi33uuHetvhkZiYMjmibqGmnm+jRo4K6aotiscOysvIF41QNrkoV9XmRgTlVH/SZzB 1jveT3+4DbVL0AAsYpGzdmIb4gsqZr0NXxNPE4z0acfsUCZ5RHwAA8dO34FiMfSaadCd LzXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rjm7KOIt; 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 f3si1395290edy.2.2020.07.08.22.40.04; Wed, 08 Jul 2020 22:40:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=rjm7KOIt; 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 S1726171AbgGIFjp (ORCPT + 99 others); Thu, 9 Jul 2020 01:39:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:51234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbgGIFjo (ORCPT ); Thu, 9 Jul 2020 01:39:44 -0400 Received: from localhost (unknown [104.132.1.66]) (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 E301B20657; Thu, 9 Jul 2020 05:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594273184; bh=u4VGfYmxoQQo8VoSbT3epFWuRgc3syhk7PNc7fYiTNQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rjm7KOItMNWn+yWPSIAoI2JEoMgXWBvZ4eFFL0SdpUT2G0k2HiFsYfQ3Ix4QMXbz0 1Xr6jRWPWqbWETfjvqy1NqHaupnEclhSr6yGCVR+x90g+svQ4ZcgPH1tj+vmsCKA3L LrQH2XCEI6C+PtLzu7s7PLYexvW7eN2CCBHN8ysI= Date: Wed, 8 Jul 2020 22:39:43 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Daeho Jeong , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Subject: Re: [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero Message-ID: <20200709053943.GA352648@google.com> References: <20200709015739.1653668-1-daeho43@gmail.com> <619af72b-2f8a-4a84-f73e-ac49989ba79f@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <619af72b-2f8a-4a84-f73e-ac49989ba79f@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/09, Chao Yu wrote: > 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? If we want to trim whole file, do we need to give the exact i_size? Wouldn't it be better to give trim(0, -1)? > > Thanks, > > > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel