From patchwork Tue Feb 12 12:23:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 2128171 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C8E66DFB7B for ; Tue, 12 Feb 2013 12:26:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933195Ab3BLMZs (ORCPT ); Tue, 12 Feb 2013 07:25:48 -0500 Received: from mail-vc0-f174.google.com ([209.85.220.174]:38227 "EHLO mail-vc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933185Ab3BLMX6 (ORCPT ); Tue, 12 Feb 2013 07:23:58 -0500 Received: by mail-vc0-f174.google.com with SMTP id n11so8364vch.5 for ; Tue, 12 Feb 2013 04:23:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=bMoLqguxdulzLudqY511HJp0o5WyyDwELK3BfJnTAHc=; b=G6XQOhFC6DnWWB3mLqBoWNlkq1/kSnJJPbIqP5v9PjfZKMJb4WGdMbrelzQ1473+6x 74i/9YCN31mYyqFX3JTLfdKt9punVXgprrrxw0GkPNt2pfk2lwWcfSM2BRq+Kk3DOrYK ByTIBkVaQSRUNrxHcKM6bOiW0nyNlXxoePcLo7ruKB3H7WDGV6rdzIrv6nplWRvQJ9+4 S25368d/NFZdLAF4NyGcrE+H13/NrBKbz9y/uCptaR5oERAhu7u4B1Om33RthDcRPyyx FiREnNGMs/wp5HwlQnJZmv70ddx/+DDEjWx80NqZGcEYPZJtYYxVuIhjWUDet041icoc mEUQ== X-Received: by 10.59.13.197 with SMTP id fa5mr23393417ved.47.1360671837283; Tue, 12 Feb 2013 04:23:57 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-179-137.ip50.fastwebnet.it. [93.34.179.137]) by mx.google.com with ESMTPS id a19sm64574262vdh.9.2013.02.12.04.23.54 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 12 Feb 2013 04:23:56 -0800 (PST) From: Paolo Bonzini To: linux-kernel@vger.kernel.org Cc: Wanlong Gao , asias@redhat.com, mst@redhat.com, Rusty Russell , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH 5/9] scatterlist: introduce sg_unmark_end Date: Tue, 12 Feb 2013 13:23:31 +0100 Message-Id: <1360671815-2135-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1360671815-2135-1-git-send-email-pbonzini@redhat.com> References: <1360671815-2135-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This is useful in places that recycle the same scatterlist multiple times, and do not want to incur the cost of sg_init_table every time in hot paths. Acked-by: Jens Axboe Signed-off-by: Paolo Bonzini --- block/blk-integrity.c | 2 +- block/blk-merge.c | 2 +- include/linux/scatterlist.h | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index da2a818..0f5004f 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -110,7 +110,7 @@ new_segment: if (!sg) sg = sglist; else { - sg->page_link &= ~0x02; + sg_unmark_end(sg); sg = sg_next(sg); } diff --git a/block/blk-merge.c b/block/blk-merge.c index 936a110..5f24482 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -143,7 +143,7 @@ new_segment: * termination bit to avoid doing a full * sg_init_table() in drivers for each command. */ - (*sg)->page_link &= ~0x02; + sg_unmark_end(*sg); *sg = sg_next(*sg); } diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 4bd6c06..9b83784 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -172,6 +172,22 @@ static inline void sg_mark_end(struct scatterlist *sg) } /** + * sg_unmark_end - Undo setting the end of the scatterlist + * @sg: SG entryScatterlist + * + * Description: + * Removes the termination marker from the given entry of the scatterlist. + * + **/ +static inline void sg_unmark_end(struct scatterlist *sg) +{ +#ifdef CONFIG_DEBUG_SG + BUG_ON(sg->sg_magic != SG_MAGIC); +#endif + sg->page_link &= ~0x02; +} + +/** * sg_phys - Return physical address of an sg entry * @sg: SG entry *