Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

duplicate target to parallel file handling #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions nfs/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
type Target struct {
*rpc.Client

addr string
auth rpc.Auth
fh []byte
dirPath string
Expand All @@ -39,6 +40,7 @@ func NewTarget(addr string, auth rpc.Auth, fh []byte, dirpath string) (*Target,

vol := &Target{
Client: client,
addr: addr,
auth: auth,
fh: fh,
dirPath: dirpath,
Expand Down Expand Up @@ -74,6 +76,37 @@ func (v *Target) call(c interface{}) (io.ReadSeeker, error) {
return res, nil
}

func (v *Target) Dup() (*Target, error) {
m := rpc.Mapping{
Prog: Nfs3Prog,
Vers: Nfs3Vers,
Prot: rpc.IPProtoTCP,
Port: 0,
}

client, err := DialService(v.addr, m)
if err != nil {
return nil, err
}

vol := &Target{
Client: client,
auth: v.auth,
fh: v.fh,
dirPath: v.dirPath,
}

fsinfo, err := vol.FSInfo()
if err != nil {
return nil, err
}

vol.fsinfo = fsinfo
util.Debugf("%s:%s fsinfo=%#v", v.addr, v.dirPath, fsinfo)

return vol, nil
}

func (v *Target) FSInfo() (*FSInfo, error) {
type FSInfoArgs struct {
rpc.Header
Expand Down