Whamcloud - gitweb
LU-13775 target: fix memory copy in tgt_pages2shortio() 33/39333/4
authorWang Shilong <wshilong@ddn.com>
Fri, 10 Jul 2020 07:29:39 +0000 (15:29 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 7 Aug 2020 04:59:15 +0000 (04:59 +0000)
tgt_pages2shortio() try to copy local pages memory to ptlrpc
inline buf.

The right logic should move page @ptr to offset + count, however,
it does this logic wrongly, this doesn't cause any problem so
far, because normally @lnb_page_offset is 0. when i tried to
play with unaligned DIO, we could hit the problem.

Anyway, fix to use right logic to handle memory.

Fixes: 70f092a ("LU-1757 brw: add short io osc/ost transfer.")
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: I0a2e05732c0f425043af8393eb41f6bec178da6f
Reviewed-on: https://review.whamcloud.com/39333
Reviewed-by: Patrick Farrell <farr0186@gmail.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/target/tgt_handler.c

index f585359..593fa72 100644 (file)
@@ -1983,7 +1983,7 @@ static int tgt_pages2shortio(struct niobuf_local *local, int npages,
                        return -EINVAL;
 
                ptr = kmap_atomic(local[i].lnb_page);
                        return -EINVAL;
 
                ptr = kmap_atomic(local[i].lnb_page);
-               memcpy(buf + off, ptr, len);
+               memcpy(buf, ptr + off, len);
                kunmap_atomic(ptr);
                buf += len;
                size -= len;
                kunmap_atomic(ptr);
                buf += len;
                size -= len;