diff options
author | Jack Hou <jackhou@chromium.org> | 2014-09-30 12:38:58 +1000 |
---|---|---|
committer | Jack Hou <jackhou@chromium.org> | 2014-09-30 02:40:24 +0000 |
commit | 6b3de5bd8492336d53d8317e43caa00377ce19e4 (patch) | |
tree | f5645e16a0be9458f45675d772aa1cef3b8d7cd5 | |
parent | 35e6e57ebb807eb83568b99a7042940dbd5cc703 (diff) | |
download | chromium_src-6b3de5bd8492336d53d8317e43caa00377ce19e4.zip chromium_src-6b3de5bd8492336d53d8317e43caa00377ce19e4.tar.gz chromium_src-6b3de5bd8492336d53d8317e43caa00377ce19e4.tar.bz2 |
[Mac] Use raw disks (/dev/rdisk#) in image_writer_mac.
For some USB drives, writes on Mac are much slower than using the old image
creator. This is most likely because the implementation in Chrome uses
/dev/disk# whereas the old implementation used /dev/rdisk# whenever
possible.
The main requirement is that writes are in multiples of the block size, but
since ImageWriter::WriteChunk always writes in multiples of
kMemoryAlignment (4096), it should be fine to always use the raw disk.
My brief tests using a Lexar JumpDrive 16GB and a 1.6GB image:
before: ~6.5 minutes to write, same to verify
after: ~5 minutes to write, ~1.5 minutes to verify
BUG=415891
Review URL: https://codereview.chromium.org/599853002
Cr-Commit-Position: refs/heads/master@{#296875}
(cherry picked from commit e06a8c6b35efd534d911d9d6382daf5e8986a1d1)
TBR=miket@chromium.org
Review URL: https://codereview.chromium.org/613923002
Cr-Commit-Position: refs/branch-heads/2125@{#529}
Cr-Branched-From: b68026d94bda36dd106a3d91a098719f952a9477-refs/heads/master@{#290040}
-rw-r--r-- | chrome/utility/image_writer/image_writer.cc | 1 | ||||
-rw-r--r-- | chrome/utility/image_writer/image_writer_mac.cc | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/chrome/utility/image_writer/image_writer.cc b/chrome/utility/image_writer/image_writer.cc index 65994db..2a2b8a1 100644 --- a/chrome/utility/image_writer/image_writer.cc +++ b/chrome/utility/image_writer/image_writer.cc @@ -125,6 +125,7 @@ void ImageWriter::WriteChunk() { // aligned writes to devices. int bytes_to_write = bytes_read + (kMemoryAlignment - 1) - (bytes_read - 1) % kMemoryAlignment; + DCHECK_EQ(0, bytes_to_write % kMemoryAlignment); int bytes_written = device_file_.Write(bytes_processed_, buffer.get(), bytes_to_write); diff --git a/chrome/utility/image_writer/image_writer_mac.cc b/chrome/utility/image_writer/image_writer_mac.cc index c572d14..8eb4d31 100644 --- a/chrome/utility/image_writer/image_writer_mac.cc +++ b/chrome/utility/image_writer/image_writer_mac.cc @@ -95,9 +95,15 @@ bool ImageWriter::OpenDevice() { // Find the file path to open. base::FilePath real_device_path; if (device_path_.IsAbsolute()) { + // This only occurs for tests where the device path is mocked with a + // temporary file. real_device_path = device_path_; } else { - real_device_path = base::FilePath("/dev").Append(device_path_); + // Get the raw device file. Writes need to be in multiples of + // DAMediaBlockSize (usually 512). This is fine since WriteChunk() writes in + // multiples of kMemoryAlignment. + real_device_path = + base::FilePath("/dev").Append("r" + device_path_.BaseName().value()); } // Build the command line. |