Commit 1493bf217f7f59a5d9e2095a7dbcec00fb36ca8b

Authored by Tejun Heo
Committed by Jens Axboe
1 parent c3e33e043f

block: use struct parsed_partitions *state universally in partition check code

Make the following changes to partition check code.

* Add ->bdev to struct parsed_partitions.

* Introduce read_part_sector() which is a simple wrapper around
  read_dev_sector() which takes struct parsed_partitions *state
  instead of @bdev.

* For functions which used to take @state and @bdev, drop @bdev.  For
  functions which used to take @bdev, replace it with @state.

* While updating, drop superflous checks on NULL state/bdev in ldm.c.

This cleans up the API a bit and enables better handling of IO errors
during partition check as the generic partition check code now has
much better visibility into what went wrong in the low level code
paths.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

Showing 30 changed files with 225 additions and 239 deletions Side-by-side Diff

fs/partitions/acorn.c
... ... @@ -70,14 +70,14 @@
70 70  
71 71 #if defined(CONFIG_ACORN_PARTITION_CUMANA) || \
72 72 defined(CONFIG_ACORN_PARTITION_ADFS)
73   -static int
74   -riscix_partition(struct parsed_partitions *state, struct block_device *bdev,
75   - unsigned long first_sect, int slot, unsigned long nr_sects)
  73 +static int riscix_partition(struct parsed_partitions *state,
  74 + unsigned long first_sect, int slot,
  75 + unsigned long nr_sects)
