Skip to contentSkip to conversation

afs: Remove logically dead code

PATCH-next Advait Dhamorikar 2 participants 4 messages Nov 16, 2024 – Nov 18, 2024 Afs filesystem

lore
Share & tools
lore
#0 lore raw

Initially ret is initialized to 0 and its value is then never updated again, thus the indicated dead code may have performed some action; that action will never occur.

---
 fs/afs/dir.c | 2 --
 1 file changed, 2 deletions(-)
fs/afs/dir.c +0 -2
index b6a202fd9926..afa7c24828ec 100644
@@ -502,8 +502,6 @@ static int afs_dir_iterate_contents(struct inode *dir, struct dir_context *ctx)
 	iterate_folioq(&iter, iov_iter_count(&iter), dvnode, ctx,
 		       afs_dir_iterate_step);
 
-	if (ret == -ESTALE)
-		afs_invalidate_dir(dvnode, afs_dir_invalid_iter_stale);
 	return ret;
 }
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw

fs/afs/dir.c static int afs_dir_iterate_contents(struct inode *dir, struct dir_context *ctx) · line 505

Quoted 6 lines · Advait Dhamorikar
fs/afs/dir.c +0 -2
 	iterate_folioq(&iter, iov_iter_count(&iter), dvnode, ctx,
 		       afs_dir_iterate_step);
 
-	if (ret == -ESTALE)
-		afs_invalidate_dir(dvnode, afs_dir_invalid_iter_stale);
 	return ret;

Removing this is the wrong thing to do. However, you're correct that ret is never set to -ESTALE.

A better solution, I think, is to check the result of iterate_folioq(), invalidating the dir and returning -ESTALE if 0 and if the iterator count is not 0.

David

maintainer
#2 lore raw

I think the attached change is what I want.

David
---

fs/afs/dir.c +4 -4
index b6a202fd9926..2adc034603f2 100644
@@ -499,11 +499,11 @@ static int afs_dir_iterate_contents(struct inode *dir, struct dir_context *ctx)
 	iov_iter_folio_queue(&iter, ITER_SOURCE, dvnode->directory, 0, 0, i_size);
 	iov_iter_advance(&iter, round_down(ctx->pos, AFS_DIR_BLOCK_SIZE));
 
-	iterate_folioq(&iter, iov_iter_count(&iter), dvnode, ctx,
-		       afs_dir_iterate_step);
-
-	if (ret == -ESTALE)
+	if (!iterate_folioq(&iter, iov_iter_count(&iter), dvnode, ctx,
+			    afs_dir_iterate_step)) {
 		afs_invalidate_dir(dvnode, afs_dir_invalid_iter_stale);
+		ret = -ESTALE;
+	}
 	return ret;
 }
 
#3 lore raw
In reply to David Howells

Hello David,

Quoted 3 lines

A better solution, I think, is to check the result of iterate_folioq(), invalidating the dir and returning -ESTALE if 0 and if the iterator count is not 0.

Thanks for the insights and the feedback, however it looks like this patch is no longer relevant as there have been significant changes to the file since then.

Best regards,
Advait