Skip to contentSkip to conversation

qed: make qed_alloc_clusters round up offset to nearest cluster

PATCH In review Devin Nakamura 4 participants 6 messages Aug 15, 2011 – Aug 25, 2011 1 message not in the archive Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qed: make qed_alloc_clusters round up offset to nearest cluster

---
 block/qed.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
block/qed.c +2 -0
index 333f067..9a1e49c 100644
@@ -263,6 +263,8 @@ static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n,
  */
 static uint64_t qed_alloc_clusters(BDRVQEDState *s, unsigned int n)
 {
+    s->file_size =  qed_start_of_cluster(s, s->file_size +
+                                         s->header.cluster_size - 1);
     uint64_t offset = s->file_size;
     s->file_size += n * s->header.cluster_size;
     return offset;
Signature · 1 line
1.7.6.rc1
#1 lore raw

block/qed.c static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n, · line 267

Quoted 6 lines · Devin Nakamura
block/qed.c +2 -0
@@ -263,6 +263,8 @@ static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n,
  */
 static uint64_t qed_alloc_clusters(BDRVQEDState *s, unsigned int n)
 {
+    s->file_size =  qed_start_of_cluster(s, s->file_size +
+                                         s->header.cluster_size - 1);

Why do you need this? QED cluster aligns the file size on open. file_size should always be cluster-aligned.

Stefan

A message that is not in the archive (sent off-list or not yet received): CAJ1AwB5v8V-KMz7YK9xYuyXn6jWN+H23dXCn5EV1hsuS3iqgnQ@mail.gmail.com

#3 lore raw

PATCH 1/1 qed: make qed_alloc_clusters round up offset to nearest cluster

Quoted 11 lines · Stefan Hajnoczi

block/qed.c static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n, · line 267

Quoted 6 lines · Devin Nakamura
block/qed.c +2 -0
@@ -263,6 +263,8 @@ static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n,
   */
  static uint64_t qed_alloc_clusters(BDRVQEDState *s, unsigned int n)
  {
+    s->file_size =  qed_start_of_cluster(s, s->file_size +
+                                         s->header.cluster_size - 1);

Why do you need this?  QED cluster aligns the file size on open. file_size should always be cluster-aligned.

Quoted 2 lines

Stefan

I was running into problems when I was doing in-place conversion from qcow2. But I suppose I could cluster align the file offset when I open the conversion target. I just seemed this way was safer.

#4 lore raw
In reply to Devin Nakamura

Am 16.08.2011 01:16, schrieb Devin Nakamura:

Quoted 10 lines
---
 block/qed.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
block/qed.c +0 -0
index 333f067..9a1e49c 100644

block/qed.c static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n, · line 270

Quoted 8 lines
block/qed.c +2 -0
@@ -263,6 +263,8 @@ static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n,
  */
 static uint64_t qed_alloc_clusters(BDRVQEDState *s, unsigned int n)
 {
+    s->file_size =  qed_start_of_cluster(s, s->file_size +
+                                         s->header.cluster_size - 1);
     uint64_t offset = s->file_size;
     s->file_size += n * s->header.cluster_size;
     return offset;

Stefan, Devin, have you come to a conclusion about this patch?

Kevin

#5 lore raw
Quoted 6 lines · Kevin Wolf

Am 16.08.2011 01:16, schrieb Devin Nakamura:

Quoted 5 lines
---
 block/qed.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 15 lines

block/qed.c static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n, · line 270

Quoted 13 lines
block/qed.c +2 -0
index 333f067..9a1e49c 100644
@@ -263,6 +263,8 @@ static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n,
  */
 static uint64_t qed_alloc_clusters(BDRVQEDState *s, unsigned int n)
 {
+    s->file_size =  qed_start_of_cluster(s, s->file_size +
+                                         s->header.cluster_size - 1);
     uint64_t offset = s->file_size;
     s->file_size += n * s->header.cluster_size;
     return offset;

Stefan, Devin, have you come to a conclusion about this patch?

Yes, I suggested keeping the current contraint that file_size is cluster-aligned.

Devin, does that work for you?

Stefan

#6 lore raw

Works fine for me

Quoted 30 lines · Stefan Hajnoczi
Quoted 6 lines · Kevin Wolf

Am 16.08.2011 01:16, schrieb Devin Nakamura:

Quoted 5 lines

---
 block/qed.c |    2 ++

 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 15 lines

block/qed.c static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n, · line 270

Quoted 13 lines
block/qed.c +2 -0
index 333f067..9a1e49c 100644
@@ -263,6 +263,8 @@ static int qed_read_string(BlockDriverState *file, uint64_t offset, size_t n,
   */
  static uint64_t qed_alloc_clusters(BDRVQEDState *s, unsigned int n)
  {
+    s->file_size =  qed_start_of_cluster(s, s->file_size +
+                                         s->header.cluster_size - 1);
      uint64_t offset = s->file_size;
      s->file_size += n * s->header.cluster_size;
      return offset;

Stefan, Devin, have you come to a conclusion about this patch?

Yes, I suggested keeping the current contraint that file_size is cluster-aligned.

Devin, does that work for you?

Stefan