Recent changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following changes since commit 7078106dbbc524b6a3b2c39ddd04a9f676b10e53:

  Fix address truncation on Windows (2012-04-03 18:00:00 -0600)

are available in the git repository at:
  git://git.kernel.dk/fio.git master

Bruce Cran (1):
      Windows fixes

Jens Axboe (1):
      iolog: remove assert in io_u overlap

 engines/windowsaio.c |   19 +++++++++----------
 iolog.c              |    4 +++-
 os/os-windows.h      |    1 +
 os/windows/posix.c   |   44 +++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 52 insertions(+), 16 deletions(-)

---

Diff of recent changes:

diff --git a/engines/windowsaio.c b/engines/windowsaio.c
index 766cc5d..ea89969 100644
--- a/engines/windowsaio.c
+++ b/engines/windowsaio.c
@@ -82,16 +82,16 @@ static int fio_windowsaio_init(struct thread_data *td)
 	}
 
 	if (!rc) {
-	    for (i = 0; i < td->o.iodepth; i++) {
-	        wd->ovls[i].io_free = TRUE;
-	        wd->ovls[i].io_complete = FALSE;
+		for (i = 0; i < td->o.iodepth; i++) {
+			wd->ovls[i].io_free = TRUE;
+			wd->ovls[i].io_complete = FALSE;
 
 			wd->ovls[i].o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
 			if (wd->ovls[i].o.hEvent == NULL) {
 				rc = 1;
 				break;
 			}
-	    }
+		}
 	}
 
 	if (!rc) {
@@ -287,6 +287,7 @@ static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min,
 			if (fov->io_complete) {
 				fov->io_complete = FALSE;
 				fov->io_free  = TRUE;
+				ResetEvent(fov->o.hEvent);
 				wd->aio_events[dequeued] = io_u;
 				dequeued++;
 			}
@@ -297,7 +298,7 @@ static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min,
 
 		if (dequeued < min) {
 			status = WaitForSingleObject(wd->iocomplete_event, mswait);
-			if (status != WAIT_OBJECT_0 && dequeued > 0)
+			if (status != WAIT_OBJECT_0 && dequeued >= min)
 			    break;
 		}
 
@@ -322,17 +323,15 @@ static int fio_windowsaio_queue(struct thread_data *td, struct io_u *io_u)
 	wd = td->io_ops->data;
 
 	for (index = 0; index < td->o.iodepth; index++) {
-		if (wd->ovls[index].io_free) {
-			wd->ovls[index].io_free = FALSE;
-			ResetEvent(wd->ovls[index].o.hEvent);
+		if (wd->ovls[index].io_free)
 			break;
-		}
 	}
 
 	assert(index < td->o.iodepth);
 
-	lpOvl = &wd->ovls[index].o;
+	wd->ovls[index].io_free = FALSE;
 	wd->ovls[index].io_u = io_u;
+	lpOvl = &wd->ovls[index].o;
 	lpOvl->Internal = STATUS_PENDING;
 	lpOvl->InternalHigh = 0;
 	lpOvl->Offset = io_u->offset & 0xFFFFFFFF;
diff --git a/iolog.c b/iolog.c
index 1d61ba2..12f09d0 100644
--- a/iolog.c
+++ b/iolog.c
@@ -239,7 +239,9 @@ restart:
 		else if (ipo->offset > __ipo->offset)
 			p = &(*p)->rb_right;
 		else {
-			assert(ipo->len == __ipo->len);
+			dprint(FD_IO, "iolog: overlap %llu/%lu, %llu/%lu",
+				__ipo->offset, __ipo->len,
+				ipo->offset, ipo->len);
 			td->io_hist_len--;
 			rb_erase(parent, &td->io_hist_tree);
 			remove_trim_entry(td, __ipo);
diff --git a/os/os-windows.h b/os/os-windows.h
index 06fe433..8b801ed 100644
--- a/os/os-windows.h
+++ b/os/os-windows.h
@@ -20,6 +20,7 @@
 #define FIO_HAVE_CHARDEV_SIZE
 #define FIO_HAVE_FDATASYNC
 #define FIO_HAVE_WINDOWSAIO
+#define FIO_HAVE_FALLOCATE
 #define FIO_HAVE_GETTID
 #define FIO_HAVE_CLOCK_MONOTONIC
 #define FIO_USE_GENERIC_RAND
diff --git a/os/windows/posix.c b/os/windows/posix.c
index ba7abb5..9ef369e 100755
--- a/os/windows/posix.c
+++ b/os/windows/posix.c
@@ -331,9 +331,43 @@ char *basename(char *path)
 
 int posix_fallocate(int fd, off_t offset, off_t len)
 {
-	log_err("%s is not implemented\n", __func__);
-	errno = ENOSYS;
-	return (-1);
+	const int BUFFER_SIZE = 64*1024*1024;
+	int rc = 0;
+	char *buf;
+	unsigned int write_len;
+	unsigned int bytes_written;
+	off_t bytes_remaining = len;
+
+	if (len == 0 || offset < 0)
+		return EINVAL;
+
+	buf = malloc(BUFFER_SIZE);
+
+	if (buf == NULL)
+		return ENOMEM;
+
+	memset(buf, 0, BUFFER_SIZE);
+
+	if (lseek(fd, offset, SEEK_SET) == -1)
+		return errno;
+
+	while (bytes_remaining > 0) {
+		if (bytes_remaining < BUFFER_SIZE)
+			write_len = (unsigned int)bytes_remaining;
+		else
+			write_len = BUFFER_SIZE;
+
+		bytes_written = _write(fd, buf, write_len);
+		if (bytes_written == -1) {
+			rc = errno;
+			break;
+		}
+
+		bytes_remaining -= bytes_written;
+	}
+
+	free(buf);
+	return rc;
 }
 
 int ftruncate(int fildes, off_t length)
@@ -545,7 +579,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
 	int rc;
 
 	if (timeout != -1)
-		to = &tv;		
+		to = &tv;
 
 	to->tv_sec = timeout / 1000;
 	to->tv_usec = (timeout % 1000) * 1000;
@@ -567,7 +601,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
 		if (fds[i].events & POLLOUT)
 			FD_SET(fds[i].fd, &writefds);
 
-		FD_SET(fds[i].fd, &exceptfds);		
+		FD_SET(fds[i].fd, &exceptfds);
 	}
 
 	rc = select(nfds, &readfds, &writefds, &exceptfds, to);
--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux