Skip to content

Commit af22941

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block layer fixes from Jens Axboe: "Just a set of small fixes that have either been queued up after the original pull for this merge window, or just missed the original pull request. - a few bcache fixes/changes from Eric and Kent - add WRITE_SAME to the command filter whitelist frm Mauricio - kill an unused struct member from Ritesh - partition IO alignment fix from Stefan - nvme sysfs printf fix from Stephen" * 'for-linus' of git://git.kernel.dk/linux-block: block: check partition alignment nvme : Use correct scnprintf in cmb show block: allow WRITE_SAME commands with the SG_IO ioctl block: Remove unused member (busy) from struct blk_queue_tag bcache: partition support: add 16 minors per bcacheN device bcache: Make gc wakeup sane, remove set_task_state()
2 parents 9be962d + 633395b commit af22941

File tree

9 files changed

+38
-30
lines changed

9 files changed

+38
-30
lines changed

block/ioctl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
4545
|| pstart < 0 || plength < 0 || partno > 65535)
4646
return -EINVAL;
4747
}
48+
/* check if partition is aligned to blocksize */
49+
if (p.start & (bdev_logical_block_size(bdev) - 1))
50+
return -EINVAL;
4851

4952
mutex_lock(&bdev->bd_mutex);
5053

block/scsi_ioctl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ static void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter)
182182
__set_bit(WRITE_16, filter->write_ok);
183183
__set_bit(WRITE_LONG, filter->write_ok);
184184
__set_bit(WRITE_LONG_2, filter->write_ok);
185+
__set_bit(WRITE_SAME, filter->write_ok);
186+
__set_bit(WRITE_SAME_16, filter->write_ok);
187+
__set_bit(WRITE_SAME_32, filter->write_ok);
185188
__set_bit(ERASE, filter->write_ok);
186189
__set_bit(GPCMD_MODE_SELECT_10, filter->write_ok);
187190
__set_bit(MODE_SELECT, filter->write_ok);

