[PATCHES] vfs_gpfs: Remove fileset quota check

Christof Schmitt cs at samba.org
Wed Apr 15 15:48:56 MDT 2015


From f0df75e8ee557f14391f83f073c75c0cd10a8615 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 6 Apr 2015 14:56:11 -0700
Subject: [PATCH 1/3] vfs_gpfs: Remove check for fileset quota

Querying the fileset id requires additional GPFS API calls and also
opening a directory, which might have other side effects. A better
option would be configuring the file system with --filesetdf, then the
fileset quota is automatically reflected in the free space information
reported from gpfs.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/vfs_gpfs.c |   89 ++-----------------------------------------
 1 files changed, 5 insertions(+), 84 deletions(-)

diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 2044a0e..c7f17cd 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -2045,50 +2045,6 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle,
 	return 0;
 }
 
-static int get_gpfs_fset_id(const char *pathname, int *fset_id)
-{
-	int err, fd, errno_fcntl;
-
-	struct {
-		gpfsFcntlHeader_t hdr;
-		gpfsGetFilesetName_t fsn;
-	} arg;
-
-	arg.hdr.totalLength = sizeof(arg);
-	arg.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
-	arg.hdr.fcntlReserved = 0;
-	arg.fsn.structLen = sizeof(arg.fsn);
-	arg.fsn.structType = GPFS_FCNTL_GET_FILESETNAME;
-
-	fd = open(pathname, O_RDONLY);
-	if (fd == -1) {
-		DEBUG(1, ("Could not open %s: %s\n",
-			  pathname, strerror(errno)));
-		return fd;
-	}
-
-	err = gpfswrap_fcntl(fd, &arg);
-	errno_fcntl = errno;
-	close(fd);
-
-	if (err) {
-		errno = errno_fcntl;
-		if (errno != ENOSYS) {
-			DEBUG(1, ("GPFS_FCNTL_GET_FILESETNAME for %s failed: "
-				  "%s\n", pathname, strerror(errno)));
-		}
-		return err;
-	}
-
-	err = gpfswrap_getfilesetid(discard_const_p(char, pathname),
-				    arg.fsn.buffer, fset_id);
-	if (err && errno != ENOSYS) {
-		DEBUG(1, ("gpfs_getfilesetid for %s failed: %s\n",
-			  pathname, strerror(errno)));
-	}
-	return err;
-}
-
 static int get_gpfs_quota(const char *pathname, int type, int id,
 			  struct gpfs_quotaInfo *qi)
 {
@@ -2117,37 +2073,12 @@ static int get_gpfs_quota(const char *pathname, int type, int id,
 }
 
 static int vfs_gpfs_get_quotas(const char *path, uid_t uid, gid_t gid,
-			       int *fset_id,
 			       struct gpfs_quotaInfo *qi_user,
-			       struct gpfs_quotaInfo *qi_group,
-			       struct gpfs_quotaInfo *qi_fset)
+			       struct gpfs_quotaInfo *qi_group)
 {
 	int err;
-	char *dir_path;
 	bool b;
 
-	/*
-	 * We want to always use the directory to get the fileset id,
-	 * because files might have a share mode. We also do not want
-	 * to get the parent directory when there is already a
-	 * directory to avoid stepping in a different fileset.  The
-	 * path passed here is currently either "." or a filename, so
-	 * this is ok. The proper solution would be having a way to
-	 * query the fileset id without opening the file.
-	 */
-	b = parent_dirname(talloc_tos(), path, &dir_path, NULL);
-	if (!b) {
-		errno = ENOMEM;
-		return -1;
-	}
-
-	DEBUG(10, ("path %s, directory %s\n", path, dir_path));
-
-	err = get_gpfs_fset_id(dir_path, fset_id);
-	if (err) {
-		return err;
-	}
-
 	err = get_gpfs_quota(path, GPFS_USRQUOTA, uid, qi_user);
 	if (err) {
 		return err;
@@ -2158,11 +2089,6 @@ static int vfs_gpfs_get_quotas(const char *path, uid_t uid, gid_t gid,
 		return err;
 	}
 
-	err = get_gpfs_quota(path, GPFS_FILESETQUOTA, *fset_id, qi_fset);
-	if (err) {
-		return err;
-	}
-
 	return 0;
 }
 
@@ -2210,9 +2136,9 @@ 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, qi_fset;
+	struct gpfs_quotaInfo qi_user, qi_group;
 	struct gpfs_config_data *config;
-	int err, fset_id;
+	int err;
 	time_t cur_time;
 
 	SMB_VFS_HANDLE_GET_DATA(handle, config, struct gpfs_config_data,
@@ -2236,8 +2162,8 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle, const char *path,
 		   (unsigned long long)*dfree, (unsigned long long)*dsize));
 
 	utok = handle->conn->session_info->unix_token;
