func (s *BlockVolume) getOrCreateBlockINode(ref torus.INodeRef) (*models.INode, error) {
	if ref.Volume() != torus.VolumeID(s.volume.Id) {
		panic("ids managed by metadata didn't match, how is that possible?")
	}
	if ref.INode != 1 {
		return s.srv.INodes.GetINode(s.getContext(), ref)
	}
	globals, err := s.mds.GlobalMetadata()
	if err != nil {

	}
	bs, err := blockset.CreateBlocksetFromSpec(globals.DefaultBlockSpec, nil)
	if err != nil {
		return nil, err
	}
	nBlocks := (s.volume.MaxBytes / globals.BlockSize)
	if s.volume.MaxBytes%globals.BlockSize != 0 {
		nBlocks++
	}
	err = bs.Truncate(int(nBlocks), globals.BlockSize)
	if err != nil {
		return nil, err
	}
	inode := models.NewEmptyINode()
	inode.INode = 1
	inode.Volume = s.volume.Id
	inode.Filesize = s.volume.MaxBytes
	inode.Blocks, err = torus.MarshalBlocksetToProto(bs)
	return inode, err
}
func marshalTest(t *testing.T, s torus.BlockStore, spec torus.BlockLayerSpec) {
	b, err := CreateBlocksetFromSpec(spec, s)
	if err != nil {
		t.Fatal(err)
	}
	inode := torus.NewINodeRef(1, 1)
	b.PutBlock(context.TODO(), inode, 0, []byte("Some data"))
	marshal, err := torus.MarshalBlocksetToProto(b)
	if err != nil {
		t.Fatal(err)
	}

	b = nil
	newb, err := UnmarshalFromProto(marshal, s)
	if err != nil {
		t.Fatal(err)
	}

	data, err := newb.GetBlock(context.TODO(), 0)
	if err != nil {
		t.Fatal(err)
	}
	if string(data) != "Some data" {
		t.Error("data not retrieved")
	}
}
func makeFile(name string, t *testing.T) (*torus.Server, *torus.File) {
	srv := torus.NewMemoryServer()
	vol := &models.Volume{
		Name: name,
		Id:   3,
		Type: "test",
	}
	globals, err := srv.MDS.GlobalMetadata()
	if err != nil {
		t.Fatal(err)
	}
	bs, err := blockset.CreateBlocksetFromSpec(globals.DefaultBlockSpec, srv.Blocks)
	if err != nil {
		t.Fatal(err)
	}
	inode := models.NewEmptyINode()
	inode.INode = 1
	inode.Volume = vol.Id
	inode.Blocks, err = torus.MarshalBlocksetToProto(bs)
	f, err := srv.CreateFile(vol, inode, bs)
	if err != nil {
		t.Fatal(err)
	}
	return srv, f
}