| @@ -447,7 +447,7 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt) · 446 unmodified lines |
| 447 | 447 | return 0; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | | −static struct fuse_conn *new_conn(void) |
| 450 | +static struct fuse_conn *new_conn(struct super_block *sb) |
| 451 | 451 | { |
| 452 | 452 | struct fuse_conn *fc; |
| 453 | 453 | int err; |
| @@ -468,19 +468,26 @@ static struct fuse_conn *new_conn(void) · 14 unmodified lines |
| 468 | 468 | atomic_set(&fc->num_waiting, 0); |
| 469 | 469 | fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; |
| 470 | 470 | fc->bdi.unplug_io_fn = default_unplug_io_fn; |
| 471 | + fc->dev = sb->s_dev; |
| 471 | 472 | err = bdi_init(&fc->bdi); |
| 472 | | − if (err) { |
| 473 | | − kfree(fc); |
| 474 | | − fc = NULL; |
| 475 | | − goto out; |
| 476 | | − } |
| 473 | + if (err) |
| 474 | + goto error_kfree; |
| 475 | + err = bdi_register_dev(&fc->bdi, fc->dev); |
| 476 | + if (err) |
| 477 | + goto error_bdi_destroy; |
| 477 | 478 | fc->reqctr = 0; |
| 478 | 479 | fc->blocked = 1; |
| 479 | 480 | fc->attr_version = 1; |
| 480 | 481 | get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); |
| 481 | 482 | } |
| 482 | | −out: |
| 483 | 483 | return fc; |
| 484 | + |
| 485 | +error_bdi_destroy: |
| 486 | + bdi_destroy(&fc->bdi); |
| 487 | +error_kfree: |
| 488 | + mutex_destroy(&fc->inst_mutex); |
| 489 | + kfree(fc); |
| 490 | + return NULL; |
| 484 | 491 | } |
| 485 | 492 | |
| 486 | 493 | void fuse_conn_put(struct fuse_conn *fc) |
| @@ -578,12 +585,6 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req) · 91 unmodified lines |
| 578 | 585 | request_send_background(fc, req); |
| 579 | 586 | } |
| 580 | 587 | |
| 581 | | −static u64 conn_id(void) |
| 582 | | −{ |
| 583 | | − static u64 ctr = 1; |
| 584 | | − return ctr++; |
| 585 | | −} |
| 586 | | − |
| 587 | 588 | static int fuse_fill_super(struct super_block *sb, void *data, int silent) |
| 588 | 589 | { |
| 589 | 590 | struct fuse_conn *fc; |
| @@ -621,7 +622,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) · 31 unmodified lines |
| 621 | 622 | if (file->f_op != &fuse_dev_operations) |
| 622 | 623 | return -EINVAL; |
| 623 | 624 | |
| 624 | | − fc = new_conn(); |
| 625 | + fc = new_conn(sb); |
| 625 | 626 | if (!fc) |
| 626 | 627 | return -ENOMEM; |
| 627 | 628 | |
| @@ -659,7 +660,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) · 31 unmodified lines |
| 659 | 660 | if (file->private_data) |
| 660 | 661 | goto err_unlock; |
| 661 | 662 | |
| 662 | | − fc->id = conn_id(); |
| 663 | 663 | err = fuse_ctl_add_conn(fc); |
| 664 | 664 | if (err) |
| 665 | 665 | goto err_unlock; |