Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp892001ybg; Wed, 10 Jun 2020 17:03:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXkLOx7Tf4JLpIuGoACmWyyv7raPJSfhQqr++xsjhtgEny0KX7voDI/y4dR4Ub8/Fd4dor X-Received: by 2002:aa7:d64e:: with SMTP id v14mr4788786edr.103.1591833836428; Wed, 10 Jun 2020 17:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591833836; cv=none; d=google.com; s=arc-20160816; b=qGSmXYxPqAR1rBi6x7gNByv4DppYFmj2G9Rw9ib8PIK80L840goJELagULuQS5OIoC bl4qrUI3wwNG0oLnJJAKEUToBoG0ThwzbhuqYWbk5je/7CbY+ehpUXOocuTGU0+ZaGHF RonTHhXGIgtDtIpMdm/QwaaM3eV3V9puCEi4Ko8ERianpyCVMmwNLkwED0npkBTymIJP 83xsiCBXmqfb7o2iyHcy/rwUMsC0JcnxHN7su705LdLpGv0uylG42Ot355t7VFL5GP0c GSfleCorfupAcrGkYNq4BNdSy+1DteumIhBcrcX4qNxqqRjbCJl4uCQPp80uEDd7QxrH TbKA== 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=Icv4+KDxh0xdgHt1Oajk+9qefWlOLQw14cIP2Kpgj5w=; b=WAX/INut3xtOZJ6MmhxfqBbGBlIbre5SR2o7xF3tmDJvRUn1TvG/GDvkNF6IS7qhjc 3Bm49HtRGIkKeTx09a9icAoepw51wAGrdbYdXPCA06OfQf18T9ggisVX4TYDkaFUvU76 BMgweZl9LXTsp3Rrkte50Cx0tUY3wrApVnDfrjsRa6hGgqNKg1VCy2dRb2y+GuquiQdU QurviriI7qZd5asfVL1mXxraJpxlO+AO0qTcTTJcfIjT+FcbW7cTvMPK1bUI+9sYX8fe Rkw3rJqBoaGiZLj3xfEwYOkVbni5ymIJkwx87XAeAXkYwyNMRJUdNjr+CTxBw5o3odhO aAVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YL76uirK; 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 l8si687696edn.346.2020.06.10.17.03.33; Wed, 10 Jun 2020 17:03:56 -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=YL76uirK; 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 S1726977AbgFKAAk (ORCPT + 99 others); Wed, 10 Jun 2020 20:00:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:40454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726768AbgFKAAj (ORCPT ); Wed, 10 Jun 2020 20:00:39 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (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 B7F5C20747; Thu, 11 Jun 2020 00:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591833638; bh=5sGHU0TXkJgqIou25g8bOOckwAZ4up5Cw9usUbqqcE0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YL76uirKlAFVeJnBYKcm15iNePJ5NPoXXfgvDSo41XH9Qgq87gpdK0QlQeib2YKyM UUGnZeY7N7fl6hixkdG98ddnzmSNL2RngUOgq3Sz7hZSAWjy12Yz+n+mvU/0JyLqLG Q1iWCUgphwz4qbEDSQ+sqzaH3BtQKmmc34jSryIg= Date: Wed, 10 Jun 2020 17:00:37 -0700 From: Eric Biggers 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: add F2FS_IOC_SEC_TRIM_FILE ioctl Message-ID: <20200611000037.GC1339@sol.localdomain> References: <20200609060137.143501-1-daeho43@gmail.com> <20200609165107.GA228564@gmail.com> <20200610031532.GA6286@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 11, 2020 at 08:53:10AM +0900, Daeho Jeong wrote: > > > > > Using FMODE_WRITE is more proper for this case, since we're going to > > > > > modify the data. But I think mnt_want_write_file() is still required > > > > > to prevent the filesystem from freezing or something else. > > > > > > > > Right, the freezing check is actually still necessary. But getting write access > > > > to the mount is not necessary. I think you should use file_start_write() and > > > > file_end_write(), like vfs_write() does. > > > > I've checked this again. > > > > But I think mnt_want_write_file() looks better than the combination of > > checking FMODE_WRITE and file_start_write(), because > > mnt_want_write_file() handles all the things we need. > > It checks FMODE_WRITER, which is set in do_dentry_open() when > > FMODE_WRITE is already set, and does the stuff that file_start_write() > > is doing. This is why the other filesystem system calls use it. > > > > What do you think? > > Hmm, we still need FMODE_WRITE check. > But mnt_want_write_file() looks better, because it'll call > mnt_clone_write() internally, if the file is open for write already. There's no need to get write access to the mount if you already have a writable fd. You just need file_start_write() for the freeze protection. Again, see vfs_write(). - Eric