Home | History | Annotate | Download | only in dm
History log of /src/sys/dev/dm/dm_ioctl.c
RevisionDateAuthorComments
 1.57  14-Jan-2024  mlelstv Avoid leaving a configured device without resources.
 1.56  13-Oct-2022  andvar s/exaple/example/
 1.55  21-Aug-2021  andvar fix typos in sys/dev/dm code comments and documentation.
also remove some trailing space in documentation.
 1.54  20-Aug-2021  andvar fix various typos in comments and log messages.
 1.53  24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.52  21-Jun-2021  christos fix proplib deprecation
 1.51  07-May-2021  hannken Make sure the unit number of device-mapper devices matches their minor number.
 1.50  08-Jul-2020  thorpej branches: 1.50.6;
Adapt to proplib API chanages.
 1.49  23-Dec-2019  tkusumi dm: Make target's ->table() optional

Since ->info() (counter part of ->table() in the original dm design
in Linux kernel in .status where both INFO and TABLE are optional)
is an optional handler, make ->table() optional as well. Some
targets don't have anything to do in ->table() just as in ->info().

taken-from: DragonFlyBSD
 1.48  21-Dec-2019  tkusumi dm: Remove target's ->deps() by implementing deps in dm core

Retrieving device dependencies doesn't need to be target specific.
The reason it currently needs ->deps() is because dm core doesn't
have data structure that allows table to walk through target's
underlying devices. Add struct dm_mapping to be able to do this,
and remove ->deps()'s from targets which basically do the same thing.

=====(A) before this commit
table
| [dm core]
-------------------------------------------------------
| pdev pdev pdev [dm targets]
v ^ ^ ^
target----/---------/---------/
(void*)

=====(B) this commit
table---->mapping-->mapping-->mapping-->...
| | | |
| v v v [dm core]
-------------------------------------------------------
| pdev pdev pdev [dm targets]
v ^ ^ ^
target----/---------/---------/
(void*)

taken-from: DragonFlyBSD
 1.47  19-Dec-2019  tkusumi dm: Minor dm_ioctl.c fixes (indentation/typo/type/etc)
 1.46  15-Dec-2019  tkusumi dm: Style cleanups (no functional changes)
 1.45  15-Dec-2019  tkusumi dm: Rename targets' ->status() to ->table() given ->info() exists

Since now that dm targets in NetBSD have ->info() for "status",
->status() should be renamed to ->table() for "table",
given how dm target status was originally designed in Linux kernel.

taken-from: DragonFlyBSD
 1.44  14-Dec-2019  tkusumi dm: Don't try to implement "status" as subset of "table"

The way dm_table_status_ioctl() implements "status" and "table" is
not compatible with Linux kernel. Some targets have different outputs
that "status" can't be implemented as subset of "table".

Add ->info() handler to sync with "status" behavior in Linux kernel.
Some targets which currently exist in NetBSD (I think striped)
as well as some minor targets that I plan to port to NetBSD
can/should implement ->info(), but will do that in a different commit.

taken-from: DragonFlyBSD
 1.43  14-Dec-2019  tkusumi dm: Make dm_dbg_print_flags() take uint32_t flag

which comes from prop_dictionary_get_uint32() result.
taken-from: DragonFlyBSD
 1.42  14-Dec-2019  tkusumi dm: Move extern declaration of global variables to dm.h
 1.41  12-Dec-2019  tkusumi dm: Make target's ->init() take parsed argc and argv

This gets rid of the same parser code in each target using strsep(3).
taken-from: DragonFlyBSD
 1.40  08-Dec-2019  tkusumi dm: Refactor target's ->init() i/f

Take dm_table_entry_t* instead of void**.
Remove dm_dev_t* unneeded by target code.
No functional change, but for future changes.

taken-from: DragonFlyBSD
 1.39  06-Dec-2019  tkusumi dm: Fix typos in comments/messages

taken-from: DragonFlyBSD
 1.38  05-Dec-2019  tkusumi dm: Remove unneeded dm_get_version_ioctl()

"version" is implemented and handled in userspace,
hence dm ioctl doesn't need to support it.

