+static ssize_t xsegbd_cleanup(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t size)
+{
+ struct xsegbd_device *xsegbd_dev = dev_to_xsegbd(dev);
+ int ret = size, i;
+ struct request *blkreq = NULL;
+ struct xsegbd_pending *pending = NULL;
+ struct completion *comp = NULL;
+
+ mutex_lock_nested(&xsegbd_mutex, SINGLE_DEPTH_NESTING);
+ for (i = 0; i < xsegbd_dev->nr_requests; i++) {
+ xlock_acquire(&xsegbd_dev->blk_queue_pending.lock,
+ xsegbd_dev->src_portno);
+ if (!__xq_check(&xsegbd_dev->blk_queue_pending, i)) {
+ pending = &xsegbd_dev->blk_req_pending[i];
+ blkreq = pending->request;
+ pending->request = NULL;
+ comp = pending->comp;
+ pending->comp = NULL;
+ if (blkreq)
+ blk_end_request_all(blkreq, -EIO);
+ if (comp)
+ complete(comp);
+ __xq_append_tail(&xsegbd_dev->blk_queue_pending, i);
+ }
+ xlock_release(&xsegbd_dev->blk_queue_pending.lock);
+ }
+
+ mutex_unlock(&xsegbd_mutex);
+ return ret;
+}
+