Message ID | 20181126021720.19471-12-ming.lei@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 0F62E1750 for <patchwork-linux-mm@patchwork.kernel.org>; Mon, 26 Nov 2018 02:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F057C29A3D for <patchwork-linux-mm@patchwork.kernel.org>; Mon, 26 Nov 2018 02:20:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E417329A3F; Mon, 26 Nov 2018 02:20:00 +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 838F829A3D for <patchwork-linux-mm@patchwork.kernel.org>; Mon, 26 Nov 2018 02:20:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A33526B3F7A; Sun, 25 Nov 2018 21:19:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A08236B3F7C; Sun, 25 Nov 2018 21:19:59 -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 8F9A86B3F7D; Sun, 25 Nov 2018 21:19:59 -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 5EF476B3F7A for <linux-mm@kvack.org>; Sun, 25 Nov 2018 21:19:59 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id 67so17782202qkj.18 for <linux-mm@kvack.org>; Sun, 25 Nov 2018 18:19:59 -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=NqRnUsjWXdLCn3+BBd1E+TE68uZNAdSmdjd3DOkgrrI=; b=Sm/PZQ7/MPkpjchmRfOT1pmWr9MShyIDbypGfsRuKgTuLCZvcpeAFpoF4jf/q9jo18 1m+EODQR2HD/NrYswQ5iQLQmWyOUUOeBFoK5qtno5/dnqMCfBmxHNtvv/vNu30/TnZgs 4gXwzhXG7tiolyO4widmX6Vpa0D2YhZjAmAn4d9iVR2OgPcnYr0zTrAc5845dDh7a9S2 v/eOzUvK4Vx5YP15juOSZZv/JaFVrH9ifS0LltNENSzcKnpyBnKAfPDpGRcWLJOpKhAe AZHTHDcmPnDr3QGRLgueIrVrJ99Q/dBkoVHp2hfV17FLS0BU85Mk/LC1w3L8qifPzUPL 3OOA== 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: AA+aEWbpYCeuvtezuiq6L9X5SBs9Ot9dvKKKuPdJY+Sdnbx/hWeTbUWO 2lG+0/YRCIqscr+kvj9BQBC4h0FMJaC/40wsE7Vqs3CW1IA32tyvTOy/k9WFq3DmfBGjEY2GuvU RbJf7Q3fSBgO6bNAqdClh4vVaUp8XX6V+psthdBc0p+hIkheEojyjf7hy3EDTWqliSg== X-Received: by 2002:ac8:1414:: with SMTP id k20mr24084106qtj.298.1543198799150; Sun, 25 Nov 2018 18:19:59 -0800 (PST) X-Google-Smtp-Source: AJdET5erCyFJ3ZKoH5q1OJzy+PYOrBUJLURUCY+MnfvGgNVXWhM7tjNxry7zVyx6bXx+RTcgxU2V X-Received: by 2002:ac8:1414:: with SMTP id k20mr24084093qtj.298.1543198798611; Sun, 25 Nov 2018 18:19:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198798; cv=none; d=google.com; s=arc-20160816; b=C/oKQTYdrWRRsvdiypanJ51h/92Jbn71HYHMfwNZw09VtH7w1J91ktCNkhZMUZ/ZuA jBOtZAk8uJeLWNpamajaJ4AnsmIsGg1a8RTkzwwrm7ijtWlheppfguRGgz3ApWRAYH9B 8YQurLFwuvpGgsKANydMFMzOkxCtk4yW5Ze/YUnB1B/gZ9kgBokMMeSAobFl/OKzkM4J J3sbLPeD6y6ty6EBHSTKfSKdEuR5mwNz3bUlPEUovvKs4PkpULibnbtrBrEmnNc/2YyN ZUCMdLOnF20JT1mUaZDOihuqU0VBydxJszliH24N0wPptMY/4pagXoMu9Uyom1ICKlHR kpqw== 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=NqRnUsjWXdLCn3+BBd1E+TE68uZNAdSmdjd3DOkgrrI=; b=SDULwPghibqWlWohBoFA7xFpoebZIrNiXykrt52h7idsX1IXkJyQ8YZe/mIKzZ289f +lIWGF4vAfJA1RQsDvm5PAyzY0PCFWuh7oNQJ158L7juTdQXJ80/6+kxXKIiXzyGTkU8 OWtlLjuIgu3+OkyH022Sv5TTpQs4fkZDyBDBbEiNsiEHCwOcZJp5aEQ1u60zD+wGyym4 WaDaaLHcz99PR38cDTiBV/KFy8jRIn1tXLNjBLu6OjYM1psKMASgvwagz5VB7eEsnTbj p/lk1CTaXiVi6xsMvRN8y/+snPoclAECF06eQiYEqhMXnoLopGUSPX9RqgqWzxEKdQVn vkQg== 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 g11si7617480qth.320.2018.11.25.18.19.58 for <linux-mm@kvack.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:19:58 -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 9B82E3001E46; Mon, 26 Nov 2018 02:19:57 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD4101001947; Mon, 26 Nov 2018 02:19:45 +0000 (UTC) From: Ming Lei <ming.lei@redhat.com> To: Jens Axboe <axboe@kernel.dk> Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o <tytso@mit.edu>, Omar Sandoval <osandov@fb.com>, Sagi Grimberg <sagi@grimberg.me>, Dave Chinner <dchinner@redhat.com>, Kent Overstreet <kent.overstreet@gmail.com>, Mike Snitzer <snitzer@redhat.com>, dm-devel@redhat.com, Alexander Viro <viro@zeniv.linux.org.uk>, linux-fsdevel@vger.kernel.org, Shaohua Li <shli@kernel.org>, linux-raid@vger.kernel.org, David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org, "Darrick J . Wong" <darrick.wong@oracle.com>, linux-xfs@vger.kernel.org, Gao Xiang <gaoxiang25@huawei.com>, Christoph Hellwig <hch@lst.de>, linux-ext4@vger.kernel.org, Coly Li <colyli@suse.de>, linux-bcache@vger.kernel.org, Boaz Harrosh <ooo@electrozaur.com>, Bob Peterson <rpeterso@redhat.com>, cluster-devel@redhat.com, Ming Lei <ming.lei@redhat.com> Subject: [PATCH V12 11/20] block: introduce bvec_last_segment() Date: Mon, 26 Nov 2018 10:17:11 +0800 Message-Id: <20181126021720.19471-12-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.47]); Mon, 26 Nov 2018 02:19:57 +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: <linux-mm.kvack.org> X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
block: support multi-page bvec
|
expand
|
diff --git a/include/linux/bvec.h b/include/linux/bvec.h index d441486db605..ca6e630f88ab 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -131,4 +131,26 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, .bi_bvec_done = 0, \ } +/* + * Get the last single-page segment from the multi-page 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 - 1) / PAGE_SIZE; + + 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 */