From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D7B0C4332D for ; Sat, 21 Mar 2020 01:40:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EEBD92076C for ; Sat, 21 Mar 2020 01:40:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726840AbgCUBkE (ORCPT ); Fri, 20 Mar 2020 21:40:04 -0400 Received: from mx1.didichuxing.com ([111.202.154.82]:2116 "HELO bsf02.didichuxing.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with SMTP id S1727046AbgCUBkE (ORCPT ); Fri, 20 Mar 2020 21:40:04 -0400 X-ASG-Debug-ID: 1584753666-0e4108235339cd50001-Cu09wu Received: from mail.didiglobal.com (bogon [172.20.36.235]) by bsf02.didichuxing.com with ESMTP id 0oVwvWonRB63dX8P; Sat, 21 Mar 2020 09:21:06 +0800 (CST) X-Barracuda-Envelope-From: zhangweiping@didiglobal.com Received: from 192.168.3.9 (172.22.50.20) by BJSGEXMBX03.didichuxing.com (172.20.15.133) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 21 Mar 2020 09:21:05 +0800 Date: Sat, 21 Mar 2020 09:21:04 +0800 From: Weiping Zhang To: , CC: , Subject: [RFC 1/3] update the real issue size when bio_split Message-ID: X-ASG-Orig-Subj: [RFC 1/3] update the real issue size when bio_split Mail-Followup-To: axboe@kernel.dk, tj@kernel.org, linux-block@vger.kernel.org, cgroups@vger.kernel.org References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [172.22.50.20] X-ClientProxiedBy: BJEXCAS04.didichuxing.com (172.20.36.192) To BJSGEXMBX03.didichuxing.com (172.20.15.133) X-Barracuda-Connect: bogon[172.20.36.235] X-Barracuda-Start-Time: 1584753666 X-Barracuda-URL: https://bsf02.didichuxing.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at didichuxing.com X-Barracuda-Scan-Msg-Size: 1990 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.80738 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The split.bi_iter.bi_size was copied from @bio, bi_issue was initialized in this flow: bio_clone_fast->__bio_clone_fast->blkcg_bio_issue_init So the split->bi_issue has a wrong size, so update the size at here. Change-Id: I1f9c8c973ac1d41f4aea17a9a766b4c4d532f642 Signed-off-by: Weiping Zhang --- block/bio.c | 13 +++++++++++++ include/linux/blk_types.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/block/bio.c b/block/bio.c index 0985f3422556..8654c4d692e5 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1911,6 +1911,19 @@ struct bio *bio_split(struct bio *bio, int sectors, split->bi_iter.bi_size = sectors << 9; + /* + * reinit bio->bi_issue, the split.bi_iter.bi_size was copied + * from @bio, bi_issue was initialized in this flow: + * bio_clone_fast->__bio_clone_fast->blkcg_bio_issue_init + * + * So the split->bi_issue has a wrong size, so update the size + * at here. + * + * Actually, we can just use blkcg_bio_issue_init, there is just + * a bit difference for the issue_time. + */ + bio_issue_update_size(&split->bi_issue, bio_sectors(split)); + if (bio_integrity(split)) bio_integrity_trim(split); diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 70254ae11769..56e41ef3e827 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -128,6 +128,15 @@ static inline sector_t bio_issue_size(struct bio_issue *issue) return ((issue->value & BIO_ISSUE_SIZE_MASK) >> BIO_ISSUE_SIZE_SHIFT); } +static inline void bio_issue_update_size(struct bio_issue *issue, sector_t size) +{ + size &= (1ULL << BIO_ISSUE_SIZE_BITS) - 1; + /* set all _issue_size bits to 1 */ + issue->value |= (u64)BIO_ISSUE_SIZE_MASK; + /* set new size */ + issue->value &= ((u64)size << BIO_ISSUE_SIZE_SHIFT); +} + static inline void bio_issue_init(struct bio_issue *issue, sector_t size) { -- 2.18.1