device-mapper.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*
  2. * Copyright (C) 2001 Sistina Software (UK) Limited.
  3. * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
  4. *
  5. * This file is released under the LGPL.
  6. */
  7. #ifndef _LINUX_DEVICE_MAPPER_H
  8. #define _LINUX_DEVICE_MAPPER_H
  9. #include <linux/bio.h>
  10. #include <linux/blkdev.h>
  11. #include <linux/math64.h>
  12. #include <linux/ratelimit.h>
  13. struct dm_dev;
  14. struct dm_target;
  15. struct dm_table;
  16. struct mapped_device;
  17. struct bio_vec;
  18. /*
  19. * Type of table, mapped_device's mempool and request_queue
  20. */
  21. enum dm_queue_mode {
  22. DM_TYPE_NONE = 0,
  23. DM_TYPE_BIO_BASED = 1,
  24. DM_TYPE_REQUEST_BASED = 2,
  25. DM_TYPE_MQ_REQUEST_BASED = 3,
  26. DM_TYPE_DAX_BIO_BASED = 4,
  27. };
  28. typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t;
  29. union map_info {
  30. void *ptr;
  31. };
  32. /*
  33. * In the constructor the target parameter will already have the
  34. * table, type, begin and len fields filled in.
  35. */
  36. typedef int (*dm_ctr_fn) (struct dm_target *target,
  37. unsigned int argc, char **argv);
  38. /*
  39. * The destructor doesn't need to free the dm_target, just
  40. * anything hidden ti->private.
  41. */
  42. typedef void (*dm_dtr_fn) (struct dm_target *ti);
  43. /*
  44. * The map function must return:
  45. * < 0: error
  46. * = 0: The target will handle the io by resubmitting it later
  47. * = 1: simple remap complete
  48. * = 2: The target wants to push back the io
  49. */
  50. typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio);
  51. typedef int (*dm_clone_and_map_request_fn) (struct dm_target *ti,
  52. struct request *rq,
  53. union map_info *map_context,
  54. struct request **clone);
  55. typedef void (*dm_release_clone_request_fn) (struct request *clone);
  56. /*
  57. * Returns:
  58. * < 0 : error (currently ignored)
  59. * 0 : ended successfully
  60. * 1 : for some reason the io has still not completed (eg,
  61. * multipath target might want to requeue a failed io).
  62. * 2 : The target wants to push back the io
  63. */
  64. typedef int (*dm_endio_fn) (struct dm_target *ti,
  65. struct bio *bio, int error);
  66. typedef int (*dm_request_endio_fn) (struct dm_target *ti,
  67. struct request *clone, int error,
  68. union map_info *map_context);
  69. typedef void (*dm_presuspend_fn) (struct dm_target *ti);
  70. typedef void (*dm_presuspend_undo_fn) (struct dm_target *ti);
  71. typedef void (*dm_postsuspend_fn) (struct dm_target *ti);
  72. typedef int (*dm_preresume_fn) (struct dm_target *ti);
  73. typedef void (*dm_resume_fn) (struct dm_target *ti);
  74. typedef void (*dm_status_fn) (struct dm_target *ti, status_type_t status_type,
  75. unsigned status_flags, char *result, unsigned maxlen);
  76. typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv);
  77. typedef int (*dm_prepare_ioctl_fn) (struct dm_target *ti,
  78. struct block_device **bdev, fmode_t *mode);
  79. /*
  80. * These iteration functions are typically used to check (and combine)
  81. * properties of underlying devices.
  82. * E.g. Does at least one underlying device support flush?
  83. * Does any underlying device not support WRITE_SAME?
  84. *
  85. * The callout function is called once for each contiguous section of
  86. * an underlying device. State can be maintained in *data.
  87. * Return non-zero to stop iterating through any further devices.
  88. */
  89. typedef int (*iterate_devices_callout_fn) (struct dm_target *ti,
  90. struct dm_dev *dev,
  91. sector_t start, sector_t len,
  92. void *data);
  93. /*
  94. * This function must iterate through each section of device used by the
  95. * target until it encounters a non-zero return code, which it then returns.
  96. * Returns zero if no callout returned non-zero.
  97. */
  98. typedef int (*dm_iterate_devices_fn) (struct dm_target *ti,
  99. iterate_devices_callout_fn fn,
  100. void *data);
  101. typedef void (*dm_io_hints_fn) (struct dm_target *ti,
  102. struct queue_limits *limits);
  103. /*
  104. * Returns:
  105. * 0: The target can handle the next I/O immediately.
  106. * 1: The target can't handle the next I/O immediately.
  107. */
  108. typedef int (*dm_busy_fn) (struct dm_target *ti);
  109. /*
  110. * Returns:
  111. * < 0 : error
  112. * >= 0 : the number of bytes accessible at the address
  113. */
  114. typedef long (*dm_dax_direct_access_fn) (struct dm_target *ti, pgoff_t pgoff,
  115. long nr_pages, void **kaddr, pfn_t *pfn);
  116. typedef size_t (*dm_dax_copy_from_iter_fn)(struct dm_target *ti, pgoff_t pgoff,
  117. void *addr, size_t bytes, struct iov_iter *i);
  118. #define PAGE_SECTORS (PAGE_SIZE / 512)
  119. void dm_error(const char *message);
  120. struct dm_dev {
  121. struct block_device *bdev;
  122. struct dax_device *dax_dev;
  123. fmode_t mode;
  124. char name[16];
  125. };
  126. dev_t dm_get_dev_t(const char *path);
  127. /*
  128. * Constructors should call these functions to ensure destination devices
  129. * are opened/closed correctly.
  130. */
  131. int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode,
  132. struct dm_dev **result);
  133. void dm_put_device(struct dm_target *ti, struct dm_dev *d);
  134. /*
  135. * Information about a target type
  136. */
  137. struct target_type {
  138. uint64_t features;
  139. const char *name;
  140. struct module *module;
  141. unsigned version[3];
  142. dm_ctr_fn ctr;
  143. dm_dtr_fn dtr;
  144. dm_map_fn map;
  145. dm_clone_and_map_request_fn clone_and_map_rq;
  146. dm_release_clone_request_fn release_clone_rq;
  147. dm_endio_fn end_io;
  148. dm_request_endio_fn rq_end_io;
  149. dm_presuspend_fn presuspend;
  150. dm_presuspend_undo_fn presuspend_undo;
  151. dm_postsuspend_fn postsuspend;
  152. dm_preresume_fn preresume;
  153. dm_resume_fn resume;
  154. dm_status_fn status;
  155. dm_message_fn message;
  156. dm_prepare_ioctl_fn prepare_ioctl;
  157. dm_busy_fn busy;
  158. dm_iterate_devices_fn iterate_devices;
  159. dm_io_hints_fn io_hints;
  160. dm_dax_direct_access_fn direct_access;
  161. dm_dax_copy_from_iter_fn dax_copy_from_iter;
  162. /* For internal device-mapper use. */
  163. struct list_head list;
  164. };
  165. /*
  166. * Target features
  167. */
  168. /*
  169. * Any table that contains an instance of this target must have only one.
  170. */
  171. #define DM_TARGET_SINGLETON 0x00000001
  172. #define dm_target_needs_singleton(type) ((type)->features & DM_TARGET_SINGLETON)
  173. /*
  174. * Indicates that a target does not support read-only devices.
  175. */
  176. #define DM_TARGET_ALWAYS_WRITEABLE 0x00000002
  177. #define dm_target_always_writeable(type) \
  178. ((type)->features & DM_TARGET_ALWAYS_WRITEABLE)
  179. /*
  180. * Any device that contains a table with an instance of this target may never
  181. * have tables containing any different target type.
  182. */
  183. #define DM_TARGET_IMMUTABLE 0x00000004
  184. #define dm_target_is_immutable(type) ((type)->features & DM_TARGET_IMMUTABLE)
  185. /*
  186. * Indicates that a target may replace any target; even immutable targets.
  187. * .map, .map_rq, .clone_and_map_rq and .release_clone_rq are all defined.
  188. */
  189. #define DM_TARGET_WILDCARD 0x00000008
  190. #define dm_target_is_wildcard(type) ((type)->features & DM_TARGET_WILDCARD)
  191. /*
  192. * Some targets need to be sent the same WRITE bio severals times so
  193. * that they can send copies of it to different devices. This function
  194. * examines any supplied bio and returns the number of copies of it the
  195. * target requires.
  196. */
  197. typedef unsigned (*dm_num_write_bios_fn) (struct dm_target *ti, struct bio *bio);
  198. /*
  199. * A target implements own bio data integrity.
  200. */
  201. #define DM_TARGET_INTEGRITY 0x00000010
  202. #define dm_target_has_integrity(type) ((type)->features & DM_TARGET_INTEGRITY)
  203. /*
  204. * A target passes integrity data to the lower device.
  205. */
  206. #define DM_TARGET_PASSES_INTEGRITY 0x00000020
  207. #define dm_target_passes_integrity(type) ((type)->features & DM_TARGET_PASSES_INTEGRITY)
  208. struct dm_target {
  209. struct dm_table *table;
  210. struct target_type *type;
  211. /* target limits */
  212. sector_t begin;
  213. sector_t len;
  214. /* If non-zero, maximum size of I/O submitted to a target. */
  215. uint32_t max_io_len;
  216. /*
  217. * A number of zero-length barrier bios that will be submitted
  218. * to the target for the purpose of flushing cache.
  219. *
  220. * The bio number can be accessed with dm_bio_get_target_bio_nr.
  221. * It is a responsibility of the target driver to remap these bios
  222. * to the real underlying devices.
  223. */
  224. unsigned num_flush_bios;
  225. /*
  226. * The number of discard bios that will be submitted to the target.
  227. * The bio number can be accessed with dm_bio_get_target_bio_nr.
  228. */
  229. unsigned num_discard_bios;
  230. /*
  231. * The number of WRITE SAME bios that will be submitted to the target.
  232. * The bio number can be accessed with dm_bio_get_target_bio_nr.
  233. */
  234. unsigned num_write_same_bios;
  235. /*
  236. * The number of WRITE ZEROES bios that will be submitted to the target.
  237. * The bio number can be accessed with dm_bio_get_target_bio_nr.
  238. */
  239. unsigned num_write_zeroes_bios;
  240. /*
  241. * The minimum number of extra bytes allocated in each io for the
  242. * target to use.
  243. */
  244. unsigned per_io_data_size;
  245. /*
  246. * If defined, this function is called to find out how many
  247. * duplicate bios should be sent to the target when writing
  248. * data.
  249. */
  250. dm_num_write_bios_fn num_write_bios;
  251. /* target specific data */
  252. void *private;
  253. /* Used to provide an error string from the ctr */
  254. char *error;
  255. /*
  256. * Set if this target needs to receive flushes regardless of
  257. * whether or not its underlying devices have support.
  258. */
  259. bool flush_supported:1;
  260. /*
  261. * Set if this target needs to receive discards regardless of
  262. * whether or not its underlying devices have support.
  263. */
  264. bool discards_supported:1;
  265. /*
  266. * Set if the target required discard bios to be split
  267. * on max_io_len boundary.
  268. */
  269. bool split_discard_bios:1;
  270. };
  271. /* Each target can link one of these into the table */
  272. struct dm_target_callbacks {
  273. struct list_head list;
  274. int (*congested_fn) (struct dm_target_callbacks *, int);
  275. };
  276. /*
  277. * For bio-based dm.
  278. * One of these is allocated for each bio.
  279. * This structure shouldn't be touched directly by target drivers.
  280. * It is here so that we can inline dm_per_bio_data and
  281. * dm_bio_from_per_bio_data
  282. */
  283. struct dm_target_io {
  284. struct dm_io *io;
  285. struct dm_target *ti;
  286. unsigned target_bio_nr;
  287. unsigned *len_ptr;
  288. struct bio clone;
  289. };
  290. static inline void *dm_per_bio_data(struct bio *bio, size_t data_size)
  291. {
  292. return (char *)bio - offsetof(struct dm_target_io, clone) - data_size;
  293. }
  294. static inline struct bio *dm_bio_from_per_bio_data(void *data, size_t data_size)
  295. {
  296. return (struct bio *)((char *)data + data_size + offsetof(struct dm_target_io, clone));
  297. }
  298. static inline unsigned dm_bio_get_target_bio_nr(const struct bio *bio)
  299. {
  300. return container_of(bio, struct dm_target_io, clone)->target_bio_nr;
  301. }
  302. int dm_register_target(struct target_type *t);
  303. void dm_unregister_target(struct target_type *t);
  304. /*
  305. * Target argument parsing.
  306. */
  307. struct dm_arg_set {
  308. unsigned argc;
  309. char **argv;
  310. };
  311. /*
  312. * The minimum and maximum value of a numeric argument, together with
  313. * the error message to use if the number is found to be outside that range.
  314. */
  315. struct dm_arg {
  316. unsigned min;
  317. unsigned max;
  318. char *error;
  319. };
  320. /*
  321. * Validate the next argument, either returning it as *value or, if invalid,
  322. * returning -EINVAL and setting *error.
  323. */
  324. int dm_read_arg(struct dm_arg *arg, struct dm_arg_set *arg_set,
  325. unsigned *value, char **error);
  326. /*
  327. * Process the next argument as the start of a group containing between
  328. * arg->min and arg->max further arguments. Either return the size as
  329. * *num_args or, if invalid, return -EINVAL and set *error.
  330. */
  331. int dm_read_arg_group(struct dm_arg *arg, struct dm_arg_set *arg_set,
  332. unsigned *num_args, char **error);
  333. /*
  334. * Return the current argument and shift to the next.
  335. */
  336. const char *dm_shift_arg(struct dm_arg_set *as);
  337. /*
  338. * Move through num_args arguments.
  339. */
  340. void dm_consume_args(struct dm_arg_set *as, unsigned num_args);
  341. /*-----------------------------------------------------------------
  342. * Functions for creating and manipulating mapped devices.
  343. * Drop the reference with dm_put when you finish with the object.
  344. *---------------------------------------------------------------*/
  345. /*
  346. * DM_ANY_MINOR chooses the next available minor number.
  347. */
  348. #define DM_ANY_MINOR (-1)
  349. int dm_create(int minor, struct mapped_device **md);
  350. /*
  351. * Reference counting for md.
  352. */
  353. struct mapped_device *dm_get_md(dev_t dev);
  354. void dm_get(struct mapped_device *md);
  355. int dm_hold(struct mapped_device *md);
  356. void dm_put(struct mapped_device *md);
  357. /*
  358. * An arbitrary pointer may be stored alongside a mapped device.
  359. */
  360. void dm_set_mdptr(struct mapped_device *md, void *ptr);
  361. void *dm_get_mdptr(struct mapped_device *md);
  362. /*
  363. * A device can still be used while suspended, but I/O is deferred.
  364. */
  365. int dm_suspend(struct mapped_device *md, unsigned suspend_flags);
  366. int dm_resume(struct mapped_device *md);
  367. /*
  368. * Event functions.
  369. */
  370. uint32_t dm_get_event_nr(struct mapped_device *md);
  371. int dm_wait_event(struct mapped_device *md, int event_nr);
  372. uint32_t dm_next_uevent_seq(struct mapped_device *md);
  373. void dm_uevent_add(struct mapped_device *md, struct list_head *elist);
  374. /*
  375. * Info functions.
  376. */
  377. const char *dm_device_name(struct mapped_device *md);
  378. int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid);
  379. struct gendisk *dm_disk(struct mapped_device *md);
  380. int dm_suspended(struct dm_target *ti);
  381. int dm_noflush_suspending(struct dm_target *ti);
  382. void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors);
  383. union map_info *dm_get_rq_mapinfo(struct request *rq);
  384. struct queue_limits *dm_get_queue_limits(struct mapped_device *md);
  385. /*
  386. * Geometry functions.
  387. */
  388. int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo);
  389. int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo);
  390. /*-----------------------------------------------------------------
  391. * Functions for manipulating device-mapper tables.
  392. *---------------------------------------------------------------*/
  393. /*
  394. * First create an empty table.
  395. */
  396. int dm_table_create(struct dm_table **result, fmode_t mode,
  397. unsigned num_targets, struct mapped_device *md);
  398. /*
  399. * Then call this once for each target.
  400. */
  401. int dm_table_add_target(struct dm_table *t, const char *type,
  402. sector_t start, sector_t len, char *params);
  403. /*
  404. * Target_ctr should call this if it needs to add any callbacks.
  405. */
  406. void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callbacks *cb);
  407. /*
  408. * Target can use this to set the table's type.
  409. * Can only ever be called from a target's ctr.
  410. * Useful for "hybrid" target (supports both bio-based
  411. * and request-based).
  412. */
  413. void dm_table_set_type(struct dm_table *t, enum dm_queue_mode type);
  414. /*
  415. * Finally call this to make the table ready for use.
  416. */
  417. int dm_table_complete(struct dm_table *t);
  418. /*
  419. * Target may require that it is never sent I/O larger than len.
  420. */
  421. int __must_check dm_set_target_max_io_len(struct dm_target *ti, sector_t len);
  422. /*
  423. * Table reference counting.
  424. */
  425. struct dm_table *dm_get_live_table(struct mapped_device *md, int *srcu_idx);
  426. void dm_put_live_table(struct mapped_device *md, int srcu_idx);
  427. void dm_sync_table(struct mapped_device *md);
  428. /*
  429. * Queries
  430. */
  431. sector_t dm_table_get_size(struct dm_table *t);
  432. unsigned int dm_table_get_num_targets(struct dm_table *t);
  433. fmode_t dm_table_get_mode(struct dm_table *t);
  434. struct mapped_device *dm_table_get_md(struct dm_table *t);
  435. /*
  436. * Trigger an event.
  437. */
  438. void dm_table_event(struct dm_table *t);
  439. /*
  440. * Run the queue for request-based targets.
  441. */
  442. void dm_table_run_md_queue_async(struct dm_table *t);
  443. /*
  444. * The device must be suspended before calling this method.
  445. * Returns the previous table, which the caller must destroy.
  446. */
  447. struct dm_table *dm_swap_table(struct mapped_device *md,
  448. struct dm_table *t);
  449. /*
  450. * A wrapper around vmalloc.
  451. */
  452. void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
  453. /*-----------------------------------------------------------------
  454. * Macros.
  455. *---------------------------------------------------------------*/
  456. #define DM_NAME "device-mapper"
  457. #ifdef CONFIG_PRINTK
  458. extern struct ratelimit_state dm_ratelimit_state;
  459. #define dm_ratelimit() __ratelimit(&dm_ratelimit_state)
  460. #else
  461. #define dm_ratelimit() 0
  462. #endif
  463. #define DMCRIT(f, arg...) \
  464. printk(KERN_CRIT DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
  465. #define DMERR(f, arg...) \
  466. printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
  467. #define DMERR_LIMIT(f, arg...) \
  468. do { \
  469. if (dm_ratelimit()) \
  470. printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " \
  471. f "\n", ## arg); \
  472. } while (0)
  473. #define DMWARN(f, arg...) \
  474. printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
  475. #define DMWARN_LIMIT(f, arg...) \
  476. do { \
  477. if (dm_ratelimit()) \
  478. printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " \
  479. f "\n", ## arg); \
  480. } while (0)
  481. #define DMINFO(f, arg...) \
  482. printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
  483. #define DMINFO_LIMIT(f, arg...) \
  484. do { \
  485. if (dm_ratelimit()) \
  486. printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f \
  487. "\n", ## arg); \
  488. } while (0)
  489. #ifdef CONFIG_DM_DEBUG
  490. # define DMDEBUG(f, arg...) \
  491. printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg)
  492. # define DMDEBUG_LIMIT(f, arg...) \
  493. do { \
  494. if (dm_ratelimit()) \
  495. printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \
  496. "\n", ## arg); \
  497. } while (0)
  498. #else
  499. # define DMDEBUG(f, arg...) do {} while (0)
  500. # define DMDEBUG_LIMIT(f, arg...) do {} while (0)
  501. #endif
  502. #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
  503. 0 : scnprintf(result + sz, maxlen - sz, x))
  504. #define SECTOR_SHIFT 9
  505. /*
  506. * Definitions of return values from target end_io function.
  507. */
  508. #define DM_ENDIO_DONE 0
  509. #define DM_ENDIO_INCOMPLETE 1
  510. #define DM_ENDIO_REQUEUE 2
  511. /*
  512. * Definitions of return values from target map function.
  513. */
  514. #define DM_MAPIO_SUBMITTED 0
  515. #define DM_MAPIO_REMAPPED 1
  516. #define DM_MAPIO_REQUEUE DM_ENDIO_REQUEUE
  517. #define DM_MAPIO_DELAY_REQUEUE 3
  518. #define DM_MAPIO_KILL 4
  519. #define dm_sector_div64(x, y)( \
  520. { \
  521. u64 _res; \
  522. (x) = div64_u64_rem(x, y, &_res); \
  523. _res; \
  524. } \
  525. )
  526. /*
  527. * Ceiling(n / sz)
  528. */
  529. #define dm_div_up(n, sz) (((n) + (sz) - 1) / (sz))
  530. #define dm_sector_div_up(n, sz) ( \
  531. { \
  532. sector_t _r = ((n) + (sz) - 1); \
  533. sector_div(_r, (sz)); \
  534. _r; \
  535. } \
  536. )
  537. /*
  538. * ceiling(n / size) * size
  539. */
  540. #define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz))
  541. #define dm_array_too_big(fixed, obj, num) \
  542. ((num) > (UINT_MAX - (fixed)) / (obj))
  543. /*
  544. * Sector offset taken relative to the start of the target instead of
  545. * relative to the start of the device.
  546. */
  547. #define dm_target_offset(ti, sector) ((sector) - (ti)->begin)
  548. static inline sector_t to_sector(unsigned long n)
  549. {
  550. return (n >> SECTOR_SHIFT);
  551. }
  552. static inline unsigned long to_bytes(sector_t n)
  553. {
  554. return (n << SECTOR_SHIFT);
  555. }
  556. #endif /* _LINUX_DEVICE_MAPPER_H */