Skip to content

Commit

Permalink
walleye: gpt-utils: fsync after block device writes
Browse files Browse the repository at this point in the history
When markBoolSuccessful is invoked, we update
the partition table. These writes should be
synced before merge operation is resumed post OTA.
If not, any crash before these writes are landed to
backing storage will lead to incorrect switching of
slots.

BUG: 175711601
Test: Verify slot switching correctly after crash when merge in progress
(on redbull)
Signed-off-by: Akilesh Kailash <[email protected]>
Change-Id: I4d30342b44aaeb7a4fdc915cc1e53ffb20c17a2f
  • Loading branch information
Akilesh Kailash authored and PixelBoot committed Feb 18, 2024
1 parent 5cb5cf4 commit a73f33f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions gpt-utils/gpt-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,18 @@ static int blk_rw(int fd, int rw, int64_t offset, uint8_t *buf, unsigned len)
else
r = read(fd, buf, len);

if (r < 0)
if (r < 0) {
fprintf(stderr, "block dev %s failed: %s\n", rw ? "write" : "read",
strerror(errno));
else
r = 0;
} else {
if (rw) {
r = fsync(fd);
if (r < 0)
fprintf(stderr, "fsync failed: %s\n", strerror(errno));
} else {
r = 0;
}
}

return r;
}
Expand Down

0 comments on commit a73f33f

Please sign in to comment.