Skip to contentSkip to conversation

ext4: remove unneeded check of nr_to_submit

PATCH Applied Tom Rix 3 participants 4 messages Mar 16, 2023 – Apr 20, 2023 ext4 file system

lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 ext4: remove unneeded check of nr_to_submit

cppcheck reports
fs/ext4/page-io.c:516:51: style:
Condition 'nr_to_submit' is always true [knownConditionTrueFalse]

 if (fscrypt_inode_uses_fs_layer_crypto(inode) && nr_to_submit) {
                                                  ^
This earlier check to bail, makes this check unncessary
	/* Nothing to submit? Just unlock the page... */
	if (!nr_to_submit)
		return 0;
---
 fs/ext4/page-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/page-io.c +1 -1
index 8703fd732abb..b847131bc958 100644
@@ -513,7 +513,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
 	 * (e.g. holes) to be unnecessarily encrypted, but this is rare and
 	 * can't happen in the common case of blocksize == PAGE_SIZE.
 	 */
-	if (fscrypt_inode_uses_fs_layer_crypto(inode) && nr_to_submit) {
+	if (fscrypt_inode_uses_fs_layer_crypto(inode)) {
 		gfp_t gfp_flags = GFP_NOFS;
 		unsigned int enc_bytes = round_up(len, i_blocksize(inode));
 
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Tom Rix

cppcheck reports
fs/ext4/page-io.c:516:51: style:
Condition 'nr_to_submit' is always true [knownConditionTrueFalse]

 if (fscrypt_inode_uses_fs_layer_crypto(inode) && nr_to_submit) {
                                                  ^
This earlier check to bail, makes this check unncessary
	/* Nothing to submit? Just unlock the page... */
	if (!nr_to_submit)
		return 0;

Maybe add:

Fixes dff4ac75eeee ("ext4: move keep_towrite handling to ext4_bio_write_page()")

Either way, looks good to me.

- Eric

author
#2 lore raw
Quoted 11 lines · Eric Biggers
Quoted 10 lines · Tom Rix

cppcheck reports
fs/ext4/page-io.c:516:51: style:
Condition 'nr_to_submit' is always true [knownConditionTrueFalse]

  if (fscrypt_inode_uses_fs_layer_crypto(inode) && nr_to_submit) {
                                                   ^
This earlier check to bail, makes this check unncessary
	/* Nothing to submit? Just unlock the page... */
	if (!nr_to_submit)
		return 0;
Quoted 4 lines
Quoted 1 line

Maybe add:

Fixes dff4ac75eeee ("ext4: move keep_towrite handling to ext4_bio_write_page()")

The rule of thumb I use is 'would this require a recompile?'

In this case, the existing code will work, so no fixes:

Tom

Quoted 6 lines

Either way, looks good to me.

- Eric

maintainer Applied
#3 lore raw
In reply to Tom Rix
Quoted 11 lines · Tom Rix

cppcheck reports
fs/ext4/page-io.c:516:51: style:
Condition 'nr_to_submit' is always true [knownConditionTrueFalse]

 if (fscrypt_inode_uses_fs_layer_crypto(inode) && nr_to_submit) {
                                                  ^
This earlier check to bail, makes this check unncessary
	/* Nothing to submit? Just unlock the page... */
	if (!nr_to_submit)
		return 0;

[...]

Applied, thanks!

[1/1] ext4: remove unneeded check of nr_to_submit

      commit: 8ae56b4e82ee29b5cc1fbea8b00a0a7e0758f3c2

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>