static int max_part;
static int part_shift;
+static void __lo_print_error(struct bio *bio, int error,
+ const char *func, int line)
+{
+ char b[BDEVNAME_SIZE];
+ char dev_info[64];
+ char err_buf[64];
+ struct block_device *bdev;
+
+ if (bio) {
+ bdev = bio->bi_bdev;
+ snprintf(dev_info, sizeof(dev_info),
+ "Device %s MAJOR:%d MINOR:%d",
+ bdevname(bdev, b), MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev));
+ } else
+ snprintf(dev_info, sizeof(dev_info), "%s",
+ "Device Info Unavailable");
+
+ /* Special ENOSPC and EDQUOT as they are common in Dom0 */
+ if (error == -ENOSPC)
+ snprintf(err_buf, sizeof(err_buf), "ERROR:%d - %s.",
+ error, "No space left on device");
+ else if (error == -EDQUOT)
+ snprintf(err_buf, sizeof(err_buf), "ERROR:%d - %s.",
+ error, "Quota exceeded");
+ else
+ snprintf(err_buf, sizeof(err_buf), "ERROR:%d received.",
+ error);
+
+ printk_ratelimited(KERN_INFO "%s:%d:%s %s\n", func, line,
+ err_buf, dev_info);
+}
+
+#define lo_print_error(bio, error) \
+ __lo_print_error(bio, error, __func__, __LINE__)
+
static int transfer_xor(struct loop_device *lo, int cmd,
struct page *raw_page, unsigned raw_off,
struct page *loop_page, unsigned loop_off,
return 0;
printk_ratelimited(KERN_ERR
- "loop: Write error at byte offset %llu, length %i.\n",
- (unsigned long long)*ppos, bvec->bv_len);
+ "loop: Write error %zd at byte offset %llu, length %i.\n",
+ bw, (unsigned long long)*ppos, bvec->bv_len);
if (bw >= 0)
bw = -EIO;
return bw;
}
ret = file->f_op->fallocate(file, mode, pos, blk_rq_bytes(rq));
- if (unlikely(ret && ret != -EINVAL && ret != -EOPNOTSUPP))
+ if (unlikely(ret && ret != -EINVAL && ret != -EOPNOTSUPP)) {
+ lo_print_error(rq->bio, ret);
ret = -EIO;
+ }
out:
return ret;
}
{
struct file *file = lo->lo_backing_file;
int ret = vfs_fsync(file, 0);
- if (unlikely(ret && ret != -EINVAL))
+ if (unlikely(ret && ret != -EINVAL)) {
+ lo_print_error(rq->bio, ret);
ret = -EIO;
+ }
return ret;
}
if (ret > 0)
ret = 0;
- else if (ret < 0)
+ else if (ret < 0) {
+ lo_print_error(rq->bio, ret);
ret = -EIO;
+ }
rq->errors = ret;
blk_mq_complete_request(rq);