Revision 1: 2.5 backport Revision 2: The locking when leaving __request was broken. Split off __deferring() Revision 3: s->table wasn't being set in the snapshot contructor Revision 4: I don't know why dm-ioctl.c was including rather than Revision 5: Four constants: DM_DIR, DM_MAX_TYPE_NAME, DM_NAME_LEN, DM_UUID_LEN Were being declared in device-mapper.h, these are all specific to the ioctl interface, so they've been moved to dm-ioctl.h. Nobody in userland should ever include so remove ifdef __KERNEL guards. Revision 6: No need to validate the parameters if we are doing a REMOVE_ALL command. Revision 7: Fluff Revision 8: Mempool version by Christoph Hellwig that holds the free objects in an array rather than a list. This prevents the objects getting dirtied, eg, people maybe expecting them to come out of a slab with a particular state. Revision 9: Return -ENOTBLK if lookup_device() finds the inode, but it is not a block device. [Cristoph Hellwig] Revision 10: get_kdev() was locking _minor_lock rather than &_minor_lock. [Heinz Mauelshagen] Revision 11: minor change for dm-strip.c. Tests for correct chunksize before it allocates the stripe context. [Heinz Mauelshagen] Revision 12: There's a bug in the dm-stripe.c constructor failing top check if enough destinations are handed in. [Heinz Mauelshagen] Revision 13: Give each device its own io mempool to avoid a potential deadlock with stacked devices. [HM + EJT] Revision 14: Let the persistent/non persistent arg to the snapshot constructor be case insensitive. [Heinz Mauelshagen] Revision 15: queue_io() was checking the DMF_SUSPENDED flag rather than the new DMF_BLOCK_IO flag. This meant suspend could deadlock under load. Revision 16: dm_suspend(): Stop holding the read lock around the while loop that waits for pending io to complete. Revision 17: Add a run_task_queue(&tq_disk) to encourage pending io to flush when we're doing a dm_suspend(). Revision 18: Don't hook the io until after the target->map function has been called. Revision 19: Lift the dm_io allocation out of __map_buffer so that it is outside of the read lock. Hook all io, not just simple mappings. Revision 20: Use a rw_semaphore in dm_target.c rather than a rwlock_t, just to keep in line with dm.c Revision 21: Don't let the ioctl interface drop a suspended device. Revision 22: Call dm_put_target_type() *after* calling the destructor. Revision 23: Fluff Revision 24: printk tgt->error if dm_table_add_target() fails. Revision 25: Just return an error from the error targets map function, rather than erroring the buffer_head. Revision 26: Export dm_table_get_mode() Revision 27: If an alloc_page() call fails in init_pages(), unlock all locked pages before freeing them. [Kevin Corry] Revision 28: The calls to calc_block_sizes() in kcopyd_write_pages() and kcopyd_copy() are redundant, since kcopyd_io() already calls calc_block_sizes(). Revision 29: Remove the line in dispatch_bh() that sets bh->b_dev to B_FREE, since it sets bh->b_dev to job->disk.dev a few lines later. [Kevin Corry] Revision 30: Move a set_bit() into the preceeding assignment statement. [Kevin Corry] Revision 31: Set bh->b_count to 1 in dispatch_bh(). [Kevin Corry] Revision 32: Comment fix in run_pages_job(). [Kevin Corry] Revision 33: In copy_write(), don't need to set job->context = info, since it is already set to that when the function is called. [Kevin Corry] Revision 34: Always halt a copy if the read part failed, not just when there is a notify_fn (fix coding error). [Kevin Corry] Revision 35: 'Persistent' flag checking in the snapshot target constructor had a coding error which meant that it was always invalid. Revision 36: Introduce an end_io method to the target types. Revision 37: Allow the map method to pass some context to the endio method. Revision 38: When reloading a device the ioctl interface was forgetting to drop a reference on the new table. Revision 39: alloc_io() cannot fail, so stop checking the return value. Revision 40: Fix problem with devfs when unloading the dm module. dm-ioctl.c: deregister the misc device, and its associated symlink *before* removing the /dev/mapper dir. [Alasdair Kergon] Revision 41: Hook the io before we call the targets map function, this allows us to implement little things like the zero target. Revision 42: Silly mistake in error path when an unknown target type is requested. Revision 43: Define SECTOR_SHIFT and SECTOR_SIZE in dm.h so each individual DM source file doesn't have to define them. Revision 44: When generating STATUSTYPE_TABLE strings, use bdevname() instead of kdevname() so the device-name will match the ones generated in the 2.5 kernels. This should keep the user-space tools simpler, since they will only have to parse one form of the device-name strings. [Kevin Corry] Revision 45: Allow slashes ('/') within a DM device name, but not at the beginning. Devfs will automatically create all necessary sub-directories if a name with embedded slashes is registered. [Kevin Corry] Revision 46: When initializing the ioctl interface, always print the info message, instead of only when devfs is not present. [Kevin Corry] Revision 47: When running on ppc64, sparc64, or x86-64, register ioctls with the ioctl32 translation layer. [Don Mulvey] Revision 48: In snapshot_ctr(), if the call to register_snapshot() fails, we need to unlock the origin's filesystem (if the VFS-lock patch has been applied). [Kevin Corry] Revision 49: In persistent_prepare(), when incrementing the next_free field and checking for the location for the next metadata area, it doesn't seem to account for the header chunk at the beginning of the cow device. For example: chunk_size = 32 (16k) exceptions_per_area = 1024 stride = 1025 The header is chunk 0, the first metadata area is chunk 1, and the first data area is chunks 2 through 1025. When next_free equals 1024 (the second- to-last data chunk in the first area), it will be incremented to 1025, then mod'd with stride to get 0, and then incremented again to 1026. This effectively skips the last data chunk in the first data area and sets next_free to the chunk for the second metadata area. I'm guessing this will eventually look like data corruption if the snapshot tries to read data from that chunk, since it will eventually be overwritten by metadata. This patch corrects this by checking for a mod value of 1, instead of 0. Another possible solution would be to change the prefix-increment to a postfix-increment. [Kevin Corry] Revision 50: Revert patches 44, 45 and 47 - will be re-integrated later. [Alasdair Kergon] Revision 51: Support for more architectures (parisc, mips64, ppc64, s390x, sparc64, x86_64) [Alasdair Kergon] Revision 52: In persistent_prepare(), the "enough-room-left" check only verifies that the start of the next-free chunk is within the cow device. If the cow device is not an even multiple of the chunk-size, the snapshot code will eventually try to write off the end of the cow device. Check that the entire next-free chunk is within the cow device. [Kevin Corry] Revision 53: In dm_create_persistent(), when setting up an existing snapshot, if the valid bit from the snapshot header is not set, refuse to activate the snapshot. [Kevin Corry] Revision 54: In __map_buffer(), the call to dm_table_find_target() will never return a NULL pointer (provided every DM device table has a valid "targets" array, which should be the case). It may, however, return a pointer to a blank target record (since there are always a KEYS_PER_NODE-multiple of target records in the B-tree, but not all of these target records are necessarily used). This will occur when DM receives an I/O request past the end of a device. (You'd think this shouldn't happen, but it does - generic_make_request() will allow an I/O one sector past the end of a device with an even number of sectors.) Instead of checking for a NULL return from dm_table_find_target(), check for a valid "type" field in the returned target. [Kevin Corry] Revision 55: Whitespace tweaking. [Alasdair Kergon] Revision 56: Tidy some DMWARNs. [Alasdair Kergon] Revision 57: Update version number. [Alasdair Kergon] Revision 58: signed/unsigned audit. Revision 59: Automatically register and deregister extra major numbers to get around the 256 minor limit in 2.4. Revision 60: Change VOLUME_SIZE() macro to volume_size() inline. Revision 61: Tidy away inode->i_rdev --> dev Revision 62: Change snapshot status line to how full it is as a fraction. [Alasdair Kergon] Revision 63: Remove ancient emacs crap. Revision 64: Remove bogus dm_suspended() check in dm-ioctl.c:remove() [Alasdair Kergon] Revision 65: Version 3 of the ioctl interface. [Alasdair Kergon] Revision 66: Change ioctl structs to be 8 byte aligned rather than sizeof(int). [Alasdair Kergon]