From patchwork Mon May 21 18:35:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 10416183 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 161BC6053B for ; Mon, 21 May 2018 18:35:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2038289EB for ; Mon, 21 May 2018 18:35:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E542F289ED; Mon, 21 May 2018 18:35:07 +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=ham 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 7BE34289EB for ; Mon, 21 May 2018 18:35:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751073AbeEUSfG (ORCPT ); Mon, 21 May 2018 14:35:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:42410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750909AbeEUSfF (ORCPT ); Mon, 21 May 2018 14:35:05 -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 83C5E2084A; Mon, 21 May 2018 18:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526927705; bh=o2JflcWLXjSG4ZTmyrGc2ICwidQUWGDpHq7TwOEkgDw=; h=From:To:Cc:Subject:Date:From; b=f7ROPm1SVjuSO1ujDtFSojifuexhGo3W88xcYmQ3nn5PWdR2SNUv/cn2HAnYaoBxw D4L/AK3EqrUKEIaVs5n1sZf1KEa9oLzvbSYjeVEEMw8XayLs9eya6Sh6fjY2Gy23tf HW7lRSL3+VKy87XdC009UNkycVq+koCz5A5fkd00= From: Jeff Layton To: axboe@fb.com Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, willy@infradead.org, darrick.wong@oracle.com, tytso@mit.edu, bfoster@redhat.com Subject: [PATCH RESEND] loop: clear wb_err in bd_inode when detaching backing file Date: Mon, 21 May 2018 14:35:03 -0400 Message-Id: <20180521183503.6029-1-jlayton@kernel.org> X-Mailer: git-send-email 2.17.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@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. Reported-and-Tested-by: Theodore Y. Ts'o Signed-off-by: Jeff Layton --- drivers/block/loop.c | 1 + 1 file changed, 1 insertion(+) Resend to fix the attributions. 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);