SMB_VFS_GET_DOS_ATTRIBUTES vs SMB_VFS_IS_OFFLINE

Ralph Böhme slow at samba.org
Tue Oct 11 07:40:44 UTC 2016


Hi!

On Mon, Sep 12, 2016 at 11:13:58AM +0200, Ralph Böhme wrote:
> On Sun, Sep 11, 2016 at 09:23:21PM +0300, Uri Simchoni wrote:
> > I actually like the original idea. From previous discussions on this
> > list, we don't care about compatibility in VFS modules (except for
> > incrementing the version number). There has to be a compelling reason to
> > have a separate offline manipulation code (for example the
> > create_file_fn VFS is complex, and most of the time you want to
> > customize just the UNIX open, not all the bookkeeping around it, so we
> > have both create_file_fn and open_fn).
> 
> this reasoning is exactly what lead me to wiping the slate clean and
> removing the offline function: there's nothing that can't also be done
> from an enhanced SMB_VFS_{GET|SET}_DOS_ATTRIBUTES().

so here's the final patchset that removes the offline VFS calls and
moves functionality to the DOS attributes calls.

> > Another remark is that "old_mode" seems odd - usually a "set" function
> > is just given the new desired state, and maybe it returns the old
> > state.
> 
> That was in attempt to mimic the current behaviour where
> file_set_dosmode() doesn the check, comparing old_dosmode against the
> new_dosmode and then only calling SMB_VFS_SET_OFFLINE() in case the
> the offline flag was not set in old_dosmode but is set in
> new_dosmode.
>
> > There's one module that needs the previous offline state, but it can
> > handle it by itself.
> 
> Good point! This way wouldn't have to always call dosmode() in
> file_set_dosmode() and only do this in the single module that needs
> it. Thanks!

The updated patchset now does it this way.

Please review & push if ok.

Cheerio!
-slow
-------------- next part --------------
From 5ff84ce681b75088460217f217e54bcc000474f5 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 11 Sep 2016 12:39:13 +0200
Subject: [PATCH 1/2] s3/vfs: merge offline functionality into DOS attributes
 handling

The offline VFS functions predate the SMB_VFS_{GET|SET}_DOS_ATTRIBUTES()
functions, now that we have these, we can use them for the offline
attribute as well.

The primary reason for this is: performance. Merging both functions has
the benefit that in VFS modules that use same backing store bits for
both offline attribute and DOS attributes (like gpfs), we avoid calling
the backing store twice in dos_mode() and file_set_dosmode().

This commit modifies all existing users of the offline attribute to
adapt to the change, the next commit will then remove the obsolete
offline functions.

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 libcli/smb/smb_constants.h    |   3 +-
 source3/modules/vfs_default.c |  32 +++++++------
 source3/modules/vfs_gpfs.c    |   6 +++
 source3/modules/vfs_offline.c |  20 ++++++---
 source3/modules/vfs_tsmsm.c   | 102 ++++++++++++++++++++++++++++++++++++++----
 source3/smbd/dosmode.c        |  45 +++----------------
 6 files changed, 141 insertions(+), 67 deletions(-)

diff --git a/libcli/smb/smb_constants.h b/libcli/smb/smb_constants.h
index b963c73..47b5629 100644
--- a/libcli/smb/smb_constants.h
+++ b/libcli/smb/smb_constants.h
@@ -341,7 +341,8 @@ enum csc_policy {
 					FILE_ATTRIBUTE_HIDDEN|\
 					FILE_ATTRIBUTE_SYSTEM|\
 					FILE_ATTRIBUTE_DIRECTORY|\
-					FILE_ATTRIBUTE_ARCHIVE)
+					FILE_ATTRIBUTE_ARCHIVE|\
+					FILE_ATTRIBUTE_OFFLINE)
 
 /* File type flags */
 #define FILE_TYPE_DISK  0
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 3cecaeb..63320a8 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1571,10 +1571,21 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 	return NT_STATUS_NOT_SUPPORTED;
 }
 
+static bool vfswrap_is_offline(struct vfs_handle_struct *handle,
+			       const struct smb_filename *fname,
+			       SMB_STRUCT_STAT *sbuf);
+
 static NTSTATUS vfswrap_get_dos_attributes(struct vfs_handle_struct *handle,
 					   struct smb_filename *smb_fname,
 					   uint32_t *dosmode)
 {
+	bool offline;
+
+	offline = vfswrap_is_offline(handle, smb_fname, &smb_fname->st);
+	if (offline) {
+		*dosmode |= FILE_ATTRIBUTE_OFFLINE;
+	}
+
 	return get_ea_dos_attribute(handle->conn, smb_fname, dosmode);
 }
 