drivers/md/bcache/bcache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ struct cache {
425425
* until a gc finishes - otherwise we could pointlessly burn a ton of
426426
* cpu
427427
*/
428-
unsigned invalidate_needs_gc:1;
428+
unsigned invalidate_needs_gc;
429429

430430
bool discard; /* Get rid of? */
431431

@@ -593,8 +593,8 @@ struct cache_set {
593593

594594
/* Counts how many sectors bio_insert has added to the cache */
595595
atomic_t sectors_to_gc;
596+
wait_queue_head_t gc_wait;
596597

597-
wait_queue_head_t moving_gc_wait;
598598
struct keybuf moving_gc_keys;
599599
/* Number of moving GC bios in flight */
600600
struct semaphore moving_in_flight;

drivers/md/bcache/btree.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,44 +1757,45 @@ static void bch_btree_gc(struct cache_set *c)
17571757
bch_moving_gc(c);
17581758
}
17591759

1760-
static int bch_gc_thread(void *arg)
1760+
static bool gc_should_run(struct cache_set *c)
17611761
{
1762-
struct cache_set *c = arg;
17631762
struct cache *ca;
17641763
unsigned i;
17651764

1766-
while (1) {
1767-
again:
1768-
bch_btree_gc(c);
1765+
for_each_cache(ca, c, i)
1766+
if (ca->invalidate_needs_gc)
1767+
return true;
17691768

1770-
set_current_state(TASK_INTERRUPTIBLE);
1771-
if (kthread_should_stop())
1772-
break;
1769+
if (atomic_read(&c->sectors_to_gc) < 0)
1770+
return true;
17731771

1774-
mutex_lock(&c->bucket_lock);
1772+
return false;
1773+
}
17751774

1776-
for_each_cache(ca, c, i)
1777-
if (ca->invalidate_needs_gc) {
1778-
mutex_unlock(&c->bucket_lock);
1779-
set_current_state(TASK_RUNNING);
1780-
goto again;
1781-
}
1775+
static int bch_gc_thread(void *arg)
1776+
{
1777+
struct cache_set *c = arg;
17821778

1783-
mutex_unlock(&c->bucket_lock);
1779+
while (1) {
1780+
wait_event_interruptible(c->gc_wait,
1781+
kthread_should_stop() || gc_should_run(c));
17841782

1785-
schedule();
1783+
if (kthread_should_stop())
1784+
break;
1785+
1786+
set_gc_sectors(c);
1787+
bch_btree_gc(c);
17861788
}
17871789

17881790
return 0;
17891791
}
17901792

17911793
int bch_gc_thread_start(struct cache_set *c)
17921794
{
1793-
c->gc_thread = kthread_create(bch_gc_thread, c, "bcache_gc");
1795+
c->gc_thread = kthread_run(bch_gc_thread, c, "bcache_gc");
17941796
if (IS_ERR(c->gc_thread))
17951797
return PTR_ERR(c->gc_thread);
17961798

1797-
set_task_state(c->gc_thread, TASK_INTERRUPTIBLE);
17981799
return 0;
17991800
}
18001801

drivers/md/bcache/btree.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ void bch_initial_mark_key(struct cache_set *, int, struct bkey *);
260260

261261
static inline void wake_up_gc(struct cache_set *c)
262262
{
263-
if (c->gc_thread)
264-
wake_up_process(c->gc_thread);
263+
wake_up(&c->gc_wait);
265264
}
266265

267266
#define MAP_DONE 0

drivers/md/bcache/request.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,8 @@ static void bch_data_insert_start(struct closure *cl)
196196
struct data_insert_op *op = container_of(cl, struct data_insert_op, cl);
197197
struct bio *bio = op->bio, *n;
198198

199-
if (atomic_sub_return(bio_sectors(bio), &op->c->sectors_to_gc) < 0) {
200-
set_gc_sectors(op->c);
199+
if (atomic_sub_return(bio_sectors(bio), &op->c->sectors_to_gc) < 0)
201200
wake_up_gc(op->c);
202-
}
203201

204202
if (op->bypass)
205203
return bch_data_invalidate(cl);

drivers/md/bcache/super.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static wait_queue_head_t unregister_wait;
5858
struct workqueue_struct *bcache_wq;
5959

6060
#define BTREE_MAX_PAGES (256 * 1024 / PAGE_SIZE)
61+
#define BCACHE_MINORS 16 /* partition support */
6162

6263
/* Superblock */
6364

@@ -783,8 +784,10 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
783784
if (minor < 0)
784785
return minor;
785786

787+
minor *= BCACHE_MINORS;
788+
786789
if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) ||
787-
!(d->disk = alloc_disk(1))) {
790+
!(d->disk = alloc_disk(BCACHE_MINORS))) {
788791
ida_simple_remove(&bcache_minor, minor);
789792
return -ENOMEM;
790793
}
@@ -1489,6 +1492,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
14891492
mutex_init(&c->bucket_lock);
14901493
init_waitqueue_head(&c->btree_cache_wait);
14911494
init_waitqueue_head(&c->bucket_wait);
1495+
init_waitqueue_head(&c->gc_wait);
14921496
sema_init(&c->uuid_write_mutex, 1);
14931497

14941498
spin_lock_init(&c->btree_gc_time.lock);
@@ -1548,6 +1552,7 @@ static void run_cache_set(struct cache_set *c)
15481552

15491553
for_each_cache(ca, c, i)
15501554
c->nbuckets += ca->sb.nbuckets;
1555+
set_gc_sectors(c);
15511556

15521557
if (CACHE_SYNC(&c->sb)) {
15531558
LIST_HEAD(journal);

drivers/nvme/host/pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#define NVME_AQ_DEPTH 256
5151
#define SQ_SIZE(depth) (depth * sizeof(struct nvme_command))
5252
#define CQ_SIZE(depth) (depth * sizeof(struct nvme_completion))
53-
53+
5454
/*
5555
* We handle AEN commands ourselves and don't even let the
5656
* block layer know about them.
@@ -1349,7 +1349,7 @@ static ssize_t nvme_cmb_show(struct device *dev,
13491349
{
13501350
struct nvme_dev *ndev = to_nvme_dev(dev_get_drvdata(dev));
13511351

1352-
return snprintf(buf, PAGE_SIZE, "cmbloc : x%08x\ncmbsz : x%08x\n",
1352+
return scnprintf(buf, PAGE_SIZE, "cmbloc : x%08x\ncmbsz : x%08x\n",
13531353
ndev->cmbloc, ndev->cmbsz);
13541354
}
13551355
static DEVICE_ATTR(cmb, S_IRUGO, nvme_cmb_show, NULL);

include/linux/blkdev.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ enum blk_queue_state {
288288
struct blk_queue_tag {
289289
struct request **tag_index; /* map of busy tags */
290290
unsigned long *tag_map; /* bit map of free/busy tags */
291-
int busy; /* current depth */
292291
int max_depth; /* what we will send to device */
293292
int real_max_depth; /* what the array can hold */
294293
atomic_t refcnt; /* map can be shared */

0 commit comments

Comments
 (0)