super.c (dcacbc1242c71e18fa9d2eadc5647e115c9c627d) | super.c (ee4a36f414617aaae01f93133e828363e7e9dd17) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * bcache setup/teardown code, and some metadata io - read a superblock and 4 * figure out what to do with it. 5 * 6 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com> 7 * Copyright 2012 Google, Inc. 8 */ --- 5 unchanged lines hidden (view full) --- 14#include "request.h" 15#include "writeback.h" 16 17#include <linux/blkdev.h> 18#include <linux/debugfs.h> 19#include <linux/genhd.h> 20#include <linux/idr.h> 21#include <linux/kthread.h> | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * bcache setup/teardown code, and some metadata io - read a superblock and 4 * figure out what to do with it. 5 * 6 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com> 7 * Copyright 2012 Google, Inc. 8 */ --- 5 unchanged lines hidden (view full) --- 14#include "request.h" 15#include "writeback.h" 16 17#include <linux/blkdev.h> 18#include <linux/debugfs.h> 19#include <linux/genhd.h> 20#include <linux/idr.h> 21#include <linux/kthread.h> |
22#include <linux/workqueue.h> |
|
22#include <linux/module.h> 23#include <linux/random.h> 24#include <linux/reboot.h> 25#include <linux/sysfs.h> 26 27unsigned int bch_cutoff_writeback; 28unsigned int bch_cutoff_writeback_sync; 29 --- 2345 unchanged lines hidden (view full) --- 2375} 2376 2377static bool bch_is_open(struct block_device *bdev) 2378{ 2379 return bch_is_open_cache(bdev) || bch_is_open_backing(bdev); 2380} 2381 2382struct async_reg_args { | 23#include <linux/module.h> 24#include <linux/random.h> 25#include <linux/reboot.h> 26#include <linux/sysfs.h> 27 28unsigned int bch_cutoff_writeback; 29unsigned int bch_cutoff_writeback_sync; 30 --- 2345 unchanged lines hidden (view full) --- 2376} 2377 2378static bool bch_is_open(struct block_device *bdev) 2379{ 2380 return bch_is_open_cache(bdev) || bch_is_open_backing(bdev); 2381} 2382 2383struct async_reg_args { |
2383 struct work_struct reg_work; | 2384 struct delayed_work reg_work; |
2384 char *path; 2385 struct cache_sb *sb; 2386 struct cache_sb_disk *sb_disk; 2387 struct block_device *bdev; 2388}; 2389 2390static void register_bdev_worker(struct work_struct *work) 2391{ 2392 int fail = false; 2393 struct async_reg_args *args = | 2385 char *path; 2386 struct cache_sb *sb; 2387 struct cache_sb_disk *sb_disk; 2388 struct block_device *bdev; 2389}; 2390 2391static void register_bdev_worker(struct work_struct *work) 2392{ 2393 int fail = false; 2394 struct async_reg_args *args = |
2394 container_of(work, struct async_reg_args, reg_work); | 2395 container_of(work, struct async_reg_args, reg_work.work); |
2395 struct cached_dev *dc; 2396 2397 dc = kzalloc(sizeof(*dc), GFP_KERNEL); 2398 if (!dc) { 2399 fail = true; 2400 put_page(virt_to_page(args->sb_disk)); 2401 blkdev_put(args->bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); 2402 goto out; --- 13 unchanged lines hidden (view full) --- 2416 kfree(args); 2417 module_put(THIS_MODULE); 2418} 2419 2420static void register_cache_worker(struct work_struct *work) 2421{ 2422 int fail = false; 2423 struct async_reg_args *args = | 2396 struct cached_dev *dc; 2397 2398 dc = kzalloc(sizeof(*dc), GFP_KERNEL); 2399 if (!dc) { 2400 fail = true; 2401 put_page(virt_to_page(args->sb_disk)); 2402 blkdev_put(args->bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); 2403 goto out; --- 13 unchanged lines hidden (view full) --- 2417 kfree(args); 2418 module_put(THIS_MODULE); 2419} 2420 2421static void register_cache_worker(struct work_struct *work) 2422{ 2423 int fail = false; 2424 struct async_reg_args *args = |
2424 container_of(work, struct async_reg_args, reg_work); | 2425 container_of(work, struct async_reg_args, reg_work.work); |
2425 struct cache *ca; 2426 2427 ca = kzalloc(sizeof(*ca), GFP_KERNEL); 2428 if (!ca) { 2429 fail = true; 2430 put_page(virt_to_page(args->sb_disk)); 2431 blkdev_put(args->bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); 2432 goto out; --- 11 unchanged lines hidden (view full) --- 2444 kfree(args->path); 2445 kfree(args); 2446 module_put(THIS_MODULE); 2447} 2448 2449static void register_device_aync(struct async_reg_args *args) 2450{ 2451 if (SB_IS_BDEV(args->sb)) | 2426 struct cache *ca; 2427 2428 ca = kzalloc(sizeof(*ca), GFP_KERNEL); 2429 if (!ca) { 2430 fail = true; 2431 put_page(virt_to_page(args->sb_disk)); 2432 blkdev_put(args->bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); 2433 goto out; --- 11 unchanged lines hidden (view full) --- 2445 kfree(args->path); 2446 kfree(args); 2447 module_put(THIS_MODULE); 2448} 2449 2450static void register_device_aync(struct async_reg_args *args) 2451{ 2452 if (SB_IS_BDEV(args->sb)) |
2452 INIT_WORK(&args->reg_work, register_bdev_worker); | 2453 INIT_DELAYED_WORK(&args->reg_work, register_bdev_worker); |
2453 else | 2454 else |
2454 INIT_WORK(&args->reg_work, register_cache_worker); | 2455 INIT_DELAYED_WORK(&args->reg_work, register_cache_worker); |
2455 | 2456 |
2456 queue_work(system_wq, &args->reg_work); | 2457 /* 10 jiffies is enough for a delay */ 2458 queue_delayed_work(system_wq, &args->reg_work, 10); |
2457} 2458 2459static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, 2460 const char *buffer, size_t size) 2461{ 2462 const char *err; 2463 char *path = NULL; 2464 struct cache_sb *sb; --- 381 unchanged lines hidden --- | 2459} 2460 2461static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, 2462 const char *buffer, size_t size) 2463{ 2464 const char *err; 2465 char *path = NULL; 2466 struct cache_sb *sb; --- 381 unchanged lines hidden --- |