Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4830312imm; Wed, 30 May 2018 12:54:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIzp+ST6jqsGkUsblJn5Imrq0EKVeJ67LXqy7jL2++Nlq6+ELDsSkTXlE49qyEEqOSW3X64 X-Received: by 2002:a17:902:8a87:: with SMTP id p7-v6mr4049124plo.278.1527710048456; Wed, 30 May 2018 12:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527710048; cv=none; d=google.com; s=arc-20160816; b=CtkxLXNkCswsxRCv+je1sxWX7Xkt+Z4xnakDugpOqk5CAdGcLF8Dj8SUZ6iUtJ7eHD 7KffiAmC7bkaqSr7pt1W4WYmq+90lQ+rMPOr7Z9aA8DEYGdJ9mn1vtnz11AvfmxDcdG9 yyMpMKha2f8B2mfW4FCL+PYshzjuoQ0a8VJJsLGTsayKtCQ4sl9+YmqDkLCUt7BOU2BJ pc6kUAUT9DeLbXmRGUy9YnNHNzW/T+PWM1JFnEdpx6d3lK9L/m2QTjAGFmLj1Sa9QY1d OhI0gbThY3F/Ur/tZBQEu4qdpSj2PvXEUYKh1J81GODLQK7IOvwBRkQBiobf6l9LcsCJ oGdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=9uYlDfDkr9c59kBbNgzH+SKhZJEYb+KAqaNYlQjjY88=; b=p0QRjqP+RlxIlPa0Kv9cwVpqK3wiWvZ3zO5//+rPtDHEC7tdm8AaB+9iCApy2FEkg3 n2oXvfLg11GGTAwipnQV0GAACRE1aIi/X4w3Gv4npT0Kd02wWnlO4dsnrpkE8ySYFzub S139JuDzLxkep4dquYA9SLzMVMUcsLJw5/FCO/OUQg2arUVvi6BY7wvjsqTi+AEFQocG pAbEn9LU8+SSS2daiF/vMvnMfmaKk0IKF7xbOLYgTUD5MdgkcmH1JY53SGHajHJ//wq8 OCS/arsGQDjfmWYnCqmVXGyOjDoM3G+XT9imBhIMPnOPSQBUTXKdJkmz8I0iO4TAJQsx Jj5Q== ARC-Authentication-Results: i=1; mx.google.com; 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 u15-v6si28070884pgv.355.2018.05.30.12.53.54; Wed, 30 May 2018 12:54:08 -0700 (PDT) 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; 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 S932431AbeE3Tv2 (ORCPT + 99 others); Wed, 30 May 2018 15:51:28 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:60182 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932256AbeE3Ttz (ORCPT ); Wed, 30 May 2018 15:49:55 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id O75Pf6FQGN7esO75Pf2xlM; Wed, 30 May 2018 12:48:53 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1fO75P-0008Ft-Fm; Wed, 30 May 2018 12:48:43 -0700 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Long Li Subject: [Patch v2 06/15] CIFS: Introduce helper function to get page offset and length in smb_rqst Date: Wed, 30 May 2018 12:47:58 -0700 Message-Id: <20180530194807.31657-7-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530194807.31657-1-longli@linuxonhyperv.com> References: <20180530194807.31657-1-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com X-CMAE-Envelope: MS4wfE2En6LZZmxVtn5WKUvfoKAOIZvu+60DXJGDbf1f8+6++sqxIEmMRhgezaWWXCvpGXnmTXOQuTPDJE2kZeCFY2BD8wyxuA2Vf6TmbqxQJ251u1oJ83B4 e9Jx9UR2v7un3wLbFfsZdGQ8EkJTEJx4gjb9NjVKMdoeUCppyTtFCG8T3CHIVNP8Drxwit4oUMlbYqPE1SOYBt+J51G/w9/3oUDAJONxDd7eonmAXozEy5Bp zRSG34UPEPICL0oARu5ukGvaw5AFKCqcD72VC7GJnw9i255KSW+WOAdq8ZlLewgTdLjy5XTegDI/6hZMxwEpg/Yb50YivHXiUVKw47W4F/+dcvEQ19FwmjT6 8tRKz/oOQ9UWFv+25N7Ei9GYitZVmfcjw2aAiPfpvxZMmo6y+BC++kOUljFYLMpMlB03lW1l Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li Introduce a function rqst_page_get_length to return the page offset and length for a given page in smb_rqst. This function is to be used by following patches. Signed-off-by: Long Li --- fs/cifs/cifsproto.h | 3 +++ fs/cifs/misc.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 7933c5f..89dda14 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -557,4 +557,7 @@ int cifs_alloc_hash(const char *name, struct crypto_shash **shash, struct sdesc **sdesc); void cifs_free_hash(struct crypto_shash **shash, struct sdesc **sdesc); +extern void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page, + unsigned int *len, unsigned int *offset); + #endif /* _CIFSPROTO_H */ diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 96849b5..e951417 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c @@ -905,3 +905,20 @@ cifs_free_hash(struct crypto_shash **shash, struct sdesc **sdesc) crypto_free_shash(*shash); *shash = NULL; } + +/** + * rqst_page_get_length - obtain the length and offset for a page in smb_rqst + * Input: rqst - a smb_rqst, page - a page index for rqst + * Output: *len - the length for this page, *offset - the offset for this page + */ +void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page, + unsigned int *len, unsigned int *offset) +{ + *len = rqst->rq_pagesz; + *offset = (page == 0) ? rqst->rq_offset : 0; + + if (rqst->rq_npages == 1 || page == rqst->rq_npages-1) + *len = rqst->rq_tailsz; + else if (page == 0) + *len = rqst->rq_pagesz - rqst->rq_offset; +} -- 2.7.4