Lines Matching refs:snapshot
54 * This module implements the file system snapshot code, which provides a
58 * "fssnap" that represents the snapshot. Each snapshot is assigned a
60 * device with a high minor number is used to initiate snapshot creation and
63 * file system at the time the snapshot was created.
70 * When a snapshot is to be created, the user utility will send an ioctl to
73 * hold old data before it is overwritten, and other snapshot parameters.
77 * no changes occur while the snapshot is being created. It then calls
78 * fssnap_create() to create state for a new snapshot, from which an opaque
79 * handle is returned with the snapshot locked. Next, the file system must
80 * populate the "candidate bitmap", which tells the snapshot code which
85 * allocated blocks in the file system at the time the snapshot was created.
89 * complete the snapshot creation and unlock the snapshot. The file system
92 * Once a snapshot is created, the file system must perform all writes
101 * data to the backing file specified at snapshot creation time. The
110 * snapshot pseudo-driver can piece together the original file system
122 * - The snapshot driver, which is a character/block driver
123 * representing the snapshot itself. These routines are
127 * are used by file systems that use this snapshot implementation.
131 * - The helper routines used by the snapshot driver and the fssnap
139 static struct snapshot_id *snapshot = NULL;
152 /* snapshot driver */
238 "snapshot driver", /* Name of the module */
272 * Fill in the snapshot operations vector for file systems
342 * This section implements the snapshot character and block drivers. The
344 * applications that wish to back it up or mount it. The snapshot driver
346 * tells the snapshot driver where to find the data necessary to piece
350 * The read request may require the snapshot driver to retrieve data from
354 * The device minor number corresponds to the snapshot number in the list of
355 * snapshot identifiers. The soft state for each minor number is simply a
356 * pointer to the snapshot id, which holds all of the snapshot state. One
357 * minor number is designated as the control device. All snapshot create
365 * snap_getinfo() - snapshot driver getinfo(9E) routine
384 * snap_attach() - snapshot driver attach(9E) routine
386 * sets up snapshot control device and control state. The control state
408 /* the control sid is not linked into the snapshot list */
428 * snap_detach() - snapshot driver detach(9E) routine
430 * destroys snapshot control device and control state. If any snapshots
448 /* free up the snapshot list */
449 for (sidp = snapshot; sidp != NULL; sidp = sidnextp) {
456 snapshot = NULL;
474 * snap_open() - snapshot driver open(9E) routine
476 * marks the snapshot id as busy so it will not be recycled when deleted
477 * until the snapshot is closed.
521 /* check to see if this snapshot has been killed on us */
523 cmn_err(CE_WARN, "snap_open: snapshot %d does not exist.",
544 * at this point if a valid snapshot was found then it has
551 * snap_close() - snapshot driver close(9E) routine
553 * unsets the busy bits in the snapshot id. If the snapshot has been
554 * deleted while the snapshot device was open, the close call will clean
578 "snapshot %d.", minor);
585 /* Mark the snapshot as not being busy anymore */
601 * if this is the last close on a snapshot that has been
628 * snap_read() - snapshot driver read(9E) routine
630 * reads data from the snapshot by calling snap_strategy() through physio()
643 "snap_read: could not find state for snapshot %d.", minor);
650 * snap_strategy() - snapshot driver strategy(9E) routine
655 * is returned. The snapshot driver is read-only, so a write is invalid.
669 /* snapshot device is read-only */
681 "snap_strategy: could not find state for snapshot %d.",
769 * This function does the real work of the snapshot driver.
795 * was not allocated when the snapshot was taken. Since it does
796 * not contain data associated with this snapshot, just return a
914 * snap_print() - snapshot driver print(9E) routine
928 "snap_print: could not find state for snapshot %d.", minor);
932 cmn_err(CE_NOTE, "snap_print: snapshot %d: %s", minor, str);
938 * snap_prop_op() - snapshot driver prop_op(9E) routine
969 "snapshot %d.", minor);
995 * snap_ioctl() - snapshot driver ioctl(9E) routine
998 * ioctl requests: create a snapshot or delete a snapshot. In either
1002 * destroying a snapshot, including any file system specific operations
1003 * that must be performed as well as setting up and deleting the snapshot
1101 for (sidp = snapshot; sidp != NULL; sidp = sidnextp) {
1215 * called by the snapshot driver to find data that has been translated.
1280 * called when the snapshot is deleted. This frees all of the nodes in
1303 * The following functions implement snapshot interface routines that are
1304 * called by the file system to create, delete, and use a snapshot. The
1308 * snapshot device drivers.
1318 * bdev_strategy()), the snapshot may not be consistent.
1321 * the snapshot was not deleted out from under it or deleted and then
1324 * a POINTER TO A POINTER to the snapshot id. Once the snapshot id is
1325 * locked, it knows things are ok and that this snapshot is really for
1346 * Because we were not able to take the snapshot read lock BEFORE
1347 * checking for a snapshot back in the file system, things may have
1348 * drastically changed out from under us. For instance, the snapshot
1350 * for this file system but now the snapshot number is in use by another
1353 * Having a pointer to the file system's snapshot id pointer allows us
1361 * if this file system's snapshot was disabled, just pass the
1370 * Once we have the reader lock the snapshot will not magically go
1377 * set to indicate the snapshot should be deleted and no new
1388 * If the file system is no longer pointing to the snapshot we were
1390 * it may be going to a snapshot for a different file system.
1391 * Even if the file system snapshot pointer is still the same, the
1392 * snapshot may have been disabled before we got the reader lock.
1401 * At this point we're sure the snapshot will not go away while the
1403 * writing to the correct snapshot.
1409 * for the snapshot to be deleted in this time frame. If this
1431 * allocated when the snapshot was created, then it checks to see whether
1453 /* make sure the snapshot is active */
1494 * it never changes once the snapshot is created. The reader lock is
1511 * larger since the snapshot was taken.
1518 * snapshot was created then no copy-on-write will be
1541 * the snapshot (wants the sid_rwlock as a writer, but can't
1599 "old data for snapshot %d, chunk %llu, disk block "
1618 * Add a reference to the snapshot id so the lower level
1673 /* if the snapshot was disabled from under us, drop the request. */
1687 cmn_err(CE_WARN, "fssnap_write_taskq: snapshot %d (%s) has "
1730 * fssnap_create_impl() - called from the file system to create a new snapshot
1732 * allocates and initializes the structures needed for a new snapshot.
1734 * create a new snapshot. An unused snapshot identifier is either found
1736 * system will use to identify this snapshot. The snapshot number
1737 * associated with the snapshot identifier is the same as the minor
1738 * number for the snapshot device that is used to access that snapshot.
1740 * The snapshot can not be used until the candidate bitmap is populated
1743 * Nearly all of the snapshot locks are held for the duration of the
1769 * Look for unused snapshot identifiers. Snapshot ids are never
1770 * freed, but deleted snapshot ids will be recycled as needed.
1776 for (sidp = snapshot; sidp != NULL; sidp = sidp->sid_next) {
1782 * activity on each snapshot is not stalled while searching
1783 * for a free snapshot id.
1788 * If the snapshot has been deleted and nobody is using the
1789 * snapshot device than we can reuse this snapshot_id. If
1790 * the snapshot is marked to be deleted (SID_DELETE), then
1799 * add a new snapshot identifier if there are no deleted
1814 sidp->sid_snapnumber = (snapshot == NULL) ? 0 : lastsnap + 1;
1817 sidp->sid_next = snapshot;
1818 snapshot = sidp;
1840 * Initialize task queues for this snapshot. Only a small number
1873 /* initialize kstats for this snapshot */
1882 * return with snapshot id rwlock held as a writer until
1893 * the file system at the time the snapshot is taken are candidates,
1931 * fssnap_create_done_impl() - complete the snapshot setup process
1934 * and it is ready to start using the snapshot. This routine releases
1935 * the snapshot locks, allows taskq tasks to start processing, and
1936 * creates the device minor nodes associated with the snapshot.
1960 /* allocate state structure and find new snapshot id */
1964 "state for snapshot %d.", snapnumber);
1972 /* create minor node based on snapshot number */
1978 "block minor node for snapshot %d.", snapnumber);
1987 "character minor node for snapshot %d.", snapnumber);
2002 * fssnap_delete_impl() - delete a snapshot
2004 * used when a snapshot is no longer needed. This is called by the file
2005 * system when it receives an ioctl request to delete a snapshot. It is
2008 * If the snapshot device is busy when the delete request is received,
2010 * associated with the snapshot; they will be deleted when the snapshot
2013 * NOTE this function takes a POINTER TO A POINTER to the snapshot id,
2032 * the snapshot list is append-only.
2044 * double check that the snapshot is still valid for THIS file system
2052 * Now we know the snapshot is still valid and will not go away
2127 "fssnap_delete_impl: could not find state for snapshot %d.",
2134 * and avoid many race conditions. Return the snapshot number
2146 * If the snapshot is not busy, free the device info now. Otherwise
2172 * fssnap_create_kstats() - allocate and initialize snapshot kstats
2276 * fssnap_update_kstat_num() - update a numerical snapshot kstat value
2307 * fssnap_delete_kstats() - deallocate snapshot kstats