11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * Copyright (C) 2001 Sistina Software (UK) Limited. 30da336e5SAlasdair G Kergon * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * This file is released under the LGPL. 61da177e4SLinus Torvalds */ 71da177e4SLinus Torvalds 81da177e4SLinus Torvalds #ifndef _LINUX_DEVICE_MAPPER_H 91da177e4SLinus Torvalds #define _LINUX_DEVICE_MAPPER_H 101da177e4SLinus Torvalds 11416cd17bSHeinz Mauelshagen #include <linux/bio.h> 12f6fccb12SMilan Broz #include <linux/blkdev.h> 13416cd17bSHeinz Mauelshagen 141da177e4SLinus Torvalds struct dm_target; 151da177e4SLinus Torvalds struct dm_table; 1617b2f66fSAlasdair G Kergon struct mapped_device; 17f6fccb12SMilan Broz struct bio_vec; 181da177e4SLinus Torvalds 191da177e4SLinus Torvalds typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds union map_info { 221da177e4SLinus Torvalds void *ptr; 231da177e4SLinus Torvalds unsigned long long ll; 241da177e4SLinus Torvalds }; 251da177e4SLinus Torvalds 261da177e4SLinus Torvalds /* 271da177e4SLinus Torvalds * In the constructor the target parameter will already have the 281da177e4SLinus Torvalds * table, type, begin and len fields filled in. 291da177e4SLinus Torvalds */ 301da177e4SLinus Torvalds typedef int (*dm_ctr_fn) (struct dm_target *target, 311da177e4SLinus Torvalds unsigned int argc, char **argv); 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds /* 341da177e4SLinus Torvalds * The destructor doesn't need to free the dm_target, just 351da177e4SLinus Torvalds * anything hidden ti->private. 361da177e4SLinus Torvalds */ 371da177e4SLinus Torvalds typedef void (*dm_dtr_fn) (struct dm_target *ti); 381da177e4SLinus Torvalds 391da177e4SLinus Torvalds /* 401da177e4SLinus Torvalds * The map function must return: 411da177e4SLinus Torvalds * < 0: error 421da177e4SLinus Torvalds * = 0: The target will handle the io by resubmitting it later 4345cbcd79SKiyoshi Ueda * = 1: simple remap complete 442e93ccc1SKiyoshi Ueda * = 2: The target wants to push back the io 451da177e4SLinus Torvalds */ 461da177e4SLinus Torvalds typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio, 471da177e4SLinus Torvalds union map_info *map_context); 481da177e4SLinus Torvalds 491da177e4SLinus Torvalds /* 501da177e4SLinus Torvalds * Returns: 511da177e4SLinus Torvalds * < 0 : error (currently ignored) 521da177e4SLinus Torvalds * 0 : ended successfully 531da177e4SLinus Torvalds * 1 : for some reason the io has still not completed (eg, 541da177e4SLinus Torvalds * multipath target might want to requeue a failed io). 552e93ccc1SKiyoshi Ueda * 2 : The target wants to push back the io 561da177e4SLinus Torvalds */ 571da177e4SLinus Torvalds typedef int (*dm_endio_fn) (struct dm_target *ti, 581da177e4SLinus Torvalds struct bio *bio, int error, 591da177e4SLinus Torvalds union map_info *map_context); 601da177e4SLinus Torvalds 61999d8168SBryn Reeves typedef void (*dm_flush_fn) (struct dm_target *ti); 621da177e4SLinus Torvalds typedef void (*dm_presuspend_fn) (struct dm_target *ti); 631da177e4SLinus Torvalds typedef void (*dm_postsuspend_fn) (struct dm_target *ti); 648757b776SMilan Broz typedef int (*dm_preresume_fn) (struct dm_target *ti); 651da177e4SLinus Torvalds typedef void (*dm_resume_fn) (struct dm_target *ti); 661da177e4SLinus Torvalds 671da177e4SLinus Torvalds typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, 681da177e4SLinus Torvalds char *result, unsigned int maxlen); 691da177e4SLinus Torvalds 701da177e4SLinus Torvalds typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv); 711da177e4SLinus Torvalds 72647b3d00SAl Viro typedef int (*dm_ioctl_fn) (struct dm_target *ti, unsigned int cmd, 73aa129a22SMilan Broz unsigned long arg); 74aa129a22SMilan Broz 75f6fccb12SMilan Broz typedef int (*dm_merge_fn) (struct dm_target *ti, struct bvec_merge_data *bvm, 76f6fccb12SMilan Broz struct bio_vec *biovec, int max_size); 77f6fccb12SMilan Broz 781da177e4SLinus Torvalds void dm_error(const char *message); 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds /* 813cb40214SBryn Reeves * Combine device limits. 823cb40214SBryn Reeves */ 833cb40214SBryn Reeves void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev); 843cb40214SBryn Reeves 8582b1519bSMikulas Patocka struct dm_dev { 8682b1519bSMikulas Patocka struct block_device *bdev; 87aeb5d727SAl Viro fmode_t mode; 8882b1519bSMikulas Patocka char name[16]; 8982b1519bSMikulas Patocka }; 9082b1519bSMikulas Patocka 913cb40214SBryn Reeves /* 921da177e4SLinus Torvalds * Constructors should call these functions to ensure destination devices 931da177e4SLinus Torvalds * are opened/closed correctly. 941da177e4SLinus Torvalds * FIXME: too many arguments. 951da177e4SLinus Torvalds */ 961da177e4SLinus Torvalds int dm_get_device(struct dm_target *ti, const char *path, sector_t start, 97aeb5d727SAl Viro sector_t len, fmode_t mode, struct dm_dev **result); 981da177e4SLinus Torvalds void dm_put_device(struct dm_target *ti, struct dm_dev *d); 991da177e4SLinus Torvalds 1001da177e4SLinus Torvalds /* 1011da177e4SLinus Torvalds * Information about a target type 1021da177e4SLinus Torvalds */ 1031da177e4SLinus Torvalds struct target_type { 1041da177e4SLinus Torvalds const char *name; 1051da177e4SLinus Torvalds struct module *module; 1061da177e4SLinus Torvalds unsigned version[3]; 1071da177e4SLinus Torvalds dm_ctr_fn ctr; 1081da177e4SLinus Torvalds dm_dtr_fn dtr; 1091da177e4SLinus Torvalds dm_map_fn map; 1101da177e4SLinus Torvalds dm_endio_fn end_io; 111999d8168SBryn Reeves dm_flush_fn flush; 1121da177e4SLinus Torvalds dm_presuspend_fn presuspend; 1131da177e4SLinus Torvalds dm_postsuspend_fn postsuspend; 1148757b776SMilan Broz dm_preresume_fn preresume; 1151da177e4SLinus Torvalds dm_resume_fn resume; 1161da177e4SLinus Torvalds dm_status_fn status; 1171da177e4SLinus Torvalds dm_message_fn message; 118aa129a22SMilan Broz dm_ioctl_fn ioctl; 119f6fccb12SMilan Broz dm_merge_fn merge; 1201da177e4SLinus Torvalds }; 1211da177e4SLinus Torvalds 1221da177e4SLinus Torvalds struct io_restrictions { 1235ec140e6SVasily Averin unsigned long bounce_pfn; 1244f41b09fSVasily Averin unsigned long seg_boundary_mask; 1254f41b09fSVasily Averin unsigned max_hw_sectors; 1264f41b09fSVasily Averin unsigned max_sectors; 1274f41b09fSVasily Averin unsigned max_segment_size; 1284f41b09fSVasily Averin unsigned short hardsect_size; 1294f41b09fSVasily Averin unsigned short max_hw_segments; 1304f41b09fSVasily Averin unsigned short max_phys_segments; 131969429b5SNeilBrown unsigned char no_cluster; /* inverted so that 0 is default */ 1321da177e4SLinus Torvalds }; 1331da177e4SLinus Torvalds 1341da177e4SLinus Torvalds struct dm_target { 1351da177e4SLinus Torvalds struct dm_table *table; 1361da177e4SLinus Torvalds struct target_type *type; 1371da177e4SLinus Torvalds 1381da177e4SLinus Torvalds /* target limits */ 1391da177e4SLinus Torvalds sector_t begin; 1401da177e4SLinus Torvalds sector_t len; 1411da177e4SLinus Torvalds 1421da177e4SLinus Torvalds /* FIXME: turn this into a mask, and merge with io_restrictions */ 1431da177e4SLinus Torvalds /* Always a power of 2 */ 1441da177e4SLinus Torvalds sector_t split_io; 1451da177e4SLinus Torvalds 1461da177e4SLinus Torvalds /* 1471da177e4SLinus Torvalds * These are automatically filled in by 1481da177e4SLinus Torvalds * dm_table_get_device. 1491da177e4SLinus Torvalds */ 1501da177e4SLinus Torvalds struct io_restrictions limits; 1511da177e4SLinus Torvalds 1521da177e4SLinus Torvalds /* target specific data */ 1531da177e4SLinus Torvalds void *private; 1541da177e4SLinus Torvalds 1551da177e4SLinus Torvalds /* Used to provide an error string from the ctr */ 1561da177e4SLinus Torvalds char *error; 1571da177e4SLinus Torvalds }; 1581da177e4SLinus Torvalds 1591da177e4SLinus Torvalds int dm_register_target(struct target_type *t); 160*10d3bd09SMikulas Patocka void dm_unregister_target(struct target_type *t); 16117b2f66fSAlasdair G Kergon 16217b2f66fSAlasdair G Kergon /*----------------------------------------------------------------- 16317b2f66fSAlasdair G Kergon * Functions for creating and manipulating mapped devices. 16417b2f66fSAlasdair G Kergon * Drop the reference with dm_put when you finish with the object. 16517b2f66fSAlasdair G Kergon *---------------------------------------------------------------*/ 16617b2f66fSAlasdair G Kergon 16717b2f66fSAlasdair G Kergon /* 16817b2f66fSAlasdair G Kergon * DM_ANY_MINOR chooses the next available minor number. 16917b2f66fSAlasdair G Kergon */ 17017b2f66fSAlasdair G Kergon #define DM_ANY_MINOR (-1) 17117b2f66fSAlasdair G Kergon int dm_create(int minor, struct mapped_device **md); 17217b2f66fSAlasdair G Kergon 17317b2f66fSAlasdair G Kergon /* 17417b2f66fSAlasdair G Kergon * Reference counting for md. 17517b2f66fSAlasdair G Kergon */ 17617b2f66fSAlasdair G Kergon struct mapped_device *dm_get_md(dev_t dev); 17717b2f66fSAlasdair G Kergon void dm_get(struct mapped_device *md); 17817b2f66fSAlasdair G Kergon void dm_put(struct mapped_device *md); 17917b2f66fSAlasdair G Kergon 18017b2f66fSAlasdair G Kergon /* 18117b2f66fSAlasdair G Kergon * An arbitrary pointer may be stored alongside a mapped device. 18217b2f66fSAlasdair G Kergon */ 18317b2f66fSAlasdair G Kergon void dm_set_mdptr(struct mapped_device *md, void *ptr); 18417b2f66fSAlasdair G Kergon void *dm_get_mdptr(struct mapped_device *md); 18517b2f66fSAlasdair G Kergon 18617b2f66fSAlasdair G Kergon /* 18717b2f66fSAlasdair G Kergon * A device can still be used while suspended, but I/O is deferred. 18817b2f66fSAlasdair G Kergon */ 189a3d77d35SKiyoshi Ueda int dm_suspend(struct mapped_device *md, unsigned suspend_flags); 19017b2f66fSAlasdair G Kergon int dm_resume(struct mapped_device *md); 19117b2f66fSAlasdair G Kergon 19217b2f66fSAlasdair G Kergon /* 19317b2f66fSAlasdair G Kergon * Event functions. 19417b2f66fSAlasdair G Kergon */ 19517b2f66fSAlasdair G Kergon uint32_t dm_get_event_nr(struct mapped_device *md); 19617b2f66fSAlasdair G Kergon int dm_wait_event(struct mapped_device *md, int event_nr); 1977a8c3d3bSMike Anderson uint32_t dm_next_uevent_seq(struct mapped_device *md); 1987a8c3d3bSMike Anderson void dm_uevent_add(struct mapped_device *md, struct list_head *elist); 19917b2f66fSAlasdair G Kergon 20017b2f66fSAlasdair G Kergon /* 20117b2f66fSAlasdair G Kergon * Info functions. 20217b2f66fSAlasdair G Kergon */ 20372d94861SAlasdair G Kergon const char *dm_device_name(struct mapped_device *md); 20496a1f7dbSMike Anderson int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid); 20517b2f66fSAlasdair G Kergon struct gendisk *dm_disk(struct mapped_device *md); 20617b2f66fSAlasdair G Kergon int dm_suspended(struct mapped_device *md); 2072e93ccc1SKiyoshi Ueda int dm_noflush_suspending(struct dm_target *ti); 20889343da0SMikulas Patocka union map_info *dm_get_mapinfo(struct bio *bio); 20917b2f66fSAlasdair G Kergon 21017b2f66fSAlasdair G Kergon /* 21117b2f66fSAlasdair G Kergon * Geometry functions. 21217b2f66fSAlasdair G Kergon */ 21317b2f66fSAlasdair G Kergon int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo); 21417b2f66fSAlasdair G Kergon int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo); 21517b2f66fSAlasdair G Kergon 21617b2f66fSAlasdair G Kergon 21717b2f66fSAlasdair G Kergon /*----------------------------------------------------------------- 21817b2f66fSAlasdair G Kergon * Functions for manipulating device-mapper tables. 21917b2f66fSAlasdair G Kergon *---------------------------------------------------------------*/ 22017b2f66fSAlasdair G Kergon 22117b2f66fSAlasdair G Kergon /* 22217b2f66fSAlasdair G Kergon * First create an empty table. 22317b2f66fSAlasdair G Kergon */ 224aeb5d727SAl Viro int dm_table_create(struct dm_table **result, fmode_t mode, 22517b2f66fSAlasdair G Kergon unsigned num_targets, struct mapped_device *md); 22617b2f66fSAlasdair G Kergon 22717b2f66fSAlasdair G Kergon /* 22817b2f66fSAlasdair G Kergon * Then call this once for each target. 22917b2f66fSAlasdair G Kergon */ 23017b2f66fSAlasdair G Kergon int dm_table_add_target(struct dm_table *t, const char *type, 23117b2f66fSAlasdair G Kergon sector_t start, sector_t len, char *params); 23217b2f66fSAlasdair G Kergon 23317b2f66fSAlasdair G Kergon /* 23417b2f66fSAlasdair G Kergon * Finally call this to make the table ready for use. 23517b2f66fSAlasdair G Kergon */ 23617b2f66fSAlasdair G Kergon int dm_table_complete(struct dm_table *t); 23717b2f66fSAlasdair G Kergon 23817b2f66fSAlasdair G Kergon /* 239ea0ec640SMikulas Patocka * Unplug all devices in a table. 240ea0ec640SMikulas Patocka */ 241ea0ec640SMikulas Patocka void dm_table_unplug_all(struct dm_table *t); 242ea0ec640SMikulas Patocka 243ea0ec640SMikulas Patocka /* 24417b2f66fSAlasdair G Kergon * Table reference counting. 24517b2f66fSAlasdair G Kergon */ 24617b2f66fSAlasdair G Kergon struct dm_table *dm_get_table(struct mapped_device *md); 24717b2f66fSAlasdair G Kergon void dm_table_get(struct dm_table *t); 24817b2f66fSAlasdair G Kergon void dm_table_put(struct dm_table *t); 24917b2f66fSAlasdair G Kergon 25017b2f66fSAlasdair G Kergon /* 25117b2f66fSAlasdair G Kergon * Queries 25217b2f66fSAlasdair G Kergon */ 25317b2f66fSAlasdair G Kergon sector_t dm_table_get_size(struct dm_table *t); 25417b2f66fSAlasdair G Kergon unsigned int dm_table_get_num_targets(struct dm_table *t); 255aeb5d727SAl Viro fmode_t dm_table_get_mode(struct dm_table *t); 25617b2f66fSAlasdair G Kergon struct mapped_device *dm_table_get_md(struct dm_table *t); 25717b2f66fSAlasdair G Kergon 25817b2f66fSAlasdair G Kergon /* 25917b2f66fSAlasdair G Kergon * Trigger an event. 26017b2f66fSAlasdair G Kergon */ 26117b2f66fSAlasdair G Kergon void dm_table_event(struct dm_table *t); 26217b2f66fSAlasdair G Kergon 26317b2f66fSAlasdair G Kergon /* 26417b2f66fSAlasdair G Kergon * The device must be suspended before calling this method. 26517b2f66fSAlasdair G Kergon */ 26617b2f66fSAlasdair G Kergon int dm_swap_table(struct mapped_device *md, struct dm_table *t); 26717b2f66fSAlasdair G Kergon 26854160904SMikulas Patocka /* 26954160904SMikulas Patocka * A wrapper around vmalloc. 27054160904SMikulas Patocka */ 27154160904SMikulas Patocka void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); 27254160904SMikulas Patocka 2730da336e5SAlasdair G Kergon /*----------------------------------------------------------------- 2740da336e5SAlasdair G Kergon * Macros. 2750da336e5SAlasdair G Kergon *---------------------------------------------------------------*/ 2760da336e5SAlasdair G Kergon #define DM_NAME "device-mapper" 2770da336e5SAlasdair G Kergon 278*10d3bd09SMikulas Patocka #define DMCRIT(f, arg...) \ 279*10d3bd09SMikulas Patocka printk(KERN_CRIT DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) 280*10d3bd09SMikulas Patocka 2810da336e5SAlasdair G Kergon #define DMERR(f, arg...) \ 2820da336e5SAlasdair G Kergon printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) 2830da336e5SAlasdair G Kergon #define DMERR_LIMIT(f, arg...) \ 2840da336e5SAlasdair G Kergon do { \ 2850da336e5SAlasdair G Kergon if (printk_ratelimit()) \ 2860da336e5SAlasdair G Kergon printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " \ 2870da336e5SAlasdair G Kergon f "\n", ## arg); \ 2880da336e5SAlasdair G Kergon } while (0) 2890da336e5SAlasdair G Kergon 2900da336e5SAlasdair G Kergon #define DMWARN(f, arg...) \ 2910da336e5SAlasdair G Kergon printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) 2920da336e5SAlasdair G Kergon #define DMWARN_LIMIT(f, arg...) \ 2930da336e5SAlasdair G Kergon do { \ 2940da336e5SAlasdair G Kergon if (printk_ratelimit()) \ 2950da336e5SAlasdair G Kergon printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " \ 2960da336e5SAlasdair G Kergon f "\n", ## arg); \ 2970da336e5SAlasdair G Kergon } while (0) 2980da336e5SAlasdair G Kergon 2990da336e5SAlasdair G Kergon #define DMINFO(f, arg...) \ 3000da336e5SAlasdair G Kergon printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) 3010da336e5SAlasdair G Kergon #define DMINFO_LIMIT(f, arg...) \ 3020da336e5SAlasdair G Kergon do { \ 3030da336e5SAlasdair G Kergon if (printk_ratelimit()) \ 3040da336e5SAlasdair G Kergon printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f \ 3050da336e5SAlasdair G Kergon "\n", ## arg); \ 3060da336e5SAlasdair G Kergon } while (0) 3070da336e5SAlasdair G Kergon 3080da336e5SAlasdair G Kergon #ifdef CONFIG_DM_DEBUG 3090da336e5SAlasdair G Kergon # define DMDEBUG(f, arg...) \ 3100da336e5SAlasdair G Kergon printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg) 3110da336e5SAlasdair G Kergon # define DMDEBUG_LIMIT(f, arg...) \ 3120da336e5SAlasdair G Kergon do { \ 3130da336e5SAlasdair G Kergon if (printk_ratelimit()) \ 3140da336e5SAlasdair G Kergon printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \ 3150da336e5SAlasdair G Kergon "\n", ## arg); \ 3160da336e5SAlasdair G Kergon } while (0) 3170da336e5SAlasdair G Kergon #else 3180da336e5SAlasdair G Kergon # define DMDEBUG(f, arg...) do {} while (0) 3190da336e5SAlasdair G Kergon # define DMDEBUG_LIMIT(f, arg...) do {} while (0) 3200da336e5SAlasdair G Kergon #endif 3210da336e5SAlasdair G Kergon 3220da336e5SAlasdair G Kergon #define DMEMIT(x...) sz += ((sz >= maxlen) ? \ 3230da336e5SAlasdair G Kergon 0 : scnprintf(result + sz, maxlen - sz, x)) 3240da336e5SAlasdair G Kergon 3250da336e5SAlasdair G Kergon #define SECTOR_SHIFT 9 3260da336e5SAlasdair G Kergon 3270da336e5SAlasdair G Kergon /* 3280da336e5SAlasdair G Kergon * Definitions of return values from target end_io function. 3290da336e5SAlasdair G Kergon */ 3300da336e5SAlasdair G Kergon #define DM_ENDIO_INCOMPLETE 1 3310da336e5SAlasdair G Kergon #define DM_ENDIO_REQUEUE 2 3320da336e5SAlasdair G Kergon 3330da336e5SAlasdair G Kergon /* 3340da336e5SAlasdair G Kergon * Definitions of return values from target map function. 3350da336e5SAlasdair G Kergon */ 3360da336e5SAlasdair G Kergon #define DM_MAPIO_SUBMITTED 0 3370da336e5SAlasdair G Kergon #define DM_MAPIO_REMAPPED 1 3380da336e5SAlasdair G Kergon #define DM_MAPIO_REQUEUE DM_ENDIO_REQUEUE 3390da336e5SAlasdair G Kergon 3400da336e5SAlasdair G Kergon /* 3410da336e5SAlasdair G Kergon * Ceiling(n / sz) 3420da336e5SAlasdair G Kergon */ 3430da336e5SAlasdair G Kergon #define dm_div_up(n, sz) (((n) + (sz) - 1) / (sz)) 3440da336e5SAlasdair G Kergon 3450da336e5SAlasdair G Kergon #define dm_sector_div_up(n, sz) ( \ 3460da336e5SAlasdair G Kergon { \ 3470da336e5SAlasdair G Kergon sector_t _r = ((n) + (sz) - 1); \ 3480da336e5SAlasdair G Kergon sector_div(_r, (sz)); \ 3490da336e5SAlasdair G Kergon _r; \ 3500da336e5SAlasdair G Kergon } \ 3510da336e5SAlasdair G Kergon ) 3520da336e5SAlasdair G Kergon 3530da336e5SAlasdair G Kergon /* 3540da336e5SAlasdair G Kergon * ceiling(n / size) * size 3550da336e5SAlasdair G Kergon */ 3560da336e5SAlasdair G Kergon #define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz)) 3570da336e5SAlasdair G Kergon 358d63a5ce3SMikulas Patocka #define dm_array_too_big(fixed, obj, num) \ 359d63a5ce3SMikulas Patocka ((num) > (UINT_MAX - (fixed)) / (obj)) 360d63a5ce3SMikulas Patocka 3610da336e5SAlasdair G Kergon static inline sector_t to_sector(unsigned long n) 3620da336e5SAlasdair G Kergon { 3630da336e5SAlasdair G Kergon return (n >> SECTOR_SHIFT); 3640da336e5SAlasdair G Kergon } 3650da336e5SAlasdair G Kergon 3660da336e5SAlasdair G Kergon static inline unsigned long to_bytes(sector_t n) 3670da336e5SAlasdair G Kergon { 3680da336e5SAlasdair G Kergon return (n << SECTOR_SHIFT); 3690da336e5SAlasdair G Kergon } 3700da336e5SAlasdair G Kergon 3711da177e4SLinus Torvalds #endif /* _LINUX_DEVICE_MAPPER_H */ 372