diff options
| author | Jan Kara <jack@suse.cz> | 2017-04-12 06:24:40 -0400 |
|---|---|---|
| committer | Jens Axboe <axboe@fb.com> | 2017-04-20 14:09:55 -0400 |
| commit | 5f7f7543f52eee03ed35c9d671fbb1cdbd4bc9b5 (patch) | |
| tree | a748abbc4eafb7c068739f4fa48d88e672d5ac48 /fs | |
| parent | c7f014771b18e002fed373838fe14cf2065f3499 (diff) | |
fuse: Convert to separately allocated bdi
Allocate struct backing_dev_info separately instead of embedding it
inside the superblock. This unifies handling of bdi among users.
CC: Miklos Szeredi <miklos@szeredi.hu>
CC: linux-fsdevel@vger.kernel.org
Acked-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/fuse/dev.c | 8 | ||||
| -rw-r--r-- | fs/fuse/fuse_i.h | 3 | ||||
| -rw-r--r-- | fs/fuse/inode.c | 42 |
3 files changed, 17 insertions, 36 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index b681b43c766e..78887f68ee6a 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
| @@ -383,8 +383,8 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req) | |||
| 383 | 383 | ||
| 384 | if (fc->num_background == fc->congestion_threshold && | 384 | if (fc->num_background == fc->congestion_threshold && |
| 385 | fc->connected && fc->bdi_initialized) { | 385 | fc->connected && fc->bdi_initialized) { |
| 386 | clear_bdi_congested(&fc->bdi, BLK_RW_SYNC); | 386 | clear_bdi_congested(fc->sb->s_bdi, BLK_RW_SYNC); |
| 387 | clear_bdi_congested(&fc->bdi, BLK_RW_ASYNC); | 387 | clear_bdi_congested(fc->sb->s_bdi, BLK_RW_ASYNC); |
| 388 | } | 388 | } |
| 389 | fc->num_background--; | 389 | fc->num_background--; |
| 390 | fc->active_background--; | 390 | fc->active_background--; |
| @@ -575,8 +575,8 @@ void fuse_request_send_background_locked(struct fuse_conn *fc, | |||
| 575 | fc->blocked = 1; | 575 | fc->blocked = 1; |
| 576 | if (fc->num_background == fc->congestion_threshold && | 576 | if (fc->num_background == fc->congestion_threshold && |
| 577 | fc->bdi_initialized) { | 577 | fc->bdi_initialized) { |
| 578 | set_bdi_congested(&fc->bdi, BLK_RW_SYNC); | 578 | set_bdi_congested(fc->sb->s_bdi, BLK_RW_SYNC); |
| 579 | set_bdi_congested(&fc->bdi, BLK_RW_ASYNC); | 579 | set_bdi_congested(fc->sb->s_bdi, BLK_RW_ASYNC); |
| 580 | } | 580 | } |
| 581 | list_add_tail(&req->list, &fc->bg_queue); | 581 | list_add_tail(&req->list, &fc->bg_queue); |
| 582 | flush_bg_queue(fc); | 582 | flush_bg_queue(fc); |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 32ac2c9b09c0..0e7c79a390e0 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
| @@ -631,9 +631,6 @@ struct fuse_conn { | |||
| 631 | /** Negotiated minor version */ | 631 | /** Negotiated minor version */ |
| 632 | unsigned minor; | 632 | unsigned minor; |
| 633 | 633 | ||
| 634 | /** Backing dev info */ | ||
| 635 | struct backing_dev_info bdi; | ||
| 636 | |||
| 637 | /** Entry on the fuse_conn_list */ | 634 | /** Entry on the fuse_conn_list */ |
| 638 | struct list_head entry; | 635 | struct list_head entry; |
| 639 | 636 | ||
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 6fe6a88ecb4a..90bacbc87fb3 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
| @@ -386,12 +386,6 @@ static void fuse_send_destroy(struct fuse_conn *fc) | |||
| 386 | } | 386 | } |
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | static void fuse_bdi_destroy(struct fuse_conn *fc) | ||
| 390 | { | ||
| 391 | if (fc->bdi_initialized) | ||
| 392 | bdi_destroy(&fc->bdi); | ||
| 393 | } | ||
| 394 | |||
| 395 | static void fuse_put_super(struct super_block *sb) | 389 | static void fuse_put_super(struct super_block *sb) |
| 396 | { | 390 | { |
| 397 | struct fuse_conn *fc = get_fuse_conn_super(sb); | 391 | struct fuse_conn *fc = get_fuse_conn_super(sb); |
| @@ -403,7 +397,6 @@ static void fuse_put_super(struct super_block *sb) | |||
| 403 | list_del(&fc->entry); | 397 | list_del(&fc->entry); |
| 404 | fuse_ctl_remove_conn(fc); | 398 | fuse_ctl_remove_conn(fc); |
| 405 | mutex_unlock(&fuse_mutex); | 399 | mutex_unlock(&fuse_mutex); |
| 406 | fuse_bdi_destroy(fc); | ||
| 407 | 400 | ||
| 408 | fuse_conn_put(fc); | 401 | fuse_conn_put(fc); |
| 409 | } | 402 | } |
| @@ -928,7 +921,8 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) | |||
| 928 | fc->no_flock = 1; | 921 | fc->no_flock = 1; |
| 929 | } | 922 | } |
| 930 | 923 | ||
| 931 | fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages); | 924 | fc->sb->s_bdi->ra_pages = |
| 925 | min(fc->sb->s_bdi->ra_pages, ra_pages); | ||
| 932 | fc->minor = arg->minor; | 926 | fc->minor = arg->minor; |
| 933 | fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; | 927 | fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; |
| 934 | fc->max_write = max_t(unsigned, 4096, fc->max_write); | 928 | fc->max_write = max_t(unsigned, 4096, fc->max_write); |
| @@ -944,7 +938,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req) | |||
| 944 | 938 | ||
| 945 | arg->major = FUSE_KERNEL_VERSION; | 939 | arg->major = FUSE_KERNEL_VERSION; |
| 946 | arg->minor = FUSE_KERNEL_MINOR_VERSION; | 940 | arg->minor = FUSE_KERNEL_MINOR_VERSION; |
| 947 | arg->max_readahead = fc->bdi.ra_pages * PAGE_SIZE; | 941 | arg->max_readahead = fc->sb->s_bdi->ra_pages * PAGE_SIZE; |
| 948 | arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | | 942 | arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | |
| 949 | FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK | | 943 | FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK | |
| 950 | FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ | | 944 | FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ | |
| @@ -976,27 +970,20 @@ static void fuse_free_conn(struct fuse_conn *fc) | |||
| 976 | static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb) | 970 | static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb) |
| 977 | { | 971 | { |
| 978 | int err; | 972 | int err; |
| 973 | char *suffix = ""; | ||
| 979 | 974 | ||
| 980 | fc->bdi.name = "fuse"; | 975 | if (sb->s_bdev) |
| 981 | fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_SIZE; | 976 | suffix = "-fuseblk"; |
| 982 | /* fuse does it's own writeback accounting */ | 977 | err = super_setup_bdi_name(sb, "%u:%u%s", MAJOR(fc->dev), |
| 983 | fc->bdi.capabilities = BDI_CAP_NO_ACCT_WB | BDI_CAP_STRICTLIMIT; | 978 | MINOR(fc->dev), suffix); |
| 984 | |||
| 985 | err = bdi_init(&fc->bdi); | ||
| 986 | if (err) | 979 | if (err) |
| 987 | return err; | 980 | return err; |
| 988 | 981 | ||
| 989 | fc->bdi_initialized = 1; | 982 | sb->s_bdi->ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_SIZE; |
| 990 | 983 | /* fuse does it's own writeback accounting */ | |
| 991 | if (sb->s_bdev) { | 984 | sb->s_bdi->capabilities = BDI_CAP_NO_ACCT_WB | BDI_CAP_STRICTLIMIT; |
| 992 | err = bdi_register(&fc->bdi, NULL, "%u:%u-fuseblk", | ||
| 993 | MAJOR(fc->dev), MINOR(fc->dev)); | ||
| 994 | } else { | ||
| 995 | err = bdi_register_dev(&fc->bdi, fc->dev); | ||
| 996 | } | ||
| 997 | 985 | ||
| 998 | if (err) | 986 | fc->bdi_initialized = 1; |
| 999 | return err; | ||
| 1000 | 987 | ||
| 1001 | /* | 988 | /* |
| 1002 | * For a single fuse filesystem use max 1% of dirty + | 989 | * For a single fuse filesystem use max 1% of dirty + |
| @@ -1010,7 +997,7 @@ static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb) | |||
| 1010 | * | 997 | * |
| 1011 | * /sys/class/bdi/<bdi>/max_ratio | 998 | * /sys/class/bdi/<bdi>/max_ratio |
| 1012 | */ | 999 | */ |
| 1013 | bdi_set_max_ratio(&fc->bdi, 1); | 1000 | bdi_set_max_ratio(sb->s_bdi, 1); |
| 1014 | 1001 | ||
| 1015 | return 0; | 1002 | return 0; |
| 1016 | } | 1003 | } |
| @@ -1113,8 +1100,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1113 | if (err) | 1100 | if (err) |
| 1114 | goto err_dev_free; | 1101 | goto err_dev_free; |
| 1115 | 1102 | ||
| 1116 | sb->s_bdi = &fc->bdi; | ||
| 1117 | |||
| 1118 | /* Handle umasking inside the fuse code */ | 1103 | /* Handle umasking inside the fuse code */ |
| 1119 | if (sb->s_flags & MS_POSIXACL) | 1104 | if (sb->s_flags & MS_POSIXACL) |
| 1120 | fc->dont_mask = 1; | 1105 | fc->dont_mask = 1; |
| @@ -1182,7 +1167,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1182 | err_dev_free: | 1167 | err_dev_free: |
| 1183 | fuse_dev_free(fud); | 1168 | fuse_dev_free(fud); |
| 1184 | err_put_conn: | 1169 | err_put_conn: |
| 1185 | fuse_bdi_destroy(fc); | ||
| 1186 | fuse_conn_put(fc); | 1170 | fuse_conn_put(fc); |
| 1187 | err_fput: | 1171 | err_fput: |
| 1188 | fput(file); | 1172 | fput(file); |
