| 1141 | } |
| 1142 | |
| 1143 | int KernelDevice::aio_write( |
| 1144 | uint64_t off, |
| 1145 | bufferlist &bl, |
| 1146 | IOContext *ioc, |
| 1147 | bool buffered, |
| 1148 | int write_hint) |
| 1149 | { |
| 1150 | uint64_t len = bl.length(); |
| 1151 | dout(20) << __func__ << " 0x" << std::hex << off << "~" << len << std::dec |
| 1152 | << " " << buffermode(buffered) |
| 1153 | << dendl; |
| 1154 | ceph_assert(is_valid_io(off, len)); |
| 1155 | if (cct->_conf->objectstore_blackhole) { |
| 1156 | lderr(cct) << __func__ << " objectstore_blackhole=true, throwing out IO" |
| 1157 | << dendl; |
| 1158 | return 0; |
| 1159 | } |
| 1160 | |
| 1161 | if ((!buffered || bl.get_num_buffers() >= IOV_MAX) && |
| 1162 | bl.rebuild_aligned_size_and_memory(block_size, block_size, IOV_MAX)) { |
| 1163 | dout(20) << __func__ << " rebuilding buffer to be aligned" << dendl; |
| 1164 | } |
| 1165 | dout(40) << "data:\n"; |
| 1166 | bl.hexdump(*_dout); |
| 1167 | *_dout << dendl; |
| 1168 | |
| 1169 | _aio_log_start(ioc, off, len); |
| 1170 | |
| 1171 | #ifdef HAVE_LIBAIO |
| 1172 | if (aio && dio && !buffered) { |
| 1173 | if (cct->_conf->bdev_inject_crash && |
| 1174 | rand() % cct->_conf->bdev_inject_crash == 0) { |
| 1175 | derr << __func__ << " bdev_inject_crash: dropping io 0x" << std::hex |
| 1176 | << off << "~" << len << std::dec |
| 1177 | << dendl; |
| 1178 | // generate a real io so that aio_wait behaves properly, but make it |
| 1179 | // a read instead of write, and toss the result. |
| 1180 | ioc->pending_aios.push_back(aio_t(ioc, choose_fd(false, write_hint))); |
| 1181 | ++ioc->num_pending; |
| 1182 | auto& aio = ioc->pending_aios.back(); |
| 1183 | aio.bl.push_back( |
| 1184 | ceph::buffer::ptr_node::create(ceph::buffer::create_small_page_aligned(len))); |
| 1185 | aio.bl.prepare_iov(&aio.iov); |
| 1186 | aio.preadv(off, len); |
| 1187 | ++injecting_crash; |
| 1188 | } else { |
| 1189 | if (bl.length() <= RW_IO_MAX) { |
| 1190 | // fast path (non-huge write) |
| 1191 | ioc->pending_aios.push_back(aio_t(ioc, choose_fd(false, write_hint))); |
| 1192 | ++ioc->num_pending; |
| 1193 | auto& aio = ioc->pending_aios.back(); |
| 1194 | bl.prepare_iov(&aio.iov); |
| 1195 | aio.bl.claim_append(bl); |
| 1196 | aio.pwritev(off, len); |
| 1197 | dout(30) << aio << dendl; |
| 1198 | dout(5) << __func__ << " 0x" << std::hex << off << "~" << len |
| 1199 | << std::dec << " aio " << &aio << dendl; |
| 1200 | } else { |
nothing calls this directly
no test coverage detected