Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4257018ybe; Mon, 9 Sep 2019 06:44:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqycJxc+6czgvNPn/Aq5AQ9mPWZGJ1k0GZMDteae0Bx9p7rs3a79d1p+CzKka3RqriCdwbPW X-Received: by 2002:a17:906:a414:: with SMTP id l20mr19811303ejz.211.1568036656479; Mon, 09 Sep 2019 06:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568036656; cv=none; d=google.com; s=arc-20160816; b=Zx0EGlNmgoqSVAx6DWeU7ljF7HclUz334Xh5fhS3sbsSLfOeieEwwS1yDFJq+S12TY y50qDrYxOma83FiP6gI+7BrClbxCf0lOTFnM3z6ETI6baPSSLl/c984OMUZHCGfkIfxV kvcboshiLQgm96Y5dpherVxHBUrx1WQl2bGiPAVZyAWHDZqhRvONLZFgHdZXjQCpLeUK TVVhLIZy2e20HgzTqsIF25qVHQ1BDLbYYKQduBdIzcbGc3gMpUYZlFsd7TVNIVtaIxnp 3835Evq9/vJ5Ty9MsYsYXwqwEX/bYmNjOcFjzy3XGhQAD+IR/Nw6clBof30EpP8sUksE JZ+g== 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=gx5XXdzXQF7G+1VrbudI1A9EwDDJ+tyVBcppt9K0Szs=; b=f/4T4t7PtW5UlVp49hbXZVmIW/GFKCZ7EVfMnpUo7OgWVSrxxeVPBehPzDL7dt08df DL/BISjuWcWcOqH9YfFNxxFOBxOVWHQwucBVGgwxDfb+1wVBo05BY0rBeQdWBQ8B5KF9 6FmY1TlMepZjD9zcfROuvSM6Apn1qnk/H4IThYCaiPB6jaR7ODbCKOfnHw2eMSVYP8ew Hg5cge5kZLLJhoZzRnfLZBjPqaDU6EtDVTWfiu0p05VZdicXC9s3iu/+qbOg1lrH8npx jBmG7QibYk9MWrDQqT5mhRZ8GGazkq7kIyygcVNrZpqSLD7cjHtarJmktCdfO4H8g45i vpDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=F01PsGlp; 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 pw24si7431332ejb.293.2019.09.09.06.43.50; Mon, 09 Sep 2019 06:44:16 -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=F01PsGlp; 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 S1731263AbfIHXTi (ORCPT + 99 others); Sun, 8 Sep 2019 19:19:38 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37304 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731203AbfIHXTi (ORCPT ); Sun, 8 Sep 2019 19:19:38 -0400 Received: by mail-pf1-f196.google.com with SMTP id y5so5238454pfo.4 for ; Sun, 08 Sep 2019 16:19:38 -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=gx5XXdzXQF7G+1VrbudI1A9EwDDJ+tyVBcppt9K0Szs=; b=F01PsGlpkKUdf7ARLGoLElKXYgoOD/rlV0S5n7k8NS7EP45gvPuJjctcl+F0L4k9bt pDQXERm5AzCRpD3dA1v0uoQIDzBWCX1AGcdXTMQ2swDhFSRUaF8LIthjXc+fZIig+zLQ s/7z5bNVbrZwqKM7RAAQG1VijKSr88f27jHgnsbY0tUZfcsG5/SBvOqpzcNzXQsn8XB/ J0MXTuCwsEmPEBxptasCFIhg26bDPdRLBq4eFmmB8B0TL4o7ap7flYLw3uwnqls7GuxD RgtfGkyD0IuiBJ/B8ZSqxJlUlH9WpzpR5SxzDVfsxeA6+rArw29HoA72JuYPlezWpxCG +EkQ== 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=gx5XXdzXQF7G+1VrbudI1A9EwDDJ+tyVBcppt9K0Szs=; b=UdExyZLEqJvgCz/bHBV544NK7D6QYd8ySezOAQEAwgWNsWWhdSJOljFj4pjM05Fxv9 6wHnk24lCaVdDoykBhBs8Q2XmtNCDEtLB1ZCeDrvvWVhLH7LTgIHFcdaFSLas9gGKu4J NrPOT0Xa3HC4jtAWV73nQLwGsfdEbGRPOJm9V8UeXl27yi/WrMGkBp+vfi66bGqVFxk1 W6/IRrMTiRRgpzOSIW9Z/trfpZJ51roeilXVPtk0zCVxuiSFgBSpxzCKti3MJ3QhuX81 kyfKGzoDJlIFVXStzdWIblvxF6ySUNbI+7Ikz/SuvZ/d5YE6MnFv/QpM7LWX9SoTJhBs R84w== X-Gm-Message-State: APjAAAXQHxKd3NU8/H1K/jsd4O05vQe4j5qNan80Ottjc0E1MWqBtPGw zVAX3aNM7eEshWYZHlslWgmk X-Received: by 2002:a65:5cca:: with SMTP id b10mr19318386pgt.365.1567984777787; Sun, 08 Sep 2019 16:19:37 -0700 (PDT) Received: from bobrowski ([110.232.114.101]) by smtp.gmail.com with ESMTPSA id u5sm12572075pfl.25.2019.09.08.16.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2019 16:19:37 -0700 (PDT) Date: Mon, 9 Sep 2019 09:19:31 +1000 From: Matthew Bobrowski To: tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, david@fromorbit.com, hch@infradead.org, darrick.wong@oracle.com Subject: [PATCH v2 3/6] iomap: modify ->end_io() calling convention Message-ID: <8368d2ea5f2e80fed7fbba3685b0d3c1e5ff742a.1567978633.git.mbobrowski@mbobrowski.org> 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 This patch modifies the calling convention for the iomap ->end_io() callback. Rather than passing either dio->error or dio->size as the 'size' argument, we instead pass both dio->error and dio->size values separately. In the instance that an error occurred during a write, we currently cannot determine whether any blocks have been allocated beyond the current EOF and data has subsequently been written to these blocks within the ->end_io() callback. As a result, we cannot judge whether we should take the truncate failed write path. Having both dio->error and dio->size will allow us to perform such checks within this callback. Signed-off-by: Matthew Bobrowski --- fs/iomap/direct-io.c | 9 +++------ fs/xfs/xfs_file.c | 8 +++++--- include/linux/iomap.h | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 10517cea9682..2ccf1c6460d4 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -77,13 +77,10 @@ static ssize_t iomap_dio_complete(struct iomap_dio *dio) loff_t offset = iocb->ki_pos; ssize_t ret; - if (dio->end_io) { - ret = dio->end_io(iocb, - dio->error ? dio->error : dio->size, - dio->flags); - } else { + if (dio->end_io) + ret = dio->end_io(iocb, dio->size, dio->error, dio->flags); + else ret = dio->error; - } if (likely(!ret)) { ret = dio->size; diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 28101bbc0b78..d49759008c54 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -369,21 +369,23 @@ static int xfs_dio_write_end_io( struct kiocb *iocb, ssize_t size, + int error, unsigned flags) { struct inode *inode = file_inode(iocb->ki_filp); struct xfs_inode *ip = XFS_I(inode); loff_t offset = iocb->ki_pos; unsigned int nofs_flag; - int error = 0; trace_xfs_end_io_direct_write(ip, offset, size); if (XFS_FORCED_SHUTDOWN(ip->i_mount)) return -EIO; - if (size <= 0) - return size; + if (error) + return error; + if (!size) + return 0; /* * Capture amount written on completion as we can't reliably account diff --git a/include/linux/iomap.h b/include/linux/iomap.h index bc499ceae392..d983cdcf2e72 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -188,8 +188,8 @@ sector_t iomap_bmap(struct address_space *mapping, sector_t bno, */ #define IOMAP_DIO_UNWRITTEN (1 << 0) /* covers unwritten extent(s) */ #define IOMAP_DIO_COW (1 << 1) /* covers COW extent(s) */ -typedef int (iomap_dio_end_io_t)(struct kiocb *iocb, ssize_t ret, - unsigned flags); +typedef int (iomap_dio_end_io_t)(struct kiocb *iocb, ssize_t size, + int error, unsigned int flags); ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops, iomap_dio_end_io_t end_io); int iomap_dio_iopoll(struct kiocb *kiocb, bool spin); -- 2.20.1