Graph Driver-device Mapper-04libdevmapper Basic operations

Source: Internet
Author: User

Create thin pool//call path: newdeviceset->initdevmapper->createpool1.1 func createpool (poolname string, datafile, Metadatafile *os. File, poolblocksize UInt32) error {//The interaction task is encapsulated with Libdevmapper through a task, err: = CreateTask (Devicecreate, poolname) if task = = Ni L {return Err}//data block device size, via ioctlsize, err: = Getblockdevicesize (datafile) if err! = Nil {return FMT. Errorf ("Can ' t get data size%s", err)}//create thin pool parameter params: = FMT. Sprintf ("%s%s%d 32768 1 skip_block_zeroing", Metadatafile.name (), Datafile.name (), poolblocksize)//Add function parameter If err: = Task . AddTarget (0, size/512, "Thin-pool", params); Err! = Nil {return FMT. Errorf ("Can ' t add target%s", err)}//Create a sync amount var cookie uint = 0if ERR: = task. Setcookie (&cookie, 0); Err! = Nil {return FMT. Errorf ("Can ' t set cookie%s", err)}//perform the task if err: = task. Run (); Err! = Nil {return FMT. Errorf ("Error running Devicecreate (createpool)%s", err)}//wait for thin pool to be created udevwait (cookie) return nil}//create operation, The task encapsulates the operation of the Devicemapper 1.2 func createtask (t TaskType, name String (*task, error) {//create TaskType corresponding wrapper function Task: = taskcreate (t) if Task = = Nil {return nil, fmt. Errorf ("Can ' t create task of type%d", int (t))}if ERR: = task. SetName (name); Err! = Nil {return nil, fmt. Errorf ("Can ' t set task Name%s", name)}return task, nil}//creates a specified action type 1.3 func taskcreate (TaskType tasktype) *task {//create operation C Task: = dmtaskcreate (int (tasktype)) if Ctask = = Nil {return Nil}task: = &task{unmanaged:ctask}runtime. Setfinalizer (Task, (*task). Destroy) return task}//create the specified operation//dmtaskcreate=dmtaskcreatefct1.4 func dmtaskcreatefct ( TaskType int) *cdmtask {return (*cdmtask) (C.dm_task_create (C.int (TaskType)))}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.