Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp484761pxu; Thu, 7 Jan 2021 09:48:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyN/C0TZCOurnSij8wmUkT9dudOm5PR9EIycoLbIQwP2Pw77Uk68I4x5qzpO5pMOAnfrqm9 X-Received: by 2002:a17:907:9495:: with SMTP id dm21mr3369053ejc.462.1610041718717; Thu, 07 Jan 2021 09:48:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610041718; cv=none; d=google.com; s=arc-20160816; b=uRGq5mjVwGg9+OlD20KOLqnkAOMGsOkgIdpWF85iiiWlPt/OVmf0WgPwN/pyrsX4vW 3LSOXO91EQLYQ/9Nv0tsVefo2UzROZQU5K0WKPp/b0o8abQnmka0BC1HrivWk+T9rd4Q 8OyVgwz0Pc7aufa8GXs5WWWdAiRwAVTOLZkKS7G6S2ZJ4ln+5ce/483XrpdmKwOgSxaU qBqGkSqhrYqYrm5m+tUzxC39VMGFLEjb1HTa0xiFzWHtLpvxjle766UAfU4/nraIncCA VRL/tkHoqwGSenZHrKfnN8eolybUPlO7uoMy1+XuI5svBk6eX1kh/LLXImiwIZ7ljCUe QkLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CNK3GvEL4U8HNz+MK8A+YotA76v+OyTJ7DMDgcIh4hA=; b=rP2mJg5fCSotHQ0+gh7hzVRvzlazoLYRIpySPdQqK9LmDxkpoePFt4VuCtkQvNCIiI 6ib9BXyOoxDAiQUaGnfBFEuAqR6z2QxOx32Db2dTTxiacJDvPMT0pDjbsld7d2q1YVB7 9MiSZisWsRyUduDMgZhqPplPdmKOOt0RnDM40Z3ig9dOAg53vZRJ2l1kgoRjE10+eet6 KTf9KcPYU5TmDsbP92IZyPGklGUwWp+S3Bfita1DXM2gWA7dhkffoWczPuvvipPlrI0M MybGzSk+mM5pBjPIvAFQUe95TUIZZNtZEqn76G2mTIB6Kag1xFOEDBF2Is2MfCdDYrj5 Yw7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=K845TS0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nt21si2392054ejb.739.2021.01.07.09.48.15; Thu, 07 Jan 2021 09:48:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=K845TS0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728319AbhAGRrM (ORCPT + 99 others); Thu, 7 Jan 2021 12:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727215AbhAGRrL (ORCPT ); Thu, 7 Jan 2021 12:47:11 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6792BC0612F4 for ; Thu, 7 Jan 2021 09:46:31 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id z11so6152459qkj.7 for ; Thu, 07 Jan 2021 09:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CNK3GvEL4U8HNz+MK8A+YotA76v+OyTJ7DMDgcIh4hA=; b=K845TS0CJJvuvFjUj0/sOIf8ijCuVcy9Rrl8aFb3820OKBUWOcx+gm8R4Go8dLn4k7 10usGfYNKrO3Dn7k10RIjdXiBYhbGLFYuuVaxFPvW44RQCk+hmBONOLVCwN3ooyzcxnZ TjTxetXJakVoUOQ5iFjr608k+SiM4Xf4dr968ZRG+nJn2CNhIn0g0LTo64NQVlhO5VC1 xBJ4FqAtnsca75tRq3wez0V3QiAhd/j17TM8ryuO3S8hnxU1iWvGtYnFOFQuMeMzOZ3H sJ17/FpXL5LIIG8fydoHgoWmOhNvAfw/urnEq+3WwWrKeoO3vlTfqI/PNdKtRWhff3BO a4OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CNK3GvEL4U8HNz+MK8A+YotA76v+OyTJ7DMDgcIh4hA=; b=rAD0vyPciu01mIpOv1gQhTJiDE1kz1hNd+wyl46N1aDRVYk6O12eri9NQHbsDUQi4n txVI3LGP2eqinPqGxFqqPJP5BpG1xfqJyiJ4MwvAqxUFsac0G7CFlo0N/Fxuxhq3KIce mWHQ/iWSFZQD5KneN5NhsnOOXnQB1grV4XVaz3DqFyRErztsf9rZt6rnq7w2PlpB4oyQ iM/1jibSgpliLtiKOnev8+OERX5xo4s5yC5pMYdzMhCFe0E83aTwKEJzuTdkuN4BM4NC s1sTRQN3mjq6T27ibI/c5oKdwGKz6KE1ABieD5Hzeo0aMyo5ZVxSmUW67XKDy6LQvwnB CBgA== X-Gm-Message-State: AOAM531t5+gaygx0La7uRx3S1azR+IakBqnv21YM6kwXK9JAu7hfT/WY p5gMMeTE6Y1Pcm0qhEaPERhgYg== X-Received: by 2002:a37:584:: with SMTP id 126mr5587qkf.332.1610041590660; Thu, 07 Jan 2021 09:46:30 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id j142sm3555681qke.117.2021.01.07.09.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 09:46:30 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kxZMj-003lto-I9; Thu, 07 Jan 2021 13:46:29 -0400 Date: Thu, 7 Jan 2021 13:46:29 -0400 From: Jason Gunthorpe To: Douglas Gilbert Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, target-devel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, bostroesser@gmail.com, bvanassche@acm.org, ddiss@suse.de Subject: Re: [PATCH v5 4/4] scatterlist: add sgl_memset() Message-ID: <20210107174629.GC504133@ziepe.ca> References: <20201228234955.190858-1-dgilbert@interlog.com> <20201228234955.190858-5-dgilbert@interlog.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201228234955.190858-5-dgilbert@interlog.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 28, 2020 at 06:49:55PM -0500, Douglas Gilbert wrote: > The existing sg_zero_buffer() function is a bit restrictive. For > example protection information (PI) blocks are usually initialized > to 0xff bytes. As its name suggests sgl_memset() is modelled on > memset(). One difference is the type of the val argument which is > u8 rather than int. Plus it returns the number of bytes (over)written. > > Change implementation of sg_zero_buffer() to call this new function. > > Reviewed-by: Bodo Stroesser > Signed-off-by: Douglas Gilbert > include/linux/scatterlist.h | 3 ++ > lib/scatterlist.c | 65 +++++++++++++++++++++++++------------ > 2 files changed, 48 insertions(+), 20 deletions(-) > > diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h > index 71be65f9ebb5..70d3f1f73df1 100644 > +++ b/include/linux/scatterlist.h > @@ -333,6 +333,9 @@ bool sgl_compare_sgl_idx(struct scatterlist *x_sgl, unsigned int x_nents, off_t > struct scatterlist *y_sgl, unsigned int y_nents, off_t y_skip, > size_t n_bytes, size_t *miscompare_idx); > > +size_t sgl_memset(struct scatterlist *sgl, unsigned int nents, off_t skip, > + u8 val, size_t n_bytes); > + > /* > * Maximum number of entries that will be allocated in one piece, if > * a list larger than this is required then chaining will be utilized. > diff --git a/lib/scatterlist.c b/lib/scatterlist.c > index 9332365e7eb6..f06614a880c8 100644 > +++ b/lib/scatterlist.c > @@ -1038,26 +1038,7 @@ EXPORT_SYMBOL(sg_pcopy_to_buffer); > size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents, > size_t buflen, off_t skip) > { > - unsigned int offset = 0; > - struct sg_mapping_iter miter; > - unsigned int sg_flags = SG_MITER_ATOMIC | SG_MITER_TO_SG; > - > - sg_miter_start(&miter, sgl, nents, sg_flags); > - > - if (!sg_miter_skip(&miter, skip)) > - return false; > - > - while (offset < buflen && sg_miter_next(&miter)) { > - unsigned int len; > - > - len = min(miter.length, buflen - offset); > - memset(miter.addr, 0, len); > - > - offset += len; > - } > - > - sg_miter_stop(&miter); > - return offset; > + return sgl_memset(sgl, nents, skip, 0, buflen); > } > EXPORT_SYMBOL(sg_zero_buffer); May as well make this one liner a static inline in the header. Just rename this function to sgl_memset so the diff is clearer Jason