Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp903738ybg; Wed, 10 Jun 2020 17:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUqamGizPys8r03cA/dWA7qb4XgUU0vf05pt3So/G+ycoHWT7/BvAi1ur6BXbJ5wCZ+siI X-Received: by 2002:a17:906:3e15:: with SMTP id k21mr6241721eji.525.1591835156767; Wed, 10 Jun 2020 17:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591835156; cv=none; d=google.com; s=arc-20160816; b=JjSOGF87t+toejp49ieuEtvo85WAyX3ZLXxOBWMRWMAj6l4U85kLucMVaHctsQ51Z7 /EPVhrkBcSdrpg9ZYlwabLKTFBFUqyO2OGDXYISrZdJ6PbG07SUjR/5eCZBWAbIjuzDm z2Lt0VD9c1KrYD32hiZ/o1fQtksGpp/55C0ANeYFQv8UTlCDJ/9T5hxx/gJvqmCIaToW jmC5tmtGkiQ7FYAp+EqLXsSxWOv/s0PkHlj4L6Y9fqftKa0k8EyaT32IqPTTQyPkQh24 BaagHriEaEUPV0gsN3ImEdL/fNm8C78W2q9KLm7k06LNqsT3veuMbHm4BRB43nYvBkEE smvA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zV/9caxagCyIgNigVOFFt2aaFjY9J+PRXT/oGFhZoBA=; b=sDoRko/vQ/eLCeG2ee3lIBraFDI/u8cnah+++YtSpI5PZQlW5WTdG5jubQbyUZIGhz r0OPjS/V6SydlpQDzZWyL19P9DQHGRZ8vZTY0IDwTLDR8hZJGXwieNNzZFKvkoQVhXLG r9HBPLvOorP4fkyYBi9rDOH6FaSu5QeoAvZQ7InMWmqim1wYQG2nlBMR0IQFEfPpwvb7 nQqCz0Xv9pSCheu+loWLVEHn7IcGzua9Rt/m+x10uwmOMc2RbvxgYsfhn0rDNQtLZIR6 Jugdvob2M8iiLrD1namMxw0hVRenfT8NIzF6Rni3a2MYsFoeW+MDomuPmF8rnoaaqpg7 geOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=te1Hv+GH; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp4si1161721ejc.258.2020.06.10.17.25.30; Wed, 10 Jun 2020 17:25: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=@gmail.com header.s=20161025 header.b=te1Hv+GH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726957AbgFKAXg (ORCPT + 99 others); Wed, 10 Jun 2020 20:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726350AbgFKAXg (ORCPT ); Wed, 10 Jun 2020 20:23:36 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE6D3C08C5C1 for ; Wed, 10 Jun 2020 17:23:35 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id 9so4779485ljc.8 for ; Wed, 10 Jun 2020 17:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zV/9caxagCyIgNigVOFFt2aaFjY9J+PRXT/oGFhZoBA=; b=te1Hv+GHACPwT4DA++rJFJ/v3/XNg3hh/4gDbj8OIzHkNr69uTfNOUJPCX06fhhN8/ kx0MeincOnv3n4QRO5/8bwLa4/tWIrRZRTU8G3iiZ4Ehg6Y3Dx91VusjFvthPDoJzBoj OyrIMXYKoas2GuSrSdKE5Qc4UZ9uKao2ehjk1gdTyELWoJugx1o+NDTb/Da/XQAU6sti oBgKbMA5vqbo3hCgKilnS4Jkdt3tUlLDntipU88NvPr7lQvVU1nrgC6BHCq9SEh5hnMm AXTspRe3VFtgvuzE77N/L65s1LZqVrT0X0jSPEgjo5B1n1cONZpcATOv0qShKzuXT0zJ svNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=zV/9caxagCyIgNigVOFFt2aaFjY9J+PRXT/oGFhZoBA=; b=B2E9EdgmBW4DZXiGBSZJ6h5/uqrJSEJqWSe3tkSMP+bkq796IVZuhIX8NN0mKXKv6A +beRNmPXgo/LRHgQzlnf7J6pBpXP6Zvvq4Jcy9n/V1l9UQ9Vqm9xdqBhmC9dKcEcPvIF 8ey3Zbd9vL4QPTgT4PfaYt2/taDePiYAo3YF/o+HDMzU7T11jGFYAKezL9U0iGkeRL5B 6yRQmGHt0HXoKtiEso+7JLmCirVQKT/M2uhcdpRSVPj/0h8ATN4o67zNp6Jl1dD7ClLQ BXe1XHZJn4mj8Ph7g6tdCPRaVSvLrPTtTYLHWOCah5+PY8+3t6Ck1Cn9eVYtwNIMdEGg bEJw== X-Gm-Message-State: AOAM5316pcQ9/uuXx8iYrp0/53bAtFEbANvZ9MLpBcX2XF96A6KdTtwI QGayW03iGpgGCHpBzYsIGxhpEeT5q+PCLuJktNJlMsRpYk1K+Q== X-Received: by 2002:a2e:a0cc:: with SMTP id f12mr2812617ljm.250.1591835014295; Wed, 10 Jun 2020 17:23:34 -0700 (PDT) MIME-Version: 1.0 References: <20200609060137.143501-1-daeho43@gmail.com> <20200609165107.GA228564@gmail.com> <20200610031532.GA6286@sol.localdomain> <20200611000037.GC1339@sol.localdomain> In-Reply-To: <20200611000037.GC1339@sol.localdomain> From: Daeho Jeong Date: Thu, 11 Jun 2020 09:23:23 +0900 Message-ID: Subject: Re: [f2fs-dev] [PATCH] f2fs: add F2FS_IOC_SEC_TRIM_FILE ioctl To: Eric Biggers Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yes, I saw the implementation in vfs_write(). But if we use mnt_want_write_file() here, it'll call mnt_clone_write() internally if the file is already open in write mode. Don't you think the below thing is needed? We can increase the counter each of them, open and ioctl, like other filesystems such as ext4. int mnt_clone_write(struct vfsmount *mnt) { /* superblock may be r/o */ if (__mnt_is_readonly(mnt)) return -EROFS; preempt_disable(); mnt_inc_writers(real_mount(mnt)); preempt_enable(); return 0; } 2020=EB=85=84 6=EC=9B=94 11=EC=9D=BC (=EB=AA=A9) =EC=98=A4=EC=A0=84 9:00, E= ric Biggers =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > 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 goi= ng to > > > > > > modify the data. But I think mnt_want_write_file() is still req= uired > > > > > > to prevent the filesystem from freezing or something else. > > > > > > > > > > Right, the freezing check is actually still necessary. But getti= ng 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 o= f > > > 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 wr= itable > fd. You just need file_start_write() for the freeze protection. Again, = see > vfs_write(). > > - Eric