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 settings = current_settings.get();
    auto metadata = readMeta(path);
    LOG_TRACE(log, "Read from file by path: {}. Existing S3 objects: {}",
        backQuote(metadata_path + path), metadata.remote_fs_objects.size());
    bool threadpool_read = read_settings.remote_fs_method == RemoteFSReadMethod::threadpool;
    auto s3_impl = std::make_unique<ReadBufferFromS3Gather>(
        path,
        settings->client, bucket, metadata,
        settings->s3_max_single_read_retries, read_settings, threadpool_read);
    if (threadpool_read)
    {
        auto reader = getThreadPoolReader();
        return std::make_unique<AsynchronousReadIndirectBufferFromRemoteFS>(reader, read_settings, std::move(s3_impl));
    }
    else
    {
        auto buf = std::make_unique<ReadIndirectBufferFromRemoteFS>(std::move(s3_impl));
        return std::make_unique<SeekAvoidingReadBuffer>(std::move(buf), settings->min_bytes_for_seek);
    }
}
std::unique_ptr<WriteBufferFromFileBase> DiskS3::writeFile(const String & path, size_t buf_size, WriteMode mode)