From: Meet Soni <meetsoni3017@gmail.com>
To: git@vger.kernel.org
Cc: ps@pks.im, gitster@pobox.com, Meet Soni <meetsoni3017@gmail.com>
Subject: [GSoC PATCH v4 0/3] reftable: return proper error codes from block_writer_add
Date: Wed, 19 Mar 2025 13:29:40 +0530 [thread overview]
Message-ID: <20250319075943.28904-1-meetsoni3017@gmail.com> (raw)
In-Reply-To: <20250312121148.1879604-1-meetsoni3017@gmail.com>
This patch attempts to avoid making an assumption regarding error codes
returned by block_writer_add().
Changes since v3:
- split commit based on the functions it alters
- add comment back that was earlier removed.
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 | 27 +++++++++++++++---------
4 files changed, 49 insertions(+), 46 deletions(-)
Range-diff against v3:
1: 6ab35d569c = 1: 6ab35d569c reftable: propagate specific error codes in block_writer_add()
2: a54d440dd3 ! 2: 7f0bdc27e1 reftable: adapt writer code to propagate block_writer_add() errors
@@ Metadata
Author: Meet Soni <meetsoni3017@gmail.com>
## Commit message ##
- reftable: adapt writer code to propagate block_writer_add() errors
+ reftable: adapt writer_add_record() to propagate block_writer_add() errors
- Previously, writer_add_record() and 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, 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 code 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.
-
- All call sites now handle various error codes returned by
- block_writer_add().
+ 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.
Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
@@ reftable/writer.c: static int writer_add_record(struct reftable_writer *w,
* The current block is full, so we need to flush and reinitialize the
* writer to start writing the next block.
@@ reftable/writer.c: static int writer_add_record(struct reftable_writer *w,
- goto done;
-
/*
-- * Try to add the record to the writer again. If this still fails then
-- * the record does not fit into the block size.
+ * Try to add the record to the writer again. If this still fails then
+ * the record does not fit into the block size.
- *
- * TODO: it would be great to have `block_writer_add()` return proper
- * error codes so that we don't have to second-guess the failure
- * mode here.
-+ * Try to add the record to the writer again.
*/
err = block_writer_add(w->block_writer, rec);
- if (err) {
@@ reftable/writer.c: static int writer_add_record(struct reftable_writer *w,
done:
return err;
-@@ reftable/writer.c: static void write_object_record(void *void_arg, void *key)
- if (arg->err < 0)
- goto done;
-
-+ /*
-+ * Try to add the record to the writer. If this succeeds then we're
-+ * done. Otherwise the block writer may have hit the block size limit
-+ * and needs to be flushed.
-+ */
- 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;
-+
-+ /*
-+ * The current block is full, so we need to flush and reinitialize the
-+ * writer to start writing the next block.
-+ */
- arg->err = writer_flush_block(arg->w);
- if (arg->err < 0)
- goto done;
-: ---------- > 3: 480ac27797 reftable: adapt write_object_record() to propagate block_writer_add() errors
--
2.34.1
next prev parent reply other threads:[~2025-03-19 8:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 12:13 [GSoC PATCH] reftable: return proper error code from block_writer_add() Meet Soni
2025-03-06 14:43 ` Patrick Steinhardt
2025-03-06 17:04 ` Junio C Hamano
2025-03-08 13:33 ` [GSoC PATCH v2] " Meet Soni
2025-03-12 8:23 ` Patrick Steinhardt
2025-03-12 12:11 ` [GSoC PATCH v3 0/2] reftable: return proper error codes from block_writer_add Meet Soni
2025-03-12 12:11 ` [PATCH v3 1/2] reftable: propagate specific error codes in block_writer_add() Meet Soni
2025-03-12 12:11 ` [PATCH v3 2/2] reftable: adapt writer code to propagate block_writer_add() errors Meet Soni
2025-03-12 12:49 ` Patrick Steinhardt
2025-03-13 15:29 ` Meet Soni
2025-03-19 13:18 ` Patrick Steinhardt
2025-03-19 7:59 ` Meet Soni [this message]
2025-03-19 7:59 ` [PATCH v4 1/3] reftable: propagate specific error codes in block_writer_add() Meet Soni
2025-03-19 7:59 ` [PATCH v4 2/3] reftable: adapt writer_add_record() to propagate block_writer_add() errors Meet Soni
2025-03-19 7:59 ` [PATCH v4 3/3] reftable: adapt write_object_record() " Meet Soni
2025-03-19 15:29 ` [GSoC PATCH v5 0/3] reftable: return proper error codes from block_writer_add Meet Soni
2025-03-19 15:29 ` [GSoC PATCH v5 1/3] reftable: propagate specific error codes in block_writer_add() Meet Soni
2025-03-19 15:29 ` [GSoC PATCH v5 2/3] reftable: adapt writer_add_record() to propagate block_writer_add() errors Meet Soni
2025-03-19 15:29 ` [GSoC PATCH v5 3/3] reftable: adapt write_object_record() " Meet Soni
2025-03-19 15:48 ` [GSoC PATCH v5 0/3] reftable: return proper error codes from block_writer_add Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250319075943.28904-1-meetsoni3017@gmail.com \
--to=meetsoni3017@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).