-	err = vfs_gpfs_get_quotas(path, utok->uid, utok->gid, &fset_id,
-				  &qi_user, &qi_group, &qi_fset);
+	err = vfs_gpfs_get_quotas(path, utok->uid, utok->gid,
+				  &qi_user, &qi_group);
 	if (err) {
 		return SMB_VFS_NEXT_DISK_FREE(handle, path,
 					      bsize, dfree, dsize);
@@ -2249,11 +2175,6 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle, const char *path,
 	vfs_gpfs_disk_free_quota(qi_user, cur_time, dfree, dsize);
 	vfs_gpfs_disk_free_quota(qi_group, cur_time, dfree, dsize);
 
-	/* Id 0 indicates the default quota, not an actual quota */
-	if (fset_id != 0) {
-		vfs_gpfs_disk_free_quota(qi_fset, cur_time, dfree, dsize);
-	}
-
 	disk_norm(bsize, dfree, dsize);
 	return *dfree;
 }
-- 
1.7.1


From 7fe3c1686b300dde6a96465807cd8ccecde47398 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 6 Apr 2015 15:07:59 -0700
Subject: [PATCH 2/3] vfs_gpfs: Remove vfs_gpfs_get_quotas

Call get_gpfs_quota directly from vfs_gpfs_disk_free_quota to get user
and group quotas.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/modules/vfs_gpfs.c |   30 ++++++++----------------------
 1 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index c7f17cd..aa07060 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -2072,26 +2072,6 @@ static int get_gpfs_quota(const char *pathname, int type, int id,
 	return ret;
 }
 
-static int vfs_gpfs_get_quotas(const char *path, uid_t uid, gid_t gid,
-			       struct gpfs_quotaInfo *qi_user,
-			       struct gpfs_quotaInfo *qi_group)
-{
-	int err;
-	bool b;
-
-	err = get_gpfs_quota(path, GPFS_USRQUOTA, uid, qi_user);
-	if (err) {
-		return err;
-	}
-
-	err = get_gpfs_quota(path, GPFS_GRPQUOTA, gid, qi_group);
-	if (err) {
-		return err;
-	}
-
-	return 0;
-}
-
 static void vfs_gpfs_disk_free_quota(struct gpfs_quotaInfo qi, time_t cur_time,
 				     uint64_t *dfree, uint64_t *dsize)
 {
@@ -2162,8 +2142,14 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle, const char *path,
 		   (unsigned long long)*dfree, (unsigned long long)*dsize));
 
 	utok = handle->conn->session_info->unix_token;
-	err = vfs_gpfs_get_quotas(path, utok->uid, utok->gid,
-				  &qi_user, &qi_group);
+
+	err = get_gpfs_quota(path, GPFS_USRQUOTA, utok->uid, &qi_user);
+	if (err) {
+		return SMB_VFS_NEXT_DISK_FREE(handle, path,
+					      bsize, dfree, dsize);
+	}
+
+	err = get_gpfs_quota(path, GPFS_GRPQUOTA, utok->gid, &qi_group);
 	if (err) {
 		return SMB_VFS_NEXT_DISK_FREE(handle, path,
 					      bsize, dfree, dsize);
-- 
1.7.1


From 8d4dbeef8ceefd3d72c42ffd80e8e7bb714da10f Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 7 Apr 2015 13:43:41 -0700
Subject: [PATCH 3/3] docs: Update vfs_gpfs manpage for the removed fileset quota check

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 docs-xml/manpages/vfs_gpfs.8.xml |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/docs-xml/manpages/vfs_gpfs.8.xml b/docs-xml/manpages/vfs_gpfs.8.xml
index 21865c4..c67aedc 100644
--- a/docs-xml/manpages/vfs_gpfs.8.xml
+++ b/docs-xml/manpages/vfs_gpfs.8.xml
@@ -281,10 +281,12 @@
 		Adjust reporting of the size and free space of a share
 		according to quotas. If this setting is "yes", a
 		request for size and free space will also evaluate the
-		user quota of the user requesting the data, the group
-		quota of the primary group of the user and the fileset
-		quota for the fileset containing the top level
-		directory of the share.
+		user quota of the user requesting the data and the
+		group quota of the primary group of the user. Fileset
+		quotas are not queried, since GPFS already provides
+		the option --dfreequota to reflect the fileset quota
+		in the free space query. Please use that option to
+		include fileset quotas in the reported disk space.
 		</para>
 
 		<para>
-- 
1.7.1



More information about the samba-technical mailing list