Bug 215373 - ubifs: ubifs_assert_failed [ubifs]: UBIFS assert failed: 0, in fs/ubifs/file.c:1499 (writepage races with truncate)
Summary: ubifs: ubifs_assert_failed [ubifs]: UBIFS assert failed: 0, in fs/ubifs/file....
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: fs_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-20 07:38 UTC by Zhihao Cheng
Modified: 2021-12-20 08:20 UTC (History)
0 users

See Also:
Kernel Version: 5.16-rc5
Subsystem:
Regression: No
Bisected commit-id:


Attachments
delay.patch (2.02 KB, patch)
2021-12-20 08:19 UTC, Zhihao Cheng
Details | Diff
setup.sh (893 bytes, application/x-shellscript)
2021-12-20 08:20 UTC, Zhihao Cheng
Details
a.c (944 bytes, text/plain)
2021-12-20 08:20 UTC, Zhihao Cheng
Details

Description Zhihao Cheng 2021-12-20 07:38:17 UTC
[   78.065456] UBIFS error (ubi0:0 pid 1492): ubifs_assert_failed [ubifs]: UBIFS assert failed: 0, in fs/ubifs/file.c:1499
[   78.068836] UBIFS warning (ubi0:0 pid 1492): ubifs_ro_mode [ubifs]: switched to read-only mode, error -22
[   78.071833] CPU: 2 PID: 1492 Comm: aa Not tainted 5.16.0-rc5-00012-g7bb767dee0ba-dirty #293
[   78.074386] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014
[   78.077104] Call Trace:
[   78.077433]  <TASK>
[   78.077718]  ? dump_stack_lvl+0x73/0x9f
[   78.078255]  ? dump_stack+0x13/0x1b
[   78.078724]  ? ubifs_ro_mode+0x54/0x60 [ubifs]
[   78.079337]  ? ubifs_assert_failed+0x4b/0x80 [ubifs]
[   78.080015]  ? ubifs_releasepage+0x7e/0x1e0 [ubifs]
[   78.080676]  ? try_to_release_page+0x57/0xe0
[   78.081252]  ? invalidate_inode_page+0xfb/0x130
[   78.081852]  ? __invalidate_mapping_pages+0xb9/0x280
[   78.082513]  ? blk_finish_plug+0x31/0x50
[   78.083046]  ? generic_writepages+0x6f/0xb0
[   78.083610]  ? do_writepages+0xcc/0x200
[   78.084129]  ? hung_up_tty_compat_ioctl+0x1/0x30
[   78.084745]  ? filemap_fdatawrite_wbc+0xb1/0x100
[   78.085366]  ? __filemap_fdatawrite_range+0x5c/0x80
[   78.086020]  ? invalidate_mapping_pagevec+0x12/0x20
[   78.086670]  ? generic_fadvise+0x303/0x3c0
[   78.087225]  ? vfs_fadvise+0x35/0x40
[   78.087703]  ? ksys_fadvise64_64+0x4c/0xb0
[   78.088254]  ? __x64_sys_fadvise64+0x22/0x30
[   78.088827]  ? do_syscall_64+0x35/0x80
[   78.089335]  ? entry_SYSCALL_64_after_hwframe+0x44/0xae
[   78.090022]  </TASK>




static int ubifs_releasepage(struct page *page, gfp_t unused_gfp_flags)
{
	struct inode *inode = page->mapping->host;
	struct ubifs_info *c = inode->i_sb->s_fs_info;

	/*
	 * An attempt to release a dirty page without budgeting for it - should
	 * not happen.
	 */
	if (PageWriteback(page))
		return 0;
	ubifs_assert(c, PagePrivate(page));
	ubifs_assert(c, 0);                   <--- assert failed
	ClearPagePrivate(page);
	ClearPageChecked(page);
	return 1;
}
Comment 1 Zhihao Cheng 2021-12-20 07:42:03 UTC
reproducer:
1. Apply diff.patch
2. ./setup.sh 1
3. compile a.c -> aa
4. dd if=/dev/urandom of=/root/temp/file bs=20K
5. truncate -s 0 /root/temp/file  // Execute it after seeing message "... wait truncate"
6. ./aa                           // Execute it after seeing message "... wait fadvise"

[   28.232326] ubifs_writepage: index 4, size 20480, wait truncate
[   29.471054] truncate_setsize: new isize 0
[   31.251556] ubifs_writepage: index 4, size 0, truncated
[   31.252434] ubifs_writepage: unlock page 4, wait fadvise
[   32.084340] UBIFS error (ubi0:0 pid 1683): ubifs_assert_failed [ubifs]: UBIFS assert failed: 0, in fs/ubifs/file.c:1513
[   32.086765] UBIFS warning (ubi0:0 pid 1683): ubifs_ro_mode [ubifs]: switched to read-only mode, error -22
[   32.088648] CPU: 2 PID: 1683 Comm: aa Not tainted 5.16.0-rc5-00184-g0bca5994cacc-dirty #308
[   32.090211] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014
[   32.092653] Call Trace:
[   32.093125]  <TASK>
[   32.093532]  ? dump_stack_lvl+0x73/0x9f
[   32.094272]  ? dump_stack+0x13/0x1b
[   32.094761]  ? ubifs_ro_mode+0x54/0x60 [ubifs]
[   32.095355]  ? ubifs_assert_failed+0x4b/0x80 [ubifs]
[   32.096040]  ? ubifs_releasepage+0x67/0x1d0 [ubifs]
[   32.096684]  ? try_to_release_page+0x57/0xe0
[   32.097238]  ? invalidate_inode_page+0xfb/0x130
[   32.097823]  ? __invalidate_mapping_pages+0xb9/0x280
[   32.098472]  ? do_writepages+0x1b8/0x200
[   32.098981]  ? filemap_fdatawrite_wbc+0xb1/0x100
[   32.099581]  ? __filemap_fdatawrite_range+0x5c/0x80
[   32.100210]  ? invalidate_mapping_pagevec+0x12/0x20
[   32.100833]  ? generic_fadvise+0x303/0x3c0
[   32.101364]  ? putname+0x75/0xb0
[   32.101786]  ? vfs_fadvise+0x35/0x40
[   32.102253]  ? ksys_fadvise64_64+0x4c/0xb0
[   32.102781]  ? __x64_sys_fadvise64+0x22/0x30
[   32.103339]  ? do_syscall_64+0x35/0x80
[   32.103829]  ? entry_SYSCALL_64_after_hwframe+0x44/0xae
[   32.104513]  </TASK>
[   35.667523] truncate_setsize: truncate pages
Comment 2 Zhihao Cheng 2021-12-20 08:19:48 UTC
Created attachment 300083 [details]
delay.patch
Comment 3 Zhihao Cheng 2021-12-20 08:20:00 UTC
Created attachment 300085 [details]
setup.sh
Comment 4 Zhihao Cheng 2021-12-20 08:20:10 UTC
Created attachment 300087 [details]
a.c

Note You need to log in before you can comment on or make changes to this bug.