Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3751229ybl; Mon, 12 Aug 2019 05:54:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYEzSGWOTTvb0h9ncDul9e5Oy6GmMBsUnkbJOM2j76c0W8OuwQvly0iGv60WU+OhsBKECl X-Received: by 2002:a63:5754:: with SMTP id h20mr29242913pgm.195.1565614499017; Mon, 12 Aug 2019 05:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565614499; cv=none; d=google.com; s=arc-20160816; b=QYzvRMFPM0C/ipgnawyilwsm3uLN6OEZ01ZDSq8HZzK8LaR12s30DJr02RDm+7YlD3 Iau2k8RIQ6Jo7w3NniyoGxOUB1TY+v5S/28ZVtWvhTsPGbEyozwwDb1Lu6bgSc+Mlyja EpR2H+/PCMHoV6CzmW9JQ8Z+dDILFe+kD4Ab99WzpQIjTgLI/rDfB3Ie4/NgysEYiH3W 0fxmig01ny3CV2VH1S2GQFntl7xFA7+uSWFH6NP9WvthdItJWKjFftgyJxpsNuqCeuT6 2FR7Ea74za7o1Jjpp+dn40/w9/+eBuxCr5eT6Xb8SOPtLsHCUgbspsnJ506P4c3TJZYl 0nBw== 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=jlm68OvjvwxectZJjO7YyqQBIqDzQa/8Tu7Xy7csYWM=; b=XsP07iU1S5mR/4a2gDBP01czFtWN+pOSj3ARoCBgKoJWxC22/If4/lkN7Sr7RpC4G4 BGqQVATZfQLUQt5LG0+iIHFuUdGgqrxprjhk3HdWAgvkfbXBlBYO9/4wvqK4iRTm242w nDFrfi3JdANZ6Es30NSKIUAAJNi2zrfB99QDwJ4vAb5DukmbDb/+SxWMzzEfhaW2DclQ DhqgFh9rQfHdPkhW6iERCa916UVcGDXBI2Fee14ElzDHaHZG6i157jkoufLXTHVJ27kG xhFxihMLKHdaacCK2VWHipNyCTILhqCP1K9dJfMH3CM6E/erbLyZZ1Rk7Yq4qfH2N+YX fCeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=mdafEdS8; 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 26si4263647pja.6.2019.08.12.05.54.45; Mon, 12 Aug 2019 05:54:59 -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=mdafEdS8; 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 S1728777AbfHLMxT (ORCPT + 99 others); Mon, 12 Aug 2019 08:53:19 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37832 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbfHLMxT (ORCPT ); Mon, 12 Aug 2019 08:53:19 -0400 Received: by mail-pl1-f195.google.com with SMTP id bj8so814494plb.4 for ; Mon, 12 Aug 2019 05:53:18 -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=jlm68OvjvwxectZJjO7YyqQBIqDzQa/8Tu7Xy7csYWM=; b=mdafEdS87TvCMdOCuqx01fbZ3ZkvvIZLle8Nrcg0codWVMdxEn1nxpDUJZp4+yAauh 7WAq293WPp9W4+DJ4IaLcVQXHDLCzhZV1BPy/Y24XF6+nIe+ap/JEmvIiMf/uEzqGLgB jvJ2uOuv1E0RviVmGgj6VYwZjjM9sbkQkaq0X2zcYS01CBP0dWVIT1qYrQRvIEPWu8mp 1oRp5JmZt6zXJ7nRYkSa0uj6J6OeELgzLUkM2unbt9Lqi8FdgjPpVvVdVrDCYsv8pxKx n+/xfvek+y1xaz9TUasoUKbdCzAiKOfaSMrYRNnsLbEAxlbcZQt8RF0WwH6SgVEoujZs JNqA== 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=jlm68OvjvwxectZJjO7YyqQBIqDzQa/8Tu7Xy7csYWM=; b=BYZhUwPjYQfmxujAvGmVT7n9pFB2GqSl+4hLaCppUtd9M1CnkjhFlJfuX/lyo4Aqfc 8rXt4IooWVUb5dEZmDID7zDUIu1hdODxAjWC9GoLs9WDPNnLKJOHhx7Zqm4MEbr+pH/i Pyt06s64eyWZiaFiWJ6RxijU/eKAKXjgnMVH2QPMYfhdpdW7I27KbLLKObcc5tQBy8ca XvSFmhIAywddUnK3urKxmmoWY8z6fShkOvMP/wd0/V1cdrin0LIMKIPl8FuZTAoFcr0V yYyVxLeEJWsurHIAtQOY1EP+XjYMQnyicMMfb1b0QX4VD9aaD/IZfpBLvXJDoX2ko5eZ a+9g== X-Gm-Message-State: APjAAAWga2YqoqeoiH8FaykrjPZg3sdD4CEZiJD7lhBJQk+uRniN0u2m 3tR4WM+VLziG8kua79DCNcnGMxlnNA== X-Received: by 2002:a17:902:900a:: with SMTP id a10mr33440442plp.281.1565614398017; Mon, 12 Aug 2019 05:53:18 -0700 (PDT) Received: from neo.home (n1-42-37-191.mas1.nsw.optusnet.com.au. [1.42.37.191]) by smtp.gmail.com with ESMTPSA id p10sm2783709pff.132.2019.08.12.05.53.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 12 Aug 2019 05:53:17 -0700 (PDT) Date: Mon, 12 Aug 2019 22:53:11 +1000 From: Matthew Bobrowski To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, jack@suse.cz, tytso@mit.edu, riteshh@linux.ibm.com Subject: [PATCH 3/5] iomap: modify ->end_io() calling convention Message-ID: 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 | 17 +++++++++-------- include/linux/iomap.h | 4 ++-- 3 files changed, 14 insertions(+), 16 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..f2bc3ac4a60e 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -369,21 +369,22 @@ static int xfs_dio_write_end_io( struct kiocb *iocb, ssize_t size, + ssize_t 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; + int ret = 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 || !size) + return error ? error : size; /* * Capture amount written on completion as we can't reliably account @@ -399,8 +400,8 @@ xfs_dio_write_end_io( nofs_flag = memalloc_nofs_save(); if (flags & IOMAP_DIO_COW) { - error = xfs_reflink_end_cow(ip, offset, size); - if (error) + ret = xfs_reflink_end_cow(ip, offset, size); + if (ret) goto out; } @@ -411,7 +412,7 @@ xfs_dio_write_end_io( * they are converted. */ if (flags & IOMAP_DIO_UNWRITTEN) { - error = xfs_iomap_write_unwritten(ip, offset, size, true); + ret = xfs_iomap_write_unwritten(ip, offset, size, true); goto out; } @@ -430,14 +431,14 @@ xfs_dio_write_end_io( if (offset + size > i_size_read(inode)) { i_size_write(inode, offset + size); spin_unlock(&ip->i_flags_lock); - error = xfs_setfilesize(ip, offset, size); + ret = xfs_setfilesize(ip, offset, size); } else { spin_unlock(&ip->i_flags_lock); } out: memalloc_nofs_restore(nofs_flag); - return error; + return ret; } /* diff --git a/include/linux/iomap.h b/include/linux/iomap.h index bc499ceae392..900284e5c06c 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, + ssize_t 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.16.4 -- Matthew Bobrowski