taken-from: DragonFlyBSD
 1.37  04-Dec-2019  tkusumi dm: style + whitespace + indentation fixes

No functional changes.
 1.36  03-Dec-2019  tkusumi dm: Include <sys/vnode.h> in dm.h

dm.h already depends on vnode, so have dm.h include <sys/vnode.h>
instead of other .c files.

taken-from: DragonFlyBSD
 1.35  01-Dec-2019  tkusumi dm: Remove unused dm_dev::dev_type

Given OOP-like architecture of dm target device structure,
dm_dev doesn't need to have self contained target type field,
and in fact this is unused.
 1.34  30-Nov-2019  tkusumi dm: Always initialize target's status string

Explicitly clear status string to prevent dmsetup(8) from
printing binary junk to stdout. Similar change has been
applied to DragonFlyBSD since 2015.

https://github.com/DragonFlyBSD/DragonFlyBSD/commit/a6cf54187fd7c3e994c573215806ec03572c038e

taken-from: DragonFlyBSD
 1.33  11-Nov-2018  mlelstv Only _if_ an inactive table has been loaded, make it active when resuming.
Fixes lvrename operation.
 1.32  05-Jan-2018  christos branches: 1.32.2; 1.32.4;
PR/52900: Tomohiro Kusumi: Fix kernel panic when target's ->init() failed
Reliably unbusy the target in the *all* the destroy routines, so ioctl
does not need to do it.
 1.31  01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.30  10-May-2015  christos branches: 1.30.8;
CID 976256: Help coverity understand that when the list is empty the head
is NULL.
 1.29  02-Oct-2014  justin branches: 1.29.2;
Call prop_dictionary_get_uint32 with uint32_t
 1.28  24-Dec-2013  mlelstv release proplib iterator in failure paths.
 1.27  18-Oct-2013  christos remove unused variables
 1.26  27-Aug-2011  ahoka branches: 1.26.2; 1.26.12; 1.26.16;
- add a function to get the inactive table's size
- some whitespace fix from emacs...
 1.25  24-May-2011  joerg Fix logic error
 1.24  06-Dec-2010  haad branches: 1.24.2;
We don't need 64 bit variable for dm_device coutner, too.
 1.23  06-Dec-2010  haad Add comment about dm_dev minor, and change it to 32bit value we realy not
going to use so much device minor numbers.
 1.22  18-May-2010  haad Fix typo in comment.
 1.21  25-Feb-2010  jakllsch branches: 1.21.2;
Be sure to config_cfattach_attach() in dmattach().
Loosely based on patch from Brian Brombacher,
with other inspriation from vnd(4).

This should fix PR kern/42799.

While here, a few prototype, style and namespace pollution-related changes.
 1.20  04-Jan-2010  haad branches: 1.20.2;
Indent files remove unnecessary blank lines, white spaces and KNFize code.
 1.19  03-Jan-2010  haad Hook device-mapper to autoconf framework. Add dm_attach, dm_match and dm_detach
routines used by autoconf users. Change dm_dev_remove_ioctl to call dm_detach.

This should be primary used by kernel to disable devices during shutdown of
system with nested disk devices.

Requested by dyoung@.
 1.18  29-Dec-2009  haad Add private lock to dm_dev_t used for mutual exclusion for diks(9) api
routines. This change fixes PR kern/42532.
 1.17  06-Dec-2009  haad Add support for DM_QUERY_INACTIVE_TABLE_FLAG to dm_table_status and dm_table_deps
this flag was introduced to dm->lvm protocol in 4.16.0 version of it. Restore
vrsion check functionality and sent back actual kernel driver version.
 1.16  05-Dec-2009  haad Fix bug in dm_table_resume_ioctl where dmv->flags was sent back to libdevmapper
except flags variable. This fixes weird behaviour, when worng links to
devices in /dev/mapper were created after lvrename/lvresize.
 1.15  01-Dec-2009  haad Revert my commit which have added knowledge about dm targets to libdevmapper,
this breaks abstraction. Because only lvmtools/lvmlib and device-mapper can
have knowledge about target mapping and libdevmapper only passes requests
from lvmtools to kernel and back. Bump major library and driver version.

