| 167 | } |
| 168 | |
| 169 | int ScrubStack::enqueue(CInode *in, ScrubHeaderRef& header, bool top) |
| 170 | { |
| 171 | // abort in progress |
| 172 | if (clear_stack) |
| 173 | return -EAGAIN; |
| 174 | |
| 175 | header->set_origin(in->ino()); |
| 176 | auto ret = scrubbing_map.emplace(header->get_tag(), header); |
| 177 | if (!ret.second) { |
| 178 | dout(10) << __func__ << " with {" << *in << "}" |
| 179 | << ", conflicting tag " << header->get_tag() << dendl; |
| 180 | return -EEXIST; |
| 181 | } |
| 182 | if (header->get_scrub_mdsdir()) { |
| 183 | filepath fp; |
| 184 | mds_rank_t rank; |
| 185 | rank = mdcache->mds->get_nodeid(); |
| 186 | if(rank >= 0 && rank < MAX_MDS) { |
| 187 | fp.set_path("", MDS_INO_MDSDIR(rank)); |
| 188 | } |
| 189 | int r = _enqueue(mdcache->get_inode(fp.get_ino()), header, true); |
| 190 | if (r < 0) { |
| 191 | return r; |
| 192 | } |
| 193 | //to make sure mdsdir is always on the top |
| 194 | top = false; |
| 195 | } |
| 196 | |
| 197 | std::string path; |
| 198 | in->make_path_string(path); |
| 199 | init_scrub_counters(path, header->get_tag()); |
| 200 | int r = _enqueue(in, header, top); |
| 201 | if (r < 0) |
| 202 | return r; |
| 203 | |
| 204 | clog_scrub_summary(in); |
| 205 | |
| 206 | kick_off_scrubs(); |
| 207 | return 0; |
| 208 | } |
| 209 | |
| 210 | void ScrubStack::add_to_waiting(MDSCacheObject *obj) |
| 211 | { |