From: Song Chen <chensong_2000@126.com>
To: dsterba@suse.com, mason@kernel.org, akinobu.mita@gmail.com,
corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org,
arnd@arndb.de, akpm@linux-foundation.org, ees@kernel.org
Cc: linux-doc@vger.kernel.org, linux-arch@vger.kernel.org,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Song Chen <chensong_2000@126.com>
Subject: [PATCH v3 1/2] error-injection: Introduce EI_ETYPE_FALSE for fail_function
Date: Tue, 13 Oct 2026 05:29:09 +0800 [thread overview]
Message-ID: <20261012212910.54623-2-chensong_2000@126.com> (raw)
In-Reply-To: <20261012212910.54623-1-chensong_2000@126.com>
Introduce EI_ETYPE_FALSE for functions which need false as return
value in their error-injections, like btrfs_data_csum_ok.
EI_ETYPE_NULL can return 0 too but its readability is not good
enough.
Acked-by: David Sterba <dsterba@suse.com>
Signed-off-by: Song Chen <chensong_2000@126.com>
---
Documentation/fault-injection/fault-injection.rst | 3 +++
include/asm-generic/error-injection.h | 1 +
kernel/fail_function.c | 2 ++
lib/error-inject.c | 2 ++
4 files changed, 8 insertions(+)
diff --git a/Documentation/fault-injection/fault-injection.rst b/Documentation/fault-injection/fault-injection.rst
index c2d3996b5b40..86431ad2b565 100644
--- a/Documentation/fault-injection/fault-injection.rst
+++ b/Documentation/fault-injection/fault-injection.rst
@@ -347,6 +347,9 @@ EI_ETYPE_ERRNO_NULL
EI_ETYPE_TRUE
This function will return `true` (non-zero positive value) if it fails.
+EI_ETYPE_FALSE
+ This function will return `false` if it fails.
+
If you specifies a wrong type, for example, EI_TYPE_ERRNO for the function
which returns an allocated object, it may cause a problem because the returned
value is not an object address and the caller can not access to the address.
diff --git a/include/asm-generic/error-injection.h b/include/asm-generic/error-injection.h
index b05253f68eaa..6c399121ab7a 100644
--- a/include/asm-generic/error-injection.h
+++ b/include/asm-generic/error-injection.h
@@ -8,6 +8,7 @@ enum {
EI_ETYPE_ERRNO, /* Return -ERRNO if failure */
EI_ETYPE_ERRNO_NULL, /* Return -ERRNO or NULL if failure */
EI_ETYPE_TRUE, /* Return true if failure */
+ EI_ETYPE_FALSE, /* Return false if failure */
};
struct error_injection_entry {
diff --git a/kernel/fail_function.c b/kernel/fail_function.c
index 2eaf55005f49..90cdad0412cd 100644
--- a/kernel/fail_function.c
+++ b/kernel/fail_function.c
@@ -48,6 +48,8 @@ static unsigned long adjust_error_retval(unsigned long addr, unsigned long retv)
break;
case EI_ETYPE_TRUE:
return 1;
+ case EI_ETYPE_FALSE:
+ return 0;
}
return retv;
diff --git a/lib/error-inject.c b/lib/error-inject.c
index 32f3d1ca9ea2..115b10dbf9aa 100644
--- a/lib/error-inject.c
+++ b/lib/error-inject.c
@@ -189,6 +189,8 @@ static const char *error_type_string(int etype)
return "ERRNO_NULL";
case EI_ETYPE_TRUE:
return "TRUE";
+ case EI_ETYPE_FALSE:
+ return "FALSE";
default:
return "(unknown)";
}
--
2.43.0
next prev parent reply other threads:[~2026-10-12 13:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 21:29 [PATCH v3 0/2] btrfs: add error injection support for checksum verification Song Chen
2026-10-12 21:29 ` Song Chen [this message]
2026-10-12 21:29 ` [PATCH v3 2/2] btrfs: Allow error injection on btrfs_data_csum_ok Song Chen
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=20261012212910.54623-2-chensong_2000@126.com \
--to=chensong_2000@126.com \
--cc=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=corbet@lwn.net \
--cc=dsterba@suse.com \
--cc=ees@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@kernel.org \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.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
all inboxes | Powered by JetHome®