Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to know if the part about creating a pool with log settings is not implemented. If it is, can you provide an example? #47

Open
alphandbelt opened this issue Sep 15, 2023 · 4 comments

Comments

@alphandbelt
Copy link

No description provided.

@fkasumovic
Copy link
Contributor

Hi @alphandbelt,

Are you referring to the zpool history log or the creation of the pool with log/ZIL devices?

For setting up ZIL, you can use the VDevTree structure argument with the PoolCreate(...) function to pass a pointer to the Logs *VDevTree.

@alphandbelt
Copy link
Author

Thank you for your reply! I want to set up ZIL.
This is is test code.
func (pc *PoolCreateProps) CreateLogPool() (err error) {

// FIXME

log.Printf("### CreateLogPool (%v) ###\n", pc.PoolType)

var mdevs, tdevs []_zfs.VDevTree
var vdevs []_zfs.VDevTree
//poolType := pc.PoolType
diskss := pc.PoolDisks


for _, d := range diskss {
	log.Printf("top_level_disks:%v\n", d.TopLevelDisks)
	log.Printf("log_disks:%v\n", d.LogDisks)
	//mdevs = []_zfs.VDevTree{}

	tdevs = append(tdevs, _zfs.VDevTree{
		Type: _zfs.VDevTypeDisk,
		Path: d.TopLevelDisks,
	})

	for _, _d := range d.LogDisks {
		mdevs = append(mdevs, _zfs.VDevTree{
			Type: _zfs.VDevTypeDisk,
			Path: _d,
		})
	}

	log.Printf("d:%v\n", d.Disks)
	vdevs = append(vdevs, _zfs.VDevTree{
		Type:    _zfs.VDevTypeMirror,
		Devices: mdevs,
	})

}

var logDevs _zfs.VDevTree
logLogDevs := _zfs.VDevTree{
	Type:    _zfs.VDevTypeMirror,
	Devices: vdevs,
}

logDevs.Logs = &logLogDevs

for _, _t := range tdevs {
	_t.Logs = &logLogDevs
}

logDevs.Devices = tdevs

logLogDevsString, err := json.Marshal(logLogDevs)
if err != nil {
	return err
}
log.Printf("logLogDevsString:%v\n", logLogDevsString)

props := make(map[_zfs.Prop]string)
props[_zfs.PoolPropFailuremode] = "continue"
// root dataset filesystem properties
fsprops := make(map[_zfs.Prop]string)
// pool features
features := make(map[string]string)

// Turn off auto mounting by ZFS
fsprops[_zfs.DatasetPropMountpoint] = "none"

// Enable some features
features["async_destroy"] = "enabled"
features["empty_bpobj"] = "enabled"
features["lz4_compress"] = "enabled"
features["log_spacemap"] = "enabled"

marshal, err := json.Marshal(logDevs)
if err != nil {
	return err
}
log.Printf("logDevs:%v\n", string(marshal))

// Based on specs formed above create test pool as 2 disk mirror and
// one spare disk

log.Printf("logDevs.Logs:%v\n\n", logDevs.Logs)

pool, err := _zfs.PoolCreate(pc.Name, logDevs, features, props, fsprops)
if err != nil {
	log.Printf("Error: %v\n", err.Error())
	return err
}

defer pool.Close()

return nil

}

before call the func of PoolCreate
, i print the logDevs.Logs, it's value is ok. but the pool created just has the top level devices, Logs is null, i don't know why!

@fkasumovic
Copy link
Contributor

@alphandbelt, after digging into the code, you are right; it's actually never implemented. I obviously forgot about that. You can add spare and L2 cache disks, but logs are ignored.

@alphandbelt
Copy link
Author

@alphandbelt, after digging into the code, you are right; it's actually never implemented. I obviously forgot about that. You can add spare and L2 cache disks, but logs are ignored.

Thank you for your response! This Golang library is very convenient to use, and as ZFS becomes more popular, more and more people will find this excellent library useful. Do you have any plans to continue adding more features to it?

By the way, I have another question. When I create an L2 cache device, the pool that is created turns out to be a spare pool, which is very strange. Could you please take another look at it? I really appreciate your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants