Skip to content

reftable: return proper error codes from block_writer_add

Meet Soni git 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest3 patches 1 replyIn review
  2. v43 patches 0 repliesSuperseded
  3. v32 patches 3 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v21 patch1 replySuperseded
v11 patch2 repliesSuperseded

Changes in v5 from the cover letter

- update commit message.
- add documentation comment.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3reftable: propagate specific error codes in block_writer_add()reftable/block.c reftable/block.h reftable/record.c+32 -360 replies
2/3reftable: adapt writer_add_record() to propagate block_writer_add() errorsreftable/writer.c+5 -100 replies
3/3reftable: adapt write_object_record() to propagate block_writer_add() errorsreftable/writer.c+19 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [GSoC PATCH v5 0/3] reftable: return proper error codes from block_writer_add

This patch series attempts to avoid making an assumption regarding error codes returned by block_writer_add().

Changes since v4:
- update commit message.
- add documentation comment.

Meet Soni (3):
reftable: propagate specific error codes in block_writer_add()
reftable: adapt writer_add_record() to propagate block_writer_add()
errors
reftable: adapt write_object_record() to propagate block_writer_add()
errors

 reftable/block.c  | 13 ++++++------
 reftable/block.h  |  2 +-
 reftable/record.c | 53 +++++++++++++++++++++--------------------------
 reftable/writer.c | 34 +++++++++++++++++++++---------
 4 files changed, 56 insertions(+), 46 deletions(-)

Range-diff against v4:

1:  6ab35d569c = 1:  6ab35d569c reftable: propagate specific error codes in block_writer_add()
2:  7f0bdc27e1 ! 2:  873a991a2c reftable: adapt writer_add_record() to propagate block_writer_add() errors

@@ Metadata
## Commit message ##
reftable: adapt writer_add_record() to propagate block_writer_add() errors

- Previously, writer_add_record() would flush the current block and
- retry appending the record whenever block_writer_add() returned any
- nonzero error. This forced an assumption that every failure meant
- the block was full, even when errors such as memory allocation or I/O
- failures occurred.
+ Previously, writer_add_record() would flush the current block and retry
+ appending the record whenever block_writer_add() returned any nonzero
+ error. This forced an assumption that every failure meant the block was
+ full, even when errors such as memory allocation or I/O failures occurred.

- Update the writer_add_record() to inspect the error code returned by
- block_writer_add() and only flush and reinitialize the writer when the
- error is REFTABLE_ENTRY_TOO_BIG_ERROR. For any other error, immediately
- propagate it.
+ Update the writer_add_record() to inspect the error code returned by
+ block_writer_add() and only flush and reinitialize the writer when the
+ error is REFTABLE_ENTRY_TOO_BIG_ERROR. For any other error, immediately
+ propagate it.

3: 480ac27797 ! 3: 1e2f7ff83f reftable: adapt write_object_record() to propagate block_writer_add() errors
@@ Metadata
## Commit message ##
reftable: adapt write_object_record() to propagate block_writer_add() errors

- Previously, write_object_record() would flush the current block and
- retry appending the record whenever block_writer_add() returned any
- nonzero error. This forced an assumption that every failure meant the
- block was full, even when errors such as memory allocation or I/O
- failures occurred.
+ Previously, write_object_record() would flush the current block and retry
+ appending the record whenever block_writer_add() returned any nonzero
+ error. This forced an assumption that every failure meant the block was
+ full, even when errors such as memory allocation or I/O failures occurred.

- Update the write_object_record() to inspect the error code returned by
- block_writer_add() and only flush and reinitialize the writer when the
- error is REFTABLE_ENTRY_TOO_BIG_ERROR. For any other error, immediately
- propagate it.
+ Update the write_object_record() to inspect the error code returned by
+ block_writer_add() and flush and reinitialize the writer iff the
+ error is REFTABLE_ENTRY_TOO_BIG_ERROR. For any other error, immediately
+ propagate it.

- All call sites now handle various error codes returned by
- block_writer_add().
+ If the flush and reinitialization still fail with
+ REFTABLE_ENTRY_TOO_BIG_ERROR, reset the record's offset length to zero
+ before a final attempt.
+
+ All call sites now handle various error codes returned by
+ block_writer_add().

@@ reftable/writer.c: static void write_object_record(void *void_arg, void *key)
arg->err = writer_flush_block(arg->w);
if (arg->err < 0)
goto done;
+@@ reftable/writer.c: static void write_object_record(void *void_arg, void *key)
+ if (arg->err < 0)
+ goto done;
+
++ /*
++ * If this still fails then we may need to reset record's offset
++ * length to reduce the data size to be written.
++ */
+ arg->err = block_writer_add(arg->w->block_writer, &rec);
+ if (arg->err == 0)
+ goto done;
+
++ if (arg->err != REFTABLE_ENTRY_TOO_BIG_ERROR)
++ goto done;
++
+ rec.u.obj.offset_len = 0;
+ arg->err = block_writer_add(arg->w->block_writer, &rec);
+

Signature · 1 line
2.34.1