From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42554 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750703AbcGBGYc (ORCPT ); Sat, 2 Jul 2016 02:24:32 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u626NTwb019866 for ; Sat, 2 Jul 2016 02:24:29 -0400 Received: from e28smtp07.in.ibm.com (e28smtp07.in.ibm.com [125.16.236.7]) by mx0b-001b2d01.pphosted.com with ESMTP id 23wpwwcs5e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sat, 02 Jul 2016 02:24:29 -0400 Received: from localhost by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 2 Jul 2016 11:54:26 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id A7E37E005B for ; Sat, 2 Jul 2016 11:58:15 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay02.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u626OFlm16056652 for ; Sat, 2 Jul 2016 11:54:16 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u626OMc6006632 for ; Sat, 2 Jul 2016 11:54:23 +0530 From: Chandan Rajendra To: Josef Bacik Cc: David Sterba , linux-btrfs@vger.kernel.org Subject: Re: btrfs/113: Assertion failure Date: Sat, 02 Jul 2016 11:54:20 +0530 In-Reply-To: References: <2400102.bkxfPSyYym@localhost.localdomain> <2057588.odf3SpF3Kc@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Message-Id: <1789803.4cv15UiFCH@localhost.localdomain> Sender: linux-btrfs-owner@vger.kernel.org List-ID: On Friday, July 01, 2016 04:25:52 PM Josef Bacik wrote: > On 07/01/2016 12:11 PM, Chandan Rajendra wrote: > > Sorry, Forgot to add the mailing list to CC. Doing it now ... > > > >> While running btrfs/113, I see the following call trace, > >> > >> [ 182.272009] BTRFS: assertion failed: !current->journal_info || flush != BTRFS_RESERVE_FLUSH_ALL, file: /home/chandan/repos/linux/fs/btrfs/extent-tree.c, line: 5131 > >> [ 182.274010] ------------[ cut here ]------------ > >> [ 182.274685] kernel BUG at /home/chandan/repos/linux/fs/btrfs/ctree.h:3347! > >> [ 182.274982] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC > >> [ 182.274982] Modules linked in: > >> [ 182.274982] CPU: 2 PID: 2911 Comm: xfs_io Not tainted 4.6.0-g5027553-dirty #29 > >> [ 182.274982] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 > >> [ 182.274982] task: ffff8818a4c3a400 ti: ffff8818aec4c000 task.ti: ffff8818aec4c000 > >> [ 182.274982] RIP: 0010:[] [] assfail+0x1a/0x1c > >> [ 182.274982] RSP: 0018:ffff8818aec4f5d8 EFLAGS: 00010282 > >> [ 182.274982] RAX: 0000000000000097 RBX: 0000000000030000 RCX: ffffffff8203dc18 > >> [ 182.274982] RDX: 0000000000000001 RSI: 0000000000000286 RDI: ffffffff822c8ccc > >> [ 182.274982] RBP: ffff8818aec4f5d8 R08: 00000000fffffffe R09: 0000000000000000 > >> [ 182.274982] R10: 0000000000000005 R11: 000000000000028d R12: ffff8818b44ff000 > >> [ 182.274982] R13: 0000000000030000 R14: ffff8818a54a01f0 R15: ffff8818a4f36150 > >> [ 182.274982] FS: 00007f54fbc6b700(0000) GS:ffff881933500000(0000) knlGS:0000000000000000 > >> [ 182.274982] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > >> [ 182.274982] CR2: 000000000061eba0 CR3: 00000018aec54000 CR4: 00000000000006e0 > >> [ 182.274982] Stack: > >> [ 182.274982] ffff8818aec4fa70 ffffffff8134a891 0000000200000000 0000000000030000 > >> [ 182.274982] ffff8818b2502600 ffff8818b44ff000 0000000000000000 0000000000000000 > >> [ 182.274982] 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > >> [ 182.274982] Call Trace: > >> [ 182.274982] [] __reserve_metadata_bytes+0xb1/0x1fe0 > >> [ 182.274982] [] ? lookup_address+0x23/0x30 > >> [ 182.274982] [] ? _lookup_address_cpa.isra.9+0x2d/0x30 > >> [ 182.274982] [] ? __change_page_attr_set_clr+0xeb/0xc80 > >> [ 182.274982] [] ? lookup_address+0x23/0x30 > >> [ 182.274982] [] ? get_alloc_profile+0x8a/0x1a0 > >> [ 182.274982] [] ? btrfs_get_alloc_profile+0x2b/0x30 > >> [ 182.274982] [] ? can_overcommit+0x9e/0x100 > >> [ 182.274982] [] ? __reserve_metadata_bytes+0xc88/0x1fe0 > >> [ 182.274982] [] ? __alloc_pages_nodemask+0x10d/0xc80 > >> [ 182.274982] [] ? _lookup_address_cpa.isra.9+0x2d/0x30 > >> [ 182.274982] [] ? __change_page_attr_set_clr+0xeb/0xc80 > >> [ 182.274982] [] ? lookup_address+0x23/0x30 > >> [ 182.274982] [] ? __slab_free+0x96/0x2b0 > >> [ 182.274982] [] ? __probe_kernel_read+0x39/0x90 > >> [ 182.274982] [] ? insert_state+0xc9/0x150 > >> [ 182.274982] [] ? add_delayed_ref_tail_merge+0x2e/0x350 > >> [ 182.274982] [] reserve_metadata_bytes+0x1f/0xe0 > >> [ 182.274982] [] btrfs_block_rsv_add+0x26/0x50 > >> [ 182.274982] [] ? free_extent_state+0x15/0x20 > >> [ 182.274982] [] btrfs_delalloc_reserve_metadata+0x13e/0x490 > >> [ 182.274982] [] btrfs_delalloc_reserve_space+0x2a/0x50 > >> [ 182.274982] [] btrfs_truncate_block+0x8a/0x430 > >> [ 182.274982] [] ? generic_bin_search.constprop.35+0x86/0x1e0 > >> [ 182.274982] [] truncate_inline_extent+0x157/0x260 > >> [ 182.274982] [] ? btrfs_search_slot+0x86c/0x990 > >> [ 182.274982] [] ? free_extent_map+0x4c/0xa0 > >> [ 182.274982] [] btrfs_truncate_inode_items+0xba7/0xdc0 > >> [ 182.274982] [] btrfs_truncate+0x168/0x280 > >> [ 182.274982] [] btrfs_setattr+0x214/0x320 > >> [ 182.274982] [] notify_change+0x1dc/0x380 > >> [ 182.274982] [] do_truncate+0x61/0xa0 > >> [ 182.274982] [] do_sys_ftruncate.constprop.17+0xf9/0x160 > >> [ 182.274982] [] SyS_ftruncate+0x9/0x10 > >> [ 182.274982] [] entry_SYSCALL_64_fastpath+0x13/0x8f > >> [ 182.274982] Code: 48 c7 c7 48 14 df 81 48 89 e5 e8 ac ac d3 ff 0f 0b 55 89 d1 31 c0 48 89 f2 48 89 fe 48 c7 c7 48 14 df 81 48 89 e5 e8 90 ac d3 ff <0f> 0b 55 b9 11 00 00 00 48 89 e5 41 55 49 89 f5 41 54 49 89 d4 > >> [ 182.274982] RIP [] assfail+0x1a/0x1c > >> [ 182.274982] RSP > >> [ 182.327207] ---[ end trace 44721e14eef0a6b2 ]--- > >> > >> > >> Basically btrfs_truncate() starts a transaction, btrfs_truncate_inode_items() > >> encounters an inline extent and invokes > >> btrfs_truncate_block(). btrfs_truncate_block() tries to reserve delalloc (both > >> data & metadata) space. While doing so it passes BTRFS_RESERVE_FLUSH_ALL as an > >> argument. Since we already have a transaction running, we fail the following > >> ASSERT() statement in __reserve_metadata_bytes(), > >> > >> ASSERT(!current->journal_info || flush != BTRFS_RESERVE_FLUSH_ALL); > >> > > > > Where is this code? I can't find it anywhere. Thanks, > Hi Josef, You can find the code in David's for-next branch at git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git. The relevant commit is ... 48f43b07fa3e2e7e86965c443979b578a9b1fe65 Author: Josef Bacik AuthorDate: Fri May 27 13:24:13 2016 -0400 Commit: David Sterba CommitDate: Tue May 31 22:57:37 2016 +0200 Btrfs: use FLUSH_LIMIT for relocation in reserve_metadata_bytes We used to allow you to set FLUSH_ALL and then just wouldn't do things like commit transactions or wait on ordered extents if we noticed you were in a transaction. However now that all the flushing for FLUSH_ALL is asynchronous we've lost the ability to tell, and we could end up deadlocking. So instead use FLUSH_LIMIT in reserve_metadata_bytes in relocation and then return -EAGAIN if we error out to preserve the previous behavior. I've also added an ASSERT() to catch anybody else who tries to do this. Thanks, -- chandan