Bluehost.com Web Hosting $6.95

NFS dir timestamp question

This is a discussion on NFS dir timestamp question within the Linux Networking forums, part of the Linux Forums category; In my code compilation environment, I have setup my Makefile dependencies to use a directory timestamp, like this: abc: my_obj_dir $(...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-09-2005
scream29125@yahoo.com
 
Posts: n/a
Default NFS dir timestamp question

In my code compilation environment, I have setup my Makefile
dependencies to use a directory timestamp, like this:

abc: my_obj_dir
$(CC) my_obj_dir/*.o $(LDFLAGS) -o abc

my_obj_dir contains a bunch of .o files. This method assumes that
whenever any file in my_obj_dir changes, the timestamp of my_obj_dir
changes too. So when any .o file gets updated, program "abc" will be
regenerated using those files. This provides an easy way to keep abc
up-to-date, even when the number of .o files in my_obj_dir changes.

This method works fine on locally mounted partitions, but it fails when
my_obj_dir is mounted over NFS. I found that when a new file gets
created in my_obj_dir, my_obj_dir's timestamp is updated, which is
expected. However, when an existing file gets changed/overwritten,
my_obj_dir's timestamp is NOT changed. Hence, abc is not regenerated.

This doesn't seem to be an NFS caching problem, because the timestamp
of my_obj_dir on the NFS server really did not change.

Is this an expected behavior with NFS? If so, what would be a better
solution to achieve the same dependency checking behavior as I
described above?

Thanks.

Reply With Quote
  #2 (permalink)  
Old 05-09-2005
Allen McIntosh
 
Posts: n/a
Default Re: NFS dir timestamp question

> Is this an expected behavior with NFS?
Modifying a file doesn't change the directory it contains. But that's
not the question you need to ask. The "right" question is, what is gcc
doing? Try this:
echo 'int main() { return 0; }' > foo.c
gcc -c foo.c
strace -f gcc -c foo.c 2>&1 | grep foo
to see what gcc (and as) are up to. In my case, I see (among other things):

[pid 17180] unlink("foo.o")

This happens on my machine whether the directory is NFS mounted or not.
So, this says the directory is being modified. Since the timestamp on
the files is accurate only to the nearest second, it is quite likely
that the directory and the .o file will wind up with the same time
stamp. Whatever make does with this, it's not likely to be what you
want :-)

With a large .o file and the higher latency of NFS, the .o file is more
likely to wind up appearing newer than the directory.

> If so, what would be a better
> solution to achieve the same dependency checking behavior as I
> described above?


Make the dependency on the .o files explicit. The "info" files that
come with make have an example that shows you how to manufacture a list
of .o files from a list of source files.
Reply With Quote
  #3 (permalink)  
Old 05-11-2005
scream29125@yahoo.com
 
Posts: n/a
Default Re: NFS dir timestamp question

Thanks, your analysis helped me understand what's happening better.

I was trying to set it up so that an explicit list of .o files isn't
necessary. I guess I need to rethink the approach.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 01:27 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0