Commit Graph

6 Commits

Author SHA1 Message Date
Marat Radchenko
285eebdddf Revert "Stop replacing files in LFS storage when downloading them concurrently on Windows"
This reverts commit 0c8edfc097a8364819649c9ba4df2221082a8cf8.
2019-11-05 17:30:13 +03:00
Marat Radchenko
0c8edfc097 Stop replacing files in LFS storage when downloading them concurrently on Windows
On Windows, there is no way to replace file atomically. Instead, MoveFileExA:

1. Calls CreateFileA(access=Delete, shareMode=Delete)
2. Calls SetRenameInformationFile to rename file
3. Calls CloseFile

The problem is that if parallel process attempts to open destination file for reading between
steps 2 and 3, it will try to do that without shareMode=Delete and will hit a SHARING_VIOLATION error.

In practice, this race condition results in:

  Smudge error: Error opening media file.: open .git\lfs\objects\<sha>: The process cannot access the file because it is being used by another process.

There are two solutions here:

 1. Do not overwrite file if it already exists
 2. Retry reading from file if got a SHARING_VIOLATION

This commit implements option 1.

Fixes #2825 (for Windows, other OSes are race-free already). Also see #3813 and #3826.
2019-10-25 10:54:25 +03:00
Kazuki MATSUDA / 松田一樹
e4d49352be
NON-ISSUE Use FICLONE instead of BTRFS_IOC_CLONE.
Sorry it's my miss-understanding that we should use FICLONE first and fallback to BTRFS_IOC_CLONE.
Actually, FICILONE is equal to BTRFS_IOC_CLONE.

So we already support copy-on-write also XFS not only Btrfs.

In this commit, let me use standarized name `FICILONE` instead of `BTRFS_IOC_CLONE`.

FICILONE definition:
----

`#define FICLONE		_IOW(0x94, 9, int)`  in https://github.com/torvalds/linux/blob/v5.2/include/uapi/linux/fs.h#L195

BTRFS_IOC_CLONE definition:
----

`#define BTRFS_IOC_CLONE        _IOW(BTRFS_IOCTL_MAGIC, 9, int)` in https://github.com/torvalds/linux/blob/v5.2/include/uapi/linux/btrfs.h#L850

and

`#define BTRFS_IOCTL_MAGIC 0x94` in https://github.com/torvalds/linux/blob/v5.2/include/uapi/linux/btrfs.h#L25
2019-08-29 10:01:25 +09:00
Kazuki MATSUDA / 松田一樹
8c7ed55536
Add new command git lfs dedup for file system level deduplication.
Implements and closes https://github.com/git-lfs/git-lfs/issues/3740.
2019-08-19 10:44:37 +09:00
Kazuki MATSUDA / 松田一樹
268625d325
Add clone file (CloneFileByPath) on MacOS X (darwin) 2019-08-01 23:32:29 +09:00
Steve Streeting
1ef2d43306 Move CopyWithCallback into general tools for re-use 2016-05-19 15:12:46 +01:00