Skip to content

Commit ed41fd0

Browse files
committed
Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - Missing CRC32 selections (Arnd) - Fix for a merge window regression with bdev inode init (Christoph) - bcache fixes - rnbd fixes - NVMe pull request from Christoph: - fix a race in the nvme-tcp send code (Sagi Grimberg) - fix a list corruption in an nvme-rdma error path (Israel Rukshin) - avoid a possible double fetch in nvme-pci (Lalithambika Krishnakumar) - add the susystem NQN quirk for a Samsung driver (Gopal Tiwari) - fix two compiler warnings in nvme-fcloop (James Smart) - don't call sleeping functions from irq context in nvme-fc (James Smart) - remove an unused argument (Max Gurtovoy) - remove unused exports (Minwoo Im) - Use-after-free fix for partition iteration (Ming) - Missing blk-mq debugfs flag annotation (John) - Bdev freeze regression fix (Satya) - blk-iocost NULL pointer deref fix (Tejun) * tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block: (26 commits) bcache: set bcache device into read-only mode for BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET bcache: introduce BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE for large bucket bcache: check unsupported feature sets for bcache register bcache: fix typo from SUUP to SUPP in features.h bcache: set pdev_set_uuid before scond loop iteration blk-mq-debugfs: Add decode for BLK_MQ_F_TAG_HCTX_SHARED block/rnbd-clt: avoid module unload race with close confirmation block/rnbd: Adding name to the Contributors List block/rnbd-clt: Fix sg table use after free block/rnbd-srv: Fix use after free in rnbd_srv_sess_dev_force_close block/rnbd: Select SG_POOL for RNBD_CLIENT block: pre-initialize struct block_device in bdev_alloc_inode fs: Fix freeze_bdev()/thaw_bdev() accounting of bd_fsfreeze_sb nvme: remove the unused status argument from nvme_trace_bio_complete nvmet-rdma: Fix list_del corruption on queue establishment failure nvme: unexport functions with no external caller nvme: avoid possible double fetch in handling CQE nvme-tcp: Fix possible race of io_work and direct send nvme-pci: mark Samsung PM1725a as IGNORE_DEV_SUBNQN nvme-fcloop: Fix sscanf type and list_first_entry_or_null warnings ...
2 parents d430adf + 5342fd4 commit ed41fd0

File tree

22 files changed

+172
-59
lines changed

22 files changed

+172
-59
lines changed

block/bfq-iosched.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6332,13 +6332,13 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd,
63326332
* limit 'something'.
63336333
*/
63346334
/* no more than 50% of tags for async I/O */
6335-
bfqd->word_depths[0][0] = max((1U << bt->sb.shift) >> 1, 1U);
6335+
bfqd->word_depths[0][0] = max(bt->sb.depth >> 1, 1U);
63366336
/*
63376337
* no more than 75% of tags for sync writes (25% extra tags
63386338
* w.r.t. async I/O, to prevent async I/O from starving sync
63396339
* writes)
63406340
*/
6341-
bfqd->word_depths[0][1] = max(((1U << bt->sb.shift) * 3) >> 2, 1U);
6341+
bfqd->word_depths[0][1] = max((bt->sb.depth * 3) >> 2, 1U);
63426342

63436343
/*
63446344
* In-word depths in case some bfq_queue is being weight-
@@ -6348,9 +6348,9 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd,
63486348
* shortage.
63496349
*/
63506350
/* no more than ~18% of tags for async I/O */
6351-
bfqd->word_depths[1][0] = max(((1U << bt->sb.shift) * 3) >> 4, 1U);
6351+
bfqd->word_depths[1][0] = max((bt->sb.depth * 3) >> 4, 1U);
63526352
/* no more than ~37% of tags for sync writes (~20% extra tags) */
6353-
bfqd->word_depths[1][1] = max(((1U << bt->sb.shift) * 6) >> 4, 1U);
6353+
bfqd->word_depths[1][1] = max((bt->sb.depth * 6) >> 4, 1U);
63546354

63556355
for (i = 0; i < 2; i++)
63566356
for (j = 0; j < 2; j++)

