From patchwork Thu Nov 15 08:52:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86ED914BA for ; Thu, 15 Nov 2018 08:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 789C128496 for ; Thu, 15 Nov 2018 08:53:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B35128505; Thu, 15 Nov 2018 08:53:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D597328496 for ; Thu, 15 Nov 2018 08:53:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 079996B026D; Thu, 15 Nov 2018 03:53:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 051356B026E; Thu, 15 Nov 2018 03:53:52 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB4E06B026F; Thu, 15 Nov 2018 03:53:51 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id C2D386B026D for ; Thu, 15 Nov 2018 03:53:51 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id z126so43515600qka.10 for ; Thu, 15 Nov 2018 00:53:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=boCV00+SsQK+T2rHZQwqNcLhuNoj2OH5hjO/svFBmcI=; b=Q1Ndl0wjSI7uulcQqSMgSy4+1uxpqiarbcWneJYZ8pIYLWshQV/QxiWocUnHiWEuQe njnhrVi4DXFgWqKsINcAHbKaa8Yj2c70TqGRdG1/dUo/CieLwvwkfYS3Pd87aiBvtQl3 pedWtqgi7neLQRuYbLfrf7Ri3tayOGFvPdFLQkMTTIHjDejA1ENDbphTDpH/9gt+zbNp f9+jrLw6VTp081B1XxHlOEq8b2R7hfrceOwmEoMoT/mS6WiDFitZCAWGcudbaGc9c7MJ uEc4vWTwSGsNX9JkbpJTwznivcKcnHULo6TUX34cF8HR4jQewdW1IAz8TPO6FKOkdixF uQSA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gKVfmFyLUX83a3af8mg0He0mfLUT824uC2oudNqJJYe2zl18h1M M1QcucFZf7HhQGb2esAjzZfgPy3YkvaCuuJDwL5/qZ/H+mSiIsAUlq7CAStg9o6u1cFIKgXG5w4 Q6gNAT198/GCrnzdb4LMGgTEC1urXLYdkHwTftiVkbkDcyhci5BSNDgXOkI7eLWeRMQ== X-Received: by 2002:a0c:f9c3:: with SMTP id j3mr5432118qvo.107.1542272031559; Thu, 15 Nov 2018 00:53:51 -0800 (PST) X-Google-Smtp-Source: AJdET5f5arn828kzD5I3RZH4a/rMCsQkxL9OLLgVI5pa0ze1r6m9Cirz3oIfp1jL99taSJBTnme7 X-Received: by 2002:a0c:f9c3:: with SMTP id j3mr5432088qvo.107.1542272031022; Thu, 15 Nov 2018 00:53:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272030; cv=none; d=google.com; s=arc-20160816; b=Qei18zPDUBWZS2GJRh0jQwtiBq5m75S35D2jTA9FOQD61WLbQyc8i7Jta2ZSlWNImv eWzaWPilHl7ujQ605bWAlvMPu3aVcsV32GxwA/C6vIy58NaRm4TQ6U5WWHQElbEfcP9A NpCY0M7xynNftfjgCGdz62DCM2GxtUzgN0BQuywAVM+gj8lY3bqBocjO1nWu/3/WJVd5 pPuBp8niJEkN+QL/dEG5/3RIZ9kGMtAnZ49aeeqNcj+TIKrT8z9Rt/HRZyHz4PdDY8EE ZZgOiayZKzU4FiLjGUpeNQJPZbLyr1dXUViXZEDgMt8McsZ3P0a00NC7vJmfsB1tG3dT 4rfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=boCV00+SsQK+T2rHZQwqNcLhuNoj2OH5hjO/svFBmcI=; b=V4H1Txz3wfa72lighS5Edfv22y/UuARHi2uHhlMimEQ2TJnQbeOGiWhsLIwk53y20b Wc5jPJBDYXCY6Qqd/K+Lxs8xB2z1UBoYV9nmYiIdTLe9tsHD0hgEOaiIQl8Lb9+JX5uD ziJnDsFNsj7bgcV5jT0RcCQSiODNDRn1WlW4OmmbwVlCYi2+va65xq3dSRNgv4ywFyKr UTvLg3w/ktGTFhePCcAfSy3cnWSBZyWO0qqi9t0mPPua5OnrkheGksVBhB5GErlyEg1k gFHtmr6QMBTOsiLJTfVdsOLU5he4+nH1FHdrZefSlS/WuiWljo//xQsKngmeCQj3WNkp hHjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id y65si14337989qtd.327.2018.11.15.00.53.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:53:50 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C4F5307D992; Thu, 15 Nov 2018 08:53:49 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id C21B15C220; Thu, 15 Nov 2018 08:53:36 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 01/19] block: introduce multi-page page bvec helpers Date: Thu, 15 Nov 2018 16:52:48 +0800 Message-Id: <20181115085306.9910-2-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 15 Nov 2018 08:53:50 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces helpers of 'mp_bvec_iter_*' for multipage bvec support. The introduced helpers treate one bvec as real multi-page segment, which may include more than one pages. The existed helpers of bvec_iter_* are interfaces for supporting current bvec iterator which is thought as single-page by drivers, fs, dm and etc. These introduced helpers will build single-page bvec in flight, so this way won't break current bio/bvec users, which needn't any change. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- include/linux/bvec.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 02c73c6aa805..8ef904a50577 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -23,6 +23,44 @@ #include #include #include +#include + +/* + * What is multi-page bvecs? + * + * - bvecs stored in bio->bi_io_vec is always multi-page(mp) style + * + * - bvec(struct bio_vec) represents one physically contiguous I/O + * buffer, now the buffer may include more than one pages after + * multi-page(mp) bvec is supported, and all these pages represented + * by one bvec is physically contiguous. Before mp support, at most + * one page is included in one bvec, we call it single-page(sp) + * bvec. + * + * - .bv_page of the bvec represents the 1st page in the mp bvec + * + * - .bv_offset of the bvec represents offset of the buffer in the bvec + * + * The effect on the current drivers/filesystem/dm/bcache/...: + * + * - almost everyone supposes that one bvec only includes one single + * page, so we keep the sp interface not changed, for example, + * bio_for_each_segment() still returns bvec with single page + * + * - bio_for_each_segment*() will be changed to return single-page + * bvec too + * + * - during iterating, iterator variable(struct bvec_iter) is always + * updated in multipage bvec style and that means bvec_iter_advance() + * is kept not changed + * + * - returned(copied) single-page bvec is built in flight by bvec + * helpers from the stored multipage bvec + * + * - In case that some components(such as iov_iter) need to support + * multi-page bvec, we introduce new helpers(mp_bvec_iter_*) for + * them. + */ /* * was unsigned short, but we might as well be ready for > 64kB I/O pages @@ -50,16 +88,35 @@ struct bvec_iter { */ #define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx]) -#define bvec_iter_page(bvec, iter) \ +#define mp_bvec_iter_page(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_page) -#define bvec_iter_len(bvec, iter) \ +#define mp_bvec_iter_len(bvec, iter) \ min((iter).bi_size, \ __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done) -#define bvec_iter_offset(bvec, iter) \ +#define mp_bvec_iter_offset(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done) +#define mp_bvec_iter_page_idx(bvec, iter) \ + (mp_bvec_iter_offset((bvec), (iter)) / PAGE_SIZE) + +/* + * of single-page(sp) segment. + * + * This helpers are for building sp bvec in flight. + */ +#define bvec_iter_offset(bvec, iter) \ + (mp_bvec_iter_offset((bvec), (iter)) % PAGE_SIZE) + +#define bvec_iter_len(bvec, iter) \ + min_t(unsigned, mp_bvec_iter_len((bvec), (iter)), \ + (PAGE_SIZE - (bvec_iter_offset((bvec), (iter))))) + +#define bvec_iter_page(bvec, iter) \ + nth_page(mp_bvec_iter_page((bvec), (iter)), \ + mp_bvec_iter_page_idx((bvec), (iter))) + #define bvec_iter_bvec(bvec, iter) \ ((struct bio_vec) { \ .bv_page = bvec_iter_page((bvec), (iter)), \ From patchwork Thu Nov 15 08:52:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF9B914BA for ; Thu, 15 Nov 2018 08:54:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE6C7299C2 for ; Thu, 15 Nov 2018 08:54:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1B392ACBC; Thu, 15 Nov 2018 08:54:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43945299C2 for ; Thu, 15 Nov 2018 08:54:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F9D06B026F; Thu, 15 Nov 2018 03:54:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5CFFC6B0270; Thu, 15 Nov 2018 03:54:09 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E6E26B0271; Thu, 15 Nov 2018 03:54:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 256D16B026F for ; Thu, 15 Nov 2018 03:54:09 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id z126so43516722qka.10 for ; Thu, 15 Nov 2018 00:54:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=cQk/x+AIffjZs0Qf2lqhZSuTnGQ87wOCv1fbuhTicYI=; b=r6i3YQ7rVaTaQ5+L6ZrXBdf4T70qXKfQBevbUwRhG4Ah2Uc3UcZrqGl4iOLVTrJ+Vg NyMHpZQR6PEJBGjYq++3RA78+V2QNG3FhuEu0ibqgQxvTg1WhpKDbCYhl/1hzmLoftWw Qta6wabR8W+UMjFG1KYaNH/rUG6aDchjM65DKWGmYfe6fSbTZVFOXFxJMq8+5O+od29p p9flTu75Rww4eUfUNohrzOYM2fip05jWaaerYeXQ4XdfMYyRtmNeOUodZhETz0VrrsCX jVA5LAodyYhOrVHkOV8RQk+kxeRYx0+HLuekvgYD0ZGMZzvDuVO4l/sKaJSlTzhzTByP 5DmA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gIcVRD0AaJYBhveDhpVwakWT390nJEw8EV1/zY1N8QWP37cQlV6 AOi4Az7QHSBDWcxUVO9Va5orHwBt2JPdGx1UASlRxb+WTJQgNkzta/5lX4mZqd7sua7qakHSApc veDPBuGbR5AFpsP3F+64GxVRVXcoEly570JjDSjr1rsY2umUjVa4dqB9vUx2sOTzOLg== X-Received: by 2002:a0c:9e05:: with SMTP id p5mr5245841qve.246.1542272048881; Thu, 15 Nov 2018 00:54:08 -0800 (PST) X-Google-Smtp-Source: AJdET5f2LBs92oSkPIUrhZbIXiHNXpEprQJF4t4eeqTtmJVAJtIh5TtAMK0/BR0jOAv8QJIrGB/v X-Received: by 2002:a0c:9e05:: with SMTP id p5mr5245822qve.246.1542272048372; Thu, 15 Nov 2018 00:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272048; cv=none; d=google.com; s=arc-20160816; b=k0mkd8uGTLLZ804XVuBYsqgRAFnZDvzkpVokoG3TNGGpdWfN0YFUNH7IgnnDih49sC uoM7Ckdqv23Rur2pShWRAnwbJvABLp7S+C6jk4lpdmC0XHP46FIj4RAPTq7RJiWK0WWS o7VtO4q+wd/jBH+m7b/rDMNv1KnOetnIDiyXxw6124Exu+W6uDbvF5x8ku0ktyCHVKUo CE0Zm5W+AXxBACIYwinH7ozjT9puDEh2VFIL82MUVjcxnYKujURYsqDmFyunVC08V0i1 Y/8tphlHWWiWg0Zk8u5/Aqi8to2fepR7iEKSF2old34iBD5PNhlE4WrqHRrvDYwEWU7s TYPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=cQk/x+AIffjZs0Qf2lqhZSuTnGQ87wOCv1fbuhTicYI=; b=r6Abf9mw3xVjnYwWEHA7d593g+jhZliRieLsBtiMF7cJ9Alm8Ikr0+Sc8/eYduP97o ztLpADTTj9IBzbXntv5bEQN/ROFbXkaWK4gcgYnjf4BP8HfwInPdU1u3IBlCRXrR5qgQ 8nQL94HCRShKz6y64B7CsgyLt+EaXAzQdBqm43oqGvKOvfTzSSC1jJmOx2TVxMvu9nBx d3Ly9Vnw9o2ncIhvoPXKhf/LKOo7vxPefu8Qc0Fn8o856EPnpItHzK5BLaEzzXECZluI 8SMWuQq3CpKjhYjh9k2djAF0wNVQWjE3voNk3ut33+INDhyEf7YixONWruNtm2nKBM0u tCqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id m58si11350635qtb.280.2018.11.15.00.54.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:54:08 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B9F7C04959E; Thu, 15 Nov 2018 08:54:07 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0A396015E; Thu, 15 Nov 2018 08:53:51 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 02/19] block: introduce bio_for_each_bvec() Date: Thu, 15 Nov 2018 16:52:49 +0800 Message-Id: <20181115085306.9910-3-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 15 Nov 2018 08:54:07 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This helper is used for iterating over multi-page bvec for bio split & merge code. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- include/linux/bio.h | 34 +++++++++++++++++++++++++++++++--- include/linux/bvec.h | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 056fb627edb3..1f0dcf109841 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -76,6 +76,9 @@ #define bio_data_dir(bio) \ (op_is_write(bio_op(bio)) ? WRITE : READ) +#define bio_iter_mp_iovec(bio, iter) \ + mp_bvec_iter_bvec((bio)->bi_io_vec, (iter)) + /* * Check whether this bio carries any data or not. A NULL bio is allowed. */ @@ -135,18 +138,33 @@ static inline bool bio_full(struct bio *bio) #define bio_for_each_segment_all(bvl, bio, i) \ for (i = 0, bvl = (bio)->bi_io_vec; i < (bio)->bi_vcnt; i++, bvl++) -static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, - unsigned bytes) +static inline void __bio_advance_iter(struct bio *bio, struct bvec_iter *iter, + unsigned bytes, bool mp) { iter->bi_sector += bytes >> 9; if (bio_no_advance_iter(bio)) iter->bi_size -= bytes; else - bvec_iter_advance(bio->bi_io_vec, iter, bytes); + if (!mp) + bvec_iter_advance(bio->bi_io_vec, iter, bytes); + else + mp_bvec_iter_advance(bio->bi_io_vec, iter, bytes); /* TODO: It is reasonable to complete bio with error here. */ } +static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, + unsigned bytes) +{ + __bio_advance_iter(bio, iter, bytes, false); +} + +static inline void bio_advance_mp_iter(struct bio *bio, struct bvec_iter *iter, + unsigned bytes) +{ + __bio_advance_iter(bio, iter, bytes, true); +} + #define __bio_for_each_segment(bvl, bio, iter, start) \ for (iter = (start); \ (iter).bi_size && \ @@ -156,6 +174,16 @@ static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, #define bio_for_each_segment(bvl, bio, iter) \ __bio_for_each_segment(bvl, bio, iter, (bio)->bi_iter) +#define __bio_for_each_bvec(bvl, bio, iter, start) \ + for (iter = (start); \ + (iter).bi_size && \ + ((bvl = bio_iter_mp_iovec((bio), (iter))), 1); \ + bio_advance_mp_iter((bio), &(iter), (bvl).bv_len)) + +/* returns one real segment(multipage bvec) each time */ +#define bio_for_each_bvec(bvl, bio, iter) \ + __bio_for_each_bvec(bvl, bio, iter, (bio)->bi_iter) + #define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len) static inline unsigned bio_segments(struct bio *bio) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 8ef904a50577..3d61352cd8cf 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -124,8 +124,16 @@ struct bvec_iter { .bv_offset = bvec_iter_offset((bvec), (iter)), \ }) -static inline bool bvec_iter_advance(const struct bio_vec *bv, - struct bvec_iter *iter, unsigned bytes) +#define mp_bvec_iter_bvec(bvec, iter) \ +((struct bio_vec) { \ + .bv_page = mp_bvec_iter_page((bvec), (iter)), \ + .bv_len = mp_bvec_iter_len((bvec), (iter)), \ + .bv_offset = mp_bvec_iter_offset((bvec), (iter)), \ +}) + +static inline bool __bvec_iter_advance(const struct bio_vec *bv, + struct bvec_iter *iter, + unsigned bytes, bool mp) { if (WARN_ONCE(bytes > iter->bi_size, "Attempted to advance past end of bvec iter\n")) { @@ -134,8 +142,14 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, } while (bytes) { - unsigned iter_len = bvec_iter_len(bv, *iter); - unsigned len = min(bytes, iter_len); + unsigned len; + + if (mp) + len = mp_bvec_iter_len(bv, *iter); + else + len = bvec_iter_len(bv, *iter); + + len = min(bytes, len); bytes -= len; iter->bi_size -= len; @@ -173,6 +187,20 @@ static inline bool bvec_iter_rewind(const struct bio_vec *bv, return true; } +static inline bool bvec_iter_advance(const struct bio_vec *bv, + struct bvec_iter *iter, + unsigned bytes) +{ + return __bvec_iter_advance(bv, iter, bytes, false); +} + +static inline bool mp_bvec_iter_advance(const struct bio_vec *bv, + struct bvec_iter *iter, + unsigned bytes) +{ + return __bvec_iter_advance(bv, iter, bytes, true); +} + #define for_each_bvec(bvl, bio_vec, iter, start) \ for (iter = (start); \ (iter).bi_size && \ From patchwork Thu Nov 15 08:52:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E68A17F3 for ; Thu, 15 Nov 2018 08:54:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F57F29B7E for ; Thu, 15 Nov 2018 08:54:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 820412B678; Thu, 15 Nov 2018 08:54:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D072E29B7E for ; Thu, 15 Nov 2018 08:54:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE86B6B0271; Thu, 15 Nov 2018 03:54:13 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DBEB96B0272; Thu, 15 Nov 2018 03:54:13 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD4FA6B0273; Thu, 15 Nov 2018 03:54:13 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 9F8C86B0271 for ; Thu, 15 Nov 2018 03:54:13 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id d196so43704414qkb.6 for ; Thu, 15 Nov 2018 00:54:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=KtxO1h8lTIMO6x3g4219zciNDYDpEDTAic2TXSE5EAk=; b=d5eaA57MjGHZi0cKlXdfYnnN5rkr/4ffZGjRt9Z4WxYX7Du49zxrx85l+8NBIiiSrr 7bgQrjaF+lr+fBksUimkYu0FKZ4qzKZ9MV1lFR/t3vc9HyX6gR75imt7qujQzny+Rzpb 7UBxFnb3PoxZmKAimst0BCE4GtphJXQMng/Y9kNGxdC+BRZ9Ti7aGJhn2kgpKhfIHo1T 2VMjrXVhO/25QdgFNK5Izw/SzlgfN7bVO+6LJT12V8/9qTJbLAdpS2NurXNm7wsmO1Xp RgKq5tNEqu7I2n36AX5fM6g7z8CXKvW0DM11YeHJiokR5GzQoU1eAvoN4MzFI/83FF6/ s49w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gKtkTlpQHE4Hkg6dg9wMUSrIiDn31h2IUUpRf2fNRZRKWmcEL/1 vygF/dqR5ekNqBpGcIbYntKRqcqtkahdpHVp2n5ZlXRV1Rd4Vb/fN5uVo1LRqaVppH9/DvIR0Cg W7Hh16kQMtVY3w9j4Hc9AQug/caPHzlzljPrM/gNpIzPCycIUmggqLiNxYFQtpN2xQQ== X-Received: by 2002:a37:474b:: with SMTP id u72mr5049503qka.106.1542272053376; Thu, 15 Nov 2018 00:54:13 -0800 (PST) X-Google-Smtp-Source: AJdET5dUgkN4CK0ngj1tH9/gmNkJr9CZmwUftur9ifE+1QzPhLvSAxYisFRnlTvcMDCBrOjlnXGO X-Received: by 2002:a37:474b:: with SMTP id u72mr5049479qka.106.1542272052773; Thu, 15 Nov 2018 00:54:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272052; cv=none; d=google.com; s=arc-20160816; b=c0v9la/HkzOaPaWOS2CQoWSqqWiQyAwvexwUYH8k/zbBh11wrQoCNY4bjdGRP2hRrb zEJ2eqTKjOTkzdFK0nzlQJi+La7e40G1gZOPf+wdMfxIsesLzsAnaVlP34H0KJB3IVjH bNMQyE7do24EESX4cq5Nad7kyqeSSHfQBfb8BjWYFkogCybJSxPG201TFy9oHQ0cgU8v b5GBV2QMUCudixo/HPlw3b7l2YJx/uGoLr5VNdhyaW0Qe9CxR2Ow6EXcHDn2won4KuZK KTwmnslZuGPoSZH3ahrVu1hMFRc7eaURYC3EojEg2Vr01d7LdtBRqDnNzzLS7RADly7Z OlVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=KtxO1h8lTIMO6x3g4219zciNDYDpEDTAic2TXSE5EAk=; b=Jmde5F6TkTK6R/R8rmgmxmP9sHO7iy7Hp3+xx+eCXDwbMgvQv2rw98nvKsGzL/WJSs mvvse0xdOBH44XZDnnCxFhUNFbUuXGM9KwL+rDcoT/cWKDJI+PIuB4gAeOwgaICTVOyz UpJvGQlnuAkIPxRCGC8+fLvYHJfJI3VzZsFhDHFvC97I4N90Gulasah2ythJmHWa2RMr 8zNODblPmEyfJ1aRBFynjYxR6CIHqJ8pFr0gYFdZ0wb6MJf3/l3sGn/ZQFLZUbeljFbV tbU+sZ9dot6Q6LXW7pFIM0aJuena6C46roRRezm6SleI1ixBCCoqyr3x2JOAOrj9pmOX iykQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id n69si11784014qkn.55.2018.11.15.00.54.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:54:12 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5067AA4051; Thu, 15 Nov 2018 08:54:11 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 738D6600C3; Thu, 15 Nov 2018 08:54:09 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 03/19] block: use bio_for_each_bvec() to compute multi-page bvec count Date: Thu, 15 Nov 2018 16:52:50 +0800 Message-Id: <20181115085306.9910-4-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 15 Nov 2018 08:54:11 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP First it is more efficient to use bio_for_each_bvec() in both blk_bio_segment_split() and __blk_recalc_rq_segments() to compute how many multi-page bvecs there are in the bio. Secondly once bio_for_each_bvec() is used, the bvec may need to be splitted because its length can be very longer than max segment size, so we have to split the big bvec into several segments. Thirdly when splitting multi-page bvec into segments, the max segment limit may be reached, so the bio split need to be considered under this situation too. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei --- block/blk-merge.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 14 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 91b2af332a84..6f7deb94a23f 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -160,6 +160,62 @@ static inline unsigned get_max_io_size(struct request_queue *q, return sectors; } +/* + * Split the bvec @bv into segments, and update all kinds of + * variables. + */ +static bool bvec_split_segs(struct request_queue *q, struct bio_vec *bv, + unsigned *nsegs, unsigned *last_seg_size, + unsigned *front_seg_size, unsigned *sectors) +{ + bool need_split = false; + unsigned len = bv->bv_len; + unsigned total_len = 0; + unsigned new_nsegs = 0, seg_size = 0; + + if ((*nsegs >= queue_max_segments(q)) || !len) + return need_split; + + /* + * Multipage bvec may be too big to hold in one segment, + * so the current bvec has to be splitted as multiple + * segments. + */ + while (new_nsegs + *nsegs < queue_max_segments(q)) { + seg_size = min(queue_max_segment_size(q), len); + + new_nsegs++; + total_len += seg_size; + len -= seg_size; + + if ((queue_virt_boundary(q) && ((bv->bv_offset + + total_len) & queue_virt_boundary(q))) || !len) + break; + } + + /* split in the middle of the bvec */ + if (len) + need_split = true; + + /* update front segment size */ + if (!*nsegs) { + unsigned first_seg_size = seg_size; + + if (new_nsegs > 1) + first_seg_size = queue_max_segment_size(q); + if (*front_seg_size < first_seg_size) + *front_seg_size = first_seg_size; + } + + /* update other varibles */ + *last_seg_size = seg_size; + *nsegs += new_nsegs; + if (sectors) + *sectors += total_len >> 9; + + return need_split; +} + static struct bio *blk_bio_segment_split(struct request_queue *q, struct bio *bio, struct bio_set *bs, @@ -173,7 +229,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, struct bio *new = NULL; const unsigned max_sectors = get_max_io_size(q, bio); - bio_for_each_segment(bv, bio, iter) { + bio_for_each_bvec(bv, bio, iter) { /* * If the queue doesn't support SG gaps and adding this * offset would create a gap, disallow it. @@ -188,8 +244,12 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, */ if (nsegs < queue_max_segments(q) && sectors < max_sectors) { - nsegs++; - sectors = max_sectors; + /* split in the middle of bvec */ + bv.bv_len = (max_sectors - sectors) << 9; + bvec_split_segs(q, &bv, &nsegs, + &seg_size, + &front_seg_size, + §ors); } goto split; } @@ -214,11 +274,12 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, if (nsegs == 1 && seg_size > front_seg_size) front_seg_size = seg_size; - nsegs++; bvprv = bv; bvprvp = &bvprv; - seg_size = bv.bv_len; - sectors += bv.bv_len >> 9; + + if (bvec_split_segs(q, &bv, &nsegs, &seg_size, + &front_seg_size, §ors)) + goto split; } @@ -296,6 +357,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, struct bio_vec bv, bvprv = { NULL }; int cluster, prev = 0; unsigned int seg_size, nr_phys_segs; + unsigned front_seg_size = bio->bi_seg_front_size; struct bio *fbio, *bbio; struct bvec_iter iter; @@ -316,7 +378,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, seg_size = 0; nr_phys_segs = 0; for_each_bio(bio) { - bio_for_each_segment(bv, bio, iter) { + bio_for_each_bvec(bv, bio, iter) { /* * If SG merging is disabled, each bio vector is * a segment @@ -336,20 +398,20 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, continue; } new_segment: - if (nr_phys_segs == 1 && seg_size > - fbio->bi_seg_front_size) - fbio->bi_seg_front_size = seg_size; + if (nr_phys_segs == 1 && seg_size > front_seg_size) + front_seg_size = seg_size; - nr_phys_segs++; bvprv = bv; prev = 1; - seg_size = bv.bv_len; + bvec_split_segs(q, &bv, &nr_phys_segs, &seg_size, + &front_seg_size, NULL); } bbio = bio; } - if (nr_phys_segs == 1 && seg_size > fbio->bi_seg_front_size) - fbio->bi_seg_front_size = seg_size; + if (nr_phys_segs == 1 && seg_size > front_seg_size) + front_seg_size = seg_size; + fbio->bi_seg_front_size = front_seg_size; if (seg_size > bbio->bi_seg_back_size) bbio->bi_seg_back_size = seg_size; From patchwork Thu Nov 15 08:52:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7227814D6 for ; Thu, 15 Nov 2018 08:54:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 615DA29B7E for ; Thu, 15 Nov 2018 08:54:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5317B2B678; Thu, 15 Nov 2018 08:54:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2C10299C2 for ; Thu, 15 Nov 2018 08:54:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAEFE6B0273; Thu, 15 Nov 2018 03:54:26 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C84C56B0274; Thu, 15 Nov 2018 03:54:26 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B755B6B0275; Thu, 15 Nov 2018 03:54:26 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 8F1436B0273 for ; Thu, 15 Nov 2018 03:54:26 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id z68so19249514qkb.14 for ; Thu, 15 Nov 2018 00:54:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=UAC3xfu38p9M5OE/1aJqJB2xtFYtd9P0GOC7iU0x+2Q=; b=jUIWN7H5OWXaZZTahXKK0Js5a89PucnFAgzBREkax0fON1aMYIeeO8QCsmCy4j/vK1 AohcYjZ345rfhLVlkEJV2E0yN/sv0qzOTn6G94LGp7Ht7CVkfscmZqlg+pl3mWzo6/kO PN72ggOl7cvyVVc/JXHptG7CVOqvD2k2Mt6tDWptgDOsuyxN0Fn0G1iwTZ5ie/wJKpmi y1g3HEFipLO+Fmpvwb6mwJhzNvViiZ5RmSx9KuAf7Gvqh+zgHAh7BXsBhp0a1GnYpOZy R3VgwDh9kp5SzkK0L7VktLwOqIONvu+2rL52qkwIc1Rg86Xw1iQRNwzBS7w/j+n5eQ6b 2gAQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gJ71J5VSJ5EscMdSVsXE2MrfXqqvkAa9gxFEEOPTbBic2DgP3qz BVkk8QWLUc7YkNb07mOCcmYx6hti68evjHLTuHtlC86xBk7hnPGBaB5BzIA9yqweKK/4TWXOARn rKQrv0TF6MDKnENHnSocUo7P09jaOpLcr/7Kbsw7aaIQ0KF6kqMsNUK8g9nl5lW3xJQ== X-Received: by 2002:ac8:748:: with SMTP id k8mr5064753qth.235.1542272066334; Thu, 15 Nov 2018 00:54:26 -0800 (PST) X-Google-Smtp-Source: AJdET5fD95U46OXgRf04fupUL+dMa5HBmlzinxkxWjX4r7pWZYK6pLvOcp1D+plSDkkZNm7dULTL X-Received: by 2002:ac8:748:: with SMTP id k8mr5064732qth.235.1542272065769; Thu, 15 Nov 2018 00:54:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272065; cv=none; d=google.com; s=arc-20160816; b=dAZte4I5BFAW0V6XWbIJ/Ek6JAeXykdGWv9XeM55RR6cgykgE2AnXtRRjBtjY0jhhk s56q1qPXmoUpxEs3e3Vf7W25p0jeQAAoK/Ce3AEL24b7LjjM8fMods0XKz5LDrHiW+jg JcU2WHZt0gq2i+JhCBuntEtm6+QvjuonHDb24tiLXUtthY+oazVtOygcn7FuZ3jVihD8 SuvThkdTjp+D+8k7XsSqWflESOhnoVg3WmvzOAXhDQrv8zt30R99g6QbBdPCURZXaK1u zRgZ9ccq+eG96M65Erd8mdZUe0qoO+XeTKyMygOMQMHMPnfOQIwqmJ+axnCvHW4oayms AAOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=UAC3xfu38p9M5OE/1aJqJB2xtFYtd9P0GOC7iU0x+2Q=; b=fRmTS+OQ7UpA2YcKVqaAO45KlQJjg5lYfs4Yfg+uFbk5UGj0eiPcZ8H/ybxOkp0Cbd uL9QGeCkrIyav6Kb8Ys7xLspwpIY3yfnNX9WSU36yI/oV1o8tqNW+HYkKVjzjra3Y/Vf AOeuRtANcwWe5/Y+nna4hUIb5ZndWdz3NLEExL0jKJPoyoZp3BrinQbNlOjV1t95oo4S TBZJ28QEcLVg6BMdFsbEIzH8Rdum8aJ1L3+h+YSRiJzU6L3BZp/h7+qMuwJYDP1s2x2F ZL7gppD0g+sz3o0F8zgdgzYy1X4RsBh70dxd+6xpZJnDiKOeQpglxlZLwrRv8hGbkww2 TpJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 36si278339qta.249.2018.11.15.00.54.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:54:25 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 980BA30024FC; Thu, 15 Nov 2018 08:54:24 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B4F55D739; Thu, 15 Nov 2018 08:54:13 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 04/19] block: use bio_for_each_bvec() to map sg Date: Thu, 15 Nov 2018 16:52:51 +0800 Message-Id: <20181115085306.9910-5-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 15 Nov 2018 08:54:24 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It is more efficient to use bio_for_each_bvec() to map sg, meantime we have to consider splitting multipage bvec as done in blk_bio_segment_split(). Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- block/blk-merge.c | 72 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 6f7deb94a23f..cb9f49bcfd36 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -473,6 +473,56 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, return biovec_phys_mergeable(q, &end_bv, &nxt_bv); } +static struct scatterlist *blk_next_sg(struct scatterlist **sg, + struct scatterlist *sglist) +{ + if (!*sg) + return sglist; + else { + /* + * If the driver previously mapped a shorter + * list, we could see a termination bit + * prematurely unless it fully inits the sg + * table on each mapping. We KNOW that there + * must be more entries here or the driver + * would be buggy, so force clear the + * termination bit to avoid doing a full + * sg_init_table() in drivers for each command. + */ + sg_unmark_end(*sg); + return sg_next(*sg); + } +} + +static unsigned blk_bvec_map_sg(struct request_queue *q, + struct bio_vec *bvec, struct scatterlist *sglist, + struct scatterlist **sg) +{ + unsigned nbytes = bvec->bv_len; + unsigned nsegs = 0, total = 0; + + while (nbytes > 0) { + unsigned seg_size; + struct page *pg; + unsigned offset, idx; + + *sg = blk_next_sg(sg, sglist); + + seg_size = min(nbytes, queue_max_segment_size(q)); + offset = (total + bvec->bv_offset) % PAGE_SIZE; + idx = (total + bvec->bv_offset) / PAGE_SIZE; + pg = nth_page(bvec->bv_page, idx); + + sg_set_page(*sg, pg, seg_size, offset); + + total += seg_size; + nbytes -= seg_size; + nsegs++; + } + + return nsegs; +} + static inline void __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec, struct scatterlist *sglist, struct bio_vec *bvprv, @@ -490,25 +540,7 @@ __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec, (*sg)->length += nbytes; } else { new_segment: - if (!*sg) - *sg = sglist; - else { - /* - * If the driver previously mapped a shorter - * list, we could see a termination bit - * prematurely unless it fully inits the sg - * table on each mapping. We KNOW that there - * must be more entries here or the driver - * would be buggy, so force clear the - * termination bit to avoid doing a full - * sg_init_table() in drivers for each command. - */ - sg_unmark_end(*sg); - *sg = sg_next(*sg); - } - - sg_set_page(*sg, bvec->bv_page, nbytes, bvec->bv_offset); - (*nsegs)++; + (*nsegs) += blk_bvec_map_sg(q, bvec, sglist, sg); } *bvprv = *bvec; } @@ -530,7 +562,7 @@ static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, int cluster = blk_queue_cluster(q), nsegs = 0; for_each_bio(bio) - bio_for_each_segment(bvec, bio, iter) + bio_for_each_bvec(bvec, bio, iter) __blk_segment_map_sg(q, &bvec, sglist, &bvprv, sg, &nsegs, &cluster); From patchwork Thu Nov 15 08:52:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9571114D6 for ; Thu, 15 Nov 2018 08:54:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 860C5299C2 for ; Thu, 15 Nov 2018 08:54:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79E7D2ACBC; Thu, 15 Nov 2018 08:54:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DDB129B7E for ; Thu, 15 Nov 2018 08:54:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 582556B0275; Thu, 15 Nov 2018 03:54:43 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 532AD6B0276; Thu, 15 Nov 2018 03:54:43 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 449066B0277; Thu, 15 Nov 2018 03:54:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 1B6716B0275 for ; Thu, 15 Nov 2018 03:54:43 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id a199so43307672qkb.23 for ; Thu, 15 Nov 2018 00:54:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=CjGkhGQ3mjObcZSlpfeHqGI+rxG1OBhrlzbMY/mtO8E=; b=TwoRnc/Uv0c5YtTq3/1yjEns+2HOA6KfvfTmZHnoevC2hwbWX1Bmc1yr+idjz9tPt+ DrZqy/gQo2Dm9MBobu4XHv+BP3KjfdsfTJxbCHkCAvVGEto2UE6mNzI5fUGDqazQQwRj dG6IFJyXXZPJT91bId9xp45vxA1MjUAy8auJCb7jAaHeMrg1rkzdYMl4mCRcrQ77qG30 xDwvgkO9ek+eysyeSZee5R+MHmAw8CW0yT5yH1eOaJajPrIWYp6Ra9j6vqpnVcYY8v57 kBxZRn116Wn+jqQzjrcZps7PhSWjW92DD89B6YymKnq5ocRU+I1kWW5CYxPNL0+gYvkn eW9Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gJj9EkAr+HhObzGYQTtseDg15f45JJmK7L9D8gHFaMvVZH2Vm83 CZv+kBBctFfSR8JRSh3aaG1q91fb4m1Dcz+7Y0YNjRPCdt9kNsWkU6Eqs225duPlnvekEgeThZO o/LY48RiXLKClrm66Ry2Pi8aBmHOJxSW1jFedkQxZxPqspkFHIydLcvEL3q1tynxQQg== X-Received: by 2002:ac8:593:: with SMTP id a19mr4995382qth.111.1542272082894; Thu, 15 Nov 2018 00:54:42 -0800 (PST) X-Google-Smtp-Source: AJdET5doPPx7OejBe04FGnQ/vdkOGH5aFxNtlwD0z8TzHjmgya7ZJqDkdpdt0DugmqG6ykegdDeB X-Received: by 2002:ac8:593:: with SMTP id a19mr4995360qth.111.1542272082376; Thu, 15 Nov 2018 00:54:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272082; cv=none; d=google.com; s=arc-20160816; b=wqKWOQcg387VcHBtrbwILMdtkkGX59p5gv98IzuzXEmBWSE2q/1wqaGDuv8ZMmW7+6 gcgugigWHes0Ei72Dn1Efu1+IiR3sEQPuuFHZcpT7NjaUeSXoyid6X3K3X3TU7+ZbERV tSJaaSUGGjHk5I8LqmD0h55pSNdiR43cmL+WeyKMY4/uNH0WVoBZyI0aGaTVD1ljUJWg Ic0bAoIuxnLr5uyzt6q0l7SAoqv8rJORUAzPVsyo/dxXgvYicEZCt2aVzRp72TYBqH1m eLZ9Od7wTwFxy3m2coR/M3Kx63x7dQUArywDfeeF7EfhFUUYTWS1N9335pWeplUccron Yu6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=CjGkhGQ3mjObcZSlpfeHqGI+rxG1OBhrlzbMY/mtO8E=; b=oL5twdlFkGakDgkJHIP129AOORGC4Xq58LNS5Tntv04GqVlAugGO35SZR+SBCZb75n nNsJDmyj86zTAM18nwueNQiaQcwK5awoBzn5n1s+KH3Ljvw2QHEPifmiOc/ac7AGjR7h nWCym0Fuj+LqpWTAK3fZ3GON4uE9xRtgiUubePXvB9BoAVEN1UAnZxIgwpaGKAimwknz 983Os2AeLoo3H5zbbKkb4T/dcs4/GxKpB9gsucGCn1hSCCFOKNOfp9I/e8r8MjOGHN7e KX+1hqhl72kCDOP6oVVrEYE8SKyC8C1BVYj9HceEdxZD6tkj+HOAZGmKJgbHR+5ucCKG TYCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id v8si263689qkb.11.2018.11.15.00.54.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:54:42 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C14ABDE1; Thu, 15 Nov 2018 08:54:41 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id C235C1019638; Thu, 15 Nov 2018 08:54:26 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 05/19] block: introduce bvec_last_segment() Date: Thu, 15 Nov 2018 16:52:52 +0800 Message-Id: <20181115085306.9910-6-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 15 Nov 2018 08:54:41 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP BTRFS and guard_bio_eod() need to get the last singlepage segment from one multipage bvec, so introduce this helper to make them happy. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- include/linux/bvec.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 3d61352cd8cf..01616a0b6220 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -216,4 +216,29 @@ static inline bool mp_bvec_iter_advance(const struct bio_vec *bv, .bi_bvec_done = 0, \ } +/* + * Get the last singlepage segment from the multipage bvec and store it + * in @seg + */ +static inline void bvec_last_segment(const struct bio_vec *bvec, + struct bio_vec *seg) +{ + unsigned total = bvec->bv_offset + bvec->bv_len; + unsigned last_page = total / PAGE_SIZE; + + if (last_page * PAGE_SIZE == total) + last_page--; + + seg->bv_page = nth_page(bvec->bv_page, last_page); + + /* the whole segment is inside the last page */ + if (bvec->bv_offset >= last_page * PAGE_SIZE) { + seg->bv_offset = bvec->bv_offset % PAGE_SIZE; + seg->bv_len = bvec->bv_len; + } else { + seg->bv_offset = 0; + seg->bv_len = total - last_page * PAGE_SIZE; + } +} + #endif /* __LINUX_BVEC_ITER_H */ From patchwork Thu Nov 15 08:52:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E65F814BA for ; Thu, 15 Nov 2018 08:55:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D671E299C2 for ; Thu, 15 Nov 2018 08:55:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6DD92ACBC; Thu, 15 Nov 2018 08:55:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C842299C2 for ; Thu, 15 Nov 2018 08:55:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 646416B0277; Thu, 15 Nov 2018 03:55:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 61BC56B0278; Thu, 15 Nov 2018 03:55:00 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 532666B0279; Thu, 15 Nov 2018 03:55:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 26C406B0277 for ; Thu, 15 Nov 2018 03:55:00 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id n68so43129068qkn.8 for ; Thu, 15 Nov 2018 00:55:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=lGLdQmCulR8OC8y0KcHKnMxgou6Piswucg/kiYcQVp8=; b=BWCRd9hMMeYU+VSuryberdAA22DGcop15e+gAUxC3mp3ZYVWu95svX89O9oeof/MRO sbzw+cRvqT7tvMyRTTlFxKrb9SU3s5RrlbicCg9cwyTt6Ck21f+pV4khl54cRIkxR5Ux VJNTwxSoWjUJqUcvd15RHz1K4ZSf8eVOE2pnywviXhs9SgMgzT81shaWAsQKf1Lz+6H4 X17YmRMmoG/JOvnd01P3tCDCqErIGRFRKAk4oPtMcGwZgLBHiqhY2SMVrhGHNQj8IQIz /7JfXhko7uFxzdtNwigrmR7KxMelO1SzvLNdmre1aq6u8VgJHB4z9QvlaxPqshZ/cOWI iJkA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gLg/JSCPgRiQaIxVgbs+pVJUaWzIR57ue0qv09ehUqFkjSjACIf tfDC0T2AG9kdeMPme+5n6HNqWsD5jNKaq12B875Ppy5b5Nv3O5YGu4pBkRSwpQhCp2rNSyL0AvP as7Y7dzc+udtI5VNDeLOWocjnfKUaYdlf7+lzdTeXMtxJ+h/Nw3BCe8PsZ7ok1HPDnA== X-Received: by 2002:a37:9d15:: with SMTP id g21mr5032234qke.171.1542272099862; Thu, 15 Nov 2018 00:54:59 -0800 (PST) X-Google-Smtp-Source: AJdET5fHi2KRC8CHf/H/qxeTYtwVlRoDDc40fVJbij/RGRqfg+fzPmIWh2nl/mH08pJxO0zvszV3 X-Received: by 2002:a37:9d15:: with SMTP id g21mr5032220qke.171.1542272099356; Thu, 15 Nov 2018 00:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272099; cv=none; d=google.com; s=arc-20160816; b=Va8XDxKddLMtkpJeRIToQ7qABDfwkigkPIihSldMuEm8VEyGz1F6cb9E7eJd9GCVCr R7rU2/m4lypgyGcYslJRL5ayu9TISLGUgzgOmEIP4ayYDeLX6mtDqx9dWA7nWr4g9hhU QFkvOLnk0fKXFGqfGZsNMWy+IHAw8Dr8K4Whl3+V64ozMg97fd2sidnCgKZ5hdM2NXrJ PFZstnggrN656hnQdNWv1fjMYeBLYkBzFbmUU5R6tdu2u9U/jyW3VZN5L3sALIIP3tOk FxRsTopEjFHw35muUSwnzG/QUVxEHqHED7kqEB8PwjuVQIiJj4ZZRvtZwncyDmsfiW1q NQ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=lGLdQmCulR8OC8y0KcHKnMxgou6Piswucg/kiYcQVp8=; b=wOkxHACFYWRcOzKGAaXlDgBt2jiP2kwX8BnXY69aKGnRXCCoZsCLjNkruRO8yNKKvS xyW1c0pEWqHG4zpOh9IRPXshpLfaQhY7fHOCNsjQXNor9SGKGgvKal576aTYJN+JHsBb QVhNYdDXfGf/8LTmHHXONDbd/0BSZ5orlV64Cc0smsFuzoXucKoL4jxvMkix6gJYuB/U vlCiANA72UCa1luFMpnsA1L+F/k8jn5cjHYv5hjG/X86IP6qxOY16i2RafO6MUNmY1Ie lEhQPhpQU2RcDmInnzIeSO9Wj9tpFJAtIgj5LNfMcTk+hhHxnjM02d4B8P+aHarKrjRv mr6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id f70si4753493qke.10.2018.11.15.00.54.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:54:59 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52302307D86D; Thu, 15 Nov 2018 08:54:58 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18B515D75C; Thu, 15 Nov 2018 08:54:43 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 06/19] fs/buffer.c: use bvec iterator to truncate the bio Date: Thu, 15 Nov 2018 16:52:53 +0800 Message-Id: <20181115085306.9910-7-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 15 Nov 2018 08:54:58 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Once multi-page bvec is enabled, the last bvec may include more than one page, this patch use bvec_last_segment() to truncate the bio. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig --- fs/buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 1286c2b95498..fa37ad52e962 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3032,7 +3032,10 @@ void guard_bio_eod(int op, struct bio *bio) /* ..and clear the end of the buffer for reads */ if (op == REQ_OP_READ) { - zero_user(bvec->bv_page, bvec->bv_offset + bvec->bv_len, + struct bio_vec bv; + + bvec_last_segment(bvec, &bv); + zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, truncated_bytes); } } From patchwork Thu Nov 15 08:52:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BACEA14D6 for ; Thu, 15 Nov 2018 08:55:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB571299C2 for ; Thu, 15 Nov 2018 08:55:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F4DA2B678; Thu, 15 Nov 2018 08:55:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16DD9299C2 for ; Thu, 15 Nov 2018 08:55:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 421086B0279; Thu, 15 Nov 2018 03:55:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3D2C46B027A; Thu, 15 Nov 2018 03:55:19 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2ADDB6B027B; Thu, 15 Nov 2018 03:55:19 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id F2C2C6B0279 for ; Thu, 15 Nov 2018 03:55:18 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id k203so43875480qke.2 for ; Thu, 15 Nov 2018 00:55:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=sksoPAoBobrodaqFaviy7ZtyOdLgNXqBU8Jp1HYMzKA=; b=pDYXqtPmS0Tw+2Px8r0ZtzbJ0d9s+uycLJ+5UbODjRK3GLijAYkBRTSm8zwzS81IQ3 Z5hO0l4QgNKv+bKom2SVw5XkktHXUFmuTyL8R7jpkCBEc+Qkl2MdFci30u9utRvzv9im 6tHHpHolYhZsoml6xsFtLBI2bSwpo6xqbjxzjM1pVWAfbAij7ud0P0vomR5rBET1kulj g2OwfuQ5qgPXINwcGjbqnSh52+FrIIR7VSkO98P+kS5S/z5mFcGkVrYkCgLGw2tX9UzD OCS16DEXNZijc/ffTTOugDcXbbgjlFAYP8KIOlX1I6mc0c2Xa1ILp0a3aYzwNhjNX9yA tncQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gKkpXFC89T44aHA+s9oRFadyB1JlKuLHkKg4vocQVYfgGjY73W5 XkPNrya3xmJ9gQCrABlnhH+p5ixBSxPaWXIKS/uxRyBME8+Zsp7b0CNEyDlNm0FggZOg/9+U/N4 0pp3k2IqKvMpFbmoP2+5y+A5pt/EqOaj+TVq6xRZDU1HYtf/ll3YM4njhpKI+L3H7Ig== X-Received: by 2002:a0c:c350:: with SMTP id j16mr5333138qvi.201.1542272118772; Thu, 15 Nov 2018 00:55:18 -0800 (PST) X-Google-Smtp-Source: AJdET5dAIWfNWQOnomp5gLpOJjW8tcT5T6VJxSenyyNhtnqqx1YYybSMdAJCk8M27znkZQqQASlL X-Received: by 2002:a0c:c350:: with SMTP id j16mr5333122qvi.201.1542272118276; Thu, 15 Nov 2018 00:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272118; cv=none; d=google.com; s=arc-20160816; b=wZd+DaeVWBseUHBbL4OWcoD0xAMJSU3MR3D4gw5vT4dVjUSbP/2C/VskShWw9E+ESD i2Vz1ZJ5GUykjTxMKH/LE4MGpEVHPSFriYAY4pVWLwWK/h/6MWcKWf5iJBnaHDgQnUKT r7CNfTazJO74WpLQ6YS5EQi2pQKRjPXpN8Z4kVzEMgZGYJxhHQoMz6mTORDmOZ1t6O/g hAwJBS5vLPQL6CM7/uyERo7zi43O4ndAz4ij/O9hXL9JclK8GoQWwlXHRjzsTFj/t5fS kUVdGZuCD4imWAC/cRwlAj9F0/FvL6x7zcMPjIdpXF2pEgv9z5iykD+efEocIXvwvtlI fT3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=sksoPAoBobrodaqFaviy7ZtyOdLgNXqBU8Jp1HYMzKA=; b=YD3pKNuVcZ/ajeGsp/c6/lhGtw0bd5qRszpRA1bnUjKqb7S4CUA+atYKcjIMik2tXE 9lOWtFwE6D0vnEKVJHPvs57M5S787gsleqVJsROPTy4Cwajz9ecBwPcY42WvGAjQ/MYE v5mEpHu6TCepf761PcFqut3APtoUugzboa8P1T44RneGIgY41CDZLBIOhr+5Hluf3zB8 oq5muJtYtc11UmjvPS+htFEjmXm/UlectzU/n6yjluPoP/B7HWbfebwlrevnPMYrcfTO g/RYLBaqYEO+CEG7XuP+Uo1h44I1OYAAqnVZt6eBbWGuzLfZKa/+2TmAOBjvOSJK/gfY JB3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id t57si291084qtj.158.2018.11.15.00.55.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:55:18 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03E51C045109; Thu, 15 Nov 2018 08:55:17 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D5ED60C7E; Thu, 15 Nov 2018 08:55:00 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 07/19] btrfs: use bvec_last_segment to get bio's last page Date: Thu, 15 Nov 2018 16:52:54 +0800 Message-Id: <20181115085306.9910-8-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 15 Nov 2018 08:55:17 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Preparing for supporting multi-page bvec. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- fs/btrfs/compression.c | 5 ++++- fs/btrfs/extent_io.c | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 2955a4ea2fa8..161e14b8b180 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -400,8 +400,11 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, static u64 bio_end_offset(struct bio *bio) { struct bio_vec *last = bio_last_bvec_all(bio); + struct bio_vec bv; - return page_offset(last->bv_page) + last->bv_len + last->bv_offset; + bvec_last_segment(last, &bv); + + return page_offset(bv.bv_page) + bv.bv_len + bv.bv_offset; } static noinline int add_ra_bio_pages(struct inode *inode, diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index d228f706ff3e..5d5965297e7e 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2720,11 +2720,12 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num, { blk_status_t ret = 0; struct bio_vec *bvec = bio_last_bvec_all(bio); - struct page *page = bvec->bv_page; + struct bio_vec bv; struct extent_io_tree *tree = bio->bi_private; u64 start; - start = page_offset(page) + bvec->bv_offset; + bvec_last_segment(bvec, &bv); + start = page_offset(bv.bv_page) + bv.bv_offset; bio->bi_private = NULL; From patchwork Thu Nov 15 08:52:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F8A814D6 for ; Thu, 15 Nov 2018 08:55:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B3D7299C2 for ; Thu, 15 Nov 2018 08:55:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F41F2B334; Thu, 15 Nov 2018 08:55:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1325299C2 for ; Thu, 15 Nov 2018 08:55:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E350D6B027B; Thu, 15 Nov 2018 03:55:36 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DE3CD6B027C; Thu, 15 Nov 2018 03:55:36 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFAA86B027D; Thu, 15 Nov 2018 03:55:36 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id A2AAE6B027B for ; Thu, 15 Nov 2018 03:55:36 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id s19so43892036qke.20 for ; Thu, 15 Nov 2018 00:55:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=tM2fCUTiqNJ83ZUHUFDg+ZAzp2ZS8MMRbJFFzEGHe40=; b=Iw7PbkiWGyU0aeHq9bnY92+MQP7Ru60MKxfzk/WPanfhTFOuSmAgIldh9fTMS3Nvt6 FG7YzfpfXFDpy645i4DqsGTt2BC5yKfGlDm+i2afp2m1Hb8yLcW1lN5FAIEkIF+zRLZo qjOdaiAA2FM9m6aWha1AOIq1+Xeo5cmumylV6qzmugoBotRNxp8mYlpOo+a7ZnYUzlyr lEb26+V1grUswYxODp1kKj8ofC30KDGYsVb8IkUGFkA6dKqIPA3+OxIUTwSwisADOwQG 5a8evDH7H7/TA5Z2YHILcclXySnjmEJ7Xq6GZRkandRZiHp3wMfmBp7DmX9etdfDWK75 4gsQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gKC9V2EQYZ/2XqQ2tsilELpOAuV9ikxH9Gzhl+qHOmVDXtZSHrK p97xtnG5lGuF+mwIPYdWzFHEPYgGlCUomLcIJyoF/k58wfpkS41pfgw43xA+nn1bVRthUbR+Ivc V1ld8L2n+G1lIUiFVGrEmEXdOjuXwH2S+2luNrkCko5qqaGlvCXmiGavEV93MYjID/w== X-Received: by 2002:a37:7d05:: with SMTP id y5mr4909065qkc.310.1542272136417; Thu, 15 Nov 2018 00:55:36 -0800 (PST) X-Google-Smtp-Source: AJdET5eoyWn5ax+N91csBu0mayQ9DNJrVeb0R2Xxqbdcux0uGdnjRm2N4bkHNz07X4T/MzELE8b7 X-Received: by 2002:a37:7d05:: with SMTP id y5mr4909041qkc.310.1542272135756; Thu, 15 Nov 2018 00:55:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272135; cv=none; d=google.com; s=arc-20160816; b=s7y9R9yR1ZdMEp3MGvsQHSOAsB967IvFKIzgp1IGOUc5xNGiLxlwUMch0FxBqlA486 1fj53qL5N2D3mqD2PSbdoXZ33lebZfp37/sfOb54f9wOoYUomrOoloaPdC7mY2SmYhrH 1ybGCl5ILg3nT1dOxG+2lS/kw1dAhTG8IISEVaRqiprgja1SxZi9Sk68UXjz7BO3rX9n SzMnCexG+TTUEvdwhh2auuUhSyV2xZwcDI4rMHvhBQSiv/Y/FY1ef8NnKPXbJNisMo3d shuRLkDHhBbUbbh/kclpBib4Y+2htIeo/JejedSTY29boEh6uWU7AlKNl/9WmEczmFhK dp2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=tM2fCUTiqNJ83ZUHUFDg+ZAzp2ZS8MMRbJFFzEGHe40=; b=iUN4NEDDgPEorx8o/zwDNPbeWP63dj8snjoQxRoOKljhjPQSsTnlGqHSdSjxXho2sJ sVdWdQz6IooDaXTYHUm2T4i75F/ulCmK9sSl0cPeYZXMvc2nw0lqKsWwv7J+YNKOcRpp JiqdRQe4x27NSCJgLvHewh8N0LAfkqZjwN+Qmkyd1cLu0Fv7dxez5wSNf9SNVtDA+MKv EWbhGyUHwXPAueu6Z1zVgIqP196utyE+zK4Sx4El/WhxgC3KodjWgl5uPqC/ksAOBj3c 0IPcp+p6gOWbEievo5MQAmele2kdpXRjFm3Sd00IiATLHB9Xe/mcwioWxGE95KvlMWgp ruNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id x2si3058711qvp.94.2018.11.15.00.55.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:55:35 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CE7FC072243; Thu, 15 Nov 2018 08:55:34 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F4451A928; Thu, 15 Nov 2018 08:55:19 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 08/19] btrfs: move bio_pages_all() to btrfs Date: Thu, 15 Nov 2018 16:52:55 +0800 Message-Id: <20181115085306.9910-9-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 15 Nov 2018 08:55:35 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP BTRFS is the only user of this helper, so move this helper into BTRFS, and implement it via bio_for_each_segment_all(), since bio->bi_vcnt may not equal to number of pages after multipage bvec is enabled. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei --- fs/btrfs/extent_io.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 5d5965297e7e..874bb9aeebdc 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2348,6 +2348,18 @@ struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio, return bio; } +static unsigned btrfs_bio_pages_all(struct bio *bio) +{ + unsigned i; + struct bio_vec *bv; + + WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); + + bio_for_each_segment_all(bv, bio, i) + ; + return i; +} + /* * this is a generic handler for readpage errors (default * readpage_io_failed_hook). if other copies exist, read those and write back @@ -2368,7 +2380,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, int read_mode = 0; blk_status_t status; int ret; - unsigned failed_bio_pages = bio_pages_all(failed_bio); + unsigned failed_bio_pages = btrfs_bio_pages_all(failed_bio); BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE); From patchwork Thu Nov 15 08:52:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6593714D6 for ; Thu, 15 Nov 2018 08:55:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54F65299C2 for ; Thu, 15 Nov 2018 08:55:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48C422B334; Thu, 15 Nov 2018 08:55:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE191299C2 for ; Thu, 15 Nov 2018 08:55:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED1546B027D; Thu, 15 Nov 2018 03:55:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA7576B027E; Thu, 15 Nov 2018 03:55:48 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBD8B6B027F; Thu, 15 Nov 2018 03:55:48 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id AF6296B027D for ; Thu, 15 Nov 2018 03:55:48 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id 67so43054392qkj.18 for ; Thu, 15 Nov 2018 00:55:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=aBBM3nmRuvsMADjOAX8n/4Cbd0z9pc1PG2XIqdD3L3o=; b=uE65hQk0O7UkM9CCQmiLlPFDC7NN9h36ljUaV+6/SoysZkL/Bwlz2e/ZSQNYf6puUn jnWzZLcmWX5wFP07oe/gR1fKeDtDTfcoCXSyl3q0cx+5v3kxGp9yacqdOpn/xxv0v6tl lbyYwEO58q0k+tgRmZskNWH5NzJM/jbNbA8AfSmScKxPI01TuI5baDPAprm5fwJFvjtG wVArHyd7MzcnViTkDrIJLPVrMu3ig3Mr4Yf35VA12oW7ItvYWUcKVkPRydxkkKyB4g3Z MVTpapgmag+1nqKdnYasJUoSXCaLey5b7lBjaT0qhj0bmhfCFSgPgvN8p9suRt+nbAKz uPQA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gIY3LKHNsD8u4EHgU6i2auh1ia5pPQtuFc5/vJ2hsQdz32/VPGk gozX2JALB9wkQS2GZ3iQI5SCG7DuaDi6Bai3+ima/mZNepaeFifeLFZZyYicdk79HFgjyOy6V5C i66vMKo71RL0vEbM2Pdg1WXuw4XZ8s8ypufG7iaR2srTRwZtJPncbZYzA8FusnADcVQ== X-Received: by 2002:a0c:8b64:: with SMTP id d36mr5207836qvc.233.1542272148498; Thu, 15 Nov 2018 00:55:48 -0800 (PST) X-Google-Smtp-Source: AJdET5fIvr1sbFs9qYmRlHmutdPRfVece4z3gXVLUFu0MkHBwhSbCRyZm7TQnoTR01b5hR0oMbWj X-Received: by 2002:a0c:8b64:: with SMTP id d36mr5207818qvc.233.1542272147955; Thu, 15 Nov 2018 00:55:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272147; cv=none; d=google.com; s=arc-20160816; b=WrVLk7K7J+Y+Gv2hHo3S/ykpXr+lGoJTWNqlg6dIuO2Q360xu6YHwIcD+13NvB3sJk b+F6+6J2SXTmb5jHeNCQqYdX36OiCUmqgKCyrBywSFsxKxJo1mN2U526blUHJ1wyVBsZ mvmC89G0vnBmFUXVPtwTP1MpLx4vy9pFb1w3Z4cC921MGjIDAlJvnWD0QKMRbvvlXGz0 Nztee9bGscdwyJQIesCvNncetjZ88t/56/9bwIDrFaU8AThLD+pZ4seVH5AK8mX0UZBC RppNUyQUXkO3TVhtJ0Olx69H5h0w0Rrk543zswbLyvkLcponmC1LHaxZ9dXZqQL+nrZN Jp9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=aBBM3nmRuvsMADjOAX8n/4Cbd0z9pc1PG2XIqdD3L3o=; b=opG9leARW0EMQCuXIrSISN5fGJpU+HcIbRU4Mvtaz16pwPkDA+NzaUupgBCYs75Ipq Gb1kz24UbATaE8GOFDy+ZvD2FcqYrsH5cqs5zHaZi74GmCoaTDKwSzy/obYwCJPDm4fu 4/RX9YX4vT9qUphDb0YTUIdzO1t+F/OucyszINiFiKekals0oKbtbBRpcnyRKYj0eCyv sv10qlg+tAvsFnCBgblmMSVqWbA8uvAOg7ijpdylIu0qTY4p+2YQZFjKYhABPr1FXEXQ H6ueX0rrqqcm1Ie6Jr2m6OSHclr92qWIydjhoGfF2WsBOOSZmfe2qmKtguIZadvhPvHS X0OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id s29si6771953qth.384.2018.11.15.00.55.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:55:47 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDABE88307; Thu, 15 Nov 2018 08:55:46 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC1D4608E1; Thu, 15 Nov 2018 08:55:36 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 09/19] block: introduce bio_bvecs() Date: Thu, 15 Nov 2018 16:52:56 +0800 Message-Id: <20181115085306.9910-10-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 15 Nov 2018 08:55:47 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP There are still cases in which we need to use bio_bvecs() for get the number of multi-page segment, so introduce it. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- include/linux/bio.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 1f0dcf109841..3496c816946e 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -196,7 +196,6 @@ static inline unsigned bio_segments(struct bio *bio) * We special case discard/write same/write zeroes, because they * interpret bi_size differently: */ - switch (bio_op(bio)) { case REQ_OP_DISCARD: case REQ_OP_SECURE_ERASE: @@ -205,13 +204,34 @@ static inline unsigned bio_segments(struct bio *bio) case REQ_OP_WRITE_SAME: return 1; default: - break; + bio_for_each_segment(bv, bio, iter) + segs++; + return segs; } +} - bio_for_each_segment(bv, bio, iter) - segs++; +static inline unsigned bio_bvecs(struct bio *bio) +{ + unsigned bvecs = 0; + struct bio_vec bv; + struct bvec_iter iter; - return segs; + /* + * We special case discard/write same/write zeroes, because they + * interpret bi_size differently: + */ + switch (bio_op(bio)) { + case REQ_OP_DISCARD: + case REQ_OP_SECURE_ERASE: + case REQ_OP_WRITE_ZEROES: + return 0; + case REQ_OP_WRITE_SAME: + return 1; + default: + bio_for_each_bvec(bv, bio, iter) + bvecs++; + return bvecs; + } } /* From patchwork Thu Nov 15 08:52:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECE8E14D6 for ; Thu, 15 Nov 2018 08:56:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAC32299C2 for ; Thu, 15 Nov 2018 08:56:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD7E92B334; Thu, 15 Nov 2018 08:56:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BAC7299C2 for ; Thu, 15 Nov 2018 08:56:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D0736B027F; Thu, 15 Nov 2018 03:56:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5A5FB6B0280; Thu, 15 Nov 2018 03:56:00 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46EF96B0281; Thu, 15 Nov 2018 03:56:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 1EDB76B027F for ; Thu, 15 Nov 2018 03:56:00 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id h68so43884259qke.3 for ; Thu, 15 Nov 2018 00:56:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=E2rITT6VB8lacRXi3Hmi4VFiydk50DyJ1y8Nm3m92Ew=; b=qV8YhNfuYKFAmpW8rs0FjRlwViKLMc8wZl4H6Dw3J2j8AXvFUq8IE+zHotqatCWXTY 59VYP9sE7AcFdvAa/0srEziDvekbVDGLT8thN6CMrti+45K+uOZqwN7FBfDPhr0iT5/Y Sap8bKTb1+//C0XWfJrL6F49S69yiao+16iskX6LFCuUpWh3g5QALWglATV7Ha5O8lK3 xqmaTpgyYFpiRkWaM4lZwaYg4cG6MOSUH8Cf9fHjLLxn7VRajoK5VuTfgexscSVnlUHq HexVgYGlJKN5dDj804mKjX98ujzK5j03islTAxtJpIdBIB+gCqxbpi33Nyj3HCpxSLu7 snMQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gJKT7oILrB45hESWQO9EWrENA0bDSiExvs2LIzTjlaR3WU/Jh6w z75TjZdzQ9qTSq+P+RD4pcZ2K9Uv95XcTYsDnrXiz6tlxAhybZD7EcPT7SFz0wMgT2JamkOpaiM l1kDK0HflAGVTvMdJLHsb/nGYCmOzMCBKwPsD3iZh+aECVr4HGKyz1znHLbf7srBCCw== X-Received: by 2002:a0c:f4c2:: with SMTP id o2mr5233939qvm.236.1542272159892; Thu, 15 Nov 2018 00:55:59 -0800 (PST) X-Google-Smtp-Source: AJdET5fz+Ap3oA7vQLWvGE6G0KHVJit8J0Day4SHxOZKa6oRB2ZBiLHnalTVeSD7KEWPv3/wq23u X-Received: by 2002:a0c:f4c2:: with SMTP id o2mr5233916qvm.236.1542272159398; Thu, 15 Nov 2018 00:55:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272159; cv=none; d=google.com; s=arc-20160816; b=nuBpZdZkQsXARp35vMkHSkRK/2smBAccs/c7XfKn8iinnwuN4ICxckkQA3I/0svysX Wzu7zX3NeJIp7FEBOrA4b7x0qe31SKlYJkuLScQFExINKo71XRCec8EkQmYu0x7FW3B5 9W6+R3esgZPwyDWpc4SIEsqyIqgSqIqJFGZMqeJyQ5P4WTCRbBi0N808AmXhcSMiaLW2 PnMC5+ME2IjpXjFCS3zmx9x4oHmU5PlBn0/+MpCCaDG9HDqQUSeNOOejh8YuWlO1qEF0 CH4CpnfKZV4nercT7HMN2zpqNbPY1exUMlfu0V7gsN+0IXu9w+ezLSs7aZqK4Wr/Oile Mmow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=E2rITT6VB8lacRXi3Hmi4VFiydk50DyJ1y8Nm3m92Ew=; b=0fz0kDtLblQt7t6KvpAgmUFeu63EXdvjXGqMcW6WqxOQqGXl7sdisLCcRlkn+5egM6 IcDYltGDq8bIQClnIgOVgqtvxfc7zm4WdNVGGn0+vGMaztpOvyBCGcuDFcXzMkD2OxDo vN30Y0h9mQrCW2nUuxzahnFctjGZMh9rrDZQDeSwwVO4JpG/H+TMFJxUsIgdYdps5Fqj McTsvt7s6Y+0yNpTRkF+Q1cDWl13aUk2HIUBRZYBs2z3eRdZRnsViKB1UN33RoaYXGqe urwhTk7jqU2TIZbR81b3tdoY17k+2MscBAw9aG4fcnsZ0suM/X1TjoCCZo4VJhYil8g5 HKNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 42si7087020qvd.29.2018.11.15.00.55.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:55:59 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C7F23099F9E; Thu, 15 Nov 2018 08:55:58 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC3145D9D1; Thu, 15 Nov 2018 08:55:48 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 10/19] block: loop: pass multi-page bvec to iov_iter Date: Thu, 15 Nov 2018 16:52:57 +0800 Message-Id: <20181115085306.9910-11-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 15 Nov 2018 08:55:58 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP iov_iter is implemented with bvec itererator, so it is safe to pass multipage bvec to it, and this way is much more efficient than passing one page in each bvec. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- drivers/block/loop.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index bf6bc35aaf88..a3fd418ec637 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -515,16 +515,16 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, struct bio *bio = rq->bio; struct file *file = lo->lo_backing_file; unsigned int offset; - int segments = 0; + int nr_bvec = 0; int ret; if (rq->bio != rq->biotail) { - struct req_iterator iter; + struct bvec_iter iter; struct bio_vec tmp; __rq_for_each_bio(bio, rq) - segments += bio_segments(bio); - bvec = kmalloc_array(segments, sizeof(struct bio_vec), + nr_bvec += bio_bvecs(bio); + bvec = kmalloc_array(nr_bvec, sizeof(struct bio_vec), GFP_NOIO); if (!bvec) return -EIO; @@ -533,13 +533,14 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, /* * The bios of the request may be started from the middle of * the 'bvec' because of bio splitting, so we can't directly - * copy bio->bi_iov_vec to new bvec. The rq_for_each_segment + * copy bio->bi_iov_vec to new bvec. The bio_for_each_bvec * API will take care of all details for us. */ - rq_for_each_segment(tmp, rq, iter) { - *bvec = tmp; - bvec++; - } + __rq_for_each_bio(bio, rq) + bio_for_each_bvec(tmp, bio, iter) { + *bvec = tmp; + bvec++; + } bvec = cmd->bvec; offset = 0; } else { @@ -550,11 +551,11 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, */ offset = bio->bi_iter.bi_bvec_done; bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); - segments = bio_segments(bio); + nr_bvec = bio_bvecs(bio); } atomic_set(&cmd->ref, 2); - iov_iter_bvec(&iter, rw, bvec, segments, blk_rq_bytes(rq)); + iov_iter_bvec(&iter, rw, bvec, nr_bvec, blk_rq_bytes(rq)); iter.iov_offset = offset; cmd->iocb.ki_pos = pos; From patchwork Thu Nov 15 08:52:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3E8814D6 for ; Thu, 15 Nov 2018 08:56:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C48A1299C2 for ; Thu, 15 Nov 2018 08:56:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B88DD2B334; Thu, 15 Nov 2018 08:56:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 573A5299C2 for ; Thu, 15 Nov 2018 08:56:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 929D76B0280; Thu, 15 Nov 2018 03:56:29 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8DABE6B0282; Thu, 15 Nov 2018 03:56:29 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CA2A6B0283; Thu, 15 Nov 2018 03:56:29 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 548F06B0280 for ; Thu, 15 Nov 2018 03:56:29 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id f22so42868106qkm.11 for ; Thu, 15 Nov 2018 00:56:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=KsK+yW7qYUQuHCvE6rEDlffDmIoBa+mM4kNBOYDMPlI=; b=Mbsi8qS9Kkykk36Tr1zLbhdt71YXmYOwjpY7piWhRGbHcDh+UdMjUac6+PyQp8Zs9D xP5legV5JVPCDs3SzJgnSt0nSEnIhJzczIfUOfd7wMmUB7mXCWvUoXNmMfdfLeoXkJag qfuWB/KK1A6BUwdYkjPkTkC/Aym6MJMMRvDZKx0+wWlZkChregw0WBxVYv1MQS4IOI3I E8+ST6zEsr89X93MpIyX7Ih3MOavbv5X+9+44ITOX8iM5XCE8/Fs5rpf/N1XzkY6zj9e LoKp9jlM5QV3mzra7MHT/CP8zAf8BWV1U2VR91B3CeLbBjYlC7gHml9Csytg6tZ7RB5G iB2g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gLmQbtbywnkdp/QGPSoUZaG4ZF76yxfd8wVSJoEgWDdKaJqXNra 0y39bmQ3ei011skMfOjtXNw6oTJoID70o8jnEkmut6Ph9hBAcPP9ZlQ9okxf09nY0c8vVUvhkdQ 6C+LdWifav28HsZ21vzhnDJZzLlNYeJtmrM5w8LoXF9sCf2MlI5ybP62mN0vKWls0pg== X-Received: by 2002:a0c:93e2:: with SMTP id g31mr5299639qvg.194.1542272189118; Thu, 15 Nov 2018 00:56:29 -0800 (PST) X-Google-Smtp-Source: AJdET5e2W+I0463+dz0GLGuTs+mhDrC6bkhBSauoWyHEcvN14FevWKSqc4Lqm3yeqoZQIxAySQPS X-Received: by 2002:a0c:93e2:: with SMTP id g31mr5299613qvg.194.1542272188631; Thu, 15 Nov 2018 00:56:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272188; cv=none; d=google.com; s=arc-20160816; b=yuT3Or8QmTZE+WgLK4a22vRTGN/wJaS77TOf4ZYqeECVKBhol0h7sqlXjEhyE8ajF9 F5AG17z3NeKUZglqWpam6vnib3WAr2KgGV8HQgACPkpLLC63Xo/MxldOc208wscE7B9F /I5EO7GgXxigotd9VrI1WsWGPh5SIXdflBx3rpNQbWXQxwfixua6Igbur44bgUPPk7wP /BxPq/5qafp/FHe0j0RX5SLa/ENzhR3BAIo28ql8xgE72jh5pTFBRKXgRwvF8/klCvHM JFqBd+trJlwaYnRuCXftnhdt/+nuhQOX4WBSOTDHRxeenmxOkyQ+tMDy62zK37LEiP2O azeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=KsK+yW7qYUQuHCvE6rEDlffDmIoBa+mM4kNBOYDMPlI=; b=rflODseFMWpfx6RyepkHRsu8jHBwbP7vGHBI0cdzhfD1ZFJz4sXNEWgcpZUSLf7Iwr +GYPnQ+pJdfwJHVj99C5YiFM2r8g5naxwZhQffH0IKWHMP9k8h6Ad0KPTtD6pOEqaAv6 O+Cc5airE7XKI2jNkHcVxWbN7xvCrdPqIjs2jk8PF3whPl8ErlDhXgohrwkAgBOcFaOF ELGZj/KNPtHViaQO/FgNI0i63XOTGeDFpxh0iVnXRyT5SxVN0LWG2wdJTa0IuOj+rSsH rgAI1kS3LE4BuVbTI1V6N2nYzD2GHZH7/bETxV9+dwQw7QiSbmMcya72UxIdCTJQVk1D NAGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id a62si8941325qke.165.2018.11.15.00.56.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:56:28 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4EE95308ED4B; Thu, 15 Nov 2018 08:56:27 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4796A5E1BF; Thu, 15 Nov 2018 08:55:59 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 11/19] bcache: avoid to use bio_for_each_segment_all() in bch_bio_alloc_pages() Date: Thu, 15 Nov 2018 16:52:58 +0800 Message-Id: <20181115085306.9910-12-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 15 Nov 2018 08:56:27 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP bch_bio_alloc_pages() is always called on one new bio, so it is safe to access the bvec table directly. Given it is the only kind of this case, open code the bvec table access since bio_for_each_segment_all() will be changed to support for iterating over multipage bvec. Cc: Dave Chinner Cc: Kent Overstreet Acked-by: Coly Li Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei --- drivers/md/bcache/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 20eddeac1531..8517aebcda2d 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -270,7 +270,7 @@ int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp_mask) int i; struct bio_vec *bv; - bio_for_each_segment_all(bv, bio, i) { + for (i = 0, bv = bio->bi_io_vec; i < bio->bi_vcnt; bv++) { bv->bv_page = alloc_page(gfp_mask); if (!bv->bv_page) { while (--bv >= bio->bi_io_vec) From patchwork Thu Nov 15 08:52:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4750414BA for ; Thu, 15 Nov 2018 08:56:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C7A299C2 for ; Thu, 15 Nov 2018 08:56:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26BB12B678; Thu, 15 Nov 2018 08:56:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66B82299C2 for ; Thu, 15 Nov 2018 08:56:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66C3F6B0283; Thu, 15 Nov 2018 03:56:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 61B8A6B0284; Thu, 15 Nov 2018 03:56:39 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E46D6B0285; Thu, 15 Nov 2018 03:56:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 118CD6B0283 for ; Thu, 15 Nov 2018 03:56:39 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id l7-v6so43804811qkd.5 for ; Thu, 15 Nov 2018 00:56:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=7QEcjY6g9GhDoTgehWEyQAwheRYVxaDtuGlvcUspcW4=; b=cpJIN/2LleFJke6uguJhXk+KT86T5SOffmj96fTyWVMA4reMM1g+N3t7u4DpZ+SeOm ckRhyz8nnXwOYMqeSJq/C5Mo5u4sHAiWYo+lj3KnDdLfq4vRRxSue6F0uZQx61TlGGKl sfEYGZRixeHKlkDqaBRsXO/iPkcFO9piit5FNgA/BeYVfpprlSFvwxc1vG8nP2eGgYUR xHal8s5UkQdstGDWRAEk9OrVpkZpKyHTKECI2vd5hG5kEYIxQOhNl6s8z/fSzFck7Nze IpWrQQmoLc4kJRqYw63JRkTaYeCrOoRxLpZPQoo+qOl2lUN2X4qoWjBVHkzN9OHdQ+2h EnZg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gKdUO5Bebxo3uaMhCr1OS96bpCX/y5eTTl/7tlIbzrqwqgJd+p5 idmkcjS16kgVeXXnarD/Hr+LO9OWbELr30QBrOn1I2ClQUUuiD83s55XyKipCL1iThMtYbMT70E auGAS/E0A5X89Xqsp4vRDcZrSvhQrlmG/JVWrApxw2cA/bPU0P+UrdHG90GopS81Qkw== X-Received: by 2002:ac8:478f:: with SMTP id k15mr5084677qtq.281.1542272198695; Thu, 15 Nov 2018 00:56:38 -0800 (PST) X-Google-Smtp-Source: AJdET5eS6DWh5C6TwGDnXRoTqXXlidcqVJpbABm/8Rb0mNPOKZgwNUsWxDi28UgqufnA8nTi/pon X-Received: by 2002:ac8:478f:: with SMTP id k15mr5084633qtq.281.1542272197354; Thu, 15 Nov 2018 00:56:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272197; cv=none; d=google.com; s=arc-20160816; b=wpFEkMjfUMxmgcho1C78iyzOE7QPPts//sQYQMU6Pd4Adui9H3gYlucM3A7R5V6Ng9 fJRDhvkeRQtUWrArHZf9GAzmPdmRIxVKKbOAoJb+ozb73+HKz8j5T+8VzbTTZtVgu2pG 0CvFS6gaZBN+KD8V8vZ2v47DX29hc1VG75NN1zKyJeZUEpwogkw66F3COlc/zKfCGhoc H2frIDKdb6cllYbKUUYS2FnBaEQZaX/jxw0cvfMwLKJwVRtM0cGnsdFVycgBM08MjLUr E5LqK+EvIxzUl/MQj5m6fZny1hnA+ZFustnpPglFPcwf2ti9PiwZ6U5bnzKTqqIpFh0z sWAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=7QEcjY6g9GhDoTgehWEyQAwheRYVxaDtuGlvcUspcW4=; b=uFt/9r5BY0EMbLxOKiAKghZz/EBoqvGwjP6tSuU+wvDUNAAsK4o3nz0biaUBf98fVC 24JhpiRqITPb9cWoX8jqd0wzuUjw0AfM59rnALa0R9s8gClwJ2e/JOjw+w7l495frFtD +Jx0GsucQ/UjGeMOYL/Q9euLPZY/3NsXgh7mM7Mxc10amCgXAfLfszf+D44w9M/bRo7a NpjfJ/SRe53tqUWXIfbjkEZMk6QlT+K3EemfKpWCol9nmQf3eC8BGizDYSocRvNk6tzi Hdciv6WmAldcp2GfHmoe88JySkTx+5aCHN26NcqN4Z6TZfUx3DvllHBAP1wLA2dd8pMh gNfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id c19si2396932qkb.99.2018.11.15.00.56.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:56:37 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 686543084038; Thu, 15 Nov 2018 08:56:35 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EC0B26163; Thu, 15 Nov 2018 08:56:29 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , linux-fsdevel@vger.kernel.org, Alexander Viro , Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org, David Sterba , "Darrick J . Wong" , Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 12/19] block: allow bio_for_each_segment_all() to iterate over multi-page bvec Date: Thu, 15 Nov 2018 16:52:59 +0800 Message-Id: <20181115085306.9910-13-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 15 Nov 2018 08:56:36 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces one extra iterator variable to bio_for_each_segment_all(), then we can allow bio_for_each_segment_all() to iterate over multi-page bvec. Given it is just one mechannical & simple change on all bio_for_each_segment_all() users, this patch does tree-wide change in one single patch, so that we can avoid to use a temporary helper for this conversion. Cc: Dave Chinner Cc: Kent Overstreet Cc: linux-fsdevel@vger.kernel.org Cc: Alexander Viro Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: linux-btrfs@vger.kernel.org Cc: David Sterba Cc: Darrick J. Wong Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei --- block/bio.c | 27 ++++++++++++++++++--------- block/blk-zoned.c | 1 + block/bounce.c | 6 ++++-- drivers/md/bcache/btree.c | 3 ++- drivers/md/dm-crypt.c | 3 ++- drivers/md/raid1.c | 3 ++- drivers/staging/erofs/data.c | 3 ++- drivers/staging/erofs/unzip_vle.c | 3 ++- fs/block_dev.c | 6 ++++-- fs/btrfs/compression.c | 3 ++- fs/btrfs/disk-io.c | 3 ++- fs/btrfs/extent_io.c | 12 ++++++++---- fs/btrfs/inode.c | 6 ++++-- fs/btrfs/raid56.c | 3 ++- fs/crypto/bio.c | 3 ++- fs/direct-io.c | 4 +++- fs/exofs/ore.c | 3 ++- fs/exofs/ore_raid.c | 3 ++- fs/ext4/page-io.c | 3 ++- fs/ext4/readpage.c | 3 ++- fs/f2fs/data.c | 9 ++++++--- fs/gfs2/lops.c | 6 ++++-- fs/gfs2/meta_io.c | 3 ++- fs/iomap.c | 6 ++++-- fs/mpage.c | 3 ++- fs/xfs/xfs_aops.c | 5 +++-- include/linux/bio.h | 11 +++++++++-- include/linux/bvec.h | 31 +++++++++++++++++++++++++++++++ 28 files changed, 129 insertions(+), 46 deletions(-) diff --git a/block/bio.c b/block/bio.c index d5368a445561..6486722d4d4b 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1072,8 +1072,9 @@ static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter) { int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { ssize_t ret; ret = copy_page_from_iter(bvec->bv_page, @@ -1103,8 +1104,9 @@ static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter) { int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { ssize_t ret; ret = copy_page_to_iter(bvec->bv_page, @@ -1126,8 +1128,9 @@ void bio_free_pages(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) __free_page(bvec->bv_page); } EXPORT_SYMBOL(bio_free_pages); @@ -1293,6 +1296,7 @@ struct bio *bio_map_user_iov(struct request_queue *q, struct bio *bio; int ret; struct bio_vec *bvec; + struct bvec_iter_all iter_all; if (!iov_iter_count(iter)) return ERR_PTR(-EINVAL); @@ -1366,7 +1370,7 @@ struct bio *bio_map_user_iov(struct request_queue *q, return bio; out_unmap: - bio_for_each_segment_all(bvec, bio, j) { + bio_for_each_segment_all(bvec, bio, j, iter_all) { put_page(bvec->bv_page); } bio_put(bio); @@ -1377,11 +1381,12 @@ static void __bio_unmap_user(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; /* * make sure we dirty pages we wrote to */ - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { if (bio_data_dir(bio) == READ) set_page_dirty_lock(bvec->bv_page); @@ -1473,8 +1478,9 @@ static void bio_copy_kern_endio_read(struct bio *bio) char *p = bio->bi_private; struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { memcpy(p, page_address(bvec->bv_page), bvec->bv_len); p += bvec->bv_len; } @@ -1583,8 +1589,9 @@ void bio_set_pages_dirty(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { if (!PageCompound(bvec->bv_page)) set_page_dirty_lock(bvec->bv_page); } @@ -1595,8 +1602,9 @@ static void bio_release_pages(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) put_page(bvec->bv_page); } @@ -1643,8 +1651,9 @@ void bio_check_pages_dirty(struct bio *bio) struct bio_vec *bvec; unsigned long flags; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { if (!PageDirty(bvec->bv_page) && !PageCompound(bvec->bv_page)) goto defer; } diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 13ba2011a306..789b09ae402a 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -123,6 +123,7 @@ static int blk_report_zones(struct gendisk *disk, sector_t sector, unsigned int z = 0, n, nrz = *nr_zones; sector_t capacity = get_capacity(disk); int ret; + struct bvec_iter_all iter_all; while (z < nrz && sector < capacity) { n = nrz - z; diff --git a/block/bounce.c b/block/bounce.c index 36869afc258c..aee79b3e4777 100644 --- a/block/bounce.c +++ b/block/bounce.c @@ -165,11 +165,12 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool) struct bio_vec *bvec, orig_vec; int i; struct bvec_iter orig_iter = bio_orig->bi_iter; + struct bvec_iter_all iter_all; /* * free up bounce indirect pages used */ - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { orig_vec = bio_iter_iovec(bio_orig, orig_iter); if (bvec->bv_page != orig_vec.bv_page) { dec_zone_page_state(bvec->bv_page, NR_BOUNCE); @@ -292,6 +293,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig, bool bounce = false; int sectors = 0; bool passthrough = bio_is_passthrough(*bio_orig); + struct bvec_iter_all iter_all; bio_for_each_segment(from, *bio_orig, iter) { if (i++ < BIO_MAX_PAGES) @@ -311,7 +313,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig, bio = bounce_clone_bio(*bio_orig, GFP_NOIO, passthrough ? NULL : &bounce_bio_set); - bio_for_each_segment_all(to, bio, i) { + bio_for_each_segment_all(to, bio, i, iter_all) { struct page *page = to->bv_page; if (page_to_pfn(page) <= q->limits.bounce_pfn) diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 3f4211b5cd33..6242ae4e2127 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -427,8 +427,9 @@ static void do_btree_node_write(struct btree *b) int j; struct bio_vec *bv; void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, b->bio, j) + bio_for_each_segment_all(bv, b->bio, j, iter_all) memcpy(page_address(bv->bv_page), base + j * PAGE_SIZE, PAGE_SIZE); diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index b8eec515a003..a0dcf28c01b5 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1447,8 +1447,9 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) { unsigned int i; struct bio_vec *bv; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, clone, i) { + bio_for_each_segment_all(bv, clone, i, iter_all) { BUG_ON(!bv->bv_page); mempool_free(bv->bv_page, &cc->page_pool); } diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 1d54109071cc..6f74a3b06c7e 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2114,13 +2114,14 @@ static void process_checks(struct r1bio *r1_bio) struct page **spages = get_resync_pages(sbio)->pages; struct bio_vec *bi; int page_len[RESYNC_PAGES] = { 0 }; + struct bvec_iter_all iter_all; if (sbio->bi_end_io != end_sync_read) continue; /* Now we can 'fixup' the error value */ sbio->bi_status = 0; - bio_for_each_segment_all(bi, sbio, j) + bio_for_each_segment_all(bi, sbio, j, iter_all) page_len[j] = bi->bv_len; if (!status) { diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c index 6384f73e5418..96240ceca02a 100644 --- a/drivers/staging/erofs/data.c +++ b/drivers/staging/erofs/data.c @@ -20,8 +20,9 @@ static inline void read_endio(struct bio *bio) int i; struct bio_vec *bvec; const blk_status_t err = bio->bi_status; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; /* page is already locked */ diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 79d3ba62b298..41a8a9399863 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -731,11 +731,12 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) const blk_status_t err = bio->bi_status; unsigned int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; #ifdef EROFS_FS_HAS_MANAGED_CACHE struct address_space *mngda = NULL; #endif - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; bool cachemngd = false; diff --git a/fs/block_dev.c b/fs/block_dev.c index c039abfb2052..0fcb5515dca7 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -197,6 +197,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, ssize_t ret; blk_qc_t qc; int i; + struct bvec_iter_all iter_all; if ((pos | iov_iter_alignment(iter)) & (bdev_logical_block_size(bdev) - 1)) @@ -246,7 +247,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, } __set_current_state(TASK_RUNNING); - bio_for_each_segment_all(bvec, &bio, i) { + bio_for_each_segment_all(bvec, &bio, i, iter_all) { if (should_dirty && !PageCompound(bvec->bv_page)) set_page_dirty_lock(bvec->bv_page); put_page(bvec->bv_page); @@ -314,8 +315,9 @@ static void blkdev_bio_end_io(struct bio *bio) } else { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) put_page(bvec->bv_page); bio_put(bio); } diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 161e14b8b180..ac3c201377e1 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -162,13 +162,14 @@ static void end_compressed_bio_read(struct bio *bio) } else { int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; /* * we have verified the checksum already, set page * checked so the end_io handlers know about it */ ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, cb->orig_bio, i) + bio_for_each_segment_all(bvec, cb->orig_bio, i, iter_all) SetPageChecked(bvec->bv_page); bio_endio(cb->orig_bio); diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index b0ab41da91d1..834efe6e3137 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -819,9 +819,10 @@ static blk_status_t btree_csum_one_bio(struct bio *bio) struct bio_vec *bvec; struct btrfs_root *root; int i, ret = 0; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { root = BTRFS_I(bvec->bv_page->mapping->host)->root; ret = csum_dirty_buffer(root->fs_info, bvec->bv_page); if (ret) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 874bb9aeebdc..9373eb8ade06 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2352,10 +2352,11 @@ static unsigned btrfs_bio_pages_all(struct bio *bio) { unsigned i; struct bio_vec *bv; + struct bvec_iter_all iter_all; WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bv, bio, i) + bio_for_each_segment_all(bv, bio, i, iter_all) ; return i; } @@ -2457,9 +2458,10 @@ static void end_bio_extent_writepage(struct bio *bio) u64 start; u64 end; int i; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; struct inode *inode = page->mapping->host; struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); @@ -2528,9 +2530,10 @@ static void end_bio_extent_readpage(struct bio *bio) int mirror; int ret; int i; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; struct inode *inode = page->mapping->host; struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); @@ -3682,9 +3685,10 @@ static void end_bio_extent_buffer_writepage(struct bio *bio) struct bio_vec *bvec; struct extent_buffer *eb; int i, done; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; eb = (struct extent_buffer *)page->private; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d3df5b52278c..0ec8c1dd328f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7811,6 +7811,7 @@ static void btrfs_retry_endio_nocsum(struct bio *bio) struct bio_vec *bvec; struct extent_io_tree *io_tree, *failure_tree; int i; + struct bvec_iter_all iter_all; if (bio->bi_status) goto end; @@ -7822,7 +7823,7 @@ static void btrfs_retry_endio_nocsum(struct bio *bio) done->uptodate = 1; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) clean_io_failure(BTRFS_I(inode)->root->fs_info, failure_tree, io_tree, done->start, bvec->bv_page, btrfs_ino(BTRFS_I(inode)), 0); @@ -7901,6 +7902,7 @@ static void btrfs_retry_endio(struct bio *bio) int uptodate; int ret; int i; + struct bvec_iter_all iter_all; if (bio->bi_status) goto end; @@ -7914,7 +7916,7 @@ static void btrfs_retry_endio(struct bio *bio) failure_tree = &BTRFS_I(inode)->io_failure_tree; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { ret = __readpage_endio_check(inode, io_bio, i, bvec->bv_page, bvec->bv_offset, done->start, bvec->bv_len); diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index df41d7049936..e33a99871d60 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1443,10 +1443,11 @@ static void set_bio_pages_uptodate(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) SetPageUptodate(bvec->bv_page); } diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 0959044c5cee..5759bcd018cd 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -30,8 +30,9 @@ static void __fscrypt_decrypt_bio(struct bio *bio, bool done) { struct bio_vec *bv; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { struct page *page = bv->bv_page; int ret = fscrypt_decrypt_page(page->mapping->host, page, PAGE_SIZE, 0, page->index); diff --git a/fs/direct-io.c b/fs/direct-io.c index ea07d5a34317..5904fc2e180c 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -551,7 +551,9 @@ static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio) if (dio->is_async && dio->op == REQ_OP_READ && dio->should_dirty) { bio_check_pages_dirty(bio); /* transfers ownership */ } else { - bio_for_each_segment_all(bvec, bio, i) { + struct bvec_iter_all iter_all; + + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; if (dio->op == REQ_OP_READ && !PageCompound(page) && diff --git a/fs/exofs/ore.c b/fs/exofs/ore.c index 5331a15a61f1..24a8e34882e9 100644 --- a/fs/exofs/ore.c +++ b/fs/exofs/ore.c @@ -420,8 +420,9 @@ static void _clear_bio(struct bio *bio) { struct bio_vec *bv; unsigned i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { unsigned this_count = bv->bv_len; if (likely(PAGE_SIZE == this_count)) diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c index 199590f36203..e83bab54b03e 100644 --- a/fs/exofs/ore_raid.c +++ b/fs/exofs/ore_raid.c @@ -468,11 +468,12 @@ static void _mark_read4write_pages_uptodate(struct ore_io_state *ios, int ret) /* loop on all devices all pages */ for (d = 0; d < ios->numdevs; d++) { struct bio *bio = ios->per_dev[d].bio; + struct bvec_iter_all iter_all; if (!bio) continue; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { struct page *page = bv->bv_page; SetPageUptodate(page); diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index db7590178dfc..0644b4e7d6d4 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -63,8 +63,9 @@ static void ext4_finish_bio(struct bio *bio) { int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; #ifdef CONFIG_EXT4_FS_ENCRYPTION struct page *data_page = NULL; diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index f461d75ac049..b0d9537bc797 100644 --- a/fs/ext4/readpage.c +++ b/fs/ext4/readpage.c @@ -72,6 +72,7 @@ static void mpage_end_io(struct bio *bio) { struct bio_vec *bv; int i; + struct bvec_iter_all iter_all; if (ext4_bio_encrypted(bio)) { if (bio->bi_status) { @@ -81,7 +82,7 @@ static void mpage_end_io(struct bio *bio) return; } } - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { struct page *page = bv->bv_page; if (!bio->bi_status) { diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index b293cb3e27a2..d28f482a0d52 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -87,8 +87,9 @@ static void __read_end_io(struct bio *bio) struct page *page; struct bio_vec *bv; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { page = bv->bv_page; /* PG_error was set if any post_read step failed */ @@ -164,13 +165,14 @@ static void f2fs_write_end_io(struct bio *bio) struct f2fs_sb_info *sbi = bio->bi_private; struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; if (time_to_inject(sbi, FAULT_WRITE_IO)) { f2fs_show_injection_info(FAULT_WRITE_IO); bio->bi_status = BLK_STS_IOERR; } - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; enum count_type type = WB_DATA_TYPE(page); @@ -347,6 +349,7 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode, struct bio_vec *bvec; struct page *target; int i; + struct bvec_iter_all iter_all; if (!io->bio) return false; @@ -354,7 +357,7 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode, if (!inode && !page && !ino) return true; - bio_for_each_segment_all(bvec, io->bio, i) { + bio_for_each_segment_all(bvec, io->bio, i, iter_all) { if (bvec->bv_page->mapping) target = bvec->bv_page; diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 4c7069b8f3c1..f2f165620161 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -168,7 +168,8 @@ u64 gfs2_log_bmap(struct gfs2_sbd *sdp) * that is pinned in the pagecache. */ -static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp, struct bio_vec *bvec, +static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp, + struct bio_vec *bvec, blk_status_t error) { struct buffer_head *bh, *next; @@ -207,6 +208,7 @@ static void gfs2_end_log_write(struct bio *bio) struct bio_vec *bvec; struct page *page; int i; + struct bvec_iter_all iter_all; if (bio->bi_status) { fs_err(sdp, "Error %d writing to journal, jid=%u\n", @@ -214,7 +216,7 @@ static void gfs2_end_log_write(struct bio *bio) wake_up(&sdp->sd_logd_waitq); } - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { page = bvec->bv_page; if (page_has_buffers(page)) gfs2_end_log_write_bh(sdp, bvec, bio->bi_status); diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index be9c0bf697fe..3201342404a7 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -190,8 +190,9 @@ static void gfs2_meta_read_endio(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; struct buffer_head *bh = page_buffers(page); unsigned int len = bvec->bv_len; diff --git a/fs/iomap.c b/fs/iomap.c index f61d13dfdf09..df0212560b36 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -262,8 +262,9 @@ iomap_read_end_io(struct bio *bio) int error = blk_status_to_errno(bio->bi_status); struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) iomap_read_page_end_io(bvec, error); bio_put(bio); } @@ -1541,8 +1542,9 @@ static void iomap_dio_bio_end_io(struct bio *bio) } else { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) put_page(bvec->bv_page); bio_put(bio); } diff --git a/fs/mpage.c b/fs/mpage.c index c820dc9bebab..3f19da75178b 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -48,8 +48,9 @@ static void mpage_end_io(struct bio *bio) { struct bio_vec *bv; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { struct page *page = bv->bv_page; page_endio(page, bio_op(bio), blk_status_to_errno(bio->bi_status)); diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 338b9d9984e0..1f1829e506e8 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -62,7 +62,7 @@ xfs_find_daxdev_for_inode( static void xfs_finish_page_writeback( struct inode *inode, - struct bio_vec *bvec, + struct bio_vec *bvec, int error) { struct iomap_page *iop = to_iomap_page(bvec->bv_page); @@ -98,6 +98,7 @@ xfs_destroy_ioend( for (bio = &ioend->io_inline_bio; bio; bio = next) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; /* * For the last bio, bi_private points to the ioend, so we @@ -109,7 +110,7 @@ xfs_destroy_ioend( next = bio->bi_private; /* walk each page on bio, ending page IO on them */ - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) xfs_finish_page_writeback(inode, bvec, error); bio_put(bio); } diff --git a/include/linux/bio.h b/include/linux/bio.h index 3496c816946e..1a2430a8b89d 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -131,12 +131,19 @@ static inline bool bio_full(struct bio *bio) return bio->bi_vcnt >= bio->bi_max_vecs; } +#define bvec_for_each_segment(bv, bvl, i, iter_all) \ + for (bv = bvec_init_iter_all(&iter_all); \ + (iter_all.done < (bvl)->bv_len) && \ + ((bvec_next_segment((bvl), &iter_all)), 1); \ + iter_all.done += bv->bv_len, i += 1) + /* * drivers should _never_ use the all version - the bio may have been split * before it got to the driver and the driver won't own all of it */ -#define bio_for_each_segment_all(bvl, bio, i) \ - for (i = 0, bvl = (bio)->bi_io_vec; i < (bio)->bi_vcnt; i++, bvl++) +#define bio_for_each_segment_all(bvl, bio, i, iter_all) \ + for (i = 0, iter_all.idx = 0; iter_all.idx < (bio)->bi_vcnt; iter_all.idx++) \ + bvec_for_each_segment(bvl, &((bio)->bi_io_vec[iter_all.idx]), i, iter_all) static inline void __bio_advance_iter(struct bio *bio, struct bvec_iter *iter, unsigned bytes, bool mp) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 01616a0b6220..02f26d2b59ad 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -82,6 +82,12 @@ struct bvec_iter { current bvec */ }; +struct bvec_iter_all { + struct bio_vec bv; + int idx; + unsigned done; +}; + /* * various member access, note that bio_data should of course not be used * on highmem page vectors @@ -216,6 +222,31 @@ static inline bool mp_bvec_iter_advance(const struct bio_vec *bv, .bi_bvec_done = 0, \ } +static inline struct bio_vec *bvec_init_iter_all(struct bvec_iter_all *iter_all) +{ + iter_all->bv.bv_page = NULL; + iter_all->done = 0; + + return &iter_all->bv; +} + +/* used for chunk_for_each_segment */ +static inline void bvec_next_segment(const struct bio_vec *bvec, + struct bvec_iter_all *iter_all) +{ + struct bio_vec *bv = &iter_all->bv; + + if (bv->bv_page) { + bv->bv_page += 1; + bv->bv_offset = 0; + } else { + bv->bv_page = bvec->bv_page; + bv->bv_offset = bvec->bv_offset; + } + bv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset, + bvec->bv_len - iter_all->done); +} + /* * Get the last singlepage segment from the multipage bvec and store it * in @seg From patchwork Thu Nov 15 08:53:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F153D14BA for ; Thu, 15 Nov 2018 08:56:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1048299C2 for ; Thu, 15 Nov 2018 08:56:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D44A22B678; Thu, 15 Nov 2018 08:56:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B686299C2 for ; Thu, 15 Nov 2018 08:56:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 471636B0285; Thu, 15 Nov 2018 03:56:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 41FE06B0286; Thu, 15 Nov 2018 03:56:46 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E8F16B0287; Thu, 15 Nov 2018 03:56:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id F406C6B0285 for ; Thu, 15 Nov 2018 03:56:45 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id c7so43505482qkg.16 for ; Thu, 15 Nov 2018 00:56:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=E09knOifqlVupGWM9sVFS8Kn9kf1+wj380uyw3uRi34=; b=Xa62OkrBmztv+ohw8okn7oCGMOh2liO89Ehr0khbZJEeVhjwsVnwdlIhSJ1fDXj2ut P5sje0gJ61CWL+EqLlevTpVNAet7maJvRZ+5axzzkIkgaUzr/Jtp/Q74OS42vY3isd+F z7oxxCMZ6y8xL/jZJ1RL/7zxQQwz2H6ZQdVqlA0tZO9N9YVC0RzY6gRX+pgq226N7xA3 z1g05nqZlzEy3Km6ZrNSgZru/CbrV712vL9mLIB94GKAekA4LGtT1o+Z9aVkXI4MWOrj vlUbUVR4VMfTaeOD/GtpN8yPbS+6vMFRZpZC9f2AkgD9VMUs2uPV3+5D7p16oYMMFeNm 5omQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gIsxkrw8c0gYtnBVuzyqI7FCrq3eXZJBIoE3iRIy0RmImaWUES+ hX5gS5zcBTr+u0pk5vBH3tnJnZegz7pP2NbGIdh7JOV0B3C2OdvTj7nPO7k/DkEoeLxffN0oHaY RnCRAlx3XLV4vKoVhhFCrFScIEa8504gzo2UH+V2qqQviuwNDAF/LM/vIhy8xkSkOkA== X-Received: by 2002:ac8:44d3:: with SMTP id b19mr5321013qto.107.1542272205728; Thu, 15 Nov 2018 00:56:45 -0800 (PST) X-Google-Smtp-Source: AJdET5e8jSKyJ0zMZFZSM0ge16f02+zD0bNWHxoA9M5MowQJE6IKPXVM16PUnrUyaUYOKFEEE8je X-Received: by 2002:ac8:44d3:: with SMTP id b19mr5320987qto.107.1542272205082; Thu, 15 Nov 2018 00:56:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272205; cv=none; d=google.com; s=arc-20160816; b=QrZKFZfNrPpX4rVCptQNMDEsWGEfhpn/omKYZZXM8MbTtkfiKcwoAreaENPTtXesl+ jw76q95wmVjJWaNCBGkPAzSBxjs17unks/Tv5w7ZxpV6GNft1zQcsCZ6wE7wXQRokjHb 6LzcSvJckZZtrsA40fa9hKLdOVcIY9AQW+25Eta78auRvFm2JdIuD3FXuojTuT9M82bB ENtdoEHwyTFpWuRF29wwj35+yXtQlJaE4x7tNX5j+KYu3q675z3QT/DuiunC5EvGLZJC zEY3F1De6imGYILgQOUk44/+8l6LcrKGXtGktLvuKFgyZS0NFT1sFvGjRzpOFyznggyY pXzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=E09knOifqlVupGWM9sVFS8Kn9kf1+wj380uyw3uRi34=; b=nTr89p8lrqaw7eDm9Tv/VlBU4scPnQKKlbKxbNrN/Xba9BAQC99gt4MCNzoKecxCSg dvkyOHdp45TvHc7sUNCOLBNvuxxJIcQ8L/C2SdCyaL9NHRBeAanSF9xrn3ih4bRp74Af Ixg1q9wO8SzschCyu7Zynns6Qq7ztRRD5cNBegg5RLt++N/qgXhtjFgA6nxnRlYwPfrf JYJkBdi1MlowvjybbEARN21w5SGVAxeYf7S4A3yxE422+VGFDB0s93y+1zZiEYF6jXh5 sdbDew0Ja4GfTMKiJpvxqjnDwBOTPAkNlBn0n66tzTrJvXak19E2cics1nGYRQSc0qBI jfYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id p41si4691650qve.126.2018.11.15.00.56.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:56:45 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D26F5821CC; Thu, 15 Nov 2018 08:56:43 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2BEF26163; Thu, 15 Nov 2018 08:56:37 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 13/19] iomap & xfs: only account for new added page Date: Thu, 15 Nov 2018 16:53:00 +0800 Message-Id: <20181115085306.9910-14-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 15 Nov 2018 08:56:44 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP After multi-page is enabled, one new page may be merged to a segment even though it is a new added page. This patch deals with this issue by post-check in case of merge, and only a freshly new added page need to be dealt with for iomap & xfs. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei --- fs/iomap.c | 22 ++++++++++++++-------- fs/xfs/xfs_aops.c | 10 ++++++++-- include/linux/bio.h | 11 +++++++++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index df0212560b36..a1b97a5c726a 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -288,6 +288,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, loff_t orig_pos = pos; unsigned poff, plen; sector_t sector; + bool need_account = false; if (iomap->type == IOMAP_INLINE) { WARN_ON_ONCE(pos); @@ -313,18 +314,15 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, */ sector = iomap_sector(iomap, pos); if (ctx->bio && bio_end_sector(ctx->bio) == sector) { - if (__bio_try_merge_page(ctx->bio, page, plen, poff)) + if (__bio_try_merge_page(ctx->bio, page, plen, poff)) { + need_account = iop && bio_is_last_segment(ctx->bio, + page, plen, poff); goto done; + } is_contig = true; } - /* - * If we start a new segment we need to increase the read count, and we - * need to do so before submitting any previous full bio to make sure - * that we don't prematurely unlock the page. - */ - if (iop) - atomic_inc(&iop->read_count); + need_account = true; if (!ctx->bio || !is_contig || bio_full(ctx->bio)) { gfp_t gfp = mapping_gfp_constraint(page->mapping, GFP_KERNEL); @@ -347,6 +345,14 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, __bio_add_page(ctx->bio, page, plen, poff); done: /* + * If we add a new page we need to increase the read count, and we + * need to do so before submitting any previous full bio to make sure + * that we don't prematurely unlock the page. + */ + if (iop && need_account) + atomic_inc(&iop->read_count); + + /* * Move the caller beyond our range so that it keeps making progress. * For that we have to include any leading non-uptodate ranges, but * we can skip trailing ones as they will be handled in the next diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 1f1829e506e8..d8e9cc9f751a 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -603,6 +603,7 @@ xfs_add_to_ioend( unsigned len = i_blocksize(inode); unsigned poff = offset & (PAGE_SIZE - 1); sector_t sector; + bool need_account; sector = xfs_fsb_to_db(ip, wpc->imap.br_startblock) + ((offset - XFS_FSB_TO_B(mp, wpc->imap.br_startoff)) >> 9); @@ -617,13 +618,18 @@ xfs_add_to_ioend( } if (!__bio_try_merge_page(wpc->ioend->io_bio, page, len, poff)) { - if (iop) - atomic_inc(&iop->write_count); + need_account = true; if (bio_full(wpc->ioend->io_bio)) xfs_chain_bio(wpc->ioend, wbc, bdev, sector); __bio_add_page(wpc->ioend->io_bio, page, len, poff); + } else { + need_account = iop && bio_is_last_segment(wpc->ioend->io_bio, + page, len, poff); } + if (iop && need_account) + atomic_inc(&iop->write_count); + wpc->ioend->io_size += len; } diff --git a/include/linux/bio.h b/include/linux/bio.h index 1a2430a8b89d..5040e9a2eb09 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -341,6 +341,17 @@ static inline struct bio_vec *bio_last_bvec_all(struct bio *bio) return &bio->bi_io_vec[bio->bi_vcnt - 1]; } +/* iomap needs this helper to deal with sub-pagesize bvec */ +static inline bool bio_is_last_segment(struct bio *bio, struct page *page, + unsigned int len, unsigned int off) +{ + struct bio_vec bv; + + bvec_last_segment(bio_last_bvec_all(bio), &bv); + + return bv.bv_page == page && bv.bv_len == len && bv.bv_offset == off; +} + enum bip_flags { BIP_BLOCK_INTEGRITY = 1 << 0, /* block layer owns integrity data */ BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */ From patchwork Thu Nov 15 08:53:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BC4C14D6 for ; Thu, 15 Nov 2018 08:57:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B553299C2 for ; Thu, 15 Nov 2018 08:57:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D48A2B678; Thu, 15 Nov 2018 08:57:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A73D1299C2 for ; Thu, 15 Nov 2018 08:57:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD92D6B0287; Thu, 15 Nov 2018 03:57:14 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A61146B0288; Thu, 15 Nov 2018 03:57:14 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92A696B0289; Thu, 15 Nov 2018 03:57:14 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 641F16B0287 for ; Thu, 15 Nov 2018 03:57:14 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id s19so43898374qke.20 for ; Thu, 15 Nov 2018 00:57:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=5mBS/Rubp9DSJ4BLHUaql/WAm+yy83Dk5w3S9m90Zg8=; b=jitwg3Tzvm6+PKRRLDz0mTVTNLl9YsYPvdlPeNEmufwJtL1H4wyJ/Ni5maQ9Z+gye7 lNBfch9sBgRXky4CJIMpYwTjQYBoT9HZPhMA9ZRRwthVumyuiunNf/p8WgCunFjahxCu pXrxglYRrH2wcNx+ezmZMjmhGYo3L5JIHKSha7YSHruy1H03qXIQFJ21OiSTSR75cUXi jN33vuC9joei8qdjcxdtHwfTF5ZR8IwWnFCFksZewMtj0gSNzkIZ5QgpiY/IqF2zk8C6 De2Sia8tXR11zM1y5S6o7SAQJJBg9khJ38az1Co5ZCi8rMO0b9SjvQ1cBB/DzTZORUGB yQSA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gLiCvDLG0LMLlaUlJ4g+FGIP97MxE3dppzUeRke1L8k4Ba4gD/m JySnSHCWEKk14PQIdjk4o+XpyPFhJfwFqLkyx1idiSSZXr/qUePw//GRz7vx57+1wyR05h3NN6y FliMNPXQ0PEWI7sjEYg2lr0j9x9L9nuq4Y2fHDBD03Kj/WU9aSljpLq858zh/AZ/Apg== X-Received: by 2002:a37:9181:: with SMTP id t123mr4401426qkd.187.1542272234185; Thu, 15 Nov 2018 00:57:14 -0800 (PST) X-Google-Smtp-Source: AJdET5eIKfS/vpZy0Zwywl3XeGjsYYUNOQY46qnojvFUwgBvP694dR/eKXNZumevzLyxtBQ3Q/uY X-Received: by 2002:a37:9181:: with SMTP id t123mr4401410qkd.187.1542272233680; Thu, 15 Nov 2018 00:57:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272233; cv=none; d=google.com; s=arc-20160816; b=qu8GJ0hWYvcN5PG0Q+GGg4RL2nwLBjIelLXqDh/H3TAWP31iNN0uTVcnF1/lZ2eM9R itX7aA5jQ9+YkvKfQJLXQYRtFcQCNN2XuHYknSqF2ff9MHYkRhiwI/ujCMkHa93I17vy bY/VUnllraryj50dK7RXMaERgM6zJDLwK5XA1pu+Y+6sm5xvsBlxlcDBlXJVj9Wx2ElO TROiJlYcaLywrKW9JtOKjvRtaSUYPB/hWlbuU1Fq35gCCqfUpIqqBg201B5yzx5NtS+R RBXkPZBgbWD0WPgG5QxwuzHdGaSyFsp4aI8z+tHelFd54EYLL9cHDiVCP6MGg/FbGnsb faqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=5mBS/Rubp9DSJ4BLHUaql/WAm+yy83Dk5w3S9m90Zg8=; b=M5TAiXgO1QoSUiEmQaDzANZWVMDdzTwTLEs5pdbCtZkGry8rRsZyT9QZsDnzVYfmUi DAEoCXlqtHVqHR2bDiQp5PLMUewDAVC5Ifgc9B0EoPQBjp1RtpEJAzAODGBOtLRvSKsm YcriH0/vOF7IGCW697kQT82sfRi8ZluEyS0eBc1E56ZC+8cuXg15W7C7e8smWfuA68vX g1pWBX8OSjYdsjI58wKjaUxT/HNBwrIrbekBHnyFhL3T6pmaBooMHvUYKm7rL1huL/nV miKuBkDyAp6dC+SuzQpa5QafRFYPQqRmt8C1b2tvWVJqxkPV1V29qqsOJNVNg41Gk6Gq Tjjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id s60si1766713qtd.374.2018.11.15.00.57.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:57:13 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E085A308ED4B; Thu, 15 Nov 2018 08:57:11 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05ACA61491; Thu, 15 Nov 2018 08:56:45 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 14/19] block: enable multipage bvecs Date: Thu, 15 Nov 2018 16:53:01 +0800 Message-Id: <20181115085306.9910-15-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 15 Nov 2018 08:57:12 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This patch pulls the trigger for multi-page bvecs. Now any request queue which supports queue cluster will see multi-page bvecs. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei --- block/bio.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/block/bio.c b/block/bio.c index 6486722d4d4b..ed6df6f8e63d 100644 --- a/block/bio.c +++ b/block/bio.c @@ -767,12 +767,24 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page, if (bio->bi_vcnt > 0) { struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; - - if (page == bv->bv_page && off == bv->bv_offset + bv->bv_len) { - bv->bv_len += len; - bio->bi_iter.bi_size += len; - return true; - } + struct request_queue *q = NULL; + + if (page == bv->bv_page && off == (bv->bv_offset + bv->bv_len) + && (off + len) <= PAGE_SIZE) + goto merge; + + if (bio->bi_disk) + q = bio->bi_disk->queue; + + /* disable multi-page bvec too if cluster isn't enabled */ + if (!q || !blk_queue_cluster(q) || + ((page_to_phys(bv->bv_page) + bv->bv_offset + bv->bv_len) != + (page_to_phys(page) + off))) + return false; + merge: + bv->bv_len += len; + bio->bi_iter.bi_size += len; + return true; } return false; } From patchwork Thu Nov 15 08:53:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2195514D6 for ; Thu, 15 Nov 2018 08:57:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D70D29B7E for ; Thu, 15 Nov 2018 08:57:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00B482B678; Thu, 15 Nov 2018 08:57:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9213029B7E for ; Thu, 15 Nov 2018 08:57:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 953326B0289; Thu, 15 Nov 2018 03:57:33 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D98F6B028A; Thu, 15 Nov 2018 03:57:33 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A40F6B028B; Thu, 15 Nov 2018 03:57:33 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 4BD076B0289 for ; Thu, 15 Nov 2018 03:57:33 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id z126so43528254qka.10 for ; Thu, 15 Nov 2018 00:57:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=IuzoizmNxooh9FMOsI6khiQZjrW/+dloH4RuOnNRpso=; b=PuRQyuE86Hk+3A42BJCrrmmEX0QVH+UKSP+MdoTbNOANT3Zuc6379CV1WBoZhZgU0m go3ZuyY9C0IgNMUUyD60UXcuYWWAgtpte8h3LIb07NeDP71rHi2pymWoEezyQ4AU1iDQ nQgu6XwytswrjHgF8Gw9G5K+xf8nVziJT64yYAWAZxQPj/UU1Wd7y9iQEK9DS2EXrC2N U8y9YyFV3WLrYQe0qU9ZhEdGHiu4kl1LNS2E/B7i/kfaoz9fEWGSZyQ+AFWL7Z4M/YHR TbvrnY/71pLpssAfpK33+wRVFEdZiIifRHzi/V00rsV70yFAGz6iUbv1SzeNgljO1elV L+DA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gIw8kLbKe8Z5vBUfabaTvWdbZ/xBbPJ8oiPaWpxtoOhzwRQ8bza EIByRP3ckeO5E/sNhUlEj779xWJppOwW2i+OQ7v30/WCgUmqBc7Qc2E6dLzbrMtIOTksA5GhP2P iFcH2ihlzRJRN/0CEx35Ikh+ZdMRbJQB7PkzIePt6wZ+XMlhPlLne1k20zI4h9tu1qg== X-Received: by 2002:a0c:91e8:: with SMTP id r37mr5222914qvr.141.1542272253085; Thu, 15 Nov 2018 00:57:33 -0800 (PST) X-Google-Smtp-Source: AJdET5ebfvxqn90hi9JszHiQJTIStdBjl0+EFF/01PSkA7pMPFeYFqJR7vxoGUNYkjaxKJvb2wqG X-Received: by 2002:a0c:91e8:: with SMTP id r37mr5222896qvr.141.1542272252631; Thu, 15 Nov 2018 00:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272252; cv=none; d=google.com; s=arc-20160816; b=otklEqbGhlOVOZJnmlub+tsqa3GzvODNkTnFTeMHXNWoFqYxP3S7cKt9ED5CFg6SKd 99vwe1isGAzeUwVASwA/kTk44HEhPy4ByUaeITUUGUFWnVzrcs3f6QomR6UITRmHAmN7 2m0JQlZl7sz6H1+2GEkeKq6z98Q7jP4mJdgnzuvY4ZHAANOdpGAl1xfUqKUDWGmNhS8C 4YHNK5BhMZOLRt1pVFJcsH1up39ExZWSe5bmjcrD3WL+ste0VyjLirXkZ+zwxBcJidkK BH/TT+oPdafdk1wachRJ0+iRqwRYxgm1fctlviOPYACXMJht7pFc9gYfSirUNwNSngS8 thTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=IuzoizmNxooh9FMOsI6khiQZjrW/+dloH4RuOnNRpso=; b=FGbrhv8ylUapqDGzHlmieArt/h32zfJE9vRwN8s/I+ZwbKqOVhyoUnI7Rr48b10iMY ggh1tiALAuejYScuvXlYCmEOA32mIY5U9APekZp1KI7oQpwhwbJEmuottC7foMudx2M6 k9HdjkxYwcQooR8mDfLkKcLnwvZruxyzkH+3/tlWkVbsb/v1EtSWX/my8q8v6Lz3dOuf WCSBnRKg2g1bNBsW31O618y3lgHBMP8nQ3f0ltb8EhPppQz9tLguiHOAEKd/ivjCeIni uFZ3iwhUKRQdJtGcHIYgKXYclda+AhzyR4bjPuxmsFT+PQ9jLFdstuck+W7IyN7tc5o+ W6lQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id m9si1446341qtp.201.2018.11.15.00.57.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:57:32 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93CA33680A; Thu, 15 Nov 2018 08:57:31 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1E851054FDC; Thu, 15 Nov 2018 08:57:13 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 15/19] block: always define BIO_MAX_PAGES as 256 Date: Thu, 15 Nov 2018 16:53:02 +0800 Message-Id: <20181115085306.9910-16-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 15 Nov 2018 08:57:31 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Now multi-page bvec can cover CONFIG_THP_SWAP, so we don't need to increase BIO_MAX_PAGES for it. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig --- include/linux/bio.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 5040e9a2eb09..277921ad42e7 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -34,15 +34,7 @@ #define BIO_BUG_ON #endif -#ifdef CONFIG_THP_SWAP -#if HPAGE_PMD_NR > 256 -#define BIO_MAX_PAGES HPAGE_PMD_NR -#else #define BIO_MAX_PAGES 256 -#endif -#else -#define BIO_MAX_PAGES 256 -#endif #define bio_prio(bio) (bio)->bi_ioprio #define bio_set_prio(bio, prio) ((bio)->bi_ioprio = prio) From patchwork Thu Nov 15 08:53:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5EA214BA for ; Thu, 15 Nov 2018 08:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C45ED299C2 for ; Thu, 15 Nov 2018 08:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7B8C2B334; Thu, 15 Nov 2018 08:57:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CA28299C2 for ; Thu, 15 Nov 2018 08:57:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BB466B028B; Thu, 15 Nov 2018 03:57:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 642466B028C; Thu, 15 Nov 2018 03:57:48 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E3E96B028D; Thu, 15 Nov 2018 03:57:48 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 1EB9B6B028B for ; Thu, 15 Nov 2018 03:57:48 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id a199so43318044qkb.23 for ; Thu, 15 Nov 2018 00:57:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=1VthWFeyi5rIl88r9mrERDwdoFL6E3EkYoZDARxIQUk=; b=GcwPq3UfYCAPB5KvFph8vxkHg/MEDKitx+en7Q9zlgdlxNOndUwn2g395i9F6imgZr 8y4XptTB/jo+86KwwEYQnoqEVe570XoptHDQKo243qll7z5s4JKu6ybC4HP5R79/EwZM 0yLsQ6HGFyeLZUndlL1iWxquqkKvBaTxRlxh+YxQIy01GZ22G1u1DLpjhzjGsYIo/nC/ AZbzYPqE5txdy6hvF1mHdIdgsYa1uR98BuwatuCPMVK4rtNaaBXUmxTXG70oosZDIE2n Upbvm4/Cxgze3tOWLyPL+38dN1CP0p3rrRnVngrpPSml+ImxEYEH4F2GVr6/fUF3qGV3 j9EA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gK3BFKXNKwU3PrXhbpCVkHohus+Edjbi5f9c8TaPPg5owmlTzO+ 6gQJY+uUVu2XQscUdR9P5aTOVDQuIB49Ghu8dw88g/LAWuHpqaQComhmdIVapzAHp8Xna3bkBqn quU1ZnJ/EC8sMLulYRcSAQj4LwJuRRBXJqiSyT5Fnu0XHgHG5Hp/eNBSV/ibD+sLqGA== X-Received: by 2002:ad4:510f:: with SMTP id g15mr5447507qvp.46.1542272267886; Thu, 15 Nov 2018 00:57:47 -0800 (PST) X-Google-Smtp-Source: AJdET5eFp26GADgAlYrqWtsvIlSysrKYJG7Lt91xSsMZtTdY7kqfbjaPNw/v89E5wSzu08Qlq/wd X-Received: by 2002:ad4:510f:: with SMTP id g15mr5447496qvp.46.1542272267402; Thu, 15 Nov 2018 00:57:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272267; cv=none; d=google.com; s=arc-20160816; b=VmpEUhZBud3EQvdyfAu+4bc6MZSlvonzeT8FubRo3l/ddkuEhTAjiL5k5dpgzFOEkf NKrttFVy/iDwYkmIc2pK9rGMCdedynLVMABPze3u8rVbUfDu1Yvrxy1wDrlV11zrByby NaVrIdJvun7GgSHS+ILQINtyblag8+j6RJWoGZ/9V5MrzaQQdb8C/PuWb1NoBmvpmGFS dz7djHyfLjXzsIoJDotXR+LRXms1ZGh9GX+CbY/F+0/FkL4xKWmL01r0GqbOhOhnTq1r /Kh4i5z/gls/GRecMm2A4yyJMkMJfDxp2UsACgV74GvpIPpMlBqcWZz4CKSDUZTIEnn2 V3mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=1VthWFeyi5rIl88r9mrERDwdoFL6E3EkYoZDARxIQUk=; b=q+tofPGMjnCcI2P8HMiTjJprG8C0MW1UGHAEHHPwMtyyxPKwUhpXc65uAho+SsUzXp dTPTr8T0Av7OfyJOUncPbyE8CbZegWXjVUS5L/Rya8PCCIruTI/3h57avxKZFaAM5J3j 1Ujc1reQ+Pz97c5NhC2Csh43/M9BDULsRr210ltfmzrplB8KMjJAL75Hm4TRFBo3U/fU 6XQhN6M1anV0sIUsC67ncNNbIjS8SA1rN+Xi1rx3t6Mre4DpukttFWjNKyfmvk0XwPrC bcSVntYOdZ33sBLmrdx5sCZRfa4RUYHquRKBpTpCqro9kRyWvuDWKEZ42m6vupgbpAC5 E6Sg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id i20si1404077qkh.98.2018.11.15.00.57.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:57:47 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 41C9030B9DF6; Thu, 15 Nov 2018 08:57:46 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACE015D75F; Thu, 15 Nov 2018 08:57:33 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 16/19] block: document usage of bio iterator helpers Date: Thu, 15 Nov 2018 16:53:03 +0800 Message-Id: <20181115085306.9910-17-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 15 Nov 2018 08:57:46 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Now multi-page bvec is supported, some helpers may return page by page, meantime some may return segment by segment, this patch documents the usage. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei --- Documentation/block/biovecs.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Documentation/block/biovecs.txt b/Documentation/block/biovecs.txt index 25689584e6e0..bfafb70d0d9e 100644 --- a/Documentation/block/biovecs.txt +++ b/Documentation/block/biovecs.txt @@ -117,3 +117,29 @@ Other implications: size limitations and the limitations of the underlying devices. Thus there's no need to define ->merge_bvec_fn() callbacks for individual block drivers. + +Usage of helpers: +================= + +* The following helpers whose names have the suffix of "_all" can only be used +on non-BIO_CLONED bio, and usually they are used by filesystem code, and driver +shouldn't use them because bio may have been split before they got to the driver: + + bio_for_each_segment_all() + bio_first_bvec_all() + bio_first_page_all() + bio_last_bvec_all() + +* The following helpers iterate over single-page bvec, and the local +variable of 'struct bio_vec' or the reference records single-page IO +vector during the itearation: + + bio_for_each_segment() + bio_for_each_segment_all() + +* The following helper iterates over multi-page bvec, and each bvec may +include multiple physically contiguous pages, and the local variable of +'struct bio_vec' or the reference records multi-page IO vector during the +itearation: + + bio_for_each_bvec() From patchwork Thu Nov 15 08:53:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683893 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9544614D6 for ; Thu, 15 Nov 2018 08:58:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83626299C2 for ; Thu, 15 Nov 2018 08:58:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 768732B334; Thu, 15 Nov 2018 08:58:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 572C6299C2 for ; Thu, 15 Nov 2018 08:58:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 868716B028D; Thu, 15 Nov 2018 03:58:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7EEA26B028E; Thu, 15 Nov 2018 03:58:15 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B8C16B028F; Thu, 15 Nov 2018 03:58:15 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 3F8B36B028D for ; Thu, 15 Nov 2018 03:58:15 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id 92so43695894qkx.19 for ; Thu, 15 Nov 2018 00:58:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=bMFfeA1s4ovfbuodnvxSUpfFDcroT0auXSYw4L+o2mc=; b=BU7EXQ46dZnwh8rqgK4n24r1Ru8+rRnhsQ760KUXRvVwT07PyG+ir5VIL9GdJ7Av08 /TnDfcldSse+zDlzbN1U2PYSXHvdxk2oo5MIAv/mzgUB8jrAJw1yNOToSmdOQ3UAd2QD SyFQ7L4JSKMAmNG59nQWdEEoTyO+XGVQ0E8CD6NCKutcS6wKn3/fbc0ahip5akSoqfS1 giizK/pGZI0XW9E6aop7cvt4sAe9IS3eSxKvL6+adx11y4TKJvNvMPnZRnzoJNqnV0MT 5zTNFCM9x+hZTz4BjfFatN+57rzwebCbUe9MUY4bUb4hMENa2n1DmzNeiUJm/Z7rR7X+ pORw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gItutrvFmlXA8uPoK3HQ79kco2APLCO2WNB3GrAE/5nNnrudjr7 SWbUuEK0h9sUf4bEhVH0rLGYTkmhV2fPwYgGOpBx4kTsPywcCqE9k0Salbd0ILMKwi16+bLRBWF 28myj8Rv+W1Cv0s5sroZIw4Acny7A07VUNjSroQKBdRINLm5Nl2ArUJJKdaZjgHGW7g== X-Received: by 2002:a37:7003:: with SMTP id l3mr5353608qkc.80.1542272295003; Thu, 15 Nov 2018 00:58:15 -0800 (PST) X-Google-Smtp-Source: AJdET5dcqR9aC8OxfgeSpjjAjUDrGEZgDJP4q3LtUOfI6sUrNnB4rue2JWYsOGEDHR2rTTFj4hz0 X-Received: by 2002:a37:7003:: with SMTP id l3mr5353582qkc.80.1542272294426; Thu, 15 Nov 2018 00:58:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272294; cv=none; d=google.com; s=arc-20160816; b=KI+hxW1zIWwDTnbv5YHwcucRJbxabnolMRLf2/SotXmdJHgqmHM284eAfve33/zEW+ 0PeMeN7xJCpxCrDFWx8ZfoYhlNhevKP06S1odpCS40BSXZhDgNcC2/sPd0SB2302CnT7 q9FvixZiRHw0wtwZYWfqZZubO5ilA+rUGLiAYoq6ScYEmrbnDT9yg39nIf0zHlqhIqgL bZx/KoBqKSzIxpmrd24aAXPglrSKqypjFGH42NnQQtnS/rFINrEF34q6tsi65R9lIOLH 9Gn/Xk/fw1t5W0cxW9ajuNNsLVoSE5hNYBdMU4Pn5jXb6RFyOBJ4ZLRNziR+msH5e9WP MurQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=bMFfeA1s4ovfbuodnvxSUpfFDcroT0auXSYw4L+o2mc=; b=osJCXFA25Gd9QTt72WoYgWx10MM5TSwtjhMTcOn6lNyhYWL3FK3A0jsoDG3UbQwG/5 aG8GRVxt7VqZfZqX+fXD/14HneiEgEcU/ZcmnauBQhDNJmVskqYNb7qZrNx8lcrpMJi+ 0526+kC3S4+SU7VEQzUDFrOzUN7bBn6ajp4MtR2lbjUgf45dmuPamjHFwBRqKc2HvocW 34Gd696RJRa1ENfK0BhBNY8ynvyUimL3RTdCMbPb6sRtiycj7pSPCOhwb2qEgQ+eUOIy HruMkbat2E/hZR6kvlFDj7ABh4VIfsTNspsaFkNJsBL8b5Oww9FO7cy11ECFYV/70qmr /m3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id p93si12041096qtd.400.2018.11.15.00.58.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:58:14 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A9533082B72; Thu, 15 Nov 2018 08:58:13 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 869DA611A0; Thu, 15 Nov 2018 08:57:48 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 17/19] block: don't use bio->bi_vcnt to figure out segment number Date: Thu, 15 Nov 2018 16:53:04 +0800 Message-Id: <20181115085306.9910-18-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 15 Nov 2018 08:58:13 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It is wrong to use bio->bi_vcnt to figure out how many segments there are in the bio even though CLONED flag isn't set on this bio, because this bio may be splitted or advanced. So always use bio_segments() in blk_recount_segments(), and it shouldn't cause any performance loss now because the physical segment number is figured out in blk_queue_split() and BIO_SEG_VALID is set meantime since bdced438acd83ad83a6c ("block: setup bi_phys_segments after splitting"). Cc: Dave Chinner Cc: Kent Overstreet Fixes: 7f60dcaaf91 ("block: blk-merge: fix blk_recount_segments()") Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig --- block/blk-merge.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index cb9f49bcfd36..153a659fde74 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -429,13 +429,7 @@ void blk_recalc_rq_segments(struct request *rq) void blk_recount_segments(struct request_queue *q, struct bio *bio) { - unsigned short seg_cnt; - - /* estimate segment number by bi_vcnt for non-cloned bio */ - if (bio_flagged(bio, BIO_CLONED)) - seg_cnt = bio_segments(bio); - else - seg_cnt = bio->bi_vcnt; + unsigned short seg_cnt = bio_segments(bio); if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) && (seg_cnt < queue_max_segments(q))) From patchwork Thu Nov 15 08:53:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F163B17EE for ; Thu, 15 Nov 2018 08:58:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E17CE29784 for ; Thu, 15 Nov 2018 08:58:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D56FA2C2B4; Thu, 15 Nov 2018 08:58:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FEA429784 for ; Thu, 15 Nov 2018 08:58:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 535D66B028F; Thu, 15 Nov 2018 03:58:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4E3366B0290; Thu, 15 Nov 2018 03:58:25 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AC796B0291; Thu, 15 Nov 2018 03:58:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 0C9826B028F for ; Thu, 15 Nov 2018 03:58:25 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id 80so43923419qkd.0 for ; Thu, 15 Nov 2018 00:58:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=hcXKumjyShHoMSZciWJNOWh20lA69nfydjcP7zW2DO0=; b=WsVdEAvTQgDK5be5+tiyK5bKvYTniYRwddWPxETUeud8J2RFzBxVE1/M9Uk5lm1ZQE zuxrUCOAC10PGw0xDh6Z8Jik7xFFpWijVcRaCkvhzdGo7tFABXeMwrwcqIN9fr2kdB9E vlEZhEMZ+xztf+q05fOgAiZD8nSSrQ39ZMUkyMDMpwVKPwOAU9J3br89NQzRysRfLLrr Ogyx+CALn3EPptOb4ZmxXARP71crbNMAT2vR1PCSN/3NHygPjDRU7rAoS3pdy1h7Q064 qFBMR6bM4iiejbcBoBI/rYiDs056C5g5WhkZHiAp3Kfdb6DrrV5qQSLFMk31iufF0WgQ 1NFg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gJljY7Ee/6fpZmSLvov0hqeZBWqqetq4gj8W/UqWzNQXWzeuars JPd7MT6djfd1Qoo51dX/9Y5NTHqJR7CJZurbGuPzTxE7xDPDdwY4jL55U4WpibmcQzlDRjkTM0k /MrCbnt1eoLnFBl1VoT9V6RwwhWIAIUR8Xx5CShT8BIv+PhRITD5DXza9ciQMkRKz8w== X-Received: by 2002:a0c:d5ba:: with SMTP id g55mr5328128qvi.37.1542272304782; Thu, 15 Nov 2018 00:58:24 -0800 (PST) X-Google-Smtp-Source: AJdET5c2PMGvaPbcXRo8I6UblpJmAWZ3IVIXKQKB68BllaB60WJSVbem+lVhQOjXpZW1ShBP1Adr X-Received: by 2002:a0c:d5ba:: with SMTP id g55mr5328099qvi.37.1542272304160; Thu, 15 Nov 2018 00:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272304; cv=none; d=google.com; s=arc-20160816; b=tuDeP/pIWMj5o9QpWJd8OQB3cnRHUwm+LwcNg3f+tUfA55DUKsPmQ3d12G8Grhh/Rt vWhvuDztB2qKT3InFmWN5XQvA6kzwTKJ9Ggw6lZW6g1gkZgeEfSHQ8rI9T8vWYLPskTt cjZhbl56GHeMRijm7sYErXOjCND9N0AANVVE/FpygR/h9RFYY6EHkrSM8POZV1/up9o/ V5BxBPe9yRpd53kwGIFbvXvUUywLaHF2u2vqBwqJXdgqUFguQ+cKSf6QJ91wPbCYgqSt ro5GZxSmHD7Up0E5hVSEx9MoWsOoprwF0jr+for06pkiYGkbNVgWgEydzpNOXEeYw90b sBPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=hcXKumjyShHoMSZciWJNOWh20lA69nfydjcP7zW2DO0=; b=prNfC/37ODpQ4UZW5WeQzB6nE/Nw0UFoW2vIImHYiq5qxOZxBBVjJlPXPKDh2npT1v 3VMDxamJ4VrM2SU1npDnIiqgaTRW4OrZ0QVDTohcxkWmsYpkPpUWm+5T3EyW093tw8yA tFRRRRahY01vtFEld1BgcMxeMtB+sC29Kx7o4I/3sFkmWKbJmbJdR+KXZ/rCeUOZrBAZ rava++FpTxufQzGIpPZGuFUXEfAD+PndiOju67+IjT1XpYrh/1HDUqEzwaoENdR1W9bp 3bMYvn4WahallXohIpbykuIh+luG5U4vKXXs90bzdeyoX4CwsC3nIs6tDj+41qR7xHZb aZZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id j129si9978040qkj.265.2018.11.15.00.58.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:58:24 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3B52308A95D; Thu, 15 Nov 2018 08:58:22 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A42760BF7; Thu, 15 Nov 2018 08:58:15 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 18/19] block: kill QUEUE_FLAG_NO_SG_MERGE Date: Thu, 15 Nov 2018 16:53:05 +0800 Message-Id: <20181115085306.9910-19-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 15 Nov 2018 08:58:23 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Since bdced438acd83ad83a6c ("block: setup bi_phys_segments after splitting"), physical segment number is mainly figured out in blk_queue_split() for fast path, and the flag of BIO_SEG_VALID is set there too. Now only blk_recount_segments() and blk_recalc_rq_segments() use this flag. Basically blk_recount_segments() is bypassed in fast path given BIO_SEG_VALID is set in blk_queue_split(). For another user of blk_recalc_rq_segments(): - run in partial completion branch of blk_update_request, which is an unusual case - run in blk_cloned_rq_check_limits(), still not a big problem if the flag is killed since dm-rq is the only user. Multi-page bvec is enabled now, QUEUE_FLAG_NO_SG_MERGE doesn't make sense any more. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval --- block/blk-merge.c | 31 ++++++------------------------- block/blk-mq-debugfs.c | 1 - block/blk-mq.c | 3 --- drivers/md/dm-table.c | 13 ------------- include/linux/blkdev.h | 1 - 5 files changed, 6 insertions(+), 43 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 153a659fde74..06be298be332 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -351,8 +351,7 @@ void blk_queue_split(struct request_queue *q, struct bio **bio) EXPORT_SYMBOL(blk_queue_split); static unsigned int __blk_recalc_rq_segments(struct request_queue *q, - struct bio *bio, - bool no_sg_merge) + struct bio *bio) { struct bio_vec bv, bvprv = { NULL }; int cluster, prev = 0; @@ -379,13 +378,6 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, nr_phys_segs = 0; for_each_bio(bio) { bio_for_each_bvec(bv, bio, iter) { - /* - * If SG merging is disabled, each bio vector is - * a segment - */ - if (no_sg_merge) - goto new_segment; - if (prev && cluster) { if (seg_size + bv.bv_len > queue_max_segment_size(q)) @@ -420,27 +412,16 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, void blk_recalc_rq_segments(struct request *rq) { - bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE, - &rq->q->queue_flags); - - rq->nr_phys_segments = __blk_recalc_rq_segments(rq->q, rq->bio, - no_sg_merge); + rq->nr_phys_segments = __blk_recalc_rq_segments(rq->q, rq->bio); } void blk_recount_segments(struct request_queue *q, struct bio *bio) { - unsigned short seg_cnt = bio_segments(bio); - - if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) && - (seg_cnt < queue_max_segments(q))) - bio->bi_phys_segments = seg_cnt; - else { - struct bio *nxt = bio->bi_next; + struct bio *nxt = bio->bi_next; - bio->bi_next = NULL; - bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio, false); - bio->bi_next = nxt; - } + bio->bi_next = NULL; + bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio); + bio->bi_next = nxt; bio_set_flag(bio, BIO_SEG_VALID); } diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index f021f4817b80..e188b1090759 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -128,7 +128,6 @@ static const char *const blk_queue_flag_name[] = { QUEUE_FLAG_NAME(SAME_FORCE), QUEUE_FLAG_NAME(DEAD), QUEUE_FLAG_NAME(INIT_DONE), - QUEUE_FLAG_NAME(NO_SG_MERGE), QUEUE_FLAG_NAME(POLL), QUEUE_FLAG_NAME(WC), QUEUE_FLAG_NAME(FUA), diff --git a/block/blk-mq.c b/block/blk-mq.c index 411be60d0cb6..ed484af5744b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2755,9 +2755,6 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT; - if (!(set->flags & BLK_MQ_F_SG_MERGE)) - queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q); - q->sg_reserved_size = INT_MAX; INIT_DELAYED_WORK(&q->requeue_work, blk_mq_requeue_work); diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 9038c302d5c2..22fed6987aea 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1698,14 +1698,6 @@ static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev, return q && !blk_queue_add_random(q); } -static int queue_supports_sg_merge(struct dm_target *ti, struct dm_dev *dev, - sector_t start, sector_t len, void *data) -{ - struct request_queue *q = bdev_get_queue(dev->bdev); - - return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags); -} - static bool dm_table_all_devices_attribute(struct dm_table *t, iterate_devices_callout_fn func) { @@ -1902,11 +1894,6 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, if (!dm_table_supports_write_zeroes(t)) q->limits.max_write_zeroes_sectors = 0; - if (dm_table_all_devices_attribute(t, queue_supports_sg_merge)) - blk_queue_flag_clear(QUEUE_FLAG_NO_SG_MERGE, q); - else - blk_queue_flag_set(QUEUE_FLAG_NO_SG_MERGE, q); - dm_table_verify_integrity(t); /* diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index e67ad2dd025e..c5c7799e88c2 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -604,7 +604,6 @@ struct request_queue { #define QUEUE_FLAG_SAME_FORCE 15 /* force complete on same CPU */ #define QUEUE_FLAG_DEAD 16 /* queue tear-down finished */ #define QUEUE_FLAG_INIT_DONE 17 /* queue is initialized */ -#define QUEUE_FLAG_NO_SG_MERGE 18 /* don't attempt to merge SG segments*/ #define QUEUE_FLAG_POLL 19 /* IO polling enabled if set */ #define QUEUE_FLAG_WC 20 /* Write back caching */ #define QUEUE_FLAG_FUA 21 /* device supports FUA writes */ From patchwork Thu Nov 15 08:53:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9940D14D6 for ; Thu, 15 Nov 2018 08:58:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86CAD2C37A for ; Thu, 15 Nov 2018 08:58:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 776C52C381; Thu, 15 Nov 2018 08:58:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC1F72C382 for ; Thu, 15 Nov 2018 08:58:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E58B76B0291; Thu, 15 Nov 2018 03:58:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DE1C06B0292; Thu, 15 Nov 2018 03:58:53 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAABF6B0293; Thu, 15 Nov 2018 03:58:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 9F0F26B0291 for ; Thu, 15 Nov 2018 03:58:53 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id s70so44255326qks.4 for ; Thu, 15 Nov 2018 00:58:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=ifLe+kAdjlgWkOolSe71+0MDOzPqwoqhk2buoKqIZvE=; b=jIGCM/HwkBZW9H2Rp73SDPSSXBqLZbOsRzAsIXKmj0vlKt645Q6x80mFid2yzbVOi8 /IDjERkPYQWr/GJbwep70OHFo8lUbTDxOnP9tyj0S4CZkb1K4iLxBX06QrCfwKFJP9HX KaGOpzQW3huv9bszlJhtYllCu2XHdjzKjc7zoz7iAnBSqY/9fU+JbW9O2e0QOTho8dkT y+iXsVpP8c26W70oWWN1ffQPWlO4PGQbfhGbg3jYkg8RGC37hcEy7NATWUgDvbCSYT2Q hr9XTQQQhITAYOXlwfaQAjSkmUs3LZs9kabwJHxSYeuAUXGi5lfOO8wpF3HsxcH1kBCl STeQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gIWX1BpUwZmvbEUOJup0BCiyRK2dAcunndu93yyF2D+wWbnIS+9 kdIWkFXMZUv8enTYdST82VyGeCUJUWajR5Zk639VnpUFEIyPjRevNxXQTn1heNInnVkppEVzC6a u8/LSPOBC7e3+6dO9EQmy4IaJ/+0p6VFfzMRa/xLiXu91DsJsn63ICLhBdUWVoEwdTg== X-Received: by 2002:ac8:4a10:: with SMTP id x16mr5318139qtq.164.1542272333390; Thu, 15 Nov 2018 00:58:53 -0800 (PST) X-Google-Smtp-Source: AJdET5cH5LAoNu7hfGmjhnP1sblW/QAT8514hJXFpQ8k1lqg39A8SYIg1FhfApRCn6qNAAuU10fE X-Received: by 2002:ac8:4a10:: with SMTP id x16mr5318110qtq.164.1542272332723; Thu, 15 Nov 2018 00:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272332; cv=none; d=google.com; s=arc-20160816; b=m1sb1E3wGvGOlBP0/pIuO57T+AkZJGUItZKQU2fUt8pQ9zh0lU5MQQLuw6FGLl7f3B WLQuqswJXKCdEjzPAlZQtnhlO11m9G1tIoRnv+uN7fxOci2mNUJh+Adc9eZ5uiC1RR5V sa6/kwSfe+2+SJ7A/dJi1mrPBTh8rq7EpCUqnZzdCYqRmVgFrXRSEyNbP1fi9JV8RgWz bDkbz6qn9XeaTIB/Jxz98r+7CCVi7iOFHbsLPX3VJEfrWRvhoCOv6DZscosovD+qkxb8 sxiMtb52uTQhiJMCmBP82vI6U7Wazu3zk8jUgg+2A6uu5yRhUWQec0Pn1DLqxzyLp9t2 v9Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=ifLe+kAdjlgWkOolSe71+0MDOzPqwoqhk2buoKqIZvE=; b=ZjLornF9Yn0FuVnlLjIW1Mloo6DCaB9tCgPUwdvcK0J2SOwBJjKLSK7AjTzPcNuVzR nLXQanHF9PFKpvdEhhjA+J8k3p+lmIn98HzDpTok5eSGdq2SeZ7Dumg7DSfdh/9A2lLC kpe3iU/MheVx8ei8UcL+2d5Kq+id8QTG0Xvp3ANzZHT5tHU51qJs2/CJuDn7MAFUjxLO 4j2SqRCwTAspie0Av4WV9BLjiSYxJP7sS319AvDDztUkdMMR9rJVeWDaR0mhDG/AVVg2 Y/plm7pn+64fxiJuktiq1VhKjnYVBakRVdhfXGJo0co+zdc1HvhWDlFI/8sSB4bgWJUV iOMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id k9si2023700qvd.103.2018.11.15.00.58.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:58:52 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 830623086259; Thu, 15 Nov 2018 08:58:51 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1733D105B1F3; Thu, 15 Nov 2018 08:58:24 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 19/19] block: kill BLK_MQ_F_SG_MERGE Date: Thu, 15 Nov 2018 16:53:06 +0800 Message-Id: <20181115085306.9910-20-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 15 Nov 2018 08:58:51 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP QUEUE_FLAG_NO_SG_MERGE has been killed, so kill BLK_MQ_F_SG_MERGE too. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval --- block/blk-mq-debugfs.c | 1 - drivers/block/loop.c | 2 +- drivers/block/nbd.c | 2 +- drivers/block/rbd.c | 2 +- drivers/block/skd_main.c | 1 - drivers/block/xen-blkfront.c | 2 +- drivers/md/dm-rq.c | 2 +- drivers/mmc/core/queue.c | 3 +-- drivers/scsi/scsi_lib.c | 2 +- include/linux/blk-mq.h | 1 - 10 files changed, 7 insertions(+), 11 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index e188b1090759..e1c12358391a 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -250,7 +250,6 @@ static const char *const alloc_policy_name[] = { static const char *const hctx_flag_name[] = { HCTX_FLAG_NAME(SHOULD_MERGE), HCTX_FLAG_NAME(TAG_SHARED), - HCTX_FLAG_NAME(SG_MERGE), HCTX_FLAG_NAME(BLOCKING), HCTX_FLAG_NAME(NO_SCHED), }; diff --git a/drivers/block/loop.c b/drivers/block/loop.c index a3fd418ec637..d509902a8046 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1907,7 +1907,7 @@ static int loop_add(struct loop_device **l, int i) lo->tag_set.queue_depth = 128; lo->tag_set.numa_node = NUMA_NO_NODE; lo->tag_set.cmd_size = sizeof(struct loop_cmd); - lo->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + lo->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; lo->tag_set.driver_data = lo; err = blk_mq_alloc_tag_set(&lo->tag_set); diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 08696f5f00bb..999c94de78e5 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1570,7 +1570,7 @@ static int nbd_dev_add(int index) nbd->tag_set.numa_node = NUMA_NO_NODE; nbd->tag_set.cmd_size = sizeof(struct nbd_cmd); nbd->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | - BLK_MQ_F_SG_MERGE | BLK_MQ_F_BLOCKING; + BLK_MQ_F_BLOCKING; nbd->tag_set.driver_data = nbd; err = blk_mq_alloc_tag_set(&nbd->tag_set); diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 8e5140bbf241..3dfd300b5283 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3988,7 +3988,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev) rbd_dev->tag_set.ops = &rbd_mq_ops; rbd_dev->tag_set.queue_depth = rbd_dev->opts->queue_depth; rbd_dev->tag_set.numa_node = NUMA_NO_NODE; - rbd_dev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + rbd_dev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; rbd_dev->tag_set.nr_hw_queues = 1; rbd_dev->tag_set.cmd_size = sizeof(struct work_struct); diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index a10d5736d8f7..a7040f9a1b1b 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -2843,7 +2843,6 @@ static int skd_cons_disk(struct skd_device *skdev) skdev->sgs_per_request * sizeof(struct scatterlist); skdev->tag_set.numa_node = NUMA_NO_NODE; skdev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | - BLK_MQ_F_SG_MERGE | BLK_ALLOC_POLICY_TO_MQ_FLAG(BLK_TAG_ALLOC_FIFO); skdev->tag_set.driver_data = skdev; rc = blk_mq_alloc_tag_set(&skdev->tag_set); diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 56452cabce5b..297412bf23e1 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -977,7 +977,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, } else info->tag_set.queue_depth = BLK_RING_SIZE(info); info->tag_set.numa_node = NUMA_NO_NODE; - info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; info->tag_set.cmd_size = sizeof(struct blkif_req); info->tag_set.driver_data = info; diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index 7cd36e4d1310..140ada0b99fc 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -536,7 +536,7 @@ int dm_mq_init_request_queue(struct mapped_device *md, struct dm_table *t) md->tag_set->ops = &dm_mq_ops; md->tag_set->queue_depth = dm_get_blk_mq_queue_depth(); md->tag_set->numa_node = md->numa_node_id; - md->tag_set->flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + md->tag_set->flags = BLK_MQ_F_SHOULD_MERGE; md->tag_set->nr_hw_queues = dm_get_blk_mq_nr_hw_queues(); md->tag_set->driver_data = md; diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index 6edffeed9953..6a0e9f6b6412 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -387,8 +387,7 @@ static int mmc_mq_init_queue(struct mmc_queue *mq, int q_depth, mq->tag_set.ops = mq_ops; mq->tag_set.queue_depth = q_depth; mq->tag_set.numa_node = NUMA_NO_NODE; - mq->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE | - BLK_MQ_F_BLOCKING; + mq->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING; mq->tag_set.nr_hw_queues = 1; mq->tag_set.cmd_size = sizeof(struct mmc_queue_req); mq->tag_set.driver_data = mq; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 5d83a162d03b..c7b0e4ff5e6d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1883,7 +1883,7 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) shost->tag_set.queue_depth = shost->can_queue; shost->tag_set.cmd_size = cmd_size; shost->tag_set.numa_node = NUMA_NO_NODE; - shost->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + shost->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; shost->tag_set.flags |= BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy); shost->tag_set.driver_data = shost; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 929e8abc5535..ca7389d7e04f 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -211,7 +211,6 @@ struct blk_mq_ops { enum { BLK_MQ_F_SHOULD_MERGE = 1 << 0, BLK_MQ_F_TAG_SHARED = 1 << 1, - BLK_MQ_F_SG_MERGE = 1 << 2, BLK_MQ_F_BLOCKING = 1 << 5, BLK_MQ_F_NO_SCHED = 1 << 6, BLK_MQ_F_ALLOC_POLICY_START_BIT = 8,