]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge pull request #46960 from xdavidwu/client-readdir-performance
authorRishabh Dave <ridave@redhat.com>
Thu, 13 Jul 2023 12:33:43 +0000 (18:03 +0530)
committerGitHub <noreply@github.com>
Thu, 13 Jul 2023 12:33:43 +0000 (18:03 +0530)
client: readdir_r_cb: get rstat for dir only if using rbytes for size

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Rishabh Dave <ridave@redhat.com>
1  2 
src/client/Client.cc

index 4ed12c30a7d734f9383c17fe89416fcfe0d221b0,2fe11c6f31216df72cd145b7d91429de3428df4c..7b11911081487427a39b80db5bbbe9dcc62acae3
@@@ -9264,59 -9193,11 +9264,60 @@@ int Client::_readdir_cache_cb(dir_resul
    return 0;
  }
  
 -int Client::readdir_r_cb(dir_result_t *d, add_dirent_cb_t cb, void *p,
 -                       unsigned want, unsigned flags, bool getref)
 +int Client::readdir_r_cb(dir_result_t* d,
 +  add_dirent_cb_t cb,
 +  void* p,
 +  unsigned want,
 +  unsigned flags,
 +  bool getref)
 +{
 +  auto fill_readdir_cb = [](dir_result_t* dirp,
 +                          MetaRequest* req,
 +                          InodeRef& diri,
 +                          frag_t fg) {
 +    filepath path;
 +    diri->make_nosnap_relative_path(path);
 +    req->set_filepath(path);
 +    req->set_inode(diri.get());
 +    req->head.args.readdir.frag = fg;
 +    req->head.args.readdir.flags = CEPH_READDIR_REPLY_BITFLAGS;
 +    if (dirp->last_name.length()) {
 +      req->path2.set_path(dirp->last_name);
 +    } else if (dirp->hash_order()) {
 +      req->head.args.readdir.offset_hash = dirp->offset_high();
 +    }
 +    req->dirp = dirp;
 +  };
 +  int op = CEPH_MDS_OP_READDIR;
 +  if (d->inode && d->inode->snapid == CEPH_SNAPDIR)
 +    op = CEPH_MDS_OP_LSSNAP;
 +  return _readdir_r_cb(op,
 +    d,
 +    cb,
 +    fill_readdir_cb,
 +    p,
 +    want,
 +    flags,
 +    getref,
 +    false);
 +}
 +
 +//
 +// NB: this is used for both readdir and readdir_snapdiff results processing
 +// hence it should be request type agnostic
 +//
 +int Client::_readdir_r_cb(int op,
 +  dir_result_t *d,
 +  add_dirent_cb_t cb,
 +  fill_readdir_args_cb_t fill_cb,
 +  void *p,
 +  unsigned want,
 +  unsigned flags,
 +  bool getref,
 +  bool bypass_cache)
  {
    int caps = statx_to_mask(flags, want);
+   int rstat_on_dir = cct->_conf->client_dirsize_rbytes ? CEPH_STAT_RSTAT : 0;
  
    RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
    if (!mref_reader.is_state_satisfied())