block/blk-iocost.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,8 +2551,8 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
25512551
bool use_debt, ioc_locked;
25522552
unsigned long flags;
25532553

2554-
/* bypass IOs if disabled or for root cgroup */
2555-
if (!ioc->enabled || !iocg->level)
2554+
/* bypass IOs if disabled, still initializing, or for root cgroup */
2555+
if (!ioc->enabled || !iocg || !iocg->level)
25562556
return;
25572557

25582558
/* calculate the absolute vtime cost */
@@ -2679,14 +2679,14 @@ static void ioc_rqos_merge(struct rq_qos *rqos, struct request *rq,
26792679
struct bio *bio)
26802680
{
26812681
struct ioc_gq *iocg = blkg_to_iocg(bio->bi_blkg);
2682-
struct ioc *ioc = iocg->ioc;
2682+
struct ioc *ioc = rqos_to_ioc(rqos);
26832683
sector_t bio_end = bio_end_sector(bio);
26842684
struct ioc_now now;
26852685
u64 vtime, abs_cost, cost;
26862686
unsigned long flags;
26872687

2688-
/* bypass if disabled or for root cgroup */
2689-
if (!ioc->enabled || !iocg->level)
2688+
/* bypass if disabled, still initializing, or for root cgroup */
2689+
if (!ioc->enabled || !iocg || !iocg->level)
26902690
return;
26912691

26922692
abs_cost = calc_vtime_cost(bio, iocg, true);
@@ -2863,6 +2863,12 @@ static int blk_iocost_init(struct request_queue *q)
28632863
ioc_refresh_params(ioc, true);
28642864
spin_unlock_irq(&ioc->lock);
28652865

2866+
/*
2867+
* rqos must be added before activation to allow iocg_pd_init() to
2868+
* lookup the ioc from q. This means that the rqos methods may get
2869+
* called before policy activation completion, can't assume that the
2870+
* target bio has an iocg associated and need to test for NULL iocg.
2871+
*/
28662872
rq_qos_add(q, rqos);
28672873
ret = blkcg_activate_policy(q, &blkcg_policy_iocost);
28682874
if (ret) {

block/blk-mq-debugfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ static const char *const hctx_flag_name[] = {
246246
HCTX_FLAG_NAME(BLOCKING),
247247
HCTX_FLAG_NAME(NO_SCHED),
248248
HCTX_FLAG_NAME(STACKING),
249+
HCTX_FLAG_NAME(TAG_HCTX_SHARED),
249250
};
250251
#undef HCTX_FLAG_NAME
251252

block/genhd.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,18 @@ struct block_device *disk_part_iter_next(struct disk_part_iter *piter)
246246
part = rcu_dereference(ptbl->part[piter->idx]);
247247
if (!part)
248248
continue;
249+
piter->part = bdgrab(part);
250+
if (!piter->part)
251+
continue;
249252
if (!bdev_nr_sectors(part) &&
250253
!(piter->flags & DISK_PITER_INCL_EMPTY) &&
251254
!(piter->flags & DISK_PITER_INCL_EMPTY_PART0 &&
252-
piter->idx == 0))
255+
piter->idx == 0)) {
256+
bdput(piter->part);
257+
piter->part = NULL;
253258
continue;
259+
}
254260

255-
piter->part = bdgrab(part);
256-
if (!piter->part)
257-
continue;
258261
piter->idx += inc;
259262
break;
260263
}

drivers/block/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ config BLK_DEV_RBD
445445
config BLK_DEV_RSXX
446446
tristate "IBM Flash Adapter 900GB Full Height PCIe Device Driver"
447447
depends on PCI
448+
select CRC32
448449
help
449450
Device driver for IBM's high speed PCIe SSD
450451
storage device: Flash Adapter 900GB Full Height.

drivers/block/rnbd/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config BLK_DEV_RNBD_CLIENT
77
tristate "RDMA Network Block Device driver client"
88
depends on INFINIBAND_RTRS_CLIENT
99
select BLK_DEV_RNBD
10+
select SG_POOL
1011
help
1112
RNBD client is a network block device driver using rdma transport.
1213

