From 51317539fc583820e42fe7313e6b755811a27d72 Mon Sep 17 00:00:00 2001 From: vibhansa-msft Date: Tue, 11 Apr 2023 15:58:31 +0530 Subject: [PATCH 1/8] fix for #1102 --- CHANGELOG.md | 1 + component/libfuse/libfuse2_handler.go | 6 +++--- component/libfuse/libfuse_handler.go | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d479f500..2e4bb9496 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#1100](https://github.com/Azure/azure-storage-fuse/issues/1100) If content-encoding is set in blob then transport layer compression shall be disabled. - Subdir mount is not able to list blobs correctly when virtual-directory is turned on. - Adding support to pass down uid/gid values supplied in mount to libfuse. +- [[#1102](https://github.com/Azure/azure-storage-fuse/issues/1102) Remove nanoseconds from file times as storage does not provide that granuality. **Features** - Added new CLI parameter "--sync-to-flush". Once configured sync() call on file will force upload a file to storage container. As this is file handle based api, if file was not in file-cache it will first download and then upload the file. diff --git a/component/libfuse/libfuse2_handler.go b/component/libfuse/libfuse2_handler.go index 47dd4c627..2794a7d74 100644 --- a/component/libfuse/libfuse2_handler.go +++ b/component/libfuse/libfuse2_handler.go @@ -311,13 +311,13 @@ func (lf *Libfuse) fillStat(attr *internal.ObjAttr, stbuf *C.stat_t) { } (*stbuf).st_atim.tv_sec = C.long(attr.Atime.Unix()) - (*stbuf).st_atim.tv_nsec = C.long(attr.Atime.UnixNano()) + (*stbuf).st_atim.tv_nsec = 0 (*stbuf).st_ctim.tv_sec = C.long(attr.Ctime.Unix()) - (*stbuf).st_ctim.tv_nsec = C.long(attr.Ctime.UnixNano()) + (*stbuf).st_ctim.tv_nsec = 0 (*stbuf).st_mtim.tv_sec = C.long(attr.Mtime.Unix()) - (*stbuf).st_mtim.tv_nsec = C.long(attr.Mtime.UnixNano()) + (*stbuf).st_mtim.tv_nsec = 0 } // File System Operations diff --git a/component/libfuse/libfuse_handler.go b/component/libfuse/libfuse_handler.go index 57cd12310..1ffd89d50 100644 --- a/component/libfuse/libfuse_handler.go +++ b/component/libfuse/libfuse_handler.go @@ -343,13 +343,13 @@ func (lf *Libfuse) fillStat(attr *internal.ObjAttr, stbuf *C.stat_t) { } (*stbuf).st_atim.tv_sec = C.long(attr.Atime.Unix()) - (*stbuf).st_atim.tv_nsec = C.long(attr.Atime.UnixNano()) + (*stbuf).st_atim.tv_nsec = 0 (*stbuf).st_ctim.tv_sec = C.long(attr.Ctime.Unix()) - (*stbuf).st_ctim.tv_nsec = C.long(attr.Ctime.UnixNano()) + (*stbuf).st_ctim.tv_nsec = 0 (*stbuf).st_mtim.tv_sec = C.long(attr.Mtime.Unix()) - (*stbuf).st_mtim.tv_nsec = C.long(attr.Mtime.UnixNano()) + (*stbuf).st_mtim.tv_nsec = 0 } // File System Operations From df5d1fdd80719caf5cd9f7de30d1a8e489093905 Mon Sep 17 00:00:00 2001 From: vibhansa-msft Date: Tue, 11 Apr 2023 18:01:13 +0530 Subject: [PATCH 2/8] spell correction --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e4bb9496..10890108e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - [#1100](https://github.com/Azure/azure-storage-fuse/issues/1100) If content-encoding is set in blob then transport layer compression shall be disabled. - Subdir mount is not able to list blobs correctly when virtual-directory is turned on. - Adding support to pass down uid/gid values supplied in mount to libfuse. -- [[#1102](https://github.com/Azure/azure-storage-fuse/issues/1102) Remove nanoseconds from file times as storage does not provide that granuality. +- [[#1102](https://github.com/Azure/azure-storage-fuse/issues/1102) Remove nanoseconds from file times as storage does not provide that granularity. **Features** - Added new CLI parameter "--sync-to-flush". Once configured sync() call on file will force upload a file to storage container. As this is file handle based api, if file was not in file-cache it will first download and then upload the file. From 25bb49bec67d4156acd117fe30d1389266551e3d Mon Sep 17 00:00:00 2001 From: vibhansa-msft Date: Tue, 11 Apr 2023 18:01:49 +0530 Subject: [PATCH 3/8] spell correction --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10890108e..8a7d40a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - [#1100](https://github.com/Azure/azure-storage-fuse/issues/1100) If content-encoding is set in blob then transport layer compression shall be disabled. - Subdir mount is not able to list blobs correctly when virtual-directory is turned on. - Adding support to pass down uid/gid values supplied in mount to libfuse. -- [[#1102](https://github.com/Azure/azure-storage-fuse/issues/1102) Remove nanoseconds from file times as storage does not provide that granularity. +- [#1102](https://github.com/Azure/azure-storage-fuse/issues/1102) Remove nanoseconds from file times as storage does not provide that granularity. **Features** - Added new CLI parameter "--sync-to-flush". Once configured sync() call on file will force upload a file to storage container. As this is file handle based api, if file was not in file-cache it will first download and then upload the file. From 7d69decb645d0e589df45326ddecdb895d50404c Mon Sep 17 00:00:00 2001 From: vibhansa-msft Date: Tue, 11 Apr 2023 22:39:05 +0530 Subject: [PATCH 4/8] Adding test case for getattr --- component/libfuse/libfuse2_handler_test_wrapper.go | 8 ++++++++ component/libfuse/libfuse_handler_test_wrapper.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/component/libfuse/libfuse2_handler_test_wrapper.go b/component/libfuse/libfuse2_handler_test_wrapper.go index 8cbf60a73..5c78244b4 100644 --- a/component/libfuse/libfuse2_handler_test_wrapper.go +++ b/component/libfuse/libfuse2_handler_test_wrapper.go @@ -202,6 +202,14 @@ func testCreate(suite *libfuseTestSuite) { err := libfuse_create(path, 0775, info) suite.assert.Equal(C.int(0), err) + + option := internal.GetAttrOptions{Name: name} + suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) + stbuf := &C.stat_t{} + err = libfuse2_getattr(path, stbuf) + suite.assert.Equal(C.int(0), err) + suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) + suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0)) } func testCreateError(suite *libfuseTestSuite) { diff --git a/component/libfuse/libfuse_handler_test_wrapper.go b/component/libfuse/libfuse_handler_test_wrapper.go index 4ff4d094b..43e0f05f4 100644 --- a/component/libfuse/libfuse_handler_test_wrapper.go +++ b/component/libfuse/libfuse_handler_test_wrapper.go @@ -186,6 +186,14 @@ func testCreate(suite *libfuseTestSuite) { err := libfuse_create(path, 0775, info) suite.assert.Equal(C.int(0), err) + + option := internal.GetAttrOptions{Name: name} + suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) + stbuf := &C.stat_t{} + err = libfuse_getattr(path, stbuf) + suite.assert.Equal(C.int(0), err) + suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) + suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0)) } func testCreateError(suite *libfuseTestSuite) { From 968c999fd1a3250096c1058e8b9dd3add350cc4f Mon Sep 17 00:00:00 2001 From: vibhansa-msft Date: Wed, 12 Apr 2023 08:56:27 +0530 Subject: [PATCH 5/8] Correction as per linting results --- component/libfuse/libfuse2_handler_test_wrapper.go | 2 ++ component/libfuse/libfuse_handler_test_wrapper.go | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/component/libfuse/libfuse2_handler_test_wrapper.go b/component/libfuse/libfuse2_handler_test_wrapper.go index 5c78244b4..084f84116 100644 --- a/component/libfuse/libfuse2_handler_test_wrapper.go +++ b/component/libfuse/libfuse2_handler_test_wrapper.go @@ -205,8 +205,10 @@ func testCreate(suite *libfuseTestSuite) { option := internal.GetAttrOptions{Name: name} suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) + stbuf := &C.stat_t{} err = libfuse2_getattr(path, stbuf) + suite.assert.Equal(C.int(0), err) suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0)) diff --git a/component/libfuse/libfuse_handler_test_wrapper.go b/component/libfuse/libfuse_handler_test_wrapper.go index 43e0f05f4..78a341a51 100644 --- a/component/libfuse/libfuse_handler_test_wrapper.go +++ b/component/libfuse/libfuse_handler_test_wrapper.go @@ -186,11 +186,13 @@ func testCreate(suite *libfuseTestSuite) { err := libfuse_create(path, 0775, info) suite.assert.Equal(C.int(0), err) - + option := internal.GetAttrOptions{Name: name} suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) + stbuf := &C.stat_t{} - err = libfuse_getattr(path, stbuf) + err = libfuse_getattr(path, stbuf, 0) + suite.assert.Equal(C.int(0), err) suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0)) From 95590dd116bae1e8332b41ef78077f9357bd4709 Mon Sep 17 00:00:00 2001 From: vibhansa-msft Date: Wed, 12 Apr 2023 11:34:34 +0530 Subject: [PATCH 6/8] linting fixes --- component/libfuse/libfuse2_handler_test_wrapper.go | 2 -- component/libfuse/libfuse_handler_test_wrapper.go | 3 --- 2 files changed, 5 deletions(-) diff --git a/component/libfuse/libfuse2_handler_test_wrapper.go b/component/libfuse/libfuse2_handler_test_wrapper.go index 084f84116..5c78244b4 100644 --- a/component/libfuse/libfuse2_handler_test_wrapper.go +++ b/component/libfuse/libfuse2_handler_test_wrapper.go @@ -205,10 +205,8 @@ func testCreate(suite *libfuseTestSuite) { option := internal.GetAttrOptions{Name: name} suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) - stbuf := &C.stat_t{} err = libfuse2_getattr(path, stbuf) - suite.assert.Equal(C.int(0), err) suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0)) diff --git a/component/libfuse/libfuse_handler_test_wrapper.go b/component/libfuse/libfuse_handler_test_wrapper.go index 78a341a51..394bd4540 100644 --- a/component/libfuse/libfuse_handler_test_wrapper.go +++ b/component/libfuse/libfuse_handler_test_wrapper.go @@ -186,13 +186,10 @@ func testCreate(suite *libfuseTestSuite) { err := libfuse_create(path, 0775, info) suite.assert.Equal(C.int(0), err) - option := internal.GetAttrOptions{Name: name} suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) - stbuf := &C.stat_t{} err = libfuse_getattr(path, stbuf, 0) - suite.assert.Equal(C.int(0), err) suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0)) From 5dc471f2dca6fec26804fd77f6699de30e1197d1 Mon Sep 17 00:00:00 2001 From: vibhansa-msft Date: Wed, 12 Apr 2023 11:52:04 +0530 Subject: [PATCH 7/8] linting fixes --- component/libfuse/libfuse_handler_test_wrapper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/libfuse/libfuse_handler_test_wrapper.go b/component/libfuse/libfuse_handler_test_wrapper.go index 394bd4540..63df3c53a 100644 --- a/component/libfuse/libfuse_handler_test_wrapper.go +++ b/component/libfuse/libfuse_handler_test_wrapper.go @@ -189,7 +189,7 @@ func testCreate(suite *libfuseTestSuite) { option := internal.GetAttrOptions{Name: name} suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) stbuf := &C.stat_t{} - err = libfuse_getattr(path, stbuf, 0) + err = libfuse_getattr(path, stbuf, c.NULL) suite.assert.Equal(C.int(0), err) suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0)) From c35dfcf00d91a60be41ae34638ea95d40f7e793b Mon Sep 17 00:00:00 2001 From: vibhansa-msft Date: Wed, 12 Apr 2023 11:55:12 +0530 Subject: [PATCH 8/8] linting fixes --- component/libfuse/libfuse_handler_test_wrapper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/libfuse/libfuse_handler_test_wrapper.go b/component/libfuse/libfuse_handler_test_wrapper.go index 63df3c53a..0c8b66545 100644 --- a/component/libfuse/libfuse_handler_test_wrapper.go +++ b/component/libfuse/libfuse_handler_test_wrapper.go @@ -189,7 +189,7 @@ func testCreate(suite *libfuseTestSuite) { option := internal.GetAttrOptions{Name: name} suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) stbuf := &C.stat_t{} - err = libfuse_getattr(path, stbuf, c.NULL) + err = libfuse_getattr(path, stbuf, &C.fuse_file_info_t{}) suite.assert.Equal(C.int(0), err) suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0))