From patchwork Mon May 21 12:37:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 10415101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C62D46032C for ; Mon, 21 May 2018 12:38:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B702627C05 for ; Mon, 21 May 2018 12:38:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9F9F27BA5; Mon, 21 May 2018 12:38:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CC0127BA5 for ; Mon, 21 May 2018 12:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751161AbeEUMiC (ORCPT ); Mon, 21 May 2018 08:38:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:35514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751056AbeEUMiB (ORCPT ); Mon, 21 May 2018 08:38:01 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 69F6E206B7; Mon, 21 May 2018 12:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526906281; bh=sQ8RQm+pH0INcweo7aAwKyocn3zpBmYW4hL9d5wcNSw=; h=From:To:Cc:Subject:Date:From; b=Mdz7p+DKMrVrsNeRUNiebPig7ealWc+j2zWSJaz9hDIVZ0THvgeeI9Ii1aZuhgnPz aNu7ZpmWFcM7U2lvMvojFjtuCrvoF524bRfw1s0Me4Lt6tdk8MCAC96ItLVETjfcyo HUtur0dSNBSwEU/57EhXYAaVr73gT5VED9uu2MSE= From: Jeff Layton To: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Cc: willy@infradead.org, darrick.wong@oracle.com, tytso@mit.edu, bfoster@redhat.com Subject: [PATCH] loop: clear wb_err in bd_inode when detaching backing file Date: Mon, 21 May 2018 08:37:58 -0400 Message-Id: <20180521123758.9537-1-jlayton@kernel.org> X-Mailer: git-send-email 2.17.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff Layton When a loop block device encounters a writeback error, that error will get propagated to the bd_inode's wb_err field. If we then detach the backing file from it, attach another and fsync it, we'll get back the writeback error that we had from the previous backing file. This is a bit of a grey area as POSIX doesn't cover loop devices, but it is somewhat counterintuitive. If we detach a backing file from the loopdev while there are still unreported errors, take it as a sign that we're no longer interested in the previous file, and clear out the wb_err in the loop blockdev. Signed-off-by: Jeff Layton --- drivers/block/loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 5d4e31655d96..55cf554bc914 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1068,6 +1068,7 @@ static int loop_clr_fd(struct loop_device *lo) if (bdev) { bdput(bdev); invalidate_bdev(bdev); + bdev->bd_inode->i_mapping->wb_err = 0; } set_capacity(lo->lo_disk, 0); loop_sysfs_exit(lo);