Message ID | 20190111110127.21664-10-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 579DC6C5 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 11 Jan 2019 11:04:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 469C9297AD for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 11 Jan 2019 11:04:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A7B229AFF; Fri, 11 Jan 2019 11:04:08 +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 B4099297AD for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 11 Jan 2019 11:04:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D86418E000B; Fri, 11 Jan 2019 06:04:06 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D358F8E0001; Fri, 11 Jan 2019 06:04:06 -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 C26018E000B; Fri, 11 Jan 2019 06:04:06 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 955848E0001 for <linux-mm@kvack.org>; Fri, 11 Jan 2019 06:04:06 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id z6so16114396qtj.21 for <linux-mm@kvack.org>; Fri, 11 Jan 2019 03:04:06 -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=rVuv8G5IzGIxz80i47kF2LMs1DUZBo46LCTYPEmo6r22O1mG3LJrjsBMsKt24Nduvl vZxB6uxV5L1GuDgveun1vWEhiBvaD4UkcJUfxsZxq5Khj6dWf1vbQC/2tESZULaMm26e G/9OukPRkk2hX3ap4dUvwvHJDCiz0YJFj+XBQGD1XvSfq4xpmwz9cfUd6Eh++9zIAZi4 wDt2hMvPBsNdQEAUblwPxFBBmg/svkqwMJSGGdZ4qsyCvvvBmg/I6prgmF2AUknm7/PU CSrKEqN1FvIKspec0Q/WF2RjiO+k3+UNJ2XycDHJ6XBwqfkKg0yf8Yl42VqJR34Mr3RO rmHQ== 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: AJcUukfP7ISJ+JRDvd/+AmVKzm9HdqbmWJwVAJOHeL3gA7pes64rahMT YVc4oXXF7RPm8QUNrXvVBSuRcFgQQCqdoU/kJUUZp8naKgldIqNEN/4iL2HyQWtSmD/DSu5yisv QsL9Sg3ClVXXfk+JD7WifiJuJCaD+tgRj7TOxkNnsPP5jmgok4pt7n9djYPXBok6rTA== X-Received: by 2002:a0c:9e05:: with SMTP id p5mr13259077qve.246.1547204646396; Fri, 11 Jan 2019 03:04:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN6rKFCOdzZd/PP/e0s/KH+DiKuEKFYFfqxNwjMzXb+63r9Lg34YS3vEIAWHuUzjC+asr9K0 X-Received: by 2002:a0c:9e05:: with SMTP id p5mr13259045qve.246.1547204645946; Fri, 11 Jan 2019 03:04:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204645; cv=none; d=google.com; s=arc-20160816; b=OfUoqbV9Gd2hRWTi7ucHMiBjZGo8dQ/kqu8j45fuGCV+147I3hZXLo7x3/AW/ak59E oj1IyXlcR9oIUd/woq9v4wXg1cq6WOKm9gunIUIAxsAmzVcgG7ZwwapyB9xomLupX7SN mhbP3TVkBkynLsEWzUMx0ea0fcg62VnkV/OLNBu+4oGUkZUBEjjsNSYqJGF9+bdmffOI GKuQRVORfvKlfXcTueAj2csVUbFWwSufhShO1AIbD/wzrTljpELM5zshMAwiYVpYFo4p XpJCkPAatGqCe6srkcaHD+JnYE7+QxFwPl0DUaj33KpdXAod0qYtV9Oa6VK8mYesyYkJ sbKQ== 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=P++KJUSC1mWppyHsIfCOH1WAEmKvKfc3wn48VxItEzHaGlikRyXL6H1DTh/XlD4lHB TX3l7MnPDYsecZt+zZFu+N2QZyX6fGlGgdujfRFzYQMpputwAi9W4eaghAp8/dWn7GXD 6TDIU1PjEbfFlX9nx0BPZU6z3beuH/Ef86gXmRSCrlmSIY2N8ejTJ0Xg45Amo5jEoZwY qRUjQmxJ9YVJ8Ndl4tFLtnAC/JDjKIlDi/tkM9chfTl6eiy2Zy8jjzZz9JYO5BuKJncw 4JntWbbyDr+A50WeusdbK3RTdgDxdryleCusKgcxQDWmvglLS4IAAglV62s8ML/7O+A4 LwVA== 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 p8si2509811qki.221.2019.01.11.03.04.05 for <linux-mm@kvack.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:04:05 -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 C297F7E45A; Fri, 11 Jan 2019 11:04:04 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 368A71019626; Fri, 11 Jan 2019 11:03:53 +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, 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 V13 09/19] block: introduce bvec_last_segment() Date: Fri, 11 Jan 2019 19:01:17 +0800 Message-Id: <20190111110127.21664-10-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.27]); Fri, 11 Jan 2019 11:04:05 +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 */