linux/tools
Milos Vyletel d7c72606d9 perf tools: Avoid possible race condition in copyfile()
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.

Succesfully tested by myself by running perf record, archive and reading
the data on other system and by running perf buildid-cache on perf
binary itself. I also did revert fix from 0635b0f that to exposes
previously fixed race with EEXIST and recreator test passed sucessfully.

Signed-off-by: Milos Vyletel <milos@redhat.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1433775018-19868-1-git-send-email-milos@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-10 11:51:24 -03:00
..
arch tools include: Add basic atomic.h implementation from the kernel sources 2015-05-08 16:11:05 -03:00
build perf build: Do not fail on missing Build file 2015-05-29 12:44:25 -03:00
cgroup
firewire
hv hv: hypervvssd: call endmntent before call setmntent again 2015-03-25 11:53:54 +01:00
iio tools: iio: generic_buffer: Fix generic scale extraction 2015-03-28 11:01:49 +00:00
include tools: Move tools/perf/util/include/linux/{list.h,poison.h} to tools/include 2015-06-02 19:07:29 -03:00
lguest tools/lguest: don't use legacy definitions for net device in example launcher. 2015-02-13 17:15:55 +10:30
lib tools lib traceevent: Ignore libtrace-dynamic-list file 2015-06-08 10:30:32 -03:00
net tools: bpf_asm: cleanup vlan extension related token 2015-03-24 21:21:41 -04:00
nfsd
perf perf tools: Avoid possible race condition in copyfile() 2015-06-10 11:51:24 -03:00
power More power management and ACPI updates for v4.1-rc1 2015-04-26 13:56:35 -07:00
scripts tools lib traceevent: Add global QUIET_CC_FPIC build output 2013-12-19 16:18:10 -03:00
testing linux-kselftest-4.1-rc4 2015-05-16 15:03:52 -07:00
thermal/tmon tools/thermal: tmon: fixed the 'make install' command 2015-05-09 13:36:58 +08:00
time tools: add script to test udelay 2014-07-23 10:16:38 -07:00
usb tools: ffs-aio-example: use endpoint addresses from descriptors 2015-01-15 09:41:49 -06:00
virtio tools/virtio: add virtio 1.0 in vringh_test 2014-12-15 23:49:22 +02:00
vm tools: Fix tools/vm build 2015-05-12 18:11:06 -03:00
Makefile tools build: Fix Makefile(s) to properly invoke tools build 2015-04-29 10:37:46 -03:00