Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0330aad

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommittedNov 1, 2023
os: report IO_REPARSE_TAG_DEDUP files as regular in Stat and Lstat
Prior to CL 460595, Lstat reported most reparse points as regular files. However, reparse points can in general implement unusual behaviors (consider IO_REPARSE_TAG_AF_UNIX or IO_REPARSE_TAG_LX_CHR), and Windows allows arbitrary user-defined reparse points, so in general we must not assume that an unrecognized reparse tag represents a regular file; in CL 460595, we began marking them as irregular. As it turns out, the Data Deduplication service on Windows Server runs an Optimization job that turns regular files into reparse files with the tag IO_REPARSE_TAG_DEDUP. Those files still behave more-or-less like regular files, in that they have well-defined sizes and support random-access reads and writes, so most programs can treat them as regular files without difficulty. However, they are still reparse files: as a result, on servers with the Data Deduplication service enabled, files could arbitrarily change from “regular” to “irregular” without explicit user intervention. Since dedup files are converted in the background and otherwise behave like regular files, this change adds a special case to report DEDUP reparse points as regular. Fixes #63429. No test because to my knowledge we don't have any Windows builders that have the deduplication service enabled, nor do we have a way to reliably guarantee the existence of an IO_REPARSE_TAG_DEDUP file. (In theory we could add a builder with the service enabled on a specific volume, write a test that encodes knowledge of that volume, and use the GO_BUILDER_NAME environment variable to run that test only on the specially-configured builders. However, I don't currently have the bandwidth to reconfigure the builders in this way, and given the simplicity of the change I think it is unlikely to regress accidentally.) Change-Id: I649e7ef0b67e3939a980339ce7ec6a20b31b23a1 Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/537915 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Alex Brainman <[email protected]> Reviewed-by: Quim Muntal <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
1 parent b7a695b commit 0330aad

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
 

‎src/internal/syscall/windows/reparse_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
const (
1313
FSCTL_SET_REPARSE_POINT = 0x000900A4
1414
IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
15+
IO_REPARSE_TAG_DEDUP = 0x80000013
1516

1617
SYMLINK_FLAG_RELATIVE = 1
1718
)

‎src/os/types_windows.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,23 @@ func (fs *fileStat) Mode() (m FileMode) {
185185
m |= ModeDevice | ModeCharDevice
186186
}
187187
if fs.FileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0 && m&ModeType == 0 {
188-
m |= ModeIrregular
188+
if fs.ReparseTag == windows.IO_REPARSE_TAG_DEDUP {
189+
// If the Data Deduplication service is enabled on Windows Server, its
190+
// Optimization job may convert regular files to IO_REPARSE_TAG_DEDUP
191+
// whenever that job runs.
192+
//
193+
// However, DEDUP reparse points remain similar in most respects to
194+
// regular files: they continue to support random-access reads and writes
195+
// of persistent data, and they shouldn't add unexpected latency or
196+
// unavailability in the way that a network filesystem might.
197+
//
198+
// Go programs may use ModeIrregular to filter out unusual files (such as
199+
// raw device files on Linux, POSIX FIFO special files, and so on), so
200+
// to avoid files changing unpredictably from regular to irregular we will
201+
// consider DEDUP files to be close enough to regular to treat as such.
202+
} else {
203+
m |= ModeIrregular
204+
}
189205
}
190206
return m
191207
}

0 commit comments

Comments
 (0)
Please sign in to comment.