| 18244 | }; |
| 18245 | |
| 18246 | int Client::check_pool_perm(Inode *in, int need) |
| 18247 | { |
| 18248 | ceph_assert(ceph_mutex_is_locked_by_me(client_lock)); |
| 18249 | |
| 18250 | if (!cct->_conf->client_check_pool_perm) |
| 18251 | return 0; |
| 18252 | |
| 18253 | /* Only need to do this for regular files */ |
| 18254 | if (!in->is_file()) |
| 18255 | return 0; |
| 18256 | |
| 18257 | int64_t pool_id = in->layout.pool_id; |
| 18258 | std::string pool_ns = in->layout.pool_ns; |
| 18259 | std::pair<int64_t, std::string> perm_key(pool_id, pool_ns); |
| 18260 | int have = 0; |
| 18261 | while (true) { |
| 18262 | auto it = pool_perms.find(perm_key); |
| 18263 | if (it == pool_perms.end()) |
| 18264 | break; |
| 18265 | if (it->second == POOL_CHECKING) { |
| 18266 | // avoid concurrent checkings |
| 18267 | wait_on_list(waiting_for_pool_perm); |
| 18268 | } else { |
| 18269 | have = it->second; |
| 18270 | ceph_assert(have & POOL_CHECKED); |
| 18271 | break; |
| 18272 | } |
| 18273 | } |
| 18274 | |
| 18275 | if (!have) { |
| 18276 | if (in->snapid != CEPH_NOSNAP) { |
| 18277 | // pool permission check needs to write to the first object. But for snapshot, |
| 18278 | // head of the first object may have already been deleted. To avoid creating |
| 18279 | // orphan object, skip the check for now. |
| 18280 | return 0; |
| 18281 | } |
| 18282 | |
| 18283 | pool_perms[perm_key] = POOL_CHECKING; |
| 18284 | |
| 18285 | char oid_buf[32]; |
| 18286 | snprintf(oid_buf, sizeof(oid_buf), "%llx.00000000", (unsigned long long)in->ino); |
| 18287 | object_t oid = oid_buf; |
| 18288 | |
| 18289 | SnapContext nullsnapc; |
| 18290 | |
| 18291 | C_SaferCond rd_cond; |
| 18292 | ObjectOperation rd_op; |
| 18293 | rd_op.stat(nullptr, nullptr, nullptr); |
| 18294 | |
| 18295 | objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), rd_op, |
| 18296 | nullsnapc, ceph::real_clock::now(), 0, &rd_cond); |
| 18297 | |
| 18298 | C_SaferCond wr_cond; |
| 18299 | ObjectOperation wr_op; |
| 18300 | wr_op.create(true); |
| 18301 | |
| 18302 | objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), wr_op, |
| 18303 | nullsnapc, ceph::real_clock::now(), 0, &wr_cond); |
nothing calls this directly
no test coverage detected