From patchwork Sat Oct 29 08:08:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9403121 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 38B8F60588 for ; Sat, 29 Oct 2016 08:12:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 272E02A2D0 for ; Sat, 29 Oct 2016 08:12:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BDA12A522; Sat, 29 Oct 2016 08:12:05 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAF912A2D0 for ; Sat, 29 Oct 2016 08:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753705AbcJ2IL7 (ORCPT ); Sat, 29 Oct 2016 04:11:59 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33613 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752291AbcJ2ILy (ORCPT ); Sat, 29 Oct 2016 04:11:54 -0400 Received: by mail-pf0-f196.google.com with SMTP id i85so3370744pfa.0; Sat, 29 Oct 2016 01:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V2Am3VihM32eKyRAuUQQIDK5ALYmTKdYcjJ4Vd2mkB4=; b=ezVuJYWD0JtgbFYzUVgsPourx9Eu/AeEjpip4uf45I6lLKrEz987//IsAf7F3Td159 cOzjvuA/Y3TI+1NZy8+wgdQU/NFhOszCdPa+yJI7bT10qGQKyZ2a9vyYL6J8/U1V8EIM P9q956gHGhpYXMk2eqKovf4g2GmgR1m5Nz+xDq/i/tskDVci4NzNNEMo61n3ePfpgGBA wRA5U1OBDYgVHqRpflqIKXKDvm1VKGX9DXvOWZm5GUHiW5ungZ/fBI8AlFCDSMrmk724 caAvWdNhmGuM2NcnalD5W4fst9ZS29JswdWBNhNMjOiPP65vDwBQPQGJhsq5U26FIhUG cBkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V2Am3VihM32eKyRAuUQQIDK5ALYmTKdYcjJ4Vd2mkB4=; b=gN/skNo/+tOdum74xnllRtozHOa8HIwopEsFVh2XQdMP7i3fb2ASWOOsIXdybwtjd7 tjfuQEJaRhrwP8/lIbvt4jT1Iveq2ftsUwQHT84/7fEV7exzw8H07m9Irf/WLMe91OaF atm7sksPuiQn2BigwpvRXEQz1KsWAVdh1IQIHqMnS119cZAT2qStewFY9isOOVV1ycqj 4LXUh9Ac/yAGVqclgEc+G8M0T03yn3WCXSGe0JX0kJkyGPOTJcwAL7X647NAT0Es+4ue L84JADtH2p/4NXqDx1wpfItZFnJ9OaUtUFL9wWdLengxaiB9C1UGDrv5h0rLLxALcNXC k/hg== X-Gm-Message-State: ABUngvdcYBCCZYHqg6BjHwzegJkNvOom2hh8PWl9NeSeMMPXUzrbL7mvdTpAOyGT2/1EYA== X-Received: by 10.99.56.74 with SMTP id h10mr26017753pgn.63.1477728713088; Sat, 29 Oct 2016 01:11:53 -0700 (PDT) Received: from localhost ([45.34.23.101]) by smtp.gmail.com with ESMTPSA id s64sm23473653pfk.81.2016.10.29.01.11.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Oct 2016 01:11:52 -0700 (PDT) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , "Kirill A . Shutemov" , Ming Lei , Mike Christie , Hannes Reinecke , Keith Busch , Mike Snitzer Subject: [PATCH 01/60] block: bio: introduce bio_init_with_vec_table() Date: Sat, 29 Oct 2016 16:08:00 +0800 Message-Id: <1477728600-12938-2-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477728600-12938-1-git-send-email-tom.leiming@gmail.com> References: <1477728600-12938-1-git-send-email-tom.leiming@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some drivers often uses external bvec table, so introduce this helper for this case. It is always safe to access the bio->bi_io_vec in this way for this case. After converting to this helper, it will becomes a bit easier to evaluate the remaining direct access to bio->bi_io_vec, so it can help to prepare for the following multipage bvec support. Signed-off-by: Ming Lei --- include/linux/bio.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index 97cb48f03dc7..8634bd24984c 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -664,6 +664,16 @@ static inline void bio_inc_remaining(struct bio *bio) atomic_inc(&bio->__bi_remaining); } +static inline void bio_init_with_vec_table(struct bio *bio, + struct bio_vec *table, + unsigned max_vecs) +{ + bio_init(bio); + bio->bi_io_vec = table; + bio->bi_max_vecs = max_vecs; +} + + /* * bio_set is used to allow other portions of the IO system to * allocate their own private memory pools for bio and iovec structures.