From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: [PATCH v5 05/17] ext2: return -EIO on ext2_iomap_end() failure Date: Tue, 11 Oct 2016 08:48:01 +0200 Message-ID: <20161011064801.GA6952@quack2.suse.cz> References: <1475874544-24842-1-git-send-email-ross.zwisler@linux.intel.com> <1475874544-24842-6-git-send-email-ross.zwisler@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-kernel@vger.kernel.org, Theodore Ts'o , Alexander Viro , Andreas Dilger , Andrew Morton , Christoph Hellwig , Dan Williams , Dave Chinner , Jan Kara , Matthew Wilcox , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org To: Ross Zwisler Return-path: Content-Disposition: inline In-Reply-To: <1475874544-24842-6-git-send-email-ross.zwisler@linux.intel.com> Sender: owner-linux-mm@kvack.org List-Id: linux-ext4.vger.kernel.org On Fri 07-10-16 15:08:52, Ross Zwisler wrote: > Right now we just return 0 for success, but we really want to let callers > know about this failure. > > Signed-off-by: Ross Zwisler > --- > fs/ext2/inode.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c > index c7dbb46..368913c 100644 > --- a/fs/ext2/inode.c > +++ b/fs/ext2/inode.c > @@ -830,8 +830,10 @@ ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length, > { > if (iomap->type == IOMAP_MAPPED && > written < length && > - (flags & IOMAP_WRITE)) > + (flags & IOMAP_WRITE)) { > ext2_write_failed(inode->i_mapping, offset + length); > + return -EIO; > + } So this is wrong. This (written < length) happens when we fail to copy data to / from userspace buffer into pagecache pages / DAX blocks. It may be because the passed buffer pointer is just wrong, or just because the page got swapped out and we have to swap it back in. It is a role of upper layers to decide what went wrong and proceed accordingly but from filesystem point of view we just have to cancel the operation we have prepared and return to upper layers. So returning 0 in this case is correct. Honza -- Jan Kara SUSE Labs, CR -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D6AE91A1E77 for ; Tue, 11 Oct 2016 11:42:31 -0700 (PDT) Date: Tue, 11 Oct 2016 08:48:01 +0200 From: Jan Kara Subject: Re: [PATCH v5 05/17] ext2: return -EIO on ext2_iomap_end() failure Message-ID: <20161011064801.GA6952@quack2.suse.cz> References: <1475874544-24842-1-git-send-email-ross.zwisler@linux.intel.com> <1475874544-24842-6-git-send-email-ross.zwisler@linux.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1475874544-24842-6-git-send-email-ross.zwisler@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Ross Zwisler Cc: Theodore Ts'o , Matthew Wilcox , Dave Chinner , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Andreas Dilger , Alexander Viro , Jan Kara , linux-fsdevel@vger.kernel.org, Andrew Morton , linux-ext4@vger.kernel.org, Christoph Hellwig List-ID: On Fri 07-10-16 15:08:52, Ross Zwisler wrote: > Right now we just return 0 for success, but we really want to let callers > know about this failure. > > Signed-off-by: Ross Zwisler > --- > fs/ext2/inode.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c > index c7dbb46..368913c 100644 > --- a/fs/ext2/inode.c > +++ b/fs/ext2/inode.c > @@ -830,8 +830,10 @@ ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length, > { > if (iomap->type == IOMAP_MAPPED && > written < length && > - (flags & IOMAP_WRITE)) > + (flags & IOMAP_WRITE)) { > ext2_write_failed(inode->i_mapping, offset + length); > + return -EIO; > + } So this is wrong. This (written < length) happens when we fail to copy data to / from userspace buffer into pagecache pages / DAX blocks. It may be because the passed buffer pointer is just wrong, or just because the page got swapped out and we have to swap it back in. It is a role of upper layers to decide what went wrong and proceed accordingly but from filesystem point of view we just have to cancel the operation we have prepared and return to upper layers. So returning 0 in this case is correct. Honza -- Jan Kara SUSE Labs, CR _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:43853 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753645AbcJKSyq (ORCPT ); Tue, 11 Oct 2016 14:54:46 -0400 Date: Tue, 11 Oct 2016 08:48:01 +0200 From: Jan Kara Subject: Re: [PATCH v5 05/17] ext2: return -EIO on ext2_iomap_end() failure Message-ID: <20161011064801.GA6952@quack2.suse.cz> References: <1475874544-24842-1-git-send-email-ross.zwisler@linux.intel.com> <1475874544-24842-6-git-send-email-ross.zwisler@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1475874544-24842-6-git-send-email-ross.zwisler@linux.intel.com> Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: Ross Zwisler Cc: linux-kernel@vger.kernel.org, Theodore Ts'o , Alexander Viro , Andreas Dilger , Andrew Morton , Christoph Hellwig , Dan Williams , Dave Chinner , Jan Kara , Matthew Wilcox , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org On Fri 07-10-16 15:08:52, Ross Zwisler wrote: > Right now we just return 0 for success, but we really want to let callers > know about this failure. > > Signed-off-by: Ross Zwisler > --- > fs/ext2/inode.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c > index c7dbb46..368913c 100644 > --- a/fs/ext2/inode.c > +++ b/fs/ext2/inode.c > @@ -830,8 +830,10 @@ ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length, > { > if (iomap->type == IOMAP_MAPPED && > written < length && > - (flags & IOMAP_WRITE)) > + (flags & IOMAP_WRITE)) { > ext2_write_failed(inode->i_mapping, offset + length); > + return -EIO; > + } So this is wrong. This (written < length) happens when we fail to copy data to / from userspace buffer into pagecache pages / DAX blocks. It may be because the passed buffer pointer is just wrong, or just because the page got swapped out and we have to swap it back in. It is a role of upper layers to decide what went wrong and proceed accordingly but from filesystem point of view we just have to cancel the operation we have prepared and return to upper layers. So returning 0 in this case is correct. Honza -- Jan Kara SUSE Labs, CR From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754597AbcJKS4l (ORCPT ); Tue, 11 Oct 2016 14:56:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:43853 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753645AbcJKSyq (ORCPT ); Tue, 11 Oct 2016 14:54:46 -0400 Date: Tue, 11 Oct 2016 08:48:01 +0200 From: Jan Kara To: Ross Zwisler Cc: linux-kernel@vger.kernel.org, "Theodore Ts'o" , Alexander Viro , Andreas Dilger , Andrew Morton , Christoph Hellwig , Dan Williams , Dave Chinner , Jan Kara , Matthew Wilcox , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@ml01.01.org, linux-xfs@vger.kernel.org Subject: Re: [PATCH v5 05/17] ext2: return -EIO on ext2_iomap_end() failure Message-ID: <20161011064801.GA6952@quack2.suse.cz> References: <1475874544-24842-1-git-send-email-ross.zwisler@linux.intel.com> <1475874544-24842-6-git-send-email-ross.zwisler@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1475874544-24842-6-git-send-email-ross.zwisler@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 07-10-16 15:08:52, Ross Zwisler wrote: > Right now we just return 0 for success, but we really want to let callers > know about this failure. > > Signed-off-by: Ross Zwisler > --- > fs/ext2/inode.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c > index c7dbb46..368913c 100644 > --- a/fs/ext2/inode.c > +++ b/fs/ext2/inode.c > @@ -830,8 +830,10 @@ ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length, > { > if (iomap->type == IOMAP_MAPPED && > written < length && > - (flags & IOMAP_WRITE)) > + (flags & IOMAP_WRITE)) { > ext2_write_failed(inode->i_mapping, offset + length); > + return -EIO; > + } So this is wrong. This (written < length) happens when we fail to copy data to / from userspace buffer into pagecache pages / DAX blocks. It may be because the passed buffer pointer is just wrong, or just because the page got swapped out and we have to swap it back in. It is a role of upper layers to decide what went wrong and proceed accordingly but from filesystem point of view we just have to cancel the operation we have prepared and return to upper layers. So returning 0 in this case is correct. Honza -- Jan Kara SUSE Labs, CR