maindavfs2 - Support: sr #108575, understand davfs2 lock

 
 

sr #108575: understand davfs2 lock

Submitter:  Jeet singh <jeetpei>
Submitted:  Mon 19 May 2014 06:52:00 AM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  In Progress
Privacy:  Public Assigned to:  _71007
Open/Closed:  Closed Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 19 May 2014 07:26:02 PM UTC, comment #2: 

First: when you do some operation in python there are a lot of interfaces involved until there may be finally some WebDAV-request. davfs2 only gets to see the upcalls from the kernel (like lookup, getattr, open, create, ...). So you can't expect that any local file system operation directly translates into a corresponding WebDAV request. Transforming local file operations 1:1 into WebDAV operations is indeed impossible.

Locking:
There are a lot of diverent locking mechanism on Unix-like operationg systems. davfs2 suppurts none of these. Your operating system may still allow you locks on file descriptors, but this happens without any involvement of davfs2.

davfs2 and WebDAV-locks:
The logic is quite simole. By default davfs2 uses WebDAV-locks, but you can disable this with option 'use_locks 0'.
With WebDAV-locks enabled:
Whenever you open a file for writing (the file may already exist or may not exist) davfs2 will send a LOCK-request to the server and save the lock token it gets in the response. When you close the file, davfs2 will wait for about 'delay_upload' seconds, send the file with PUT to the server and in case of success it will release the lock. In case of a temporary error it will keep the file and the lock token and retry later again.
The purpose of this is to minimize the chance of writing over someone elses changes to a file.

The problem with empty files:
WebDAV allows servers two different reactions in response to a LOCK-request for a file that does not yet exist:

  • old style: lock the name, but do not create a file. When there is no PUT request for this file and it is unlocked, nothing remains.
  • new style: create an empty file and lock this file. When it is unlocked the file remains.

A server may choose any of these aproches. The client has no influence on this.

But apart from this there seems to be a misunderstanding:
If you open a file for writing (which does not yet exist) and then close the file, you have created an new file. It may be empty but it is there. If you don't want this file you will have to delete it.

From the point of view of davfs2:
davfs2 gets from the kernel a request to create and open a file. This is what davfs2 does. If you write to the file - davfs2 will do it. If you don't write to the file - the file will be empty. But the file is there, because it was requested to create it.
If davfs2 gets an request from the kernel to delete the file - davfs2 will do it and it will also delete the file on the server, independent of what locking logic the server uses.

Cheers
Werner

- <_71007>
Mon 19 May 2014 07:30:26 AM UTC, comment #1: 

BTW i am using python's open("file","ab+") to lock a file..

is there any other method to achieve my goal then please let me know.

Jeet singh <jeetpei>
Mon 19 May 2014 06:52:00 AM UTC, original submission:  

Hi,

i am using davfs2 for internal testing in my company which is cloud_file_server provider.

what is see is if i lock a file in write mode and close opened file a new version of file created.

what i want is if i open a file in write mode its should get locked
in cloud and when i release lock it should simply unlock rather than create a new version.

waiting for any help by you

Jeet singh <jeetpei>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by _71007 (Posted a comment)
  • -email is unavailable- added by jeetpei (Submitted the item)
  • -email is unavailable- added by jeetpei
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-15 _71007 Open/ClosedOpen Closed
    2014-05-19 _71007 StatusNone In Progress
        Assigned toNone _71007
    2014-05-19 jeetpei Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code