Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp204245ybt; Thu, 9 Jul 2020 20:03:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4lxQ3SJl9mgEKRDFwfy31DxIzZNNFC/vsDWPF4beYfnX/0+9NBRwYHY/hoTkcR8eghu75 X-Received: by 2002:a17:906:6d0e:: with SMTP id m14mr58350609ejr.251.1594350226476; Thu, 09 Jul 2020 20:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594350226; cv=none; d=google.com; s=arc-20160816; b=09Jm7mgIXIy59i+kBdBRgePH0LSGqEuy2QVR+7UXUpQcQ0i36peh8zheUV49L3UKyU 1quXwSZ9E4VRqd5NP9F9XHL7i873fddcvaXcFg9HfpZ9r5MJV1i6BfJXxEUY/RSB7LpD osqR/kW2+H80740H5u45QEt6/2hqWDWwR8VxWGFLHF2o7BUflKJ5y1yOENKRCdb3ceSS S2/JGcMCDXJld3nsMdJUBULAicSQVbjVhsHudi8e6whtdIYtSlM518cSgW9Zzk+qeOG4 xmO8yBkWDlthJNnzx97Qk7VXEiJUiNmNQNQ5VTxGnJD2uUSDzMR6NMrlFvcWf2qeO3DD sDlw== 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=kV7rruElF/IgUZx86OxA5KP7g2V8JdHogkFMVAYJgD4=; b=r6oJCwUMPiTm9Dl4boQAAL1P/BX+ZKG4fSrXi8HeYAgjUTXRIMe9Qr9EAHxUvDVuLF 31BFSttWuUEW6ALnhtQbMBK982KW90zetEI9r2srs7bsX93NJ59IGqFyQmjxrEHY9EP5 oEOrVgBGJgHIeyFHlU84oucVv+kXMrahMlv1WSluu7tMRn0bs94AcqXWDvXakKxiikwb gn3kOgXoQXZZ89NAIVlxf+HcQohZTEpF91KELf/CM19cBlF4bwSSBjmw5NOrFz//H93m iM3KgA5W3a02c/90JfeaROkA4HfU/PyNuGC5kfKZDMAlTA5B8C57S7URGzEMemNS9Vkd vInw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tqHGwKlT; 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 bu2si3632952edb.423.2020.07.09.20.03.23; Thu, 09 Jul 2020 20:03:46 -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=tqHGwKlT; 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 S1726856AbgGJDCs (ORCPT + 99 others); Thu, 9 Jul 2020 23:02:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726509AbgGJDCr (ORCPT ); Thu, 9 Jul 2020 23:02:47 -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 295B82073A; Fri, 10 Jul 2020 03:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594350167; bh=kAsBqQZRZQ5C/sbtKjmCiPtuu3wHYS/cK2L+QzdWOnc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tqHGwKlTh3pB/U89lbrCjuUTdiwUZEC2BCFgH+77JglaOhDpyn9Q8CuHHd8esUQEm ubL9ago1UFinysqXO7P8lb65P0L5AgHWks6mT7aNQ5MKO3FwNJYLot71b9/i2GwuPo FqTJYk/VtPS+E0m9qU/WNpqoI/rn+hin3jwpm3Qc= Date: Thu, 9 Jul 2020 20:02:46 -0700 From: Jaegeuk Kim To: Daeho Jeong Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Subject: Re: [f2fs-dev] [PATCH] f2fs: change the way of handling range.len in F2FS_IOC_SEC_TRIM_FILE Message-ID: <20200710030246.GA545837@google.com> References: <20200710021505.2405872-1-daeho43@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200710021505.2405872-1-daeho43@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/10, 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 signify the end of file. > 2. If the end of the range passes over the end of file, it means until > the end of file. > 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 > --- > fs/f2fs/file.c | 16 +++++++--------- > 1 file changed, 7 insertions(+), 9 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 368c80f8e2a1..1c4601f99326 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -3813,21 +3813,19 @@ 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; > - } > - end_addr = range.start + range.len; > + if (range.len == (u64)-1 || inode->i_size - range.start < range.len) > + end_addr = inode->i_size; Hmm, what if there are blocks beyond i_size? Do we need to check i_blocks for ending criteria? > + else > + end_addr = range.start + range.len; > > to_end = (end_addr == inode->i_size); > if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) || > -- > 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