[PATCH] s3-vfs: handle calling chdir after disconnect

Ira Cooper ira at samba.org
Thu Jan 15 09:46:01 MST 2015


I'd argue you are papering over the real problem, which is that Samba
shouldn't be doing that in the first place.

Try this patch out, it swaps the two calls in the close_cnum.

(The code is 100% untested!)

Jeremy/Volker, I'd love your eyes on this one.

Thanks,

-Ira

On Tue, Jan 13, 2015 at 9:19 PM, Yan, Zheng <zyan at redhat.com> wrote:

> close_cnum() in smbd/service.c calls SMB_VFS_DISCONNECT(), then
> calls vfs_ChDir(). ceph mount is shutdown when the last connection
> is disconnected. So we need to handle vfs_ChDir() when there is no
> ceph mount
>
> Signed-off-by: Yan, Zheng <zyan at redhat.com>
> ---
>  source3/modules/vfs_ceph.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
> index ec72312..ab81190 100644
> --- a/source3/modules/vfs_ceph.c
> +++ b/source3/modules/vfs_ceph.c
> @@ -152,6 +152,7 @@ static void cephwrap_disconnect(struct
> vfs_handle_struct *handle)
>         ceph_shutdown(cmount);
>
>         cmount = NULL;  /* Make it safe */
> +       handle->data = NULL;
>  }
>
>  /* Disk operations */
> @@ -223,6 +224,10 @@ static int cephwrap_statvfs(struct vfs_handle_struct
> *handle,  const char *path,
>         struct statvfs statvfs_buf;
>         int ret;
>
> +       if (!handle->data) {
> +               WRAP_RETURN(-ENOTCONN);
> +       }
> +
>         ret = ceph_statfs(handle->data, path, &statvfs_buf);
>         if (ret < 0) {
>                 WRAP_RETURN(ret);
> @@ -726,6 +731,10 @@ static int cephwrap_chdir(struct vfs_handle_struct
> *handle,  const char *path)
>  {
>         int result = -1;
>         DEBUG(10, ("[CEPH] chdir(%p, %s)\n", handle, path));
> +
> +       if (!handle->data) {
> +               WRAP_RETURN(-ENOTCONN);
> +       }
>         /*
>          * If the path is just / use chdir because Ceph is below / and
>          * cannot deal with changing directory above its mount point
> @@ -740,7 +749,11 @@ static int cephwrap_chdir(struct vfs_handle_struct
> *handle,  const char *path)
>
>  static char *cephwrap_getwd(struct vfs_handle_struct *handle)
>  {
> -       const char *cwd = ceph_getcwd(handle->data);
> +       const char *cwd;
> +       if (handle->data)
> +               cwd = ceph_getcwd(handle->data);
> +       else
> +               cwd = "/";
>         DEBUG(10, ("[CEPH] getwd(%p) = %s\n", handle, cwd));
>         return SMB_STRDUP(cwd);
>  }
> --
> 1.9.3
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: look
Type: application/octet-stream
Size: 1086 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150115/d1bdda70/attachment.obj>


More information about the samba-technical mailing list