| 2078 | } |
| 2079 | |
| 2080 | int SyntheticClient::write_fd(int fd, int size, int wrsize) // size is in MB, wrsize in bytes |
| 2081 | { |
| 2082 | //uint64_t wrsize = 1024*256; |
| 2083 | char *buf = new char[wrsize+100]; // 1 MB |
| 2084 | memset(buf, 7, wrsize); |
| 2085 | uint64_t chunks = (uint64_t)size * (uint64_t)(1024*1024) / (uint64_t)wrsize; |
| 2086 | |
| 2087 | //dout(5) << "SyntheticClient::write_fd: writing to fd " << fd << dendl; |
| 2088 | if (fd < 0) { |
| 2089 | delete[] buf; |
| 2090 | return fd; |
| 2091 | } |
| 2092 | |
| 2093 | for (unsigned i=0; i<chunks; i++) { |
| 2094 | if (time_to_stop()) { |
| 2095 | dout(0) << "stopping" << dendl; |
| 2096 | break; |
| 2097 | } |
| 2098 | dout(2) << "writing block " << i << "/" << chunks << dendl; |
| 2099 | |
| 2100 | // fill buf with a 16 byte fingerprint |
| 2101 | // 64 bits : file offset |
| 2102 | // 64 bits : client id |
| 2103 | // = 128 bits (16 bytes) |
| 2104 | uint64_t *p = (uint64_t*)buf; |
| 2105 | while ((char*)p < buf + wrsize) { |
| 2106 | *p = (uint64_t)i*(uint64_t)wrsize + (uint64_t)((char*)p - buf); |
| 2107 | p++; |
| 2108 | *p = client->get_nodeid().v; |
| 2109 | p++; |
| 2110 | } |
| 2111 | |
| 2112 | client->write(fd, buf, wrsize, i*wrsize); |
| 2113 | } |
| 2114 | client->close(fd); |
| 2115 | delete[] buf; |
| 2116 | |
| 2117 | return 0; |
| 2118 | } |
| 2119 | |
| 2120 | |
| 2121 | int SyntheticClient::write_batch(int nfile, int size, int wrsize) |
nothing calls this directly
no test coverage detected