Requested by: yamt@
 1.14  09-Sep-2009  haad Fix bug in kmem_alloc/kmem_free of params string. Params string was
allocated with length DM_MAX_PARAMS_SIZE and released with strlen + 1 size.

Disable KM_NOSLEEP allocation because we do not need them here there is
nothing critical in ioctl part of dm driver.

Bug reported by jak@.
 1.13  05-Jun-2009  haad Add support for DIOCGDISKINFO to disk like device drivers. Change
partutil.c::getdiskinfo to use it to get disk geometry info.
Use DIOCGWEDGEINFO ioctl to get information about partition size, if disk
driver doesn't support it use old DIOCGDINFO. This patch adds support for
wedge like devices(lvm logical volumes, ZFS zvol partitions) to newfs and
other tools.

No objections on tech-userlevel@.
 1.12  05-Jun-2009  haad Parse dm param string in libdevmapper and not in a dm target init function.
Create proplib param dictionary entry in libdevmapper and pass it to dm in
dm_ioctl dict.
Param target is then passed to target init function, where is parse. I like
this aproach much better than passing char **argv and trusting to user input.

I have bumped minor lib/driver version.

XXX. Add more sanity checks in kernel.
 1.11  13-Apr-2009  haad branches: 1.11.2;
Destroy locks in dm_dev_free, do not allocate struct disk twice.
 1.10  06-Apr-2009  haad Use functions from disk(9) framework. Initialize disk/disklabel during
dm_device_create_ioctl, before calling dmgetdisklabel.
Use disk_busy/disk_unbusy in dmstrategy to display LVM LV's in iostat
output.
 1.9  08-Mar-2009  agc Fix tyop in previous.
 1.8  20-Feb-2009  haad Release tables before we drop reference on device, now creating device with
nonexistent target fails and not ends with deadlock.
 1.7  19-Feb-2009  haad Add support for autoloading of device-mapper targets modules. Add
dm_target_autoload function which tries to load target module. Fix two
deadlocks in dm_table_load_ioctl error path(I forgot to call dm_dev_unbusy).
 1.6  16-Jan-2009  haad branches: 1.6.2; 1.6.4; 1.6.6;
Disable unloading of dm driver when there are any devices defined. This means
that we have to run lvm vgchange -a n before modunload in NetBSD.

We really need to disable module unloading only for mounted devices, I have
to look at vfs_hooks for mount/umount calls and find way how to mark devices
as mounted in dm driver.
 1.5  11-Jan-2009  haad Use 64bit long minor nuber in dm_dev structure.
 1.4  21-Dec-2008  haad Fix error path in target_init call. When initializing target fails i have
to release table before I try to destroy it and I haveto unbusy device, too.
 1.3  19-Dec-2008  haad Add infrastructure needed to load device-mapper targets as modules.
Targets wasn't converted yet and at least snapshot target will be converted
in a near future.
 1.2  19-Dec-2008  haad Merge the haad-dm branch to -current. This branch adds LVM functionality to
the base NetBSD system. It uses Linux LVM2 tools and our BSD licensed
device-mapper driver.

