| 17175 | buffer was written, return the write length on success. */ |
| 17176 | |
| 17177 | int Client::ll_write_block(Inode *in, uint64_t blockid, |
| 17178 | char* buf, uint64_t offset, |
| 17179 | uint64_t length, file_layout_t* layout, |
| 17180 | uint64_t snapseq, uint32_t sync) |
| 17181 | { |
| 17182 | vinodeno_t vino = ll_get_vino(in); |
| 17183 | int r = 0; |
| 17184 | std::unique_ptr<C_SaferCond> onsafe = nullptr; |
| 17185 | |
| 17186 | RWRef_t mref_reader(mount_state, CLIENT_MOUNTING); |
| 17187 | if (!mref_reader.is_state_satisfied()) |
| 17188 | return -ENOTCONN; |
| 17189 | |
| 17190 | if (length == 0) { |
| 17191 | return -EINVAL; |
| 17192 | } |
| 17193 | if (true || sync) { |
| 17194 | /* if write is stable, the epilogue is waiting on |
| 17195 | * flock */ |
| 17196 | onsafe.reset(new C_SaferCond("Client::ll_write_block flock")); |
| 17197 | } |
| 17198 | object_t oid = file_object_t(vino.ino, blockid); |
| 17199 | SnapContext fakesnap; |
| 17200 | ceph::bufferlist bl; |
| 17201 | if (length > 0) { |
| 17202 | bl.push_back(buffer::copy(buf, length)); |
| 17203 | } |
| 17204 | |
| 17205 | ldout(cct, 1) << "ll_block_write for " << vino.ino << "." << blockid |
| 17206 | << dendl; |
| 17207 | |
| 17208 | fakesnap.seq = snapseq; |
| 17209 | |
| 17210 | /* lock just in time */ |
| 17211 | objecter->write(oid, |
| 17212 | object_locator_t(layout->pool_id), |
| 17213 | offset, |
| 17214 | length, |
| 17215 | fakesnap, |
| 17216 | bl, |
| 17217 | ceph::real_clock::now(), |
| 17218 | 0, |
| 17219 | onsafe.get()); |
| 17220 | |
| 17221 | if (nullptr != onsafe) { |
| 17222 | r = onsafe->wait(); |
| 17223 | } |
| 17224 | |
| 17225 | if (r < 0) { |
| 17226 | return r; |
| 17227 | } else { |
| 17228 | return length; |
| 17229 | } |
| 17230 | } |
| 17231 | |
| 17232 | int Client::ll_commit_blocks(Inode *in, |
| 17233 | uint64_t offset, |
no test coverage detected