Add ddt_object_count() error handling

The interface for the ddt_zap_count() function assumes it can
never fail.  However, internally ddt_zap_count() is implemented
with zap_count() which can potentially fail.  Now because there
was no way to return the error to the caller a VERIFY was used
to ensure this case never happens.

Unfortunately, it has been observed that pools can be damaged in
such a way that zap_count() fails.  The result is that the pool can
not be imported without hitting the VERIFY and crashing the system.

This patch reworks ddt_object_count() so the error can be safely
caught and returned to the caller.  This allows a pool which has
be damaged in this way to be safely rewound for import.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #910
This commit is contained in:
Brian Behlendorf
2012-10-26 10:01:49 -07:00
parent 178e73b376
commit e8fd45a0f9
4 changed files with 28 additions and 19 deletions
+3 -7
View File
@@ -138,14 +138,10 @@ ddt_zap_walk(objset_t *os, uint64_t object, ddt_entry_t *dde, uint64_t *walk)
return (error);
}
static uint64_t
ddt_zap_count(objset_t *os, uint64_t object)
static int
ddt_zap_count(objset_t *os, uint64_t object, uint64_t *count)
{
uint64_t count = 0;
VERIFY(zap_count(os, object, &count) == 0);
return (count);
return zap_count(os, object, count);
}
const ddt_ops_t ddt_zap_ops = {