Commit feba13bb authored by Jim Harris's avatar Jim Harris
Browse files

blob: do not decrement ref on close until it is done



This ensures we do not end up with a racing close v.
delete.  If we decrement the ref up front, we could
start the close process (which may include persisting
metadata) and then also allow a delete operation to
start.  It is safer to wait until the close operation
is done before decrementing the ref count, because then
it will eliminate this race condition (the delete op
would immediately fail).

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Iad7fd8320d2c9b56f3c4fce054bcb6271e19ad38

Reviewed-on: https://review.gerrithub.io/391493


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 751691d2
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -2859,6 +2859,8 @@ _spdk_blob_close_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
{
	struct spdk_blob_data *blob = cb_arg;

	if (bserrno == 0) {
		blob->open_ref--;
		if (blob->open_ref == 0) {
			/*
			 * Blobs with active.num_pages == 0 are deleted blobs.
@@ -2871,6 +2873,7 @@ _spdk_blob_close_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
			}
			_spdk_blob_free(blob);
		}
	}

	spdk_bs_sequence_finish(seq, bserrno);
}
@@ -2895,8 +2898,6 @@ void spdk_blob_close(struct spdk_blob *b, spdk_blob_op_complete cb_fn, void *cb_
		return;
	}

	blob->open_ref--;

	cpl.type = SPDK_BS_CPL_TYPE_BLOB_BASIC;
	cpl.u.blob_basic.cb_fn = cb_fn;
	cpl.u.blob_basic.cb_arg = cb_arg;