From 961a46f57e602f14f1e10e5f786fa698ea5af539 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 5 Apr 2016 21:15:42 +0800 Subject: [PATCH] client: fix pool permisson check handle pool namespace Signed-off-by: Yan, Zheng --- src/client/Client.cc | 20 +++++++++++--------- src/client/Client.h | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 177a61e937b8d..545ec26fb42a5 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -12099,10 +12099,12 @@ int Client::check_pool_perm(Inode *in, int need) if (!cct->_conf->client_check_pool_perm) return 0; - int64_t pool = in->layout.pool_id; + int64_t pool_id = in->layout.pool_id; + std::string pool_ns = in->layout.pool_ns; + std::pair perm_key(pool_id, pool_ns); int have = 0; while (true) { - std::map::iterator it = pool_perms.find(pool); + auto it = pool_perms.find(perm_key); if (it == pool_perms.end()) break; if (it->second == POOL_CHECKING) { @@ -12123,7 +12125,7 @@ int Client::check_pool_perm(Inode *in, int need) return 0; } - pool_perms[pool] = POOL_CHECKING; + pool_perms[perm_key] = POOL_CHECKING; char oid_buf[32]; snprintf(oid_buf, sizeof(oid_buf), "%llx.00000000", (unsigned long long)in->ino); @@ -12155,7 +12157,7 @@ int Client::check_pool_perm(Inode *in, int need) if (rd_ret == 0 || rd_ret == -ENOENT) have |= POOL_READ; else if (rd_ret != -EPERM) { - ldout(cct, 10) << "check_pool_perm on pool " << pool + ldout(cct, 10) << "check_pool_perm on pool " << pool_id << " ns " << pool_ns << " rd_err = " << rd_ret << " wr_err = " << wr_ret << dendl; errored = true; } @@ -12163,7 +12165,7 @@ int Client::check_pool_perm(Inode *in, int need) if (wr_ret == 0 || wr_ret == -EEXIST) have |= POOL_WRITE; else if (wr_ret != -EPERM) { - ldout(cct, 10) << "check_pool_perm on pool " << pool + ldout(cct, 10) << "check_pool_perm on pool " << pool_id << " ns " << pool_ns << " rd_err = " << rd_ret << " wr_err = " << wr_ret << dendl; errored = true; } @@ -12172,22 +12174,22 @@ int Client::check_pool_perm(Inode *in, int need) // Indeterminate: erase CHECKING state so that subsequent calls re-check. // Raise EIO because actual error code might be misleading for // userspace filesystem user. - pool_perms.erase(pool); + pool_perms.erase(perm_key); signal_cond_list(waiting_for_pool_perm); return -EIO; } - pool_perms[pool] = have | POOL_CHECKED; + pool_perms[perm_key] = have | POOL_CHECKED; signal_cond_list(waiting_for_pool_perm); } if ((need & CEPH_CAP_FILE_RD) && !(have & POOL_READ)) { - ldout(cct, 10) << "check_pool_perm on pool " << pool + ldout(cct, 10) << "check_pool_perm on pool " << pool_id << " ns " << pool_ns << " need " << ccap_string(need) << ", but no read perm" << dendl; return -EPERM; } if ((need & CEPH_CAP_FILE_WR) && !(have & POOL_WRITE)) { - ldout(cct, 10) << "check_pool_perm on pool " << pool + ldout(cct, 10) << "check_pool_perm on pool " << pool_id << " ns " << pool_ns << " need " << ccap_string(need) << ", but no write perm" << dendl; return -EPERM; } diff --git a/src/client/Client.h b/src/client/Client.h index d53ca1df169a4..d912db05c058e 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -541,7 +541,7 @@ protected: bool is_quota_bytes_exceeded(Inode *in, int64_t new_bytes); bool is_quota_bytes_approaching(Inode *in); - std::map pool_perms; + std::map, int> pool_perms; list waiting_for_pool_perm; int check_pool_perm(Inode *in, int need); -- 2.39.5