[PATCHES] Some cleanup patches for gpfs code

Christof Schmitt cs at samba.org
Tue Jul 7 23:38:54 CEST 2015


Volker gave me the ok to add his reviewed-by, when fixing the
initializer from { } to { 0 }. I will make this change and push the
patches.

Christof

On Thu, Jul 02, 2015 at 03:36:13PM -0700, Christof Schmitt wrote:
> From 26b588597ad77604a5556e58a62c09491b21cd95 Mon Sep 17 00:00:00 2001
> From: Christof Schmitt <cs at samba.org>
> Date: Mon, 23 Mar 2015 12:54:34 -0700
> Subject: [PATCH 1/4] vfs_gpfs: Use ACL defines from GPFS 3.5 header files
> 
> GPFS 3.5 is now the oldest support version. Cleanup the ACL code by
> using the defines and structs from the 3.5 header file.
> 
> Signed-off-by: Christof Schmitt <cs at samba.org>
> ---
>  source3/modules/vfs_gpfs.c |   28 ++++++++++++----------------
>  1 files changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
> index 9ad8fbc..2a3b026 100644
> --- a/source3/modules/vfs_gpfs.c
> +++ b/source3/modules/vfs_gpfs.c
> @@ -56,19 +56,16 @@ struct gpfs_config_data {
>  
>  static inline unsigned int gpfs_acl_flags(gpfs_acl_t *gacl)
>  {
> -	if (gacl->acl_level == 1) { /* GPFS_ACL_LEVEL_V4FLAGS */
> -		/* gacl->v4Level1.acl_flags requires gpfs 3.5 */
> -		return *(unsigned int *)&gacl->ace_v4;
> +	if (gacl->acl_level == GPFS_ACL_LEVEL_V4FLAGS) {
> +		return gacl->v4Level1.acl_flags;
>  	}
>  	return 0;
>  }
>  
>  static inline gpfs_ace_v4_t *gpfs_ace_ptr(gpfs_acl_t *gacl, unsigned int i)
>  {
> -	if (gacl->acl_level == 1) { /* GPFS_ACL_LEVEL_V4FLAGS */
> -		/* &gacl->v4Level1.ace_v4[i] requires gpfs 3.5 */
> -		char *ptr = (char *)&gacl->ace_v4[i] + sizeof(unsigned int);
> -		return (gpfs_ace_v4_t *)ptr;
> +	if (gacl->acl_level == GPFS_ACL_LEVEL_V4FLAGS) {
> +		return &gacl->v4Level1.ace_v4[i];
>  	}
>  	return &gacl->ace_v4[i];
>  }
> @@ -315,12 +312,11 @@ static void sd2gpfs_control(uint16_t control, struct gpfs_acl *gacl)
>  		SEC_DESC_DACL_PRESENT | SEC_DESC_SACL_PRESENT;
>  	gpfs_aclflags = control << 8;
>  	if (!(control & SEC_DESC_DACL_PRESENT))
> -		gpfs_aclflags |= 0x00800000; /* ACL4_FLAG_NULL_DACL; */
> +		gpfs_aclflags |= ACL4_FLAG_NULL_DACL;
>  	if (!(control & SEC_DESC_SACL_PRESENT))
> -		gpfs_aclflags |= 0x01000000; /* ACL4_FLAG_NULL_SACL; */
> -	gacl->acl_level = 1; /* GPFS_ACL_LEVEL_V4FLAGS*/
> -	/* gacl->v4Level1.acl_flags requires gpfs 3.5 */
> -	*(unsigned int *)&gacl->ace_v4 = gpfs_aclflags;
> +		gpfs_aclflags |= ACL4_FLAG_NULL_SACL;
> +	gacl->acl_level = GPFS_ACL_LEVEL_V4FLAGS;
> +	gacl->v4Level1.acl_flags = gpfs_aclflags;
>  }
>  
>  static uint16_t gpfs2sd_control(unsigned int gpfs_aclflags)
> @@ -396,7 +392,7 @@ again:
>  	} else {
>  		struct gpfs_acl *buf = (struct gpfs_acl *) aclbuf;
>  		buf->acl_type = type;
> -		buf->acl_level = 1; /* GPFS_ACL_LEVEL_V4FLAGS */
> +		buf->acl_level = GPFS_ACL_LEVEL_V4FLAGS;
>  		flags = GPFS_GETACL_STRUCT;
>  		len = &(buf->acl_len);
>  		/* reserve space for control flags in gpfs 3.5 and beyond */
> @@ -471,7 +467,7 @@ static int gpfs_get_nfs4_acl(TALLOC_CTX *mem_ctx, const char *fname, SMB4ACL_T *
>  
>  	*ppacl = smb_create_smb4acl(mem_ctx);
>  
> -	if (gacl->acl_level == 1) { /* GPFS_ACL_LEVEL_V4FLAGS */
> +	if (gacl->acl_level == GPFS_ACL_LEVEL_V4FLAGS) {
>  		uint16_t control = gpfs2sd_control(gpfs_acl_flags(gacl));
>  		smbacl4_set_controlflags(*ppacl, control);
>  	}
> @@ -648,13 +644,13 @@ static struct gpfs_acl *vfs_gpfs_smbacl2gpfsacl(TALLOC_CTX *mem_ctx,
>  		return NULL;
>  	}
>  
> -	gacl->acl_level = 0; /* GPFS_ACL_LEVEL_BASE */
> +	gacl->acl_level = GPFS_ACL_LEVEL_BASE;
>  	gacl->acl_version = GPFS_ACL_VERSION_NFS4;
>  	gacl->acl_type = GPFS_ACL_TYPE_NFS4;
>  	gacl->acl_nace = 0; /* change later... */
>  
>  	if (controlflags) {
> -		gacl->acl_level = 1; /* GPFS_ACL_LEVEL_V4FLAGS */
> +		gacl->acl_level = GPFS_ACL_LEVEL_V4FLAGS;
>  		sd2gpfs_control(smbacl4_get_controlflags(smbacl), gacl);
>  	}
>  
> -- 
> 1.7.1
> 
> 
> From 1a3f162eea00a2d274f350474b341c32b1dc296b Mon Sep 17 00:00:00 2001
> From: Christof Schmitt <cs at samba.org>
> Date: Mon, 23 Mar 2015 12:57:39 -0700
> Subject: [PATCH 2/4] vfs_gpfs: Use C99 initializers
> 
> Signed-off-by: Christof Schmitt <cs at samba.org>
> ---
>  source3/modules/vfs_gpfs.c |   15 +++++----------
>  1 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
> index 2a3b026..257bc4f 100644
> --- a/source3/modules/vfs_gpfs.c
> +++ b/source3/modules/vfs_gpfs.c
> @@ -478,12 +478,11 @@ static int gpfs_get_nfs4_acl(TALLOC_CTX *mem_ctx, const char *fname, SMB4ACL_T *
>  
>  	for (i=0; i<gacl->acl_nace; i++) {
>  		struct gpfs_ace_v4 *gace = gpfs_ace_ptr(gacl, i);
> -		SMB_ACE4PROP_T smbace;
> +		SMB_ACE4PROP_T smbace = {};
>  		DEBUG(10, ("type: %d, iflags: %x, flags: %x, mask: %x, "
>  			   "who: %d\n", gace->aceType, gace->aceIFlags,
>  			   gace->aceFlags, gace->aceMask, gace->aceWho));
>  
> -		ZERO_STRUCT(smbace);
>  		if (gace->aceIFlags & ACE4_IFLAG_SPECIAL_ID) {
>  			smbace.flags |= SMB_ACE4_ID_SPECIAL;
>  			switch (gace->aceWho) {
> @@ -1299,7 +1298,7 @@ static int gpfsacl_emu_chmod(vfs_handle_struct *handle,
>  	int     result;
>  	bool    haveAllowEntry[SMB_ACE4_WHO_EVERYONE + 1] = {False, False, False, False};
>  	int     i;
> -	files_struct    fake_fsp; /* TODO: rationalize parametrization */
> +	files_struct    fake_fsp = {}; /* TODO: rationalize parametrization */
>  	SMB4ACE_T       *smbace;
>  	TALLOC_CTX *frame = talloc_stackframe();
>  
> @@ -1345,12 +1344,11 @@ static int gpfsacl_emu_chmod(vfs_handle_struct *handle,
>  	 * - if necessary
>  	 */
>  	for(i = SMB_ACE4_WHO_OWNER; i<=SMB_ACE4_WHO_EVERYONE; i++) {
> -		SMB_ACE4PROP_T  ace;
> +		SMB_ACE4PROP_T ace = {};
>  
>  		if (haveAllowEntry[i]==True)
>  			continue;
>  
> -		ZERO_STRUCT(ace);
>  		ace.aceType = SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE;
>  		ace.flags |= SMB_ACE4_ID_SPECIAL;
>  		ace.who.special_id = i;
> @@ -1372,7 +1370,6 @@ static int gpfsacl_emu_chmod(vfs_handle_struct *handle,
>  	}
>  
>  	/* don't add complementary DENY ACEs here */
> -	ZERO_STRUCT(fake_fsp);
>  	fake_fsp.fsp_name = synthetic_smb_fname(
>  		frame, path, NULL, NULL);
>  	if (fake_fsp.fsp_name == NULL) {
> @@ -1767,11 +1764,10 @@ static void timespec_to_gpfs_time(struct timespec ts, gpfs_timestruc_t *gt,
>  
>  static int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft)
>  {
> -	gpfs_timestruc_t gpfs_times[4];
> +	gpfs_timestruc_t gpfs_times[4] = {};
>  	int flags = 0;
>  	int rc;
>  
> -	ZERO_ARRAY(gpfs_times);
>  	timespec_to_gpfs_time(ft->atime, gpfs_times, 0, &flags);
>  	timespec_to_gpfs_time(ft->mtime, gpfs_times, 1, &flags);
>  	/* No good mapping from LastChangeTime to ctime, not storing */
> @@ -2067,7 +2063,6 @@ static int get_gpfs_quota(const char *pathname, int type, int id,
>  {
>  	int ret;
>  
> -	ZERO_STRUCTP(qi);
>  	ret = gpfswrap_quotactl(discard_const_p(char, pathname),
>  				GPFS_QCMD(Q_GETQUOTA, type), id, qi);
>  
> @@ -2133,7 +2128,7 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle, const char *path,
>  				   uint64_t *dfree, uint64_t *dsize)
>  {
>  	struct security_unix_token *utok;
> -	struct gpfs_quotaInfo qi_user, qi_group;
> +	struct gpfs_quotaInfo qi_user = {}, qi_group = {};
>  	struct gpfs_config_data *config;
>  	int err;
>  	time_t cur_time;
> -- 
> 1.7.1
> 
> 
> From 623ffe1a74a5e10bcf2c35dffa5a650fde5f7451 Mon Sep 17 00:00:00 2001
> From: Christof Schmitt <cs at samba.org>
> Date: Thu, 2 Jul 2015 15:20:01 -0700
> Subject: [PATCH 3/4] gpfswrap: Remove unused wrapper for gpfs_fnctl
> 
> Since the removal of the fileset quota check, this wrapper function is
> longer used.
> 
> Signed-off-by: Christof Schmitt <cs at samba.org>
> ---
>  lib/util/gpfswrap.c |   12 ------------
>  lib/util/gpfswrap.h |    1 -
>  2 files changed, 0 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/util/gpfswrap.c b/lib/util/gpfswrap.c
> index 732fcb6..4c74105 100644
> --- a/lib/util/gpfswrap.c
> +++ b/lib/util/gpfswrap.c
> @@ -38,7 +38,6 @@ static int (*gpfs_lib_init_fn)(int flags);
>  static int (*gpfs_set_times_path_fn)(char *pathname, int flags,
>  				     gpfs_timestruc_t times[4]);
>  static int (*gpfs_quotactl_fn)(char *pathname, int cmd, int id, void *bufp);
> -static int (*gpfs_fcntl_fn)(int fd, void *argp);
>  static int (*gpfs_getfilesetid_fn)(char *pathname, char *name, int *idp);
>  static int (*gpfs_init_trace_fn)(void);
>  static int (*gpfs_query_trace_fn)(void);
> @@ -71,7 +70,6 @@ int gpfswrap_init(void)
>  	gpfs_lib_init_fn	      = dlsym(l, "gpfs_lib_init");
>  	gpfs_set_times_path_fn	      = dlsym(l, "gpfs_set_times_path");
>  	gpfs_quotactl_fn	      = dlsym(l, "gpfs_quotactl");
> -	gpfs_fcntl_fn		      = dlsym(l, "gpfs_fcntl");
>  	gpfs_getfilesetid_fn	      = dlsym(l, "gpfs_getfilesetid");
>  	gpfs_init_trace_fn	      = dlsym(l, "gpfs_init_trace");
>  	gpfs_query_trace_fn	      = dlsym(l, "gpfs_query_trace");
> @@ -213,16 +211,6 @@ int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp)
>  	return gpfs_quotactl_fn(pathname, cmd, id, bufp);
>  }
>  
> -int gpfswrap_fcntl(int fd, void *argp)
> -{
> -	if (gpfs_fcntl_fn == NULL) {
> -		errno = ENOSYS;
> -		return -1;
> -	}
> -
> -	return gpfs_fcntl_fn(fd, argp);
> -}
> -
>  int gpfswrap_getfilesetid(char *pathname, char *name, int *idp)
>  {
>  	if (gpfs_getfilesetid_fn == NULL) {
> diff --git a/lib/util/gpfswrap.h b/lib/util/gpfswrap.h
> index fc8ac4a..6fee40a 100644
> --- a/lib/util/gpfswrap.h
> +++ b/lib/util/gpfswrap.h
> @@ -42,7 +42,6 @@ int gpfswrap_lib_init(int flags);
>  int gpfswrap_set_times_path(char *pathname, int flags,
>  			    gpfs_timestruc_t times[4]);
>  int gpfswrap_quotactl(char *pathname, int cmd, int id, void *bufp);
> -int gpfswrap_fcntl(int fd, void *argp);
>  int gpfswrap_getfilesetid(char *pathname, char *name, int *idp);
>  int gpfswrap_init_trace(void);
>  int gpfswrap_query_trace(void);
> -- 
> 1.7.1
> 
> 
> From 373de26ddcd57ab053370a0070feb1c56c91ec88 Mon Sep 17 00:00:00 2001
> From: Christof Schmitt <cs at samba.org>
> Date: Thu, 2 Jul 2015 15:31:29 -0700
> Subject: [PATCH 4/4] gpfswrap: Use gpfs.h instead of gpfs_fcntl.h
> 
> Without the need for the gpfs_fcntl function, only the gpfs.h header
> file is required.
> 
> Signed-off-by: Christof Schmitt <cs at samba.org>
> ---
>  lib/util/gpfswrap.h        |    2 +-
>  lib/util/wscript_configure |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/util/gpfswrap.h b/lib/util/gpfswrap.h
> index 6fee40a..25b1ba8 100644
> --- a/lib/util/gpfswrap.h
> +++ b/lib/util/gpfswrap.h
> @@ -24,7 +24,7 @@
>  #ifndef __GPFSWRAP_H__
>  #define __GPFSWRAP_H__
>  
> -#include <gpfs_fcntl.h>
> +#include <gpfs.h>
>  
>  int gpfswrap_init(void);
>  int gpfswrap_set_share(int fd, unsigned int allow, unsigned int deny);
> diff --git a/lib/util/wscript_configure b/lib/util/wscript_configure
> index a17cb56..95a8949 100644
> --- a/lib/util/wscript_configure
> +++ b/lib/util/wscript_configure
> @@ -136,5 +136,5 @@ else:
>      conf.undefine('HAVE_LTTNG_TRACEF')
>  
>  conf.env['CPPPATH_GPFS'] = '/usr/lpp/mmfs/include/'
> -if conf.CHECK_HEADERS('gpfs_fcntl.h', False, False, "gpfs"):
> +if conf.CHECK_HEADERS('gpfs.h', False, False, "gpfs"):
>      conf.DEFINE('HAVE_GPFS', '1')
> -- 
> 1.7.1


More information about the samba-technical mailing list