coreutils
[Top][All Lists]
Advanced

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

Re: [coreutils] strange behavior of parallel ln across filesystems?


From: Bob Proulx
Subject: Re: [coreutils] strange behavior of parallel ln across filesystems?
Date: Wed, 7 Jul 2010 01:57:07 -0600
User-agent: Mutt/1.5.18 (2008-05-17)

Peng Yu wrote:
> could you please let me know what might cause ln to generate the
> following error?

The ln -f option instructs ln to remove existing targets.  You are
running multiple parallel processes because make is running two jobs
in parallel due to make -j2.  This creates a race condition.
Sometimes, not always, the actions of both ln processes will line up
and both will stat(2) the target, both will notice that it is there,
and both will try to remove it.  The first one that gets there will
remove it and the other will fail to remove it and write an error
message because of the failure.

The problem is that the ln -fs step is being done multiple times with
redundant operations.  If it were only happening once then you
wouldn't have the problem.  Therefore I think the best solution would
be to avoid the multiple redundant actions.  Move the ln up to be an
action under the all target.  Try something like this:

$ cat Makefile
.PHONY: all

OUTDIR:=/storage/tmp/output
#OUTDIR:=here/output

OUTPUT:=$(OUTDIR)/a.txt $(OUTDIR)/b.txt

all: $(OUTPUT)
        ln -fs $(dir $@)

$(OUTPUT): $(OUTDIR)/%.txt: input/%.txt
        mkdir -p $(dir $@); touch $@

clean:
        $(RM) -r $(OUTDIR)

I think that should solve the problem.

Bob



reply via email to

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