lkml.org 
[lkml]   [2015]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf tools: avoid possible race condition in copyfile

* Milos Vyletel <milos@redhat.com> wrote:

> Use unique temporary files when copying to buildid dir to prevent races
> in case multiple instances are trying to copy same file. This is done by
>
> - creating template in form <path>/.<filename>.XXXXXX where the suffix is
> used by mkstemp() to create unique file
> - change file mode
> - copy content
> - if successful link temp file to target file
> - unlink temp file
>
> At this point the only file left at target path should be the desired
> one either created by us or other instance if we raced. This should also
> prevent not yet fully copied files to be visible to to other perf
> instances that could try to parse them.
>
> On top of that slow_copyfile no longer needs to deal with file mode when
> creating file since temporary file is already created and mode is set.
>
> Signed-off-by: Milos Vyletel <milos@redhat.com>

Ok, that looks nice!

Assuming it passes testing you can add my ack to it:

Acked-by: Ingo Molnar <mingo@kernel.org>

Is there any other place in tools/perf where we are using file locking or racy
shared access to the same file(s)?

Thanks,

Ingo


\
 
 \ /
  Last update: 2015-06-04 11:21    [W:0.110 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site