From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+a14d8ac9af3a2a4fd0c8@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [btrfs?] kernel BUG in btrfs_folio_end_all_writers
Date: Sun, 28 Jul 2024 12:43:28 +0800 [thread overview]
Message-ID: <tencent_697761F76E26CD3369437B6979E3ADC45A05@qq.com> (raw)
In-Reply-To: <0000000000008a971a061dde1f74@google.com>
in cow_file_range, only ret == 0 means succuess
#syz test: upstream b1bc554e009e
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d62c96f00ff8..8253717cf2fd 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -762,7 +762,8 @@ static noinline int cow_file_range_inline(struct btrfs_inode *inode, u64 offset,
return ret;
}
- extent_clear_unlock_delalloc(inode, offset, end, NULL, &cached,
+ if (ret == 0)
+ extent_clear_unlock_delalloc(inode, offset, end, NULL, &cached,
clear_flags,
PAGE_UNLOCK | PAGE_START_WRITEBACK |
PAGE_END_WRITEBACK);
@@ -1043,8 +1044,16 @@ static void compress_file_range(struct btrfs_work *work)
ret = cow_file_range_inline(inode, start, end, total_compressed,
compress_type, folios[0], false);
if (ret <= 0) {
- if (ret < 0)
+ if (ret < 0) {
+ unsigned long clear_flags = EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
+ EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING | EXTENT_LOCKED;
mapping_set_error(mapping, -EIO);
+ extent_clear_unlock_delalloc(inode, start, end, NULL, NULL,
+ clear_flags,
+ PAGE_UNLOCK | PAGE_START_WRITEBACK |
+ PAGE_END_WRITEBACK);
+ }
+ return ret;
goto free_pages;
}
@@ -1361,7 +1370,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
/* lets try to make an inline extent */
ret = cow_file_range_inline(inode, start, end, 0,
BTRFS_COMPRESS_NONE, NULL, false);
- if (ret <= 0) {
+ if (ret == 0) {
/*
* We succeeded, return 1 so the caller knows we're done
* with this page and already handled the IO.
@@ -1369,8 +1378,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
* If there was an error then cow_file_range_inline() has
* already done the cleanup.
*/
- if (ret == 0)
- ret = 1;
+ ret = 1;
goto done;
}
}
next prev parent reply other threads:[~2024-07-28 4:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 23:08 syzbot
2024-07-28 4:43 ` Edward Adam Davis [this message]
2024-07-28 4:58 ` syzbot
2024-07-28 6:49 ` Edward Adam Davis
2024-07-28 7:05 ` syzbot
2024-07-28 8:17 ` Edward Adam Davis
2024-07-28 8:33 ` syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_697761F76E26CD3369437B6979E3ADC45A05@qq.com \
--to=eadavis@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+a14d8ac9af3a2a4fd0c8@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®