diff options
Diffstat (limited to 'fs/exofs/super.c')
-rw-r--r-- | fs/exofs/super.c | 425 |
1 files changed, 338 insertions, 87 deletions
diff --git a/fs/exofs/super.c b/fs/exofs/super.c index 9f500dec3b59..03149b9a5178 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/vfs.h> | 37 | #include <linux/vfs.h> |
38 | #include <linux/random.h> | 38 | #include <linux/random.h> |
39 | #include <linux/exportfs.h> | 39 | #include <linux/exportfs.h> |
40 | #include <linux/slab.h> | ||
40 | 41 | ||
41 | #include "exofs.h" | 42 | #include "exofs.h" |
42 | 43 | ||
@@ -203,49 +204,45 @@ int exofs_sync_fs(struct super_block *sb, int wait) | |||
203 | { | 204 | { |
204 | struct exofs_sb_info *sbi; | 205 | struct exofs_sb_info *sbi; |
205 | struct exofs_fscb *fscb; | 206 | struct exofs_fscb *fscb; |
206 | struct osd_request *or; | 207 | struct exofs_io_state *ios; |
207 | struct osd_obj_id obj; | ||
208 | int ret = -ENOMEM; | 208 | int ret = -ENOMEM; |
209 | 209 | ||
210 | fscb = kzalloc(sizeof(struct exofs_fscb), GFP_KERNEL); | ||
211 | if (!fscb) { | ||
212 | EXOFS_ERR("exofs_write_super: memory allocation failed.\n"); | ||
213 | return -ENOMEM; | ||
214 | } | ||
215 | |||
216 | lock_super(sb); | 210 | lock_super(sb); |
217 | sbi = sb->s_fs_info; | 211 | sbi = sb->s_fs_info; |
212 | fscb = &sbi->s_fscb; | ||
213 | |||
214 | ret = exofs_get_io_state(&sbi->layout, &ios); | ||
215 | if (ret) | ||
216 | goto out; | ||
217 | |||
218 | /* Note: We only write the changing part of the fscb. .i.e upto the | ||
219 | * the fscb->s_dev_table_oid member. There is no read-modify-write | ||
220 | * here. | ||
221 | */ | ||
222 | ios->length = offsetof(struct exofs_fscb, s_dev_table_oid); | ||
223 | memset(fscb, 0, ios->length); | ||
218 | fscb->s_nextid = cpu_to_le64(sbi->s_nextid); | 224 | fscb->s_nextid = cpu_to_le64(sbi->s_nextid); |
219 | fscb->s_numfiles = cpu_to_le32(sbi->s_numfiles); | 225 | fscb->s_numfiles = cpu_to_le32(sbi->s_numfiles); |
220 | fscb->s_magic = cpu_to_le16(sb->s_magic); | 226 | fscb->s_magic = cpu_to_le16(sb->s_magic); |
221 | fscb->s_newfs = 0; | 227 | fscb->s_newfs = 0; |
228 | fscb->s_version = EXOFS_FSCB_VER; | ||
222 | 229 | ||
223 | or = osd_start_request(sbi->s_dev, GFP_KERNEL); | 230 | ios->obj.id = EXOFS_SUPER_ID; |
224 | if (unlikely(!or)) { | 231 | ios->offset = 0; |
225 | EXOFS_ERR("exofs_write_super: osd_start_request failed.\n"); | 232 | ios->kern_buff = fscb; |
226 | goto out; | 233 | ios->cred = sbi->s_cred; |
227 | } | ||
228 | |||
229 | obj.partition = sbi->s_pid; | ||
230 | obj.id = EXOFS_SUPER_ID; | ||
231 | ret = osd_req_write_kern(or, &obj, 0, fscb, sizeof(*fscb)); | ||
232 | if (unlikely(ret)) { | ||
233 | EXOFS_ERR("exofs_write_super: osd_req_write_kern failed.\n"); | ||
234 | goto out; | ||
235 | } | ||
236 | 234 | ||
237 | ret = exofs_sync_op(or, sbi->s_timeout, sbi->s_cred); | 235 | ret = exofs_sbi_write(ios); |
238 | if (unlikely(ret)) { | 236 | if (unlikely(ret)) { |
239 | EXOFS_ERR("exofs_write_super: exofs_sync_op failed.\n"); | 237 | EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__); |
240 | goto out; | 238 | goto out; |
241 | } | 239 | } |
242 | sb->s_dirt = 0; | 240 | sb->s_dirt = 0; |
243 | 241 | ||
244 | out: | 242 | out: |
245 | if (or) | 243 | EXOFS_DBGMSG("s_nextid=0x%llx ret=%d\n", _LLU(sbi->s_nextid), ret); |
246 | osd_end_request(or); | 244 | exofs_put_io_state(ios); |
247 | unlock_super(sb); | 245 | unlock_super(sb); |
248 | kfree(fscb); | ||
249 | return ret; | 246 | return ret; |
250 | } | 247 | } |
251 | 248 | ||
@@ -257,6 +254,29 @@ static void exofs_write_super(struct super_block *sb) | |||
257 | sb->s_dirt = 0; | 254 | sb->s_dirt = 0; |
258 | } | 255 | } |
259 | 256 | ||
257 | static void _exofs_print_device(const char *msg, const char *dev_path, | ||
258 | struct osd_dev *od, u64 pid) | ||
259 | { | ||
260 | const struct osd_dev_info *odi = osduld_device_info(od); | ||
261 | |||
262 | printk(KERN_NOTICE "exofs: %s %s osd_name-%s pid-0x%llx\n", | ||
263 | msg, dev_path ?: "", odi->osdname, _LLU(pid)); | ||
264 | } | ||
265 | |||
266 | void exofs_free_sbi(struct exofs_sb_info *sbi) | ||
267 | { | ||
268 | while (sbi->layout.s_numdevs) { | ||
269 | int i = --sbi->layout.s_numdevs; | ||
270 | struct osd_dev *od = sbi->layout.s_ods[i]; | ||
271 | |||
272 | if (od) { | ||
273 | sbi->layout.s_ods[i] = NULL; | ||
274 | osduld_put_device(od); | ||
275 | } | ||
276 | } | ||
277 | kfree(sbi); | ||
278 | } | ||
279 | |||
260 | /* | 280 | /* |
261 | * This function is called when the vfs is freeing the superblock. We just | 281 | * This function is called when the vfs is freeing the superblock. We just |
262 | * need to free our own part. | 282 | * need to free our own part. |
@@ -279,11 +299,236 @@ static void exofs_put_super(struct super_block *sb) | |||
279 | msecs_to_jiffies(100)); | 299 | msecs_to_jiffies(100)); |
280 | } | 300 | } |
281 | 301 | ||
282 | osduld_put_device(sbi->s_dev); | 302 | _exofs_print_device("Unmounting", NULL, sbi->layout.s_ods[0], |
283 | kfree(sb->s_fs_info); | 303 | sbi->layout.s_pid); |
304 | |||
305 | bdi_destroy(&sbi->bdi); | ||
306 | exofs_free_sbi(sbi); | ||
284 | sb->s_fs_info = NULL; | 307 | sb->s_fs_info = NULL; |
285 | } | 308 | } |
286 | 309 | ||
310 | static int _read_and_match_data_map(struct exofs_sb_info *sbi, unsigned numdevs, | ||
311 | struct exofs_device_table *dt) | ||
312 | { | ||
313 | u64 stripe_length; | ||
314 | |||
315 | sbi->data_map.odm_num_comps = | ||
316 | le32_to_cpu(dt->dt_data_map.cb_num_comps); | ||
317 | sbi->data_map.odm_stripe_unit = | ||
318 | le64_to_cpu(dt->dt_data_map.cb_stripe_unit); | ||
319 | sbi->data_map.odm_group_width = | ||
320 | le32_to_cpu(dt->dt_data_map.cb_group_width); | ||
321 | sbi->data_map.odm_group_depth = | ||
322 | le32_to_cpu(dt->dt_data_map.cb_group_depth); | ||
323 | sbi->data_map.odm_mirror_cnt = | ||
324 | le32_to_cpu(dt->dt_data_map.cb_mirror_cnt); | ||
325 | sbi->data_map.odm_raid_algorithm = | ||
326 | le32_to_cpu(dt->dt_data_map.cb_raid_algorithm); | ||
327 | |||
328 | /* FIXME: Only raid0 for now. if not so, do not mount */ | ||
329 | if (sbi->data_map.odm_num_comps != numdevs) { | ||
330 | EXOFS_ERR("odm_num_comps(%u) != numdevs(%u)\n", | ||
331 | sbi->data_map.odm_num_comps, numdevs); | ||
332 | return -EINVAL; | ||
333 | } | ||
334 | if (sbi->data_map.odm_raid_algorithm != PNFS_OSD_RAID_0) { | ||
335 | EXOFS_ERR("Only RAID_0 for now\n"); | ||
336 | return -EINVAL; | ||
337 | } | ||
338 | if (0 != (numdevs % (sbi->data_map.odm_mirror_cnt + 1))) { | ||
339 | EXOFS_ERR("Data Map wrong, numdevs=%d mirrors=%d\n", | ||
340 | numdevs, sbi->data_map.odm_mirror_cnt); | ||
341 | return -EINVAL; | ||
342 | } | ||
343 | |||
344 | if (0 != (sbi->data_map.odm_stripe_unit & ~PAGE_MASK)) { | ||
345 | EXOFS_ERR("Stripe Unit(0x%llx)" | ||
346 | " must be Multples of PAGE_SIZE(0x%lx)\n", | ||
347 | _LLU(sbi->data_map.odm_stripe_unit), PAGE_SIZE); | ||
348 | return -EINVAL; | ||
349 | } | ||
350 | |||
351 | sbi->layout.stripe_unit = sbi->data_map.odm_stripe_unit; | ||
352 | sbi->layout.mirrors_p1 = sbi->data_map.odm_mirror_cnt + 1; | ||
353 | |||
354 | if (sbi->data_map.odm_group_width) { | ||
355 | sbi->layout.group_width = sbi->data_map.odm_group_width; | ||
356 | sbi->layout.group_depth = sbi->data_map.odm_group_depth; | ||
357 | if (!sbi->layout.group_depth) { | ||
358 | EXOFS_ERR("group_depth == 0 && group_width != 0\n"); | ||
359 | return -EINVAL; | ||
360 | } | ||
361 | sbi->layout.group_count = sbi->data_map.odm_num_comps / | ||
362 | sbi->layout.mirrors_p1 / | ||
363 | sbi->data_map.odm_group_width; | ||
364 | } else { | ||
365 | if (sbi->data_map.odm_group_depth) { | ||
366 | printk(KERN_NOTICE "Warning: group_depth ignored " | ||
367 | "group_width == 0 && group_depth == %d\n", | ||
368 | sbi->data_map.odm_group_depth); | ||
369 | sbi->data_map.odm_group_depth = 0; | ||
370 | } | ||
371 | sbi->layout.group_width = sbi->data_map.odm_num_comps / | ||
372 | sbi->layout.mirrors_p1; | ||
373 | sbi->layout.group_depth = -1; | ||
374 | sbi->layout.group_count = 1; | ||
375 | } | ||
376 | |||
377 | stripe_length = (u64)sbi->layout.group_width * sbi->layout.stripe_unit; | ||
378 | if (stripe_length >= (1ULL << 32)) { | ||
379 | EXOFS_ERR("Total Stripe length(0x%llx)" | ||
380 | " >= 32bit is not supported\n", _LLU(stripe_length)); | ||
381 | return -EINVAL; | ||
382 | } | ||
383 | |||
384 | return 0; | ||
385 | } | ||
386 | |||
387 | /* @odi is valid only as long as @fscb_dev is valid */ | ||
388 | static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev, | ||
389 | struct osd_dev_info *odi) | ||
390 | { | ||
391 | odi->systemid_len = le32_to_cpu(dt_dev->systemid_len); | ||
392 | memcpy(odi->systemid, dt_dev->systemid, odi->systemid_len); | ||
393 | |||
394 | odi->osdname_len = le32_to_cpu(dt_dev->osdname_len); | ||
395 | odi->osdname = dt_dev->osdname; | ||
396 | |||
397 | /* FIXME support long names. Will need a _put function */ | ||
398 | if (dt_dev->long_name_offset) | ||
399 | return -EINVAL; | ||
400 | |||
401 | /* Make sure osdname is printable! | ||
402 | * mkexofs should give us space for a null-terminator else the | ||
403 | * device-table is invalid. | ||
404 | */ | ||
405 | if (unlikely(odi->osdname_len >= sizeof(dt_dev->osdname))) | ||
406 | odi->osdname_len = sizeof(dt_dev->osdname) - 1; | ||
407 | dt_dev->osdname[odi->osdname_len] = 0; | ||
408 | |||
409 | /* If it's all zeros something is bad we read past end-of-obj */ | ||
410 | return !(odi->systemid_len || odi->osdname_len); | ||
411 | } | ||
412 | |||
413 | static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi, | ||
414 | unsigned table_count) | ||
415 | { | ||
416 | struct exofs_sb_info *sbi = *psbi; | ||
417 | struct osd_dev *fscb_od; | ||
418 | struct osd_obj_id obj = {.partition = sbi->layout.s_pid, | ||
419 | .id = EXOFS_DEVTABLE_ID}; | ||
420 | struct exofs_device_table *dt; | ||
421 | unsigned table_bytes = table_count * sizeof(dt->dt_dev_table[0]) + | ||
422 | sizeof(*dt); | ||
423 | unsigned numdevs, i; | ||
424 | int ret; | ||
425 | |||
426 | dt = kmalloc(table_bytes, GFP_KERNEL); | ||
427 | if (unlikely(!dt)) { | ||
428 | EXOFS_ERR("ERROR: allocating %x bytes for device table\n", | ||
429 | table_bytes); | ||
430 | return -ENOMEM; | ||
431 | } | ||
432 | |||
433 | fscb_od = sbi->layout.s_ods[0]; | ||
434 | sbi->layout.s_ods[0] = NULL; | ||
435 | sbi->layout.s_numdevs = 0; | ||
436 | ret = exofs_read_kern(fscb_od, sbi->s_cred, &obj, 0, dt, table_bytes); | ||
437 | if (unlikely(ret)) { | ||
438 | EXOFS_ERR("ERROR: reading device table\n"); | ||
439 | goto out; | ||
440 | } | ||
441 | |||
442 | numdevs = le64_to_cpu(dt->dt_num_devices); | ||
443 | if (unlikely(!numdevs)) { | ||
444 | ret = -EINVAL; | ||
445 | goto out; | ||
446 | } | ||
447 | WARN_ON(table_count != numdevs); | ||
448 | |||
449 | ret = _read_and_match_data_map(sbi, numdevs, dt); | ||
450 | if (unlikely(ret)) | ||
451 | goto out; | ||
452 | |||
453 | if (likely(numdevs > 1)) { | ||
454 | unsigned size = numdevs * sizeof(sbi->layout.s_ods[0]); | ||
455 | |||
456 | sbi = krealloc(sbi, sizeof(*sbi) + size, GFP_KERNEL); | ||
457 | if (unlikely(!sbi)) { | ||
458 | ret = -ENOMEM; | ||
459 | goto out; | ||
460 | } | ||
461 | memset(&sbi->layout.s_ods[1], 0, | ||
462 | size - sizeof(sbi->layout.s_ods[0])); | ||
463 | *psbi = sbi; | ||
464 | } | ||
465 | |||
466 | for (i = 0; i < numdevs; i++) { | ||
467 | struct exofs_fscb fscb; | ||
468 | struct osd_dev_info odi; | ||
469 | struct osd_dev *od; | ||
470 | |||
471 | if (exofs_devs_2_odi(&dt->dt_dev_table[i], &odi)) { | ||
472 | EXOFS_ERR("ERROR: Read all-zeros device entry\n"); | ||
473 | ret = -EINVAL; | ||
474 | goto out; | ||
475 | } | ||
476 | |||
477 | printk(KERN_NOTICE "Add device[%d]: osd_name-%s\n", | ||
478 | i, odi.osdname); | ||
479 | |||
480 | /* On all devices the device table is identical. The user can | ||
481 | * specify any one of the participating devices on the command | ||
482 | * line. We always keep them in device-table order. | ||
483 | */ | ||
484 | if (fscb_od && osduld_device_same(fscb_od, &odi)) { | ||
485 | sbi->layout.s_ods[i] = fscb_od; | ||
486 | ++sbi->layout.s_numdevs; | ||
487 | fscb_od = NULL; | ||
488 | continue; | ||
489 | } | ||
490 | |||
491 | od = osduld_info_lookup(&odi); | ||
492 | if (unlikely(IS_ERR(od))) { | ||
493 | ret = PTR_ERR(od); | ||
494 | EXOFS_ERR("ERROR: device requested is not found " | ||
495 | "osd_name-%s =>%d\n", odi.osdname, ret); | ||
496 | goto out; | ||
497 | } | ||
498 | |||
499 | sbi->layout.s_ods[i] = od; | ||
500 | ++sbi->layout.s_numdevs; | ||
501 | |||
502 | /* Read the fscb of the other devices to make sure the FS | ||
503 | * partition is there. | ||
504 | */ | ||
505 | ret = exofs_read_kern(od, sbi->s_cred, &obj, 0, &fscb, | ||
506 | sizeof(fscb)); | ||
507 | if (unlikely(ret)) { | ||
508 | EXOFS_ERR("ERROR: Malformed participating device " | ||
509 | "error reading fscb osd_name-%s\n", | ||
510 | odi.osdname); | ||
511 | goto out; | ||
512 | } | ||
513 | |||
514 | /* TODO: verify other information is correct and FS-uuid | ||
515 | * matches. Benny what did you say about device table | ||
516 | * generation and old devices? | ||
517 | */ | ||
518 | } | ||
519 | |||
520 | out: | ||
521 | kfree(dt); | ||
522 | if (unlikely(!ret && fscb_od)) { | ||
523 | EXOFS_ERR( | ||
524 | "ERROR: Bad device-table container device not present\n"); | ||
525 | osduld_put_device(fscb_od); | ||
526 | ret = -EINVAL; | ||
527 | } | ||
528 | |||
529 | return ret; | ||
530 | } | ||
531 | |||
287 | /* | 532 | /* |
288 | * Read the superblock from the OSD and fill in the fields | 533 | * Read the superblock from the OSD and fill in the fields |
289 | */ | 534 | */ |
@@ -292,25 +537,36 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
292 | struct inode *root; | 537 | struct inode *root; |
293 | struct exofs_mountopt *opts = data; | 538 | struct exofs_mountopt *opts = data; |
294 | struct exofs_sb_info *sbi; /*extended info */ | 539 | struct exofs_sb_info *sbi; /*extended info */ |
540 | struct osd_dev *od; /* Master device */ | ||
295 | struct exofs_fscb fscb; /*on-disk superblock info */ | 541 | struct exofs_fscb fscb; /*on-disk superblock info */ |
296 | struct osd_request *or = NULL; | ||
297 | struct osd_obj_id obj; | 542 | struct osd_obj_id obj; |
543 | unsigned table_count; | ||
298 | int ret; | 544 | int ret; |
299 | 545 | ||
300 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 546 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
301 | if (!sbi) | 547 | if (!sbi) |
302 | return -ENOMEM; | 548 | return -ENOMEM; |
303 | sb->s_fs_info = sbi; | 549 | |
550 | ret = bdi_setup_and_register(&sbi->bdi, "exofs", BDI_CAP_MAP_COPY); | ||
551 | if (ret) | ||
552 | goto free_bdi; | ||
304 | 553 | ||
305 | /* use mount options to fill superblock */ | 554 | /* use mount options to fill superblock */ |
306 | sbi->s_dev = osduld_path_lookup(opts->dev_name); | 555 | od = osduld_path_lookup(opts->dev_name); |
307 | if (IS_ERR(sbi->s_dev)) { | 556 | if (IS_ERR(od)) { |
308 | ret = PTR_ERR(sbi->s_dev); | 557 | ret = PTR_ERR(od); |
309 | sbi->s_dev = NULL; | ||
310 | goto free_sbi; | 558 | goto free_sbi; |
311 | } | 559 | } |
312 | 560 | ||
313 | sbi->s_pid = opts->pid; | 561 | /* Default layout in case we do not have a device-table */ |
562 | sbi->layout.stripe_unit = PAGE_SIZE; | ||
563 | sbi->layout.mirrors_p1 = 1; | ||
564 | sbi->layout.group_width = 1; | ||
565 | sbi->layout.group_depth = -1; | ||
566 | sbi->layout.group_count = 1; | ||
567 | sbi->layout.s_ods[0] = od; | ||
568 | sbi->layout.s_numdevs = 1; | ||
569 | sbi->layout.s_pid = opts->pid; | ||
314 | sbi->s_timeout = opts->timeout; | 570 | sbi->s_timeout = opts->timeout; |
315 | 571 | ||
316 | /* fill in some other data by hand */ | 572 | /* fill in some other data by hand */ |
@@ -323,35 +579,13 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
323 | sb->s_bdev = NULL; | 579 | sb->s_bdev = NULL; |
324 | sb->s_dev = 0; | 580 | sb->s_dev = 0; |
325 | 581 | ||
326 | /* read data from on-disk superblock object */ | 582 | obj.partition = sbi->layout.s_pid; |
327 | obj.partition = sbi->s_pid; | ||
328 | obj.id = EXOFS_SUPER_ID; | 583 | obj.id = EXOFS_SUPER_ID; |
329 | exofs_make_credential(sbi->s_cred, &obj); | 584 | exofs_make_credential(sbi->s_cred, &obj); |
330 | 585 | ||
331 | or = osd_start_request(sbi->s_dev, GFP_KERNEL); | 586 | ret = exofs_read_kern(od, sbi->s_cred, &obj, 0, &fscb, sizeof(fscb)); |
332 | if (unlikely(!or)) { | 587 | if (unlikely(ret)) |
333 | if (!silent) | ||
334 | EXOFS_ERR( | ||
335 | "exofs_fill_super: osd_start_request failed.\n"); | ||
336 | ret = -ENOMEM; | ||
337 | goto free_sbi; | ||
338 | } | ||
339 | ret = osd_req_read_kern(or, &obj, 0, &fscb, sizeof(fscb)); | ||
340 | if (unlikely(ret)) { | ||
341 | if (!silent) | ||
342 | EXOFS_ERR( | ||
343 | "exofs_fill_super: osd_req_read_kern failed.\n"); | ||
344 | ret = -ENOMEM; | ||
345 | goto free_sbi; | ||
346 | } | ||
347 | |||
348 | ret = exofs_sync_op(or, sbi->s_timeout, sbi->s_cred); | ||
349 | if (unlikely(ret)) { | ||
350 | if (!silent) | ||
351 | EXOFS_ERR("exofs_fill_super: exofs_sync_op failed.\n"); | ||
352 | ret = -EIO; | ||
353 | goto free_sbi; | 588 | goto free_sbi; |
354 | } | ||
355 | 589 | ||
356 | sb->s_magic = le16_to_cpu(fscb.s_magic); | 590 | sb->s_magic = le16_to_cpu(fscb.s_magic); |
357 | sbi->s_nextid = le64_to_cpu(fscb.s_nextid); | 591 | sbi->s_nextid = le64_to_cpu(fscb.s_nextid); |
@@ -364,12 +598,27 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
364 | ret = -EINVAL; | 598 | ret = -EINVAL; |
365 | goto free_sbi; | 599 | goto free_sbi; |
366 | } | 600 | } |
601 | if (le32_to_cpu(fscb.s_version) != EXOFS_FSCB_VER) { | ||
602 | EXOFS_ERR("ERROR: Bad FSCB version expected-%d got-%d\n", | ||
603 | EXOFS_FSCB_VER, le32_to_cpu(fscb.s_version)); | ||
604 | ret = -EINVAL; | ||
605 | goto free_sbi; | ||
606 | } | ||
367 | 607 | ||
368 | /* start generation numbers from a random point */ | 608 | /* start generation numbers from a random point */ |
369 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); | 609 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); |
370 | spin_lock_init(&sbi->s_next_gen_lock); | 610 | spin_lock_init(&sbi->s_next_gen_lock); |
371 | 611 | ||
612 | table_count = le64_to_cpu(fscb.s_dev_table_count); | ||
613 | if (table_count) { | ||
614 | ret = exofs_read_lookup_dev_table(&sbi, table_count); | ||
615 | if (unlikely(ret)) | ||
616 | goto free_sbi; | ||
617 | } | ||
618 | |||
372 | /* set up operation vectors */ | 619 | /* set up operation vectors */ |
620 | sb->s_bdi = &sbi->bdi; | ||
621 | sb->s_fs_info = sbi; | ||
373 | sb->s_op = &exofs_sops; | 622 | sb->s_op = &exofs_sops; |
374 | sb->s_export_op = &exofs_export_ops; | 623 | sb->s_export_op = &exofs_export_ops; |
375 | root = exofs_iget(sb, EXOFS_ROOT_ID - EXOFS_OBJ_OFF); | 624 | root = exofs_iget(sb, EXOFS_ROOT_ID - EXOFS_OBJ_OFF); |
@@ -395,16 +644,17 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
395 | goto free_sbi; | 644 | goto free_sbi; |
396 | } | 645 | } |
397 | 646 | ||
398 | ret = 0; | 647 | _exofs_print_device("Mounting", opts->dev_name, sbi->layout.s_ods[0], |
399 | out: | 648 | sbi->layout.s_pid); |
400 | if (or) | 649 | return 0; |
401 | osd_end_request(or); | ||
402 | return ret; | ||
403 | 650 | ||
404 | free_sbi: | 651 | free_sbi: |
405 | osduld_put_device(sbi->s_dev); /* NULL safe */ | 652 | bdi_destroy(&sbi->bdi); |
406 | kfree(sbi); | 653 | free_bdi: |
407 | goto out; | 654 | EXOFS_ERR("Unable to mount exofs on %s pid=0x%llx err=%d\n", |
655 | opts->dev_name, sbi->layout.s_pid, ret); | ||
656 | exofs_free_sbi(sbi); | ||
657 | return ret; | ||
408 | } | 658 | } |
409 | 659 | ||
410 | /* | 660 | /* |
@@ -433,7 +683,7 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
433 | { | 683 | { |
434 | struct super_block *sb = dentry->d_sb; | 684 | struct super_block *sb = dentry->d_sb; |
435 | struct exofs_sb_info *sbi = sb->s_fs_info; | 685 | struct exofs_sb_info *sbi = sb->s_fs_info; |
436 | struct osd_obj_id obj = {sbi->s_pid, 0}; | 686 | struct exofs_io_state *ios; |
437 | struct osd_attr attrs[] = { | 687 | struct osd_attr attrs[] = { |
438 | ATTR_DEF(OSD_APAGE_PARTITION_QUOTAS, | 688 | ATTR_DEF(OSD_APAGE_PARTITION_QUOTAS, |
439 | OSD_ATTR_PQ_CAPACITY_QUOTA, sizeof(__be64)), | 689 | OSD_ATTR_PQ_CAPACITY_QUOTA, sizeof(__be64)), |
@@ -442,32 +692,33 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
442 | }; | 692 | }; |
443 | uint64_t capacity = ULLONG_MAX; | 693 | uint64_t capacity = ULLONG_MAX; |
444 | uint64_t used = ULLONG_MAX; | 694 | uint64_t used = ULLONG_MAX; |
445 | struct osd_request *or; | ||
446 | uint8_t cred_a[OSD_CAP_LEN]; | 695 | uint8_t cred_a[OSD_CAP_LEN]; |
447 | int ret; | 696 | int ret; |
448 | 697 | ||
449 | /* get used/capacity attributes */ | 698 | ret = exofs_get_io_state(&sbi->layout, &ios); |
450 | exofs_make_credential(cred_a, &obj); | 699 | if (ret) { |
451 | 700 | EXOFS_DBGMSG("exofs_get_io_state failed.\n"); | |
452 | or = osd_start_request(sbi->s_dev, GFP_KERNEL); | 701 | return ret; |
453 | if (unlikely(!or)) { | ||
454 | EXOFS_DBGMSG("exofs_statfs: osd_start_request failed.\n"); | ||
455 | return -ENOMEM; | ||
456 | } | 702 | } |
457 | 703 | ||
458 | osd_req_get_attributes(or, &obj); | 704 | exofs_make_credential(cred_a, &ios->obj); |
459 | osd_req_add_get_attr_list(or, attrs, ARRAY_SIZE(attrs)); | 705 | ios->cred = sbi->s_cred; |
460 | ret = exofs_sync_op(or, sbi->s_timeout, cred_a); | 706 | ios->in_attr = attrs; |
707 | ios->in_attr_len = ARRAY_SIZE(attrs); | ||
708 | |||
709 | ret = exofs_sbi_read(ios); | ||
461 | if (unlikely(ret)) | 710 | if (unlikely(ret)) |
462 | goto out; | 711 | goto out; |
463 | 712 | ||
464 | ret = extract_attr_from_req(or, &attrs[0]); | 713 | ret = extract_attr_from_ios(ios, &attrs[0]); |
465 | if (likely(!ret)) | 714 | if (likely(!ret)) { |
466 | capacity = get_unaligned_be64(attrs[0].val_ptr); | 715 | capacity = get_unaligned_be64(attrs[0].val_ptr); |
467 | else | 716 | if (unlikely(!capacity)) |
717 | capacity = ULLONG_MAX; | ||
718 | } else | ||
468 | EXOFS_DBGMSG("exofs_statfs: get capacity failed.\n"); | 719 | EXOFS_DBGMSG("exofs_statfs: get capacity failed.\n"); |
469 | 720 | ||
470 | ret = extract_attr_from_req(or, &attrs[1]); | 721 | ret = extract_attr_from_ios(ios, &attrs[1]); |
471 | if (likely(!ret)) | 722 | if (likely(!ret)) |
472 | used = get_unaligned_be64(attrs[1].val_ptr); | 723 | used = get_unaligned_be64(attrs[1].val_ptr); |
473 | else | 724 | else |
@@ -476,15 +727,15 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
476 | /* fill in the stats buffer */ | 727 | /* fill in the stats buffer */ |
477 | buf->f_type = EXOFS_SUPER_MAGIC; | 728 | buf->f_type = EXOFS_SUPER_MAGIC; |
478 | buf->f_bsize = EXOFS_BLKSIZE; | 729 | buf->f_bsize = EXOFS_BLKSIZE; |
479 | buf->f_blocks = (capacity >> EXOFS_BLKSHIFT); | 730 | buf->f_blocks = capacity >> 9; |
480 | buf->f_bfree = ((capacity - used) >> EXOFS_BLKSHIFT); | 731 | buf->f_bfree = (capacity - used) >> 9; |
481 | buf->f_bavail = buf->f_bfree; | 732 | buf->f_bavail = buf->f_bfree; |
482 | buf->f_files = sbi->s_numfiles; | 733 | buf->f_files = sbi->s_numfiles; |
483 | buf->f_ffree = EXOFS_MAX_ID - sbi->s_numfiles; | 734 | buf->f_ffree = EXOFS_MAX_ID - sbi->s_numfiles; |
484 | buf->f_namelen = EXOFS_NAME_LEN; | 735 | buf->f_namelen = EXOFS_NAME_LEN; |
485 | 736 | ||
486 | out: | 737 | out: |
487 | osd_end_request(or); | 738 | exofs_put_io_state(ios); |
488 | return ret; | 739 | return ret; |
489 | } | 740 | } |
490 | 741 | ||