From patchwork Mon Mar 14 21:10:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Moyer X-Patchwork-Id: 8583881 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7380F9F3D1 for ; Mon, 14 Mar 2016 21:10:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BF892022D for ; Mon, 14 Mar 2016 21:10:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D469201C8 for ; Mon, 14 Mar 2016 21:10:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933850AbcCNVKD (ORCPT ); Mon, 14 Mar 2016 17:10:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35664 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932387AbcCNVKB (ORCPT ); Mon, 14 Mar 2016 17:10:01 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 5D21B85365; Mon, 14 Mar 2016 21:10:01 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2ELA0c9024790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 14 Mar 2016 17:10:00 -0400 From: Jeff Moyer To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [patch] direct-io: propagate -ENOSPC errors X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-PCLoadLetter: What the f**k does that mean? Date: Mon, 14 Mar 2016 17:10:00 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dio_bio_complete turns all errors into -EIO. This is historical, since you used to only get 1 bit precision for errors (BIO_UPTODATE). Now that we get actual error codes, we can return the appropriate code to userspace. File systems seem to only propagate either EIO or ENOSPC, so I've followed suit in this patch. This fixes an issue where -ENOSPC was being turned into -EIO when testing dm-thin. Reported-by: Carlos Maiolino Tested-by: Mike Snitzer Signed-off-by: Jeff Moyer Reviewed-by: Carlos Maiolino --- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/direct-io.c b/fs/direct-io.c index d6a9012..990e0aa 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -466,13 +466,15 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio) { struct bio_vec *bvec; unsigned i; - int err; - if (bio->bi_error) + /* Only EIO and ENOSPC should be returned to userspace. */ + if (bio->bi_error == 0 || + bio->bi_error == -ENOSPC || bio->bi_error == -EIO) + dio->io_error = bio->bi_error; + else dio->io_error = -EIO; if (dio->is_async && dio->rw == READ && dio->should_dirty) { - err = bio->bi_error; bio_check_pages_dirty(bio); /* transfers ownership */ } else { bio_for_each_segment_all(bvec, bio, i) { @@ -483,10 +485,9 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio) set_page_dirty_lock(page); page_cache_release(page); } - err = bio->bi_error; bio_put(bio); } - return err; + return dio->io_error; } /*