This source file includes following definitions.
- part_to_disk
- disk_max_parts
- disk_part_scan_enabled
- disk_devt
- part_devt
- disk_put_part
- part_stat_set_all
- init_part_stats
- free_part_stats
- part_stat_set_all
- init_part_stats
- free_part_stats
- alloc_part_info
- free_part_info
- add_disk
- add_disk_no_queue_reg
- get_disk_ro
- add_disk_randomness
- get_capacity
- set_capacity
- hd_ref_init
- hd_struct_get
- hd_struct_try_get
- hd_struct_put
- hd_struct_kill
- hd_free_part
- part_nr_sects_read
- part_nr_sects_write
- blk_integrity_add
- blk_integrity_del
- printk_all_partitions
- blk_lookup_devt
1
2 #ifndef _LINUX_GENHD_H
3 #define _LINUX_GENHD_H
4
5
6
7
8
9
10
11
12
13 #include <linux/types.h>
14 #include <linux/kdev_t.h>
15 #include <linux/rcupdate.h>
16 #include <linux/slab.h>
17 #include <linux/percpu-refcount.h>
18 #include <linux/uuid.h>
19 #include <linux/blk_types.h>
20 #include <asm/local.h>
21
22 #ifdef CONFIG_BLOCK
23
24 #define dev_to_disk(device) container_of((device), struct gendisk, part0.__dev)
25 #define dev_to_part(device) container_of((device), struct hd_struct, __dev)
26 #define disk_to_dev(disk) (&(disk)->part0.__dev)
27 #define part_to_dev(part) (&((part)->__dev))
28
29 extern struct device_type part_type;
30 extern struct kobject *block_depr;
31 extern struct class block_class;
32
33 enum {
34
35
36 DOS_EXTENDED_PARTITION = 5,
37 LINUX_EXTENDED_PARTITION = 0x85,
38 WIN98_EXTENDED_PARTITION = 0x0f,
39
40 SUN_WHOLE_DISK = DOS_EXTENDED_PARTITION,
41
42 LINUX_SWAP_PARTITION = 0x82,
43 LINUX_DATA_PARTITION = 0x83,
44 LINUX_LVM_PARTITION = 0x8e,
45 LINUX_RAID_PARTITION = 0xfd,
46
47 SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION,
48 NEW_SOLARIS_X86_PARTITION = 0xbf,
49
50 DM6_AUX1PARTITION = 0x51,
51 DM6_AUX3PARTITION = 0x53,
52 DM6_PARTITION = 0x54,
53 EZD_PARTITION = 0x55,
54
55 FREEBSD_PARTITION = 0xa5,
56 OPENBSD_PARTITION = 0xa6,
57 NETBSD_PARTITION = 0xa9,
58 BSDI_PARTITION = 0xb7,
59 MINIX_PARTITION = 0x81,
60 UNIXWARE_PARTITION = 0x63,
61 };
62
63 #define DISK_MAX_PARTS 256
64 #define DISK_NAME_LEN 32
65
66 #include <linux/major.h>
67 #include <linux/device.h>
68 #include <linux/smp.h>
69 #include <linux/string.h>
70 #include <linux/fs.h>
71 #include <linux/workqueue.h>
72
73 struct partition {
74 unsigned char boot_ind;
75 unsigned char head;
76 unsigned char sector;
77 unsigned char cyl;
78 unsigned char sys_ind;
79 unsigned char end_head;
80 unsigned char end_sector;
81 unsigned char end_cyl;
82 __le32 start_sect;
83 __le32 nr_sects;
84 } __attribute__((packed));
85
86 struct disk_stats {
87 u64 nsecs[NR_STAT_GROUPS];
88 unsigned long sectors[NR_STAT_GROUPS];
89 unsigned long ios[NR_STAT_GROUPS];
90 unsigned long merges[NR_STAT_GROUPS];
91 unsigned long io_ticks;
92 unsigned long time_in_queue;
93 local_t in_flight[2];
94 };
95
96 #define PARTITION_META_INFO_VOLNAMELTH 64
97
98
99
100
101 #define PARTITION_META_INFO_UUIDLTH (UUID_STRING_LEN + 1)
102
103 struct partition_meta_info {
104 char uuid[PARTITION_META_INFO_UUIDLTH];
105 u8 volname[PARTITION_META_INFO_VOLNAMELTH];
106 };
107
108 struct hd_struct {
109 sector_t start_sect;
110
111
112
113
114
115 sector_t nr_sects;
116 seqcount_t nr_sects_seq;
117 sector_t alignment_offset;
118 unsigned int discard_alignment;
119 struct device __dev;
120 struct kobject *holder_dir;
121 int policy, partno;
122 struct partition_meta_info *info;
123 #ifdef CONFIG_FAIL_MAKE_REQUEST
124 int make_it_fail;
125 #endif
126 unsigned long stamp;
127 #ifdef CONFIG_SMP
128 struct disk_stats __percpu *dkstats;
129 #else
130 struct disk_stats dkstats;
131 #endif
132 struct percpu_ref ref;
133 struct rcu_work rcu_work;
134 };
135
136 #define GENHD_FL_REMOVABLE 1
137
138 #define GENHD_FL_MEDIA_CHANGE_NOTIFY 4
139 #define GENHD_FL_CD 8
140 #define GENHD_FL_UP 16
141 #define GENHD_FL_SUPPRESS_PARTITION_INFO 32
142 #define GENHD_FL_EXT_DEVT 64
143 #define GENHD_FL_NATIVE_CAPACITY 128
144 #define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 256
145 #define GENHD_FL_NO_PART_SCAN 512
146 #define GENHD_FL_HIDDEN 1024
147
148 enum {
149 DISK_EVENT_MEDIA_CHANGE = 1 << 0,
150 DISK_EVENT_EJECT_REQUEST = 1 << 1,
151 };
152
153 enum {
154
155 DISK_EVENT_FLAG_POLL = 1 << 0,
156
157 DISK_EVENT_FLAG_UEVENT = 1 << 1,
158 };
159
160 struct disk_part_tbl {
161 struct rcu_head rcu_head;
162 int len;
163 struct hd_struct __rcu *last_lookup;
164 struct hd_struct __rcu *part[];
165 };
166
167 struct disk_events;
168 struct badblocks;
169
170 #if defined(CONFIG_BLK_DEV_INTEGRITY)
171
172 struct blk_integrity {
173 const struct blk_integrity_profile *profile;
174 unsigned char flags;
175 unsigned char tuple_size;
176 unsigned char interval_exp;
177 unsigned char tag_size;
178 };
179
180 #endif
181
182 struct gendisk {
183
184
185
186 int major;
187 int first_minor;
188 int minors;
189
190
191 char disk_name[DISK_NAME_LEN];
192 char *(*devnode)(struct gendisk *gd, umode_t *mode);
193
194 unsigned short events;
195 unsigned short event_flags;
196
197
198
199
200
201
202 struct disk_part_tbl __rcu *part_tbl;
203 struct hd_struct part0;
204
205 const struct block_device_operations *fops;
206 struct request_queue *queue;
207 void *private_data;
208
209 int flags;
210 struct rw_semaphore lookup_sem;
211 struct kobject *slave_dir;
212
213 struct timer_rand_state *random;
214 atomic_t sync_io;
215 struct disk_events *ev;
216 #ifdef CONFIG_BLK_DEV_INTEGRITY
217 struct kobject integrity_kobj;
218 #endif
219 int node_id;
220 struct badblocks *bb;
221 struct lockdep_map lockdep_map;
222 };
223
224 static inline struct gendisk *part_to_disk(struct hd_struct *part)
225 {
226 if (likely(part)) {
227 if (part->partno)
228 return dev_to_disk(part_to_dev(part)->parent);
229 else
230 return dev_to_disk(part_to_dev(part));
231 }
232 return NULL;
233 }
234
235 static inline int disk_max_parts(struct gendisk *disk)
236 {
237 if (disk->flags & GENHD_FL_EXT_DEVT)
238 return DISK_MAX_PARTS;
239 return disk->minors;
240 }
241
242 static inline bool disk_part_scan_enabled(struct gendisk *disk)
243 {
244 return disk_max_parts(disk) > 1 &&
245 !(disk->flags & GENHD_FL_NO_PART_SCAN);
246 }
247
248 static inline dev_t disk_devt(struct gendisk *disk)
249 {
250 return MKDEV(disk->major, disk->first_minor);
251 }
252
253 static inline dev_t part_devt(struct hd_struct *part)
254 {
255 return part_to_dev(part)->devt;
256 }
257
258 extern struct hd_struct *__disk_get_part(struct gendisk *disk, int partno);
259 extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno);
260
261 static inline void disk_put_part(struct hd_struct *part)
262 {
263 if (likely(part))
264 put_device(part_to_dev(part));
265 }
266
267
268
269
270 #define DISK_PITER_REVERSE (1 << 0)
271 #define DISK_PITER_INCL_EMPTY (1 << 1)
272 #define DISK_PITER_INCL_PART0 (1 << 2)
273 #define DISK_PITER_INCL_EMPTY_PART0 (1 << 3)
274
275 struct disk_part_iter {
276 struct gendisk *disk;
277 struct hd_struct *part;
278 int idx;
279 unsigned int flags;
280 };
281
282 extern void disk_part_iter_init(struct disk_part_iter *piter,
283 struct gendisk *disk, unsigned int flags);
284 extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter);
285 extern void disk_part_iter_exit(struct disk_part_iter *piter);
286
287 extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk,
288 sector_t sector);
289
290
291
292
293
294
295
296
297
298
299
300
301
302 #ifdef CONFIG_SMP
303 #define part_stat_lock() ({ rcu_read_lock(); get_cpu(); })
304 #define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0)
305
306 #define part_stat_get_cpu(part, field, cpu) \
307 (per_cpu_ptr((part)->dkstats, (cpu))->field)
308
309 #define part_stat_get(part, field) \
310 part_stat_get_cpu(part, field, smp_processor_id())
311
312 #define part_stat_read(part, field) \
313 ({ \
314 typeof((part)->dkstats->field) res = 0; \
315 unsigned int _cpu; \
316 for_each_possible_cpu(_cpu) \
317 res += per_cpu_ptr((part)->dkstats, _cpu)->field; \
318 res; \
319 })
320
321 static inline void part_stat_set_all(struct hd_struct *part, int value)
322 {
323 int i;
324
325 for_each_possible_cpu(i)
326 memset(per_cpu_ptr(part->dkstats, i), value,
327 sizeof(struct disk_stats));
328 }
329
330 static inline int init_part_stats(struct hd_struct *part)
331 {
332 part->dkstats = alloc_percpu(struct disk_stats);
333 if (!part->dkstats)
334 return 0;
335 return 1;
336 }
337
338 static inline void free_part_stats(struct hd_struct *part)
339 {
340 free_percpu(part->dkstats);
341 }
342
343 #else
344 #define part_stat_lock() ({ rcu_read_lock(); 0; })
345 #define part_stat_unlock() rcu_read_unlock()
346
347 #define part_stat_get(part, field) ((part)->dkstats.field)
348 #define part_stat_get_cpu(part, field, cpu) part_stat_get(part, field)
349 #define part_stat_read(part, field) part_stat_get(part, field)
350
351 static inline void part_stat_set_all(struct hd_struct *part, int value)
352 {
353 memset(&part->dkstats, value, sizeof(struct disk_stats));
354 }
355
356 static inline int init_part_stats(struct hd_struct *part)
357 {
358 return 1;
359 }
360
361 static inline void free_part_stats(struct hd_struct *part)
362 {
363 }
364
365 #endif
366
367 #define part_stat_read_msecs(part, which) \
368 div_u64(part_stat_read(part, nsecs[which]), NSEC_PER_MSEC)
369
370 #define part_stat_read_accum(part, field) \
371 (part_stat_read(part, field[STAT_READ]) + \
372 part_stat_read(part, field[STAT_WRITE]) + \
373 part_stat_read(part, field[STAT_DISCARD]))
374
375 #define __part_stat_add(part, field, addnd) \
376 (part_stat_get(part, field) += (addnd))
377
378 #define part_stat_add(part, field, addnd) do { \
379 __part_stat_add((part), field, addnd); \
380 if ((part)->partno) \
381 __part_stat_add(&part_to_disk((part))->part0, \
382 field, addnd); \
383 } while (0)
384
385 #define part_stat_dec(gendiskp, field) \
386 part_stat_add(gendiskp, field, -1)
387 #define part_stat_inc(gendiskp, field) \
388 part_stat_add(gendiskp, field, 1)
389 #define part_stat_sub(gendiskp, field, subnd) \
390 part_stat_add(gendiskp, field, -subnd)
391
392 #define part_stat_local_dec(gendiskp, field) \
393 local_dec(&(part_stat_get(gendiskp, field)))
394 #define part_stat_local_inc(gendiskp, field) \
395 local_inc(&(part_stat_get(gendiskp, field)))
396 #define part_stat_local_read(gendiskp, field) \
397 local_read(&(part_stat_get(gendiskp, field)))
398 #define part_stat_local_read_cpu(gendiskp, field, cpu) \
399 local_read(&(part_stat_get_cpu(gendiskp, field, cpu)))
400
401 unsigned int part_in_flight(struct request_queue *q, struct hd_struct *part);
402 void part_in_flight_rw(struct request_queue *q, struct hd_struct *part,
403 unsigned int inflight[2]);
404 void part_dec_in_flight(struct request_queue *q, struct hd_struct *part,
405 int rw);
406 void part_inc_in_flight(struct request_queue *q, struct hd_struct *part,
407 int rw);
408
409 static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk)
410 {
411 if (disk)
412 return kzalloc_node(sizeof(struct partition_meta_info),
413 GFP_KERNEL, disk->node_id);
414 return kzalloc(sizeof(struct partition_meta_info), GFP_KERNEL);
415 }
416
417 static inline void free_part_info(struct hd_struct *part)
418 {
419 kfree(part->info);
420 }
421
422 void update_io_ticks(struct hd_struct *part, unsigned long now);
423
424
425 extern void device_add_disk(struct device *parent, struct gendisk *disk,
426 const struct attribute_group **groups);
427 static inline void add_disk(struct gendisk *disk)
428 {
429 device_add_disk(NULL, disk, NULL);
430 }
431 extern void device_add_disk_no_queue_reg(struct device *parent, struct gendisk *disk);
432 static inline void add_disk_no_queue_reg(struct gendisk *disk)
433 {
434 device_add_disk_no_queue_reg(NULL, disk);
435 }
436
437 extern void del_gendisk(struct gendisk *gp);
438 extern struct gendisk *get_gendisk(dev_t dev, int *partno);
439 extern struct block_device *bdget_disk(struct gendisk *disk, int partno);
440
441 extern void set_device_ro(struct block_device *bdev, int flag);
442 extern void set_disk_ro(struct gendisk *disk, int flag);
443
444 static inline int get_disk_ro(struct gendisk *disk)
445 {
446 return disk->part0.policy;
447 }
448
449 extern void disk_block_events(struct gendisk *disk);
450 extern void disk_unblock_events(struct gendisk *disk);
451 extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
452 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
453
454
455 extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
456 extern void rand_initialize_disk(struct gendisk *disk);
457
458 static inline sector_t get_start_sect(struct block_device *bdev)
459 {
460 return bdev->bd_part->start_sect;
461 }
462 static inline sector_t get_capacity(struct gendisk *disk)
463 {
464 return disk->part0.nr_sects;
465 }
466 static inline void set_capacity(struct gendisk *disk, sector_t size)
467 {
468 disk->part0.nr_sects = size;
469 }
470
471 #ifdef CONFIG_SOLARIS_X86_PARTITION
472
473 #define SOLARIS_X86_NUMSLICE 16
474 #define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
475
476 struct solaris_x86_slice {
477 __le16 s_tag;
478 __le16 s_flag;
479 __le32 s_start;
480 __le32 s_size;
481 };
482
483 struct solaris_x86_vtoc {
484 unsigned int v_bootinfo[3];
485 __le32 v_sanity;
486 __le32 v_version;
487 char v_volume[8];
488 __le16 v_sectorsz;
489 __le16 v_nparts;
490 unsigned int v_reserved[10];
491 struct solaris_x86_slice
492 v_slice[SOLARIS_X86_NUMSLICE];
493 unsigned int timestamp[SOLARIS_X86_NUMSLICE];
494 char v_asciilabel[128];
495 };
496
497 #endif
498
499 #ifdef CONFIG_BSD_DISKLABEL
500
501
502
503
504
505
506
507 #define BSD_DISKMAGIC (0x82564557UL)
508 #define BSD_MAXPARTITIONS 16
509 #define OPENBSD_MAXPARTITIONS 16
510 #define BSD_FS_UNUSED 0
511 struct bsd_disklabel {
512 __le32 d_magic;
513 __s16 d_type;
514 __s16 d_subtype;
515 char d_typename[16];
516 char d_packname[16];
517 __u32 d_secsize;
518 __u32 d_nsectors;
519 __u32 d_ntracks;
520 __u32 d_ncylinders;
521 __u32 d_secpercyl;
522 __u32 d_secperunit;
523 __u16 d_sparespertrack;
524 __u16 d_sparespercyl;
525 __u32 d_acylinders;
526 __u16 d_rpm;
527 __u16 d_interleave;
528 __u16 d_trackskew;
529 __u16 d_cylskew;
530 __u32 d_headswitch;
531 __u32 d_trkseek;
532 __u32 d_flags;
533 #define NDDATA 5
534 __u32 d_drivedata[NDDATA];
535 #define NSPARE 5
536 __u32 d_spare[NSPARE];
537 __le32 d_magic2;
538 __le16 d_checksum;
539
540
541 __le16 d_npartitions;
542 __le32 d_bbsize;
543 __le32 d_sbsize;
544 struct bsd_partition {
545 __le32 p_size;
546 __le32 p_offset;
547 __le32 p_fsize;
548 __u8 p_fstype;
549 __u8 p_frag;
550 __le16 p_cpg;
551 } d_partitions[BSD_MAXPARTITIONS];
552 };
553
554 #endif
555
556 #ifdef CONFIG_UNIXWARE_DISKLABEL
557
558
559
560
561
562 #define UNIXWARE_DISKMAGIC (0xCA5E600DUL)
563 #define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL)
564 #define UNIXWARE_NUMSLICE 16
565 #define UNIXWARE_FS_UNUSED 0
566
567 struct unixware_slice {
568 __le16 s_label;
569 __le16 s_flags;
570 __le32 start_sect;
571 __le32 nr_sects;
572 };
573
574 struct unixware_disklabel {
575 __le32 d_type;
576 __le32 d_magic;
577 __le32 d_version;
578 char d_serial[12];
579 __le32 d_ncylinders;
580 __le32 d_ntracks;
581 __le32 d_nsectors;
582 __le32 d_secsize;
583 __le32 d_part_start;
584 __le32 d_unknown1[12];
585 __le32 d_alt_tbl;
586 __le32 d_alt_len;
587 __le32 d_phys_cyl;
588 __le32 d_phys_trk;
589 __le32 d_phys_sec;
590 __le32 d_phys_bytes;
591 __le32 d_unknown2;
592 __le32 d_unknown3;
593 __le32 d_pad[8];
594
595 struct unixware_vtoc {
596 __le32 v_magic;
597 __le32 v_version;
598 char v_name[8];
599 __le16 v_nslices;
600 __le16 v_unknown1;
601 __le32 v_reserved[10];
602 struct unixware_slice
603 v_slice[UNIXWARE_NUMSLICE];
604 } vtoc;
605
606 };
607
608 #endif
609
610 #ifdef CONFIG_MINIX_SUBPARTITION
611 # define MINIX_NR_SUBPARTITIONS 4
612 #endif
613
614 #define ADDPART_FLAG_NONE 0
615 #define ADDPART_FLAG_RAID 1
616 #define ADDPART_FLAG_WHOLEDISK 2
617
618 extern int blk_alloc_devt(struct hd_struct *part, dev_t *devt);
619 extern void blk_free_devt(dev_t devt);
620 extern void blk_invalidate_devt(dev_t devt);
621 extern dev_t blk_lookup_devt(const char *name, int partno);
622 extern char *disk_name (struct gendisk *hd, int partno, char *buf);
623
624 extern int disk_expand_part_tbl(struct gendisk *disk, int target);
625 extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
626 extern int invalidate_partitions(struct gendisk *disk, struct block_device *bdev);
627 extern struct hd_struct * __must_check add_partition(struct gendisk *disk,
628 int partno, sector_t start,
629 sector_t len, int flags,
630 struct partition_meta_info
631 *info);
632 extern void __delete_partition(struct percpu_ref *);
633 extern void delete_partition(struct gendisk *, int);
634 extern void printk_all_partitions(void);
635
636 extern struct gendisk *__alloc_disk_node(int minors, int node_id);
637 extern struct kobject *get_disk_and_module(struct gendisk *disk);
638 extern void put_disk(struct gendisk *disk);
639 extern void put_disk_and_module(struct gendisk *disk);
640 extern void blk_register_region(dev_t devt, unsigned long range,
641 struct module *module,
642 struct kobject *(*probe)(dev_t, int *, void *),
643 int (*lock)(dev_t, void *),
644 void *data);
645 extern void blk_unregister_region(dev_t devt, unsigned long range);
646
647 extern ssize_t part_size_show(struct device *dev,
648 struct device_attribute *attr, char *buf);
649 extern ssize_t part_stat_show(struct device *dev,
650 struct device_attribute *attr, char *buf);
651 extern ssize_t part_inflight_show(struct device *dev,
652 struct device_attribute *attr, char *buf);
653 #ifdef CONFIG_FAIL_MAKE_REQUEST
654 extern ssize_t part_fail_show(struct device *dev,
655 struct device_attribute *attr, char *buf);
656 extern ssize_t part_fail_store(struct device *dev,
657 struct device_attribute *attr,
658 const char *buf, size_t count);
659 #endif
660
661 #define alloc_disk_node(minors, node_id) \
662 ({ \
663 static struct lock_class_key __key; \
664 const char *__name; \
665 struct gendisk *__disk; \
666 \
667 __name = "(gendisk_completion)"#minors"("#node_id")"; \
668 \
669 __disk = __alloc_disk_node(minors, node_id); \
670 \
671 if (__disk) \
672 lockdep_init_map(&__disk->lockdep_map, __name, &__key, 0); \
673 \
674 __disk; \
675 })
676
677 #define alloc_disk(minors) alloc_disk_node(minors, NUMA_NO_NODE)
678
679 static inline int hd_ref_init(struct hd_struct *part)
680 {
681 if (percpu_ref_init(&part->ref, __delete_partition, 0,
682 GFP_KERNEL))
683 return -ENOMEM;
684 return 0;
685 }
686
687 static inline void hd_struct_get(struct hd_struct *part)
688 {
689 percpu_ref_get(&part->ref);
690 }
691
692 static inline int hd_struct_try_get(struct hd_struct *part)
693 {
694 return percpu_ref_tryget_live(&part->ref);
695 }
696
697 static inline void hd_struct_put(struct hd_struct *part)
698 {
699 percpu_ref_put(&part->ref);
700 }
701
702 static inline void hd_struct_kill(struct hd_struct *part)
703 {
704 percpu_ref_kill(&part->ref);
705 }
706
707 static inline void hd_free_part(struct hd_struct *part)
708 {
709 free_part_stats(part);
710 free_part_info(part);
711 percpu_ref_exit(&part->ref);
712 }
713
714
715
716
717
718
719
720
721
722
723 static inline sector_t part_nr_sects_read(struct hd_struct *part)
724 {
725 #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
726 sector_t nr_sects;
727 unsigned seq;
728 do {
729 seq = read_seqcount_begin(&part->nr_sects_seq);
730 nr_sects = part->nr_sects;
731 } while (read_seqcount_retry(&part->nr_sects_seq, seq));
732 return nr_sects;
733 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
734 sector_t nr_sects;
735
736 preempt_disable();
737 nr_sects = part->nr_sects;
738 preempt_enable();
739 return nr_sects;
740 #else
741 return part->nr_sects;
742 #endif
743 }
744
745
746
747
748
749
750 static inline void part_nr_sects_write(struct hd_struct *part, sector_t size)
751 {
752 #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
753 write_seqcount_begin(&part->nr_sects_seq);
754 part->nr_sects = size;
755 write_seqcount_end(&part->nr_sects_seq);
756 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
757 preempt_disable();
758 part->nr_sects = size;
759 preempt_enable();
760 #else
761 part->nr_sects = size;
762 #endif
763 }
764
765 #if defined(CONFIG_BLK_DEV_INTEGRITY)
766 extern void blk_integrity_add(struct gendisk *);
767 extern void blk_integrity_del(struct gendisk *);
768 #else
769 static inline void blk_integrity_add(struct gendisk *disk) { }
770 static inline void blk_integrity_del(struct gendisk *disk) { }
771 #endif
772
773 #else
774
775 static inline void printk_all_partitions(void) { }
776
777 static inline dev_t blk_lookup_devt(const char *name, int partno)
778 {
779 dev_t devt = MKDEV(0, 0);
780 return devt;
781 }
782 #endif
783
784 #endif