| 512 | } |
| 513 | |
| 514 | int FSCryptKeyStore::invalidate(struct fscrypt_remove_key_arg* arg, int user) |
| 515 | { |
| 516 | std::unique_lock rl{lock}; |
| 517 | |
| 518 | ceph_fscrypt_key_identifier id; |
| 519 | int r = id.init(arg->key_spec); |
| 520 | if (r < 0) { |
| 521 | return r; |
| 522 | } |
| 523 | |
| 524 | FSCryptKeyHandlerRef kh; |
| 525 | r = _find(id, kh); |
| 526 | if (r < 0) { |
| 527 | return r; |
| 528 | } |
| 529 | |
| 530 | auto& users = kh->get_users(); |
| 531 | r = maybe_remove_user(arg, &users, user); |
| 532 | if (r == -EUSERS) { |
| 533 | r = 0; |
| 534 | goto out; |
| 535 | } |
| 536 | |
| 537 | kh->present = false; |
| 538 | |
| 539 | //do a final clean up |
| 540 | if (!kh->present && kh->di->get_inodes().empty()) { |
| 541 | kh->reset(++epoch, nullptr); |
| 542 | m.erase(id); |
| 543 | } else { |
| 544 | r = 0; |
| 545 | arg->removal_status_flags |= FSCRYPT_KEY_REMOVAL_STATUS_FLAG_FILES_BUSY; |
| 546 | } |
| 547 | |
| 548 | out: |
| 549 | return r; |
| 550 | } |
| 551 | |
| 552 | FSCryptKeyValidator::FSCryptKeyValidator(CephContext *cct, FSCryptKeyHandlerRef& kh, int64_t e) : cct(cct), handler(kh), epoch(e) { |
| 553 | } |
no test coverage detected