From 5a2b5e84d06e0704928d111249e75615173cdcfb Mon Sep 17 00:00:00 2001 From: Joran Dirk Greef Date: Wed, 27 Sep 2017 11:09:28 +0200 Subject: [PATCH] win: change st_blksize from `2048` to `4096` `fs__stat_handle()` used to set st_blksize to `2048` regardless of the underlying physical sector size of the disk. `4096` is a better constant to avoid read-modify-write behavior on advanced format drives. Fixes: https://github.com/libuv/libuv/issues/1563 PR-URL: https://github.com/libuv/libuv/pull/1566 Reviewed-By: Bartosz Sosnowski --- src/win/fs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/win/fs.c b/src/win/fs.c index c374a82c..51afac28 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -1178,8 +1178,12 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf) { * * Therefore we'll just report a sensible value that's quite commonly okay * on modern hardware. + * + * 4096 is the minimum required to be compatible with newer Advanced Format + * drives (which have 4096 bytes per physical sector), and to be backwards + * compatible with older drives (which have 512 bytes per physical sector). */ - statbuf->st_blksize = 2048; + statbuf->st_blksize = 4096; /* Todo: set st_flags to something meaningful. Also provide a wrapper for * chattr(2).