From patchwork Thu Mar 9 23:53:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahsin Erdogan X-Patchwork-Id: 9614361 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 49A3E604D9 for ; Thu, 9 Mar 2017 23:53:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C085286CF for ; Thu, 9 Mar 2017 23:53:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F38B286E6; Thu, 9 Mar 2017 23:53:45 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM 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 DC5B7286CF for ; Thu, 9 Mar 2017 23:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754500AbdCIXxi (ORCPT ); Thu, 9 Mar 2017 18:53:38 -0500 Received: from mail-io0-f171.google.com ([209.85.223.171]:33319 "EHLO mail-io0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753758AbdCIXxO (ORCPT ); Thu, 9 Mar 2017 18:53:14 -0500 Received: by mail-io0-f171.google.com with SMTP id f84so37801182ioj.0 for ; Thu, 09 Mar 2017 15:53:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=yDw3XEXpCfYQtNTBHvISc4HLDXqOOm+6p82K7t57hGg=; b=cD1r716CJlfUzsPM7vivRioNjFc+LGt+GklCbOgsOEFOk8oWxDoYYY6PZJIHINvN/I h/lCGFzYn1FcgFwnSFdOeOackP06yYA8h1K5bYWcpwJxEcPRlKq9+XpoZBJhpkUVK/e7 vsVV6QLOYE31pU1XFToIWnbDm53IcSBRReeVJ+gG1WsFXFble7r5A/x7zBmQ/h8VT+Lv C7sA01GKyXOxCKR4N4HhhPy4BNplNahOKltEDMUIIUhLqfzkpk72dgf/2kRrZkG6mMuE zHoC1X/E6kcBv11GmLYWXqpG4y3txVJBBsmrnRUkH8pTvfPebx5ocZuqCcDxpcEZ6CkX mRdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=yDw3XEXpCfYQtNTBHvISc4HLDXqOOm+6p82K7t57hGg=; b=YtOaAph/2GaPCqSuv/amqqtk9q6qhdmrtwIG0NQw+hYctbX0YkOuFWTxd1YSpIv4EI 1RxB83zTQqtwKlgTpj0phKpJkPFDjQbR2cGjHOxJzeBvi0YRNGQ6N2h1MktMRkZZqtGR c6R/JQ9BoIKo91tZSiD9wp8xPL7GCHxasIh2d93WYoopdkPghe+wMl0bniqmZ5IvbVfD 0+kDXHR23Lim+jRJimQMGjU6R/yvSxHvCBTQRnISjoJqyIqT03WOURxBf6cpLEPOJnCt NKfaxvFKpZXnPLi5gU7N82MyseoM/v/YtT3uDmnIKCK6ugOv2e7/gIpDgEXr+2x61exC eRlg== X-Gm-Message-State: AMke39n70U+Nvyks8CrHOhVMT7uAc45WhglM+iZ+Jc6BQ1ygoTakYiRlKdDHWWf+5AptB85gKBoaoodFqokezzxX X-Received: by 10.107.176.79 with SMTP id z76mr14694861ioe.223.1489103592463; Thu, 09 Mar 2017 15:53:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.3.73 with HTTP; Thu, 9 Mar 2017 15:53:11 -0800 (PST) In-Reply-To: <20170309234608.12738-1-tahsin@google.com> References: <20170309182645.GD28982@htj.duckdns.org> <20170309234608.12738-1-tahsin@google.com> From: Tahsin Erdogan Date: Thu, 9 Mar 2017 15:53:11 -0800 Message-ID: Subject: Re: [PATCH v2] block, writeback: wait for writeback to finish before detaching wb To: Alexander Viro , Ilya Dryomov , Jens Axboe , Raghavendra K T , Tejun Heo , Jan Kara Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Tahsin Erdogan 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 Hi Tejun, > > White line contaminations. Fixed in v2. > Given that there's write_inode_now(@sync == true) call right above, > I'm not sure how waiting for I_SYNC once more time would make a > difference. Can you please explain how to trigger the issue? bdev_write_inode() calls write_inode_now() only if I_DIRTY is set for the inode. It is possible that I_DIRTY flags have been cleared by the writeback thread, but it hasn't run node_sync_complete() yet. I am able to reproduce the problem by adding articial delays in __blkdev_put() and writeback_sb_inodes(). Please see the repro patch below: diff --git a/fs/block_dev.c b/fs/block_dev.c index 2eca00ec4370..e3cfbba19a6c 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "internal.h" struct bdev_inode { @@ -1875,6 +1876,8 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) sync_blockdev(bdev); kill_bdev(bdev); + /* Allow time for writeback thread to clear I_DIRTY flags */ + mdelay(200); bdev_write_inode(bdev); /* * Detaching bdev inode from its wb in __destroy_inode() diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index ef600591d96f..55073cbc1823 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "internal.h" /* @@ -1585,6 +1586,10 @@ static long writeback_sb_inodes(struct super_block *sb, cond_resched(); } + /* Allow __blkdev_put() to run inode_detach_wb() */ + if (inode->i_ino == 0) + mdelay(200); + /* * Requeue @inode if still dirty. Be careful as @inode may * have been switched to another wb in the meantime. diff --git a/wb-detach-repro.sh b/wb-detach-repro.sh new file mode 100755 index 000000000000..66892d71cd20 --- /dev/null +++ b/wb-detach-repro.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -ex + +echo 100 > /proc/sys/vm/dirty_expire_centisecs +echo 100 > /proc/sys/vm/dirty_writeback_centisecs + +mount /dev/sdb /mnt/sdb +sleep 0.9 +echo 10 > /proc/sys/vm/dirty_writeback_centisecs +umount /dev/sdb