Skip to contentSkip to conversation

block/nfs: fix calculation of allocated file size

PATCH Applied Peter Lieven 3 participants 4 messages Aug 20, 2015 – Aug 26, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

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.

---
 block/nfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/nfs.c +1 -1
index c026ff6..02eb4e4 100644
@@ -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 on v1 1/1
#1 lore raw
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.

---
  block/nfs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
block/nfs.c +0 -0
index c026ff6..02eb4e4 100644

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 on v1 1/1
#2 lore raw
In reply to Peter Lieven
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.

---
 block/nfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/nfs.c +1 -1
index c026ff6..02eb4e4 100644
@@ -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
Applied
#3 lore raw
In reply to Peter Lieven
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.

---
 block/nfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/nfs.c +1 -1
index c026ff6..02eb4e4 100644
@@ -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