mirror of https://github.com/schoebel/mars
copy: clarify error messages
This commit is contained in:
parent
f0dd60867a
commit
1932198fd9
|
@ -312,7 +312,7 @@ int _make_mref(struct copy_brick *brick,
|
||||||
/* let the compiler check for 0 <= queue <= 1 */
|
/* let the compiler check for 0 <= queue <= 1 */
|
||||||
const bool _queue,
|
const bool _queue,
|
||||||
void *data,
|
void *data,
|
||||||
loff_t pos, loff_t end_pos,
|
loff_t current_pos, loff_t end_pos,
|
||||||
__u32 flags)
|
__u32 flags)
|
||||||
{
|
{
|
||||||
struct mref_object *mref;
|
struct mref_object *mref;
|
||||||
|
@ -320,6 +320,7 @@ int _make_mref(struct copy_brick *brick,
|
||||||
struct copy_input *input;
|
struct copy_input *input;
|
||||||
struct copy_state *st;
|
struct copy_state *st;
|
||||||
struct mref_object *old_mref;
|
struct mref_object *old_mref;
|
||||||
|
loff_t diff;
|
||||||
const unsigned queue = _queue;
|
const unsigned queue = _queue;
|
||||||
unsigned input_index;
|
unsigned input_index;
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
|
@ -327,28 +328,36 @@ int _make_mref(struct copy_brick *brick,
|
||||||
int status = -EAGAIN;
|
int status = -EAGAIN;
|
||||||
|
|
||||||
/* Does it make sense to create a new mref right here? */
|
/* Does it make sense to create a new mref right here? */
|
||||||
if (brick->clash || pos < 0 || end_pos <= 0 || pos >= end_pos)
|
if (brick->clash)
|
||||||
|
goto done;
|
||||||
|
status = -EINVAL;
|
||||||
|
if (current_pos < 0 || end_pos <= 0)
|
||||||
|
goto done;
|
||||||
|
diff = (end_pos - current_pos);
|
||||||
|
if (diff <= 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Some safeguards */
|
/* Some safeguards */
|
||||||
if (unlikely(queue < 0 || queue >= 2)) {
|
if (unlikely(queue < 0 || queue >= 2)) {
|
||||||
MARS_ERR("trying bad queue %d\n",
|
MARS_ERR("trying bad queue %d\n",
|
||||||
queue);
|
queue);
|
||||||
status = -EINVAL;
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (unlikely(index > NR_COPY_REQUESTS)) {
|
if (unlikely(index > NR_COPY_REQUESTS)) {
|
||||||
MARS_ERR("trying bad index=%u at queue=%d pos=%lld end_pos=%lld flags=%d\n",
|
MARS_ERR("trying bad index=%u at queue=%d pos=%lld+%lld flags=%d\n",
|
||||||
index, queue, pos, end_pos, flags);
|
index, queue,
|
||||||
status = -EINVAL;
|
current_pos, diff, flags);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check the state table */
|
||||||
st = &GET_STATE(brick, index);
|
st = &GET_STATE(brick, index);
|
||||||
old_mref = READ_ONCE(st->table[queue]);
|
old_mref = READ_ONCE(st->table[queue]);
|
||||||
if (unlikely(old_mref)) {
|
if (unlikely(old_mref)) {
|
||||||
MARS_ERR("cannot overrride old_mref=%p at index=%u queue=%d pos=%lld end_pos=%lld flags=%d\n",
|
MARS_ERR("cannot overrride old_mref=%p at index=%u queue=%d pos=%lld+%lld flags=%d\n",
|
||||||
old_mref,
|
old_mref,
|
||||||
index, queue, pos, end_pos, flags);
|
index, queue,
|
||||||
|
current_pos, diff, flags);
|
||||||
status = -EEXIST;
|
status = -EEXIST;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -375,18 +384,18 @@ int _make_mref(struct copy_brick *brick,
|
||||||
input = brick->inputs[input_index];
|
input = brick->inputs[input_index];
|
||||||
mref_a->input = input;
|
mref_a->input = input;
|
||||||
mref_a->brick = brick;
|
mref_a->brick = brick;
|
||||||
mref_a->orig_ref_pos = pos;
|
mref_a->orig_ref_pos = current_pos;
|
||||||
mref_a->saved_queue = queue;
|
mref_a->saved_queue = queue;
|
||||||
mref_a->saved_index = index;
|
mref_a->saved_index = index;
|
||||||
|
|
||||||
/* Compute the start values for the new mref */
|
/* Compute the start values for the new mref */
|
||||||
mref->ref_flags = flags;
|
mref->ref_flags = flags;
|
||||||
mref->ref_data = data;
|
mref->ref_data = data;
|
||||||
mref->ref_pos = pos;
|
mref->ref_pos = current_pos;
|
||||||
offset = GET_OFFSET(pos);
|
offset = GET_OFFSET(current_pos);
|
||||||
len = COPY_CHUNK - offset;
|
len = COPY_CHUNK - offset;
|
||||||
if (pos + len > end_pos) {
|
if (current_pos + len > end_pos) {
|
||||||
unsigned new_len = end_pos - pos;
|
unsigned new_len = end_pos - current_pos;
|
||||||
|
|
||||||
if (new_len < len)
|
if (new_len < len)
|
||||||
len = new_len;
|
len = new_len;
|
||||||
|
|
Loading…
Reference in New Issue