Received: by 10.223.185.116 with SMTP id b49csp4997187wrg; Wed, 7 Mar 2018 04:49:46 -0800 (PST) X-Google-Smtp-Source: AG47ELuACw3US3exTgAd9RoiuWAAkaLanwCuv/3uTTmfn1KKvNqrjWhKEzuLvu9XJKdYdEaKmeOl X-Received: by 2002:a17:902:57c1:: with SMTP id g1-v6mr20366764plj.381.1520426986454; Wed, 07 Mar 2018 04:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520426986; cv=none; d=google.com; s=arc-20160816; b=sHDD73Q0PiZnJ7+klRsLLmGVJFGRgV3WacoA6LsngRtLRpgGADCwIgVD4lHBRqeP5j zOP0NL88sOSITe/lLfUG/tJC4YfVvuM0Gbyoqm2UEqlOIziGAyEb+NnGe9ZM+7LCnNcS NrN5faMQnC6CiqdW78GkW7AXjbocsDZNyqLVnJfCHOytDzuHJBko89pEQw+aTDjvVAOy t9VvvLBfhRXVPUXXgWdZBhE0ajRefyg6fNkTXXVtf4/nMupGpz70cvn5JcPeuoaiWM0g 6hvT749Sk5nathwQiAfGj7yw1xG6JVl8BL1zIMIYOhP744bIs0GjWl9GRVYsLbjCjLO3 9rPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Cwi9XqoR0pantJu3qAH3oZb95d4ZVP5hWa1tyskGiJ0=; b=vwghdR1omSyOGJvkB6KakcfxHo6m751HA8bHYSvNSLmDe0jY1cEx6w2MafSonNQg4d MSE/udijpAJ2gRn1EECIpaYoWtyJZWvxGc0Pn1k+O/FIOMgyrjnMNyz/zMKnEnu/r7bv e0nHf104jFXZr6yntLb1iRInmD60NmAKVI0t59TLcwhahvi10j8NqPOuy8atn/EpOXz8 zXPXQmLtWqyCNWHSr+jJi/pRjB9ti+wytwn2omL+TnVYX/nOMihjfbL5qsKX6sKxIVVt XgEG4OYCysHYwM2rMKH0p4VHrY7No/pDVAdEJQIwV0lL1w6S1chOM8Cq39lPmJqfcFTx YB2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ursulin-net.20150623.gappssmtp.com header.s=20150623 header.b=1P4zfEIb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7-v6si12815938ple.721.2018.03.07.04.49.32; Wed, 07 Mar 2018 04:49:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ursulin-net.20150623.gappssmtp.com header.s=20150623 header.b=1P4zfEIb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754505AbeCGMsV (ORCPT + 99 others); Wed, 7 Mar 2018 07:48:21 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55575 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754248AbeCGMrd (ORCPT ); Wed, 7 Mar 2018 07:47:33 -0500 Received: by mail-wm0-f68.google.com with SMTP id q83so4539705wme.5 for ; Wed, 07 Mar 2018 04:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Cwi9XqoR0pantJu3qAH3oZb95d4ZVP5hWa1tyskGiJ0=; b=1P4zfEIbUun23ROMeZCuG7G6rXcgSR7HVG5yifuhimPH8zP5q1R2kuMyNSEAG5AG3K Puf5dERv7s0OtLuVTlwkRqYAoJffbbYy/SE2lH57tAWUpmRYe066Gw6CS8alLGaqy5C7 xo4fe7jzY3WyKJQu9FhzYb8G1+LcTMS+uSYJc8AlIg9rYLU+9WOeyZj4QzzEdsOltcDG BzE018N8qWHZAOtqYpmIOIYE5C3ULSEvzQMU9Xss4vHBHE+ICTphXvrBDc7B+dKrDDcM oseUe50jusBUhXDWwj+52Rcg0+sgm+JZPjPJJGS/DsQdYAhJbuJf7FhSjhm2lIqP7seC J48A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Cwi9XqoR0pantJu3qAH3oZb95d4ZVP5hWa1tyskGiJ0=; b=Y5y9y9GGu1KHsNHldjEEyYUuFGvnmJz4+LqsWcZc3JxsNbE0PEylY0msiMr22O3pJT ATyfpO9bJxm7X26rPckD24wfLBvFqxW9jvKGpnUuLlG+5dBWg2D5IHTeXreGEIe1IDvF SsuwoyQXgeQsqoMp2svzgqh0xiapSK3/lGsNusbu4hAjuLTcH4jplpIGG/PUR8aB2vCx QPNzEstev39XtHrI0HI78rtyCbLRMejtc42JcJqaqcrzfd3PYPDs8I+MQZIILabRZXrp weIfrGcMpeudFj+tToXkgCUbmYBN9i/npj8nXQ9X6d8bvtR5NM3Rwc3Ao2ZzdhZu4MVh xCTg== X-Gm-Message-State: AElRT7GrvYkWUY52xRL6iRFb8LfSMU9dHWNKTurjr7dQq851XLmLzFRP dNhbUU2oT4+YECqotOwHXUFxYcuP X-Received: by 10.28.159.68 with SMTP id i65mr15296487wme.27.1520426851735; Wed, 07 Mar 2018 04:47:31 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id x78sm24325756wmd.2.2018.03.07.04.47.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Mar 2018 04:47:31 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: linux-kernel@vger.kernel.org Cc: Tvrtko Ursulin , Bart Van Assche , Hannes Reinecke , Johannes Thumshirn , Jens Axboe , "Nicholas A. Bellinger" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 6/6] lib/scatterlist: Drop order argument from sgl_free_n_order Date: Wed, 7 Mar 2018 12:47:12 +0000 Message-Id: <20180307124712.14963-7-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180307124712.14963-1-tvrtko.ursulin@linux.intel.com> References: <20180307124712.14963-1-tvrtko.ursulin@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tvrtko Ursulin We can derive the order from sg->length and so do not need to pass it in explicitly. Rename the function to sgl_free_n. Signed-off-by: Tvrtko Ursulin Cc: Bart Van Assche Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Jens Axboe Cc: "Nicholas A. Bellinger" Cc: linux-scsi@vger.kernel.org Cc: target-devel@vger.kernel.org --- drivers/target/target_core_transport.c | 2 +- include/linux/scatterlist.h | 5 ++--- lib/scatterlist.c | 16 ++++++---------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 4558f2e1fe1b..91e8f4047492 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2303,7 +2303,7 @@ static void target_complete_ok_work(struct work_struct *work) void target_free_sgl(struct scatterlist *sgl, int nents) { - sgl_free_n_order(sgl, nents, 0); + sgl_free_n(sgl, nents); } EXPORT_SYMBOL(target_free_sgl); diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 3ffc5f3bf181..3779d1fdd5c4 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -280,8 +280,7 @@ int sg_alloc_table_from_pages(struct sg_table *sgt, struct page **pages, struct scatterlist *sgl_alloc_order(unsigned long length, unsigned int order, bool chainable, gfp_t gfp, unsigned int *nent_p); -void sgl_free_n_order(struct scatterlist *sgl, unsigned int nents, - unsigned int order); +void sgl_free_n(struct scatterlist *sgl, unsigned int nents); /** * sgl_alloc - allocate a scatterlist and its pages @@ -303,7 +302,7 @@ sgl_alloc(unsigned long length, gfp_t gfp, unsigned int *nent_p) */ static inline void sgl_free(struct scatterlist *sgl) { - sgl_free_n_order(sgl, UINT_MAX, 0); + sgl_free_n(sgl, UINT_MAX); } #endif /* CONFIG_SGL_ALLOC */ diff --git a/lib/scatterlist.c b/lib/scatterlist.c index c637849482d3..76111e91a038 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -493,7 +493,7 @@ struct scatterlist *sgl_alloc_order(unsigned long length, unsigned int order, { unsigned int chunk_len = PAGE_SIZE << order; struct scatterlist *sgl, *sg; - unsigned int nent, i; + unsigned int nent; nent = round_up(length, chunk_len) >> (PAGE_SHIFT + order); @@ -517,12 +517,11 @@ struct scatterlist *sgl_alloc_order(unsigned long length, unsigned int order, sg_init_table(sgl, nent); sg = sgl; - i = 0; while (length) { struct page *page = alloc_pages(gfp, order); if (!page) { - sgl_free_n_order(sgl, i, order); + sgl_free(sgl); return NULL; } @@ -530,7 +529,6 @@ struct scatterlist *sgl_alloc_order(unsigned long length, unsigned int order, sg_set_page(sg, page, chunk_len, 0); length -= chunk_len; sg = sg_next(sg); - i++; } WARN_ONCE(length, "length = %ld\n", length); return sgl; @@ -538,10 +536,9 @@ struct scatterlist *sgl_alloc_order(unsigned long length, unsigned int order, EXPORT_SYMBOL(sgl_alloc_order); /** - * sgl_free_n_order - free a scatterlist and its pages + * sgl_free_n - free a scatterlist and its pages * @sgl: Scatterlist with one or more elements * @nents: Maximum number of elements to free - * @order: Second argument for __free_pages() * * Notes: * - If several scatterlists have been chained and each chain element is @@ -550,8 +547,7 @@ EXPORT_SYMBOL(sgl_alloc_order); * - All pages in a chained scatterlist can be freed at once by setting @nents * to a high number. */ -void sgl_free_n_order(struct scatterlist *sgl, unsigned int nents, - unsigned int order) +void sgl_free_n(struct scatterlist *sgl, unsigned int nents) { struct scatterlist *sg; struct page *page; @@ -562,11 +558,11 @@ void sgl_free_n_order(struct scatterlist *sgl, unsigned int nents, break; page = sg_page(sg); if (page) - __free_pages(page, order); + __free_pages(page, get_order(sg->length)); } kfree(sgl); } -EXPORT_SYMBOL(sgl_free_n_order); +EXPORT_SYMBOL(sgl_free_n); #endif /* CONFIG_SGL_ALLOC */ -- 2.14.1