@@ -1582,6 +1593,13 @@ static NTSTATUS vfswrap_fget_dos_attributes(struct vfs_handle_struct *handle,
 					    struct files_struct *fsp,
 					    uint32_t *dosmode)
 {
+	bool offline;
+
+	offline = vfswrap_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
+	if (offline) {
+		*dosmode |= FILE_ATTRIBUTE_OFFLINE;
+	}
+
 	return get_ea_dos_attribute(handle->conn, fsp->fsp_name, dosmode);
 }
 
@@ -2710,16 +2728,6 @@ static bool vfswrap_is_offline(struct vfs_handle_struct *handle,
 	return offline;
 }
 
-static int vfswrap_set_offline(struct vfs_handle_struct *handle,
-			       const struct smb_filename *fname)
-{
-	/* We don't know how to set offline bit by default, needs to be overriden in the vfs modules */
-#if defined(ENOTSUP)
-	errno = ENOTSUP;
-#endif
-	return -1;
-}
-
 static NTSTATUS vfswrap_durable_cookie(struct vfs_handle_struct *handle,
 				       struct files_struct *fsp,
 				       TALLOC_CTX *mem_ctx,
@@ -2881,10 +2889,6 @@ static struct vfs_fn_pointers vfs_default_fns = {
 	/* aio operations */
 	.aio_force_fn = vfswrap_aio_force,
 
-	/* offline operations */
-	.is_offline_fn = vfswrap_is_offline,
-	.set_offline_fn = vfswrap_set_offline,
-
 	/* durable handle operations */
 	.durable_cookie_fn = vfswrap_durable_cookie,
 	.durable_disconnect_fn = vfswrap_durable_disconnect,
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 70b831b..dd2742b 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1502,6 +1502,9 @@ static uint32_t vfs_gpfs_winattrs_to_dosmode(unsigned int winattrs)
 	if (winattrs & GPFS_WINATTR_SPARSE_FILE) {
 		dosmode |= FILE_ATTRIBUTE_SPARSE;
 	}
+	if (winattrs & GPFS_WINATTR_OFFLINE) {
+		dosmode |= FILE_ATTRIBUTE_OFFLINE;
+	}
 
 	return dosmode;
 }
@@ -1525,6 +1528,9 @@ static unsigned int vfs_gpfs_dosmode_to_winattrs(uint32_t dosmode)
 	if (dosmode & FILE_ATTRIBUTE_SPARSE) {
 		winattrs |= GPFS_WINATTR_SPARSE_FILE;
 	}
+	if (dosmode & FILE_ATTRIBUTE_OFFLINE) {
+		winattrs |= GPFS_WINATTR_OFFLINE;
+	}
 
 	return winattrs;
 }
diff --git a/source3/modules/vfs_offline.c b/source3/modules/vfs_offline.c
index 5921f43..e2d66fa 100644
--- a/source3/modules/vfs_offline.c
+++ b/source3/modules/vfs_offline.c
@@ -27,16 +27,26 @@ static uint32_t offline_fs_capabilities(struct vfs_handle_struct *handle,
 	       FILE_SUPPORTS_REMOTE_STORAGE;
 }
 
-static bool offline_is_offline(struct vfs_handle_struct *handle,
-			       const struct smb_filename *fname,
-			       SMB_STRUCT_STAT *stbuf)
+static NTSTATUS offline_get_dos_attributes(struct vfs_handle_struct *handle,
+					   struct smb_filename *smb_fname,
+					   uint32_t *dosmode)
 {
-	return true;
+	*dosmode |= FILE_ATTRIBUTE_OFFLINE;
+	return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle, smb_fname, dosmode);
+}
+
+static NTSTATUS offline_fget_dos_attributes(struct vfs_handle_struct *handle,
+					    struct files_struct *fsp,
+					    uint32_t *dosmode)
+{
+	*dosmode |= FILE_ATTRIBUTE_OFFLINE;
+	return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle, fsp, dosmode);
 }
 
 static struct vfs_fn_pointers offline_fns = {
     .fs_capabilities_fn = offline_fs_capabilities,
-    .is_offline_fn = offline_is_offline,
+	.get_dos_attributes_fn = offline_get_dos_attributes,
+	.fget_dos_attributes_fn = offline_fget_dos_attributes,
 };
 
 NTSTATUS vfs_offline_init(void);
