@@ -6354,11 +6354,10 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
63546354 client_t exclude_ct = mdr->get_client ();
63556355 mdcache->broadcast_quota_to_client (cur, exclude_ct, true );
63566356 } else if (name == " ceph.quiesce.block" sv) {
6357- bool val;
6358- try {
6359- val = boost::lexical_cast<bool >(value);
6360- } catch (boost::bad_lexical_cast const &) {
6361- dout (10 ) << " bad vxattr value, unable to parse bool for " << name << dendl;
6357+ std::string errstr;
6358+ bool val = strict_strtob (value, &errstr);
6359+ if (!errstr.empty ()) {
6360+ dout (10 ) << " bad vxattr value, unable to parse bool for " << name << " : " << errstr << dendl;
63626361 respond_to_request (mdr, -EINVAL);
63636362 return ;
63646363 }
@@ -6416,7 +6415,13 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
64166415 }
64176416 value = " 0" ;
64186417 }
6419- val = boost::lexical_cast<bool >(value);
6418+ std::string errstr;
6419+ val = strict_strtob (value, &errstr);
6420+ if (!errstr.empty ()) {
6421+ dout (10 ) << " bad vxattr value, unable to parse bool for " << name << " : " << errstr << dendl;
6422+ respond_to_request (mdr, -EINVAL);
6423+ return ;
6424+ }
64206425 } catch (boost::bad_lexical_cast const &) {
64216426 dout (10 ) << " bad vxattr value, unable to parse bool for " << name << dendl;
64226427 respond_to_request (mdr, -EINVAL);
@@ -6565,7 +6570,13 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
65656570 }
65666571 value = " 0" ;
65676572 }
6568- val = boost::lexical_cast<bool >(value);
6573+ std::string errstr;
6574+ val = strict_strtob (value, &errstr);
6575+ if (!errstr.empty ()) {
6576+ dout (10 ) << " bad vxattr value, unable to parse bool for " << name << " : " << errstr << dendl;
6577+ respond_to_request (mdr, -EINVAL);
6578+ return ;
6579+ }
65696580 } catch (boost::bad_lexical_cast const &) {
65706581 dout (10 ) << " bad vxattr value, unable to parse bool for " << name << dendl;
65716582 respond_to_request (mdr, -EINVAL);
@@ -6592,11 +6603,7 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
65926603 if (!xlock_policylock (mdr, cur, false , false , std::move (lov)))
65936604 return ;
65946605
6595- if (_dir_is_nonempty (mdr, cur)) {
6596- respond_to_request (mdr, -ENOTEMPTY);
6597- return ;
6598- }
6599- if (cur->snaprealm && cur->snaprealm ->srnode .snaps .size ()) {
6606+ if (_dir_is_nonempty (mdr, cur) || _dir_has_snaps (mdr, cur)) {
66006607 respond_to_request (mdr, -ENOTEMPTY);
66016608 return ;
66026609 }
@@ -6624,20 +6631,15 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
66246631 if (!xlock_policylock (mdr, cur, false , false , std::move (lov)))
66256632 return ;
66266633
6627- if (_dir_is_nonempty (mdr, cur)) {
6628- respond_to_request (mdr, -ENOTEMPTY);
6629- return ;
6630- }
6631- if (cur->snaprealm && cur->snaprealm ->srnode .snaps .size ()) {
6634+ if (_dir_is_nonempty (mdr, cur) || _dir_has_snaps (mdr, cur)) {
66326635 respond_to_request (mdr, -ENOTEMPTY);
66336636 return ;
66346637 }
66356638
6636- bool val;
6637- try {
6638- val = boost::lexical_cast<bool >(value);
6639- } catch (boost::bad_lexical_cast const &) {
6640- dout (10 ) << " bad vxattr value, unable to parse bool for " << name << dendl;
6639+ std::string errstr;
6640+ bool val = strict_strtob (value, &errstr);
6641+ if (!errstr.empty ()) {
6642+ dout (10 ) << " bad vxattr value, unable to parse bool for " << name << " : " << errstr << dendl;
66416643 respond_to_request (mdr, -EINVAL);
66426644 return ;
66436645 }
@@ -6662,11 +6664,7 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
66626664 if (!xlock_policylock (mdr, cur, false , false , std::move (lov)))
66636665 return ;
66646666
6665- if (_dir_is_nonempty (mdr, cur)) {
6666- respond_to_request (mdr, -ENOTEMPTY);
6667- return ;
6668- }
6669- if (cur->snaprealm && cur->snaprealm ->srnode .snaps .size ()) {
6667+ if (_dir_is_nonempty (mdr, cur) || _dir_has_snaps (mdr, cur)) {
66706668 respond_to_request (mdr, -ENOTEMPTY);
66716669 return ;
66726670 }
@@ -6690,11 +6688,7 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
66906688 if (!xlock_policylock (mdr, cur, false , false , std::move (lov)))
66916689 return ;
66926690
6693- if (_dir_is_nonempty (mdr, cur)) {
6694- respond_to_request (mdr, -ENOTEMPTY);
6695- return ;
6696- }
6697- if (cur->snaprealm && cur->snaprealm ->srnode .snaps .size ()) {
6691+ if (_dir_is_nonempty (mdr, cur) || _dir_has_snaps (mdr, cur)) {
66986692 respond_to_request (mdr, -ENOTEMPTY);
66996693 return ;
67006694 }
@@ -9223,6 +9217,16 @@ bool Server::_dir_is_nonempty_unlocked(const MDRequestRef& mdr, CInode *in)
92239217 return false ;
92249218}
92259219
9220+ bool Server::_dir_has_snaps (const MDRequestRef& mdr, CInode *diri)
9221+ {
9222+ dout (10 ) << __func__ << " : " << *diri << dendl;
9223+ ceph_assert (diri->is_auth ());
9224+ ceph_assert (diri->snaplock .can_read (mdr->get_client ()));
9225+
9226+ SnapRealm *realm = diri->find_snaprealm ();
9227+ return !realm->get_snaps ().empty ();
9228+ }
9229+
92269230bool Server::_dir_is_nonempty (const MDRequestRef& mdr, CInode *in)
92279231{
92289232 dout (10 ) << " dir_is_nonempty " << *in << dendl;
0 commit comments