linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/10] pnfs-block ctl
@ 2011-12-05  8:09 Benny Halevy
  2011-12-05  8:12 ` [PATCH 01/10] use gcc Benny Halevy
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:09 UTC (permalink / raw)
  To: NFS list

Folks,

The following are fixes to Rick McNeal's user-space ctl daemon
for the pnfs block server.

They are available on:
git://linux-nfs.org/~bhalevy/pnfsd-block-ctl.git

The daemon is required on the server side to get the pnfs
block device EFI signature and volume signature.


[PATCH 01/10] use gcc
[PATCH 02/10] efi: fix user-land debug printouts
[PATCH 03/10] ctl: improve debug printouts
[PATCH 04/10] increase compiler warning level
[PATCH 05/10] ctl: always return a value from find_dm_name
[PATCH 06/10] add missing includes
[PATCH 07/10] ctl: fix compiler warnings
[PATCH 08/10] fix compiler warnings around get_output use of argv
[PATCH 09/10] ctl: main should return 0 on success
[PATCH 10/10] efi: fix compiler warnings

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 01/10] use gcc
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
@ 2011-12-05  8:12 ` Benny Halevy
  2011-12-05  8:13 ` [PATCH 02/10] efi: fix user-land debug printouts Benny Halevy
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:12 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 Makefile |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 14bb2ff..2b40126 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,9 @@
+CC= gcc
 OBJS=	ctl.o efi.o
 CFLAGS= -I../../linux-pnfs.working/include
 
 ctl: $(OBJS)
-	cc -o ctl $(OBJS) -levent -lpthread -lparted
+	$(CC) -o ctl $(OBJS) -levent -lpthread -lparted
 
 clean:
 	rm -f $(OBJS) ctl
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 02/10] efi: fix user-land debug printouts
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
  2011-12-05  8:12 ` [PATCH 01/10] use gcc Benny Halevy
@ 2011-12-05  8:13 ` Benny Halevy
  2011-12-05  8:13 ` [PATCH 03/10] ctl: improve " Benny Halevy
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:13 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 efi.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/efi.c b/efi.c
index 20efb2b..b653092 100644
--- a/efi.c
+++ b/efi.c
@@ -98,9 +98,12 @@
 
 #include "efi.h"
 
+#ifndef EFI_DEBUG
+#define EFI_DEBUG
+#endif
 #undef EFI_DEBUG
 #ifdef EFI_DEBUG
-#define Dprintk(x...) printk(KERN_DEBUG x)
+#define Dprintk(x...) fprintf(stderr, x)
 #else
 #define Dprintk(x...)
 #endif
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 03/10] ctl: improve debug printouts
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
  2011-12-05  8:12 ` [PATCH 01/10] use gcc Benny Halevy
  2011-12-05  8:13 ` [PATCH 02/10] efi: fix user-land debug printouts Benny Halevy
@ 2011-12-05  8:13 ` Benny Halevy
  2011-12-05  8:13 ` [PATCH 04/10] increase compiler warning level Benny Halevy
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:13 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 ctl.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/ctl.c b/ctl.c
index 2071b0e..959ef6a 100644
--- a/ctl.c
+++ b/ctl.c
@@ -176,6 +176,7 @@ process_msg(int fd, short ev_type, void *arg)
 		resp->res_status = PNFS_BLOCK_FAILURE;
 	} else {
 		printf("Processing: %s: ", table[msg.msg_type].msg_name);
+		fflush(stdout);
 		resp = table[msg.msg_type].msg_func(&msg, resp, &len);
 	}
 
@@ -215,6 +216,8 @@ get_sig(bl_comm_msg_t *msg, bl_comm_res_t *res, int *lenp)
 	minor = msg->u.msg_dev & 0xfffff;
 	dev = (major << 8) | (minor & ~0xf);
 
+	printf("%s: %d:%d: ", __func__, major, minor);
+	fflush(stdout);
 	res->res_status = PNFS_BLOCK_FAILURE;	// Default condition
 	
 	if (mknod(path, S_IFBLK | 0600, dev)) {
@@ -386,6 +389,8 @@ get_slice(bl_comm_msg_t *msg, bl_comm_res_t *res, int *len)
 	partition = minor & 0xf;
 	res->res_status = PNFS_BLOCK_FAILURE;	// Default condition
 	
+	printf("%s: %u:%u: ", __func__, major, minor); fflush(stdout);
+
 	if (mknod(path, S_IFBLK | 0600, dev)) {
 		perror("mknod");
 		goto out;
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 04/10] increase compiler warning level
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
                   ` (2 preceding siblings ...)
  2011-12-05  8:13 ` [PATCH 03/10] ctl: improve " Benny Halevy
@ 2011-12-05  8:13 ` Benny Halevy
  2011-12-05  8:13 ` [PATCH 05/10] ctl: always return a value from find_dm_name Benny Halevy
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:13 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 2b40126..df074dd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 CC= gcc
 OBJS=	ctl.o efi.o
-CFLAGS= -I../../linux-pnfs.working/include
+CFLAGS= -I../../linux-pnfs.working/include -Wall
 
 ctl: $(OBJS)
 	$(CC) -o ctl $(OBJS) -levent -lpthread -lparted
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 05/10] ctl: always return a value from find_dm_name
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
                   ` (3 preceding siblings ...)
  2011-12-05  8:13 ` [PATCH 04/10] increase compiler warning level Benny Halevy
@ 2011-12-05  8:13 ` Benny Halevy
  2011-12-05  8:13 ` [PATCH 06/10] add missing includes Benny Halevy
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:13 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 ctl.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/ctl.c b/ctl.c
index 959ef6a..7432a09 100644
--- a/ctl.c
+++ b/ctl.c
@@ -494,7 +494,7 @@ find_dm_name(int major, int minor)
 	if (((fd = get_output("/sbin/dmsetup", argv)) == -1) ||
 	    ((fp = fdopen(fd, "r")) == NULL)) {
 		printf("%s: get_output/fdopen failed\n", __func__);
-		return;
+		return NULL;
 	}
 	while (fgets(buf, sizeof (buf), fp) != NULL) {
 		t = __token_init(buf, '\t');
@@ -545,6 +545,7 @@ error:
 	
 	fclose(fp);
 	(void) wait(&status);
+	return NULL;
 }
 
 static int
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 06/10] add missing includes
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
                   ` (4 preceding siblings ...)
  2011-12-05  8:13 ` [PATCH 05/10] ctl: always return a value from find_dm_name Benny Halevy
@ 2011-12-05  8:13 ` Benny Halevy
  2011-12-05  8:14 ` [PATCH 07/10] ctl: fix compiler warnings Benny Halevy
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:13 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 ctl.c |    2 ++
 efi.c |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/ctl.c b/ctl.c
index 7432a09..d989ab8 100644
--- a/ctl.c
+++ b/ctl.c
@@ -1,7 +1,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <sys/time.h>
+#include <sys/wait.h>
 #include <event.h>
 #include <pthread.h>
 
diff --git a/efi.c b/efi.c
index b653092..67b6211 100644
--- a/efi.c
+++ b/efi.c
@@ -95,6 +95,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
 
 #include "efi.h"
 
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 07/10] ctl: fix compiler warnings
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
                   ` (5 preceding siblings ...)
  2011-12-05  8:13 ` [PATCH 06/10] add missing includes Benny Halevy
