Skip to content

Commit 4e4cd21

Browse files
committed
Merge tag 'block-5.5-2020-01-10' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "A few fixes that should go into this round. This pull request contains two NVMe fixes via Keith, removal of a dead function, and a fix for the bio op for read truncates (Ming)" * tag 'block-5.5-2020-01-10' of git://git.kernel.dk/linux-block: nvmet: fix per feat data len for get_feature nvme: Translate more status codes to blk_status_t fs: move guard_bio_eod() after bio_set_op_attrs block: remove unused mp_bvec_last_segment
2 parents 30b6487 + e17016f commit 4e4cd21

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

block/bio.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,16 @@ void zero_fill_bio_iter(struct bio *bio, struct bvec_iter start)
538538
}
539539
EXPORT_SYMBOL(zero_fill_bio_iter);
540540

541+
/**
542+
* bio_truncate - truncate the bio to small size of @new_size
543+
* @bio: the bio to be truncated
544+
* @new_size: new size for truncating the bio
545+
*
546+
* Description:
547+
* Truncate the bio to new size of @new_size. If bio_op(bio) is
548+
* REQ_OP_READ, zero the truncated part. This function should only
549+
* be used for handling corner cases, such as bio eod.
550+
*/
541551
void bio_truncate(struct bio *bio, unsigned new_size)
542552
{
543553
struct bio_vec bv;
@@ -548,7 +558,7 @@ void bio_truncate(struct bio *bio, unsigned new_size)
548558
if (new_size >= bio->bi_iter.bi_size)
549559
return;
550560

551-
if (bio_data_dir(bio) != READ)
561+
if (bio_op(bio) != REQ_OP_READ)
552562
goto exit;
553563

554564
bio_for_each_segment(bv, bio, iter) {

drivers/nvme/host/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ static blk_status_t nvme_error_status(u16 status)
222222
case NVME_SC_CAP_EXCEEDED:
223223
return BLK_STS_NOSPC;
224224
case NVME_SC_LBA_RANGE:
225+
case NVME_SC_CMD_INTERRUPTED:
226+
case NVME_SC_NS_NOT_READY:
225227
return BLK_STS_TARGET;
226228
case NVME_SC_BAD_ATTRIBUTES:
227229
case NVME_SC_ONCS_NOT_SUPPORTED:

drivers/nvme/target/admin-cmd.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd)
2424
return len;
2525
}
2626

27+
static u32 nvmet_feat_data_len(struct nvmet_req *req, u32 cdw10)
28+
{
29+
switch (cdw10 & 0xff) {
30+
case NVME_FEAT_HOST_ID:
31+
return sizeof(req->sq->ctrl->hostid);
32+
default:
33+
return 0;
34+
}
35+
}
36+
2737
u64 nvmet_get_log_page_offset(struct nvme_command *cmd)
2838
{
2939
return le64_to_cpu(cmd->get_log_page.lpo);
@@ -778,7 +788,7 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
778788
u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
779789
u16 status = 0;
780790

781-
if (!nvmet_check_data_len(req, 0))
791+
if (!nvmet_check_data_len(req, nvmet_feat_data_len(req, cdw10)))
782792
return;
783793

784794
switch (cdw10 & 0xff) {

fs/buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,7 +3031,7 @@ static void end_bio_bh_io_sync(struct bio *bio)
30313031
* errors, this only handles the "we need to be able to
30323032
* do IO at the final sector" case.
30333033
*/
3034-
void guard_bio_eod(int op, struct bio *bio)
3034+
void guard_bio_eod(struct bio *bio)
30353035
{
30363036
sector_t maxsector;
30373037
struct hd_struct *part;
@@ -3095,15 +3095,15 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
30953095
bio->bi_end_io = end_bio_bh_io_sync;
30963096
bio->bi_private = bh;
30973097

3098-
/* Take care of bh's that straddle the end of the device */
3099-
guard_bio_eod(op, bio);
3100-
31013098
if (buffer_meta(bh))
31023099
op_flags |= REQ_META;
31033100
if (buffer_prio(bh))
31043101
op_flags |= REQ_PRIO;
31053102
bio_set_op_attrs(bio, op, op_flags);
31063103

3104+
/* Take care of bh's that straddle the end of the device */
3105+
guard_bio_eod(bio);
3106+
31073107
if (wbc) {
31083108
wbc_init_bio(wbc, bio);
31093109
wbc_account_cgroup_owner(wbc, bh->b_page, bh->b_size);

fs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static inline int __sync_blockdev(struct block_device *bdev, int wait)
3838
/*
3939
* buffer.c
4040
*/
41-
extern void guard_bio_eod(int rw, struct bio *bio);
41+
extern void guard_bio_eod(struct bio *bio);
4242
extern int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
4343
get_block_t *get_block, struct iomap *iomap);
4444

fs/mpage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static struct bio *mpage_bio_submit(int op, int op_flags, struct bio *bio)
6262
{
6363
bio->bi_end_io = mpage_end_io;
6464
bio_set_op_attrs(bio, op, op_flags);
65-
guard_bio_eod(op, bio);
65+
guard_bio_eod(bio);
6666
submit_bio(bio);
6767
return NULL;
6868
}

include/linux/bvec.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -153,26 +153,4 @@ static inline void bvec_advance(const struct bio_vec *bvec,
153153
}
154154
}
155155

156-
/*
157-
* Get the last single-page segment from the multi-page bvec and store it
158-
* in @seg
159-
*/
160-
static inline void mp_bvec_last_segment(const struct bio_vec *bvec,
161-
struct bio_vec *seg)
162-
{
163-
unsigned total = bvec->bv_offset + bvec->bv_len;
164-
unsigned last_page = (total - 1) / PAGE_SIZE;
165-
166-
seg->bv_page = bvec->bv_page + last_page;
167-
168-
/* the whole segment is inside the last page */
169-
if (bvec->bv_offset >= last_page * PAGE_SIZE) {
170-
seg->bv_offset = bvec->bv_offset % PAGE_SIZE;
171-
seg->bv_len = bvec->bv_len;
172-
} else {
173-
seg->bv_offset = 0;
174-
seg->bv_len = total - last_page * PAGE_SIZE;
175-
}
176-
}
177-
178156
#endif /* __LINUX_BVEC_ITER_H */

0 commit comments

Comments
 (0)