Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp814042ybx; Tue, 5 Nov 2019 06:03:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxeGqNtMemVMChzKH8Zdsy2MIsQPYC9qYpwyeUiZ5VuwL3PkTsD9yhLT0OOMocScXvwDQL4 X-Received: by 2002:aa7:c6c9:: with SMTP id b9mr25738449eds.1.1572962583582; Tue, 05 Nov 2019 06:03:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962583; cv=none; d=google.com; s=arc-20160816; b=f/9tAyWB5LSZ5SabAiLWRzjHq5fydN9UJEDLNMDzJVXCdUY8Peyb3fp/VdpuL8LRXW x0Fo1AkjMjNdz05DC5qR8thK5Bha4a8EyIyuKWcnzlL5WW0j8JxmQ8HULca+nOL01xWl V83//Mkba8amx/J4VPkMIEnD46k0+hpOV2iqcCjjDn5GY2TQ4PPNYONdnkGnlY0RZewj v4TQq4lAXqPdsbJl9sDB6O18NWPMPAHv7WE5g8OQnXX3Yu5p0R2wsgKkwfNT6ToKXpFS +rqbYqhSbL2Gdhm1B5MmmeL9qRS8ysZbl3P3+DucjC6Eo4jZXUQwnb31bFvidEWzzxiu hHMQ== 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; bh=1bl19fJ8+a01PxQOtLqiw5F85HjDlqcju0HEVqHUou8=; b=EpuiNrCdKfVR/9Q79duqpVyzPKICU/yPm6/Iex2E2cRvZsYjyBAbfg2VY1v1kXS1k4 Rz9BsOihgFKZkzaEBC1Hpo+ZxS94NWTqhjVx/ybI2oaOiD66jE1Sh5s8gNBPd90emwQ5 jXFxFBoPWjLjldILQFRT+NxRXHnXWIksqJE3gx035r/9njgOxT/FxmHDOwrPr4DmDokv ULVzdHHUbtj7ormn1VhkRJmQ4adu18AIpYvflQq70jfJ2OdbXTpidxS97SmRjbNrvRqc ZZhnH/M1/CYNcrmgHrGkpwvsDkFNhACoLseIAQbDH6NzyaXgxgPINUuRgvmPFrynfh8s gL5Q== ARC-Authentication-Results: i=1; mx.google.com; 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 s35si9924948edd.261.2019.11.05.06.02.31; Tue, 05 Nov 2019 06:03:03 -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; 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 S2389166AbfKEN7e (ORCPT + 99 others); Tue, 5 Nov 2019 08:59:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:41568 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388209AbfKEN7e (ORCPT ); Tue, 5 Nov 2019 08:59:34 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E376FAC44; Tue, 5 Nov 2019 13:59:32 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 3C9EC1E47E5; Tue, 5 Nov 2019 14:59:32 +0100 (CET) Date: Tue, 5 Nov 2019 14:59:32 +0100 From: Jan Kara To: Matthew Bobrowski Cc: tytso@mit.edu, jack@suse.cz, 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: <20191105135932.GN22379@quack2.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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. > + err = filemap_write_and_wait_range(iocb->ki_filp->f_mapping, > + offset, endbyte); > + if (!err) > + invalidate_mapping_pages(iocb->ki_filp->f_mapping, > + offset >> PAGE_SHIFT, > + endbyte >> PAGE_SHIFT); > + } > + > + return ret; > +} > + Honza -- Jan Kara SUSE Labs, CR