@ 2011-12-05  8:14 ` Benny Halevy
  2011-12-05  8:14 ` [PATCH 08/10] fix compiler warnings around get_output use of argv Benny Halevy
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:14 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 ctl.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/ctl.c b/ctl.c
index d989ab8..e5d16e3 100644
--- a/ctl.c
+++ b/ctl.c
@@ -75,11 +75,10 @@ struct event	ge;
 int
 main(int argc, char **argv)
 {
-	int		upcall_fd,
-			operation	= -1,
-			len;
-	char		c,
-			*prog;
+	int		upcall_fd;
+	int		operation = -1;
+	char		c;
+	char		*prog;
 	pthread_t	t;
 	void		*thr_val;
 
@@ -162,7 +161,7 @@ process_msg(int fd, short ev_type, void *arg)
 		return;
 	len = sizeof (bl_comm_res_t);
 	if ((cc = read(fd, &msg, sizeof (msg))) != sizeof (msg)) {
-		printf("Failed to get all of message. Got %d, expected %d\n",
+		printf("Failed to get all of message. Got %d, expected %Zd\n",
 		    cc, sizeof (msg));
 		resp->res_status = PNFS_BLOCK_FAILURE;
 		write(fd, resp, len);
@@ -352,9 +351,7 @@ get_dm(bl_comm_msg_t *msg, bl_comm_res_t *res, int *lenp)
 bl_comm_res_t *
 check_dm(bl_comm_msg_t *msg, bl_comm_res_t *res, int *len)
 {
-	int	fd,
-		major,
-		minor;
+	int	major, minor;
 	char	*name;
 	
 	res->res_status = PNFS_BLOCK_SUCCESS;
@@ -391,7 +388,7 @@ get_slice(bl_comm_msg_t *msg, bl_comm_res_t *res, int *len)
 	partition = minor & 0xf;
 	res->res_status = PNFS_BLOCK_FAILURE;	// Default condition
 	
-	printf("%s: %u:%u: ", __func__, major, minor); fflush(stdout);
+	printf("%s: %u:%u: ", __func__, (unsigned)major, (unsigned)minor); fflush(stdout);
 
 	if (mknod(path, S_IFBLK | 0600, dev)) {
 		perror("mknod");
@@ -421,7 +418,8 @@ get_slice(bl_comm_msg_t *msg, bl_comm_res_t *res, int *len)
 	res->res_status = PNFS_BLOCK_SUCCESS;
 	res->u.slice.start = ppart->geom.start;
 	res->u.slice.length = ppart->geom.length;
-	printf("Dev: %d:%d, Start: %llu, Length: %llu\n", major, minor,
+	printf("Dev: %u:%u, Start: %llu, Length: %llu\n",
+	       (unsigned)major, (unsigned)minor,
 	       res->u.slice.start, res->u.slice.length);
 out:
 	(void) unlink(path);
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 08/10] fix compiler warnings around get_output use of argv
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
                   ` (6 preceding siblings ...)
  2011-12-05  8:14 ` [PATCH 07/10] ctl: fix compiler warnings Benny Halevy
@ 2011-12-05  8:14 ` Benny Halevy
  2011-12-05  8:14 ` [PATCH 09/10] ctl: main should return 0 on success Benny Halevy
  2011-12-05  8:14 ` [PATCH 10/10] efi: fix compiler warnings Benny Halevy
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:14 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 ctl.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/ctl.c b/ctl.c
index e5d16e3..f1d878d 100644
--- a/ctl.c
+++ b/ctl.c
@@ -52,7 +52,7 @@ static int __token_count(token_t *t);
 static const char * __token_next(token_t *t);
 static const char * __token_str(token_t *t);
 static int __token_next_int(token_t *t);
-static int get_output(char *prog, const char **argv);
+static int get_output(char *prog, char * const *argv);
 static char *find_dm_name(int major, int minor);
 static void hexdump(char *p, int len, int off);
 
@@ -277,7 +277,7 @@ get_vers(bl_comm_msg_t *msg, bl_comm_res_t *res, int *len)
 bl_comm_res_t *
 get_dm(bl_comm_msg_t *msg, bl_comm_res_t *res, int *lenp)
 {
-	const char	*argv[4] = {"dmsetup", "table", NULL, NULL};
+	char	*argv[4] = {"dmsetup", "table", NULL, NULL};
 	char	buf[128],
 		*name;
 	int	major,
@@ -298,7 +298,7 @@ get_dm(bl_comm_msg_t *msg, bl_comm_res_t *res, int *lenp)
 		return res;
 	}
 	argv[2] = name;
-	if (((fd = get_output("/sbin/dmsetup", argv)) == -1) ||
+	if (((fd = get_output("/sbin/dmsetup", (char * const *)argv)) == -1) ||
 	    ((fp = fdopen(fd, "r")) == NULL)) {
 		printf("%s: get_output/fdopen failed\n", __func__);
 		res->res_status = PNFS_BLOCK_FAILURE;
@@ -479,7 +479,7 @@ set_operation(int op)
 static char *
 find_dm_name(int major, int minor)
 {
-	const char	*argv[5] = {"dmsetup", "ls", "--target", "striped", NULL};
+	char * const argv[5] = {"dmsetup", "ls", "--target", "striped", NULL};
 	char		buf[128],
 			*name;
 	const char	*majmin;
@@ -549,7 +549,7 @@ error:
 }
 
 static int
-get_output(char *prog, const char **argv)
+get_output(char *prog, char * const *argv)
 {
 	int	fildes[2];
 	
@@ -567,13 +567,11 @@ get_output(char *prog, const char **argv)
 			close(fildes[0]);
 			dup2(fildes[1], 1);
 			dup2(fildes[1], 2);
-			if (execv(prog, argv) == -1) {
-				perror("execv");
-				exit(1);
-			}
-			break;
+			execv(prog, argv);
+			perror("execv");
+			exit(1);
 			
-			default:
+		default:
 			close(fildes[1]);
 			return fildes[0];
 	}
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 09/10] ctl: main should return 0 on success
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
                   ` (7 preceding siblings ...)
  2011-12-05  8:14 ` [PATCH 08/10] fix compiler warnings around get_output use of argv Benny Halevy
@ 2011-12-05  8:14 ` Benny Halevy
  2011-12-05  8:14 ` [PATCH 10/10] efi: fix compiler warnings Benny Halevy
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:14 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 ctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/ctl.c b/ctl.c
index f1d878d..a28c9e9 100644
--- a/ctl.c
+++ b/ctl.c
@@ -131,6 +131,8 @@ main(int argc, char **argv)
 		close(upcall_fd);
 		pthread_join(t, &thr_val);
 	}
+
+	return 0;
 }
 
 /*
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 10/10] efi: fix compiler warnings
  2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
                   ` (8 preceding siblings ...)
  2011-12-05  8:14 ` [PATCH 09/10] ctl: main should return 0 on success Benny Halevy
@ 2011-12-05  8:14 ` Benny Halevy
  9 siblings, 0 replies; 11+ messages in thread
From: Benny Halevy @ 2011-12-05  8:14 UTC (permalink / raw)
  To: linux-nfs

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 efi.c |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/efi.c b/efi.c
index 67b6211..a8c70d2 100644
--- a/efi.c
+++ b/efi.c
@@ -123,8 +123,6 @@
 static size_t
 read_lba(int fd, u64 lba, u8 * buffer, size_t count)
 {
-	size_t totalreadcount = 0;
-
 	lseek(fd, lba * 512LL, 0);
 	return read(fd, buffer, count);
 }
@@ -205,9 +203,6 @@ static int
 is_gpt_valid(int fd, u64 lba,
 	     gpt_header **gpt, gpt_entry **ptes)
 {
-	u32 crc, origcrc;
-	u64 lastlba;
-
 	if (!(*gpt = alloc_read_gpt_header(fd, lba)))
 		return 0;
 
@@ -236,9 +231,6 @@ is_gpt_valid(int fd, u64 lba,
 	/* We're done, all's well */
 	return 1;
 
- fail_ptes:
-	free(*ptes);
-	*ptes = NULL;
  fail:
 	free(*gpt);
 	*gpt = NULL;
@@ -284,7 +276,7 @@ efi_signature(int fd, struct partition_sig *sig)
         gpt_entry       *ptes   = NULL;
         int             rval    = 0;
 
-        sig->ps_sector_off = (u32)&((gpt_header *)0)->disk_guid.b[0];
+        sig->ps_sector_off = __builtin_offsetof(gpt_header, disk_guid.b);
         sig->ps_sector = GPT_PRIMARY_PARTITION_TABLE_LBA;
         sig->ps_len = sizeof (efi_guid_t);
 
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-12-05  8:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-05  8:09 [PATCH 0/10] pnfs-block ctl Benny Halevy
2011-12-05  8:12 ` [PATCH 01/10] use gcc Benny Halevy
2011-12-05  8:13 ` [PATCH 02/10] efi: fix user-land debug printouts Benny Halevy
2011-12-05  8:13 ` [PATCH 03/10] ctl: improve " Benny Halevy
2011-12-05  8:13 ` [PATCH 04/10] increase compiler warning level Benny Halevy
2011-12-05  8:13 ` [PATCH 05/10] ctl: always return a value from find_dm_name Benny Halevy
2011-12-05  8:13 ` [PATCH 06/10] add missing includes Benny Halevy
2011-12-05  8:14 ` [PATCH 07/10] ctl: fix compiler warnings Benny Halevy
2011-12-05  8:14 ` [PATCH 08/10] fix compiler warnings around get_output use of argv Benny Halevy
2011-12-05  8:14 ` [PATCH 09/10] ctl: main should return 0 on success Benny Halevy
2011-12-05  8:14 ` [PATCH 10/10] efi: fix compiler warnings Benny Halevy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).