s.append(name.data(), name.length());
}
+/* path_comp_count = path component count. default value is 10 which implies
+ * generate entire path.
+ *
+ * XXX Generating more than 10 components of a path for printing in logs will
+ * consume too much time when the path is too long (imagine a path with 2000
+ * components) since the path would've to be generated indidividually for each
+ * log entry.
+ *
+ * Besides consuming too much time, such long paths in logs are not only not
+ * useful but also it makes reading logs harder. Therefore, shorten the path
+ * when used for logging.
+ */
+void CDentry::make_trimmed_path_string(string& s, bool projected,
+ int path_comp_count) const
+{
+ make_path_string(s, projected, path_comp_count);
+}
+
/* path_comp_count = path component count. default value is -1 which implies
* generate entire path.
*/
const CDentry& operator= (const CDentry& right);
// misc
+ void make_trimmed_path_string(std::string& s, bool projected,
+ int path_comp_count=10) const;
void make_path_string(std::string& s, bool projected=false,
int path_comp_count=-1) const;
void make_path(filepath& fp, bool projected=false,
const vector<uint64_t> *caller_gid_list,
unsigned mask,
uid_t new_uid, gid_t new_gid,
- const entity_addr_t& addr) const
+ const entity_addr_t& addr,
+ string_view trimmed_inode_path) const
{
- ldout(g_ceph_context, 10) << __func__ << "fs_name " << fs_name << " inode(path /" << inode_path
+ ldout(g_ceph_context, 10) << __func__ << "fs_name " << fs_name
+ << " inode(path /" << trimmed_inode_path
<< " owner " << inode_uid << ":" << inode_gid
<< " mode 0" << std::oct << inode_mode << std::dec
<< ") by caller " << caller_uid << ":" << caller_gid
uid_t inode_uid, gid_t inode_gid, unsigned inode_mode,
uid_t uid, gid_t gid, const std::vector<uint64_t> *caller_gid_list,
unsigned mask, uid_t new_uid, gid_t new_gid,
- const entity_addr_t& addr) const;
+ const entity_addr_t& addr, std::string_view trimmed_inode_path) const;
bool path_capable(std::string_view inode_path) const;
bool fs_name_capable(std::string_view fs_name, unsigned mask) const {
{
std::string t;
destdn->make_path_string(t, true);
- dout(20) << " stray_prior_path = " << t << dendl;
+ std::string trimmed_t;
+ destdn->make_trimmed_path_string(t, true);
+ dout(20) << " stray_prior_path = " << trimmed_t << dendl;
tpi->stray_prior_path = std::move(t);
}
tpi->nlink--;
{
std::string t;
destdn->make_path_string(t, true);
- dout(20) << __func__ << " referent stray_prior_path = " << t << dendl;
+ std::string trimmed_t;
+ destdn->make_trimmed_path_string(t, true);
+ dout(20) << __func__ << " referent stray_prior_path = " << trimmed_t << dendl;
trpi->stray_prior_path = std::move(t);
}
}
}
}
+ string trimmed_inode_path;
if (!path.empty()) {
dout(20) << __func__ << " stray_prior_path " << path << dendl;
} else {
in->make_path_string(path, true);
- dout(20) << __func__ << " path " << path << dendl;
+ in->make_trimmed_path_string(trimmed_inode_path, true);
+ dout(20) << __func__ << " path " << trimmed_inode_path << dendl;
}
if (path.length())
path = path.substr(1); // drop leading /
if (!auth_caps.is_capable(fs_name, path, inode->uid, inode->gid, inode->mode,
caller_uid, caller_gid, caller_gid_list, mask,
- new_uid, new_gid,
- info.inst.addr)) {
+ new_uid, new_gid, info.inst.addr, trimmed_inode_path)) {
return -EACCES;
}
return 0;