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

[ZoL#22] Implement DKIOCFLUSHWRITECACHE vdev ioctl command #3

Merged
merged 1 commit into from
Mar 7, 2018

Conversation

jkryl
Copy link

@jkryl jkryl commented Mar 1, 2018

As noted in the code, this flush command works only for SCSI drives controlled by sd driver and regarding synchronicity of flush command, I tested performance with synchronous and asynchronous (using taskq) flush and with sync workloads the performance penalty is 25% when using async and only 15% when using sync. So we will be calling flush synchronously in zio pipeline. So just to highlight it, for drives which support SCSI SYNCHRONIZE CACHE command we sacrifice 15% of performance for sync workloads, but that is understandable as we have more work to do in such case.

@jkryl jkryl requested review from payes, gila and vishnuitta March 1, 2018 08:59
if (errno == EINVAL || errno == ENOTTY) {
fprintf(stderr, "Disk %s does not support synchronize "
"cache SCSI command\n", vd->vdev_path);
vda->vda_noflush = B_TRUE;
Copy link

Choose a reason for hiding this comment

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

Can dump the sense data in case of failure? Depending on the failed mode -- we might as well disable flushing altogether for this device for future IOs?

Copy link
Author

Choose a reason for hiding this comment

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

I try to distinguish between two cases:

  1. cache flush not possible
    * this is either EINVAL if SG_IO is not supported at all (i.e. lofi device)
    * or ENOTTY if SG_IO is understood nevertheless cache synchronize command not implemented
  2. transient error (all other cases)

For case number 1 we never attempt to flush again in the future (stop losing time). For case number 2 we return error for that particular zio, but cache flushing remains enabled.

Regarding printing sense data, there is a bug in current fix as I need to distinguish between failed ioctl and failed SCSI command. For failed SCSI command we could print the sense data to stderr. I would prefer to print it raw (in hex), the routine for decoding sense data would be pretty long (example: https://fossies.org/dox/sg3_utils-1.42/sg__lib_8c_source.html#l01412) . So everytime when ioctl succeeds but SCSI cmd fails we will print an error to stderr. I just hope it won't happen too frequently :-)

Let me know if you agree with the proposal above. thanks

Copy link

@vishnuitta vishnuitta left a comment

Choose a reason for hiding this comment

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

changes looks good. Better to add a testcase @jkryl

@jkryl
Copy link
Author

jkryl commented Mar 1, 2018

Hi @vishnuitta , I don't want to look that I always have some excuse for writing tests, but it is rather complicated in this case :) Higher level code will never know that a flush has failed with the test disks which we are using. Flush is not supported for them, thus flush is noop and not reported to higher level code. and we don't have real SCSI devices in automated tests and even if we had, I would not be able to simulate transient failures on them which is the only case when zio actually fails. I fear we have to trust the manual testing I have done and hope it will not break in future.

@jkryl jkryl force-pushed the disk-flush branch 2 times, most recently from c47c918 to e29765e Compare March 2, 2018 08:40
@vishnuitta
Copy link

vishnuitta commented Mar 2, 2018

does this have dependency on the kernel or other libraries @jkryl ?

@jkryl
Copy link
Author

jkryl commented Mar 2, 2018

@vishnuitta: talking only about the code I have added, the only dependency is on sgio header file which contains definitions needed for SG_IO ioctl to kernel. SG_IO ioctl has been standard part of linux kernel for a long time. So we don't depend on anything unusual.

@vishnuitta
Copy link

Changes looks good @jkryl
I'm thinking whether we should create a documentation issue saying that flushing write cache is supported for drives through sd device driver, and anything else need to have write cache disabled. What do you suggest @jkryl @gila @satbirchhikara ?

Copy link

@vishnuitta vishnuitta left a comment

Choose a reason for hiding this comment

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

changes are good

@@ -404,6 +408,95 @@ kick_submitter(vdev_disk_aio_t *vda)
assert(rc == sizeof (data));
}

#define SCSI_STATUS_GOOD 0
#define SCSI_STATUS_CHECK_COND 2

Choose a reason for hiding this comment

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

should we get these constants from some standard header files?

Choose a reason for hiding this comment

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

any standard header files with these constants @jkryl ?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks Vitta! I found most of them defined in scsi/scsi.h linux header file. Only two defines remained and those have been moved to the beginning of the file to usual place.

@jkryl jkryl force-pushed the disk-flush branch 3 times, most recently from 71547a6 to 5b98569 Compare March 5, 2018 16:46
@jkryl
Copy link
Author

jkryl commented Mar 7, 2018

The ticket for documentation issue has been created (zenhub ticket #46). In addition to that I have mentioned it in README file.

@jkryl jkryl merged commit 925775b into zfs-0.7-release Mar 7, 2018
@jkryl jkryl deleted the disk-flush branch March 7, 2018 08:55
jkryl pushed a commit that referenced this pull request Jun 26, 2018
 CCS-54 google test framework for uZFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants