Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QAT related bug fixes #9303

Merged
merged 1 commit into from
Sep 12, 2019
Merged

QAT related bug fixes #9303

merged 1 commit into from
Sep 12, 2019

Conversation

cfzhu
Copy link
Contributor

@cfzhu cfzhu commented Sep 10, 2019

Motivation and Context

  1. Kernel oops when reading a file with dd from a dataset, after
    pressing Ctrl+C to abort the command. Kernel BUG with QAT during decompression #9276
    As wait_for_completion_interruptible_timeout() is interruptible. the
    fuction qat_compress_impl() will return when pressing Ctrl + C.
    it will free the memory resources that have been allocated.
    When the callback function qat_dc_callback is called, it will access
    the memory that has been freed.
    QAT encryption&checksum have the same issue.

Description

  1. Change the wait_for_completion_interruptible_timeout() to
    wait_for_completion() to make each QAT call uninterruptible,
    but Ctrl-C interrupt still works in user-space process.
  2. Copy the digest result to the buffer only when doing encryption,
    and vise-versa for decryption.

How Has This Been Tested?

When reading a file with dd from a dataset with QAT enabled,
press Ctrl+C to abort the command, the kernel don't not crash.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Sep 10, 2019
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for running this down, this looks good to me.

@behlendorf behlendorf requested a review from tcaputi September 10, 2019 16:02
Copy link
Contributor

@tcaputi tcaputi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks right to me. I would want @wli5's opinion here if he has a minute, just to confirm that there isn't a deeper reason for the wait_for_completion_interruptible_timeout()

@@ -403,11 +403,7 @@ qat_compress_impl(qat_compress_dir_t dir, char *src, int src_len,
}

/* we now wait until the completion of the operation. */
if (!wait_for_completion_interruptible_timeout(&complete,
QAT_TIMEOUT_MS)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove QAT_TIMEOUT_MS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's done, thanks.

@cfzhu cfzhu requested a review from behlendorf September 11, 2019 05:06
@codecov
Copy link

codecov bot commented Sep 11, 2019

Codecov Report

Merging #9303 into master will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9303      +/-   ##
==========================================
- Coverage   79.14%    79.1%   -0.05%     
==========================================
  Files         401      401              
  Lines      122077   122063      -14     
==========================================
- Hits        96617    96557      -60     
- Misses      25460    25506      +46
Flag Coverage Δ
#kernel 79.72% <ø> (-0.04%) ⬇️
#user 66.64% <ø> (-0.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d666206...cf722c6. Read the comment docs.

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Just one small nit.

bcopy(op_data.pDigestResult, digest_buf, ZIO_DATA_MAC_LEN);
/* if dir is QAT_ENCRYPT, save pDigestResult to digest_buf */
if (dir == QAT_ENCRYPT)
bcopy(op_data.pDigestResult, digest_buf, ZIO_DATA_MAC_LEN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I missed this on my first read through, but it would be less redundant to move the bcopy in to the existing if (dir == QAT_ENCRYPT) just two lines down.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's done, thanks

1. Fix issue:  Kernel BUG with QAT during decompression  #9276.
   Now it is uninterruptible for a specific given QAT request,
   but Ctrl-C interrupt still works in user-space process.

2. Copy the digest result to the buffer only when doing encryption,
   and vise-versa for decryption.

Signed-off-by: Chengfei Zhu <[email protected]>
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Sep 12, 2019
@behlendorf behlendorf merged commit 7238cbd into openzfs:master Sep 12, 2019
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Sep 17, 2019
1. Fix issue:  Kernel BUG with QAT during decompression  openzfs#9276.
   Now it is uninterruptible for a specific given QAT request,
   but Ctrl-C interrupt still works in user-space process.

2. Copy the digest result to the buffer only when doing encryption,
   and vise-versa for decryption.

Reviewed-by: Tom Caputi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chengfei Zhu <[email protected]>
Closes openzfs#9276 
Closes openzfs#9303
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Sep 18, 2019
1. Fix issue:  Kernel BUG with QAT during decompression  openzfs#9276.
   Now it is uninterruptible for a specific given QAT request,
   but Ctrl-C interrupt still works in user-space process.

2. Copy the digest result to the buffer only when doing encryption,
   and vise-versa for decryption.

Reviewed-by: Tom Caputi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chengfei Zhu <[email protected]>
Closes openzfs#9276 
Closes openzfs#9303
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Sep 18, 2019
1. Fix issue:  Kernel BUG with QAT during decompression  openzfs#9276.
   Now it is uninterruptible for a specific given QAT request,
   but Ctrl-C interrupt still works in user-space process.

2. Copy the digest result to the buffer only when doing encryption,
   and vise-versa for decryption.

Reviewed-by: Tom Caputi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chengfei Zhu <[email protected]>
Closes openzfs#9276 
Closes openzfs#9303
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Sep 18, 2019
1. Fix issue:  Kernel BUG with QAT during decompression  openzfs#9276.
   Now it is uninterruptible for a specific given QAT request,
   but Ctrl-C interrupt still works in user-space process.

2. Copy the digest result to the buffer only when doing encryption,
   and vise-versa for decryption.

Reviewed-by: Tom Caputi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chengfei Zhu <[email protected]>
Closes openzfs#9276 
Closes openzfs#9303
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Sep 19, 2019
1. Fix issue:  Kernel BUG with QAT during decompression  openzfs#9276.
   Now it is uninterruptible for a specific given QAT request,
   but Ctrl-C interrupt still works in user-space process.

2. Copy the digest result to the buffer only when doing encryption,
   and vise-versa for decryption.

Reviewed-by: Tom Caputi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chengfei Zhu <[email protected]>
Closes openzfs#9276 
Closes openzfs#9303
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Sep 23, 2019
1. Fix issue:  Kernel BUG with QAT during decompression  openzfs#9276.
   Now it is uninterruptible for a specific given QAT request,
   but Ctrl-C interrupt still works in user-space process.

2. Copy the digest result to the buffer only when doing encryption,
   and vise-versa for decryption.

Reviewed-by: Tom Caputi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chengfei Zhu <[email protected]>
Closes openzfs#9276 
Closes openzfs#9303
tonyhutter pushed a commit that referenced this pull request Sep 26, 2019
1. Fix issue:  Kernel BUG with QAT during decompression  #9276.
   Now it is uninterruptible for a specific given QAT request,
   but Ctrl-C interrupt still works in user-space process.

2. Copy the digest result to the buffer only when doing encryption,
   and vise-versa for decryption.

Reviewed-by: Tom Caputi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chengfei Zhu <[email protected]>
Closes #9276
Closes #9303
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants