NB: this is used for both readdir and readdir_snapdiff results processing hence it should be request type agnostic
| 10024 | // hence it should be request type agnostic |
| 10025 | // |
| 10026 | int Client::_readdir_r_cb(int op, |
| 10027 | dir_result_t *d, |
| 10028 | add_dirent_cb_t cb, |
| 10029 | fill_readdir_args_cb_t fill_cb, |
| 10030 | void *p, |
| 10031 | unsigned want, |
| 10032 | unsigned flags, |
| 10033 | bool getref, |
| 10034 | bool bypass_cache) |
| 10035 | { |
| 10036 | int caps = statx_to_mask(flags, want); |
| 10037 | int rstat_on_dir = cct->_conf->client_dirsize_rbytes ? CEPH_STAT_RSTAT : 0; |
| 10038 | |
| 10039 | RWRef_t mref_reader(mount_state, CLIENT_MOUNTING); |
| 10040 | if (!mref_reader.is_state_satisfied()) |
| 10041 | return -ENOTCONN; |
| 10042 | |
| 10043 | std::unique_lock cl(client_lock); |
| 10044 | |
| 10045 | dir_result_t *dirp = static_cast<dir_result_t*>(d); |
| 10046 | |
| 10047 | ldout(cct, 10) << __func__ << " " << *dirp->inode << " offset " << hex << dirp->offset |
| 10048 | << dec << " at_end=" << dirp->at_end() |
| 10049 | << " hash_order=" << dirp->hash_order() << dendl; |
| 10050 | |
| 10051 | struct dirent de; |
| 10052 | struct ceph_statx stx; |
| 10053 | memset(&de, 0, sizeof(de)); |
| 10054 | memset(&stx, 0, sizeof(stx)); |
| 10055 | |
| 10056 | InodeRef& diri = dirp->inode; |
| 10057 | |
| 10058 | if (dirp->at_end()) |
| 10059 | return 0; |
| 10060 | |
| 10061 | if (dirp->offset == 0) { |
| 10062 | ldout(cct, 15) << " including ." << dendl; |
| 10063 | ceph_assert(diri->dentries.size() < 2); // can't have multiple hard-links to a dir |
| 10064 | uint64_t next_off = 1; |
| 10065 | |
| 10066 | int r; |
| 10067 | r = _getattr(diri, caps | rstat_on_dir, dirp->perms); |
| 10068 | if (r < 0) |
| 10069 | return r; |
| 10070 | |
| 10071 | fill_statx(diri, caps, &stx); |
| 10072 | fill_dirent(&de, ".", S_IFDIR, stx.stx_ino, next_off); |
| 10073 | |
| 10074 | Inode *inode = NULL; |
| 10075 | if (getref) { |
| 10076 | inode = diri.get(); |
| 10077 | _ll_get(inode); |
| 10078 | } |
| 10079 | |
| 10080 | cl.unlock(); |
| 10081 | r = cb(p, &de, &stx, next_off, inode); |
| 10082 | cl.lock(); |
| 10083 | if (r < 0) |
nothing calls this directly
no test coverage detected