pnfs-block ctl
Subsystems (3)
cover pnfs-block ctl
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
PATCH 1/10 use gcc
From: Benny Halevy <[email protected]>
--- Makefile | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
Makefile +2 -1
@@ -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
Signature · 1 line
1.7.6
PATCH 2/10 efi: fix user-land debug printouts
In reply to Benny HalevyFrom: Benny Halevy <[email protected]>
--- efi.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
efi.c +4 -1
@@ -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
Signature · 1 line
1.7.6
PATCH 3/10 ctl: improve debug printouts
In reply to Benny HalevyFrom: Benny Halevy <[email protected]>
--- ctl.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
ctl.c +5 -0
@@ -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;
Signature · 1 line
1.7.6
PATCH 4/10 increase compiler warning level
In reply to Benny HalevyFrom: Benny Halevy <[email protected]>
--- Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +1 -1
@@ -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
Signature · 1 line
1.7.6
PATCH 5/10 ctl: always return a value from find_dm_name
In reply to Benny HalevyFrom: Benny Halevy <[email protected]>
--- ctl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
ctl.c +2 -1
@@ -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
Signature · 1 line
1.7.6
PATCH 6/10 add missing includes
In reply to Benny HalevyFrom: Benny Halevy <[email protected]>
--- ctl.c | 2 ++ efi.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
ctl.c +2 -0
@@ -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>
efi.c +2 -0
@@ -95,6 +95,8 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> +#include <sys/types.h> #include "efi.h"
Signature · 1 line
1.7.6
PATCH 7/10 ctl: fix compiler warnings
In reply to Benny HalevyFrom: Benny Halevy <[email protected]>
--- ctl.c | 20 +++++++++----------- 1 files changed, 9 insertions(+), 11 deletions(-)
ctl.c +9 -11
@@ -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);
Signature · 1 line
1.7.6
PATCH 8/10 fix compiler warnings around get_output use of argv
In reply to Benny HalevyFrom: Benny Halevy <[email protected]>
--- ctl.c | 20 +++++++++----------- 1 files changed, 9 insertions(+), 11 deletions(-)
ctl.c +9 -11
@@ -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 ]; }
Signature · 1 line
1.7.6
PATCH 9/10 ctl: main should return 0 on success
In reply to Benny HalevyFrom: Benny Halevy <[email protected]>
--- ctl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
ctl.c +2 -0
@@ -131,6 +131,8 @@ main(int argc, char **argv)close (upcall_fd);pthread_join (t, &thr_val); } + +return 0 ; }/*
Signature · 1 line
1.7.6
PATCH 10/10 efi: fix compiler warnings
In reply to Benny HalevyFrom: Benny Halevy <[email protected]>
--- efi.c | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-)
efi.c +1 -9
@@ -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);
Signature · 1 line
1.7.6