From patchwork Wed Jul 26 09:23:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: OGAWA Hirofumi X-Patchwork-Id: 9864485 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 07C876038F for ; Wed, 26 Jul 2017 09:45:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5EFD28742 for ; Wed, 26 Jul 2017 09:45:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7BA728745; Wed, 26 Jul 2017 09:45:08 +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.9 required=2.0 tests=BAYES_00,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 D71AB28742 for ; Wed, 26 Jul 2017 09:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750907AbdGZJpG (ORCPT ); Wed, 26 Jul 2017 05:45:06 -0400 Received: from mail.parknet.co.jp ([210.171.160.6]:51661 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750816AbdGZJpG (ORCPT ); Wed, 26 Jul 2017 05:45:06 -0400 X-Greylist: delayed 1314 seconds by postgrey-1.27 at vger.kernel.org; Wed, 26 Jul 2017 05:45:06 EDT Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTP id 8D5F9170001; Wed, 26 Jul 2017 18:23:10 +0900 (JST) Received: from devron.myhome.or.jp (root@devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (8.15.2/8.15.2/Debian-8) with ESMTPS id v6Q9N9lr002400 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jul 2017 18:23:10 +0900 Received: from devron.myhome.or.jp (hirofumi@localhost [127.0.0.1]) by devron.myhome.or.jp (8.15.2/8.15.2/Debian-8) with ESMTPS id v6Q9N9e7024146 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jul 2017 18:23:09 +0900 Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.15.2/8.15.2/Submit) id v6Q9N8IA024145; Wed, 26 Jul 2017 18:23:08 +0900 From: OGAWA Hirofumi To: Johannes Thumshirn Cc: Ross Zwisler , "Kani\, Toshimitsu" , "linux-nvdimm\@lists.01.org" , "linux-fsdevel\@vger.kernel.org" Subject: Re: FIle copy to FAT FS on NVDIMM hits BUG_ON at fs/buffer.c:3305! References: <1501018096.2042.70.camel@hpe.com> <20170725222247.GA26391@linux.intel.com> <20170726082159.GE4039@linux-x5ow.site> Date: Wed, 26 Jul 2017 18:23:08 +0900 In-Reply-To: <20170726082159.GE4039@linux-x5ow.site> (Johannes Thumshirn's message of "Wed, 26 Jul 2017 10:21:59 +0200") Message-ID: <87d18neemb.fsf@devron> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.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 "Kani, Toshimitsu" writes: > kernel BUG at fs/buffer.c:3305! > invalid opcode: 0000 [#1] SMP > : > Workqueue: writeback wb_workfn (flush-259:0) > task: ffff8d02595b8000 task.stack: ffffa22242400000 > RIP: 0010:try_to_free_buffers+0xd2/0xe0 > RSP: 0018:ffffa22242403830 EFLAGS: 00010246 > RAX: 00afffc000001028 RBX: 0000000000000008 RCX: ffff8d012dcf19c0 > RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffffc468e3b52b80 > RBP: ffffa22242403858 R08: 0000000000000000 R09: 000000000002067c > R10: ffff8d027ffe6000 R11: 0000000000000000 R12: 0000000000000000 > R13: ffff8d022fccdbe0 R14: ffffc468e3b52b80 R15: ffffa22242403ad0 > FS: 0000000000000000(0000) GS:ffff8d027fd40000(0000) The locking of this path seems to be broken. The guy familiar to bdev_write_page() path will made real fix though, The following patch should be explaining enough what is wrong. In short, clean_buffers() must be called before unlocking lock_page(). Signed-off-by: OGAWA Hirofumi --- fs/block_dev.c | 2 -- fs/mpage.c | 1 + mm/page_io.c | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff -puN fs/mpage.c~bdev_write_page-fix fs/mpage.c --- linux/fs/mpage.c~bdev_write_page-fix 2017-07-26 18:05:53.078204737 +0900 +++ linux-hirofumi/fs/mpage.c 2017-07-26 18:07:03.960043665 +0900 @@ -605,6 +605,7 @@ alloc_new: if (!bdev_write_page(bdev, blocks[0] << (blkbits - 9), page, wbc)) { clean_buffers(page, first_unmapped); + unlock_page(page); goto out; } } diff -puN mm/page_io.c~bdev_write_page-fix mm/page_io.c --- linux/mm/page_io.c~bdev_write_page-fix 2017-07-26 18:06:16.807150810 +0900 +++ linux-hirofumi/mm/page_io.c 2017-07-26 18:06:23.425135771 +0900 @@ -308,6 +308,7 @@ int __swap_writepage(struct page *page, ret = bdev_write_page(sis->bdev, swap_page_sector(page), page, wbc); if (!ret) { + unlock_page(page); count_vm_event(PSWPOUT); return 0; } diff -puN fs/block_dev.c~bdev_write_page-fix fs/block_dev.c --- linux/fs/block_dev.c~bdev_write_page-fix 2017-07-26 18:08:53.490794861 +0900 +++ linux-hirofumi/fs/block_dev.c 2017-07-26 18:08:58.375783767 +0900 @@ -714,8 +714,6 @@ int bdev_write_page(struct block_device result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, true); if (result) end_page_writeback(page); - else - unlock_page(page); blk_queue_exit(bdev->bd_queue); return result; }