This is an automated email from the git hooks/post-receive script.
teigland pushed a change to branch master in repository sanlock.
from 05cb313 sanlock: allow setting max_sectors_kb new 3981ad5 sanlock: remove posix aio code new 2cc91bc sanlock: improve non-aio usage
The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
Summary of changes: src/diskio.c | 252 +++++++++++++++++++++++++++++++---------------------------- src/main.c | 4 + 2 files changed, 136 insertions(+), 120 deletions(-)
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master in repository sanlock.
commit 3981ad5ce2d9a7984ec452d72c7c964d6448f0e3 Author: David Teigland teigland@redhat.com AuthorDate: Wed Nov 7 14:48:22 2018 -0600
sanlock: remove posix aio code
This code has never been used.
Keeping the native linux aio code. --- src/diskio.c | 108 ++--------------------------------------------------------- 1 file changed, 2 insertions(+), 106 deletions(-)
diff --git a/src/diskio.c b/src/diskio.c index 83b0b1e..cd24c11 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -24,7 +24,6 @@ #include <sys/sysmacros.h> #include <blkid/blkid.h>
-#include <libaio.h> /* linux aio */ #include <aio.h> /* posix aio */ #include <aio.h> /* posix aio */
@@ -679,114 +678,13 @@ static int do_read_aio_linux(int fd, uint64_t offset, char *buf, int len, return do_linux_aio(fd, offset, buf, len, task, ioto, IO_CMD_PREAD, rd_ms); }
-static int do_write_aio_posix(int fd, uint64_t offset, char *buf, int len, - struct task *task GNUC_UNUSED, int ioto) -{ - struct timespec ts; - struct aiocb cb; - struct aiocb const *p_cb; - int rv; - - memset(&ts, 0, sizeof(struct timespec)); - ts.tv_sec = ioto; - - memset(&cb, 0, sizeof(struct aiocb)); - p_cb = &cb; - - cb.aio_fildes = fd; - cb.aio_buf = buf; - cb.aio_nbytes = len; - cb.aio_offset = offset; - - rv = aio_write(&cb); - if (rv < 0) - return -1; - - rv = aio_suspend(&p_cb, 1, &ts); - if (!rv) - return 0; - - /* the write timed out, try to cancel it... */ - - rv = aio_cancel(fd, &cb); - if (rv < 0) - return -1; - - if (rv == AIO_ALLDONE) - return 0; - - if (rv == AIO_CANCELED) - return -EIO; - - /* Functions that depend on the timeout might consider - * the action failed even if it will complete if that - * happened after the alloted time frame */ - - if (rv == AIO_NOTCANCELED) - return -EIO; - - /* undefined error condition */ - return -1; -} - -static int do_read_aio_posix(int fd, uint64_t offset, char *buf, int len, - struct task *task GNUC_UNUSED, int ioto) -{ - struct timespec ts; - struct aiocb cb; - struct aiocb const *p_cb; - int rv; - - memset(&ts, 0, sizeof(struct timespec)); - ts.tv_sec = ioto; - - memset(&cb, 0, sizeof(struct aiocb)); - p_cb = &cb; - - cb.aio_fildes = fd; - cb.aio_buf = buf; - cb.aio_nbytes = len; - cb.aio_offset = offset; - - rv = aio_read(&cb); - if (rv < 0) - return -1; - - rv = aio_suspend(&p_cb, 1, &ts); - if (!rv) - return 0; - - /* the read timed out, try to cancel it... */ - - rv = aio_cancel(fd, &cb); - if (rv < 0) - return -1; - - if (rv == AIO_ALLDONE) - return 0; - - if (rv == AIO_CANCELED) - return -EIO; - - if (rv == AIO_NOTCANCELED) - /* Functions that depend on the timeout might consider - * the action failed even if it will complete if that - * happened apter the alloted time frame */ - return -EIO; - - /* undefined error condition */ - return -1; -} - /* write aligned io buffer */
int write_iobuf(int fd, uint64_t offset, char *iobuf, int iobuf_len, struct task *task, int ioto, int *wr_ms) { - if (task && task->use_aio == 1) + if (task && task->use_aio) return do_write_aio_linux(fd, offset, iobuf, iobuf_len, task, ioto, wr_ms); - else if (task && task->use_aio == 2) - return do_write_aio_posix(fd, offset, iobuf, iobuf_len, task, ioto); else return do_write(fd, offset, iobuf, iobuf_len, task); } @@ -884,10 +782,8 @@ int write_sectors(const struct sync_disk *disk, int sector_size, uint64_t sector int read_iobuf(int fd, uint64_t offset, char *iobuf, int iobuf_len, struct task *task, int ioto, int *rd_ms) { - if (task && task->use_aio == 1) + if (task && task->use_aio) return do_read_aio_linux(fd, offset, iobuf, iobuf_len, task, ioto, rd_ms); - else if (task && task->use_aio == 2) - return do_read_aio_posix(fd, offset, iobuf, iobuf_len, task, ioto); else return do_read(fd, offset, iobuf, iobuf_len, task); }
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master in repository sanlock.
commit 2cc91bcbc67331d85055dbef054c0c519176c9ca Author: David Teigland teigland@redhat.com AuthorDate: Wed Nov 7 15:30:41 2018 -0600
sanlock: improve non-aio usage
Allow use_aio to be set to 0 in sanlock.conf. Add the same io timing and debugging to the sync io code as exists in the aio code. --- src/diskio.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ src/main.c | 4 ++ 2 files changed, 134 insertions(+), 14 deletions(-)
diff --git a/src/diskio.c b/src/diskio.c index cd24c11..563647b 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -353,25 +353,49 @@ int open_disks(struct sync_disk *disks, int num_disks) return rv; }
-static int do_write(int fd, uint64_t offset, const char *buf, int len, struct task *task) +static int do_write(int fd, uint64_t offset, const char *buf, int len, struct task *task, int *wr_ms) { off_t ret; int rv; int pos = 0; + int sys_error = 0; + int save_errno = 0; + struct timespec begin, end, diff; + const char *len_str; + char off_str[16]; + char ms_str[8];
if (task) task->io_count++;
+ if (com.debug_io_submit) { + len_str = align_size_debug_str(len); + offset_to_str(offset, sizeof(off_str), off_str); + + if (len_str) + log_taskd(task, "WR %s at %s", len_str, off_str); + else + log_taskd(task, "WR %d at %s", len, off_str); + } + ret = lseek(fd, offset, SEEK_SET); - if (ret != offset) + if (ret != offset) { + log_taskw(task, "WR %d at %s seek error %llu", len, off_str, (unsigned long long)ret); return -1; + } + + if (wr_ms) + clock_gettime(CLOCK_MONOTONIC_RAW, &begin);
retry: rv = write(fd, buf + pos, len); if (rv == -1 && errno == EINTR) goto retry; - if (rv < 0) - return -1; + if (rv < 0) { + sys_error = 1; + save_errno = errno; + goto out; + }
/* if (rv != len && len == sector_size) return error? partial sector writes should not happen AFAIK, and @@ -383,33 +407,125 @@ static int do_write(int fd, uint64_t offset, const char *buf, int len, struct ta goto retry; }
- return 0; + if (sys_error) + rv = -1; + else + rv = 0; + + out: + if (wr_ms) { + clock_gettime(CLOCK_MONOTONIC_RAW, &end); + ts_diff(&begin, &end, &diff); + *wr_ms = (diff.tv_sec * 1000) + (diff.tv_nsec / 1000000); + } + + if (com.debug_io_complete || sys_error) { + len_str = align_size_debug_str(len); + offset_to_str(offset, sizeof(off_str), off_str); + + if (wr_ms) { + memset(ms_str, 0, sizeof(ms_str)); + snprintf(ms_str, 7, "%u", *wr_ms); + } + + if (len_str) + log_taskd(task, "WR %s at %s done %s", + len_str, off_str, wr_ms ? ms_str : ""); + else + log_taskd(task, "WR %d at %s done %s", + len, off_str, wr_ms ? ms_str : ""); + + if (sys_error) + log_taskw(task, "WR %d at %s error %d %s", + len, off_str, save_errno, wr_ms ? ms_str : ""); + } + + return rv; }
-static int do_read(int fd, uint64_t offset, char *buf, int len, struct task *task) +static int do_read(int fd, uint64_t offset, char *buf, int len, struct task *task, int *rd_ms) { off_t ret; int rv, pos = 0; + int sys_error = 0; + int save_errno = 0; + struct timespec begin, end, diff; + const char *len_str; + char off_str[16]; + char ms_str[8];
if (task) task->io_count++;
+ if (com.debug_io_submit) { + len_str = align_size_debug_str(len); + offset_to_str(offset, sizeof(off_str), off_str); + + if (len_str) + log_taskd(task, "RD %s at %s", len_str, off_str); + else + log_taskd(task, "RD %d at %s", len, off_str); + } + ret = lseek(fd, offset, SEEK_SET); - if (ret != offset) + if (ret != offset) { + log_taskw(task, "RD %d at %s seek error %llu", len, off_str, (unsigned long long)ret); return -1; + } + + if (rd_ms) + clock_gettime(CLOCK_MONOTONIC_RAW, &begin);
while (pos < len) { rv = read(fd, buf + pos, len - pos); - if (rv == 0) - return -1; + if (rv == 0) { + sys_error = 1; + save_errno = errno; + break; + } if (rv == -1 && errno == EINTR) continue; - if (rv < 0) - return -1; + if (rv < 0) { + sys_error = 1; + save_errno = errno; + break; + } pos += rv; }
- return 0; + if (sys_error) + rv = -1; + else + rv = 0; + + if (rd_ms) { + clock_gettime(CLOCK_MONOTONIC_RAW, &end); + ts_diff(&begin, &end, &diff); + *rd_ms = (diff.tv_sec * 1000) + (diff.tv_nsec / 1000000); + } + + if (com.debug_io_complete || sys_error) { + len_str = align_size_debug_str(len); + offset_to_str(offset, sizeof(off_str), off_str); + + if (rd_ms) { + memset(ms_str, 0, sizeof(ms_str)); + snprintf(ms_str, 7, "%u", *rd_ms); + } + + if (len_str) + log_taskd(task, "RD %s at %s done %s", + len_str, off_str, rd_ms ? ms_str : ""); + else + log_taskd(task, "RD %d at %s done %s", + len, off_str, rd_ms ? ms_str : ""); + + if (sys_error) + log_taskw(task, "RD %d at %s error %d %s", + len, off_str, save_errno, rd_ms ? ms_str : ""); + } + + return rv; }
static struct aicb *find_callback_slot(struct task *task, int ioto) @@ -686,7 +802,7 @@ int write_iobuf(int fd, uint64_t offset, char *iobuf, int iobuf_len, if (task && task->use_aio) return do_write_aio_linux(fd, offset, iobuf, iobuf_len, task, ioto, wr_ms); else - return do_write(fd, offset, iobuf, iobuf_len, task); + return do_write(fd, offset, iobuf, iobuf_len, task, wr_ms); }
static int _write_sectors(const struct sync_disk *disk, int sector_size, uint64_t sector_nr, @@ -785,7 +901,7 @@ int read_iobuf(int fd, uint64_t offset, char *iobuf, int iobuf_len, if (task && task->use_aio) return do_read_aio_linux(fd, offset, iobuf, iobuf_len, task, ioto, rd_ms); else - return do_read(fd, offset, iobuf, iobuf_len, task); + return do_read(fd, offset, iobuf, iobuf_len, task, rd_ms); }
/* read sector_count sectors starting with sector_nr, where sector_nr diff --git a/src/main.c b/src/main.c index e4514e7..6cbc7bf 100644 --- a/src/main.c +++ b/src/main.c @@ -2582,6 +2582,10 @@ static void read_config_file(void) get_val_int(line, &val); com.debug_renew = val;
+ } else if (!strcmp(str, "use_aio")) { + get_val_int(line, &val); + com.aio_arg = val; + } else if (!strcmp(str, "logfile_priority")) { get_val_int(line, &val); log_logfile_priority = val;
sanlock-devel@lists.fedorahosted.org