Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3928947ybe; Mon, 16 Sep 2019 03:55:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2rCxoR5yWb3McfFvCx562OMWvwPo60RiQMxVjVcdkCqz/zlqKq5kIe77wYL1TEt+1d8f8 X-Received: by 2002:a17:907:20c1:: with SMTP id qq1mr1368390ejb.87.1568631324702; Mon, 16 Sep 2019 03:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568631324; cv=none; d=google.com; s=arc-20160816; b=q3yEVALfNEMx8/CxZp3d/j+H3iHc77d3pcRYw9K1IBadcYbpoY0x9zUku1/qHH8gmQ MqEJjCiXOO+g2g2UONWbKSGnR6PnGBBCuYC7vvg4sVyCS2//ToSd6UcoRcFYAmCE62wf F/9wVesz3yg9gyTL8mh9x3JlJtzDqDNdkp2Cr9vGIShNio/DFoYhtDwKKrT65Yyl6xsn x2R1FKZLSVqB1u563RSqFYq19usC7X4QQSVviM+W+s1Tb2OkL1RB0Bcz7HVuo4v0XVCZ 7OLjIe4Pkaqjts9nucWiFP33I2KMaFs1kIhlmpsS2hERdAtZy0EYibWgE17kMPM7O1nd ermQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YwusKXBUgyUMXSs68FocspxMjGXcgKSvza9r85FVtq4=; b=KKf0uv70ngP5Du36kbEzKZ+7plEIaLBnqt3tAZZsYalPk+qHCebspS67kF9uDQyM7y sS8/cVddbEp4yTNSM0D2pGZfHQSi0s4b9GC527yTCR8vTMqpXz3njE5nQ1tgla1FO0Do xv/ohH2wQmSxl9Txlsg2gwIIL2MAyEYQ5NcvjCHprRvLvrfsA22RXm5l3nZMSyt59+x8 ftZYTdaf/uaXqrVUcT2SKhKSvZRfb1Tdmjhj27okdPFh9/viZpptctSNJtTzghiNBFuF H/IZwjOKjxj3We5g1TdggZkwQhxVL+gqsO60XlQ7gNTGwq9ZoC89vFcqsBS0VTnQw2vd An/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=v6z5y0Mc; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si22240396edc.81.2019.09.16.03.54.54; Mon, 16 Sep 2019 03:55:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=v6z5y0Mc; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728040AbfIPKOa (ORCPT + 99 others); Mon, 16 Sep 2019 06:14:30 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43573 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbfIPKOa (ORCPT ); Mon, 16 Sep 2019 06:14:30 -0400 Received: by mail-pg1-f193.google.com with SMTP id u72so19544504pgb.10 for ; Mon, 16 Sep 2019 03:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mbobrowski-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YwusKXBUgyUMXSs68FocspxMjGXcgKSvza9r85FVtq4=; b=v6z5y0McOHGn6caqnH2fZHUUguAgMIWn1G5wkZy2mpOO5Vr6+zYEtdp5B1DnXNZlI9 EZWCcKune2GEpOoZmPN3Fd/xBqTPw3GeDjDHCrTbDGxRkcxQVRvZgaae45tiNWz4egdv 7aWNYbhwB4cnAhNaDOf89BHHxLVO1IBC/+9uxgIdOe8EFp4mc3LIMT2XcvnaYeRKqQqm Yiwb3IyFtUpA4Ev1VKh3dS8+BcwUFt3NgeiHb4dTUF5GGF13r6EgZNvrXUUnviBbd+Wk SJ2CKtC8oD+7uODionnjzRsjJjaPai1sErp6OMT7XZ+QlqSV+h0QR24i2CVmFXGruzsq R9Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YwusKXBUgyUMXSs68FocspxMjGXcgKSvza9r85FVtq4=; b=YBxyoRQL6CDlYAiC8bEMJC+HfBs86YbAzbm7Z+AmtOYCupSjjpewK2cRNZutzfvXEm WEW4QF2yP26Wlwf2o+LxTKSL96PiUIha9Ai3hheMXkybV1X7u0oBtbBK+FG7ioomDybJ wRnUO5qL8BrpeCfxDU/QoJESsmfc1B4FKbRPac/Exj+gxorOcPnNTvTZahiIrtHQeGKj tbVZvHuTo1DQO60TpFXzAZCYRjMLKDmRohW4Efi1q3dhpHtCcmX4hUu9FzYiSPJH6FIS ZgtBsKifxnLihM/dFlfEI30IJeyIwsR9INU7LU+hw7Q9k17IVLHd4HAhsp450GkTg4Xg 84iw== X-Gm-Message-State: APjAAAXr4DGDqK/cjYIZ5ybcPUZixDluyDwArtxgxTdGM8rtrOTQfjJO JaCsOAhC3DcFpdu/jiPWmpn6 X-Received: by 2002:a63:5941:: with SMTP id j1mr55238748pgm.319.1568628864456; Mon, 16 Sep 2019 03:14:24 -0700 (PDT) Received: from bobrowski ([110.232.114.101]) by smtp.gmail.com with ESMTPSA id j4sm4197326pfn.29.2019.09.16.03.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 03:14:23 -0700 (PDT) Date: Mon, 16 Sep 2019 20:14:17 +1000 From: Matthew Bobrowski To: Ritesh Harjani Cc: tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, david@fromorbit.com, hch@infradead.org, darrick.wong@oracle.com Subject: Re: [PATCH v3 5/6] ext4: introduce direct IO write path using iomap infrastructure Message-ID: <20190916101417.GA4024@bobrowski> References: <20190916043741.BCBDEA4054@b06wcsmtp001.portsmouth.uk.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190916043741.BCBDEA4054@b06wcsmtp001.portsmouth.uk.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Sep 16, 2019 at 10:07:41AM +0530, Ritesh Harjani wrote: > > @@ -213,12 +214,16 @@ static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from) > > struct inode *inode = file_inode(iocb->ki_filp); > > ssize_t ret; > > > > + if (unlikely(IS_IMMUTABLE(inode))) > > + return -EPERM; > > + > > ret = generic_write_checks(iocb, from); > > if (ret <= 0) > > return ret; > > > > - if (unlikely(IS_IMMUTABLE(inode))) > > - return -EPERM; > > + ret = file_modified(iocb->ki_filp); > > + if (ret) > > + return 0; > > Why not return ret directly, otherwise we will be returning the wrong > error code to user space. Thoughts? You're right. I can't remember exactly why I decided to return '0', however looking at the code once again I don't see a reason why we don't just return 'ret', as any value other than '0' represents a failure in this case anyway. Thanks for picking that up. > Do you think simplification/restructuring of this API > "ext4_write_checks" can be a separate patch, so that this patch > only focuses on conversion of DIO write path to iomap? Hm, if we split it up so that it comes before this patch then it becomes hairy in the sense that a whole bunch of other changes would also need to come with what looks to be such a miniscule modification i.e. ext4_buffered_write_iter(), ext4_file_write_iter(), etc. Splitting it to come after just doesn't make any sense. To be honest, I don't really have any strong opinions around why we shouldn't split it up, nor do I have a strong opinion around why we should, so I think we should just leave it for now. > Also, I think we can make the function (ext4_write_checks()) > like below. This way we call for file_modified() only after we > have checked for write limits, at one place. No objections and I think it's a good idea. > static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter > *from) > { > struct inode *inode = file_inode(iocb->ki_filp); > ssize_t ret; > > if (unlikely(IS_IMMUTABLE(inode))) > return -EPERM; > > ret = generic_write_checks(iocb, from); > if (ret <= 0) > _ return ret; > /* > * If we have encountered a bitmap-format file, the size limit > * is smaller than s_maxbytes, which is for extent-mapped files. > */ > if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { > struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); > > if (iocb->ki_pos >= sbi->s_bitmap_maxbytes) > return -EFBIG; > iov_iter_truncate(from, sbi->s_bitmap_maxbytes - > iocb->ki_pos); > } > + > + ret = file_modified(iocb->ki_filp); > + if (ret) > + return ret; > + > return iov_iter_count(from); > } ----