On Sun, Jan 12, 2020 at 7:42 AM Richard Purdie
<[email protected]> wrote:
>
> Depending on the kernel and coreutils cersion, mv operations test for 
> existence

typo version -> version
> of files and can potentially race. It also leads to the file always changing 
> which
> leads to potential problems if using and NFS share and there are other 
> readers.
>
> Using ln instead means we don't overwrite the file if it already exists 
> meaning
> other readers aren't disrupted and should work more reliably on NFS which is 
> used
> for sstate on the autobuilder.
>
> Since we're not overwriting files, touch the file to show activity as would 
> have
> been done it it were reused from sstate.
>
> Signed-off-by: Richard Purdie <[email protected]>
> ---
>  meta/classes/sstate.bbclass | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
> index 356fe7ec180..b4ffffcd98b 100644
> --- a/meta/classes/sstate.bbclass
> +++ b/meta/classes/sstate.bbclass
> @@ -776,6 +776,7 @@ sstate_task_postfunc[dirs] = "${WORKDIR}"
>  sstate_create_package () {
>         # Exit early if it already exists
>         if [ -e ${SSTATE_PKG} ]; then
> +               touch ${SSTATE_PKG}
>                 return
>         fi
>
> @@ -803,10 +804,13 @@ sstate_create_package () {
>         chmod 0664 $TFILE
>         # Skip if it was already created by some other process
>         if [ ! -e ${SSTATE_PKG} ]; then
> -               mv -f $TFILE ${SSTATE_PKG}
> +               # Move into place using ln to attempt an atomic op.
> +               # Abort if it already exists
> +               ln $TFILE ${SSTATE_PKG} && rm $TFILE
>         else
>                 rm $TFILE
>         fi
> +       touch ${SSTATE_PKG}
>  }
>
>  python sstate_sign_package () {
> --
> 2.20.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> [email protected]
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
-- 
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to