[Virtio-fs] [PATCH 5/5] virtiofsd: add helper for lo_data cleanup
Dr. David Alan Gilbert
dgilbert at redhat.com
Thu Jun 6 09:41:06 UTC 2019
* Liu Bo (bo.liu at linux.alibaba.com) wrote:
> This offers an helper function for lo_data's cleanup.
>
> Signed-off-by: Liu Bo <bo.liu at linux.alibaba.com>
That's ok, but will need updating when you do a new version of the
lo.source.
Dave
> ---
> contrib/virtiofsd/passthrough_ll.c | 34 +++++++++++++++++++---------------
> 1 file changed, 19 insertions(+), 15 deletions(-)
>
> diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthrough_ll.c
> index 649991e..73ca09f 100644
> --- a/contrib/virtiofsd/passthrough_ll.c
> +++ b/contrib/virtiofsd/passthrough_ll.c
> @@ -2205,6 +2205,24 @@ static gboolean lo_key_equal(gconstpointer a, gconstpointer b)
> la->dev == lb->dev;
> }
>
> +static void fuse_lo_data_cleanup(struct lo_data *lo, bool free_source)
> +{
> + if (lo->inodes)
> + g_hash_table_destroy(lo->inodes);
> + lo_map_destroy(&lo->fd_map);
> + lo_map_destroy(&lo->dirp_map);
> + lo_map_destroy(&lo->ino_map);
> +
> + if (lo->proc_self_fd >= 0) {
> + close(lo->proc_self_fd);
> + }
> +
> + if (lo->root.fd >= 0)
> + close(lo->root.fd);
> +
> + if (free_source)
> + free((char *)lo->source);
> +}
>
> int main(int argc, char *argv[])
> {
> @@ -2325,21 +2343,7 @@ err_out2:
> err_out1:
> fuse_opt_free_args(&args);
>
> - if (lo.inodes)
> - g_hash_table_destroy(lo.inodes);
> - lo_map_destroy(&lo.fd_map);
> - lo_map_destroy(&lo.dirp_map);
> - lo_map_destroy(&lo.ino_map);
> -
> - if (lo.proc_self_fd >= 0) {
> - close(lo.proc_self_fd);
> - }
> -
> - if (lo.root.fd >= 0)
> - close(lo.root.fd);
> -
> - if (free_source)
> - free((char *)lo.source);
> + fuse_lo_data_cleanup(&lo, free_source);
>
> return ret ? 1 : 0;
> }
> --
> 1.8.3.1
>
> _______________________________________________
> Virtio-fs mailing list
> Virtio-fs at redhat.com
> https://www.redhat.com/mailman/listinfo/virtio-fs
--
Dr. David Alan Gilbert / dgilbert at redhat.com / Manchester, UK
More information about the Virtio-fs
mailing list