The device-mapper driver can be used to create virtual block devices which
maps virtual blocks to real with target mapping called target. Currently
these targets are available a linear, zero, error and a snapshot (this is
work in progress and doesn't work yet).

The lvm2tools adds lvm and dmsetup binary to based system, where the lvm
tool is used to manage and administer whole LVM and the dmestup is used to
communicate iwith device-mapper kernel driver. With these tools also
a libdevmapper library is instaled to the base system.

Building of tools and driver is currently disable and can be enabled with
MKLVM=yes in mk.conf. I will add sets lists and rc.d script soon.

Oked by agc@ and cube@.
 1.1  07-Jul-2008  haad branches: 1.1.2;
Add dmgetdefaultdisklabel to get virtual disklabel for Logical Volume device. Add snapshot targets (snapshot, snapshot-origin), add dm_type to dm_dev structure to identify type of device. e.g. we can have mirrored disk device with snapshot on them and spare disk on them. When driver want to work with snapshot devices, it looks to upcalls list and finds all DM_SNAPSHOT devices.
 1.1.2.23  03-Dec-2008  haad Fix several memory leaks in proplib library handling. Rework dm_cmd_to_fun
function to use prop_string_t.
 1.1.2.22  05-Nov-2008  haad Fix copyright in TNF licenses.
 1.1.2.21  02-Nov-2008  haad Use typedef in all structures in dm driver and use them in source code.
No functional change expected.
 1.1.2.20  29-Oct-2008  haad Fix locking in dm_table_load_ioctl. With new locking architecture is not
allowed to call write table operation (dm_table_destroy,
dm_table_switch_tables) after dm_table_get_entry call. Because after
after table_get_entry call we are holding table reference counter and
writer table functions will sleep while reference counter is 0.
 1.1.2.19  16-Oct-2008  haad Rewrite locking in dm driver for last time. Replace rwlock with mutex/cv.
Move table lists to separate structure called table_head and access them
through dm_table interface. Thx go@, rmind@ and Dusan Bernat for help and
suggestions.
 1.1.2.18  26-Sep-2008  haad Rework disklabel stuff once again, do not allocate nw disklabel struct
every time DIOCGPART is called. Recreate disklabel after resume so it
contains correct table. Do not leak device when I want to create device
with name which already exists.

XXX: dm_dev_resume_ioctl and dmgetdisklabel is broken I need to completly
rework locking here soon.
 1.1.2.17  22-Sep-2008  haad Fix bug where I tried to prop_object_release null object which caused weird
atuvm panic. Change init functions to failed when they receive params string
== NULL when they need some data.
 1.1.2.16  11-Sep-2008  haad Add new dm_target_*_deps function which will get all dependiences from
selected target. It is used to get device dependencies during
dm_table_deps_ioctl. Remove dm_dev::pdevs list which was really hard to
manage and wasn't use for anything usefull.
 1.1.2.15  10-Sep-2008  haad Introduce new dm_dev_lookup and use it to lookup for device name, uuid and
minor number in device global list.
 1.1.2.14  08-Sep-2008  haad Add new version of snapshot code for nowonlyinitial configuration of
snapshots (parsing parameters strings and opening devices was added).

Fixonebug in dm_pdev where was one SLIST_ENTRY used to for global
pdev list and for per device pdev list. This bug was hidden for a
long time because I haven't used devices with more than one pdev.
 1.1.2.13  05-Sep-2008  haad Rework handling of disklabel stuff. Remove disklabel from dstruct dm_dev
and generate it dynamicaly for every call. Withthese changes using -F and
-s options when creating file-system with newfs is not needed anymore.
 1.1.2.12  03-Sep-2008  haad Simplify locking remove mutexes from pdev, target part of dm and only allow
one ioctl command to be in driver at time. Ioctl interface of dm device is
not performance critical so I don't need to paralelize dm driver so much.

Add new dev_type --> DM_DELETING_DEV which is set to device during
dm_device_remove_ioctl. To disable any incoming IO which will come in time
window between geting a rw_lock and removing device from global dev list.

XXX. I can't remove mutex from dm_dev.c also because dm_lookup_minor is
called from device-mapper and not from dm_ioctl.c
 1.1.2.11  28-Aug-2008  haad Add new parameters to netbsd proplib protocol. Fix flags manipulation
in our driver it should behaves like linux now. Fix other minor protocol
differences.
 1.1.2.10  20-Aug-2008  haad Fix bug reported by blymn@, after failed dm_target_*_init I haven't cleaned
tables properly and therefore after next try I get panic.

Fix dm_dev_remove_ioctl to properly remove pdevs from a device list.
 1.1.2.9  19-Aug-2008  haad Remove unnecessary call of dm_pdev_rem in dm_table_load. Change dm_dev_remove
to call dm_pdev_decr for all devices in pdev list.

Because target config contains pdevs I have to decrement them in
dm_target_*_destroy.
 1.1.2.8  19-Aug-2008  haad Add $NetBSD$ tag to all dm driver sources.
 1.1.2.7  02-Aug-2008  haad Fix dm_table_status_ioctl error path. When there is no active table ioctl
routine have to return.
 1.1.2.6  28-Jul-2008  haad Add basic synchronization between dmstrategy routine and ioctl functions.
Dmstrategy locks, per dev rwlock for reading and all struct dm_dev changing
routines in dm_ioctl(such as dm_table_resume_ioctl, dm_dev_remove_ioctl),
have to lock it for writing.
Modify comments and ad description to each function about locking which
I think should be used there. I want to use mutex for synchronization of
different ioctl calls on same device. e.g. we can't remove table from
inactive slot when there is dm_table_status_ioctl runnning.
 1.1.2.5  28-Jul-2008  haad Add status function to targets. This function is called from dm_table_status_ioctl,
when DM_STATUS_TABLE_FLAG is specified and it's purpose is construct params string.
Which can be sent back to libdevmapper.

Add adding removing of the DM_SUSPENDED_FLAG flag in dm_dev_suspend/resume ioctls.
 1.1.2.4  22-Jul-2008  haad Change parsing of parameter string. Remove knowledge about pramaer string
from dm_table_load_ioctl and move it to target_init routines. Parameter
string is targets specific and therefore only target routine know how to
parse it correctly. Remove unneeded parameter from dm_target_*_init(argc)
and change dm target routines accordingly.

Simplify dm_table_load_ioctl and move pdev inserting code to target init
funstions.
 1.1.2.3  19-Jul-2008  haad *** empty log message ***
 1.1.2.2  11-Jul-2008  haad KNFize my sources add space after comma in function parameters.
Wrap to 80 chars per line.
 1.1.2.1  07-Jul-2008  haad Import of device-mapper driver. This driver is BSD rewrite of linux dm driver.
For now only error, linear and zero targets are supported. This driver uses NetBSD
specific ioctl protocola based on proplib.

I was able to create logical volume (with lvm2tools lvcreate utility) with this
version of driver, newfs it and mount it.
 1.6.6.2  23-Jul-2009  jym Sync with HEAD.
 1.6.6.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.4.4  28-Apr-2009  skrll Sync with HEAD.
 1.6.4.3  03-Mar-2009  skrll Sync with HEAD.
 1.6.4.2  19-Jan-2009  skrll Sync with HEAD.
 1.6.4.1  16-Jan-2009  skrll file dm_ioctl.c was added on branch nick-hppapmap on 2009-01-19 13:17:53 +0000
 1.6.2.2  17-Jan-2009  mjf Sync with HEAD.
 1.6.2.1  16-Jan-2009  mjf file dm_ioctl.c was added on branch mjf-devfs2 on 2009-01-17 13:28:53 +0000
 1.11.2.6  11-Aug-2010  yamt sync with head.
 1.11.2.5  11-Mar-2010  yamt sync with head
 1.11.2.4  16-Sep-2009  yamt sync with head
 1.11.2.3  20-Jun-2009  yamt sync with head
 1.11.2.2  04-May-2009  yamt sync with head.
 1.11.2.1  13-Apr-2009  yamt file dm_ioctl.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:36 +0000
 1.20.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.20.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.21.2.3  31-May-2011  rmind sync with head
 1.21.2.2  05-Mar-2011  rmind sync with head
 1.21.2.1  30-May-2010  rmind sync with head
 1.24.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.26.16.1  18-May-2014  rmind sync with head
 1.26.12.2  03-Dec-2017  jdolecek update from HEAD
 1.26.12.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.2.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.29.2.2  28-Aug-2017  skrll Sync with HEAD
 1.29.2.1  06-Jun-2015  skrll Sync with HEAD
 1.30.8.1  17-May-2017  pgoyette At suggestion of chuq@, modify config_attach_pseudo() to return with a
reference held on the device.

Adapt callers to expect the reference to exist, and to ensure that the
reference is released.
 1.32.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.32.4.1  10-Jun-2019  christos Sync with HEAD
 1.32.2.1  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.50.6.2  01-Aug-2021  thorpej Sync with HEAD.
 1.50.6.1  13-May-2021  thorpej Sync with HEAD.

RSS XML Feed