Loading fs_mgr/libsnapshot/include/libsnapshot/snapuserd.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -65,7 +65,7 @@ class Snapuserd final { backing_store_device_(in_backing_store_device), backing_store_device_(in_backing_store_device), metadata_read_done_(false) {} metadata_read_done_(false) {} int Init(); bool Init(); int Run(); int Run(); int ReadDmUserHeader(); int ReadDmUserHeader(); int WriteDmUserPayload(size_t size); int WriteDmUserPayload(size_t size); Loading fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h +0 −14 Original line number Original line Diff line number Diff line Loading @@ -14,22 +14,8 @@ #pragma once #pragma once #include <arpa/inet.h> #include <cutils/sockets.h> #include <errno.h> #include <netdb.h> #include <netinet/in.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #include <chrono> #include <cstring> #include <cstring> #include <iostream> #include <iostream> #include <sstream> #include <string> #include <string> #include <thread> #include <thread> #include <vector> #include <vector> Loading fs_mgr/libsnapshot/include/libsnapshot/snapuserd_daemon.h +7 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,8 @@ #pragma once #pragma once #include <poll.h> #include <libsnapshot/snapuserd_server.h> #include <libsnapshot/snapuserd_server.h> namespace android { namespace android { Loading @@ -34,12 +36,17 @@ class Daemon { private: private: bool is_running_; bool is_running_; std::unique_ptr<struct pollfd> poll_fd_; // Signal mask used with ppoll() sigset_t signal_mask_; Daemon(); Daemon(); Daemon(Daemon const&) = delete; Daemon(Daemon const&) = delete; void operator=(Daemon const&) = delete; void operator=(Daemon const&) = delete; SnapuserdServer server_; SnapuserdServer server_; void MaskAllSignalsExceptIntAndTerm(); void MaskAllSignals(); static void SignalHandler(int signal); static void SignalHandler(int signal); }; }; Loading fs_mgr/libsnapshot/include/libsnapshot/snapuserd_server.h +2 −14 Original line number Original line Diff line number Diff line Loading @@ -14,18 +14,6 @@ #pragma once #pragma once #include <stdint.h> #include <arpa/inet.h> #include <cutils/sockets.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #include <errno.h> #include <cstdio> #include <cstdio> #include <cstring> #include <cstring> #include <functional> #include <functional> Loading Loading @@ -89,6 +77,7 @@ class SnapuserdServer : public Stoppable { android::base::unique_fd sockfd_; android::base::unique_fd sockfd_; bool terminating_; bool terminating_; std::vector<std::unique_ptr<Client>> clients_vec_; std::vector<std::unique_ptr<Client>> clients_vec_; void ThreadStart(std::string cow_device, std::string backing_device) override; void ThreadStart(std::string cow_device, std::string backing_device) override; void ShutdownThreads(); void ShutdownThreads(); DaemonOperations Resolveop(std::string& input); DaemonOperations Resolveop(std::string& input); Loading @@ -100,8 +89,6 @@ class SnapuserdServer : public Stoppable { bool IsTerminating() { return terminating_; } bool IsTerminating() { return terminating_; } public: public: ~SnapuserdServer() { clients_vec_.clear(); } SnapuserdServer() { terminating_ = false; } SnapuserdServer() { terminating_ = false; } int Start(std::string socketname); int Start(std::string socketname); Loading @@ -109,6 +96,7 @@ class SnapuserdServer : public Stoppable { int Receivemsg(int fd); int Receivemsg(int fd); int Sendmsg(int fd, char* msg, size_t len); int Sendmsg(int fd, char* msg, size_t len); std::string Recvmsg(int fd, int* ret); std::string Recvmsg(int fd, int* ret); android::base::borrowed_fd GetSocketFd() { return sockfd_; } }; }; } // namespace snapshot } // namespace snapshot Loading fs_mgr/libsnapshot/snapuserd.cpp +12 −7 Original line number Original line Diff line number Diff line Loading @@ -485,17 +485,17 @@ int Snapuserd::WriteDmUserPayload(size_t size) { return sizeof(struct dm_user_header) + size; return sizeof(struct dm_user_header) + size; } } int Snapuserd::Init() { bool Snapuserd::Init() { backing_store_fd_.reset(open(backing_store_device_.c_str(), O_RDONLY)); backing_store_fd_.reset(open(backing_store_device_.c_str(), O_RDONLY)); if (backing_store_fd_ < 0) { if (backing_store_fd_ < 0) { LOG(ERROR) << "Open Failed: " << backing_store_device_; LOG(ERROR) << "Open Failed: " << backing_store_device_; return 1; return false; } } cow_fd_.reset(open(cow_device_.c_str(), O_RDWR)); cow_fd_.reset(open(cow_device_.c_str(), O_RDWR)); if (cow_fd_ < 0) { if (cow_fd_ < 0) { LOG(ERROR) << "Open Failed: " << cow_device_; LOG(ERROR) << "Open Failed: " << cow_device_; return 1; return false; } } std::string str(cow_device_); std::string str(cow_device_); Loading @@ -509,7 +509,7 @@ int Snapuserd::Init() { std::string uuid; std::string uuid; if (!dm.GetDmDeviceUuidByName(device_name, &uuid)) { if (!dm.GetDmDeviceUuidByName(device_name, &uuid)) { LOG(ERROR) << "Unable to find UUID for " << cow_device_; LOG(ERROR) << "Unable to find UUID for " << cow_device_; return 1; return false; } } LOG(DEBUG) << "UUID: " << uuid; LOG(DEBUG) << "UUID: " << uuid; Loading @@ -518,7 +518,7 @@ int Snapuserd::Init() { ctrl_fd_.reset(open(t.control_path().c_str(), O_RDWR)); ctrl_fd_.reset(open(t.control_path().c_str(), O_RDWR)); if (ctrl_fd_ < 0) { if (ctrl_fd_ < 0) { LOG(ERROR) << "Unable to open " << t.control_path(); LOG(ERROR) << "Unable to open " << t.control_path(); return 1; return false; } } // Allocate the buffer which is used to communicate between // Allocate the buffer which is used to communicate between Loading @@ -528,7 +528,7 @@ int Snapuserd::Init() { size_t buf_size = sizeof(struct dm_user_header) + PAYLOAD_SIZE; size_t buf_size = sizeof(struct dm_user_header) + PAYLOAD_SIZE; bufsink_.Initialize(buf_size); bufsink_.Initialize(buf_size); return 0; return true; } } int Snapuserd::Run() { int Snapuserd::Run() { Loading Loading @@ -601,6 +601,11 @@ int Snapuserd::Run() { ret = ReadData(chunk + num_chunks_read, read_size); ret = ReadData(chunk + num_chunks_read, read_size); if (ret < 0) { if (ret < 0) { LOG(ERROR) << "ReadData failed"; LOG(ERROR) << "ReadData failed"; // TODO: Bug 168259959: All the error paths from this function // should send error code to dm-user thereby IO // terminates with an error from dm-user. Returning // here without sending error code will block the // IO. return ret; return ret; } } } } Loading @@ -622,7 +627,7 @@ int Snapuserd::Run() { } } case DM_USER_MAP_WRITE: { case DM_USER_MAP_WRITE: { // TODO: After merge operation is completed, kernel issues write // TODO: Bug: 168311203: After merge operation is completed, kernel issues write // to flush all the exception mappings where the merge is // to flush all the exception mappings where the merge is // completed. If dm-user routes the WRITE IO, we need to clear // completed. If dm-user routes the WRITE IO, we need to clear // in-memory data structures representing those exception // in-memory data structures representing those exception Loading Loading
fs_mgr/libsnapshot/include/libsnapshot/snapuserd.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -65,7 +65,7 @@ class Snapuserd final { backing_store_device_(in_backing_store_device), backing_store_device_(in_backing_store_device), metadata_read_done_(false) {} metadata_read_done_(false) {} int Init(); bool Init(); int Run(); int Run(); int ReadDmUserHeader(); int ReadDmUserHeader(); int WriteDmUserPayload(size_t size); int WriteDmUserPayload(size_t size); Loading
fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h +0 −14 Original line number Original line Diff line number Diff line Loading @@ -14,22 +14,8 @@ #pragma once #pragma once #include <arpa/inet.h> #include <cutils/sockets.h> #include <errno.h> #include <netdb.h> #include <netinet/in.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #include <chrono> #include <cstring> #include <cstring> #include <iostream> #include <iostream> #include <sstream> #include <string> #include <string> #include <thread> #include <thread> #include <vector> #include <vector> Loading
fs_mgr/libsnapshot/include/libsnapshot/snapuserd_daemon.h +7 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,8 @@ #pragma once #pragma once #include <poll.h> #include <libsnapshot/snapuserd_server.h> #include <libsnapshot/snapuserd_server.h> namespace android { namespace android { Loading @@ -34,12 +36,17 @@ class Daemon { private: private: bool is_running_; bool is_running_; std::unique_ptr<struct pollfd> poll_fd_; // Signal mask used with ppoll() sigset_t signal_mask_; Daemon(); Daemon(); Daemon(Daemon const&) = delete; Daemon(Daemon const&) = delete; void operator=(Daemon const&) = delete; void operator=(Daemon const&) = delete; SnapuserdServer server_; SnapuserdServer server_; void MaskAllSignalsExceptIntAndTerm(); void MaskAllSignals(); static void SignalHandler(int signal); static void SignalHandler(int signal); }; }; Loading
fs_mgr/libsnapshot/include/libsnapshot/snapuserd_server.h +2 −14 Original line number Original line Diff line number Diff line Loading @@ -14,18 +14,6 @@ #pragma once #pragma once #include <stdint.h> #include <arpa/inet.h> #include <cutils/sockets.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #include <errno.h> #include <cstdio> #include <cstdio> #include <cstring> #include <cstring> #include <functional> #include <functional> Loading Loading @@ -89,6 +77,7 @@ class SnapuserdServer : public Stoppable { android::base::unique_fd sockfd_; android::base::unique_fd sockfd_; bool terminating_; bool terminating_; std::vector<std::unique_ptr<Client>> clients_vec_; std::vector<std::unique_ptr<Client>> clients_vec_; void ThreadStart(std::string cow_device, std::string backing_device) override; void ThreadStart(std::string cow_device, std::string backing_device) override; void ShutdownThreads(); void ShutdownThreads(); DaemonOperations Resolveop(std::string& input); DaemonOperations Resolveop(std::string& input); Loading @@ -100,8 +89,6 @@ class SnapuserdServer : public Stoppable { bool IsTerminating() { return terminating_; } bool IsTerminating() { return terminating_; } public: public: ~SnapuserdServer() { clients_vec_.clear(); } SnapuserdServer() { terminating_ = false; } SnapuserdServer() { terminating_ = false; } int Start(std::string socketname); int Start(std::string socketname); Loading @@ -109,6 +96,7 @@ class SnapuserdServer : public Stoppable { int Receivemsg(int fd); int Receivemsg(int fd); int Sendmsg(int fd, char* msg, size_t len); int Sendmsg(int fd, char* msg, size_t len); std::string Recvmsg(int fd, int* ret); std::string Recvmsg(int fd, int* ret); android::base::borrowed_fd GetSocketFd() { return sockfd_; } }; }; } // namespace snapshot } // namespace snapshot Loading
fs_mgr/libsnapshot/snapuserd.cpp +12 −7 Original line number Original line Diff line number Diff line Loading @@ -485,17 +485,17 @@ int Snapuserd::WriteDmUserPayload(size_t size) { return sizeof(struct dm_user_header) + size; return sizeof(struct dm_user_header) + size; } } int Snapuserd::Init() { bool Snapuserd::Init() { backing_store_fd_.reset(open(backing_store_device_.c_str(), O_RDONLY)); backing_store_fd_.reset(open(backing_store_device_.c_str(), O_RDONLY)); if (backing_store_fd_ < 0) { if (backing_store_fd_ < 0) { LOG(ERROR) << "Open Failed: " << backing_store_device_; LOG(ERROR) << "Open Failed: " << backing_store_device_; return 1; return false; } } cow_fd_.reset(open(cow_device_.c_str(), O_RDWR)); cow_fd_.reset(open(cow_device_.c_str(), O_RDWR)); if (cow_fd_ < 0) { if (cow_fd_ < 0) { LOG(ERROR) << "Open Failed: " << cow_device_; LOG(ERROR) << "Open Failed: " << cow_device_; return 1; return false; } } std::string str(cow_device_); std::string str(cow_device_); Loading @@ -509,7 +509,7 @@ int Snapuserd::Init() { std::string uuid; std::string uuid; if (!dm.GetDmDeviceUuidByName(device_name, &uuid)) { if (!dm.GetDmDeviceUuidByName(device_name, &uuid)) { LOG(ERROR) << "Unable to find UUID for " << cow_device_; LOG(ERROR) << "Unable to find UUID for " << cow_device_; return 1; return false; } } LOG(DEBUG) << "UUID: " << uuid; LOG(DEBUG) << "UUID: " << uuid; Loading @@ -518,7 +518,7 @@ int Snapuserd::Init() { ctrl_fd_.reset(open(t.control_path().c_str(), O_RDWR)); ctrl_fd_.reset(open(t.control_path().c_str(), O_RDWR)); if (ctrl_fd_ < 0) { if (ctrl_fd_ < 0) { LOG(ERROR) << "Unable to open " << t.control_path(); LOG(ERROR) << "Unable to open " << t.control_path(); return 1; return false; } } // Allocate the buffer which is used to communicate between // Allocate the buffer which is used to communicate between Loading @@ -528,7 +528,7 @@ int Snapuserd::Init() { size_t buf_size = sizeof(struct dm_user_header) + PAYLOAD_SIZE; size_t buf_size = sizeof(struct dm_user_header) + PAYLOAD_SIZE; bufsink_.Initialize(buf_size); bufsink_.Initialize(buf_size); return 0; return true; } } int Snapuserd::Run() { int Snapuserd::Run() { Loading Loading @@ -601,6 +601,11 @@ int Snapuserd::Run() { ret = ReadData(chunk + num_chunks_read, read_size); ret = ReadData(chunk + num_chunks_read, read_size); if (ret < 0) { if (ret < 0) { LOG(ERROR) << "ReadData failed"; LOG(ERROR) << "ReadData failed"; // TODO: Bug 168259959: All the error paths from this function // should send error code to dm-user thereby IO // terminates with an error from dm-user. Returning // here without sending error code will block the // IO. return ret; return ret; } } } } Loading @@ -622,7 +627,7 @@ int Snapuserd::Run() { } } case DM_USER_MAP_WRITE: { case DM_USER_MAP_WRITE: { // TODO: After merge operation is completed, kernel issues write // TODO: Bug: 168311203: After merge operation is completed, kernel issues write // to flush all the exception mappings where the merge is // to flush all the exception mappings where the merge is // completed. If dm-user routes the WRITE IO, we need to clear // completed. If dm-user routes the WRITE IO, we need to clear // in-memory data structures representing those exception // in-memory data structures representing those exception Loading