Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b02ed52 authored by Stephen Crane's avatar Stephen Crane
Browse files

storageproxy: Support POST_COMMIT sync for all commands

Previously we did not support STORAGE_MSG_FLAG_POST_COMMIT for anything
but RPMB operations (in which case it was a no-op). We need to support
this flag in order to store a superblock in non-secure storage, as we
need that write to commit atomically wrt all other writes.

Test: com.android.storage-unittest.nsp
Bug: 228793975
Change-Id: Ia453c1916970e0b65a91e42f18b920ac4e1f01db
Merged-In: Ia453c1916970e0b65a91e42f18b920ac4e1f01db
(cherry picked from commit 57770a53)
parent c134d822
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -116,10 +116,11 @@ static int drop_privs(void) {
static int handle_req(struct storage_msg* msg, const void* req, size_t req_len) {
static int handle_req(struct storage_msg* msg, const void* req, size_t req_len) {
    int rc;
    int rc;


    if ((msg->flags & STORAGE_MSG_FLAG_POST_COMMIT) && (msg->cmd != STORAGE_RPMB_SEND)) {
    if ((msg->flags & STORAGE_MSG_FLAG_POST_COMMIT) && msg->cmd != STORAGE_RPMB_SEND &&
        msg->cmd != STORAGE_FILE_WRITE) {
        /*
        /*
         * handling post commit messages on non rpmb commands are not
         * handling post commit messages on commands other than rpmb and write
         * implemented as there is no use case for this yet.
         * operations are not implemented as there is no use case for this yet.
         */
         */
        ALOGE("cmd 0x%x: post commit option is not implemented\n", msg->cmd);
        ALOGE("cmd 0x%x: post commit option is not implemented\n", msg->cmd);
        msg->result = STORAGE_ERR_UNIMPLEMENTED;
        msg->result = STORAGE_ERR_UNIMPLEMENTED;
+8 −0
Original line number Original line Diff line number Diff line
@@ -407,6 +407,14 @@ int storage_file_write(struct storage_msg *msg,
        goto err_response;
        goto err_response;
    }
    }


    if (msg->flags & STORAGE_MSG_FLAG_POST_COMMIT) {
        rc = storage_sync_checkpoint();
        if (rc < 0) {
            msg->result = STORAGE_ERR_GENERIC;
            goto err_response;
        }
    }

    msg->result = STORAGE_NO_ERROR;
    msg->result = STORAGE_NO_ERROR;


err_response:
err_response: