Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1233523ybx; Tue, 5 Nov 2019 12:36:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzo4WgPHDA5rQSZXnkf4arcsf03m9CJ7pIkgB/Y0pbX0tH5wDyKfMnZYV0ANeaP6L8jFoQU X-Received: by 2002:a17:906:4e55:: with SMTP id g21mr32322459ejw.0.1572986164672; Tue, 05 Nov 2019 12:36:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572986164; cv=none; d=google.com; s=arc-20160816; b=XlyaSCwD7DqOsWSiU8piA9kzQD8oKs01N2o7JQQVFlftkKSojV+pgRURKNx4GaLlTk MZKhiVPiV1X498f6Es4xFikhOEX1T/jwJtq1OceuK+EYuBRnrbq3b94sEXzn6Hpt7ys8 Lsl3zJtmpXX9dgC/OM892Fx6PXVhH6y9KV54nRX0J4mTwFBuHxpwotE4FsKaMGLwct5I cye9buUlHGlK+S3BEjxZViuWhFHa8mELM4enb6GVVTMYVive8wFfmfxE/mwmYGyOlW51 cvJeaEgAUtay7dNhem+LRP4Yy6BiCcfMLLsyIM7cTf8oZ7KHD7TiOS4h2GextILOjF1K IqFQ== 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=CXqKLplEg6QFJZFTjZZERaYQH2HOfWcmYOoVbXgDrYo=; b=BbYMB16UZl4aYVXRXpIxoBV1wXhWNBq78DfhsNLa2ug7KejamwKxqZUbi5AcXHaxBz CBRuRL9pcYK10NdbhU5MqAHgsxB7NcY8CFWT2OFzficK+kDG+P7Ujs7C+8McehhWX7fJ VwaiXqKnD64G0g8yvrmVLZPUUIxUdETmSS0XAQIEaMiMhv5/6Iv7wcNNmWcQ9XEaB6rs DiqLgN40gH1/wOdaX2yIXY5UnAhdWTitLpMKH2PQah5UDQWaUq9/vssE/0a6y81x66NP /TPs35CthR3Sb8OHkMomNdBMP0DNOtEdEMeHDMiOuNJX1m3zetdgG0s0QADKKE55TpHa UTZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=ZZ4KzDbS; 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 qp14si205889ejb.274.2019.11.05.12.35.33; Tue, 05 Nov 2019 12:36:04 -0800 (PST) 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=ZZ4KzDbS; 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 S1726594AbfKEUcJ (ORCPT + 99 others); Tue, 5 Nov 2019 15:32:09 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37900 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726608AbfKEUcI (ORCPT ); Tue, 5 Nov 2019 15:32:08 -0500 Received: by mail-pf1-f194.google.com with SMTP id c13so16687006pfp.5 for ; Tue, 05 Nov 2019 12:32:08 -0800 (PST) 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=CXqKLplEg6QFJZFTjZZERaYQH2HOfWcmYOoVbXgDrYo=; b=ZZ4KzDbSDUnfjdiSr4ueKak6InnyZZT0EjdcNFWCU9zuCk+mxbpPoWVQvwIndVnoXv +rzNJYjXmR9sjSKIbOQyA58Q7cJq1Gu/2TDoL0HhMwN5T8ZFIP1IA2azWIQxYsLTUVi6 0Bq5dewkmpugtQP9/pfDq5ZYCHv0zXEYipxhj2D2PLsO+uBNU58W2ZW+QRf26icZwvdA mpi2VwyguV420FGRuekjjaErHt/sudVEJuUq9WWdK5guNc8gW6Hlo0mO/+qxT5G8dpJK HwCfuV2m42nL05+A28xjeYQG67z3Djsx1rsbXRaLE/JlFgsoaK/4D0Y+88etk1JIBdRJ mNlQ== 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=CXqKLplEg6QFJZFTjZZERaYQH2HOfWcmYOoVbXgDrYo=; b=Kzff3dFloqv3bayiO4xJttH8Ro15C8afbsdEBunq6suPsu81jFVlsDPIAlNALRfmwg 1OPIZsvdt1c/R78LSabaQgTCf2QrLJZb4l0G/KG1avXAMj7dl0OtHFfnPzkx2URqZfzO sVnMld0h8S+8UgBHVWk5nCvdCp1i1V6CbbGaGx4QVfdZU1ZbvfXCVua0VQkU09iDI5oZ zdKm2jRuhj0p71DPAhDF46xR5DXAhn/5eKlK/k6XfiPi9lneZbIVvtti/ho1X6Tzx5c1 7fKMP/LuZPiDiKagLrksmQ1iziaj5SeiWA3MTvlSHZlzHEPauhCn9tRPP+/b3irLt5zH TktQ== X-Gm-Message-State: APjAAAUTUKvVLfdQ2Q3i6Ie9ruPTTXt8oqGYLJZQhlc+8wZqp5M6C66J VB40e0VwHfQGnWtOCVWyxaTG X-Received: by 2002:a17:90a:35d0:: with SMTP id r74mr1186988pjb.47.1572985927720; Tue, 05 Nov 2019 12:32:07 -0800 (PST) Received: from bobrowski ([110.232.114.101]) by smtp.gmail.com with ESMTPSA id h9sm294751pjh.8.2019.11.05.12.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 12:32:07 -0800 (PST) Date: Wed, 6 Nov 2019 07:32:00 +1100 From: Matthew Bobrowski To: Jan Kara Cc: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, riteshh@linux.ibm.com Subject: Re: [PATCH v7 11/11] ext4: introduce direct I/O write using iomap infrastructure Message-ID: <20191105203158.GA1739@bobrowski> References: <20191105135932.GN22379@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191105135932.GN22379@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 Tue, Nov 05, 2019 at 02:59:32PM +0100, Jan Kara wrote: > On Tue 05-11-19 23:02:39, Matthew Bobrowski wrote: > > + if (ret >= 0 && iov_iter_count(from)) { > > + ssize_t err; > > + loff_t endbyte; > > + > > + offset = iocb->ki_pos; > > + err = ext4_buffered_write_iter(iocb, from); > > + if (err < 0) > > + return err; > > + > > + /* > > + * We need to ensure that the pages within the page cache for > > + * the range covered by this I/O are written to disk and > > + * invalidated. This is in attempt to preserve the expected > > + * direct I/O semantics in the case we fallback to buffered I/O > > + * to complete off the I/O request. > > + */ > > + ret += err; > > + endbyte = offset + ret - 1; > ^^ err here? > > Otherwise you would write out and invalidate too much AFAICT - the 'offset' > is position just before we fall back to buffered IO. Otherwise this hunk > looks good to me. Er, yes. That's right, it should rather be 'err' instead or else we would write/invalidate too much. I actually had this originally, but I must've muddled it up while rewriting this patch on my other computer. Thanks for picking that up! /M