drivers/block/rnbd/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ Kleber Souza <[email protected]>
9090
Lutz Pogrell <[email protected]>
9191
Milind Dumbare <[email protected]>
9292
Roman Penyaev <[email protected]>
93+
Swapnil Ingle <[email protected]>

drivers/block/rnbd/rnbd-clt.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,19 @@ static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess,
375375
init_waitqueue_head(&iu->comp.wait);
376376
iu->comp.errno = INT_MAX;
377377

378+
if (sg_alloc_table(&iu->sgt, 1, GFP_KERNEL)) {
379+
rnbd_put_permit(sess, permit);
380+
kfree(iu);
381+
return NULL;
382+
}
383+
378384
return iu;
379385
}
380386

381387
static void rnbd_put_iu(struct rnbd_clt_session *sess, struct rnbd_iu *iu)
382388
{
383389
if (atomic_dec_and_test(&iu->refcount)) {
390+
sg_free_table(&iu->sgt);
384391
rnbd_put_permit(sess, iu->permit);
385392
kfree(iu);
386393
}
@@ -487,8 +494,6 @@ static int send_msg_close(struct rnbd_clt_dev *dev, u32 device_id, bool wait)
487494
iu->buf = NULL;
488495
iu->dev = dev;
489496

490-
sg_alloc_table(&iu->sgt, 1, GFP_KERNEL);
491-
492497
msg.hdr.type = cpu_to_le16(RNBD_MSG_CLOSE);
493498
msg.device_id = cpu_to_le32(device_id);
494499

@@ -502,7 +507,6 @@ static int send_msg_close(struct rnbd_clt_dev *dev, u32 device_id, bool wait)
502507
err = errno;
503508
}
504509

505-
sg_free_table(&iu->sgt);
506510
rnbd_put_iu(sess, iu);
507511
return err;
508512
}
@@ -575,7 +579,6 @@ static int send_msg_open(struct rnbd_clt_dev *dev, bool wait)
575579
iu->buf = rsp;
576580
iu->dev = dev;
577581

578-
sg_alloc_table(&iu->sgt, 1, GFP_KERNEL);
579582
sg_init_one(iu->sgt.sgl, rsp, sizeof(*rsp));
580583

581584
msg.hdr.type = cpu_to_le16(RNBD_MSG_OPEN);
@@ -594,7 +597,6 @@ static int send_msg_open(struct rnbd_clt_dev *dev, bool wait)
594597
err = errno;
595598
}
596599

597-
sg_free_table(&iu->sgt);
598600
rnbd_put_iu(sess, iu);
599601
return err;
600602
}
@@ -622,8 +624,6 @@ static int send_msg_sess_info(struct rnbd_clt_session *sess, bool wait)
622624

623625
iu->buf = rsp;
624626
iu->sess = sess;
625-
626-
sg_alloc_table(&iu->sgt, 1, GFP_KERNEL);
627627
sg_init_one(iu->sgt.sgl, rsp, sizeof(*rsp));
628628

629629
msg.hdr.type = cpu_to_le16(RNBD_MSG_SESS_INFO);
@@ -650,7 +650,6 @@ static int send_msg_sess_info(struct rnbd_clt_session *sess, bool wait)
650650
} else {
651651
err = errno;
652652
}
653-
sg_free_table(&iu->sgt);
654653
rnbd_put_iu(sess, iu);
655654
return err;
656655
}
@@ -1698,7 +1697,8 @@ static void rnbd_destroy_sessions(void)
16981697
*/
16991698