76 76 {
77 77 Sector sect;
78 78 struct riscix_record *rr;
79 79  
80   - rr = (struct riscix_record *)read_dev_sector(bdev, first_sect, &sect);
  80 + rr = read_part_sector(state, first_sect, &sect);
81 81 if (!rr)
82 82 return -1;
83 83  
... ... @@ -123,9 +123,9 @@
123 123  
124 124 #if defined(CONFIG_ACORN_PARTITION_CUMANA) || \
125 125 defined(CONFIG_ACORN_PARTITION_ADFS)
126   -static int
127   -linux_partition(struct parsed_partitions *state, struct block_device *bdev,
128   - unsigned long first_sect, int slot, unsigned long nr_sects)
  126 +static int linux_partition(struct parsed_partitions *state,
  127 + unsigned long first_sect, int slot,
  128 + unsigned long nr_sects)
129 129 {
130 130 Sector sect;
131 131 struct linux_part *linuxp;
... ... @@ -135,7 +135,7 @@
135 135  
136 136 put_partition(state, slot++, first_sect, size);
137 137  
138   - linuxp = (struct linux_part *)read_dev_sector(bdev, first_sect, &sect);
  138 + linuxp = read_part_sector(state, first_sect, &sect);
139 139 if (!linuxp)
140 140 return -1;
141 141  
... ... @@ -157,8 +157,7 @@
157 157 #endif
158 158  
159 159 #ifdef CONFIG_ACORN_PARTITION_CUMANA
160   -int
161   -adfspart_check_CUMANA(struct parsed_partitions *state, struct block_device *bdev)
  160 +int adfspart_check_CUMANA(struct parsed_partitions *state)
162 161 {
163 162 unsigned long first_sector = 0;
164 163 unsigned int start_blk = 0;
... ... @@ -185,7 +184,7 @@
185 184 struct adfs_discrecord *dr;
186 185 unsigned int nr_sects;
187 186  
188   - data = read_dev_sector(bdev, start_blk * 2 + 6, &sect);
  187 + data = read_part_sector(state, start_blk * 2 + 6, &sect);
189 188 if (!data)
190 189 return -1;
191 190  
192 191  
... ... @@ -217,14 +216,14 @@
217 216 #ifdef CONFIG_ACORN_PARTITION_RISCIX
218 217 case PARTITION_RISCIX_SCSI:
219 218 /* RISCiX - we don't know how to find the next one. */
220   - slot = riscix_partition(state, bdev, first_sector,
221   - slot, nr_sects);
  219 + slot = riscix_partition(state, first_sector, slot,
  220 + nr_sects);
222 221 break;
223 222 #endif
224 223  
225 224 case PARTITION_LINUX:
226   - slot = linux_partition(state, bdev, first_sector,
227   - slot, nr_sects);
  225 + slot = linux_partition(state, first_sector, slot,
  226 + nr_sects);
228 227 break;
229 228 }
230 229 put_dev_sector(sect);
... ... @@ -249,8 +248,7 @@
249 248 * hda1 = ADFS partition on first drive.
250 249 * hda2 = non-ADFS partition.
251 250 */
252   -int
253   -adfspart_check_ADFS(struct parsed_partitions *state, struct block_device *bdev)
  251 +int adfspart_check_ADFS(struct parsed_partitions *state)
254 252 {
255 253 unsigned long start_sect, nr_sects, sectscyl, heads;
256 254 Sector sect;
... ... @@ -259,7 +257,7 @@
259 257 unsigned char id;
260 258 int slot = 1;
261 259  
262   - data = read_dev_sector(bdev, 6, &sect);
  260 + data = read_part_sector(state, 6, &sect);
263 261 if (!data)
264 262 return -1;
265 263  
266 264  
267 265  
... ... @@ -278,21 +276,21 @@
278 276 /*
279 277 * Work out start of non-adfs partition.
280 278 */
281   - nr_sects = (bdev->bd_inode->i_size >> 9) - start_sect;
  279 + nr_sects = (state->bdev->bd_inode->i_size >> 9) - start_sect;
282 280  
283 281 if (start_sect) {
284 282 switch (id) {
285 283 #ifdef CONFIG_ACORN_PARTITION_RISCIX
286 284 case PARTITION_RISCIX_SCSI:
287 285 case PARTITION_RISCIX_MFM:
288   - slot = riscix_partition(state, bdev, start_sect,
289   - slot, nr_sects);
  286 + slot = riscix_partition(state, start_sect, slot,
  287 + nr_sects);
290 288 break;
291 289 #endif
292 290  
293 291 case PARTITION_LINUX:
294   - slot = linux_partition(state, bdev, start_sect,
295   - slot, nr_sects);
  292 + slot = linux_partition(state, start_sect, slot,
  293 + nr_sects);
296 294 break;
297 295 }
298 296 }
299 297  
... ... @@ -308,10 +306,11 @@
308 306 __le32 size;
309 307 };
310 308  
311   -static int adfspart_check_ICSLinux(struct block_device *bdev, unsigned long block)
  309 +static int adfspart_check_ICSLinux(struct parsed_partitions *state,
  310 + unsigned long block)
312 311 {
313 312 Sector sect;
314   - unsigned char *data = read_dev_sector(bdev, block, &sect);
  313 + unsigned char *data = read_part_sector(state, block, &sect);
315 314 int result = 0;
316 315  
317 316 if (data) {
... ... @@ -349,8 +348,7 @@
349 348 * hda2 = ADFS partition 1 on first drive.
350 349 * ..etc..
351 350 */
352   -int
353   -adfspart_check_ICS(struct parsed_partitions *state, struct block_device *bdev)
  351 +int adfspart_check_ICS(struct parsed_partitions *state)
354 352 {
355 353 const unsigned char *data;
356 354 const struct ics_part *p;
... ... @@ -360,7 +358,7 @@
360 358 /*
361 359 * Try ICS style partitions - sector 0 contains partition info.
362 360 */
363   - data = read_dev_sector(bdev, 0, &sect);
  361 + data = read_part_sector(state, 0, &sect);
364 362 if (!data)
365 363 return -1;
366 364  
... ... @@ -392,7 +390,7 @@
392 390 * partition is. We must not make this visible
393 391 * to the filesystem.
394 392 */
395   - if (size > 1 && adfspart_check_ICSLinux(bdev, start)) {
  393 + if (size > 1 && adfspart_check_ICSLinux(state, start)) {
396 394 start += 1;
397 395 size -= 1;
398 396 }
... ... @@ -446,8 +444,7 @@
446 444 * hda2 = ADFS partition 1 on first drive.
447 445 * ..etc..
448 446 */
449   -int
450   -adfspart_check_POWERTEC(struct parsed_partitions *state, struct block_device *bdev)
  447 +int adfspart_check_POWERTEC(struct parsed_partitions *state)
451 448 {
452 449 Sector sect;
453 450 const unsigned char *data;
... ... @@ -455,7 +452,7 @@
455 452 int slot = 1;
456 453 int i;
457 454  
458   - data = read_dev_sector(bdev, 0, &sect);
  455 + data = read_part_sector(state, 0, &sect);
459 456 if (!data)
460 457 return -1;
461 458  
... ... @@ -508,8 +505,7 @@
508 505 * 1. The individual ADFS boot block entries that are placed on the disk.
509 506 * 2. The start address of the next entry.
510 507 */
511   -int
512   -adfspart_check_EESOX(struct parsed_partitions *state, struct block_device *bdev)
  508 +int adfspart_check_EESOX(struct parsed_partitions *state)
513 509 {
514 510 Sector sect;
515 511 const unsigned char *data;
... ... @@ -518,7 +514,7 @@
518 514 sector_t start = 0;
519 515 int i, slot = 1;
520 516  
521   - data = read_dev_sector(bdev, 7, &sect);
  517 + data = read_part_sector(state, 7, &sect);
522 518 if (!data)
523 519 return -1;
524 520  
... ... @@ -545,7 +541,7 @@
545 541 if (i != 0) {
546 542 sector_t size;
547 543  
548   - size = get_capacity(bdev->bd_disk);
  544 + size = get_capacity(state->bdev->bd_disk);
549 545 put_partition(state, slot++, start, size - start);
550 546 printk("\n");
551 547 }
fs/partitions/acorn.h
... ... @@ -7,9 +7,9 @@
7 7 * format, and everyone stick to it?
8 8 */
9 9  
10   -int adfspart_check_CUMANA(struct parsed_partitions *state, struct block_device *bdev);
11   -int adfspart_check_ADFS(struct parsed_partitions *state, struct block_device *bdev);
12   -int adfspart_check_ICS(struct parsed_partitions *state, struct block_device *bdev);
13   -int adfspart_check_POWERTEC(struct parsed_partitions *state, struct block_device *bdev);
14   -int adfspart_check_EESOX(struct parsed_partitions *state, struct block_device *bdev);
  10 +int adfspart_check_CUMANA(struct parsed_partitions *state);
  11 +int adfspart_check_ADFS(struct parsed_partitions *state);
  12 +int adfspart_check_ICS(struct parsed_partitions *state);
  13 +int adfspart_check_POWERTEC(struct parsed_partitions *state);
  14 +int adfspart_check_EESOX(struct parsed_partitions *state);
fs/partitions/amiga.c
... ... @@ -23,8 +23,7 @@
23 23 return sum;
24 24 }
25 25  
26   -int
27   -amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
  26 +int amiga_partition(struct parsed_partitions *state)
28 27 {
29 28 Sector sect;
30 29 unsigned char *data;
31 30  
... ... @@ -38,11 +37,11 @@
38 37 for (blk = 0; ; blk++, put_dev_sector(sect)) {
39 38 if (blk == RDB_ALLOCATION_LIMIT)
40 39 goto rdb_done;
41   - data = read_dev_sector(bdev, blk, &sect);
  40 + data = read_part_sector(state, blk, &sect);
42 41 if (!data) {
43 42 if (warn_no_part)
44 43 printk("Dev %s: unable to read RDB block %d\n",
45   - bdevname(bdev, b), blk);
  44 + bdevname(state->bdev, b), blk);
46 45 res = -1;
47 46 goto rdb_done;
48 47 }
... ... @@ -64,7 +63,7 @@
64 63 }
65 64  
66 65 printk("Dev %s: RDB in block %d has bad checksum\n",
67   - bdevname(bdev, b), blk);
  66 + bdevname(state->bdev, b), blk);
68 67 }
69 68  
70 69 /* blksize is blocks per 512 byte standard block */
71 70  
... ... @@ -75,11 +74,11 @@
75 74 put_dev_sector(sect);
76 75 for (part = 1; blk>0 && part<=16; part++, put_dev_sector(sect)) {
77 76 blk *= blksize; /* Read in terms partition table understands */
78   - data = read_dev_sector(bdev, blk, &sect);
  77 + data = read_part_sector(state, blk, &sect);
79 78 if (!data) {
80 79 if (warn_no_part)
81 80 printk("Dev %s: unable to read partition block %d\n",
82   - bdevname(bdev, b), blk);
  81 + bdevname(state->bdev, b), blk);
83 82 res = -1;
84 83 goto rdb_done;
85 84 }
fs/partitions/amiga.h
... ... @@ -2,5 +2,5 @@
2 2 * fs/partitions/amiga.h
3 3 */
4 4  
5   -int amiga_partition(struct parsed_partitions *state, struct block_device *bdev);
  5 +int amiga_partition(struct parsed_partitions *state);
fs/partitions/atari.c
... ... @@ -30,7 +30,7 @@
30 30 memcmp (s, "RAW", 3) == 0 ;
31 31 }
32 32  
33   -int atari_partition(struct parsed_partitions *state, struct block_device *bdev)
  33 +int atari_partition(struct parsed_partitions *state)
34 34 {
35 35 Sector sect;
36 36 struct rootsector *rs;
37 37  
... ... @@ -42,12 +42,12 @@
42 42 int part_fmt = 0; /* 0:unknown, 1:AHDI, 2:ICD/Supra */
43 43 #endif
44 44  
45   - rs = (struct rootsector *) read_dev_sector(bdev, 0, &sect);
  45 + rs = read_part_sector(state, 0, &sect);
46 46 if (!rs)
47 47 return -1;
48 48  
49 49 /* Verify this is an Atari rootsector: */
50   - hd_size = bdev->bd_inode->i_size >> 9;
  50 + hd_size = state->bdev->bd_inode->i_size >> 9;
51 51 if (!VALID_PARTITION(&rs->part[0], hd_size) &&
52 52 !VALID_PARTITION(&rs->part[1], hd_size) &&
53 53 !VALID_PARTITION(&rs->part[2], hd_size) &&
... ... @@ -84,7 +84,7 @@
84 84 printk(" XGM<");
85 85 partsect = extensect = be32_to_cpu(pi->st);
86 86 while (1) {
87   - xrs = (struct rootsector *)read_dev_sector(bdev, partsect, &sect2);
  87 + xrs = read_part_sector(state, partsect, &sect2);
88 88 if (!xrs) {
89 89 printk (" block %ld read failed\n", partsect);
90 90 put_dev_sector(sect);
fs/partitions/atari.h
... ... @@ -31,5 +31,5 @@
31 31 u16 checksum; /* checksum for bootable disks */
32 32 } __attribute__((__packed__));
33 33  
34   -int atari_partition(struct parsed_partitions *state, struct block_device *bdev);
  34 +int atari_partition(struct parsed_partitions *state);
fs/partitions/check.c
... ... @@ -45,7 +45,7 @@
45 45  
46 46 int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
47 47  
48   -static int (*check_part[])(struct parsed_partitions *, struct block_device *) = {
  48 +static int (*check_part[])(struct parsed_partitions *) = {
49 49 /*
50 50 * Probe partition formats with tables at disk address 0
51 51 * that also have an ADFS boot block at 0xdc0.
... ... @@ -165,6 +165,7 @@
165 165 if (!state)
166 166 return NULL;
167 167  
  168 + state->bdev = bdev;
168 169 disk_name(hd, 0, state->name);
169 170 printk(KERN_INFO " %s:", state->name);
170 171 if (isdigit(state->name[strlen(state->name)-1]))
... ... @@ -174,7 +175,7 @@
174 175 i = res = err = 0;
175 176 while (!res && check_part[i]) {
176 177 memset(&state->parts, 0, sizeof(state->parts));
177   - res = check_part[i++](state, bdev);
  178 + res = check_part[i++](state);
178 179 if (res < 0) {
179 180 /* We have hit an I/O error which we don't report now.
180 181 * But record it, and let the others do their job.
fs/partitions/check.h
... ... @@ -6,6 +6,7 @@
6 6 * description.
7 7 */
8 8 struct parsed_partitions {
  9 + struct block_device *bdev;
9 10 char name[BDEVNAME_SIZE];
10 11 struct {
11 12 sector_t from;
... ... @@ -15,6 +16,12 @@
15 16 int next;
16 17 int limit;
17 18 };
  19 +
  20 +static inline void *read_part_sector(struct parsed_partitions *state,
  21 + sector_t n, Sector *p)
  22 +{
  23 + return read_dev_sector(state->bdev, n, p);
  24 +}
18 25  
19 26 static inline void
20 27 put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
... ... @@ -140,8 +140,7 @@
140 140 * the part[0] entry for this disk, and is the number of
141 141 * physical sectors available on the disk.
142 142 */
143   -static u64
144   -last_lba(struct block_device *bdev)
  143 +static u64 last_lba(struct block_device *bdev)
145 144 {
146 145 if (!bdev || !bdev->bd_inode)
147 146 return 0;
148 147  
149 148  
150 149  
151 150  
152 151  
... ... @@ -181,27 +180,28 @@
181 180  
182 181 /**
183 182 * read_lba(): Read bytes from disk, starting at given LBA
184   - * @bdev
  183 + * @state
185 184 * @lba
186 185 * @buffer
187 186 * @size_t
188 187 *
189   - * Description: Reads @count bytes from @bdev into @buffer.
  188 + * Description: Reads @count bytes from @state->bdev into @buffer.
190 189 * Returns number of bytes read on success, 0 on error.
191 190 */
192   -static size_t
193   -read_lba(struct block_device *bdev, u64 lba, u8 * buffer, size_t count)
  191 +static size_t read_lba(struct parsed_partitions *state,
  192 + u64 lba, u8 *buffer, size_t count)
194 193 {
195 194 size_t totalreadcount = 0;
  195 + struct block_device *bdev = state->bdev;
196 196 sector_t n = lba * (bdev_logical_block_size(bdev) / 512);
197 197  
198   - if (!bdev || !buffer || lba > last_lba(bdev))
  198 + if (!buffer || lba > last_lba(bdev))
199 199 return 0;
200 200  
201 201 while (count) {
202 202 int copied = 512;
203 203 Sector sect;
204   - unsigned char *data = read_dev_sector(bdev, n++, &sect);
  204 + unsigned char *data = read_part_sector(state, n++, &sect);
205 205 if (!data)
206 206 break;
207 207 if (copied > count)
208 208  
209 209  
... ... @@ -217,19 +217,20 @@
217 217  
218 218 /**
219 219 * alloc_read_gpt_entries(): reads partition entries from disk
220   - * @bdev
  220 + * @state
221 221 * @gpt - GPT header
222 222 *
223 223 * Description: Returns ptes on success, NULL on error.
224 224 * Allocates space for PTEs based on information found in @gpt.
225 225 * Notes: remember to free pte when you're done!
226 226 */
227   -static gpt_entry *
228   -alloc_read_gpt_entries(struct block_device *bdev, gpt_header *gpt)
  227 +static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
  228 + gpt_header *gpt)
229 229 {
230 230 size_t count;
231 231 gpt_entry *pte;
232   - if (!bdev || !gpt)
  232 +
  233 + if (!gpt)
233 234 return NULL;
234 235  
235 236 count = le32_to_cpu(gpt->num_partition_entries) *
... ... @@ -240,7 +241,7 @@
240 241 if (!pte)
241 242 return NULL;
242 243  
243   - if (read_lba(bdev, le64_to_cpu(gpt->partition_entry_lba),
  244 + if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
244 245 (u8 *) pte,
245 246 count) < count) {
246 247 kfree(pte);
247 248  
248 249  
249 250  
250 251  
251 252  
... ... @@ -252,27 +253,24 @@
252 253  
253 254 /**
254 255 * alloc_read_gpt_header(): Allocates GPT header, reads into it from disk
255   - * @bdev
  256 + * @state
256 257 * @lba is the Logical Block Address of the partition table
257 258 *
258 259 * Description: returns GPT header on success, NULL on error. Allocates
259   - * and fills a GPT header starting at @ from @bdev.
  260 + * and fills a GPT header starting at @ from @state->bdev.
260 261 * Note: remember to free gpt when finished with it.
261 262 */
262   -static gpt_header *
263   -alloc_read_gpt_header(struct block_device *bdev, u64 lba)
  263 +static gpt_header *alloc_read_gpt_header(struct parsed_partitions *state,
  264 + u64 lba)
264 265 {
265 266 gpt_header *gpt;
266   - unsigned ssz = bdev_logical_block_size(bdev);
  267 + unsigned ssz = bdev_logical_block_size(state->bdev);
267 268  
268   - if (!bdev)
269   - return NULL;
270   -
271 269 gpt = kzalloc(ssz, GFP_KERNEL);
272 270 if (!gpt)
273 271 return NULL;
274 272  
275   - if (read_lba(bdev, lba, (u8 *) gpt, ssz) < ssz) {
  273 + if (read_lba(state, lba, (u8 *) gpt, ssz) < ssz) {
276 274 kfree(gpt);
277 275 gpt=NULL;
278 276 return NULL;
... ... @@ -283,7 +281,7 @@
283 281  
284 282 /**
285 283 * is_gpt_valid() - tests one GPT header and PTEs for validity
286   - * @bdev
  284 + * @state
287 285 * @lba is the logical block address of the GPT header to test
288 286 * @gpt is a GPT header ptr, filled on return.
289 287 * @ptes is a PTEs ptr, filled on return.
290 288  
291 289  
... ... @@ -291,16 +289,15 @@
291 289 * Description: returns 1 if valid, 0 on error.
292 290 * If valid, returns pointers to newly allocated GPT header and PTEs.
293 291 */
294   -static int
295   -is_gpt_valid(struct block_device *bdev, u64 lba,
296   - gpt_header **gpt, gpt_entry **ptes)
  292 +static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
  293 + gpt_header **gpt, gpt_entry **ptes)
297 294 {
298 295 u32 crc, origcrc;
299 296 u64 lastlba;
300 297  
301   - if (!bdev || !gpt || !ptes)
  298 + if (!ptes)
302 299 return 0;
303   - if (!(*gpt = alloc_read_gpt_header(bdev, lba)))
  300 + if (!(*gpt = alloc_read_gpt_header(state, lba)))
304 301 return 0;
305 302  
306 303 /* Check the GUID Partition Table signature */
... ... @@ -336,7 +333,7 @@
336 333 /* Check the first_usable_lba and last_usable_lba are
337 334 * within the disk.
338 335 */
339   - lastlba = last_lba(bdev);
  336 + lastlba = last_lba(state->bdev);
340 337 if (le64_to_cpu((*gpt)->first_usable_lba) > lastlba) {
341 338 pr_debug("GPT: first_usable_lba incorrect: %lld > %lld\n",
342 339 (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba),
... ... @@ -350,7 +347,7 @@
350 347 goto fail;
351 348 }
352 349  
353   - if (!(*ptes = alloc_read_gpt_entries(bdev, *gpt)))
  350 + if (!(*ptes = alloc_read_gpt_entries(state, *gpt)))
354 351 goto fail;
355 352  
356 353 /* Check the GUID Partition Entry Array CRC */
... ... @@ -495,7 +492,7 @@
495 492  
496 493 /**
497 494 * find_valid_gpt() - Search disk for valid GPT headers and PTEs
498   - * @bdev
  495 + * @state
499 496 * @gpt is a GPT header ptr, filled on return.
500 497 * @ptes is a PTEs ptr, filled on return.
501 498 * Description: Returns 1 if valid, 0 on error.
502 499  
503 500  
504 501  
... ... @@ -508,24 +505,25 @@
508 505 * This protects against devices which misreport their size, and forces
509 506 * the user to decide to use the Alternate GPT.
510 507 */
511   -static int
512   -find_valid_gpt(struct block_device *bdev, gpt_header **gpt, gpt_entry **ptes)
  508 +static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,
  509 + gpt_entry **ptes)
513 510 {
514 511 int good_pgpt = 0, good_agpt = 0, good_pmbr = 0;
515 512 gpt_header *pgpt = NULL, *agpt = NULL;
516 513 gpt_entry *pptes = NULL, *aptes = NULL;
517 514 legacy_mbr *legacymbr;
518 515 u64 lastlba;
519   - if (!bdev || !gpt || !ptes)
  516 +
  517 + if (!ptes)
520 518 return 0;
521 519  
522   - lastlba = last_lba(bdev);
  520 + lastlba = last_lba(state->bdev);
523 521 if (!force_gpt) {
524 522 /* This will be added to the EFI Spec. per Intel after v1.02. */
525 523 legacymbr = kzalloc(sizeof (*legacymbr), GFP_KERNEL);
526 524 if (legacymbr) {
527   - read_lba(bdev, 0, (u8 *) legacymbr,
528   - sizeof (*legacymbr));
  525 + read_lba(state, 0, (u8 *) legacymbr,
  526 + sizeof (*legacymbr));
529 527 good_pmbr = is_pmbr_valid(legacymbr);
530 528 kfree(legacymbr);
531 529 }
532 530  
533 531  
... ... @@ -533,15 +531,14 @@
533 531 goto fail;
534 532 }
535 533  
536   - good_pgpt = is_gpt_valid(bdev, GPT_PRIMARY_PARTITION_TABLE_LBA,
  534 + good_pgpt = is_gpt_valid(state, GPT_PRIMARY_PARTITION_TABLE_LBA,
537 535 &pgpt, &pptes);
538 536 if (good_pgpt)
539   - good_agpt = is_gpt_valid(bdev,
  537 + good_agpt = is_gpt_valid(state,
540 538 le64_to_cpu(pgpt->alternate_lba),
541 539 &agpt, &aptes);
542 540 if (!good_agpt && force_gpt)
543   - good_agpt = is_gpt_valid(bdev, lastlba,
544   - &agpt, &aptes);
  541 + good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes);
545 542  
546 543 /* The obviously unsuccessful case */
547 544 if (!good_pgpt && !good_agpt)
548 545  
... ... @@ -583,9 +580,8 @@
583 580 }
584 581  
585 582 /**
586   - * efi_partition(struct parsed_partitions *state, struct block_device *bdev)
  583 + * efi_partition(struct parsed_partitions *state)
587 584 * @state
588   - * @bdev
589 585 *
590 586 * Description: called from check.c, if the disk contains GPT
591 587 * partitions, sets up partition entries in the kernel.
592 588  
593 589  
... ... @@ -602,15 +598,14 @@
602 598 * 1 if successful
603 599 *
604 600 */
605   -int
606   -efi_partition(struct parsed_partitions *state, struct block_device *bdev)
  601 +int efi_partition(struct parsed_partitions *state)
607 602 {
608 603 gpt_header *gpt = NULL;
609 604 gpt_entry *ptes = NULL;
610 605 u32 i;
611   - unsigned ssz = bdev_logical_block_size(bdev) / 512;
  606 + unsigned ssz = bdev_logical_block_size(state->bdev) / 512;
612 607  
613   - if (!find_valid_gpt(bdev, &gpt, &ptes) || !gpt || !ptes) {
  608 + if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
614 609 kfree(gpt);
615 610 kfree(ptes);
616 611 return 0;
... ... @@ -623,7 +618,7 @@
623 618 u64 size = le64_to_cpu(ptes[i].ending_lba) -
624 619 le64_to_cpu(ptes[i].starting_lba) + 1ULL;
625 620  
626   - if (!is_pte_valid(&ptes[i], last_lba(bdev)))
  621 + if (!is_pte_valid(&ptes[i], last_lba(state->bdev)))
627 622 continue;
628 623  
629 624 put_partition(state, i+1, start * ssz, size * ssz);
... ... @@ -110,7 +110,7 @@
110 110 } __attribute__ ((packed)) legacy_mbr;
111 111  
112 112 /* Functions */
113   -extern int efi_partition(struct parsed_partitions *state, struct block_device *bdev);
  113 +extern int efi_partition(struct parsed_partitions *state);
114 114  
115 115 #endif
116 116  
... ... @@ -58,9 +58,9 @@
58 58  
59 59 /*
60 60 */
61   -int
62   -ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
  61 +int ibm_partition(struct parsed_partitions *state)
63 62 {
  63 + struct block_device *bdev = state->bdev;
64 64 int blocksize, res;
65 65 loff_t i_size, offset, size, fmt_size;
66 66 dasd_information2_t *info;
... ... @@ -100,7 +100,8 @@
100 100 /*
101 101 * Get volume label, extract name and type.
102 102 */
103   - data = read_dev_sector(bdev, info->label_block*(blocksize/512), &sect);
  103 + data = read_part_sector(state, info->label_block*(blocksize/512),
  104 + &sect);
104 105 if (data == NULL)
105 106 goto out_readerr;
106 107  
... ... @@ -193,8 +194,8 @@
193 194 */
194 195 blk = cchhb2blk(&label->vol.vtoc, geo) + 1;
195 196 counter = 0;
196   - data = read_dev_sector(bdev, blk * (blocksize/512),
197   - &sect);
  197 + data = read_part_sector(state, blk * (blocksize/512),
  198 + &sect);
198 199 while (data != NULL) {
199 200 struct vtoc_format1_label f1;
200 201  
... ... @@ -208,9 +209,8 @@
208 209 || f1.DS1FMTID == _ascebc['7']
209 210 || f1.DS1FMTID == _ascebc['9']) {
210 211 blk++;
211   - data = read_dev_sector(bdev, blk *
212   - (blocksize/512),
213   - &sect);
  212 + data = read_part_sector(state,
  213 + blk * (blocksize/512), &sect);
214 214 continue;
215 215 }
216 216  
... ... @@ -230,9 +230,8 @@
230 230 size * (blocksize >> 9));
231 231 counter++;
232 232 blk++;
233   - data = read_dev_sector(bdev,
234   - blk * (blocksize/512),
235   - &sect);
  233 + data = read_part_sector(state,
  234 + blk * (blocksize/512), &sect);
236 235 }
237 236  
238 237 if (!data)
1   -int ibm_partition(struct parsed_partitions *, struct block_device *);
  1 +int ibm_partition(struct parsed_partitions *);
fs/partitions/karma.c
... ... @@ -9,7 +9,7 @@
9 9 #include "check.h"
10 10 #include "karma.h"
11 11  
12   -int karma_partition(struct parsed_partitions *state, struct block_device *bdev)
  12 +int karma_partition(struct parsed_partitions *state)
13 13 {
14 14 int i;
15 15 int slot = 1;
... ... @@ -29,7 +29,7 @@
29 29 } __attribute__((packed)) *label;
30 30 struct d_partition *p;
31 31  
32   - data = read_dev_sector(bdev, 0, &sect);
  32 + data = read_part_sector(state, 0, &sect);
33 33 if (!data)
34 34 return -1;
35 35  
fs/partitions/karma.h
... ... @@ -4,5 +4,5 @@
4 4  
5 5 #define KARMA_LABEL_MAGIC 0xAB56
6 6  
7   -int karma_partition(struct parsed_partitions *state, struct block_device *bdev);
  7 +int karma_partition(struct parsed_partitions *state);
... ... @@ -309,7 +309,7 @@
309 309  
310 310 /**
311 311 * ldm_validate_privheads - Compare the primary privhead with its backups
312   - * @bdev: Device holding the LDM Database
  312 + * @state: Partition check state including device holding the LDM Database
313 313 * @ph1: Memory struct to fill with ph contents
314 314 *
315 315 * Read and compare all three privheads from disk.
... ... @@ -321,8 +321,8 @@
321 321 * Return: 'true' Success
322 322 * 'false' Error
323 323 */
324   -static bool ldm_validate_privheads (struct block_device *bdev,
325   - struct privhead *ph1)
  324 +static bool ldm_validate_privheads(struct parsed_partitions *state,
  325 + struct privhead *ph1)
326 326 {
327 327 static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 };
328 328 struct privhead *ph[3] = { ph1 };
... ... @@ -332,7 +332,7 @@
332 332 long num_sects;
333 333 int i;
334 334  
335   - BUG_ON (!bdev || !ph1);
  335 + BUG_ON (!state || !ph1);
336 336  
337 337 ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL);
338 338 ph[2] = kmalloc (sizeof (*ph[2]), GFP_KERNEL);
... ... @@ -346,8 +346,8 @@
346 346  
347 347 /* Read and parse privheads */
348 348 for (i = 0; i < 3; i++) {
349   - data = read_dev_sector (bdev,
350   - ph[0]->config_start + off[i], &sect);
  349 + data = read_part_sector(state, ph[0]->config_start + off[i],
  350 + &sect);
351 351 if (!data) {
352 352 ldm_crit ("Disk read failed.");
353 353 goto out;
... ... @@ -363,7 +363,7 @@
363 363 }
364 364 }
365 365  
366   - num_sects = bdev->bd_inode->i_size >> 9;
  366 + num_sects = state->bdev->bd_inode->i_size >> 9;
367 367  
368 368 if ((ph[0]->config_start > num_sects) ||
369 369 ((ph[0]->config_start + ph[0]->config_size) > num_sects)) {
370 370  
371 371  
... ... @@ -397,20 +397,20 @@
397 397  
398 398 /**
399 399 * ldm_validate_tocblocks - Validate the table of contents and its backups
400   - * @bdev: Device holding the LDM Database
401   - * @base: Offset, into @bdev, of the database
  400 + * @state: Partition check state including device holding the LDM Database
  401 + * @base: Offset, into @state->bdev, of the database
402 402 * @ldb: Cache of the database structures
403 403 *
404 404 * Find and compare the four tables of contents of the LDM Database stored on
405   - * @bdev and return the parsed information into @toc1.
  405 + * @state->bdev and return the parsed information into @toc1.
406 406 *
407 407 * The offsets and sizes of the configs are range-checked against a privhead.
408 408 *
409 409 * Return: 'true' @toc1 contains validated TOCBLOCK info
410 410 * 'false' @toc1 contents are undefined
411 411 */
412   -static bool ldm_validate_tocblocks(struct block_device *bdev,
413   - unsigned long base, struct ldmdb *ldb)
  412 +static bool ldm_validate_tocblocks(struct parsed_partitions *state,
  413 + unsigned long base, struct ldmdb *ldb)
414 414 {
415 415 static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4};
416 416 struct tocblock *tb[4];
... ... @@ -420,7 +420,7 @@
420 420 int i, nr_tbs;
421 421 bool result = false;
422 422  
423   - BUG_ON(!bdev || !ldb);
  423 + BUG_ON(!state || !ldb);
424 424 ph = &ldb->ph;
425 425 tb[0] = &ldb->toc;
426 426 tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
... ... @@ -437,7 +437,7 @@
437 437 * skip any that fail as long as we get at least one valid TOCBLOCK.
438 438 */
439 439 for (nr_tbs = i = 0; i < 4; i++) {
440   - data = read_dev_sector(bdev, base + off[i], &sect);
  440 + data = read_part_sector(state, base + off[i], &sect);
441 441 if (!data) {
442 442 ldm_error("Disk read failed for TOCBLOCK %d.", i);
443 443 continue;
... ... @@ -473,7 +473,7 @@
473 473  
474 474 /**
475 475 * ldm_validate_vmdb - Read the VMDB and validate it
476   - * @bdev: Device holding the LDM Database
  476 + * @state: Partition check state including device holding the LDM Database
477 477 * @base: Offset, into @bdev, of the database
478 478 * @ldb: Cache of the database structures
479 479 *
... ... @@ -483,8 +483,8 @@
483 483 * Return: 'true' @ldb contains validated VBDB info
484 484 * 'false' @ldb contents are undefined
485 485 */
486   -static bool ldm_validate_vmdb (struct block_device *bdev, unsigned long base,
487   - struct ldmdb *ldb)
  486 +static bool ldm_validate_vmdb(struct parsed_partitions *state,
  487 + unsigned long base, struct ldmdb *ldb)
488 488 {
489 489 Sector sect;
490 490 u8 *data;
491 491  
... ... @@ -492,12 +492,12 @@
492 492 struct vmdb *vm;
493 493 struct tocblock *toc;
494 494  
495   - BUG_ON (!bdev || !ldb);
  495 + BUG_ON (!state || !ldb);
496 496  
497 497 vm = &ldb->vm;
498 498 toc = &ldb->toc;
499 499  
500   - data = read_dev_sector (bdev, base + OFF_VMDB, &sect);
  500 + data = read_part_sector(state, base + OFF_VMDB, &sect);
501 501 if (!data) {
502 502 ldm_crit ("Disk read failed.");
503 503 return false;
504 504  
505 505  
506 506  
... ... @@ -534,21 +534,21 @@
534 534  
535 535 /**
536 536 * ldm_validate_partition_table - Determine whether bdev might be a dynamic disk
537   - * @bdev: Device holding the LDM Database
  537 + * @state: Partition check state including device holding the LDM Database
538 538 *
539 539 * This function provides a weak test to decide whether the device is a dynamic
540 540 * disk or not. It looks for an MS-DOS-style partition table containing at
541 541 * least one partition of type 0x42 (formerly SFS, now used by Windows for
542 542 * dynamic disks).
543 543 *
544   - * N.B. The only possible error can come from the read_dev_sector and that is
  544 + * N.B. The only possible error can come from the read_part_sector and that is
545 545 * only likely to happen if the underlying device is strange. If that IS
546 546 * the case we should return zero to let someone else try.
547 547 *
548   - * Return: 'true' @bdev is a dynamic disk
549   - * 'false' @bdev is not a dynamic disk, or an error occurred
  548 + * Return: 'true' @state->bdev is a dynamic disk
  549 + * 'false' @state->bdev is not a dynamic disk, or an error occurred
550 550 */
551   -static bool ldm_validate_partition_table (struct block_device *bdev)
  551 +static bool ldm_validate_partition_table(struct parsed_partitions *state)
552 552 {
553 553 Sector sect;
554 554 u8 *data;
555 555  
... ... @@ -556,9 +556,9 @@
556 556 int i;
557 557 bool result = false;
558 558  
559   - BUG_ON (!bdev);
  559 + BUG_ON(!state);
560 560  
561   - data = read_dev_sector (bdev, 0, &sect);
  561 + data = read_part_sector(state, 0, &sect);
562 562 if (!data) {
563 563 ldm_crit ("Disk read failed.");
564 564 return false;
... ... @@ -1391,8 +1391,8 @@
1391 1391  
1392 1392 /**
1393 1393 * ldm_get_vblks - Read the on-disk database of VBLKs into memory
1394   - * @bdev: Device holding the LDM Database
1395   - * @base: Offset, into @bdev, of the database
  1394 + * @state: Partition check state including device holding the LDM Database
  1395 + * @base: Offset, into @state->bdev, of the database
1396 1396 * @ldb: Cache of the database structures
1397 1397 *
1398 1398 * To use the information from the VBLKs, they need to be read from the disk,
... ... @@ -1401,8 +1401,8 @@
1401 1401 * Return: 'true' All the VBLKs were read successfully
1402 1402 * 'false' An error occurred
1403 1403 */
1404   -static bool ldm_get_vblks (struct block_device *bdev, unsigned long base,
1405   - struct ldmdb *ldb)
  1404 +static bool ldm_get_vblks(struct parsed_partitions *state, unsigned long base,
  1405 + struct ldmdb *ldb)
1406 1406 {
1407 1407 int size, perbuf, skip, finish, s, v, recs;
1408 1408 u8 *data = NULL;
... ... @@ -1410,7 +1410,7 @@
1410 1410 bool result = false;
1411 1411 LIST_HEAD (frags);
1412 1412  
1413   - BUG_ON (!bdev || !ldb);
  1413 + BUG_ON(!state || !ldb);
1414 1414  
1415 1415 size = ldb->vm.vblk_size;
1416 1416 perbuf = 512 / size;
... ... @@ -1418,7 +1418,7 @@
1418 1418 finish = (size * ldb->vm.last_vblk_seq) >> 9;
1419 1419  
1420 1420 for (s = skip; s < finish; s++) { /* For each sector */
1421   - data = read_dev_sector (bdev, base + OFF_VMDB + s, &sect);
  1421 + data = read_part_sector(state, base + OFF_VMDB + s, &sect);
1422 1422 if (!data) {
1423 1423 ldm_crit ("Disk read failed.");
1424 1424 goto out;
... ... @@ -1474,8 +1474,7 @@
1474 1474  
1475 1475 /**
1476 1476 * ldm_partition - Find out whether a device is a dynamic disk and handle it
1477   - * @pp: List of the partitions parsed so far
1478   - * @bdev: Device holding the LDM Database
  1477 + * @state: Partition check state including device holding the LDM Database
1479 1478 *
1480 1479 * This determines whether the device @bdev is a dynamic disk and if so creates
1481 1480 * the partitions necessary in the gendisk structure pointed to by @hd.
1482 1481  
1483 1482  
1484 1483  
1485 1484  
... ... @@ -1485,21 +1484,21 @@
1485 1484 * example, if the device is hda, we would have: hda1: LDM database, hda2, hda3,
1486 1485 * and so on: the actual data containing partitions.
1487 1486 *
1488   - * Return: 1 Success, @bdev is a dynamic disk and we handled it
1489   - * 0 Success, @bdev is not a dynamic disk
  1487 + * Return: 1 Success, @state->bdev is a dynamic disk and we handled it
  1488 + * 0 Success, @state->bdev is not a dynamic disk
1490 1489 * -1 An error occurred before enough information had been read
1491   - * Or @bdev is a dynamic disk, but it may be corrupted
  1490 + * Or @state->bdev is a dynamic disk, but it may be corrupted
1492 1491 */
1493   -int ldm_partition (struct parsed_partitions *pp, struct block_device *bdev)
  1492 +int ldm_partition(struct parsed_partitions *state)
1494 1493 {
1495 1494 struct ldmdb *ldb;
1496 1495 unsigned long base;
1497 1496 int result = -1;
1498 1497  
1499   - BUG_ON (!pp || !bdev);
  1498 + BUG_ON(!state);
1500 1499  
1501 1500 /* Look for signs of a Dynamic Disk */
1502   - if (!ldm_validate_partition_table (bdev))
  1501 + if (!ldm_validate_partition_table(state))
1503 1502 return 0;
1504 1503  
1505 1504 ldb = kmalloc (sizeof (*ldb), GFP_KERNEL);
1506 1505  
... ... @@ -1509,15 +1508,15 @@
1509 1508 }
1510 1509  
1511 1510 /* Parse and check privheads. */
1512   - if (!ldm_validate_privheads (bdev, &ldb->ph))
  1511 + if (!ldm_validate_privheads(state, &ldb->ph))
1513 1512 goto out; /* Already logged */
1514 1513  
1515 1514 /* All further references are relative to base (database start). */
1516 1515 base = ldb->ph.config_start;
1517 1516  
1518 1517 /* Parse and check tocs and vmdb. */
1519   - if (!ldm_validate_tocblocks (bdev, base, ldb) ||
1520   - !ldm_validate_vmdb (bdev, base, ldb))
  1518 + if (!ldm_validate_tocblocks(state, base, ldb) ||
  1519 + !ldm_validate_vmdb(state, base, ldb))
1521 1520 goto out; /* Already logged */
1522 1521  
1523 1522 /* Initialize vblk lists in ldmdb struct */
1524 1523  
... ... @@ -1527,13 +1526,13 @@
1527 1526 INIT_LIST_HEAD (&ldb->v_comp);
1528 1527 INIT_LIST_HEAD (&ldb->v_part);
1529 1528  
1530   - if (!ldm_get_vblks (bdev, base, ldb)) {
  1529 + if (!ldm_get_vblks(state, base, ldb)) {
1531 1530 ldm_crit ("Failed to read the VBLKs from the database.");
1532 1531 goto cleanup;
1533 1532 }
1534 1533  
1535 1534 /* Finally, create the data partition devices. */
1536   - if (ldm_create_data_partitions (pp, ldb)) {
  1535 + if (ldm_create_data_partitions(state, ldb)) {
1537 1536 ldm_debug ("Parsed LDM database successfully.");
1538 1537 result = 1;
1539 1538 }
... ... @@ -209,7 +209,7 @@
209 209 struct list_head v_part;
210 210 };
211 211  
212   -int ldm_partition (struct parsed_partitions *state, struct block_device *bdev);
  212 +int ldm_partition(struct parsed_partitions *state);
213 213  
214 214 #endif /* _FS_PT_LDM_H_ */
... ... @@ -27,7 +27,7 @@
27 27 stg[i] = 0;
28 28 }
29 29  
30   -int mac_partition(struct parsed_partitions *state, struct block_device *bdev)
  30 +int mac_partition(struct parsed_partitions *state)
31 31 {
32 32 int slot = 1;
33 33 Sector sect;
... ... @@ -42,7 +42,7 @@
42 42 struct mac_driver_desc *md;
43 43  
44 44 /* Get 0th block and look at the first partition map entry. */
45   - md = (struct mac_driver_desc *) read_dev_sector(bdev, 0, &sect);
  45 + md = read_part_sector(state, 0, &sect);
46 46 if (!md)
47 47 return -1;
48 48 if (be16_to_cpu(md->signature) != MAC_DRIVER_MAGIC) {
... ... @@ -51,7 +51,7 @@
51 51 }
52 52 secsize = be16_to_cpu(md->block_size);
53 53 put_dev_sector(sect);
54   - data = read_dev_sector(bdev, secsize/512, &sect);
  54 + data = read_part_sector(state, secsize/512, &sect);
55 55 if (!data)
56 56 return -1;
57 57 part = (struct mac_partition *) (data + secsize%512);
... ... @@ -64,7 +64,7 @@
64 64 for (blk = 1; blk <= blocks_in_map; ++blk) {
65 65 int pos = blk * secsize;
66 66 put_dev_sector(sect);
67   - data = read_dev_sector(bdev, pos/512, &sect);
  67 + data = read_part_sector(state, pos/512, &sect);
68 68 if (!data)
69 69 return -1;
70 70 part = (struct mac_partition *) (data + pos%512);
... ... @@ -123,7 +123,8 @@
123 123 }
124 124 #ifdef CONFIG_PPC_PMAC
125 125 if (found_root_goodness)
126   - note_bootable_part(bdev->bd_dev, found_root, found_root_goodness);
  126 + note_bootable_part(state->bdev->bd_dev, found_root,
  127 + found_root_goodness);
127 128 #endif
128 129  
129 130 put_dev_sector(sect);
... ... @@ -41,5 +41,5 @@
41 41 /* ... more stuff */
42 42 };
43 43  
44   -int mac_partition(struct parsed_partitions *state, struct block_device *bdev);
  44 +int mac_partition(struct parsed_partitions *state);
fs/partitions/msdos.c
... ... @@ -64,7 +64,7 @@
64 64 #define AIX_LABEL_MAGIC2 0xC2
65 65 #define AIX_LABEL_MAGIC3 0xD4
66 66 #define AIX_LABEL_MAGIC4 0xC1
67   -static int aix_magic_present(unsigned char *p, struct block_device *bdev)
  67 +static int aix_magic_present(struct parsed_partitions *state, unsigned char *p)
68 68 {
69 69 struct partition *pt = (struct partition *) (p + 0x1be);
70 70 Sector sect;
... ... @@ -85,7 +85,7 @@
85 85 is_extended_partition(pt))
86 86 return 0;
87 87 }
88   - d = read_dev_sector(bdev, 7, &sect);
  88 + d = read_part_sector(state, 7, &sect);
89 89 if (d) {
90 90 if (d[0] == '_' && d[1] == 'L' && d[2] == 'V' && d[3] == 'M')
91 91 ret = 1;
92 92  
... ... @@ -105,15 +105,14 @@
105 105 * only for the actual data partitions.
106 106 */
107 107  
108   -static void
109   -parse_extended(struct parsed_partitions *state, struct block_device *bdev,
110   - sector_t first_sector, sector_t first_size)
  108 +static void parse_extended(struct parsed_partitions *state,
  109 + sector_t first_sector, sector_t first_size)
111 110 {
112 111 struct partition *p;
113 112 Sector sect;
114 113 unsigned char *data;
115 114 sector_t this_sector, this_size;
116   - sector_t sector_size = bdev_logical_block_size(bdev) / 512;
  115 + sector_t sector_size = bdev_logical_block_size(state->bdev) / 512;
117 116 int loopct = 0; /* number of links followed
118 117 without finding a data partition */
119 118 int i;
... ... @@ -126,7 +125,7 @@
126 125 return;
127 126 if (state->next == state->limit)
128 127 return;
129   - data = read_dev_sector(bdev, this_sector, &sect);
  128 + data = read_part_sector(state, this_sector, &sect);
130 129 if (!data)
131 130 return;
132 131  
... ... @@ -198,9 +197,8 @@
198 197 /* james@bpgc.com: Solaris has a nasty indicator: 0x82 which also
199 198 indicates linux swap. Be careful before believing this is Solaris. */
200 199  
201   -static void
202   -parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev,
203   - sector_t offset, sector_t size, int origin)
  200 +static void parse_solaris_x86(struct parsed_partitions *state,
  201 + sector_t offset, sector_t size, int origin)
204 202 {
205 203 #ifdef CONFIG_SOLARIS_X86_PARTITION
206 204 Sector sect;
... ... @@ -208,7 +206,7 @@
208 206 int i;
209 207 short max_nparts;
210 208  
211   - v = (struct solaris_x86_vtoc *)read_dev_sector(bdev, offset+1, &sect);
  209 + v = read_part_sector(state, offset + 1, &sect);
212 210 if (!v)
213 211 return;
214 212 if (le32_to_cpu(v->v_sanity) != SOLARIS_X86_VTOC_SANE) {
215 213  
... ... @@ -245,16 +243,15 @@
245 243 * Create devices for BSD partitions listed in a disklabel, under a
246 244 * dos-like partition. See parse_extended() for more information.
247 245 */
248   -static void
249   -parse_bsd(struct parsed_partitions *state, struct block_device *bdev,
250   - sector_t offset, sector_t size, int origin, char *flavour,
251   - int max_partitions)
  246 +static void parse_bsd(struct parsed_partitions *state,
  247 + sector_t offset, sector_t size, int origin, char *flavour,
  248 + int max_partitions)
252 249 {
253 250 Sector sect;
254 251 struct bsd_disklabel *l;
255 252 struct bsd_partition *p;
256 253  
257   - l = (struct bsd_disklabel *)read_dev_sector(bdev, offset+1, &sect);
  254 + l = read_part_sector(state, offset + 1, &sect);
258 255 if (!l)
259 256 return;
260 257 if (le32_to_cpu(l->d_magic) != BSD_DISKMAGIC) {
261 258  
262 259  
263 260  
264 261  
265 262  
... ... @@ -291,33 +288,28 @@
291 288 }
292 289 #endif
293 290  
294   -static void
295   -parse_freebsd(struct parsed_partitions *state, struct block_device *bdev,
296   - sector_t offset, sector_t size, int origin)
  291 +static void parse_freebsd(struct parsed_partitions *state,
  292 + sector_t offset, sector_t size, int origin)
297 293 {
298 294 #ifdef CONFIG_BSD_DISKLABEL
299   - parse_bsd(state, bdev, offset, size, origin,
300   - "bsd", BSD_MAXPARTITIONS);
  295 + parse_bsd(state, offset, size, origin, "bsd", BSD_MAXPARTITIONS);
301 296 #endif
302 297 }
303 298  
304   -static void
305   -parse_netbsd(struct parsed_partitions *state, struct block_device *bdev,
306   - sector_t offset, sector_t size, int origin)
  299 +static void parse_netbsd(struct parsed_partitions *state,
  300 + sector_t offset, sector_t size, int origin)
307 301 {
308 302 #ifdef CONFIG_BSD_DISKLABEL
309   - parse_bsd(state, bdev, offset, size, origin,
310   - "netbsd", BSD_MAXPARTITIONS);
  303 + parse_bsd(state, offset, size, origin, "netbsd", BSD_MAXPARTITIONS);
311 304 #endif
312 305 }
313 306  
314   -static void
315   -parse_openbsd(struct parsed_partitions *state, struct block_device *bdev,
316   - sector_t offset, sector_t size, int origin)
  307 +static void parse_openbsd(struct parsed_partitions *state,
  308 + sector_t offset, sector_t size, int origin)
317 309 {
318 310 #ifdef CONFIG_BSD_DISKLABEL
319   - parse_bsd(state, bdev, offset, size, origin,
320   - "openbsd", OPENBSD_MAXPARTITIONS);
  311 + parse_bsd(state, offset, size, origin, "openbsd",
  312 + OPENBSD_MAXPARTITIONS);
321 313 #endif
322 314 }
323 315  
324 316  
... ... @@ -325,16 +317,15 @@
325 317 * Create devices for Unixware partitions listed in a disklabel, under a
326 318 * dos-like partition. See parse_extended() for more information.
327 319 */
328   -static void
329   -parse_unixware(struct parsed_partitions *state, struct block_device *bdev,
330   - sector_t offset, sector_t size, int origin)
  320 +static void parse_unixware(struct parsed_partitions *state,
  321 + sector_t offset, sector_t size, int origin)
331 322 {
332 323 #ifdef CONFIG_UNIXWARE_DISKLABEL
333 324 Sector sect;
334 325 struct unixware_disklabel *l;
335 326 struct unixware_slice *p;
336 327  
337   - l = (struct unixware_disklabel *)read_dev_sector(bdev, offset+29, &sect);
  328 + l = read_part_sector(state, offset + 29, &sect);
338 329 if (!l)
339 330 return;
340 331 if (le32_to_cpu(l->d_magic) != UNIXWARE_DISKMAGIC ||
... ... @@ -365,9 +356,8 @@
365 356 * Anand Krishnamurthy <anandk@wiproge.med.ge.com>
366 357 * Rajeev V. Pillai <rajeevvp@yahoo.com>
367 358 */
368   -static void
369   -parse_minix(struct parsed_partitions *state, struct block_device *bdev,
370   - sector_t offset, sector_t size, int origin)
  359 +static void parse_minix(struct parsed_partitions *state,
  360 + sector_t offset, sector_t size, int origin)
371 361 {
372 362 #ifdef CONFIG_MINIX_SUBPARTITION
373 363 Sector sect;
... ... @@ -375,7 +365,7 @@
375 365 struct partition *p;
376 366 int i;
377 367  
378   - data = read_dev_sector(bdev, offset, &sect);
  368 + data = read_part_sector(state, offset, &sect);
379 369 if (!data)
380 370 return;
381 371  
... ... @@ -404,8 +394,7 @@
404 394  
405 395 static struct {
406 396 unsigned char id;
407   - void (*parse)(struct parsed_partitions *, struct block_device *,
408   - sector_t, sector_t, int);
  397 + void (*parse)(struct parsed_partitions *, sector_t, sector_t, int);
409 398 } subtypes[] = {
410 399 {FREEBSD_PARTITION, parse_freebsd},
411 400 {NETBSD_PARTITION, parse_netbsd},
412 401  
413 402  
... ... @@ -417,16 +406,16 @@
417 406 {0, NULL},
418 407 };
419 408  
420   -int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
  409 +int msdos_partition(struct parsed_partitions *state)
421 410 {
422   - sector_t sector_size = bdev_logical_block_size(bdev) / 512;
  411 + sector_t sector_size = bdev_logical_block_size(state->bdev) / 512;
423 412 Sector sect;
424 413 unsigned char *data;
425 414 struct partition *p;
426 415 struct fat_boot_sector *fb;
427 416 int slot;
428 417  
429   - data = read_dev_sector(bdev, 0, &sect);
  418 + data = read_part_sector(state, 0, &sect);
430 419 if (!data)
431 420 return -1;
432 421 if (!msdos_magic_present(data + 510)) {
... ... @@ -434,7 +423,7 @@
434 423 return 0;
435 424 }
436 425  
437   - if (aix_magic_present(data, bdev)) {
  426 + if (aix_magic_present(state, data)) {
438 427 put_dev_sector(sect);
439 428 printk( " [AIX]");
440 429 return 0;
... ... @@ -503,7 +492,7 @@
503 492 put_partition(state, slot, start, n);
504 493  
505 494 printk(" <");
506   - parse_extended(state, bdev, start, size);
  495 + parse_extended(state, start, size);
507 496 printk(" >");
508 497 continue;
509 498 }
... ... @@ -532,8 +521,8 @@
532 521  
533 522 if (!subtypes[n].parse)
534 523 continue;
535   - subtypes[n].parse(state, bdev, start_sect(p)*sector_size,
536   - nr_sects(p)*sector_size, slot);
  524 + subtypes[n].parse(state, start_sect(p) * sector_size,
  525 + nr_sects(p) * sector_size, slot);
537 526 }
538 527 put_dev_sector(sect);
539 528 return 1;
fs/partitions/msdos.h
... ... @@ -4,5 +4,5 @@
4 4  
5 5 #define MSDOS_LABEL_MAGIC 0xAA55
6 6  
7   -int msdos_partition(struct parsed_partitions *state, struct block_device *bdev);
  7 +int msdos_partition(struct parsed_partitions *state);
... ... @@ -10,7 +10,7 @@
10 10 #include "check.h"
11 11 #include "osf.h"
12 12  
13   -int osf_partition(struct parsed_partitions *state, struct block_device *bdev)
  13 +int osf_partition(struct parsed_partitions *state)
14 14 {
15 15 int i;
16 16 int slot = 1;
... ... @@ -49,7 +49,7 @@
49 49 } * label;
50 50 struct d_partition * partition;
51 51  
52   - data = read_dev_sector(bdev, 0, &sect);
  52 + data = read_part_sector(state, 0, &sect);
53 53 if (!data)
54 54 return -1;
55 55  
... ... @@ -4,5 +4,5 @@
4 4  
5 5 #define DISKLABELMAGIC (0x82564557UL)
6 6  
7   -int osf_partition(struct parsed_partitions *state, struct block_device *bdev);
  7 +int osf_partition(struct parsed_partitions *state);
... ... @@ -27,7 +27,7 @@
27 27 __be32 _unused1; /* Padding */
28 28 };
29 29  
30   -int sgi_partition(struct parsed_partitions *state, struct block_device *bdev)
  30 +int sgi_partition(struct parsed_partitions *state)
31 31 {
32 32 int i, csum;
33 33 __be32 magic;
... ... @@ -39,7 +39,7 @@
39 39 struct sgi_partition *p;
40 40 char b[BDEVNAME_SIZE];
41 41  
42   - label = (struct sgi_disklabel *) read_dev_sector(bdev, 0, &sect);
  42 + label = read_part_sector(state, 0, &sect);
43 43 if (!label)
44 44 return -1;
45 45 p = &label->partitions[0];
... ... @@ -57,7 +57,7 @@
57 57 }
58 58 if(csum) {
59 59 printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
60   - bdevname(bdev, b));
  60 + bdevname(state->bdev, b));
61 61 put_dev_sector(sect);
62 62 return 0;
63 63 }
... ... @@ -2,7 +2,7 @@
2 2 * fs/partitions/sgi.h
3 3 */
4 4  
5   -extern int sgi_partition(struct parsed_partitions *state, struct block_device *bdev);
  5 +extern int sgi_partition(struct parsed_partitions *state);
6 6  
7 7 #define SGI_LABEL_MAGIC 0x0be5a941
... ... @@ -10,7 +10,7 @@
10 10 #include "check.h"
11 11 #include "sun.h"
12 12  
13   -int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
  13 +int sun_partition(struct parsed_partitions *state)
14 14 {
15 15 int i;
16 16 __be16 csum;
... ... @@ -61,7 +61,7 @@
61 61 int use_vtoc;
62 62 int nparts;
63 63  
64   - label = (struct sun_disklabel *)read_dev_sector(bdev, 0, &sect);
  64 + label = read_part_sector(state, 0, &sect);
65 65 if (!label)
66 66 return -1;
67 67  
... ... @@ -78,7 +78,7 @@
78 78 csum ^= *ush--;
79 79 if (csum) {
80 80 printk("Dev %s Sun disklabel: Csum bad, label corrupted\n",
81   - bdevname(bdev, b));
  81 + bdevname(state->bdev, b));
82 82 put_dev_sector(sect);
83 83 return 0;
84 84 }
... ... @@ -5,5 +5,5 @@
5 5 #define SUN_LABEL_MAGIC 0xDABE
6 6 #define SUN_VTOC_SANITY 0x600DDEEE
7 7  
8   -int sun_partition(struct parsed_partitions *state, struct block_device *bdev);
  8 +int sun_partition(struct parsed_partitions *state);
fs/partitions/sysv68.c
... ... @@ -46,7 +46,7 @@
46 46 };
47 47  
48 48  
49   -int sysv68_partition(struct parsed_partitions *state, struct block_device *bdev)
  49 +int sysv68_partition(struct parsed_partitions *state)
50 50 {
51 51 int i, slices;
52 52 int slot = 1;
... ... @@ -55,7 +55,7 @@
55 55 struct dkblk0 *b;
56 56 struct slice *slice;
57 57  
58   - data = read_dev_sector(bdev, 0, &sect);
  58 + data = read_part_sector(state, 0, &sect);
59 59 if (!data)
60 60 return -1;
61 61  
... ... @@ -68,7 +68,7 @@
68 68 i = be32_to_cpu(b->dk_ios.ios_slcblk);
69 69 put_dev_sector(sect);
70 70  
71   - data = read_dev_sector(bdev, i, &sect);
  71 + data = read_part_sector(state, i, &sect);
72 72 if (!data)
73 73 return -1;
74 74  
fs/partitions/sysv68.h
1   -extern int sysv68_partition(struct parsed_partitions *state, struct block_device *bdev);
  1 +extern int sysv68_partition(struct parsed_partitions *state);
fs/partitions/ultrix.c
... ... @@ -9,7 +9,7 @@
9 9 #include "check.h"
10 10 #include "ultrix.h"
11 11  
12   -int ultrix_partition(struct parsed_partitions *state, struct block_device *bdev)
  12 +int ultrix_partition(struct parsed_partitions *state)
13 13 {
14 14 int i;
15 15 Sector sect;
... ... @@ -26,7 +26,7 @@
26 26 #define PT_MAGIC 0x032957 /* Partition magic number */
27 27 #define PT_VALID 1 /* Indicates if struct is valid */
28 28  
29   - data = read_dev_sector(bdev, (16384 - sizeof(*label))/512, &sect);
  29 + data = read_part_sector(state, (16384 - sizeof(*label))/512, &sect);
30 30 if (!data)
31 31 return -1;
32 32  
fs/partitions/ultrix.h
... ... @@ -2,5 +2,5 @@
2 2 * fs/partitions/ultrix.h
3 3 */
4 4  
5   -int ultrix_partition(struct parsed_partitions *state, struct block_device *bdev);
  5 +int ultrix_partition(struct parsed_partitions *state);