diff --git a/source3/modules/vfs_tsmsm.c b/source3/modules/vfs_tsmsm.c
index 91daa6f..b943515 100644
--- a/source3/modules/vfs_tsmsm.c
+++ b/source3/modules/vfs_tsmsm.c
@@ -266,6 +266,33 @@ done:
 	return offline;
 }
 
+static NTSTATUS tsmsm_get_dos_attributes(struct vfs_handle_struct *handle,
+					 struct smb_filename *fname,
+					 uint32_t *dosmode)
+{
+	bool offline;
+
+	offline = tsmsm_is_offline(handle, fname, &fname->st);
+	if (offline) {
+		*dosmode |= FILE_ATTRIBUTE_OFFLINE;
+	}
+
+	return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle, fname, dosmode);
+}
+
+static NTSTATUS tsmsm_fget_dos_attributes(struct vfs_handle_struct *handle,
+					  files_struct *fsp,
+					  uint32_t *dosmode)
+{
+	bool offline;
+
+	offline = tsmsm_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
+	if (offline) {
+		*dosmode |= FILE_ATTRIBUTE_OFFLINE;
+	}
+
+	return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle, fsp, dosmode);
+}
 
 static bool tsmsm_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
 {
@@ -467,8 +494,8 @@ static ssize_t tsmsm_pwrite(struct vfs_handle_struct *handle, struct files_struc
 	return result;
 }
 
-static int tsmsm_set_offline(struct vfs_handle_struct *handle, 
-                             const struct smb_filename *fname)
+static NTSTATUS tsmsm_set_offline(struct vfs_handle_struct *handle,
+				  const struct smb_filename *fname)
 {
 	struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data;
 	int result = 0;
@@ -479,27 +506,82 @@ static int tsmsm_set_offline(struct vfs_handle_struct *handle,
 	if (tsmd->hsmscript == NULL) {
 		/* no script enabled */
 		DEBUG(1, ("tsmsm_set_offline: No 'tsmsm:hsm script' configured\n"));
-		return 0;
+		return NT_STATUS_OK;
 	}
 
         status = get_full_smb_filename(talloc_tos(), fname, &path);
         if (!NT_STATUS_IS_OK(status)) {
-                errno = map_errno_from_nt_status(status);
-                return false;
+		return status;
         }
 
 	/* Now, call the script */
 	command = talloc_asprintf(tsmd, "%s offline \"%s\"", tsmd->hsmscript, path);
 	if(!command) {
 		DEBUG(1, ("tsmsm_set_offline: can't allocate memory to run hsm script"));
-		return -1;
+		return NT_STATUS_NO_MEMORY;
 	}
 	DEBUG(10, ("tsmsm_set_offline: Running [%s]\n", command));
 	if((result = smbrun(command, NULL)) != 0) {
 		DEBUG(1,("tsmsm_set_offline: Running [%s] returned %d\n", command, result));
+		TALLOC_FREE(command);
+		return NT_STATUS_INTERNAL_ERROR;
 	}
 	TALLOC_FREE(command);
-	return result;
+	return NT_STATUS_OK;
+}
+
+static NTSTATUS tsmsm_set_dos_attributes(struct vfs_handle_struct *handle,
+					 const struct smb_filename *smb_fname,
+					 uint32_t dosmode)
+{
+	NTSTATUS status;
+	uint32_t old_dosmode;
+	struct smb_filename *fname = NULL;
+
+	/* dos_mode() doesn't like const smb_fname */
+	fname = cp_smb_filename(talloc_tos(), smb_fname);
+	if (fname == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	old_dosmode = dos_mode(handle->conn, fname);
+	TALLOC_FREE(fname);
+
+	status = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle, smb_fname, dosmode);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	if (!(old_dosmode & FILE_ATTRIBUTE_OFFLINE) &&
+	    (dosmode & FILE_ATTRIBUTE_OFFLINE))
+	{
+		return NT_STATUS_OK;
+	}
+
+	return tsmsm_set_offline(handle, smb_fname);
+}
+
+static NTSTATUS tsmsm_fset_dos_attributes(struct vfs_handle_struct *handle,
+					  struct files_struct *fsp,
+					  uint32_t dosmode)
+{
+	NTSTATUS status;
+	uint32_t old_dosmode;
+
+	old_dosmode = dos_mode(handle->conn, fsp->fsp_name);
+
+	status = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle, fsp, dosmode);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	if (!(old_dosmode & FILE_ATTRIBUTE_OFFLINE) &&
+	    (dosmode & FILE_ATTRIBUTE_OFFLINE))
+	{
+		return NT_STATUS_OK;
+	}
+
+	return tsmsm_set_offline(handle, fsp->fsp_name);
 }
 
 static uint32_t tsmsm_fs_capabilities(struct vfs_handle_struct *handle,
@@ -519,8 +601,10 @@ static struct vfs_fn_pointers tsmsm_fns = {
 	.pwrite_send_fn = tsmsm_pwrite_send,
 	.pwrite_recv_fn = tsmsm_pwrite_recv,
 	.sendfile_fn = tsmsm_sendfile,
-	.is_offline_fn = tsmsm_is_offline,
-	.set_offline_fn = tsmsm_set_offline,
+	.set_dos_attributes_fn = tsmsm_set_dos_attributes,
+	.fset_dos_attributes_fn = tsmsm_fset_dos_attributes,
+	.get_dos_attributes_fn = tsmsm_get_dos_attributes,
+	.fget_dos_attributes_fn = tsmsm_fget_dos_attributes,
 };
 
 NTSTATUS vfs_tsmsm_init(void);
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index a376cbc..dab47c0 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -384,6 +384,12 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn,
 		return NT_STATUS_NOT_IMPLEMENTED;
 	}
 
+	/*
+	 * Don't store FILE_ATTRIBUTE_OFFLINE, it's dealt with in
+	 * vfs_default via DMAPI if that is enabled.
+	 */
+	dosmode &= ~FILE_ATTRIBUTE_OFFLINE;
+
 	ZERO_STRUCT(dosattrib);
 	ZERO_STRUCT(blob);
 
@@ -605,7 +611,6 @@ static uint32_t dos_mode_from_name(connection_struct *conn,
 uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
 {
 	uint32_t result = 0;
-	bool offline;
 	NTSTATUS status = NT_STATUS_OK;
 
 	DEBUG(8,("dos_mode: %s\n", smb_fname_str_dbg(smb_fname)));
@@ -620,11 +625,6 @@ uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
 		result |= dos_mode_from_sbuf(conn, smb_fname);
 	}
 
-	offline = SMB_VFS_IS_OFFLINE(conn, smb_fname, &smb_fname->st);
-	if (S_ISREG(smb_fname->st.st_ex_mode) && offline) {
-		result |= FILE_ATTRIBUTE_OFFLINE;
-	}
-
 	if (conn->fs_capabilities & FILE_FILE_COMPRESSION) {
 		bool compressed = false;
 		status = dos_mode_check_compressed(conn, smb_fname,
@@ -665,8 +665,6 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
 	mode_t tmp;
 	mode_t unixmode;
 	int ret = -1, lret = -1;
-	uint32_t old_mode;
-	struct timespec new_create_timespec;
 	files_struct *fsp = NULL;
 	bool need_close = false;
 	NTSTATUS status;
@@ -676,8 +674,7 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
 		return -1;
 	}
 
-	/* We only allow READONLY|HIDDEN|SYSTEM|DIRECTORY|ARCHIVE here. */
-	dosmode &= (SAMBA_ATTRIBUTES_MASK | FILE_ATTRIBUTE_OFFLINE);
+	dosmode &= SAMBA_ATTRIBUTES_MASK;
 
 	DEBUG(10,("file_set_dosmode: setting dos mode 0x%x on file %s\n",
 		  dosmode, smb_fname_str_dbg(smb_fname)));
@@ -692,34 +689,6 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
 	else
 		dosmode &= ~FILE_ATTRIBUTE_DIRECTORY;
 
-	new_create_timespec = smb_fname->st.st_ex_btime;
-
-	old_mode = dos_mode(conn, smb_fname);
-
-	if ((dosmode & FILE_ATTRIBUTE_OFFLINE) &&
-	    !(old_mode & FILE_ATTRIBUTE_OFFLINE)) {
-		lret = SMB_VFS_SET_OFFLINE(conn, smb_fname);
-		if (lret == -1) {
-			if (errno == ENOTSUP) {
-				DEBUG(10, ("Setting FILE_ATTRIBUTE_OFFLINE for "
-					   "%s/%s is not supported.\n",
-					   parent_dir,
-					   smb_fname_str_dbg(smb_fname)));
-			} else {
-				DEBUG(0, ("An error occurred while setting "
-					  "FILE_ATTRIBUTE_OFFLINE for "
-					  "%s/%s: %s", parent_dir,
-					  smb_fname_str_dbg(smb_fname),
-					  strerror(errno)));
-			}
-		}
-	}
-
-	dosmode  &= ~FILE_ATTRIBUTE_OFFLINE;
-	old_mode &= ~FILE_ATTRIBUTE_OFFLINE;
-
-	smb_fname->st.st_ex_btime = new_create_timespec;
-
 	/* Store the DOS attributes in an EA by preference. */
 	status = SMB_VFS_SET_DOS_ATTRIBUTES(conn, smb_fname, dosmode);
 	if (NT_STATUS_IS_OK(status)) {
-- 
2.7.4


From 9e0d46bad1197fa61089ba8f6739602adb01e809 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Mon, 10 Oct 2016 17:10:43 +0200
Subject: [PATCH 2/2] s3/vfs: remove now unused is_offline/set_offline VFS
 functions

The previous commit removed all callers of this, so lets remove it.

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 examples/VFS/skel_opaque.c          | 19 ---------
 examples/VFS/skel_transparent.c     | 17 --------
 source3/include/vfs.h               | 12 ++----
 source3/include/vfs_macros.h        | 10 -----
 source3/modules/vfs_ceph.c          | 18 ---------
 source3/modules/vfs_full_audit.c    | 25 ------------
 source3/modules/vfs_glusterfs.c     | 20 ----------
 source3/modules/vfs_gpfs.c          |  1 -
 source3/modules/vfs_media_harmony.c | 77 -------------------------------------
 source3/modules/vfs_time_audit.c    | 41 --------------------
 source3/modules/vfs_unityed_media.c | 59 ----------------------------
 source3/smbd/vfs.c                  | 15 --------
 12 files changed, 3 insertions(+), 311 deletions(-)

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 81ce184..9479595 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -860,21 +860,6 @@ static bool skel_aio_force(struct vfs_handle_struct *handle,
 	return false;
 }
 
-static bool skel_is_offline(struct vfs_handle_struct *handle,
-			    const struct smb_filename *fname,
-			    SMB_STRUCT_STAT *sbuf)
-{
-	errno = ENOSYS;
-	return false;
-}
-
-static int skel_set_offline(struct vfs_handle_struct *handle,
-			    const struct smb_filename *fname)
-{
-	errno = ENOSYS;
-	return -1;
-}
-
 /* VFS operations structure */
 
 struct vfs_fn_pointers skel_opaque_fns = {
@@ -1006,10 +991,6 @@ struct vfs_fn_pointers skel_opaque_fns = {
 
 	/* aio operations */
 	.aio_force_fn = skel_aio_force,
-
-	/* offline operations */
-	.is_offline_fn = skel_is_offline,
-	.set_offline_fn = skel_set_offline
 };
 
 static_decl_vfs;
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index 418ee24..f601312 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -985,19 +985,6 @@ static bool skel_aio_force(struct vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
 }
 
-static bool skel_is_offline(struct vfs_handle_struct *handle,
-			    const struct smb_filename *fname,
-			    SMB_STRUCT_STAT *sbuf)
-{
-	return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
-}
-
-static int skel_set_offline(struct vfs_handle_struct *handle,
-			    const struct smb_filename *fname)
-{
-	return SMB_VFS_NEXT_SET_OFFLINE(handle, fname);
-}
-
 /* VFS operations structure */
 
 struct vfs_fn_pointers skel_transparent_fns = {
@@ -1129,10 +1116,6 @@ struct vfs_fn_pointers skel_transparent_fns = {
 
 	/* aio operations */
 	.aio_force_fn = skel_aio_force,
-
-	/* offline operations */
-	.is_offline_fn = skel_is_offline,
-	.set_offline_fn = skel_set_offline
 };
 
 static_decl_vfs;
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index fb9f866..d7a65d4 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -193,8 +193,9 @@
 /* Version 35 - Add uint32_t flags to struct smb_filename */
 /* Version 35 - Add get/set/fget/fset dos attribute functions. */
 /* Version 35 - Add bool use_ofd_locks to struct files_struct */
-
-#define SMB_VFS_INTERFACE_VERSION 35
+/* Bump to version 36 - Samba 4.6 will ship with that */
+/* Version 36 - Remove is_offline and set_offline */
+#define SMB_VFS_INTERFACE_VERSION 36
 
 /*
     All intercepted VFS operations must be declared as static functions inside module source
@@ -877,13 +878,6 @@ struct vfs_fn_pointers {
 	/* aio operations */
 	bool (*aio_force_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
 
-	/* offline operations */
-	bool (*is_offline_fn)(struct vfs_handle_struct *handle,
-			   const struct smb_filename *fname,
-			   SMB_STRUCT_STAT *sbuf);
-	int (*set_offline_fn)(struct vfs_handle_struct *handle,
-			   const struct smb_filename *fname);
-
 	/* durable handle operations */
 	NTSTATUS (*durable_cookie_fn)(struct vfs_handle_struct *handle,
 				      struct files_struct *fsp,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 62fa129..9845135 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -573,16 +573,6 @@
 #define SMB_VFS_NEXT_AIO_FORCE(handle,fsp) \
 	smb_vfs_call_aio_force((handle)->next,(fsp))
 
-#define SMB_VFS_IS_OFFLINE(conn,fname,sbuf) \
-	smb_vfs_call_is_offline((conn)->vfs_handles,(fname),(sbuf))
-#define SMB_VFS_NEXT_IS_OFFLINE(handle,fname,sbuf) \
-	smb_vfs_call_is_offline((handle)->next,(fname),(sbuf))
-
-#define SMB_VFS_SET_OFFLINE(conn,fname) \
-	smb_vfs_call_set_offline((conn)->vfs_handles,(fname))
-#define SMB_VFS_NEXT_SET_OFFLINE(handle,fname) \
-	smb_vfs_call_set_offline((handle)->next, (fname))
-
 /* durable handle operations */
 
 #define SMB_VFS_DURABLE_COOKIE(fsp, mem_ctx, cookie) \
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 59e9b9c..8e02683 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -1204,20 +1204,6 @@ static bool cephwrap_aio_force(struct vfs_handle_struct *handle, struct files_st
 	return false;
 }
 
-static bool cephwrap_is_offline(struct vfs_handle_struct *handle,
-				const struct smb_filename *fname,
-				SMB_STRUCT_STAT *sbuf)
-{
-	return false;
-}
-
-static int cephwrap_set_offline(struct vfs_handle_struct *handle,
-				const struct smb_filename *fname)
-{
-	errno = ENOTSUP;
-	return -1;
-}
-
 static struct vfs_fn_pointers ceph_fns = {
 	/* Disk operations */
 
@@ -1300,10 +1286,6 @@ static struct vfs_fn_pointers ceph_fns = {
 
 	/* aio operations */
 	.aio_force_fn = cephwrap_aio_force,
-
-	/* offline operations */
-	.is_offline_fn = cephwrap_is_offline,
-	.set_offline_fn = cephwrap_set_offline
 };
 
 NTSTATUS vfs_ceph_init(void);
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index edff395..613ce6c 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -2376,29 +2376,6 @@ static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
 	return result;
 }
 
-static bool smb_full_audit_is_offline(struct vfs_handle_struct *handle,
-				      const struct smb_filename *fname,
-				      SMB_STRUCT_STAT *sbuf)
-{
-	bool result;
-
-	result = SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
-	do_log(SMB_VFS_OP_IS_OFFLINE, result, handle, "%s",
-	       smb_fname_str_do_log(fname));
-	return result;
-}
-
-static int smb_full_audit_set_offline(struct vfs_handle_struct *handle,
-				      const struct smb_filename *fname)
-{
-	int result;
-
-	result = SMB_VFS_NEXT_SET_OFFLINE(handle, fname);
-	do_log(SMB_VFS_OP_SET_OFFLINE, result >= 0, handle, "%s",
-	       smb_fname_str_do_log(fname));
-	return result;
-}
-
 static NTSTATUS smb_full_audit_durable_cookie(struct vfs_handle_struct *handle,
 				struct files_struct *fsp,
 				TALLOC_CTX *mem_ctx,
@@ -2575,8 +2552,6 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
 	.setxattr_fn = smb_full_audit_setxattr,
 	.fsetxattr_fn = smb_full_audit_fsetxattr,
 	.aio_force_fn = smb_full_audit_aio_force,
-	.is_offline_fn = smb_full_audit_is_offline,
-	.set_offline_fn = smb_full_audit_set_offline,
 	.durable_cookie_fn = smb_full_audit_durable_cookie,
 	.durable_disconnect_fn = smb_full_audit_durable_disconnect,
 	.durable_reconnect_fn = smb_full_audit_durable_reconnect,
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index a467235..4ff2f18 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -1247,22 +1247,6 @@ static bool vfs_gluster_aio_force(struct vfs_handle_struct *handle,
 	return false;
 }
 
-/* Offline Operations */
-
-static bool vfs_gluster_is_offline(struct vfs_handle_struct *handle,
-				   const struct smb_filename *fname,
-				   SMB_STRUCT_STAT *sbuf)
-{
-	return false;
-}
-
-static int vfs_gluster_set_offline(struct vfs_handle_struct *handle,
-				   const struct smb_filename *fname)
-{
-	errno = ENOTSUP;
-	return -1;
-}
-
 static struct vfs_fn_pointers glusterfs_fns = {
 
 	/* Disk Operations */
@@ -1382,10 +1366,6 @@ static struct vfs_fn_pointers glusterfs_fns = {
 	/* AIO Operations */
 	.aio_force_fn = vfs_gluster_aio_force,
 
-	/* Offline Operations */
-	.is_offline_fn = vfs_gluster_is_offline,
-	.set_offline_fn = vfs_gluster_set_offline,
-
 	/* Durable handle Operations */
 	.durable_cookie_fn = NULL,
 	.durable_disconnect_fn = NULL,
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index dd2742b..5c516f4 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -2700,7 +2700,6 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
 	.statlite_fn = vfs_gpfs_statlite,
 	.fstatlite_fn = vfs_gpfs_fstatlite,
 	.ntimes_fn = vfs_gpfs_ntimes,
-	.is_offline_fn = vfs_gpfs_is_offline,
 	.aio_force_fn = vfs_gpfs_aio_force,
 	.sendfile_fn = vfs_gpfs_sendfile,
 	.fallocate_fn = vfs_gpfs_fallocate,
diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c
index 8f80221..d6a93f8 100644
--- a/source3/modules/vfs_media_harmony.c
+++ b/source3/modules/vfs_media_harmony.c
@@ -2368,79 +2368,6 @@ out:
 	return status;
 }
 
-/*
- * Success: return true
- * Failure: set errno, return false
- */
-static bool mh_is_offline(struct vfs_handle_struct *handle,
-		const struct smb_filename *fname,
-		SMB_STRUCT_STAT *sbuf)
-{
-	// check if sbuf is modified further down the chain.
-	bool ret;
-	struct smb_filename *clientFname;
-	TALLOC_CTX *ctx;
-
-	DEBUG(MH_INFO_DEBUG, ("Entering mh_is_offline\n"));
-	if (!is_in_media_files(fname->base_name))
-	{
-		ret = SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
-		goto out;
-	}
-
-	clientFname = NULL;
-	ctx = talloc_tos();
-
-	if(alloc_get_client_smb_fname(handle, ctx,
-				fname,
-				&clientFname))
-	{
-		ret = -1;
-		goto err;
-	}
-
-	ret = SMB_VFS_NEXT_IS_OFFLINE(handle, clientFname, sbuf);
-err:
-	TALLOC_FREE(clientFname);
-out:
-	return ret;
-}
-
-/*
- * Success: return 0 (?)
- * Failure: set errno, return -1
- */
-static int mh_set_offline(struct vfs_handle_struct *handle,
-		const struct smb_filename *fname)
-{
-	int status;
-	struct smb_filename *clientFname;
-	TALLOC_CTX *ctx;
-
-	DEBUG(MH_INFO_DEBUG, ("Entering mh_set_offline\n"));
-	if (!is_in_media_files(fname->base_name))
-	{
-		status = SMB_VFS_NEXT_SET_OFFLINE(handle, fname);
-		goto out;
-	}
-
-	clientFname = NULL;
-	ctx = talloc_tos();
-
-	if ((status = alloc_get_client_smb_fname(handle, ctx,
-				fname,
-				&clientFname)))
-	{
-		goto err;
-	}
-
-	status = SMB_VFS_NEXT_SET_OFFLINE(handle, clientFname);
-err:
-	TALLOC_FREE(clientFname);
-out:
-	return status;
-}
-
 /* VFS operations structure */
 
 static struct vfs_fn_pointers vfs_mh_fns = {
@@ -2502,10 +2429,6 @@ static struct vfs_fn_pointers vfs_mh_fns = {
 	.setxattr_fn = mh_setxattr,
 
 	/* aio operations */
-
-	/* offline operations */
-	.is_offline_fn = mh_is_offline,
-	.set_offline_fn = mh_set_offline
 };
 
 NTSTATUS vfs_media_harmony_init(void);
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index b3610ee..986fe79 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -2495,45 +2495,6 @@ static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
 	return result;
 }
 
-static bool smb_time_audit_is_offline(struct vfs_handle_struct *handle,
-				      const struct smb_filename *fname,
-				      SMB_STRUCT_STAT *sbuf)
-{
-	bool result;
-	struct timespec ts1,ts2;
-	double timediff;
-
-	clock_gettime_mono(&ts1);
-	result = SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
-	clock_gettime_mono(&ts2);
-	timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
-
-	if (timediff > audit_timeout) {
-		smb_time_audit_log_smb_fname("is_offline", timediff, fname);
-	}
-
-	return result;
-}
-
-static int smb_time_audit_set_offline(struct vfs_handle_struct *handle,
-				      const struct smb_filename *fname)
-{
-	int result;
-	struct timespec ts1,ts2;
-	double timediff;
-
-	clock_gettime_mono(&ts1);
-	result = SMB_VFS_NEXT_SET_OFFLINE(handle, fname);
-	clock_gettime_mono(&ts2);
-	timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
-
-	if (timediff > audit_timeout) {
-		smb_time_audit_log_smb_fname("set_offline", timediff, fname);
-	}
-
-	return result;
-}
-
 static NTSTATUS smb_time_audit_durable_cookie(struct vfs_handle_struct *handle,
 					      struct files_struct *fsp,
 					      TALLOC_CTX *mem_ctx,
@@ -2712,8 +2673,6 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
 	.setxattr_fn = smb_time_audit_setxattr,
 	.fsetxattr_fn = smb_time_audit_fsetxattr,
 	.aio_force_fn = smb_time_audit_aio_force,
-	.is_offline_fn = smb_time_audit_is_offline,
-	.set_offline_fn = smb_time_audit_set_offline,
 	.durable_cookie_fn = smb_time_audit_durable_cookie,
 	.durable_disconnect_fn = smb_time_audit_durable_disconnect,
 	.durable_reconnect_fn = smb_time_audit_durable_reconnect,
diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c
index 3b3493d..d8191e1 100644
--- a/source3/modules/vfs_unityed_media.c
+++ b/source3/modules/vfs_unityed_media.c
@@ -1806,59 +1806,6 @@ err:
 	return status;
 }
 
-static bool um_is_offline(struct vfs_handle_struct *handle,
-			  const struct smb_filename *fname,
-			  SMB_STRUCT_STAT *sbuf)
-{
-	bool ret;
-	struct smb_filename *client_fname = NULL;
-	int status;
-
-	DEBUG(10, ("Entering um_is_offline\n"));
-
-	if (!is_in_media_files(fname->base_name)) {
-		return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
-	}
-
-	status = alloc_get_client_smb_fname(handle, talloc_tos(),
-					    fname, &client_fname);
-	if (status != 0) {
-		ret = false;
-		goto err;
-	}
-
-	ret = SMB_VFS_NEXT_IS_OFFLINE(handle, client_fname, sbuf);
-
-err:
-	TALLOC_FREE(client_fname);
-	return ret;
-}
-
-static int um_set_offline(struct vfs_handle_struct *handle,
-			  const struct smb_filename *fname)
-{
-	int status;
-	struct smb_filename *client_fname = NULL;
-
-	DEBUG(10, ("Entering um_set_offline\n"));
-
-	if (!is_in_media_files(fname->base_name)) {
-		return SMB_VFS_NEXT_SET_OFFLINE(handle, fname);
-	}
-
-	status = alloc_get_client_smb_fname(handle, talloc_tos(),
-					    fname, &client_fname);
-	if (status != 0) {
-		goto err;
-	}
-
-	status = SMB_VFS_NEXT_SET_OFFLINE(handle, client_fname);
-
-err:
-	TALLOC_FREE(client_fname);
-	return status;
-}
-
 static int um_connect(vfs_handle_struct *handle,
 			 const char *service,
 			 const char *user)
@@ -1956,12 +1903,6 @@ static struct vfs_fn_pointers vfs_um_fns = {
 	.listxattr_fn = um_listxattr,
 	.removexattr_fn = um_removexattr,
 	.setxattr_fn = um_setxattr,
-
-	/* aio operations */
-
-	/* offline operations */
-	.is_offline_fn = um_is_offline,
-	.set_offline_fn = um_set_offline
 };
 
 NTSTATUS vfs_unityed_media_init(void);
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index f118b9d..93c38a3 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -2593,21 +2593,6 @@ bool smb_vfs_call_aio_force(struct vfs_handle_struct *handle,
 	return handle->fns->aio_force_fn(handle, fsp);
 }
 
-bool smb_vfs_call_is_offline(struct vfs_handle_struct *handle,
-			     const struct smb_filename *fname,
-			     SMB_STRUCT_STAT *sbuf)
-{
-	VFS_FIND(is_offline);
-	return handle->fns->is_offline_fn(handle, fname, sbuf);
-}
-
-int smb_vfs_call_set_offline(struct vfs_handle_struct *handle,
-                             const struct smb_filename *fname)
-{
-	VFS_FIND(set_offline);
-	return handle->fns->set_offline_fn(handle, fname);
-}
-
 NTSTATUS smb_vfs_call_durable_cookie(struct vfs_handle_struct *handle,
 				     struct files_struct *fsp,
 				     TALLOC_CTX *mem_ctx,
-- 
2.7.4



More information about the samba-technical mailing list