[ 
https://issues.apache.org/jira/browse/HDFS-3431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13468864#comment-13468864
 ] 

Colin Patrick McCabe commented on HDFS-3431:
--------------------------------------------

It's very difficult to improve on truncate without supporting a truncate 
operation natively in HDFS.

One example: let's say superuser creates /a/b/c with mode = 666, length L.
bob asks to truncate /a/b/c to half its original length, L/2.

How can fuse implement this?  We would have to re-create the file and write L/2 
bytes, then close it.  However, the new file we create will be owned by bob, 
not by superuser.  This is an unfixable problem because bob's DFSClient may not 
even have the credentials to create the file as superuser.

Another consideration is that writing out L/2 bytes could be very expensive.  
For example, if we have a 1GB file, that's 512 MB we have to buffer and 
re-write in order to perform the truncate operation.
                
> Improve fuse-dfs truncate
> -------------------------
>
>                 Key: HDFS-3431
>                 URL: https://issues.apache.org/jira/browse/HDFS-3431
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: fuse-dfs
>            Reporter: Eli Collins
>            Priority: Minor
>
> Fuse-dfs truncate only works for size == 0 and per the function's comment is 
> a "Weak implementation in that we just delete the file and then re-create it, 
> but don't set the user, group, and times to the old file's metadata". Per 
> HDFS-860 we should ENOTSUP when the size != 0 or the size of the file.  
> Also, we should implement the ftruncate system call in FUSE.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to