In class IDiskRemote, all metadata file system operations use os file system api directly.
There is little extendiability if we want store the metadata of HDFS or S3 into distributed file system.
So I suggest change this way by using DiskPtr and will propose a pull request.

In addition, metadata of HDFS or S3 only store local FS which is not sharable.

{
    auto creator = [](const String & name,
                      const Poco::Util::AbstractConfiguration & config,
                      const String & config_prefix,
                      ContextPtr context_,
                      const DisksMap & ) -> DiskPtr
    {
        fs::path disk = fs::path(context_->getPath()) / "disks" / name;
        fs::create_directories(disk);
        String uri{config.getString(config_prefix + ".endpoint")};
        checkHDFSURL(uri);
        if (uri.back() != '/')
            throw Exception(ErrorCodes::BAD_ARGUMENTS, "HDFS path must ends with '/', but '{}' doesn't.", uri);
        String metadata_path = context_->getPath() + "disks/" + name + "/";
        return std::make_shared<DiskHDFS>(
            name, uri,
            getSettings(config, config_prefix),
            metadata_path, config);
    };
    factory.registerDiskType("hdfs", creator);
}
}