mirror of
https://github.com/ceph/ceph
synced 2025-01-21 02:31:19 +00:00
mds: enable rmxattr on pool_namespace attrs
So that a user has a natural way of undoing a setxattr which set a pool_namespace. Fixes: http://tracker.ceph.com/issues/17797 Signed-off-by: John Spray <john.spray@redhat.com>
This commit is contained in:
parent
82ee518c21
commit
77177530f2
@ -1,6 +1,7 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# detect data pool
|
||||
datapool=
|
||||
@ -37,6 +38,8 @@ setfattr -n ceph.file.layout.pool -v $datapool file2
|
||||
getfattr -n ceph.file.layout.pool file2 | grep -q $datapool
|
||||
setfattr -n ceph.file.layout.pool_namespace -v foons file2
|
||||
getfattr -n ceph.file.layout.pool_namespace file2 | grep -q foons
|
||||
setfattr -x ceph.file.layout.pool_namespace file2
|
||||
getfattr -n ceph.file.layout.pool_namespace file2 | grep -q -v foons
|
||||
|
||||
getfattr -n ceph.file.layout.stripe_unit file2 | grep -q 1048576
|
||||
getfattr -n ceph.file.layout.stripe_count file2 | grep -q 8
|
||||
@ -90,6 +93,7 @@ getfattr -n ceph.dir.layout.stripe_count dir | grep -q 8
|
||||
getfattr -n ceph.dir.layout.object_size dir | grep -q 10485760
|
||||
getfattr -n ceph.dir.layout.pool_namespace dir | grep -q dirns
|
||||
|
||||
|
||||
setfattr -n ceph.file.layout -v "stripe_count=16" file2
|
||||
getfattr -n ceph.file.layout.stripe_count file2 | grep -q 16
|
||||
setfattr -n ceph.file.layout -v "object_size=10485760 stripe_count=8 stripe_unit=1048576 pool=$datapool pool_namespace=dirns" file2
|
||||
@ -102,6 +106,9 @@ getfattr -n ceph.file.layout.stripe_count dir/file | grep -q 8
|
||||
getfattr -n ceph.file.layout.object_size dir/file | grep -q 10485760
|
||||
getfattr -n ceph.file.layout.pool_namespace dir/file | grep -q dirns
|
||||
|
||||
setfattr -x ceph.dir.layout.pool_namespace dir
|
||||
getfattr -n ceph.dir.layout dir | grep -q -v pool_namespace=dirns
|
||||
|
||||
setfattr -x ceph.dir.layout dir
|
||||
getfattr -n ceph.dir.layout dir 2>&1 | grep -q 'No such attribute'
|
||||
|
||||
|
@ -4297,7 +4297,8 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur,
|
||||
if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
|
||||
return;
|
||||
|
||||
if (cur->inode.layout.pool_id != layout.pool_id) {
|
||||
if (cur->inode.layout.pool_id != layout.pool_id
|
||||
|| cur->inode.layout.pool_ns != layout.pool_ns) {
|
||||
if (!check_access(mdr, cur, MAY_SET_POOL)) {
|
||||
return;
|
||||
}
|
||||
@ -4379,12 +4380,16 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur,
|
||||
}
|
||||
|
||||
void Server::handle_remove_vxattr(MDRequestRef& mdr, CInode *cur,
|
||||
file_layout_t *dir_layout,
|
||||
set<SimpleLock*> rdlocks,
|
||||
set<SimpleLock*> wrlocks,
|
||||
set<SimpleLock*> xlocks)
|
||||
{
|
||||
MClientRequest *req = mdr->client_request;
|
||||
string name(req->get_path2());
|
||||
|
||||
dout(10) << __func__ << " " << name << " on " << *cur << dendl;
|
||||
|
||||
if (name == "ceph.dir.layout") {
|
||||
if (!cur->is_dir()) {
|
||||
respond_to_request(mdr, -ENODATA);
|
||||
@ -4419,6 +4424,14 @@ void Server::handle_remove_vxattr(MDRequestRef& mdr, CInode *cur,
|
||||
|
||||
journal_and_reply(mdr, cur, 0, le, new C_MDS_inode_update_finish(this, mdr, cur));
|
||||
return;
|
||||
} else if (name == "ceph.dir.layout.pool_namespace"
|
||||
|| name == "ceph.file.layout.pool_namespace") {
|
||||
// Namespace is the only layout field that has a meaningful
|
||||
// null/none value (empty string, means default layout). Is equivalent
|
||||
// to a setxattr with empty string: pass through the empty payload of
|
||||
// the rmxattr request to do this.
|
||||
handle_set_vxattr(mdr, cur, dir_layout, rdlocks, wrlocks, xlocks);
|
||||
return;
|
||||
}
|
||||
|
||||
respond_to_request(mdr, -ENODATA);
|
||||
@ -4539,7 +4552,7 @@ void Server::handle_client_removexattr(MDRequestRef& mdr)
|
||||
}
|
||||
|
||||
if (name.compare(0, 5, "ceph.") == 0) {
|
||||
handle_remove_vxattr(mdr, cur, rdlocks, wrlocks, xlocks);
|
||||
handle_remove_vxattr(mdr, cur, dir_layout, rdlocks, wrlocks, xlocks);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -187,6 +187,7 @@ public:
|
||||
set<SimpleLock*> wrlocks,
|
||||
set<SimpleLock*> xlocks);
|
||||
void handle_remove_vxattr(MDRequestRef& mdr, CInode *cur,
|
||||
file_layout_t *dir_layout,
|
||||
set<SimpleLock*> rdlocks,
|
||||
set<SimpleLock*> wrlocks,
|
||||
set<SimpleLock*> xlocks);
|
||||
|
Loading…
Reference in New Issue
Block a user