Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2175263ybl; Thu, 29 Aug 2019 04:45:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqynPJjWfEyZmU5DSjrbIJh48oVo71xjEGHbJsjTOVQwMPelEgT4oripVLYj0Krp94puuF+i X-Received: by 2002:a63:755e:: with SMTP id f30mr8003654pgn.246.1567079156138; Thu, 29 Aug 2019 04:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567079156; cv=none; d=google.com; s=arc-20160816; b=IkJzaNWE4qEK/otwnxwPwEqkf5ty+y6fPw+R39pVLzLPUySR3HMI+qURaXxuBtZjbX kF1/JwhvcWYwE3mRDa02rFRp/KrXDvDkIhkhhr7+BghM307XnpQCgCOhD/cjNYr8k1OW ky+5TfUiHoE5udt6L8/wUpOaK7b515mMDBTG1+fG10WoRkv21ucKI0OZqD2QAX6vN6d6 ei420SVsjO+Z5jaC5cBR8NKbd+dYxsqufmNxuOSbcrhV3iRz6hkWya9rF5YjbRJbH9Cz 8DwzOTaEYBZnOK3pwTz12sRy9Qc7qAgHFpw2a9vLytG8dTEuiTNXDb9729FW+0dpvfeW 0yiw== 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=MqS1n+/kWBlf5HzoeS1+0Wf6ywBuVHMcP4Zd5v2vykU=; b=qKHFNnNbjaBf2JZDolqvSVHbRupZlg6T3yxk6EEekxpJC9lYEUJTiDFbopz6X/uxUv a13PL/Btq9oWgtphsss3CQcFnHP8RDiroYUzBBsRZ4u6uC9BOhF3oSBuAk1R5kG/K6O7 ZhgfeBl2uQBollxdAJWZQ3eW37mPk523ifd0i+AV5x55yQxVAd4L4wOcu30DBmXEpQHd pW+f4u1kkBqXY/qI+McpRJLjHnIVRP5u6CyH3BSzl8ZYHLejtcLe6h5KKmD23/m+J2XD FoV+YpoHCbHoSU7U03popNSt9fVZyIrMeaU4XOqT2AcSEuLmek+JyNC3hN077AmupfF0 UtJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=mdIDqLaB; 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 d9si1953725pjr.20.2019.08.29.04.45.32; Thu, 29 Aug 2019 04:45:56 -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=mdIDqLaB; 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 S1727025AbfH2LpY (ORCPT + 99 others); Thu, 29 Aug 2019 07:45:24 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37551 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbfH2LpY (ORCPT ); Thu, 29 Aug 2019 07:45:24 -0400 Received: by mail-pf1-f195.google.com with SMTP id y9so1884998pfl.4 for ; Thu, 29 Aug 2019 04:45:23 -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=MqS1n+/kWBlf5HzoeS1+0Wf6ywBuVHMcP4Zd5v2vykU=; b=mdIDqLaBtnn4IaZZGKHrtyp7wJkdWaciLMXUalX3oHKTw8eg3NcOhn8yxFRxgVznu6 /6WxBSATWjFePBBZ/jwCizKSOgNE4EkKaGoAQnRcRFVwdJUaNibVxg3B9/wdtM6Pp6ae rbmgtQrseeTlGuo3fQhKIczNVCU+ufHd6nYxkHSOLR9XNJWg3kIJIjB9CDJfpLSBftwV 4wm2tIGASGoR8X7L1d81xixB6T8dgZ+KXBrPY7t6L2MXspMrftFVgwXSLIjdsKBG9euM fviBHk03XgfpQC11Z4JlNUP+cLDt52hpD+cB0F9tTjq5513FTwZsiSHsRw3wBz8i+Nac v8Rg== 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=MqS1n+/kWBlf5HzoeS1+0Wf6ywBuVHMcP4Zd5v2vykU=; b=rbPAJarfsFBURGr4ffWMW0sIzS5GmnFs2bYvwOM4s0WoyU98dCPHSU9IO8Hj+IvxGM hQrSMrzzjnGY/7SJnha0Gt9du3wL1sUzp1r79xwTI6yAlvVdcpmo1xEVfXYb9peHlCfu hwsE/ThQT/UVumsNgW/f7j8qBZ2rpLNJGw90f2cEe5qrYon4efRjfFX6U/NVy/5ZgV6U jkjyS27FISEQiuOJdbwTxKUcxcoKVai9qKu5l2tQGipACdmfqjtyxyVJQZ1tfI05WSSQ lLyRwUvByrGEzM9Tv2EicL437RHQHQTdqu147l1RhF7pgG1oI5hUBrt2Es/rerUmZ2DX +F2g== X-Gm-Message-State: APjAAAVtLhKZPaXmAu/BMyJCfSVEgMfAZEALAu949bqFU/mbYi9RVSGK YrHpkKT/kcg7M5JvZbF+NHrwM+YX49Fh X-Received: by 2002:a17:90a:9f09:: with SMTP id n9mr9402548pjp.72.1567079122932; Thu, 29 Aug 2019 04:45:22 -0700 (PDT) Received: from poseidon.bobrowski.net ([114.78.226.167]) by smtp.gmail.com with ESMTPSA id t11sm2200901pgb.33.2019.08.29.04.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 04:45:22 -0700 (PDT) Date: Thu, 29 Aug 2019 21:45:17 +1000 From: Matthew Bobrowski To: Jan Kara Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, riteshh@linux.ibm.com Subject: Re: [PATCH 4/5] ext4: introduce direct IO write code path using iomap infrastructure Message-ID: <20190829114515.GB2486@poseidon.bobrowski.net> References: <581c3a2da89991e7ce5862d93dcfb23e1dc8ddc8.1565609891.git.mbobrowski@mbobrowski.org> <20190828202619.GG22343@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190828202619.GG22343@quack2.suse.cz> 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 Wed, Aug 28, 2019 at 10:26:19PM +0200, Jan Kara wrote: > On Mon 12-08-19 22:53:26, Matthew Bobrowski wrote: > Overall this is very nice. Some smaller comments below. Awesome, thanks for the review Jan! > > @@ -235,6 +244,34 @@ static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from) > > return iov_iter_count(from); > > } > > > > +static ssize_t ext4_buffered_write_iter(struct kiocb *iocb, > > + struct iov_iter *from) > > +{ > > + ssize_t ret; > > + struct inode *inode = file_inode(iocb->ki_filp); > > + > > + if (!inode_trylock(inode)) { > > + if (iocb->ki_flags & IOCB_NOWAIT) > > + return -EOPNOTSUPP; > > + inode_lock(inode); > > + } > > Currently there's no support for IOCB_NOWAIT for buffered IO so you can > replace this with "inode_lock(inode)". Noted. I've also taken into consideration what Dave mentioned in the other thread around explicitly checking for IOCB_NOWAIT and returning EOPTNOTSUPP irrespective whether we can acquire the lock or not. > > @@ -284,6 +321,128 @@ static int ext4_handle_inode_extension(struct inode *inode, loff_t size, > > return ret; > > } > > > > I'd mention here that for cases where inode size is extended, > ext4_dio_write_iter() waits for DIO to complete and thus we are protected > by inode_lock in that case. Easy. > > +static int ext4_dio_write_end_io(struct kiocb *iocb, ssize_t size, > > + ssize_t error, unsigned int flags) > > Here I'd expand the comment to explain that we wait in case inode is > extended so that inode extension in ext4_dio_write_end_io() is properly > covered by inode_lock. > Easy. > > + if (ret == -EIOCBQUEUED && (unaligned_aio || extend)) > > + inode_dio_wait(inode); > > + > > + if (ret >= 0 && iov_iter_count(from)) { > > + overwrite ? inode_unlock_shared(inode) : inode_unlock(inode); > > + return ext4_buffered_write_iter(iocb, from); > > + } > > +out: > > + overwrite ? inode_unlock_shared(inode) : inode_unlock(inode); > > + return ret; > > +} > > + > > #ifdef CONFIG_FS_DAX > > static ssize_t > > ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) > > ... > > > @@ -3581,10 +3611,10 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length, > > iomap->type = delalloc ? IOMAP_DELALLOC : IOMAP_HOLE; > > iomap->addr = IOMAP_NULL_ADDR; > > } else { > > - if (map.m_flags & EXT4_MAP_MAPPED) { > > - iomap->type = IOMAP_MAPPED; > > - } else if (map.m_flags & EXT4_MAP_UNWRITTEN) { > > + if (map.m_flags & EXT4_MAP_UNWRITTEN) { > > iomap->type = IOMAP_UNWRITTEN; > > + } else if (map.m_flags & EXT4_MAP_MAPPED) { > > + iomap->type = IOMAP_MAPPED; > > } else { > > WARN_ON_ONCE(1); > > return -EIO; > > Possibly this hunk should go into a separate patch (since this is not > directly related with iomap conversion) with a changelog / comment > explaining why we need to check EXT4_MAP_UNWRITTEN first. But wouldn't doing so break bisection? Seeing as though we needed to change this statement specifically to accommodate for the weirdness being returned from ext4_map_blocks()? i.e. map.m_flags being set to either of the following: - (EXT4_MAP_NEW | EXT4_MAP_MAPPED) or - (EXT4_MAP_NEW | EXT4_MAP_MAPPED | EXT4_MAP_UNWRITTEN) So, if we left the statement in its original form, we'd allocate unwritten extents but never actually get around to converting them in ext4_dio_write_end_io() as IOMAP_DIO_UNWRITTEN would never be set? --M