From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH] btrfs: Handle ENOMEM gracefully in cow_file_range_async
Date: Wed, 9 Jan 2019 16:43:03 +0200 [thread overview]
Message-ID: <20190109144303.31847-1-nborisov@suse.com> (raw)
If we run out of memory during delalloc filling in compress case btrfs
is going to BUG_ON. This is unnecessary since the higher levels code
(btrfs_run_delalloc_range and its callers) gracefully handle error
condtions and error out the page being submittede. Let's be a model
kernel citizen and no panic the machine due to ENOMEM and instead fail
the IO.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/inode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index cde51ace68b5..b4b2d7f8a98b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1197,7 +1197,8 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
1, 0, NULL);
while (start < end) {
async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS);
- BUG_ON(!async_cow); /* -ENOMEM */
+ if (!async_cow)
+ return -ENOMEM;
/*
* igrab is called higher up in the call chain, take only the
* lightweight reference for the callback lifetime
--
2.17.1
next reply other threads:[~2019-01-09 14:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 14:43 Nikolay Borisov [this message]
2019-01-09 14:46 ` [PATCH] btrfs: Handle ENOMEM gracefully in cow_file_range_async Johannes Thumshirn
2019-01-23 8:31 ` Nikolay Borisov
2019-01-25 15:05 ` David Sterba
2019-01-25 16:17 ` Nikolay Borisov
2019-01-25 17:46 ` Filipe Manana
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=20190109144303.31847-1-nborisov@suse.com \
--to=nborisov@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).