| 10404 | } |
| 10405 | |
| 10406 | int Client::file_blockdiff(struct scan_state_t *state, const UserPerm &perms, |
| 10407 | std::vector<std::pair<uint64_t,uint64_t>> *blocks) |
| 10408 | { |
| 10409 | RWRef_t mref_reader(mount_state, CLIENT_MOUNTING); |
| 10410 | if (!mref_reader.is_state_satisfied()) { |
| 10411 | return -ENOTCONN; |
| 10412 | } |
| 10413 | |
| 10414 | ldout(cct, 20) << __func__ << dendl; |
| 10415 | |
| 10416 | InodeRef inode1; |
| 10417 | InodeRef inode2; |
| 10418 | |
| 10419 | std::unique_lock lock(client_lock); |
| 10420 | |
| 10421 | int r = get_fd_inode(state->fd1, &inode1); |
| 10422 | if (r < 0) { |
| 10423 | return r; |
| 10424 | } |
| 10425 | r = get_fd_inode(state->fd2, &inode2); |
| 10426 | if (r < 0) { |
| 10427 | return r; |
| 10428 | } |
| 10429 | |
| 10430 | ceph_assert(inode1->ino == inode2->ino); |
| 10431 | |
| 10432 | MetaRequest *req = new MetaRequest(CEPH_MDS_OP_FILE_BLOCKDIFF); |
| 10433 | |
| 10434 | filepath path1, path2; |
| 10435 | inode1->make_nosnap_relative_path(path1); |
| 10436 | req->set_filepath(path1); |
| 10437 | |
| 10438 | inode2->make_nosnap_relative_path(path2); |
| 10439 | req->set_filepath2(path2); |
| 10440 | req->set_inode(inode2.get()); |
| 10441 | |
| 10442 | req->head.args.blockdiff.scan_idx = state->index; |
| 10443 | req->head.args.blockdiff.max_objects = |
| 10444 | cct->_conf.get_val<uint64_t>("client_file_blockdiff_max_concurrent_object_scans"); |
| 10445 | |
| 10446 | bufferlist bl; |
| 10447 | r = make_request(req, perms, nullptr, nullptr, -1, &bl, CEPHFS_FEATURE_BLOCKDIFF); |
| 10448 | ldout(cct, 10) << __func__ << ": result=" << r << dendl; |
| 10449 | |
| 10450 | if (r < 0) { |
| 10451 | return r; |
| 10452 | } |
| 10453 | |
| 10454 | BlockDiff block_diff; |
| 10455 | auto p = bl.cbegin(); |
| 10456 | decode(block_diff, p); |
| 10457 | |
| 10458 | ldout(cct, 10) << __func__ << ": block_diff=" << block_diff << dendl; |
| 10459 | if (!block_diff.blocks.empty()) { |
| 10460 | for (auto &block : block_diff.blocks) { |
| 10461 | blocks->emplace_back(std::make_pair(block.first, block.second)); |
| 10462 | } |
| 10463 | } |
nothing calls this directly
no test coverage detected