17001699
list_for_each_entry_safe(sess, sn, &sess_list, list) {
1701-
WARN_ON(!rnbd_clt_get_sess(sess));
1700+
if (!rnbd_clt_get_sess(sess))
1701+
continue;
17021702
close_rtrs(sess);
17031703
list_for_each_entry_safe(dev, tn, &sess->devs_list, list) {
17041704
/*

drivers/block/rnbd/rnbd-srv.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,12 @@ static int rnbd_srv_link_ev(struct rtrs_srv *rtrs,
338338

339339
void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev)
340340
{
341-
mutex_lock(&sess_dev->sess->lock);
342-
rnbd_srv_destroy_dev_session_sysfs(sess_dev);
343-
mutex_unlock(&sess_dev->sess->lock);
341+
struct rnbd_srv_session *sess = sess_dev->sess;
342+
344343
sess_dev->keep_id = true;
344+
mutex_lock(&sess->lock);
345+
rnbd_srv_destroy_dev_session_sysfs(sess_dev);
346+
mutex_unlock(&sess->lock);
345347
}
346348

347349
static int process_msg_close(struct rtrs_srv *rtrs,

drivers/lightnvm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if NVM
1919

2020
config NVM_PBLK
2121
tristate "Physical Block Device Open-Channel SSD target"
22+
select CRC32
2223
help
2324
Allows an open-channel SSD to be exposed as a block device to the
2425
host. The target assumes the device exposes raw flash and must be

drivers/md/bcache/features.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct feature {
1717
};
1818

1919
static struct feature feature_list[] = {
20-
{BCH_FEATURE_INCOMPAT, BCH_FEATURE_INCOMPAT_LARGE_BUCKET,
20+
{BCH_FEATURE_INCOMPAT, BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE,
2121
"large_bucket"},
2222
{0, 0, 0 },
2323
};

drivers/md/bcache/features.h

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313

1414
/* Feature set definition */
1515
/* Incompat feature set */
16-
#define BCH_FEATURE_INCOMPAT_LARGE_BUCKET 0x0001 /* 32bit bucket size */
16+
/* 32bit bucket size, obsoleted */
17+
#define BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET 0x0001
18+
/* real bucket size is (1 << bucket_size) */
19+
#define BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE 0x0002
1720

18-
#define BCH_FEATURE_COMPAT_SUUP 0
19-
#define BCH_FEATURE_RO_COMPAT_SUUP 0
20-
#define BCH_FEATURE_INCOMPAT_SUUP BCH_FEATURE_INCOMPAT_LARGE_BUCKET
21+
#define BCH_FEATURE_COMPAT_SUPP 0
22+
#define BCH_FEATURE_RO_COMPAT_SUPP 0
23+
#define BCH_FEATURE_INCOMPAT_SUPP (BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET| \
24+
BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE)
2125

2226
#define BCH_HAS_COMPAT_FEATURE(sb, mask) \
2327
((sb)->feature_compat & (mask))
@@ -77,7 +81,23 @@ static inline void bch_clear_feature_##name(struct cache_sb *sb) \
7781
~BCH##_FEATURE_INCOMPAT_##flagname; \
7882
}
7983

80-
BCH_FEATURE_INCOMPAT_FUNCS(large_bucket, LARGE_BUCKET);
84+
BCH_FEATURE_INCOMPAT_FUNCS(obso_large_bucket, OBSO_LARGE_BUCKET);
85+
BCH_FEATURE_INCOMPAT_FUNCS(large_bucket, LOG_LARGE_BUCKET_SIZE);
86+
87+
static inline bool bch_has_unknown_compat_features(struct cache_sb *sb)
88+
{
89+
return ((sb->feature_compat & ~BCH_FEATURE_COMPAT_SUPP) != 0);
90+
}
91+
92+
static inline bool bch_has_unknown_ro_compat_features(struct cache_sb *sb)
93+
{
94+
return ((sb->feature_ro_compat & ~BCH_FEATURE_RO_COMPAT_SUPP) != 0);
95+
}
96+
97+
static inline bool bch_has_unknown_incompat_features(struct cache_sb *sb)
98+
{
99+
return ((sb->feature_incompat & ~BCH_FEATURE_INCOMPAT_SUPP) != 0);
100+
}
81101

82102
int bch_print_cache_set_feature_compat(struct cache_set *c, char *buf, int size);
83103
int bch_print_cache_set_feature_ro_compat(struct cache_set *c, char *buf, int size);

