fix unnecessarily slow writing of EMMC partitions
These were attempts to write partitions "conservatively" in hopes of fixing the problems with writing the radio partition on Nexus 4. They didn't work (a kernel patch was needed), but got left in. They make writing of partitions unnecessarily slow (ie, we really shouldn't need to sync() after every 4kb). Roll back most of them, but leave the verification read-back in. Change-Id: I94badc0979e88816c5aa0485f6316c02be69173c
This commit is contained in:
parent
c87bab1018
commit
168724c31a
1 changed files with 3 additions and 15 deletions
|
@ -424,20 +424,18 @@ int WriteToPartition(unsigned char* data, size_t len,
|
||||||
{
|
{
|
||||||
size_t start = 0;
|
size_t start = 0;
|
||||||
int success = 0;
|
int success = 0;
|
||||||
int fd = open(partition, O_RDWR | O_SYNC);
|
int fd = open(partition, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
printf("failed to open %s: %s\n", partition, strerror(errno));
|
printf("failed to open %s: %s\n", partition, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int attempt;
|
int attempt;
|
||||||
|
|
||||||
for (attempt = 0; attempt < 10; ++attempt) {
|
for (attempt = 0; attempt < 2; ++attempt) {
|
||||||
size_t next_sync = start + (1<<20);
|
|
||||||
printf("raw O_SYNC write %s attempt %d start at %d\n", partition, attempt+1, start);
|
|
||||||
lseek(fd, start, SEEK_SET);
|
lseek(fd, start, SEEK_SET);
|
||||||
while (start < len) {
|
while (start < len) {
|
||||||
size_t to_write = len - start;
|
size_t to_write = len - start;
|
||||||
if (to_write > 4096) to_write = 4096;
|
if (to_write > 1<<20) to_write = 1<<20;
|
||||||
|
|
||||||
ssize_t written = write(fd, data+start, to_write);
|
ssize_t written = write(fd, data+start, to_write);
|
||||||
if (written < 0) {
|
if (written < 0) {
|
||||||
|
@ -450,10 +448,6 @@ int WriteToPartition(unsigned char* data, size_t len,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start += written;
|
start += written;
|
||||||
if (start >= next_sync) {
|
|
||||||
fsync(fd);
|
|
||||||
next_sync = start + (1<<20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fsync(fd);
|
fsync(fd);
|
||||||
|
|
||||||
|
@ -506,8 +500,6 @@ int WriteToPartition(unsigned char* data, size_t len,
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
@ -519,11 +511,7 @@ int WriteToPartition(unsigned char* data, size_t len,
|
||||||
printf("error closing %s (%s)\n", partition, strerror(errno));
|
printf("error closing %s (%s)\n", partition, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// hack: sync and sleep after closing in hopes of getting
|
|
||||||
// the data actually onto flash.
|
|
||||||
printf("sleeping after close\n");
|
|
||||||
sync();
|
sync();
|
||||||
sleep(5);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue