afs: Remove logically dead code
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
@@ -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
David Howells
maintainerfs/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
-2iterate_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
David Howells
maintainerI think the attached change is what I want.
David
---
fs/afs/dir.c +4 -4
@@ -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; }
Hello David,
Quoted 3 lines
A better solution, I think, is to check the result of
iterate_folioq(), invalidating the dir and returning-ESTALEif 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