bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] trans: populate the mtab on demand


From: Samuel Thibault
Subject: Re: [PATCH 2/3] trans: populate the mtab on demand
Date: Sun, 15 Dec 2013 20:44:24 +0100
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Justus Winter, le Wed 20 Nov 2013 11:10:07 +0100, a écrit :
> Previously the mtab content was generated in the open hook. Delay this
> until the data is needed. A follow up patch will take advantage of
> this to both simplify the logic in mtab_populate and make it more
> robust at the same time.

Ack, but it probably needs locking in the multithread version, too, to
avoid several threads populating the mtab concurrently.

> * trans/mtab.c (open_hook): Do not eagerly populate the mtab.
> (trivfs_S_io_read): Populate the mtab struct on demand.
> (trivfs_S_io_seek): Likewise.
> (trivfs_S_io_readable): Likewise.
> ---
>  trans/mtab.c |   24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/trans/mtab.c b/trans/mtab.c
> index 4d10632..b1a3939 100644
> --- a/trans/mtab.c
> +++ b/trans/mtab.c
> @@ -598,7 +598,7 @@ open_hook (struct trivfs_peropen *peropen)
>    mtab->contents = NULL;
>    mtab->contents_len = 0;
>  
> -  return mtab_populate (mtab, target_path, insecure);
> +  return 0;
>  }
>  
>  static void
> @@ -628,6 +628,14 @@ trivfs_S_io_read (struct trivfs_protid *cred,
>  
>    /* Get the offset.  */
>    op = cred->po->hook;
> +
> +  if (op->contents == NULL)
> +    {
> +      error_t err = mtab_populate (op, target_path, insecure);
> +      if (err)
> +        return err;
> +    }
> +
>    if (offs == -1)
>      offs = op->offs;
>  
> @@ -670,6 +678,13 @@ trivfs_S_io_seek (struct trivfs_protid *cred,
>  
>    struct mtab *op = cred->po->hook;
>  
> +  if (op->contents == NULL)
> +    {
> +      error_t err = mtab_populate (op, target_path, insecure);
> +      if (err)
> +        return err;
> +    }
> +
>    switch (whence)
>      {
>      case SEEK_CUR:
> @@ -715,6 +730,13 @@ trivfs_S_io_readable (struct trivfs_protid *cred,
>  
>    struct mtab *op = cred->po->hook;
>  
> +  if (op->contents == NULL)
> +    {
> +      error_t err = mtab_populate (op, target_path, insecure);
> +      if (err)
> +        return err;
> +    }
> +
>    *amount = op->contents_len - op->offs;
>    return 0;
>  }
> -- 
> 1.7.10.4
> 

-- 
Samuel
/*
 * [...] Note that 120 sec is defined in the protocol as the maximum
 * possible RTT.  I guess we'll have to use something other than TCP
 * to talk to the University of Mars.
 * PAWS allows us longer timeouts and large windows, so once implemented
 * ftp to mars will work nicely.
 */
(from /usr/src/linux/net/inet/tcp.c, concerning RTT [retransmission timeout])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]