[PATCHES] vfs_gpfs: Remove unnecessary calls for handling paths
Christof Schmitt
cs at samba.org
Thu May 24 23:57:33 UTC 2018
On Thu, May 24, 2018 at 04:31:01PM -0700, Jeremy Allison wrote:
> On Thu, May 24, 2018 at 04:30:17PM -0700, Christof Schmitt via samba-technical wrote:
> > Small small optimizations. get_full_smb_filename is not required as that
> > only adds stream information. The full path in
> > vfs_gpfs_get_real_filename can be construced through full_path_tos to
> > avoid the talloc call.
> >
> > Please review and push.
>
> ENOPATCH :-).
Here :-)
-------------- next part --------------
From 946983218da9c2dd3db26ef4142d0b2f44dca2f1 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 22 May 2018 12:22:06 -0700
Subject: [PATCH 1/3] vfs_gpfs: Remove wrong get_full_smb_filename from ntimes
function
Updating the timestamps requires the path to the file, but no stream
information.
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/modules/vfs_gpfs.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index a0fd48f..bd64b20 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1879,23 +1879,15 @@ static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
struct gpfs_winattr attrs;
int ret;
- char *path = NULL;
- NTSTATUS status;
struct gpfs_config_data *config;
SMB_VFS_HANDLE_GET_DATA(handle, config,
struct gpfs_config_data,
return -1);
- status = get_full_smb_filename(talloc_tos(), smb_fname, &path);
- if (!NT_STATUS_IS_OK(status)) {
- errno = map_errno_from_nt_status(status);
- return -1;
- }
-
/* Try to use gpfs_set_times if it is enabled and available */
if (config->settimes) {
- ret = smbd_gpfs_set_times_path(path, ft);
+ ret = smbd_gpfs_set_times_path(smb_fname->base_name, ft);
if (ret == 0 || (ret == -1 && errno != ENOSYS)) {
return ret;
@@ -1928,7 +1920,7 @@ static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
attrs.creationTime.tv_sec = ft->create_time.tv_sec;
attrs.creationTime.tv_nsec = ft->create_time.tv_nsec;
- ret = gpfswrap_set_winattrs_path(discard_const_p(char, path),
+ ret = gpfswrap_set_winattrs_path(smb_fname->base_name,
GPFS_WINATTR_SET_CREATION_TIME,
&attrs);
if(ret == -1 && errno != ENOSYS){
--
1.8.3.1
From d4d08b1dbe84620d8b92f66873f211955f021041 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 22 May 2018 12:25:42 -0700
Subject: [PATCH 2/3] vfs_gpfs: Remove get_full_smb_filename from is_offline
check
No stream information is required here.
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/modules/vfs_gpfs.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index bd64b20..c7eb81b 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1994,8 +1994,6 @@ static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
SMB_STRUCT_STAT *sbuf)
{
struct gpfs_winattr attrs;
- char *path = NULL;
- NTSTATUS status;
struct gpfs_config_data *config;
int ret;
@@ -2007,24 +2005,17 @@ static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
return false;
}
- status = get_full_smb_filename(talloc_tos(), fname, &path);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
- }
-
- ret = gpfswrap_get_winattrs_path(path, &attrs);
+ ret = gpfswrap_get_winattrs_path(fname->base_name, &attrs);
if (ret == -1) {
- TALLOC_FREE(path);
return false;
}
if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) {
- DEBUG(10, ("%s is offline\n", path));
- TALLOC_FREE(path);
+ DBG_DEBUG("%s is offline\n", fname->base_name);
return true;
}
- DEBUG(10, ("%s is online\n", path));
- TALLOC_FREE(path);
+
+ DBG_DEBUG("%s is online\n", fname->base_name);
return false;
}
--
1.8.3.1
From cdc908006f2e099cb6305a7a771f291ba3e54c08 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 22 May 2018 12:52:58 -0700
Subject: [PATCH 3/3] vfs_gpfs: Use full_path_tos instead of talloc_asprintf
full_path_tos avoids the talloc call for most cases; use that instead of
talloc_asprintf.
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/modules/vfs_gpfs.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index c7eb81b..3e4b090 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -243,8 +243,9 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
char **found_name)
{
int result;
- char *full_path;
- char real_pathname[PATH_MAX+1];
+ char *full_path, *to_free;
+ char real_pathname[PATH_MAX+1], tmpbuf[PATH_MAX];
+ size_t full_path_len;
int buflen;
bool mangled;
struct gpfs_config_data *config;
@@ -264,8 +265,9 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
mem_ctx, found_name);
}
- full_path = talloc_asprintf(talloc_tos(), "%s/%s", path, name);
- if (full_path == NULL) {
+ full_path_len = full_path_tos(path, name, tmpbuf, sizeof(tmpbuf),
+ &full_path, &to_free);
+ if (full_path_len == -1) {
errno = ENOMEM;
return -1;
}
@@ -275,7 +277,7 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
result = gpfswrap_get_realfilename_path(full_path, real_pathname,
&buflen);
- TALLOC_FREE(full_path);
+ TALLOC_FREE(to_free);
if ((result == -1) && (errno == ENOSYS)) {
return SMB_VFS_NEXT_GET_REAL_FILENAME(
--
1.8.3.1
More information about the samba-technical
mailing list