函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\partition-generic.c Create Date:2022-07-27 18:56:31
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Must be called either with bd_mutex held, before a disk can be opened or* after all disk users are gone.

函数原型:struct hd_struct *add_partition(struct gendisk *disk, int partno, sector_t start, sector_t len, int flags, struct partition_meta_info *info)

返回类型:struct hd_struct

参数:

类型参数名称
struct gendisk *disk
intpartno
sector_tstart
sector_tlen
intflags
struct partition_meta_info *info
317  devt等于MKDEV(0, 0)
318  ddev等于disk_to_dev(disk)
329  :zoned恒等于Host-managed zoned block device
330  打印警告信息("%s: partitions not supported on host managed zoned block device\n", name of major driver )
332  返回:错误号
333  :zoned恒等于Host-aware zoned block device
334  打印信息("%s: disabling host aware zoned block device support due to partitions\n", name of major driver )
336  zoned等于Regular block device
337  退出
338  :zoned恒等于Regular block device
339  退出
342  err等于disk_expand_part_tbl - expand disk->part_tbl*@disk: disk to expand part_tbl for*@partno: expand such that this partno can fit in* Expand disk->part_tbl such that @partno can fit in. disk->part_tbl
343  如果err则返回:错误号
345  ptbl等于cu_dereference_protected() - fetch RCU pointer when updates prevented*@p: The pointer to read, prior to dereferencing*@c: The conditions under which the dereference will take place* Return the value of the specified RCU-protected pointer, but omit( Array of pointers to partitions indexed by partno. * Protected with matching bdev lock but stat and other * non-critical accesses use RCU. Always access through * helpers., 1)
347  如果part[partno]则返回:错误号
350  p等于分配内存并置零
351  如果非p则返回:错误号
354  如果非init_part_stats(p)则
355  err等于负ENOMEM
356  转到:out_free
359  seqcount_init( & nr_sects_seq)
360  pdev等于part_to_dev(p)
362  start_sect等于start
363  alignment_offset等于queue_limit_alignment_offset( & limits, start)
365  discard_alignment等于queue_limit_discard_alignment( & limits, start)
367  * nr_sects is protected by sequence counter. One might extend a * partition while IO is happening to it and update of nr_sects * can be non-atomic on 32bit machines with 64bit sector_t.等于len
368  partno等于partno
369  policy等于get_disk_ro(disk)
371  如果info
372  pinfo等于alloc_part_info(disk)
373  如果非pinfo
374  err等于负ENOMEM
375  转到:out_free_stats
377  memcpy(pinfo, info, info的长度)
378  info等于pinfo
381  dname等于dev_name(ddev)
382  如果是数字dev_set_name(pdev, "%sp%d", dname, partno)
384  否则dev_set_name(pdev, "%s%d", dname, partno)
387  device_initialize(pdev)
388  class等于block_class
389  type等于part_type
390  parent等于ddev
392  err等于lk_alloc_devt - allocate a dev_t for a partition*@part: partition to allocate dev_t for*@devt: out parameter for resulting dev_t* Allocate a dev_t for block device
393  如果err则转到:out_free_info
395  dev_t, creates the sysfs "dev" 等于devt
398  dev_set_uevent_suppress(pdev, 1)
399  err等于device_add(pdev)
400  如果err则转到:out_put
403  err等于负ENOMEM
404  holder_dir等于kobject_create_and_add() - Create a struct kobject dynamically and* register it with sysfs.*@name: the name for the kobject*@parent: the parent kobject of this kobject, if any.* This function creates a kobject structure dynamically and registers it
405  如果非holder_dir则转到:out_del
408  dev_set_uevent_suppress(pdev, 0)
409  如果flags按位与ADDPART_FLAG_WHOLEDISK
410  err等于device_create_file(pdev, & dev_attr_whole_disk)
411  如果err则转到:out_del
415  err等于hd_ref_init(p)
416  如果err
417  如果flags按位与ADDPART_FLAG_WHOLEDISK则转到:out_remove_file
419  转到:out_del
423  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization(part[partno], p)
426  如果非dev_get_uevent_suppress(ddev)则通过发送一个uevent通知用户空间
428  返回:p
430  out_free_info :
431  free_part_info(p)
432  out_free_stats :
433  free_part_stats(p)
434  out_free :
435  释放内存
436  返回:错误号
437  out_remove_file :
438  device_remove_file(pdev, & dev_attr_whole_disk)
439  out_del :
440  递减引用计数对象
441  device_del(pdev)
442  out_put :
443  put_device(pdev)
444  返回:错误号
调用者
名称描述
blk_add_partition