Whamcloud - gitweb
LU-13004 target: take offset into account in tgt_send_buffer 71/37571/4
authorMikhail Pershin <mpershin@whamcloud.com>
Fri, 14 Feb 2020 09:59:05 +0000 (12:59 +0300)
committerOleg Drokin <green@whamcloud.com>
Tue, 25 Feb 2020 05:51:54 +0000 (05:51 +0000)
While calculating amount of pages needed, take buffer offset into
account because it can be non-aligned after allocations in
out_read().

Signed-off-by: Mikhail Pershin <mpershin@whamcloud.com>
Change-Id: Ib7c9b35d328d366a27cc553ffe2f2c5930949cf4
Reviewed-on: https://review.whamcloud.com/37571
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ptlrpc/client.c
lustre/target/tgt_handler.c

index cc93dd4..98486eb 100644 (file)
@@ -72,13 +72,13 @@ static void ptlrpc_release_bulk_page_pin(struct ptlrpc_bulk_desc *desc)
 static int ptlrpc_prep_bulk_frag_pages(struct ptlrpc_bulk_desc *desc,
                                       void *frag, int len)
 {
-       unsigned int offset = (uintptr_t)frag & ~PAGE_MASK;
+       unsigned int offset = (unsigned long)frag & ~PAGE_MASK;
 
        ENTRY;
        while (len > 0) {
                int page_len = min_t(unsigned int, PAGE_SIZE - offset,
                                     len);
-               uintptr_t vaddr = (uintptr_t) frag;
+               unsigned long vaddr = (unsigned long)frag;
 
                ptlrpc_prep_bulk_page_nopin(desc,
                                            lnet_kvaddr_to_page(vaddr),
index dd2ec2e..df2b1c6 100644 (file)
@@ -1073,12 +1073,14 @@ int tgt_send_buffer(struct tgt_session_info *tsi, struct lu_rdbuf *rdbuf)
 
        ENTRY;
 
-       for (i = 0; i < rdbuf->rb_nbufs; i++)
-               /* There is only one caller (out_read) and we *know* that
-                * bufs are at most 4K, and 4K aligned, so a simple DIV_ROUND_UP
-                * is always sufficient.
-                */
-               pages += DIV_ROUND_UP(rdbuf->rb_bufs[i].lb_len, PAGE_SIZE);
+       for (i = 0; i < rdbuf->rb_nbufs; i++) {
+               unsigned int offset;
+
+               offset = (unsigned long)rdbuf->rb_bufs[i].lb_buf & ~PAGE_MASK;
+               pages += DIV_ROUND_UP(rdbuf->rb_bufs[i].lb_len + offset,
+                                     PAGE_SIZE);
+       }
+
        desc = ptlrpc_prep_bulk_exp(req, pages, 1,
                                  PTLRPC_BULK_PUT_SOURCE | PTLRPC_BULK_BUF_KIOV,
                                    MDS_BULK_PORTAL,