xfs: use null daddr for unset first bad log block
Subsystems (2)
PATCH v2 1/1 xfs: use null daddr for unset first bad log block
xlog_do_recovery_pass() may return before setting first_bad. The caller must distinguish that case from an error at a valid log block, including block zero after the log wraps.
Initialize first_bad to XFS_BUF_DADDR_NULL and test it explicitly before treating the error as a torn write.
---
Changes in v2:
- Use XFS_BUF_DADDR_NULL instead of zero as the unset sentinel.
- Test the sentinel explicitly before handling a torn write.
fs/xfs/xfs_log_recover.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/xfs/xfs_log_recover.c +3 -3
@@ -1028,7 +1028,7 @@ xlog_verify_head( {struct xlog_rec_header *tmp_rhead;char *tmp_buffer; -xfs_daddr_t first_bad; +xfs_daddr_t first_bad =XFS_BUF_DADDR_NULL ;xfs_daddr_t tmp_rhead_blk;int found;int error;
@@ -1057,7 +1057,8 @@ xlog_verify_head(*/ error =xlog_do_recovery_pass (log, *head_blk, tmp_rhead_blk,XLOG_RECOVER_CRCPASS , &first_bad); -if ((error == -EFSBADCRC || error == -EFSCORRUPTED ) && first_bad) { +if ((error == -EFSBADCRC || error == -EFSCORRUPTED ) && + first_bad !=XFS_BUF_DADDR_NULL ) {/* * We've hit a potential torn write. Reset the error and warn * about it.
@@ -3575,4 +3576,3 @@ xlog_recover_cancel(if (xlog_recovery_needed (log))xlog_recover_cancel_intents (log); } -
Signature · 1 line
2.54.0
Quoted 4 lines · Yousef Alhouseen
xlog_do_recovery_pass()may return before settingfirst_bad. The caller must distinguish that case from an error at a valid log block, including block zero after the log wraps.
Quoted 8 lines
Initialize
first_badtoXFS_BUF_DADDR_NULLand test it explicitly before treating the error as a torn write.Fixes 7088c4136fa1 ("xfs: detect and trim torn writes during log recovery")Suggested-by Darrick J. Wong <[email protected]>Reported-by [email protected]
Quoted 1 line
Signed-off-by Yousef Alhouseen <[email protected]>
Much better now, thanks.
--D
Quoted 39 lines
---
Changes in v2:
- UseXFS_BUF_DADDR_NULLinstead of zero as the unset sentinel.
- Test the sentinel explicitly before handling a torn write.fs/xfs/xfs_log_recover.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/xfs/xfs_log_recover.c +3
-3@@ -1028,7 +1028,7 @@ xlog_verify_head( {struct xlog_rec_header *tmp_rhead;char *tmp_buffer; -xfs_daddr_t first_bad; +xfs_daddr_t first_bad =XFS_BUF_DADDR_NULL ;xfs_daddr_t tmp_rhead_blk;int found;int error;@@ -1057,7 +1057,8 @@ xlog_verify_head(*/ error =xlog_do_recovery_pass (log, *head_blk, tmp_rhead_blk,XLOG_RECOVER_CRCPASS , &first_bad); -if ((error == -EFSBADCRC || error == -EFSCORRUPTED ) && first_bad) { +if ((error == -EFSBADCRC || error == -EFSCORRUPTED ) && + first_bad !=XFS_BUF_DADDR_NULL ) {/* * We've hit a potential torn write. Reset the error and warn * about it. @@ -3575,4 +3576,3 @@ xlog_recover_cancel(if (xlog_recovery_needed (log))xlog_recover_cancel_intents (log); } -Signature · 1 line
2.54.0
Looks good:
Quoted 8 lines · Yousef Alhouseen
xlog_do_recovery_pass()may return before settingfirst_bad. The caller must distinguish that case from an error at a valid log block, including block zero after the log wraps.Initialize
first_badtoXFS_BUF_DADDR_NULLand test it explicitly before treating the error as a torn write.[...]
Applied to for-next, thanks!
[1/1] xfs: use null daddr for unset first bad log block
commit: cc9af5e461ea5f6e37738f3f1e41c45a9b7f45d6
Best regards,
Signature · 1 line
Carlos Maiolino <[email protected]>