drivers/md/bcache/super.c

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,25 @@ static unsigned int get_bucket_size(struct cache_sb *sb, struct cache_sb_disk *s
6464
{
6565
unsigned int bucket_size = le16_to_cpu(s->bucket_size);
6666

67-
if (sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES &&
68-
bch_has_feature_large_bucket(sb))
69-
bucket_size |= le16_to_cpu(s->bucket_size_hi) << 16;
67+
if (sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES) {
68+
if (bch_has_feature_large_bucket(sb)) {
69+
unsigned int max, order;
70+
71+
max = sizeof(unsigned int) * BITS_PER_BYTE - 1;
72+
order = le16_to_cpu(s->bucket_size);
73+
/*
74+
* bcache tool will make sure the overflow won't
75+
* happen, an error message here is enough.
76+
*/
77+
if (order > max)
78+
pr_err("Bucket size (1 << %u) overflows\n",
79+
order);
80+
bucket_size = 1 << order;
81+
} else if (bch_has_feature_obso_large_bucket(sb)) {
82+
bucket_size +=
83+
le16_to_cpu(s->obso_bucket_size_hi) << 16;
84+
}
85+
}
7086

7187
return bucket_size;
7288
}
@@ -228,6 +244,20 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
228244
sb->feature_compat = le64_to_cpu(s->feature_compat);
229245
sb->feature_incompat = le64_to_cpu(s->feature_incompat);
230246
sb->feature_ro_compat = le64_to_cpu(s->feature_ro_compat);
247+
248+
/* Check incompatible features */
249+
err = "Unsupported compatible feature found";
250+
if (bch_has_unknown_compat_features(sb))
251+
goto err;
252+
253+
err = "Unsupported read-only compatible feature found";
254+
if (bch_has_unknown_ro_compat_features(sb))
255+
goto err;
256+
257+
err = "Unsupported incompatible feature found";
258+
if (bch_has_unknown_incompat_features(sb))
259+
goto err;
260+
231261
err = read_super_common(sb, bdev, s);
232262
if (err)
233263
goto err;
@@ -1302,6 +1332,12 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
13021332
bcache_device_link(&dc->disk, c, "bdev");
13031333
atomic_inc(&c->attached_dev_nr);
13041334

1335+
if (bch_has_feature_obso_large_bucket(&(c->cache->sb))) {
1336+
pr_err("The obsoleted large bucket layout is unsupported, set the bcache device into read-only\n");
1337+
pr_err("Please update to the latest bcache-tools to create the cache device\n");
1338+
set_disk_ro(dc->disk.disk, 1);
1339+
}
1340+
13051341
/* Allow the writeback thread to proceed */
13061342
up_write(&dc->writeback_lock);
13071343

@@ -1524,6 +1560,12 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
15241560

15251561
bcache_device_link(d, c, "volume");
15261562

1563+
if (bch_has_feature_obso_large_bucket(&c->cache->sb)) {
1564+
pr_err("The obsoleted large bucket layout is unsupported, set the bcache device into read-only\n");
1565+
pr_err("Please update to the latest bcache-tools to create the cache device\n");
1566+
set_disk_ro(d->disk, 1);
1567+
}
1568+
15271569
return 0;
15281570
err:
15291571
kobject_put(&d->kobj);
@@ -2083,6 +2125,9 @@ static int run_cache_set(struct cache_set *c)
20832125
c->cache->sb.last_mount = (u32)ktime_get_real_seconds();
20842126
bcache_write_super(c);
20852127

2128+
if (bch_has_feature_obso_large_bucket(&c->cache->sb))
2129+
pr_err("Detect obsoleted large bucket layout, all attached bcache device will be read-only\n");
2130+
20862131
list_for_each_entry_safe(dc, t, &uncached_devices, list)
20872132
bch_cached_dev_attach(dc, c, NULL);
20882133

@@ -2644,8 +2689,8 @@ static ssize_t bch_pending_bdevs_cleanup(struct kobject *k,
26442689
}
26452690

26462691
list_for_each_entry_safe(pdev, tpdev, &pending_devs, list) {
2692+
char *pdev_set_uuid = pdev->dc->sb.set_uuid;
26472693
list_for_each_entry_safe(c, tc, &bch_cache_sets, list) {
2648-
char *pdev_set_uuid = pdev->dc->sb.set_uuid;
26492694
char *set_uuid = c->set_uuid;
26502695

26512696
if (!memcmp(pdev_set_uuid, set_uuid, 16)) {

0 commit comments

Comments
 (0)