fuse: remove the 1GiB buffer view limit#101
Open
chinasasu wants to merge 1 commit into
Open
Conversation
bbe850d to
174d49c
Compare
174d49c to
9d910cf
Compare
Collaborator
|
I understand that this may solve a real problem for you. However we still need to support 32-bit systems and this looks a bit complicated to me. The expression So perhaps the following change should do the trick. From: buff := (*[1 << 30]byte)(unsafe.Pointer(buff0))To: buff := (*[1 << (30 + 10*(^uint(0)>>32&1))]byte)(unsafe.Pointer(buff0))Full diff: diff --git c/fuse/host.go i/fuse/host.go
index 083c03c..5176029 100644
--- c/fuse/host.go
+++ i/fuse/host.go
@@ -135,7 +135,7 @@ func hostReadlink(path0 *c_char, buff0 *c_char, size0 c_size_t) (errc0 c_int) {
fsop := hostHandleGet(c_fuse_get_context().private_data).fsop
path := c_GoString(path0)
errc, rslt := fsop.Readlink(path)
- buff := (*[1 << 30]byte)(unsafe.Pointer(buff0))
+ buff := (*[1 << (30 + 10*(^uint(0)>>32&1))]byte)(unsafe.Pointer(buff0))
copy(buff[:size0-1], rslt)
rlen := len(rslt)
if c_size_t(rlen) < size0 {
@@ -284,7 +284,7 @@ func hostRead(path0 *c_char, buff0 *c_char, size0 c_size_t, ofst0 c_fuse_off_t,
defer recoverAsErrno(&nbyt0)
fsop := hostHandleGet(c_fuse_get_context().private_data).fsop
path := c_GoString(path0)
- buff := (*[1 << 30]byte)(unsafe.Pointer(buff0))
+ buff := (*[1 << (30 + 10*(^uint(0)>>32&1))]byte)(unsafe.Pointer(buff0))
nbyt := fsop.Read(path, buff[:size0], int64(ofst0), uint64(fi0.fh))
return c_int(nbyt)
}
@@ -294,7 +294,7 @@ func hostWrite(path0 *c_char, buff0 *c_char, size0 c_size_t, ofst0 c_fuse_off_t,
defer recoverAsErrno(&nbyt0)
fsop := hostHandleGet(c_fuse_get_context().private_data).fsop
path := c_GoString(path0)
- buff := (*[1 << 30]byte)(unsafe.Pointer(buff0))
+ buff := (*[1 << (30 + 10*(^uint(0)>>32&1))]byte)(unsafe.Pointer(buff0))
nbyt := fsop.Write(path, buff[:size0], int64(ofst0), uint64(fi0.fh))
return c_int(nbyt)
}
@@ -346,7 +346,7 @@ func hostSetxattr(path0 *c_char, name0 *c_char, buff0 *c_char, size0 c_size_t,
fsop := hostHandleGet(c_fuse_get_context().private_data).fsop
path := c_GoString(path0)
name := c_GoString(name0)
- buff := (*[1 << 30]byte)(unsafe.Pointer(buff0))
+ buff := (*[1 << (30 + 10*(^uint(0)>>32&1))]byte)(unsafe.Pointer(buff0))
errc := fsop.Setxattr(path, name, buff[:size0], int(flags))
return c_int(errc)
}
@@ -364,7 +364,7 @@ func hostGetxattr(path0 *c_char, name0 *c_char, buff0 *c_char, size0 c_size_t) (
if len(rslt) > int(size0) {
return -c_int(ERANGE)
}
- buff := (*[1 << 30]byte)(unsafe.Pointer(buff0))
+ buff := (*[1 << (30 + 10*(^uint(0)>>32&1))]byte)(unsafe.Pointer(buff0))
copy(buff[:size0], rslt)
}
return c_int(len(rslt))
@@ -374,7 +374,7 @@ func hostListxattr(path0 *c_char, buff0 *c_char, size0 c_size_t) (nbyt0 c_int) {
defer recoverAsErrno(&nbyt0)
fsop := hostHandleGet(c_fuse_get_context().private_data).fsop
path := c_GoString(path0)
- buff := (*[1 << 30]byte)(unsafe.Pointer(buff0))
+ buff := (*[1 << (30 + 10*(^uint(0)>>32&1))]byte)(unsafe.Pointer(buff0))
size := int(size0)
nbyt := 0
fill := func(name1 string) bool {
@@ -599,7 +599,7 @@ func hostGetpath(path0 *c_char, buff0 *c_char, size0 c_size_t,
fifh = uint64(fi0.fh)
}
errc, rslt := intf.Getpath(path, fifh)
- buff := (*[1 << 30]byte)(unsafe.Pointer(buff0))
+ buff := (*[1 << (30 + 10*(^uint(0)>>32&1))]byte)(unsafe.Pointer(buff0))
copy(buff[:size0-1], rslt)
rlen := len(rslt)
if c_size_t(rlen) < size0 { |
Collaborator
|
And maybe specifying: const maxwidth = 1 << (30 + 10*(^uint(0)>>32&1))And then changing the buff := (*[maxwidth]byte)(unsafe.Pointer(buff0))Would be even better. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This replaces the fixed
(*[1 << 30]byte)(unsafe.Pointer(...))buffer view with anunsafe.Sliceview sized to the actual request.Why this change:
hostRead,hostWrite,hostSetxattr,hostGetxattr,hostListxattr,hostReadlink, andhostGetpathis at most 1 GiB longbuff[:size0]can panic before the filesystem callback is reachedrecoverAsErrnothen converts that panic into-EIO, which surfaces as an unexpected I/O failure to the callerWhat this patch does:
size0-1Validation:
IO DEVICE ERRORfor a singleReadFilerequest larger than 1 GiB before this changego test ./fusepasses locally