You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: reader.go
    path of file: ./repos/cloud-torrent/vendor/github.com/anacrolix/torrent
    
    the code of the file until where you have to start completion: package torrent

import (
	"errors"
	"io"
	"log"
	"os"
	"sync"

	"github.com/anacroli
    
func (r *Reader) readOnceAt(b []byte, pos int64, ctxErr *error) (n int, err error) {
	if pos >= r.t.length {
		err = io.EOF
		return
	}
	for {
		avail := r.waitAvailable(pos, int64(len(b)), ctxErr)
		if avail == 0 {
			if r.t.closed.IsSet() {
				err = errors.New("torrent closed")
				return
			}
			if *ctxErr != nil {
				err = *ctxErr
				return
			}
		}
		b1 := b[:avail]
		pi := int(pos / r.t.info.PieceLength)
		ip := r.t.info.Piece(pi)
		po := pos % r.t.info.PieceLength
		missinggo.LimitLen(&b1, ip.Length()-po)
		n, err = r.t.readAt(b1, pos)
		if n != 0 {
			err = nil
			return
		}
		r.t.cl.mu.Lock()
		log.Printf("error reading torrent %q piece %d offset %d, %d bytes: %s", r.t, pi, po, len(b1), err)
		r.t.updateAllPieceCompletions()
		r.t.updateAllPiecePriorities()
		r.t.cl.mu.Unlock()
	}
}