scoutfs: warn on compaction stale seg reads

It's possible to trigger stale segment reads during compaction.  This
shouldn't be possible during regular operation because the server
protects the input segments while the compaction is pending.  Stale
segment reads can only happen to client reads which aren't serialized
with segment allocation and writes.

Warn if we see a stale segment read during compaction.  It means that we
either have a bug in the server or someone armed a stale segment read
trigger that hit compaction.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2019-08-20 15:52:13 -07:00
committed by Zach Brown
parent feaf17c3a5
commit 07c9edb58f
+8 -3
View File
@@ -608,8 +608,10 @@ static int prepare_curs(struct super_block *sb, struct compact_cursor *curs,
* segments, then generating the response that describes the output
* segments.
*
* The server will either commit our response or cleanup the request
* if we return an error that the caller sends in response.
* The server will either commit our response or cleanup the request if
* we return an error that the caller sends in response. The server
* protects the input segments so they shouldn't be overwritten by other
* compactions or allocations. We shouldn't get stale segment reads.
*/
int scoutfs_compact(struct super_block *sb,
struct scoutfs_net_compact_request *req,
@@ -668,8 +670,11 @@ int scoutfs_compact(struct super_block *sb,
ret = 0;
out:
if (ret == -ESTALE)
/* server protects input segments, shouldn't be possible */
if (WARN_ON_ONCE(ret == -ESTALE)) {
scoutfs_inc_counter(sb, compact_stale_error);
ret = -EIO;
}
free_cseg_list(sb, &curs.csegs);
free_cseg_list(sb, &results);