Merge pull request #9856 from hzhang-wx/master

librbd: discard should return error if length too large

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2016-06-28 08:18:14 -04:00 committed by GitHub
commit 89eb5635b5

View File

@ -1160,6 +1160,10 @@ namespace librbd {
{
ImageCtx *ictx = (ImageCtx *)ctx;
tracepoint(librbd, discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len);
if (len > std::numeric_limits<int32_t>::max()) {
tracepoint(librbd, discard_exit, -EINVAL);
return -EINVAL;
}
int r = ictx->aio_work_queue->discard(ofs, len);
tracepoint(librbd, discard_exit, r);
return r;