Commit f1301897 authored by Andrey Filippov's avatar Andrey Filippov

added more files for debugging

parent 296d54dd
This diff is collapsed.
This diff is collapsed.
......@@ -174,7 +174,7 @@ static unsigned int dio_bio_write_op(struct kiocb *iocb)
return op;
}
#define DIO_INLINE_BIO_VECS 4
#define DIO_INLINE_BIO_VECS BIO_MAX_PAGES // 4
static void blkdev_bio_end_io_simple(struct bio *bio)
{
......@@ -197,11 +197,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
ssize_t ret;
blk_qc_t qc;
int i;
pr_debug("pos = %lld, nr_pages = %d, type=%d, iov_offset=0x%x, count=%d, iter->iov->iov_base=%p, iter->iov->iov_len=%d, nr_segs = %ld", \
pos, nr_pages, iter->type, iter->iov_offset, iter->count, iter->iov->iov_base, iter->iov->iov_len, iter->nr_segs); // pos - in file
if ((pos | iov_iter_alignment(iter)) &
(bdev_logical_block_size(bdev) - 1))
(bdev_logical_block_size(bdev) - 1)) {
pr_debug("pos = %lld, iov_iter_alignment(iter) = %ld, nr_pages = %d, bdev_logical_block_size(bdev) = %d", pos, iov_iter_alignment(iter), nr_pages, bdev_logical_block_size(bdev));
return -EINVAL;
}
if (nr_pages <= DIO_INLINE_BIO_VECS)
vecs = inline_vecs;
else {
......@@ -210,7 +212,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
if (!vecs)
return -ENOMEM;
}
pr_debug("DIO_INLINE_BIO_VECS = %d, nr_pages = %d", DIO_INLINE_BIO_VECS, nr_pages);
bio_init(&bio, vecs, nr_pages);
bio_set_dev(&bio, bdev);
bio.bi_iter.bi_sector = pos >> 9;
......@@ -218,12 +220,12 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
bio.bi_private = current;
bio.bi_end_io = blkdev_bio_end_io_simple;
bio.bi_ioprio = iocb->ki_ioprio;
ret = bio_iov_iter_get_pages(&bio, iter);
pr_debug("ret = %d", ret); // -14
if (unlikely(ret))
goto out;
ret = bio.bi_iter.bi_size;
// Does nothing as CONFIG_TASK_IO_ACCOUNTING in not defined
if (iov_iter_rw(iter) == READ) {
bio.bi_opf = REQ_OP_READ;
if (iter_is_iovec(iter))
......@@ -243,12 +245,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
io_schedule();
}
__set_current_state(TASK_RUNNING);
pr_debug("after __set_current_state(TASK_RUNNING)");
bio_for_each_segment_all(bvec, &bio, i) {
if (should_dirty && !PageCompound(bvec->bv_page))
set_page_dirty_lock(bvec->bv_page);
put_page(bvec->bv_page);
}
pr_debug("bio.bi_status = %d", bio.bi_status);
if (unlikely(bio.bi_status))
ret = blk_status_to_errno(bio.bi_status);
......@@ -332,11 +335,12 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
loff_t pos = iocb->ki_pos;
blk_qc_t qc = BLK_QC_T_NONE;
int ret = 0;
pr_debug("pos = %lld, nr_pages = %d", pos, nr_pages);
if ((pos | iov_iter_alignment(iter)) &
(bdev_logical_block_size(bdev) - 1))
(bdev_logical_block_size(bdev) - 1)) {
pr_debug("pos = %lld, iov_iter_alignment(iter) = %ld, nr_pages = %d, bdev_logical_block_size(bdev) = %d", pos, iov_iter_alignment(iter), nr_pages, bdev_logical_block_size(bdev));
return -EINVAL;
}
bio = bio_alloc_bioset(GFP_KERNEL, nr_pages, &blkdev_dio_pool);
bio_get(bio); /* extra ref for the completion handler */
......@@ -424,8 +428,8 @@ static ssize_t
blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
{
int nr_pages;
nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES + 1);
pr_debug("nr_pages = %d, is_sync_kiocb(iocb) = %d", nr_pages, is_sync_kiocb(iocb));
if (!nr_pages)
return 0;
if (is_sync_kiocb(iocb) && nr_pages <= BIO_MAX_PAGES)
......
......@@ -466,7 +466,9 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
struct kiocb kiocb;
struct iov_iter iter;
ssize_t ret;
if (!strncmp(filp->f_path.dentry->d_name.name, "sda2", 4)) {
pr_debug("pos=%llu, len=%d, buf=0x%p", *ppos, len, buf); // pr_debug("pos=%llu, len=%d, buf=0x%p, data=0x%llx", *ppos, len, buf, ((loff_t*) (buf))[0]);
}
init_sync_kiocb(&kiocb, filp);
kiocb.ki_pos = *ppos;
iov_iter_init(&iter, WRITE, &iov, 1, len);
......@@ -481,6 +483,10 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
ssize_t __vfs_write(struct file *file, const char __user *p, size_t count,
loff_t *pos)
{
if (!strncmp(file->f_path.dentry->d_name.name, "sda2", 4)) {
pr_debug("pos=%llu, count=%d, p=0x%p", *pos, count, p); // pr_debug("pos=%llu, count=%d, p=0x%p, data=0x%llx", *pos, count, p, ((loff_t*) (p))[0]);
}
if (file->f_op->write)
return file->f_op->write(file, p, count, pos);
else if (file->f_op->write_iter)
......@@ -661,19 +667,22 @@ SYSCALL_DEFINE4(pwrite64, unsigned int, fd, const char __user *, buf,
{
return ksys_pwrite64(fd, buf, count, pos);
}
static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
loff_t *ppos, int type, rwf_t flags)
{
struct kiocb kiocb;
ssize_t ret;
pr_debug("pos=%llu, flags=0x%x, type=%s", *ppos, flags, type?"WRITE":"READ");
if (!strncmp(filp->f_path.dentry->d_name.name, "sda2", 4)) {
pr_debug("pos=%llu, flags=0x%x, type=%s", *ppos, flags, type?"WRITE":"READ");
pr_debug("iov_offset=0x%x, count=%d, iter->iov->iov_base=%p, iter->iov->iov_len=%d, nr_segs = %ld", \
iter->iov_offset, iter->count, iter->iov->iov_base, iter->iov->iov_len, iter->nr_segs); // pos - in file
// pr_debug("data=0x%llx", ((loff_t*) (iter->iov->iov_base))[0]);
}
init_sync_kiocb(&kiocb, filp);
ret = kiocb_set_rw_flags(&kiocb, flags);
if (ret)
return ret;
kiocb.ki_pos = *ppos;
if (type == READ)
ret = call_read_iter(filp, &kiocb, iter);
else
......
This diff is collapsed.
......@@ -437,13 +437,13 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
.range_start = start,
.range_end = end,
};
pr_debug("mapping = %p, start = %lld, end = %lld, sync_mode=%d", mapping, start, end, sync_mode);
if (!mapping_cap_writeback_dirty(mapping))
return 0;
wbc_attach_fdatawrite_inode(&wbc, mapping->host);
ret = do_writepages(mapping, &wbc);
wbc_detach_inode(&wbc);
pr_debug("ret=%d", ret);
return ret;
}
......@@ -651,14 +651,16 @@ int filemap_write_and_wait_range(struct address_space *mapping,
loff_t lstart, loff_t lend)
{
int err = 0;
pr_debug("mapping = %p, lstart = %lld, lend = %lld, needs write_back=%d", mapping, lstart, lend, mapping_needs_writeback(mapping));
if (mapping_needs_writeback(mapping)) {
err = __filemap_fdatawrite_range(mapping, lstart, lend,
WB_SYNC_ALL);
pr_debug("err=%d", err);
/* See comment of filemap_write_and_wait() */
if (err != -EIO) {
int err2 = filemap_fdatawait_range(mapping,
lstart, lend);
pr_debug("err2=%d", err2);
if (!err)
err = err2;
} else {
......@@ -667,6 +669,7 @@ int filemap_write_and_wait_range(struct address_space *mapping,
}
} else {
err = filemap_check_errors(mapping);
pr_debug("filemap_check_errors(mapping) -> %d", err);
}
return err;
}
......@@ -3005,8 +3008,8 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from)
ssize_t written;
size_t write_len;
pgoff_t end;
pr_debug("generic_file_direct_write()");
write_len = iov_iter_count(from);
pr_debug("generic_file_direct_write(), pos=%lld, write_len = %d", pos, write_len);
end = (pos + write_len - 1) >> PAGE_SHIFT;
if (iocb->ki_flags & IOCB_NOWAIT) {
......@@ -3017,10 +3020,12 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from)
} else {
written = filemap_write_and_wait_range(mapping, pos,
pos + write_len - 1);
if (written)
if (written) {
pr_debug("written = %d", written);
goto out;
}
}
pr_debug("not written, written = %d", written);
/*
* After a write we want buffered reads to be sure to go to disk to get
* the new data. We invalidate clean cached page from the region we're
......@@ -3038,9 +3043,9 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from)
return 0;
goto out;
}
pr_debug("Before mapping->a_ops->direct_IO");
written = mapping->a_ops->direct_IO(iocb, from);
pr_debug("After mapping->a_ops->direct_IO, written = %d", written);
/*
* Finally, try again to invalidate clean pages which might have been
* cached by non-direct readahead, or faulted in by get_user_pages()
......@@ -3225,7 +3230,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
}
if (iocb->ki_flags & IOCB_DIRECT) {
loff_t pos, endbyte;
pr_debug("using IOCB_DIRECT");
pr_debug("using IOCB_DIRECT, count = %d, type = %d",iov_iter_count(from), from->type);
written = generic_file_direct_write(iocb, from);
/*
* If the write stopped short of completing, fall back to
......@@ -3234,8 +3239,11 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
* not succeed (even if it did, DAX does not handle dirty
* page-cache pages correctly).
*/
if (written < 0 || !iov_iter_count(from) || IS_DAX(inode))
if (written < 0 || !iov_iter_count(from) || IS_DAX(inode)){
pr_debug("IOCB_DIRECT %s: written = %d, iov_iter_count(from)= %d", (written < 0)?"ERROR":"OK", written, iov_iter_count(from));
goto out;
}
pr_debug("IOCB_DIRECT NEED MORE: written = %d, iov_iter_count(from)= %d", written, iov_iter_count(from));
status = generic_perform_write(file, from, pos = iocb->ki_pos);
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment