vfs_gpfs: use handle based gpfswrap_get_winattrs()
authorRalph Boehme <slow@samba.org>
Tue, 17 May 2022 14:32:23 +0000 (16:32 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 3 Jun 2022 20:56:35 +0000 (20:56 +0000)
Fixes detecting offline flag for files in snapshot – no idea if this is
actually expected.

Replaces path based gpfswrap_get_winattrs_path() with handle based version
gpfswrap_get_winattrs(). When dealing with files in snapshots fsp->fsp_name
points to the active dataset, which will cause ENOENT failures if files are
deleted there any only present in the snapshot.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15069

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
source3/modules/vfs_gpfs.c

index 5de28acd53be64f0b456eadaecff00e8d95ffcf3..ca1a9a3947970f4852677de70554ea63916fd0ce 100644 (file)
@@ -1878,7 +1878,7 @@ static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
-                               const struct smb_filename *fname,
+                               struct files_struct *fsp,
                                SMB_STRUCT_STAT *sbuf)
 {
        struct gpfs_winattr attrs;
@@ -1893,17 +1893,17 @@ static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
                return false;
        }
 
-       ret = gpfswrap_get_winattrs_path(fname->base_name, &attrs);
+       ret = gpfswrap_get_winattrs(fsp_get_pathref_fd(fsp), &attrs);
        if (ret == -1) {
                return false;
        }
 
        if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) {
-               DBG_DEBUG("%s is offline\n", fname->base_name);
+               DBG_DEBUG("%s is offline\n", fsp_str_dbg(fsp));
                return true;
        }
 
-       DBG_DEBUG("%s is online\n", fname->base_name);
+       DBG_DEBUG("%s is online\n", fsp_str_dbg(fsp));
        return false;
 }
 
@@ -1917,7 +1917,7 @@ static bool vfs_gpfs_fsp_is_offline(struct vfs_handle_struct *handle,
                /*
                 * Something bad happened, always ask.
                 */
-               return vfs_gpfs_is_offline(handle, fsp->fsp_name,
+               return vfs_gpfs_is_offline(handle, fsp,
                                           &fsp->fsp_name->st);
        }
 
@@ -1925,7 +1925,7 @@ static bool vfs_gpfs_fsp_is_offline(struct vfs_handle_struct *handle,
                /*
                 * As long as it's offline, ask.
                 */
-               ext->offline = vfs_gpfs_is_offline(handle, fsp->fsp_name,
+               ext->offline = vfs_gpfs_is_offline(handle, fsp,
                                                   &fsp->fsp_name->st);
        }