block/nfs: fix calculation of allocated file size
PATCH 1/1 block/nfs: fix calculation of allocated file size
st.st_blocks is always counted in 512 byte units. Do not use st.st_blksize as multiplicator which may be larger.
Signed-off-by Peter Lieven <[email protected]>
--- block/nfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/nfs.c +1 -1
@@ -475,7 +475,7 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)aio_poll (client->aio_context, true); } -return (task.ret <0 ? task.ret : st.st_blocks * st.st_blksize); +return (task.ret <0 ? task.ret : st.st_blocks *512 ); }static int nfs_file_truncate (BlockDriverState *bs,int64_t offset)
Signature · 1 line
1.9.1
Quoted 14 lines · Peter Lieven
st.st_blocks is always counted in 512 byte units. Do not use st.st_blksize as multiplicator which may be larger.
Signed-off-by Peter Lieven <[email protected]>--- block/nfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/nfs.c +0
-0
block/nfs.c static int64_t nfs_get_allocated_file_size(BlockDriverState *bs) · line 481
Quoted 8 lines
block/nfs.c +1
-1@@ -475,7 +475,7 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)aio_poll (client->aio_context, true); } -return (task.ret <0 ? task.ret : st.st_blocks * st.st_blksize); +return (task.ret <0 ? task.ret : st.st_blocks *512 ); }static int nfs_file_truncate (BlockDriverState *bs,int64_t offset)
Reviewed-by Max Reitz <[email protected]>
Quoted 25 lines · Peter Lieven
st.st_blocks is always counted in 512 byte units. Do not use st.st_blksize as multiplicator which may be larger.
Signed-off-by Peter Lieven <[email protected]>--- block/nfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/nfs.c +1
-1@@ -475,7 +475,7 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)aio_poll (client->aio_context, true); } -return (task.ret <0 ? task.ret : st.st_blocks * st.st_blksize); +return (task.ret <0 ? task.ret : st.st_blocks *512 ); }static int nfs_file_truncate (BlockDriverState *bs,int64_t offset)Signature · 1 line
1.9.1
Reviewed-by Jeff Cody <[email protected]>
Jeff Cody
AppliedQuoted 25 lines · Peter Lieven
st.st_blocks is always counted in 512 byte units. Do not use st.st_blksize as multiplicator which may be larger.
Signed-off-by Peter Lieven <[email protected]>--- block/nfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/nfs.c +1
-1@@ -475,7 +475,7 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)aio_poll (client->aio_context, true); } -return (task.ret <0 ? task.ret : st.st_blocks * st.st_blksize); +return (task.ret <0 ? task.ret : st.st_blocks *512 ); }static int nfs_file_truncate (BlockDriverState *bs,int64_t offset)Signature · 1 line
1.9.1
Thanks, applied to my block tree:
git://github.com/codyprime/qemu-kvm-jtc.git block
-Jeff