[PATCH] s3/vfs/nfs4_acls: avoid a stat
Ralph Böhme
slow at samba.org
Sun Sep 11 14:10:57 UTC 2016
Hi!
Not 100% sure about this one, but I think we can avoid a stat in the
nfs4_acls and reuse the stat info from the files_struct or the
smb_filename if it's valid.
Please review & push if ok. Thanks!
Cheerio!
-slow
-------------- next part --------------
From f1f35207637a43abaab2b0907dd71c2d9d8c531f Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 11 Sep 2016 13:30:44 +0200
Subject: [PATCH] s3/vfs/nfs4_acls: avoid a stat
Signed-off-by: Ralph Boehme <slow at samba.org>
---
source3/modules/nfs4_acls.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 71f4d8d..a954831 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -529,11 +529,19 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
{
SMB_STRUCT_STAT sbuf;
struct smbacl4_vfs_params params;
+ SMB_STRUCT_STAT *psbuf = NULL;
DEBUG(10, ("smb_fget_nt_acl_nfs4 invoked for %s\n", fsp_str_dbg(fsp)));
- if (smbacl4_fGetFileOwner(fsp, &sbuf)) {
- return map_nt_error_from_unix(errno);
+ if (VALID_STAT(fsp->fsp_name->st)) {
+ psbuf = &fsp->fsp_name->st;
+ }
+
+ if (psbuf == NULL) {
+ if (smbacl4_fGetFileOwner(fsp, &sbuf)) {
+ return map_nt_error_from_unix(errno);
+ }
+ psbuf = &sbuf;
}
if (pparams == NULL) {
@@ -544,7 +552,7 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
pparams = ¶ms;
}
- return smb_get_nt_acl_nfs4_common(&sbuf, pparams, security_info,
+ return smb_get_nt_acl_nfs4_common(psbuf, pparams, security_info,
mem_ctx, ppdesc, theacl);
}
@@ -558,12 +566,20 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
{
SMB_STRUCT_STAT sbuf;
struct smbacl4_vfs_params params;
+ const SMB_STRUCT_STAT *psbuf = NULL;
DEBUG(10, ("smb_get_nt_acl_nfs4 invoked for %s\n",
smb_fname->base_name));
- if (smbacl4_GetFileOwner(conn, smb_fname, &sbuf)) {
- return map_nt_error_from_unix(errno);
+ if (VALID_STAT(smb_fname->st)) {
+ psbuf = &smb_fname->st;
+ }
+
+ if (psbuf == NULL) {
+ if (smbacl4_GetFileOwner(conn, smb_fname, &sbuf)) {
+ return map_nt_error_from_unix(errno);
+ }
+ psbuf = &sbuf;
}
if (pparams == NULL) {
@@ -574,7 +590,7 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
pparams = ¶ms;
}
- return smb_get_nt_acl_nfs4_common(&sbuf, pparams, security_info,
+ return smb_get_nt_acl_nfs4_common(psbuf, pparams, security_info,
mem_ctx, ppdesc, theacl);
}
--
2.7.4
More information about the samba-technical
mailing list