You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/06/15 16:49:33 UTC

[GitHub] [trafficserver] moonchen commented on a diff in pull request #8534: TS_USE_MMAP: mmap+memcopy instead pread+pwrite

moonchen commented on code in PR #8534:
URL: https://github.com/apache/trafficserver/pull/8534#discussion_r898185392


##########
iocore/aio/I_AIO.h:
##########
@@ -33,6 +33,7 @@
 #include "tscore/ink_platform.h"
 #include "I_EventSystem.h"
 #include "records/I_RecProcess.h"
+#include <sys/mman.h>

Review Comment:
   This should be behind #if TS_USE_MMAP



##########
iocore/aio/AIO.cc:
##########
@@ -380,17 +400,27 @@ aio_queue_req(AIOCallbackInternal *op, int fromAPI = 0)
 static inline int
 cache_op(AIOCallbackInternal *op)
 {
-  bool read = (op->aiocb.aio_lio_opcode == LIO_READ);
+  bool const read = (op->aiocb.aio_lio_opcode == LIO_READ);
   for (; op; op = (AIOCallbackInternal *)op->then) {
     ink_aiocb *a = &op->aiocb;
     ssize_t err, res = 0;
 
     while (a->aio_nbytes - res > 0) {
       do {
         if (read) {
+#if TS_USE_MMAP
+          memcpy(static_cast<char *>(a->aio_buf) + res, static_cast<char const *>(a->aio_fildes) + a->aio_offset + res,
+                 err = a->aio_nbytes - res);
+#else
           err = pread(a->aio_fildes, (static_cast<char *>(a->aio_buf)) + res, a->aio_nbytes - res, a->aio_offset + res);
+#endif
         } else {
+#if TS_USE_MMAP

Review Comment:
   Need to check bounds.



##########
iocore/aio/AIO.cc:
##########
@@ -537,6 +568,8 @@ DiskHandler::mainAIOEvent(int event, Event *e)
   if (num > 0) {
     int ret;
     do {
+      Fatal("io_submit not supported with TS_USE_MMAP and TS_USE_LINUX_NATIVE_AIO");

Review Comment:
   This is inside an `#if !TS_USE_MMAP`.  Is it still necessary to Fatal() here?



##########
iocore/aio/AIO.cc:
##########
@@ -380,17 +400,27 @@ aio_queue_req(AIOCallbackInternal *op, int fromAPI = 0)
 static inline int
 cache_op(AIOCallbackInternal *op)
 {
-  bool read = (op->aiocb.aio_lio_opcode == LIO_READ);
+  bool const read = (op->aiocb.aio_lio_opcode == LIO_READ);
   for (; op; op = (AIOCallbackInternal *)op->then) {
     ink_aiocb *a = &op->aiocb;
     ssize_t err, res = 0;
 
     while (a->aio_nbytes - res > 0) {
       do {
         if (read) {
+#if TS_USE_MMAP
+          memcpy(static_cast<char *>(a->aio_buf) + res, static_cast<char const *>(a->aio_fildes) + a->aio_offset + res,

Review Comment:
   Need to check bounds.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org