Skip to content

Commit 374bf88

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "Two fixes that should go into this release. One is an nvme regression fix from Keith, fixing a missing queue freeze if the controller is being reset. This causes the reset to hang. The other is a fix for a leak of the bio protection info, if smaller sized O_DIRECT is used. This fix should be more involved as we have other problematic paths in the kernel, but given as this isn't a regression in this series, we'll tackle those for 4.13" * 'for-linus' of git://git.kernel.dk/linux-block: block: provide bio_uninit() free freeing integrity/task associations nvme/pci: Fix stuck nvme reset
2 parents 6474924 + 9ae3b3f commit 374bf88

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

block/bio.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,21 @@ struct bio_vec *bvec_alloc(gfp_t gfp_mask, int nr, unsigned long *idx,
240240
return bvl;
241241
}
242242

243-
static void __bio_free(struct bio *bio)
243+
void bio_uninit(struct bio *bio)
244244
{
245245
bio_disassociate_task(bio);
246246

247247
if (bio_integrity(bio))
248248
bio_integrity_free(bio);
249249
}
250+
EXPORT_SYMBOL(bio_uninit);
250251

251252
static void bio_free(struct bio *bio)
252253
{
253254
struct bio_set *bs = bio->bi_pool;
254255
void *p;
255256

256-
__bio_free(bio);
257+
bio_uninit(bio);
257258

258259
if (bs) {
259260
bvec_free(bs->bvec_pool, bio->bi_io_vec, BVEC_POOL_IDX(bio));
@@ -271,6 +272,11 @@ static void bio_free(struct bio *bio)
271272
}
272273
}
273274

275+
/*
276+
* Users of this function have their own bio allocation. Subsequently,
277+
* they must remember to pair any call to bio_init() with bio_uninit()
278+
* when IO has completed, or when the bio is released.
279+
*/
274280
void bio_init(struct bio *bio, struct bio_vec *table,
275281
unsigned short max_vecs)
276282
{
@@ -297,7 +303,7 @@ void bio_reset(struct bio *bio)
297303
{
298304
unsigned long flags = bio->bi_flags & (~0UL << BIO_RESET_BITS);
299305

300-
__bio_free(bio);
306+
bio_uninit(bio);
301307

302308
memset(bio, 0, BIO_RESET_BYTES);
303309
bio->bi_flags = flags;

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,8 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
18051805
if (pci_is_enabled(pdev)) {
18061806
u32 csts = readl(dev->bar + NVME_REG_CSTS);
18071807

1808-
if (dev->ctrl.state == NVME_CTRL_LIVE)
1808+
if (dev->ctrl.state == NVME_CTRL_LIVE ||
1809+
dev->ctrl.state == NVME_CTRL_RESETTING)
18091810
nvme_start_freeze(&dev->ctrl);
18101811
dead = !!((csts & NVME_CSTS_CFS) || !(csts & NVME_CSTS_RDY) ||
18111812
pdev->error_state != pci_channel_io_normal);

fs/block_dev.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
263263
kfree(vecs);
264264

265265
if (unlikely(bio.bi_error))
266-
return bio.bi_error;
266+
ret = bio.bi_error;
267+
268+
bio_uninit(&bio);
269+
267270
return ret;
268271
}
269272

include/linux/bio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ extern void bio_advance(struct bio *, unsigned);
426426

427427
extern void bio_init(struct bio *bio, struct bio_vec *table,
428428
unsigned short max_vecs);
429+
extern void bio_uninit(struct bio *);
429430
extern void bio_reset(struct bio *);
430431
void bio_chain(struct bio *, struct bio *);
431432

0 commit comments

Comments
 (0)