Module Name:    src
Committed By:   mlelstv
Date:           Tue Sep 30 15:25:18 UTC 2014

Modified Files:
        src/external/bsd/iscsi/dist/src/lib: disk.c

Log Message:
make seek test routine work with the configured block size.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/iscsi/dist/src/lib/disk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/iscsi/dist/src/lib/disk.c
diff -u src/external/bsd/iscsi/dist/src/lib/disk.c:1.8 src/external/bsd/iscsi/dist/src/lib/disk.c:1.9
--- src/external/bsd/iscsi/dist/src/lib/disk.c:1.8	Sat Sep 29 07:18:21 2012
+++ src/external/bsd/iscsi/dist/src/lib/disk.c	Tue Sep 30 15:25:18 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: disk.c,v 1.8 2012/09/29 07:18:21 mlelstv Exp $ */
+/* $NetBSD: disk.c,v 1.9 2014/09/30 15:25:18 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -703,33 +703,38 @@ device_set_var(const char *var, const ch
 /* allocate some space for a disk/extent, using an lseek, read and
 * write combination */
 static int
-de_allocate(disc_de_t *de, char *filename)
+de_allocate(disc_de_t *de, char *filename, uint64_t blocklen)
 {
 	off_t	size;
-	char	block[DEFAULT_TARGET_BLOCK_LEN];
+	char	 *block;
 
+	block = malloc(blocklen);
 	size = de_getsize(de);
-	if (de_lseek(de, size - sizeof(block), SEEK_SET) == -1) {
+	if (de_lseek(de, size - blocklen, SEEK_SET) == -1) {
 		iscsi_err(__FILE__, __LINE__,
 				"error seeking \"%s\"\n", filename);
+		free(block);
 		return 0;
 	}
-	if (de_read(de, block, sizeof(block)) == -1) {
+	if (de_read(de, block, blocklen) == -1) {
 		iscsi_err(__FILE__, __LINE__,
 				"error reading \"%s\"\n", filename);
+		free(block);
 		return 0;
 	}
-	if (de_write(de, block, sizeof(block)) == -1) {
+	if (de_write(de, block, blocklen) == -1) {
 		iscsi_err(__FILE__, __LINE__,
 				"error writing \"%s\"\n", filename);
+		free(block);
 		return 0;
 	}
+	free(block);
 	return 1;
 }
 
 /* allocate space as desired */
 static int
-allocate_space(disc_target_t *tp)
+allocate_space(disc_target_t *tp, uint64_t blocklen)
 {
 	uint32_t	i;
 
@@ -737,10 +742,10 @@ allocate_space(disc_target_t *tp)
 	following write() in de_allocate is non-destructive */
 	switch(tp->de.type) {
 	case DE_EXTENT:
-		return de_allocate(&tp->de, tp->target);
+		return de_allocate(&tp->de, tp->target, blocklen);
 	case DE_DEVICE:
 		for (i = 0 ; i < tp->de.u.dp->c ; i++) {
-			if (!de_allocate(&tp->de.u.dp->xv[i], tp->target)) {
+			if (!de_allocate(&tp->de.u.dp->xv[i], tp->target, blocklen)) {
 				return 0;
 			}
 		}
@@ -877,7 +882,7 @@ device_init(iscsi_target_t *tgt, targv_t
 			"error opening \"%s\"\n", idisk->filename);
 		return -1;
 	}
-	if (!(tp->flags & TARGET_READONLY) && !allocate_space(tp)) {
+	if (!(tp->flags & TARGET_READONLY) && !allocate_space(tp, idisk->blocklen)) {
 		iscsi_err(__FILE__, __LINE__,
 			"error allocating space for \"%s\"\n", tp->target);
 		return -1;
@@ -1514,7 +1519,7 @@ disk_read(target_session_t *sess, iscsi_
 			(unsigned) bytec;
 	args->length = (unsigned) bytec;
 	args->send_sg_len = 1;
-	args->status = 0;
+	args->status = SCSI_SUCCESS;
 	args->send_buffer = ptr;
 	return 0;
 out:

Reply via email to