epylar / s3fs

Automatically exported from code.google.com/p/s3fs
GNU General Public License v2.0
0 stars 0 forks source link

truncate is skipped if the same file is opened at another thread or process. #415

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Detailed description of observed behavior:

Incorrect fs behavior, truncate won't work if same file is already open. On 
process 1: if you open a file, and hold it for some time before closing. on 
process 2: if you simply truncate the same file to a smaller size.

on local file system (ext4), you get expected truncated file size, but on s3fs 
, truncate is simply skipped. 

After checking source code, found that FdEntity Open doesn't cover this case if 
FdManager has an entry (same file) already opened. 

What steps will reproduce the problem - please be very specific and
detailed. (if the developers cannot reproduce the issue, then it is
unlikely a fix will be found)?

Process 1: 
FILE *fp = NULL;
const char* buffer = "1234567890";
fp = fopen(filename.c_str(), "w");
fwrite (buffer , sizeof(char), strlen(buffer), fp);
fflush(fp);
sleep(45);

if(fp)
    fclose(fp);

Process 2:
   err = truncate (filename.c_str(), trunc_len);

test program is attached, steps to reproduce the problem
./testfs 3 test.txt &
./testfs 1 test.txt

===================================================================
The following information is very important in order to help us to help
you.  Omission of the following details may delay your support request or
receive no attention at all.
===================================================================
Version of s3fs being used (s3fs --version): 1.74

Version of fuse being used (pkg-config --modversion fuse): 2.93

System information (uname -a): 2.6.32

Distro (cat /etc/issue):

s3fs command line used (if applicable):

/etc/fstab entry (if applicable):

s3fs syslog messages (grep s3fs /var/log/syslog):

Original issue reported on code.google.com by hujinhu...@gmail.com on 30 Mar 2014 at 6:39

Attachments: